From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1M7S0s-0004pv-CZ for qemu-devel@nongnu.org; Fri, 22 May 2009 06:30:06 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1M7S0m-0004mx-BL for qemu-devel@nongnu.org; Fri, 22 May 2009 06:30:04 -0400 Received: from [199.232.76.173] (port=51493 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1M7S0m-0004mk-4D for qemu-devel@nongnu.org; Fri, 22 May 2009 06:30:00 -0400 Received: from an-out-0708.google.com ([209.85.132.242]:55877) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1M7S0l-00027L-25 for qemu-devel@nongnu.org; Fri, 22 May 2009 06:29:59 -0400 Received: by an-out-0708.google.com with SMTP id d11so946215and.37 for ; Fri, 22 May 2009 03:29:57 -0700 (PDT) MIME-Version: 1.0 Date: Fri, 22 May 2009 20:29:57 +1000 Message-ID: From: Aaron Mason Content-Type: multipart/alternative; boundary=0016e644ddeaf5851c046a7dbd07 Subject: [Qemu-devel] Patch: Adding ability for qemu-img to create SCSI VMware disk images List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org --0016e644ddeaf5851c046a7dbd07 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Hi, I needed to create a heap of virtual hard drives to practice creating RAID arrays. Since qemu-img only creates IDE images, creating a large number of images for this was a very cumbersome excercise. I compared a SCSI image to an IDE image, and the only difference is the adapter type. This patch adds command line parameters to qemu-img to specify either a BusLogic or LSI Logic image for 'create' and 'convert', and extends the 'info' command to show the adapter type. I have also updated the file qemu-img.text and the help output to display the new parameters, and put in a parameter that was missing. The patch is as follows, and can be applied to 0.10.5 stable (and latest snapshot if qemu-img hasn't changed) with patch -Np1: diff -Naur qemu-0.10.5.orig/block-vmdk.c qemu-0.10.5/block-vmdk.c --- qemu-0.10.5.orig/block-vmdk.c Thu May 21 06:46:58 2009 +++ qemu-0.10.5/block-vmdk.c Fri May 22 20:09:44 2009 @@ -692,6 +692,7 @@ int fd, i; VMDK4Header header; uint32_t tmp, magic, grains, gd_size, gt_size, gt_count; + static const char desc_template[] = "# Disk DescriptorFile\n" "version=1\n" @@ -709,10 +710,19 @@ "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]; + char adaptType[10]; const char *real_filename, *temp_str; + /* If neither BusLogic or LSI logic is requested, default to IDE - thirdwheel, 17/04/2009 */ + if (flags & BLOCK_FLAG_BUSLOGIC) + strcpy(adaptType, "buslogic"); + else if (flags & BLOCK_FLAG_LSILOGIC) + strcpy(adaptType, "lsilogic"); + else + strcpy(adaptType, "ide"); + /* XXX: add support for backing file */ if (backing_file) { return vmdk_snapshot_create(filename, backing_file); @@ -784,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), + adaptType); /* write the descriptor */ lseek(fd, le64_to_cpu(header.desc_offset) << 9, SEEK_SET); diff -Naur qemu-0.10.5.orig/block_int.h qemu-0.10.5/block_int.h --- qemu-0.10.5.orig/block_int.h Thu May 21 06:46:58 2009 +++ qemu-0.10.5/block_int.h Fri May 22 20:09:44 2009 @@ -36,6 +36,10 @@ BlockDriverAIOCB *free_aiocb; } AIOPool; +/* Added by thirdwheel to support BusLogic and LSI logic based VMDKs - 17/04/09 */ +#define BLOCK_FLAG_BUSLOGIC 8 +#define BLOCK_FLAG_LSILOGIC 16 + struct BlockDriver { const char *format_name; int instance_size; diff -Naur qemu-0.10.5.orig/qemu-img.c qemu-0.10.5/qemu-img.c --- qemu-0.10.5.orig/qemu-img.c Thu May 21 06:47:00 2009 +++ qemu-0.10.5/qemu-img.c Fri May 22 20:09:44 2009 @@ -58,9 +58,9 @@ "QEMU disk image utility\n" "\n" "Command syntax:\n" - " create [-e] [-6] [-b base_image] [-f fmt] filename [size]\n" + " create [-e] [-6] [-S] [-L] [-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] [-6] [-S] [-L] [-f fmt] [-O output_fmt] [-B output_base_image] filename [filename2 [...]] output_filename\n" " info [-f fmt] filename\n" " snapshot [-l | -a snapshot | -c snapshot | -d snapshot] filename\n" "\n" @@ -81,6 +81,8 @@ " '-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" " '-6' indicates that the target image must use compatibility level 6 (vmdk format only)\n" + " '-S' indicates that the target image must be a BusLogic SCSI virtual disk (vmdk format only)\n" + " '-L' indicates that the target image must be a LSI Logic SCSI virtual disk (vmdk format only)\n" " '-h' with or without a command shows this help and lists the supported formats\n" "\n" "Parameters to snapshot subcommand:\n" @@ -226,7 +228,7 @@ flags = 0; for(;;) { - c = getopt(argc, argv, "b:f:he6"); + c = getopt(argc, argv, "b:f:he6SL"); if (c == -1) break; switch(c) { @@ -245,6 +247,12 @@ case '6': flags |= BLOCK_FLAG_COMPAT6; break; + case 'S': + flags |= BLOCK_FLAG_BUSLOGIC; + break; + case 'L': + flags |= BLOCK_FLAG_LSILOGIC; + break; } } if (optind >= argc) @@ -275,12 +283,23 @@ drv = bdrv_find_format(fmt); if (!drv) error("Unknown file format '%s'", fmt); + if (flags & BLOCK_FLAG_BUSLOGIC && drv != &bdrv_vmdk) + error("BusLogic images not supported for this file format"); + if (flags & BLOCK_FLAG_LSILOGIC && drv != &bdrv_vmdk) + error("LSI Logic images not supported for this file format"); + if (flags & BLOCK_FLAG_LSILOGIC && flags & BLOCK_FLAG_BUSLOGIC) + error("Please select either LSI Logic or BusLogic, not both"); + printf("Formatting '%s', fmt=%s", filename, fmt); if (flags & BLOCK_FLAG_ENCRYPT) printf(", encrypted"); if (flags & BLOCK_FLAG_COMPAT6) printf(", compatibility level=6"); + if (flags & BLOCK_FLAG_BUSLOGIC) + printf(", in BusLogic mode"); + if (flags & BLOCK_FLAG_LSILOGIC) + printf(", in LSI Logic mode"); if (base_filename) { printf(", backing_file=%s", base_filename); @@ -415,7 +434,7 @@ out_baseimg = NULL; flags = 0; for(;;) { - c = getopt(argc, argv, "f:O:B:hce6"); + c = getopt(argc, argv, "f:O:B:hce6SL"); if (c == -1) break; switch(c) { @@ -440,6 +459,12 @@ case '6': flags |= BLOCK_FLAG_COMPAT6; break; + case 'S': + flags |= BLOCK_FLAG_BUSLOGIC; + break; + case 'L': + flags |= BLOCK_FLAG_LSILOGIC; + break; } } @@ -473,6 +498,15 @@ error("Encryption 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_BUSLOGIC && drv != &bdrv_vmdk) + error("BusLogic images not supported for this file format"); + if (flags & BLOCK_FLAG_LSILOGIC && drv != &bdrv_vmdk) + error("LSI Logic images not supported for this file format"); + if (flags & BLOCK_FLAG_LSILOGIC && flags & BLOCK_FLAG_BUSLOGIC) + error("Please select either LSI Logic or BusLogic, not both"); + /* I'm not sure if buslogic and/or lsi logic images are supported at compatibility level 6 - if not, uncomment this until it can be tested */ + /*if ((flags & BLOCK_FLAG_LSILOGIC || flags & BLOCK_FLAG_BUSLOGIC) && BLOCK_FLAG_COMPAT6) */ + /*error("SCSI VMDK images are not currently supported in compatibilty level 6");*/ if (flags & BLOCK_FLAG_ENCRYPT && flags & BLOCK_FLAG_COMPRESS) error("Compression and encryption not supported at the same time"); @@ -681,6 +715,10 @@ char backing_filename[1024]; char backing_filename2[1024]; BlockDriverInfo bdi; + + /* Added this to show what kind of adapter a vmdk image is - thirdwheel 17/04/2009 */ + char line[1024]; + FILE *vmdk; fmt = NULL; for(;;) { @@ -729,6 +767,22 @@ filename, fmt_name, size_buf, (total_sectors * 512), dsize_buf); + + if (strcmp(fmt_name, "vmdk") == 0) { + /* Now we find out what adapter type it is! - thirdwheel, 17/04/2009 */ + vmdk = fopen(filename, "r"); + fseek(vmdk, 512, SEEK_SET); + + while (fgets(line, 1024, vmdk) != NULL) { + + if (strcmp(strtok(line, "\""), "ddb.adapterType = ") == 0) { + + printf("Adapter type: %s\n", strtok(NULL, "\"")); + break; + } + } + fclose(vmdk); + } if (bdrv_is_encrypted(bs)) printf("encrypted: yes\n"); if (bdrv_get_info(bs, &bdi) >= 0) { diff -Naur qemu-0.10.5.orig/qemu-img.texi qemu-0.10.5/qemu-img.texi --- qemu-0.10.5.orig/qemu-img.texi Thu May 21 06:47:00 2009 +++ qemu-0.10.5/qemu-img.texi Fri May 22 20:16:30 2009 @@ -52,7 +52,7 @@ image format in QEMU. It is supported only for compatibility with previous versions. It does not work on win32. @item vmdk -VMware 3 and 4 compatible image format. +VMware 3 and 4 compatible image format. Supports IDE and SCSI (BusLogic and LSI Logic) adapters @item cloop Linux Compressed Loop image, useful only to reuse directly compressed CD-ROM images present for example in the Knoppix CD-ROMs. @@ -98,7 +98,7 @@ Command description: @table @option -@item create [-6] [-e] [-b @var{base_image}] [-f @var{fmt}] @var{filename} [@var{size}] +@item create [-S] [-L] [-6] [-e] [-b @var{base_image}] [-f @var{fmt}] @var{filename} [@var{size}] Create the new disk image @var{filename} of size @var{size} and format @var{fmt}. @@ -108,11 +108,15 @@ this case. @var{base_image} will never be modified unless you use the @code{commit} monitor command. +If the format is @code{vmdk}, the @code{-S} option will create a BusLogic image, +whereas the @code{-L} will create an LSI Logic image. Specifying neither option +creates an IDE image. + @item commit [-f @var{fmt}] @var{filename} Commit the changes recorded in @var{filename} in its base image. -@item convert [-c] [-e] [-f @var{fmt}] @var{filename} [-O @var{output_fmt}] @var{output_filename} +@item convert [-c] [-e] [-6] [-S] [-L] [-f @var{fmt}] @var{filename} [-O @var{output_fmt}] @var{output_filename} Convert the disk image @var{filename} to disk image @var{output_filename} using format @var{output_fmt}. It can be optionally encrypted @@ -129,12 +133,17 @@ growable format such as @code{qcow} or @code{cow}: the empty sectors are detected and suppressed from the destination image. +As with the create command, if the format is @code{vmdk}, the @code{-S} +option will create a BusLogic image, whereas the @code{-L} will create +an LSI Logic image. Specifying neither option creates an IDE image. + @item info [-f @var{fmt}] @var{filename} Give information about the disk image @var{filename}. Use it in particular to know the size reserved on disk which can be different from the displayed size. If VM snapshots are stored in the disk image, -they are displayed too. +they are displayed too. For the @code{vmdk} format, the adapter type of +the image is displayed as well. @item snapshot [-l | -a @var{snapshot} | -c @var{snapshot} | -d @var{snapshot} ] @var{filename} --0016e644ddeaf5851c046a7dbd07 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Hi,

I needed to create a heap of virtual hard drives to practice cre= ating RAID arrays.=A0 Since qemu-img only creates IDE images, creating a la= rge number of images for this was a very cumbersome excercise.=A0 I compare= d a SCSI image to an IDE image, and the only difference is the adapter type= .=A0 This patch adds command line parameters to qemu-img to specify either = a BusLogic or LSI Logic image for 'create' and 'convert', a= nd extends the 'info' command to show the adapter type.=A0 I have a= lso updated the file qemu-img.text and the help output to display the new p= arameters, and put in a parameter that was missing.

The patch is as follows, and can be applied to 0.10.5 stable (and lates= t snapshot if qemu-img hasn't changed) with patch -Np1:

diff -Na= ur qemu-0.10.5.orig/block-vmdk.c qemu-0.10.5/block-vmdk.c
--- qemu-0.10.= 5.orig/block-vmdk.c=A0=A0=A0 Thu May 21 06:46:58 2009
+++ qemu-0.10.5/block-vmdk.c=A0=A0=A0 Fri May 22 20:09:44 2009
@@ -692,6= +692,7 @@
=A0=A0=A0=A0 int fd, i;
=A0=A0=A0=A0 VMDK4Header header;=A0=A0=A0=A0 uint32_t tmp, magic, grains, gd_size, gt_size, gt_count;
= +=A0=A0=A0
=A0=A0=A0=A0 static const char desc_template[] =3D
=A0=A0=A0=A0=A0=A0=A0=A0 "# Disk DescriptorFile\n"
=A0=A0=A0= =A0=A0=A0=A0=A0 "version=3D1\n"
@@ -709,10 +710,19 @@
=A0= =A0=A0=A0=A0=A0=A0=A0 "ddb.geometry.cylinders =3D \"%" PRId6= 4 "\"\n"
=A0=A0=A0=A0=A0=A0=A0=A0 "ddb.geometry.head= s =3D \"16\"\n"
=A0=A0=A0=A0=A0=A0=A0=A0 "ddb.geometry.sectors =3D \"63\"\n&= quot;
-=A0=A0=A0=A0=A0=A0=A0 "ddb.adapterType =3D \"ide\"= \n";
+=A0=A0=A0=A0=A0=A0=A0 "ddb.adapterType =3D \"%s\&qu= ot;\n";
=A0=A0=A0=A0 char desc[1024];
+=A0=A0=A0 char adaptType[= 10];
=A0=A0=A0=A0 const char *real_filename, *temp_str;
=A0
+=A0=A0=A0 /* = If neither BusLogic or LSI logic is requested, default to IDE - thirdwheel,= 17/04/2009 */
+=A0=A0=A0 if (flags & BLOCK_FLAG_BUSLOGIC)
+=A0= =A0=A0 strcpy(adaptType, "buslogic");
+=A0=A0=A0 else if (flags & BLOCK_FLAG_LSILOGIC)
+=A0=A0=A0 strcpy(a= daptType, "lsilogic");
+=A0=A0=A0 else
+=A0=A0=A0 strcpy(ad= aptType, "ide");
+
=A0=A0=A0=A0 /* XXX: add support for bac= king file */
=A0=A0=A0=A0 if (backing_file) {
=A0=A0=A0=A0=A0=A0=A0=A0 return vmdk_snapshot_create(filename, backing_file= );
@@ -784,7 +794,8 @@
=A0=A0=A0=A0 snprintf(desc, sizeof(desc), desc= _template, (unsigned int)time(NULL),
=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0= =A0=A0 total_size, real_filename,
=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0= =A0 (flags & BLOCK_FLAG_COMPAT6 ? 6 : 4),
-=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 total_size / (int64_t)(63 * 16));
= +=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 total_size / (int64_t)(63 * 16),
+= =A0=A0=A0 =A0=A0=A0=A0 adaptType);
=A0
=A0=A0=A0=A0 /* write the desc= riptor */
=A0=A0=A0=A0 lseek(fd, le64_to_cpu(header.desc_offset) <<= ; 9, SEEK_SET);
diff -Naur qemu-0.10.5.orig/block_int.h qemu-0.10.5/block_int.h
--- qemu= -0.10.5.orig/block_int.h=A0=A0=A0 Thu May 21 06:46:58 2009
+++ qemu-0.10= .5/block_int.h=A0=A0=A0 Fri May 22 20:09:44 2009
@@ -36,6 +36,10 @@
= =A0=A0=A0=A0 BlockDriverAIOCB *free_aiocb;
=A0} AIOPool;
=A0
+/* Added by thirdwheel to support BusLogic and LSI= logic based VMDKs - 17/04/09 */
+#define BLOCK_FLAG_BUSLOGIC=A0=A0=A0 8=
+#define BLOCK_FLAG_LSILOGIC=A0=A0=A0 16
+
=A0struct BlockDriver = {
=A0=A0=A0=A0 const char *format_name;
=A0=A0=A0=A0 int instance_size;
diff -Naur qemu-0.10.5.orig/qemu-img.c q= emu-0.10.5/qemu-img.c
--- qemu-0.10.5.orig/qemu-img.c=A0=A0=A0 Thu May 2= 1 06:47:00 2009
+++ qemu-0.10.5/qemu-img.c=A0=A0=A0 Fri May 22 20:09:44 = 2009
@@ -58,9 +58,9 @@
=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 "QEMU disk image utility\n"
= =A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 "\n"
=A0=A0=A0=A0=A0=A0=A0= =A0=A0=A0=A0 "Command syntax:\n"
-=A0=A0=A0=A0=A0=A0=A0=A0=A0= =A0 "=A0 create [-e] [-6] [-b base_image] [-f fmt] filename [size]\n&q= uot;
+=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 "=A0 create [-e] [-6] [-S] [-L= ] [-b base_image] [-f fmt] filename [size]\n"
=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 "=A0 commit [-f fmt] filename\n"= ;
-=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 "=A0 convert [-c] [-e] [-6] [-f f= mt] [-O output_fmt] [-B output_base_image] filename [filename2 [...]] outpu= t_filename\n"
+=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 "=A0 convert [-c= ] [-e] [-6] [-S] [-L] [-f fmt] [-O output_fmt] [-B output_base_image] filen= ame [filename2 [...]] output_filename\n"
=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 "=A0 info [-f fmt] filename\n"<= br>=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 "=A0 snapshot [-l | -a snapshot |= -c snapshot | -d snapshot] filename\n"
=A0=A0=A0=A0=A0=A0=A0=A0=A0= =A0=A0 "\n"
@@ -81,6 +81,8 @@
=A0=A0=A0=A0=A0=A0=A0=A0=A0= =A0=A0 "=A0 '-c' indicates that target image must be compresse= d (qcow format only)\n"
=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 "=A0 '-e' indicates that the= target image must be encrypted (qcow format only)\n"
=A0=A0=A0=A0= =A0=A0=A0=A0=A0=A0=A0 "=A0 '-6' indicates that the target imag= e must use compatibility level 6 (vmdk format only)\n"
+=A0=A0=A0 =A0=A0 "=A0 '-S' indicates that the target image mu= st be a BusLogic SCSI virtual disk (vmdk format only)\n"
+=A0=A0=A0= =A0=A0 "=A0 '-L' indicates that the target image must be a LS= I Logic SCSI virtual disk (vmdk format only)\n"
=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 "=A0 '-h' with or without a = command shows this help and lists the supported formats\n"
=A0=A0= =A0=A0=A0=A0=A0=A0=A0=A0=A0 "\n"
=A0=A0=A0=A0=A0=A0=A0=A0=A0= =A0=A0 "Parameters to snapshot subcommand:\n"
@@ -226,7 +228,7= @@
=A0
=A0=A0=A0=A0 flags =3D 0;
=A0=A0=A0=A0 for(;;) {
-=A0=A0=A0=A0= =A0=A0=A0 c =3D getopt(argc, argv, "b:f:he6");
+=A0=A0=A0=A0= =A0=A0=A0 c =3D getopt(argc, argv, "b:f:he6SL");
=A0=A0=A0=A0= =A0=A0=A0=A0 if (c =3D=3D -1)
=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 break= ;
=A0=A0=A0=A0=A0=A0=A0=A0 switch(c) {
@@ -245,6 +247,12 @@
=A0=A0=A0=A0=A0=A0=A0=A0 case '6':
=A0= =A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 flags |=3D BLOCK_FLAG_COMPAT6;
=A0=A0= =A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 break;
+=A0=A0=A0 case 'S':
+= =A0=A0=A0 =A0=A0=A0 flags |=3D BLOCK_FLAG_BUSLOGIC;
+=A0=A0=A0 =A0=A0=A0= break;
+=A0=A0=A0 case 'L':
+=A0=A0=A0 =A0=A0=A0 flags |=3D BLOCK_FLAG_LSILOGIC;
+=A0=A0=A0 =A0=A0= =A0 break;
=A0=A0=A0=A0=A0=A0=A0=A0 }
=A0=A0=A0=A0 }
=A0=A0=A0=A0 = if (optind >=3D argc)
@@ -275,12 +283,23 @@
=A0=A0=A0=A0 drv =3D b= drv_find_format(fmt);
=A0=A0=A0=A0 if (!drv)
=A0=A0=A0=A0=A0=A0=A0=A0= error("Unknown file format '%s'", fmt);
+=A0=A0=A0 if (flags & BLOCK_FLAG_BUSLOGIC && drv !=3D &bdr= v_vmdk)
+=A0=A0=A0=A0=A0=A0=A0 error("BusLogic images not supported= for this file format");
+=A0=A0=A0 if (flags & BLOCK_FLAG_LSIL= OGIC && drv !=3D &bdrv_vmdk)
+=A0=A0=A0=A0=A0=A0=A0 error("LSI Logic images not supported for this = file format");
+=A0=A0=A0 if (flags & BLOCK_FLAG_LSILOGIC &= & flags & BLOCK_FLAG_BUSLOGIC)
+=A0=A0=A0=A0=A0=A0=A0 error(&quo= t;Please select either LSI Logic or BusLogic, not both");
+
=A0=A0=A0=A0 printf("Formatting '%s', fmt=3D%s",
= =A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 filename, fmt);
=A0=A0=A0=A0 if (flags= & BLOCK_FLAG_ENCRYPT)
=A0=A0=A0=A0=A0=A0=A0=A0 printf(", encry= pted");
=A0=A0=A0=A0 if (flags & BLOCK_FLAG_COMPAT6)
=A0=A0=A0=A0=A0=A0=A0=A0 printf(", compatibility level=3D6");
= +=A0=A0=A0 if (flags & BLOCK_FLAG_BUSLOGIC)
+=A0=A0=A0=A0=A0=A0=A0 p= rintf(", in BusLogic mode");
+=A0=A0=A0 if (flags & BLOCK_= FLAG_LSILOGIC)
+=A0=A0=A0=A0=A0=A0=A0 printf(", in LSI Logic mode&q= uot;);
=A0=A0=A0=A0 if (base_filename) {
=A0=A0=A0=A0=A0=A0=A0=A0 printf("= , backing_file=3D%s",
=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0= base_filename);
@@ -415,7 +434,7 @@
=A0=A0=A0=A0 out_baseimg =3D NUL= L;
=A0=A0=A0=A0 flags =3D 0;
=A0=A0=A0=A0 for(;;) {
-=A0=A0=A0=A0= =A0=A0=A0 c =3D getopt(argc, argv, "f:O:B:hce6");
+=A0=A0=A0=A0=A0=A0=A0 c =3D getopt(argc, argv, "f:O:B:hce6SL");<= br>=A0=A0=A0=A0=A0=A0=A0=A0 if (c =3D=3D -1)
=A0=A0=A0=A0=A0=A0=A0=A0=A0= =A0=A0=A0 break;
=A0=A0=A0=A0=A0=A0=A0=A0 switch(c) {
@@ -440,6 +459,= 12 @@
=A0=A0=A0=A0=A0=A0=A0=A0 case '6':
=A0=A0=A0=A0=A0=A0= =A0=A0=A0=A0=A0=A0 flags |=3D BLOCK_FLAG_COMPAT6;
=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 break;
+=A0=A0=A0 case 'S':=
+=A0=A0=A0 =A0=A0=A0 flags |=3D BLOCK_FLAG_BUSLOGIC;
+=A0=A0=A0 =A0= =A0=A0 break;
+=A0=A0=A0 case 'L':
+=A0=A0=A0 =A0=A0=A0 flags= |=3D BLOCK_FLAG_LSILOGIC;
+=A0=A0=A0 =A0=A0=A0 break;
=A0=A0=A0=A0= =A0=A0=A0=A0 }
=A0=A0=A0=A0 }
=A0
@@ -473,6 +498,15 @@
=A0=A0=A0=A0=A0=A0=A0=A0 error("Encrypt= ion not supported for this file format");
=A0=A0=A0=A0 if (flags &a= mp; BLOCK_FLAG_COMPAT6 && drv !=3D &bdrv_vmdk)
=A0=A0=A0=A0= =A0=A0=A0=A0 error("Alternative compatibility level not supported for = this file format");
+=A0=A0=A0 if (flags & BLOCK_FLAG_BUSLOGIC && drv !=3D &bdr= v_vmdk)
+=A0=A0=A0=A0=A0=A0=A0 error("BusLogic images not supported= for this file format");
+=A0=A0=A0 if (flags & BLOCK_FLAG_LSIL= OGIC && drv !=3D &bdrv_vmdk)
+=A0=A0=A0=A0=A0=A0=A0 error("LSI Logic images not supported for this = file format");
+=A0=A0=A0 if (flags & BLOCK_FLAG_LSILOGIC &= & flags & BLOCK_FLAG_BUSLOGIC)
+=A0=A0=A0=A0=A0=A0=A0 error(&quo= t;Please select either LSI Logic or BusLogic, not both");
+=A0=A0=A0 /* I'm not sure if buslogic and/or lsi logic images are supp= orted at compatibility level 6 - if not, uncomment this until it can be tes= ted */
+=A0=A0=A0 /*if ((flags & BLOCK_FLAG_LSILOGIC || flags & = BLOCK_FLAG_BUSLOGIC) && BLOCK_FLAG_COMPAT6) */
+=A0=A0=A0=A0=A0=A0=A0 /*error("SCSI VMDK images are not currently sup= ported in compatibilty level 6");*/
=A0=A0=A0=A0 if (flags & BL= OCK_FLAG_ENCRYPT && flags & BLOCK_FLAG_COMPRESS)
=A0=A0=A0= =A0=A0=A0=A0=A0 error("Compression and encryption not supported at the= same time");
=A0
@@ -681,6 +715,10 @@
=A0=A0=A0=A0 char backing_filename[1024];=A0=A0=A0=A0 char backing_filename2[1024];
=A0=A0=A0=A0 BlockDriverInfo= bdi;
+=A0=A0=A0
+=A0=A0=A0 /* Added this to show what kind of adapt= er a vmdk image is - thirdwheel 17/04/2009 */
+=A0=A0=A0 char line[1024];
+=A0=A0=A0 FILE *vmdk;
=A0
=A0=A0=A0= =A0 fmt =3D NULL;
=A0=A0=A0=A0 for(;;) {
@@ -729,6 +767,22 @@
=A0= =A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 filename, fmt_name, size_buf,
=A0=A0=A0= =A0=A0=A0=A0=A0=A0=A0=A0 (total_sectors * 512),
=A0=A0=A0=A0=A0=A0=A0=A0= =A0=A0=A0 dsize_buf);
+=A0=A0=A0 =A0=A0
+=A0=A0=A0 if (strcmp(fmt_name, "vmdk") =3D= =3D 0) {
+=A0=A0=A0=A0=A0=A0=A0 /* Now we find out what adapter type it = is! - thirdwheel, 17/04/2009 */
+=A0=A0=A0 vmdk =3D fopen(filename, &quo= t;r");
+=A0=A0=A0 fseek(vmdk, 512, SEEK_SET);
+=A0=A0=A0
+=A0=A0=A0 while (fgets(line, 1024, vmdk) !=3D NULL) {
+= =A0=A0=A0
+=A0=A0=A0 =A0=A0=A0 if (strcmp(strtok(line, "\"&qu= ot;), "ddb.adapterType =3D ") =3D=3D 0) {
+=A0=A0=A0 =A0=A0=A0=
+=A0=A0=A0 =A0=A0=A0 =A0=A0=A0 printf("Adapter type: %s\n", = strtok(NULL, "\""));
+=A0=A0=A0 =A0=A0=A0 =A0=A0=A0 break;
+=A0=A0=A0 =A0=A0=A0 }
+=A0=A0= =A0 }
+=A0=A0=A0 fclose(vmdk);
+=A0=A0=A0 }
=A0=A0=A0=A0 if (bdrv_= is_encrypted(bs))
=A0=A0=A0=A0=A0=A0=A0=A0 printf("encrypted: yes\n= ");
=A0=A0=A0=A0 if (bdrv_get_info(bs, &bdi) >=3D 0) {
di= ff -Naur qemu-0.10.5.orig/qemu-img.texi qemu-0.10.5/qemu-img.texi
--- qemu-0.10.5.orig/qemu-img.texi=A0=A0=A0 Thu May 21 06:47:00 2009
+++= qemu-0.10.5/qemu-img.texi=A0=A0=A0 Fri May 22 20:16:30 2009
@@ -52,7 +5= 2,7 @@
=A0image format in QEMU. It is supported only for compatibility w= ith
=A0previous versions. It does not work on win32.
=A0@item vmdk
-VMware 3 and 4 compatible image format.
+VMware 3 and = 4 compatible image format.=A0 Supports IDE and SCSI (BusLogic and LSI Logic= ) adapters
=A0@item cloop
=A0Linux Compressed Loop image, useful only= to reuse directly compressed
=A0CD-ROM images present for example in the Knoppix CD-ROMs.
@@ -98,7 +9= 8,7 @@
=A0Command description:
=A0
=A0@table @option
-@item cre= ate [-6] [-e] [-b @var{base_image}] [-f @var{fmt}] @var{filename} [@var{siz= e}]
+@item create [-S] [-L] [-6] [-e] [-b @var{base_image}] [-f @var{fmt}] @var= {filename} [@var{size}]
=A0
=A0Create the new disk image @var{filenam= e} of size @var{size} and format
=A0@var{fmt}.
@@ -108,11 +108,15 @@<= br> =A0this case. @var{base_image} will never be modified unless you use the=A0@code{commit} monitor command.
=A0
+If the format is @code{vmdk},= the @code{-S} option will create a BusLogic image,
+whereas the @code{-= L} will create an LSI Logic image.=A0 Specifying neither option
+creates an IDE image.
+
=A0@item commit [-f @var{fmt}] @var{filename= }
=A0
=A0Commit the changes recorded in @var{filename} in its base im= age.
=A0
-@item convert [-c] [-e] [-f @var{fmt}] @var{filename} [-O @= var{output_fmt}] @var{output_filename}
+@item convert [-c] [-e] [-6] [-S] [-L] [-f @var{fmt}] @var{filename} [-O @= var{output_fmt}] @var{output_filename}
=A0
=A0Convert the disk image = @var{filename} to disk image @var{output_filename}
=A0using format @var{= output_fmt}. It can be optionally encrypted
@@ -129,12 +133,17 @@
=A0growable format such as @code{qcow} or @code{co= w}: the empty sectors
=A0are detected and suppressed from the destinatio= n image.
=A0
+As with the create command, if the format is @code{vmdk= }, the @code{-S}
+option will create a BusLogic image, whereas the @code{-L} will create +an LSI Logic image.=A0 Specifying neither option creates an IDE image.+
=A0@item info [-f @var{fmt}] @var{filename}
=A0
=A0Give informa= tion about the disk image @var{filename}. Use it in
=A0particular to know the size reserved on disk which can be different
= =A0from the displayed size. If VM snapshots are stored in the disk image,-they are displayed too.
+they are displayed too.=A0 For the @code{vmd= k} format, the adapter type of
+the image is displayed as well.
=A0
=A0@item snapshot [-l | -a @var{= snapshot} | -c @var{snapshot} | -d @var{snapshot} ] @var{filename}
=A0
--0016e644ddeaf5851c046a7dbd07--