qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Vitaly Kuznetsov <vkuznets@redhat.com>
To: Antoine Damhet <antoine.damhet@blade-group.com>,
	"Dr. David Alan Gilbert" <dgilbert@redhat.com>
Cc: Juan Quintela <quintela@redhat.com>,
	Marcelo Tosatti <mtosatti@redhat.com>,
	qemu-devel@nongnu.org, "Michael S. Tsirkin" <mst@redhat.com>,
	Paolo Bonzini <pbonzini@redhat.com>
Subject: Re: [BUG] Migration hv_time rollback
Date: Wed, 16 Sep 2020 14:16:14 +0200	[thread overview]
Message-ID: <878sd9j4s1.fsf@vitty.brq.redhat.com> (raw)
In-Reply-To: <20200916115950.tsarwvk2dwgiceoe@tartarus>

Antoine Damhet <antoine.damhet@blade-group.com> writes:

> On Wed, Sep 16, 2020 at 12:29:56PM +0100, Dr. David Alan Gilbert wrote:
>> cc'ing in Vitaly who knows about the hv stuff.
>
> Thanks
>
>> 
>> * Antoine Damhet (antoine.damhet@blade-group.com) wrote:
>> > Hi,
>> > 
>> > We are experiencing timestamp rollbacks during live-migration of
>> > Windows 10 guests with the following qemu configuration (linux 5.4.46
>> > and qemu master):
>> > ```
>> > $ qemu-system-x86_64 -enable-kvm -cpu host,kvm=off,hv_time [...]
>> > ```
>> 
>> How big a jump are you seeing, and how did you notice it in the guest?
>
> I'm seeing jumps of about the guest uptime (indicating a reset of the
> counter). It's expected because we won't call `KVM_SET_CLOCK` to
> restore any value.
>
> We first noticed it because after some migrations `dwm.exe` crashes with
> the "(NTSTATUS) 0x8898009b - QueryPerformanceCounter returned a time in
> the past." error code.
>
> I can also confirm the following hack makes the behavior disappear:
>
> ```
> diff --git a/hw/i386/kvm/clock.c b/hw/i386/kvm/clock.c
> index 64283358f9..f334bdf35f 100644
> --- a/hw/i386/kvm/clock.c
> +++ b/hw/i386/kvm/clock.c
> @@ -332,11 +332,7 @@ void kvmclock_create(void)
>  {
>      X86CPU *cpu = X86_CPU(first_cpu);
>
> -    if (kvm_enabled() &&
> -        cpu->env.features[FEAT_KVM] & ((1ULL << KVM_FEATURE_CLOCKSOURCE) |
> -                                       (1ULL << KVM_FEATURE_CLOCKSOURCE2))) {
> -        sysbus_create_simple(TYPE_KVM_CLOCK, -1, NULL);
> -    }
> +    sysbus_create_simple(TYPE_KVM_CLOCK, -1, NULL);
>  }
>


Oh, I think I see what's going on. When you add 'kvm=off'
cpu->env.features[FEAT_KVM] is reset (see x86_cpu_expand_features()) so
kvmclock QEMU device is not created and nobody calls KVM_SET_CLOCK on
migration.

In case we really want to support 'kvm=off' I think we can add Hyper-V
features check here along with KVM, this should do the job.

-- 
Vitaly



  reply	other threads:[~2020-09-16 12:31 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-09-16  9:06 [BUG] Migration hv_time rollback Antoine Damhet
2020-09-16 11:29 ` Dr. David Alan Gilbert
2020-09-16 11:59   ` Vitaly Kuznetsov
2020-09-16 12:14     ` Antoine Damhet
2020-09-16 11:59   ` Antoine Damhet
2020-09-16 12:16     ` Vitaly Kuznetsov [this message]
2020-09-16 12:50       ` Vitaly Kuznetsov
2020-09-16 13:25         ` Antoine Damhet
2020-09-16 13:05   ` Paolo Bonzini
2020-09-16 13:17     ` Vitaly Kuznetsov

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=878sd9j4s1.fsf@vitty.brq.redhat.com \
    --to=vkuznets@redhat.com \
    --cc=antoine.damhet@blade-group.com \
    --cc=dgilbert@redhat.com \
    --cc=mst@redhat.com \
    --cc=mtosatti@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=quintela@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).