daemon: debug segv correct use of dereferencing NULL.
[libguestfs.git] / rescue / virt-rescue.pod
index c24d9ec..050db48 100755 (executable)
@@ -10,6 +10,8 @@ virt-rescue - Run a rescue shell on a virtual machine
 
  virt-rescue [--options] -a disk.img [-a disk.img ...]
 
+ virt-rescue --suggest (-d domname | -a disk.img ...)
+
 Old style:
 
  virt-rescue [--options] domname
@@ -51,19 +53,45 @@ rescue appliance.  You must mount the virtual machine's filesystems by
 hand.  There is an empty directory called C</sysroot> where you can
 mount filesystems.
 
-In the example below, we list logical volumes, then choose one to
-mount under C</sysroot>:
+You can get virt-rescue to suggest mount commands for you by using the
+I<--suggest> option (in another terminal):
+
+ $ virt-rescue --suggest -d Fedora15
+ Inspecting the virtual machine or disk image ...
+ This disk contains one or more operating systems.  You can use these
+ mount commands in virt-rescue (at the ><rescue> prompt) to mount the
+ filesystems.
+ # /dev/vg_f15x32/lv_root is the root of a linux operating system
+ # type: linux, distro: fedora, version: 15.0
+ # Fedora release 15 (Lovelock)
+ mount /dev/vg_f15x32/lv_root /sysroot/
+ mount /dev/vda1 /sysroot/boot
+ mount --bind /dev /sysroot/dev
+ mount --bind /dev/pts /sysroot/dev/pts
+ mount --bind /proc /sysroot/proc
+ mount --bind /sys /sysroot/sys
+
+Another way is to list the logical volumes (with L<lvs(8)>) and
+partitions (with L<parted(8)>) and mount them by hand:
 
  ><rescue> lvs
  LV      VG        Attr   LSize   Origin Snap%  Move Log Copy%  Convert
- lv_root vg_f11x64 -wi-a-   8.83G
- lv_swap vg_f11x64 -wi-a- 992.00M
- ><rescue> mount /dev/vg_f11x64/lv_root /sysroot
+ lv_root vg_f15x32 -wi-a-   8.83G
+ lv_swap vg_f15x32 -wi-a- 992.00M
+ ><rescue> mount /dev/vg_f15x32/lv_root /sysroot
+ ><rescue> mount /dev/vda1 /sysroot/boot
  ><rescue> ls /sysroot
 
-If you don't know what filesystems are available on the virtual
-machine then you can use commands such as L<parted(8)> and L<lvs(8)>
-to find out.
+Another command to list available filesystems is
+L<virt-filesystems(1)>.
+
+To run commands in a Linux guest (for example, grub), you should
+chroot into the /sysroot directory first:
+
+ ><rescue> chroot /sysroot
 
 =head2 NOTES
 
@@ -73,6 +101,9 @@ want to partition that file (although we would recommend using
 L<guestfish(1)> instead as it is more suitable for this purpose).  You
 can even use virt-rescue on things like SD cards.
 
+Virt-rescue does not require root.  You only need to run it as root if
+you need root to open the disk image.
+
 This tool is just designed for quick interactive hacking on a virtual
 machine.  For more structured access to a virtual machine disk image,
 you should use L<guestfs(3)>.  To get a structured shell that you can
@@ -115,7 +146,8 @@ not used at all.
 
 =item B<--domain> guest
 
-Add all the disks from the named libvirt guest.
+Add all the disks from the named libvirt guest.  Domain UUIDs can be
+used instead of names.
 
 =item B<--format=raw|qcow2|..>
 
@@ -139,8 +171,7 @@ auto-detection for C<another.img>.
 
 If you have untrusted raw-format guest disk images, you should use
 this option to specify the disk format.  This avoids a possible
-security problem with malicious guests (CVE-2010-3851).  See also
-L</add-drive-opts>.
+security problem with malicious guests (CVE-2010-3851).
 
 =item B<-m MB>
 
@@ -153,7 +184,7 @@ parameter is specified in megabytes.
 
 =item B<--network>
 
