p2v: Add scripts to make disk or kickstart-based P2V ISO.

Two scripts are added, replacing the make targets from the
previous commit:

virt-p2v-make-disk: Builds a virt-p2v disk or USB key using
virt-builder.

virt-p2v-make-kickstart: Builds a kickstart file (only) which can be
fed to livecd-creator or similar tools on Red Hat-derived distros.

Kickstart generation is slightly different: Instead of requiring the
downstream 'libguestfs-pvhelper' package, the kickstart now embeds the
virt-p2v binary(!) making it self-contained and downstream packaging
simpler.

In addition there are documentation changes.
This commit is contained in:
Richard W.M. Jones
2014-09-06 10:05:18 +01:00
parent 8e6478dc7d
commit 0866d22381
15 changed files with 950 additions and 9 deletions

9
.gitignore vendored
View File

@@ -251,6 +251,8 @@ Makefile.in
/html/virt-ls.1.html
/html/virt-make-fs.1.html
/html/virt-p2v.1.html
/html/virt-p2v-make-disk.1.html
/html/virt-p2v-make-kickstart.1.html
/html/virt-rescue.1.html
/html/virt-resize.1.html
/html/virt-sparsify.1.html
@@ -320,9 +322,16 @@ Makefile.in
/ocaml/stamp-mlguestfs
/ocaml/t/*.bc
/ocaml/t/*.opt
/p2v/launch-virt-p2v
/p2v/stamp-virt-p2v.pod
/p2v/stamp-virt-p2v-make-disk.pod
/p2v/stamp-virt-p2v-make-kickstart.pod
/p2v/virt-p2v
/p2v/virt-p2v.1
/p2v/virt-p2v-make-disk
/p2v/virt-p2v-make-disk.1
/p2v/virt-p2v-make-kickstart
/p2v/virt-p2v-make-kickstart.1
/perl/bindtests.pl
/perl/blib
/perl/examples/guestfs-perl.3

View File

@@ -245,7 +245,6 @@ HTMLFILES = \
html/virt-log.1.html \
html/virt-ls.1.html \
html/virt-make-fs.1.html \
html/virt-p2v.1.html \
html/virt-rescue.1.html \
html/virt-resize.1.html \
html/virt-sparsify.1.html \
@@ -285,6 +284,12 @@ HTMLFILES += \
html/guestmount.1.html \
html/guestunmount.1.html
endif
if HAVE_P2V
HTMLFILES += \
html/virt-p2v.1.html \
html/virt-p2v-make-disk.1.html \
html/virt-p2v-make-kickstart.1.html
endif
HTMLSUPPORTFILES = \
html/draft.png \

View File

@@ -1614,6 +1614,10 @@ AC_CONFIG_FILES([appliance/libguestfs-make-fixed-appliance],
[chmod +x,-w appliance/libguestfs-make-fixed-appliance])
AC_CONFIG_FILES([inspector/test-xmllint.sh],
[chmod +x,-w inspector/test-xmllint.sh])
AC_CONFIG_FILES([p2v/virt-p2v-make-disk],
[chmod +x,-w p2v/virt-p2v-make-disk])
AC_CONFIG_FILES([p2v/virt-p2v-make-kickstart],
[chmod +x,-w p2v/virt-p2v-make-kickstart])
AC_CONFIG_FILES([php/extension/php-for-tests.sh],
[chmod +x,-w php/extension/php-for-tests.sh])
AC_CONFIG_FILES([pick-guests.pl],

View File

@@ -18,9 +18,20 @@
include $(top_srcdir)/subdir-rules.mk
EXTRA_DIST = \
virt-p2v.pod
issue \
launch-virt-p2v.in \
p2v.ks.in \
p2v.service \
virt-p2v.pod \
virt-p2v-make-disk.in \
virt-p2v-make-disk.pod \
virt-p2v-make-kickstart.in \
virt-p2v-make-kickstart.pod
CLEANFILES = stamp-virt-p2v.pod
CLEANFILES = \
stamp-virt-p2v.pod \
stamp-virt-p2v-make-disk.pod \
stamp-virt-p2v-make-kickstart.pod
# Although virt-p2v is a regular binary, it is not usually installed
# in /usr/bin since it only functions when contained in an ISO or PXE
@@ -63,11 +74,35 @@ virt_p2v_LDADD = \
$(GTK2_LIBS) \
../gnulib/lib/libgnu.la
# Scripts to build the disk image, USB key, or kickstart.
bin_SCRIPTS = virt-p2v-make-disk virt-p2v-make-kickstart
# Support files needed by the virt-p2v-make-* scripts.
virtp2vdatadir = $(datadir)/virt-p2v
virtp2vdata_DATA = \
issue \
launch-virt-p2v \
p2v.ks.in \
p2v.service
# Deal with stupid autotools libexecdir-not-expandable crap.
launch-virt-p2v: launch-virt-p2v.in
rm -f $@ $@-t
sed 's,@''libexecdir@,$(libexecdir),g' < $< > $@-t
chmod 0555 $@-t
mv $@-t $@
# Manual pages and HTML files for the website.
man_MANS = virt-p2v.1
man_MANS = \
virt-p2v.1 \
virt-p2v-make-disk.1 \
virt-p2v-make-kickstart.1
noinst_DATA = \
$(top_builddir)/html/virt-p2v.1.html
$(top_builddir)/html/virt-p2v.1.html \
$(top_builddir)/html/virt-p2v-make-disk.1.html \
$(top_builddir)/html/virt-p2v-make-kickstart.1.html
virt-p2v.1 $(top_builddir)/html/virt-p2v.1.html: stamp-virt-p2v.pod
@@ -79,6 +114,26 @@ stamp-virt-p2v.pod: virt-p2v.pod
$<
touch $@
virt-p2v-make-disk.1 $(top_builddir)/html/virt-p2v-make-disk.1.html: stamp-virt-p2v-make-disk.pod
stamp-virt-p2v-make-disk.pod: virt-p2v-make-disk.pod
$(PODWRAPPER) \
--man virt-p2v-make-disk.1 \
--html $(top_builddir)/html/virt-p2v-make-disk.1.html \
--license GPLv2+ \
$<
touch $@
virt-p2v-make-kickstart.1 $(top_builddir)/html/virt-p2v-make-kickstart.1.html: stamp-virt-p2v-make-kickstart.pod
stamp-virt-p2v-make-kickstart.pod: virt-p2v-make-kickstart.pod
$(PODWRAPPER) \
--man virt-p2v-make-kickstart.1 \
--html $(top_builddir)/html/virt-p2v-make-kickstart.1.html \
--license GPLv2+ \
$<
touch $@
# Tests.
TESTS_ENVIRONMENT = $(top_builddir)/run --test

14
p2v/issue Normal file
View File

@@ -0,0 +1,14 @@
virt-p2v - Convert a physical machine to use KVM.
***
The root password is "p2v" (without quotes).
If virt-p2v is not running, you can start it by typing:
launch-virt-p2v
If virt-p2v didn't start automatically, look for logs:
systemctl status p2v -l
***

22
p2v/launch-virt-p2v.in Executable file
View File

@@ -0,0 +1,22 @@
#!/bin/bash -
# @configure_input@
# (C) Copyright 2014 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 normally runs from systemd which deals with logging.
cd /
xinit @libexecdir@/virt-p2v

172
p2v/p2v.ks.in Normal file
View File

@@ -0,0 +1,172 @@
# Kickstart file for creating the virt-p2v ISO.
# (C) Copyright 2014 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.
# Generated by virt-p2v-make-kickstart.
install
lang en_US.UTF-8
keyboard us
timezone --utc GMT
selinux --enforcing
firewall --enabled
# Need to specify --device, else:
# Error creating Live CD : No --device specified with network kickstart command
network --bootproto=dhcp --device=eth0
bootloader --location=mbr --append="console=tty0 console=ttyS0,115200 rd_NO_PLYMOUTH"
zerombr
clearpart --all --initlabel
part / --size 3000 --fstype ext4
reboot
# Repository lines:
__REPOS__
# Packages to install in the ISO. For dependencies, see
# p2v/Makefile.am. Note that libguestfs is NOT required by virt-p2v.
%packages
@core
# Note you must have a kernel, else the boot menu won't work:
kernel
# Needed by post script to unpack the blobs.
/usr/bin/base64
/usr/bin/gzip
# The dependencies of virt-p2v.
/usr/bin/xinit
/usr/bin/ssh
/usr/bin/qemu-nbd
/usr/bin/Xorg
xorg-x11-drivers
xorg-x11-fonts-Type1
pcre
libxml2
gtk2
%end
# Post-install configuration.
%post
# Base64-decoding of /etc/issue
base64 -d > /etc/issue << EOF
__BASE64_ISSUE__
EOF
cp /etc/issue /etc/issue.net
# Base64-decoding of launch-virt-p2v
base64 -d > /usr/bin/launch-virt-p2v <<EOF
__BASE64_LAUNCH_VIRT_P2V__
EOF
chmod 0755 /usr/bin/launch-virt-p2v
# Base64-decoding of p2v.service unit file
base64 -d > /etc/systemd/system/p2v.service <<EOF
__BASE64_P2V_SERVICE__
EOF
systemctl enable p2v.service
# Base64-decoding of virt-p2v binary
base64 -d <<EOF | gzip -cd > __LIBEXECDIR__/virt-p2v
__BASE64_VIRT_P2V__
EOF
chmod 0755 __LIBEXECDIR__/virt-p2v
# Update the default getty target to login automatically as root without
# prompting for a password
sed -i 's/^ExecStart=\(.*\)/ExecStart=\1 -a root/' \
/usr/lib/systemd/system/getty@.service
# Reserve tty1 as a getty so we can document it clearly
echo ReserveVT=1 >> /etc/systemd/logind.conf
%end
%post --nochroot
PRODUCT='Virt P2V'
PRODUCT_SHORT='virt-p2v'
PACKAGE='__PACKAGE_NAME__'
VERSION='__PACKAGE_VERSION__'
echo "Customizing boot menu"
sed -i -e '
# Put product information at the top of the file
1 {
i '"say $PRODUCT $VERSION"'
i '"menu title $PRODUCT_SHORT $VERSION"'
}
# Remove any existing menu title
/^menu title .*/d
# Remove quiet bootparam
#s/ quiet//
# Disable selinux.
#/^\s*append\s/ s/\s*$/ selinux=0/
# Remove Verify and Boot option
#/label check0/{N;N;N;d;}
# Set the default timeout to 60 seconds
s/^timeout .*/timeout 60/
' $LIVE_ROOT/isolinux/isolinux.cfg
# TODO: Replace the splash screen with something P2V appropriate
#cp $INSTALL_ROOT//syslinux-vesa-splash.jpg $LIVE_ROOT/isolinux/splash.jpg
# store image version info in the ISO
cat > $LIVE_ROOT/isolinux/version <<EOF
PRODUCT='$PRODUCT'
PRODUCT_SHORT='${PRODUCT_SHORT}'
#PRODUCT_CODE=$PRODUCT_CODE
#RECIPE_SHA256=$RECIPE_SHA256
#RECIPE_RPM=$RECIPE_RPM
PACKAGE=$PACKAGE
VERSION=$VERSION
EOF
# overwrite user visible banners with the image versioning info
cat > $INSTALL_ROOT/etc/$PACKAGE-release <<EOF
$PRODUCT release $VERSION
EOF
#ln -snf $PACKAGE-release $INSTALL_ROOT/etc/redhat-release
#ln -snf $PACKAGE-release $INSTALL_ROOT/etc/system-release
# replace initramfs if regenerated
if [ -f "$INSTALL_ROOT/initrd0.img" ]; then
mv -v "$INSTALL_ROOT/initrd0.img" "$LIVE_ROOT/isolinux/initrd0.img"
fi
%end

