[libvirt] [PATCH 0/3]generate man pages to describe valid keycodes

This patchset will try to generate manpages to describe valid keycodes. It does this job via a helper perl script passing file src/util/keymaps.csv. we have 1 man page per keycode set, that is, 11 manpages to be generated in total. Each of them corresponds to codeset defined in virsh manpage. libvirt-keycode-linux.5 libvirt-keycode-xt.5 libvirt-keycode-atset1.5 libvirt-keycode-atset2.5 libvirt-keycode-atset3.5 libvirt-keycode-os_x.5 libvirt-keycode-kbd.5 libvirt-keycode-win32.5 libvirt-keycode-usb.5 libvirt-keycode-rfb.5 I really think that the words in these manpages still be polished again. If anyone could help, that would be appreciated. Guannan Ren(3) doc: Add a perl script to generate keycodes mapping automake: generate libvirt keycodes manpages doc: fix some typoes on virsh manpage .gitignore | 2 +- tools/Makefile.am | 31 +++++++++++++++++++++++++--- tools/keymap-gen.pl | 202 +++++++++++++++++++++++++++++++++++++++++++++ tools/virsh.pod | 27 +++++++++++++------------ 4 files changed, 245 insertions(+), 17 deletions(-)

This script helps generate keycode mapping table in files of POD format. These files are used for producing manpage such as: libvirt-keycode-linux.5 libvirt-keycode-xt.5 libvirt-keycode-xt_kbd.5 libvirt-keycode-xt_atset1.5 ... --- tools/keymap-gen.pl | 202 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 202 insertions(+) create mode 100644 tools/keymap-gen.pl diff --git a/tools/keymap-gen.pl b/tools/keymap-gen.pl new file mode 100644 index 0000000..ac22b59 --- /dev/null +++ b/tools/keymap-gen.pl @@ -0,0 +1,202 @@ +#!/usr/bin/perl + +use strict; +use warnings; + +my %names = ( + linux => [], + os_x => [], + win32 => [], + ); + +my %namecolumns = ( + linux => 0, + os_x => 2, + win32 => 10, + ); + +my %mapcolumns = ( + os_x => 3, + atset1 => 4, + atset2 => 5, + atset3 => 6, + xt => 7, + xt_kbd => 8, + usb => 9, + win32 => 11, + xwinxt => 12, + xkbdxt => 13, + ); + +my @libvirtmaps = qw(linux xt atset1 atset2 atset3 os_x xt_kbd win32 usb rfb); +my @basemaps = qw(linux os_x atset1 atset2 atset3 xt xt_kbd usb win32 xwinxt xkbdxt); +my @derivedmaps = qw(xorgevdev xorgkbd xorgxquartz xorgxwin rfb); +my @maps = (@basemaps, @derivedmaps); + +my %maps; + +foreach my $map (@maps) { + $maps{$map} = []; +} + +sub help { + my $msg = shift; + print $msg; + print "\n"; + exit (1); +} + +if ($#ARGV != 0) { + help("syntax: $0 KEYMAPS \n"); +} + +my $keymaps = shift @ARGV; + +open CSV, $keymaps + or die "cannot read $keymaps: $!"; + +# Discard column headings +scalar <CSV>; + +my @row; +while (<CSV>) { + chomp; + @row = split /,/; + + my $linux = $row[1]; + + $linux = hex($linux) if $linux =~ /0x/; + + my $codeset = $maps{linux}; + $codeset->[$linux] = $linux; + + foreach my $name (keys %namecolumns) { + my $col = $namecolumns{$name}; + my $val = $row[$col]; + + $val = "" unless defined $val; + $names{$name}->[$linux] = $val; + } + + foreach my $name (keys %mapcolumns) { + my $col = $mapcolumns{$name}; + my $val = $row[$col]; + + next unless defined $val && $val ne ""; + $val = hex($val) if $val =~ /0x/; + + $codeset = $maps{$name}; + $codeset->[$linux] = $val; + } + + # XXX there are some special cases in kbd to handle + # Xorg KBD driver is the Xorg KBD XT codes offset by +8 + # The XKBD XT codes are the same as normal XT codes + # for values <= 83, and completely made up for extended + # scancodes :-( + $codeset = $maps{xorgkbd}; + if (defined $maps{xkbdxt}->[$linux]) { + $codeset->[$linux] = $maps{xkbdxt}->[$linux] + 8; + } + + # Xorg evdev is simply Linux keycodes offset by +8 + $codeset = $maps{xorgevdev}; + $codeset->[$linux] = $linux + 8; + + # Xorg XQuartz is simply OS-X keycodes offset by +8 + $codeset = $maps{xorgxquartz}; + if (defined $maps{os_x}->[$linux]) { + $codeset->[$linux] = $maps{os_x}->[$linux] + 8; + } + + # RFB keycodes are XT kbd keycodes with a slightly + # different encoding of 0xe0 scan codes. RFB uses + # the high bit of the first byte, instead of the low + # bit of the second byte. + $codeset = $maps{rfb}; + my $xtkbd = $maps{xtk_bd}->[$linux]; + if (defined $xtkbd) { + $codeset->[$linux] = $xtkbd ? (($xtkbd & 0x100)>>1) | ($xtkbd & 0x7f) : 0; + } + + # Xorg Cygwin is the Xorg Cygwin XT codes offset by +8 + # The Cygwin XT codes are the same as normal XT codes + # for values <= 83, and completely made up for extended + # scancodes :-( + $codeset = $maps{xorgxwin}; + if (defined $maps{xwinxt}->[$linux]) { + $codeset->[$linux] = $maps{xwinxt}->[$linux] + 8; + } +} + +close CSV; + +sub podfile_producer { + + my $dst = shift; + my $POD = shift; + my $srcmap = $maps{linux}; + my $dstmap = $maps{$dst}; + + printf $POD "=head1 Name\n\n"; + printf $POD "%s - linux codes mapping table\n\n", $dst; + + printf $POD "=head1 DESCRIPTION\n\n"; + + if ($dst eq "linux") { + printf $POD "This is a B<linux> codeset table. The decimal numeric values +in the first column are Linux Keycode. The symbolic names in the second column +match the corresponding Linux key constant macro names.\n\n"; + + } else { + printf $POD "This is a B<linux> vs B<%s> codes mapping table. The decimal numeric values +in the first column are Linux Keycode. The symbolic names in the second column +match the corresponding Linux key constant macro names. The third column lists B<%s> +decimal numeric code values mapping to B<linux> as well as its symbolic names which will +be list in the fourth column if provided.\n\n", $dst, $dst; + } + + printf $POD "=over 4\n\n"; + printf $POD "=item B<linux(symbolic names)> B<%s(symbolic names)>\n\n", $dst; + printf $POD "=back\n\n"; + + for (my $i = 0 ; $i <= $#{$srcmap} ; $i++) { + my $linux = $srcmap->[$i] || 0; + my $j = $dstmap->[$linux]; + next unless $linux && $j; + + my $srcname = $names{linux}->[$linux]; + my $dstname = $names{$dst}->[$linux] if exists $names{$dst}; + + $srcname = "" unless $srcname; + $dstname = "" unless $dstname; + $srcname = " ($srcname)" if $srcname; + $dstname = " ($dstname)" if $dstname; + + my $linuxcodeset = sprintf "%d%s", $i, $srcname; + + if ($dst eq "linux") { + printf $POD " %s\n", $linuxcodeset; + } else { + printf $POD " %-30s%d%s\n", $linuxcodeset, $j, $dstname; + } + } + + printf $POD "\n=head1 COPYRIGHT\n\n"; + printf $POD "Copyright (C) 2012 Red Hat, Inc.\n\n"; + + printf $POD "=head1 SEE ALSO\n\n"; + printf $POD "L<virsh(1)>, online instructions C<http://libvirt.org/locking.html>\n\n"; + + printf $POD "=cut\n"; +} + +foreach (@libvirtmaps) { + my $podfile = sprintf "libvirt-keycode-%s.in", $_; + + open my $POD, "> $podfile" + or die "cannot write $podfile: $!"; + + podfile_producer($_, $POD); + close($POD); +} -- 1.7.11.2

