]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
add compression support for "virsh dump"
authorKAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>
Thu, 28 Oct 2010 07:31:46 +0000 (16:31 +0900)
committerEric Blake <eblake@redhat.com>
Fri, 29 Oct 2010 16:04:34 +0000 (10:04 -0600)
Add dump_image_format[] to qemu.conf and support compressed dump
at virsh dump. coredump compression is important for saving disk space
in an environment where multiple guests run.

In general, "disk space for dump" is specially allocated and will be
a dead space in the system. It's used only at emergency. So, it's better
to have both of save_image_format and dump_image_format. "save" is done
in scheduled manner with enough calculated disk space for it.

This code reuses some of save_image_format[] and supports the same format.

Changelog:
 - modified libvirtd_qemu.aug
 - modified test_libvirtd_qemu.aug
 - fixed error handling of qemudSaveCompressionTypeFromString()

src/qemu/libvirtd_qemu.aug
src/qemu/qemu.conf
src/qemu/qemu_conf.c
src/qemu/qemu_conf.h
src/qemu/qemu_driver.c
src/qemu/test_libvirtd_qemu.aug

index b9ace3ed0c31f95e01fbe34f1a26550bb7ae2cca..78852f36316994ff517d98fe69a0876e5feb445d 100644 (file)
@@ -36,6 +36,7 @@ module Libvirtd_qemu =
                  | str_array_entry "cgroup_controllers"
                  | str_array_entry "cgroup_device_acl"
                  | str_entry "save_image_format"
+                 | str_entry "dump_image_format"
                  | str_entry "hugetlbfs_mount"
                  | bool_entry "relaxed_acs_check"
                  | bool_entry "vnc_allow_host_audio"
index 53b76e718b80a6c5dab762b08e19bbc984d44233..e2c581e662a50827e6c0d630a381ffdbe6a2e822 100644 (file)
 # saving a domain in order to save disk space; the list above is in descending
 # order by performance and ascending order by compression ratio.
 #
+# save_image_format is used when you use 'virsh save' at scheduled saving.
+# dump_image_format is used when you use 'virsh dump' at emergency crashdump.
+#
 # save_image_format = "raw"
+# dump_image_format = "raw"
 
 
 # If provided by the host and a hugetlbfs mount point is configured,
index 5bd3d4c7b7ca9b999e1a68d2b5917b0ae242c398..b5c17b5a2221b693f843f571a70739533928c3f2 100644 (file)
@@ -325,6 +325,17 @@ int qemudLoadDriverConfig(struct qemud_driver *driver,
         }
     }
 
+    p = virConfGetValue (conf, "dump_image_format");
+    CHECK_TYPE ("dump_image_format", VIR_CONF_STRING);
+    if (p && p->str) {
+        VIR_FREE(driver->dumpImageFormat);
+        if (!(driver->dumpImageFormat = strdup(p->str))) {
+            virReportOOMError();
+            virConfFree(conf);
+            return -1;
+        }
+    }
+
      p = virConfGetValue (conf, "hugetlbfs_mount");
      CHECK_TYPE ("hugetlbfs_mount", VIR_CONF_STRING);
      if (p && p->str) {
index 530dcdbbda66ee21ac78e9bd67ec4cda5e1daa8e..bbe68871c4166fb581606d8f319c4bd6810a488c 100644 (file)
@@ -164,6 +164,7 @@ struct qemud_driver {
     virSecurityDriverPtr securitySecondaryDriver;
 
     char *saveImageFormat;
+    char *dumpImageFormat;
 
     pciDeviceList *activePciHostdevs;
 
index 554bf8628149a676ec957f9fb3191a1c4e33e822..8aa593175e40ba40188e6120a02502a5dadbda50 100644 (file)
@@ -5909,11 +5909,22 @@ static int qemudDomainCoreDump(virDomainPtr dom,
     int resume = 0, paused = 0;
     int ret = -1, fd = -1;
     virDomainEventPtr event = NULL;
-    const char *args[] = {
-        "cat",
-        NULL,
-    };
+    int compress;
     qemuDomainObjPrivatePtr priv;
+    /*
+     * We reuse "save" flag for "dump" here. Then, we can support the same
+     * format in "save" and "dump".
+     */
+    compress = QEMUD_SAVE_FORMAT_RAW;
+    if (driver->dumpImageFormat) {
+        compress = qemudSaveCompressionTypeFromString(driver->dumpImageFormat);
+        if (compress < 0) {
+           qemuReportError(VIR_ERR_OPERATION_FAILED, "%s",
+                           _("Invalid dump image format specified in "
+                             "configuration file"));
+           return -1;
+        }
+    }
 
     qemuDriverLock(driver);
     vm = virDomainFindByUUID(&driver->domains, dom->uuid);
@@ -5980,9 +5991,25 @@ static int qemudDomainCoreDump(virDomainPtr dom,
     }
 
     qemuDomainObjEnterMonitorWithDriver(driver, vm);
-    ret = qemuMonitorMigrateToFile(priv->mon,
-                                   QEMU_MONITOR_MIGRATE_BACKGROUND,
-                                   args, path, 0);
+    if (compress == QEMUD_SAVE_FORMAT_RAW) {
+        const char *args[] = {
+            "cat",
+            NULL,
+        };
+        ret = qemuMonitorMigrateToFile(priv->mon,
+                                       QEMU_MONITOR_MIGRATE_BACKGROUND,
+                                       args, path, 0);
+    } else {
+        const char *prog = qemudSaveCompressionTypeToString(compress);
+        const char *args[] = {
+            prog,
+            "-c",
+            NULL,
+        };
+        ret = qemuMonitorMigrateToFile(priv->mon,
+                                       QEMU_MONITOR_MIGRATE_BACKGROUND,
+                                       args, path, 0);
+    }
     qemuDomainObjExitMonitorWithDriver(driver, vm);
     if (ret < 0)
         goto endjob;
index 67883460e2f49f984442e0d197446fece3c6b9e5..d3ae58d4d233a5167ecaa0e9d85ad19d3238a601 100644 (file)
@@ -94,6 +94,8 @@ cgroup_device_acl = [ \"/dev/null\", \"/dev/full\", \"/dev/zero\" ]
 
 save_image_format = \"gzip\"
 
+dump_image_format = \"gzip\"
+
 hugetlbfs_mount = \"/dev/hugepages\"
 
 set_process_name = 1
@@ -209,6 +211,8 @@ allow_disk_format_probing = 1
 { "#empty" }
 { "save_image_format" = "gzip" }
 { "#empty" }
+{ "dump_image_format" = "gzip" }
+{ "#empty" }
 { "hugetlbfs_mount" = "/dev/hugepages" }
 { "#empty" }
 { "set_process_name" = "1" }