31
p2v/p2v.service Normal file
View File

@@ -0,0 +1,31 @@
# libguestfs virt-p2v ISO
# Copyright (C) 2009-2014 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
# NB: This cannot be called "virt-p2v.service" because on Fedora the
# virt- prefix will cause it to get the wrong SELinux label.
[Unit]
Description=p2v service
After=network.target
[Service]
Type=oneshot
ExecStart=/usr/bin/launch-virt-p2v
RemainAfterExit=yes
[Install]
WantedBy=graphical.target

146
p2v/virt-p2v-make-disk.in Normal file
View File

@@ -0,0 +1,146 @@
#!/bin/bash -
# @configure_input@
# virt-p2v-make-disk
# Copyright (C) 2014 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
unset CDPATH
program="virt-p2v-make-disk"
version="@PACKAGE_VERSION@"
TEMP=`getopt \
-o o:V \
--long help,output:,version \
-n $program -- "$@"`
if [ $? != 0 ]; then
echo "$program: problem parsing the command line arguments"
exit 1
fi
eval set -- "$TEMP"
output=
usage ()
{
echo "Usage:"
echo " $program [--options] -o /dev/sdX os-version"
echo
echo "Read $program(1) man page for more information."
exit $1
}
while true; do
case "$1" in
-o|--output)
output="$2"
shift 2;;
-V|--version)
echo "$program $version"
exit 0;;
--help)
usage 0;;
--)
shift
break;;
*)
echo "internal error ($1)"
exit 1;;
esac
done
if [ -z "$output" ]; then
echo "$program: You must set the -o (--output) option."
exit 1
fi
if [ $# -ne 1 ]; then
echo "$program: Missing os-version. See $program(1)."
exit 1
fi
osversion="$1"
# The dependencies are:
#
# - pcre (library only)
# - libxml2 (library only)
# - gtk2 (library only)
# - ssh
# - qemu-nbd
# - xinit (script, part of X)
# - Xorg (or another X server, but only Xorg has been tested)
# - Xorg drivers
# - some fonts
#
# Note that libguestfs is NOT a dependency.
case "$osversion" in
centos-*|fedora-*|rhel-*|scientificlinux-*)
deps=pcre,libxml2,gtk2,/usr/bin/xinit,/usr/bin/ssh,/usr/bin/qemu-nbd,/usr/bin/Xorg,xorg-x11-drivers,xorg-x11-fonts-Type1
selinux_relabel=--selinux-relabel
;;
debian-*|ubuntu-*)
deps=libpcre3,libxml2,libgtk2.0-0,openssh-client,qemu-utils,xorg,xserver-xorg-video-all
;;
archlinux-*)
deps=pcre,libxml2,gtk2,openssh,qemu,xorg-xinit,xorg-server,xf86-video-*
;;
opensuse-*|suse-*)
deps=pcre,libxml2,gtk2,/usr/bin/ssh,/usr/bin/qemu-nbd,/usr/bin/xinit,/usr/bin/Xorg,xf86-video-*
;;
*)
echo "$program: internal error: could not work out the Linux distro from '$osversion'"
exit 1
esac
# Deal with stupid autotools libexecdir-not-expandable crap.
prefix="@prefix@"
exec_prefix="@exec_prefix@"
libexecdir="@libexecdir@"
if [ -n "$VIRT_P2V_DATA_DIR" ]; then
datadir="$VIRT_P2V_DATA_DIR"
host_libexecdir="$VIRT_P2V_DATA_DIR"
else
datadir="@datadir@/virt-p2v"
host_libexecdir="@libexecdir@"
fi
# Run virt-builder. Note we controversially assume systemd here. We
# could provide a sysvinit fallback if required.
exec \
virt-builder "$osversion" \
--output "$output" \
--update \
--install "$deps" \
--root-password password:p2v \
--upload "$datadir"/issue:/etc/issue \
--upload "$datadir"/issue:/etc/issue.net \
--mkdir "$libexecdir" \
--upload "$host_libexecdir"/virt-p2v:"$libexecdir" \
--chmod 0755:"$libexecdir"/virt-p2v \
--upload "$datadir"/launch-virt-p2v:/usr/bin/ \
--chmod 0755:/usr/bin/launch-virt-p2v \
--upload "$datadir"/p2v.service:/etc/systemd/system/ \
--mkdir /etc/systemd/system/default.target.wants \
--link /etc/systemd/system/p2v.service:/etc/systemd/system/default.target.wants/p2v.service \
--edit '/usr/lib/systemd/system/getty@.service:
s/^ExecStart=(.*)/ExecStart=$1 -a root/
' \
--edit '/etc/systemd/logind.conf:
s/^[Login]/[Login]\nReserveVT=1\n/
' \
$selinux_relabel

