[PATCH v5 1/6] conf: Add a keyboard input device type

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

 



From: Li Zhang <zhlcindy@xxxxxxxxxxxxxxxxxx>

There is no keyboard for non-x86 platforms when graphics are enabled.
It's preferred to add one USB keyboard.

This patch is to add keyboard input device type.

Signed-off-by: Li Zhang <zhlcindy@xxxxxxxxxxxxxxxxxx>
---
 docs/schemas/domaincommon.rng |  1 +
 src/conf/domain_conf.c        | 18 ++++++++++++------
 src/conf/domain_conf.h        |  1 +
 3 files changed, 14 insertions(+), 6 deletions(-)

diff --git a/docs/schemas/domaincommon.rng b/docs/schemas/domaincommon.rng
index be32c6b..df6253c 100644
--- a/docs/schemas/domaincommon.rng
+++ b/docs/schemas/domaincommon.rng
@@ -3167,6 +3167,7 @@
         <choice>
           <value>tablet</value>
           <value>mouse</value>
+          <value>kbd</value>
         </choice>
       </attribute>
       <optional>
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 0079234..9c30a78 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -505,7 +505,8 @@ VIR_ENUM_IMPL(virDomainVideo, VIR_DOMAIN_VIDEO_TYPE_LAST,
 
 VIR_ENUM_IMPL(virDomainInput, VIR_DOMAIN_INPUT_TYPE_LAST,
               "mouse",
-              "tablet")
+              "tablet",
+              "kbd")
 
 VIR_ENUM_IMPL(virDomainInputBus, VIR_DOMAIN_INPUT_BUS_LAST,
               "ps2",
@@ -7659,7 +7660,8 @@ virDomainInputDefParseXML(const char *ostype,
 
         if (STREQ(ostype, "hvm")) {
             if (def->bus == VIR_DOMAIN_INPUT_BUS_PS2 && /* Only allow mouse for ps2 */
-                def->type != VIR_DOMAIN_INPUT_TYPE_MOUSE) {
+                !(def->type == VIR_DOMAIN_INPUT_TYPE_MOUSE ||
+                def->type == VIR_DOMAIN_INPUT_TYPE_KBD)) {
                 virReportError(VIR_ERR_INTERNAL_ERROR,
                                _("ps2 bus does not support %s input device"),
                                type);
@@ -7677,7 +7679,8 @@ virDomainInputDefParseXML(const char *ostype,
                                _("unsupported input bus %s"),
                                bus);
             }
-            if (def->type != VIR_DOMAIN_INPUT_TYPE_MOUSE) {
+            if (def->type != VIR_DOMAIN_INPUT_TYPE_MOUSE &&
+                def->type != VIR_DOMAIN_INPUT_TYPE_KBD) {
                 virReportError(VIR_ERR_INTERNAL_ERROR,
                                _("xen bus does not support %s input device"),
                                type);
@@ -7686,7 +7689,8 @@ virDomainInputDefParseXML(const char *ostype,
         }
     } else {
         if (STREQ(ostype, "hvm")) {
-            if (def->type == VIR_DOMAIN_INPUT_TYPE_MOUSE)
+            if (def->type == VIR_DOMAIN_INPUT_TYPE_MOUSE ||
+                def->type == VIR_DOMAIN_INPUT_TYPE_KBD)
                 def->bus = VIR_DOMAIN_INPUT_BUS_PS2;
             else
                 def->bus = VIR_DOMAIN_INPUT_BUS_USB;
@@ -12275,10 +12279,12 @@ virDomainDefParseXML(xmlDocPtr xml,
          * XXX will this be true for other virt types ? */
         if ((STREQ(def->os.type, "hvm") &&
              input->bus == VIR_DOMAIN_INPUT_BUS_PS2 &&
-             input->type == VIR_DOMAIN_INPUT_TYPE_MOUSE) ||
+             (input->type == VIR_DOMAIN_INPUT_TYPE_MOUSE ||
+              input->type == VIR_DOMAIN_INPUT_TYPE_KBD)) ||
             (STRNEQ(def->os.type, "hvm") &&
              input->bus == VIR_DOMAIN_INPUT_BUS_XEN &&
-             input->type == VIR_DOMAIN_INPUT_TYPE_MOUSE)) {
+             (input->type == VIR_DOMAIN_INPUT_TYPE_MOUSE ||
+              input->type == VIR_DOMAIN_INPUT_TYPE_KBD))) {
             virDomainInputDefFree(input);
             continue;
         }
diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h
index 647d115..23b2b9b 100644
--- a/src/conf/domain_conf.h
+++ b/src/conf/domain_conf.h
@@ -1235,6 +1235,7 @@ struct _virDomainTPMDef {
 enum virDomainInputType {
     VIR_DOMAIN_INPUT_TYPE_MOUSE,
     VIR_DOMAIN_INPUT_TYPE_TABLET,
+    VIR_DOMAIN_INPUT_TYPE_KBD,
 
     VIR_DOMAIN_INPUT_TYPE_LAST
 };
-- 
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]