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:
Eric Blake 2011-09-01 15:47:03 -06:00
parent 2b4d8deb6b
commit ece197e9d4

View File

@ -8620,7 +8620,7 @@ static virDomainSnapshotPtr qemuDomainSnapshotCreateXML(virDomainPtr domain,
char uuidstr[VIR_UUID_STRING_BUFLEN];
virDomainSnapshotDefPtr def = NULL;
virCheckFlags(0, NULL);
virCheckFlags(VIR_DOMAIN_SNAPSHOT_CREATE_NO_METADATA, NULL);
qemuDriverLock(driver);
virUUIDFormat(domain->uuid, uuidstr);
@ -8662,12 +8662,14 @@ static virDomainSnapshotPtr qemuDomainSnapshotCreateXML(virDomainPtr domain,
virReportOOMError();
goto cleanup;
}
if (!(flags & VIR_DOMAIN_SNAPSHOT_CREATE_NO_METADATA)) {
vm->current_snapshot->def->current = false;
if (qemuDomainSnapshotWriteMetadata(vm, vm->current_snapshot,
driver->snapshotDir) < 0)
goto cleanup;
vm->current_snapshot = NULL;
}
}
/* actually do the snapshot */
if (!virDomainObjIsActive(vm)) {
@ -8687,7 +8689,7 @@ static virDomainSnapshotPtr qemuDomainSnapshotCreateXML(virDomainPtr domain,
cleanup:
if (vm) {
if (snapshot) {
if (snapshot && !(flags & VIR_DOMAIN_SNAPSHOT_CREATE_NO_METADATA)) {
if (qemuDomainSnapshotWriteMetadata(vm, snap,
driver->snapshotDir) < 0)
VIR_WARN("unable to save metadata for snapshot %s",
@ -8876,7 +8878,9 @@ static char *qemuDomainSnapshotGetXMLDesc(virDomainSnapshotPtr snapshot,
virDomainSnapshotObjPtr snap = NULL;
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);
virUUIDFormat(snapshot->domain->uuid, uuidstr);