From nobody Thu Apr 25 12:24:34 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 1523477445844319.94534421133255; Wed, 11 Apr 2018 13:10:45 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 1546A18EC74; Wed, 11 Apr 2018 20:10:44 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 1FA00832C3; Wed, 11 Apr 2018 20:10:43 +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 67A27180215E; Wed, 11 Apr 2018 20:10:38 +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 w3BKAbFI019137 for ; Wed, 11 Apr 2018 16:10:37 -0400 Received: by smtp.corp.redhat.com (Postfix) id 8CCA888B0E; Wed, 11 Apr 2018 20:10:37 +0000 (UTC) Received: from unknown54ee7586bd10.attlocal.net.com (ovpn-116-52.phx2.redhat.com [10.3.116.52]) by smtp.corp.redhat.com (Postfix) with ESMTP id 01B7C832CE for ; Wed, 11 Apr 2018 20:10:15 +0000 (UTC) From: John Ferlan To: libvir-list@redhat.com Date: Wed, 11 Apr 2018 16:09:56 -0400 Message-Id: <20180411201005.14749-2-jferlan@redhat.com> In-Reply-To: <20180411201005.14749-1-jferlan@redhat.com> References: <20180411201005.14749-1-jferlan@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 01/10] Check return status for virUUIDGenerate 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.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Wed, 11 Apr 2018 20:10:44 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Although legal, a few paths were not checking a return value < 0 for failure instead they checked a non zero failure. Clean them all up to be consistent. Signed-off-by: John Ferlan --- src/conf/domain_conf.c | 2 +- src/conf/network_conf.c | 2 +- src/conf/secret_conf.c | 2 +- src/openvz/openvz_conf.c | 2 +- src/xenconfig/xen_common.c | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index d23182f18a..f57f956503 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -18776,7 +18776,7 @@ virDomainDefParseXML(xmlDocPtr xml, * also serve as the uuid. */ tmp =3D virXPathString("string(./uuid[1])", ctxt); if (!tmp) { - if (virUUIDGenerate(def->uuid)) { + if (virUUIDGenerate(def->uuid) < 0) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("Failed to generate UUID")); goto error; diff --git a/src/conf/network_conf.c b/src/conf/network_conf.c index 54109a3d2e..630a87fc07 100644 --- a/src/conf/network_conf.c +++ b/src/conf/network_conf.c @@ -1619,7 +1619,7 @@ virNetworkDefParseXML(xmlXPathContextPtr ctxt) /* Extract network uuid */ tmp =3D virXPathString("string(./uuid[1])", ctxt); if (!tmp) { - if (virUUIDGenerate(def->uuid)) { + if (virUUIDGenerate(def->uuid) < 0) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("Failed to generate UUID")); goto error; diff --git a/src/conf/secret_conf.c b/src/conf/secret_conf.c index 989705234c..7a2e4b28aa 100644 --- a/src/conf/secret_conf.c +++ b/src/conf/secret_conf.c @@ -177,7 +177,7 @@ secretXMLParseNode(xmlDocPtr xml, xmlNodePtr root) =20 uuidstr =3D virXPathString("string(./uuid)", ctxt); if (!uuidstr) { - if (virUUIDGenerate(def->uuid)) { + if (virUUIDGenerate(def->uuid) < 0) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("Failed to generate UUID")); goto cleanup; diff --git a/src/openvz/openvz_conf.c b/src/openvz/openvz_conf.c index 23a02d749e..deb2520ced 100644 --- a/src/openvz/openvz_conf.c +++ b/src/openvz/openvz_conf.c @@ -1020,7 +1020,7 @@ openvzSetUUID(int vpsid) { unsigned char uuid[VIR_UUID_BUFLEN]; =20 - if (virUUIDGenerate(uuid)) { + if (virUUIDGenerate(uuid) < 0) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("Failed to generate UUID")); return -1; diff --git a/src/xenconfig/xen_common.c b/src/xenconfig/xen_common.c index bc43185363..7db365f363 100644 --- a/src/xenconfig/xen_common.c +++ b/src/xenconfig/xen_common.c @@ -202,7 +202,7 @@ xenConfigGetUUID(virConfPtr conf, const char *name, uns= igned char *uuid) } =20 if (!(val =3D virConfGetValue(conf, name))) { - if (virUUIDGenerate(uuid)) { + if (virUUIDGenerate(uuid) < 0) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("Failed to generate UUID")); return -1; --=20 2.13.6 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Thu Apr 25 12:24:34 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 1523477445807945.4445783186327; Wed, 11 Apr 2018 13:10:45 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id D700330B96C2; Wed, 11 Apr 2018 20:10:43 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 11EBB189F9; Wed, 11 Apr 2018 20:10:43 +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 06683180BAD3; Wed, 11 Apr 2018 20:10:40 +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 w3BKAcuf019146 for ; Wed, 11 Apr 2018 16:10:38 -0400 Received: by smtp.corp.redhat.com (Postfix) id 7879688B0B; Wed, 11 Apr 2018 20:10:38 +0000 (UTC) Received: from unknown54ee7586bd10.attlocal.net.com (ovpn-116-52.phx2.redhat.com [10.3.116.52]) by smtp.corp.redhat.com (Postfix) with ESMTP id 9492288B18 for ; Wed, 11 Apr 2018 20:10:23 +0000 (UTC) From: John Ferlan To: libvir-list@redhat.com Date: Wed, 11 Apr 2018 16:09:57 -0400 Message-Id: <20180411201005.14749-3-jferlan@redhat.com> In-Reply-To: <20180411201005.14749-1-jferlan@redhat.com> References: <20180411201005.14749-1-jferlan@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 02/10] conf: Modify last arg to virDomainDefCopy 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.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.49]); Wed, 11 Apr 2018 20:10:44 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Rather than single boolean, let's create a virDomainDefCopyFlags and have the last argument be an unsigned int using the new VIR_DOMAIN_DEF_COPY_MIGRATABLE bit. Signed-off-by: John Ferlan --- src/conf/domain_conf.c | 8 ++++---- src/conf/domain_conf.h | 6 +++++- src/libxl/libxl_domain.c | 4 ++-- src/qemu/qemu_domain.c | 5 +++-- src/qemu/qemu_driver.c | 5 +++-- src/test/test_driver.c | 5 +++-- 6 files changed, 20 insertions(+), 13 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index f57f956503..5fdcddfa91 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -3320,7 +3320,7 @@ virDomainObjSetDefTransient(virCapsPtr caps, if (domain->newDef) return 0; =20 - if (!(domain->newDef =3D virDomainDefCopy(domain->def, caps, xmlopt, N= ULL, false))) + if (!(domain->newDef =3D virDomainDefCopy(domain->def, caps, xmlopt, N= ULL, 0))) goto out; =20 ret =3D 0; @@ -27891,7 +27891,7 @@ virDomainDefCopy(virDomainDefPtr src, virCapsPtr caps, virDomainXMLOptionPtr xmlopt, void *parseOpaque, - bool migratable) + unsigned int flags) { char *xml; virDomainDefPtr ret; @@ -27899,7 +27899,7 @@ virDomainDefCopy(virDomainDefPtr src, unsigned int parse_flags =3D VIR_DOMAIN_DEF_PARSE_INACTIVE | VIR_DOMAIN_DEF_PARSE_SKIP_VALIDATE; =20 - if (migratable) + if (flags & VIR_DOMAIN_DEF_COPY_MIGRATABLE) format_flags |=3D VIR_DOMAIN_DEF_FORMAT_INACTIVE | VIR_DOMAIN_DEF_= FORMAT_MIGRATABLE; =20 /* Easiest to clone via a round-trip through XML. */ @@ -27920,7 +27920,7 @@ virDomainObjCopyPersistentDef(virDomainObjPtr dom, virDomainDefPtr cur; =20 cur =3D virDomainObjGetPersistentDef(caps, xmlopt, dom); - return virDomainDefCopy(cur, caps, xmlopt, NULL, false); + return virDomainDefCopy(cur, caps, xmlopt, NULL, 0); } =20 =20 diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h index 89a7131fdb..4ca22d3617 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -2862,11 +2862,15 @@ virDomainDefPtr virDomainObjGetOneDefState(virDomai= nObjPtr vm, bool *state); virDomainDefPtr virDomainObjGetOneDef(virDomainObjPtr vm, unsigned int fla= gs); =20 +typedef enum { + /* Set when creating a copy of a definition for the purpose of migrati= on */ + VIR_DOMAIN_DEF_COPY_MIGRATABLE =3D 1 << 0, +} virDomainDefCopyFlags; virDomainDefPtr virDomainDefCopy(virDomainDefPtr src, virCapsPtr caps, virDomainXMLOptionPtr xmlopt, void *parseOpaque, - bool migratable); + unsigned int flags); virDomainDefPtr virDomainObjCopyPersistentDef(virDomainObjPtr dom, virCapsPtr caps, virDomainXMLOptionPtr xmlopt= ); diff --git a/src/libxl/libxl_domain.c b/src/libxl/libxl_domain.c index e76740247d..c58a9c7d72 100644 --- a/src/libxl/libxl_domain.c +++ b/src/libxl/libxl_domain.c @@ -1443,8 +1443,8 @@ libxlDomainDefCheckABIStability(libxlDriverPrivatePtr= driver, libxlDriverConfigPtr cfg =3D libxlDriverConfigGet(driver); bool ret =3D false; =20 - if (!(migratableDefSrc =3D virDomainDefCopy(src, cfg->caps, driver->xm= lopt, NULL, true)) || - !(migratableDefDst =3D virDomainDefCopy(dst, cfg->caps, driver->xm= lopt, NULL, true))) + if (!(migratableDefSrc =3D virDomainDefCopy(src, cfg->caps, driver->xm= lopt, NULL, VIR_DOMAIN_DEF_COPY_MIGRATABLE)) || + !(migratableDefDst =3D virDomainDefCopy(dst, cfg->caps, driver->xm= lopt, NULL, VIR_DOMAIN_DEF_COPY_MIGRATABLE))) goto cleanup; =20 ret =3D virDomainDefCheckABIStability(migratableDefSrc, diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index 100304fd05..6568054d7d 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -6182,6 +6182,8 @@ qemuDomainDefFormatBufInternal(virQEMUDriverPtr drive= r, virDomainDefPtr copy =3D NULL; virCapsPtr caps =3D NULL; virQEMUCapsPtr qemuCaps =3D NULL; + unsigned int copyFlags =3D (flags & VIR_DOMAIN_XML_MIGRATABLE) ? + VIR_DOMAIN_DEF_COPY_MIGRATABLE : 0; =20 if (!(caps =3D virQEMUDriverGetCapabilities(driver, false))) goto cleanup; @@ -6189,8 +6191,7 @@ qemuDomainDefFormatBufInternal(virQEMUDriverPtr drive= r, if (!(flags & (VIR_DOMAIN_XML_UPDATE_CPU | VIR_DOMAIN_XML_MIGRATABLE))) goto format; =20 - if (!(copy =3D virDomainDefCopy(def, caps, driver->xmlopt, NULL, - flags & VIR_DOMAIN_XML_MIGRATABLE))) + if (!(copy =3D virDomainDefCopy(def, caps, driver->xmlopt, NULL, copyF= lags))) goto cleanup; =20 def =3D copy; diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index 5c31dfdd58..3fede93687 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -15849,7 +15849,8 @@ qemuDomainRevertToSnapshot(virDomainSnapshotPtr sna= pshot, snap->def->current =3D true; if (snap->def->dom) { config =3D virDomainDefCopy(snap->def->dom, caps, - driver->xmlopt, NULL, true); + driver->xmlopt, NULL, + VIR_DOMAIN_DEF_COPY_MIGRATABLE); if (!config) goto endjob; } @@ -20468,7 +20469,7 @@ qemuDomainGetFSInfo(virDomainPtr dom, if (!(caps =3D virQEMUDriverGetCapabilities(driver, false))) goto endjob; =20 - if (!(def =3D virDomainDefCopy(vm->def, caps, driver->xmlopt, NULL, fa= lse))) + if (!(def =3D virDomainDefCopy(vm->def, caps, driver->xmlopt, NULL, 0)= )) goto endjob; =20 agent =3D qemuDomainObjEnterAgent(vm); diff --git a/src/test/test_driver.c b/src/test/test_driver.c index 856869c9d3..f16bcf75de 100644 --- a/src/test/test_driver.c +++ b/src/test/test_driver.c @@ -6467,7 +6467,7 @@ testDomainSnapshotCreateXML(virDomainPtr domain, privconn->caps, privconn->xmlopt, NULL, - true))) + VIR_DOMAIN_DEF_COPY_MIGRATABLE))) goto cleanup; =20 if (testDomainSnapshotAlignDisks(vm, def, flags) < 0) @@ -6722,7 +6722,8 @@ testDomainRevertToSnapshot(virDomainSnapshotPtr snaps= hot, =20 snap->def->current =3D true; config =3D virDomainDefCopy(snap->def->dom, privconn->caps, - privconn->xmlopt, NULL, true); + privconn->xmlopt, NULL, + VIR_DOMAIN_DEF_COPY_MIGRATABLE); if (!config) goto cleanup; =20 --=20 2.13.6 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Thu Apr 25 12:24:34 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 15234774536071005.6170968180587; Wed, 11 Apr 2018 13:10:53 -0700 (PDT) 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 EEA2DC047B94; Wed, 11 Apr 2018 20:10:51 +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 C91CF6D012; Wed, 11 Apr 2018 20:10:51 +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 6FA424CA9C; Wed, 11 Apr 2018 20:10:51 +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 w3BKAj6a019163 for ; Wed, 11 Apr 2018 16:10:45 -0400 Received: by smtp.corp.redhat.com (Postfix) id 5A2DF832C9; Wed, 11 Apr 2018 20:10:45 +0000 (UTC) Received: from unknown54ee7586bd10.attlocal.net.com (ovpn-116-52.phx2.redhat.com [10.3.116.52]) by smtp.corp.redhat.com (Postfix) with ESMTP id D7FE9832BB for ; Wed, 11 Apr 2018 20:10:37 +0000 (UTC) From: John Ferlan To: libvir-list@redhat.com Date: Wed, 11 Apr 2018 16:09:58 -0400 Message-Id: <20180411201005.14749-4-jferlan@redhat.com> In-Reply-To: <20180411201005.14749-1-jferlan@redhat.com> References: <20180411201005.14749-1-jferlan@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 03/10] qemu: Add flags to qemuDomainMigratableDefCheckABIStability 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.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.31]); Wed, 11 Apr 2018 20:10:52 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Allow the caller to qemuDomainMigratableDefCheckABIStability to also provide a flag to be used for virDomainDefCheckABIStabilityFlags. Signed-off-by: John Ferlan --- src/qemu/qemu_domain.c | 18 ++++++++++++------ src/qemu/qemu_domain.h | 6 ++++-- src/qemu/qemu_driver.c | 7 ++++--- src/qemu/qemu_migration.c | 4 ++-- 4 files changed, 22 insertions(+), 13 deletions(-) diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index 6568054d7d..9c4bdf1ee4 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -7997,12 +7997,14 @@ qemuDomainMigratableDefCheckABIStability(virQEMUDri= verPtr driver, virDomainDefPtr src, virDomainDefPtr migratableSrc, virDomainDefPtr dst, - virDomainDefPtr migratableDst) + virDomainDefPtr migratableDst, + unsigned flags) { + flags |=3D VIR_DOMAIN_DEF_ABI_CHECK_SKIP_VOLATILE; if (!virDomainDefCheckABIStabilityFlags(migratableSrc, migratableDst, driver->xmlopt, - VIR_DOMAIN_DEF_ABI_CHECK_SKIP_= VOLATILE)) + flags)) return false; =20 /* Force update any skipped values from the volatile flag */ @@ -8018,7 +8020,8 @@ qemuDomainMigratableDefCheckABIStability(virQEMUDrive= rPtr driver, bool qemuDomainDefCheckABIStability(virQEMUDriverPtr driver, virDomainDefPtr src, - virDomainDefPtr dst) + virDomainDefPtr dst, + unsigned int flags) { virDomainDefPtr migratableDefSrc =3D NULL; virDomainDefPtr migratableDefDst =3D NULL; @@ -8030,7 +8033,8 @@ qemuDomainDefCheckABIStability(virQEMUDriverPtr drive= r, =20 ret =3D qemuDomainMigratableDefCheckABIStability(driver, src, migratableDefSrc, - dst, migratableDefDst); + dst, migratableDefDst, + flags); =20 cleanup: virDomainDefFree(migratableDefSrc); @@ -8042,7 +8046,8 @@ qemuDomainDefCheckABIStability(virQEMUDriverPtr drive= r, bool qemuDomainCheckABIStability(virQEMUDriverPtr driver, virDomainObjPtr vm, - virDomainDefPtr dst) + virDomainDefPtr dst, + unsigned int flags) { virDomainDefPtr migratableSrc =3D NULL; virDomainDefPtr migratableDst =3D NULL; @@ -8056,7 +8061,8 @@ qemuDomainCheckABIStability(virQEMUDriverPtr driver, =20 ret =3D qemuDomainMigratableDefCheckABIStability(driver, vm->def, migratableSrc, - dst, migratableDst); + dst, migratableDst, + flags); =20 cleanup: VIR_FREE(xml); diff --git a/src/qemu/qemu_domain.h b/src/qemu/qemu_domain.h index 21e12f6594..73463a681e 100644 --- a/src/qemu/qemu_domain.h +++ b/src/qemu/qemu_domain.h @@ -718,11 +718,13 @@ int qemuDomainUpdateMemoryDeviceInfo(virQEMUDriverPtr= driver, =20 bool qemuDomainDefCheckABIStability(virQEMUDriverPtr driver, virDomainDefPtr src, - virDomainDefPtr dst); + virDomainDefPtr dst, + unsigned int flags); =20 bool qemuDomainCheckABIStability(virQEMUDriverPtr driver, virDomainObjPtr vm, - virDomainDefPtr dst); + virDomainDefPtr dst, + unsigned int flags); =20 bool qemuDomainAgentAvailable(virDomainObjPtr vm, bool reportError); diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index 3fede93687..261b680775 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -3387,7 +3387,7 @@ qemuDomainSaveInternal(virQEMUDriverPtr driver, VIR_DOMAIN_DEF_PARSE_SKIP_VALI= DATE))) { goto endjob; } - if (!qemuDomainCheckABIStability(driver, vm, def)) { + if (!qemuDomainCheckABIStability(driver, vm, def, 0)) { virDomainDefFree(def); goto endjob; } @@ -15885,9 +15885,10 @@ qemuDomainRevertToSnapshot(virDomainSnapshotPtr sn= apshot, goto endjob; =20 compatible =3D qemuDomainDefCheckABIStability(driver, = vm->def, - config); + config, 0); } else { - compatible =3D qemuDomainCheckABIStability(driver, vm,= config); + compatible =3D qemuDomainCheckABIStability(driver, vm,= config, + 0); } =20 if (!compatible) { diff --git a/src/qemu/qemu_migration.c b/src/qemu/qemu_migration.c index 256b994bd9..a949104f5a 100644 --- a/src/qemu/qemu_migration.c +++ b/src/qemu/qemu_migration.c @@ -2163,7 +2163,7 @@ qemuMigrationSrcBeginPhase(virQEMUDriverPtr driver, VIR_DOMAIN_DEF_PARSE_SKIP_VALI= DATE))) goto cleanup; =20 - if (!qemuDomainCheckABIStability(driver, vm, def)) + if (!qemuDomainCheckABIStability(driver, vm, def, 0)) goto cleanup; =20 rv =3D qemuDomainDefFormatLive(driver, def, NULL, false, true); @@ -2715,7 +2715,7 @@ qemuMigrationDstPrepareAny(virQEMUDriverPtr driver, if (!newdef) goto cleanup; =20 - if (!qemuDomainDefCheckABIStability(driver, *def, newdef))= { + if (!qemuDomainDefCheckABIStability(driver, *def, newdef, = 0)) { virDomainDefFree(newdef); goto cleanup; } --=20 2.13.6 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Thu Apr 25 12:24:34 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 1523780857697370.9320666247404; Sun, 15 Apr 2018 01:27:37 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 69F9A4E4C3; Sun, 15 Apr 2018 08:27:36 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 425626046C; Sun, 15 Apr 2018 08:27:36 +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 C9BCF180BAD9; Sun, 15 Apr 2018 08:27:35 +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 w3BKB23U019202 for ; Wed, 11 Apr 2018 16:11:02 -0400 Received: by smtp.corp.redhat.com (Postfix) id 12339832DB; Wed, 11 Apr 2018 20:11:02 +0000 (UTC) Received: from unknown54ee7586bd10.attlocal.net.com (ovpn-116-52.phx2.redhat.com [10.3.116.52]) by smtp.corp.redhat.com (Postfix) with ESMTP id 1154787E2E for ; Wed, 11 Apr 2018 20:10:45 +0000 (UTC) From: John Ferlan To: libvir-list@redhat.com Date: Wed, 11 Apr 2018 16:09:59 -0400 Message-Id: <20180411201005.14749-5-jferlan@redhat.com> In-Reply-To: <20180411201005.14749-1-jferlan@redhat.com> References: <20180411201005.14749-1-jferlan@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 04/10] conf: Add VM Generation ID to virDomainDef 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.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Sun, 15 Apr 2018 08:27:36 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Add a genid[] field to be able to store a uuid-like GUID value. Also add associated bool's to support VM Generation ID operation. Signed-off-by: John Ferlan --- src/conf/domain_conf.h | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h index 4ca22d3617..9da3b23393 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -2322,6 +2322,11 @@ struct _virDomainDef { virDomainVirtType virtType; int id; unsigned char uuid[VIR_UUID_BUFLEN]; + + unsigned char genid[VIR_UUID_BUFLEN]; + bool genidRequested; + bool genidGenerated; + char *name; char *title; char *description; --=20 2.13.6 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Thu Apr 25 12:24:34 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 1523780861747488.09242282445996; Sun, 15 Apr 2018 01:27:41 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 54A15883B0; Sun, 15 Apr 2018 08:27:40 +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 194F65DD84; Sun, 15 Apr 2018 08:27:40 +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 C29935BBE6; Sun, 15 Apr 2018 08:27:39 +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 w3BKB7ra019220 for ; Wed, 11 Apr 2018 16:11:08 -0400 Received: by smtp.corp.redhat.com (Postfix) id EE7BA7C256; Wed, 11 Apr 2018 20:11:07 +0000 (UTC) Received: from unknown54ee7586bd10.attlocal.net.com (ovpn-116-52.phx2.redhat.com [10.3.116.52]) by smtp.corp.redhat.com (Postfix) with ESMTP id AAF0588B22 for ; Wed, 11 Apr 2018 20:11:00 +0000 (UTC) From: John Ferlan To: libvir-list@redhat.com Date: Wed, 11 Apr 2018 16:10:00 -0400 Message-Id: <20180411201005.14749-6-jferlan@redhat.com> In-Reply-To: <20180411201005.14749-1-jferlan@redhat.com> References: <20180411201005.14749-1-jferlan@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 05/10] conf: Add flag to regenerate genid for virDomainDefCopy 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.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.26]); Sun, 15 Apr 2018 08:27:40 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Add the VIR_DOMAIN_DEF_COPY_NEWGENID to indicate that the generated domain definition should adjust the genid value before returning the @def to the caller. Signed-off-by: John Ferlan --- src/conf/domain_conf.c | 12 ++++++++++++ src/conf/domain_conf.h | 5 +++++ src/qemu/qemu_driver.c | 3 ++- src/test/test_driver.c | 3 ++- 4 files changed, 21 insertions(+), 2 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 5fdcddfa91..385ba4ce8c 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -27908,6 +27908,18 @@ virDomainDefCopy(virDomainDefPtr src, =20 ret =3D virDomainDefParseString(xml, caps, xmlopt, parseOpaque, parse_= flags); =20 + /* If we have a genid and we're being called from a path that would + * require a different genid value, then regardless of whether it was + * generated or not generate a new one. */ + if (ret && ret->genidRequested && (flags & VIR_DOMAIN_DEF_COPY_NEWGENI= D)) { + if (virUUIDGenerate(ret->genid)) { + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("Failed to generate a new genid")); + virDomainDefFree(ret); + ret =3D NULL; + } + } + VIR_FREE(xml); return ret; } diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h index 9da3b23393..dc748162b9 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -2870,6 +2870,11 @@ virDomainDefPtr virDomainObjGetOneDef(virDomainObjPt= r vm, unsigned int flags); typedef enum { /* Set when creating a copy of a definition for the purpose of migrati= on */ VIR_DOMAIN_DEF_COPY_MIGRATABLE =3D 1 << 0, + + /* Set when the copy should create a new genid value if supported + * the domain def. + */ + VIR_DOMAIN_DEF_COPY_NEWGENID =3D 1 << 1, } virDomainDefCopyFlags; virDomainDefPtr virDomainDefCopy(virDomainDefPtr src, virCapsPtr caps, diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index 261b680775..56ac64630f 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -15850,7 +15850,8 @@ qemuDomainRevertToSnapshot(virDomainSnapshotPtr sna= pshot, if (snap->def->dom) { config =3D virDomainDefCopy(snap->def->dom, caps, driver->xmlopt, NULL, - VIR_DOMAIN_DEF_COPY_MIGRATABLE); + VIR_DOMAIN_DEF_COPY_MIGRATABLE | + VIR_DOMAIN_DEF_COPY_NEWGENID); if (!config) goto endjob; } diff --git a/src/test/test_driver.c b/src/test/test_driver.c index f16bcf75de..d6be51795f 100644 --- a/src/test/test_driver.c +++ b/src/test/test_driver.c @@ -6723,7 +6723,8 @@ testDomainRevertToSnapshot(virDomainSnapshotPtr snaps= hot, snap->def->current =3D true; config =3D virDomainDefCopy(snap->def->dom, privconn->caps, privconn->xmlopt, NULL, - VIR_DOMAIN_DEF_COPY_MIGRATABLE); + VIR_DOMAIN_DEF_COPY_MIGRATABLE | + VIR_DOMAIN_DEF_COPY_NEWGENID); if (!config) goto cleanup; =20 --=20 2.13.6 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Thu Apr 25 12:24:34 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 1523477473495799.9020976571946; Wed, 11 Apr 2018 13:11:13 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 2037C7B125; Wed, 11 Apr 2018 20:11:12 +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 E677A77D80; Wed, 11 Apr 2018 20:11:11 +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 A0DA04CAA0; Wed, 11 Apr 2018 20:11:11 +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 w3BKBBRo019231 for ; Wed, 11 Apr 2018 16:11:11 -0400 Received: by smtp.corp.redhat.com (Postfix) id 563B665939; Wed, 11 Apr 2018 20:11:11 +0000 (UTC) Received: from unknown54ee7586bd10.attlocal.net.com (ovpn-116-52.phx2.redhat.com [10.3.116.52]) by smtp.corp.redhat.com (Postfix) with ESMTP id 01A605E4FD for ; Wed, 11 Apr 2018 20:11:08 +0000 (UTC) From: John Ferlan To: libvir-list@redhat.com Date: Wed, 11 Apr 2018 16:10:01 -0400 Message-Id: <20180411201005.14749-7-jferlan@redhat.com> In-Reply-To: <20180411201005.14749-1-jferlan@redhat.com> References: <20180411201005.14749-1-jferlan@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 06/10] conf: Add VM Generation ID parse/format support 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.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.26]); Wed, 11 Apr 2018 20:11:12 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" The VM Generation ID is a mechanism to provide a unique 128-bit, cryptographically random, and integer value identifier known as the GUID (Globally Unique Identifier) to the guest OS. The value is used to help notify the guest operating system when the virtual machine is executed with a different configuration. This patch adds support for a new "genid" XML element similar to the "uuid" element. The "genid" element can have two forms "" or "$GUID". If the $GUID is not provided, libvirt will generate one. For the ABI checks add avoidance for the genid comparison if the appropriate flag is set. Since adding support for a generated GUID (or UUID like) value to be displayed only for an active guest, modifying the xml2xml test to include virrandommock.so is necessary since it will generate a "known" UUID value that can be compared against for the active test. Signed-off-by: John Ferlan --- docs/formatdomain.html.in | 29 ++++++++++++ docs/schemas/domaincommon.rng | 8 ++++ src/conf/domain_conf.c | 59 ++++++++++++++++++++= ++++ src/conf/domain_conf.h | 3 ++ tests/qemuxml2argvdata/genid-auto.xml | 32 +++++++++++++ tests/qemuxml2argvdata/genid.xml | 32 +++++++++++++ tests/qemuxml2xmloutdata/genid-active.xml | 32 +++++++++++++ tests/qemuxml2xmloutdata/genid-auto-active.xml | 32 +++++++++++++ tests/qemuxml2xmloutdata/genid-auto-inactive.xml | 32 +++++++++++++ tests/qemuxml2xmloutdata/genid-inactive.xml | 32 +++++++++++++ tests/qemuxml2xmltest.c | 5 +- 11 files changed, 295 insertions(+), 1 deletion(-) create mode 100644 tests/qemuxml2argvdata/genid-auto.xml create mode 100644 tests/qemuxml2argvdata/genid.xml create mode 100644 tests/qemuxml2xmloutdata/genid-active.xml create mode 100644 tests/qemuxml2xmloutdata/genid-auto-active.xml create mode 100644 tests/qemuxml2xmloutdata/genid-auto-inactive.xml create mode 100644 tests/qemuxml2xmloutdata/genid-inactive.xml diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in index 5e99884dc5..fe9c3b19f0 100644 --- a/docs/formatdomain.html.in +++ b/docs/formatdomain.html.in @@ -34,6 +34,7 @@ <domain type=3D'kvm' id=3D'1'> <name>MyGuest</name> <uuid>4dea22b3-1d52-d8f3-2516-782e98ab3fa0</uuid> + <genid>43dc0cf8-809b-4adb-9bea-a9abb5f3d90e</genid> <title>A short description - title - of the domain</title> <description>Some human readable description</description> <metadata> @@ -61,6 +62,34 @@ specification. Since 0.0.1, sysinfo since 0.8.7 =20 +
genid
+
Since 4.3.0, the genid + element can be used to add a Virtual Machine Generation ID which + exposes a 128-bit, cryptographically random, integer value identif= ier, + referred to as a Globally Unique Identifier (GUID) using the same + format as the uuid. The value is used to help notify + the guest operating system when the virtual machine is executed + with a different configuration, such as: + +
    +
  • snapshot execution
  • +
  • backup recovery
  • +
  • failover in a disaster recovery environment
  • +
  • creation from template (import, copy, clone)
  • +
