From: Li Zhang <zhlcindy(a)linux.vnet.ibm.com>
PPC64 doesn't have keyboard device when graphic is enabled. It needs to
add one default USB keyboard device for it when graphic is enabled.
This patch is to add the default USB keyboard for PPC64.
Signed-off-by: Li Zhang <zhlcindy(a)linux.vnet.ibm.com>
---
src/conf/domain_conf.c | 35 +++++++++++++++++++++++++++++++++++
src/conf/domain_conf.h | 4 ++++
src/libvirt_private.syms | 1 +
src/qemu/qemu_domain.c | 14 +++++++++++++-
4 files changed, 53 insertions(+), 1 deletion(-)
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index d90f05c..e64e95d 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -10762,6 +10762,41 @@ virDomainDefMaybeAddController(virDomainDefPtr def,
return 0;
}
+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) {
+ goto error;
+ }
+ input->type = type;
+ input->bus = bus;
+
+ if (VIR_REALLOC_N(def->inputs, def->ninputs + 1) < 0) {
+ virDomainInputDefFree(input);
+ goto error;
+ }
+
+ def->inputs[def->ninputs] = input;
+ def->ninputs ++;
+ return 0;
+
+error:
+ virReportOOMError();
+ return -1;
+}
+
+
/* Parse a memory element located at XPATH within CTXT, and store the
* result into MEM. If REQUIRED, then the value must exist;
diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h
index c8fecaf..f8a968c 100644
--- a/src/conf/domain_conf.h
+++ b/src/conf/domain_conf.h
@@ -2739,6 +2739,10 @@ virDomainDefMaybeAddController(virDomainDefPtr def,
int type,
int idx,
int model);
+int
+virDomainDefMaybeAddInput(virDomainDefPtr def,
+ int type,
+ int bus);
char *virDomainDefGetDefaultEmulator(virDomainDefPtr def, virCapsPtr caps);
diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
index a705c56..13d2419 100644
--- a/src/libvirt_private.syms
+++ b/src/libvirt_private.syms
@@ -165,6 +165,7 @@ virDomainDefGenSecurityLabelDef;
virDomainDefGetDefaultEmulator;
virDomainDefGetSecurityLabelDef;
virDomainDefMaybeAddController;
+virDomainDefMaybeAddInput;
virDomainDefNew;
virDomainDefParseFile;
virDomainDefParseNode;
diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
index 346fec3..b891a36 100644
--- a/src/qemu/qemu_domain.c
+++ b/src/qemu/qemu_domain.c
@@ -691,6 +691,7 @@ qemuDomainDefPostParse(virDomainDefPtr def,
bool addPCIRoot = false;
bool addPCIeRoot = false;
bool addDefaultMemballoon = true;
+ bool addDefaultUSBKBD = false;
/* check for emulator and create a default one if needed */
if (!def->emulator &&
@@ -728,9 +729,13 @@ qemuDomainDefPostParse(virDomainDefPtr def,
addDefaultMemballoon = false;
break;
+ case VIR_ARCH_PPC64:
+ addPCIRoot = true;
+ addDefaultUSBKBD = true;
+ break;
+
case VIR_ARCH_ALPHA:
case VIR_ARCH_PPC:
- case VIR_ARCH_PPC64:
case VIR_ARCH_PPCEMB:
case VIR_ARCH_SH4:
case VIR_ARCH_SH4EB:
@@ -783,6 +788,13 @@ qemuDomainDefPostParse(virDomainDefPtr def,
def->memballoon = memballoon;
}
+ if (addDefaultUSBKBD &&
+ def->ngraphics > 0 &&
+ virDomainDefMaybeAddInput(
+ def, VIR_DOMAIN_INPUT_TYPE_KBD,
+ VIR_DOMAIN_INPUT_BUS_USB) < 0)
+ return -1;
+
return 0;
}
--
1.8.2.1