[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH 12/56] vmdk: remove wrong calculation of relative pa
From: |
Michael Roth |
Subject: |
[Qemu-devel] [PATCH 12/56] vmdk: remove wrong calculation of relative path |
Date: |
Tue, 13 Aug 2013 10:10:36 -0500 |
From: Fam Zheng <address@hidden>
When creating image with backing file, the driver tries to calculate the
relative path from created image file to backing file, but the path
computation is incorrect. e.g.:
$ qemu-img create -f vmdk -b vmdk-data-disk.vmdk vmdk-data-snapshot1
Formatting 'vmdk-data-snapshot1', fmt=vmdk size=10737418240
backing_file='vmdk-data-disk.vmdk' compat6=off zeroed_grain=off
$ qemu-img info vmdk-data-snapshot1
image: vmdk-data-snapshot1
file format: vmdk
virtual size: 10G (10737418240 bytes)
disk size: 12K
-> backing file: disk.vmdk
The common part in file names, "vmdk-data-", is incorrectly forgotten by
relative_path(). As the VMDK specification has no restriction on
parentNameHint to be relative path, we simply remove this by using the
backing_file option.
Cc: address@hidden
Signed-off-by: Fam Zheng <address@hidden>
Signed-off-by: Kevin Wolf <address@hidden>
(cherry picked from commit 8ed610a1c983dd2ed1eed8841036af55751d115f)
Signed-off-by: Michael Roth <address@hidden>
---
block/vmdk.c | 44 +-------------------------------------------
1 file changed, 1 insertion(+), 43 deletions(-)
diff --git a/block/vmdk.c b/block/vmdk.c
index ee50a73..8c8f1fd 100644
--- a/block/vmdk.c
+++ b/block/vmdk.c
@@ -1465,45 +1465,6 @@ static int filename_decompose(const char *filename, char
*path, char *prefix,
return VMDK_OK;
}
-static int relative_path(char *dest, int dest_size,
- const char *base, const char *target)
-{
- int i = 0;
- int n = 0;
- const char *p, *q;
-#ifdef _WIN32
- const char *sep = "\\";
-#else
- const char *sep = "/";
-#endif
-
- if (!(dest && base && target)) {
- return VMDK_ERROR;
- }
- if (path_is_absolute(target)) {
- pstrcpy(dest, dest_size, target);
- return VMDK_OK;
- }
- while (base[i] == target[i]) {
- i++;
- }
- p = &base[i];
- q = &target[i];
- while (*p) {
- if (*p == *sep) {
- n++;
- }
- p++;
- }
- dest[0] = '\0';
- for (; n; n--) {
- pstrcat(dest, dest_size, "..");
- pstrcat(dest, dest_size, sep);
- }
- pstrcat(dest, dest_size, q);
- return VMDK_OK;
-}
-
static int vmdk_create(const char *filename, QEMUOptionParameter *options)
{
int fd, idx = 0;
@@ -1603,7 +1564,6 @@ static int vmdk_create(const char *filename,
QEMUOptionParameter *options)
return -ENOTSUP;
}
if (backing_file) {
- char parent_filename[PATH_MAX];
BlockDriverState *bs = bdrv_new("");
ret = bdrv_open(bs, backing_file, NULL, 0, NULL);
if (ret != 0) {
@@ -1616,10 +1576,8 @@ static int vmdk_create(const char *filename,
QEMUOptionParameter *options)
}
parent_cid = vmdk_read_cid(bs, 0);
bdrv_delete(bs);
- relative_path(parent_filename, sizeof(parent_filename),
- filename, backing_file);
snprintf(parent_desc_line, sizeof(parent_desc_line),
- "parentFileNameHint=\"%s\"", parent_filename);
+ "parentFileNameHint=\"%s\"", backing_file);
}
/* Create extents */
--
1.7.9.5
- [Qemu-devel] [PATCH 01/56] s390/virtio-ccw: Fix virtio reset, (continued)
- [Qemu-devel] [PATCH 01/56] s390/virtio-ccw: Fix virtio reset, Michael Roth, 2013/08/13
- [Qemu-devel] [PATCH 04/56] qxl: Fix QXLRam initialisation., Michael Roth, 2013/08/13
- [Qemu-devel] [PATCH 05/56] virtio-scsi: forward scsibus for virtio-scsi-pci., Michael Roth, 2013/08/13
- [Qemu-devel] [PATCH 06/56] acl: acl_add can't insert before last list element, fix, Michael Roth, 2013/08/13
- [Qemu-devel] [PATCH 07/56] usb-host-libusb: set USB_DEV_FLAG_IS_HOST, Michael Roth, 2013/08/13
- [Qemu-devel] [PATCH 08/56] s390/ipl: Fix boot order, Michael Roth, 2013/08/13
- [Qemu-devel] [PATCH 09/56] Fix iSCSI crash on SG_IO with an iovector, Michael Roth, 2013/08/13
- [Qemu-devel] [PATCH 10/56] block/ssh: Set bdrv_has_zero_init according to the file type., Michael Roth, 2013/08/13
- [Qemu-devel] [PATCH 13/56] Revert "migration: do not sent zero pages in bulk stage", Michael Roth, 2013/08/13
- [Qemu-devel] [PATCH 11/56] gluster: Return bdrv_has_zero_init = 0, Michael Roth, 2013/08/13
- [Qemu-devel] [PATCH 12/56] vmdk: remove wrong calculation of relative path,
Michael Roth <=
- [Qemu-devel] [PATCH 14/56] migration: do not overwrite zero pages, Michael Roth, 2013/08/13
- [Qemu-devel] [PATCH 15/56] raw-posix: Fix /dev/cdrom magic on OS X, Michael Roth, 2013/08/13
- [Qemu-devel] [PATCH 16/56] kvmclock: clock should count only if vm is running, Michael Roth, 2013/08/13
- [Qemu-devel] [PATCH 17/56] qemu-char: Fix ID reuse after chardev-remove for qapi-based init, Michael Roth, 2013/08/13
- [Qemu-devel] [PATCH 19/56] target-lm32: gen_intermediate_code_internal() should be inlined, Michael Roth, 2013/08/13
- [Qemu-devel] [PATCH 20/56] target-microblaze: gen_intermediate_code_internal() should be inlined, Michael Roth, 2013/08/13
- [Qemu-devel] [PATCH 18/56] target-cris: gen_intermediate_code_internal() should be inlined, Michael Roth, 2013/08/13
- [Qemu-devel] [PATCH 21/56] target-moxie: gen_intermediate_code_internal() should be inlined, Michael Roth, 2013/08/13
- [Qemu-devel] [PATCH 22/56] target-xtensa: gen_intermediate_code_internal() should be inlined, Michael Roth, 2013/08/13
- [Qemu-devel] [PATCH 23/56] block: fix bdrv_flush() ordering in bdrv_close(), Michael Roth, 2013/08/13