[PATCH 0/4] qemu: Fix broken check rejecting virtiofs hotplug with 'bootindex' set

See 3/4 Peter Krempa (4): syms: Properly export 'virDomainDeviceDefValidate' qemu: hotplug: Validate definition of 'FS' device after address allocation qemu: validate: Fix check for unsupported FS-device bootindex use on un-assigned addresses NEWS: Mention fix for broken 'fs' device bootindex support check NEWS.rst | 6 ++++++ src/libvirt_private.syms | 1 + src/qemu/qemu_hotplug.c | 4 ++++ src/qemu/qemu_validate.c | 5 ++++- 4 files changed, 15 insertions(+), 1 deletion(-) -- 2.45.1

While the function is exported via header, the symbol itself was not. Signed-off-by: Peter Krempa <pkrempa@redhat.com> --- src/libvirt_private.syms | 1 + 1 file changed, 1 insertion(+) diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index f0f7aa8654..653c84a520 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -796,6 +796,7 @@ virDomainDefPostParse; virDomainActualNetDefValidate; virDomainDefOSValidate; virDomainDefValidate; +virDomainDeviceDefValidate; virDomainDeviceValidateAliasForHotplug; virDomainDiskDefSourceLUNValidate; virDomainDiskDefValidateStartupPolicy; -- 2.45.1

Some of the checks make sense only after the address is allocated and thus we need to re-do the validation after the address is assigned. Signed-off-by: Peter Krempa <pkrempa@redhat.com> --- src/qemu/qemu_hotplug.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c index 4739beead8..416e89d00d 100644 --- a/src/qemu/qemu_hotplug.c +++ b/src/qemu/qemu_hotplug.c @@ -40,6 +40,7 @@ #include "domain_audit.h" #include "domain_cgroup.h" #include "domain_interface.h" +#include "domain_validate.h" #include "netdev_bandwidth_conf.h" #include "domain_nwfilter.h" #include "virlog.h" @@ -3216,6 +3217,9 @@ qemuDomainAttachFSDevice(virQEMUDriver *driver, qemuAssignDeviceFSAlias(vm->def, fs); + if (virDomainDeviceDefValidate(&dev, vm->def, 0, driver->xmlopt, priv->qemuCaps) < 0) + goto cleanup; + chardev = virDomainChrSourceDefNew(priv->driver->xmlopt); chardev->type = VIR_DOMAIN_CHR_TYPE_UNIX; chardev->data.nix.path = qemuDomainGetVHostUserFSSocketPath(priv, fs); -- 2.45.1

When hot-plugging a FS device with un-assigned address with a bootindex the recently-added validation check would fail as validation on hotplug is done prior to address assignment. To fix this problem we can simply relax the check to also pass on _NONE addresses. Unsupported configurations will still be caught as previous commit re-checks the definition after address assignment prior to hotplug. Resolves: https://issues.redhat.com/browse/RHEL-39271 Fixes: 4690058b6d3dab672bd18ff69c83392245253024 Signed-off-by: Peter Krempa <pkrempa@redhat.com> --- src/qemu/qemu_validate.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/qemu/qemu_validate.c b/src/qemu/qemu_validate.c index ac1940cb31..c08e1538f9 100644 --- a/src/qemu/qemu_validate.c +++ b/src/qemu/qemu_validate.c @@ -4519,7 +4519,10 @@ qemuValidateDomainDeviceDefFS(virDomainFSDef *fs, return -1; } - if (fs->info.type != VIR_DOMAIN_DEVICE_ADDRESS_TYPE_PCI) { + /* Address type may be _NONE when validating and will be assigned + * later during hotplug */ + if (fs->info.type != VIR_DOMAIN_DEVICE_ADDRESS_TYPE_NONE && + fs->info.type != VIR_DOMAIN_DEVICE_ADDRESS_TYPE_PCI) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", _("setting virtiofs boot order is supported only with PCI bus")); return -1; -- 2.45.1

Signed-off-by: Peter Krempa <pkrempa@redhat.com> --- NEWS.rst | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/NEWS.rst b/NEWS.rst index 14505116b1..edb4a9965d 100644 --- a/NEWS.rst +++ b/NEWS.rst @@ -70,6 +70,12 @@ v10.4.0 (unreleased) The bug was introduced in `v10.1.0 (2024-03-01)`_. + * qemu: Fix hotplug of ``virtiofs`` filesystem device with ``<boot order=`` set + + The bug was introduced in `v10.3.0 (2024-05-02)`_ when attempting to reject + unsupported configurations. During hotplug the addresses are + assigned after validation and thus errorneously reject valid configs. + v10.3.0 (2024-05-02) ==================== -- 2.45.1

On 5/30/24 16:51, Peter Krempa wrote:
See 3/4
Peter Krempa (4): syms: Properly export 'virDomainDeviceDefValidate' qemu: hotplug: Validate definition of 'FS' device after address allocation qemu: validate: Fix check for unsupported FS-device bootindex use on un-assigned addresses NEWS: Mention fix for broken 'fs' device bootindex support check
NEWS.rst | 6 ++++++ src/libvirt_private.syms | 1 + src/qemu/qemu_hotplug.c | 4 ++++ src/qemu/qemu_validate.c | 5 ++++- 4 files changed, 15 insertions(+), 1 deletion(-)
Reviewed-by: Michal Privoznik <mprivozn@redhat.com> Michal
participants (2)
-
Michal Prívozník
-
Peter Krempa