Some VMware guests specify NVRAM storage using the 'nvram' parameter.
If found, parse it and store it in the domain's os.loader.nvram field,
which gets formatted as:
<os>
<type arch='x86_64'>hvm</type>
<nvram>[datastore] directory/dokuwiki.nvram</nvram>
</os>
The NVRAM path uses the same transformation functions as disk paths
(ctx->parseFileName and ctx->formatFileName) to ensure consistent
handling of datastore-qualified paths.
The NVRAM is stored as a virStorageSource with type VIR_STORAGE_TYPE_FILE
to ensure compatibility with libvirt's existing firmware handling
infrastructure.
Signed-off-by: Surya Gupta <surygupt@redhat.com>
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
<group>
<ref name="diskSource"/>
</group>
+ <group>
+ <ref name="vmwarePath"/>
+ </group>
</choice>
</optional>
</element>
long long coresPerSocket = 0;
virCPUDef *cpu = NULL;
char *firmware = NULL;
+ g_autofree char *nvram = NULL;
size_t saved_ndisks = 0;
if (ctx->parseFileName == NULL) {
VIR_TRISTATE_BOOL_YES;
}
+ /* vmx:nvram */
+ if (virVMXGetConfigString(conf, "nvram", &nvram, true) < 0) {
+ goto cleanup;
+ }
+
+ if (nvram != NULL) {
+ g_autoptr(virStorageSource) n = virStorageSourceNew();
+
+ def->os.loader = virDomainLoaderDefNew();
+
+ n->type = VIR_STORAGE_TYPE_FILE;
+ if (ctx->parseFileName(nvram, ctx->opaque, &(n->path), false) < 0)
+ goto cleanup;
+ def->os.loader->nvram = g_steal_pointer(&n);
+ }
+
if (virDomainDefPostParse(def, VIR_DOMAIN_DEF_PARSE_ABI_UPDATE,
xmlopt, NULL) < 0)
goto cleanup;
if (def->os.firmware == VIR_DOMAIN_OS_DEF_FIRMWARE_EFI)
virBufferAddLit(&buffer, "firmware = \"efi\"\n");
+ /* vmx:nvram */
+ if (def->os.loader && def->os.loader->nvram && def->os.loader->nvram->path) {
+ g_autofree char *nvramPath = NULL;
+
+ nvramPath = ctx->formatFileName(def->os.loader->nvram->path, ctx->opaque);
+ if (nvramPath != NULL) {
+ virBufferAsprintf(&buffer, "nvram = \"%s\"\n", nvramPath);
+ }
+ }
+
if (virtualHW_version >= 7) {
if (hasSCSI) {
virBufferAddLit(&buffer, "pciBridge0.present = \"true\"\n");
</cputune>
<os>
<type arch='i686'>hvm</type>
+ <nvram>[datastore] directory/FEDORA11.NVRAM</nvram>
</os>
<clock offset='utc'/>
<on_poweroff>destroy</on_poweroff>
</cputune>
<os>
<type arch='i686'>hvm</type>
+ <nvram>[datastore] directory/fedora11.nvram</nvram>
</os>
<clock offset='utc'/>
<on_poweroff>destroy</on_poweroff>
</cputune>
<os>
<type arch='i686'>hvm</type>
+ <nvram>[datastore] directory/Fedora11.nvram</nvram>
</os>
<clock offset='utc'/>
<on_poweroff>destroy</on_poweroff>
</cputune>
<os>
<type arch='x86_64'>hvm</type>
+ <nvram>[datastore] directory/windows2019biosvmware.nvram</nvram>
</os>
<cpu>
<topology sockets='1' dies='1' clusters='1' cores='2' threads='1'/>
</cputune>
<os>
<type arch='x86_64'>hvm</type>
+ <nvram>[datastore] directory/esx6.7-rhel7.7-x86_64.nvram</nvram>
</os>
<clock offset='utc'/>
<on_poweroff>destroy</on_poweroff>
<feature enabled='yes' name='enrolled-keys'/>
<feature enabled='yes' name='secure-boot'/>
</firmware>
+ <nvram>[datastore] directory/Auto-esx8.0-rhell9.3-efi-with-empty-cdrom.nvram</nvram>
</os>
<clock offset='utc'/>
<on_poweroff>destroy</on_poweroff>
</cputune>
<os>
<type arch='x86_64'>hvm</type>
+ <nvram>[datastore] directory/Test-Mig-VM-1 (01ce57d0-4e20-41a5-8b6c-bcbf49a032ec).nvram</nvram>
</os>
<clock offset='utc'/>
<on_poweroff>destroy</on_poweroff>
<vcpu placement='static'>12</vcpu>
<os>
<type arch='x86_64'>hvm</type>
+ <nvram>[datastore] directory/wild14.nvram</nvram>
</os>
<clock offset='utc'/>
<on_poweroff>destroy</on_poweroff>
</cputune>
<os>
<type arch='x86_64'>hvm</type>
+ <nvram>[datastore] directory/dokuwiki.nvram</nvram>
</os>
<clock offset='utc'/>
<on_poweroff>destroy</on_poweroff>
<feature enabled='yes' name='enrolled-keys'/>
<feature enabled='yes' name='secure-boot'/>
</firmware>
+ <nvram>[datastore] directory/Auto-esx8.0-rhel9.4-efi-nvme-disk.nvram</nvram>
</os>
<clock offset='utc'/>
<on_poweroff>destroy</on_poweroff>
</cputune>
<os>
<type arch='x86_64'>hvm</type>
+ <nvram>[datastore] directory/esx8.0-win11-with-second-disk-in-subfolder.nvram</nvram>
</os>
<clock offset='utc'/>
<on_poweroff>destroy</on_poweroff>
<vcpu placement='static' cpuset='0-2,5-7'>4</vcpu>
<os>
<type arch='x86_64'>hvm</type>
+ <nvram>[datastore] directory/Debian1.nvram</nvram>
</os>
<clock offset='utc'/>
<on_poweroff>destroy</on_poweroff>
<vcpu placement='static' cpuset='0,3-5'>2</vcpu>
<os>
<type arch='x86_64'>hvm</type>
+ <nvram>[datastore] directory/Debian2.nvram</nvram>
</os>
<clock offset='utc'/>
<on_poweroff>destroy</on_poweroff>
</cputune>
<os>
<type arch='i686'>hvm</type>
+ <nvram>[datastore] directory/virtMonServ1.nvram</nvram>
</os>
<clock offset='utc'/>
<on_poweroff>destroy</on_poweroff>
</cputune>
<os>
<type arch='x86_64'>hvm</type>
+ <nvram>[datastore] directory/vmtest.nvram</nvram>
</os>
<clock offset='utc'/>
<on_poweroff>destroy</on_poweroff>
<vcpu placement='static'>1</vcpu>
<os>
<type arch='x86_64'>hvm</type>
+ <nvram>[datastore] directory/el6-test.nvram</nvram>
</os>
<clock offset='utc'/>
<on_poweroff>destroy</on_poweroff>
<vcpu placement='static'>1</vcpu>
<os>
<type arch='x86_64'>hvm</type>
+ <nvram>[datastore] directory/esx-rhel6-mini.nvram</nvram>
</os>
<clock offset='utc'/>
<on_poweroff>destroy</on_poweroff>
</cputune>
<os>
<type arch='x86_64'>hvm</type>
+ <nvram>[datastore] directory/RHEL7_6.nvram</nvram>
</os>
<cpu>
<topology sockets='4' dies='1' clusters='1' cores='2' threads='1'/>
</cputune>
<os>
<type arch='x86_64'>hvm</type>
+ <nvram>[datastore] directory/v2v-windows-kkulkarn.nvram</nvram>
</os>
<cpu>
<topology sockets='4' dies='1' clusters='1' cores='4' threads='1'/>
<vcpu placement='static'>1</vcpu>
<os>
<type arch='i686'>hvm</type>
+ <nvram>[datastore] directory/Debian-System1.nvram</nvram>
</os>
<clock offset='utc'/>
<on_poweroff>destroy</on_poweroff>
<vcpu placement='static'>1</vcpu>
<os>
<type arch='i686'>hvm</type>
+ <nvram>[datastore] directory/Server2.nvram</nvram>
</os>
<clock offset='utc'/>
<on_poweroff>destroy</on_poweroff>
<vcpu placement='static'>1</vcpu>
<os>
<type arch='i686'>hvm</type>
+ <nvram>[datastore] directory/Debian-System3.nvram</nvram>
</os>
<clock offset='utc'/>
<on_poweroff>destroy</on_poweroff>
<vcpu placement='static'>1</vcpu>
<os>
<type arch='i686'>hvm</type>
+ <nvram>[datastore] directory/Debian-System4.nvram</nvram>
</os>
<clock offset='utc'/>
<on_poweroff>destroy</on_poweroff>