vmx: convert firmware config for autoselection

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>
This commit is contained in:
Pino Toscano 2019-04-09 16:04:31 +02:00 committed by Cole Robinson
parent fc79e73836
commit 9bb6e4e739
4 changed files with 39 additions and 0 deletions

View 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;

View File

@ -0,0 +1,3 @@
config.version = "8"
virtualHW.version = "13"
firmware = "efi"

View File

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

View 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");