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

Cole Robinson crobinso at redhat.com
Wed Oct 18 22:43:04 UTC 2017


On 10/11/2017 05:13 PM, Jim Fehlig wrote:
> 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
> 

Thanks, pushed now with the redundant parentheses dropped, and a test
suite tweak

- Cole




More information about the virt-tools-list mailing list