[libvirt] [PATCH v2 3/8] qemu: Introduce helper qemuGetCompressionProgram

Ján Tomko jtomko at redhat.com
Tue Sep 27 16:40:02 UTC 2016


On Fri, Sep 23, 2016 at 07:30:51AM -0400, John Ferlan wrote:
>Split out the guts of getCompressionType to perform the same functionality
>in the new helper program with a subsequent patch goal to be reusable for
>other callers making similar checks/calls to ensure the compression type
>is valid and that the compression program cannot be found.
>
>Signed-off-by: John Ferlan <jferlan at redhat.com>
>---
> src/qemu/qemu_driver.c | 67 ++++++++++++++++++++++++++++++++++----------------
> 1 file changed, 46 insertions(+), 21 deletions(-)
>
>diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
>index 956bddd..3f03576 100644
>--- a/src/qemu/qemu_driver.c
>+++ b/src/qemu/qemu_driver.c
>@@ -3267,36 +3267,61 @@ qemuCompressProgramAvailable(virQEMUSaveFormat compress)
> }
>
>
>+/* qemuGetCompressionProgram:
>+ * @imageFormat: String representation from qemu.conf for the compression
>+ *               image format being used (dump, save, or snapshot).
>+ *
>+ * Returns:
>+ *    virQEMUSaveFormat    - Integer representation of the compression
>+ *                           program to be used for particular style
>+ *                           (e.g. dump, save, or snapshot).
>+ *    QEMU_SAVE_FORMAT_RAW - If there is no qemu.conf imageFormat value or
>+ *                           no there was an error, then just return RAW
>+ *                           indicating none.
>+ */
>+static virQEMUSaveFormat
>+qemuGetCompressionProgram(const char *imageFormat)
>+{
>+    virQEMUSaveFormat ret;
>+
>+    if (!imageFormat)
>+        return QEMU_SAVE_FORMAT_RAW;
>+
>+    if ((ret = qemuSaveCompressionTypeFromString(imageFormat)) < 0)
>+        goto error;
>+

The list of supported values is known at compile time.

If the value is invalid, we should reject it when parsing the config
file.

That way the 'getCompressionProgram' helper would be faithful to its
name and only try to get the compression program.

Jan
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 801 bytes
Desc: Digital signature
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20160927/2952752a/attachment-0001.sig>


More information about the libvir-list mailing list