From f3a73384092f798261d99bf1ce099c8ea6cc91a9 Mon Sep 17 00:00:00 2001 From: Peter Krempa Date: Mon, 6 Mar 2023 09:18:51 +0100 Subject: [PATCH] qemuBuildHostNetProps: Report proper errors for unhandled interface types MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit VIR_DOMAIN_NET_TYPE_NULL and VIR_DOMAIN_NET_TYPE_VDS are not implemented for the qemu driver but the formatter code in 'qemuBuildHostNetProps' didn't report an error for them and didn't even return from the function when they were encountered. This caused a crash in 'virJSONValueObjectAppendStringPrintf' which does not tolerate NULL JSON object to append to when the unsupported devices were used. Properly report error when unhandled devices are encountered. This also includes the case for VIR_DOMAIN_NET_TYPE_HOSTDEV, but that code path should never be reached. Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=2175582 Fixes: bac6b266fb6a / 6457619d186 Fixes: 0225483adce Signed-off-by: Peter Krempa Reviewed-by: Ján Tomko --- src/qemu/qemu_command.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index 3afe1bb245..eb71a47091 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -3995,8 +3995,14 @@ qemuBuildHostNetProps(virDomainObj *vm, /* Should have been handled earlier via PCI/USB hotplug code. */ case VIR_DOMAIN_NET_TYPE_NULL: case VIR_DOMAIN_NET_TYPE_VDS: + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("network device type '%s' is not supported by this hypervisor"), + virDomainNetTypeToString(netType)); + return NULL; + case VIR_DOMAIN_NET_TYPE_LAST: - break; + virReportEnumRangeError(virDomainNetType, netType); + return NULL; } if (virJSONValueObjectAppendStringPrintf(netprops, "id", "host%s", net->info.alias) < 0)