tools/Makefile.am: add make rules for manpages tools/virsh.pod: add reference to keycodes manpages .gitignore: ignore manpage files --- .gitignore | 2 +- tools/Makefile.am | 31 ++++++++++++++++++++++++++++--- tools/virsh.pod | 21 ++++++++++++--------- 3 files changed, 41 insertions(+), 13 deletions(-) diff --git a/.gitignore b/.gitignore index d998f0e..d0cd2bd 100644 --- a/.gitignore +++ b/.gitignore @@ -168,7 +168,7 @@ /tests/vmx2xmltest /tests/xencapstest /tests/xmconfigtest -/tools/*.[18] +/tools/*.[158] /tools/libvirt-guests.init /tools/libvirt-guests.service /tools/virsh diff --git a/tools/Makefile.am b/tools/Makefile.am index 0d7822d..370601c 100644 --- a/tools/Makefile.am +++ b/tools/Makefile.am @@ -33,10 +33,11 @@ EXTRA_DIST = \ virsh-network.c virsh-nodedev.c \ virsh-nwfilter.c virsh-pool.c \ virsh-secret.c virsh-snapshot.c \ - virsh-volume.c - + virsh-volume.c \ + keymap-gen.pl +BUILT_SOURCES = DISTCLEANFILES = bin_SCRIPTS = virt-xml-validate virt-pki-validate @@ -47,11 +48,29 @@ sbin_SCRIPTS = virt-sanlock-cleanup DISTCLEANFILES += virt-sanlock-cleanup endif +LIBVIRT_KEYCODESET= \ + libvirt-keycode-linux.5 \ + libvirt-keycode-xt.5 \ + libvirt-keycode-atset1.5 \ + libvirt-keycode-atset2.5 \ + libvirt-keycode-atset3.5 \ + libvirt-keycode-os_x.5 \ + libvirt-keycode-xt_kbd.5 \ + libvirt-keycode-win32.5 \ + libvirt-keycode-usb.5 \ + libvirt-keycode-rfb.5 + +BUILT_SOURCES += $(LIBVIRT_KEYCODESET) + dist_man1_MANS = \ virt-host-validate.1 \ virt-pki-validate.1 \ virt-xml-validate.1 \ virsh.1 + +dist_man5_MANS = \ + $(LIBVIRT_KEYCODESET) + if HAVE_SANLOCK dist_man8_MANS = virt-sanlock-cleanup.8 endif @@ -81,6 +100,13 @@ virt-sanlock-cleanup: virt-sanlock-cleanup.in Makefile virt-sanlock-cleanup.8: virt-sanlock-cleanup.in $(AM_V_GEN)$(POD2MAN) --name VIRT-SANLOCK-CLEANUP $< $(srcdir)/$@ +libvirt-keycode-%.in: keymap-gen.pl ../src/util/keymaps.csv + $(AM_V_GEN)$(PERL) keymap-gen.pl ../src/util/keymaps.csv + +libvirt-keycode-%.5: libvirt-keycode-%.in + $(AM_V_GEN)$(POD2MAN) --name VIRT-CODESET $< $@ + + virt_host_validate_SOURCES = \ virt-host-validate.c \ virt-host-validate-common.c virt-host-validate-common.h \ @@ -133,7 +159,6 @@ virsh_CFLAGS = \ $(COVERAGE_CFLAGS) \ $(LIBXML_CFLAGS) \ $(READLINE_CFLAGS) -BUILT_SOURCES = if WITH_WIN_ICON virsh_LDADD += virsh_win_icon.$(OBJEXT) diff --git a/tools/virsh.pod b/tools/virsh.pod index 68138e5..fc7ce67 100644 --- a/tools/virsh.pod +++ b/tools/virsh.pod @@ -1252,53 +1252,55 @@ be chosen. The numeric values are those defined by the Linux generic input event subsystem. The symbolic names match the corresponding -Linux key constant macro names. +Linux key constant macro names. See L<libvirt-keycode-linux(5)> =item B<xt> The numeric values are those defined by the original XT keyboard -controller. No symbolic names are provided +controller. No symbolic names are provided. See L<libvirt-keycode-xt(5)> =item B<atset1> The numeric values are those defined by the AT keyboard controller, set 1 (aka XT compatible set). Extended keycoes from B<atset1> may differ from extended keycodes in the B<xt> codeset. No symbolic -names are provided +names are provided. See L<libvirt-keycode-atset1(5)> =item B<atset2> The numeric values are those defined by the AT keyboard controller, -set 2. No symbolic names are provided +set 2. No symbolic names are provided. See L<libvirt-keycode-atset2(5)> =item B<atset3> The numeric values are those defined by the AT keyboard controller, -set 3 (aka PS/2 compatible set). No symbolic names are provided +set 3 (aka PS/2 compatible set). No symbolic names are provided. +See L<libvirt-keycode-atset3(5)> =item B<os_x> The numeric values are those defined by the OS-X keyboard input subsystem. The symbolic names match the corresponding OS-X key -constant macro names +constant macro names. See L<libvirt-keycode-os_x(5)> =item B<xt_kbd> The numeric values are those defined by the Linux KBD device. These are a variant on the original XT codeset, but often with different encoding for extended keycodes. No symbolic names are -provided. +provided. See L<libvirt-keycode-kbd(5)> =item B<win32> The numeric values are those defined by the Win32 keyboard input subsystem. The symbolic names match the corresponding Win32 key -constant macro names +constant macro names. See L<libvirt-keycode-win32(5)> =item B<usb> The numeric values are those defined by the USB HID specification -for keyboard input. No symbolic names are provided +for keyboard input. No symbolic names are provided. +See L<libvirt-keycode-usb(5)> =item B<rfb> @@ -1306,6 +1308,7 @@ The numeric values are those defined by the RFB extension for sending raw keycodes. These are a variant on the XT codeset, but extended keycodes have the low bit of the second byte set, instead of the high bit of the first byte. No symbolic names are provided. +See L<libvirt-keycode-rfb(5)> =back -- 1.7.11.2

--- tools/virsh.pod | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/tools/virsh.pod b/tools/virsh.pod index fc7ce67..e7df72c 100644 --- a/tools/virsh.pod +++ b/tools/virsh.pod @@ -686,7 +686,7 @@ address of virtual interface (such as I<detach-interface> or I<domif-setlink>) will accept the MAC address printed by this command. =item B<blockcopy> I<domain> I<path> I<dest> [I<bandwidth>] [I<--shallow>] -[I<--reuse-external>] [I<--raw>] [I<--wait> [I<--verbose] +[I<--reuse-external>] [I<--raw>] [I<--wait> [I<--verbose>] [{I<--pivot> | I<--finish>}] [I<--timeout> B<seconds>] [I<--async>]] Copy a disk backing image chain to I<dest>. By default, this command @@ -727,7 +727,7 @@ I<path> specifies fully-qualified path of the disk. I<bandwidth> specifies copying bandwidth limit in MiB/s. =item B<blockpull> I<domain> I<path> [I<bandwidth>] [I<base>] -[I<--wait> [I<--verbose>] [I<--timeout> B<seconds>] [I<--async]] +[I<--wait> [I<--verbose>] [I<--timeout> B<seconds>] [I<--async>]] Populate a disk from its backing image chain. By default, this command flattens the entire chain; but if I<base> is specified, containing the @@ -2825,8 +2825,6 @@ the result will also be converted back from QMP. If more than one argument is provided for I<command>, they are concatenated with a space in between before passing the single command to the monitor. -=back - =item B<qemu-agent-command> I<domain> [I<--timeout> I<seconds> | I<--async> | I<--block>] I<command>... Send an arbitrary guest agent command I<command> to domain I<domain> through -- 1.7.11.2

On 2012年09月07日 21:54, Guannan Ren wrote:
--- tools/virsh.pod | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)
diff --git a/tools/virsh.pod b/tools/virsh.pod index fc7ce67..e7df72c 100644 --- a/tools/virsh.pod +++ b/tools/virsh.pod @@ -686,7 +686,7 @@ address of virtual interface (such as I<detach-interface> or I<domif-setlink>) will accept the MAC address printed by this command.
=item B<blockcopy> I<domain> I<path> I<dest> [I<bandwidth>] [I<--shallow>] -[I<--reuse-external>] [I<--raw>] [I<--wait> [I<--verbose] +[I<--reuse-external>] [I<--raw>] [I<--wait> [I<--verbose>] [{I<--pivot> | I<--finish>}] [I<--timeout> B<seconds>] [I<--async>]]
Copy a disk backing image chain to I<dest>. By default, this command @@ -727,7 +727,7 @@ I<path> specifies fully-qualified path of the disk. I<bandwidth> specifies copying bandwidth limit in MiB/s.
=item B<blockpull> I<domain> I<path> [I<bandwidth>] [I<base>] -[I<--wait> [I<--verbose>] [I<--timeout> B<seconds>] [I<--async]] +[I<--wait> [I<--verbose>] [I<--timeout> B<seconds>] [I<--async>]]
[I<--timeout> B<seconds>] is not documented. Deserved to fix it together.
Populate a disk from its backing image chain. By default, this command flattens the entire chain; but if I<base> is specified, containing the @@ -2825,8 +2825,6 @@ the result will also be converted back from QMP. If more than one argument is provided for I<command>, they are concatenated with a space in between before passing the single command to the monitor.
-=back -
Why remove this?
=item B<qemu-agent-command> I<domain> [I<--timeout> I<seconds> | I<--async> | I<--block>] I<command>...
Send an arbitrary guest agent command I<command> to domain I<domain> through

On 09/18/2012 10:25 AM, Osier Yang wrote:
On 2012年09月07日 21:54, Guannan Ren wrote:
--- tools/virsh.pod | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)
diff --git a/tools/virsh.pod b/tools/virsh.pod index fc7ce67..e7df72c 100644 --- a/tools/virsh.pod +++ b/tools/virsh.pod @@ -686,7 +686,7 @@ address of virtual interface (such as I<detach-interface> or I<domif-setlink>) will accept the MAC address printed by this command.
=item B<blockcopy> I<domain> I<path> I<dest> [I<bandwidth>] [I<--shallow>] -[I<--reuse-external>] [I<--raw>] [I<--wait> [I<--verbose] +[I<--reuse-external>] [I<--raw>] [I<--wait> [I<--verbose>] [{I<--pivot> | I<--finish>}] [I<--timeout> B<seconds>] [I<--async>]]
Copy a disk backing image chain to I<dest>. By default, this command @@ -727,7 +727,7 @@ I<path> specifies fully-qualified path of the disk. I<bandwidth> specifies copying bandwidth limit in MiB/s.
=item B<blockpull> I<domain> I<path> [I<bandwidth>] [I<base>] -[I<--wait> [I<--verbose>] [I<--timeout> B<seconds>] [I<--async]] +[I<--wait> [I<--verbose>] [I<--timeout> B<seconds>] [I<--async>]]
[I<--timeout> B<seconds>] is not documented. Deserved to fix it together.
Populate a disk from its backing image chain. By default, this command flattens the entire chain; but if I<base> is specified, containing the @@ -2825,8 +2825,6 @@ the result will also be converted back from QMP. If more than one argument is provided for I<command>, they are concatenated with a space in between before passing the single command to the monitor.
-=back -
Why remove this?
It should be a duplicate one. It cause errors showed at the bottom of virsh manpage like: POD ERRORS Hey! The above document had some coding errors, which are explained below: Around line 2837: '=item' outside of any '=over'

On 09/07/2012 09:54 PM, Guannan Ren wrote:
This patchset will try to generate manpages to describe valid keycodes. It does this job via a helper perl script passing file src/util/keymaps.csv. we have 1 man page per keycode set, that is, 11 manpages to be generated in total. Each of them corresponds to codeset defined in virsh manpage.
libvirt-keycode-linux.5 libvirt-keycode-xt.5 libvirt-keycode-atset1.5 libvirt-keycode-atset2.5 libvirt-keycode-atset3.5 libvirt-keycode-os_x.5 libvirt-keycode-kbd.5 libvirt-keycode-win32.5 libvirt-keycode-usb.5 libvirt-keycode-rfb.5
I really think that the words in these manpages still be polished again. If anyone could help, that would be appreciated.
Guannan Ren(3) doc: Add a perl script to generate keycodes mapping automake: generate libvirt keycodes manpages doc: fix some typoes on virsh manpage
.gitignore | 2 +- tools/Makefile.am | 31 +++++++++++++++++++++++++--- tools/keymap-gen.pl | 202 +++++++++++++++++++++++++++++++++++++++++++++ tools/virsh.pod | 27 +++++++++++++------------ 4 files changed, 245 insertions(+), 17 deletions(-)
-- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
ping :)
participants (2)
-
Guannan Ren
-
Osier Yang