Skip to contentSkip to conversation

Allow users to specify the vmdk virtual hardware version.

PATCH In review Janne Karhunen 2 participants 9 messages Apr 20, 2016 – Apr 25, 2016 Block layer

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Allow users to specify the vmdk virtual hardware version.

From: Janne Karhunen <[email protected]>

Replace hardcoded vmdk description file hardware version flag with a user definable version.

---
 block/vmdk.c              | 20 ++++++++++----------
 include/block/block_int.h |  3 +--
 qemu-doc.texi             |  4 ++--
 3 files changed, 13 insertions(+), 14 deletions(-)
block/vmdk.c +10 -10
index 45f9d3c..1436785 100644
@@ -1829,8 +1829,8 @@ static int vmdk_create(const char *filename, QemuOpts *opts, Error **errp)
     int64_t total_size = 0, filesize;
     char *adapter_type = NULL;
     char *backing_file = NULL;
+    char *hw_version = NULL;
     char *fmt = NULL;
-    int flags = 0;
     int ret = 0;
     bool flat, split, compress;
     GString *ext_desc_lines;
@@ -1861,7 +1861,7 @@ static int vmdk_create(const char *filename, QemuOpts *opts, Error **errp)
         "# The Disk Data Base\n"
         "#DDB\n"
         "\n"
-        "ddb.virtualHWVersion = \"%d\"\n"
+        "ddb.virtualHWVersion = \"%s\"\n"
         "ddb.geometry.cylinders = \"%" PRId64 "\"\n"
         "ddb.geometry.heads = \"%" PRIu32 "\"\n"
         "ddb.geometry.sectors = \"63\"\n"
@@ -1878,9 +1878,8 @@ static int vmdk_create(const char *filename, QemuOpts *opts, Error **errp)
                           BDRV_SECTOR_SIZE);
     adapter_type = qemu_opt_get_del(opts, BLOCK_OPT_ADAPTER_TYPE);
     backing_file = qemu_opt_get_del(opts, BLOCK_OPT_BACKING_FILE);
-    if (qemu_opt_get_bool_del(opts, BLOCK_OPT_COMPAT6, false)) {
-        flags |= BLOCK_FLAG_COMPAT6;
-    }
+    hw_version = qemu_opt_get_del(opts, BLOCK_OPT_HWVERSION);
+
     fmt = qemu_opt_get_del(opts, BLOCK_OPT_SUBFMT);
     if (qemu_opt_get_bool_del(opts, BLOCK_OPT_ZEROED_GRAIN, false)) {
         zeroed_grain = true;
@@ -2001,7 +2000,7 @@ static int vmdk_create(const char *filename, QemuOpts *opts, Error **errp)
                            fmt,
                            parent_desc_line,
                            ext_desc_lines->str,
-                           (flags & BLOCK_FLAG_COMPAT6 ? 6 : 4),
+                           hw_version,
                            total_size /
                                (int64_t)(63 * number_heads * BDRV_SECTOR_SIZE),
                            number_heads,
@@ -2047,6 +2046,7 @@ exit:
     }
     g_free(adapter_type);
     g_free(backing_file);
+    g_free(hw_version);
     g_free(fmt);
     g_free(desc);
     g_free(path);
