On Mon, Mar 06, 2023 at 10:20:30AM +0100, Peter Krempa wrote:
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: 6457619d186
Technically bac6b266fb6a was the first offender ;)
Fixes: 0225483adce
Signed-off-by: Peter Krempa <pkrempa(a)redhat.com>
---
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 4839d45a34..589ec3e639 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)
--
2.39.2