diff --git a/docs/schemas/domaincommon.rng b/docs/schemas/domaincommon.rng index c1efcd21cb..601e7ac657 100644 --- a/docs/schemas/domaincommon.rng +++ b/docs/schemas/domaincommon.rng @@ -3269,6 +3269,7 @@ tablet mouse + keyboard diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 939b4231b1..75b87d11ba 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -507,7 +507,8 @@ VIR_ENUM_IMPL(virDomainVideo, VIR_DOMAIN_VIDEO_TYPE_LAST, VIR_ENUM_IMPL(virDomainInput, VIR_DOMAIN_INPUT_TYPE_LAST, "mouse", - "tablet") + "tablet", + "keyboard") VIR_ENUM_IMPL(virDomainInputBus, VIR_DOMAIN_INPUT_BUS_LAST, "ps2", @@ -7773,7 +7774,7 @@ error: /* Parse the XML definition for an input device */ static virDomainInputDefPtr -virDomainInputDefParseXML(const char *ostype, +virDomainInputDefParseXML(const virDomainDef *dom, xmlNodePtr node, unsigned int flags) { @@ -7806,9 +7807,10 @@ virDomainInputDefParseXML(const char *ostype, goto error; } - if (STREQ(ostype, "hvm")) { - if (def->bus == VIR_DOMAIN_INPUT_BUS_PS2 && /* Only allow mouse for ps2 */ - def->type != VIR_DOMAIN_INPUT_TYPE_MOUSE) { + if (STREQ(dom->os.type, "hvm")) { + if (def->bus == VIR_DOMAIN_INPUT_BUS_PS2 && + 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); @@ -7826,7 +7828,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); @@ -7834,8 +7837,9 @@ virDomainInputDefParseXML(const char *ostype, } } } else { - if (STREQ(ostype, "hvm")) { - if (def->type == VIR_DOMAIN_INPUT_TYPE_MOUSE) + if (STREQ(dom->os.type, "hvm")) { + 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; @@ -9857,7 +9861,7 @@ virDomainDeviceDefParse(const char *xmlStr, goto error; break; case VIR_DOMAIN_DEVICE_INPUT: - if (!(dev->data.input = virDomainInputDefParseXML(def->os.type, + if (!(dev->data.input = virDomainInputDefParseXML(def, node, flags))) goto error; break; @@ -12442,7 +12446,7 @@ virDomainDefParseXML(xmlDocPtr xml, goto error; for (i = 0; i < n; i++) { - virDomainInputDefPtr input = virDomainInputDefParseXML(def->os.type, + virDomainInputDefPtr input = virDomainInputDefParseXML(def, nodes[i], flags); if (!input) @@ -12462,10 +12466,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; } @@ -12502,8 +12508,12 @@ virDomainDefParseXML(xmlDocPtr xml, VIR_DOMAIN_INPUT_TYPE_MOUSE, input_bus) < 0) goto error; - } + if (virDomainDefMaybeAddInput(def, + VIR_DOMAIN_INPUT_TYPE_KBD, + input_bus) < 0) + goto error; + } /* analysis of the sound devices */ if ((n = virXPathNodeSet("./devices/sound", ctxt, &nodes)) < 0) { @@ -17520,7 +17530,7 @@ virDomainDefFormatInternal(virDomainDefPtr def, } if (def->ngraphics > 0) { - /* If graphics is enabled, add the implicit mouse */ + /* If graphics is enabled, add the implicit mouse/keyboard */ virDomainInputDef autoInput = { VIR_DOMAIN_INPUT_TYPE_MOUSE, STREQ(def->os.type, "hvm") ? @@ -17531,6 +17541,12 @@ virDomainDefFormatInternal(virDomainDefPtr def, if (virDomainInputDefFormat(buf, &autoInput, flags) < 0) goto error; + if (!(flags & VIR_DOMAIN_XML_MIGRATABLE)) { + autoInput.type = VIR_DOMAIN_INPUT_TYPE_KBD; + if (virDomainInputDefFormat(buf, &autoInput, flags) < 0) + goto error; + } + for (n = 0; n < def->ngraphics; n++) if (virDomainGraphicsDefFormat(buf, def->graphics[n], flags) < 0) goto error; diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h index bef4a3d4b8..fcc84e6984 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -1239,6 +1239,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 }; diff --git a/tests/qemuhotplugtestdata/qemuhotplug-console-compat-2+console-virtio.xml b/tests/qemuhotplugtestdata/qemuhotplug-console-compat-2+console-virtio.xml index d75af19bd9..a484e82341 100644 --- a/tests/qemuhotplugtestdata/qemuhotplug-console-compat-2+console-virtio.xml +++ b/tests/qemuhotplugtestdata/qemuhotplug-console-compat-2+console-virtio.xml @@ -104,6 +104,7 @@ + diff --git a/tests/qemuxml2argvdata/qemuxml2argv-console-compat-2.xml b/tests/qemuxml2argvdata/qemuxml2argv-console-compat-2.xml index 37e8e00a9a..065ef2d732 100644 --- a/tests/qemuxml2argvdata/qemuxml2argv-console-compat-2.xml +++ b/tests/qemuxml2argvdata/qemuxml2argv-console-compat-2.xml @@ -99,6 +99,7 @@ + diff --git a/tests/qemuxml2argvdata/qemuxml2argv-graphics-listen-network.xml b/tests/qemuxml2argvdata/qemuxml2argv-graphics-listen-network.xml index b0054405f5..98b7d6a9bb 100644 --- a/tests/qemuxml2argvdata/qemuxml2argv-graphics-listen-network.xml +++ b/tests/qemuxml2argvdata/qemuxml2argv-graphics-listen-network.xml @@ -23,6 +23,7 @@ + diff --git a/tests/qemuxml2argvdata/qemuxml2argv-graphics-listen-network2.xml b/tests/qemuxml2argvdata/qemuxml2argv-graphics-listen-network2.xml index 870ef55710..aa458d7a47 100644 --- a/tests/qemuxml2argvdata/qemuxml2argv-graphics-listen-network2.xml +++ b/tests/qemuxml2argvdata/qemuxml2argv-graphics-listen-network2.xml @@ -22,6 +22,7 @@ + diff --git a/tests/qemuxml2argvdata/qemuxml2argv-graphics-sdl-fullscreen.xml b/tests/qemuxml2argvdata/qemuxml2argv-graphics-sdl-fullscreen.xml index 7793161c2b..4aa385c186 100644 --- a/tests/qemuxml2argvdata/qemuxml2argv-graphics-sdl-fullscreen.xml +++ b/tests/qemuxml2argvdata/qemuxml2argv-graphics-sdl-fullscreen.xml @@ -24,6 +24,7 @@ +