115
p2v/virt-p2v-make-disk.pod Normal file
View File

@@ -0,0 +1,115 @@
=head1 NAME
virt-p2v-make-disk - Build the virt-p2v disk using virt-builder
=head1 SYNOPSIS
virt-p2v-make-disk -o /dev/sdX os-version
=head1 DESCRIPTION
L<virt-p2v(1)> converts a physical machine to run virtualized on KVM,
managed by libvirt or Red Hat Enterprise Virtualisation (RHEV) version
2.2 or later.
virt-p2v-make-disk is a script which creates a bootable disk image or
USB key containing virt-p2v. It uses L<virt-builder(1)> to do this,
and is just a small shell script around virt-builder.
virt-p2v-make-disk has two required parameters:
The I<-o> parameter specifies where the output should go, for example
to a USB key (eg. C<-o /dev/sdX>) or to a file. If you pass a device
name, then B<the existing contents of the device will be erased>.
The C<os-version> parameter is the base Linux distro to use for the
operating system on the ISO. To list possible C<os-version>
combinations, do:
virt-builder -l
=head2 EXAMPLES
Write a virt-p2v bootable USB key on C</dev/sdX> (and existing content
is erased), using Fedora 20 as the base distribution:
virt-p2v-make-disk -o /dev/sdX fedora-20
Write a virt-p2v bootable virtual disk image, and boot it under qemu:
virt-p2v-make-disk -o /var/tmp/p2v.img fedora-20
qemu-kvm -m 1024 -boot c \
-drive file=/var/tmp/p2v.img,if=virtio,index=0 \
-drive file=/var/tmp/guest.img,if=virtio,index=1
where C</var/tmp/guest.img> would be the disk image of some guest that
you want to convert (for testing only).
=head1 OPTIONS
=over 4
=item B<--help>
Display help.
=item B<-o> OUTPUT
=item B<--output> OUTPUT
Write output to C<OUTPUT>, which can be a local file or block device.
B<The existing contents of the device will be erased>.
=item B<-V>
=item B<--version>
Display version number and exit.
=back
=head1 FILES
=over 4
=item C<$libexecdir/virt-p2v>
The L<virt-p2v(1)> binary which is copied into the bootable disk
image. The location of the binary can be changed by setting the
C<VIRT_P2V_DATA_DIR> environment variable.
=item C<$datadir/issue>
=item C<$datadir/launch-virt-p2v.in>
=item C<$datadir/p2v.service>
Various data files that are copied into the bootable disk image.
=back
=head1 ENVIRONMENT VARIABLES
=over 4
=item C<VIRT_P2V_DATA_DIR>
The directory where virt-p2v-make-disk looks for data files (see
L</FILES> above). If not set, a compiled-in location is used.
=back
=head1 SEE ALSO
L<virt-p2v(1)>,
L<virt-p2v-make-kickstart(1)>,
L<virt-v2v(1)>,
L<http://libguestfs.org/>.
=head1 AUTHORS
Richard W.M. Jones L<http://people.redhat.com/~rjones/>
=head1 COPYRIGHT
Copyright (C) 2009-2014 Red Hat Inc.

