qemu-img: Create SCSI VMDK disks
PATCH 1/1 qemu-img: Create SCSI VMDK disks
This patch introduces a new option to qemu-img: -s indicates for VMDK images that the image is meant to be used as SCSI disk. Depending on the switch "ide" or "buslogic" is written to the image as adapter type.
block-vmdk.c +4 -2
@@ -719,7 +719,7 @@ static int vmdk_create(const char *filen"ddb.geometry.cylinders = \"%lu\"\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;
@@ -792,7 +792,9 @@ static int vmdk_create(const char *filenif ((temp_str =strrchr (real_filename,':' )) !=NULL ) real_filename = temp_str +1 ;sprintf (desc, desc_template,time (NULL ), (unsigned long )total_size, - real_filename, (flags &BLOCK_FLAG_COMPAT6 ?6 :4 ), total_size / (63 *16 )); + real_filename, (flags &BLOCK_FLAG_COMPAT6 ?6 :4 ), + total_size / (63 *16 ), + flags &BLOCK_FLAG_SCSI ?"buslogic" :"ide" );/* write the descriptor */ lseek (fd,le64_to_cpu (header.desc_offset) <<9 ,SEEK_SET );
qemu-img.c +15 -4
@@ -53,9 +53,9 @@ static void help(void)"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] filename [filename2 [...]] output_filename\n" +" convert [-c] [-e] [-s] [-6] [-f fmt] [-O output_fmt] filename [filename2 [...]] output_filename\n" " info [-f fmt] filename\n" "\n" "Command parameters:\n"
@@ -69,6 +69,7 @@ static void help(void)" '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:" );
@@ -207,7 +208,7 @@ static int img_create(int argc, char **a flags =0 ;for (;;) { - c =getopt (argc, argv,"b:f:he6" ); + c =getopt (argc, argv,"b:f:hes6" );if (c ==-1 )break ;switch (c) {
@@ -223,6 +224,9 @@ static int img_create(int argc, char **acase 'e' : flags |=BLOCK_FLAG_ENCRYPT ;break ; +case 's' : + flags |=BLOCK_FLAG_SCSI ; +break ;case '6' : flags |=BLOCK_FLAG_COMPAT6 ;break ;
@@ -258,6 +262,8 @@ static int img_create(int argc, char **aerror ("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 )
@@ -386,7 +392,7 @@ static int img_convert(int argc, char ** out_fmt ="raw" ; flags =0 ;for (;;) { - c =getopt (argc, argv,"f:O:hce6" ); + c =getopt (argc, argv,"f:O:hces6" );if (c ==-1 )break ;switch (c) {
@@ -405,6 +411,9 @@ static int img_convert(int argc, char **case 'e' : flags |=BLOCK_FLAG_ENCRYPT ;break ; +case 's' : + flags |=BLOCK_FLAG_SCSI ; +break ;case '6' : flags |=BLOCK_FLAG_COMPAT6 ;break ;
@@ -436,6 +445,8 @@ static int img_convert(int argc, char **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 )
block_int.h +1 -0
@@ -29,6 +29,7 @@#define BLOCK_FLAG_ENCRYPT 1#define BLOCK_FLAG_COMPRESS 2#define BLOCK_FLAG_COMPAT6 4 +#define BLOCK_FLAG_SCSI 8struct BlockDriver {const char *format_name;
Quoted 3 lines
This patch introduces a new option to qemu-img: -s indicates for VMDK images that the image is meant to be used as SCSI disk. Depending on the switch "ide" or "buslogic" is written to the image as adapter type.
Any particular reason you chose "buslogic" over "lsilogic"? What about adding "-a" (adapter) option like in vmware-vdiskmanager?
- Sebastian
Quoted 6 lines · Sebastian Herbszt
Quoted 3 lines
This patch introduces a new option to qemu-img: -s indicates for VMDK images that the image is meant to be used as SCSI disk. Depending on the switch "ide" or "buslogic" is written to the image as adapter type.
Any particular reason you chose "buslogic" over "lsilogic"? What about adding "-a" (adapter) option like in vmware-vdiskmanager?
Not really. It's just what was needed internally (read: what I was asked to implement in a free minute). I certainly wouldn't oppose if anyone wanted to extend it to be more generic.
Kevin