4 # Copyright (C) 2009 Red Hat Inc.
6 # This program is free software; you can redistribute it and/or modify
7 # it under the terms of the GNU General Public License as published by
8 # the Free Software Foundation; either version 2 of the License, or
9 # (at your option) any later version.
11 # This program is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 # GNU General Public License for more details.
16 # You should have received a copy of the GNU General Public License
17 # along with this program; if not, write to the Free Software
18 # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
29 hostinfo-test - make or test hostinfo requests from a virtual machine
33 hostinfo-test [--options]
37 I<Note:> It only makes sense to use this command from inside
38 a guest (virtual machine).
40 This command is used to make/test hostinfo requests. You can
41 use this to test that the hostinfo system is working end-to-end.
48 error: no response ping request
68 Display version number and exit.
72 my $serial = "/dev/ttyS1";
74 =item B<--serial /dev/ttyS?> | B<-s /dev/ttyS?>
76 Select the serial device to use. The default is C</dev/ttyS1>.
78 If you use the wrong serial device, you will get no response from
79 hostinfo commands, so choosing the correct device is important. To
80 find out which serial device to use, you should get the host system
81 administrator to run L<hostinfo-status(8)> on the host.
87 =item B<--verbose> | B<-v>
93 GetOptions ("help|?" => \$help,
94 "version" => \$version,
95 "serial|s=s" => \$serial,
96 "verbose|v" => \$verbose,
98 pod2usage (1) if $help;
104 # Set the serial port to raw mode, no echo.
105 system ("stty raw -echo < $serial") == 0 or die "stty: $?";
107 open SERIAL, "+<$serial" or die "$serial: $!";
110 my @chars = ('a'..'z', 'A'..'Z', '0'..'9');
111 $echodata .= $chars[rand @chars] foreach (1..16);
113 print qq{<<< PING "$echodata"\n} if $verbose;
114 print SERIAL qq{PING "$echodata"\r\n};
116 local $SIG{ALRM} = sub { die "error: no response from ping test\n" };
119 my $input = <SERIAL>;
120 print ">>> $input" if $verbose;
124 if ($input !~ /^1\.\d+ 200 $echodata/) {
125 die "error: incorrect or unexpected response from ping test\n";
130 =head1 TROUBLESHOOTING
136 Use I<-v> option to get more verbose messages.
140 Look in the system log files on the host.
144 Follow the I<TROUBLESHOOTING> section in L<hostinfo(8)> manpage.
150 This command returns 0 if the test succeeded, or non-zero if the
151 command failed or there was some other error.
157 L<hostinfo-status(8)>,
158 L<hostinfo-protocol(5)>,
161 L<http://fedoraproject.org/wiki/Features/Hostinfo>,
162 L<http://libvirt.org/>.
166 Richard W.M. Jones (C<rjones at redhat dot com>)
170 Copyright (C) 2009 Red Hat Inc.
171 L<http://fedoraproject.org/wiki/Features/Hostinfo>
173 This program is free software; you can redistribute it and/or modify
174 it under the terms of the GNU General Public License as published by
175 the Free Software Foundation; either version 2 of the License, or
176 (at your option) any later version.
178 This program is distributed in the hope that it will be useful,
179 but WITHOUT ANY WARRANTY; without even the implied warranty of
180 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
181 GNU General Public License for more details.
183 You should have received a copy of the GNU General Public License
184 along with this program; if not, write to the Free Software
185 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.