qemu_hotplug: Report better error message for platform serial devices

This should be better than the current for both hotplug:

    error: internal error: Invalid target model for serial device

and hot-unplug:

    error: An error occurred, but the cause is unknown

which should not be reached at all.

Resolves: https://issues.redhat.com/browse/RHEL-66222
Resolves: https://issues.redhat.com/browse/RHEL-66223
Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
This commit is contained in:
Martin Kletzander 2024-11-08 12:21:09 +01:00
parent 52c2e3e0a7
commit 27ae5e602a

View File

@ -2063,6 +2063,12 @@ qemuDomainAttachChrDevice(virQEMUDriver *driver,
bool need_release = false;
bool guestfwd = false;
if (qemuChrIsPlatformDevice(vmdef, chr)) {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
_("Cannot hotplug platform device"));
return -1;
}
if (chr->deviceType == VIR_DOMAIN_CHR_DEVICE_TYPE_CHANNEL) {
guestfwd = chr->targetType == VIR_DOMAIN_CHR_CHANNEL_TARGET_TYPE_GUESTFWD;
@ -6051,6 +6057,12 @@ qemuDomainDetachDeviceChr(virQEMUDriver *driver,
goto cleanup;
}
if (qemuChrIsPlatformDevice(vmdef, tmpChr)) {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
_("Cannot detach platform device"));
return -1;
}
if (vmdef->os.type == VIR_DOMAIN_OSTYPE_HVM &&
tmpChr->deviceType == VIR_DOMAIN_CHR_DEVICE_TYPE_CONSOLE &&
(tmpChr->targetType == VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_SERIAL ||