@@ -2292,10 +2292,10 @@ static QemuOptsList vmdk_create_opts = {
             .help = "File name of a base image"
         },
         {
-            .name = BLOCK_OPT_COMPAT6,
-            .type = QEMU_OPT_BOOL,
-            .help = "VMDK version 6 image",
-            .def_value_str = "off"
+            .name = BLOCK_OPT_HWVERSION,
+            .type = QEMU_OPT_STRING,
+            .help = "VMDK hardware version",
+            .def_value_str = "4"
         },
         {
             .name = BLOCK_OPT_SUBFMT,
include/block/block_int.h +1 -2
index 10d8759..0852316 100644
@@ -38,12 +38,11 @@
 #include "qemu/throttle.h"
 
 #define BLOCK_FLAG_ENCRYPT          1
-#define BLOCK_FLAG_COMPAT6          4
 #define BLOCK_FLAG_LAZY_REFCOUNTS   8
 
 #define BLOCK_OPT_SIZE              "size"
 #define BLOCK_OPT_ENCRYPT           "encryption"
-#define BLOCK_OPT_COMPAT6           "compat6"
+#define BLOCK_OPT_HWVERSION         "hwversion"
 #define BLOCK_OPT_BACKING_FILE      "backing_file"
 #define BLOCK_OPT_BACKING_FMT       "backing_fmt"
 #define BLOCK_OPT_CLUSTER_SIZE      "cluster_size"
qemu-doc.texi +2 -2
index 79141d3..79f4168 100644
@@ -691,8 +691,8 @@ Supported options:
 @table @code
 @item backing_file
 File name of a base image (see @option{create} subcommand).
-@item compat6
-Create a VMDK version 6 image (instead of version 4)
+@item hwversion
+Specify vmdk hardware version (default 4)
 @item subformat
 Specifies which VMDK subformat to use. Valid options are
 @code{monolithicSparse} (default),
Signature · 1 line
1.9.1
#1 lore raw
Quoted 4 lines · Janne Karhunen

From: Janne Karhunen <[email protected]>

Replace hardcoded vmdk description file hardware version flag with a user definable version.

Hi Janne,

Since this is a new feature, please explain why this change is desired (i.e. the necessity.)

Quoted 63 lines
---
 block/vmdk.c              | 20 ++++++++++----------
 include/block/block_int.h |  3 +--
 qemu-doc.texi             |  4 ++--
 3 files changed, 13 insertions(+), 14 deletions(-)
block/vmdk.c +6 -6
index 45f9d3c..1436785 100644
@@ -1829,8 +1829,8 @@ static int vmdk_create(const char *filename, QemuOpts *opts, Error **errp)
     int64_t total_size = 0, filesize;
     char *adapter_type = NULL;
     char *backing_file = NULL;
+    char *hw_version = NULL;
     char *fmt = NULL;
-    int flags = 0;
     int ret = 0;
     bool flat, split, compress;
     GString *ext_desc_lines;
@@ -1861,7 +1861,7 @@ static int vmdk_create(const char *filename, QemuOpts *opts, Error **errp)
         "# The Disk Data Base\n"
         "#DDB\n"
         "\n"
-        "ddb.virtualHWVersion = \"%d\"\n"
+        "ddb.virtualHWVersion = \"%s\"\n"
         "ddb.geometry.cylinders = \"%" PRId64 "\"\n"
         "ddb.geometry.heads = \"%" PRIu32 "\"\n"
         "ddb.geometry.sectors = \"63\"\n"
@@ -1878,9 +1878,8 @@ static int vmdk_create(const char *filename, QemuOpts *opts, Error **errp)
                           BDRV_SECTOR_SIZE);
     adapter_type = qemu_opt_get_del(opts, BLOCK_OPT_ADAPTER_TYPE);
     backing_file = qemu_opt_get_del(opts, BLOCK_OPT_BACKING_FILE);
-    if (qemu_opt_get_bool_del(opts, BLOCK_OPT_COMPAT6, false)) {
-        flags |= BLOCK_FLAG_COMPAT6;
-    }
+    hw_version = qemu_opt_get_del(opts, BLOCK_OPT_HWVERSION);
+
     fmt = qemu_opt_get_del(opts, BLOCK_OPT_SUBFMT);
     if (qemu_opt_get_bool_del(opts, BLOCK_OPT_ZEROED_GRAIN, false)) {
         zeroed_grain = true;
@@ -2001,7 +2000,7 @@ static int vmdk_create(const char *filename, QemuOpts *opts, Error **errp)
                            fmt,
                            parent_desc_line,
                            ext_desc_lines->str,
-                           (flags & BLOCK_FLAG_COMPAT6 ? 6 : 4),
+                           hw_version,
                            total_size /
                                (int64_t)(63 * number_heads * BDRV_SECTOR_SIZE),
                            number_heads,
@@ -2047,6 +2046,7 @@ exit:
     }
     g_free(adapter_type);
     g_free(backing_file);
+    g_free(hw_version);
     g_free(fmt);
     g_free(desc);
     g_free(path);
@@ -2292,10 +2292,10 @@ static QemuOptsList vmdk_create_opts = {
             .help = "File name of a base image"
         },

