]> xenbits.xensource.com Git - libvirt.git/commitdiff
qemu: Move check for chardev backends which can't be hotplugged out of the monitor
authorPeter Krempa <pkrempa@redhat.com>
Tue, 17 Sep 2024 12:53:54 +0000 (14:53 +0200)
committerPeter Krempa <pkrempa@redhat.com>
Thu, 19 Sep 2024 08:30:14 +0000 (10:30 +0200)
The upcoming refactor of the monitor code will make the hotplug code
paths use the same generator we have for commandline -chardev backends
which doesn't refuse to format certain backends which can't be
hotplugged.

To prepare for this we add a check to qemuHotplugChardevAttach()
refusing such hotplug and remove 'qemumonitorjsontest' test cases which
will not make sense any more.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
src/qemu/qemu_hotplug.c
tests/qemumonitorjsontest.c

index 75b97cf7367b51d50ebda9fc0baed403488f0ebf..a58c1446e9745c9b4fbe9b0aa2c3c83a339b4197 100644 (file)
@@ -243,6 +243,35 @@ qemuHotplugChardevAttach(qemuMonitor *mon,
                          const char *alias,
                          virDomainChrSourceDef *def)
 {
+    switch ((virDomainChrType) def->type) {
+    case VIR_DOMAIN_CHR_TYPE_NULL:
+    case VIR_DOMAIN_CHR_TYPE_VC:
+    case VIR_DOMAIN_CHR_TYPE_PTY:
+    case VIR_DOMAIN_CHR_TYPE_FILE:
+    case VIR_DOMAIN_CHR_TYPE_DEV:
+    case VIR_DOMAIN_CHR_TYPE_UNIX:
+    case VIR_DOMAIN_CHR_TYPE_TCP:
+    case VIR_DOMAIN_CHR_TYPE_UDP:
+    case VIR_DOMAIN_CHR_TYPE_SPICEVMC:
+    case VIR_DOMAIN_CHR_TYPE_QEMU_VDAGENT:
+    case VIR_DOMAIN_CHR_TYPE_DBUS:
+        break;
+
+    case VIR_DOMAIN_CHR_TYPE_SPICEPORT:
+    case VIR_DOMAIN_CHR_TYPE_PIPE:
+    case VIR_DOMAIN_CHR_TYPE_STDIO:
+    case VIR_DOMAIN_CHR_TYPE_NMDM:
+        virReportError(VIR_ERR_OPERATION_FAILED,
+                       _("Hotplug unsupported for char device type '%1$s'"),
+                       virDomainChrTypeToString(def->type));
+        return -1;
+
+    case VIR_DOMAIN_CHR_TYPE_LAST:
+    default:
+        virReportEnumRangeError(virDomainChrType, def->type);
+        return -1;
+    }
+
     return qemuMonitorAttachCharDev(mon, alias, def);
 }
 
index 66d0c127ca3cda07e97cf6050c80d8d3605b7101..2249787ba7ba983c60eb52c65b687e862c04f05b 100644 (file)
@@ -652,12 +652,6 @@ qemuMonitorJSONTestAttachChardev(virDomainXMLOption *xmlopt,
               "{'id':'alias','backend':{'type':'spicevmc',"
                                        "'data':{'type':'vdagent'}}}");
 
-        chr->type = VIR_DOMAIN_CHR_TYPE_PIPE;
-        CHECK("pipe", true, NULL);
-
-        chr->type = VIR_DOMAIN_CHR_TYPE_STDIO;
-        CHECK("stdio", true, NULL);
-
         chr->type = VIR_DOMAIN_CHR_TYPE_PTY;
         CHECK("pty missing path", true,
               "{'id':'alias','backend':{'type':'pty','data':{}}}");