[Pkg-libvirt-commits] [libguestfs] 40/165: Add p2v-iso directory containing scripts for building the virt-p2v ISO.

Hilko Bengen bengen at moszumanska.debian.org
Sat Aug 30 08:24:23 UTC 2014


This is an automated email from the git hooks/post-receive script.

bengen pushed a commit to branch experimental
in repository libguestfs.

commit 047b6d3050a8e7b07f21df62044673380c6f897a
Author: Richard W.M. Jones <rjones at redhat.com>
Date:   Thu May 15 13:43:18 2014 +0100

    Add p2v-iso directory containing scripts for building the virt-p2v ISO.
    
    It is not possible to have the ISO be built automatically when the
    user runs 'make'.  The README file describes how you should go about
    building the ISO or disk image.
---
 .gitignore                        |   1 +
 Makefile.am                       |   2 +-
 configure.ac                      |   3 ++
 p2v-iso/Makefile.am               |  30 ++++++++++++
 p2v-iso/README                    | 100 ++++++++++++++++++++++++++++++++++++++
 p2v-iso/issue                     |  14 ++++++
 p2v-iso/launch-virt-p2v           |  21 ++++++++
 p2v-iso/p2v.service               |  31 ++++++++++++
 p2v-iso/virt-builder-target.sh.in |  85 ++++++++++++++++++++++++++++++++
 src/guestfs.pod                   |   4 ++
 10 files changed, 290 insertions(+), 1 deletion(-)

diff --git a/.gitignore b/.gitignore
index f97318b..a0b1590 100644
--- a/.gitignore
+++ b/.gitignore
@@ -318,6 +318,7 @@ Makefile.in
 /p2v/stamp-virt-p2v.pod
 /p2v/virt-p2v
 /p2v/virt-p2v.1
+/p2v-iso/virt-builder-target.sh
 /perl/bindtests.pl
 /perl/blib
 /perl/examples/guestfs-perl.3
diff --git a/Makefile.am b/Makefile.am
index 67b1fa8..d490f6f 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -82,7 +82,7 @@ SUBDIRS += fish
 # virt-tools in C.
 SUBDIRS += align cat diff df edit format inspector make-fs rescue
 if HAVE_P2V
-SUBDIRS += p2v
+SUBDIRS += p2v p2v-iso
 endif
 
 # bash-completion
