Re: [libvirt] [PATCH v9 2/7] conf: Add a keyboard input device type

2014-02-19 Thread Ján Tomko
On 02/19/2014 07:22 AM, Li Zhang wrote:
 On 2014年02月18日 20:51, Ján Tomko wrote:
 On 02/17/2014 11:17 AM, Li Zhang wrote:
 From: Li Zhang zhlci...@linux.vnet.ibm.com

 There is no keyboard support currently in libvirt .
 For some platforms, it needs to add a USB keyboard when graphics are 
 enabled.

 This patch is to add keyboard input device type.

 Signed-off-by: Li Zhang zhlci...@linux.vnet.ibm.com
 ---
   docs/schemas/domaincommon.rng  |  1 +
   src/conf/domain_conf.c | 70
 --
   src/conf/domain_conf.h |  1 +
 ...
   tests/vmx2xmldata/vmx2xml-graphics-vnc.xml |  1 +
   27 files changed, 66 insertions(+), 31 deletions(-)

 This fails 'make check' for me:
 FAIL: sexpr2xmltest
 FAIL: xmconfigtest
 
 Ah, I can't get any errors when doing 'make check' on my side. :(
 

Libvirt needs to be built --with-xen for those tests to work. You probably
don't have the xen library headers on your system.

Jan




signature.asc
Description: OpenPGP digital signature
--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list

Re: [libvirt] [PATCH v9 2/7] conf: Add a keyboard input device type

2014-02-18 Thread Ján Tomko
On 02/17/2014 11:17 AM, Li Zhang wrote:
 From: Li Zhang zhlci...@linux.vnet.ibm.com
 
 There is no keyboard support currently in libvirt .
 For some platforms, it needs to add a USB keyboard when graphics are enabled.
 
 This patch is to add keyboard input device type.
 
 Signed-off-by: Li Zhang zhlci...@linux.vnet.ibm.com
 ---
  docs/schemas/domaincommon.rng  |  1 +
  src/conf/domain_conf.c | 70 
 --
  src/conf/domain_conf.h |  1 +
...
  tests/vmx2xmldata/vmx2xml-graphics-vnc.xml |  1 +
  27 files changed, 66 insertions(+), 31 deletions(-)
 

This fails 'make check' for me:
FAIL: sexpr2xmltest
FAIL: xmconfigtest


 @@ -7805,9 +7806,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  /* PS2 can be mouse 
 or keyboard */
 +!(def-type == VIR_DOMAIN_INPUT_TYPE_MOUSE ||
 +def-type == VIR_DOMAIN_INPUT_TYPE_KBD)) {

This is easier to read as:
def-type != MOUSE  def-type != KBD

  virReportError(VIR_ERR_INTERNAL_ERROR,
 _(ps2 bus does not support %s input device),
 type);

 @@ -7833,8 +7836,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)) 

