Re: [PATCH v2 2/2] KVM: selftests: Add KVM/PV clock selftest to prove timer correction

From: Dongli Zhang
Date: Fri Apr 12 2024 - 04:20:20 EST




On 4/10/24 02:52, Jack Allister wrote:
> A VM's KVM/PV clock has an inherent relationship to it's TSC (guest). When
> either the host system live-updates or the VM is live-migrated this pairing
> of the two clock sources should stay the same.
>

[snip]

> +
> +int main(int argc, char *argv[])
> +{
> + struct kvm_vcpu *vcpu;
> + struct kvm_vm *vm;
> + bool scale_tsc;
> +
> + scale_tsc = argc > 1 && (!strncmp(argv[1], "-s", 3) ||
> + !strncmp(argv[1], "--scale-tsc", 10));
> +
> + TEST_REQUIRE(sys_clocksource_is_based_on_tsc());
> +
> + vm = vm_create_with_one_vcpu(&vcpu, guest_code);
> +
> + configure_pvclock(vm, vcpu);
> +
> + if (scale_tsc)
> + configure_scaled_tsc(vcpu);
> +
> + run_test(vm, vcpu);
> +
> + return 0;
> +}

David suggested make the scale_tsc automatically based on the availability of
the feature.

Therefore, if there is going to be v3, I suggest add kvm_vm_free() explicitly
(similar to close(fd)).

Thank you very much!

Dongli Zhang