if (!def)
return;
- virDomainMomentDefClear(&def->common);
+ virDomainMomentDefClear(&def->parent);
VIR_FREE(def->file);
for (i = 0; i < def->ndisks; i++)
virDomainSnapshotDiskDefClear(&def->disks[i]);
if (VIR_ALLOC(def) < 0)
goto cleanup;
- def->common.name = virXPathString("string(./name)", ctxt);
- if (def->common.name == NULL) {
+ def->parent.name = virXPathString("string(./name)", ctxt);
+ if (def->parent.name == NULL) {
if (flags & VIR_DOMAIN_SNAPSHOT_PARSE_REDEFINE) {
virReportError(VIR_ERR_XML_ERROR, "%s",
_("a redefined snapshot must have a name"));
}
}
- def->common.description = virXPathString("string(./description)", ctxt);
+ def->parent.description = virXPathString("string(./description)", ctxt);
if (flags & VIR_DOMAIN_SNAPSHOT_PARSE_REDEFINE) {
if (virXPathLongLong("string(./creationTime)", ctxt,
- &def->common.creationTime) < 0) {
+ &def->parent.creationTime) < 0) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("missing creationTime from existing snapshot"));
goto cleanup;
}
- def->common.parent_name = virXPathString("string(./parent/name)", ctxt);
+ def->parent.parent_name = virXPathString("string(./parent/name)", ctxt);
state = virXPathString("string(./state)", ctxt);
if (state == NULL) {
_("missing domain in snapshot"));
goto cleanup;
}
- def->common.dom = virDomainDefParseNode(ctxt->node->doc, domainNode,
+ def->parent.dom = virDomainDefParseNode(ctxt->node->doc, domainNode,
caps, xmlopt, NULL, domainflags);
- if (!def->common.dom)
+ if (!def->parent.dom)
goto cleanup;
} else {
VIR_WARN("parsing older snapshot that lacks domain");
}
- } else if (virDomainXMLOptionRunMomentPostParse(xmlopt, &def->common) < 0) {
+ } else if (virDomainXMLOptionRunMomentPostParse(xmlopt, &def->parent) < 0) {
goto cleanup;
}
/* Perform sanity checking on a redefined snapshot definition. If
- * @other is non-NULL, this may include swapping def->common.dom from other
+ * @other is non-NULL, this may include swapping def->parent.dom from other
* into def. */
int
virDomainSnapshotRedefineValidate(virDomainSnapshotDefPtr def,
virReportError(VIR_ERR_INVALID_ARG,
_("disk-only flag for snapshot %s requires "
"disk-snapshot state"),
- def->common.name);
+ def->parent.name);
return -1;
}
- if (def->common.dom && memcmp(def->common.dom->uuid, domain_uuid,
+ if (def->parent.dom && memcmp(def->parent.dom->uuid, domain_uuid,
VIR_UUID_BUFLEN)) {
char uuidstr[VIR_UUID_STRING_BUFLEN];
virUUIDFormat(domain_uuid, uuidstr);
virReportError(VIR_ERR_INVALID_ARG,
_("definition for snapshot %s must use uuid %s"),
- def->common.name, uuidstr);
+ def->parent.name, uuidstr);
return -1;
}
virReportError(VIR_ERR_INVALID_ARG,
_("cannot change between online and offline "
"snapshot state in snapshot %s"),
- def->common.name);
+ def->parent.name);
return -1;
}
virReportError(VIR_ERR_INVALID_ARG,
_("cannot change between disk only and "
"full system in snapshot %s"),
- def->common.name);
+ def->parent.name);
return -1;
}
- if (otherdef->common.dom) {
- if (def->common.dom) {
- if (!virDomainDefCheckABIStability(otherdef->common.dom,
- def->common.dom, xmlopt))
+ if (otherdef->parent.dom) {
+ if (def->parent.dom) {
+ if (!virDomainDefCheckABIStability(otherdef->parent.dom,
+ def->parent.dom, xmlopt))
return -1;
} else {
/* Transfer the domain def */
- VIR_STEAL_PTR(def->common.dom, otherdef->common.dom);
+ VIR_STEAL_PTR(def->parent.dom, otherdef->parent.dom);
}
}
}
- if (def->common.dom) {
+ if (def->parent.dom) {
if (external) {
align_location = VIR_DOMAIN_SNAPSHOT_LOCATION_EXTERNAL;
align_match = false;
return -1;
}
- if (!(origpath = virDomainDiskGetSource(def->common.dom->disks[i]))) {
+ if (!(origpath = virDomainDiskGetSource(def->parent.dom->disks[i]))) {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
_("cannot generate external snapshot name "
"for disk '%s' without source"),
if ((tmp = strrchr(tmppath, '.')) && !strchr(tmp, '/'))
*tmp = '\0';
- if (virAsprintf(&disk->src->path, "%s.%s", tmppath, def->common.name) < 0) {
+ if (virAsprintf(&disk->src->path, "%s.%s", tmppath, def->parent.name) < 0) {
VIR_FREE(tmppath);
return -1;
}
return diska->idx - diskb->idx;
}
-/* Align def->disks to def->common.dom. Sort the list of def->disks,
+/* Align def->disks to def->parent.dom. Sort the list of def->disks,
* filling in any missing disks or snapshot state defaults given by
* the domain, with a fallback to a passed in default. Convert paths
* to disk targets for uniformity. Issue an error and return -1 if
size_t i;
int ndisks;
- if (!def->common.dom) {
+ if (!def->parent.dom) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("missing domain in snapshot"));
goto cleanup;
}
- if (def->ndisks > def->common.dom->ndisks) {
+ if (def->ndisks > def->parent.dom->ndisks) {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
_("too many disk snapshot requests for domain"));
goto cleanup;
}
/* Unlikely to have a guest without disks but technically possible. */
- if (!def->common.dom->ndisks) {
+ if (!def->parent.dom->ndisks) {
ret = 0;
goto cleanup;
}
- if (!(map = virBitmapNew(def->common.dom->ndisks)))
+ if (!(map = virBitmapNew(def->parent.dom->ndisks)))
goto cleanup;
/* Double check requested disks. */
for (i = 0; i < def->ndisks; i++) {
virDomainSnapshotDiskDefPtr disk = &def->disks[i];
- int idx = virDomainDiskIndexByName(def->common.dom, disk->name, false);
+ int idx = virDomainDiskIndexByName(def->parent.dom, disk->name, false);
int disk_snapshot;
if (idx < 0) {
ignore_value(virBitmapSetBit(map, idx));
disk->idx = idx;
- disk_snapshot = def->common.dom->disks[idx]->snapshot;
+ disk_snapshot = def->parent.dom->disks[idx]->snapshot;
if (!disk->snapshot) {
if (disk_snapshot &&
(!require_match ||
disk->src->path, disk->name);
goto cleanup;
}
- if (STRNEQ(disk->name, def->common.dom->disks[idx]->dst)) {
+ if (STRNEQ(disk->name, def->parent.dom->disks[idx]->dst)) {
VIR_FREE(disk->name);
- if (VIR_STRDUP(disk->name, def->common.dom->disks[idx]->dst) < 0)
+ if (VIR_STRDUP(disk->name, def->parent.dom->disks[idx]->dst) < 0)
goto cleanup;
}
}
/* Provide defaults for all remaining disks. */
ndisks = def->ndisks;
if (VIR_EXPAND_N(def->disks, def->ndisks,
- def->common.dom->ndisks - def->ndisks) < 0)
+ def->parent.dom->ndisks - def->ndisks) < 0)
goto cleanup;
- for (i = 0; i < def->common.dom->ndisks; i++) {
+ for (i = 0; i < def->parent.dom->ndisks; i++) {
virDomainSnapshotDiskDefPtr disk;
if (virBitmapIsBitSet(map, i))
disk = &def->disks[ndisks++];
if (!(disk->src = virStorageSourceNew()))
goto cleanup;
- if (VIR_STRDUP(disk->name, def->common.dom->disks[i]->dst) < 0)
+ if (VIR_STRDUP(disk->name, def->parent.dom->disks[i]->dst) < 0)
goto cleanup;
disk->idx = i;
/* Don't snapshot empty drives */
- if (virStorageSourceIsEmpty(def->common.dom->disks[i]->src))
+ if (virStorageSourceIsEmpty(def->parent.dom->disks[i]->src))
disk->snapshot = VIR_DOMAIN_SNAPSHOT_LOCATION_NONE;
else
- disk->snapshot = def->common.dom->disks[i]->snapshot;
+ disk->snapshot = def->parent.dom->disks[i]->snapshot;
disk->src->type = VIR_STORAGE_TYPE_FILE;
if (!disk->snapshot)
virBufferAddLit(buf, "<domainsnapshot>\n");
virBufferAdjustIndent(buf, 2);
- virBufferEscapeString(buf, "<name>%s</name>\n", def->common.name);
- if (def->common.description)
+ virBufferEscapeString(buf, "<name>%s</name>\n", def->parent.name);
+ if (def->parent.description)
virBufferEscapeString(buf, "<description>%s</description>\n",
- def->common.description);
+ def->parent.description);
if (def->state)
virBufferAsprintf(buf, "<state>%s</state>\n",
virDomainSnapshotStateTypeToString(def->state));
- if (def->common.parent_name) {
+ if (def->parent.parent_name) {
virBufferAddLit(buf, "<parent>\n");
virBufferAdjustIndent(buf, 2);
virBufferEscapeString(buf, "<name>%s</name>\n",
- def->common.parent_name);
+ def->parent.parent_name);
virBufferAdjustIndent(buf, -2);
virBufferAddLit(buf, "</parent>\n");
}
- if (def->common.creationTime)
+ if (def->parent.creationTime)
virBufferAsprintf(buf, "<creationTime>%lld</creationTime>\n",
- def->common.creationTime);
+ def->parent.creationTime);
if (def->memory) {
virBufferAsprintf(buf, "<memory snapshot='%s'",
virBufferAddLit(buf, "</disks>\n");
}
- if (def->common.dom) {
- if (virDomainDefFormatInternal(def->common.dom, caps, domainflags, buf,
+ if (def->parent.dom) {
+ if (virDomainDefFormatInternal(def->parent.dom, caps, domainflags, buf,
xmlopt) < 0)
goto error;
} else if (uuidstr) {
bool check_if_stolen;
/* Prevent circular chains */
- if (def->common.parent_name) {
- if (STREQ(def->common.name, def->common.parent_name)) {
+ if (def->parent.parent_name) {
+ if (STREQ(def->parent.name, def->parent.parent_name)) {
virReportError(VIR_ERR_INVALID_ARG,
_("cannot set snapshot %s as its own parent"),
- def->common.name);
+ def->parent.name);
return -1;
}
other = virDomainSnapshotFindByName(vm->snapshots,
- def->common.parent_name);
+ def->parent.parent_name);
if (!other) {
virReportError(VIR_ERR_INVALID_ARG,
_("parent %s for snapshot %s not found"),
- def->common.parent_name, def->common.name);
+ def->parent.parent_name, def->parent.name);
return -1;
}
otherdef = virDomainSnapshotObjGetDef(other);
- while (otherdef->common.parent_name) {
- if (STREQ(otherdef->common.parent_name, def->common.name)) {
+ while (otherdef->parent.parent_name) {
+ if (STREQ(otherdef->parent.parent_name, def->parent.name)) {
virReportError(VIR_ERR_INVALID_ARG,
_("parent %s would create cycle to %s"),
- otherdef->common.name, def->common.name);
+ otherdef->parent.name, def->parent.name);
return -1;
}
other = virDomainSnapshotFindByName(vm->snapshots,
- otherdef->common.parent_name);
+ otherdef->parent.parent_name);
if (!other) {
VIR_WARN("snapshots are inconsistent for %s",
vm->def->name);
}
}
- other = virDomainSnapshotFindByName(vm->snapshots, def->common.name);
+ other = virDomainSnapshotFindByName(vm->snapshots, def->parent.name);
otherdef = other ? virDomainSnapshotObjGetDef(other) : NULL;
- check_if_stolen = other && otherdef->common.dom;
+ check_if_stolen = other && otherdef->parent.dom;
if (virDomainSnapshotRedefineValidate(def, domain->uuid, other, xmlopt,
flags) < 0) {
/* revert any stealing of the snapshot domain definition */
- if (check_if_stolen && def->common.dom && !otherdef->common.dom)
- VIR_STEAL_PTR(otherdef->common.dom, def->common.dom);
+ if (check_if_stolen && def->parent.dom && !otherdef->parent.dom)
+ VIR_STEAL_PTR(otherdef->parent.dom, def->parent.dom);
return -1;
}
if (other) {
* child relations by reusing snap. */
virDomainMomentDropParent(other);
virDomainSnapshotDefFree(otherdef);
- other->def = &(*defptr)->common;
+ other->def = &(*defptr)->parent;
*defptr = NULL;
*snap = other;
}
/* Stores the complete snapshot metadata */
struct _virDomainSnapshotDef {
- virDomainMomentDef common;
+ virDomainMomentDef parent;
/* Additional public XML. */
int state; /* virDomainSnapshotState */
virDomainSnapshotAssignDef(virDomainSnapshotObjListPtr snapshots,
virDomainSnapshotDefPtr def)
{
- return virDomainMomentAssignDef(snapshots->base, &def->common);
+ return virDomainMomentAssignDef(snapshots->base, &def->parent);
}
priv->parsedUri->autoAnswer) < 0 ||
esxVI_LookupRootSnapshotTreeList(priv->primary, domain->uuid,
&rootSnapshotList) < 0 ||
- esxVI_GetSnapshotTreeByName(rootSnapshotList, def->common.name,
+ esxVI_GetSnapshotTreeByName(rootSnapshotList, def->parent.name,
&snapshotTree, NULL,
esxVI_Occurrence_OptionalItem) < 0) {
goto cleanup;
if (snapshotTree) {
virReportError(VIR_ERR_OPERATION_INVALID,
- _("Snapshot '%s' already exists"), def->common.name);
+ _("Snapshot '%s' already exists"), def->parent.name);
goto cleanup;
}
if (esxVI_CreateSnapshot_Task(priv->primary, virtualMachine->obj,
- def->common.name, def->common.description,
+ def->parent.name, def->parent.description,
diskOnly ? esxVI_Boolean_False : esxVI_Boolean_True,
quiesce ? esxVI_Boolean_True : esxVI_Boolean_False,
&task) < 0 ||
goto cleanup;
}
- snapshot = virGetDomainSnapshot(domain, def->common.name);
+ snapshot = virGetDomainSnapshot(domain, def->parent.name);
cleanup:
virDomainSnapshotDefFree(def);
goto cleanup;
}
- def.common.name = snapshot->name;
- def.common.description = snapshotTree->description;
- def.common.parent_name = snapshotTreeParent ? snapshotTreeParent->name : NULL;
+ def.parent.name = snapshot->name;
+ def.parent.description = snapshotTree->description;
+ def.parent.parent_name = snapshotTreeParent ? snapshotTreeParent->name : NULL;
if (esxVI_DateTime_ConvertToCalendarTime(snapshotTree->createTime,
- &def.common.creationTime) < 0) {
+ &def.parent.creationTime) < 0) {
goto cleanup;
}
goto cleanup;
}
- if (virAsprintf(&snapFile, "%s/%s.xml", snapDir, def->common.name) < 0)
+ if (virAsprintf(&snapFile, "%s/%s.xml", snapDir, def->parent.name) < 0)
goto cleanup;
ret = virXMLSaveFile(snapFile, NULL, "snapshot-edit", newxml);
* create them correctly. */
for (i = 0; i < snapdef->ndisks && !reuse; i++) {
snapdisk = &(snapdef->disks[i]);
- defdisk = snapdef->common.dom->disks[snapdisk->idx];
+ defdisk = snapdef->parent.dom->disks[snapdisk->idx];
if (snapdisk->snapshot != VIR_DOMAIN_SNAPSHOT_LOCATION_EXTERNAL)
continue;
/* reject snapshot names containing slashes or starting with dot as
* snapshot definitions are saved in files named by the snapshot name */
if (!(flags & VIR_DOMAIN_SNAPSHOT_CREATE_NO_METADATA)) {
- if (strchr(def->common.name, '/')) {
+ if (strchr(def->parent.name, '/')) {
virReportError(VIR_ERR_XML_DETAIL,
_("invalid snapshot name '%s': "
"name can't contain '/'"),
- def->common.name);
+ def->parent.name);
goto cleanup;
}
- if (def->common.name[0] == '.') {
+ if (def->parent.name[0] == '.') {
virReportError(VIR_ERR_XML_DETAIL,
_("invalid snapshot name '%s': "
"name can't start with '.'"),
- def->common.name);
+ def->parent.name);
goto cleanup;
}
}
* conversion in and back out of xml. */
if (!(xml = qemuDomainDefFormatLive(driver, vm->def, priv->origCPU,
true, true)) ||
- !(def->common.dom = virDomainDefParseString(xml, caps, driver->xmlopt, NULL,
+ !(def->parent.dom = virDomainDefParseString(xml, caps, driver->xmlopt, NULL,
VIR_DOMAIN_DEF_PARSE_INACTIVE |
VIR_DOMAIN_DEF_PARSE_SKIP_VALIDATE)))
goto endjob;
&update_current, flags) < 0)
goto cleanup;
} else {
- if (!(def->common.dom = virDomainDefCopy(vm->def,
+ if (!(def->parent.dom = virDomainDefCopy(vm->def,
privconn->caps,
privconn->xmlopt,
NULL,
* 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->common.dom->ndisks; it++) {
+ for (it = 0; it < def->parent.dom->ndisks; it++) {
int diskInMediaRegistry = 0;
IMedium *readOnlyMedium = NULL;
PRUnichar *locationUtf = NULL;
VBOX_IID_INITIALIZE(&iid);
VBOX_IID_INITIALIZE(&parentiid);
diskInMediaRegistry = virVBoxSnapshotConfDiskIsInMediaRegistry(snapshotMachineDesc,
- def->common.dom->disks[it]->src->path);
+ def->parent.dom->disks[it]->src->path);
if (diskInMediaRegistry == -1) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("Unable to know if disk is in media registry"));
continue;
/*The read only disk is not in the media registry*/
- VBOX_UTF8_TO_UTF16(def->common.dom->disks[it]->src->path, &locationUtf);
+ VBOX_UTF8_TO_UTF16(def->parent.dom->disks[it]->src->path, &locationUtf);
rc = gVBoxAPI.UIVirtualBox.OpenMedium(data->vboxObj,
locationUtf,
DeviceType_HardDisk,
readOnlyDisk->format = format;
readOnlyDisk->uuid = uuid;
- if (VIR_STRDUP(readOnlyDisk->location, def->common.dom->disks[it]->src->path) < 0) {
+ if (VIR_STRDUP(readOnlyDisk->location, def->parent.dom->disks[it]->src->path) < 0) {
VIR_FREE(readOnlyDisk);
goto cleanup;
}
goto cleanup;
VIR_DEBUG("New snapshot UUID: %s", newSnapshotPtr->uuid);
- if (VIR_STRDUP(newSnapshotPtr->name, def->common.name) < 0)
+ if (VIR_STRDUP(newSnapshotPtr->name, def->parent.name) < 0)
goto cleanup;
- newSnapshotPtr->timeStamp = virTimeStringThen(def->common.creationTime * 1000);
+ newSnapshotPtr->timeStamp = virTimeStringThen(def->parent.creationTime * 1000);
- if (VIR_STRDUP(newSnapshotPtr->description, def->common.description) < 0)
+ if (VIR_STRDUP(newSnapshotPtr->description, def->parent.description) < 0)
goto cleanup;
if (VIR_STRDUP(newSnapshotPtr->hardware, snapshotMachineDesc->hardware) < 0)
goto cleanup;
/*We get the parent disk uuid from the parent disk location to correctly fill the storage controller.*/
- for (it = 0; it < def->common.dom->ndisks; it++) {
+ for (it = 0; it < def->parent.dom->ndisks; it++) {
char *location = NULL;
const char *uuidReplacing = NULL;
char *tmp = NULL;
- location = def->common.dom->disks[it]->src->path;
+ location = def->parent.dom->disks[it]->src->path;
if (!location)
goto cleanup;
/*Replacing the uuid*/
VIR_FREE(tmp);
}
- if (virVBoxSnapshotConfAddSnapshotToXmlMachine(newSnapshotPtr, snapshotMachineDesc, def->common.parent_name) < 0) {
+ if (virVBoxSnapshotConfAddSnapshotToXmlMachine(newSnapshotPtr, snapshotMachineDesc, def->parent.parent_name) < 0) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("Unable to add the snapshot to the machine description"));
goto cleanup;
* Open the snapshot's read-write disk's full ancestry to allow opening the
* read-write disk itself.
*/
- for (it = 0; it < def->common.dom->ndisks; it++) {
+ for (it = 0; it < def->parent.dom->ndisks; it++) {
char *location = NULL;
- location = def->common.dom->disks[it]->src->path;
+ location = def->parent.dom->disks[it]->src->path;
if (!location)
goto cleanup;
}
} else {
/*Create a "fake" disk to avoid corrupting children snapshot disks.*/
- for (it = 0; it < def->common.dom->ndisks; it++) {
+ for (it = 0; it < def->parent.dom->ndisks; it++) {
IMedium *medium = NULL;
PRUnichar *locationUtf16 = NULL;
char *parentUuid = NULL;
VBOX_IID_INITIALIZE(&iid);
VBOX_IID_INITIALIZE(&parentiid);
- VBOX_UTF8_TO_UTF16(def->common.dom->disks[it]->src->path, &locationUtf16);
+ VBOX_UTF8_TO_UTF16(def->parent.dom->disks[it]->src->path, &locationUtf16);
rc = gVBoxAPI.UIVirtualBox.OpenMedium(data->vboxObj,
locationUtf16,
DeviceType_HardDisk,
* All the snapshot structure manipulation is done, we close the disks we have
* previously opened.
*/
- for (it = 0; it < def->common.dom->ndisks; it++) {
- char *location = def->common.dom->disks[it]->src->path;
+ for (it = 0; it < def->parent.dom->ndisks; it++) {
+ char *location = def->parent.dom->disks[it]->src->path;
if (!location)
goto cleanup;
if (flags & VIR_DOMAIN_SNAPSHOT_CREATE_REDEFINE) {
if (vboxSnapshotRedefine(dom, def, isCurrent) < 0)
goto cleanup;
- ret = virGetDomainSnapshot(dom, def->common.name);
+ ret = virGetDomainSnapshot(dom, def->parent.name);
goto cleanup;
}
}
goto cleanup;
}
- VBOX_UTF8_TO_UTF16(def->common.name, &name);
+ VBOX_UTF8_TO_UTF16(def->parent.name, &name);
if (!name) {
virReportOOMError();
goto cleanup;
}
- if (def->common.description) {
- VBOX_UTF8_TO_UTF16(def->common.description, &description);
+ if (def->parent.description) {
+ VBOX_UTF8_TO_UTF16(def->parent.description, &description);
if (!description) {
virReportOOMError();
goto cleanup;
goto cleanup;
}
- ret = virGetDomainSnapshot(dom, def->common.name);
+ ret = virGetDomainSnapshot(dom, def->parent.name);
cleanup:
VBOX_RELEASE(progress);
vboxArray mediumAttachments = VBOX_ARRAY_INITIALIZER;
size_t i = 0, diskCount = 0, sdCount = 0;
int ret = -1;
- virDomainDefPtr defdom = def->common.dom;
+ virDomainDefPtr defdom = def->parent.dom;
if (!data->vboxObj)
return ret;
if (!(snap = vboxDomainSnapshotGet(data, dom, machine, snapshot->name)))
goto cleanup;
- if (VIR_ALLOC(def) < 0 || !(def->common.dom = virDomainDefNew()))
+ if (VIR_ALLOC(def) < 0 || !(def->parent.dom = virDomainDefNew()))
goto cleanup;
- defdom = def->common.dom;
- if (VIR_STRDUP(def->common.name, snapshot->name) < 0)
+ defdom = def->parent.dom;
+ if (VIR_STRDUP(def->parent.name, snapshot->name) < 0)
goto cleanup;
if (gVBoxAPI.vboxSnapshotRedefine) {
if (str16) {
VBOX_UTF16_TO_UTF8(str16, &str8);
VBOX_UTF16_FREE(str16);
- if (VIR_STRDUP(def->common.description, str8) < 0) {
+ if (VIR_STRDUP(def->parent.description, str8) < 0) {
VBOX_UTF8_FREE(str8);
goto cleanup;
}
goto cleanup;
}
/* timestamp is in milliseconds while creationTime in seconds */
- def->common.creationTime = timestamp / 1000;
+ def->parent.creationTime = timestamp / 1000;
rc = gVBoxAPI.UISnapshot.GetParent(snap, &parent);
if (NS_FAILED(rc)) {
}
VBOX_UTF16_TO_UTF8(str16, &str8);
VBOX_UTF16_FREE(str16);
- if (VIR_STRDUP(def->common.parent_name, str8) < 0) {
+ if (VIR_STRDUP(def->parent.parent_name, str8) < 0) {
VBOX_UTF8_FREE(str8);
goto cleanup;
}
goto cleanup;
}
- isCurrent = virVBoxSnapshotConfIsCurrentSnapshot(snapshotMachineDesc, def->common.name);
+ isCurrent = virVBoxSnapshotConfIsCurrentSnapshot(snapshotMachineDesc, def->parent.name);
if (isCurrent < 0) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("Unable to know if the snapshot is the current 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->common.parent_name != NULL) {
- for (it = 0; it < def->common.dom->ndisks; it++) {
+ if (def->parent.parent_name != NULL) {
+ for (it = 0; it < def->parent.dom->ndisks; it++) {
virVBoxSnapshotConfHardDiskPtr readOnly = NULL;
IMedium *medium = NULL;
PRUnichar *locationUtf16 = NULL;
VBOX_IID_INITIALIZE(&iid);
VBOX_IID_INITIALIZE(&parentiid);
readOnly = virVBoxSnapshotConfHardDiskPtrByLocation(snapshotMachineDesc,
- def->common.dom->disks[it]->src->path);
+ def->parent.dom->disks[it]->src->path);
if (!readOnly) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("Cannot get hard disk by location"));
VBOX_UTF8_TO_UTF16("VDI", &formatUtf16);
if (virAsprintf(&newLocationUtf8, "%sfakedisk-%s-%d.vdi",
- machineLocationPath, def->common.parent_name, it) < 0)
+ machineLocationPath, def->parent.parent_name, it) < 0)
goto cleanup;
VBOX_UTF8_TO_UTF16(newLocationUtf8, &newLocation);
rc = gVBoxAPI.UIVirtualBox.CreateHardDisk(data->vboxObj,
}
}
} else {
- for (it = 0; it < def->common.dom->ndisks; it++) {
+ for (it = 0; it < def->parent.dom->ndisks; it++) {
const char *uuidRO = NULL;
char *tmp = NULL;
uuidRO = virVBoxSnapshotConfHardDiskUuidByLocation(snapshotMachineDesc,
- def->common.dom->disks[it]->src->path);
+ def->parent.dom->disks[it]->src->path);
if (!uuidRO) {
virReportError(VIR_ERR_INTERNAL_ERROR,
_("No such disk in media registry %s"),
- def->common.dom->disks[it]->src->path);
+ def->parent.dom->disks[it]->src->path);
goto cleanup;
}
}
}
/*If the parent snapshot is not NULL, we remove the-read only disks from the media registry*/
- if (def->common.parent_name != NULL) {
- for (it = 0; it < def->common.dom->ndisks; it++) {
+ if (def->parent.parent_name != NULL) {
+ for (it = 0; it < def->parent.dom->ndisks; it++) {
const char *uuidRO =
virVBoxSnapshotConfHardDiskUuidByLocation(snapshotMachineDesc,
- def->common.dom->disks[it]->src->path);
+ def->parent.dom->disks[it]->src->path);
if (!uuidRO) {
virReportError(VIR_ERR_INTERNAL_ERROR,
- _("Unable to find UUID for location %s"), def->common.dom->disks[it]->src->path);
+ _("Unable to find UUID for location %s"), def->parent.dom->disks[it]->src->path);
goto cleanup;
}
if (virVBoxSnapshotConfRemoveHardDisk(snapshotMachineDesc->mediaRegistry, uuidRO) < 0) {
}
/*removing the snapshot*/
- if (virVBoxSnapshotConfRemoveSnapshot(snapshotMachineDesc, def->common.name) < 0) {
+ if (virVBoxSnapshotConfRemoveSnapshot(snapshotMachineDesc, def->parent.name) < 0) {
virReportError(VIR_ERR_INTERNAL_ERROR,
- _("Unable to remove snapshot %s"), def->common.name);
+ _("Unable to remove snapshot %s"), def->parent.name);
goto cleanup;
}
if (isCurrent) {
VIR_FREE(snapshotMachineDesc->currentSnapshot);
- if (def->common.parent_name != NULL) {
- virVBoxSnapshotConfSnapshotPtr snap = virVBoxSnapshotConfSnapshotByName(snapshotMachineDesc->snapshot, def->common.parent_name);
+ if (def->parent.parent_name != NULL) {
+ virVBoxSnapshotConfSnapshotPtr snap = virVBoxSnapshotConfSnapshotByName(snapshotMachineDesc->snapshot, def->parent.parent_name);
if (!snap) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("Unable to get the snapshot to remove"));
goto cleanup;
/* snaphot name is ignored, it will be set to auto generated by sdk uuid */
- if (prlsdkCreateSnapshot(dom, def->common.description) < 0)
+ if (prlsdkCreateSnapshot(dom, def->parent.description) < 0)
goto cleanup;
if (!(snapshots = prlsdkLoadSnapshots(dom)))
ctxt->node = nodes[i];
- def->common.name = virXPathString("string(./@guid)", ctxt);
- if (!def->common.name) {
+ def->parent.name = virXPathString("string(./@guid)", ctxt);
+ if (!def->parent.name) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("missing 'guid' attribute"));
goto cleanup;
}
- def->common.parent_name = virXPathString("string(../@guid)", ctxt);
+ def->parent.parent_name = virXPathString("string(../@guid)", ctxt);
xmlstr = virXPathString("string(./DateTime)", ctxt);
if (!xmlstr) {
_("missing 'DateTime' element"));
goto cleanup;
}
- if ((def->common.creationTime = prlsdkParseDateTime(xmlstr)) < 0)
+ if ((def->parent.creationTime = prlsdkParseDateTime(xmlstr)) < 0)
goto cleanup;
VIR_FREE(xmlstr);
- def->common.description = virXPathString("string(./Description)", ctxt);
+ def->parent.description = virXPathString("string(./Description)", ctxt);
def->memory = VIR_DOMAIN_SNAPSHOT_LOCATION_NONE;
xmlstr = virXPathString("string(./@state)", ctxt);