Patchwork PATCH: Adding options to generate SCSI based VMDK images

login
register
mail settings
Submitter Aaron Mason
Date July 28, 2010, 2:01 a.m.
Message ID <AANLkTim35MUJLkgc4BqEXguMWR3Q9Fsuohj+84SvJSsY@mail.gmail.com>
Download mbox | patch
Permalink /patch/60080/
State New
Headers show

Comments

Aaron Mason - July 28, 2010, 2:01 a.m.
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).
Kevin Wolf - July 28, 2010, 1:10 p.m.
Hi Aaron,

Am 28.07.2010 04:01, schrieb Aaron Mason:
> 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).

Needs a Signed-off-by line. Also please use "[PATCH]" instead of
"PATCH:" in the subject line so that git am automatically removes it
when applying the patch. You get a correctly formatted mail with git
format-patch.

And yes, your mailer has broken the patch, so adding the attachment was
a good idea (using git send-email would be even better, though).

> 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;
> +        }

qemu uses four spaces for indentation, tabs are not allowed. Also, a \
at the end of a line is not needed.

The logic of the patch looks okay, so please send a v2 with just these
formal things fixed.

Kevin

Patch

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);