[libvirt] [PATCH v8 3/7] conf: Remove the implicit PS2 mouse for non-X86 platforms and add an implicit PS2 keyboard device for X86 platforms.
Li Zhang
zhlcindy at gmail.com
Mon Feb 17 09:04:01 UTC 2014
On 2014年02月17日 16:48, Ján Tomko wrote:
> On 02/17/2014 08:33 AM, Li Zhang wrote:
>> From: Li Zhang <zhlcindy at linux.vnet.ibm.com>
>>
>> PS2 device only works for X86 platform, other platforms may need
>> USB mouse. Athough it doesn't influence the QEMU command line, but
>> it's not right to add one PS2 mouse for non-X86 platform.
>>
>> What's more, PS2 keyboard can be supported for X86.
>>
>> So, this patch is to remove PS2 mouse for non-x86 platforms and also add
>> an implicit PS2 keyboard device for X86.
>>
>> Signed-off-by: Li Zhang <zhlcindy at linux.vnet.ibm.com>
>> ---
>> diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
>> index 3301398..10c753c 100644
>> --- a/src/conf/domain_conf.c
>> +++ b/src/conf/domain_conf.c
>> @@ -12495,29 +12496,27 @@ virDomainDefParseXML(xmlDocPtr xml,
>> VIR_FREE(nodes);
>>
>> /* If graphics are enabled, there's an implicit PS2 mouse */
>> - if (def->ngraphics > 0) {
>> - virDomainInputDefPtr input;
>> + if (def->ngraphics > 0 &&
>> + ARCH_IS_X86(def->os.arch)) {
>> + int input_bus = VIR_DOMAIN_INPUT_BUS_XEN;
>>
>> - if (VIR_ALLOC(input) < 0) {
>> - goto error;
>> - }
>> - if (STREQ(def->os.type, "hvm")) {
>> - input->type = VIR_DOMAIN_INPUT_TYPE_MOUSE;
>> - input->bus = VIR_DOMAIN_INPUT_BUS_PS2;
>> - } else {
>> - input->type = VIR_DOMAIN_INPUT_TYPE_MOUSE;
>> - input->bus = VIR_DOMAIN_INPUT_BUS_XEN;
>> - }
>> + if (STREQ(def->os.type, "hvm"))
>> + input_bus = VIR_DOMAIN_INPUT_BUS_PS2;
>>
>> - if (VIR_REALLOC_N(def->inputs, def->ninputs + 1) < 0) {
>> - virDomainInputDefFree(input);
>> + if (virDomainDefMaybeAddInput(def,
>> + VIR_DOMAIN_INPUT_TYPE_MOUSE,
>> + input_bus) < 0)
>> goto error;
>> +
>> + /*Ignore keyboard for XEN, only add a PS2 keyboard device for hvm*/
>> + if (STREQ(def->os.type, "hvm")) {
>> + if (virDomainDefMaybeAddInput(def,
>> + VIR_DOMAIN_INPUT_TYPE_KBD,
>> + input_bus) < 0)
>> + goto error;
>> }
> Adding the default keyboard should be in the patch that adds it to the parser
> according to
> https://www.redhat.com/archives/libvir-list/2014-February/msg00889.html
Do you mean merge this patch to the first patch?
>
>> - def->inputs[def->ninputs] = input;
>> - def->ninputs++;
>> }
>>
>> -
>> /* analysis of the sound devices */
>> if ((n = virXPathNodeSet("./devices/sound", ctxt, &nodes)) < 0) {
>> goto error;
>> @@ -17533,16 +17532,24 @@ virDomainDefFormatInternal(virDomainDefPtr def,
>> }
>>
>> if (def->ngraphics > 0) {
>> - /* If graphics is enabled, add the implicit mouse */
>> - virDomainInputDef autoInput = {
>> - VIR_DOMAIN_INPUT_TYPE_MOUSE,
>> - STREQ(def->os.type, "hvm") ?
>> - VIR_DOMAIN_INPUT_BUS_PS2 : VIR_DOMAIN_INPUT_BUS_XEN,
>> - { .alias = NULL },
>> - };
>> + /* If graphics is enabled, add the implicit mouse/keyboard */
>> + if ((ARCH_IS_X86(def->os.arch)) ||
>> + def->os.arch == VIR_ARCH_NONE) {
>> + virDomainInputDef autoInput = {
>> + VIR_DOMAIN_INPUT_TYPE_MOUSE,
>> + STREQ(def->os.type, "hvm") ?
>> + VIR_DOMAIN_INPUT_BUS_PS2 : VIR_DOMAIN_INPUT_BUS_XEN,
>> + { .alias = NULL },
>> + };
>> + if (virDomainInputDefFormat(buf, &autoInput, flags) < 0)
>> + goto error;
>>
>> - if (virDomainInputDefFormat(buf, &autoInput, flags) < 0)
>> - goto error;
>> + if (flags & ~VIR_DOMAIN_XML_MIGRATABLE) {
> This condition is true, if any other flag than MIGRATABLE is true.
> It should be if (!(flags & VIR_DOMAIN_XML_MIGRATABLE)) and also a part fo the
> patch adding 'keyboard' to the parser.
>
>> + 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)
> Jan
>
More information about the libvir-list
mailing list