]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
qemu: handle missing bind host/service on chardev hotplug
authorJán Tomko <jtomko@redhat.com>
Fri, 19 May 2017 10:56:48 +0000 (12:56 +0200)
committerJán Tomko <jtomko@redhat.com>
Tue, 11 Jul 2017 13:18:31 +0000 (15:18 +0200)
On domain startup, bind host or bind service can be omitted
and we will format a working command line.

Extend this to hotplug as well and specify the service to QEMU
even if the host is missing.

https://bugzilla.redhat.com/show_bug.cgi?id=1452441

src/qemu/qemu_monitor_json.c
tests/qemumonitorjsontest.c

index 5ddc09ca63e036fd8989bb26ad7263adbafd83dd..65b1fbb8ee74c9f3cd1fb5069a764be7402a1264 100644 (file)
@@ -6435,6 +6435,8 @@ qemuMonitorJSONAttachCharDevCommand(const char *chrID,
     virJSONValuePtr data = NULL;
     virJSONValuePtr addr = NULL;
     const char *backend_type = NULL;
+    const char *host;
+    const char *port;
     char *tlsalias = NULL;
     bool telnet;
 
@@ -6498,9 +6500,14 @@ qemuMonitorJSONAttachCharDevCommand(const char *chrID,
             virJSONValueObjectAppend(data, "remote", addr) < 0)
             goto cleanup;
 
-        if (chr->data.udp.bindHost) {
-            addr = qemuMonitorJSONBuildInetSocketAddress(chr->data.udp.bindHost,
-                                                         chr->data.udp.bindService);
+        host = chr->data.udp.bindHost;
+        port = chr->data.udp.bindService;
+        if (host || port) {
+            if (!host)
+                host = "";
+            if (!port)
+                port = "";
+            addr = qemuMonitorJSONBuildInetSocketAddress(host, port);
             if (!addr ||
                 virJSONValueObjectAppend(data, "local", addr) < 0)
                 goto cleanup;
index 6da27f7839bece5ff57902500a0e9ec338448b02..243f76469dd3149e2e3a6de4e2810247056336c3 100644 (file)
@@ -895,6 +895,17 @@ qemuMonitorJSONTestAttachChardev(virDomainXMLOptionPtr xmlopt)
                                        "'data':{'host':'localhost',"
                                                "'port':'4321'}}}}}");
 
+    chr.data.udp.bindHost = NULL;
+    chr.data.udp.bindService = (char *) "4321";
+    CHECK("udp", false,
+          "{'id':'alias',"
+           "'backend':{'type':'udp',"
+                      "'data':{'remote':{'type':'inet',"
+                                        "'data':{'host':'example.com',"
+                                                "'port':'1234'}},"
+                              "'local':{'type':'inet',"
+                                       "'data':{'host':'',"
+                                               "'port':'4321'}}}}}");
     memset(&chr, 0, sizeof(chr));
     chr.type = VIR_DOMAIN_CHR_TYPE_UNIX;
     chr.data.nix.path = (char *) "/path/to/socket";