[virt-tools-list] [PATCH] virtinst: ignore comments in keymap conf files

Jim Fehlig jfehlig at suse.com
Wed Oct 11 21:13:26 UTC 2017


On a host system with keyboard configured to en-US, it was noticed
that virt-install created install XML with keymap='de'. The host
system did not have /etc/vconsole.conf, so /etc/sysconfig/keyboard
was the next file to check, which contained the following

# Path:        Hardware/Keyboard
## Description: Keyboard settings
## Type:        string
## Default:     ""
## ServiceRestart: kbd
#
# Keyboard settings for the text console
#
# Keyboard mapping
# (/usr/share/kbd/keymaps/)
# e.g. KEYTABLE="de-latin1-nodeadkeys", "us" or empty for US settings
#
KEYTABLE=""

Currently the parsing code does not ignore comments and incorrectly
parsed a 'de' keymap. Fix by ignoring any lines that start with '#'
after trimming whitespace.
---
 virtinst/hostkeymap.py | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/virtinst/hostkeymap.py b/virtinst/hostkeymap.py
index 71503730..562d0f99 100644
--- a/virtinst/hostkeymap.py
+++ b/virtinst/hostkeymap.py
@@ -71,6 +71,9 @@ def _sysconfig_keyboard(f):
         s = f.readline()
         if s == "":
             break
+        s = s.strip()
+        if (s.startswith("#")):
+            continue
         if (re.search("KEYMAP", s) is not None or
             re.search("KEYTABLE", s) is not None or
            (re.search("KEYBOARD", s) is not None and
-- 
2.12.3




More information about the virt-tools-list mailing list