qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH] qemu-img: Create SCSI VMDK disks
@ 2008-04-22 15:57 Kevin Wolf
  2008-04-23 20:18 ` [Qemu-devel] " Sebastian Herbszt
  0 siblings, 1 reply; 3+ messages in thread
From: Kevin Wolf @ 2008-04-22 15:57 UTC (permalink / raw)
  To: qemu-devel

[-- Attachment #1: Type: text/plain, Size: 254 bytes --]

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.

Signed-off-by: Kevin Wolf <kwolf@suse.de>

[-- Attachment #2: qemu-img-vmdk-scsi.patch --]
[-- Type: text/x-patch, Size: 4804 bytes --]

Index: qemu-svn/block-vmdk.c
===================================================================
--- qemu-svn.orig/block-vmdk.c
+++ qemu-svn/block-vmdk.c
@@ -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 *filen
     if ((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);
Index: qemu-svn/qemu-img.c
===================================================================
--- qemu-svn.orig/qemu-img.c
+++ qemu-svn/qemu-img.c
@@ -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 **a
         case '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 **a
         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)
@@ -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)
Index: qemu-svn/block_int.h
===================================================================
--- qemu-svn.orig/block_int.h
+++ qemu-svn/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;

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [Qemu-devel] Re: [PATCH] qemu-img: Create SCSI VMDK disks
  2008-04-22 15:57 [Qemu-devel] [PATCH] qemu-img: Create SCSI VMDK disks Kevin Wolf
@ 2008-04-23 20:18 ` Sebastian Herbszt
  2008-04-24  6:05   ` Kevin Wolf
  0 siblings, 1 reply; 3+ messages in thread
From: Sebastian Herbszt @ 2008-04-23 20:18 UTC (permalink / raw)
  To: qemu-devel

> 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

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [Qemu-devel] Re: [PATCH] qemu-img: Create SCSI VMDK disks
  2008-04-23 20:18 ` [Qemu-devel] " Sebastian Herbszt
@ 2008-04-24  6:05   ` Kevin Wolf
  0 siblings, 0 replies; 3+ messages in thread
From: Kevin Wolf @ 2008-04-24  6:05 UTC (permalink / raw)
  To: qemu-devel

Sebastian Herbszt schrieb:
>> 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

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2008-04-24  6:27 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-04-22 15:57 [Qemu-devel] [PATCH] qemu-img: Create SCSI VMDK disks Kevin Wolf
2008-04-23 20:18 ` [Qemu-devel] " Sebastian Herbszt
2008-04-24  6:05   ` Kevin Wolf

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).