From mboxrd@z Thu Jan 1 00:00:00 1970 From: Paolo Bonzini Subject: Re: [QEMU PATCH] kvmclock: advance clock by time window between vm_stop and pre_save Date: Fri, 4 Nov 2016 18:35:23 -0400 (EDT) Message-ID: <184247986.10964505.1478298923187.JavaMail.zimbra@redhat.com> References: <20161104094322.GA16930@amt.cnet> <20161104152522.GC5388@potion> <1c69a083-eef0-8fa0-0e74-5a4e25a066a0@redhat.com> <20161104154827.GD5388@potion> <1217f6ce-8143-8d0e-97f6-470926438992@redhat.com> <20161104171605.GE5388@potion> <595276440.10962400.1478294976364.JavaMail.zimbra@redhat.com> <20161104214747.GA17560@amt.cnet> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit Cc: Radim =?utf-8?B?S3LEjW3DocWZ?= , kvm@vger.kernel.org, qemu-devel , "Dr. David Alan Gilbert" , Juan Quintela , Eduardo Habkost , Roman Kagan To: Marcelo Tosatti Return-path: Received: from mx3-phx2.redhat.com ([209.132.183.24]:46067 "EHLO mx3-phx2.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1757884AbcKDWfZ (ORCPT ); Fri, 4 Nov 2016 18:35:25 -0400 In-Reply-To: <20161104214747.GA17560@amt.cnet> Sender: kvm-owner@vger.kernel.org List-ID: > > But that's why separating the two cases brings us the best of both worlds. > > If migrating a paused guest, there's no need for any adjustment, so no > > advance_clock hack. If pausing at the end of migration, there's no need > > to pause kvmclock (this patch is effectively working around 00f4d64ee76e) > > and if we don't do that we can just call KVM_GET_CLOCK at pre_save time. > > That was my internal v1. But then, the destination ignores s->clock > as follows: > > if (running) { > struct kvm_clock_data data = {}; > uint64_t time_at_migration = kvmclock_current_nsec(s); Right, but this is unnecessary in 4.9-rc, where KVM_GET_CLOCK *already* returns the same as QEMU's kvmclock_current_nsec. So this is the other half of my suggestion, where we need to check the behavior of KVM_GET_CLOCK via KVM_CHECK_EXTENSION. I think it's okay to only fix the bug with master clock enabled and for new KVM with sensible KVM_GET_CLOCK semantics. Paolo > s->clock_valid = false; > > /* We can't rely on the migrated clock value, just discard it */ > if (time_at_migration) { > s->clock = time_at_migration; > } > > data.clock = s->clock; > ret = kvm_vm_ioctl(kvm_state, KVM_SET_CLOCK, &data); > > So you need to send that "ns" value (difference of two clock reads) > separately. > > > > > > Oh, and this does introduce a minor bug to this patch -- the time > > > counted by KVM_GET_CLOCK is has different frequency CLOCK_MONOTONIC. > > > Not accounting for that is bearable. > > > > Not really, I was going to point that out when I got to replying with > > a review. :) > > > > Paolo > >