+ + The guest operating system notices the change and is then able to + react as appropriate by marking its copies of distributed databases + as dirty, re-initializing its random number generator, etc. + +

+ When a GUID value is not provided, e.g. using the XML syntax + <genid/>, then libvirt will automatically generate a GUID. + This is the recommended configuration since the hypervisor then + can handle changing the GUID value for specific state transitions. + Using a static GUID value may result in failures for starting from + snapshot, restoring from backup, starting a cloned domain, etc.

+
title
The optional element title provides space for a short description of the domain. The title should not contain diff --git a/docs/schemas/domaincommon.rng b/docs/schemas/domaincommon.rng index 4cab55f05d..1892a7c63c 100644 --- a/docs/schemas/domaincommon.rng +++ b/docs/schemas/domaincommon.rng @@ -502,6 +502,14 @@ + + + + + + + + diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 385ba4ce8c..0fa9386270 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -18791,6 +18791,34 @@ virDomainDefParseXML(xmlDocPtr xml, VIR_FREE(tmp); } =20 + /* Extract domain genid - a genid can either be provided or generated = */ + if ((n =3D virXPathNodeSet("./genid", ctxt, &nodes)) < 0) + goto error; + + if (n > 0) { + if (n !=3D 1) { + virReportError(VIR_ERR_XML_ERROR, "%s", + _("element 'genid' can only appear once")); + goto error; + } + def->genidRequested =3D true; + if (!(tmp =3D virXPathString("string(./genid[1])", ctxt))) { + if (virUUIDGenerate(def->genid) < 0) { + virReportError(VIR_ERR_INTERNAL_ERROR, + "%s", _("Failed to generate genid")); + goto error; + } + def->genidGenerated =3D true; + } else { + if (virUUIDParse(tmp, def->genid) < 0) { + virReportError(VIR_ERR_INTERNAL_ERROR, + "%s", _("malformed genid element")); + goto error; + } + } + } + VIR_FREE(nodes); + /* Extract short description of domain (title) */ def->title =3D virXPathString("string(./title[1])", ctxt); if (def->title && strchr(def->title, '\n')) { @@ -21903,6 +21931,26 @@ virDomainDefCheckABIStabilityFlags(virDomainDefPtr= src, goto error; } =20 + if (src->genidRequested !=3D dst->genidRequested) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("Target domain requested genid does not match sou= rce")); + goto error; + } + + if (src->genidRequested && + !(flags & VIR_DOMAIN_DEF_ABI_CHECK_SKIP_GENID) && + memcmp(src->genid, dst->genid, VIR_UUID_BUFLEN) !=3D 0) { + char guidsrc[VIR_UUID_STRING_BUFLEN]; + char guiddst[VIR_UUID_STRING_BUFLEN]; + + virUUIDFormat(src->genid, guidsrc); + virUUIDFormat(dst->genid, guiddst); + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("Target domain genid %s does not match source %s"= ), + guiddst, guidsrc); + goto error; + } + /* Not strictly ABI related, but we want to make sure domains * don't get silently re-named through the backdoor when passing * custom XML into various APIs, since this would create havoc @@ -26540,6 +26588,17 @@ virDomainDefFormatInternal(virDomainDefPtr def, virUUIDFormat(uuid, uuidstr); virBufferAsprintf(buf, "%s\n", uuidstr); =20 + if (def->genidRequested) { + char genidstr[VIR_UUID_STRING_BUFLEN]; + + virUUIDFormat(def->genid, genidstr); + if (!def->genidGenerated || + !(flags & VIR_DOMAIN_DEF_FORMAT_INACTIVE)) + virBufferAsprintf(buf, "%s\n", genidstr); + else + virBufferAddLit(buf, "\n"); + } + virBufferEscapeString(buf, "%s\n", def->title); =20 virBufferEscapeString(buf, "%s\n", diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h index dc748162b9..dfd44bd9ff 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -2947,6 +2947,9 @@ typedef enum { /* Set when domain lock must be released and there exists the possibil= ity * that some external action could alter the value, such as cur_balloo= n. */ VIR_DOMAIN_DEF_ABI_CHECK_SKIP_VOLATILE =3D 1 << 0, + + /* Set when the ABI check should skip the genid comparison */ + VIR_DOMAIN_DEF_ABI_CHECK_SKIP_GENID =3D 1 << 1, } virDomainDefABICheckFlags; =20 virDomainDeviceDefPtr virDomainDeviceDefParse(const char *xmlStr, diff --git a/tests/qemuxml2argvdata/genid-auto.xml b/tests/qemuxml2argvdata= /genid-auto.xml new file mode 100644 index 0000000000..96ad9ddda8 --- /dev/null +++ b/tests/qemuxml2argvdata/genid-auto.xml @@ -0,0 +1,32 @@ + + QEMUGuest1 + c7a5fdbd-edaf-9455-926a-d65c16db1809 + + 219136 + 219136 + 1 + + hvm + + + + + + + destroy + restart + destroy + + /usr/bin/qemu-system-x86_64 + +
+ + +
+ + + + + + + diff --git a/tests/qemuxml2argvdata/genid.xml b/tests/qemuxml2argvdata/geni= d.xml new file mode 100644 index 0000000000..fc41f2dd28 --- /dev/null +++ b/tests/qemuxml2argvdata/genid.xml @@ -0,0 +1,32 @@ + + QEMUGuest1 + c7a5fdbd-edaf-9455-926a-d65c16db1809 + e9392370-2917-565e-692b-d057f46512d6 + 219136 + 219136 + 1 + + hvm + + + + + + + destroy + restart + destroy + + /usr/bin/qemu-system-x86_64 + +
+ + +
+ + + + + + + diff --git a/tests/qemuxml2xmloutdata/genid-active.xml b/tests/qemuxml2xmlo= utdata/genid-active.xml new file mode 100644 index 0000000000..fc41f2dd28 --- /dev/null +++ b/tests/qemuxml2xmloutdata/genid-active.xml @@ -0,0 +1,32 @@ + + QEMUGuest1 + c7a5fdbd-edaf-9455-926a-d65c16db1809 + e9392370-2917-565e-692b-d057f46512d6 + 219136 + 219136 + 1 + + hvm + + + + + + + destroy + restart + destroy + + /usr/bin/qemu-system-x86_64 + +
+ + +
+ + + + + + + diff --git a/tests/qemuxml2xmloutdata/genid-auto-active.xml b/tests/qemuxml= 2xmloutdata/genid-auto-active.xml new file mode 100644 index 0000000000..aeca0d7fc0 --- /dev/null +++ b/tests/qemuxml2xmloutdata/genid-auto-active.xml @@ -0,0 +1,32 @@ + + QEMUGuest1 + c7a5fdbd-edaf-9455-926a-d65c16db1809 + 00010203-0405-4607-8809-0a0b0c0d0e0f + 219136 + 219136 + 1 + + hvm + + + + + + + destroy + restart + destroy + + /usr/bin/qemu-system-x86_64 + +
+ + +
+ + + + + + + diff --git a/tests/qemuxml2xmloutdata/genid-auto-inactive.xml b/tests/qemux= ml2xmloutdata/genid-auto-inactive.xml new file mode 100644 index 0000000000..83c924395b --- /dev/null +++ b/tests/qemuxml2xmloutdata/genid-auto-inactive.xml @@ -0,0 +1,32 @@ + + QEMUGuest1 + c7a5fdbd-edaf-9455-926a-d65c16db1809 + + 219136 + 219136 + 1 + + hvm + + + + + + + destroy + restart + destroy + + /usr/bin/qemu-system-x86_64 + +
+ + +
+ + + + + + + diff --git a/tests/qemuxml2xmloutdata/genid-inactive.xml b/tests/qemuxml2xm= loutdata/genid-inactive.xml new file mode 100644 index 0000000000..8bd526a7a9 --- /dev/null +++ b/tests/qemuxml2xmloutdata/genid-inactive.xml @@ -0,0 +1,32 @@ + + QEMUGuest1 + c7a5fdbd-edaf-9455-926a-d65c16db1809 + e9392370-2917-565e-692b-d057f46512d6 + 219136 + 219136 + 1 + + hvm + + + + + + + destroy + restart + destroy + + /usr/bin/qemu-system-x86_64 + +
+ + +
+ + + + + + + diff --git a/tests/qemuxml2xmltest.c b/tests/qemuxml2xmltest.c index d123180e79..0240dae051 100644 --- a/tests/qemuxml2xmltest.c +++ b/tests/qemuxml2xmltest.c @@ -276,6 +276,8 @@ mymain(void) setenv("PATH", "/bin", 1); =20 DO_TEST("minimal", NONE); + DO_TEST("genid", NONE); + DO_TEST("genid-auto", NONE); DO_TEST("machine-core-on", NONE); DO_TEST("machine-core-off", NONE); DO_TEST("machine-loadparm-multiple-disks-nets-s390", NONE); @@ -1284,7 +1286,8 @@ mymain(void) } =20 VIR_TEST_MAIN_PRELOAD(mymain, - abs_builddir "/.libs/virpcimock.so") + abs_builddir "/.libs/virpcimock.so", + abs_builddir "/.libs/virrandommock.so") =20 #else =20 --=20 2.13.6 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Thu Apr 25 12:24:34 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 1523477478572735.5885179850543; Wed, 11 Apr 2018 13:11:18 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id EFF11552FC; Wed, 11 Apr 2018 20:11:16 +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 BD29478DA3; Wed, 11 Apr 2018 20:11:16 +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 812834CAA1; Wed, 11 Apr 2018 20:11:16 +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 w3BKBEF1019246 for ; Wed, 11 Apr 2018 16:11:14 -0400 Received: by smtp.corp.redhat.com (Postfix) id 49C3087E44; Wed, 11 Apr 2018 20:11:14 +0000 (UTC) Received: from unknown54ee7586bd10.attlocal.net.com (ovpn-116-52.phx2.redhat.com [10.3.116.52]) by smtp.corp.redhat.com (Postfix) with ESMTP id EAACE8BE20 for ; Wed, 11 Apr 2018 20:11:11 +0000 (UTC) From: John Ferlan To: libvir-list@redhat.com Date: Wed, 11 Apr 2018 16:10:02 -0400 Message-Id: <20180411201005.14749-8-jferlan@redhat.com> In-Reply-To: <20180411201005.14749-1-jferlan@redhat.com> References: <20180411201005.14749-1-jferlan@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 07/10] qemu: Add VM Generation ID device capability 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.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.29]); Wed, 11 Apr 2018 20:11:17 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Add the query of the device objects for the vmgenid device Signed-off-by: John Ferlan --- src/qemu/qemu_capabilities.c | 2 ++ src/qemu/qemu_capabilities.h | 1 + tests/qemucapabilitiesdata/caps_2.10.0.x86_64.xml | 1 + tests/qemucapabilitiesdata/caps_2.12.0.x86_64.xml | 1 + tests/qemucapabilitiesdata/caps_2.9.0.x86_64.xml | 1 + 5 files changed, 6 insertions(+) diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c index 91b7aa31ec..bd1d800098 100644 --- a/src/qemu/qemu_capabilities.c +++ b/src/qemu/qemu_capabilities.c @@ -468,6 +468,7 @@ VIR_ENUM_IMPL(virQEMUCaps, QEMU_CAPS_LAST, "virtio-tablet-ccw", "qcow2-luks", "pcie-pci-bridge", + "vmgenid", ); =20 =20 @@ -1104,6 +1105,7 @@ struct virQEMUCapsStringFlags virQEMUCapsObjectTypes[= ] =3D { { "virtio-mouse-ccw", QEMU_CAPS_DEVICE_VIRTIO_MOUSE_CCW }, { "virtio-tablet-ccw", QEMU_CAPS_DEVICE_VIRTIO_TABLET_CCW }, { "pcie-pci-bridge", QEMU_CAPS_DEVICE_PCIE_PCI_BRIDGE }, + { "vmgenid", QEMU_CAPS_DEVICE_VMGENID }, }; =20 static struct virQEMUCapsStringFlags virQEMUCapsObjectPropsVirtioBalloon[]= =3D { diff --git a/src/qemu/qemu_capabilities.h b/src/qemu/qemu_capabilities.h index bec28cae92..a562385b4f 100644 --- a/src/qemu/qemu_capabilities.h +++ b/src/qemu/qemu_capabilities.h @@ -452,6 +452,7 @@ typedef enum { QEMU_CAPS_DEVICE_VIRTIO_TABLET_CCW, /* -device virtio-tablet-ccw */ QEMU_CAPS_QCOW2_LUKS, /* qcow2 format support LUKS encryption */ QEMU_CAPS_DEVICE_PCIE_PCI_BRIDGE, /* -device pcie-pci-bridge */ + QEMU_CAPS_DEVICE_VMGENID, /* -device vmgenid */ =20 QEMU_CAPS_LAST /* this must always be the last item */ } virQEMUCapsFlags; diff --git a/tests/qemucapabilitiesdata/caps_2.10.0.x86_64.xml b/tests/qemu= capabilitiesdata/caps_2.10.0.x86_64.xml index 4dd5602014..35c16e400e 100644 --- a/tests/qemucapabilitiesdata/caps_2.10.0.x86_64.xml +++ b/tests/qemucapabilitiesdata/caps_2.10.0.x86_64.xml @@ -230,6 +230,7 @@ + 2010000 0 344938 diff --git a/tests/qemucapabilitiesdata/caps_2.12.0.x86_64.xml b/tests/qemu= capabilitiesdata/caps_2.12.0.x86_64.xml index 4ed2e1ea96..81515980b2 100644 --- a/tests/qemucapabilitiesdata/caps_2.12.0.x86_64.xml +++ b/tests/qemucapabilitiesdata/caps_2.12.0.x86_64.xml @@ -227,6 +227,7 @@ + 2011090 0 390060 diff --git a/tests/qemucapabilitiesdata/caps_2.9.0.x86_64.xml b/tests/qemuc= apabilitiesdata/caps_2.9.0.x86_64.xml index 13fc8c143f..972cee5f25 100644 --- a/tests/qemucapabilitiesdata/caps_2.9.0.x86_64.xml +++ b/tests/qemucapabilitiesdata/caps_2.9.0.x86_64.xml @@ -225,6 +225,7 @@ + 2009000 0 320947 --=20 2.13.6 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Thu Apr 25 12:24:34 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 1523477480198550.418928469838; Wed, 11 Apr 2018 13:11:20 -0700 (PDT) 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 D361930B8F91; Wed, 11 Apr 2018 20:11:18 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 9BFD46E6EF; Wed, 11 Apr 2018 20:11:18 +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 21D7E18033EB; Wed, 11 Apr 2018 20:11:18 +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 w3BKBGxh019384 for ; Wed, 11 Apr 2018 16:11:16 -0400 Received: by smtp.corp.redhat.com (Postfix) id D01CE65935; Wed, 11 Apr 2018 20:11:16 +0000 (UTC) Received: from unknown54ee7586bd10.attlocal.net.com (ovpn-116-52.phx2.redhat.com [10.3.116.52]) by smtp.corp.redhat.com (Postfix) with ESMTP id 8DD73895B3 for ; Wed, 11 Apr 2018 20:11:14 +0000 (UTC) From: John Ferlan To: libvir-list@redhat.com Date: Wed, 11 Apr 2018 16:10:03 -0400 Message-Id: <20180411201005.14749-9-jferlan@redhat.com> In-Reply-To: <20180411201005.14749-1-jferlan@redhat.com> References: <20180411201005.14749-1-jferlan@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 08/10] qemu: Handle genid processing during startup/launch 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.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.49]); Wed, 11 Apr 2018 20:11:19 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Before we generate the command line for qemu, if the domain about to be launched desires to utilize the VM Generation ID functionality, then handle both the regenerating the GUID value for backup recovery (restore operation) and the startup after snapshot as well as checking that the genid value that's about to be placed on the command line doesn't duplicate some other already running domain. Signed-off-by: John Ferlan --- src/qemu/qemu_driver.c | 22 +++++++--- src/qemu/qemu_process.c | 110 ++++++++++++++++++++++++++++++++++++++++++++= +++- src/qemu/qemu_process.h | 1 + 3 files changed, 126 insertions(+), 7 deletions(-) diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index 56ac64630f..c417680dac 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -6611,7 +6611,8 @@ qemuDomainSaveImageStartVM(virConnectPtr conn, if (qemuProcessStart(conn, driver, vm, cookie ? cookie->cpu : NULL, asyncJob, "stdio", *fd, path, NULL, VIR_NETDEV_VPORT_PROFILE_OP_RESTORE, - VIR_QEMU_PROCESS_START_PAUSED) =3D=3D 0) + VIR_QEMU_PROCESS_START_PAUSED | + VIR_QEMU_PROCESS_START_GEN_VMID) =3D=3D 0) restored =3D true; =20 if (intermediatefd !=3D -1) { @@ -15873,6 +15874,7 @@ qemuDomainRevertToSnapshot(virDomainSnapshotPtr sna= pshot, * the migratable XML or it will always fail otherwise */ if (config) { bool compatible; + bool abiflags =3D VIR_DOMAIN_DEF_ABI_CHECK_SKIP_GENID; =20 /* Replace the CPU in config and put the original one in p= riv * once we're done. When we have the updated CPU def in the @@ -15886,10 +15888,19 @@ qemuDomainRevertToSnapshot(virDomainSnapshotPtr s= napshot, goto endjob; =20 compatible =3D qemuDomainDefCheckABIStability(driver, = vm->def, - config, 0); + config, ab= iflags); } else { compatible =3D qemuDomainCheckABIStability(driver, vm,= config, - 0); + abiflags); + } + + /* If using VM GenID, there is no way currently to change + * the genid for the running guest, so set an error and + * mark as incompatible. */ + if (compatible && config->genidRequested) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("domain genid update requires restart= ")); + compatible =3D false; } =20 if (!compatible) { @@ -15972,7 +15983,8 @@ qemuDomainRevertToSnapshot(virDomainSnapshotPtr sna= pshot, cookie ? cookie->cpu : NULL, QEMU_ASYNC_JOB_START, NULL, -1, NULL, sn= ap, VIR_NETDEV_VPORT_PROFILE_OP_CREATE, - VIR_QEMU_PROCESS_START_PAUSED); + VIR_QEMU_PROCESS_START_PAUSED | + VIR_QEMU_PROCESS_START_GEN_VMID); virDomainAuditStart(vm, "from-snapshot", rc >=3D 0); detail =3D VIR_DOMAIN_EVENT_STARTED_FROM_SNAPSHOT; event =3D virDomainEventLifecycleNewFromObj(vm, @@ -16058,7 +16070,7 @@ qemuDomainRevertToSnapshot(virDomainSnapshotPtr sna= pshot, VIR_DOMAIN_SNAPSHOT_REVERT_PAUSED)) { /* Flush first event, now do transition 2 or 3 */ bool paused =3D (flags & VIR_DOMAIN_SNAPSHOT_REVERT_PAUSED) != =3D 0; - unsigned int start_flags =3D 0; + unsigned int start_flags =3D VIR_QEMU_PROCESS_START_GEN_VMID; =20 start_flags |=3D paused ? VIR_QEMU_PROCESS_START_PAUSED : 0; =20 diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c index f02114c693..20fcdf7f26 100644 --- a/src/qemu/qemu_process.c +++ b/src/qemu/qemu_process.c @@ -5882,6 +5882,107 @@ qemuProcessPrepareHost(virQEMUDriverPtr driver, =20 =20 /** + * qemuProcessCheckGenID: + * @vm: Domain to be checked + * @opaque: Domain about to be started + * + * For each running domain, let's make sure the domain to be started doesn= 't + * duplicate any running domain's genid GUID value + * + * Returns 0 on success, -1 on failure w/ error message set + */ +static int +qemuProcessCheckGenID(virDomainObjPtr vm, + void *opaque) +{ + int ret =3D 0; + virDomainObjPtr startvm =3D opaque; + + /* Ignore ourselves as we're already locked */ + if (vm =3D=3D startvm) + return 0; + + virObjectLock(vm); + + if (!virDomainObjIsActive(vm)) + goto cleanup; + + if (!vm->def->genidRequested) + goto cleanup; + + if (memcmp(startvm->def->genid, vm->def->genid, VIR_UUID_BUFLEN) =3D= =3D 0) { + /* For a generated value, just change it. Perhaps a result of + * not using virDomainDefCopy which generates a new genid when + * def->genidRequested is true. */ + if (startvm->def->genidGenerated) { + if (virUUIDGenerate(startvm->def->genid) < 0) { + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("failed to regenerate genid")); + ret =3D -1; + } + } else { + char guidstr[VIR_UUID_STRING_BUFLEN]; + + virUUIDFormat(startvm->def->genid, guidstr); + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("domain '%s' already running with genid '%s'"= ), + vm->def->name, guidstr); + ret =3D -1; + } + goto cleanup; + } + + cleanup: + virObjectUnlock(vm); + return ret; +} + + +/** + * qemuProcessGenID: + * @driver: Pointer to driver + * @vm: Pointer to domain object + * @flags: qemuProcessStartFlags + * + * If this domain is requesting to use genid + */ +static int +qemuProcessGenID(virQEMUDriverPtr driver, + virDomainObjPtr vm, + unsigned int flags) +{ + qemuDomainObjPrivatePtr priv =3D vm->privateData; + + if (!vm->def->genidRequested) + return 0; + + if (!virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_DEVICE_VMGENID)) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("this QEMU does not support the 'genid' capability= ")); + return -1; + } + + /* If we are coming from a path where we must provide a new gen id + * value regardless of whether it was previously generated or provided, + * then generate a new GUID value before we build the command line. */ + if (flags & VIR_QEMU_PROCESS_START_GEN_VMID) { + if (virUUIDGenerate(vm->def->genid)) { + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("failed to regenerate genid")); + return -1; + } + } + + /* Now let's make sure the genid this domain has is not duplicitous + * with something else running. */ + if (virDomainObjListForEach(driver->domains, qemuProcessCheckGenID, vm= ) < 0) + return -1; + + return 0; +} + + +/** * qemuProcessLaunch: * * Launch a new QEMU process with stopped virtual CPUs. @@ -5933,7 +6034,8 @@ qemuProcessLaunch(virConnectPtr conn, virCheckFlags(VIR_QEMU_PROCESS_START_COLD | VIR_QEMU_PROCESS_START_PAUSED | VIR_QEMU_PROCESS_START_AUTODESTROY | - VIR_QEMU_PROCESS_START_NEW, -1); + VIR_QEMU_PROCESS_START_NEW | + VIR_QEMU_PROCESS_START_GEN_VMID, -1); =20 cfg =3D virQEMUDriverGetConfig(driver); =20 @@ -5957,6 +6059,9 @@ qemuProcessLaunch(virConnectPtr conn, goto cleanup; logfile =3D qemuDomainLogContextGetWriteFD(logCtxt); =20 + if (qemuProcessGenID(driver, vm, flags) < 0) + goto cleanup; + VIR_DEBUG("Building emulator command line"); if (!(cmd =3D qemuBuildCommandLine(driver, qemuDomainLogContextGetManager(logCtx= t), @@ -6317,7 +6422,8 @@ qemuProcessStart(virConnectPtr conn, =20 virCheckFlagsGoto(VIR_QEMU_PROCESS_START_COLD | VIR_QEMU_PROCESS_START_PAUSED | - VIR_QEMU_PROCESS_START_AUTODESTROY, cleanup); + VIR_QEMU_PROCESS_START_AUTODESTROY | + VIR_QEMU_PROCESS_START_GEN_VMID, cleanup); =20 if (!migrateFrom && !snapshot) flags |=3D VIR_QEMU_PROCESS_START_NEW; diff --git a/src/qemu/qemu_process.h b/src/qemu/qemu_process.h index 2741115673..30a73ff3f1 100644 --- a/src/qemu/qemu_process.h +++ b/src/qemu/qemu_process.h @@ -78,6 +78,7 @@ typedef enum { VIR_QEMU_PROCESS_START_AUTODESTROY =3D 1 << 2, VIR_QEMU_PROCESS_START_PRETEND =3D 1 << 3, VIR_QEMU_PROCESS_START_NEW =3D 1 << 4, /* internal, new VM is= starting */ + VIR_QEMU_PROCESS_START_GEN_VMID =3D 1 << 5, /* Generate a new VMID= */ } qemuProcessStartFlags; =20 int qemuProcessStart(virConnectPtr conn, --=20 2.13.6 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Thu Apr 25 12:24:34 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 1523477493581659.0077234651486; Wed, 11 Apr 2018 13:11:33 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 0BB4D81DE6; Wed, 11 Apr 2018 20:11:32 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id D8AA1189BF; Wed, 11 Apr 2018 20:11:31 +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 9D53718033EB; Wed, 11 Apr 2018 20:11:31 +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 w3BKBUrQ019671 for ; Wed, 11 Apr 2018 16:11:30 -0400 Received: by smtp.corp.redhat.com (Postfix) id 6458665935; Wed, 11 Apr 2018 20:11:30 +0000 (UTC) Received: from unknown54ee7586bd10.attlocal.net.com (ovpn-116-52.phx2.redhat.com [10.3.116.52]) by smtp.corp.redhat.com (Postfix) with ESMTP id 223277C254 for ; Wed, 11 Apr 2018 20:11:16 +0000 (UTC) From: John Ferlan To: libvir-list@redhat.com Date: Wed, 11 Apr 2018 16:10:04 -0400 Message-Id: <20180411201005.14749-10-jferlan@redhat.com> In-Reply-To: <20180411201005.14749-1-jferlan@redhat.com> References: <20180411201005.14749-1-jferlan@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 09/10] qemu: Add VM Generation ID to qemu command line 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.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]); Wed, 11 Apr 2018 20:11:32 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" https://bugzilla.redhat.com/show_bug.cgi?id=3D1149445 If the domain requests usage of the genid functionality, then add the QEMU '-device vmgenid' to the command line providing either the supplied or generated GUID value. Add tests for both a generated and supplied GUID value. Signed-off-by: John Ferlan --- src/qemu/qemu_command.c | 31 +++++++++++++++++++++++++++++++ tests/qemuxml2argvdata/genid-auto.args | 21 +++++++++++++++++++++ tests/qemuxml2argvdata/genid.args | 21 +++++++++++++++++++++ tests/qemuxml2argvtest.c | 4 ++++ 4 files changed, 77 insertions(+) create mode 100644 tests/qemuxml2argvdata/genid-auto.args create mode 100644 tests/qemuxml2argvdata/genid.args diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index 955134d019..3b43cd4b56 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -6023,6 +6023,34 @@ qemuBuildSmbiosCommandLine(virCommandPtr cmd, =20 =20 static int +qemuBuildVMGenIDCommandLine(virCommandPtr cmd, + const virDomainDef *def, + virQEMUCapsPtr qemuCaps) +{ + virBuffer opts =3D VIR_BUFFER_INITIALIZER; + char guid[VIR_UUID_STRING_BUFLEN]; + + if (!def->genidRequested) + return 0; + + if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE_VMGENID)) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("genid is not supported with this QEMU binary")); + return -1; + } + + virUUIDFormat(def->genid, guid); + virBufferAsprintf(&opts, "vmgenid,guid=3D%s,id=3Dvmgenid0", guid); + + virCommandAddArg(cmd, "-device"); + virCommandAddArgBuffer(cmd, &opts); + + virBufferFreeAndReset(&opts); + return 0; +} + + +static int qemuBuildSgaCommandLine(virCommandPtr cmd, const virDomainDef *def, virQEMUCapsPtr qemuCaps) @@ -10078,6 +10106,9 @@ qemuBuildCommandLine(virQEMUDriverPtr driver, if (qemuBuildSmbiosCommandLine(cmd, driver, def, qemuCaps) < 0) goto error; =20 + if (qemuBuildVMGenIDCommandLine(cmd, def, qemuCaps) < 0) + goto error; + /* * NB, -nographic *MUST* come before any serial, or monitor * or parallel port flags due to QEMU craziness, where it diff --git a/tests/qemuxml2argvdata/genid-auto.args b/tests/qemuxml2argvdat= a/genid-auto.args new file mode 100644 index 0000000000..980cc077b9 --- /dev/null +++ b/tests/qemuxml2argvdata/genid-auto.args @@ -0,0 +1,21 @@ +LC_ALL=3DC \ +PATH=3D/bin \ +HOME=3D/home/test \ +USER=3Dtest \ +LOGNAME=3Dtest \ +QEMU_AUDIO_DRV=3Dnone \ +/usr/bin/qemu-system-x86_64 \ +-name QEMUGuest1 \ +-S \ +-M pc \ +-m 214 \ +-smp 1,sockets=3D1,cores=3D1,threads=3D1 \ +-uuid c7a5fdbd-edaf-9455-926a-d65c16db1809 \ +-device vmgenid,guid=3D00010203-0405-4607-8809-0a0b0c0d0e0f,id=3Dvmgenid0 \ +-nographic \ +-nodefaults \ +-chardev socket,id=3Dcharmonitor,path=3D/tmp/lib/domain--1-QEMUGuest1/moni= tor.sock,\ +server,nowait \ +-mon chardev=3Dcharmonitor,id=3Dmonitor,mode=3Dreadline \ +-boot c \ +-usb diff --git a/tests/qemuxml2argvdata/genid.args b/tests/qemuxml2argvdata/gen= id.args new file mode 100644 index 0000000000..0d5dfde98f --- /dev/null +++ b/tests/qemuxml2argvdata/genid.args @@ -0,0 +1,21 @@ +LC_ALL=3DC \ +PATH=3D/bin \ +HOME=3D/home/test \ +USER=3Dtest \ +LOGNAME=3Dtest \ +QEMU_AUDIO_DRV=3Dnone \ +/usr/bin/qemu-system-x86_64 \ +-name QEMUGuest1 \ +-S \ +-M pc \ +-m 214 \ +-smp 1,sockets=3D1,cores=3D1,threads=3D1 \ +-uuid c7a5fdbd-edaf-9455-926a-d65c16db1809 \ +-device vmgenid,guid=3De9392370-2917-565e-692b-d057f46512d6,id=3Dvmgenid0 \ +-nographic \ +-nodefaults \ +-chardev socket,id=3Dcharmonitor,path=3D/tmp/lib/domain--1-QEMUGuest1/moni= tor.sock,\ +server,nowait \ +-mon chardev=3Dcharmonitor,id=3Dmonitor,mode=3Dreadline \ +-boot c \ +-usb diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c index 3a328e02a2..343d8eb221 100644 --- a/tests/qemuxml2argvtest.c +++ b/tests/qemuxml2argvtest.c @@ -731,6 +731,10 @@ mymain(void) DO_TEST("minimal", NONE); DO_TEST_PARSE_ERROR("minimal-no-memory", NONE); DO_TEST("minimal-msg-timestamp", QEMU_CAPS_MSG_TIMESTAMP); + + DO_TEST("genid", QEMU_CAPS_DEVICE_VMGENID); + DO_TEST("genid-auto", QEMU_CAPS_DEVICE_VMGENID); + DO_TEST("machine-aliases1", NONE); DO_TEST("machine-aliases2", QEMU_CAPS_KVM); DO_TEST("machine-core-on", QEMU_CAPS_MACHINE_OPT, --=20 2.13.6 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Thu Apr 25 12:24:34 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 1523477501049414.7746898619953; Wed, 11 Apr 2018 13:11:41 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 89442313065E; Wed, 11 Apr 2018 20:11:39 +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 42819189F3; Wed, 11 Apr 2018 20:11:39 +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 EC8624CAA5; Wed, 11 Apr 2018 20:11:38 +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 w3BKBcP3019707 for ; Wed, 11 Apr 2018 16:11:38 -0400 Received: by smtp.corp.redhat.com (Postfix) id 0B53165935; Wed, 11 Apr 2018 20:11:38 +0000 (UTC) Received: from unknown54ee7586bd10.attlocal.net.com (ovpn-116-52.phx2.redhat.com [10.3.116.52]) by smtp.corp.redhat.com (Postfix) with ESMTP id B932965928 for ; Wed, 11 Apr 2018 20:11:30 +0000 (UTC) From: John Ferlan To: libvir-list@redhat.com Date: Wed, 11 Apr 2018 16:10:05 -0400 Message-Id: <20180411201005.14749-11-jferlan@redhat.com> In-Reply-To: <20180411201005.14749-1-jferlan@redhat.com> References: <20180411201005.14749-1-jferlan@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 10/10] docs: Add news article for VM Generation ID 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.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.47]); Wed, 11 Apr 2018 20:11:39 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Signed-off-by: John Ferlan --- docs/news.xml | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/docs/news.xml b/docs/news.xml index 798ab6da40..8246ef0509 100644 --- a/docs/news.xml +++ b/docs/news.xml @@ -44,6 +44,18 @@ add this controller when traditional PCI devices are in use. + + + Add support for VM Generation ID + + + The VM Generatation ID exposes a 128-bit, cryptographically + random, integer value identifier, referred to as a Globally + Unique Identifier (GUID) to the guest in order to notify the + guest operating system when the virtual machine is executed + with a different configuration. + +
--=20 2.13.6 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list