[libvirt] [PATCH 0/3] vmx: add efi firmware attribute

Use the recently added infrastructure for firmware autoselection, and indicate which firmware is used by a VMware guest. Pino Toscano (3): vmx: convert firmware config for autoselection vmx: write firmware back from autoselection docs: document firmware attribute for VMware guests docs/formatdomain.html.in | 5 ++++- src/vmx/vmx.c | 20 ++++++++++++++++++++ tests/vmx2xmldata/vmx2xml-firmware-efi.vmx | 3 +++ tests/vmx2xmldata/vmx2xml-firmware-efi.xml | 18 ++++++++++++++++++ tests/vmx2xmltest.c | 2 ++ tests/xml2vmxdata/xml2vmx-firmware-efi.vmx | 11 +++++++++++ tests/xml2vmxdata/xml2vmx-firmware-efi.xml | 8 ++++++++ tests/xml2vmxtest.c | 2 ++ 8 files changed, 68 insertions(+), 1 deletion(-) create mode 100644 tests/vmx2xmldata/vmx2xml-firmware-efi.vmx create mode 100644 tests/vmx2xmldata/vmx2xml-firmware-efi.xml create mode 100644 tests/xml2vmxdata/xml2vmx-firmware-efi.vmx create mode 100644 tests/xml2vmxdata/xml2vmx-firmware-efi.xml -- 2.20.1

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@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

When writing the VMX file from the domain XML, write the firmware key according to the firmware autoselection. Though, at the moment only 'efi' is supported. Signed-off-by: Pino Toscano <ptoscano@redhat.com> --- src/vmx/vmx.c | 4 ++++ tests/xml2vmxdata/xml2vmx-firmware-efi.vmx | 11 +++++++++++ tests/xml2vmxdata/xml2vmx-firmware-efi.xml | 8 ++++++++ tests/xml2vmxtest.c | 2 ++ 4 files changed, 25 insertions(+) create mode 100644 tests/xml2vmxdata/xml2vmx-firmware-efi.vmx create mode 100644 tests/xml2vmxdata/xml2vmx-firmware-efi.xml diff --git a/src/vmx/vmx.c b/src/vmx/vmx.c index 3842991bab..f5d7bffb57 100644 --- a/src/vmx/vmx.c +++ b/src/vmx/vmx.c @@ -3408,6 +3408,10 @@ virVMXFormatConfig(virVMXContext *ctx, virDomainXMLOptionPtr xmlopt, virDomainDe goto cleanup; } + /* vmx:firmware */ + if (def->os.firmware == VIR_DOMAIN_OS_DEF_FIRMWARE_EFI) + virBufferAddLit(&buffer, "firmware = \"efi\"\n"); + if (virtualHW_version >= 7) { if (hasSCSI) { virBufferAddLit(&buffer, "pciBridge0.present = \"true\"\n"); diff --git a/tests/xml2vmxdata/xml2vmx-firmware-efi.vmx b/tests/xml2vmxdata/xml2vmx-firmware-efi.vmx new file mode 100644 index 0000000000..cc3ec9f34b --- /dev/null +++ b/tests/xml2vmxdata/xml2vmx-firmware-efi.vmx @@ -0,0 +1,11 @@ +.encoding = "UTF-8" +config.version = "8" +virtualHW.version = "4" +guestOS = "other" +uuid.bios = "56 4d 9b ef ac d9 b4 e0-c8 f0 ae a8 b9 10 35 15" +displayName = "firmware-efi" +memsize = "4" +numvcpus = "1" +floppy0.present = "false" +floppy1.present = "false" +firmware = "efi" diff --git a/tests/xml2vmxdata/xml2vmx-firmware-efi.xml b/tests/xml2vmxdata/xml2vmx-firmware-efi.xml new file mode 100644 index 0000000000..b91735ab63 --- /dev/null +++ b/tests/xml2vmxdata/xml2vmx-firmware-efi.xml @@ -0,0 +1,8 @@ +<domain type='vmware'> + <name>firmware-efi</name> + <uuid>564d9bef-acd9-b4e0-c8f0-aea8b9103515</uuid> + <memory unit='KiB'>4096</memory> + <os firmware='efi'> + <type>hvm</type> + </os> +</domain> diff --git a/tests/xml2vmxtest.c b/tests/xml2vmxtest.c index 0143c05b19..5d5dc0a518 100644 --- a/tests/xml2vmxtest.c +++ b/tests/xml2vmxtest.c @@ -295,6 +295,8 @@ mymain(void) DO_TEST("svga", "svga", 4); + DO_TEST("firmware-efi", "firmware-efi", 4); + DO_TEST("datacenterpath", "datacenterpath", 4); virObjectUnref(caps); -- 2.20.1

Signed-off-by: Pino Toscano <ptoscano@redhat.com> --- docs/formatdomain.html.in | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in index 0e3799061d..3d84ae0fcb 100644 --- a/docs/formatdomain.html.in +++ b/docs/formatdomain.html.in @@ -159,7 +159,10 @@ For more information refer to firmware metadata specification as described in <code>docs/interop/firmware.json</code> in QEMU repository. Regular users do not need to bother. - <span class="since">Since 5.2.0 (QEMU and KVM only)</span> + <span class="since">Since 5.2.0 (QEMU and KVM only)</span><br/> + For VMware guests, this is set to <code>efi</code> when the guest + uses UEFI, and it is not set when using BIOS. + <span class="since">Since 5.3.0 (VMware ESX and Workstation/Player)</span> </dd> <dt><code>type</code></dt> <dd>The content of the <code>type</code> element specifies the -- 2.20.1

On 4/9/19 10:04 AM, Pino Toscano wrote:
Use the recently added infrastructure for firmware autoselection, and indicate which firmware is used by a VMware guest.
Pino Toscano (3): vmx: convert firmware config for autoselection vmx: write firmware back from autoselection docs: document firmware attribute for VMware guests
docs/formatdomain.html.in | 5 ++++- src/vmx/vmx.c | 20 ++++++++++++++++++++ tests/vmx2xmldata/vmx2xml-firmware-efi.vmx | 3 +++ tests/vmx2xmldata/vmx2xml-firmware-efi.xml | 18 ++++++++++++++++++ tests/vmx2xmltest.c | 2 ++ tests/xml2vmxdata/xml2vmx-firmware-efi.vmx | 11 +++++++++++ tests/xml2vmxdata/xml2vmx-firmware-efi.xml | 8 ++++++++ tests/xml2vmxtest.c | 2 ++ 8 files changed, 68 insertions(+), 1 deletion(-) create mode 100644 tests/vmx2xmldata/vmx2xml-firmware-efi.vmx create mode 100644 tests/vmx2xmldata/vmx2xml-firmware-efi.xml create mode 100644 tests/xml2vmxdata/xml2vmx-firmware-efi.vmx create mode 100644 tests/xml2vmxdata/xml2vmx-firmware-efi.xml
Reviewed-by: Cole Robinson <crobinso@redhat.com> And pushed - Cole
participants (2)
-
Cole Robinson
-
Pino Toscano