- libxl: Support custom firmware paths

bf3be5b7-libxl-Support-custom-firmware-path.patch,
  705525cb-libxl-Support-custom-firmware-path-conversion.patch
  bsc#1209161
- spec: Move ovmf dependency to correct package

OBS-URL: https://build.opensuse.org/package/show/Virtualization/libvirt?expand=0&rev=972
This commit is contained in:
James Fehlig 2023-03-10 21:22:41 +00:00 committed by Git OBS Bridge
parent 997b4043d9
commit f5adb7d85c
8 changed files with 320 additions and 16 deletions

View File

@ -0,0 +1,87 @@
From a4bec048bc68b2eeac0f3157a9b946b404f1cea1 Mon Sep 17 00:00:00 2001
From: Jim Fehlig <jfehlig@suse.com>
Date: Mon, 13 Feb 2023 14:30:31 -0700
Subject: [PATCH 2/2] libxl: Add support for custom firmware path in config
converter
Signed-off-by: Jim Fehlig <jfehlig@suse.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
(cherry picked from commit 705525cbec0b2551d54a04d22b5605b04e0343c0)
References: bsc#1209161
---
src/libxl/xen_xl.c | 19 ++++++++++++++-----
tests/xlconfigdata/test-fullvirt-ovmf.cfg | 1 +
tests/xlconfigdata/test-fullvirt-ovmf.xml | 2 +-
3 files changed, 16 insertions(+), 6 deletions(-)
Index: libvirt-9.1.0/src/libxl/xen_xl.c
===================================================================
--- libvirt-9.1.0.orig/src/libxl/xen_xl.c
+++ libvirt-9.1.0/src/libxl/xen_xl.c
@@ -104,18 +104,23 @@ xenParseXLOS(virConf *conf, virDomainDef
if (def->os.type == VIR_DOMAIN_OSTYPE_HVM) {
g_autofree char *bios = NULL;
+ g_autofree char *bios_path = NULL;
g_autofree char *boot = NULL;
int val = 0;
if (xenConfigGetString(conf, "bios", &bios, NULL) < 0)
return -1;
+ if (xenConfigGetString(conf, "bios_path_override", &bios_path, NULL) < 0)
+ return -1;
if (bios && STREQ(bios, "ovmf")) {
def->os.loader = g_new0(virDomainLoaderDef, 1);
def->os.loader->type = VIR_DOMAIN_LOADER_TYPE_PFLASH;
def->os.loader->readonly = VIR_TRISTATE_BOOL_YES;
-
- def->os.loader->path = g_strdup(LIBXL_FIRMWARE_DIR "/ovmf.bin");
+ if (bios_path)
+ def->os.loader->path = g_strdup(bios_path);
+ else
+ def->os.loader->path = g_strdup(LIBXL_FIRMWARE_DIR "/ovmf.bin");
} else {
for (i = 0; i < caps->nguests; i++) {
if (caps->guests[i]->ostype == VIR_DOMAIN_OSTYPE_HVM &&
@@ -1119,9 +1124,13 @@ xenFormatXLOS(virConf *conf, virDomainDe
if (xenConfigSetString(conf, "builder", "hvm") < 0)
return -1;
- if (virDomainDefHasOldStyleUEFI(def) &&
- xenConfigSetString(conf, "bios", "ovmf") < 0)
- return -1;
+ if (virDomainDefHasOldStyleUEFI(def)) {
+ if (xenConfigSetString(conf, "bios", "ovmf") < 0)
+ return -1;
+ if (def->os.loader->path &&
+ (xenConfigSetString(conf, "bios_path_override", def->os.loader->path) < 0))
+ return -1;
+ }
if (def->os.slic_table &&
xenConfigSetString(conf, "acpi_firmware", def->os.slic_table) < 0)
Index: libvirt-9.1.0/tests/xlconfigdata/test-fullvirt-ovmf.cfg
===================================================================
--- libvirt-9.1.0.orig/tests/xlconfigdata/test-fullvirt-ovmf.cfg
+++ libvirt-9.1.0/tests/xlconfigdata/test-fullvirt-ovmf.cfg
@@ -22,5 +22,6 @@ parallel = "none"
serial = "none"
builder = "hvm"
bios = "ovmf"
+bios_path_override = "/usr/share/qemu/ovmf-x86_64-xen.bin"
boot = "d"
disk = [ "format=raw,vdev=hda,access=rw,backendtype=phy,target=/dev/HostVG/XenGuest2", "format=qcow2,vdev=hdb,access=rw,backendtype=qdisk,target=/var/lib/libvirt/images/XenGuest2-home", "format=raw,vdev=hdc,access=ro,backendtype=qdisk,devtype=cdrom,target=/root/boot.iso" ]
Index: libvirt-9.1.0/tests/xlconfigdata/test-fullvirt-ovmf.xml
===================================================================
--- libvirt-9.1.0.orig/tests/xlconfigdata/test-fullvirt-ovmf.xml
+++ libvirt-9.1.0/tests/xlconfigdata/test-fullvirt-ovmf.xml
@@ -6,7 +6,7 @@
<vcpu placement='static'>1</vcpu>
<os>
<type arch='x86_64' machine='xenfv'>hvm</type>
- <loader readonly='yes' type='pflash'>/LIBXL_FIRMWARE_DIR/ovmf.bin</loader>
+ <loader readonly='yes' type='pflash'>/usr/share/qemu/ovmf-x86_64-xen.bin</loader>
<boot dev='cdrom'/>
</os>
<features>

View File

@ -0,0 +1,204 @@
From 4bb53ee6b832c4f8f6631ab7508c6bccd7a4241e Mon Sep 17 00:00:00 2001
From: Jim Fehlig <jfehlig@suse.com>
Date: Fri, 10 Feb 2023 14:22:19 -0700
Subject: [PATCH 1/2] libxl: Support specifying a custom firmware path
libxl added support for specifying custom firmware paths long ago. The
functionality exists in all Xen version supported by libvirt. This patch
adds support for user-specified efi firmware paths in the libxl driver.
Signed-off-by: Jim Fehlig <jfehlig@suse.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
(cherry picked from commit bf3be5b76e96f22edfe71738f97c02a01f3b8354)
References: bsc#1209161
---
src/libxl/libxl_conf.c | 14 ++--
tests/libxlxml2domconfigdata/efi-hvm.json | 91 +++++++++++++++++++++++
tests/libxlxml2domconfigdata/efi-hvm.xml | 36 +++++++++
tests/libxlxml2domconfigtest.c | 1 +
4 files changed, 134 insertions(+), 8 deletions(-)
Index: libvirt-9.1.0/src/libxl/libxl_conf.c
===================================================================
--- libvirt-9.1.0.orig/src/libxl/libxl_conf.c
+++ libvirt-9.1.0/src/libxl/libxl_conf.c
@@ -632,14 +632,10 @@ libxlMakeDomBuildInfo(virDomainDef *def,
b_info->ramdisk = g_strdup(def->os.initrd);
/*
- * Currently libxl only allows specifying the type of BIOS.
- * If automatic firmware selection is enabled or the loader
- * type is PFLASH, we assume OVMF and set libxl_bios_type
- * to LIBXL_BIOS_TYPE_OVMF. The path to the OVMF firmware is
- * configured when building Xen using '--with-system-ovmf='. If
- * not specified, LIBXL_FIRMWARE_DIR/ovmf.bin is used. In the
- * future, Xen will support a user-specified firmware path. See
- * https://lists.xenproject.org/archives/html/xen-devel/2016-03/msg01628.html
+ * libxl allows specifying the type of firmware and an optional path.
+ * If the path is not explicitly specified, a default path for the given
+ * firmware type is used. For EFI, it's LIBXL_FIRMWARE_DIR/ovmf.bin.
+ * Currently libxl does not support specifying nvram for EFI firmwares.
*/
if (def->os.firmware == VIR_DOMAIN_OS_DEF_FIRMWARE_EFI) {
if (def->os.loader == NULL)
@@ -651,9 +647,11 @@ libxlMakeDomBuildInfo(virDomainDef *def,
if (def->os.loader->readonly == VIR_TRISTATE_BOOL_ABSENT)
def->os.loader->readonly = VIR_TRISTATE_BOOL_YES;
b_info->u.hvm.bios = LIBXL_BIOS_TYPE_OVMF;
+ b_info->u.hvm.system_firmware = g_strdup(def->os.loader->path);
def->os.firmware = VIR_DOMAIN_OS_DEF_FIRMWARE_NONE;
} else if (virDomainDefHasOldStyleUEFI(def)) {
b_info->u.hvm.bios = LIBXL_BIOS_TYPE_OVMF;
+ b_info->u.hvm.system_firmware = g_strdup(def->os.loader->path);
}
if (def->emulator) {
Index: libvirt-9.1.0/tests/libxlxml2domconfigdata/efi-hvm.json
===================================================================
--- /dev/null
+++ libvirt-9.1.0/tests/libxlxml2domconfigdata/efi-hvm.json
@@ -0,0 +1,91 @@
+{
+ "c_info": {
+ "type": "hvm",
+ "name": "test-hvm",
+ "uuid": "2147d599-9cc6-c0dc-92ab-4064b5446e9b"
+ },
+ "b_info": {
+ "max_vcpus": 4,
+ "avail_vcpus": [
+ 0,
+ 1,
+ 2,
+ 3
+ ],
+ "max_memkb": 1048576,
+ "target_memkb": 1048576,
+ "video_memkb": 8192,
+ "shadow_memkb": 1234,
+ "device_model_version": "qemu_xen",
+ "device_model": "/bin/true",
+ "sched_params": {
+
+ },
+ "apic": "True",
+ "acpi": "True",
+ "type.hvm": {
+ "bios": "ovmf",
+ "pae": "True",
+ "system_firmware": "/usr/share/qemu/ovmf-x86_64-xen.bin",
+ "vga": {
+ "kind": "cirrus"
+ },
+ "vnc": {
+ "enable": "True",
+ "listen": "0.0.0.0",
+ "findunused": "False"
+ },
+ "sdl": {
+ "enable": "False"
+ },
+ "spice": {
+
+ },
+ "boot": "c",
+ "rdm": {
+
+ }
+ },
+ "arch_arm": {
+
+ }
+ },
+ "disks": [
+ {
+ "pdev_path": "/var/lib/xen/images/test-hvm.img",
+ "vdev": "hda",
+ "backend": "qdisk",
+ "format": "raw",
+ "removable": 1,
+ "readwrite": 1
+ }
+ ],
+ "nics": [
+ {
+ "devid": 0,
+ "mac": "00:16:3e:66:12:b4",
+ "bridge": "br0",
+ "script": "/etc/xen/scripts/vif-bridge",
+ "nictype": "vif_ioemu"
+ }
+ ],
+ "vfbs": [
+ {
+ "devid": -1,
+ "vnc": {
+ "enable": "True",
+ "listen": "0.0.0.0",
+ "findunused": "False"
+ },
+ "sdl": {
+ "enable": "False"
+ }
+ }
+ ],
+ "vkbs": [
+ {
+ "devid": -1
+ }
+ ],
+ "on_reboot": "restart"
+}
Index: libvirt-9.1.0/tests/libxlxml2domconfigdata/efi-hvm.xml
===================================================================
--- /dev/null
+++ libvirt-9.1.0/tests/libxlxml2domconfigdata/efi-hvm.xml
@@ -0,0 +1,36 @@
+<domain type='xen'>
+ <name>test-hvm</name>
+ <description>None</description>
+ <uuid>2147d599-9cc6-c0dc-92ab-4064b5446e9b</uuid>
+ <memory>1048576</memory>
+ <currentMemory>1048576</currentMemory>
+ <vcpu>4</vcpu>
+ <on_poweroff>destroy</on_poweroff>
+ <on_reboot>restart</on_reboot>
+ <on_crash>destroy</on_crash>
+ <clock offset='utc'/>
+ <os>
+ <type>hvm</type>
+ <loader readonly='yes' type='pflash'>/usr/share/qemu/ovmf-x86_64-xen.bin</loader>
+ <boot dev='hd'/>
+ </os>
+ <features>
+ <apic/>
+ <acpi/>
+ <pae/>
+ </features>
+ <devices>
+ <emulator>/bin/true</emulator>
+ <disk type='file' device='disk'>
+ <driver name='qemu'/>
+ <source file='/var/lib/xen/images/test-hvm.img'/>
+ <target dev='hda'/>
+ </disk>
+ <interface type='bridge'>
+ <source bridge='br0'/>
+ <mac address='00:16:3e:66:12:b4'/>
+ <script path='/etc/xen/scripts/vif-bridge'/>
+ </interface>
+ <graphics type='vnc' port='-1' autoport='yes' listen='0.0.0.0'/>
+ </devices>
+</domain>
Index: libvirt-9.1.0/tests/libxlxml2domconfigtest.c
===================================================================
--- libvirt-9.1.0.orig/tests/libxlxml2domconfigtest.c
+++ libvirt-9.1.0/tests/libxlxml2domconfigtest.c
@@ -183,6 +183,7 @@ mymain(void)
DO_TEST("basic-pv");
DO_TEST("basic-hvm");
+ DO_TEST("efi-hvm");
# ifdef WITH_XEN_PVH
DO_TEST("basic-pvh");
# endif

View File

@ -1,3 +1,12 @@
-------------------------------------------------------------------
Fri Mar 10 19:01:21 UTC 2023 - James Fehlig <jfehlig@suse.com>
- libxl: Support custom firmware paths
bf3be5b7-libxl-Support-custom-firmware-path.patch,
705525cb-libxl-Support-custom-firmware-path-conversion.patch
bsc#1209161
- spec: Move ovmf dependency to correct package
-------------------------------------------------------------------
Thu Mar 2 23:11:37 UTC 2023 - James Fehlig <jfehlig@suse.com>

View File

@ -304,6 +304,8 @@ Source99: baselibs.conf
Source100: %{name}-rpmlintrc
# Upstream patches
Patch0: 4959490e-support-SUSE-edk2-firmware-paths.patch
Patch1: bf3be5b7-libxl-Support-custom-firmware-path.patch
Patch2: 705525cb-libxl-Support-custom-firmware-path-conversion.patch
# Patches pending upstream review
Patch100: libxl-dom-reset.patch
Patch101: network-don-t-use-dhcp-authoritative-on-static-netwo.patch
@ -385,13 +387,6 @@ Requires: group(libvirt)
Requires: gettext-runtime
Requires: bash-completion >= 2.0
# A KVM or Xen libvirt stack really does need UEFI firmware these days
%ifarch x86_64
Requires: qemu-ovmf-x86_64
%endif
%ifarch aarch64
Requires: qemu-uefi-aarch64
%endif
%if %{with_apparmor}
Recommends: apparmor-abstractions
%endif
@ -655,6 +650,13 @@ Requires: systemd-container
%if 0%{?suse_version} >= 1550 || 0%{?sle_version} >= 150300
Requires: swtpm
%endif
# The KVM libvirt stack really does need UEFI firmware these days
%ifarch x86_64
Requires: qemu-ovmf-x86_64
%endif
%ifarch aarch64
Requires: qemu-uefi-aarch64
%endif
%if %{with_numad}
Suggests: numad
%endif
@ -695,6 +697,8 @@ VirtualBox
Summary: Libxl driver plugin for the libvirtd daemon
Requires: %{name}-daemon-common = %{version}-%{release}
Requires: %{name}-libs = %{version}-%{release}
# The Xen libvirt stack really does need UEFI firmware these days
Requires: qemu-ovmf-x86_64
%description daemon-driver-libxl
The Libxl driver plugin for the libvirtd daemon, providing

View File

@ -14,7 +14,7 @@ Index: libvirt-9.1.0/src/libxl/libxl_conf.c
===================================================================
--- libvirt-9.1.0.orig/src/libxl/libxl_conf.c
+++ libvirt-9.1.0/src/libxl/libxl_conf.c
@@ -949,6 +949,28 @@ libxlDiskSetDiscard(libxl_device_disk *x
@@ -947,6 +947,28 @@ libxlDiskSetDiscard(libxl_device_disk *x
}
}
@ -43,7 +43,7 @@ Index: libvirt-9.1.0/src/libxl/libxl_conf.c
static char *
libxlMakeNetworkDiskSrcStr(virStorageSource *src,
const char *username,
@@ -1183,6 +1205,7 @@ libxlMakeDisk(virDomainDiskDef *l_disk,
@@ -1181,6 +1203,7 @@ libxlMakeDisk(virDomainDiskDef *l_disk,
x_disk->readwrite = !l_disk->src->readonly;
x_disk->is_cdrom = l_disk->device == VIR_DOMAIN_DISK_DEVICE_CDROM ? 1 : 0;
libxlDiskSetDiscard(x_disk, l_disk->discard);

View File

@ -17,7 +17,7 @@ Index: libvirt-9.1.0/src/libxl/libxl_conf.c
===================================================================
--- libvirt-9.1.0.orig/src/libxl/libxl_conf.c
+++ libvirt-9.1.0/src/libxl/libxl_conf.c
@@ -950,6 +950,20 @@ libxlDiskSetDiscard(libxl_device_disk *x
@@ -948,6 +948,20 @@ libxlDiskSetDiscard(libxl_device_disk *x
}
static void
@ -38,7 +38,7 @@ Index: libvirt-9.1.0/src/libxl/libxl_conf.c
libxlDiskSetCacheMode(libxl_device_disk *x_disk, int cachemode)
{
switch (cachemode) {
@@ -1087,6 +1101,7 @@ libxlMakeNetworkDiskSrc(virStorageSource
@@ -1085,6 +1099,7 @@ libxlMakeNetworkDiskSrc(virStorageSource
int
libxlMakeDisk(virDomainDiskDef *l_disk, libxl_device_disk *x_disk)
{
@ -46,7 +46,7 @@ Index: libvirt-9.1.0/src/libxl/libxl_conf.c
const char *driver = virDomainDiskGetDriver(l_disk);
int format = virDomainDiskGetFormat(l_disk);
virStorageType actual_type = virStorageSourceGetActualType(l_disk->src);
@@ -1100,7 +1115,7 @@ libxlMakeDisk(virDomainDiskDef *l_disk,
@@ -1098,7 +1113,7 @@ libxlMakeDisk(virDomainDiskDef *l_disk,
if (libxlMakeNetworkDiskSrc(l_disk->src, &x_disk->pdev_path) < 0)
return -1;
} else {
@ -55,7 +55,7 @@ Index: libvirt-9.1.0/src/libxl/libxl_conf.c
}
x_disk->vdev = g_strdup(l_disk->dst);
@@ -1206,6 +1221,8 @@ libxlMakeDisk(virDomainDiskDef *l_disk,
@@ -1204,6 +1219,8 @@ libxlMakeDisk(virDomainDiskDef *l_disk,
x_disk->is_cdrom = l_disk->device == VIR_DOMAIN_DISK_DEVICE_CDROM ? 1 : 0;
libxlDiskSetDiscard(x_disk, l_disk->discard);
libxlDiskSetCacheMode(x_disk, l_disk->cachemode);

View File

@ -41,7 +41,7 @@ Index: libvirt-9.1.0/src/libxl/libxl_conf.c
===================================================================
--- libvirt-9.1.0.orig/src/libxl/libxl_conf.c
+++ libvirt-9.1.0/src/libxl/libxl_conf.c
@@ -1740,15 +1740,12 @@ libxlMakeBuildInfoVfb(virPortAllocatorRa
@@ -1738,15 +1738,12 @@ libxlMakeBuildInfoVfb(virPortAllocatorRa
/*
* Get domain0 autoballoon configuration. Honor user-specified
* setting in libxl.conf first. If not specified, autoballooning
@ -58,7 +58,7 @@ Index: libvirt-9.1.0/src/libxl/libxl_conf.c
int res;
res = virConfGetValueBool(conf, "autoballoon", &cfg->autoballoon);
@@ -1757,15 +1754,8 @@ libxlGetAutoballoonConf(libxlDriverConfi
@@ -1755,15 +1752,8 @@ libxlGetAutoballoonConf(libxlDriverConfi
else if (res == 1)
return 0;

View File

@ -16,7 +16,7 @@ Index: libvirt-9.1.0/src/libxl/libxl_conf.c
===================================================================
--- libvirt-9.1.0.orig/src/libxl/libxl_conf.c
+++ libvirt-9.1.0/src/libxl/libxl_conf.c
@@ -1791,7 +1791,7 @@ libxlDriverConfigNew(void)
@@ -1789,7 +1789,7 @@ libxlDriverConfigNew(void)
cfg->firmwares = g_new0(virFirmware *, 1);
cfg->nfirmwares = 1;
cfg->firmwares[0] = g_new0(virFirmware, 1);