Blob Blame History Raw
From c8cdce47bc38d2f59ecc4b75d6db7f032b63d527 Mon Sep 17 00:00:00 2001
From: "Richard W.M. Jones" <rjones@redhat.com>
Date: Tue, 18 Jan 2022 20:49:21 +0000
Subject: [PATCH] vddk: Allow create-hwversion to be specified as a number

This gives us a bit of future-proofing so we don't always need to add
new hardware versions immediately.  Another reason for this is that
VDDK allows you to specify seemingly any number here without
complaint.

Updates: commit a39d5773afc3ebab7e5768118a2bccb89a654585
(cherry picked from commit 071e32927237c2c00d78684c8a0f2e5fbca9963e)
---
 plugins/vddk/nbdkit-vddk-plugin.pod | 8 ++++++--
 plugins/vddk/vddk.c                 | 3 ++-
 2 files changed, 8 insertions(+), 3 deletions(-)

diff --git a/plugins/vddk/nbdkit-vddk-plugin.pod b/plugins/vddk/nbdkit-vddk-plugin.pod
index 6c7ae989..e6972900 100644
--- a/plugins/vddk/nbdkit-vddk-plugin.pod
+++ b/plugins/vddk/nbdkit-vddk-plugin.pod
@@ -195,10 +195,14 @@ Specify the VMDK disk adapter type.  The default is C<scsi-buslogic>.
 
 =item B<create-hwversion=esx65>
 
+=item B<create-hwversion=>N
+
 (nbdkit E<ge> 1.30)
 
-Specify the VMDK virtual hardware version.  The default is
-C<workstation5>.
+Specify the VMDK virtual hardware version.  You can give either the
+named version or the equivalent 16 bit number.
+
+The default is C<workstation5> (N = 4).
 
 =item B<create-size=>SIZE
 
diff --git a/plugins/vddk/vddk.c b/plugins/vddk/vddk.c
index 5ebf9a2c..bab8de6f 100644
--- a/plugins/vddk/vddk.c
+++ b/plugins/vddk/vddk.c
@@ -192,7 +192,8 @@ vddk_config (const char *key, const char *value)
       create_hwversion = VIXDISKLIB_HWVERSION_ESX60;
     else if (strcmp (value, "esx65") == 0)
       create_hwversion = VIXDISKLIB_HWVERSION_ESX65;
-    else {
+    else if (nbdkit_parse_uint16_t ("create-hwversion", value,
+                                    &create_hwversion) == -1) {
       nbdkit_error ("unknown create-hwversion: %s", value);
       return -1;
     }
-- 
2.31.1