Trailing space breaks 'make syntax-check'

  def-bus = VIR_DOMAIN_INPUT_BUS_PS2;
  else
  def-bus = VIR_DOMAIN_INPUT_BUS_USB;

 @@ -12491,29 +12497,26 @@ 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) { 

Another trailing space.

 +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)) {

Xen has hvm domains too, and since we were adding the mouse for non-hvm
domains, I think we should get rid of this condition and add keyboards too (I
think this is different from what I said earlier)

 +if (virDomainDefMaybeAddInput(def,
 +  VIR_DOMAIN_INPUT_TYPE_KBD,
 +  input_bus)  0)
 +goto error;
  }
 -def-inputs[def-ninputs] = input;
 -def-ninputs++;
  }
  
 -
  /* analysis of the sound devices */
  if ((n = virXPathNodeSet(./devices/sound, ctxt, nodes))  0) {
  goto error;

 diff --git a/tests/qemuxml2argvdata/qemuxml2argv-graphics-spice-timeout.xml 
 b/tests/qemuxml2argvdata/qemuxml2argv-graphics-spice-timeout.xml
 index f9fdf37..341322c 100644
 --- a/tests/qemuxml2argvdata/qemuxml2argv-graphics-spice-timeout.xml
 +++ b/tests/qemuxml2argvdata/qemuxml2argv-graphics-spice-timeout.xml
 @@ -71,7 +71,9 @@
  /console
  input type='tablet' bus='usb'/
  input type='mouse' bus='ps2'/
 +input type='keyboard' bus='ps2'/
  graphics type='spice' port='5900' autoport='no' passwd='sercet' 
 passwdValidTo='2011-05-31T16:11:22' connected='disconnect'/
 +input type='keyboard' bus='ps2'/
  sound model='ac97'
address type='pci' domain='0x' bus='0x00' slot='0x03' 
 function='0x0'/
  /sound

Double keyboard entry.

ACK with this squashed in:

diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 5031441..75b87d1 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -7808,9 +7808,9 @@ virDomainInputDefParseXML(const virDomainDef *dom,
 }

 if (STREQ(dom-os.type, hvm)) {
-  

[libvirt] [PATCH v9 2/7] conf: Add a keyboard input device type

2014-02-17 Thread Li Zhang
From: Li Zhang zhlci...@linux.vnet.ibm.com

There is no keyboard support currently in libvirt .
For some platforms, it needs to add a USB keyboard when graphics are enabled.

This patch is to add keyboard input device type.

Signed-off-by: Li Zhang zhlci...@linux.vnet.ibm.com
---
 docs/schemas/domaincommon.rng  |  1 +
 src/conf/domain_conf.c | 70 --
 src/conf/domain_conf.h |  1 +
 ...qemuhotplug-console-compat-2+console-virtio.xml |  1 +
 .../qemuxml2argv-console-compat-2.xml  |  1 +
 .../qemuxml2argv-graphics-listen-network.xml   |  1 +
 .../qemuxml2argv-graphics-listen-network2.xml  |  1 +
 .../qemuxml2argv-graphics-sdl-fullscreen.xml   |  1 +
 .../qemuxml2argvdata/qemuxml2argv-graphics-sdl.xml |  1 +
 .../qemuxml2argv-graphics-spice-compression.xml|  1 +
 .../qemuxml2argv-graphics-spice-qxl-vga.xml|  1 +
 .../qemuxml2argv-graphics-spice-timeout.xml|  2 +
 .../qemuxml2argv-graphics-spice.xml|  1 +
 .../qemuxml2argv-graphics-vnc-policy.xml   |  1 +
 .../qemuxml2argv-graphics-vnc-sasl.xml |  1 +
 .../qemuxml2argv-graphics-vnc-socket.xml   |  1 +
 .../qemuxml2argv-graphics-vnc-tls.xml  |  1 +
 .../qemuxml2argv-graphics-vnc-websocket.xml|  1 +
 .../qemuxml2argvdata/qemuxml2argv-graphics-vnc.xml |  1 +
 tests/qemuxml2argvdata/qemuxml2argv-input-xen.xml  |  1 +
 .../qemuxml2argv-net-bandwidth.xml |  1 +
 tests/qemuxml2argvdata/qemuxml2argv-pci-bridge.xml |  1 +
 .../qemuxml2argvdata/qemuxml2argv-pseries-disk.xml |  1 +
 .../qemuxml2argv-serial-spiceport.xml  |  1 +
 .../qemuxml2xmlout-graphics-listen-network2.xml|  1 +
 .../qemuxml2xmlout-graphics-spice-timeout.xml  |  1 +
 tests/vmx2xmldata/vmx2xml-graphics-vnc.xml |  1 +
 27 files changed, 66 insertions(+), 31 deletions(-)

diff --git a/docs/schemas/domaincommon.rng b/docs/schemas/domaincommon.rng
index c1efcd2..601e7ac 100644
--- a/docs/schemas/domaincommon.rng
+++ b/docs/schemas/domaincommon.rng
@@ -3269,6 +3269,7 @@
 choice
   valuetablet/value
   valuemouse/value
+  valuekeyboard/value
 /choice
   /attribute
   optional
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 1c24440..c475d87 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -506,7 +506,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,
@@ -7772,7 +7773,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)
 {
@@ -7805,9 +7806,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  /* PS2 can be mouse or 
keyboard */
+!(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);
@@ -7825,7 +7827,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);
@@ -7833,8 +7836,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;
@@ -9856,7 +9860,7 @@ virDomainDeviceDefParse(const char *xmlStr,
 goto error;
 break;
 case VIR_DOMAIN_DEVICE_INPUT:
-if (!(dev-data.input =