mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-12-23 14:15:28 +00:00
snapshot: s/current/parent/ as prep for virObject
VIR_CLASS_NEW insists that descendents of virObject have 'parent' as the name of their inherited base class member at offset 0. While it would be possible to write a new class-creation macro that takes the actual field name 'current', and rewrite VIR_CLASS_NEW to call the new macro with the hard-coded name 'parent', it seems less confusing if all object code uses similar naming. Thus, this is a mechanical rename in preparation of making virDomainSnapshotDef a descendent of virObject. Signed-off-by: Eric Blake <eblake@redhat.com> Acked-by: Peter Krempa <pkrempa@redhat.com>
This commit is contained in:
parent
36603bc568
commit
098043eddd
@ -88,7 +88,7 @@ void virDomainSnapshotDefFree(virDomainSnapshotDefPtr def)
|
||||
if (!def)
|
||||
return;
|
||||
|
||||
virDomainMomentDefClear(&def->common);
|
||||
virDomainMomentDefClear(&def->parent);
|
||||
VIR_FREE(def->file);
|
||||
for (i = 0; i < def->ndisks; i++)
|
||||
virDomainSnapshotDiskDefClear(&def->disks[i]);
|
||||
@ -208,8 +208,8 @@ virDomainSnapshotDefParse(xmlXPathContextPtr ctxt,
|
||||
if (VIR_ALLOC(def) < 0)
|
||||
goto cleanup;
|
||||
|
||||
def->common.name = 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"));
|
||||
@ -217,17 +217,17 @@ virDomainSnapshotDefParse(xmlXPathContextPtr ctxt,
|
||||
}
|
||||
}
|
||||
|
||||
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) {
|
||||
@ -263,14 +263,14 @@ virDomainSnapshotDefParse(xmlXPathContextPtr ctxt,
|
||||
_("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;
|
||||
}
|
||||
|
||||
@ -422,7 +422,7 @@ virDomainSnapshotDefParseString(const char *xmlStr,
|
||||
|
||||
|
||||
/* Perform sanity checking on a redefined snapshot definition. If
|
||||
* @other is non-NULL, this may include swapping def->common.dom from other
|
||||
* @other is non-NULL, this may include swapping def->parent.dom from other
|
||||
* into def. */
|
||||
int
|
||||
virDomainSnapshotRedefineValidate(virDomainSnapshotDefPtr def,
|
||||
@ -440,17 +440,17 @@ virDomainSnapshotRedefineValidate(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;
|
||||
}
|
||||
|
||||
@ -464,7 +464,7 @@ virDomainSnapshotRedefineValidate(virDomainSnapshotDefPtr def,
|
||||
virReportError(VIR_ERR_INVALID_ARG,
|
||||
_("cannot change between online and offline "
|
||||
"snapshot state in snapshot %s"),
|
||||
def->common.name);
|
||||
def->parent.name);
|
||||
return -1;
|
||||
}
|
||||
|
||||
@ -473,23 +473,23 @@ virDomainSnapshotRedefineValidate(virDomainSnapshotDefPtr def,
|
||||
virReportError(VIR_ERR_INVALID_ARG,
|
||||
_("cannot change between disk only and "
|
||||
"full system in snapshot %s"),
|
||||
def->common.name);
|
||||
def->parent.name);
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (otherdef->common.dom) {
|
||||
if (def->common.dom) {
|
||||
if (!virDomainDefCheckABIStability(otherdef->common.dom,
|
||||
def->common.dom, xmlopt))
|
||||
if (otherdef->parent.dom) {
|
||||
if (def->parent.dom) {
|
||||
if (!virDomainDefCheckABIStability(otherdef->parent.dom,
|
||||
def->parent.dom, xmlopt))
|
||||
return -1;
|
||||
} else {
|
||||
/* Transfer the domain def */
|
||||
VIR_STEAL_PTR(def->common.dom, otherdef->common.dom);
|
||||
VIR_STEAL_PTR(def->parent.dom, otherdef->parent.dom);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (def->common.dom) {
|
||||
if (def->parent.dom) {
|
||||
if (external) {
|
||||
align_location = VIR_DOMAIN_SNAPSHOT_LOCATION_EXTERNAL;
|
||||
align_match = false;
|
||||
@ -536,7 +536,7 @@ virDomainSnapshotDefAssignExternalNames(virDomainSnapshotDefPtr def)
|
||||
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"),
|
||||
@ -560,7 +560,7 @@ virDomainSnapshotDefAssignExternalNames(virDomainSnapshotDefPtr def)
|
||||
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;
|
||||
}
|
||||
@ -593,7 +593,7 @@ virDomainSnapshotCompareDiskIndex(const void *a, const void *b)
|
||||
return diska->idx - diskb->idx;
|
||||
}
|
||||
|
||||
/* Align def->disks to def->common.dom. Sort the list of def->disks,
|
||||
/* Align def->disks to def->parent.dom. Sort the list of def->disks,
|
||||
* filling in any missing disks or snapshot state defaults given by
|
||||
* the domain, with a fallback to a passed in default. Convert paths
|
||||
* to disk targets for uniformity. Issue an error and return -1 if
|
||||
@ -610,31 +610,31 @@ virDomainSnapshotAlignDisks(virDomainSnapshotDefPtr def,
|
||||
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) {
|
||||
@ -652,7 +652,7 @@ virDomainSnapshotAlignDisks(virDomainSnapshotDefPtr def,
|
||||
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 ||
|
||||
@ -680,9 +680,9 @@ virDomainSnapshotAlignDisks(virDomainSnapshotDefPtr def,
|
||||
disk->src->path, disk->name);
|
||||
goto cleanup;
|
||||
}
|
||||
if (STRNEQ(disk->name, def->common.dom->disks[idx]->dst)) {
|
||||
if (STRNEQ(disk->name, def->parent.dom->disks[idx]->dst)) {
|
||||
VIR_FREE(disk->name);
|
||||
if (VIR_STRDUP(disk->name, def->common.dom->disks[idx]->dst) < 0)
|
||||
if (VIR_STRDUP(disk->name, def->parent.dom->disks[idx]->dst) < 0)
|
||||
goto cleanup;
|
||||
}
|
||||
}
|
||||
@ -690,10 +690,10 @@ virDomainSnapshotAlignDisks(virDomainSnapshotDefPtr def,
|
||||
/* 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))
|
||||
@ -701,15 +701,15 @@ virDomainSnapshotAlignDisks(virDomainSnapshotDefPtr def,
|
||||
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)
|
||||
@ -801,26 +801,26 @@ virDomainSnapshotDefFormatInternal(virBufferPtr buf,
|
||||
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'",
|
||||
@ -840,8 +840,8 @@ virDomainSnapshotDefFormatInternal(virBufferPtr buf,
|
||||
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) {
|
||||
@ -933,31 +933,31 @@ virDomainSnapshotRedefinePrep(virDomainPtr domain,
|
||||
bool check_if_stolen;
|
||||
|
||||
/* Prevent circular chains */
|
||||
if (def->common.parent_name) {
|
||||
if (STREQ(def->common.name, def->common.parent_name)) {
|
||||
if (def->parent.parent_name) {
|
||||
if (STREQ(def->parent.name, def->parent.parent_name)) {
|
||||
virReportError(VIR_ERR_INVALID_ARG,
|
||||
_("cannot set snapshot %s as its own parent"),
|
||||
def->common.name);
|
||||
def->parent.name);
|
||||
return -1;
|
||||
}
|
||||
other = 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);
|
||||
@ -967,14 +967,14 @@ virDomainSnapshotRedefinePrep(virDomainPtr domain,
|
||||
}
|
||||
}
|
||||
|
||||
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) {
|
||||
@ -987,7 +987,7 @@ virDomainSnapshotRedefinePrep(virDomainPtr domain,
|
||||
* child relations by reusing snap. */
|
||||
virDomainMomentDropParent(other);
|
||||
virDomainSnapshotDefFree(otherdef);
|
||||
other->def = &(*defptr)->common;
|
||||
other->def = &(*defptr)->parent;
|
||||
*defptr = NULL;
|
||||
*snap = other;
|
||||
}
|
||||
|
@ -74,7 +74,7 @@ struct _virDomainSnapshotDiskDef {
|
||||
|
||||
/* Stores the complete snapshot metadata */
|
||||
struct _virDomainSnapshotDef {
|
||||
virDomainMomentDef common;
|
||||
virDomainMomentDef parent;
|
||||
|
||||
/* Additional public XML. */
|
||||
int state; /* virDomainSnapshotState */
|
||||
|
@ -44,7 +44,7 @@ virDomainMomentObjPtr
|
||||
virDomainSnapshotAssignDef(virDomainSnapshotObjListPtr snapshots,
|
||||
virDomainSnapshotDefPtr def)
|
||||
{
|
||||
return virDomainMomentAssignDef(snapshots->base, &def->common);
|
||||
return virDomainMomentAssignDef(snapshots->base, &def->parent);
|
||||
}
|
||||
|
||||
|
||||
|
@ -4118,7 +4118,7 @@ esxDomainSnapshotCreateXML(virDomainPtr domain, const char *xmlDesc,
|
||||
priv->parsedUri->autoAnswer) < 0 ||
|
||||
esxVI_LookupRootSnapshotTreeList(priv->primary, domain->uuid,
|
||||
&rootSnapshotList) < 0 ||
|
||||
esxVI_GetSnapshotTreeByName(rootSnapshotList, def->common.name,
|
||||
esxVI_GetSnapshotTreeByName(rootSnapshotList, def->parent.name,
|
||||
&snapshotTree, NULL,
|
||||
esxVI_Occurrence_OptionalItem) < 0) {
|
||||
goto cleanup;
|
||||
@ -4126,12 +4126,12 @@ esxDomainSnapshotCreateXML(virDomainPtr domain, const char *xmlDesc,
|
||||
|
||||
if (snapshotTree) {
|
||||
virReportError(VIR_ERR_OPERATION_INVALID,
|
||||
_("Snapshot '%s' already exists"), def->common.name);
|
||||
_("Snapshot '%s' already exists"), def->parent.name);
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
if (esxVI_CreateSnapshot_Task(priv->primary, virtualMachine->obj,
|
||||
def->common.name, def->common.description,
|
||||
def->parent.name, def->parent.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->common.name);
|
||||
snapshot = virGetDomainSnapshot(domain, def->parent.name);
|
||||
|
||||
cleanup:
|
||||
virDomainSnapshotDefFree(def);
|
||||
@ -4189,12 +4189,12 @@ esxDomainSnapshotGetXMLDesc(virDomainSnapshotPtr snapshot,
|
||||
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;
|
||||
}
|
||||
|
||||
|
@ -8467,7 +8467,7 @@ qemuDomainSnapshotWriteMetadata(virDomainObjPtr vm,
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
if (virAsprintf(&snapFile, "%s/%s.xml", snapDir, def->common.name) < 0)
|
||||
if (virAsprintf(&snapFile, "%s/%s.xml", snapDir, def->parent.name) < 0)
|
||||
goto cleanup;
|
||||
|
||||
ret = virXMLSaveFile(snapFile, NULL, "snapshot-edit", newxml);
|
||||
|
@ -14446,7 +14446,7 @@ qemuDomainSnapshotCreateInactiveExternal(virQEMUDriverPtr driver,
|
||||
* 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;
|
||||
|
||||
@ -15621,19 +15621,19 @@ qemuDomainSnapshotCreateXML(virDomainPtr domain,
|
||||
/* reject snapshot names containing slashes or starting with dot as
|
||||
* snapshot definitions are saved in files named by the snapshot name */
|
||||
if (!(flags & VIR_DOMAIN_SNAPSHOT_CREATE_NO_METADATA)) {
|
||||
if (strchr(def->common.name, '/')) {
|
||||
if (strchr(def->parent.name, '/')) {
|
||||
virReportError(VIR_ERR_XML_DETAIL,
|
||||
_("invalid snapshot name '%s': "
|
||||
"name can't contain '/'"),
|
||||
def->common.name);
|
||||
def->parent.name);
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
if (def->common.name[0] == '.') {
|
||||
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;
|
||||
}
|
||||
}
|
||||
@ -15704,7 +15704,7 @@ qemuDomainSnapshotCreateXML(virDomainPtr domain,
|
||||
* 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;
|
||||
|
@ -6403,7 +6403,7 @@ testDomainSnapshotCreateXML(virDomainPtr domain,
|
||||
&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,
|
||||
|
@ -4811,7 +4811,7 @@ vboxSnapshotRedefine(virDomainPtr dom,
|
||||
* read-only disks are in the redefined snapshot's media registry (the disks need to
|
||||
* be open to query their uuid).
|
||||
*/
|
||||
for (it = 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;
|
||||
@ -4825,7 +4825,7 @@ vboxSnapshotRedefine(virDomainPtr dom,
|
||||
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"));
|
||||
@ -4835,7 +4835,7 @@ vboxSnapshotRedefine(virDomainPtr dom,
|
||||
continue;
|
||||
/*The read only disk is not in the media registry*/
|
||||
|
||||
VBOX_UTF8_TO_UTF16(def->common.dom->disks[it]->src->path, &locationUtf);
|
||||
VBOX_UTF8_TO_UTF16(def->parent.dom->disks[it]->src->path, &locationUtf);
|
||||
rc = gVBoxAPI.UIVirtualBox.OpenMedium(data->vboxObj,
|
||||
locationUtf,
|
||||
DeviceType_HardDisk,
|
||||
@ -4908,7 +4908,7 @@ vboxSnapshotRedefine(virDomainPtr dom,
|
||||
|
||||
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;
|
||||
}
|
||||
@ -5013,12 +5013,12 @@ vboxSnapshotRedefine(virDomainPtr dom,
|
||||
goto cleanup;
|
||||
|
||||
VIR_DEBUG("New snapshot UUID: %s", newSnapshotPtr->uuid);
|
||||
if (VIR_STRDUP(newSnapshotPtr->name, def->common.name) < 0)
|
||||
if (VIR_STRDUP(newSnapshotPtr->name, def->parent.name) < 0)
|
||||
goto cleanup;
|
||||
|
||||
newSnapshotPtr->timeStamp = 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)
|
||||
@ -5028,12 +5028,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->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*/
|
||||
@ -5061,7 +5061,7 @@ vboxSnapshotRedefine(virDomainPtr dom,
|
||||
|
||||
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;
|
||||
@ -5081,10 +5081,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->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;
|
||||
|
||||
@ -5228,7 +5228,7 @@ vboxSnapshotRedefine(virDomainPtr dom,
|
||||
}
|
||||
} 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;
|
||||
@ -5244,7 +5244,7 @@ vboxSnapshotRedefine(virDomainPtr dom,
|
||||
|
||||
VBOX_IID_INITIALIZE(&iid);
|
||||
VBOX_IID_INITIALIZE(&parentiid);
|
||||
VBOX_UTF8_TO_UTF16(def->common.dom->disks[it]->src->path, &locationUtf16);
|
||||
VBOX_UTF8_TO_UTF16(def->parent.dom->disks[it]->src->path, &locationUtf16);
|
||||
rc = gVBoxAPI.UIVirtualBox.OpenMedium(data->vboxObj,
|
||||
locationUtf16,
|
||||
DeviceType_HardDisk,
|
||||
@ -5393,8 +5393,8 @@ vboxSnapshotRedefine(virDomainPtr dom,
|
||||
* All the snapshot structure manipulation is done, we close the disks we have
|
||||
* previously opened.
|
||||
*/
|
||||
for (it = 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;
|
||||
|
||||
@ -5513,7 +5513,7 @@ vboxDomainSnapshotCreateXML(virDomainPtr dom,
|
||||
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;
|
||||
}
|
||||
}
|
||||
@ -5540,14 +5540,14 @@ vboxDomainSnapshotCreateXML(virDomainPtr dom,
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
VBOX_UTF8_TO_UTF16(def->common.name, &name);
|
||||
VBOX_UTF8_TO_UTF16(def->parent.name, &name);
|
||||
if (!name) {
|
||||
virReportOOMError();
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
if (def->common.description) {
|
||||
VBOX_UTF8_TO_UTF16(def->common.description, &description);
|
||||
if (def->parent.description) {
|
||||
VBOX_UTF8_TO_UTF16(def->parent.description, &description);
|
||||
if (!description) {
|
||||
virReportOOMError();
|
||||
goto cleanup;
|
||||
@ -5577,7 +5577,7 @@ vboxDomainSnapshotCreateXML(virDomainPtr dom,
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
ret = virGetDomainSnapshot(dom, def->common.name);
|
||||
ret = virGetDomainSnapshot(dom, def->parent.name);
|
||||
|
||||
cleanup:
|
||||
VBOX_RELEASE(progress);
|
||||
@ -5981,7 +5981,7 @@ vboxSnapshotGetReadOnlyDisks(virDomainSnapshotDefPtr def,
|
||||
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;
|
||||
@ -6220,10 +6220,10 @@ static char *vboxDomainSnapshotGetXMLDesc(virDomainSnapshotPtr snapshot,
|
||||
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) {
|
||||
@ -6271,7 +6271,7 @@ static char *vboxDomainSnapshotGetXMLDesc(virDomainSnapshotPtr snapshot,
|
||||
if (str16) {
|
||||
VBOX_UTF16_TO_UTF8(str16, &str8);
|
||||
VBOX_UTF16_FREE(str16);
|
||||
if (VIR_STRDUP(def->common.description, str8) < 0) {
|
||||
if (VIR_STRDUP(def->parent.description, str8) < 0) {
|
||||
VBOX_UTF8_FREE(str8);
|
||||
goto cleanup;
|
||||
}
|
||||
@ -6286,7 +6286,7 @@ static char *vboxDomainSnapshotGetXMLDesc(virDomainSnapshotPtr snapshot,
|
||||
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)) {
|
||||
@ -6305,7 +6305,7 @@ static char *vboxDomainSnapshotGetXMLDesc(virDomainSnapshotPtr snapshot,
|
||||
}
|
||||
VBOX_UTF16_TO_UTF8(str16, &str8);
|
||||
VBOX_UTF16_FREE(str16);
|
||||
if (VIR_STRDUP(def->common.parent_name, str8) < 0) {
|
||||
if (VIR_STRDUP(def->parent.parent_name, str8) < 0) {
|
||||
VBOX_UTF8_FREE(str8);
|
||||
goto cleanup;
|
||||
}
|
||||
@ -6987,7 +6987,7 @@ vboxDomainSnapshotDeleteMetadataOnly(virDomainSnapshotPtr snapshot)
|
||||
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"));
|
||||
@ -6999,8 +6999,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->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;
|
||||
@ -7020,7 +7020,7 @@ vboxDomainSnapshotDeleteMetadataOnly(virDomainSnapshotPtr snapshot)
|
||||
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"));
|
||||
@ -7058,7 +7058,7 @@ vboxDomainSnapshotDeleteMetadataOnly(virDomainSnapshotPtr snapshot)
|
||||
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,
|
||||
@ -7156,15 +7156,15 @@ vboxDomainSnapshotDeleteMetadataOnly(virDomainSnapshotPtr snapshot)
|
||||
}
|
||||
}
|
||||
} 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;
|
||||
}
|
||||
|
||||
@ -7209,14 +7209,14 @@ vboxDomainSnapshotDeleteMetadataOnly(virDomainSnapshotPtr snapshot)
|
||||
}
|
||||
}
|
||||
/*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) {
|
||||
@ -7281,16 +7281,16 @@ vboxDomainSnapshotDeleteMetadataOnly(virDomainSnapshotPtr snapshot)
|
||||
}
|
||||
|
||||
/*removing the snapshot*/
|
||||
if (virVBoxSnapshotConfRemoveSnapshot(snapshotMachineDesc, def->common.name) < 0) {
|
||||
if (virVBoxSnapshotConfRemoveSnapshot(snapshotMachineDesc, def->parent.name) < 0) {
|
||||
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||
_("Unable to remove snapshot %s"), def->common.name);
|
||||
_("Unable to remove snapshot %s"), def->parent.name);
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
if (isCurrent) {
|
||||
VIR_FREE(snapshotMachineDesc->currentSnapshot);
|
||||
if (def->common.parent_name != 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"));
|
||||
|
@ -2619,7 +2619,7 @@ vzDomainSnapshotCreateXML(virDomainPtr domain,
|
||||
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)))
|
||||
|
@ -4696,14 +4696,14 @@ prlsdkParseSnapshotTree(const char *treexml)
|
||||
|
||||
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) {
|
||||
@ -4711,11 +4711,11 @@ prlsdkParseSnapshotTree(const char *treexml)
|
||||
_("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);
|
||||
|
Loading…
Reference in New Issue
Block a user