mirror of
https://github.com/libguestfs/libguestfs.git
synced 2026-03-21 22:53:37 +00:00
Added outline of the virt-v2v script.
This commit is contained in:
2
.gitignore
vendored
2
.gitignore
vendored
@@ -68,6 +68,7 @@ html/guestfish.1.html
|
||||
html/guestfs.3.html
|
||||
html/recipes.html
|
||||
html/virt-inspector.1.html
|
||||
html/virt-v2v.1.html
|
||||
images/100kallnewlines
|
||||
images/100kallspaces
|
||||
images/100kallzeroes
|
||||
@@ -158,3 +159,4 @@ src/guestfs-structs.h
|
||||
src/.pod2text.data
|
||||
src/stamp-generator
|
||||
stamp-h1
|
||||
v2v/virt-v2v.1
|
||||
|
||||
3
HACKING
3
HACKING
@@ -85,6 +85,9 @@ src/
|
||||
Source code to the C library.
|
||||
Also contains the crucial generator program.
|
||||
|
||||
v2v/
|
||||
Xen to KVM (V2V) conversion tool.
|
||||
|
||||
Debugging
|
||||
----------------------------------------------------------------------
|
||||
|
||||
|
||||
@@ -41,6 +41,9 @@ endif
|
||||
if HAVE_INSPECTOR
|
||||
SUBDIRS += inspector
|
||||
endif
|
||||
if HAVE_V2V
|
||||
SUBDIRS += v2v
|
||||
endif
|
||||
|
||||
EXTRA_DIST = \
|
||||
config.rpath \
|
||||
@@ -124,6 +127,7 @@ html/recipes.html: $(wildcard recipes/*.sh) $(wildcard recipes/*.html) $(wildcar
|
||||
|
||||
HTMLFILES = html/guestfs.3.html html/guestfish.1.html \
|
||||
html/virt-inspector.1.html \
|
||||
html/virt-v2v.1.html \
|
||||
html/recipes.html \
|
||||
html/pod.css html/recipes.css
|
||||
|
||||
|
||||
@@ -506,7 +506,7 @@ AC_CHECK_PROG([GHC],[ghc],[ghc],[no])
|
||||
AM_CONDITIONAL([HAVE_HASKELL],
|
||||
[test "x$GHC" != "xno"])
|
||||
|
||||
dnl Check for Perl modules needed by the inspector.
|
||||
dnl Check for Perl modules needed by the inspector and V2V.
|
||||
missing_perl_modules=no
|
||||
for pm in Pod::Usage Getopt::Long Sys::Virt Data::Dumper XML::Writer; do
|
||||
AC_MSG_CHECKING([for $pm])
|
||||
@@ -518,11 +518,13 @@ for pm in Pod::Usage Getopt::Long Sys::Virt Data::Dumper XML::Writer; do
|
||||
fi
|
||||
done
|
||||
if test "x$missing_perl_modules" = "xyes"; then
|
||||
AC_MSG_WARN([some Perl modules required to compile virt-inspector are missing])
|
||||
AC_MSG_WARN([some Perl modules required to compile virt-inspector and virt-v2v are missing])
|
||||
fi
|
||||
|
||||
AM_CONDITIONAL([HAVE_INSPECTOR],
|
||||
[test "x$PERL" != "xno" -a "x$missing_perl_modules" != "xyes"])
|
||||
AM_CONDITIONAL([HAVE_V2V],
|
||||
[test "x$PERL" != "xno" -a "x$missing_perl_modules" != "xyes"])
|
||||
|
||||
dnl Library versioning.
|
||||
MAX_PROC_NR=`cat $srcdir/src/MAX_PROC_NR`
|
||||
@@ -558,6 +560,7 @@ AC_CONFIG_FILES([Makefile
|
||||
java/Makefile
|
||||
haskell/Makefile
|
||||
inspector/Makefile
|
||||
v2v/Makefile
|
||||
libguestfs.pc
|
||||
ocaml/META perl/Makefile.PL])
|
||||
AC_OUTPUT
|
||||
@@ -585,6 +588,8 @@ echo -n "Haskell bindings .................... "
|
||||
if test "x$HAVE_HASKELL" = "x"; then echo "yes"; else echo "no"; fi
|
||||
echo -n "virt-inspector ...................... "
|
||||
if test "x$HAVE_INSPECTOR" = "x"; then echo "yes"; else echo "no"; fi
|
||||
echo -n "virt-v2v ............................ "
|
||||
if test "x$HAVE_V2V" = "x"; then echo "yes"; else echo "no"; fi
|
||||
echo "supermin appliance .................. $enable_supermin"
|
||||
echo
|
||||
echo "If any optional component is configured 'no' when you expected 'yes'"
|
||||
|
||||
48
v2v/Makefile.am
Normal file
48
v2v/Makefile.am
Normal file
@@ -0,0 +1,48 @@
|
||||
# libguestfs virt-v2v
|
||||
# Copyright (C) 2009 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
|
||||
# the Free Software Foundation; either version 2 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# 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.
|
||||
|
||||
EXTRA_DIST = \
|
||||
run-v2v-locally \
|
||||
virt-v2v.pl
|
||||
|
||||
if HAVE_V2V
|
||||
|
||||
man_MANS = virt-v2v.1
|
||||
|
||||
noinst_DATA = @top_builddir@/html/virt-v2v.1.html
|
||||
|
||||
virt-v2v.1: virt-v2v.pl
|
||||
$(POD2MAN) \
|
||||
--section 1 \
|
||||
-c "Virtualization Support" \
|
||||
--release "$(PACKAGE_NAME)-$(PACKAGE_VERSION)" \
|
||||
$< > $@
|
||||
|
||||
@top_builddir@/html/virt-v2v.1.html: virt-v2v.pl
|
||||
mkdir -p @top_builddir@/html
|
||||
cd @top_builddir@ && pod2html \
|
||||
--css 'pod.css' \
|
||||
--title 'virt-v2v, convert virtual machine from Xen to KVM' \
|
||||
--htmldir html \
|
||||
--outfile html/virt-v2v.1.html \
|
||||
v2v/$<
|
||||
|
||||
install-data-hook:
|
||||
mkdir -p $(DESTDIR)$(bindir)
|
||||
install -m 0755 virt-v2v.pl $(DESTDIR)$(bindir)/virt-v2v
|
||||
|
||||
endif
|
||||
52
v2v/run-v2v-locally
Executable file
52
v2v/run-v2v-locally
Executable file
@@ -0,0 +1,52 @@
|
||||
#!/usr/bin/perl
|
||||
# virt-v2v
|
||||
# Copyright (C) 2009 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
|
||||
# the Free Software Foundation; either version 2 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# 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.
|
||||
|
||||
# This script sets up the environment so you can run virt-v2v in place
|
||||
# without needing to do 'make install' first. You can also run virt-v2v
|
||||
# by creating a symlink to this script and putting it in your path.
|
||||
#
|
||||
# Use it like this:
|
||||
# ./run-v2v-locally [usual virt-v2v args ...]
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
|
||||
use File::Basename qw(dirname);
|
||||
use File::Spec;
|
||||
use Cwd qw(abs_path);
|
||||
|
||||
my $path = $0;
|
||||
|
||||
# Follow symlinks until we get to the real file
|
||||
while(-l $path) {
|
||||
my $link = readlink($path);
|
||||
if(File::Spec->file_name_is_absolute($link)) {
|
||||
$path = $link;
|
||||
} else {
|
||||
$path = File::Spec->catfile(dirname($path), $link);
|
||||
}
|
||||
}
|
||||
|
||||
# Get the absolute path of the parent directory
|
||||
$path = abs_path(dirname($path).'/..');
|
||||
|
||||
$ENV{LD_LIBRARY_PATH} = $path.'/src/.libs';
|
||||
$ENV{LIBGUESTFS_PATH} = $path.'/appliance';
|
||||
$ENV{PERL5LIB} = $path.'/perl/blib/lib:'.$path.'/perl/blib/arch';
|
||||
|
||||
exec('perl', $path.'/v2v/virt-v2v.pl', @ARGV);
|
||||
153
v2v/virt-v2v.pl
Executable file
153
v2v/virt-v2v.pl
Executable file
@@ -0,0 +1,153 @@
|
||||
#!/usr/bin/perl -w
|
||||
# virt-v2v
|
||||
# Copyright (C) 2009 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
|
||||
# the Free Software Foundation; either version 2 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# 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.
|
||||
|
||||
use warnings;
|
||||
use strict;
|
||||
|
||||
use Sys::Guestfs;
|
||||
use Sys::Guestfs::Lib qw(open_guest get_partitions resolve_windows_path
|
||||
inspect_all_partitions inspect_partition
|
||||
inspect_operating_systems mount_operating_system inspect_in_detail);
|
||||
use Pod::Usage;
|
||||
use Getopt::Long;
|
||||
use Data::Dumper;
|
||||
use File::Temp qw/tempdir/;
|
||||
use XML::Writer;
|
||||
|
||||
=encoding utf8
|
||||
|
||||
=head1 NAME
|
||||
|
||||
virt-v2v - Convert Xen guests to KVM
|
||||
|
||||
=head1 SYNOPSIS
|
||||
|
||||
virt-v2v xen_name -o kvm_name
|
||||
|
||||
virt-v2v guest.img [guest.img ...]
|
||||
|
||||
=head1 DESCRIPTION
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
=head1 OPTIONS
|
||||
|
||||
=over 4
|
||||
|
||||
=cut
|
||||
|
||||
my $help;
|
||||
|
||||
=item B<--help>
|
||||
|
||||
Display brief help.
|
||||
|
||||
=cut
|
||||
|
||||
my $uri;
|
||||
|
||||
=item B<--connect URI> | B<-c URI>
|
||||
|
||||
If using libvirt, connect to the given I<URI>. If omitted,
|
||||
then we connect to the default libvirt hypervisor.
|
||||
|
||||
Libvirt is only used if you specify a C<domname> on the
|
||||
command line. If you specify guest block devices directly,
|
||||
then libvirt is not used at all.
|
||||
|
||||
=cut
|
||||
|
||||
GetOptions ("help|?" => \$help,
|
||||
"connect|c=s" => \$uri,
|
||||
) or pod2usage (2);
|
||||
pod2usage (1) if $help;
|
||||
pod2usage ("$0: no image or VM names given") if @ARGV == 0;
|
||||
|
||||
# my $g;
|
||||
# if ($uri) {
|
||||
# $g = open_guest (\@ARGV, rw => $rw, address => $uri);
|
||||
# } else {
|
||||
# $g = open_guest (\@ARGV, rw => $rw);
|
||||
# }
|
||||
|
||||
# $g->launch ();
|
||||
# $g->wait_ready ();
|
||||
|
||||
# # List of possible filesystems.
|
||||
# my @partitions = get_partitions ($g);
|
||||
|
||||
# # Now query each one to build up a picture of what's in it.
|
||||
# my %fses =
|
||||
# inspect_all_partitions ($g, \@partitions,
|
||||
# use_windows_registry => $windows_registry);
|
||||
|
||||
# #print "fses -----------\n";
|
||||
# #print Dumper(\%fses);
|
||||
|
||||
# my $oses = inspect_operating_systems ($g, \%fses);
|
||||
|
||||
# #print "oses -----------\n";
|
||||
# #print Dumper($oses);
|
||||
|
||||
# # Mount up the disks and check for applications.
|
||||
|
||||
# my $root_dev;
|
||||
# foreach $root_dev (sort keys %$oses) {
|
||||
# my $os = $oses->{$root_dev};
|
||||
# mount_operating_system ($g, $os);
|
||||
# inspect_in_detail ($g, $os);
|
||||
# $g->umount_all ();
|
||||
# }
|
||||
|
||||
=head1 SEE ALSO
|
||||
|
||||
L<virt-inspector(1)>,
|
||||
L<guestfs(3)>,
|
||||
L<guestfish(1)>,
|
||||
L<Sys::Guestfs(3)>,
|
||||
L<Sys::Guestfs::Lib(3)>,
|
||||
L<Sys::Virt(3)>,
|
||||
L<http://libguestfs.org/>.
|
||||
|
||||
For Windows registry parsing we require the C<reged> program
|
||||
from L<http://home.eunet.no/~pnordahl/ntpasswd/>.
|
||||
|
||||
=head1 AUTHOR
|
||||
|
||||
Richard W.M. Jones L<http://et.redhat.com/~rjones/>
|
||||
|
||||
=head1 COPYRIGHT
|
||||
|
||||
Copyright (C) 2009 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
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
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.
|
||||
Reference in New Issue
Block a user