1
0
mirror of https://gitlab.com/libvirt/libvirt.git synced 2025-03-20 07:59:00 +00:00

qemu: managedsave: Add support for compressing managed save images

The regular save image code has the support to compress images using a
specified algorithm. This was not implemented for managed save although
it shares most of the backend code.
This commit is contained in:
Peter Krempa 2013-10-09 18:05:43 +02:00
parent 97973ebb7a
commit 550cae847b
2 changed files with 24 additions and 5 deletions

View File

@ -269,9 +269,9 @@
# saving a domain in order to save disk space; the list above is in descending # saving a domain in order to save disk space; the list above is in descending
# order by performance and ascending order by compression ratio. # order by performance and ascending order by compression ratio.
# #
# save_image_format is used when you use 'virsh save' at scheduled # save_image_format is used when you use 'virsh save' or 'virsh managedsave'
# saving, and it is an error if the specified save_image_format is # at scheduled saving, and it is an error if the specified save_image_format
# not valid, or the requested compression program can't be found. # is not valid, or the requested compression program can't be found.
# #
# dump_image_format is used when you use 'virsh dump' at emergency # dump_image_format is used when you use 'virsh dump' at emergency
# crashdump, and if the specified dump_image_format is not valid, or # crashdump, and if the specified dump_image_format is not valid, or

View File

@ -3232,6 +3232,8 @@ static int
qemuDomainManagedSave(virDomainPtr dom, unsigned int flags) qemuDomainManagedSave(virDomainPtr dom, unsigned int flags)
{ {
virQEMUDriverPtr driver = dom->conn->privateData; virQEMUDriverPtr driver = dom->conn->privateData;
virQEMUDriverConfigPtr cfg = NULL;
int compressed = QEMU_SAVE_FORMAT_RAW;
virDomainObjPtr vm; virDomainObjPtr vm;
char *name = NULL; char *name = NULL;
int ret = -1; int ret = -1;
@ -3257,13 +3259,29 @@ qemuDomainManagedSave(virDomainPtr dom, unsigned int flags)
goto cleanup; goto cleanup;
} }
cfg = virQEMUDriverGetConfig(driver);
if (cfg->saveImageFormat) {
compressed = qemuSaveCompressionTypeFromString(cfg->saveImageFormat);
if (compressed < 0) {
virReportError(VIR_ERR_OPERATION_FAILED, "%s",
_("Invalid save image format specified "
"in configuration file"));
goto cleanup;
}
if (!qemuCompressProgramAvailable(compressed)) {
virReportError(VIR_ERR_OPERATION_FAILED, "%s",
_("Compression program for image format "
"in configuration file isn't available"));
goto cleanup;
}
}
if (!(name = qemuDomainManagedSavePath(driver, vm))) if (!(name = qemuDomainManagedSavePath(driver, vm)))
goto cleanup; goto cleanup;
VIR_INFO("Saving state of domain '%s' to '%s'", vm->def->name, name); VIR_INFO("Saving state of domain '%s' to '%s'", vm->def->name, name);
if ((ret = qemuDomainSaveInternal(driver, dom, vm, name, if ((ret = qemuDomainSaveInternal(driver, dom, vm, name, compressed,
QEMU_SAVE_FORMAT_RAW,
NULL, flags)) == 0) NULL, flags)) == 0)
vm->hasManagedSave = true; vm->hasManagedSave = true;
@ -3273,6 +3291,7 @@ cleanup:
if (vm) if (vm)
virObjectUnlock(vm); virObjectUnlock(vm);
VIR_FREE(name); VIR_FREE(name);
virObjectUnref(cfg);
return ret; return ret;
} }