vpc: use current_size field for XenServer VHD images
PATCH 1/1 vpc: use current_size field for XenServer VHD images
The vpc driver has two methods of determining virtual disk size. The correct one to use depends on the software that generated the image file. Add the XenServer creator_app signature so that image size is correctly detected for those images.
--- block/vpc.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
block/vpc.c +3 -1
@@ -298,6 +298,7 @@ static int vpc_open(BlockDriverState *bs, QDict *options, int flags,* 'qem2' : current_size QEMU (uses current_size) * 'win ' : current_size Hyper-V * 'd2v ' : current_size Disk2vhd +* 'tap\0' : current_size XenServer * * The user can override the table values via drive options, however * even with an override we will still use current_size for images
@@ -305,7 +306,8 @@ static int vpc_open(BlockDriverState *bs, QDict *options, int flags,*/ use_chs = (!!strncmp (footer->creator_app,"win " ,4 ) && !!strncmp (footer->creator_app,"qem2" ,4 ) && - !!strncmp (footer->creator_app,"d2v " ,4 )) || s->force_use_chs; + !!strncmp (footer->creator_app,"d2v " ,4 ) && + !!memcmp (footer->creator_app,"tap" ,4 )) || s->force_use_chs;if (!use_chs || bs->total_sectors ==VHD_MAX_GEOMETRY || s->force_use_sz) { bs->total_sectors = be64_to_cpu(footer->current_size) /
Signature · 1 line
2.5.0
Side note: After manually patching tap\0 to qem2, Spencer and I were still unable to get qemu-img info working with the image. Unsure if this is related to the patch or not.
Thanks,
Grant Wu
[email protected]
Quoted 43 lines · Stefan Hajnoczi
The vpc driver has two methods of determining virtual disk size. The correct one to use depends on the software that generated the image file. Add the XenServer
creator_appsignature so that image size is correctly detected for those images.Reported-by Grant Wu <[email protected]>Reported-by Spencer Baugh <[email protected]>Signed-off-by Stefan Hajnoczi <[email protected]>--- block/vpc.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)block/vpc.c +1
-0@@ -298,6 +298,7 @@ static int vpc_open(BlockDriverState *bs, QDict *options, int flags, * 'qem2' : current_size QEMU (uses current_size) * 'win ' : current_size Hyper-V * 'd2v ' : current_size Disk2vhd + * 'tap\0' : current_size XenServer * * The user can override the table values via drive options, however* even with an override we will still use
current_sizefor imagesblock/vpc.c +2
-1@@ -305,7 +306,8 @@ static int vpc_open(BlockDriverState *bs, QDict*options, int flags, */ use_chs = (!!strncmp (footer->creator_app,"win " ,4 ) && !!strncmp (footer->creator_app,"qem2" ,4 ) && - !!strncmp (footer->creator_app,"d2v " ,4 )) || s->force_use_chs; + !!strncmp (footer->creator_app,"d2v " ,4 ) && + !!memcmp(footer->creator_app, "tap", 4)) || s->force_use_chs;if (!use_chs || bs->total_sectors == VHD_MAX_GEOMETRY || s->force_use_sz) { bs->total_sectors = be64_to_cpu(footer->current_size) /--
2.5.0
Quoted 3 lines · Grant Wu
Side note: After manually patching tap\0 to qem2, Spencer and I were still unable to get qemu-img info working with the image. Unsure if this is related to the patch or not.
What output did you get from "qemu-img info /dev/dm-1"?
Did qemu-nbd work?
Stefan
Quoted 1 line · Stefan Hajnoczi
What output did you get from "qemu-img info
/dev/dm-1"?
After the patching:
root@storage-4:~# hexdump -C -n 512 /dev/vgstorage/tartanfsbackup 00000000 63 6f 6e 65 63 74 69 78 00 00 00 02 00 01 00 00 |conectix........| 00000010 00 00 00 00 00 00 02 00 14 10 4b 1f 71 65 6d 32 |..........K.qem2| 00000020 00 01 00 03 00 00 00 00 00 00 01 c4 4f 40 00 00 |............O@..| 00000030 00 00 01 f4 00 00 00 00 ff ff 10 ff 00 00 00 03 |................| 00000040 ff ff ed 81 6d 0d 68 bd 9c fd 4d 65 a3 17 c7 6c |....m.h...Me...l| 00000050 06 a6 aa bf 00 00 00 00 00 00 00 00 00 00 00 00 |................| 00000060 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................| * 00000200 root@storage-4:~# qemu-img info /dev/vgstorage/tartanfsbackup block-vpc: The header checksum of '/dev/vgstorage/tartanfsbackup' is incorrect. qemu-img: Could not open '/dev/vgstorage/tartanfsbackup': Could not open '/dev/vgstorage/tartanfsbackup': Invalid argument
Quoted 1 line
Did qemu-nbd work?
root@storage-4:~# qemu-nbd -c /dev/nbd1 /dev/vgstorage/tartanfsbackup block-vpc: The header checksum of '/dev/vgstorage/tartanfsbackup' is incorrect. qemu-nbd: Failed to blk_new_open '/dev/vgstorage/tartanfsbackup': Could not open '/dev/vgstorage/tartanfsbackup': Invalid argument
Quoted 5 lines · Spencer Baugh
Quoted 1 line · Stefan Hajnoczi
What output did you get from "qemu-img info
/dev/dm-1"?After the patching:
Quoted 12 lines
root@storage-4:~# hexdump -C -n 512 /dev/vgstorage/tartanfsbackup 00000000 63 6f 6e 65 63 74 69 78 00 00 00 02 00 01 00 00 |conectix........| 00000010 00 00 00 00 00 00 02 00 14 10 4b 1f 71 65 6d 32 |..........K.qem2| 00000020 00 01 00 03 00 00 00 00 00 00 01 c4 4f 40 00 00 |............O@..| 00000030 00 00 01 f4 00 00 00 00 ff ff 10 ff 00 00 00 03 |................| 00000040 ff ff ed 81 6d 0d 68 bd 9c fd 4d 65 a3 17 c7 6c |....m.h...Me...l| 00000050 06 a6 aa bf 00 00 00 00 00 00 00 00 00 00 00 00 |................| 00000060 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................| * 00000200 root@storage-4:~# qemu-img info /dev/vgstorage/tartanfsbackup block-vpc: The header checksum of '/dev/vgstorage/tartanfsbackup' is incorrect.
This is a warning message that does not cause opening the file to fail. It makes sense since the header was modified without setting the new checksum value.
Quoted 1 line
qemu-img: Could not open '
/dev/vgstorage/tartanfsbackup': Could not open '/dev/vgstorage/tartanfsbackup': Invalid argument
Please also post the output of "hexdump -C -n 512 -s 512 /dev/vgstorage/tartanfsbackup". This is another header structure and it gets parsed while opening the file.
Thanks,
Stefan
root@storage-4:~# hexdump -C -n 512 -s 512 /dev/vgstorage/tartanfsbackup 00000200 63 78 73 70 61 72 73 65 ff ff ff ff ff ff ff ff |cxsparse........| 00000210 00 00 00 00 00 00 06 00 00 01 00 00 00 10 00 00 |................| 00000220 00 20 00 00 ff ff f4 67 00 00 00 00 00 00 00 00 |. .....g........| 00000230 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................| * 00000400
Thanks,
Grant Wu
[email protected]
Quoted 17 lines · Stefan Hajnoczi
The vpc driver has two methods of determining virtual disk size. The correct one to use depends on the software that generated the image file. Add the XenServer
creator_appsignature so that image size is correctly detected for those images.Reported-by Grant Wu <[email protected]>Reported-by Spencer Baugh <[email protected]>Signed-off-by Stefan Hajnoczi <[email protected]>--- block/vpc.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)block/vpc.c +0
-0
block/vpc.c static int vpc_open(BlockDriverState *bs, QDict *options, int flags, · line 301
Quoted 4 lines
block/vpc.c +1
-0@@ -298,6 +298,7 @@ static int vpc_open(BlockDriverState *bs, QDict *options, int flags,* 'qem2' : current_size QEMU (uses current_size) * 'win ' : current_size Hyper-V * 'd2v ' : current_size Disk2vhd +* 'tap\0' : current_size XenServer
I just tried out XenConverter, and it set the creator_app field to "CTXS". We should probably add a check for that, too.
Quoted 17 lines
block/vpc.c +2
-1* * The user can override the table values via drive options, however * even with an override we will still use current_size for images @@ -305,7 +306,8 @@ static int vpc_open(BlockDriverState *bs, QDict *options, int flags,*/ use_chs = (!!strncmp (footer->creator_app,"win " ,4 ) && !!strncmp (footer->creator_app,"qem2" ,4 ) && - !!strncmp (footer->creator_app,"d2v " ,4 )) || s->force_use_chs; + !!strncmp (footer->creator_app,"d2v " ,4 ) && + !!memcmp (footer->creator_app,"tap" ,4 )) || s->force_use_chs;if (!use_chs || bs->total_sectors ==VHD_MAX_GEOMETRY || s->force_use_sz) { bs->total_sectors = be64_to_cpu(footer->current_size) /Signature · 1 line
2.5.0