mirror of
https://github.com/libvirt/libvirt.git
synced 2025-02-25 18:55:26 -06:00
snapshot: populate new XML info for qemu snapshots
Now that the XML supports listing internal snapshots, it is worth always populating the <memory> and <disks> element to match. * src/qemu/qemu_driver.c (qemuDomainSnapshotCreateXML): Always parse disk info and set memory info.
This commit is contained in:
parent
f9670bf8a4
commit
e260e401a5
@ -11192,8 +11192,10 @@ qemuDomainSnapshotCreateXML(virDomainPtr domain,
|
|||||||
char uuidstr[VIR_UUID_STRING_BUFLEN];
|
char uuidstr[VIR_UUID_STRING_BUFLEN];
|
||||||
virDomainSnapshotDefPtr def = NULL;
|
virDomainSnapshotDefPtr def = NULL;
|
||||||
bool update_current = true;
|
bool update_current = true;
|
||||||
unsigned int parse_flags = 0;
|
unsigned int parse_flags = VIR_DOMAIN_SNAPSHOT_PARSE_DISKS;
|
||||||
virDomainSnapshotObjPtr other = NULL;
|
virDomainSnapshotObjPtr other = NULL;
|
||||||
|
int align_location = VIR_DOMAIN_SNAPSHOT_LOCATION_INTERNAL;
|
||||||
|
int align_match = true;
|
||||||
|
|
||||||
virCheckFlags(VIR_DOMAIN_SNAPSHOT_CREATE_REDEFINE |
|
virCheckFlags(VIR_DOMAIN_SNAPSHOT_CREATE_REDEFINE |
|
||||||
VIR_DOMAIN_SNAPSHOT_CREATE_CURRENT |
|
VIR_DOMAIN_SNAPSHOT_CREATE_CURRENT |
|
||||||
@ -11217,8 +11219,6 @@ qemuDomainSnapshotCreateXML(virDomainPtr domain,
|
|||||||
update_current = false;
|
update_current = false;
|
||||||
if (flags & VIR_DOMAIN_SNAPSHOT_CREATE_REDEFINE)
|
if (flags & VIR_DOMAIN_SNAPSHOT_CREATE_REDEFINE)
|
||||||
parse_flags |= VIR_DOMAIN_SNAPSHOT_PARSE_REDEFINE;
|
parse_flags |= VIR_DOMAIN_SNAPSHOT_PARSE_REDEFINE;
|
||||||
if (flags & VIR_DOMAIN_SNAPSHOT_CREATE_DISK_ONLY)
|
|
||||||
parse_flags |= VIR_DOMAIN_SNAPSHOT_PARSE_DISKS;
|
|
||||||
|
|
||||||
qemuDriverLock(driver);
|
qemuDriverLock(driver);
|
||||||
virUUIDFormat(domain->uuid, uuidstr);
|
virUUIDFormat(domain->uuid, uuidstr);
|
||||||
@ -11245,6 +11245,9 @@ qemuDomainSnapshotCreateXML(virDomainPtr domain,
|
|||||||
_("cannot halt after transient domain snapshot"));
|
_("cannot halt after transient domain snapshot"));
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
if ((flags & VIR_DOMAIN_SNAPSHOT_CREATE_DISK_ONLY) ||
|
||||||
|
!virDomainObjIsActive(vm))
|
||||||
|
parse_flags |= VIR_DOMAIN_SNAPSHOT_PARSE_OFFLINE;
|
||||||
|
|
||||||
if (!(def = virDomainSnapshotDefParseString(xmlDesc, driver->caps,
|
if (!(def = virDomainSnapshotDefParseString(xmlDesc, driver->caps,
|
||||||
QEMU_EXPECTED_VIRT_TYPES,
|
QEMU_EXPECTED_VIRT_TYPES,
|
||||||
@ -11285,6 +11288,15 @@ qemuDomainSnapshotCreateXML(virDomainPtr domain,
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Check that any replacement is compatible */
|
/* Check that any replacement is compatible */
|
||||||
|
if ((flags & VIR_DOMAIN_SNAPSHOT_CREATE_DISK_ONLY) &&
|
||||||
|
def->state != VIR_DOMAIN_DISK_SNAPSHOT) {
|
||||||
|
virReportError(VIR_ERR_INVALID_ARG,
|
||||||
|
_("disk-only flag for snapshot %s requires "
|
||||||
|
"disk-snapshot state"),
|
||||||
|
def->name);
|
||||||
|
goto cleanup;
|
||||||
|
|
||||||
|
}
|
||||||
if (def->dom &&
|
if (def->dom &&
|
||||||
memcmp(def->dom->uuid, domain->uuid, VIR_UUID_BUFLEN)) {
|
memcmp(def->dom->uuid, domain->uuid, VIR_UUID_BUFLEN)) {
|
||||||
virReportError(VIR_ERR_INVALID_ARG,
|
virReportError(VIR_ERR_INVALID_ARG,
|
||||||
@ -11334,10 +11346,13 @@ qemuDomainSnapshotCreateXML(virDomainPtr domain,
|
|||||||
other->def = NULL;
|
other->def = NULL;
|
||||||
snap = other;
|
snap = other;
|
||||||
}
|
}
|
||||||
if (def->state == VIR_DOMAIN_DISK_SNAPSHOT && def->dom) {
|
if (def->dom) {
|
||||||
if (virDomainSnapshotAlignDisks(def,
|
if (def->state == VIR_DOMAIN_DISK_SNAPSHOT) {
|
||||||
VIR_DOMAIN_SNAPSHOT_LOCATION_EXTERNAL,
|
align_location = VIR_DOMAIN_SNAPSHOT_LOCATION_EXTERNAL;
|
||||||
false) < 0)
|
align_match = false;
|
||||||
|
}
|
||||||
|
if (virDomainSnapshotAlignDisks(def, align_location,
|
||||||
|
align_match) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@ -11356,13 +11371,14 @@ qemuDomainSnapshotCreateXML(virDomainPtr domain,
|
|||||||
"implemented yet"));
|
"implemented yet"));
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
if (virDomainSnapshotAlignDisks(def,
|
align_location = VIR_DOMAIN_SNAPSHOT_LOCATION_EXTERNAL;
|
||||||
VIR_DOMAIN_SNAPSHOT_LOCATION_EXTERNAL,
|
align_match = false;
|
||||||
false) < 0)
|
if (virDomainSnapshotAlignDisks(def, align_location,
|
||||||
goto cleanup;
|
align_match) < 0 ||
|
||||||
if (qemuDomainSnapshotDiskPrepare(vm, def, &flags) < 0)
|
qemuDomainSnapshotDiskPrepare(vm, def, &flags) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
def->state = VIR_DOMAIN_DISK_SNAPSHOT;
|
def->state = VIR_DOMAIN_DISK_SNAPSHOT;
|
||||||
|
def->memory = VIR_DOMAIN_SNAPSHOT_LOCATION_NONE;
|
||||||
} else {
|
} else {
|
||||||
/* In a perfect world, we would allow qemu to tell us this.
|
/* In a perfect world, we would allow qemu to tell us this.
|
||||||
* The problem is that qemu only does this check
|
* The problem is that qemu only does this check
|
||||||
@ -11373,9 +11389,14 @@ qemuDomainSnapshotCreateXML(virDomainPtr domain,
|
|||||||
* the boot device. This is probably a bug in qemu, but we'll
|
* the boot device. This is probably a bug in qemu, but we'll
|
||||||
* work around it here for now.
|
* work around it here for now.
|
||||||
*/
|
*/
|
||||||
if (!qemuDomainSnapshotIsAllowed(vm))
|
if (!qemuDomainSnapshotIsAllowed(vm) ||
|
||||||
|
virDomainSnapshotAlignDisks(def, align_location,
|
||||||
|
align_match) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
def->state = virDomainObjGetState(vm, NULL);
|
def->state = virDomainObjGetState(vm, NULL);
|
||||||
|
def->memory = (def->state == VIR_DOMAIN_SHUTOFF ?
|
||||||
|
VIR_DOMAIN_SNAPSHOT_LOCATION_NONE :
|
||||||
|
VIR_DOMAIN_SNAPSHOT_LOCATION_INTERNAL);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user