[PATCH] domain_conf: include checks against dom->os.type and dom->virtType

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

 



All the checks against dom->os.type and dom->virtType in
virDomainInputDefParseXML shifted to
virDomainInputDefValidate function

Signed-off-by: Jamm02 <codeguy.moteen@xxxxxxxxx>
---
 src/conf/domain_conf.c | 49 ++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 49 insertions(+)

diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index e0dfc9e45f..b237fd9ab1 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -11837,6 +11837,55 @@ virDomainPanicDefParseXML(virDomainXMLOption *xmlopt,
     return NULL;
 }
 
+static virDomainInputDef *
+virDomainInputDefValidate(const virDomainDef *dom,
+                          xmlNodePtr node,
+                          xmlXPathContextPtr ctxt)
+{
+    VIR_XPATH_NODE_AUTORESTORE(ctxt)
+    virDomainInputDef *def;
+    g_autofree char *bus = NULL;
+
+    def = g_new0(virDomainInputDef, 1);
+
+    ctxt->node = node;
+    bus = virXMLPropString(node, "bus");
+
+    if (bus) {
+     if ((def->bus = virDomainInputBusTypeFromString(bus)) < 0) {
+            virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
+                           _("unknown input bus type '%s'"), bus);
+            goto error;
+        }
+
+    } else {
+        if (dom->os.type == VIR_DOMAIN_OSTYPE_HVM) {
+            if ((def->type == VIR_DOMAIN_INPUT_TYPE_MOUSE ||
+                def->type == VIR_DOMAIN_INPUT_TYPE_KBD) &&
+                (ARCH_IS_X86(dom->os.arch) || dom->os.arch == VIR_ARCH_NONE)) {
+                def->bus = VIR_DOMAIN_INPUT_BUS_PS2;
+            } else if (ARCH_IS_S390(dom->os.arch) ||
+                       def->type == VIR_DOMAIN_INPUT_TYPE_PASSTHROUGH) {
+                def->bus = VIR_DOMAIN_INPUT_BUS_VIRTIO;
+            } else if (def->type == VIR_DOMAIN_INPUT_TYPE_EVDEV) {
+                def->bus = VIR_DOMAIN_INPUT_BUS_NONE;
+            } else {
+                def->bus = VIR_DOMAIN_INPUT_BUS_USB;
+            }
+        } else if (dom->os.type == VIR_DOMAIN_OSTYPE_XEN ||
+                   dom->os.type == VIR_DOMAIN_OSTYPE_XENPVH) {
+            def->bus = VIR_DOMAIN_INPUT_BUS_XEN;
+        } else {
+            if ((dom->virtType == VIR_DOMAIN_VIRT_VZ ||
+                 dom->virtType == VIR_DOMAIN_VIRT_PARALLELS))
+                def->bus = VIR_DOMAIN_INPUT_BUS_PARALLELS;
+        }
+    }
+
+ error:
+    virDomainInputDefFree(def);
+    return NULL;
+}
 /* Parse the XML definition for an input device */
 static virDomainInputDef *
 virDomainInputDefParseXML(virDomainXMLOption *xmlopt,
-- 
2.35.1




[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]

  Powered by Linux