On 02/17/2014 11:17 AM, Li Zhang wrote:
From: Li Zhang <zhlcindy(a)linux.vnet.ibm.com>
This patch is to add one new interface to add input devices.
Signed-off-by: Li Zhang <zhlcindy(a)linux.vnet.ibm.com>
---
src/conf/domain_conf.c | 29 +++++++++++++++++++++++++++++
src/conf/domain_conf.h | 4 ++++
src/libvirt_private.syms | 1 +
3 files changed, 34 insertions(+)
ACK with the following whitespace changes and with the hunk using this
function moved from 2/7 here:
Jan
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 794153d..939b423 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -11051,11 +11051,10 @@ virDomainDefMaybeAddController(virDomainDefPtr def,
}
-
int
virDomainDefMaybeAddInput(virDomainDefPtr def,
- int type,
- int bus)
+ int type,
+ int bus)
{
size_t i;
virDomainInputDefPtr input;
@@ -11080,6 +11079,7 @@ virDomainDefMaybeAddInput(virDomainDefPtr def,
return 0;
}
+
/* Parse a memory element located at XPATH within CTXT, and store the
* result into MEM. If REQUIRED, then the value must exist;
* otherwise, the value is optional. The value is in blocks of 1024.
@@ -12493,25 +12493,15 @@ virDomainDefParseXML(xmlDocPtr xml,
/* If graphics are enabled, there's an implicit PS2 mouse */
if (def->ngraphics > 0) {
- virDomainInputDefPtr input;
+ 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;
- }
- def->inputs[def->ninputs] = input;
- def->ninputs++;
}