Skip to content

Look into notifying the guest when vcpus are paused #1859

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
alxiord opened this issue May 4, 2020 · 3 comments · Fixed by #4460
Closed

Look into notifying the guest when vcpus are paused #1859

alxiord opened this issue May 4, 2020 · 3 comments · Fixed by #4460
Assignees
Labels
Priority: Medium Indicates than an issue or pull request should be resolved ahead of issues or pull requests labelled Status: Parked Indicates that an issues or pull request will be revisited later Type: Enhancement Indicates new feature requests Type: Fix Indicates a fix to existing code

Comments

@alxiord
Copy link

alxiord commented May 4, 2020

According to the documentation:

KVM_KVMCLOCK_CTRL

This signals to the host kernel that the specified guest is being paused by
userspace.  The host will set a flag in the pvclock structure that is checked
from the soft lockup watchdog.  [...] This ioctl can be called any time
after pausing the vcpu, but before it is resumed.

KVM uses this ioctl to notify the guest that it's being paused(code):

case KVM_KVMCLOCK_CTRL: {
    r = kvm_set_guest_paused(vcpu);
    goto out;
}
/*
 * kvm_set_guest_paused() indicates to the guest kernel that it has been
 * stopped by the hypervisor.  This function will be called from the host only.
 * EINVAL is returned when the host attempts to set the flag for a guest that
 * does not support pv clocks.
 */
static int kvm_set_guest_paused(struct kvm_vcpu *vcpu)
{
	if (!vcpu->arch.pv_time_enabled)
		return -EINVAL;
	vcpu->arch.pvclock_set_guest_stopped_request = true;
	kvm_make_request(KVM_REQ_CLOCK_UPDATE, vcpu);
	return 0;
}

In the context of snapshotting a microVM and resuming it later, this ioctl needs to be evaluated to assess its benefits & costs and whether it should be called immediately after pausing or between deserialization and resuming.

@acatangiu
Copy link
Contributor

Adding a bit more detail here:

In a case where the guest is paused by the hypervisor for a non-negligible period of time, that blackout period is seen by the guest as frozen/non-ticking CPUs. On resuming the VM, the guest soft-lockup watchdog might panic.

This ioctl makes KVM on the host set a special flag on the emulated/paravirtualized pv-clock. This flag is seen by the guest and tells the guest that the vCPUs haven't ticked in a while on purpose.

@alindima
Copy link
Contributor

On resuming the VM, the guest soft-lockup watchdog might panic.

Remember seeing any such panics?

@JonathanWoollett-Light JonathanWoollett-Light added Type: Enhancement Indicates new feature requests and removed Feature: Snapshotting labels Mar 23, 2023
@wearyzen
Copy link
Contributor

wearyzen commented Feb 12, 2024

This comment in our code looks related

// TODO: we should call `KVM_KVMCLOCK_CTRL` here to make sure

@xmarcalx xmarcalx added the Priority: Medium Indicates than an issue or pull request should be resolved ahead of issues or pull requests labelled label Feb 12, 2024
@ShadowCurse ShadowCurse added the Type: Fix Indicates a fix to existing code label Sep 18, 2024
@bchalios bchalios added the Status: Parked Indicates that an issues or pull request will be revisited later label Sep 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Priority: Medium Indicates than an issue or pull request should be resolved ahead of issues or pull requests labelled Status: Parked Indicates that an issues or pull request will be revisited later Type: Enhancement Indicates new feature requests Type: Fix Indicates a fix to existing code
Projects
None yet
Development

Successfully merging a pull request may close this issue.

9 participants