Pull out the common parts of virDomainSnapshotDef that will be reused
for virDomainCheckpointDef into a new base class. Adjust all callers
that use the direct fields (some of it is churn that disappears when
the next patch refactors virDomainSnapshotObj; oh well...).
Signed-off-by: Eric Blake <eblake(a)redhat.com>
---
src/conf/moment_conf.h | 41 +++++++++
src/conf/snapshot_conf.h | 11 +--
src/conf/virconftypes.h | 3 +
src/conf/Makefile.inc.am | 2 +
src/conf/moment_conf.c | 40 +++++++++
src/conf/snapshot_conf.c | 128 ++++++++++++++--------------
src/conf/virdomainsnapshotobj.c | 2 +-
src/conf/virdomainsnapshotobjlist.c | 21 ++---
src/esx/esx_driver.c | 16 ++--
src/qemu/qemu_command.c | 2 +-
src/qemu/qemu_domain.c | 18 ++--
src/qemu/qemu_driver.c | 50 +++++------
src/test/test_driver.c | 42 ++++-----
src/vbox/vbox_common.c | 88 +++++++++----------
14 files changed, 273 insertions(+), 191 deletions(-)
create mode 100644 src/conf/moment_conf.h
create mode 100644 src/conf/moment_conf.c
diff --git a/src/conf/moment_conf.h b/src/conf/moment_conf.h
new file mode 100644
index 0000000000..348cfe5a5c
--- /dev/null
+++ b/src/conf/moment_conf.h
@@ -0,0 +1,41 @@
+/*
+ * moment_conf.h: domain snapshot/checkpoint base class
+ *
+ * Copyright (C) 2006-2019 Red Hat, Inc.
+ * Copyright (C) 2006-2008 Daniel P. Berrange
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library. If not, see
+ * <
http://www.gnu.org/licenses/>.
+ */
+
+#ifndef LIBVIRT_MOMENT_CONF_H
+# define LIBVIRT_MOMENT_CONF_H
+
+# include "internal.h"
+# include "virconftypes.h"
+
+/* Base class for a domain moment */
+struct _virDomainMomentDef {
+ /* Common portion of public XML. */
+ char *name;
+ char *description;
+ char *parent;
+ long long creationTime; /* in seconds */
+
+ virDomainDefPtr dom;
+};
+
+void virDomainMomentDefClear(virDomainMomentDefPtr def);
+
+#endif /* LIBVIRT_MOMENT_CONF_H */
diff --git a/src/conf/snapshot_conf.h b/src/conf/snapshot_conf.h
index b13a500af4..4b777e94dc 100644
--- a/src/conf/snapshot_conf.h
+++ b/src/conf/snapshot_conf.h
@@ -24,6 +24,7 @@
# include "internal.h"
# include "domain_conf.h"
+# include "moment_conf.h"
/* Items related to snapshot state */
@@ -72,11 +73,9 @@ struct _virDomainSnapshotDiskDef {
/* Stores the complete snapshot metadata */
struct _virDomainSnapshotDef {
- /* Public XML. */
- char *name;
- char *description;
- char *parent;
- long long creationTime; /* in seconds */
+ virDomainMomentDef common;
+
+ /* Additional public XML. */
int state; /* virDomainSnapshotState */
int memory; /* virDomainMemorySnapshot */
@@ -85,8 +84,6 @@ struct _virDomainSnapshotDef {
size_t ndisks; /* should not exceed dom->ndisks */
virDomainSnapshotDiskDef *disks;
- virDomainDefPtr dom;
-
virObjectPtr cookie;
};
diff --git a/src/conf/virconftypes.h b/src/conf/virconftypes.h
index 3265c0468a..9b9ab314e7 100644
--- a/src/conf/virconftypes.h
+++ b/src/conf/virconftypes.h
@@ -217,6 +217,9 @@ typedef virDomainMemoryDef *virDomainMemoryDefPtr;
typedef struct _virDomainMemtune virDomainMemtune;
typedef virDomainMemtune *virDomainMemtunePtr;
+typedef struct _virDomainMomentDef virDomainMomentDef;
+typedef virDomainMomentDef *virDomainMomentDefPtr;
+
typedef struct _virDomainNVRAMDef virDomainNVRAMDef;
typedef virDomainNVRAMDef *virDomainNVRAMDefPtr;
diff --git a/src/conf/Makefile.inc.am b/src/conf/Makefile.inc.am
index 9b4d80485b..d2ff8be8fd 100644
--- a/src/conf/Makefile.inc.am
+++ b/src/conf/Makefile.inc.am
@@ -22,6 +22,8 @@ DOMAIN_CONF_SOURCES = \
conf/domain_nwfilter.h \
conf/virsavecookie.c \
conf/virsavecookie.h \
+ conf/moment_conf.c \
+ conf/moment_conf.h \
conf/snapshot_conf.c \
conf/snapshot_conf.h \
conf/numa_conf.c \
diff --git a/src/conf/moment_conf.c b/src/conf/moment_conf.c
new file mode 100644
index 0000000000..f9276a5d1e
--- /dev/null
+++ b/src/conf/moment_conf.c
@@ -0,0 +1,40 @@
+/*
+ * moment_conf.c: domain snapshot/checkpoint base class
+ *
+ * Copyright (C) 2006-2019 Red Hat, Inc.
+ * Copyright (C) 2006-2008 Daniel P. Berrange
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library. If not, see
+ * <
http://www.gnu.org/licenses/>.
+ */
+
+#include <config.h>
+
+#include "internal.h"
+#include "moment_conf.h"
+#include "domain_conf.h"
+#include "virlog.h"
+#include "viralloc.h"
+
+#define VIR_FROM_THIS VIR_FROM_DOMAIN_SNAPSHOT
+
+VIR_LOG_INIT("conf.moment_conf");
+
+void virDomainMomentDefClear(virDomainMomentDefPtr def)
+{
+ VIR_FREE(def->name);
+ VIR_FREE(def->description);
+ VIR_FREE(def->parent);
+ virDomainDefFree(def->dom);
+}
diff --git a/src/conf/snapshot_conf.c b/src/conf/snapshot_conf.c
index aec23f111c..b80b199ce4 100644
--- a/src/conf/snapshot_conf.c
+++ b/src/conf/snapshot_conf.c
@@ -87,14 +87,11 @@ void virDomainSnapshotDefFree(virDomainSnapshotDefPtr def)
if (!def)
return;
- VIR_FREE(def->name);
- VIR_FREE(def->description);
- VIR_FREE(def->parent);
+ virDomainMomentDefClear(&def->common);
VIR_FREE(def->file);
for (i = 0; i < def->ndisks; i++)
virDomainSnapshotDiskDefClear(&def->disks[i]);
VIR_FREE(def->disks);
- virDomainDefFree(def->dom);
virObjectUnref(def->cookie);
VIR_FREE(def);
}
@@ -213,28 +210,28 @@ virDomainSnapshotDefParse(xmlXPathContextPtr ctxt,
gettimeofday(&tv, NULL);
- def->name = virXPathString("string(./name)", ctxt);
- if (def->name == NULL) {
+ def->common.name = virXPathString("string(./name)", ctxt);
+ if (def->common.name == NULL) {
if (flags & VIR_DOMAIN_SNAPSHOT_PARSE_REDEFINE) {
virReportError(VIR_ERR_XML_ERROR, "%s",
_("a redefined snapshot must have a name"));
goto cleanup;
}
- if (virAsprintf(&def->name, "%lld", (long long)tv.tv_sec) <
0)
+ if (virAsprintf(&def->common.name, "%lld", (long long)tv.tv_sec)
< 0)
goto cleanup;
}
- def->description = virXPathString("string(./description)", ctxt);
+ def->common.description = virXPathString("string(./description)",
ctxt);
if (flags & VIR_DOMAIN_SNAPSHOT_PARSE_REDEFINE) {
if (virXPathLongLong("string(./creationTime)", ctxt,
- &def->creationTime) < 0) {
+ &def->common.creationTime) < 0) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("missing creationTime from existing snapshot"));
goto cleanup;
}
- def->parent = virXPathString("string(./parent/name)", ctxt);
+ def->common.parent = virXPathString("string(./parent/name)", ctxt);
state = virXPathString("string(./state)", ctxt);
if (state == NULL) {
@@ -270,15 +267,15 @@ virDomainSnapshotDefParse(xmlXPathContextPtr ctxt,
_("missing domain in snapshot"));
goto cleanup;
}
- def->dom = virDomainDefParseNode(ctxt->node->doc, domainNode,
- caps, xmlopt, NULL, domainflags);
- if (!def->dom)
+ def->common.dom = virDomainDefParseNode(ctxt->node->doc,
domainNode,
+ caps, xmlopt, NULL, domainflags);
+ if (!def->common.dom)
goto cleanup;
} else {
VIR_WARN("parsing older snapshot that lacks domain");
}
} else {
- def->creationTime = tv.tv_sec;
+ def->common.creationTime = tv.tv_sec;
}
memorySnapshot = virXPathString("string(./memory/@snapshot)", ctxt);
@@ -424,7 +421,7 @@ virDomainSnapshotDefParseString(const char *xmlStr,
/* Perform sanity checking on a redefined snapshot definition. If
- * @other is non-NULL, this may include swapping def->dom from other
+ * @other is non-NULL, this may include swapping def->common.dom from other
* into def. */
int
virDomainSnapshotRedefineValidate(virDomainSnapshotDefPtr def,
@@ -442,16 +439,17 @@ virDomainSnapshotRedefineValidate(virDomainSnapshotDefPtr def,
virReportError(VIR_ERR_INVALID_ARG,
_("disk-only flag for snapshot %s requires "
"disk-snapshot state"),
- def->name);
+ def->common.name);
return -1;
}
- if (def->dom && memcmp(def->dom->uuid, domain_uuid,
VIR_UUID_BUFLEN)) {
+ if (def->common.dom && memcmp(def->common.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->name, uuidstr);
+ def->common.name, uuidstr);
return -1;
}
@@ -465,7 +463,7 @@ virDomainSnapshotRedefineValidate(virDomainSnapshotDefPtr def,
virReportError(VIR_ERR_INVALID_ARG,
_("cannot change between online and offline "
"snapshot state in snapshot %s"),
- def->name);
+ def->common.name);
return -1;
}
@@ -474,24 +472,24 @@ virDomainSnapshotRedefineValidate(virDomainSnapshotDefPtr def,
virReportError(VIR_ERR_INVALID_ARG,
_("cannot change between disk only and "
"full system in snapshot %s"),
- def->name);
+ def->common.name);
return -1;
}
- if (otherdef->dom) {
- if (def->dom) {
- if (!virDomainDefCheckABIStability(otherdef->dom,
- def->dom, xmlopt))
+ if (otherdef->common.dom) {
+ if (def->common.dom) {
+ if (!virDomainDefCheckABIStability(otherdef->common.dom,
+ def->common.dom, xmlopt))
return -1;
} else {
/* Transfer the domain def */
- def->dom = otherdef->dom;
- otherdef->dom = NULL;
+ def->common.dom = otherdef->common.dom;
+ otherdef->common.dom = NULL;
}
}
}
- if (def->dom) {
+ if (def->common.dom) {
if (external) {
align_location = VIR_DOMAIN_SNAPSHOT_LOCATION_EXTERNAL;
align_match = false;
@@ -538,7 +536,7 @@ virDomainSnapshotDefAssignExternalNames(virDomainSnapshotDefPtr def)
return -1;
}
- if (!(origpath = virDomainDiskGetSource(def->dom->disks[i]))) {
+ if (!(origpath = virDomainDiskGetSource(def->common.dom->disks[i]))) {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
_("cannot generate external snapshot name "
"for disk '%s' without source"),
@@ -562,7 +560,7 @@ virDomainSnapshotDefAssignExternalNames(virDomainSnapshotDefPtr def)
if ((tmp = strrchr(tmppath, '.')) && !strchr(tmp, '/'))
*tmp = '\0';
- if (virAsprintf(&disk->src->path, "%s.%s", tmppath,
def->name) < 0) {
+ if (virAsprintf(&disk->src->path, "%s.%s", tmppath,
def->common.name) < 0) {
VIR_FREE(tmppath);
return -1;
}
@@ -595,7 +593,7 @@ virDomainSnapshotCompareDiskIndex(const void *a, const void *b)
return diska->idx - diskb->idx;
}
-/* Align def->disks to def->domain. Sort the list of def->disks,
+/* Align def->disks to def->common.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
@@ -612,31 +610,31 @@ virDomainSnapshotAlignDisks(virDomainSnapshotDefPtr def,
size_t i;
int ndisks;
- if (!def->dom) {
+ if (!def->common.dom) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("missing domain in snapshot"));
goto cleanup;
}
- if (def->ndisks > def->dom->ndisks) {
+ if (def->ndisks > def->common.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->dom->ndisks) {
+ if (!def->common.dom->ndisks) {
ret = 0;
goto cleanup;
}
- if (!(map = virBitmapNew(def->dom->ndisks)))
+ if (!(map = virBitmapNew(def->common.dom->ndisks)))
goto cleanup;
/* Double check requested disks. */
for (i = 0; i < def->ndisks; i++) {
virDomainSnapshotDiskDefPtr disk = &def->disks[i];
- int idx = virDomainDiskIndexByName(def->dom, disk->name, false);
+ int idx = virDomainDiskIndexByName(def->common.dom, disk->name, false);
int disk_snapshot;
if (idx < 0) {
@@ -654,7 +652,7 @@ virDomainSnapshotAlignDisks(virDomainSnapshotDefPtr def,
ignore_value(virBitmapSetBit(map, idx));
disk->idx = idx;
- disk_snapshot = def->dom->disks[idx]->snapshot;
+ disk_snapshot = def->common.dom->disks[idx]->snapshot;
if (!disk->snapshot) {
if (disk_snapshot &&
(!require_match ||
@@ -682,9 +680,9 @@ virDomainSnapshotAlignDisks(virDomainSnapshotDefPtr def,
disk->src->path, disk->name);
goto cleanup;
}
- if (STRNEQ(disk->name, def->dom->disks[idx]->dst)) {
+ if (STRNEQ(disk->name, def->common.dom->disks[idx]->dst)) {
VIR_FREE(disk->name);
- if (VIR_STRDUP(disk->name, def->dom->disks[idx]->dst) < 0)
+ if (VIR_STRDUP(disk->name, def->common.dom->disks[idx]->dst) <
0)
goto cleanup;
}
}
@@ -692,10 +690,10 @@ virDomainSnapshotAlignDisks(virDomainSnapshotDefPtr def,
/* Provide defaults for all remaining disks. */
ndisks = def->ndisks;
if (VIR_EXPAND_N(def->disks, def->ndisks,
- def->dom->ndisks - def->ndisks) < 0)
+ def->common.dom->ndisks - def->ndisks) < 0)
goto cleanup;
- for (i = 0; i < def->dom->ndisks; i++) {
+ for (i = 0; i < def->common.dom->ndisks; i++) {
virDomainSnapshotDiskDefPtr disk;
if (virBitmapIsBitSet(map, i))
@@ -703,15 +701,15 @@ virDomainSnapshotAlignDisks(virDomainSnapshotDefPtr def,
disk = &def->disks[ndisks++];
if (!(disk->src = virStorageSourceNew()))
goto cleanup;
- if (VIR_STRDUP(disk->name, def->dom->disks[i]->dst) < 0)
+ if (VIR_STRDUP(disk->name, def->common.dom->disks[i]->dst) < 0)
goto cleanup;
disk->idx = i;
/* Don't snapshot empty drives */
- if (virStorageSourceIsEmpty(def->dom->disks[i]->src))
+ if (virStorageSourceIsEmpty(def->common.dom->disks[i]->src))
disk->snapshot = VIR_DOMAIN_SNAPSHOT_LOCATION_NONE;
else
- disk->snapshot = def->dom->disks[i]->snapshot;
+ disk->snapshot = def->common.dom->disks[i]->snapshot;
disk->src->type = VIR_STORAGE_TYPE_FILE;
if (!disk->snapshot)
@@ -802,23 +800,23 @@ virDomainSnapshotDefFormatInternal(virBufferPtr buf,
virBufferAddLit(buf, "<domainsnapshot>\n");
virBufferAdjustIndent(buf, 2);
- virBufferEscapeString(buf, "<name>%s</name>\n", def->name);
- if (def->description)
+ virBufferEscapeString(buf, "<name>%s</name>\n",
def->common.name);
+ if (def->common.description)
virBufferEscapeString(buf,
"<description>%s</description>\n",
- def->description);
+ def->common.description);
virBufferAsprintf(buf, "<state>%s</state>\n",
virDomainSnapshotStateTypeToString(def->state));
- if (def->parent) {
+ if (def->common.parent) {
virBufferAddLit(buf, "<parent>\n");
virBufferAdjustIndent(buf, 2);
- virBufferEscapeString(buf, "<name>%s</name>\n",
def->parent);
+ virBufferEscapeString(buf, "<name>%s</name>\n",
def->common.parent);
virBufferAdjustIndent(buf, -2);
virBufferAddLit(buf, "</parent>\n");
}
virBufferAsprintf(buf, "<creationTime>%lld</creationTime>\n",
- def->creationTime);
+ def->common.creationTime);
if (def->memory) {
virBufferAsprintf(buf, "<memory snapshot='%s'",
@@ -838,8 +836,8 @@ virDomainSnapshotDefFormatInternal(virBufferPtr buf,
virBufferAddLit(buf, "</disks>\n");
}
- if (def->dom) {
- if (virDomainDefFormatInternal(def->dom, caps, domainflags, buf,
+ if (def->common.dom) {
+ if (virDomainDefFormatInternal(def->common.dom, caps, domainflags, buf,
xmlopt) < 0)
goto error;
} else if (uuidstr) {
@@ -931,30 +929,30 @@ virDomainSnapshotRedefinePrep(virDomainPtr domain,
bool check_if_stolen;
/* Prevent circular chains */
- if (def->parent) {
- if (STREQ(def->name, def->parent)) {
+ if (def->common.parent) {
+ if (STREQ(def->common.name, def->common.parent)) {
virReportError(VIR_ERR_INVALID_ARG,
_("cannot set snapshot %s as its own parent"),
- def->name);
+ def->common.name);
return -1;
}
- other = virDomainSnapshotFindByName(vm->snapshots, def->parent);
+ other = virDomainSnapshotFindByName(vm->snapshots, def->common.parent);
if (!other) {
virReportError(VIR_ERR_INVALID_ARG,
_("parent %s for snapshot %s not found"),
- def->parent, def->name);
+ def->common.parent, def->common.name);
return -1;
}
otherdef = virDomainSnapshotObjGetDef(other);
- while (otherdef->parent) {
- if (STREQ(otherdef->parent, def->name)) {
+ while (otherdef->common.parent) {
+ if (STREQ(otherdef->common.parent, def->common.name)) {
virReportError(VIR_ERR_INVALID_ARG,
_("parent %s would create cycle to %s"),
- otherdef->name, def->name);
+ otherdef->common.name, def->common.name);
return -1;
}
other = virDomainSnapshotFindByName(vm->snapshots,
- otherdef->parent);
+ otherdef->common.parent);
if (!other) {
VIR_WARN("snapshots are inconsistent for %s",
vm->def->name);
@@ -963,15 +961,15 @@ virDomainSnapshotRedefinePrep(virDomainPtr domain,
}
}
- other = virDomainSnapshotFindByName(vm->snapshots, def->name);
+ other = virDomainSnapshotFindByName(vm->snapshots, def->common.name);
otherdef = other ? virDomainSnapshotObjGetDef(other) : NULL;
- check_if_stolen = other && otherdef->dom;
+ check_if_stolen = other && otherdef->common.dom;
if (virDomainSnapshotRedefineValidate(def, domain->uuid, other, xmlopt,
flags) < 0) {
/* revert any stealing of the snapshot domain definition */
- if (check_if_stolen && def->dom && !otherdef->dom) {
- otherdef->dom = def->dom;
- def->dom = NULL;
+ if (check_if_stolen && def->common.dom &&
!otherdef->common.dom) {
+ otherdef->common.dom = def->common.dom;
+ def->common.dom = NULL;
}
return -1;
}
diff --git a/src/conf/virdomainsnapshotobj.c b/src/conf/virdomainsnapshotobj.c
index d6b216c7b2..0e3ee012fc 100644
--- a/src/conf/virdomainsnapshotobj.c
+++ b/src/conf/virdomainsnapshotobj.c
@@ -45,7 +45,7 @@ virDomainSnapshotForEachChild(virDomainSnapshotObjPtr snapshot,
while (child) {
virDomainSnapshotObjPtr next = child->sibling;
- (iter)(child, child->def->name, data);
+ (iter)(child, child->def->common.name, data);
child = next;
}
diff --git a/src/conf/virdomainsnapshotobjlist.c b/src/conf/virdomainsnapshotobjlist.c
index cd3ea569e3..58f094fa02 100644
--- a/src/conf/virdomainsnapshotobjlist.c
+++ b/src/conf/virdomainsnapshotobjlist.c
@@ -240,10 +240,10 @@ virDomainSnapshotObjPtr
virDomainSnapshotAssignDef(virDomainSnapshotObjListPtr s
{
virDomainSnapshotObjPtr snap;
- if (virHashLookup(snapshots->objs, def->name) != NULL) {
+ if (virHashLookup(snapshots->objs, def->common.name) != NULL) {
virReportError(VIR_ERR_INTERNAL_ERROR,
_("unexpected domain snapshot %s already exists"),
- def->name);
+ def->common.name);
return NULL;
}
@@ -251,7 +251,7 @@ virDomainSnapshotObjPtr
virDomainSnapshotAssignDef(virDomainSnapshotObjListPtr s
return NULL;
snap->def = def;
- if (virHashAddEntry(snapshots->objs, snap->def->name, snap) < 0) {
+ if (virHashAddEntry(snapshots->objs, snap->def->common.name, snap) < 0)
{
VIR_FREE(snap);
return NULL;
}
@@ -354,7 +354,7 @@ static int virDomainSnapshotObjListCopyNames(void *payload,
return 0;
if (data->names && data->count < data->maxnames &&
- VIR_STRDUP(data->names[data->count], obj->def->name) < 0) {
+ VIR_STRDUP(data->names[data->count], obj->def->common.name) < 0)
{
data->error = true;
return 0;
}
@@ -475,7 +475,7 @@ const char *
virDomainSnapshotGetCurrentName(virDomainSnapshotObjListPtr snapshots)
{
if (snapshots->current)
- return snapshots->current->def->name;
+ return snapshots->current->def->common.name;
return NULL;
}
@@ -485,7 +485,8 @@ bool
virDomainSnapshotIsCurrentName(virDomainSnapshotObjListPtr snapshots,
const char *name)
{
- return snapshots->current && STREQ(snapshots->current->def->name,
name);
+ return snapshots->current &&
STREQ(snapshots->current->def->common.name,
+ name);
}
@@ -503,7 +504,7 @@ bool virDomainSnapshotObjListRemove(virDomainSnapshotObjListPtr
snapshots,
virDomainSnapshotObjPtr snapshot)
{
bool ret = snapshots->current == snapshot;
- virHashRemoveEntry(snapshots->objs, snapshot->def->name);
+ virHashRemoveEntry(snapshots->objs, snapshot->def->common.name);
if (ret)
snapshots->current = NULL;
return ret;
@@ -547,18 +548,18 @@ virDomainSnapshotSetRelations(void *payload,
virDomainSnapshotObjPtr tmp;
virDomainSnapshotObjPtr parent;
- parent = virDomainSnapshotFindByName(curr->snapshots, obj->def->parent);
+ parent = virDomainSnapshotFindByName(curr->snapshots,
obj->def->common.parent);
if (!parent) {
curr->err = -1;
parent = &curr->snapshots->metaroot;
- VIR_WARN("snapshot %s lacks parent", obj->def->name);
+ VIR_WARN("snapshot %s lacks parent", obj->def->common.name);
} else {
tmp = parent;
while (tmp && tmp->def) {
if (tmp == obj) {
curr->err = -1;
parent = &curr->snapshots->metaroot;
- VIR_WARN("snapshot %s in circular chain",
obj->def->name);
+ VIR_WARN("snapshot %s in circular chain",
obj->def->common.name);
break;
}
tmp = tmp->parent;
diff --git a/src/esx/esx_driver.c b/src/esx/esx_driver.c
index 1c6a2dcb71..5cf881ae35 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->name,
+ esxVI_GetSnapshotTreeByName(rootSnapshotList, def->common.name,
&snapshotTree, NULL,
esxVI_Occurrence_OptionalItem) < 0) {
goto cleanup;
@@ -4126,12 +4126,12 @@ esxDomainSnapshotCreateXML(virDomainPtr domain, const char
*xmlDesc,
if (snapshotTree) {
virReportError(VIR_ERR_OPERATION_INVALID,
- _("Snapshot '%s' already exists"),
def->name);
+ _("Snapshot '%s' already exists"),
def->common.name);
goto cleanup;
}
if (esxVI_CreateSnapshot_Task(priv->primary, virtualMachine->obj,
- def->name, def->description,
+ def->common.name, def->common.description,
diskOnly ? esxVI_Boolean_False : esxVI_Boolean_True,
quiesce ? esxVI_Boolean_True : esxVI_Boolean_False,
&task) < 0 ||
@@ -4148,7 +4148,7 @@ esxDomainSnapshotCreateXML(virDomainPtr domain, const char
*xmlDesc,
goto cleanup;
}
- snapshot = virGetDomainSnapshot(domain, def->name);
+ snapshot = virGetDomainSnapshot(domain, def->common.name);
cleanup:
virDomainSnapshotDefFree(def);
@@ -4189,12 +4189,12 @@ esxDomainSnapshotGetXMLDesc(virDomainSnapshotPtr snapshot,
goto cleanup;
}
- def.name = virSnapName(snapshot);
- def.description = snapshotTree->description;
- def.parent = snapshotTreeParent ? snapshotTreeParent->name : NULL;
+ def.common.name = virSnapName(snapshot);
+ def.common.description = snapshotTree->description;
+ def.common.parent = snapshotTreeParent ? snapshotTreeParent->name : NULL;
if (esxVI_DateTime_ConvertToCalendarTime(snapshotTree->createTime,
- &def.creationTime) < 0) {
+ &def.common.creationTime) < 0) {
goto cleanup;
}
diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index bc02362495..000da64d0e 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -10859,7 +10859,7 @@ qemuBuildCommandLine(virQEMUDriverPtr driver,
goto error;
if (snapshot)
- virCommandAddArgList(cmd, "-loadvm", snapshot->def->name, NULL);
+ virCommandAddArgList(cmd, "-loadvm", snapshot->def->common.name,
NULL);
if (def->namespaceData) {
qemuDomainCmdlineDefPtr qemucmd;
diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
index e693a3b122..8e02f05c3c 100644
--- a/src/qemu/qemu_domain.c
+++ b/src/qemu/qemu_domain.c
@@ -8477,7 +8477,7 @@ qemuDomainSnapshotWriteMetadata(virDomainObjPtr vm,
goto cleanup;
}
- if (virAsprintf(&snapFile, "%s/%s.xml", snapDir, def->name) < 0)
+ if (virAsprintf(&snapFile, "%s/%s.xml", snapDir, def->common.name)
< 0)
goto cleanup;
ret = virXMLSaveFile(snapFile, NULL, "snapshot-edit", newxml);
@@ -8573,11 +8573,11 @@ qemuDomainSnapshotForEachQcow2(virQEMUDriverPtr driver,
/* Prefer action on the disks in use at the time the snapshot was
* created; but fall back to current definition if dealing with a
* snapshot created prior to libvirt 0.9.5. */
- virDomainDefPtr def = snap->def->dom;
+ virDomainDefPtr def = snap->def->common.dom;
if (!def)
def = vm->def;
- return qemuDomainSnapshotForEachQcow2Raw(driver, def, snap->def->name,
+ return qemuDomainSnapshotForEachQcow2Raw(driver, def, snap->def->common.name,
op, try_all, def->ndisks);
}
@@ -8605,30 +8605,30 @@ qemuDomainSnapshotDiscard(virQEMUDriverPtr driver,
priv = vm->privateData;
qemuDomainObjEnterMonitor(driver, vm);
/* we continue on even in the face of error */
- qemuMonitorDeleteSnapshot(priv->mon, snap->def->name);
+ qemuMonitorDeleteSnapshot(priv->mon, snap->def->common.name);
ignore_value(qemuDomainObjExitMonitor(driver, vm));
}
}
if (virAsprintf(&snapFile, "%s/%s/%s.xml", cfg->snapshotDir,
- vm->def->name, snap->def->name) < 0)
+ vm->def->name, snap->def->common.name) < 0)
goto cleanup;
if (snap == virDomainSnapshotGetCurrent(vm->snapshots)) {
virDomainSnapshotSetCurrent(vm->snapshots, NULL);
- if (update_parent && snap->def->parent) {
+ if (update_parent && snap->def->common.parent) {
parentsnap = virDomainSnapshotFindByName(vm->snapshots,
- snap->def->parent);
+ snap->def->common.parent);
if (!parentsnap) {
VIR_WARN("missing parent snapshot matching name '%s'",
- snap->def->parent);
+ snap->def->common.parent);
} 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
current",
- snap->def->parent);
+ snap->def->common.parent);
virDomainSnapshotSetCurrent(vm->snapshots, NULL);
}
}
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index eb3d112b69..ece9c9329e 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -14547,7 +14547,7 @@ qemuDomainSnapshotCreateInactiveExternal(virQEMUDriverPtr driver,
* create them correctly. */
for (i = 0; i < snap->def->ndisks && !reuse; i++) {
snapdisk = &(snap->def->disks[i]);
- defdisk = snap->def->dom->disks[snapdisk->idx];
+ defdisk = snap->def->common.dom->disks[snapdisk->idx];
if (snapdisk->snapshot != VIR_DOMAIN_SNAPSHOT_LOCATION_EXTERNAL)
continue;
@@ -14663,7 +14663,7 @@ qemuDomainSnapshotCreateActiveInternal(virQEMUDriverPtr driver,
goto cleanup;
}
- ret = qemuMonitorCreateSnapshot(priv->mon, snap->def->name);
+ ret = qemuMonitorCreateSnapshot(priv->mon, snap->def->common.name);
if (qemuDomainObjExitMonitor(driver, vm) < 0)
ret = -1;
if (ret < 0)
@@ -15726,19 +15726,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->name, '/')) {
+ if (strchr(def->common.name, '/')) {
virReportError(VIR_ERR_XML_DETAIL,
_("invalid snapshot name '%s': "
"name can't contain '/'"),
- def->name);
+ def->common.name);
goto cleanup;
}
- if (def->name[0] == '.') {
+ if (def->common.name[0] == '.') {
virReportError(VIR_ERR_XML_DETAIL,
_("invalid snapshot name '%s': "
"name can't start with '.'"),
- def->name);
+ def->common.name);
goto cleanup;
}
}
@@ -15809,9 +15809,9 @@ qemuDomainSnapshotCreateXML(virDomainPtr domain,
* conversion in and back out of xml. */
if (!(xml = qemuDomainDefFormatLive(driver, vm->def, priv->origCPU,
true, true)) ||
- !(def->dom = virDomainDefParseString(xml, caps, driver->xmlopt, NULL,
- VIR_DOMAIN_DEF_PARSE_INACTIVE |
- VIR_DOMAIN_DEF_PARSE_SKIP_VALIDATE)))
+ !(def->common.dom = virDomainDefParseString(xml, caps, driver->xmlopt,
NULL,
+ VIR_DOMAIN_DEF_PARSE_INACTIVE |
+
VIR_DOMAIN_DEF_PARSE_SKIP_VALIDATE)))
goto endjob;
if (flags & VIR_DOMAIN_SNAPSHOT_CREATE_DISK_ONLY) {
@@ -15857,7 +15857,7 @@ qemuDomainSnapshotCreateXML(virDomainPtr domain,
current = virDomainSnapshotGetCurrent(vm->snapshots);
if (current) {
if (!redefine &&
- VIR_STRDUP(snap->def->parent, current->def->name) < 0)
+ VIR_STRDUP(snap->def->common.parent, current->def->common.name)
< 0)
goto endjob;
if (update_current) {
virDomainSnapshotSetCurrent(vm->snapshots, NULL);
@@ -15906,7 +15906,7 @@ qemuDomainSnapshotCreateXML(virDomainPtr domain,
* do; we've successfully taken the snapshot, and we are now running
* on it, so we have to go forward the best we can
*/
- snapshot = virGetDomainSnapshot(domain, snap->def->name);
+ snapshot = virGetDomainSnapshot(domain, snap->def->common.name);
endjob:
if (snapshot && !(flags & VIR_DOMAIN_SNAPSHOT_CREATE_NO_METADATA)) {
@@ -15921,11 +15921,11 @@ qemuDomainSnapshotCreateXML(virDomainPtr domain,
snapshot = NULL;
virReportError(VIR_ERR_INTERNAL_ERROR,
_("unable to save metadata for snapshot %s"),
- snap->def->name);
+ snap->def->common.name);
virDomainSnapshotObjListRemove(vm->snapshots, snap);
} else {
other = virDomainSnapshotFindByName(vm->snapshots,
- snap->def->parent);
+ snap->def->common.parent);
virDomainSnapshotSetParent(snap, other);
}
} else if (snap) {
@@ -16135,7 +16135,7 @@ qemuDomainSnapshotLookupByName(virDomainPtr domain,
if (!(snap = qemuSnapObjFromName(vm, name)))
goto cleanup;
- snapshot = virGetDomainSnapshot(domain, snap->def->name);
+ snapshot = virGetDomainSnapshot(domain, snap->def->common.name);
cleanup:
virDomainObjEndAPI(&vm);
@@ -16185,14 +16185,14 @@ qemuDomainSnapshotGetParent(virDomainSnapshotPtr snapshot,
if (!(snap = qemuSnapObjFromSnapshot(vm, snapshot)))
goto cleanup;
- if (!snap->def->parent) {
+ if (!snap->def->common.parent) {
virReportError(VIR_ERR_NO_DOMAIN_SNAPSHOT,
_("snapshot '%s' does not have a parent"),
- snap->def->name);
+ snap->def->common.name);
goto cleanup;
}
- parent = virGetDomainSnapshot(virSnapDom(snapshot), snap->def->parent);
+ parent = virGetDomainSnapshot(virSnapDom(snapshot), snap->def->common.parent);
cleanup:
virDomainObjEndAPI(&vm);
@@ -16417,10 +16417,10 @@ qemuDomainRevertToSnapshot(virDomainSnapshotPtr snapshot,
}
if (!(flags & VIR_DOMAIN_SNAPSHOT_REVERT_FORCE)) {
- if (!snap->def->dom) {
+ if (!snap->def->common.dom) {
virReportError(VIR_ERR_SNAPSHOT_REVERT_RISKY,
_("snapshot '%s' lacks domain '%s'
rollback info"),
- snap->def->name, vm->def->name);
+ snap->def->common.name, vm->def->name);
goto endjob;
}
if (virDomainObjIsActive(vm) &&
@@ -16450,8 +16450,8 @@ qemuDomainRevertToSnapshot(virDomainSnapshotPtr snapshot,
*
* XXX Should domain snapshots track live xml rather
* than inactive xml? */
- if (snap->def->dom) {
- config = virDomainDefCopy(snap->def->dom, caps,
+ if (snap->def->common.dom) {
+ config = virDomainDefCopy(snap->def->common.dom, caps,
driver->xmlopt, NULL, true);
if (!config)
goto endjob;
@@ -16557,7 +16557,7 @@ qemuDomainRevertToSnapshot(virDomainSnapshotPtr snapshot,
if (qemuDomainObjEnterMonitorAsync(driver, vm,
QEMU_ASYNC_JOB_START) < 0)
goto endjob;
- rc = qemuMonitorLoadSnapshot(priv->mon, snap->def->name);
+ rc = qemuMonitorLoadSnapshot(priv->mon, snap->def->common.name);
if (qemuDomainObjExitMonitor(driver, vm) < 0)
goto endjob;
if (rc < 0) {
@@ -16774,10 +16774,10 @@ qemuDomainSnapshotReparentChildren(void *payload,
if (rep->err < 0)
return 0;
- VIR_FREE(snap->def->parent);
+ VIR_FREE(snap->def->common.parent);
if (rep->parent->def &&
- VIR_STRDUP(snap->def->parent, rep->parent->def->name) < 0) {
+ VIR_STRDUP(snap->def->common.parent,
rep->parent->def->common.name) < 0) {
rep->err = -1;
return 0;
}
@@ -16858,7 +16858,7 @@ qemuDomainSnapshotDelete(virDomainSnapshotPtr snapshot,
cfg->snapshotDir) < 0) {
virReportError(VIR_ERR_INTERNAL_ERROR,
_("failed to set snapshot '%s' as
current"),
- snap->def->name);
+ snap->def->common.name);
virDomainSnapshotSetCurrent(vm->snapshots, NULL);
goto endjob;
}
diff --git a/src/test/test_driver.c b/src/test/test_driver.c
index d3b76bfdbd..0caed1de19 100644
--- a/src/test/test_driver.c
+++ b/src/test/test_driver.c
@@ -6132,7 +6132,7 @@ testDomainSnapshotLookupByName(virDomainPtr domain,
if (!(snap = testSnapObjFromName(vm, name)))
goto cleanup;
- snapshot = virGetDomainSnapshot(domain, snap->def->name);
+ snapshot = virGetDomainSnapshot(domain, snap->def->common.name);
cleanup:
virDomainObjEndAPI(&vm);
@@ -6173,14 +6173,14 @@ testDomainSnapshotGetParent(virDomainSnapshotPtr snapshot,
if (!(snap = testSnapObjFromSnapshot(vm, snapshot)))
goto cleanup;
- if (!snap->def->parent) {
+ if (!snap->def->common.parent) {
virReportError(VIR_ERR_NO_DOMAIN_SNAPSHOT,
_("snapshot '%s' does not have a parent"),
- snap->def->name);
+ snap->def->common.name);
goto cleanup;
}
- parent = virGetDomainSnapshot(virSnapDom(snapshot), snap->def->parent);
+ parent = virGetDomainSnapshot(virSnapDom(snapshot), snap->def->common.parent);
cleanup:
virDomainObjEndAPI(&vm);
@@ -6207,7 +6207,7 @@ testDomainSnapshotCurrent(virDomainPtr domain,
goto cleanup;
}
- snapshot = virGetDomainSnapshot(domain, current->def->name);
+ snapshot = virGetDomainSnapshot(domain, current->def->common.name);
cleanup:
virDomainObjEndAPI(&vm);
@@ -6376,11 +6376,11 @@ testDomainSnapshotCreateXML(virDomainPtr domain,
&update_current, flags) < 0)
goto cleanup;
} else {
- if (!(def->dom = virDomainDefCopy(vm->def,
- privconn->caps,
- privconn->xmlopt,
- NULL,
- true)))
+ if (!(def->common.dom = virDomainDefCopy(vm->def,
+ privconn->caps,
+ privconn->xmlopt,
+ NULL,
+ true)))
goto cleanup;
if (testDomainSnapshotAlignDisks(vm, def, flags) < 0)
@@ -6394,7 +6394,7 @@ testDomainSnapshotCreateXML(virDomainPtr domain,
}
if (!redefine) {
- if (VIR_STRDUP(snap->def->parent,
+ if (VIR_STRDUP(snap->def->common.parent,
virDomainSnapshotGetCurrentName(vm->snapshots)) < 0)
goto cleanup;
@@ -6407,7 +6407,7 @@ testDomainSnapshotCreateXML(virDomainPtr domain,
}
}
- snapshot = virGetDomainSnapshot(domain, snap->def->name);
+ snapshot = virGetDomainSnapshot(domain, snap->def->common.name);
cleanup:
if (vm) {
if (snapshot) {
@@ -6415,7 +6415,7 @@ testDomainSnapshotCreateXML(virDomainPtr domain,
if (update_current)
virDomainSnapshotSetCurrent(vm->snapshots, snap);
other = virDomainSnapshotFindByName(vm->snapshots,
- snap->def->parent);
+ snap->def->common.parent);
virDomainSnapshotSetParent(snap, other);
}
virDomainObjEndAPI(&vm);
@@ -6464,10 +6464,10 @@ testDomainSnapshotReparentChildren(void *payload,
if (rep->err < 0)
return 0;
- VIR_FREE(snap->def->parent);
+ VIR_FREE(snap->def->common.parent);
if (rep->parent->def &&
- VIR_STRDUP(snap->def->parent, rep->parent->def->name) < 0) {
+ VIR_STRDUP(snap->def->common.parent,
rep->parent->def->common.name) < 0) {
rep->err = -1;
return 0;
}
@@ -6522,12 +6522,12 @@ testDomainSnapshotDelete(virDomainSnapshotPtr snapshot,
} else {
virDomainSnapshotDropParent(snap);
if (snap == virDomainSnapshotGetCurrent(vm->snapshots)) {
- if (snap->def->parent) {
+ if (snap->def->common.parent) {
parentsnap = virDomainSnapshotFindByName(vm->snapshots,
- snap->def->parent);
+
snap->def->common.parent);
if (!parentsnap)
VIR_WARN("missing parent snapshot matching name
'%s'",
- snap->def->parent);
+ snap->def->common.parent);
}
virDomainSnapshotSetCurrent(vm->snapshots, parentsnap);
}
@@ -6588,10 +6588,10 @@ testDomainRevertToSnapshot(virDomainSnapshotPtr snapshot,
}
if (!(flags & VIR_DOMAIN_SNAPSHOT_REVERT_FORCE)) {
- if (!snap->def->dom) {
+ if (!snap->def->common.dom) {
virReportError(VIR_ERR_SNAPSHOT_REVERT_RISKY,
_("snapshot '%s' lacks domain '%s'
rollback info"),
- snap->def->name, vm->def->name);
+ snap->def->common.name, vm->def->name);
goto cleanup;
}
if (virDomainObjIsActive(vm) &&
@@ -6607,7 +6607,7 @@ testDomainRevertToSnapshot(virDomainSnapshotPtr snapshot,
virDomainSnapshotSetCurrent(vm->snapshots, NULL);
- config = virDomainDefCopy(snap->def->dom, privconn->caps,
+ config = virDomainDefCopy(snap->def->common.dom, privconn->caps,
privconn->xmlopt, NULL, true);
if (!config)
goto cleanup;
diff --git a/src/vbox/vbox_common.c b/src/vbox/vbox_common.c
index 2ca12a28e5..fb8fc3a10c 100644
--- a/src/vbox/vbox_common.c
+++ b/src/vbox/vbox_common.c
@@ -4814,7 +4814,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 = 0; it < def->dom->ndisks; it++) {
+ for (it = 0; it < def->common.dom->ndisks; it++) {
int diskInMediaRegistry = 0;
IMedium *readOnlyMedium = NULL;
PRUnichar *locationUtf = NULL;
@@ -4828,7 +4828,7 @@ vboxSnapshotRedefine(virDomainPtr dom,
VBOX_IID_INITIALIZE(&iid);
VBOX_IID_INITIALIZE(&parentiid);
diskInMediaRegistry =
virVBoxSnapshotConfDiskIsInMediaRegistry(snapshotMachineDesc,
-
def->dom->disks[it]->src->path);
+
def->common.dom->disks[it]->src->path);
if (diskInMediaRegistry == -1) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("Unable to know if disk is in media registry"));
@@ -4838,7 +4838,7 @@ vboxSnapshotRedefine(virDomainPtr dom,
continue;
/*The read only disk is not in the media registry*/
- VBOX_UTF8_TO_UTF16(def->dom->disks[it]->src->path,
&locationUtf);
+ VBOX_UTF8_TO_UTF16(def->common.dom->disks[it]->src->path,
&locationUtf);
rc = gVBoxAPI.UIVirtualBox.OpenMedium(data->vboxObj,
locationUtf,
DeviceType_HardDisk,
@@ -4911,7 +4911,7 @@ vboxSnapshotRedefine(virDomainPtr dom,
readOnlyDisk->format = format;
readOnlyDisk->uuid = uuid;
- if (VIR_STRDUP(readOnlyDisk->location,
def->dom->disks[it]->src->path) < 0) {
+ if (VIR_STRDUP(readOnlyDisk->location,
def->common.dom->disks[it]->src->path) < 0) {
VIR_FREE(readOnlyDisk);
goto cleanup;
}
@@ -5016,12 +5016,12 @@ vboxSnapshotRedefine(virDomainPtr dom,
goto cleanup;
VIR_DEBUG("New snapshot UUID: %s", newSnapshotPtr->uuid);
- if (VIR_STRDUP(newSnapshotPtr->name, def->name) < 0)
+ if (VIR_STRDUP(newSnapshotPtr->name, def->common.name) < 0)
goto cleanup;
- newSnapshotPtr->timeStamp = virTimeStringThen(def->creationTime * 1000);
+ newSnapshotPtr->timeStamp = virTimeStringThen(def->common.creationTime *
1000);
- if (VIR_STRDUP(newSnapshotPtr->description, def->description) < 0)
+ if (VIR_STRDUP(newSnapshotPtr->description, def->common.description) < 0)
goto cleanup;
if (VIR_STRDUP(newSnapshotPtr->hardware, snapshotMachineDesc->hardware) <
0)
@@ -5031,12 +5031,12 @@ vboxSnapshotRedefine(virDomainPtr dom,
goto cleanup;
/*We get the parent disk uuid from the parent disk location to correctly fill the
storage controller.*/
- for (it = 0; it < def->dom->ndisks; it++) {
+ for (it = 0; it < def->common.dom->ndisks; it++) {
char *location = NULL;
const char *uuidReplacing = NULL;
char *tmp = NULL;
- location = def->dom->disks[it]->src->path;
+ location = def->common.dom->disks[it]->src->path;
if (!location)
goto cleanup;
/*Replacing the uuid*/
@@ -5064,7 +5064,7 @@ vboxSnapshotRedefine(virDomainPtr dom,
VIR_FREE(tmp);
}
- if (virVBoxSnapshotConfAddSnapshotToXmlMachine(newSnapshotPtr, snapshotMachineDesc,
def->parent) < 0) {
+ if (virVBoxSnapshotConfAddSnapshotToXmlMachine(newSnapshotPtr, snapshotMachineDesc,
def->common.parent) < 0) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("Unable to add the snapshot to the machine
description"));
goto cleanup;
@@ -5084,10 +5084,10 @@ vboxSnapshotRedefine(virDomainPtr dom,
* Open the snapshot's read-write disk's full ancestry to allow opening the
* read-write disk itself.
*/
- for (it = 0; it < def->dom->ndisks; it++) {
+ for (it = 0; it < def->common.dom->ndisks; it++) {
char *location = NULL;
- location = def->dom->disks[it]->src->path;
+ location = def->common.dom->disks[it]->src->path;
if (!location)
goto cleanup;
@@ -5231,7 +5231,7 @@ vboxSnapshotRedefine(virDomainPtr dom,
}
} else {
/*Create a "fake" disk to avoid corrupting children snapshot disks.*/
- for (it = 0; it < def->dom->ndisks; it++) {
+ for (it = 0; it < def->common.dom->ndisks; it++) {
IMedium *medium = NULL;
PRUnichar *locationUtf16 = NULL;
char *parentUuid = NULL;
@@ -5247,7 +5247,7 @@ vboxSnapshotRedefine(virDomainPtr dom,
VBOX_IID_INITIALIZE(&iid);
VBOX_IID_INITIALIZE(&parentiid);
- VBOX_UTF8_TO_UTF16(def->dom->disks[it]->src->path,
&locationUtf16);
+ VBOX_UTF8_TO_UTF16(def->common.dom->disks[it]->src->path,
&locationUtf16);
rc = gVBoxAPI.UIVirtualBox.OpenMedium(data->vboxObj,
locationUtf16,
DeviceType_HardDisk,
@@ -5396,8 +5396,8 @@ vboxSnapshotRedefine(virDomainPtr dom,
* All the snapshot structure manipulation is done, we close the disks we have
* previously opened.
*/
- for (it = 0; it < def->dom->ndisks; it++) {
- char *location = def->dom->disks[it]->src->path;
+ for (it = 0; it < def->common.dom->ndisks; it++) {
+ char *location = def->common.dom->disks[it]->src->path;
if (!location)
goto cleanup;
@@ -5516,7 +5516,7 @@ vboxDomainSnapshotCreateXML(virDomainPtr dom,
if (flags & VIR_DOMAIN_SNAPSHOT_CREATE_REDEFINE) {
if (vboxSnapshotRedefine(dom, def, isCurrent) < 0)
goto cleanup;
- ret = virGetDomainSnapshot(dom, def->name);
+ ret = virGetDomainSnapshot(dom, def->common.name);
goto cleanup;
}
}
@@ -5543,14 +5543,14 @@ vboxDomainSnapshotCreateXML(virDomainPtr dom,
goto cleanup;
}
- VBOX_UTF8_TO_UTF16(def->name, &name);
+ VBOX_UTF8_TO_UTF16(def->common.name, &name);
if (!name) {
virReportOOMError();
goto cleanup;
}
- if (def->description) {
- VBOX_UTF8_TO_UTF16(def->description, &description);
+ if (def->common.description) {
+ VBOX_UTF8_TO_UTF16(def->common.description, &description);
if (!description) {
virReportOOMError();
goto cleanup;
@@ -5580,7 +5580,7 @@ vboxDomainSnapshotCreateXML(virDomainPtr dom,
goto cleanup;
}
- ret = virGetDomainSnapshot(dom, def->name);
+ ret = virGetDomainSnapshot(dom, def->common.name);
cleanup:
VBOX_RELEASE(progress);
@@ -5984,7 +5984,7 @@ vboxSnapshotGetReadOnlyDisks(virDomainSnapshotDefPtr def,
vboxArray mediumAttachments = VBOX_ARRAY_INITIALIZER;
size_t i = 0, diskCount = 0, sdCount = 0;
int ret = -1;
- virDomainDefPtr defdom = def->dom;
+ virDomainDefPtr defdom = def->common.dom;
if (!data->vboxObj)
return ret;
@@ -6223,10 +6223,10 @@ static char *vboxDomainSnapshotGetXMLDesc(virDomainSnapshotPtr
snapshot,
if (!(snap = vboxDomainSnapshotGet(data, dom, machine, virSnapName(snapshot))))
goto cleanup;
- if (VIR_ALLOC(def) < 0 || !(def->dom = virDomainDefNew()))
+ if (VIR_ALLOC(def) < 0 || !(def->common.dom = virDomainDefNew()))
goto cleanup;
- defdom = def->dom;
- if (VIR_STRDUP(def->name, virSnapName(snapshot)) < 0)
+ defdom = def->common.dom;
+ if (VIR_STRDUP(def->common.name, virSnapName(snapshot)) < 0)
goto cleanup;
if (gVBoxAPI.vboxSnapshotRedefine) {
@@ -6274,7 +6274,7 @@ static char *vboxDomainSnapshotGetXMLDesc(virDomainSnapshotPtr
snapshot,
if (str16) {
VBOX_UTF16_TO_UTF8(str16, &str8);
VBOX_UTF16_FREE(str16);
- if (VIR_STRDUP(def->description, str8) < 0) {
+ if (VIR_STRDUP(def->common.description, str8) < 0) {
VBOX_UTF8_FREE(str8);
goto cleanup;
}
@@ -6289,7 +6289,7 @@ static char *vboxDomainSnapshotGetXMLDesc(virDomainSnapshotPtr
snapshot,
goto cleanup;
}
/* timestamp is in milliseconds while creationTime in seconds */
- def->creationTime = timestamp / 1000;
+ def->common.creationTime = timestamp / 1000;
rc = gVBoxAPI.UISnapshot.GetParent(snap, &parent);
if (NS_FAILED(rc)) {
@@ -6308,7 +6308,7 @@ static char *vboxDomainSnapshotGetXMLDesc(virDomainSnapshotPtr
snapshot,
}
VBOX_UTF16_TO_UTF8(str16, &str8);
VBOX_UTF16_FREE(str16);
- if (VIR_STRDUP(def->parent, str8) < 0) {
+ if (VIR_STRDUP(def->common.parent, str8) < 0) {
VBOX_UTF8_FREE(str8);
goto cleanup;
}
@@ -6990,7 +6990,7 @@ vboxDomainSnapshotDeleteMetadataOnly(virDomainSnapshotPtr snapshot)
goto cleanup;
}
- isCurrent = virVBoxSnapshotConfIsCurrentSnapshot(snapshotMachineDesc, def->name);
+ isCurrent = virVBoxSnapshotConfIsCurrentSnapshot(snapshotMachineDesc,
def->common.name);
if (isCurrent < 0) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("Unable to know if the snapshot is the current
snapshot"));
@@ -7002,8 +7002,8 @@ vboxDomainSnapshotDeleteMetadataOnly(virDomainSnapshotPtr snapshot)
* disks. The first thing to do is to manipulate VirtualBox API to create
* differential read-write disks if the parent snapshot is not null.
*/
- if (def->parent != NULL) {
- for (it = 0; it < def->dom->ndisks; it++) {
+ if (def->common.parent != NULL) {
+ for (it = 0; it < def->common.dom->ndisks; it++) {
virVBoxSnapshotConfHardDiskPtr readOnly = NULL;
IMedium *medium = NULL;
PRUnichar *locationUtf16 = NULL;
@@ -7023,7 +7023,7 @@ vboxDomainSnapshotDeleteMetadataOnly(virDomainSnapshotPtr snapshot)
VBOX_IID_INITIALIZE(&iid);
VBOX_IID_INITIALIZE(&parentiid);
readOnly = virVBoxSnapshotConfHardDiskPtrByLocation(snapshotMachineDesc,
-
def->dom->disks[it]->src->path);
+
def->common.dom->disks[it]->src->path);
if (!readOnly) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("Cannot get hard disk by location"));
@@ -7061,7 +7061,7 @@ vboxDomainSnapshotDeleteMetadataOnly(virDomainSnapshotPtr snapshot)
VBOX_UTF8_TO_UTF16("VDI", &formatUtf16);
if (virAsprintf(&newLocationUtf8, "%sfakedisk-%s-%d.vdi",
- machineLocationPath, def->parent, it) < 0)
+ machineLocationPath, def->common.parent, it) < 0)
goto cleanup;
VBOX_UTF8_TO_UTF16(newLocationUtf8, &newLocation);
rc = gVBoxAPI.UIVirtualBox.CreateHardDisk(data->vboxObj,
@@ -7159,15 +7159,15 @@ vboxDomainSnapshotDeleteMetadataOnly(virDomainSnapshotPtr
snapshot)
}
}
} else {
- for (it = 0; it < def->dom->ndisks; it++) {
+ for (it = 0; it < def->common.dom->ndisks; it++) {
const char *uuidRO = NULL;
char *tmp = NULL;
uuidRO = virVBoxSnapshotConfHardDiskUuidByLocation(snapshotMachineDesc,
-
def->dom->disks[it]->src->path);
+
def->common.dom->disks[it]->src->path);
if (!uuidRO) {
virReportError(VIR_ERR_INTERNAL_ERROR,
_("No such disk in media registry %s"),
- def->dom->disks[it]->src->path);
+ def->common.dom->disks[it]->src->path);
goto cleanup;
}
@@ -7212,14 +7212,14 @@ vboxDomainSnapshotDeleteMetadataOnly(virDomainSnapshotPtr
snapshot)
}
}
/*If the parent snapshot is not NULL, we remove the-read only disks from the media
registry*/
- if (def->parent != NULL) {
- for (it = 0; it < def->dom->ndisks; it++) {
+ if (def->common.parent != NULL) {
+ for (it = 0; it < def->common.dom->ndisks; it++) {
const char *uuidRO =
virVBoxSnapshotConfHardDiskUuidByLocation(snapshotMachineDesc,
-
def->dom->disks[it]->src->path);
+
def->common.dom->disks[it]->src->path);
if (!uuidRO) {
virReportError(VIR_ERR_INTERNAL_ERROR,
- _("Unable to find UUID for location %s"),
def->dom->disks[it]->src->path);
+ _("Unable to find UUID for location %s"),
def->common.dom->disks[it]->src->path);
goto cleanup;
}
if (virVBoxSnapshotConfRemoveHardDisk(snapshotMachineDesc->mediaRegistry,
uuidRO) < 0) {
@@ -7284,16 +7284,16 @@ vboxDomainSnapshotDeleteMetadataOnly(virDomainSnapshotPtr
snapshot)
}
/*removing the snapshot*/
- if (virVBoxSnapshotConfRemoveSnapshot(snapshotMachineDesc, def->name) < 0) {
+ if (virVBoxSnapshotConfRemoveSnapshot(snapshotMachineDesc, def->common.name) <
0) {
virReportError(VIR_ERR_INTERNAL_ERROR,
- _("Unable to remove snapshot %s"), def->name);
+ _("Unable to remove snapshot %s"),
def->common.name);
goto cleanup;
}
if (isCurrent) {
VIR_FREE(snapshotMachineDesc->currentSnapshot);
- if (def->parent != NULL) {
- virVBoxSnapshotConfSnapshotPtr snap =
virVBoxSnapshotConfSnapshotByName(snapshotMachineDesc->snapshot, def->parent);
+ if (def->common.parent != NULL) {
+ virVBoxSnapshotConfSnapshotPtr snap =
virVBoxSnapshotConfSnapshotByName(snapshotMachineDesc->snapshot,
def->common.parent);
if (!snap) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("Unable to get the snapshot to remove"));
--
2.20.1