mirror of
https://github.com/libvirt/libvirt.git
synced 2026-10-02 12:20:06 -05:00
vmx: Add support for NVRAM configuration
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>
This commit is contained in:
1 parent
29432312be
commit
deb4d83e7b
25 files changed
+53
No files matched your search
@@ -454,6 +454,9 @@
|
||||
<group>
|
||||
<ref name="diskSource"/>
|
||||
</group>
|
||||
<group>
|
||||
<ref name="vmwarePath"/>
|
||||
</group>
|
||||
</choice>
|
||||
</optional>
|
||||
</element>
|
||||
|
||||
@@ -1416,6 +1416,7 @@ virVMXParseConfig(virVMXContext *ctx,
|
||||
long long coresPerSocket = 0;
|
||||
virCPUDef *cpu = NULL;
|
||||
char *firmware = NULL;
|
||||
g_autofree char *nvram = NULL;
|
||||
size_t saved_ndisks = 0;
|
||||
|
||||
if (ctx->parseFileName == NULL) {
|
||||
@@ -2032,6 +2033,22 @@ virVMXParseConfig(virVMXContext *ctx,
|
||||
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;
|
||||
@@ -3802,6 +3819,16 @@ virVMXFormatConfig(virVMXContext *ctx, virDomainXMLOption *xmlopt, virDomainDef
|
||||
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");
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
</cputune>
|
||||
<os>
|
||||
<type arch='i686'>hvm</type>
|
||||
<nvram>[datastore] directory/FEDORA11.NVRAM</nvram>
|
||||
</os>
|
||||
<clock offset='utc'/>
|
||||
<on_poweroff>destroy</on_poweroff>
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
</cputune>
|
||||
<os>
|
||||
<type arch='i686'>hvm</type>
|
||||
<nvram>[datastore] directory/fedora11.nvram</nvram>
|
||||
</os>
|
||||
<clock offset='utc'/>
|
||||
<on_poweroff>destroy</on_poweroff>
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
</cputune>
|
||||
<os>
|
||||
<type arch='i686'>hvm</type>
|
||||
<nvram>[datastore] directory/Fedora11.nvram</nvram>
|
||||
</os>
|
||||
<clock offset='utc'/>
|
||||
<on_poweroff>destroy</on_poweroff>
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
</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'/>
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
</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>
|
||||
|
||||
@@ -13,6 +13,7 @@
|
||||
<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>
|
||||
|
||||
@@ -23,6 +23,7 @@ package:20.6.2
|
||||
</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>
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
<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>
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
</cputune>
|
||||
<os>
|
||||
<type arch='x86_64'>hvm</type>
|
||||
<nvram>[datastore] directory/dokuwiki.nvram</nvram>
|
||||
</os>
|
||||
<clock offset='utc'/>
|
||||
<on_poweroff>destroy</on_poweroff>
|
||||
|
||||
@@ -13,6 +13,7 @@
|
||||
<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>
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
</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>
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
<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>
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
<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>
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
</cputune>
|
||||
<os>
|
||||
<type arch='i686'>hvm</type>
|
||||
<nvram>[datastore] directory/virtMonServ1.nvram</nvram>
|
||||
</os>
|
||||
<clock offset='utc'/>
|
||||
<on_poweroff>destroy</on_poweroff>
|
||||
|
||||
@@ -13,6 +13,7 @@
|
||||
</cputune>
|
||||
<os>
|
||||
<type arch='x86_64'>hvm</type>
|
||||
<nvram>[datastore] directory/vmtest.nvram</nvram>
|
||||
</os>
|
||||
<clock offset='utc'/>
|
||||
<on_poweroff>destroy</on_poweroff>
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
<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>
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
<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>
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
</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'/>
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
</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'/>
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
<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>
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
<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>
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
<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>
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
<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>
|
||||
|
||||
Reference in new issue
Block a user