99cbc7
From 7b795534a39ad44d93ff1864ed98071c1f5bf6af Mon Sep 17 00:00:00 2001
99cbc7
Message-Id: <7b795534a39ad44d93ff1864ed98071c1f5bf6af@dist-git>
99cbc7
From: Michal Privoznik <mprivozn@redhat.com>
99cbc7
Date: Thu, 11 Apr 2019 15:14:18 -0400
99cbc7
Subject: [PATCH] qemu_hotplug: Attach guestfwd using netdev_add
99cbc7
99cbc7
https://bugzilla.redhat.com/show_bug.cgi?id=1624204
99cbc7
99cbc7
The guestfwd channels are -netdevs really. Hotplug them as such.
99cbc7
99cbc7
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
99cbc7
Reviewed-by: John Ferlan <jferlan@redhat.com>
99cbc7
(cherry picked from commit 903315dc8ffeb2af651207f090a53526decabc92)
99cbc7
99cbc7
Partially-Resolves: https://bugzilla.redhat.com/1658198
99cbc7
Signed-off-by: Laine Stump <laine@redhat.com>
99cbc7
Signed-off-by: Laine Stump <laine@laine.org>
99cbc7
Message-Id: <20190411191453.24055-7-laine@redhat.com>
99cbc7
Acked-by: Michal Privoznik <mprivozn@redhat.com>
99cbc7
---
99cbc7
 src/qemu/qemu_hotplug.c | 20 +++++++++++++++-----
99cbc7
 1 file changed, 15 insertions(+), 5 deletions(-)
99cbc7
99cbc7
diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c
99cbc7
index 46cafef4c2..680c06c1ed 100644
99cbc7
--- a/src/qemu/qemu_hotplug.c
99cbc7
+++ b/src/qemu/qemu_hotplug.c
99cbc7
@@ -1753,10 +1753,14 @@ int qemuDomainAttachChrDevice(virQEMUDriverPtr driver,
99cbc7
     char *tlsAlias = NULL;
99cbc7
     const char *secAlias = NULL;
99cbc7
     bool need_release = false;
99cbc7
+    bool guestfwd = false;
99cbc7
 
99cbc7
-    if (chr->deviceType == VIR_DOMAIN_CHR_DEVICE_TYPE_CHANNEL &&
99cbc7
-        qemuDomainPrepareChannel(chr, priv->channelTargetDir) < 0)
99cbc7
-        goto cleanup;
99cbc7
+    if (chr->deviceType == VIR_DOMAIN_CHR_DEVICE_TYPE_CHANNEL) {
99cbc7
+        guestfwd = chr->targetType == VIR_DOMAIN_CHR_CHANNEL_TARGET_TYPE_GUESTFWD;
99cbc7
+
99cbc7
+        if (qemuDomainPrepareChannel(chr, priv->channelTargetDir) < 0)
99cbc7
+            goto cleanup;
99cbc7
+    }
99cbc7
 
99cbc7
     if (qemuAssignDeviceChrAlias(vmdef, chr, -1) < 0)
99cbc7
         goto cleanup;
99cbc7
@@ -1798,8 +1802,14 @@ int qemuDomainAttachChrDevice(virQEMUDriverPtr driver,
99cbc7
         goto exit_monitor;
99cbc7
     chardevAttached = true;
99cbc7
 
99cbc7
-    if (qemuMonitorAddDevice(priv->mon, devstr) < 0)
99cbc7
-        goto exit_monitor;
99cbc7
+    if (guestfwd) {
99cbc7
+        if (qemuMonitorAddNetdev(priv->mon, devstr,
99cbc7
+                                 NULL, NULL, 0, NULL, NULL, 0) < 0)
99cbc7
+            goto exit_monitor;
99cbc7
+    } else {
99cbc7
+        if (qemuMonitorAddDevice(priv->mon, devstr) < 0)
99cbc7
+            goto exit_monitor;
99cbc7
+    }
99cbc7
 
99cbc7
     if (qemuDomainObjExitMonitor(driver, vm) < 0)
99cbc7
         goto audit;
99cbc7
-- 
99cbc7
2.21.0
99cbc7