View File

@@ -0,0 +1,158 @@
#!/bin/bash -
# @configure_input@
# virt-p2v-make-kickstart
# Copyright (C) 2014 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
unset CDPATH
program="virt-p2v-make-kickstart"
version="@PACKAGE_VERSION@"
TEMP=`getopt \
-o o:V \
--long help,output:,proxy:,version \
-n $program -- "$@"`
if [ $? != 0 ]; then
echo "$program: problem parsing the command line arguments"
exit 1
fi
eval set -- "$TEMP"
usage ()
{
echo "Usage:"
echo " $program [--options] [-o p2v.ks] [--proxy=http://...] repo [repo...]"
echo
echo "Read $program(1) man page for more information."
exit $1
}
output=p2v.ks
proxy=
while true; do
case "$1" in
-o|--output)
output="$2"
shift 2;;
--proxy)
proxy="--proxy=$2"
shift 2;;
--repo)
repo="$2"
shift 2;;
-V|--version)
echo "$program $version"
exit 0;;
--help)
usage 0;;
--)
shift
break;;
*)
echo "internal error ($1)"
exit 1;;
esac
done
if [ $# -lt 1 ]; then
echo "$program: Missing repo(s). See $program(1)."
exit 1
fi
set -e
# Deal with stupid autotools libexecdir-not-expandable crap.
prefix="@prefix@"
exec_prefix="@exec_prefix@"
libexecdir="@libexecdir@"
if [ -n "$VIRT_P2V_DATA_DIR" ]; then
datadir="$VIRT_P2V_DATA_DIR"
host_libexecdir="$VIRT_P2V_DATA_DIR"
else
datadir="@datadir@/virt-p2v"
host_libexecdir="@libexecdir@"
fi
# Base64-encode the files that we need to embed into the kickstart.
base64_issue="$(base64 $datadir/issue)"
base64_launch_virt_p2v="$(base64 $datadir/launch-virt-p2v)"
base64_p2v_service="$(base64 $datadir/p2v.service)"
# virt-p2v binary is too large unless we strip it and compress it.
tmpfile="$(mktemp -u)"
cp $host_libexecdir/virt-p2v $tmpfile
strip --strip-all $tmpfile
gzip -9 $tmpfile
base64_virt_p2v="$(base64 $tmpfile.gz)"
rm $tmpfile.gz
# Repositories.
repos=
i=0
for repo in "$@"; do
case "$repo" in
fedora)
repos="$repos
repo --name=fedora --mirrorlist=http://mirrors.fedoraproject.org/mirrorlist?repo=fedora-\$releasever\\\\&arch=\$basearch $proxy
"
;;
rawhide)
repos="$repos
repo --name=rawhide --mirrorlist=http://mirrors.fedoraproject.org/mirrorlist?repo=rawhide\\\\&arch=\$basearch $proxy
"
;;
koji)
repos="$repos
repo --name=koji --baseurl=http://koji.fedoraproject.org/repos/rawhide/latest/\$basearch/ $proxy
"
;;
*)
# A custom repo is just a URL.
((i++))
repos="$repos
repo --name=custom$i --baseurl=$repo $proxy
"
;;
esac
done
# Now generate the final kickstart, substituting as necessary.
# AWK FTW!
@AWK@ \
-v "base64_issue=$base64_issue" \
-v "base64_launch_virt_p2v=$base64_launch_virt_p2v" \
-v "base64_p2v_service=$base64_p2v_service" \
-v "base64_virt_p2v=$base64_virt_p2v" \
-v "repos=$repos" \
-v "libexecdir=$libexecdir" \
'{
gsub (/__PACKAGE_NAME__/, "@PACKAGE_NAME@");
gsub (/__PACKAGE_VERSION__/, "@PACKAGE_VERSION@");
gsub (/__BASE64_ISSUE__/, base64_issue);
gsub (/__BASE64_LAUNCH_VIRT_P2V__/, base64_launch_virt_p2v);
gsub (/__BASE64_P2V_SERVICE__/, base64_p2v_service);
gsub (/__BASE64_VIRT_P2V__/, base64_virt_p2v);
gsub (/__REPOS__/, repos);
gsub (/__LIBEXECDIR__/, libexecdir);
print;
}' \
$datadir/p2v.ks.in > $output-t
mv $output-t $output
echo "Kickstart file written to $output"

