From f238709304f9f6c57204cdd943e542cbae38fa5f Mon Sep 17 00:00:00 2001 From: Jim Meyering Date: Thu, 10 Sep 2009 11:26:00 +0200 Subject: [PATCH] qemu_driver.c: factor out more duplication * src/qemu_driver.c (qemudDomainRestore): Use the new ...TypeToString function here, too. --- src/qemu_driver.c | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/src/qemu_driver.c b/src/qemu_driver.c index d778a89f14..5217530424 100644 --- a/src/qemu_driver.c +++ b/src/qemu_driver.c @@ -4382,21 +4382,17 @@ static int qemudDomainRestore(virConnectPtr conn, if (header.version == 2) { const char *intermediate_argv[3] = { NULL, "-dc", NULL }; - if (header.compressed == QEMUD_SAVE_FORMAT_GZIP) - intermediate_argv[0] = "gzip"; - else if (header.compressed == QEMUD_SAVE_FORMAT_BZIP2) - intermediate_argv[0] = "bzip2"; - else if (header.compressed == QEMUD_SAVE_FORMAT_XZ) - intermediate_argv[0] = "xz"; - else if (header.compressed == QEMUD_SAVE_FORMAT_LZOP) - intermediate_argv[0] = "lzop"; - else if (header.compressed != QEMUD_SAVE_FORMAT_RAW) { + const char *prog = qemudSaveCompressionTypeToString(header.compressed); + if (prog == NULL) { qemudReportError(conn, NULL, NULL, VIR_ERR_OPERATION_FAILED, - _("Unknown compressed save format %d"), + _("Invalid compressed save format %d"), header.compressed); goto cleanup; } - if (intermediate_argv[0] != NULL) { + + if (header.compressed != QEMUD_SAVE_FORMAT_RAW) + intermediate_argv[0] = prog; + else { intermediatefd = fd; fd = -1; if (virExec(conn, intermediate_argv, NULL, NULL,