[PATCH v4 2/6] conf: Add one interface to add default input devices.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: Li Zhang <zhlcindy@xxxxxxxxxxxxxxxxxx>

This patch is to add one new interface to add input devices.

Signed-off-by: Li Zhang <zhlcindy@xxxxxxxxxxxxxxxxxx>
---
 src/conf/domain_conf.c   | 29 +++++++++++++++++++++++++++++
 src/conf/domain_conf.h   |  4 ++++
 src/libvirt_private.syms |  1 +
 3 files changed, 34 insertions(+)

diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 3dee9a8..d107e6f 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -10822,6 +10822,35 @@ virDomainDefMaybeAddController(virDomainDefPtr def,
     return 0;
 }
 
+int
+virDomainDefMaybeAddInput(virDomainDefPtr def,
+                               int type,
+                               int bus)
+{
+    size_t i;
+    virDomainInputDefPtr input;
+
+    for (i = 0; i < def->ninputs; i++) {
+        if (def->inputs[i]->type == type &&
+            def->inputs[i]->bus == bus)
+            return 0;
+    }
+
+    if (VIR_ALLOC(input) < 0)
+        return -1;
+
+    input->type = type;
+    input->bus = bus;
+
+    if (VIR_APPEND_ELEMENT(def->inputs, def->ninputs, input) < 0) {
+        VIR_FREE(input);
+        return -1;
+    }
+
+    return 0;
+}
+
+
 
 /* Parse a memory element located at XPATH within CTXT, and store the
  * result into MEM.  If REQUIRED, then the value must exist;
diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h
index 8aa5f50..8616066 100644
--- a/src/conf/domain_conf.h
+++ b/src/conf/domain_conf.h
@@ -2764,6 +2764,10 @@ virDomainDefMaybeAddController(virDomainDefPtr def,
                                int type,
                                int idx,
                                int model);
+int
+virDomainDefMaybeAddInput(virDomainDefPtr def,
+                          int type,
+                          int bus);
 
 char *virDomainDefGetDefaultEmulator(virDomainDefPtr def, virCapsPtr caps);
 
diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
index 0e749b1..aa497b5 100644
--- a/src/libvirt_private.syms
+++ b/src/libvirt_private.syms
@@ -165,6 +165,7 @@ virDomainDefGenSecurityLabelDef;
 virDomainDefGetDefaultEmulator;
 virDomainDefGetSecurityLabelDef;
 virDomainDefMaybeAddController;
+virDomainDefMaybeAddInput;
 virDomainDefNew;
 virDomainDefParseFile;
 virDomainDefParseNode;
-- 
1.8.2.1

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list




[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]