From: John Ferlan Date: Mon, 12 May 2014 14:21:09 +0000 (-0400) Subject: qemu: Adjust size for qcow2/qed if not on sector boundary X-Git-Tag: v1.2.5-rc1~74 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=87388d688d2dffd904f653b6860cf3df1633f6b0;p=thirdparty%2Flibvirt.git qemu: Adjust size for qcow2/qed if not on sector boundary https://bugzilla.redhat.com/show_bug.cgi?id=1002813 If qemuDomainBlockResize() is passed a size not on a KiB boundary - that is passed a size based in bytes (VIR_DOMAIN_BLOCK_RESIZE_BYTES), then depending on the source format (qcow2 or qed), the value passed must be on a sector (or 512 byte) boundary. Since other libvirt code quietly adjusts the capacity values, then do so here as well. --- diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index 1fadabc08c..a5c7f4fb75 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -9459,6 +9459,13 @@ qemuDomainBlockResize(virDomainPtr dom, } disk = vm->def->disks[idx]; + /* qcow2 and qed must be sized on 512 byte blocks/sectors, + * so adjust size if necessary to round up. + */ + if (disk->src.format == VIR_STORAGE_FILE_QCOW2 || + disk->src.format == VIR_STORAGE_FILE_QED) + size = VIR_ROUND_UP(size, 512); + if (virAsprintf(&device, "%s%s", QEMU_DRIVE_HOST_PREFIX, disk->info.alias) < 0) goto endjob;