]> xenbits.xensource.com Git - libvirt.git/commitdiff
qemu: Remove unnecessary calculations in qemuDomainSaveMemory
authorPeter Krempa <pkrempa@redhat.com>
Wed, 17 Feb 2016 12:10:11 +0000 (13:10 +0100)
committerPeter Krempa <pkrempa@redhat.com>
Wed, 17 Feb 2016 14:54:44 +0000 (15:54 +0100)
Now that the file migration doesn't require us to use 'dd' and other
legacy stuff for too old qemus we don't even have to calcuate the
offsets and other stuff.

src/qemu/qemu_driver.c
src/qemu/qemu_monitor.h

index a7ab6deda69cff8b09d55dff0010933eb2a198ce..a76252181485c7400036c54e35f06eaf92d22d09 100644 (file)
@@ -3129,38 +3129,13 @@ qemuDomainSaveMemory(virQEMUDriverPtr driver,
     int directFlag = 0;
     virFileWrapperFdPtr wrapperFd = NULL;
     unsigned int wrapperFlags = VIR_FILE_WRAPPER_NON_BLOCKING;
-    unsigned long long pad;
-    unsigned long long offset;
-    size_t len;
-    char *xml = NULL;
 
     memset(&header, 0, sizeof(header));
     memcpy(header.magic, QEMU_SAVE_PARTIAL, sizeof(header.magic));
     header.version = QEMU_SAVE_VERSION;
     header.was_running = was_running ? 1 : 0;
-
     header.compressed = compressed;
-
-    len = strlen(domXML) + 1;
-    offset = sizeof(header) + len;
-
-    /* Due to way we append QEMU state on our header with dd,
-     * we need to ensure there's a 512 byte boundary. Unfortunately
-     * we don't have an explicit offset in the header, so we fake
-     * it by padding the XML string with NUL bytes.  Additionally,
-     * we want to ensure that virDomainSaveImageDefineXML can supply
-     * slightly larger XML, so we add a minimum padding prior to
-     * rounding out to page boundaries.
-     */
-    pad = 1024;
-    pad += (QEMU_MONITOR_MIGRATE_TO_FILE_BS -
-            ((offset + pad) % QEMU_MONITOR_MIGRATE_TO_FILE_BS));
-    if (VIR_ALLOC_N(xml, len + pad) < 0)
-        goto cleanup;
-    strcpy(xml, domXML);
-
-    offset += pad;
-    header.xml_len = len;
+    header.xml_len = strlen(domXML) + 1;
 
     /* Obtain the file handle.  */
     if ((flags & VIR_DOMAIN_SAVE_BYPASS_CACHE)) {
@@ -3185,7 +3160,7 @@ qemuDomainSaveMemory(virQEMUDriverPtr driver,
         goto cleanup;
 
     /* Write header to file, followed by XML */
-    if (qemuDomainSaveHeader(fd, path, xml, &header) < 0)
+    if (qemuDomainSaveHeader(fd, path, domXML, &header) < 0)
         goto cleanup;
 
     /* Perform the migration */
@@ -3227,7 +3202,6 @@ qemuDomainSaveMemory(virQEMUDriverPtr driver,
  cleanup:
     VIR_FORCE_CLOSE(fd);
     virFileWrapperFdFree(wrapperFd);
-    VIR_FREE(xml);
 
     if (ret < 0 && needUnlink)
         unlink(path);
index d731344211689cd0a9651090683b99c9cbb3819a..134cbb67bcba264f99dbc6f798869073c555f72a 100644 (file)
@@ -560,16 +560,6 @@ int qemuMonitorMigrateToCommand(qemuMonitorPtr mon,
                                 unsigned int flags,
                                 const char * const *argv);
 
-/* In general, BS is the smallest fundamental block size we can use to
- * access a block device; everything must be aligned to a multiple of
- * this.  Linux generally supports a BS as small as 512, but with
- * newer disks with 4k sectors, performance is better if we guarantee
- * alignment to the sector size.  However, operating on BS-sized
- * blocks is painfully slow, so we also have a transfer size that is
- * larger but only aligned to the smaller block size.
- */
-# define QEMU_MONITOR_MIGRATE_TO_FILE_BS (1024llu * 4)
-
 int qemuMonitorMigrateToUnix(qemuMonitorPtr mon,
                              unsigned int flags,
                              const char *unixfile);