[libvirt] [PATCH 1/3] vmx: convert firmware config for autoselection

Pino Toscano ptoscano at redhat.com
Tue Apr 9 14:04:31 UTC 2019


Convert the firmware key to a type of autoselected firmware.

Only the 'efi' firmware is allowed for now, in case the key is present.
It seems VMware (at least ESXi) does not write the key in VMX files when
setting BIOS as firmware.

Signed-off-by: Pino Toscano <ptoscano at redhat.com>
---
 src/vmx/vmx.c                              | 16 ++++++++++++++++
 tests/vmx2xmldata/vmx2xml-firmware-efi.vmx |  3 +++
 tests/vmx2xmldata/vmx2xml-firmware-efi.xml | 18 ++++++++++++++++++
 tests/vmx2xmltest.c                        |  2 ++
 4 files changed, 39 insertions(+)
 create mode 100644 tests/vmx2xmldata/vmx2xml-firmware-efi.vmx
 create mode 100644 tests/vmx2xmldata/vmx2xml-firmware-efi.xml

diff --git a/src/vmx/vmx.c b/src/vmx/vmx.c
index ae9ee87be3..3842991bab 100644
--- a/src/vmx/vmx.c
+++ b/src/vmx/vmx.c
@@ -1304,6 +1304,7 @@ virVMXParseConfig(virVMXContext *ctx,
     struct virVMXConfigScanResults results = { -1 };
     long long coresPerSocket = 0;
     virCPUDefPtr cpu = NULL;
+    char *firmware = NULL;
 
     if (ctx->parseFileName == NULL) {
         virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
@@ -1826,6 +1827,21 @@ virVMXParseConfig(virVMXContext *ctx,
         def->namespaceData = nsdata;
     }
 
+    /* vmx:firmware */
+    if (virVMXGetConfigString(conf, "firmware", &firmware, true) < 0)
+        goto cleanup;
+
+    if (firmware != NULL) {
+        if (STREQ(firmware, "efi")) {
+            def->os.firmware = VIR_DOMAIN_OS_DEF_FIRMWARE_EFI;
+        } else {
+            virReportError(VIR_ERR_INTERNAL_ERROR,
+                           _("VMX entry 'firmware' has unknown value '%s'"),
+                           firmware);
+            goto cleanup;
+        }
+    }
+
     if (virDomainDefPostParse(def, caps, VIR_DOMAIN_DEF_PARSE_ABI_UPDATE,
                               xmlopt, NULL) < 0)
         goto cleanup;
diff --git a/tests/vmx2xmldata/vmx2xml-firmware-efi.vmx b/tests/vmx2xmldata/vmx2xml-firmware-efi.vmx
new file mode 100644
index 0000000000..dbb215a5db
--- /dev/null
+++ b/tests/vmx2xmldata/vmx2xml-firmware-efi.vmx
@@ -0,0 +1,3 @@
+config.version = "8"
+virtualHW.version = "13"
+firmware = "efi"
diff --git a/tests/vmx2xmldata/vmx2xml-firmware-efi.xml b/tests/vmx2xmldata/vmx2xml-firmware-efi.xml
new file mode 100644
index 0000000000..e21158cebf
--- /dev/null
+++ b/tests/vmx2xmldata/vmx2xml-firmware-efi.xml
@@ -0,0 +1,18 @@
+<domain type='vmware'>
+  <uuid>00000000-0000-0000-0000-000000000000</uuid>
+  <memory unit='KiB'>32768</memory>
+  <currentMemory unit='KiB'>32768</currentMemory>
+  <vcpu placement='static'>1</vcpu>
+  <os firmware='efi'>
+    <type arch='i686'>hvm</type>
+  </os>
+  <clock offset='utc'/>
+  <on_poweroff>destroy</on_poweroff>
+  <on_reboot>restart</on_reboot>
+  <on_crash>destroy</on_crash>
+  <devices>
+    <video>
+      <model type='vmvga' vram='4096' primary='yes'/>
+    </video>
+  </devices>
+</domain>
diff --git a/tests/vmx2xmltest.c b/tests/vmx2xmltest.c
index b70e8191d1..d7d03f1753 100644
--- a/tests/vmx2xmltest.c
+++ b/tests/vmx2xmltest.c
@@ -285,6 +285,8 @@ mymain(void)
 
     DO_TEST("svga", "svga");
 
+    DO_TEST("firmware-efi", "firmware-efi");
+
     ctx.datacenterPath = "folder1/folder2/datacenter1";
 
     DO_TEST("datacenterpath", "datacenterpath");
-- 
2.20.1




More information about the libvir-list mailing list