提交 f608a713 编写于 作者: L Li Zhang 提交者: Ján Tomko

conf: Add one interface to add default input devices

Use it for the default mouse.
Signed-off-by: NLi Zhang <zhlcindy@linux.vnet.ibm.com>
Signed-off-by: NJán Tomko <jtomko@redhat.com>
上级 4d882944
...@@ -11051,6 +11051,35 @@ virDomainDefMaybeAddController(virDomainDefPtr def, ...@@ -11051,6 +11051,35 @@ virDomainDefMaybeAddController(virDomainDefPtr def,
} }
int
virDomainDefMaybeAddInput(virDomainDefPtr def,
int type,
int bus)
{
size_t i;
virDomainInputDefPtr input;
for (i = 0; i < def->ninputs; i++) {
if (def->inputs[i]->type == type &&
def->inputs[i]->bus == bus)
return 0;
}
if (VIR_ALLOC(input) < 0)
return -1;
input->type = type;
input->bus = bus;
if (VIR_APPEND_ELEMENT(def->inputs, def->ninputs, input) < 0) {
VIR_FREE(input);
return -1;
}
return 0;
}
/* Parse a memory element located at XPATH within CTXT, and store the /* Parse a memory element located at XPATH within CTXT, and store the
* result into MEM. If REQUIRED, then the value must exist; * result into MEM. If REQUIRED, then the value must exist;
* otherwise, the value is optional. The value is in blocks of 1024. * otherwise, the value is optional. The value is in blocks of 1024.
...@@ -12464,25 +12493,15 @@ virDomainDefParseXML(xmlDocPtr xml, ...@@ -12464,25 +12493,15 @@ virDomainDefParseXML(xmlDocPtr xml,
/* If graphics are enabled, there's an implicit PS2 mouse */ /* If graphics are enabled, there's an implicit PS2 mouse */
if (def->ngraphics > 0) { if (def->ngraphics > 0) {
virDomainInputDefPtr input; int input_bus = VIR_DOMAIN_INPUT_BUS_XEN;
if (VIR_ALLOC(input) < 0) { if (STREQ(def->os.type, "hvm"))
goto error; input_bus = VIR_DOMAIN_INPUT_BUS_PS2;
}
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 (VIR_REALLOC_N(def->inputs, def->ninputs + 1) < 0) { if (virDomainDefMaybeAddInput(def,
virDomainInputDefFree(input); VIR_DOMAIN_INPUT_TYPE_MOUSE,
input_bus) < 0)
goto error; goto error;
}
def->inputs[def->ninputs] = input;
def->ninputs++;
} }
......
...@@ -2806,6 +2806,10 @@ virDomainDefMaybeAddController(virDomainDefPtr def, ...@@ -2806,6 +2806,10 @@ virDomainDefMaybeAddController(virDomainDefPtr def,
int type, int type,
int idx, int idx,
int model); int model);
int
virDomainDefMaybeAddInput(virDomainDefPtr def,
int type,
int bus);
char *virDomainDefGetDefaultEmulator(virDomainDefPtr def, virCapsPtr caps); char *virDomainDefGetDefaultEmulator(virDomainDefPtr def, virCapsPtr caps);
......
...@@ -165,6 +165,7 @@ virDomainDefGenSecurityLabelDef; ...@@ -165,6 +165,7 @@ virDomainDefGenSecurityLabelDef;
virDomainDefGetDefaultEmulator; virDomainDefGetDefaultEmulator;
virDomainDefGetSecurityLabelDef; virDomainDefGetSecurityLabelDef;
virDomainDefMaybeAddController; virDomainDefMaybeAddController;
virDomainDefMaybeAddInput;
virDomainDefNew; virDomainDefNew;
virDomainDefParseFile; virDomainDefParseFile;
virDomainDefParseNode; virDomainDefParseNode;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册