mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-12-23 14:15:28 +00:00
snapshot: add qemu snapshot creation without metadata
Supporting NO_METADATA on snapshot creation is interesting - we must still return a valid opaque snapshot object, but the user can't get anything out of it (unless we add a virDomainSnapshotGetName()), since it is no longer registered with the domain. Also, virsh now tries to query for secure xml, in anticipation of when we store <domain> xml inside <domainsnapshot>; for now, we can trivially support it, since we have nothing secure. * src/qemu/qemu_driver.c (qemuDomainSnapshotCreateXML): Support new flag. (qemuDomainSnapshotGetXMLDesc): Trivially support VIR_DOMAIN_XML_SECURE.
This commit is contained in:
parent
2b4d8deb6b
commit
ece197e9d4
@ -8620,7 +8620,7 @@ static virDomainSnapshotPtr qemuDomainSnapshotCreateXML(virDomainPtr domain,
|
|||||||
char uuidstr[VIR_UUID_STRING_BUFLEN];
|
char uuidstr[VIR_UUID_STRING_BUFLEN];
|
||||||
virDomainSnapshotDefPtr def = NULL;
|
virDomainSnapshotDefPtr def = NULL;
|
||||||
|
|
||||||
virCheckFlags(0, NULL);
|
virCheckFlags(VIR_DOMAIN_SNAPSHOT_CREATE_NO_METADATA, NULL);
|
||||||
|
|
||||||
qemuDriverLock(driver);
|
qemuDriverLock(driver);
|
||||||
virUUIDFormat(domain->uuid, uuidstr);
|
virUUIDFormat(domain->uuid, uuidstr);
|
||||||
@ -8662,11 +8662,13 @@ static virDomainSnapshotPtr qemuDomainSnapshotCreateXML(virDomainPtr domain,
|
|||||||
virReportOOMError();
|
virReportOOMError();
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
vm->current_snapshot->def->current = false;
|
if (!(flags & VIR_DOMAIN_SNAPSHOT_CREATE_NO_METADATA)) {
|
||||||
if (qemuDomainSnapshotWriteMetadata(vm, vm->current_snapshot,
|
vm->current_snapshot->def->current = false;
|
||||||
driver->snapshotDir) < 0)
|
if (qemuDomainSnapshotWriteMetadata(vm, vm->current_snapshot,
|
||||||
goto cleanup;
|
driver->snapshotDir) < 0)
|
||||||
vm->current_snapshot = NULL;
|
goto cleanup;
|
||||||
|
vm->current_snapshot = NULL;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* actually do the snapshot */
|
/* actually do the snapshot */
|
||||||
@ -8687,7 +8689,7 @@ static virDomainSnapshotPtr qemuDomainSnapshotCreateXML(virDomainPtr domain,
|
|||||||
|
|
||||||
cleanup:
|
cleanup:
|
||||||
if (vm) {
|
if (vm) {
|
||||||
if (snapshot) {
|
if (snapshot && !(flags & VIR_DOMAIN_SNAPSHOT_CREATE_NO_METADATA)) {
|
||||||
if (qemuDomainSnapshotWriteMetadata(vm, snap,
|
if (qemuDomainSnapshotWriteMetadata(vm, snap,
|
||||||
driver->snapshotDir) < 0)
|
driver->snapshotDir) < 0)
|
||||||
VIR_WARN("unable to save metadata for snapshot %s",
|
VIR_WARN("unable to save metadata for snapshot %s",
|
||||||
@ -8876,7 +8878,9 @@ static char *qemuDomainSnapshotGetXMLDesc(virDomainSnapshotPtr snapshot,
|
|||||||
virDomainSnapshotObjPtr snap = NULL;
|
virDomainSnapshotObjPtr snap = NULL;
|
||||||
char uuidstr[VIR_UUID_STRING_BUFLEN];
|
char uuidstr[VIR_UUID_STRING_BUFLEN];
|
||||||
|
|
||||||
virCheckFlags(0, NULL);
|
/* XXX Actually wire this up once we return domain xml; for now,
|
||||||
|
* it is trivially safe to ignore this flag. */
|
||||||
|
virCheckFlags(VIR_DOMAIN_XML_SECURE, NULL);
|
||||||
|
|
||||||
qemuDriverLock(driver);
|
qemuDriverLock(driver);
|
||||||
virUUIDFormat(snapshot->domain->uuid, uuidstr);
|
virUUIDFormat(snapshot->domain->uuid, uuidstr);
|
||||||
|
Loading…
Reference in New Issue
Block a user