3 # Copyright (C) 2009 Red Hat Inc.
5 # This program is free software; you can redistribute it and/or modify
6 # it under the terms of the GNU General Public License as published by
7 # the Free Software Foundation; either version 2 of the License, or
8 # (at your option) any later version.
10 # This program is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 # GNU General Public License for more details.
15 # You should have received a copy of the GNU General Public License
16 # along with this program; if not, write to the Free Software
17 # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
23 use Sys::Guestfs::Lib qw(open_guest get_partitions resolve_windows_path
24 inspect_all_partitions inspect_partition
25 inspect_operating_systems mount_operating_system inspect_in_detail);
29 use File::Temp qw/tempdir/;
36 virt-v2v - Convert Xen or VMWare guests to KVM
40 virt-v2v xen_name -o kvm_name
42 virt-v2v guest.ovf.zip -o kvm_name
44 virt-v2v guest.img [guest.img ...]
48 Virt-v2v converts guests from one virtualization hypervisor to
49 another. Currently it is limited in what it can convert. See the
52 -------------------------------+----------------------------
54 -------------------------------+----------------------------
55 Xen domain managed by |
59 - PV or FV kernel | KVM guest managed by
60 - with or without PV drivers | libvirt
61 - RHEL 3.9+, 4.8+, 5.3+ | - with virtio drivers
64 -------------------------------+
66 VMWare VMDK image with |
67 OVF metadata, exported from |
70 VMWare compatibility: |
71 - RHEL 3.9+, 4.8+, 5.3+ |
74 -------------------------------+----------------------------
76 =head2 CONVERTING XEN DOMAINS
78 For Xen domains managed by libvirt, perform the initial conversion
81 virt-v2v xen_name -o kvm_name
83 where C<xen_name> is the libvirt Xen domain name, and C<kvm_name> is
84 the (new) name for the converted KVM guest.
86 Then test boot the new guest in KVM:
91 When you have verified that this works, shut down the new KVM domain
92 and I<commit> the changes by doing:
94 virt-v2v --commit kvm_name
96 I<This command will destroy the original Xen domain>.
98 Or you can I<rollback> to the original Xen domain by doing:
100 virt-v2v --rollback kvm_name
102 B<Very important note:> Do I<not> try to run both the original Xen
103 domain and the KVM domain at the same time! This will cause guest
106 =head2 CONVERTING VMWARE GUESTS
108 I<This section to be written>
132 Display version number and exit.
138 =item B<--connect URI> | B<-c URI>
140 If using libvirt, connect to the given I<URI>. If omitted,
141 then we connect to the default libvirt hypervisor.
143 Libvirt is only used if you specify a C<domname> on the
144 command line. If you specify guest block devices directly,
145 then libvirt is not used at all.
151 =item B<--output name> | B<-o name>
153 Set the output guest name.
161 GetOptions ("help|?" => \$help,
162 "version" => \$version,
163 "connect|c=s" => \$uri,
164 "output|o=s" => \$output,
166 pod2usage (1) if $help;
168 my $g = Sys::Guestfs->new ();
169 my %h = $g->version ();
170 print "$h{major}.$h{minor}.$h{release}$h{extra}\n";
173 pod2usage ("$0: no image or VM names given") if @ARGV == 0;
175 # XXX This should be an option. Disable for now until we get
176 # downloads working reliably.
177 my $use_windows_registry = 0;
179 my @params = (\@ARGV);
181 push @params, address => $uri;
183 my ($g, $conn, $dom) = open_guest (@params);
188 # List of possible filesystems.
189 my @partitions = get_partitions ($g);
191 # Now query each one to build up a picture of what's in it.
193 inspect_all_partitions ($g, \@partitions,
194 use_windows_registry => $use_windows_registry);
196 #print "fses -----------\n";
197 #print Dumper(\%fses);
199 my $oses = inspect_operating_systems ($g, \%fses);
201 #print "oses -----------\n";
202 #print Dumper($oses);
204 # We should probably refuse to do anything with those rare
205 # multiboot VMs at this point ... (XXX)
207 # Mount up the disks and check for applications.
210 foreach $root_dev (sort keys %$oses) {
211 my $os = $oses->{$root_dev};
212 mount_operating_system ($g, $os);
213 inspect_in_detail ($g, $os);
238 L<virt-inspector(1)>,
242 L<Sys::Guestfs::Lib(3)>,
244 L<http://libguestfs.org/>.
246 For Windows registry parsing we require the C<reged> program
247 from L<http://home.eunet.no/~pnordahl/ntpasswd/>.
251 Richard W.M. Jones L<http://et.redhat.com/~rjones/>
253 Matthew Booth L<mbooth@redhat.com>
257 Copyright (C) 2009 Red Hat Inc.
259 This program is free software; you can redistribute it and/or modify
260 it under the terms of the GNU General Public License as published by
261 the Free Software Foundation; either version 2 of the License, or
262 (at your option) any later version.
264 This program is distributed in the hope that it will be useful,
265 but WITHOUT ANY WARRANTY; without even the implied warranty of
266 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
267 GNU General Public License for more details.
269 You should have received a copy of the GNU General Public License
270 along with this program; if not, write to the Free Software
271 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.