c1c534
From 90aa784ed6ab93eae0a5e555c55bd65bc3240647 Mon Sep 17 00:00:00 2001
c1c534
Message-Id: <90aa784ed6ab93eae0a5e555c55bd65bc3240647@dist-git>
c1c534
From: =?UTF-8?q?J=C3=A1n=20Tomko?= <jtomko@redhat.com>
c1c534
Date: Mon, 27 Nov 2017 14:20:58 +0100
c1c534
Subject: [PATCH] Introduce virDomainInputDefGetPath
c1c534
MIME-Version: 1.0
c1c534
Content-Type: text/plain; charset=UTF-8
c1c534
Content-Transfer-Encoding: 8bit
c1c534
c1c534
Use it to denadify qemuDomainSetupInput.
c1c534
c1c534
(cherry picked from commit cbf4242db7da3727f86934513c417acdec3d1a48)
c1c534
c1c534
https://bugzilla.redhat.com/show_bug.cgi?id=1509866
c1c534
c1c534
Signed-off-by: Ján Tomko <jtomko@redhat.com>
c1c534
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
c1c534
---
c1c534
 src/conf/domain_conf.c   | 16 ++++++++++++++++
c1c534
 src/conf/domain_conf.h   |  1 +
c1c534
 src/libvirt_private.syms |  1 +
c1c534
 src/qemu/qemu_domain.c   | 21 ++++-----------------
c1c534
 4 files changed, 22 insertions(+), 17 deletions(-)
c1c534
c1c534
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
c1c534
index 641a978f07..530fae9d9d 100644
c1c534
--- a/src/conf/domain_conf.c
c1c534
+++ b/src/conf/domain_conf.c
c1c534
@@ -1397,6 +1397,22 @@ void virDomainGraphicsDefFree(virDomainGraphicsDefPtr def)
c1c534
     VIR_FREE(def);
c1c534
 }
c1c534
 
c1c534
+const char *virDomainInputDefGetPath(virDomainInputDefPtr input)
c1c534
+{
c1c534
+    switch ((virDomainInputType) input->type) {
c1c534
+    case VIR_DOMAIN_INPUT_TYPE_MOUSE:
c1c534
+    case VIR_DOMAIN_INPUT_TYPE_TABLET:
c1c534
+    case VIR_DOMAIN_INPUT_TYPE_KBD:
c1c534
+    case VIR_DOMAIN_INPUT_TYPE_LAST:
c1c534
+        return NULL;
c1c534
+        break;
c1c534
+
c1c534
+    case VIR_DOMAIN_INPUT_TYPE_PASSTHROUGH:
c1c534
+        return input->source.evdev;
c1c534
+    }
c1c534
+    return NULL;
c1c534
+}
c1c534
+
c1c534
 void virDomainInputDefFree(virDomainInputDefPtr def)
c1c534
 {
c1c534
     if (!def)
c1c534
diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h
c1c534
index f967e603d1..09635763a1 100644
c1c534
--- a/src/conf/domain_conf.h
c1c534
+++ b/src/conf/domain_conf.h
c1c534
@@ -2696,6 +2696,7 @@ int virDomainObjWaitUntil(virDomainObjPtr vm,
c1c534
 void virDomainPanicDefFree(virDomainPanicDefPtr panic);
c1c534
 void virDomainResourceDefFree(virDomainResourceDefPtr resource);
c1c534
 void virDomainGraphicsDefFree(virDomainGraphicsDefPtr def);
c1c534
+const char *virDomainInputDefGetPath(virDomainInputDefPtr input);
c1c534
 void virDomainInputDefFree(virDomainInputDefPtr def);
c1c534
 virDomainDiskDefPtr virDomainDiskDefNew(virDomainXMLOptionPtr xmlopt);
c1c534
 void virDomainDiskDefFree(virDomainDiskDefPtr def);
c1c534
diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
c1c534
index 8d1d4a896b..3e0bc8730c 100644
c1c534
--- a/src/libvirt_private.syms
c1c534
+++ b/src/libvirt_private.syms
c1c534
@@ -393,6 +393,7 @@ virDomainHypervTypeToString;
c1c534
 virDomainInputBusTypeToString;
c1c534
 virDomainInputDefFind;
c1c534
 virDomainInputDefFree;
c1c534
+virDomainInputDefGetPath;
c1c534
 virDomainIOMMUModelTypeFromString;
c1c534
 virDomainIOMMUModelTypeToString;
c1c534
 virDomainIOThreadIDAdd;
c1c534
diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
c1c534
index 2f987787cd..dbe9ed5e98 100644
c1c534
--- a/src/qemu/qemu_domain.c
c1c534
+++ b/src/qemu/qemu_domain.c
c1c534
@@ -8977,25 +8977,12 @@ qemuDomainSetupInput(virQEMUDriverConfigPtr cfg ATTRIBUTE_UNUSED,
c1c534
                      virDomainInputDefPtr input,
c1c534
                      const struct qemuDomainCreateDeviceData *data)
c1c534
 {
c1c534
-    int ret = -1;
c1c534
+    const char *path = virDomainInputDefGetPath(input);
c1c534
 
c1c534
-    switch ((virDomainInputType) input->type) {
c1c534
-    case VIR_DOMAIN_INPUT_TYPE_PASSTHROUGH:
c1c534
-        if (qemuDomainCreateDevice(input->source.evdev, data, false) < 0)
c1c534
-            goto cleanup;
c1c534
-        break;
c1c534
+    if (path && qemuDomainCreateDevice(path, data, false) < 0)
c1c534
+        return -1;
c1c534
 
c1c534
-    case VIR_DOMAIN_INPUT_TYPE_MOUSE:
c1c534
-    case VIR_DOMAIN_INPUT_TYPE_TABLET:
c1c534
-    case VIR_DOMAIN_INPUT_TYPE_KBD:
c1c534
-    case VIR_DOMAIN_INPUT_TYPE_LAST:
c1c534
-        /* nada */
c1c534
-        break;
c1c534
-    }
c1c534
-
c1c534
-    ret = 0;
c1c534
- cleanup:
c1c534
-    return ret;
c1c534
+    return 0;
c1c534
 }
c1c534
 
c1c534
 
c1c534
-- 
c1c534
2.15.1
c1c534