]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
qemu_hotplug: Report better error message for platform serial devices
authorMartin Kletzander <mkletzan@redhat.com>
Fri, 8 Nov 2024 11:21:09 +0000 (12:21 +0100)
committerMartin Kletzander <mkletzan@redhat.com>
Mon, 11 Nov 2024 11:48:42 +0000 (12:48 +0100)
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>
src/qemu/qemu_hotplug.c

index 5db72ef63470c5ed5e1eebfbd82c32433fc2e4e8..8361d3d9c1b7ceeb1f80937add14957bb08899b4 100644 (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 ||