Improve copy function
[virt-p2v.git] / virt-p2v.pod
1 =head1 NAME
2
3 virt-p2v - P2V (physical to virtual machine) migration tool
4
5 =head1 SUMMARY
6
7 virt-p2v
8
9 =head1 DESCRIPTION
10
11 virt-p2v is a live CD for migrating physical machines to virtual
12 machine guests.
13
14 In the simplest mode of operation, you take a pre-built live CD ISO
15 from the main website (L<http://et.redhat.com/~rjones/virt-p2v/>) and
16 burn it to a CD-R.  Then insert the CD-R into the physical machine
17 which must be migrated, reboot, and follow the on-screen instructions.
18 See B<STANDARD USAGE> section below.
19
20 You may also build a customized live CD.  Typically this will contain
21 things like server details specific to your organization, so that the
22 live CD can run mostly or completely automatically.  See B<BUILDING A
23 CUSTOM LIVE CD> section below.
24
25 In both cases, files and disk images are transferred from the physical
26 machine over the network to the virtualization host machine over ssh.
27 Therefore C<sshd> must be running on the virtualization host, and must
28 be accessible to that host.  See B<SERVER REQUIREMENTS> section below.
29
30 The C<virt-p2v> script must only be run from the live CD.  It isn't
31 designed to run outside this environment and could do Bad Things to
32 your machine if you try it.  The script contains some checks to try to
33 stop you from doing this.
34
35 Virt-p2v does not modify the physical machine, its disks,
36 configuration etc.
37
38 =head1 STANDARD USAGE
39
40 After booting the live CD-R, you are presented with a series of
41 questions.  This section explains each question.
42
43 =over 4
44
45 =item Remote host
46
47 Enter the name or IP address of the virtualization host.  This is the
48 host running Xen (or any other virtualization system supported by
49 libvirt, eg. QEMU).  This host should be accessible on the network and
50 running an SSH daemon (C<sshd>).
51
52 =item Remote port
53
54 This is the port name or number of the SSH server on the remote host.
55 The default is C<22> which is the standard SSH port.
56
57 =item Remote directory
58
59 Enter the directory on the remote host where disk image(s) and
60 configuration file(s) must reside.
61
62 Note that if the remote host is running SELinux then you may not be
63 able to start a Xen guest unless its disk image(s) are located in the
64 default directory, C</var/lib/xen/images>.
65
66 =item Remote username
67
68 Enter the remote SSH username to use to log in to the remote host.
69
70 If you use the default username of C<root> then you should ensure that
71 remote root logins are enabled on the remote host
72 (ie. C<PermitRootLogin yes> in C</etc/ssh/sshd_config>).
73
74 =item Network configuration
75
76 Choose the way that the live CD configures network access.  The
77 current options are:
78
79 =over 4
80
81 =item Automatic configuration
82
83 In this mode, the live CD attempts to reuse the network configuration
84 from the physical machine's root filesystem.  You should probably try
85 this method even though occasionally it does not work.
86
87 =item Ask for fixed IP address and gateway
88
89 In this mode the live CD will ask you for a fixed IP address and
90 gateway address, and will configure your chosen interface with these.
91
92 =item Configure from the shell
93
94 In this mode you will be dropped into a command shell and you will
95 need to issue the correct sequence of C</sbin/ifconfig> commands in
96 order to configure the network interface.
97
98 A typical sequence of commands which should bring up the network
99 interface would be:
100
101  /sbin/ifconfig eth0 AA.BB.CC.DD
102  /sbin/route add default gw GG.HH.II.JJ eth0
103
104 where C<AA.BB.CC.DD> is the IP address and C<GG.HH.II.JJ> is the
105 gateway.
106
107 =item QEMU user network
108
109 This option configures the network for use inside a QEMU user network
110 (L<http://fabrice.bellard.free.fr/qemu/qemu-doc.html#SEC30>).  It
111 should only be used by developers.
112
113 =back
114
115 =item Devices
116
117 This question lists out all local block devices (hard disk drives and
118 similar) and asks you to choose which will be sent to the remote host.
119 You must send at least one block device.
120
121 =item Root device
122
123 This question lists out possible root filesystems and asks you to
124 choose the right one.  Choose the filesystem which would normally be
125 mounted as C</> on the system.
126
127 Virt-p2v performs some autodetection and is in most cases able to work
128 out which filesystems are possible root filesystems.  It displays what
129 it thinks is on each filesystem, but leaves it up to the user to make
130 a final decision.
131
132 The root filesystem is critical because it contains C</etc/fstab>.
133 This is used during P2V both to determine how other filesystems are
134 normally mounted on the machine, and because this file and others
135 under C</etc> may need to be modified during P2V conversion.
136
137 If the machine has more than one root filesystem (typically because
138 the machine is dual-booted with another operating system), then you
139 must choose only one of them to perform the P2V conversion on.
140
141 =item Hypervisor
142
143 This question asks you to choose the hypervisor / virtualization
144 system in use on the remote host.
145
146 If you select I<Xen>, I<QEMU> or I<KVM> then virt-p2v will produce a
147 configuration file which is customized for the selected system.  If
148 you select I<Other> then virt-p2v will produce a generic configuration
149 file which will probably require hand-modification to work.
150
151 See also L<http://libvirt.org/format.html>.
152
153 =item Machine architecture
154
155 This question asks you to choose the machine architecture.  Virt-p2v
156 can normally detect this, so you should leave it as I<Auto-detect>.
157
158 =item Memory
159
160 This question asks you to choose the amount of memory (RAM) in
161 megabytes assigned to the virtual machine.
162
163 If the entry is left blank, then virt-p2v will try to autodetect how
164 much RAM is present in the physical machine and use that, and this is
165 probably a good choice for most simple migrations.
166
167 =item Virtual CPUs
168
169 This question asks you to choose the number of virtual CPUs assigned
170 to the virtual machine.  Choosing C<1> causes the virtual machine to
171 be uniprocessor, and choosing some number greater than 1 causes the
172 virtual machine to be SMP.
173
174 If the entry is left blank, then virt-p2v will try to autodetect how
175 many CPU cores are present in the physical machine and use that, and
176 this is probably a good choice for most simple migrations.
177
178 =item MAC address
179
180 Here you should enter a MAC address for the virtual machine's emulated
181 network card.  MAC addresses are written as C<aa:bb:cc:dd:ee:ff> where
182 C<aa>, C<bb> etc are hexadecimal octets.
183
184 Leaving it blank will cause virt-p2v to choose a random MAC address
185 within the C<00:16:3e:..> space reserved for Xen guests.  These MAC
186 addresses are not tested for uniqueness so there is a very small
187 chance that they could coincide, which would leave a guest unable to
188 access the virtual network.
189
190 =item Compression
191
192 Choose whether to enable or disable compression on disk images as they
193 are copied across the network.
194
195 If enabled, the C<-C> option is passed to L<ssh(1)>.  On fast networks
196 this can sometimes be slower.
197
198 NB: The disk image is still stored uncompressed on the remote host
199 however this option is set.
200
201 =item Verify and proceed
202
203 In this step you are asked to verify the settings above.  If any are
204 incorrect, use the I<Back> button to navigate back to the setting.  If
205 all settings are correct, use the I<OK> button to begin the P2V
206 conversion.
207
208 =item Network autoconfiguration
209
210 If you selected network autoconfiguration above then virt-p2v tries to
211 autoconfigure the network and ping the remote host.  It then asks
212 I<Did automatic network configuration work?>
213
214 You should answer C<y> here if it worked.
215
216 Answering C<n> will drop you into a command shell.
217
218 You can also switch to another virtual console if you need to perform
219 additional tests.  See section B<GETTING A SHELL> below.
220
221 =item SSH connection
222
223 Unless you have set up an SSH key, or the SSH server on the remote
224 host allows passwordless logins, then for each file that has to be
225 transferred to the remote host you will need to confirm the identity
226 of the remote host and/or enter a password.
227
228 To understand more about this, please see the L<ssh(1)> manual page.
229
230 =back
231
232 =head2 BOOTING P2V GUEST ON VIRTUALIZATION HOST
233
234 Once the P2V conversion has been completed, and assuming it was
235 successful, you will find a configuration file and one or more disk
236 images on the remote host.
237
238 The files will be located in the directory selected, usually
239 C</var/lib/xen/images>.  The names of the files are made up of:
240
241 C<p2v-I<hostname>-I<YYYYMMDDHHMM>.conf> or
242 C<p2v-I<hostname>-I<YYYYMMDDHHMM>-hdI<X>.img>
243
244 To simply start up the guest, use the following commands as root:
245
246  virsh define p2v-foo-2008MMDDHHMM.conf
247  virsh start foo
248
249 For QEMU/KVM do:
250
251  virsh -c qemu:///system define p2v-foo-2008MMDDHHMM.conf
252  virsh -c qemu:///system start foo
253
254 For other hypervisors you will need to edit the configuration file and
255 read L<http://libvirt.org/uri.html>.
256
257 =head1 GETTING A SHELL
258
259 During all stages of P2V questions and conversion you can get a root
260 shell on the physical machine.  Use I<ALT> I<F2> keys to switch to the
261 second virtual console, then log in as I<root> with no password.
262
263 =head2 LOG FILE
264
265 Virt-p2v writes a detailed log file to C</tmp/virt-p2v.log>.  (Note
266 that this C</tmp> directory is a ramdisk on the live CD, not the same
267 as the C</tmp> directory of the physical machine, and more importantly
268 it disappears when the machine is rebooted).
269
270 If you are reporting a bug, please always supply this file.
271
272 =head1 SERVER REQUIREMENTS
273
274 The virtualization host (remote host) must be running an SSH daemon
275 (C<sshd>), accessible from the physical machine which is being
276 migrated.
277
278 Previous versions of virt-p2v could use a special virt-p2v server.
279 However this capability has been removed since there was practically
280 no benefit.
281
282 =head1 BUILDING A CUSTOM LIVE CD
283
284 To build a custom live CD you must download the source for virt-p2v
285 from L<http://et.redhat.com/~rjones/virt-p2v/> or from the Mercurial
286 source repository (see website for details).
287
288 Please read the C<README> file to find the dependencies which are all
289 in Fedora &gt; 8 or EPEL &gt; 5.
290
291 The steps to creating a custom live CD are:
292
293 =over 4
294
295 =item 1. Edit C<virt-p2v> and adjust defaults
296
297 Find the section "TO MAKE A CUSTOM virt-p2v SCRIPT ..." which is near
298 to the top of this file.  Edit the defaults in this section as
299 detailed below.
300
301 =item 2. C<virt-p2v --test> to verify your changes
302
303 This command should not print anything at all.  If it prints any
304 message, then you will need to fix the error by going back to the
305 first step.
306
307 =item 3. C<make build> or C<make update> to build a custom live CD
308
309 C<make build> will create a complete ISO from scratch.  C<make update>
310 can be used to build a "quick" developer ISO by updating an existing
311 ISO image.  See section B<ISO ATTACHMENTS> below for more details.
312
313 =item 4. Burn the ISO to a CD-R and test
314
315 =back
316
317 =head2 EDITING DEFAULTS IN THE C<virt-p2v> SCRIPT
318
319 For each default, setting it to C<None> will ask the user.  All of the
320 defaults are set to C<None> in the standard, uncustomized virt-p2v
321 script, and so the standard script asks all the questions.
322
323 You may edit C<virt-p2v> and change the defaults, in which case the
324 user will not be questioned.  In this way you can make the script
325 partially or fully automated.
326
327 I<Note about OCaml code:>  C<None> and C<Some foo> are similar to the
328 concept of a NULL pointer versus non-NULL pointer in other languages.
329 This a variant type defined as:
330
331 type E<945> option = None | Some of E<945>
332
333 =over 4
334
335 =item C<greeting>
336
337 If this is C<true> then we wait for a keypress after boot and at a
338 couple of other stages.  If set to C<false> then we try not to wait
339 for any keypresses (so more automated live CDs are possible).
340
341 =item C<remote_host>
342
343 Set this to C<Some "hostname"> or C<Some "IP-address"> to
344 provide the name of the remote host.
345
346 =item C<remote_port>
347
348 Set this to C<Some port> (eg. C<Some 22>) to provide the port number
349 of the remote host's SSH daemon.
350
351 =item C<remote_directory>
352
353 Set this to C<Some "path"> (eg. C<Some "/var/lib/xen/images">) to
354 provide the directory where we update P2V converted images and
355 configuration files.
356
357 =item C<remote_username>
358
359 Set this to C<Some "username"> (eg. C<Some "root">) to provide the SSH
360 username to use on the remote system.
361
362 =item C<devices_to_send>
363
364 Set this to a list of block devices to send to the remote system.
365 For example, C<Some ["sda"; "sdb"]>.
366
367 =item C<root_filesystem>
368
369 Set this to the name of the root filesystem.
370
371 For a disk partition (eg. C</dev/sda1>), use:
372
373  Some (Part ("sda", "1"))
374
375 For a logical volume (eg. C</dev/VolGroup00/LogVol00>), use:
376
377  Some (LV ("VolGroup00", "LogVol00"))
378
379 =item C<network>
380
381 Set this to the choice for network setup.  Use one of:
382
383 =over 4
384
385 =item C<Some Auto>
386
387 for auto-configuration
388
389 =item C<Some Static>
390
391 to specify the interface, address, netmask and gateway statically
392
393 =item C<Some Shell>
394
395 to launch a shell
396
397 =item C<Some QEMUUserNet>
398
399 to use a QEMU user network (developers only)
400
401 =back
402
403 =item C<static_network_config>
404
405 This setting only applies if C<network> is set to C<Some Static>,
406 in which case you should set this to the static network settings,
407 a tuple of (interface, address, netmask, gateway, nameserver):
408
409  Some ("eth0", "192.168.2.5", "255.255.255.0", "192.168.2.1", "192.168.2.1")
410
411 =item C<hypervisor>
412
413 Set this to the choice of hypervisor or virtualization system.  The
414 choices are: C<Some Xen>, C<Some QEMU> or C<Some KVM>.
415
416 =item C<architecture>
417
418 Set this to the architecture.  The choices are:
419 C<Some I386> (i386 and up, 32 bit),
420 C<Some X86_64> (AMD and Intel x86-64, 64 bit),
421 C<Some IA64> (Intel IA64),
422 C<Some PPC> (PowerPC, 32 bit),
423 C<Some PPC64> (PowerPC, 64 bit),
424 C<Some SPARC> (Sun SPARC, 32 bit),
425 C<Some SPARC64> (Sun SPARC, 64 bit),
426 C<OtherArch "foo"> (a hypothetical architecture called I<foo>), or
427 C<UnknownArch> to auto-detect the architecture.
428
429 =item C<memory>
430
431 Set this to the size of memory in megabytes, eg. C<Some 256>.  If you
432 set this to C<Some 0> then virt-p2v will try to autodetect the amount
433 of RAM installed on the physical machine.
434
435 =item C<vcpus>
436
437 Set this to the number of virtual CPUs, eg. C<Some 1>.  If you set
438 this to C<Some 0> then virt-p2v will try to autodetect the number of
439 CPU cores on the physical machine.
440
441 =item C<mac_address>
442
443 Set this to the MAC address for the virtual network card, eg. C<Some
444 "aa:bb:cc:dd:ee:ff">.  If you set this to C<Some ""> then virt-p2v
445 will choose a random MAC address within the C<00:16:3e:..> space
446 reserved for Xen guests.  These MAC addresses are not tested for
447 uniqueness so there is a very small chance that they could coincide,
448 which would leave a guest unable to access the virtual network.
449
450 =item C<compression>
451
452 Set this to C<Some false> to disable compression, or C<Some true> to
453 enable compression, or C<None> to ask the user.
454
455 =back
456
457 =head2 ISO ATTACHMENTS
458
459 Rebuilding a custom ISO is time-consuming.  You can make a "quick"
460 developer ISO by updating an existing ISO image with a new custom
461 C<virt-p2v> script.  This is useful for testing purposes.
462
463 From the source directory, assuming that you have downloaded or
464 built an existing C<virt-p2v-*.iso>, you can just do:
465
466  make update
467
468 or the equivalent manual command:
469
470  ./iso-attach virt-p2v-VERSION.iso virt-p2v
471
472 =head1 BOOTING FROM A USB KEY INSTEAD OF A CD
473
474 If you wish to boot from a USB keydrive, use the livecd-iso-to-disk
475 tool:
476
477  livecd-iso-to-disk virt-p2v-$VERSION.iso /dev/sdX1
478
479 (Replace /dev/sdX1 with the actual USB device).
480
481 In my experience I also had to set up a suitable MBR:
482
483  cat /usr/lib/syslinux/mbr.bin > /dev/sdX
484
485 =head1 TESTING AN ISO UNDER QEMU OR KVM
486
487 If you have a virtual guest running under QEMU or KVM then
488 you can test the P2V conversion process on the guest.
489
490 (Technically this is a V2V -- virtual to virtual -- conversion).
491
492 From the source directory do:
493
494  make boot HDA=qemuimage.img
495
496 where C<qemuimage.img> is the name of the QEMU/KVM image.
497
498 You can also supply an C<HDB> parameter to specify a second disk.
499
500 =head1 MAILING LIST
501
502 Please direct questions to the et-mgmt-tools mailing list
503 L<http://www.redhat.com/mailman/listinfo/et-mgmt-tools>
504 <et-mgmt-tools @ redhat . com>
505
506 =head1 SEE ALSO
507
508 L<virsh(1)>,
509 L<http://www.libvirt.org/ocaml/>,
510 L<http://www.libvirt.org/>,
511 L<http://et.redhat.com/~rjones/>,
512 L<http://caml.inria.fr/>
513
514 =head1 AUTHORS
515
516 Richard W.M. Jones <rjones @ redhat . com>
517
518 =head1 COPYRIGHT
519
520 (C) Copyright 2007-2008 Red Hat Inc., Richard W.M. Jones
521 http://libvirt.org/
522
523 This program is free software; you can redistribute it and/or modify
524 it under the terms of the GNU General Public License as published by
525 the Free Software Foundation; either version 2 of the License, or
526 (at your option) any later version.
527
528 This program is distributed in the hope that it will be useful,
529 but WITHOUT ANY WARRANTY; without even the implied warranty of
530 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
531 GNU General Public License for more details.
532
533 You should have received a copy of the GNU General Public License
534 along with this program; if not, write to the Free Software
535 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
536
537 =head1 REPORTING BUGS
538
539 Bugs can be viewed on the Red Hat Bugzilla page:
540 L<https://bugzilla.redhat.com/>.
541
542 If you find a bug in virt-p2v, please follow these steps to report it:
543
544 =over 4
545
546 =item 1. Check for existing bug reports
547
548 Go to L<https://bugzilla.redhat.com/> and search for similar bugs.
549 Someone may already have reported the same bug, and they may even
550 have fixed it.
551
552 =item 2. Capture debug and error messages
553
554 At the point where you get the error or unexpected behaviour,
555 go to the second virtual console (I<ALT> I<F2>) and look at
556 the logfile C</tmp/virt-p2v.log>.  Please make sure that
557 this file is attached to your bug report.
558
559 =item 3. Get version of virt-p2v
560
561 The version is in the name of the ISO.  If you have built a custom
562 virt-p2v ISO, please describe any changes that you have made.
563
564 =item 4. Submit a bug report.
565
566 Go to L<https://bugzilla.redhat.com/> and enter a new bug.
567 Please describe the problem in as much detail as possible.
568
569 Remember to include the version number (step 3) and to
570 attach the log file (step 2).
571
572 =item 5. Assign the bug to rjones @ redhat.com
573
574 Assign or reassign the bug to B<rjones @ redhat.com> (without the
575 spaces).  You can also send me an email with the bug number if you
576 want a faster response.
577
578 =back