-Enable QEMU user networking in the guest.
+Enable QEMU user networking in the guest.  See L</NETWORK>.
 
 =item B<-r>
 
@@ -165,11 +196,26 @@ The option must always be used if the disk image or virtual machine
 might be running, and is generally recommended in cases where you
 don't need write access to the disk.
 
+See also L<guestfish(1)/OPENING DISKS FOR READ AND WRITE>.
+
 =item B<--selinux>
 
 Enable SELinux in the rescue appliance.  You should read
 L<guestfs(3)/SELINUX> before using this option.
 
+=item B<--smp> N
+
+Enable N E<ge> 2 virtual CPUs in the rescue appliance.
+
+=item B<--suggest>
+
+Inspect the disk image and suggest what mount commands should be used
+to mount the disks.  You should use the I<--suggest> option in a
+second terminal, then paste the commands into another virt-rescue.
+
+This option implies I<--ro> and is safe to use even if the guest is up
+or if another virt-rescue is running.
+
 =item B<-v>
 
 =item B<--verbose>
@@ -182,6 +228,15 @@ Enable verbose messages for debugging.
 
 Display version number and exit.
 
+=item B<-w>
+
+=item B<--rw>
+
+This changes the I<-a> and I<-d> options so that disks are
+added and mounts are done read-write.
+
+See L<guestfish(1)/OPENING DISKS FOR READ AND WRITE>.
+
 =item B<-x>
 
 Enable tracing of libguestfs API calls.
@@ -204,6 +259,42 @@ name as a guest.
 
 For compatibility the old style is still supported.
 
+=head1 NETWORK
+
+Adding the I<--network> option enables QEMU user networking
+in the rescue appliance.  There are some differences between
+user networking and ordinary networking:
+
+=over 4
+
+=item ping does not work
+
+Because the ICMP ECHO_REQUEST protocol generally requires root in
+order to send the ping packets, and because virt-rescue must be able
+to run as non-root, QEMU user networking is not able to emulate the
+L<ping(8)> command.  The ping command will appear to resolve addresses
+but will not be able to send or receive any packets.  This does not
+mean that the network is not working.
+
+=item cannot receive connections
+
+QEMU user networking cannot receive incoming connections.
+
+=item making TCP connections
+
+The virt-rescue appliance needs to be small and so does not include
+many network tools.  In particular there is no L<telnet(1)> command.
+You can make TCP connections from the shell using the magical
+C</dev/tcp/E<lt>hostnameE<gt>/E<lt>portE<gt>> syntax:
+
+ exec 3<>/dev/tcp/redhat.com/80
+ echo "GET /" >&3
+ cat <&3
+
+See L<bash(1)> for more details.
+
+=back
+
 =head1 ENVIRONMENT VARIABLES
 
 Several environment variables affect virt-rescue.  See
@@ -216,12 +307,28 @@ have meaning to the shell such as C<#> and space.  You may need to
 quote or escape these characters on the command line.  See the shell
 manual page L<sh(1)> for details.
 
+=head1 FILES
+
+=over 4
+
+=item $HOME/.libguestfs-tools.rc
+
+=item /etc/libguestfs-tools.conf
+
+This configuration file controls the default read-only or read-write
+mode (I<--ro> or I<--rw>).
+
+See L<guestfish(1)/OPENING DISKS FOR READ AND WRITE>.
+
+=back
+
 =head1 SEE ALSO
 
 L<guestfs(3)>,
 L<guestfish(1)>,
 L<virt-cat(1)>,
 L<virt-edit(1)>,
+L<virt-filesystems(1)>,
 L<http://libguestfs.org/>.
 
 =head1 AUTHOR
@@ -230,7 +337,7 @@ Richard W.M. Jones L<http://people.redhat.com/~rjones/>
 
 =head1 COPYRIGHT
 
-Copyright (C) 2009-2010 Red Hat Inc.
+Copyright (C) 2009-2011 Red Hat Inc.
 
 This program is free software; you can redistribute it and/or modify
 it under the terms of the GNU General Public License as published by
@@ -244,4 +351,4 @@ GNU General Public License for more details.
 
 You should have received a copy of the GNU General Public License
 along with this program; if not, write to the Free Software
-Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.