qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Qemu-devel] PATCH: Adding options to generate SCSI based VMDK images


From: Aaron Mason
Subject: [Qemu-devel] PATCH: Adding options to generate SCSI based VMDK images
Date: Wed, 28 Jul 2010 12:01:57 +1000

Hi all,

I tried this once before using command-line parameters and it was
knocked back.  Someone made the mention of using options so I had a
look and saw that it was really simple to do.

The following is a patch from the latest Git snapshot.  I have also
attached it (in case it gets broken by Gmail) and uploaded it to
http://milo.thats-too-much.info/qemu-vmdk_gen_scsi.patch (in case the
mailing list prohibits attachments).

diff --git a/block/vmdk.c b/block/vmdk.c
index 2d4ba42..b60d86f 100644
--- a/block/vmdk.c
+++ b/block/vmdk.c
@@ -686,9 +686,9 @@ static int vmdk_create(const char *filename,
QEMUOptionParameter *options)
         "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;
+    const char *real_filename, *temp_str, *adapter_type = "ide";
     int64_t total_size = 0;
     const char *backing_file = NULL;
     int flags = 0;
@@ -702,6 +702,15 @@ static int vmdk_create(const char *filename,
QEMUOptionParameter *options)
             backing_file = options->value.s;
         } else if (!strcmp(options->name, BLOCK_OPT_COMPAT6)) {
             flags |= options->value.n ? BLOCK_FLAG_COMPAT6: 0;
+        } else if (!strcmp(options->name, BLOCK_OPT_ADAPTER)) {
+        if (options->value.s != NULL) {
+            if (!strcmp(options->value.s, "ide") || \
+                   !strcmp(options->value.s, "buslogic") || \
+            !strcmp(options->value.s, "lsilogic")) {
+            adapter_type = options->value.s;
+        } else
+            return -1;
+        }
         }
         options++;
     }
@@ -799,7 +808,7 @@ static int vmdk_create(const char *filename,
QEMUOptionParameter *options)
     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), adapter_type);

     /* write the descriptor */
     lseek(fd, le64_to_cpu(header.desc_offset) << 9, SEEK_SET);
@@ -845,6 +854,11 @@ static QEMUOptionParameter vmdk_create_options[] = {
         .type = OPT_FLAG,
         .help = "VMDK version 6 image"
     },
+    {
+    .name = BLOCK_OPT_ADAPTER,
+    .type = OPT_STRING,
+    .help = "Adapter type - ide (default), lsilogic or buslogic"
+    },
     { NULL }
 };

diff --git a/block_int.h b/block_int.h
index 96ff4cf..4eb8c6d 100644
--- a/block_int.h
+++ b/block_int.h
@@ -39,6 +39,7 @@
 #define BLOCK_OPT_BACKING_FMT   "backing_fmt"
 #define BLOCK_OPT_CLUSTER_SIZE  "cluster_size"
 #define BLOCK_OPT_PREALLOC      "preallocation"
+#define BLOCK_OPT_ADAPTER       "adapter_type"

 typedef struct AIOPool {
     void (*cancel)(BlockDriverAIOCB *acb);

Attachment: qemu-vmdk_gen_scsi.patch
Description: Binary data


reply via email to

[Prev in Thread] Current Thread [Next in Thread]