From nobody Thu May 15 13:56:27 2025 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 Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1508152056591443.28297944303915; Mon, 16 Oct 2017 04:07:36 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 73AEB7E439; Mon, 16 Oct 2017 11:07:35 +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 4F45F6062A; Mon, 16 Oct 2017 11:07:35 +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 808A762CEF; Mon, 16 Oct 2017 11:07:28 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id v9GB6gFx008776 for ; Mon, 16 Oct 2017 07:06:42 -0400 Received: by smtp.corp.redhat.com (Postfix) id A28EE5D965; Mon, 16 Oct 2017 11:06:42 +0000 (UTC) Received: from antique-work.brq.redhat.com (unknown [10.43.2.152]) by smtp.corp.redhat.com (Postfix) with ESMTP id 2A45C5D964 for ; Mon, 16 Oct 2017 11:06:42 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 73AEB7E439 Authentication-Results: ext-mx03.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx03.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=libvir-list-bounces@redhat.com From: Pavel Hrdina To: libvir-list@redhat.com Date: Mon, 16 Oct 2017 13:06:26 +0200 Message-Id: In-Reply-To: References: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 13/14] qemu: send allowReboot in migration cookie 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: , MIME-Version: 1.0 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.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Mon, 16 Oct 2017 11:07:35 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" We need to send allowReboot in the migration cookie to ensure the same behavior of the virDomainSetLifecycleAction() API on the destination. Consider this scenario: 1. On the source the domain is started with: destroy restart destroy 2. User calls an API to set "destroy" for : destroy destroy destroy 3. The guest is migrated to a different host 4a. Without the allowReboot in the migration cookie the QEMU process on destination would be started with -no-reboot which would prevent using the virDomainSetLifecycleAction() API for the rest of the guest lifetime. 4b. With the allowReboot in the migration cookie the QEMU process on destination is started without -no-reboot like it was started on the source host and the virDomainSetLifecycleAction() API continues to work. The following patch adds a QEMU implementation of the virDomainSetLifecycleAction() API and that implementation disallows using the API if all actions are set to "destroy" because we add "-no-reboot" on the QEMU command line. Changing the lifecycle action is in this case pointless because the QEMU process is always terminated. Signed-off-by: Pavel Hrdina --- src/qemu/qemu_domain.c | 4 ++-- src/qemu/qemu_domain.h | 8 ++++++++ src/qemu/qemu_migration.c | 7 ++++++- src/qemu/qemu_migration_cookie.c | 25 ++++++++++++++++++++++++- src/qemu/qemu_migration_cookie.h | 5 +++++ 5 files changed, 45 insertions(+), 4 deletions(-) diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index 2630b73221..d74703fd3e 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -1877,7 +1877,7 @@ qemuDomainObjPrivateXMLFormatBlockjobs(virBufferPtr b= uf, } =20 =20 -static void +void qemuDomainObjPrivateXMLFormatAllowReboot(virBufferPtr buf, virTristateBool allowReboot) { @@ -2121,7 +2121,7 @@ qemuDomainObjPrivateXMLParseBlockjobs(qemuDomainObjPr= ivatePtr priv, } =20 =20 -static int +int qemuDomainObjPrivateXMLParseAllowReboot(xmlXPathContextPtr ctxt, virTristateBool *allowReboot) { diff --git a/src/qemu/qemu_domain.h b/src/qemu/qemu_domain.h index be4aaa5613..563438f0cc 100644 --- a/src/qemu/qemu_domain.h +++ b/src/qemu/qemu_domain.h @@ -975,4 +975,12 @@ qemuDomainUpdateCPU(virDomainObjPtr vm, char * qemuDomainGetMachineName(virDomainObjPtr vm); =20 +void +qemuDomainObjPrivateXMLFormatAllowReboot(virBufferPtr buf, + virTristateBool allowReboot); + +int +qemuDomainObjPrivateXMLParseAllowReboot(xmlXPathContextPtr ctxt, + virTristateBool *allowReboot); + #endif /* __QEMU_DOMAIN_H__ */ diff --git a/src/qemu/qemu_migration.c b/src/qemu/qemu_migration.c index dd60071bfd..5b394d3bbc 100644 --- a/src/qemu/qemu_migration.c +++ b/src/qemu/qemu_migration.c @@ -2013,6 +2013,8 @@ qemuMigrationBeginPhase(virQEMUDriverPtr driver, if (priv->origCPU) cookieFlags |=3D QEMU_MIGRATION_COOKIE_CPU; =20 + cookieFlags |=3D QEMU_MIGRATION_COOKIE_ALLOW_REBOOT; + if (!(mig =3D qemuMigrationEatCookie(driver, vm, NULL, 0, 0))) goto cleanup; =20 @@ -2639,7 +2641,8 @@ qemuMigrationPrepareAny(virQEMUDriverPtr driver, QEMU_MIGRATION_COOKIE_NBD | QEMU_MIGRATION_COOKIE_MEMORY_HOTPLU= G | QEMU_MIGRATION_COOKIE_CPU_HOTPLUG | - QEMU_MIGRATION_COOKIE_CPU))) + QEMU_MIGRATION_COOKIE_CPU | + QEMU_MIGRATION_COOKIE_ALLOW_REBOOT)= )) goto cleanup; =20 if (STREQ_NULLABLE(protocol, "rdma") && @@ -2679,6 +2682,8 @@ qemuMigrationPrepareAny(virQEMUDriverPtr driver, goto stopjob; stopProcess =3D true; =20 + priv->allowReboot =3D mig->allowReboot; + if (!(incoming =3D qemuMigrationPrepareIncoming(vm, tunnel, protocol, listenAddress, port, dataFD[0]))) diff --git a/src/qemu/qemu_migration_cookie.c b/src/qemu/qemu_migration_coo= kie.c index bc6a8dc552..2877913793 100644 --- a/src/qemu/qemu_migration_cookie.c +++ b/src/qemu/qemu_migration_cookie.c @@ -49,7 +49,8 @@ VIR_ENUM_IMPL(qemuMigrationCookieFlag, "statistics", "memory-hotplug", "cpu-hotplug", - "cpu"); + "cpu", + "allowReboot"); =20 =20 static void @@ -538,6 +539,18 @@ qemuMigrationCookieAddCPU(qemuMigrationCookiePtr mig, =20 =20 static void +qemuMigrationCookieAddAllowReboot(qemuMigrationCookiePtr mig, + virDomainObjPtr vm) +{ + qemuDomainObjPrivatePtr priv =3D vm->privateData; + + mig->allowReboot =3D priv->allowReboot; + + mig->flags |=3D QEMU_MIGRATION_COOKIE_ALLOW_REBOOT; +} + + +static void qemuMigrationCookieGraphicsXMLFormat(virBufferPtr buf, qemuMigrationCookieGraphicsPtr grap) { @@ -777,6 +790,9 @@ qemuMigrationCookieXMLFormat(virQEMUDriverPtr driver, if (mig->flags & QEMU_MIGRATION_COOKIE_CPU && mig->cpu) virCPUDefFormatBufFull(buf, mig->cpu, NULL); =20 + if (mig->flags & QEMU_MIGRATION_COOKIE_ALLOW_REBOOT) + qemuDomainObjPrivateXMLFormatAllowReboot(buf, mig->allowReboot); + virBufferAdjustIndent(buf, -2); virBufferAddLit(buf, "\n"); return 0; @@ -1225,6 +1241,10 @@ qemuMigrationCookieXMLParse(qemuMigrationCookiePtr m= ig, virCPUDefParseXML(ctxt, "./cpu[1]", VIR_CPU_TYPE_GUEST, &mig->cpu)= < 0) goto error; =20 + if (flags & QEMU_MIGRATION_COOKIE_ALLOW_REBOOT && + qemuDomainObjPrivateXMLParseAllowReboot(ctxt, &mig->allowReboot) <= 0) + goto error; + virObjectUnref(caps); return 0; =20 @@ -1305,6 +1325,9 @@ qemuMigrationBakeCookie(qemuMigrationCookiePtr mig, qemuMigrationCookieAddCPU(mig, dom) < 0) return -1; =20 + if (flags & QEMU_MIGRATION_COOKIE_ALLOW_REBOOT) + qemuMigrationCookieAddAllowReboot(mig, dom); + if (!(*cookieout =3D qemuMigrationCookieXMLFormatStr(driver, mig))) return -1; =20 diff --git a/src/qemu/qemu_migration_cookie.h b/src/qemu/qemu_migration_coo= kie.h index e5f3d75a95..4a25511a9a 100644 --- a/src/qemu/qemu_migration_cookie.h +++ b/src/qemu/qemu_migration_cookie.h @@ -29,6 +29,7 @@ typedef enum { QEMU_MIGRATION_COOKIE_FLAG_MEMORY_HOTPLUG, QEMU_MIGRATION_COOKIE_FLAG_CPU_HOTPLUG, QEMU_MIGRATION_COOKIE_FLAG_CPU, + QEMU_MIGRATION_COOKIE_FLAG_ALLOW_REBOOT, =20 QEMU_MIGRATION_COOKIE_FLAG_LAST } qemuMigrationCookieFlags; @@ -45,6 +46,7 @@ typedef enum { QEMU_MIGRATION_COOKIE_MEMORY_HOTPLUG =3D (1 << QEMU_MIGRATION_COOKIE_F= LAG_MEMORY_HOTPLUG), QEMU_MIGRATION_COOKIE_CPU_HOTPLUG =3D (1 << QEMU_MIGRATION_COOKIE_FLAG= _CPU_HOTPLUG), QEMU_MIGRATION_COOKIE_CPU =3D (1 << QEMU_MIGRATION_COOKIE_FLAG_CPU), + QEMU_MIGRATION_COOKIE_ALLOW_REBOOT =3D (1 << QEMU_MIGRATION_COOKIE_FLA= G_ALLOW_REBOOT), } qemuMigrationCookieFeatures; =20 typedef struct _qemuMigrationCookieGraphics qemuMigrationCookieGraphics; @@ -127,6 +129,9 @@ struct _qemuMigrationCookie { =20 /* If flags & QEMU_MIGRATION_COOKIE_CPU */ virCPUDefPtr cpu; + + /* If flags & QEMU_MIGRATION_COOKIE_ALLOW_REBOOT */ + virTristateBool allowReboot; }; =20 =20 --=20 2.13.6 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list