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