diff --git a/configure.ac b/configure.ac
index 2239e44..91777b2 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1602,6 +1602,8 @@ 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-iso/virt-builder-target.sh],
+                [chmod +x,-w p2v-iso/virt-builder-target.sh])
 AC_CONFIG_FILES([php/extension/php-for-tests.sh],
                 [chmod +x,-w php/extension/php-for-tests.sh])
 AC_CONFIG_FILES([pick-guests.pl],
@@ -1659,6 +1661,7 @@ AC_CONFIG_FILES([Makefile
                  ocaml/Makefile
                  ocaml/examples/Makefile
                  p2v/Makefile
+                 p2v-iso/Makefile
                  perl/Makefile
                  perl/Makefile.PL
                  perl/examples/Makefile
diff --git a/p2v-iso/Makefile.am b/p2v-iso/Makefile.am
new file mode 100644
index 0000000..c825aba
--- /dev/null
+++ b/p2v-iso/Makefile.am
@@ -0,0 +1,30 @@
+# 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.
+
+include $(top_srcdir)/subdir-rules.mk
+
+EXTRA_DIST = \
+	README \
+	issue \
+	launch-virt-p2v \
+	p2v.service \
+	virt-builder-target.sh.in
+
+# You need to read the README file before trying any of these targets.
+
+virt-builder-target: virt-builder-target.sh
+	srcdir=$(srcdir) $(top_builddir)/run ./virt-builder-target.sh
diff --git a/p2v-iso/README b/p2v-iso/README
new file mode 100644
index 0000000..2db727d
--- /dev/null
+++ b/p2v-iso/README
@@ -0,0 +1,100 @@
+virt-p2v ISO
+======================================================================
+
+virt-p2v converts physical machines to run on KVM.  Normally you
+should not run virt-p2v directly.  Instead you have to boot the
+physical machine using the bootable CD-ROM, ISO, PXE or disk image
+which is provided by this directory.  The reason for this is so that
+virt-p2v runs in a "clean" environment, with no other processes
+running and modifying the disks.
+
+- This directory (libguestfs.git/p2v-iso) contains the scripts
+  used to build the bootable image.
+
+- It *does not* contain the source to virt-p2v.  See ../p2v/ for the
+  source of virt-p2v.
+
+- It *does not* contain instructions for how to run virt-p2v.  For
+  that you need to read the virt-p2v(1) manual page (see ../p2v/).
+
+- It *does not* build anything when you run 'make'.  This is because:
+
+  * building the disk image takes a long time
+
+  * you wouldn't want to rebuild it every time virt-p2v changes
+
+  * how and what to build depends on your environment
+
+  * for some targets, it isn't even possible to build anything without
+    root permissions / a network connection / a remote service (like
+    Fedora's Koji)
+
+  * some targets require interaction, eg. inserting a USB key
+
+- For the same reasons as above, 'make check' and 'make install' in
+  this directory do nothing.
+
+Although for historical reasons this is known as the virt-p2v "ISO",
+it may not actually build an ISO-formatted CD image.  Some of the
+targets are simple disk images, USB keys and so on.
+
+Although virt-p2v should be run on a physical machine, for testing
+purposes you can (and we often do) run it in a virtual machine.
+
+Running the virt-p2v ISO in a VM is also a legitimate way to convert a
+virtual machine from a hypervisor which is not supported by virt-v2v
+(Hyper-V is one such hypervisor).
+
+
+Which target should you choose?
+----------------------------------------------------------------------
+
+For a list of all targets and how to use them, see below.
+
+MOST USERS should choose 'virt-builder-target'.
+
+Fedora, RHEL, CentOS and Scientific Linux users may wish to try
+the 'kickstart-target'.
+
+Fedora and RHEL developers who have been given 'spin-livecd'
+permission by the Fedora/RHEL Koji/Brew administrators may wish to try
+building the 'kickstart-target' as a Fedora/RHEL "Spin".
+
+
+virt-builder-target
+----------------------------------------------------------------------
+
+This target uses virt-builder (see ../builder/) to build a bootable
+disk image or USB key containing the locally built virt-p2v binary
+from ../p2v
+
+Use a disk image if you want to test virt-p2v inside a virtual
+machine.  To use virt-p2v for real, you will need an empty USB key >=
+6 GB in size.  Use this target to write the USB key, which you can
+then plug into the physical machine to start the P2V process.
+
+Most users should use this target.  It does not require any special
+permissions, but it does need network access.
+
+To use the virt-builder target:
+
+(1) Choose the os-version which most closely matches your distro
+from this list:
+
+  virt-builder -l
+
+(2) Choose the output, which could be a file [filename] or a USB key
+[eg. /dev/sdX].
+
+Then run this command (from the p2v-iso directory):
+
+  make virt-builder-target OSVERSION=fedora-20 OUTPUT=/dev/sdX
+
+After building the image, you can boot it directly on physical
+hardware, or for testing in qemu or KVM (see the virt-builder man page
+for example qemu and virt-install command lines).
+
+
+kickstart-target
+----------------------------------------------------------------------
+
diff --git a/p2v-iso/issue b/p2v-iso/issue
new file mode 100644
index 0000000..ae0930f
--- /dev/null
+++ b/p2v-iso/issue
@@ -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
+***
+
diff --git a/p2v-iso/launch-virt-p2v b/p2v-iso/launch-virt-p2v
new file mode 100755
index 0000000..06675a0
--- /dev/null
+++ b/p2v-iso/launch-virt-p2v
@@ -0,0 +1,21 @@
+#!/bin/bash -
+# (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 /usr/bin/virt-p2v
diff --git a/p2v-iso/p2v.service b/p2v-iso/p2v.service
new file mode 100644
index 0000000..3a8f6ae
--- /dev/null
+++ b/p2v-iso/p2v.service
@@ -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
diff --git a/p2v-iso/virt-builder-target.sh.in b/p2v-iso/virt-builder-target.sh.in
new file mode 100644
index 0000000..70cf5da
--- /dev/null
+++ b/p2v-iso/virt-builder-target.sh.in
@@ -0,0 +1,85 @@
+#!/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.
+
+if [ -z "$OUTPUT" ]; then
+    echo "$0: You didn't set the output file or device (OUTPUT). Read the README file!"
+    exit 1
+fi
+
+if [ -z "$OSVERSION" ]; then
+    echo "$0: You didn't set OSVERSION. Read the README file!"
+    exit 1
+fi
+
+if [ -z "$srcdir" ]; then
+    echo "$0: internal error: srcdir is not set"
+    exit 1
+fi
+
+DISTRO=@DISTRO@
+
+# 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 it doesn't require libguestfs, which simplifies things.
+case "@DISTRO@" in
+    REDHAT)
+        deps=pcre,libxml2,gtk2,/usr/bin/xinit,/usr/bin/ssh,/usr/bin/qemu-nbd,/usr/bin/Xorg,xorg-x11-drv-*,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-* ;;
+    SUSE)
+        deps=pcre,libxml2,gtk2,/usr/bin/ssh,/usr/bin/qemu-nbd,/usr/bin/xinit,/usr/bin/Xorg,xf86-video-* ;;
+    *)
+        echo "$0: internal error: unknown DISTRO value: @DISTRO@"
+        exit 1
+esac
+
+# Run virt-builder.  Note we controversially assume systemd here.  We
+# could provide a sysvinit fallback if required.
+virt-builder "$OSVERSION" \
+    --output "$OUTPUT" \
+    --update \
+    --install $deps \
+    --root-password password:p2v \
+    --upload $srcdir/issue:/etc/issue \
+    --upload $srcdir/issue:/etc/issue.net \
+    --upload ../p2v/virt-p2v:/usr/bin/ \
+    --upload $srcdir/launch-virt-p2v:/usr/bin/ \
+    --upload 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 at .service:
+        s/^ExecStart=(.*)/ExecStart=$1 -a root/
+    ' \
+    --edit '/etc/systemd/logind.conf:
+        s/^[Login]/[Login]\nReserveVT=1\n/
+    ' \
+    $selinux_relabel
diff --git a/src/guestfs.pod b/src/guestfs.pod
index 55e556a..1bcaada 100644
--- a/src/guestfs.pod
+++ b/src/guestfs.pod
@@ -4374,6 +4374,10 @@ the other tools which are written in OCaml.
 
 L<virt-p2v(1)> command and documentation.
 
+=item C<p2v-iso>
+
+Scripts for building the virt-p2v ISO or disk image.
+
 =item C<po>
 
 Translations of simple gettext strings.

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-libvirt/libguestfs.git



More information about the Pkg-libvirt-commits mailing list