render / rpms / libvirt

Forked from rpms/libvirt 10 months ago
Clone
c401cc
From bd1fffc449203a9a20de243d97dedde8f34cb951 Mon Sep 17 00:00:00 2001
c401cc
Message-Id: <bd1fffc449203a9a20de243d97dedde8f34cb951.1389183249.git.jdenemar@redhat.com>
c401cc
From: Michal Privoznik <mprivozn@redhat.com>
c401cc
Date: Mon, 6 Jan 2014 17:09:30 +0100
c401cc
Subject: [PATCH] virkeycode: Allow ANSI_A
c401cc
c401cc
https://bugzilla.redhat.com/show_bug.cgi?id=1044806
c401cc
c401cc
Currently, sending the ANSI_A keycode from os_x codepage doesn't work as
c401cc
it has a special value of 0x0. Our internal code handles that no
c401cc
different to other not defined keycodes. Hence, in order to allow it we
c401cc
must change all the undefined keycodes from 0 to -1 and adapt some code
c401cc
too.
c401cc
c401cc
  # virsh send-key guestname --codeset os_x ANSI_A
c401cc
  error: invalid keycode: 'ANSI_A'
c401cc
c401cc
  # virsh send-key guestname --codeset os_x ANSI_B
c401cc
  # virsh send-key guestname --codeset os_x ANSI_C
c401cc
c401cc
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
c401cc
(cherry picked from commit 72ffbd1bf3005907c604d94c13058c9e547d46e8)
c401cc
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
c401cc
---
c401cc
 src/util/virkeycode-mapgen.py | 4 ++--
c401cc
 src/util/virkeycode.c         | 4 ++--
c401cc
 tools/virsh-domain.c          | 6 +++---
c401cc
 3 files changed, 7 insertions(+), 7 deletions(-)
c401cc
c401cc
diff --git a/src/util/virkeycode-mapgen.py b/src/util/virkeycode-mapgen.py
c401cc
index 22b21b4..8360bfe 100755
c401cc
--- a/src/util/virkeycode-mapgen.py
c401cc
+++ b/src/util/virkeycode-mapgen.py
c401cc
@@ -86,12 +86,12 @@ for i in range(len(cols)):
c401cc
     if isname:
c401cc
         print "const char *virKeymapNames_" + name + "[] = {"
c401cc
     else:
c401cc
-        print "unsigned short virKeymapValues_" + name + "[] = {"
c401cc
+        print "int virKeymapValues_" + name + "[] = {"
c401cc
 
c401cc
     for entry in keycodes:
c401cc
         if isname:
c401cc
             print "  " + quotestring(entry[i] or "NULL") + ","
c401cc
         else:
c401cc
-            print "  " + (entry[i] or "0") + ","
c401cc
+            print "  " + (entry[i] or "-1") + ","
c401cc
 
c401cc
     print "};\n"
c401cc
diff --git a/src/util/virkeycode.c b/src/util/virkeycode.c
c401cc
index 50594d6..7880a0a 100644
c401cc
--- a/src/util/virkeycode.c
c401cc
+++ b/src/util/virkeycode.c
c401cc
@@ -50,7 +50,7 @@ static const char **virKeymapNames[] = {
c401cc
 };
c401cc
 verify(ARRAY_CARDINALITY(virKeymapNames) == VIR_KEYCODE_SET_LAST);
c401cc
 
c401cc
-static unsigned short *virKeymapValues[] = {
c401cc
+static int *virKeymapValues[] = {
c401cc
     [VIR_KEYCODE_SET_LINUX] =
c401cc
       virKeymapValues_linux,
c401cc
     [VIR_KEYCODE_SET_XT] =
c401cc
@@ -113,7 +113,7 @@ int virKeycodeValueTranslate(virKeycodeSet from_codeset,
c401cc
 {
c401cc
     size_t i;
c401cc
 
c401cc
-    if (key_value <= 0)
c401cc
+    if (key_value < 0)
c401cc
         return -1;
c401cc
 
c401cc
 
c401cc
diff --git a/tools/virsh-domain.c b/tools/virsh-domain.c
c401cc
index 9afe44a..3895f39 100644
c401cc
--- a/tools/virsh-domain.c
c401cc
+++ b/tools/virsh-domain.c
c401cc
@@ -6884,7 +6884,7 @@ vshKeyCodeGetInt(const char *key_name)
c401cc
 {
c401cc
     unsigned int val;
c401cc
 
c401cc
-    if (virStrToLong_ui(key_name, NULL, 0, &val) < 0 || val > 0xffff || !val)
c401cc
+    if (virStrToLong_ui(key_name, NULL, 0, &val) < 0 || val > 0xffff)
c401cc
         return -1;
c401cc
     return val;
c401cc
 }
c401cc
@@ -6925,8 +6925,8 @@ cmdSendKey(vshControl *ctl, const vshCmd *cmd)
c401cc
             goto cleanup;
c401cc
         }
c401cc
 
c401cc
-        if ((keycode = vshKeyCodeGetInt(opt->data)) <= 0) {
c401cc
-            if ((keycode = virKeycodeValueFromString(codeset, opt->data)) <= 0) {
c401cc
+        if ((keycode = vshKeyCodeGetInt(opt->data)) < 0) {
c401cc
+            if ((keycode = virKeycodeValueFromString(codeset, opt->data)) < 0) {
c401cc
                 vshError(ctl, _("invalid keycode: '%s'"), opt->data);
c401cc
                 goto cleanup;
c401cc
             }
c401cc
-- 
c401cc
1.8.5.2
c401cc