SHA256
1
0
forked from pool/qemu
qemu/qemu-img-vmdk-scsi.patch

112 lines
4.1 KiB
Diff

Index: qemu-0.9.1/block-vmdk.c
================================================================================
--- qemu/block-vmdk.c
+++ qemu/block-vmdk.c
@@ -719,7 +719,7 @@
"ddb.geometry.cylinders = \"%" PRId64 "\"\n"
"ddb.geometry.heads = \"16\"\n"
"ddb.geometry.sectors = \"63\"\n"
- "ddb.adapterType = \"ide\"\n";
+ "ddb.adapterType = \"%s\"\n";
char desc[1024];
const char *real_filename, *temp_str;
@@ -794,7 +794,8 @@
snprintf(desc, sizeof(desc), desc_template, (unsigned int)time(NULL),
total_size, real_filename,
(flags & BLOCK_FLAG_COMPAT6 ? 6 : 4),
- total_size / (int64_t)(63 * 16));
+ total_size / (int64_t)(63 * 16),
+ flags & BLOCK_FLAG_SCSI ? "lsilogic" : "ide");
/* write the descriptor */
lseek(fd, le64_to_cpu(header.desc_offset) << 9, SEEK_SET);
--- qemu/block_int.h
+++ qemu/block_int.h
@@ -29,6 +29,7 @@
#define BLOCK_FLAG_ENCRYPT 1
#define BLOCK_FLAG_COMPRESS 2
#define BLOCK_FLAG_COMPAT6 4
+#define BLOCK_FLAG_SCSI 8
struct BlockDriver {
const char *format_name;
--- qemu/qemu-img.c
+++ qemu/qemu-img.c
@@ -53,9 +53,9 @@
"QEMU disk image utility\n"
"\n"
"Command syntax:\n"
- " create [-e] [-6] [-b base_image] [-f fmt] filename [size]\n"
+ " create [-e] [-s] [-6] [-b base_image] [-f fmt] filename [size]\n"
" commit [-f fmt] filename\n"
- " convert [-c] [-e] [-6] [-f fmt] [-O output_fmt] [-B output_base_image] filename [filename2 [...]] output_filename\n"
+ " convert [-c] [-e] [-s] [-6] [-f fmt] [-O output_fmt] [-B output_base_image] filename [filename2 [...]] output_filename\n"
" info [-f fmt] filename\n"
"\n"
"Command parameters:\n"
@@ -73,6 +73,7 @@
" 'output_fmt' is the destination format\n"
" '-c' indicates that target image must be compressed (qcow format only)\n"
" '-e' indicates that the target image must be encrypted (qcow format only)\n"
+ " '-s' indicates that the target image is meant for SCSI (vmdk format only)\n"
" '-6' indicates that the target image must use compatibility level 6 (vmdk format only)\n"
);
printf("\nSupported format:");
@@ -211,7 +212,7 @@
flags = 0;
for(;;) {
- c = getopt(argc, argv, "b:f:he6");
+ c = getopt(argc, argv, "b:f:hes6");
if (c == -1)
break;
switch(c) {
@@ -227,6 +228,9 @@
case 'e':
flags |= BLOCK_FLAG_ENCRYPT;
break;
+ case 's':
+ flags |= BLOCK_FLAG_SCSI;
+ break;
case '6':
flags |= BLOCK_FLAG_COMPAT6;
break;
@@ -262,6 +266,8 @@
error("Unknown file format '%s'", fmt);
printf("Formatting '%s', fmt=%s",
filename, fmt);
+ if (flags & BLOCK_FLAG_SCSI)
+ printf(", SCSI");
if (flags & BLOCK_FLAG_ENCRYPT)
printf(", encrypted");
if (flags & BLOCK_FLAG_COMPAT6)
@@ -398,7 +404,7 @@
out_baseimg = NULL;
flags = 0;
for(;;) {
- c = getopt(argc, argv, "f:O:B:hce6");
+ c = getopt(argc, argv, "f:O:B:hces6");
if (c == -1)
break;
switch(c) {
@@ -420,6 +426,9 @@
case 'e':
flags |= BLOCK_FLAG_ENCRYPT;
break;
+ case 's':
+ flags |= BLOCK_FLAG_SCSI;
+ break;
case '6':
flags |= BLOCK_FLAG_COMPAT6;
break;
@@ -454,6 +463,8 @@
error("Compression not supported for this file format");
if (flags & BLOCK_FLAG_ENCRYPT && drv != &bdrv_qcow && drv != &bdrv_qcow2)
error("Encryption not supported for this file format");
+ if (flags & BLOCK_FLAG_SCSI && drv != &bdrv_vmdk)
+ error("SCSI devices not supported for this file format");
if (flags & BLOCK_FLAG_COMPAT6 && drv != &bdrv_vmdk)
error("Alternative compatibility level not supported for this file format");
if (flags & BLOCK_FLAG_ENCRYPT && flags & BLOCK_FLAG_COMPRESS)