From nobody Sun May 5 09:35:08 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 15423757685850.9188332292141013; Fri, 16 Nov 2018 05:42:48 -0800 (PST) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 128A83082DDB; Fri, 16 Nov 2018 13:42:46 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 661575D75F; Fri, 16 Nov 2018 13:42:45 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 45A8E3F603; Fri, 16 Nov 2018 13:42:44 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id wAGDGaPj018778 for ; Fri, 16 Nov 2018 08:16:36 -0500 Received: by smtp.corp.redhat.com (Postfix) id 3FE8460C7D; Fri, 16 Nov 2018 13:16:36 +0000 (UTC) Received: from orkuz.int.mamuti.net (ovpn-204-187.brq.redhat.com [10.40.204.187]) by smtp.corp.redhat.com (Postfix) with ESMTPS id D9CFB60C8C for ; Fri, 16 Nov 2018 13:16:35 +0000 (UTC) Received: by orkuz.int.mamuti.net (Postfix, from userid 500) id A01312A6D44; Fri, 16 Nov 2018 14:16:34 +0100 (CET) From: Jiri Denemark To: libvir-list@redhat.com Date: Fri, 16 Nov 2018 14:16:33 +0100 Message-Id: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH] qemu: Fix post-copy migration on the source X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.46]); Fri, 16 Nov 2018 13:42:46 +0000 (UTC) Content-Type: text/plain; charset="utf-8" Post-copy migration has been broken on the source since commit v3.8.0-245-g32c29f10db which implemented support for pause-before-switchover QEMU migration capability. Even though the migration itself went well, the source did not really know when it switched to the post-copy mode despite the messages logged by MIGRATION event handler. As a result of this, the events emitted by source libvirtd were not accurate and statistics of the completed migration would cover only the pre-copy part of migration. Moreover, if migration failed during the post-copy phase for some reason, the source libvirtd would just happily resume the domain, which could lead to disk corruption. With the pause-before-switchover capability enabled, the order of events emitted by QEMU changed: pause-before-switchover disabled enabled MIGRATION, potcopy-active STOP STOP MIGRATION, pre-switchover MIGRATION, postcopy-active The STOP even handler checks the migration status (postcopy-active) and sets the domain state accordingly. Which is sufficient when pause-before-switchover is disabled, but once we enable it, the migration status is still active when we get STOP from QEMU. Thus the domain state set in the STOP handler has to be corrected once we are notified that migration changed to postcopy-active. This results in two SUSPENDED events to be emitted by the source libvirtd during post-copy migration. The first one with VIR_DOMAIN_EVENT_SUSPENDED_MIGRATED detail, while the second one reports the corrected VIR_DOMAIN_EVENT_SUSPENDED_POSTCOPY detail. This is inevitable because we don't know whether migration will eventually switch to post-copy at the time we emit the first event. https://bugzilla.redhat.com/show_bug.cgi?id=3D1647365 Signed-off-by: Jiri Denemark Reviewed-by: J=C3=A1n Tomko --- src/qemu/qemu_process.c | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c index 622341b8a4..2c89978996 100644 --- a/src/qemu/qemu_process.c +++ b/src/qemu/qemu_process.c @@ -1543,9 +1543,13 @@ static int qemuProcessHandleMigrationStatus(qemuMonitorPtr mon ATTRIBUTE_UNUSED, virDomainObjPtr vm, int status, - void *opaque ATTRIBUTE_UNUSED) + void *opaque) { qemuDomainObjPrivatePtr priv; + virQEMUDriverPtr driver =3D opaque; + virObjectEventPtr event =3D NULL; + virQEMUDriverConfigPtr cfg =3D virQEMUDriverGetConfig(driver); + int reason; =20 virObjectLock(vm); =20 @@ -1562,8 +1566,28 @@ qemuProcessHandleMigrationStatus(qemuMonitorPtr mon = ATTRIBUTE_UNUSED, priv->job.current->stats.mig.status =3D status; virDomainObjBroadcast(vm); =20 + if (status =3D=3D QEMU_MONITOR_MIGRATION_STATUS_POSTCOPY && + virDomainObjGetState(vm, &reason) =3D=3D VIR_DOMAIN_PAUSED && + reason =3D=3D VIR_DOMAIN_PAUSED_MIGRATION) { + VIR_DEBUG("Correcting paused state reason for domain %s to %s", + vm->def->name, + virDomainPausedReasonTypeToString(VIR_DOMAIN_PAUSED_POST= COPY)); + + virDomainObjSetState(vm, VIR_DOMAIN_PAUSED, VIR_DOMAIN_PAUSED_POST= COPY); + event =3D virDomainEventLifecycleNewFromObj(vm, + VIR_DOMAIN_EVENT_SUSPEND= ED, + VIR_DOMAIN_EVENT_SUSPEND= ED_POSTCOPY); + + if (virDomainSaveStatus(driver->xmlopt, cfg->stateDir, vm, driver-= >caps) < 0) { + VIR_WARN("Unable to save status on vm %s after state change", + vm->def->name); + } + } + cleanup: virObjectUnlock(vm); + virObjectEventStateQueue(driver->domainEventState, event); + virObjectUnref(cfg); return 0; } =20 --=20 2.19.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list