From nobody Fri Apr 19 20:46:42 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 ARC-Seal: i=1; a=rsa-sha256; t=1557354264; cv=none; d=zoho.com; s=zohoarc; b=Xy9XsWKUoQ3nsZG/IAB2lwPUev5VxG6hxCi06FqEoyes0ckkl+1ydUv0n2xESdOBCti/tADWVji/+rbLQrWusjNfCFLIWpH1nF/uaQ/lRFUiwpFLBqwsA+YvuMMENrUyG7CSbIHuSDH1ueGkPfGV8HOVxW01cfB0VuMwCFV/ch0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1557354264; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=oxUbwviBOVzp5Zizy5K05hDSMe4L48QM3Q99YGyVHfY=; b=BmEAQ//Q2ZmHS72duZq4bsmD+aLyzv7ccUQRVytgkysDR/U0dsBzk2c6KniOz/SOMkfBXyiPEv5I5PwlMsIfKCxG7pQXh6EIso5JnNzojwUNTJw1OnnDrGfbWdzXJ33dgTHFcooIP0pD3PztsWwRSjzTxaCxjTiakvuyFJXR7fM= ARC-Authentication-Results: i=1; mx.zoho.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 header.from= (p=none dis=none) header.from= Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1557354264220316.1302481643878; Wed, 8 May 2019 15:24:24 -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 1279D30018C0; Wed, 8 May 2019 22:24:22 +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 4BA71600CC; Wed, 8 May 2019 22:24:20 +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 7E3DC18089CB; Wed, 8 May 2019 22:24:17 +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 x48MOFta021444 for ; Wed, 8 May 2019 18:24:15 -0400 Received: by smtp.corp.redhat.com (Postfix) id BC8CC60C98; Wed, 8 May 2019 22:24:15 +0000 (UTC) Received: from blue.redhat.com (ovpn-116-15.phx2.redhat.com [10.3.116.15]) by smtp.corp.redhat.com (Postfix) with ESMTP id 6E95860C93 for ; Wed, 8 May 2019 22:24:15 +0000 (UTC) From: Eric Blake To: libvir-list@redhat.com Date: Wed, 8 May 2019 17:24:09 -0500 Message-Id: <20190508222412.11811-2-eblake@redhat.com> In-Reply-To: <20190508222412.11811-1-eblake@redhat.com> References: <20190508222412.11811-1-eblake@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 1/4] snapshot: s/parent/parent_name/ as prep for virObject 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.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.46]); Wed, 08 May 2019 22:24:22 +0000 (UTC) Content-Type: text/plain; charset="utf-8" VIR_CLASS_NEW insists that descendents of virObject have 'parent' as the name of their inherited member at offset 0. While it would be possible to write a new class-creation macro that takes the actual field name, and rewrite VIR_CLASS_NEW to call the new macro with the hard-coded name 'parent', so that we could make virDomainMomentDef use a custom name for its base class, it seems less confusing if all object code uses similar naming. Thus, this is a mechanical rename in preparation of making virDomainSnapshotDef a descendent of virObject, when we can no longer use 'parent' for a different purpose than the base class. Signed-off-by: Eric Blake --- src/conf/moment_conf.h | 2 +- src/conf/moment_conf.c | 2 +- src/conf/snapshot_conf.c | 22 ++++++++++++---------- src/conf/virdomainmomentobjlist.c | 4 ++-- src/esx/esx_driver.c | 2 +- src/qemu/qemu_domain.c | 8 ++++---- src/qemu/qemu_driver.c | 12 ++++++------ src/test/test_driver.c | 18 +++++++++--------- src/vbox/vbox_common.c | 14 +++++++------- src/vz/vz_sdk.c | 2 +- 10 files changed, 44 insertions(+), 42 deletions(-) diff --git a/src/conf/moment_conf.h b/src/conf/moment_conf.h index e06a4a7b3c..04e0c0648b 100644 --- a/src/conf/moment_conf.h +++ b/src/conf/moment_conf.h @@ -31,7 +31,7 @@ struct _virDomainMomentDef { /* Common portion of public XML. */ char *name; char *description; - char *parent; + char *parent_name; long long creationTime; /* in seconds */ virDomainDefPtr dom; diff --git a/src/conf/moment_conf.c b/src/conf/moment_conf.c index 0eb32eeb52..9829775b3c 100644 --- a/src/conf/moment_conf.c +++ b/src/conf/moment_conf.c @@ -38,7 +38,7 @@ void virDomainMomentDefClear(virDomainMomentDefPtr def) { VIR_FREE(def->name); VIR_FREE(def->description); - VIR_FREE(def->parent); + VIR_FREE(def->parent_name); virDomainDefFree(def->dom); } diff --git a/src/conf/snapshot_conf.c b/src/conf/snapshot_conf.c index eaa9b3c5e6..b571c5cc41 100644 --- a/src/conf/snapshot_conf.c +++ b/src/conf/snapshot_conf.c @@ -227,7 +227,7 @@ virDomainSnapshotDefParse(xmlXPathContextPtr ctxt, goto cleanup; } - def->common.parent =3D virXPathString("string(./parent/name)", ctx= t); + def->common.parent_name =3D virXPathString("string(./parent/name)"= , ctxt); state =3D virXPathString("string(./state)", ctxt); if (state =3D=3D NULL) { @@ -809,10 +809,11 @@ virDomainSnapshotDefFormatInternal(virBufferPtr buf, virBufferAsprintf(buf, "%s\n", virDomainSnapshotStateTypeToString(def->state)); - if (def->common.parent) { + if (def->common.parent_name) { virBufferAddLit(buf, "\n"); virBufferAdjustIndent(buf, 2); - virBufferEscapeString(buf, "%s\n", def->common.parent= ); + virBufferEscapeString(buf, "%s\n", + def->common.parent_name); virBufferAdjustIndent(buf, -2); virBufferAddLit(buf, "\n"); } @@ -932,30 +933,31 @@ virDomainSnapshotRedefinePrep(virDomainPtr domain, bool check_if_stolen; /* Prevent circular chains */ - if (def->common.parent) { - if (STREQ(def->common.name, def->common.parent)) { + if (def->common.parent_name) { + if (STREQ(def->common.name, def->common.parent_name)) { virReportError(VIR_ERR_INVALID_ARG, _("cannot set snapshot %s as its own parent"), def->common.name); return -1; } - other =3D virDomainSnapshotFindByName(vm->snapshots, def->common.p= arent); + other =3D virDomainSnapshotFindByName(vm->snapshots, + def->common.parent_name); if (!other) { virReportError(VIR_ERR_INVALID_ARG, _("parent %s for snapshot %s not found"), - def->common.parent, def->common.name); + def->common.parent_name, def->common.name); return -1; } otherdef =3D virDomainSnapshotObjGetDef(other); - while (otherdef->common.parent) { - if (STREQ(otherdef->common.parent, def->common.name)) { + while (otherdef->common.parent_name) { + if (STREQ(otherdef->common.parent_name, def->common.name)) { virReportError(VIR_ERR_INVALID_ARG, _("parent %s would create cycle to %s"), otherdef->common.name, def->common.name); return -1; } other =3D virDomainSnapshotFindByName(vm->snapshots, - otherdef->common.parent); + otherdef->common.parent_na= me); if (!other) { VIR_WARN("snapshots are inconsistent for %s", vm->def->name); diff --git a/src/conf/virdomainmomentobjlist.c b/src/conf/virdomainmomentob= jlist.c index 7f90632a53..e9df66c65b 100644 --- a/src/conf/virdomainmomentobjlist.c +++ b/src/conf/virdomainmomentobjlist.c @@ -464,7 +464,7 @@ virDomainMomentForEach(virDomainMomentObjListPtr moment= s, /* Struct and callback function used as a hash table callback; each call - * inspects the pre-existing moment->def->parent field, and adjusts + * inspects the pre-existing moment->def->parent_name field, and adjusts * the moment->parent field as well as the parent's child fields to * wire up the hierarchical relations for the given moment. The error * indicator gets set if a parent is missing or a requested parent would @@ -483,7 +483,7 @@ virDomainMomentSetRelations(void *payload, virDomainMomentObjPtr tmp; virDomainMomentObjPtr parent; - parent =3D virDomainMomentFindByName(curr->moments, obj->def->parent); + parent =3D virDomainMomentFindByName(curr->moments, obj->def->parent_n= ame); if (!parent) { curr->err =3D -1; parent =3D &curr->moments->metaroot; diff --git a/src/esx/esx_driver.c b/src/esx/esx_driver.c index d80fef0a58..dff801f946 100644 --- a/src/esx/esx_driver.c +++ b/src/esx/esx_driver.c @@ -4191,7 +4191,7 @@ esxDomainSnapshotGetXMLDesc(virDomainSnapshotPtr snap= shot, def.common.name =3D snapshot->name; def.common.description =3D snapshotTree->description; - def.common.parent =3D snapshotTreeParent ? snapshotTreeParent->name : = NULL; + def.common.parent_name =3D snapshotTreeParent ? snapshotTreeParent->na= me : NULL; if (esxVI_DateTime_ConvertToCalendarTime(snapshotTree->createTime, &def.common.creationTime) < 0= ) { diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index db67fe2193..6b16da2998 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -8606,19 +8606,19 @@ qemuDomainSnapshotDiscard(virQEMUDriverPtr driver, if (snap =3D=3D virDomainSnapshotGetCurrent(vm->snapshots)) { virDomainSnapshotSetCurrent(vm->snapshots, NULL); - if (update_parent && snap->def->parent) { + if (update_parent && snap->def->parent_name) { parentsnap =3D virDomainSnapshotFindByName(vm->snapshots, - snap->def->parent); + snap->def->parent_nam= e); if (!parentsnap) { VIR_WARN("missing parent snapshot matching name '%s'", - snap->def->parent); + snap->def->parent_name); } else { virDomainSnapshotSetCurrent(vm->snapshots, parentsnap); if (qemuDomainSnapshotWriteMetadata(vm, parentsnap, driver= ->caps, driver->xmlopt, cfg->snapshotDir) < 0)= { VIR_WARN("failed to set parent snapshot '%s' as curren= t", - snap->def->parent); + snap->def->parent_name); virDomainSnapshotSetCurrent(vm->snapshots, NULL); } } diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index 27be173e46..c12b3dff6c 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -15752,7 +15752,7 @@ qemuDomainSnapshotCreateXML(virDomainPtr domain, current =3D virDomainSnapshotGetCurrent(vm->snapshots); if (current) { if (!redefine && - VIR_STRDUP(snap->def->parent, current->def->name) < 0) + VIR_STRDUP(snap->def->parent_name, current->def->name) < 0) goto endjob; if (update_current) { virDomainSnapshotSetCurrent(vm->snapshots, NULL); @@ -15820,7 +15820,7 @@ qemuDomainSnapshotCreateXML(virDomainPtr domain, virDomainSnapshotObjListRemove(vm->snapshots, snap); } else { other =3D virDomainSnapshotFindByName(vm->snapshots, - snap->def->parent); + snap->def->parent_name); virDomainMomentSetParent(snap, other); } } else if (snap) { @@ -16080,14 +16080,14 @@ qemuDomainSnapshotGetParent(virDomainSnapshotPtr = snapshot, if (!(snap =3D qemuSnapObjFromSnapshot(vm, snapshot))) goto cleanup; - if (!snap->def->parent) { + if (!snap->def->parent_name) { virReportError(VIR_ERR_NO_DOMAIN_SNAPSHOT, _("snapshot '%s' does not have a parent"), snap->def->name); goto cleanup; } - parent =3D virGetDomainSnapshot(snapshot->domain, snap->def->parent); + parent =3D virGetDomainSnapshot(snapshot->domain, snap->def->parent_na= me); cleanup: virDomainObjEndAPI(&vm); @@ -16668,10 +16668,10 @@ qemuDomainMomentReparentChildren(void *payload, if (rep->err < 0) return 0; - VIR_FREE(moment->def->parent); + VIR_FREE(moment->def->parent_name); if (rep->parent->def && - VIR_STRDUP(moment->def->parent, rep->parent->def->name) < 0) { + VIR_STRDUP(moment->def->parent_name, rep->parent->def->name) < 0) { rep->err =3D -1; return 0; } diff --git a/src/test/test_driver.c b/src/test/test_driver.c index 460c896ef6..626167f947 100644 --- a/src/test/test_driver.c +++ b/src/test/test_driver.c @@ -6195,14 +6195,14 @@ testDomainSnapshotGetParent(virDomainSnapshotPtr sn= apshot, if (!(snap =3D testSnapObjFromSnapshot(vm, snapshot))) goto cleanup; - if (!snap->def->parent) { + if (!snap->def->parent_name) { virReportError(VIR_ERR_NO_DOMAIN_SNAPSHOT, _("snapshot '%s' does not have a parent"), snap->def->name); goto cleanup; } - parent =3D virGetDomainSnapshot(snapshot->domain, snap->def->parent); + parent =3D virGetDomainSnapshot(snapshot->domain, snap->def->parent_na= me); cleanup: virDomainObjEndAPI(&vm); @@ -6421,7 +6421,7 @@ testDomainSnapshotCreateXML(virDomainPtr domain, } if (!redefine) { - if (VIR_STRDUP(snap->def->parent, + if (VIR_STRDUP(snap->def->parent_name, virDomainSnapshotGetCurrentName(vm->snapshots)) < 0) goto cleanup; @@ -6442,7 +6442,7 @@ testDomainSnapshotCreateXML(virDomainPtr domain, if (update_current) virDomainSnapshotSetCurrent(vm->snapshots, snap); other =3D virDomainSnapshotFindByName(vm->snapshots, - snap->def->parent); + snap->def->parent_name); virDomainMomentSetParent(snap, other); } virDomainObjEndAPI(&vm); @@ -6491,10 +6491,10 @@ testDomainSnapshotReparentChildren(void *payload, if (rep->err < 0) return 0; - VIR_FREE(snap->def->parent); + VIR_FREE(snap->def->parent_name); if (rep->parent->def && - VIR_STRDUP(snap->def->parent, rep->parent->def->name) < 0) { + VIR_STRDUP(snap->def->parent_name, rep->parent->def->name) < 0) { rep->err =3D -1; return 0; } @@ -6549,12 +6549,12 @@ testDomainSnapshotDelete(virDomainSnapshotPtr snaps= hot, } else { virDomainMomentDropParent(snap); if (snap =3D=3D virDomainSnapshotGetCurrent(vm->snapshots)) { - if (snap->def->parent) { + if (snap->def->parent_name) { parentsnap =3D virDomainSnapshotFindByName(vm->snapshots, - snap->def->parent= ); + snap->def->parent= _name); if (!parentsnap) VIR_WARN("missing parent snapshot matching name '%s'", - snap->def->parent); + snap->def->parent_name); } virDomainSnapshotSetCurrent(vm->snapshots, parentsnap); } diff --git a/src/vbox/vbox_common.c b/src/vbox/vbox_common.c index 7a491b0b5f..94830f5ddb 100644 --- a/src/vbox/vbox_common.c +++ b/src/vbox/vbox_common.c @@ -5061,7 +5061,7 @@ vboxSnapshotRedefine(virDomainPtr dom, VIR_FREE(tmp); } - if (virVBoxSnapshotConfAddSnapshotToXmlMachine(newSnapshotPtr, snapsho= tMachineDesc, def->common.parent) < 0) { + if (virVBoxSnapshotConfAddSnapshotToXmlMachine(newSnapshotPtr, snapsho= tMachineDesc, def->common.parent_name) < 0) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("Unable to add the snapshot to the machine descri= ption")); goto cleanup; @@ -6305,7 +6305,7 @@ static char *vboxDomainSnapshotGetXMLDesc(virDomainSn= apshotPtr snapshot, } VBOX_UTF16_TO_UTF8(str16, &str8); VBOX_UTF16_FREE(str16); - if (VIR_STRDUP(def->common.parent, str8) < 0) { + if (VIR_STRDUP(def->common.parent_name, str8) < 0) { VBOX_UTF8_FREE(str8); goto cleanup; } @@ -6999,7 +6999,7 @@ vboxDomainSnapshotDeleteMetadataOnly(virDomainSnapsho= tPtr snapshot) * disks. The first thing to do is to manipulate VirtualBox API to= create * differential read-write disks if the parent snapshot is not nul= l. */ - if (def->common.parent !=3D NULL) { + if (def->common.parent_name !=3D NULL) { for (it =3D 0; it < def->common.dom->ndisks; it++) { virVBoxSnapshotConfHardDiskPtr readOnly =3D NULL; IMedium *medium =3D NULL; @@ -7058,7 +7058,7 @@ vboxDomainSnapshotDeleteMetadataOnly(virDomainSnapsho= tPtr snapshot) VBOX_UTF8_TO_UTF16("VDI", &formatUtf16); if (virAsprintf(&newLocationUtf8, "%sfakedisk-%s-%d.vdi", - machineLocationPath, def->common.parent, i= t) < 0) + machineLocationPath, def->common.parent_na= me, it) < 0) goto cleanup; VBOX_UTF8_TO_UTF16(newLocationUtf8, &newLocation); rc =3D gVBoxAPI.UIVirtualBox.CreateHardDisk(data->vboxObj, @@ -7209,7 +7209,7 @@ vboxDomainSnapshotDeleteMetadataOnly(virDomainSnapsho= tPtr snapshot) } } /*If the parent snapshot is not NULL, we remove the-read only disks fr= om the media registry*/ - if (def->common.parent !=3D NULL) { + if (def->common.parent_name !=3D NULL) { for (it =3D 0; it < def->common.dom->ndisks; it++) { const char *uuidRO =3D virVBoxSnapshotConfHardDiskUuidByLocation(snapshotMachineD= esc, @@ -7289,8 +7289,8 @@ vboxDomainSnapshotDeleteMetadataOnly(virDomainSnapsho= tPtr snapshot) if (isCurrent) { VIR_FREE(snapshotMachineDesc->currentSnapshot); - if (def->common.parent !=3D NULL) { - virVBoxSnapshotConfSnapshotPtr snap =3D virVBoxSnapshotConfSna= pshotByName(snapshotMachineDesc->snapshot, def->common.parent); + if (def->common.parent_name !=3D NULL) { + virVBoxSnapshotConfSnapshotPtr snap =3D virVBoxSnapshotConfSna= pshotByName(snapshotMachineDesc->snapshot, def->common.parent_name); if (!snap) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("Unable to get the snapshot to remove")); diff --git a/src/vz/vz_sdk.c b/src/vz/vz_sdk.c index 73d5c89c08..500de5f8ba 100644 --- a/src/vz/vz_sdk.c +++ b/src/vz/vz_sdk.c @@ -4703,7 +4703,7 @@ prlsdkParseSnapshotTree(const char *treexml) goto cleanup; } - def->common.parent =3D virXPathString("string(../@guid)", ctxt); + def->common.parent_name =3D virXPathString("string(../@guid)", ctx= t); xmlstr =3D virXPathString("string(./DateTime)", ctxt); if (!xmlstr) { --=20 2.20.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Fri Apr 19 20:46:42 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 ARC-Seal: i=1; a=rsa-sha256; t=1557354303; cv=none; d=zoho.com; s=zohoarc; b=NSuyHYFv0duVLjkID/lMFQzmDbAMVYp6hAfYWnMfHHljSeftUvmRpsovdpg4PD7sd2VfiV9TPZZ9XEp0xxkxxEIcaGtyXF4e6TknQRwpVbGaWPSJ+/3wEkQ1MG49YS24M5fxiMAiG8v91NKM2mx80RvUoy0+iK8cIe0kVUyHQOc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1557354303; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=zdYfN+SogwE4VtQM8EoYj594n67THGq/G7ZZ8ob+ucU=; b=iuAOUjr4124CWDsaciUxfF12tb1Xq0PVx43AGLRjEa0GbDNfkaLy9pZnnwaLUGqEtH1Wx7eEmhsqGljsue1Bui+vs4b+82hZtHH6lvpzrY/n5dj+95/gn/1ZWVuUPsKUrPQMxh8y81sp4B8ltved6gn+BcxG2hCxcp1GkwZv6RM= ARC-Authentication-Results: i=1; mx.zoho.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 header.from= (p=none dis=none) header.from= Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1557354303350985.7661846318698; Wed, 8 May 2019 15:25:03 -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 D94AC309B171; Wed, 8 May 2019 22:25:00 +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 AFC2D5C269; Wed, 8 May 2019 22:25:00 +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 67B1E41F3C; Wed, 8 May 2019 22:25:00 +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 x48MOG0X021454 for ; Wed, 8 May 2019 18:24:16 -0400 Received: by smtp.corp.redhat.com (Postfix) id 42F8960C93; Wed, 8 May 2019 22:24:16 +0000 (UTC) Received: from blue.redhat.com (ovpn-116-15.phx2.redhat.com [10.3.116.15]) by smtp.corp.redhat.com (Postfix) with ESMTP id DFDA060C6F for ; Wed, 8 May 2019 22:24:15 +0000 (UTC) From: Eric Blake To: libvir-list@redhat.com Date: Wed, 8 May 2019 17:24:10 -0500 Message-Id: <20190508222412.11811-3-eblake@redhat.com> In-Reply-To: <20190508222412.11811-1-eblake@redhat.com> References: <20190508222412.11811-1-eblake@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 2/4] snapshot: s/current/parent/ as prep for virObject 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.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.49]); Wed, 08 May 2019 22:25:01 +0000 (UTC) Content-Type: text/plain; charset="utf-8" VIR_CLASS_NEW insists that descendents of virObject have 'parent' as the name of their inherited member at offset 0. While it would be possible to write a new class-creation macro that takes the actual field name 'current', and rewrite VIR_CLASS_NEW to call the new macro with the hard-coded name 'parent', it seems less confusing if all object code uses similar naming. Thus, this is a mechanical rename in preparation of making virDomainSnapshotDef a descendent of virObject. Signed-off-by: Eric Blake --- src/conf/snapshot_conf.h | 2 +- src/conf/snapshot_conf.c | 120 ++++++++++++++-------------- src/conf/virdomainsnapshotobjlist.c | 2 +- src/esx/esx_driver.c | 16 ++-- src/qemu/qemu_domain.c | 2 +- src/qemu/qemu_driver.c | 12 +-- src/test/test_driver.c | 2 +- src/vbox/vbox_common.c | 88 ++++++++++---------- src/vz/vz_driver.c | 2 +- src/vz/vz_sdk.c | 10 +-- 10 files changed, 128 insertions(+), 128 deletions(-) diff --git a/src/conf/snapshot_conf.h b/src/conf/snapshot_conf.h index 5a762ccd96..f54be11619 100644 --- a/src/conf/snapshot_conf.h +++ b/src/conf/snapshot_conf.h @@ -74,7 +74,7 @@ struct _virDomainSnapshotDiskDef { /* Stores the complete snapshot metadata */ struct _virDomainSnapshotDef { - virDomainMomentDef common; + virDomainMomentDef parent; /* Additional public XML. */ int state; /* virDomainSnapshotState */ diff --git a/src/conf/snapshot_conf.c b/src/conf/snapshot_conf.c index b571c5cc41..dd281d57fe 100644 --- a/src/conf/snapshot_conf.c +++ b/src/conf/snapshot_conf.c @@ -88,7 +88,7 @@ void virDomainSnapshotDefFree(virDomainSnapshotDefPtr def) if (!def) return; - virDomainMomentDefClear(&def->common); + virDomainMomentDefClear(&def->parent); VIR_FREE(def->file); for (i =3D 0; i < def->ndisks; i++) virDomainSnapshotDiskDefClear(&def->disks[i]); @@ -208,8 +208,8 @@ virDomainSnapshotDefParse(xmlXPathContextPtr ctxt, if (VIR_ALLOC(def) < 0) goto cleanup; - def->common.name =3D virXPathString("string(./name)", ctxt); - if (def->common.name =3D=3D NULL) { + def->parent.name =3D virXPathString("string(./name)", ctxt); + if (def->parent.name =3D=3D NULL) { if (flags & VIR_DOMAIN_SNAPSHOT_PARSE_REDEFINE) { virReportError(VIR_ERR_XML_ERROR, "%s", _("a redefined snapshot must have a name")); @@ -217,17 +217,17 @@ virDomainSnapshotDefParse(xmlXPathContextPtr ctxt, } } - def->common.description =3D virXPathString("string(./description)", ct= xt); + def->parent.description =3D virXPathString("string(./description)", ct= xt); if (flags & VIR_DOMAIN_SNAPSHOT_PARSE_REDEFINE) { if (virXPathLongLong("string(./creationTime)", ctxt, - &def->common.creationTime) < 0) { + &def->parent.creationTime) < 0) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("missing creationTime from existing snapshot"= )); goto cleanup; } - def->common.parent_name =3D virXPathString("string(./parent/name)"= , ctxt); + def->parent.parent_name =3D virXPathString("string(./parent/name)"= , ctxt); state =3D virXPathString("string(./state)", ctxt); if (state =3D=3D NULL) { @@ -263,14 +263,14 @@ virDomainSnapshotDefParse(xmlXPathContextPtr ctxt, _("missing domain in snapshot")); goto cleanup; } - def->common.dom =3D virDomainDefParseNode(ctxt->node->doc, dom= ainNode, + def->parent.dom =3D virDomainDefParseNode(ctxt->node->doc, dom= ainNode, caps, xmlopt, NULL, do= mainflags); - if (!def->common.dom) + if (!def->parent.dom) goto cleanup; } else { VIR_WARN("parsing older snapshot that lacks domain"); } - } else if (virDomainXMLOptionRunMomentPostParse(xmlopt, &def->common) = < 0) { + } else if (virDomainXMLOptionRunMomentPostParse(xmlopt, &def->parent) = < 0) { goto cleanup; } @@ -422,7 +422,7 @@ virDomainSnapshotDefParseString(const char *xmlStr, /* Perform sanity checking on a redefined snapshot definition. If - * @other is non-NULL, this may include swapping def->common.dom from other + * @other is non-NULL, this may include swapping def->parent.dom from other * into def. */ int virDomainSnapshotRedefineValidate(virDomainSnapshotDefPtr def, @@ -440,17 +440,17 @@ virDomainSnapshotRedefineValidate(virDomainSnapshotDe= fPtr def, virReportError(VIR_ERR_INVALID_ARG, _("disk-only flag for snapshot %s requires " "disk-snapshot state"), - def->common.name); + def->parent.name); return -1; } - if (def->common.dom && memcmp(def->common.dom->uuid, domain_uuid, + if (def->parent.dom && memcmp(def->parent.dom->uuid, domain_uuid, VIR_UUID_BUFLEN)) { char uuidstr[VIR_UUID_STRING_BUFLEN]; virUUIDFormat(domain_uuid, uuidstr); virReportError(VIR_ERR_INVALID_ARG, _("definition for snapshot %s must use uuid %s"), - def->common.name, uuidstr); + def->parent.name, uuidstr); return -1; } @@ -464,7 +464,7 @@ virDomainSnapshotRedefineValidate(virDomainSnapshotDefP= tr def, virReportError(VIR_ERR_INVALID_ARG, _("cannot change between online and offline " "snapshot state in snapshot %s"), - def->common.name); + def->parent.name); return -1; } @@ -473,23 +473,23 @@ virDomainSnapshotRedefineValidate(virDomainSnapshotDe= fPtr def, virReportError(VIR_ERR_INVALID_ARG, _("cannot change between disk only and " "full system in snapshot %s"), - def->common.name); + def->parent.name); return -1; } - if (otherdef->common.dom) { - if (def->common.dom) { - if (!virDomainDefCheckABIStability(otherdef->common.dom, - def->common.dom, xmlopt= )) + if (otherdef->parent.dom) { + if (def->parent.dom) { + if (!virDomainDefCheckABIStability(otherdef->parent.dom, + def->parent.dom, xmlopt= )) return -1; } else { /* Transfer the domain def */ - VIR_STEAL_PTR(def->common.dom, otherdef->common.dom); + VIR_STEAL_PTR(def->parent.dom, otherdef->parent.dom); } } } - if (def->common.dom) { + if (def->parent.dom) { if (external) { align_location =3D VIR_DOMAIN_SNAPSHOT_LOCATION_EXTERNAL; align_match =3D false; @@ -536,7 +536,7 @@ virDomainSnapshotDefAssignExternalNames(virDomainSnapsh= otDefPtr def) return -1; } - if (!(origpath =3D virDomainDiskGetSource(def->common.dom->disks[i= ]))) { + if (!(origpath =3D virDomainDiskGetSource(def->parent.dom->disks[i= ]))) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, _("cannot generate external snapshot name " "for disk '%s' without source"), @@ -560,7 +560,7 @@ virDomainSnapshotDefAssignExternalNames(virDomainSnapsh= otDefPtr def) if ((tmp =3D strrchr(tmppath, '.')) && !strchr(tmp, '/')) *tmp =3D '\0'; - if (virAsprintf(&disk->src->path, "%s.%s", tmppath, def->common.na= me) < 0) { + if (virAsprintf(&disk->src->path, "%s.%s", tmppath, def->parent.na= me) < 0) { VIR_FREE(tmppath); return -1; } @@ -593,7 +593,7 @@ virDomainSnapshotCompareDiskIndex(const void *a, const = void *b) return diska->idx - diskb->idx; } -/* Align def->disks to def->common.dom. Sort the list of def->disks, +/* Align def->disks to def->parent.dom. Sort the list of def->disks, * filling in any missing disks or snapshot state defaults given by * the domain, with a fallback to a passed in default. Convert paths * to disk targets for uniformity. Issue an error and return -1 if @@ -610,31 +610,31 @@ virDomainSnapshotAlignDisks(virDomainSnapshotDefPtr d= ef, size_t i; int ndisks; - if (!def->common.dom) { + if (!def->parent.dom) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("missing domain in snapshot")); goto cleanup; } - if (def->ndisks > def->common.dom->ndisks) { + if (def->ndisks > def->parent.dom->ndisks) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", _("too many disk snapshot requests for domain")); goto cleanup; } /* Unlikely to have a guest without disks but technically possible. */ - if (!def->common.dom->ndisks) { + if (!def->parent.dom->ndisks) { ret =3D 0; goto cleanup; } - if (!(map =3D virBitmapNew(def->common.dom->ndisks))) + if (!(map =3D virBitmapNew(def->parent.dom->ndisks))) goto cleanup; /* Double check requested disks. */ for (i =3D 0; i < def->ndisks; i++) { virDomainSnapshotDiskDefPtr disk =3D &def->disks[i]; - int idx =3D virDomainDiskIndexByName(def->common.dom, disk->name, = false); + int idx =3D virDomainDiskIndexByName(def->parent.dom, disk->name, = false); int disk_snapshot; if (idx < 0) { @@ -652,7 +652,7 @@ virDomainSnapshotAlignDisks(virDomainSnapshotDefPtr def, ignore_value(virBitmapSetBit(map, idx)); disk->idx =3D idx; - disk_snapshot =3D def->common.dom->disks[idx]->snapshot; + disk_snapshot =3D def->parent.dom->disks[idx]->snapshot; if (!disk->snapshot) { if (disk_snapshot && (!require_match || @@ -680,9 +680,9 @@ virDomainSnapshotAlignDisks(virDomainSnapshotDefPtr def, disk->src->path, disk->name); goto cleanup; } - if (STRNEQ(disk->name, def->common.dom->disks[idx]->dst)) { + if (STRNEQ(disk->name, def->parent.dom->disks[idx]->dst)) { VIR_FREE(disk->name); - if (VIR_STRDUP(disk->name, def->common.dom->disks[idx]->dst) <= 0) + if (VIR_STRDUP(disk->name, def->parent.dom->disks[idx]->dst) <= 0) goto cleanup; } } @@ -690,10 +690,10 @@ virDomainSnapshotAlignDisks(virDomainSnapshotDefPtr d= ef, /* Provide defaults for all remaining disks. */ ndisks =3D def->ndisks; if (VIR_EXPAND_N(def->disks, def->ndisks, - def->common.dom->ndisks - def->ndisks) < 0) + def->parent.dom->ndisks - def->ndisks) < 0) goto cleanup; - for (i =3D 0; i < def->common.dom->ndisks; i++) { + for (i =3D 0; i < def->parent.dom->ndisks; i++) { virDomainSnapshotDiskDefPtr disk; if (virBitmapIsBitSet(map, i)) @@ -701,15 +701,15 @@ virDomainSnapshotAlignDisks(virDomainSnapshotDefPtr d= ef, disk =3D &def->disks[ndisks++]; if (!(disk->src =3D virStorageSourceNew())) goto cleanup; - if (VIR_STRDUP(disk->name, def->common.dom->disks[i]->dst) < 0) + if (VIR_STRDUP(disk->name, def->parent.dom->disks[i]->dst) < 0) goto cleanup; disk->idx =3D i; /* Don't snapshot empty drives */ - if (virStorageSourceIsEmpty(def->common.dom->disks[i]->src)) + if (virStorageSourceIsEmpty(def->parent.dom->disks[i]->src)) disk->snapshot =3D VIR_DOMAIN_SNAPSHOT_LOCATION_NONE; else - disk->snapshot =3D def->common.dom->disks[i]->snapshot; + disk->snapshot =3D def->parent.dom->disks[i]->snapshot; disk->src->type =3D VIR_STORAGE_TYPE_FILE; if (!disk->snapshot) @@ -801,26 +801,26 @@ virDomainSnapshotDefFormatInternal(virBufferPtr buf, virBufferAddLit(buf, "\n"); virBufferAdjustIndent(buf, 2); - virBufferEscapeString(buf, "%s\n", def->common.name); - if (def->common.description) + virBufferEscapeString(buf, "%s\n", def->parent.name); + if (def->parent.description) virBufferEscapeString(buf, "%s\n", - def->common.description); + def->parent.description); if (def->state) virBufferAsprintf(buf, "%s\n", virDomainSnapshotStateTypeToString(def->state)); - if (def->common.parent_name) { + if (def->parent.parent_name) { virBufferAddLit(buf, "\n"); virBufferAdjustIndent(buf, 2); virBufferEscapeString(buf, "%s\n", - def->common.parent_name); + def->parent.parent_name); virBufferAdjustIndent(buf, -2); virBufferAddLit(buf, "\n"); } - if (def->common.creationTime) + if (def->parent.creationTime) virBufferAsprintf(buf, "%lld\n", - def->common.creationTime); + def->parent.creationTime); if (def->memory) { virBufferAsprintf(buf, "\n"); } - if (def->common.dom) { - if (virDomainDefFormatInternal(def->common.dom, caps, domainflags,= buf, + if (def->parent.dom) { + if (virDomainDefFormatInternal(def->parent.dom, caps, domainflags,= buf, xmlopt) < 0) goto error; } else if (uuidstr) { @@ -933,31 +933,31 @@ virDomainSnapshotRedefinePrep(virDomainPtr domain, bool check_if_stolen; /* Prevent circular chains */ - if (def->common.parent_name) { - if (STREQ(def->common.name, def->common.parent_name)) { + if (def->parent.parent_name) { + if (STREQ(def->parent.name, def->parent.parent_name)) { virReportError(VIR_ERR_INVALID_ARG, _("cannot set snapshot %s as its own parent"), - def->common.name); + def->parent.name); return -1; } other =3D virDomainSnapshotFindByName(vm->snapshots, - def->common.parent_name); + def->parent.parent_name); if (!other) { virReportError(VIR_ERR_INVALID_ARG, _("parent %s for snapshot %s not found"), - def->common.parent_name, def->common.name); + def->parent.parent_name, def->parent.name); return -1; } otherdef =3D virDomainSnapshotObjGetDef(other); - while (otherdef->common.parent_name) { - if (STREQ(otherdef->common.parent_name, def->common.name)) { + while (otherdef->parent.parent_name) { + if (STREQ(otherdef->parent.parent_name, def->parent.name)) { virReportError(VIR_ERR_INVALID_ARG, _("parent %s would create cycle to %s"), - otherdef->common.name, def->common.name); + otherdef->parent.name, def->parent.name); return -1; } other =3D virDomainSnapshotFindByName(vm->snapshots, - otherdef->common.parent_na= me); + otherdef->parent.parent_na= me); if (!other) { VIR_WARN("snapshots are inconsistent for %s", vm->def->name); @@ -967,14 +967,14 @@ virDomainSnapshotRedefinePrep(virDomainPtr domain, } } - other =3D virDomainSnapshotFindByName(vm->snapshots, def->common.name); + other =3D virDomainSnapshotFindByName(vm->snapshots, def->parent.name); otherdef =3D other ? virDomainSnapshotObjGetDef(other) : NULL; - check_if_stolen =3D other && otherdef->common.dom; + check_if_stolen =3D other && otherdef->parent.dom; if (virDomainSnapshotRedefineValidate(def, domain->uuid, other, xmlopt, flags) < 0) { /* revert any stealing of the snapshot domain definition */ - if (check_if_stolen && def->common.dom && !otherdef->common.dom) - VIR_STEAL_PTR(otherdef->common.dom, def->common.dom); + if (check_if_stolen && def->parent.dom && !otherdef->parent.dom) + VIR_STEAL_PTR(otherdef->parent.dom, def->parent.dom); return -1; } if (other) { @@ -987,7 +987,7 @@ virDomainSnapshotRedefinePrep(virDomainPtr domain, * child relations by reusing snap. */ virDomainMomentDropParent(other); virDomainSnapshotDefFree(otherdef); - other->def =3D &(*defptr)->common; + other->def =3D &(*defptr)->parent; *defptr =3D NULL; *snap =3D other; } diff --git a/src/conf/virdomainsnapshotobjlist.c b/src/conf/virdomainsnapsh= otobjlist.c index 46b7d8b0e7..9bcc8d1036 100644 --- a/src/conf/virdomainsnapshotobjlist.c +++ b/src/conf/virdomainsnapshotobjlist.c @@ -44,7 +44,7 @@ virDomainMomentObjPtr virDomainSnapshotAssignDef(virDomainSnapshotObjListPtr snapshots, virDomainSnapshotDefPtr def) { - return virDomainMomentAssignDef(snapshots->base, &def->common); + return virDomainMomentAssignDef(snapshots->base, &def->parent); } diff --git a/src/esx/esx_driver.c b/src/esx/esx_driver.c index dff801f946..f45d96a4f5 100644 --- a/src/esx/esx_driver.c +++ b/src/esx/esx_driver.c @@ -4118,7 +4118,7 @@ esxDomainSnapshotCreateXML(virDomainPtr domain, const= char *xmlDesc, priv->parsedUri->autoAnswer) < 0 || esxVI_LookupRootSnapshotTreeList(priv->primary, domain->uuid, &rootSnapshotList) < 0 || - esxVI_GetSnapshotTreeByName(rootSnapshotList, def->common.name, + esxVI_GetSnapshotTreeByName(rootSnapshotList, def->parent.name, &snapshotTree, NULL, esxVI_Occurrence_OptionalItem) < 0) { goto cleanup; @@ -4126,12 +4126,12 @@ esxDomainSnapshotCreateXML(virDomainPtr domain, con= st char *xmlDesc, if (snapshotTree) { virReportError(VIR_ERR_OPERATION_INVALID, - _("Snapshot '%s' already exists"), def->common.name= ); + _("Snapshot '%s' already exists"), def->parent.name= ); goto cleanup; } if (esxVI_CreateSnapshot_Task(priv->primary, virtualMachine->obj, - def->common.name, def->common.descriptio= n, + def->parent.name, def->parent.descriptio= n, diskOnly ? esxVI_Boolean_False : esxVI_B= oolean_True, quiesce ? esxVI_Boolean_True : esxVI_Boo= lean_False, &task) < 0 || @@ -4148,7 +4148,7 @@ esxDomainSnapshotCreateXML(virDomainPtr domain, const= char *xmlDesc, goto cleanup; } - snapshot =3D virGetDomainSnapshot(domain, def->common.name); + snapshot =3D virGetDomainSnapshot(domain, def->parent.name); cleanup: virDomainSnapshotDefFree(def); @@ -4189,12 +4189,12 @@ esxDomainSnapshotGetXMLDesc(virDomainSnapshotPtr sn= apshot, goto cleanup; } - def.common.name =3D snapshot->name; - def.common.description =3D snapshotTree->description; - def.common.parent_name =3D snapshotTreeParent ? snapshotTreeParent->na= me : NULL; + def.parent.name =3D snapshot->name; + def.parent.description =3D snapshotTree->description; + def.parent.parent_name =3D snapshotTreeParent ? snapshotTreeParent->na= me : NULL; if (esxVI_DateTime_ConvertToCalendarTime(snapshotTree->createTime, - &def.common.creationTime) < 0= ) { + &def.parent.creationTime) < 0= ) { goto cleanup; } diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index 6b16da2998..53012f4116 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -8467,7 +8467,7 @@ qemuDomainSnapshotWriteMetadata(virDomainObjPtr vm, goto cleanup; } - if (virAsprintf(&snapFile, "%s/%s.xml", snapDir, def->common.name) < 0) + if (virAsprintf(&snapFile, "%s/%s.xml", snapDir, def->parent.name) < 0) goto cleanup; ret =3D virXMLSaveFile(snapFile, NULL, "snapshot-edit", newxml); diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index c12b3dff6c..833c1e88ee 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -14446,7 +14446,7 @@ qemuDomainSnapshotCreateInactiveExternal(virQEMUDri= verPtr driver, * create them correctly. */ for (i =3D 0; i < snapdef->ndisks && !reuse; i++) { snapdisk =3D &(snapdef->disks[i]); - defdisk =3D snapdef->common.dom->disks[snapdisk->idx]; + defdisk =3D snapdef->parent.dom->disks[snapdisk->idx]; if (snapdisk->snapshot !=3D VIR_DOMAIN_SNAPSHOT_LOCATION_EXTERNAL) continue; @@ -15621,19 +15621,19 @@ qemuDomainSnapshotCreateXML(virDomainPtr domain, /* reject snapshot names containing slashes or starting with dot as * snapshot definitions are saved in files named by the snapshot name = */ if (!(flags & VIR_DOMAIN_SNAPSHOT_CREATE_NO_METADATA)) { - if (strchr(def->common.name, '/')) { + if (strchr(def->parent.name, '/')) { virReportError(VIR_ERR_XML_DETAIL, _("invalid snapshot name '%s': " "name can't contain '/'"), - def->common.name); + def->parent.name); goto cleanup; } - if (def->common.name[0] =3D=3D '.') { + if (def->parent.name[0] =3D=3D '.') { virReportError(VIR_ERR_XML_DETAIL, _("invalid snapshot name '%s': " "name can't start with '.'"), - def->common.name); + def->parent.name); goto cleanup; } } @@ -15704,7 +15704,7 @@ qemuDomainSnapshotCreateXML(virDomainPtr domain, * conversion in and back out of xml. */ if (!(xml =3D qemuDomainDefFormatLive(driver, vm->def, priv->origC= PU, true, true)) || - !(def->common.dom =3D virDomainDefParseString(xml, caps, drive= r->xmlopt, NULL, + !(def->parent.dom =3D virDomainDefParseString(xml, caps, drive= r->xmlopt, NULL, VIR_DOMAIN_DEF_PAR= SE_INACTIVE | VIR_DOMAIN_DEF_PAR= SE_SKIP_VALIDATE))) goto endjob; diff --git a/src/test/test_driver.c b/src/test/test_driver.c index 626167f947..aaf67eaac9 100644 --- a/src/test/test_driver.c +++ b/src/test/test_driver.c @@ -6403,7 +6403,7 @@ testDomainSnapshotCreateXML(virDomainPtr domain, &update_current, flags) < 0) goto cleanup; } else { - if (!(def->common.dom =3D virDomainDefCopy(vm->def, + if (!(def->parent.dom =3D virDomainDefCopy(vm->def, privconn->caps, privconn->xmlopt, NULL, diff --git a/src/vbox/vbox_common.c b/src/vbox/vbox_common.c index 94830f5ddb..af557690c4 100644 --- a/src/vbox/vbox_common.c +++ b/src/vbox/vbox_common.c @@ -4811,7 +4811,7 @@ vboxSnapshotRedefine(virDomainPtr dom, * read-only disks are in the redefined snapshot's media registry (the= disks need to * be open to query their uuid). */ - for (it =3D 0; it < def->common.dom->ndisks; it++) { + for (it =3D 0; it < def->parent.dom->ndisks; it++) { int diskInMediaRegistry =3D 0; IMedium *readOnlyMedium =3D NULL; PRUnichar *locationUtf =3D NULL; @@ -4825,7 +4825,7 @@ vboxSnapshotRedefine(virDomainPtr dom, VBOX_IID_INITIALIZE(&iid); VBOX_IID_INITIALIZE(&parentiid); diskInMediaRegistry =3D virVBoxSnapshotConfDiskIsInMediaRegistry(s= napshotMachineDesc, - def->common.dom->d= isks[it]->src->path); + def->parent.dom->d= isks[it]->src->path); if (diskInMediaRegistry =3D=3D -1) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("Unable to know if disk is in media registry"= )); @@ -4835,7 +4835,7 @@ vboxSnapshotRedefine(virDomainPtr dom, continue; /*The read only disk is not in the media registry*/ - VBOX_UTF8_TO_UTF16(def->common.dom->disks[it]->src->path, &locatio= nUtf); + VBOX_UTF8_TO_UTF16(def->parent.dom->disks[it]->src->path, &locatio= nUtf); rc =3D gVBoxAPI.UIVirtualBox.OpenMedium(data->vboxObj, locationUtf, DeviceType_HardDisk, @@ -4908,7 +4908,7 @@ vboxSnapshotRedefine(virDomainPtr dom, readOnlyDisk->format =3D format; readOnlyDisk->uuid =3D uuid; - if (VIR_STRDUP(readOnlyDisk->location, def->common.dom->disks[it]-= >src->path) < 0) { + if (VIR_STRDUP(readOnlyDisk->location, def->parent.dom->disks[it]-= >src->path) < 0) { VIR_FREE(readOnlyDisk); goto cleanup; } @@ -5013,12 +5013,12 @@ vboxSnapshotRedefine(virDomainPtr dom, goto cleanup; VIR_DEBUG("New snapshot UUID: %s", newSnapshotPtr->uuid); - if (VIR_STRDUP(newSnapshotPtr->name, def->common.name) < 0) + if (VIR_STRDUP(newSnapshotPtr->name, def->parent.name) < 0) goto cleanup; - newSnapshotPtr->timeStamp =3D virTimeStringThen(def->common.creationTi= me * 1000); + newSnapshotPtr->timeStamp =3D virTimeStringThen(def->parent.creationTi= me * 1000); - if (VIR_STRDUP(newSnapshotPtr->description, def->common.description) <= 0) + if (VIR_STRDUP(newSnapshotPtr->description, def->parent.description) <= 0) goto cleanup; if (VIR_STRDUP(newSnapshotPtr->hardware, snapshotMachineDesc->hardware= ) < 0) @@ -5028,12 +5028,12 @@ vboxSnapshotRedefine(virDomainPtr dom, goto cleanup; /*We get the parent disk uuid from the parent disk location to correct= ly fill the storage controller.*/ - for (it =3D 0; it < def->common.dom->ndisks; it++) { + for (it =3D 0; it < def->parent.dom->ndisks; it++) { char *location =3D NULL; const char *uuidReplacing =3D NULL; char *tmp =3D NULL; - location =3D def->common.dom->disks[it]->src->path; + location =3D def->parent.dom->disks[it]->src->path; if (!location) goto cleanup; /*Replacing the uuid*/ @@ -5061,7 +5061,7 @@ vboxSnapshotRedefine(virDomainPtr dom, VIR_FREE(tmp); } - if (virVBoxSnapshotConfAddSnapshotToXmlMachine(newSnapshotPtr, snapsho= tMachineDesc, def->common.parent_name) < 0) { + if (virVBoxSnapshotConfAddSnapshotToXmlMachine(newSnapshotPtr, snapsho= tMachineDesc, def->parent.parent_name) < 0) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("Unable to add the snapshot to the machine descri= ption")); goto cleanup; @@ -5081,10 +5081,10 @@ vboxSnapshotRedefine(virDomainPtr dom, * Open the snapshot's read-write disk's full ancestry to allow openin= g the * read-write disk itself. */ - for (it =3D 0; it < def->common.dom->ndisks; it++) { + for (it =3D 0; it < def->parent.dom->ndisks; it++) { char *location =3D NULL; - location =3D def->common.dom->disks[it]->src->path; + location =3D def->parent.dom->disks[it]->src->path; if (!location) goto cleanup; @@ -5228,7 +5228,7 @@ vboxSnapshotRedefine(virDomainPtr dom, } } else { /*Create a "fake" disk to avoid corrupting children snapshot disks= .*/ - for (it =3D 0; it < def->common.dom->ndisks; it++) { + for (it =3D 0; it < def->parent.dom->ndisks; it++) { IMedium *medium =3D NULL; PRUnichar *locationUtf16 =3D NULL; char *parentUuid =3D NULL; @@ -5244,7 +5244,7 @@ vboxSnapshotRedefine(virDomainPtr dom, VBOX_IID_INITIALIZE(&iid); VBOX_IID_INITIALIZE(&parentiid); - VBOX_UTF8_TO_UTF16(def->common.dom->disks[it]->src->path, &loc= ationUtf16); + VBOX_UTF8_TO_UTF16(def->parent.dom->disks[it]->src->path, &loc= ationUtf16); rc =3D gVBoxAPI.UIVirtualBox.OpenMedium(data->vboxObj, locationUtf16, DeviceType_HardDisk, @@ -5393,8 +5393,8 @@ vboxSnapshotRedefine(virDomainPtr dom, * All the snapshot structure manipulation is done, we close the disks= we have * previously opened. */ - for (it =3D 0; it < def->common.dom->ndisks; it++) { - char *location =3D def->common.dom->disks[it]->src->path; + for (it =3D 0; it < def->parent.dom->ndisks; it++) { + char *location =3D def->parent.dom->disks[it]->src->path; if (!location) goto cleanup; @@ -5513,7 +5513,7 @@ vboxDomainSnapshotCreateXML(virDomainPtr dom, if (flags & VIR_DOMAIN_SNAPSHOT_CREATE_REDEFINE) { if (vboxSnapshotRedefine(dom, def, isCurrent) < 0) goto cleanup; - ret =3D virGetDomainSnapshot(dom, def->common.name); + ret =3D virGetDomainSnapshot(dom, def->parent.name); goto cleanup; } } @@ -5540,14 +5540,14 @@ vboxDomainSnapshotCreateXML(virDomainPtr dom, goto cleanup; } - VBOX_UTF8_TO_UTF16(def->common.name, &name); + VBOX_UTF8_TO_UTF16(def->parent.name, &name); if (!name) { virReportOOMError(); goto cleanup; } - if (def->common.description) { - VBOX_UTF8_TO_UTF16(def->common.description, &description); + if (def->parent.description) { + VBOX_UTF8_TO_UTF16(def->parent.description, &description); if (!description) { virReportOOMError(); goto cleanup; @@ -5577,7 +5577,7 @@ vboxDomainSnapshotCreateXML(virDomainPtr dom, goto cleanup; } - ret =3D virGetDomainSnapshot(dom, def->common.name); + ret =3D virGetDomainSnapshot(dom, def->parent.name); cleanup: VBOX_RELEASE(progress); @@ -5981,7 +5981,7 @@ vboxSnapshotGetReadOnlyDisks(virDomainSnapshotDefPtr = def, vboxArray mediumAttachments =3D VBOX_ARRAY_INITIALIZER; size_t i =3D 0, diskCount =3D 0, sdCount =3D 0; int ret =3D -1; - virDomainDefPtr defdom =3D def->common.dom; + virDomainDefPtr defdom =3D def->parent.dom; if (!data->vboxObj) return ret; @@ -6220,10 +6220,10 @@ static char *vboxDomainSnapshotGetXMLDesc(virDomain= SnapshotPtr snapshot, if (!(snap =3D vboxDomainSnapshotGet(data, dom, machine, snapshot->nam= e))) goto cleanup; - if (VIR_ALLOC(def) < 0 || !(def->common.dom =3D virDomainDefNew())) + if (VIR_ALLOC(def) < 0 || !(def->parent.dom =3D virDomainDefNew())) goto cleanup; - defdom =3D def->common.dom; - if (VIR_STRDUP(def->common.name, snapshot->name) < 0) + defdom =3D def->parent.dom; + if (VIR_STRDUP(def->parent.name, snapshot->name) < 0) goto cleanup; if (gVBoxAPI.vboxSnapshotRedefine) { @@ -6271,7 +6271,7 @@ static char *vboxDomainSnapshotGetXMLDesc(virDomainSn= apshotPtr snapshot, if (str16) { VBOX_UTF16_TO_UTF8(str16, &str8); VBOX_UTF16_FREE(str16); - if (VIR_STRDUP(def->common.description, str8) < 0) { + if (VIR_STRDUP(def->parent.description, str8) < 0) { VBOX_UTF8_FREE(str8); goto cleanup; } @@ -6286,7 +6286,7 @@ static char *vboxDomainSnapshotGetXMLDesc(virDomainSn= apshotPtr snapshot, goto cleanup; } /* timestamp is in milliseconds while creationTime in seconds */ - def->common.creationTime =3D timestamp / 1000; + def->parent.creationTime =3D timestamp / 1000; rc =3D gVBoxAPI.UISnapshot.GetParent(snap, &parent); if (NS_FAILED(rc)) { @@ -6305,7 +6305,7 @@ static char *vboxDomainSnapshotGetXMLDesc(virDomainSn= apshotPtr snapshot, } VBOX_UTF16_TO_UTF8(str16, &str8); VBOX_UTF16_FREE(str16); - if (VIR_STRDUP(def->common.parent_name, str8) < 0) { + if (VIR_STRDUP(def->parent.parent_name, str8) < 0) { VBOX_UTF8_FREE(str8); goto cleanup; } @@ -6987,7 +6987,7 @@ vboxDomainSnapshotDeleteMetadataOnly(virDomainSnapsho= tPtr snapshot) goto cleanup; } - isCurrent =3D virVBoxSnapshotConfIsCurrentSnapshot(snapshotMachineDesc= , def->common.name); + isCurrent =3D virVBoxSnapshotConfIsCurrentSnapshot(snapshotMachineDesc= , def->parent.name); if (isCurrent < 0) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("Unable to know if the snapshot is the current sn= apshot")); @@ -6999,8 +6999,8 @@ vboxDomainSnapshotDeleteMetadataOnly(virDomainSnapsho= tPtr snapshot) * disks. The first thing to do is to manipulate VirtualBox API to= create * differential read-write disks if the parent snapshot is not nul= l. */ - if (def->common.parent_name !=3D NULL) { - for (it =3D 0; it < def->common.dom->ndisks; it++) { + if (def->parent.parent_name !=3D NULL) { + for (it =3D 0; it < def->parent.dom->ndisks; it++) { virVBoxSnapshotConfHardDiskPtr readOnly =3D NULL; IMedium *medium =3D NULL; PRUnichar *locationUtf16 =3D NULL; @@ -7020,7 +7020,7 @@ vboxDomainSnapshotDeleteMetadataOnly(virDomainSnapsho= tPtr snapshot) VBOX_IID_INITIALIZE(&iid); VBOX_IID_INITIALIZE(&parentiid); readOnly =3D virVBoxSnapshotConfHardDiskPtrByLocation(snap= shotMachineDesc, - def->common.dom->disks[it= ]->src->path); + def->parent.dom->disks[it= ]->src->path); if (!readOnly) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("Cannot get hard disk by location")); @@ -7058,7 +7058,7 @@ vboxDomainSnapshotDeleteMetadataOnly(virDomainSnapsho= tPtr snapshot) VBOX_UTF8_TO_UTF16("VDI", &formatUtf16); if (virAsprintf(&newLocationUtf8, "%sfakedisk-%s-%d.vdi", - machineLocationPath, def->common.parent_na= me, it) < 0) + machineLocationPath, def->parent.parent_na= me, it) < 0) goto cleanup; VBOX_UTF8_TO_UTF16(newLocationUtf8, &newLocation); rc =3D gVBoxAPI.UIVirtualBox.CreateHardDisk(data->vboxObj, @@ -7156,15 +7156,15 @@ vboxDomainSnapshotDeleteMetadataOnly(virDomainSnaps= hotPtr snapshot) } } } else { - for (it =3D 0; it < def->common.dom->ndisks; it++) { + for (it =3D 0; it < def->parent.dom->ndisks; it++) { const char *uuidRO =3D NULL; char *tmp =3D NULL; uuidRO =3D virVBoxSnapshotConfHardDiskUuidByLocation(snaps= hotMachineDesc, - def->common.dom->dis= ks[it]->src->path); + def->parent.dom->dis= ks[it]->src->path); if (!uuidRO) { virReportError(VIR_ERR_INTERNAL_ERROR, _("No such disk in media registry %s"), - def->common.dom->disks[it]->src->path); + def->parent.dom->disks[it]->src->path); goto cleanup; } @@ -7209,14 +7209,14 @@ vboxDomainSnapshotDeleteMetadataOnly(virDomainSnaps= hotPtr snapshot) } } /*If the parent snapshot is not NULL, we remove the-read only disks fr= om the media registry*/ - if (def->common.parent_name !=3D NULL) { - for (it =3D 0; it < def->common.dom->ndisks; it++) { + if (def->parent.parent_name !=3D NULL) { + for (it =3D 0; it < def->parent.dom->ndisks; it++) { const char *uuidRO =3D virVBoxSnapshotConfHardDiskUuidByLocation(snapshotMachineD= esc, - def->common.dom-= >disks[it]->src->path); + def->parent.dom-= >disks[it]->src->path); if (!uuidRO) { virReportError(VIR_ERR_INTERNAL_ERROR, - _("Unable to find UUID for location %s"), d= ef->common.dom->disks[it]->src->path); + _("Unable to find UUID for location %s"), d= ef->parent.dom->disks[it]->src->path); goto cleanup; } if (virVBoxSnapshotConfRemoveHardDisk(snapshotMachineDesc->med= iaRegistry, uuidRO) < 0) { @@ -7281,16 +7281,16 @@ vboxDomainSnapshotDeleteMetadataOnly(virDomainSnaps= hotPtr snapshot) } /*removing the snapshot*/ - if (virVBoxSnapshotConfRemoveSnapshot(snapshotMachineDesc, def->common= .name) < 0) { + if (virVBoxSnapshotConfRemoveSnapshot(snapshotMachineDesc, def->parent= .name) < 0) { virReportError(VIR_ERR_INTERNAL_ERROR, - _("Unable to remove snapshot %s"), def->common.name= ); + _("Unable to remove snapshot %s"), def->parent.name= ); goto cleanup; } if (isCurrent) { VIR_FREE(snapshotMachineDesc->currentSnapshot); - if (def->common.parent_name !=3D NULL) { - virVBoxSnapshotConfSnapshotPtr snap =3D virVBoxSnapshotConfSna= pshotByName(snapshotMachineDesc->snapshot, def->common.parent_name); + if (def->parent.parent_name !=3D NULL) { + virVBoxSnapshotConfSnapshotPtr snap =3D virVBoxSnapshotConfSna= pshotByName(snapshotMachineDesc->snapshot, def->parent.parent_name); if (!snap) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("Unable to get the snapshot to remove")); diff --git a/src/vz/vz_driver.c b/src/vz/vz_driver.c index 83bffd95b2..419e9d215f 100644 --- a/src/vz/vz_driver.c +++ b/src/vz/vz_driver.c @@ -2619,7 +2619,7 @@ vzDomainSnapshotCreateXML(virDomainPtr domain, goto cleanup; /* snaphot name is ignored, it will be set to auto generated by sdk uu= id */ - if (prlsdkCreateSnapshot(dom, def->common.description) < 0) + if (prlsdkCreateSnapshot(dom, def->parent.description) < 0) goto cleanup; if (!(snapshots =3D prlsdkLoadSnapshots(dom))) diff --git a/src/vz/vz_sdk.c b/src/vz/vz_sdk.c index 500de5f8ba..478443298f 100644 --- a/src/vz/vz_sdk.c +++ b/src/vz/vz_sdk.c @@ -4696,14 +4696,14 @@ prlsdkParseSnapshotTree(const char *treexml) ctxt->node =3D nodes[i]; - def->common.name =3D virXPathString("string(./@guid)", ctxt); - if (!def->common.name) { + def->parent.name =3D virXPathString("string(./@guid)", ctxt); + if (!def->parent.name) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("missing 'guid' attribute")); goto cleanup; } - def->common.parent_name =3D virXPathString("string(../@guid)", ctx= t); + def->parent.parent_name =3D virXPathString("string(../@guid)", ctx= t); xmlstr =3D virXPathString("string(./DateTime)", ctxt); if (!xmlstr) { @@ -4711,11 +4711,11 @@ prlsdkParseSnapshotTree(const char *treexml) _("missing 'DateTime' element")); goto cleanup; } - if ((def->common.creationTime =3D prlsdkParseDateTime(xmlstr)) < 0) + if ((def->parent.creationTime =3D prlsdkParseDateTime(xmlstr)) < 0) goto cleanup; VIR_FREE(xmlstr); - def->common.description =3D virXPathString("string(./Description)"= , ctxt); + def->parent.description =3D virXPathString("string(./Description)"= , ctxt); def->memory =3D VIR_DOMAIN_SNAPSHOT_LOCATION_NONE; xmlstr =3D virXPathString("string(./@state)", ctxt); --=20 2.20.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Fri Apr 19 20:46:42 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 ARC-Seal: i=1; a=rsa-sha256; t=1557354264; cv=none; d=zoho.com; s=zohoarc; b=PCt/qUjhuhbiS59DuY2fw6c5PnNNff/kVeKy8n4R9BwnGOGzdh6udSK9ts+LsAxSsBcQ7iPjUVUrknu/bwH+y8DF4wa18vwzGJyVRpspD5A5rVN2P5UJGJ7tIRPjEpGRtXYFAjAHHpWltQHiOpz8kNBre4xFMKwwGx5hhv81JWg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1557354264; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=INMS4enU2z+0rqDi4S671KIEgxCW8N8zSrH9ULqexuw=; b=g81qJNOUwLvVqkXgiVL5OMdM16LWnfAKDqjKztQ/dtVPEueT94/J8iGwbK1d008GJURSTRF8Rfc/va6u0wKYqoxGMmlHqqUG2eHfDp0Uk+Wtf02hGmHvgRJ+v0OuDAdop7vBAUpjl7I+jumnz7TWUjtnDsSetdu+RVfL/LXy0rY= ARC-Authentication-Results: i=1; mx.zoho.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 header.from= (p=none dis=none) header.from= Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 15573542640580.5598336340083279; Wed, 8 May 2019 15:24:24 -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 F42213092649; Wed, 8 May 2019 22:24:21 +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 F33C35DE72; Wed, 8 May 2019 22:24:20 +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 8083318089CA; Wed, 8 May 2019 22:24:17 +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 x48MOGjQ021459 for ; Wed, 8 May 2019 18:24:16 -0400 Received: by smtp.corp.redhat.com (Postfix) id 9FB1060C6F; Wed, 8 May 2019 22:24:16 +0000 (UTC) Received: from blue.redhat.com (ovpn-116-15.phx2.redhat.com [10.3.116.15]) by smtp.corp.redhat.com (Postfix) with ESMTP id 6691660C93 for ; Wed, 8 May 2019 22:24:16 +0000 (UTC) From: Eric Blake To: libvir-list@redhat.com Date: Wed, 8 May 2019 17:24:11 -0500 Message-Id: <20190508222412.11811-4-eblake@redhat.com> In-Reply-To: <20190508222412.11811-1-eblake@redhat.com> References: <20190508222412.11811-1-eblake@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 3/4] snapshot: Add virDomainSnapshotDefNew 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.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.43]); Wed, 08 May 2019 22:24:22 +0000 (UTC) Content-Type: text/plain; charset="utf-8" In preparation for making virDomainSnapshotDef a descendant of virObject, it is time to fix all callers that allocate an object to use virDomainSnapshotDefNew() instead of VIR_ALLOC(). Fortunately, there aren't very many :) Signed-off-by: Eric Blake --- src/conf/snapshot_conf.h | 1 + src/conf/snapshot_conf.c | 16 +++++++++++++--- src/libvirt_private.syms | 1 + src/vbox/vbox_common.c | 3 ++- 4 files changed, 17 insertions(+), 4 deletions(-) diff --git a/src/conf/snapshot_conf.h b/src/conf/snapshot_conf.h index f54be11619..0ce9dda355 100644 --- a/src/conf/snapshot_conf.h +++ b/src/conf/snapshot_conf.h @@ -114,6 +114,7 @@ virDomainSnapshotDefPtr virDomainSnapshotDefParseNode(x= mlDocPtr xml, virDomainXMLOptionPt= r xmlopt, bool *current, unsigned int flags); +virDomainSnapshotDefPtr virDomainSnapshotDefNew(void); void virDomainSnapshotDefFree(virDomainSnapshotDefPtr def); char *virDomainSnapshotDefFormat(const char *uuidstr, virDomainSnapshotDefPtr def, diff --git a/src/conf/snapshot_conf.c b/src/conf/snapshot_conf.c index dd281d57fe..e5771ae635 100644 --- a/src/conf/snapshot_conf.c +++ b/src/conf/snapshot_conf.c @@ -81,7 +81,17 @@ virDomainSnapshotDiskDefClear(virDomainSnapshotDiskDefPt= r disk) disk->src =3D NULL; } -void virDomainSnapshotDefFree(virDomainSnapshotDefPtr def) +virDomainSnapshotDefPtr +virDomainSnapshotDefNew(void) +{ + virDomainSnapshotDefPtr def; + + ignore_value(VIR_ALLOC(def)); + return def; +} + +void +virDomainSnapshotDefFree(virDomainSnapshotDefPtr def) { size_t i; @@ -205,8 +215,8 @@ virDomainSnapshotDefParse(xmlXPathContextPtr ctxt, bool offline =3D !!(flags & VIR_DOMAIN_SNAPSHOT_PARSE_OFFLINE); virSaveCookieCallbacksPtr saveCookie =3D virDomainXMLOptionGetSaveCook= ie(xmlopt); - if (VIR_ALLOC(def) < 0) - goto cleanup; + if (!(def =3D virDomainSnapshotDefNew())) + return NULL; def->parent.name =3D virXPathString("string(./name)", ctxt); if (def->parent.name =3D=3D NULL) { diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index a03cf0b645..0474a4e44c 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -894,6 +894,7 @@ virDomainSnapshotAlignDisks; virDomainSnapshotDefFormat; virDomainSnapshotDefFree; virDomainSnapshotDefIsExternal; +virDomainSnapshotDefNew; virDomainSnapshotDefParseString; virDomainSnapshotFormatConvertXMLFlags; virDomainSnapshotIsExternal; diff --git a/src/vbox/vbox_common.c b/src/vbox/vbox_common.c index af557690c4..7e42f6a4fe 100644 --- a/src/vbox/vbox_common.c +++ b/src/vbox/vbox_common.c @@ -6220,7 +6220,8 @@ static char *vboxDomainSnapshotGetXMLDesc(virDomainSn= apshotPtr snapshot, if (!(snap =3D vboxDomainSnapshotGet(data, dom, machine, snapshot->nam= e))) goto cleanup; - if (VIR_ALLOC(def) < 0 || !(def->parent.dom =3D virDomainDefNew())) + if (!(def =3D virDomainSnapshotDefNew()) || + !(def->parent.dom =3D virDomainDefNew())) goto cleanup; defdom =3D def->parent.dom; if (VIR_STRDUP(def->parent.name, snapshot->name) < 0) --=20 2.20.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Fri Apr 19 20:46:42 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 ARC-Seal: i=1; a=rsa-sha256; t=1557354288; cv=none; d=zoho.com; s=zohoarc; b=MT4bpXd1610RgA7TL8V8xgo1ccQyRZswq/exiZ1bygiG+ES7tgFoiNYVsmtCwpI5Q3EeWwctjv6OPOXOz9BNzT3yNH+G9cCrAR+D3q1YUxuzpOhzaUqsJBBbVrGkUJCmJaEL3v36N0D9+klxdC8lPypgqJ2UqQU3CDbOhYaR9Go= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1557354288; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=r1BS4+sa/Zt3YnO9zVUn3m3rLIMu0JN4pdIwMi2slgw=; b=N6H8dRTT80z6+FgR/DsPQvDr82s99tKgI1be9vn55iIG6cacMDcP8TxrN89m4r4jWp/rks4HUD/pO04aYuruu13VBL/OX06Fge/R51FyLIP332Kg82RyZMP35uRDvYiqNGY3PTUtrbhP0DR3MYmqsPpRx7q4+IbeYzvt6Tm7Rao= ARC-Authentication-Results: i=1; mx.zoho.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 header.from= (p=none dis=none) header.from= Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1557354288379853.0454472399271; Wed, 8 May 2019 15:24:48 -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 8BBA53079B6F; Wed, 8 May 2019 22:24: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 6712762671; Wed, 8 May 2019 22:24:46 +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 1F36A41F58; Wed, 8 May 2019 22:24:46 +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 x48MOH4P021464 for ; Wed, 8 May 2019 18:24:17 -0400 Received: by smtp.corp.redhat.com (Postfix) id 0781860C98; Wed, 8 May 2019 22:24:17 +0000 (UTC) Received: from blue.redhat.com (ovpn-116-15.phx2.redhat.com [10.3.116.15]) by smtp.corp.redhat.com (Postfix) with ESMTP id C27E760C6F for ; Wed, 8 May 2019 22:24:16 +0000 (UTC) From: Eric Blake To: libvir-list@redhat.com Date: Wed, 8 May 2019 17:24:12 -0500 Message-Id: <20190508222412.11811-5-eblake@redhat.com> In-Reply-To: <20190508222412.11811-1-eblake@redhat.com> References: <20190508222412.11811-1-eblake@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 4/4] snapshot: Make virDomainSnapshotDef a virObject 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.41]); Wed, 08 May 2019 22:24:47 +0000 (UTC) Content-Type: text/plain; charset="utf-8" This brings about a couple of benefits: - use of VIR_AUTOUNREF() simplifies several callers - Fixes a todo about virDomainMomentObjList not being polymorphic enough Signed-off-by: Eric Blake --- src/conf/moment_conf.h | 5 ++++- src/conf/snapshot_conf.h | 1 - cfg.mk | 2 -- src/conf/moment_conf.c | 28 ++++++++++++++++++++++++- src/conf/snapshot_conf.c | 34 ++++++++++++++++++++++--------- src/conf/virdomainmomentobjlist.c | 3 +-- src/esx/esx_driver.c | 3 +-- src/libvirt_private.syms | 1 - src/qemu/qemu_driver.c | 5 ++--- src/test/test_driver.c | 5 ++--- src/vbox/vbox_common.c | 6 ++---- src/vz/vz_driver.c | 3 +-- tests/domainsnapshotxml2xmltest.c | 3 +-- 13 files changed, 65 insertions(+), 34 deletions(-) diff --git a/src/conf/moment_conf.h b/src/conf/moment_conf.h index 04e0c0648b..00ec1c1904 100644 --- a/src/conf/moment_conf.h +++ b/src/conf/moment_conf.h @@ -25,9 +25,12 @@ # include "internal.h" # include "virconftypes.h" +# include "virobject.h" /* Base class for a domain moment */ struct _virDomainMomentDef { + virObject parent; + /* Common portion of public XML. */ char *name; char *description; @@ -37,7 +40,7 @@ struct _virDomainMomentDef { virDomainDefPtr dom; }; -void virDomainMomentDefClear(virDomainMomentDefPtr def); +virClassPtr virClassForDomainMomentDef(void); int virDomainMomentDefPostParse(virDomainMomentDefPtr def); diff --git a/src/conf/snapshot_conf.h b/src/conf/snapshot_conf.h index 0ce9dda355..55b7487cfb 100644 --- a/src/conf/snapshot_conf.h +++ b/src/conf/snapshot_conf.h @@ -115,7 +115,6 @@ virDomainSnapshotDefPtr virDomainSnapshotDefParseNode(x= mlDocPtr xml, bool *current, unsigned int flags); virDomainSnapshotDefPtr virDomainSnapshotDefNew(void); -void virDomainSnapshotDefFree(virDomainSnapshotDefPtr def); char *virDomainSnapshotDefFormat(const char *uuidstr, virDomainSnapshotDefPtr def, virCapsPtr caps, diff --git a/cfg.mk b/cfg.mk index b785089910..786aa6e80a 100644 --- a/cfg.mk +++ b/cfg.mk @@ -133,7 +133,6 @@ useless_free_options =3D \ --name=3DvirDomainNetDefFree \ --name=3DvirDomainObjFree \ --name=3DvirDomainSmartcardDefFree \ - --name=3DvirDomainSnapshotDefFree \ --name=3DvirDomainSnapshotObjFree \ --name=3DvirDomainSoundDefFree \ --name=3DvirDomainVideoDefFree \ @@ -211,7 +210,6 @@ useless_free_options =3D \ # y virDomainInputDefFree # y virDomainNetDefFree # y virDomainObjFree -# y virDomainSnapshotDefFree # n virDomainSnapshotFree (returns int) # n virDomainSnapshotFreeName (returns int) # y virDomainSnapshotObjFree diff --git a/src/conf/moment_conf.c b/src/conf/moment_conf.c index 9829775b3c..fea13f0f97 100644 --- a/src/conf/moment_conf.c +++ b/src/conf/moment_conf.c @@ -34,8 +34,34 @@ VIR_LOG_INIT("conf.moment_conf"); -void virDomainMomentDefClear(virDomainMomentDefPtr def) +static virClassPtr virDomainMomentDefClass; +static void virDomainMomentDefDispose(void *obj); + +static int +virDomainMomentOnceInit(void) { + if (!VIR_CLASS_NEW(virDomainMomentDef, virClassForObject())) + return -1; + + return 0; +} + +VIR_ONCE_GLOBAL_INIT(virDomainMoment); + +virClassPtr +virClassForDomainMomentDef(void) +{ + if (virDomainMomentInitialize() < 0) + return NULL; + + return virDomainMomentDefClass; +} + +static void +virDomainMomentDefDispose(void *obj) +{ + virDomainMomentDefPtr def =3D obj; + VIR_FREE(def->name); VIR_FREE(def->description); VIR_FREE(def->parent_name); diff --git a/src/conf/snapshot_conf.c b/src/conf/snapshot_conf.c index e5771ae635..c7f29360e7 100644 --- a/src/conf/snapshot_conf.c +++ b/src/conf/snapshot_conf.c @@ -50,6 +50,20 @@ VIR_LOG_INIT("conf.snapshot_conf"); +static virClassPtr virDomainSnapshotDefClass; +static void virDomainSnapshotDefDispose(void *obj); + +static int +virDomainSnapshotOnceInit(void) +{ + if (!VIR_CLASS_NEW(virDomainSnapshotDef, virClassForDomainMomentDef())) + return -1; + + return 0; +} + +VIR_ONCE_GLOBAL_INIT(virDomainSnapshot); + VIR_ENUM_IMPL(virDomainSnapshotLocation, VIR_DOMAIN_SNAPSHOT_LOCATION_LAST, "default", @@ -81,30 +95,30 @@ virDomainSnapshotDiskDefClear(virDomainSnapshotDiskDefP= tr disk) disk->src =3D NULL; } +/* Allocate a new virDomainSnapshotDef; free with virObjectUnref() */ virDomainSnapshotDefPtr virDomainSnapshotDefNew(void) { virDomainSnapshotDefPtr def; - ignore_value(VIR_ALLOC(def)); + if (virDomainSnapshotInitialize() < 0) + return NULL; + + def =3D virObjectNew(virDomainSnapshotDefClass); return def; } -void -virDomainSnapshotDefFree(virDomainSnapshotDefPtr def) +static void +virDomainSnapshotDefDispose(void *obj) { + virDomainSnapshotDefPtr def =3D obj; size_t i; - if (!def) - return; - - virDomainMomentDefClear(&def->parent); VIR_FREE(def->file); for (i =3D 0; i < def->ndisks; i++) virDomainSnapshotDiskDefClear(&def->disks[i]); VIR_FREE(def->disks); virObjectUnref(def->cookie); - VIR_FREE(def); } static int @@ -374,7 +388,7 @@ virDomainSnapshotDefParse(xmlXPathContextPtr ctxt, VIR_FREE(nodes); VIR_FREE(memorySnapshot); VIR_FREE(memoryFile); - virDomainSnapshotDefFree(def); + virObjectUnref(def); return ret; } @@ -996,7 +1010,7 @@ virDomainSnapshotRedefinePrep(virDomainPtr domain, /* Drop and rebuild the parent relationship, but keep all * child relations by reusing snap. */ virDomainMomentDropParent(other); - virDomainSnapshotDefFree(otherdef); + virObjectUnref(otherdef); other->def =3D &(*defptr)->parent; *defptr =3D NULL; *snap =3D other; diff --git a/src/conf/virdomainmomentobjlist.c b/src/conf/virdomainmomentob= jlist.c index e9df66c65b..f56b516343 100644 --- a/src/conf/virdomainmomentobjlist.c +++ b/src/conf/virdomainmomentobjlist.c @@ -208,8 +208,7 @@ virDomainMomentObjFree(virDomainMomentObjPtr moment) VIR_DEBUG("obj=3D%p", moment); - /* FIXME: Make this polymorphic by inheriting from virObject */ - virDomainSnapshotDefFree(virDomainSnapshotObjGetDef(moment)); + virObjectUnref(moment->def); VIR_FREE(moment); } diff --git a/src/esx/esx_driver.c b/src/esx/esx_driver.c index f45d96a4f5..deb800a6b7 100644 --- a/src/esx/esx_driver.c +++ b/src/esx/esx_driver.c @@ -4081,7 +4081,6 @@ esxDomainSnapshotCreateXML(virDomainPtr domain, const= char *xmlDesc, unsigned int flags) { esxPrivate *priv =3D domain->conn->privateData; - virDomainSnapshotDefPtr def =3D NULL; esxVI_ObjectContent *virtualMachine =3D NULL; esxVI_VirtualMachineSnapshotTree *rootSnapshotList =3D NULL; esxVI_VirtualMachineSnapshotTree *snapshotTree =3D NULL; @@ -4091,6 +4090,7 @@ esxDomainSnapshotCreateXML(virDomainPtr domain, const= char *xmlDesc, virDomainSnapshotPtr snapshot =3D NULL; bool diskOnly =3D (flags & VIR_DOMAIN_SNAPSHOT_CREATE_DISK_ONLY) !=3D = 0; bool quiesce =3D (flags & VIR_DOMAIN_SNAPSHOT_CREATE_QUIESCE) !=3D 0; + VIR_AUTOUNREF(virDomainSnapshotDefPtr) def =3D NULL; /* ESX supports disk-only and quiesced snapshots; libvirt tracks no * snapshot metadata so supporting that flag is trivial. */ @@ -4151,7 +4151,6 @@ esxDomainSnapshotCreateXML(virDomainPtr domain, const= char *xmlDesc, snapshot =3D virGetDomainSnapshot(domain, def->parent.name); cleanup: - virDomainSnapshotDefFree(def); esxVI_ObjectContent_Free(&virtualMachine); esxVI_VirtualMachineSnapshotTree_Free(&rootSnapshotList); esxVI_ManagedObjectReference_Free(&task); diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index 0474a4e44c..909975750c 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -892,7 +892,6 @@ virSecretEventValueChangedNew; # conf/snapshot_conf.h virDomainSnapshotAlignDisks; virDomainSnapshotDefFormat; -virDomainSnapshotDefFree; virDomainSnapshotDefIsExternal; virDomainSnapshotDefNew; virDomainSnapshotDefParseString; diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index 833c1e88ee..2877642c4c 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -481,7 +481,7 @@ qemuDomainSnapshotLoad(virDomainObjPtr vm, snap =3D virDomainSnapshotAssignDef(vm->snapshots, def); if (snap =3D=3D NULL) { - virDomainSnapshotDefFree(def); + virObjectUnref(def); } else if (cur) { if (current) virReportError(VIR_ERR_INTERNAL_ERROR, @@ -15552,7 +15552,6 @@ qemuDomainSnapshotCreateXML(virDomainPtr domain, char *xml =3D NULL; virDomainMomentObjPtr snap =3D NULL; virDomainSnapshotPtr snapshot =3D NULL; - virDomainSnapshotDefPtr def =3D NULL; virDomainMomentObjPtr current =3D NULL; bool update_current =3D true; bool redefine =3D flags & VIR_DOMAIN_SNAPSHOT_CREATE_REDEFINE; @@ -15564,6 +15563,7 @@ qemuDomainSnapshotCreateXML(virDomainPtr domain, virCapsPtr caps =3D NULL; qemuDomainObjPrivatePtr priv; virDomainSnapshotState state; + VIR_AUTOFREE(virDomainSnapshotDefPtr) def =3D NULL; virCheckFlags(VIR_DOMAIN_SNAPSHOT_CREATE_REDEFINE | VIR_DOMAIN_SNAPSHOT_CREATE_CURRENT | @@ -15831,7 +15831,6 @@ qemuDomainSnapshotCreateXML(virDomainPtr domain, cleanup: virDomainObjEndAPI(&vm); - virDomainSnapshotDefFree(def); VIR_FREE(xml); virObjectUnref(caps); virObjectUnref(cfg); diff --git a/src/test/test_driver.c b/src/test/test_driver.c index aaf67eaac9..a06d1fc402 100644 --- a/src/test/test_driver.c +++ b/src/test/test_driver.c @@ -848,7 +848,7 @@ testParseDomainSnapshots(testDriverPtr privconn, goto error; if (!(snap =3D virDomainSnapshotAssignDef(domobj->snapshots, def))= ) { - virDomainSnapshotDefFree(def); + virObjectUnref(def); goto error; } @@ -6348,13 +6348,13 @@ testDomainSnapshotCreateXML(virDomainPtr domain, { testDriverPtr privconn =3D domain->conn->privateData; virDomainObjPtr vm =3D NULL; - virDomainSnapshotDefPtr def =3D NULL; virDomainMomentObjPtr snap =3D NULL; virDomainSnapshotPtr snapshot =3D NULL; virObjectEventPtr event =3D NULL; bool update_current =3D true; bool redefine =3D flags & VIR_DOMAIN_SNAPSHOT_CREATE_REDEFINE; unsigned int parse_flags =3D VIR_DOMAIN_SNAPSHOT_PARSE_DISKS; + VIR_AUTOUNREF(virDomainSnapshotDefPtr) def =3D NULL; /* * DISK_ONLY: Not implemented yet @@ -6448,7 +6448,6 @@ testDomainSnapshotCreateXML(virDomainPtr domain, virDomainObjEndAPI(&vm); } virObjectEventStateQueue(privconn->eventState, event); - virDomainSnapshotDefFree(def); return snapshot; } diff --git a/src/vbox/vbox_common.c b/src/vbox/vbox_common.c index 7e42f6a4fe..54e31bec9d 100644 --- a/src/vbox/vbox_common.c +++ b/src/vbox/vbox_common.c @@ -5476,7 +5476,6 @@ vboxDomainSnapshotCreateXML(virDomainPtr dom, unsigned int flags) { vboxDriverPtr data =3D dom->conn->privateData; - virDomainSnapshotDefPtr def =3D NULL; vboxIID domiid; IMachine *machine =3D NULL; IConsole *console =3D NULL; @@ -5488,6 +5487,7 @@ vboxDomainSnapshotCreateXML(virDomainPtr dom, nsresult rc; resultCodeUnion result; virDomainSnapshotPtr ret =3D NULL; + VIR_AUTOUNREF(virDomainSnapshotDefPtr) def =3D NULL; if (!data->vboxObj) return ret; @@ -5587,7 +5587,6 @@ vboxDomainSnapshotCreateXML(virDomainPtr dom, gVBoxAPI.UISession.Close(data->vboxSession); VBOX_RELEASE(machine); vboxIIDUnalloc(&domiid); - virDomainSnapshotDefFree(def); return ret; } @@ -6200,7 +6199,6 @@ static char *vboxDomainSnapshotGetXMLDesc(virDomainSn= apshotPtr snapshot, ISnapshot *snap =3D NULL; ISnapshot *parent =3D NULL; nsresult rc; - virDomainSnapshotDefPtr def =3D NULL; PRUnichar *str16; char *str8; PRInt64 timestamp; @@ -6208,6 +6206,7 @@ static char *vboxDomainSnapshotGetXMLDesc(virDomainSn= apshotPtr snapshot, char uuidstr[VIR_UUID_STRING_BUFLEN]; char *ret =3D NULL; virDomainDefPtr defdom; + VIR_AUTOUNREF(virDomainSnapshotDefPtr) def =3D NULL; if (!data->vboxObj) return ret; @@ -6330,7 +6329,6 @@ static char *vboxDomainSnapshotGetXMLDesc(virDomainSn= apshotPtr snapshot, ret =3D virDomainSnapshotDefFormat(uuidstr, def, data->caps, data->xml= opt, 0); cleanup: - virDomainSnapshotDefFree(def); VBOX_RELEASE(parent); VBOX_RELEASE(snap); VBOX_RELEASE(machine); diff --git a/src/vz/vz_driver.c b/src/vz/vz_driver.c index 419e9d215f..dfd49e7cc7 100644 --- a/src/vz/vz_driver.c +++ b/src/vz/vz_driver.c @@ -2576,7 +2576,6 @@ vzDomainSnapshotCreateXML(virDomainPtr domain, const char *xmlDesc, unsigned int flags) { - virDomainSnapshotDefPtr def =3D NULL; virDomainSnapshotPtr snapshot =3D NULL; virDomainObjPtr dom; vzConnPtr privconn =3D domain->conn->privateData; @@ -2585,6 +2584,7 @@ vzDomainSnapshotCreateXML(virDomainPtr domain, virDomainSnapshotObjListPtr snapshots =3D NULL; virDomainMomentObjPtr current; bool job =3D false; + VIR_AUTOUNREF(virDomainSnapshotDefPtr) def =3D NULL; virCheckFlags(0, NULL); @@ -2636,7 +2636,6 @@ vzDomainSnapshotCreateXML(virDomainPtr domain, cleanup: virDomainSnapshotObjListFree(snapshots); - virDomainSnapshotDefFree(def); if (job) vzDomainObjEndJob(dom); virDomainObjEndAPI(&dom); diff --git a/tests/domainsnapshotxml2xmltest.c b/tests/domainsnapshotxml2xm= ltest.c index 18ff2dc34c..c2c7bedb56 100644 --- a/tests/domainsnapshotxml2xmltest.c +++ b/tests/domainsnapshotxml2xmltest.c @@ -35,10 +35,10 @@ testCompareXMLToXMLFiles(const char *inxml, char *outXmlData =3D NULL; char *actual =3D NULL; int ret =3D -1; - virDomainSnapshotDefPtr def =3D NULL; unsigned int parseflags =3D VIR_DOMAIN_SNAPSHOT_PARSE_DISKS; unsigned int formatflags =3D VIR_DOMAIN_SNAPSHOT_FORMAT_SECURE; bool cur =3D false; + VIR_AUTOUNREF(virDomainSnapshotDefPtr) def =3D NULL; if (flags & TEST_INTERNAL) { parseflags |=3D VIR_DOMAIN_SNAPSHOT_PARSE_INTERNAL; @@ -85,7 +85,6 @@ testCompareXMLToXMLFiles(const char *inxml, VIR_FREE(inXmlData); VIR_FREE(outXmlData); VIR_FREE(actual); - virDomainSnapshotDefFree(def); return ret; } --=20 2.20.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list