[PATCH 0/2] qemuBuildHostdevMediatedDevProps: Format 'ramfb' only when enabled

Fix a regression introduced by the conversion of -device formatters and add a test case for it. Peter Krempa (2): qemuBuildHostdevMediatedDevProps: Format 'ramfb' only when enabled qemuxml2argvtest: Add device with 'ramfb=off' to 'hostdev-mdev-display-ramfb' src/qemu/qemu_command.c | 4 +++- .../hostdev-mdev-display-ramfb.x86_64-latest.args | 1 + tests/qemuxml2argvdata/hostdev-mdev-display-ramfb.xml | 5 +++++ .../hostdev-mdev-display-ramfb.x86_64-latest.xml | 6 ++++++ 4 files changed, 15 insertions(+), 1 deletion(-) -- 2.31.1

Before commit 73c352ab8c97d3 which converted the hostdev commandline formatter to JSON the 'ramfb' property was formatted only if it was enabled. The main reason for that is that enabling 'ramfb' switches the device model to 'vfio-pci-nohotplug' which actually has the property, while 'vfio-pci' (used when 'ramfb' is disabled or absent) doesn't have it. Restore the logic to format 'ramfb' only when it's enabled and add a comment that it's deliberate. Fixes: 73c352ab8c97d3 Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=2024435 Signed-off-by: Peter Krempa <pkrempa@redhat.com> --- src/qemu/qemu_command.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index 713304dd22..d1b0205eb2 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -5329,6 +5329,8 @@ qemuBuildHostdevMediatedDevProps(const virDomainDef *def, g_autoptr(virJSONValue) props = NULL; virDomainHostdevSubsysMediatedDev *mdevsrc = &dev->source.subsys.u.mdev; g_autofree char *mdevPath = NULL; + /* 'ramfb' property must be omitted unless it's to be enabled */ + bool ramfb = mdevsrc->ramfb == VIR_TRISTATE_SWITCH_ON; mdevPath = virMediatedDeviceGetSysfsPath(mdevsrc->uuidstr); @@ -5337,7 +5339,7 @@ qemuBuildHostdevMediatedDevProps(const virDomainDef *def, "s:id", dev->info->alias, "s:sysfsdev", mdevPath, "S:display", qemuOnOffAuto(mdevsrc->display), - "T:ramfb", mdevsrc->ramfb, + "B:ramfb", ramfb, "p:bootindex", dev->info->bootIndex, NULL) < 0) return NULL; -- 2.31.1

Add a test case where 'ramfb' is explicitly disabled for a mediated device to prevent regressing again. Signed-off-by: Peter Krempa <pkrempa@redhat.com> --- .../hostdev-mdev-display-ramfb.x86_64-latest.args | 1 + tests/qemuxml2argvdata/hostdev-mdev-display-ramfb.xml | 5 +++++ .../hostdev-mdev-display-ramfb.x86_64-latest.xml | 6 ++++++ 3 files changed, 12 insertions(+) diff --git a/tests/qemuxml2argvdata/hostdev-mdev-display-ramfb.x86_64-latest.args b/tests/qemuxml2argvdata/hostdev-mdev-display-ramfb.x86_64-latest.args index 7ab67b3029..31ba83f0da 100644 --- a/tests/qemuxml2argvdata/hostdev-mdev-display-ramfb.x86_64-latest.args +++ b/tests/qemuxml2argvdata/hostdev-mdev-display-ramfb.x86_64-latest.args @@ -30,5 +30,6 @@ XDG_CONFIG_HOME=/tmp/lib/domain--1-QEMUGuest2/.config \ -vnc 127.0.0.1:0,audiodev=audio1 \ -device '{"driver":"qxl-vga","id":"video0","ram_size":67108864,"vram_size":67108864,"vram64_size_mb":0,"vgamem_mb":16,"max_outputs":1,"bus":"pci.0","addr":"0x2"}' \ -device '{"driver":"vfio-pci-nohotplug","id":"hostdev0","sysfsdev":"/sys/bus/mdev/devices/53764d0e-85a0-42b4-af5c-2046b460b1dc","display":"on","ramfb":true,"bus":"pci.0","addr":"0x3"}' \ +-device '{"driver":"vfio-pci","id":"hostdev1","sysfsdev":"/sys/bus/mdev/devices/53764d0e-85a0-42b4-af5c-2046b460b1dd","display":"on","bus":"pci.0","addr":"0x4"}' \ -sandbox on,obsolete=deny,elevateprivileges=deny,spawn=deny,resourcecontrol=deny \ -msg timestamp=on diff --git a/tests/qemuxml2argvdata/hostdev-mdev-display-ramfb.xml b/tests/qemuxml2argvdata/hostdev-mdev-display-ramfb.xml index 6fdc477ca2..a494c59f9d 100644 --- a/tests/qemuxml2argvdata/hostdev-mdev-display-ramfb.xml +++ b/tests/qemuxml2argvdata/hostdev-mdev-display-ramfb.xml @@ -25,6 +25,11 @@ <address uuid='53764d0e-85a0-42b4-af5c-2046b460b1dc'/> </source> </hostdev> + <hostdev mode='subsystem' type='mdev' model='vfio-pci' display='on' ramfb='off'> + <source> + <address uuid='53764d0e-85a0-42b4-af5c-2046b460b1dd'/> + </source> + </hostdev> <video> <model type='qxl' heads='1'/> </video> diff --git a/tests/qemuxml2xmloutdata/hostdev-mdev-display-ramfb.x86_64-latest.xml b/tests/qemuxml2xmloutdata/hostdev-mdev-display-ramfb.x86_64-latest.xml index a60317d811..a137bd387e 100644 --- a/tests/qemuxml2xmloutdata/hostdev-mdev-display-ramfb.x86_64-latest.xml +++ b/tests/qemuxml2xmloutdata/hostdev-mdev-display-ramfb.x86_64-latest.xml @@ -40,6 +40,12 @@ </source> <address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/> </hostdev> + <hostdev mode='subsystem' type='mdev' managed='no' model='vfio-pci' display='on' ramfb='off'> + <source> + <address uuid='53764d0e-85a0-42b4-af5c-2046b460b1dd'/> + </source> + <address type='pci' domain='0x0000' bus='0x00' slot='0x04' function='0x0'/> + </hostdev> <memballoon model='none'/> </devices> </domain> -- 2.31.1

On a Thursday in 2021, Peter Krempa wrote:
Fix a regression introduced by the conversion of -device formatters and add a test case for it.
Peter Krempa (2): qemuBuildHostdevMediatedDevProps: Format 'ramfb' only when enabled qemuxml2argvtest: Add device with 'ramfb=off' to 'hostdev-mdev-display-ramfb'
src/qemu/qemu_command.c | 4 +++- .../hostdev-mdev-display-ramfb.x86_64-latest.args | 1 + tests/qemuxml2argvdata/hostdev-mdev-display-ramfb.xml | 5 +++++ .../hostdev-mdev-display-ramfb.x86_64-latest.xml | 6 ++++++ 4 files changed, 15 insertions(+), 1 deletion(-)
Reviewed-by: Ján Tomko <jtomko@redhat.com> Jano
participants (2)
-
Ján Tomko
-
Peter Krempa