View File

@@ -0,0 +1,201 @@
=head1 NAME
virt-p2v-make-kickstart - Build the virt-p2v kickstart
=head1 SYNOPSIS
virt-p2v-make-kickstart [-o p2v.ks] [--proxy=http://...] repo [repo...]
=head1 DESCRIPTION
L<virt-p2v(1)> converts a physical machine to run virtualized on KVM,
managed by libvirt or Red Hat Enterprise Virtualisation (RHEV) version
2.2 or later.
Kickstart is a format used by Red Hat-derived distributions (such as
Fedora, Red Hat Enterprise Linux, CentOS, Scientific Linux, and
others) to describe how to make live CDs, install the distro, make
"Spins" and so on. It is driven by a kickstart file.
virt-p2v-make-kickstart builds a kickstart file which can be used to
build a bootable P2V ISO, live CD, USB key, or PXE image. This tool
only builds the kickstart file, but this manual page describes some of
the ways you can use the kickstart file.
=head1 BUILDING THE KICKSTART FILE
Using virt-p2v-make-kickstart is very simple:
virt-p2v-make-kickstart fedora
will build a kickstart file for Fedora. The kickstart file will be
called C<p2v.ks> and located in the current directory.
The parameters are a list of one or more repositories. Some built-in
repositories are available: C<fedora>, C<rawhide> or C<koji>. You can
also use a URL as a parameter to point to a repository.
To control the name of the output file, use the I<-o> parameter. To
tell kickstart to use a proxy server or web cache to download files,
use the I<--proxy> parameter.
=head1 BUILDING A LIVE CD / ISO
Once you have the kickstart file, you can use L<livecd-creator(8)>
to make a live CD:
sudo livecd-creator p2v.ks
Before running this note that you should probably run
C<livecd-creator> in a disposable virtual machine for these reasons:
=over 4
=item *
You have to disable SELinux when running the tool.
=item *
This tool has to be run as root, and has some nasty failure modes.
=item *
You can only create the exact same Live CD distro as the host
distro. Cross-builds will fail in strange ways (eg. RHBZ#1092327).
=back
=head1 BUILDING A FEDORA SPIN USING KOJI
This requires C<spin-livecd> permissions on Koji, which are not given
out usually, even to Fedora packagers. However assuming you have been
given these permissions (or have your own Koji instance, I guess),
then you can do:
koji spin-livecd [--scratch] p2v 1.XX.YY rawhide x86_64 p2v.ks
=over 4
=item *
Add the C<--scratch> option to do a scratch build (recommended for
testing).
=item *
C<1.XX.YY> should match the libguestfs version
=item *
Instead of C<rawhide> you can use any Koji target.
=back
=head1 BUILDING BOOTABLE USB KEY
Use the L<livecd-iso-to-disk(8)> program to convert the ISO created
above to a USB key:
sudo livecd-iso-to-disk livecd-p2v.iso /dev/sdX
=head1 BUILDING A PXE BOOT IMAGE
Use the C<livecd-iso-to-pxeboot> program to convert the ISO created
above to a PXE boot image.
sudo livecd-iso-to-pxeboot livecd-p2v.iso
This creates a C<tftpboot> subdirectory under the current directory
containing the files required to PXE boot virt-p2v:
$ ls -1R tftpboot/
tftpboot/:
initrd0.img
pxelinux.0
pxelinux.cfg/
vmlinuz0
tftpboot/pxelinux.cfg:
default
=head1 TESTING THE P2V ISO USING QEMU
You can use qemu to test-boot the P2V ISO:
qemu-kvm -m 1024 -hda /tmp/guest.img -cdrom /tmp/livecd-p2v.iso -boot d
Note that C<-hda> is the (virtual) system that you want to convert
(for test purposes). It could be any guest type supported by
L<virt-v2v(1)>, including Windows or Red Hat Enterprise Linux.
=head1 OPTIONS
=over 4
=item B<--help>
Display help.
=item B<-o> OUTPUT
=item B<--output> OUTPUT
Write kickstart to C<OUTPUT>. If not specified, the default is
C<p2v.ks> in the current directory.
=item B<--proxy> URL
Tell the kickstart to use a proxy server or web cache for downloads.
=item B<-V>
=item B<--version>
Display version number and exit.
=back
=head1 FILES
=over 4
=item C<$datadir/issue>
=item C<$datadir/launch-virt-p2v.in>
=item C<$datadir/p2v.ks.in>
=item C<$datadir/p2v.service>
Various data files that used to make the kickstart.
=back
=head1 ENVIRONMENT VARIABLES
=over 4
=item C<VIRT_P2V_DATA_DIR>
The directory where virt-p2v-make-kickstart looks for data files (see
L</FILES> above). If not set, a compiled-in location is used.
=back
=head1 SEE ALSO
L<virt-p2v(1)>,
L<virt-p2v-make-disk(1)>,
L<virt-v2v(1)>,
L<livecd-creator(8)>,
L<livecd-iso-to-disk(8)>,
L<http://libguestfs.org/>.
=head1 AUTHORS
Richard W.M. Jones L<http://people.redhat.com/~rjones/>
=head1 COPYRIGHT
Copyright (C) 2009-2014 Red Hat Inc.

View File

@@ -17,8 +17,11 @@ managed by libvirt or Red Hat Enterprise Virtualisation (RHEV) version
Normally you don't run the virt-p2v program directly. Instead you
have to boot the physical machine using the bootable CD-ROM, ISO or
PXE image. This bootable image contains the virt-p2v binary and runs
it automatically. This manual page documents both the binary and the
bootable image.
it automatically.
This manual page documents running the virt-p2v program. To create
the bootable image you should look at L<virt-p2v-make-disk(1)> or
L<virt-p2v-make-kickstart(1)>.
=head1 NETWORK SETUP
@@ -253,6 +256,8 @@ Display version number and exit.
=head1 SEE ALSO
L<virt-p2v-make-disk(1)>,
L<virt-p2v-make-kickstart(1)>,
L<virt-v2v(1)>,
L<qemu-nbd(1)>,
L<http://libguestfs.org/>.

6
run.in
View File

@@ -92,6 +92,12 @@ if [ -z "$XDG_CONFIG_DIRS" ]; then
export XDG_CONFIG_DIRS
fi
# virt-p2v-make-* data directory.
if [ -z "$VIRT_P2V_DATA_DIR" ]; then
VIRT_P2V_DATA_DIR="$b/p2v"
export VIRT_P2V_DATA_DIR
fi
# For Perl.
if [ -z "$PERL5LIB" ]; then
PERL5LIB="$b/perl/blib/lib:$b/perl/blib/arch"

View File

@@ -10,8 +10,6 @@ Proper progress bars when copying.
p2v:
- vmlinuz + initrd? - if not possible, remove from man page
- PXE boot
- network dialog and network configuration
- why is the Back button insensitive?