]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
vmx: convert firmware config for autoselection
authorPino Toscano <ptoscano@redhat.com>
Tue, 9 Apr 2019 14:04:31 +0000 (16:04 +0200)
committerCole Robinson <crobinso@redhat.com>
Tue, 16 Apr 2019 00:03:55 +0000 (20:03 -0400)
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.

Reviewed-by: Cole Robinson <crobinso@redhat.com>
Signed-off-by: Pino Toscano <ptoscano@redhat.com>
src/vmx/vmx.c
tests/vmx2xmldata/vmx2xml-firmware-efi.vmx [new file with mode: 0644]
tests/vmx2xmldata/vmx2xml-firmware-efi.xml [new file with mode: 0644]
tests/vmx2xmltest.c

index cf2d4df9450661553cf9890951c635e94f26b330..2d7e827d2dc1deddb552ed0e56d8c9c7bcfc3a11 100644 (file)
@@ -1305,6 +1305,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",
@@ -1827,6 +1828,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 (file)
index 0000000..dbb215a
--- /dev/null
@@ -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 (file)
index 0000000..e21158c
--- /dev/null
@@ -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>
index b70e8191d117eb3975a97b79feef1e1c0fc75c81..d7d03f1753b4e99945b11ce7824c1412c3a5b7b4 100644 (file)
@@ -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");