From nobody Wed Dec 17 04:16:59 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; 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 1524528074364644.2688180573499; Mon, 23 Apr 2018 17:01:14 -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 65B69BDD4; Tue, 24 Apr 2018 00:01: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 11DDF74952; Tue, 24 Apr 2018 00:01:12 +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 6F7F94CAA9; Tue, 24 Apr 2018 00:01:11 +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 w3O00bNe001156 for ; Mon, 23 Apr 2018 20:00:37 -0400 Received: by smtp.corp.redhat.com (Postfix) id A1CD518A67; Tue, 24 Apr 2018 00:00:37 +0000 (UTC) Received: from unknown54ee7586bd10.attlocal.net.com (ovpn-116-64.phx2.redhat.com [10.3.116.64]) by smtp.corp.redhat.com (Postfix) with ESMTP id 5FF1218A55 for ; Tue, 24 Apr 2018 00:00:37 +0000 (UTC) From: John Ferlan To: libvir-list@redhat.com Date: Mon, 23 Apr 2018 19:59:59 -0400 Message-Id: <20180424000005.689-6-jferlan@redhat.com> In-Reply-To: <20180424000005.689-1-jferlan@redhat.com> References: <20180424000005.689-1-jferlan@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH v2 05/11] 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.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.29]); Tue, 24 Apr 2018 00:01:13 +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 1411034e7c..6d4db50998 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -27909,6 +27909,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 1b61fd8c03..910b3ca4d1 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -2875,6 +2875,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 61e49bea24..bfb7973100 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -15858,7 +15858,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 8877a467f6..7bac017e1a 100644 --- a/src/test/test_driver.c +++ b/src/test/test_driver.c @@ -6690,7 +6690,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