Upcoming patches want to add virDomainCheckpoint that behaves very
similarly to virDomainCheckpoint; the easiest way to share common code
is to give both classes a common base class. If this were C++, we'd
just use public member inheritance; but since it is C, we instead have
to touch EVERY use of member fields that will be relocated. To avoid
having to make future edits, wrap the majority of accesses behind
static inline functions, so that we only have to touch one place when
changing class inheritance; and temporarily rename the members to let
the compiler ensure we caught all uses.
Signed-off-by: Eric Blake <eblake(a)redhat.com>
---
src/datatypes.h | 22 +++++++---
src/datatypes.c | 10 ++---
src/esx/esx_driver.c | 66 ++++++++++++++---------------
src/libvirt-domain-snapshot.c | 24 +++++------
src/qemu/qemu_driver.c | 40 ++++++++---------
src/remote/remote_daemon_dispatch.c | 4 +-
src/remote/remote_driver.c | 4 +-
src/rpc/gendispatch.pl | 2 +-
src/test/test_driver.c | 20 ++++-----
src/vbox/vbox_common.c | 56 ++++++++++++------------
src/vz/vz_driver.c | 52 +++++++++++------------
11 files changed, 156 insertions(+), 144 deletions(-)
diff --git a/src/datatypes.h b/src/datatypes.h
index 12015679f3..dcba279bec 100644
--- a/src/datatypes.h
+++ b/src/datatypes.h
@@ -1,7 +1,7 @@
/*
* datatypes.h: management of structs for public data types
*
- * Copyright (C) 2006-2015 Red Hat, Inc.
+ * Copyright (C) 2006-2019 Red Hat, Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@@ -296,8 +296,8 @@ extern virClassPtr virAdmClientClass;
do { \
virDomainSnapshotPtr _snap = (obj); \
if (!virObjectIsClass(_snap, virDomainSnapshotClass) || \
- !virObjectIsClass(_snap->domain, virDomainClass) || \
- !virObjectIsClass(_snap->domain->conn, virConnectClass)) { \
+ !virObjectIsClass(virSnapDom(_snap), virDomainClass) || \
+ !virObjectIsClass(virSnapDom(_snap)->conn, virConnectClass)) { \
virReportErrorHelper(VIR_FROM_DOMAIN_SNAPSHOT, \
VIR_ERR_INVALID_DOMAIN_SNAPSHOT, \
__FILE__, __FUNCTION__, __LINE__, \
@@ -675,10 +675,22 @@ struct _virStream {
*/
struct _virDomainSnapshot {
virObject parent;
- char *name;
- virDomainPtr domain;
+ char *_name;
+ virDomainPtr _domain;
};
+static inline char *
+virSnapName(virDomainSnapshotPtr snapshot)
+{
+ return snapshot->_name;
+}
+
+static inline virDomainPtr
+virSnapDom(virDomainSnapshotPtr snapshot)
+{
+ return snapshot->_domain;
+}
+
/**
* _virNWFilter:
*
diff --git a/src/datatypes.c b/src/datatypes.c
index 9b92d892d5..916c259a6e 100644
--- a/src/datatypes.c
+++ b/src/datatypes.c
@@ -923,10 +923,10 @@ virGetDomainSnapshot(virDomainPtr domain, const char *name)
if (!(ret = virObjectNew(virDomainSnapshotClass)))
goto error;
- if (VIR_STRDUP(ret->name, name) < 0)
+ if (VIR_STRDUP(ret->_name, name) < 0)
goto error;
- ret->domain = virObjectRef(domain);
+ ret->_domain = virObjectRef(domain);
return ret;
@@ -950,10 +950,10 @@ static void
virDomainSnapshotDispose(void *obj)
{
virDomainSnapshotPtr snapshot = obj;
- VIR_DEBUG("release snapshot %p %s", snapshot, snapshot->name);
+ VIR_DEBUG("release snapshot %p %s", snapshot, snapshot->_name);
- VIR_FREE(snapshot->name);
- virObjectUnref(snapshot->domain);
+ VIR_FREE(snapshot->_name);
+ virObjectUnref(snapshot->_domain);
}
diff --git a/src/esx/esx_driver.c b/src/esx/esx_driver.c
index c6d112268f..c016f8051f 100644
--- a/src/esx/esx_driver.c
+++ b/src/esx/esx_driver.c
@@ -4166,7 +4166,7 @@ static char *
esxDomainSnapshotGetXMLDesc(virDomainSnapshotPtr snapshot,
unsigned int flags)
{
- esxPrivate *priv = snapshot->domain->conn->privateData;
+ esxPrivate *priv = virSnapDom(snapshot)->conn->privateData;
esxVI_VirtualMachineSnapshotTree *rootSnapshotList = NULL;
esxVI_VirtualMachineSnapshotTree *snapshotTree = NULL;
esxVI_VirtualMachineSnapshotTree *snapshotTreeParent = NULL;
@@ -4181,15 +4181,15 @@ esxDomainSnapshotGetXMLDesc(virDomainSnapshotPtr snapshot,
if (esxVI_EnsureSession(priv->primary) < 0)
return NULL;
- if (esxVI_LookupRootSnapshotTreeList(priv->primary, snapshot->domain->uuid,
+ if (esxVI_LookupRootSnapshotTreeList(priv->primary,
virSnapDom(snapshot)->uuid,
&rootSnapshotList) < 0 ||
- esxVI_GetSnapshotTreeByName(rootSnapshotList, snapshot->name,
+ esxVI_GetSnapshotTreeByName(rootSnapshotList, virSnapName(snapshot),
&snapshotTree, &snapshotTreeParent,
esxVI_Occurrence_RequiredItem) < 0) {
goto cleanup;
}
- def.name = snapshot->name;
+ def.name = virSnapName(snapshot);
def.description = snapshotTree->description;
def.parent = snapshotTreeParent ? snapshotTreeParent->name : NULL;
@@ -4201,7 +4201,7 @@ esxDomainSnapshotGetXMLDesc(virDomainSnapshotPtr snapshot,
def.state = esxVI_VirtualMachinePowerState_ConvertToLibvirt
(snapshotTree->state);
- virUUIDFormat(snapshot->domain->uuid, uuid_string);
+ virUUIDFormat(virSnapDom(snapshot)->uuid, uuid_string);
xml = virDomainSnapshotDefFormat(uuid_string, &def, priv->caps,
priv->xmlopt,
0);
@@ -4299,7 +4299,7 @@ static int
esxDomainSnapshotNumChildren(virDomainSnapshotPtr snapshot, unsigned int flags)
{
int count = -1;
- esxPrivate *priv = snapshot->domain->conn->privateData;
+ esxPrivate *priv = virSnapDom(snapshot)->conn->privateData;
esxVI_VirtualMachineSnapshotTree *rootSnapshotTreeList = NULL;
esxVI_VirtualMachineSnapshotTree *snapshotTree = NULL;
bool recurse;
@@ -4315,9 +4315,9 @@ esxDomainSnapshotNumChildren(virDomainSnapshotPtr snapshot, unsigned
int flags)
if (esxVI_EnsureSession(priv->primary) < 0)
return -1;
- if (esxVI_LookupRootSnapshotTreeList(priv->primary, snapshot->domain->uuid,
+ if (esxVI_LookupRootSnapshotTreeList(priv->primary,
virSnapDom(snapshot)->uuid,
&rootSnapshotTreeList) < 0 ||
- esxVI_GetSnapshotTreeByName(rootSnapshotTreeList, snapshot->name,
+ esxVI_GetSnapshotTreeByName(rootSnapshotTreeList, virSnapName(snapshot),
&snapshotTree, NULL,
esxVI_Occurrence_RequiredItem) < 0) {
goto cleanup;
@@ -4346,7 +4346,7 @@ esxDomainSnapshotListChildrenNames(virDomainSnapshotPtr snapshot,
unsigned int flags)
{
int result = -1;
- esxPrivate *priv = snapshot->domain->conn->privateData;
+ esxPrivate *priv = virSnapDom(snapshot)->conn->privateData;
esxVI_VirtualMachineSnapshotTree *rootSnapshotTreeList = NULL;
esxVI_VirtualMachineSnapshotTree *snapshotTree = NULL;
bool recurse;
@@ -4370,9 +4370,9 @@ esxDomainSnapshotListChildrenNames(virDomainSnapshotPtr snapshot,
if (esxVI_EnsureSession(priv->primary) < 0)
return -1;
- if (esxVI_LookupRootSnapshotTreeList(priv->primary, snapshot->domain->uuid,
+ if (esxVI_LookupRootSnapshotTreeList(priv->primary,
virSnapDom(snapshot)->uuid,
&rootSnapshotTreeList) < 0 ||
- esxVI_GetSnapshotTreeByName(rootSnapshotTreeList, snapshot->name,
+ esxVI_GetSnapshotTreeByName(rootSnapshotTreeList, virSnapName(snapshot),
&snapshotTree, NULL,
esxVI_Occurrence_RequiredItem) < 0) {
goto cleanup;
@@ -4457,7 +4457,7 @@ esxDomainHasCurrentSnapshot(virDomainPtr domain, unsigned int
flags)
static virDomainSnapshotPtr
esxDomainSnapshotGetParent(virDomainSnapshotPtr snapshot, unsigned int flags)
{
- esxPrivate *priv = snapshot->domain->conn->privateData;
+ esxPrivate *priv = virSnapDom(snapshot)->conn->privateData;
esxVI_VirtualMachineSnapshotTree *rootSnapshotList = NULL;
esxVI_VirtualMachineSnapshotTree *snapshotTree = NULL;
esxVI_VirtualMachineSnapshotTree *snapshotTreeParent = NULL;
@@ -4468,9 +4468,9 @@ esxDomainSnapshotGetParent(virDomainSnapshotPtr snapshot, unsigned
int flags)
if (esxVI_EnsureSession(priv->primary) < 0)
return NULL;
- if (esxVI_LookupRootSnapshotTreeList(priv->primary, snapshot->domain->uuid,
+ if (esxVI_LookupRootSnapshotTreeList(priv->primary,
virSnapDom(snapshot)->uuid,
&rootSnapshotList) < 0 ||
- esxVI_GetSnapshotTreeByName(rootSnapshotList, snapshot->name,
+ esxVI_GetSnapshotTreeByName(rootSnapshotList, virSnapName(snapshot),
&snapshotTree, &snapshotTreeParent,
esxVI_Occurrence_RequiredItem) < 0) {
goto cleanup;
@@ -4483,7 +4483,7 @@ esxDomainSnapshotGetParent(virDomainSnapshotPtr snapshot, unsigned
int flags)
goto cleanup;
}
- parent = virGetDomainSnapshot(snapshot->domain, snapshotTreeParent->name);
+ parent = virGetDomainSnapshot(virSnapDom(snapshot), snapshotTreeParent->name);
cleanup:
esxVI_VirtualMachineSnapshotTree_Free(&rootSnapshotList);
@@ -4522,7 +4522,7 @@ esxDomainSnapshotCurrent(virDomainPtr domain, unsigned int flags)
static int
esxDomainSnapshotIsCurrent(virDomainSnapshotPtr snapshot, unsigned int flags)
{
- esxPrivate *priv = snapshot->domain->conn->privateData;
+ esxPrivate *priv = virSnapDom(snapshot)->conn->privateData;
esxVI_VirtualMachineSnapshotTree *currentSnapshotTree = NULL;
esxVI_VirtualMachineSnapshotTree *rootSnapshotList = NULL;
esxVI_VirtualMachineSnapshotTree *snapshotTree = NULL;
@@ -4534,21 +4534,21 @@ esxDomainSnapshotIsCurrent(virDomainSnapshotPtr snapshot, unsigned
int flags)
return -1;
/* Check that snapshot exists. */
- if (esxVI_LookupRootSnapshotTreeList(priv->primary, snapshot->domain->uuid,
+ if (esxVI_LookupRootSnapshotTreeList(priv->primary,
virSnapDom(snapshot)->uuid,
&rootSnapshotList) < 0 ||
- esxVI_GetSnapshotTreeByName(rootSnapshotList, snapshot->name,
+ esxVI_GetSnapshotTreeByName(rootSnapshotList, virSnapName(snapshot),
&snapshotTree, NULL,
esxVI_Occurrence_RequiredItem) < 0) {
goto cleanup;
}
- if (esxVI_LookupCurrentSnapshotTree(priv->primary, snapshot->domain->uuid,
+ if (esxVI_LookupCurrentSnapshotTree(priv->primary, virSnapDom(snapshot)->uuid,
¤tSnapshotTree,
esxVI_Occurrence_RequiredItem) < 0) {
goto cleanup;
}
- ret = STREQ(snapshot->name, currentSnapshotTree->name);
+ ret = STREQ(virSnapName(snapshot), currentSnapshotTree->name);
cleanup:
esxVI_VirtualMachineSnapshotTree_Free(¤tSnapshotTree);
@@ -4560,7 +4560,7 @@ esxDomainSnapshotIsCurrent(virDomainSnapshotPtr snapshot, unsigned
int flags)
static int
esxDomainSnapshotHasMetadata(virDomainSnapshotPtr snapshot, unsigned int flags)
{
- esxPrivate *priv = snapshot->domain->conn->privateData;
+ esxPrivate *priv = virSnapDom(snapshot)->conn->privateData;
esxVI_VirtualMachineSnapshotTree *rootSnapshotList = NULL;
esxVI_VirtualMachineSnapshotTree *snapshotTree = NULL;
int ret = -1;
@@ -4571,9 +4571,9 @@ esxDomainSnapshotHasMetadata(virDomainSnapshotPtr snapshot, unsigned
int flags)
return -1;
/* Check that snapshot exists. If so, there is no metadata. */
- if (esxVI_LookupRootSnapshotTreeList(priv->primary, snapshot->domain->uuid,
+ if (esxVI_LookupRootSnapshotTreeList(priv->primary,
virSnapDom(snapshot)->uuid,
&rootSnapshotList) < 0 ||
- esxVI_GetSnapshotTreeByName(rootSnapshotList, snapshot->name,
+ esxVI_GetSnapshotTreeByName(rootSnapshotList, virSnapName(snapshot),
&snapshotTree, NULL,
esxVI_Occurrence_RequiredItem) < 0) {
goto cleanup;
@@ -4591,7 +4591,7 @@ static int
esxDomainRevertToSnapshot(virDomainSnapshotPtr snapshot, unsigned int flags)
{
int result = -1;
- esxPrivate *priv = snapshot->domain->conn->privateData;
+ esxPrivate *priv = virSnapDom(snapshot)->conn->privateData;
esxVI_VirtualMachineSnapshotTree *rootSnapshotList = NULL;
esxVI_VirtualMachineSnapshotTree *snapshotTree = NULL;
esxVI_ManagedObjectReference *task = NULL;
@@ -4603,9 +4603,9 @@ esxDomainRevertToSnapshot(virDomainSnapshotPtr snapshot, unsigned
int flags)
if (esxVI_EnsureSession(priv->primary) < 0)
return -1;
- if (esxVI_LookupRootSnapshotTreeList(priv->primary, snapshot->domain->uuid,
+ if (esxVI_LookupRootSnapshotTreeList(priv->primary,
virSnapDom(snapshot)->uuid,
&rootSnapshotList) < 0 ||
- esxVI_GetSnapshotTreeByName(rootSnapshotList, snapshot->name,
+ esxVI_GetSnapshotTreeByName(rootSnapshotList, virSnapName(snapshot),
&snapshotTree, NULL,
esxVI_Occurrence_RequiredItem) < 0) {
goto cleanup;
@@ -4613,7 +4613,7 @@ esxDomainRevertToSnapshot(virDomainSnapshotPtr snapshot, unsigned
int flags)
if (esxVI_RevertToSnapshot_Task(priv->primary, snapshotTree->snapshot, NULL,
esxVI_Boolean_Undefined, &task) < 0 ||
- esxVI_WaitForTaskCompletion(priv->primary, task,
snapshot->domain->uuid,
+ esxVI_WaitForTaskCompletion(priv->primary, task,
virSnapDom(snapshot)->uuid,
esxVI_Occurrence_RequiredItem,
priv->parsedUri->autoAnswer,
&taskInfoState,
&taskInfoErrorMessage) < 0) {
@@ -4622,7 +4622,7 @@ esxDomainRevertToSnapshot(virDomainSnapshotPtr snapshot, unsigned
int flags)
if (taskInfoState != esxVI_TaskInfoState_Success) {
virReportError(VIR_ERR_INTERNAL_ERROR,
- _("Could not revert to snapshot '%s': %s"),
snapshot->name,
+ _("Could not revert to snapshot '%s': %s"),
virSnapName(snapshot),
taskInfoErrorMessage);
goto cleanup;
}
@@ -4643,7 +4643,7 @@ static int
esxDomainSnapshotDelete(virDomainSnapshotPtr snapshot, unsigned int flags)
{
int result = -1;
- esxPrivate *priv = snapshot->domain->conn->privateData;
+ esxPrivate *priv = virSnapDom(snapshot)->conn->privateData;
esxVI_VirtualMachineSnapshotTree *rootSnapshotList = NULL;
esxVI_VirtualMachineSnapshotTree *snapshotTree = NULL;
esxVI_Boolean removeChildren = esxVI_Boolean_False;
@@ -4660,9 +4660,9 @@ esxDomainSnapshotDelete(virDomainSnapshotPtr snapshot, unsigned int
flags)
if (flags & VIR_DOMAIN_SNAPSHOT_DELETE_CHILDREN)
removeChildren = esxVI_Boolean_True;
- if (esxVI_LookupRootSnapshotTreeList(priv->primary, snapshot->domain->uuid,
+ if (esxVI_LookupRootSnapshotTreeList(priv->primary,
virSnapDom(snapshot)->uuid,
&rootSnapshotList) < 0 ||
- esxVI_GetSnapshotTreeByName(rootSnapshotList, snapshot->name,
+ esxVI_GetSnapshotTreeByName(rootSnapshotList, virSnapName(snapshot),
&snapshotTree, NULL,
esxVI_Occurrence_RequiredItem) < 0) {
goto cleanup;
@@ -4677,7 +4677,7 @@ esxDomainSnapshotDelete(virDomainSnapshotPtr snapshot, unsigned int
flags)
if (esxVI_RemoveSnapshot_Task(priv->primary, snapshotTree->snapshot,
removeChildren, &task) < 0 ||
- esxVI_WaitForTaskCompletion(priv->primary, task,
snapshot->domain->uuid,
+ esxVI_WaitForTaskCompletion(priv->primary, task,
virSnapDom(snapshot)->uuid,
esxVI_Occurrence_RequiredItem,
priv->parsedUri->autoAnswer,
&taskInfoState,
&taskInfoErrorMessage) < 0) {
@@ -4686,7 +4686,7 @@ esxDomainSnapshotDelete(virDomainSnapshotPtr snapshot, unsigned int
flags)
if (taskInfoState != esxVI_TaskInfoState_Success) {
virReportError(VIR_ERR_INTERNAL_ERROR,
- _("Could not delete snapshot '%s': %s"),
snapshot->name,
+ _("Could not delete snapshot '%s': %s"),
virSnapName(snapshot),
taskInfoErrorMessage);
goto cleanup;
}
diff --git a/src/libvirt-domain-snapshot.c b/src/libvirt-domain-snapshot.c
index be9bf71af9..e1275c69b0 100644
--- a/src/libvirt-domain-snapshot.c
+++ b/src/libvirt-domain-snapshot.c
@@ -45,7 +45,7 @@ virDomainSnapshotGetName(virDomainSnapshotPtr snapshot)
virCheckDomainSnapshotReturn(snapshot, NULL);
- return snapshot->name;
+ return virSnapName(snapshot);
}
@@ -68,7 +68,7 @@ virDomainSnapshotGetDomain(virDomainSnapshotPtr snapshot)
virCheckDomainSnapshotReturn(snapshot, NULL);
- return snapshot->domain;
+ return virSnapDom(snapshot);
}
@@ -91,7 +91,7 @@ virDomainSnapshotGetConnect(virDomainSnapshotPtr snapshot)
virCheckDomainSnapshotReturn(snapshot, NULL);
- return snapshot->domain->conn;
+ return virSnapDom(snapshot)->conn;
}
@@ -273,7 +273,7 @@ virDomainSnapshotGetXMLDesc(virDomainSnapshotPtr snapshot,
virResetLastError();
virCheckDomainSnapshotReturn(snapshot, NULL);
- conn = snapshot->domain->conn;
+ conn = virSnapDom(snapshot)->conn;
if ((conn->flags & VIR_CONNECT_RO) &&
(flags & VIR_DOMAIN_SNAPSHOT_XML_SECURE)) {
@@ -606,7 +606,7 @@ virDomainSnapshotNumChildren(virDomainSnapshotPtr snapshot, unsigned
int flags)
virResetLastError();
virCheckDomainSnapshotReturn(snapshot, -1);
- conn = snapshot->domain->conn;
+ conn = virSnapDom(snapshot)->conn;
if (conn->driver->domainSnapshotNumChildren) {
int ret = conn->driver->domainSnapshotNumChildren(snapshot, flags);
@@ -700,7 +700,7 @@ virDomainSnapshotListChildrenNames(virDomainSnapshotPtr snapshot,
virResetLastError();
virCheckDomainSnapshotReturn(snapshot, -1);
- conn = snapshot->domain->conn;
+ conn = virSnapDom(snapshot)->conn;
virCheckNonNullArgGoto(names, error);
virCheckNonNegativeArgGoto(nameslen, error);
@@ -796,7 +796,7 @@ virDomainSnapshotListAllChildren(virDomainSnapshotPtr snapshot,
*snaps = NULL;
virCheckDomainSnapshotReturn(snapshot, -1);
- conn = snapshot->domain->conn;
+ conn = virSnapDom(snapshot)->conn;
if (conn->driver->domainSnapshotListAllChildren) {
int ret = conn->driver->domainSnapshotListAllChildren(snapshot, snaps,
@@ -958,7 +958,7 @@ virDomainSnapshotGetParent(virDomainSnapshotPtr snapshot,
virResetLastError();
virCheckDomainSnapshotReturn(snapshot, NULL);
- conn = snapshot->domain->conn;
+ conn = virSnapDom(snapshot)->conn;
if (conn->driver->domainSnapshotGetParent) {
virDomainSnapshotPtr snap;
@@ -996,7 +996,7 @@ virDomainSnapshotIsCurrent(virDomainSnapshotPtr snapshot,
virResetLastError();
virCheckDomainSnapshotReturn(snapshot, -1);
- conn = snapshot->domain->conn;
+ conn = virSnapDom(snapshot)->conn;
if (conn->driver->domainSnapshotIsCurrent) {
int ret;
@@ -1035,7 +1035,7 @@ virDomainSnapshotHasMetadata(virDomainSnapshotPtr snapshot,
virResetLastError();
virCheckDomainSnapshotReturn(snapshot, -1);
- conn = snapshot->domain->conn;
+ conn = virSnapDom(snapshot)->conn;
if (conn->driver->domainSnapshotHasMetadata) {
int ret;
@@ -1106,7 +1106,7 @@ virDomainRevertToSnapshot(virDomainSnapshotPtr snapshot,
virResetLastError();
virCheckDomainSnapshotReturn(snapshot, -1);
- conn = snapshot->domain->conn;
+ conn = virSnapDom(snapshot)->conn;
virCheckReadOnlyGoto(conn->flags, error);
@@ -1163,7 +1163,7 @@ virDomainSnapshotDelete(virDomainSnapshotPtr snapshot,
virResetLastError();
virCheckDomainSnapshotReturn(snapshot, -1);
- conn = snapshot->domain->conn;
+ conn = virSnapDom(snapshot)->conn;
virCheckReadOnlyGoto(conn->flags, error);
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index 75b5b26bca..31859c20c8 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -193,7 +193,7 @@ qemuDomObjFromDomain(virDomainPtr domain)
static virDomainObjPtr
qemuDomObjFromSnapshot(virDomainSnapshotPtr snapshot)
{
- return qemuDomObjFromDomain(snapshot->domain);
+ return qemuDomObjFromDomain(virSnapDom(snapshot));
}
@@ -218,7 +218,7 @@ static virDomainSnapshotObjPtr
qemuSnapObjFromSnapshot(virDomainObjPtr vm,
virDomainSnapshotPtr snapshot)
{
- return qemuSnapObjFromName(vm, snapshot->name);
+ return qemuSnapObjFromName(vm, virSnapName(snapshot));
}
static int
@@ -16059,7 +16059,7 @@ qemuDomainSnapshotListChildrenNames(virDomainSnapshotPtr
snapshot,
if (!(vm = qemuDomObjFromSnapshot(snapshot)))
return -1;
- if (virDomainSnapshotListChildrenNamesEnsureACL(snapshot->domain->conn,
vm->def) < 0)
+ if (virDomainSnapshotListChildrenNamesEnsureACL(virSnapDom(snapshot)->conn,
vm->def) < 0)
goto cleanup;
if (!(snap = qemuSnapObjFromSnapshot(vm, snapshot)))
@@ -16089,7 +16089,7 @@ qemuDomainSnapshotNumChildren(virDomainSnapshotPtr snapshot,
if (!(vm = qemuDomObjFromSnapshot(snapshot)))
return -1;
- if (virDomainSnapshotNumChildrenEnsureACL(snapshot->domain->conn, vm->def)
< 0)
+ if (virDomainSnapshotNumChildrenEnsureACL(virSnapDom(snapshot)->conn, vm->def)
< 0)
goto cleanup;
if (!(snap = qemuSnapObjFromSnapshot(vm, snapshot)))
@@ -16119,13 +16119,13 @@ qemuDomainSnapshotListAllChildren(virDomainSnapshotPtr
snapshot,
if (!(vm = qemuDomObjFromSnapshot(snapshot)))
return -1;
- if (virDomainSnapshotListAllChildrenEnsureACL(snapshot->domain->conn,
vm->def) < 0)
+ if (virDomainSnapshotListAllChildrenEnsureACL(virSnapDom(snapshot)->conn,
vm->def) < 0)
goto cleanup;
if (!(snap = qemuSnapObjFromSnapshot(vm, snapshot)))
goto cleanup;
- n = virDomainListSnapshots(vm->snapshots, snap, snapshot->domain, snaps,
+ n = virDomainListSnapshots(vm->snapshots, snap, virSnapDom(snapshot), snaps,
flags);
cleanup:
@@ -16198,7 +16198,7 @@ qemuDomainSnapshotGetParent(virDomainSnapshotPtr snapshot,
if (!(vm = qemuDomObjFromSnapshot(snapshot)))
return NULL;
- if (virDomainSnapshotGetParentEnsureACL(snapshot->domain->conn, vm->def)
< 0)
+ if (virDomainSnapshotGetParentEnsureACL(virSnapDom(snapshot)->conn, vm->def)
< 0)
goto cleanup;
if (!(snap = qemuSnapObjFromSnapshot(vm, snapshot)))
@@ -16211,7 +16211,7 @@ qemuDomainSnapshotGetParent(virDomainSnapshotPtr snapshot,
goto cleanup;
}
- parent = virGetDomainSnapshot(snapshot->domain, snap->def->parent);
+ parent = virGetDomainSnapshot(virSnapDom(snapshot), snap->def->parent);
cleanup:
virDomainObjEndAPI(&vm);
@@ -16252,7 +16252,7 @@ static char *
qemuDomainSnapshotGetXMLDesc(virDomainSnapshotPtr snapshot,
unsigned int flags)
{
- virQEMUDriverPtr driver = snapshot->domain->conn->privateData;
+ virQEMUDriverPtr driver = virSnapDom(snapshot)->conn->privateData;
virDomainObjPtr vm = NULL;
char *xml = NULL;
virDomainSnapshotObjPtr snap = NULL;
@@ -16263,13 +16263,13 @@ qemuDomainSnapshotGetXMLDesc(virDomainSnapshotPtr snapshot,
if (!(vm = qemuDomObjFromSnapshot(snapshot)))
return NULL;
- if (virDomainSnapshotGetXMLDescEnsureACL(snapshot->domain->conn, vm->def,
flags) < 0)
+ if (virDomainSnapshotGetXMLDescEnsureACL(virSnapDom(snapshot)->conn, vm->def,
flags) < 0)
goto cleanup;
if (!(snap = qemuSnapObjFromSnapshot(vm, snapshot)))
goto cleanup;
- virUUIDFormat(snapshot->domain->uuid, uuidstr);
+ virUUIDFormat(virSnapDom(snapshot)->uuid, uuidstr);
xml = virDomainSnapshotDefFormat(uuidstr, snap->def,
driver->caps, driver->xmlopt,
@@ -16294,14 +16294,14 @@ qemuDomainSnapshotIsCurrent(virDomainSnapshotPtr snapshot,
if (!(vm = qemuDomObjFromSnapshot(snapshot)))
return -1;
- if (virDomainSnapshotIsCurrentEnsureACL(snapshot->domain->conn, vm->def)
< 0)
+ if (virDomainSnapshotIsCurrentEnsureACL(virSnapDom(snapshot)->conn, vm->def)
< 0)
goto cleanup;
if (!(snap = qemuSnapObjFromSnapshot(vm, snapshot)))
goto cleanup;
ret = (vm->current_snapshot &&
- STREQ(snapshot->name, vm->current_snapshot->def->name));
+ STREQ(virSnapName(snapshot), vm->current_snapshot->def->name));
cleanup:
virDomainObjEndAPI(&vm);
@@ -16322,7 +16322,7 @@ qemuDomainSnapshotHasMetadata(virDomainSnapshotPtr snapshot,
if (!(vm = qemuDomObjFromSnapshot(snapshot)))
return -1;
- if (virDomainSnapshotHasMetadataEnsureACL(snapshot->domain->conn, vm->def)
< 0)
+ if (virDomainSnapshotHasMetadataEnsureACL(virSnapDom(snapshot)->conn, vm->def)
< 0)
goto cleanup;
if (!(snap = qemuSnapObjFromSnapshot(vm, snapshot)))
@@ -16355,7 +16355,7 @@ static int
qemuDomainRevertToSnapshot(virDomainSnapshotPtr snapshot,
unsigned int flags)
{
- virQEMUDriverPtr driver = snapshot->domain->conn->privateData;
+ virQEMUDriverPtr driver = virSnapDom(snapshot)->conn->privateData;
virDomainObjPtr vm = NULL;
int ret = -1;
virDomainSnapshotObjPtr snap = NULL;
@@ -16398,7 +16398,7 @@ qemuDomainRevertToSnapshot(virDomainSnapshotPtr snapshot,
cfg = virQEMUDriverGetConfig(driver);
- if (virDomainRevertToSnapshotEnsureACL(snapshot->domain->conn, vm->def) <
0)
+ if (virDomainRevertToSnapshotEnsureACL(virSnapDom(snapshot)->conn, vm->def)
< 0)
goto cleanup;
if (!(caps = virQEMUDriverGetCapabilities(driver, false)))
@@ -16605,7 +16605,7 @@ qemuDomainRevertToSnapshot(virDomainSnapshotPtr snapshot,
qemuDomainFixupCPUs(vm, &cookie->cpu) < 0)
goto cleanup;
- rc = qemuProcessStart(snapshot->domain->conn, driver, vm,
+ rc = qemuProcessStart(virSnapDom(snapshot)->conn, driver, vm,
cookie ? cookie->cpu : NULL,
jobType, NULL, -1, NULL, snap,
VIR_NETDEV_VPORT_PROFILE_OP_CREATE,
@@ -16693,7 +16693,7 @@ qemuDomainRevertToSnapshot(virDomainSnapshotPtr snapshot,
start_flags |= paused ? VIR_QEMU_PROCESS_START_PAUSED : 0;
virObjectEventStateQueue(driver->domainEventState, event);
- rc = qemuProcessStart(snapshot->domain->conn, driver, vm, NULL,
+ rc = qemuProcessStart(virSnapDom(snapshot)->conn, driver, vm, NULL,
QEMU_ASYNC_JOB_START, NULL, -1, NULL, NULL,
VIR_NETDEV_VPORT_PROFILE_OP_CREATE,
start_flags);
@@ -16818,7 +16818,7 @@ static int
qemuDomainSnapshotDelete(virDomainSnapshotPtr snapshot,
unsigned int flags)
{
- virQEMUDriverPtr driver = snapshot->domain->conn->privateData;
+ virQEMUDriverPtr driver = virSnapDom(snapshot)->conn->privateData;
virDomainObjPtr vm = NULL;
int ret = -1;
virDomainSnapshotObjPtr snap = NULL;
@@ -16837,7 +16837,7 @@ qemuDomainSnapshotDelete(virDomainSnapshotPtr snapshot,
cfg = virQEMUDriverGetConfig(driver);
- if (virDomainSnapshotDeleteEnsureACL(snapshot->domain->conn, vm->def) <
0)
+ if (virDomainSnapshotDeleteEnsureACL(virSnapDom(snapshot)->conn, vm->def) <
0)
goto cleanup;
if (qemuDomainObjBeginJob(driver, vm, QEMU_JOB_MODIFY) < 0)
diff --git a/src/remote/remote_daemon_dispatch.c b/src/remote/remote_daemon_dispatch.c
index df28259042..49721536d0 100644
--- a/src/remote/remote_daemon_dispatch.c
+++ b/src/remote/remote_daemon_dispatch.c
@@ -7351,9 +7351,9 @@ make_nonnull_nwfilter_binding(remote_nonnull_nwfilter_binding
*binding_dst, virN
static int
make_nonnull_domain_snapshot(remote_nonnull_domain_snapshot *snapshot_dst,
virDomainSnapshotPtr snapshot_src)
{
- if (VIR_STRDUP(snapshot_dst->name, snapshot_src->name) < 0)
+ if (VIR_STRDUP(snapshot_dst->name, virSnapName(snapshot_src)) < 0)
return -1;
- if (make_nonnull_domain(&snapshot_dst->dom, snapshot_src->domain) < 0)
{
+ if (make_nonnull_domain(&snapshot_dst->dom, virSnapDom(snapshot_src)) < 0)
{
VIR_FREE(snapshot_dst->name);
return -1;
}
diff --git a/src/remote/remote_driver.c b/src/remote/remote_driver.c
index 5c4dd41227..f67ea1132c 100644
--- a/src/remote/remote_driver.c
+++ b/src/remote/remote_driver.c
@@ -8270,8 +8270,8 @@ make_nonnull_nwfilter_binding(remote_nonnull_nwfilter_binding
*binding_dst, virN
static void
make_nonnull_domain_snapshot(remote_nonnull_domain_snapshot *snapshot_dst,
virDomainSnapshotPtr snapshot_src)
{
- snapshot_dst->name = snapshot_src->name;
- make_nonnull_domain(&snapshot_dst->dom, snapshot_src->domain);
+ snapshot_dst->name = virSnapName(snapshot_src);
+ make_nonnull_domain(&snapshot_dst->dom, virSnapDom(snapshot_src));
}
/*----------------------------------------------------------------------*/
diff --git a/src/rpc/gendispatch.pl b/src/rpc/gendispatch.pl
index ae3a42c4c1..985eb995aa 100755
--- a/src/rpc/gendispatch.pl
+++ b/src/rpc/gendispatch.pl
@@ -1335,7 +1335,7 @@ elsif ($mode eq "client") {
if ($is_first_arg) {
if ($name eq "domain_snapshot") {
- $priv_src = "$arg_name->domain->conn";
+ $priv_src = "virSnapDom($arg_name)->conn";
} else {
$priv_src = "$arg_name->conn";
}
diff --git a/src/test/test_driver.c b/src/test/test_driver.c
index 4d49c987b5..8583a19208 100644
--- a/src/test/test_driver.c
+++ b/src/test/test_driver.c
@@ -5945,13 +5945,13 @@ static virDomainSnapshotObjPtr
testSnapObjFromSnapshot(virDomainObjPtr vm,
virDomainSnapshotPtr snapshot)
{
- return testSnapObjFromName(vm, snapshot->name);
+ return testSnapObjFromName(vm, virSnapName(snapshot));
}
static virDomainObjPtr
testDomObjFromSnapshot(virDomainSnapshotPtr snapshot)
{
- return testDomObjFromDomain(snapshot->domain);
+ return testDomObjFromDomain(virSnapDom(snapshot));
}
static int
@@ -6089,7 +6089,7 @@ testDomainSnapshotListAllChildren(virDomainSnapshotPtr snapshot,
if (!(snap = testSnapObjFromSnapshot(vm, snapshot)))
goto cleanup;
- n = virDomainListSnapshots(vm->snapshots, snap, snapshot->domain, snaps,
+ n = virDomainListSnapshots(vm->snapshots, snap, virSnapDom(snapshot), snaps,
flags);
cleanup:
@@ -6162,7 +6162,7 @@ testDomainSnapshotGetParent(virDomainSnapshotPtr snapshot,
goto cleanup;
}
- parent = virGetDomainSnapshot(snapshot->domain, snap->def->parent);
+ parent = virGetDomainSnapshot(virSnapDom(snapshot), snap->def->parent);
cleanup:
virDomainObjEndAPI(&vm);
@@ -6202,7 +6202,7 @@ testDomainSnapshotGetXMLDesc(virDomainSnapshotPtr snapshot,
char *xml = NULL;
virDomainSnapshotObjPtr snap = NULL;
char uuidstr[VIR_UUID_STRING_BUFLEN];
- testDriverPtr privconn = snapshot->domain->conn->privateData;
+ testDriverPtr privconn = virSnapDom(snapshot)->conn->privateData;
virCheckFlags(VIR_DOMAIN_SNAPSHOT_XML_SECURE, NULL);
@@ -6212,7 +6212,7 @@ testDomainSnapshotGetXMLDesc(virDomainSnapshotPtr snapshot,
if (!(snap = testSnapObjFromSnapshot(vm, snapshot)))
goto cleanup;
- virUUIDFormat(snapshot->domain->uuid, uuidstr);
+ virUUIDFormat(virSnapDom(snapshot)->uuid, uuidstr);
xml = virDomainSnapshotDefFormat(uuidstr, snap->def, privconn->caps,
privconn->xmlopt,
@@ -6236,7 +6236,7 @@ testDomainSnapshotIsCurrent(virDomainSnapshotPtr snapshot,
return -1;
ret = (vm->current_snapshot &&
- STREQ(snapshot->name, vm->current_snapshot->def->name));
+ STREQ(virSnapName(snapshot), vm->current_snapshot->def->name));
virDomainObjEndAPI(&vm);
return ret;
@@ -6545,7 +6545,7 @@ static int
testDomainRevertToSnapshot(virDomainSnapshotPtr snapshot,
unsigned int flags)
{
- testDriverPtr privconn = snapshot->domain->conn->privateData;
+ testDriverPtr privconn = virSnapDom(snapshot)->conn->privateData;
virDomainObjPtr vm = NULL;
virDomainSnapshotObjPtr snap = NULL;
virObjectEventPtr event = NULL;
@@ -6640,7 +6640,7 @@ testDomainRevertToSnapshot(virDomainSnapshotPtr snapshot,
}
virResetError(err);
- testDomainShutdownState(snapshot->domain, vm,
+ testDomainShutdownState(virSnapDom(snapshot), vm,
VIR_DOMAIN_SHUTOFF_FROM_SNAPSHOT);
event = virDomainEventLifecycleNewFromObj(vm,
VIR_DOMAIN_EVENT_STOPPED,
@@ -6712,7 +6712,7 @@ testDomainRevertToSnapshot(virDomainSnapshotPtr snapshot,
if (virDomainObjIsActive(vm)) {
/* Transitions 4, 7 */
- testDomainShutdownState(snapshot->domain, vm,
+ testDomainShutdownState(virSnapDom(snapshot), vm,
VIR_DOMAIN_SHUTOFF_FROM_SNAPSHOT);
event = virDomainEventLifecycleNewFromObj(vm,
VIR_DOMAIN_EVENT_STOPPED,
diff --git a/src/vbox/vbox_common.c b/src/vbox/vbox_common.c
index b8dfb55ef4..49c7e8a27d 100644
--- a/src/vbox/vbox_common.c
+++ b/src/vbox/vbox_common.c
@@ -5732,7 +5732,7 @@ static int
vboxSnapshotGetReadWriteDisks(virDomainSnapshotDefPtr def,
virDomainSnapshotPtr snapshot)
{
- virDomainPtr dom = snapshot->domain;
+ virDomainPtr dom = virSnapDom(snapshot);
vboxDriverPtr data = dom->conn->privateData;
vboxIID domiid;
IMachine *machine = NULL;
@@ -5756,7 +5756,7 @@ vboxSnapshotGetReadWriteDisks(virDomainSnapshotDefPtr def,
if (openSessionForMachine(data, dom->uuid, &domiid, &machine) < 0)
goto cleanup;
- if (!(snap = vboxDomainSnapshotGet(data, dom, machine, snapshot->name)))
+ if (!(snap = vboxDomainSnapshotGet(data, dom, machine, virSnapName(snapshot))))
goto cleanup;
rc = gVBoxAPI.UISnapshot.GetId(snap, &snapIid);
@@ -5972,7 +5972,7 @@ static int
vboxSnapshotGetReadOnlyDisks(virDomainSnapshotDefPtr def,
virDomainSnapshotPtr snapshot)
{
- virDomainPtr dom = snapshot->domain;
+ virDomainPtr dom = virSnapDom(snapshot);
vboxDriverPtr data = dom->conn->privateData;
vboxIID domiid;
ISnapshot *snap = NULL;
@@ -5994,7 +5994,7 @@ vboxSnapshotGetReadOnlyDisks(virDomainSnapshotDefPtr def,
if (openSessionForMachine(data, dom->uuid, &domiid, &machine) < 0)
goto cleanup;
- if (!(snap = vboxDomainSnapshotGet(data, dom, machine, snapshot->name)))
+ if (!(snap = vboxDomainSnapshotGet(data, dom, machine, virSnapName(snapshot))))
goto cleanup;
rc = gVBoxAPI.UISnapshot.GetMachine(snap, &snapMachine);
@@ -6195,7 +6195,7 @@ vboxSnapshotGetReadOnlyDisks(virDomainSnapshotDefPtr def,
static char *vboxDomainSnapshotGetXMLDesc(virDomainSnapshotPtr snapshot,
unsigned int flags)
{
- virDomainPtr dom = snapshot->domain;
+ virDomainPtr dom = virSnapDom(snapshot);
vboxDriverPtr data = dom->conn->privateData;
vboxIID domiid;
IMachine *machine = NULL;
@@ -6218,12 +6218,12 @@ static char *vboxDomainSnapshotGetXMLDesc(virDomainSnapshotPtr
snapshot,
if (openSessionForMachine(data, dom->uuid, &domiid, &machine) < 0)
goto cleanup;
- if (!(snap = vboxDomainSnapshotGet(data, dom, machine, snapshot->name)))
+ if (!(snap = vboxDomainSnapshotGet(data, dom, machine, virSnapName(snapshot))))
goto cleanup;
if (VIR_ALLOC(def) < 0 || !(def->dom = virDomainDefNew()))
goto cleanup;
- if (VIR_STRDUP(def->name, snapshot->name) < 0)
+ if (VIR_STRDUP(def->name, virSnapName(snapshot)) < 0)
goto cleanup;
if (gVBoxAPI.vboxSnapshotRedefine) {
@@ -6265,7 +6265,7 @@ static char *vboxDomainSnapshotGetXMLDesc(virDomainSnapshotPtr
snapshot,
if (NS_FAILED(rc)) {
virReportError(VIR_ERR_INTERNAL_ERROR,
_("could not get description of snapshot %s"),
- snapshot->name);
+ virSnapName(snapshot));
goto cleanup;
}
if (str16) {
@@ -6282,7 +6282,7 @@ static char *vboxDomainSnapshotGetXMLDesc(virDomainSnapshotPtr
snapshot,
if (NS_FAILED(rc)) {
virReportError(VIR_ERR_INTERNAL_ERROR,
_("could not get creation time of snapshot %s"),
- snapshot->name);
+ virSnapName(snapshot));
goto cleanup;
}
/* timestamp is in milliseconds while creationTime in seconds */
@@ -6292,7 +6292,7 @@ static char *vboxDomainSnapshotGetXMLDesc(virDomainSnapshotPtr
snapshot,
if (NS_FAILED(rc)) {
virReportError(VIR_ERR_INTERNAL_ERROR,
_("could not get parent of snapshot %s"),
- snapshot->name);
+ virSnapName(snapshot));
goto cleanup;
}
if (parent) {
@@ -6300,7 +6300,7 @@ static char *vboxDomainSnapshotGetXMLDesc(virDomainSnapshotPtr
snapshot,
if (NS_FAILED(rc) || !str16) {
virReportError(VIR_ERR_INTERNAL_ERROR,
_("could not get name of parent of snapshot %s"),
- snapshot->name);
+ virSnapName(snapshot));
goto cleanup;
}
VBOX_UTF16_TO_UTF8(str16, &str8);
@@ -6316,7 +6316,7 @@ static char *vboxDomainSnapshotGetXMLDesc(virDomainSnapshotPtr
snapshot,
if (NS_FAILED(rc)) {
virReportError(VIR_ERR_INTERNAL_ERROR,
_("could not get online state of snapshot %s"),
- snapshot->name);
+ virSnapName(snapshot));
goto cleanup;
}
if (online)
@@ -6531,7 +6531,7 @@ static virDomainSnapshotPtr
vboxDomainSnapshotGetParent(virDomainSnapshotPtr snapshot,
unsigned int flags)
{
- virDomainPtr dom = snapshot->domain;
+ virDomainPtr dom = virSnapDom(snapshot);
vboxDriverPtr data = dom->conn->privateData;
vboxIID iid;
IMachine *machine = NULL;
@@ -6550,20 +6550,20 @@ vboxDomainSnapshotGetParent(virDomainSnapshotPtr snapshot,
if (openSessionForMachine(data, dom->uuid, &iid, &machine) < 0)
goto cleanup;
- if (!(snap = vboxDomainSnapshotGet(data, dom, machine, snapshot->name)))
+ if (!(snap = vboxDomainSnapshotGet(data, dom, machine, virSnapName(snapshot))))
goto cleanup;
rc = gVBoxAPI.UISnapshot.GetParent(snap, &parent);
if (NS_FAILED(rc)) {
virReportError(VIR_ERR_INTERNAL_ERROR,
_("could not get parent of snapshot %s"),
- snapshot->name);
+ virSnapName(snapshot));
goto cleanup;
}
if (!parent) {
virReportError(VIR_ERR_NO_DOMAIN_SNAPSHOT,
_("snapshot '%s' does not have a parent"),
- snapshot->name);
+ virSnapName(snapshot));
goto cleanup;
}
@@ -6571,7 +6571,7 @@ vboxDomainSnapshotGetParent(virDomainSnapshotPtr snapshot,
if (NS_FAILED(rc) || !nameUtf16) {
virReportError(VIR_ERR_INTERNAL_ERROR,
_("could not get name of parent of snapshot %s"),
- snapshot->name);
+ virSnapName(snapshot));
goto cleanup;
}
VBOX_UTF16_TO_UTF8(nameUtf16, &name);
@@ -6652,7 +6652,7 @@ vboxDomainSnapshotCurrent(virDomainPtr dom, unsigned int flags)
static int vboxDomainSnapshotIsCurrent(virDomainSnapshotPtr snapshot,
unsigned int flags)
{
- virDomainPtr dom = snapshot->domain;
+ virDomainPtr dom = virSnapDom(snapshot);
vboxDriverPtr data = dom->conn->privateData;
vboxIID iid;
IMachine *machine = NULL;
@@ -6671,7 +6671,7 @@ static int vboxDomainSnapshotIsCurrent(virDomainSnapshotPtr
snapshot,
if (openSessionForMachine(data, dom->uuid, &iid, &machine) < 0)
goto cleanup;
- if (!(snap = vboxDomainSnapshotGet(data, dom, machine, snapshot->name)))
+ if (!(snap = vboxDomainSnapshotGet(data, dom, machine, virSnapName(snapshot))))
goto cleanup;
rc = gVBoxAPI.UIMachine.GetCurrentSnapshot(machine, ¤t);
@@ -6698,7 +6698,7 @@ static int vboxDomainSnapshotIsCurrent(virDomainSnapshotPtr
snapshot,
goto cleanup;
}
- ret = STREQ(snapshot->name, name);
+ ret = STREQ(virSnapName(snapshot), name);
cleanup:
VBOX_UTF8_FREE(name);
@@ -6713,7 +6713,7 @@ static int vboxDomainSnapshotIsCurrent(virDomainSnapshotPtr
snapshot,
static int vboxDomainSnapshotHasMetadata(virDomainSnapshotPtr snapshot,
unsigned int flags)
{
- virDomainPtr dom = snapshot->domain;
+ virDomainPtr dom = virSnapDom(snapshot);
vboxDriverPtr data = dom->conn->privateData;
vboxIID iid;
IMachine *machine = NULL;
@@ -6729,7 +6729,7 @@ static int vboxDomainSnapshotHasMetadata(virDomainSnapshotPtr
snapshot,
goto cleanup;
/* Check that snapshot exists. If so, there is no metadata. */
- if (!(snap = vboxDomainSnapshotGet(data, dom, machine, snapshot->name)))
+ if (!(snap = vboxDomainSnapshotGet(data, dom, machine, virSnapName(snapshot))))
goto cleanup;
ret = 0;
@@ -6744,7 +6744,7 @@ static int vboxDomainSnapshotHasMetadata(virDomainSnapshotPtr
snapshot,
static int vboxDomainRevertToSnapshot(virDomainSnapshotPtr snapshot,
unsigned int flags)
{
- virDomainPtr dom = snapshot->domain;
+ virDomainPtr dom = virSnapDom(snapshot);
vboxDriverPtr data = dom->conn->privateData;
vboxIID domiid;
IMachine *machine = NULL;
@@ -6763,7 +6763,7 @@ static int vboxDomainRevertToSnapshot(virDomainSnapshotPtr
snapshot,
if (openSessionForMachine(data, dom->uuid, &domiid, &machine) < 0)
goto cleanup;
- newSnapshot = vboxDomainSnapshotGet(data, dom, machine, snapshot->name);
+ newSnapshot = vboxDomainSnapshotGet(data, dom, machine, virSnapName(snapshot));
if (!newSnapshot)
goto cleanup;
@@ -6771,7 +6771,7 @@ static int vboxDomainRevertToSnapshot(virDomainSnapshotPtr
snapshot,
if (NS_FAILED(rc)) {
virReportError(VIR_ERR_INTERNAL_ERROR,
_("could not get online state of snapshot %s"),
- snapshot->name);
+ virSnapName(snapshot));
goto cleanup;
}
@@ -6908,7 +6908,7 @@ vboxDomainSnapshotDeleteMetadataOnly(virDomainSnapshotPtr snapshot)
* the machine with the new file.
*/
- virDomainPtr dom = snapshot->domain;
+ virDomainPtr dom = virSnapDom(snapshot);
vboxDriverPtr data = dom->conn->privateData;
virDomainSnapshotDefPtr def = NULL;
char *defXml = NULL;
@@ -7345,7 +7345,7 @@ vboxDomainSnapshotDeleteMetadataOnly(virDomainSnapshotPtr snapshot)
static int vboxDomainSnapshotDelete(virDomainSnapshotPtr snapshot,
unsigned int flags)
{
- virDomainPtr dom = snapshot->domain;
+ virDomainPtr dom = virSnapDom(snapshot);
vboxDriverPtr data = dom->conn->privateData;
vboxIID domiid;
IMachine *machine = NULL;
@@ -7365,7 +7365,7 @@ static int vboxDomainSnapshotDelete(virDomainSnapshotPtr snapshot,
if (openSessionForMachine(data, dom->uuid, &domiid, &machine) < 0)
goto cleanup;
- snap = vboxDomainSnapshotGet(data, dom, machine, snapshot->name);
+ snap = vboxDomainSnapshotGet(data, dom, machine, virSnapName(snapshot));
if (!snap)
goto cleanup;
diff --git a/src/vz/vz_driver.c b/src/vz/vz_driver.c
index 066d617524..1bf6daf9b0 100644
--- a/src/vz/vz_driver.c
+++ b/src/vz/vz_driver.c
@@ -2148,7 +2148,7 @@ static virDomainSnapshotObjPtr
vzSnapObjFromSnapshot(virDomainSnapshotObjListPtr snapshots,
virDomainSnapshotPtr snapshot)
{
- return vzSnapObjFromName(snapshots, snapshot->name);
+ return vzSnapObjFromName(snapshots, virSnapName(snapshot));
}
static int
@@ -2271,14 +2271,14 @@ vzDomainSnapshotGetXMLDesc(virDomainSnapshotPtr snapshot, unsigned
int flags)
virDomainSnapshotObjPtr snap;
char uuidstr[VIR_UUID_STRING_BUFLEN];
virDomainSnapshotObjListPtr snapshots = NULL;
- vzConnPtr privconn = snapshot->domain->conn->privateData;
+ vzConnPtr privconn = virSnapDom(snapshot)->conn->privateData;
virCheckFlags(VIR_DOMAIN_SNAPSHOT_XML_SECURE, NULL);
- if (!(dom = vzDomObjFromDomain(snapshot->domain)))
+ if (!(dom = vzDomObjFromDomain(virSnapDom(snapshot))))
return NULL;
- if (virDomainSnapshotGetXMLDescEnsureACL(snapshot->domain->conn, dom->def,
flags) < 0)
+ if (virDomainSnapshotGetXMLDescEnsureACL(virSnapDom(snapshot)->conn, dom->def,
flags) < 0)
goto cleanup;
if (!(snapshots = prlsdkLoadSnapshots(dom)))
@@ -2287,7 +2287,7 @@ vzDomainSnapshotGetXMLDesc(virDomainSnapshotPtr snapshot, unsigned
int flags)
if (!(snap = vzSnapObjFromSnapshot(snapshots, snapshot)))
goto cleanup;
- virUUIDFormat(snapshot->domain->uuid, uuidstr);
+ virUUIDFormat(virSnapDom(snapshot)->uuid, uuidstr);
xml = virDomainSnapshotDefFormat(uuidstr, snap->def,
privconn->driver->caps,
privconn->driver->xmlopt,
@@ -2311,10 +2311,10 @@ vzDomainSnapshotNumChildren(virDomainSnapshotPtr snapshot,
unsigned int flags)
virCheckFlags(VIR_DOMAIN_SNAPSHOT_LIST_DESCENDANTS |
VIR_DOMAIN_SNAPSHOT_FILTERS_ALL, -1);
- if (!(dom = vzDomObjFromDomain(snapshot->domain)))
+ if (!(dom = vzDomObjFromDomain(virSnapDom(snapshot))))
return -1;
- if (virDomainSnapshotNumChildrenEnsureACL(snapshot->domain->conn, dom->def)
< 0)
+ if (virDomainSnapshotNumChildrenEnsureACL(virSnapDom(snapshot)->conn, dom->def)
< 0)
goto cleanup;
if (!(snapshots = prlsdkLoadSnapshots(dom)))
@@ -2346,10 +2346,10 @@ vzDomainSnapshotListChildrenNames(virDomainSnapshotPtr snapshot,
virCheckFlags(VIR_DOMAIN_SNAPSHOT_LIST_DESCENDANTS |
VIR_DOMAIN_SNAPSHOT_FILTERS_ALL, -1);
- if (!(dom = vzDomObjFromDomain(snapshot->domain)))
+ if (!(dom = vzDomObjFromDomain(virSnapDom(snapshot))))
return -1;
- if (virDomainSnapshotListChildrenNamesEnsureACL(snapshot->domain->conn,
dom->def) < 0)
+ if (virDomainSnapshotListChildrenNamesEnsureACL(virSnapDom(snapshot)->conn,
dom->def) < 0)
goto cleanup;
if (!(snapshots = prlsdkLoadSnapshots(dom)))
@@ -2380,10 +2380,10 @@ vzDomainSnapshotListAllChildren(virDomainSnapshotPtr snapshot,
virCheckFlags(VIR_DOMAIN_SNAPSHOT_LIST_DESCENDANTS |
VIR_DOMAIN_SNAPSHOT_FILTERS_ALL, -1);
- if (!(dom = vzDomObjFromDomain(snapshot->domain)))
+ if (!(dom = vzDomObjFromDomain(virSnapDom(snapshot))))
return -1;
- if (virDomainSnapshotListAllChildrenEnsureACL(snapshot->domain->conn,
dom->def) < 0)
+ if (virDomainSnapshotListAllChildrenEnsureACL(virSnapDom(snapshot)->conn,
dom->def) < 0)
goto cleanup;
if (!(snapshots = prlsdkLoadSnapshots(dom)))
@@ -2392,7 +2392,7 @@ vzDomainSnapshotListAllChildren(virDomainSnapshotPtr snapshot,
if (!(snap = vzSnapObjFromSnapshot(snapshots, snapshot)))
goto cleanup;
- n = virDomainListSnapshots(snapshots, snap, snapshot->domain, snaps, flags);
+ n = virDomainListSnapshots(snapshots, snap, virSnapDom(snapshot), snaps, flags);
cleanup:
virDomainSnapshotObjListFree(snapshots);
@@ -2471,10 +2471,10 @@ vzDomainSnapshotGetParent(virDomainSnapshotPtr snapshot, unsigned
int flags)
virCheckFlags(0, NULL);
- if (!(dom = vzDomObjFromDomain(snapshot->domain)))
+ if (!(dom = vzDomObjFromDomain(virSnapDom(snapshot))))
return NULL;
- if (virDomainSnapshotGetParentEnsureACL(snapshot->domain->conn, dom->def)
< 0)
+ if (virDomainSnapshotGetParentEnsureACL(virSnapDom(snapshot)->conn, dom->def)
< 0)
goto cleanup;
if (!(snapshots = prlsdkLoadSnapshots(dom)))
@@ -2490,7 +2490,7 @@ vzDomainSnapshotGetParent(virDomainSnapshotPtr snapshot, unsigned
int flags)
goto cleanup;
}
- parent = virGetDomainSnapshot(snapshot->domain, snap->def->parent);
+ parent = virGetDomainSnapshot(virSnapDom(snapshot), snap->def->parent);
cleanup:
virDomainSnapshotObjListFree(snapshots);
@@ -2543,17 +2543,17 @@ vzDomainSnapshotIsCurrent(virDomainSnapshotPtr snapshot, unsigned
int flags)
virCheckFlags(0, -1);
- if (!(dom = vzDomObjFromDomain(snapshot->domain)))
+ if (!(dom = vzDomObjFromDomain(virSnapDom(snapshot))))
return -1;
- if (virDomainSnapshotIsCurrentEnsureACL(snapshot->domain->conn, dom->def)
< 0)
+ if (virDomainSnapshotIsCurrentEnsureACL(virSnapDom(snapshot)->conn, dom->def)
< 0)
goto cleanup;
if (!(snapshots = prlsdkLoadSnapshots(dom)))
goto cleanup;
current = vzFindCurrentSnapshot(snapshots);
- ret = current && STREQ(snapshot->name, current->def->name);
+ ret = current && STREQ(virSnapName(snapshot), current->def->name);
cleanup:
virDomainSnapshotObjListFree(snapshots);
@@ -2573,10 +2573,10 @@ vzDomainSnapshotHasMetadata(virDomainSnapshotPtr snapshot,
virCheckFlags(0, -1);
- if (!(dom = vzDomObjFromDomain(snapshot->domain)))
+ if (!(dom = vzDomObjFromDomain(virSnapDom(snapshot))))
return -1;
- if (virDomainSnapshotHasMetadataEnsureACL(snapshot->domain->conn, dom->def)
< 0)
+ if (virDomainSnapshotHasMetadataEnsureACL(virSnapDom(snapshot)->conn, dom->def)
< 0)
goto cleanup;
if (!(snapshots = prlsdkLoadSnapshots(dom)))
@@ -2674,13 +2674,13 @@ vzDomainSnapshotDelete(virDomainSnapshotPtr snapshot, unsigned int
flags)
virCheckFlags(VIR_DOMAIN_SNAPSHOT_DELETE_CHILDREN, -1);
- if (!(dom = vzDomObjFromDomain(snapshot->domain)))
+ if (!(dom = vzDomObjFromDomain(virSnapDom(snapshot))))
return -1;
- if (virDomainSnapshotDeleteEnsureACL(snapshot->domain->conn, dom->def) <
0)
+ if (virDomainSnapshotDeleteEnsureACL(virSnapDom(snapshot)->conn, dom->def) <
0)
goto cleanup;
- ret = prlsdkDeleteSnapshot(dom, snapshot->name,
+ ret = prlsdkDeleteSnapshot(dom, virSnapName(snapshot),
flags & VIR_DOMAIN_SNAPSHOT_DELETE_CHILDREN);
cleanup:
@@ -2698,10 +2698,10 @@ vzDomainRevertToSnapshot(virDomainSnapshotPtr snapshot, unsigned
int flags)
virCheckFlags(VIR_DOMAIN_SNAPSHOT_REVERT_PAUSED, -1);
- if (!(dom = vzDomObjFromDomain(snapshot->domain)))
+ if (!(dom = vzDomObjFromDomain(virSnapDom(snapshot))))
return -1;
- if (virDomainRevertToSnapshotEnsureACL(snapshot->domain->conn, dom->def)
< 0)
+ if (virDomainRevertToSnapshotEnsureACL(virSnapDom(snapshot)->conn, dom->def)
< 0)
goto cleanup;
if (vzDomainObjBeginJob(dom) < 0)
@@ -2711,7 +2711,7 @@ vzDomainRevertToSnapshot(virDomainSnapshotPtr snapshot, unsigned int
flags)
if (vzEnsureDomainExists(dom) < 0)
goto cleanup;
- ret = prlsdkSwitchToSnapshot(dom, snapshot->name,
+ ret = prlsdkSwitchToSnapshot(dom, virSnapName(snapshot),
flags & VIR_DOMAIN_SNAPSHOT_REVERT_PAUSED);
cleanup:
if (job)
--
2.20.1