block/vmdk.c static QemuOptsList vmdk_create_opts = { · line 2299

Quoted 10 lines
block/vmdk.c +4 -4
         {
-            .name = BLOCK_OPT_COMPAT6,
-            .type = QEMU_OPT_BOOL,
-            .help = "VMDK version 6 image",
-            .def_value_str = "off"
+            .name = BLOCK_OPT_HWVERSION,
+            .type = QEMU_OPT_STRING,
+            .help = "VMDK hardware version",
+            .def_value_str = "4"
         },

For backward compatibility reason, we shouldn't remove a pre-existing option without solid justification and probably a grace period. I suggest adding the hwversion option in addition, and document and check it as exclusive with the compat6 flag.

Fam

Quoted 39 lines
block/vmdk.c +0 -0
         {
             .name = BLOCK_OPT_SUBFMT,
include/block/block_int.h +1 -2
index 10d8759..0852316 100644
@@ -38,12 +38,11 @@
 #include "qemu/throttle.h"
 
 #define BLOCK_FLAG_ENCRYPT          1
-#define BLOCK_FLAG_COMPAT6          4
 #define BLOCK_FLAG_LAZY_REFCOUNTS   8
 
 #define BLOCK_OPT_SIZE              "size"
 #define BLOCK_OPT_ENCRYPT           "encryption"
-#define BLOCK_OPT_COMPAT6           "compat6"
+#define BLOCK_OPT_HWVERSION         "hwversion"
 #define BLOCK_OPT_BACKING_FILE      "backing_file"
 #define BLOCK_OPT_BACKING_FMT       "backing_fmt"
 #define BLOCK_OPT_CLUSTER_SIZE      "cluster_size"
qemu-doc.texi +2 -2
index 79141d3..79f4168 100644
@@ -691,8 +691,8 @@ Supported options:
 @table @code
 @item backing_file
 File name of a base image (see @option{create} subcommand).
-@item compat6
-Create a VMDK version 6 image (instead of version 4)
+@item hwversion
+Specify vmdk hardware version (default 4)
 @item subformat
 Specifies which VMDK subformat to use. Valid options are
 @code{monolithicSparse} (default),
Signature · 1 line
1.9.1
#2 lore raw
Quoted 7 lines · Fam Zheng
Quoted 2 lines

Replace hardcoded vmdk description file hardware version flag with a user definable version.

Hi Janne,

Since this is a new feature, please explain why this change is desired (i.e. the necessity.)

See here what it controls for vmware:

https://kb.vmware.com/selfservice/microsites/search.do?languag
e=en_US&cmd=displayKC&externalId=1003746

Seems that the vmware cluster I'm using is configured to eat vmdks with only certain virtual hardware versions specified as being supported, so this patch allows me to define that version. Besides that, I've read that to mean that it's a hint from me (as the vmdk author) to the cluster that this is the vmware virtual hardware version I have tested this vmdk to run with. It's actually relatively useful metadata as such.

In other words, without the patch not a single qemu-img generated vmdk is 'good' for the system I'm using.

--
Janne

#3 lore raw
Quoted 23 lines · Janne Karhunen
Quoted 7 lines · Fam Zheng
Quoted 2 lines

Replace hardcoded vmdk description file hardware version flag with a user definable version.

Hi Janne,

Since this is a new feature, please explain why this change is desired (i.e. the necessity.)

See here what it controls for vmware:

https://kb.vmware.com/selfservice/microsites/search.do?languag
e=en_US&cmd=displayKC&externalId=1003746

Seems that the vmware cluster I'm using is configured to eat vmdks with only certain virtual hardware versions specified as being supported, so this patch allows me to define that version. Besides that, I've read that to mean that it's a hint from me (as the vmdk author) to the cluster that this is the vmware virtual hardware version I have tested this vmdk to run with. It's actually relatively useful metadata as such.

Quoted 2 lines

In other words, without the patch not a single qemu-img generated vmdk is 'good' for the system I'm using.

Thanks for the explanation, please add this information into the commit message in next submission and also fix the option code so I can ack your patch.

Fam

#4 lore raw
Quoted 5 lines · Fam Zheng
Quoted 2 lines

In other words, without the patch not a single qemu-img generated vmdk is 'good' for the system I'm using.

Thanks for the explanation, please add this information into the commit message in next submission and also fix the option code so I can ack your patch.

Ack, will do. Thanks

Signature · 1 line
Janne
#5 lore raw
In reply to Fam Zheng
Quoted 4 lines · Fam Zheng

For backward compatibility reason, we shouldn't remove a pre-existing option without solid justification and probably a grace period. I suggest adding the hwversion option in addition, and document and check it as exclusive with the compat6 flag.

That's certainly doable and kind of makes sense, but I'm not entirely sure that compat6 flag makes any sense to begin with. Does it?

--
Janne

#6 lore raw
Quoted 9 lines · Janne Karhunen
Quoted 4 lines · Fam Zheng

For backward compatibility reason, we shouldn't remove a pre-existing option without solid justification and probably a grace period. I suggest adding the hwversion option in addition, and document and check it as exclusive with the compat6 flag.

That's certainly doable and kind of makes sense, but I'm not entirely sure that compat6 flag makes any sense to begin with. Does it?

I don't know VMware products well enough to tell, but it has been available since forever, therefore my suggestion is to just keep it which cannot hurt.

If we really want to get rid of it, we should start printing a warning message to indicate using the flag is deprecated and remove it one or a few releases later. IMO it's not really worth the effort.

Fam

#7 lore raw
Quoted 5 lines · Fam Zheng
Quoted 2 lines

That's certainly doable and kind of makes sense, but I'm not entirely sure that compat6 flag makes any sense to begin with. Does it?

I don't know VMware products well enough to tell, but it has been available since forever, therefore my suggestion is to just keep it which cannot hurt.

I sent the new patch yesterday with this option still present and it works the same as it always has. I also tested it to work on all option pairings, so it should be good to go AFAIK. Hope you have some time to check that.

Signature · 1 line
Janne
#8 lore raw
Quoted 5 lines · Janne Karhunen
Quoted 3 lines · Fam Zheng
Quoted 2 lines

That's certainly doable and kind of makes sense, but I'm not entirely sure that compat6 flag makes any sense to begin with. Does it?

Quoted 7 lines
Quoted 2 lines

I don't know VMware products well enough to tell, but it has been available since forever, therefore my suggestion is to just keep it which cannot hurt.

I sent the new patch yesterday with this option still present and it works the same as it always has. I also tested it to work on all option pairings, so it should be good to go AFAIK. Hope you have some time to check that.

Thanks for letting me know! I'll take a look soon. (Patches without correctly Cc'ing maintainers are very easy to get neglected. Please remember to use ./scripts/get_maintainer.pl (or ./MAINTAINERS) next time.)

Fam