Cédric Bosdonnat
2016-Jun-22 11:49 UTC
[Libguestfs] [PATCH v2 0/4] virt-p2v support for openSUSE / SLES
Diff to v1: * Use access rather than stat in gui.c * Remove now uneeded and missplaced include for stat.h Cédric Bosdonnat (4): p2v: use yast2 lan on SUSE distros rather than NM p2v: fix dependencies for SLES / openSUSE p2v: add virt-p2v-make-kiwi to generate kiwi config p2v: add -x option to nm-online .gitignore | 3 + configure.ac | 2 + p2v/Makefile.am | 31 +++++- p2v/dependencies.m4 | 19 ++-- p2v/gui.c | 6 +- p2v/kiwi-config.sh | 73 +++++++++++++++ p2v/kiwi-config.xml.in | 92 ++++++++++++++++++ p2v/launch-virt-p2v.in | 17 +++- p2v/utils.c | 2 +- p2v/virt-p2v-make-disk.pod | 1 + p2v/virt-p2v-make-kiwi.in | 228 +++++++++++++++++++++++++++++++++++++++++++++ p2v/virt-p2v-make-kiwi.pod | 184 ++++++++++++++++++++++++++++++++++++ p2v/virt-p2v.pod | 1 + 13 files changed, 641 insertions(+), 18 deletions(-) create mode 100755 p2v/kiwi-config.sh create mode 100644 p2v/kiwi-config.xml.in create mode 100644 p2v/virt-p2v-make-kiwi.in create mode 100644 p2v/virt-p2v-make-kiwi.pod -- 2.6.6
Cédric Bosdonnat
2016-Jun-22 11:49 UTC
[Libguestfs] [PATCH v2 1/4] p2v: use yast2 lan on SUSE distros rather than NM
NetworkManager isn't provided on SLES. As yast2 lan is available on all openSUSE / SLE distro, use it instead. --- p2v/gui.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/p2v/gui.c b/p2v/gui.c index e720002..58a68ec 100644 --- a/p2v/gui.c +++ b/p2v/gui.c @@ -654,7 +654,11 @@ test_connection_ok (gpointer user_data) static void configure_network_button_clicked (GtkWidget *w, gpointer data) { - ignore_value (system ("nm-connection-editor &")); + struct stat statbuf; + if (access ("/sbin/yast2", X_OK) >= 0) + ignore_value (system ("yast2 lan &")); + else + ignore_value (system ("nm-connection-editor &")); } /** -- 2.6.6
Cédric Bosdonnat
2016-Jun-22 11:49 UTC
[Libguestfs] [PATCH v2 2/4] p2v: fix dependencies for SLES / openSUSE
Use the common denominator for SLES and openSUSE in the dependencies. For example most of NetworkManager pieces and metacity aren't provided on SLES. ifconfig is in the net-tools-deprecated package in openSUSE Factory, which means after openSUSE Leap 42.2. Older versions have it in the net-tools package. Adding this complexity only to add ifconfig because sysadmins prefer it isn't too good: iproute2 is doing the job. --- p2v/dependencies.m4 | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/p2v/dependencies.m4 b/p2v/dependencies.m4 index 635e253..fd20ddd 100644 --- a/p2v/dependencies.m4 +++ b/p2v/dependencies.m4 @@ -119,8 +119,8 @@ ifelse(SUSE,1, pcre libxml2 gtk`'GTK_VERSION - /usr/bin/ssh - /usr/bin/qemu-nbd + qemu-tools + openssh curl ethtool hwdata @@ -129,14 +129,15 @@ ifelse(SUSE,1, smartmontools util-linux xterm - /usr/bin/xinit - /usr/bin/Xorg + xinit + xorg-x11-server xf86-video-* dejavu-fonts - metacity NetworkManager - nm-connection-editor - network-manager-applet - dbus-x11 - net-tools-deprecated + xf86-input-* + icewm-lite + dbus-1-x11 + yast2-network + libyui-qt + SuSEfirewall2 ) -- 2.6.6
Cédric Bosdonnat
2016-Jun-22 11:49 UTC
[Libguestfs] [PATCH v2 3/4] p2v: add virt-p2v-make-kiwi to generate kiwi config
Kiwi is the tool used by openSUSE / SLES to generate many sort of disk images. Add a virt-p2v-make-kiwi tool and his documentation to geneate the p2v appliance kiwi configuration. --- .gitignore | 3 + configure.ac | 2 + p2v/Makefile.am | 31 +++++- p2v/kiwi-config.sh | 73 +++++++++++++++ p2v/kiwi-config.xml.in | 92 ++++++++++++++++++ p2v/launch-virt-p2v.in | 17 +++- p2v/virt-p2v-make-disk.pod | 1 + p2v/virt-p2v-make-kiwi.in | 228 +++++++++++++++++++++++++++++++++++++++++++++ p2v/virt-p2v-make-kiwi.pod | 184 ++++++++++++++++++++++++++++++++++++ p2v/virt-p2v.pod | 1 + 10 files changed, 625 insertions(+), 7 deletions(-) create mode 100755 p2v/kiwi-config.sh create mode 100644 p2v/kiwi-config.xml.in create mode 100644 p2v/virt-p2v-make-kiwi.in create mode 100644 p2v/virt-p2v-make-kiwi.pod diff --git a/.gitignore b/.gitignore index d48dee3..c249cb0 100644 --- a/.gitignore +++ b/.gitignore @@ -329,6 +329,7 @@ Makefile.in /p2v/stamp-virt-p2v.pod /p2v/stamp-virt-p2v-make-disk.pod /p2v/stamp-virt-p2v-make-kickstart.pod +/p2v/stamp-virt-p2v-make-kiwi.pod /p2v/test-virt-p2v-pxe.authorized_keys /p2v/test-virt-p2v-pxe.id_rsa /p2v/test-virt-p2v-pxe.id_rsa.pub @@ -346,6 +347,8 @@ Makefile.in /p2v/virt-p2v-make-disk.1 /p2v/virt-p2v-make-kickstart /p2v/virt-p2v-make-kickstart.1 +/p2v/virt-p2v-make-kiwi +/p2v/virt-p2v-make-kiwi.1 /perl/_build /perl/bindtests.pl /perl/blib diff --git a/configure.ac b/configure.ac index 9ec8ac4..00941e0 100644 --- a/configure.ac +++ b/configure.ac @@ -157,6 +157,8 @@ 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([p2v/virt-p2v-make-kiwi], + [chmod +x,-w p2v/virt-p2v-make-kiwi]) AC_CONFIG_FILES([php/extension/php-for-tests.sh], [chmod +x,-w php/extension/php-for-tests.sh]) AC_CONFIG_FILES([pick-guests.pl], diff --git a/p2v/Makefile.am b/p2v/Makefile.am index 4c4994b..525b80c 100644 --- a/p2v/Makefile.am +++ b/p2v/Makefile.am @@ -21,6 +21,8 @@ EXTRA_DIST = \ $(TESTS) $(SLOW_TESTS) \ dependencies.m4 \ issue \ + kiwi-config.sh \ + kiwi-config.xml.in \ launch-virt-p2v.in \ p2v.ks.in \ p2v.service \ @@ -30,7 +32,9 @@ EXTRA_DIST = \ virt-p2v-make-disk.in \ virt-p2v-make-disk.pod \ virt-p2v-make-kickstart.in \ - virt-p2v-make-kickstart.pod + virt-p2v-make-kickstart.pod \ + virt-p2v-make-kiwi.in \ + virt-p2v-make-kiwi.pod # Don't clean ssh_host_rsa_key{,.pub} or id_rsa{,.pub} since those # consume system entropy to regenerate. @@ -41,6 +45,7 @@ CLEANFILES = \ stamp-virt-p2v.pod \ stamp-virt-p2v-make-disk.pod \ stamp-virt-p2v-make-kickstart.pod \ + stamp-virt-p2v-make-kiwi.pod \ test-virt-p2v-pxe.authorized_keys \ test-virt-p2v-pxe.img \ test-virt-p2v-pxe.vmlinuz \ @@ -49,7 +54,8 @@ CLEANFILES = \ virt-p2v.1 \ virt-p2v.img \ virt-p2v-make-disk.1 \ - virt-p2v-make-kickstart.1 + virt-p2v-make-kickstart.1 \ + virt-p2v-make-kiwi.1 # 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 @@ -96,7 +102,7 @@ virt_p2v_LDADD = \ ../gnulib/lib/libgnu.la # Scripts to build the disk image, USB key, or kickstart. -bin_SCRIPTS = virt-p2v-make-disk virt-p2v-make-kickstart +bin_SCRIPTS = virt-p2v-make-disk virt-p2v-make-kickstart virt-p2v-make-kiwi dependencies_files = \ dependencies.archlinux \ @@ -115,6 +121,8 @@ virtp2vdatadir = $(datadir)/virt-p2v virtp2vdata_DATA = \ $(dependencies_files) \ issue \ + kiwi-config.sh \ + kiwi-config.xml.in \ launch-virt-p2v \ p2v.ks.in \ p2v.service @@ -130,12 +138,14 @@ launch-virt-p2v: launch-virt-p2v.in man_MANS = \ virt-p2v.1 \ virt-p2v-make-disk.1 \ - virt-p2v-make-kickstart.1 + virt-p2v-make-kickstart.1 \ + virt-p2v-make-kiwi.1 noinst_DATA = \ $(top_builddir)/website/virt-p2v.1.html \ $(top_builddir)/website/virt-p2v-make-disk.1.html \ - $(top_builddir)/website/virt-p2v-make-kickstart.1.html + $(top_builddir)/website/virt-p2v-make-kickstart.1.html \ + $(top_builddir)/website/virt-p2v-make-kiwi.1.html virt-p2v.1 $(top_builddir)/website/virt-p2v.1.html: stamp-virt-p2v.pod @@ -170,6 +180,17 @@ stamp-virt-p2v-make-kickstart.pod: virt-p2v-make-kickstart.pod $< touch $@ +virt-p2v-make-kiwi.1 $(top_builddir)/website/virt-p2v-make-kiwi.1.html: stamp-virt-p2v-make-kiwi.pod + +stamp-virt-p2v-make-kiwi.pod: virt-p2v-make-kiwi.pod + $(PODWRAPPER) \ + --man virt-p2v-make-kiwi.1 \ + --html $(top_builddir)/website/virt-p2v-make-kiwi.1.html \ + --license GPLv2+ \ + --warning safe \ + $< + touch $@ + # Run virt-p2v locally either directly or in a VM. # See guestfs-hacking(1) section "Running virt-p2v" diff --git a/p2v/kiwi-config.sh b/p2v/kiwi-config.sh new file mode 100755 index 0000000..b24fd3b --- /dev/null +++ b/p2v/kiwi-config.sh @@ -0,0 +1,73 @@ +#!/bin/bash +#===============+# FILE : config.sh +#---------------- +# PROJECT : OpenSuSE KIWI Image System +# COPYRIGHT : (c) 2006 SUSE LINUX Products GmbH. All rights reserved +# : +# AUTHOR : Marcus Schaefer <ms@suse.de> +#=====================================+# Functions... +#-------------------------------------- +test -f /.kconfig && . /.kconfig +test -f /.profile && . /.profile + +#=====================================+# Greeting... +#-------------------------------------- +echo "Configure image: [$kiwi_iname]..." + +#=====================================+# Mount system filesystems +#-------------------------------------- +baseMount + +#=====================================+# Setup baseproduct link +#-------------------------------------- +suseSetupProduct + +#=====================================+# Add missing gpg keys to rpm +#-------------------------------------- +suseImportBuildKey + +#=====================================+# Activate services +#-------------------------------------- +suseInsertService p2v + +#=====================================+# Setup default target, multi-user +#-------------------------------------- +baseSetRunlevel 3 + +#=========================================+# remove package docs +#------------------------------------------ +rm -rf /usr/share/doc/packages/* +rm -rf /usr/share/doc/manual/* +rm -rf /opt/kde* + +# 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 + +sed -i 's/^ROOT_USES_LANG=.*$/ROOT_USES_LANG="yes"/' \ + /etc/sysconfig/language + +#=====================================+# SuSEconfig +#-------------------------------------- +suseConfig + +#=====================================+# Umount kernel filesystems +#-------------------------------------- +baseCleanMount + +exit 0 diff --git a/p2v/kiwi-config.xml.in b/p2v/kiwi-config.xml.in new file mode 100644 index 0000000..680076b --- /dev/null +++ b/p2v/kiwi-config.xml.in @@ -0,0 +1,92 @@ +<?xml version="1.0" encoding="utf-8"?> +<image schemaversion="6.2" name="p2v-__KIWI_BOOT__" displayname="p2v___PACKAGE_VERSION_____KIWI_BOOT__"> + <description type="system"> + <author>Marcus Schäfer</author> + <contact>ms@suse.com</contact> + <specification>P2V __PACKAGE_VERSION__</specification> + </description> + <profiles> + <profile name="vmxFlavour" description="VMX with default kernel" import="true"/> + <profile name="netboot" description="compressed rootfs image for pxe"/> + </profiles> + <preferences> + <type image="iso" primary="true" boot="isoboot/suse-__KIWI_BOOT__" flags="overlay" hybrid="true" firmware="uefi" kernelcmdline="splash"/> + <version>__PACKAGE_VERSION__</version> + <packagemanager>zypper</packagemanager> + <locale>en_US</locale> + <keytable>us.map.gz</keytable> + <hwclock>utc</hwclock> + <bootloader-theme>__BRANDING__</bootloader-theme> + <bootsplash-theme>__BRANDING__</bootsplash-theme> + <rpm-excludedocs>true</rpm-excludedocs> + <rpm-check-signatures>false</rpm-check-signatures> + </preferences> + <preferences profiles="netboot"> + <type image="pxe" filesystem="overlayfs" boot="netboot/suse-__KIWI_BOOT__"> + <pxedeploy server="192.168.100.2" blocksize="4096"> + <partitions device="/dev/sda"> + <partition type="swap" number="1" size="5"/> + <partition type="L" number="2" size="image" mountpoint="/" target="true"/> + <partition type="L" number="3" target="false"/> + </partitions> + <union ro="/dev/sda2" rw="/dev/sda3" type="overlayfs"/> + </pxedeploy> + </type> + </preferences> + <preferences profiles="vmxFlavour"> + <type image="vmx" filesystem="ext3" boot="vmxboot/suse-__KIWI_BOOT__" format="vmdk" bootloader="grub2" firmware="uefi" kernelcmdline="splash" bootpartition="false"> + <systemdisk name="systemVG"/> + <machine memory="512" guestOS="suse" HWversion="4"> + <vmdisk id="0" controller="ide"/> + <vmnic driver="e1000" interface="0" mode="bridged"/> + </machine> + </type> + </preferences> + <users group="root"> + <user password="p2v" pwdformat="plain" home="/root" name="root"/> + </users> + <!--__REPOS__--> + <packages type="image" patternType="onlyRequired"> + <package name="__BASE_PATTERN__"/> + <package name="plymouth-branding-__BRANDING__" bootinclude="true"/> + <package name="grub2-branding-__BRANDING__" bootinclude="true"/> + <package name="iputils"/> + <package name="grub2"/> + <package name="grub2-x86_64-efi"/> + <package name="syslinux"/> + <package name="lvm2"/> + <package name="plymouth"/> + <package name="fontconfig"/> + <package name="fonts-config"/> + <package name="tar"/> + <package name="systemd"/> + <package name="systemd-sysvinit"/> + <package name="dracut"/> + <package name="wicked"/> + <package name="iproute2"/> + <package name="sudo"/> + <package name="dhcp-client"/> + <package name="which"/> + <!-- virt-p2v dependencies from dependencies.suse --> +<!--__DEPENDENCIES__--> + </packages> + <packages type="iso"> + <package name="gfxboot-branding-__BRANDING__" bootinclude="true" bootdelete="true"/> + </packages> + <packages type="image" profiles="vmxFlavour"> + <package name="kernel-default" replaces="kernel-xen"/> + <package name="kernel-default" replaces="xen-kmp-default"/> + <package name="kernel-default" replaces="xen-libs"/> + <package name="kernel-default" replaces="xen-tools"/> + <package name="kernel-default" replaces="xen"/> + <package name="gfxboot-branding-__BRANDING__" bootinclude="true" bootdelete="true"/> + </packages> + <packages type="bootstrap"> + <package name="udev"/> + <package name="filesystem"/> + <package name="glibc-locale"/> + <package name="cracklib-dict-full"/> + <package name="ca-certificates"/> + <package name="__RELEASE_PKG__"/> + </packages> +</image> diff --git a/p2v/launch-virt-p2v.in b/p2v/launch-virt-p2v.in index 3e4f1f9..65481e4 100755 --- a/p2v/launch-virt-p2v.in +++ b/p2v/launch-virt-p2v.in @@ -30,8 +30,21 @@ else # self again to run the window manager and virt-p2v. if [ "$1" = "run" ]; then cd / - metacity & - nm-applet & + + ID+ if test -f /etc/os-release; then + . /etc/os-release + fi + + case "$ID" in + sles|opensuse) + # not all versions of SLE / openSUSE ship metacity and nm-applet + icewm & + ;; + *) + metacity & + nm-applet & + esac exec @libexecdir@/virt-p2v --iso else xinit "$0" run diff --git a/p2v/virt-p2v-make-disk.pod b/p2v/virt-p2v-make-disk.pod index 58e845c..0765dd8 100644 --- a/p2v/virt-p2v-make-disk.pod +++ b/p2v/virt-p2v-make-disk.pod @@ -184,6 +184,7 @@ L</FILES> above). If not set, a compiled-in location is used. L<virt-p2v(1)>, L<virt-p2v-make-kickstart(1)>, +L<virt-p2v-make-kiwi(1)>, L<virt-v2v(1)>, L<http://libguestfs.org/>. diff --git a/p2v/virt-p2v-make-kiwi.in b/p2v/virt-p2v-make-kiwi.in new file mode 100644 index 0000000..e493bd4 --- /dev/null +++ b/p2v/virt-p2v-make-kiwi.in @@ -0,0 +1,228 @@ +#!/bin/bash - +# @configure_input@ +# virt-p2v-make-kiwi +# Copyright (C) 2016 SUSE. +# +# 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-kiwi" +version="@PACKAGE_VERSION@" + +TEMP=`getopt \ + -o o:V \ + --long help,inject-ssh-identity:,output:,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 kiwi-folder]" + echo + echo "Read $program(1) man page for more information." + exit $1 +} + +output=p2v.kiwi +ssh_identity+ +while true; do + case "$1" in + --inject-ssh-identity) + ssh_identity="$2" + shift 2;; + -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 + +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 + +# Dependencies. Since kiwi is SUSE-specific, only include +# dependencies.suse here. +depsfile="$datadir/dependencies.suse" +if [ ! -f "$depsfile" ]; then + echo "$0: cannot find dependencies file ($depsfile)" + exit 1 +fi +dependencies+while read line; do + if [ -n "$line" ]; then + depname=$(echo $line | awk '{gsub(/ /, "", $0); print}') + pkg=" <package name=\"$depname\"/>" + if [ -z "$dependencies" ]; then + dependencies="$pkg" + else + dependencies="$dependencies +$pkg" + fi + fi +done < $depsfile + +# Compute the distro-dependent pieces for kiwi +branding+release_pkg+base_pattern+kiwi_boot+repos+. /etc/os-release +case "$NAME" in + SLES) + branding="SLE" + release_pkg="sles-release" + base_pattern="patterns-sles-Minimal" + case "$VERSION_ID" in + 12) + kiwi_boot="SLES12" + repos="http://download.suse.de/ibs/SUSE:/SLE-12:/Update/standard + http://download.suse.de/ibs/SUSE:/SLE-12:/GA/standard" + ;; + 12.1) + kiwi_boot="SLES12" + repos="http://download.suse.de/ibs/SUSE:/SLE-12-SP1:/Update/standard + http://download.suse.de/ibs/SUSE:/SLE-12-SP1:/GA/standard + http://download.suse.de/ibs/SUSE:/SLE-12:/Update/standard + http://download.suse.de/ibs/SUSE:/SLE-12:/GA/standard" + ;; + *) + echo "Unsupported distribution $NAME $VERSION_ID" + exit 1;; + esac;; + openSUSE*) + branding="openSUSE" + release_pkg="openSUSE-release" + base_pattern="patterns-openSUSE-base" + case "$VERSION" in + 13.1\ *) + kiwi_boot="13.1" + repos="obs://13.1/repo/oss" + ;; + 13.2\ *) + kiwi_boot="13.2" + repos="obs://13.2/repo/oss" + ;; + 42.1) + kiwi_boot="leap42.1" + repos="obs://leap/42.1/repo/oss" + ;; + *\ \(Tumbleweed\)) + kiwi_boot="leap42.1" + repos="obs://openSUSE:Factory/standard" + ;; + *) + echo "Unsupported distribution $NAME $VERSION_ID" + exit 1;; + esac;; + *) + echo "Unsupported distribution $NAME $VERSION" + exit 1;; +esac + +# Compute the repos +repos_xml+for repo in $repos; do + repos_xml=" <repository type=\"rpm-md\">\n <source path=\"$repo\"/>\n </repository>\n$repos_xml" +done + +mkdir $output +cp $datadir/kiwi-config.sh $output/config.sh + +mkdir -p $output/root/etc/sysconfig/network +cat >$output/root/etc/sysconfig/network/ifcfg-eth0 << EOF +BOOTPROTO='dhcp' +MTU='' +REMOTE_IPADDR='' +STARTMODE='onboot' +EOF + +mkdir -p $output/root/etc/systemd/system +cp $datadir/p2v.service $output/root/etc/systemd/system + +mkdir -p $output/root/etc/udev/rules.d +cat >$output/root/etc/udev/rules.d/70-persistent-net.rules <<EOF +SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="?*", ATTR{dev_id}=="0x0", ATTR{type}=="1", KERNEL=="?*", NAME="eth0" +EOF + +cp $datadir/issue $output/root/etc/issue + +mkdir -p $output/root/usr/bin +cp $datadir/launch-virt-p2v $output/root/usr/bin + +mkdir -p $output/root/$libexecdir +cp $host_libexecdir/virt-p2v $output/root/$libexecdir + +if test "z$ssh_identity" != "z"; then + mkdir -p $output/root/var/tmp + cp $ssh_identity $output/root/var/tmp/id_rsa + chmod 0600 $output/root/var/tmp/id_rsa +fi + +# Now generate the final kiwi config, substituting as necessary. +@AWK@ \ + -v "dependencies=$dependencies" \ + -v "md5sum_virt_p2v=$md5sum_virt_p2v" \ + -v "libexecdir=$libexecdir" \ + -v "branding=$branding" \ + -v "release_pkg=$release_pkg" \ + -v "base_pattern=$base_pattern" \ + -v "kiwi_boot=$kiwi_boot" \ + -v "repos=$repos_xml" \ + '{ + gsub (/__PACKAGE_NAME__/, "@PACKAGE_NAME@"); + gsub (/__PACKAGE_VERSION__/, "@PACKAGE_VERSION@"); + gsub (/__PACKAGE_VERSION_FULL__/, "@PACKAGE_VERSION_FULL@"); + gsub (/<!--__DEPENDENCIES__-->/, dependencies); + gsub (/__LIBEXECDIR__/, libexecdir); + gsub (/__BRANDING__/, branding); + gsub (/__RELEASE_PKG__/, release_pkg); + gsub (/__BASE_PATTERN__/, base_pattern); + gsub (/__KIWI_BOOT__/, kiwi_boot); + gsub (/<!--__REPOS__-->/, repos); + print; + }' \ + $datadir/kiwi-config.xml.in > $output/config.xml + +echo "kiwi config folder written to $output" diff --git a/p2v/virt-p2v-make-kiwi.pod b/p2v/virt-p2v-make-kiwi.pod new file mode 100644 index 0000000..92556d9 --- /dev/null +++ b/p2v/virt-p2v-make-kiwi.pod @@ -0,0 +1,184 @@ +=head1 NAME + +virt-p2v-make-kiwi - Build the virt-p2v kiwi configuration + +=head1 SYNOPSIS + + virt-p2v-make-kiwi [--inject-ssh-identity path] [-o kiwi-folder] + +=head1 DESCRIPTION + +L<virt-p2v(1)> converts a physical machine to run virtualized on KVM, +managed by libvirt, OpenStack, oVirt, Red Hat Enterprise +Virtualisation (RHEV), or one of the other targets supported by +L<virt-v2v(1)>. + +Kiwi is a tool used mainly by SUSE Linux Enterprise and openSUSE to +build live CDs, make appliances and so on. It is driven by a few files +including an xml description of the machine. + +virt-p2v-make-kiwi builds a folder containing all the pieces needed for +kiwi to build a bootable P2V live CD ISO, USB key, or PXE image. This tool +only builds the kiwi configuration, but this manual page describes some of +the ways you can use the kickstart file. + +=head1 BUILDING THE KIWI CONFIGURATION + +Using virt-p2v-make-kiwi is very simple: + + virt-p2v-make-kiwi + +will build a kiwi configuration based on the current machine's distribution. + +To control the name of the output folder, use the I<-o> parameter. + +=head1 BUILDING A LIVE CD / ISO + +Once you have the kiwi configuration folder, you can use L<kiwi(1)> to make a +live CD: + + sudo kiwi --build p2v.kiwi -d build --type iso + +Before running this, you may have to tweak the C<config.xml> file +to change the locale and keyboard mapping to the one you need. + +If running on a SUSE Linux Entreprise Server, add the path to your packages repositories +using the C<--ignore-repos> and C<--add-repo> kiwi parameters. + +The generated ISO image will be placed in the C<build> folder. + +=head1 BUILDING A BOOTABLE USB KEY + +Use the L<dd(1)> program to write the ISO created above to a USB key: + + sudo dd if=path/to/p2v.iso of=/dev/sdX + +=head1 BUILDING A PXE BOOT IMAGE + +To create a PXE boot image, run kiwi in such a way: + + sudo kiwi --build $PWD/p2v.kiwi -d build --add-profile netboot --type pxe + +For more details on how to use the generated image, report to the kiwi documentation +on PXE images: L<https://doc.opensuse.org/projects/kiwi/doc/#chap.pxe> + +=head1 ADDING AN SSH IDENTITY + +You can inject an SSH identity (private key) file to the kiwi config and +hence into the ISO using the I<--inject-ssh-identity> option. Note +that you I<cannot> inject a key once the ISO has been built. + +First create a key pair. It must have an empty passphrase: + + ssh-keygen -t rsa -N '' -f id_rsa + +This creates a private key (C<id_rsa>) and a public key +(C<id_rsa.pub>) pair. The public key should be appended to the +C<authorized_keys> file on the virt-v2v conversion server (usually to +C</root/.ssh/authorized_keys>). + +The private key should be added to the kiwi config and then +discarded: + + virt-p2v-make-kiwi [...] --inject-ssh-identity id_rsa + rm id_rsa + +The ISO can then be built from the kickstart in the usual way (see +above), and it will contain the embedded SSH identity +(F</var/tmp/id_rsa>). + +When booting virt-p2v, specify the URL of the injected file like this: + + │ User name: [root_____________________________] │ + │ │ + │ Password: [ <leave this field blank> ] │ + │ │ + │ SSH Identity URL: [file:///var/tmp/id_rsa___________] │ + +or if using the kernel command line, add: + + p2v.identity=file:///var/tmp/id_rsa + +For more information, see L<virt-p2v(1)/SSH IDENTITIES>. + +=head1 OPTIONS + +=over 4 + +=item B<--help> + +Display help. + +=item B<--inject-ssh-identity> id_rsa + +Add an SSH identity (private key) file into the kickstart. +See L</ADDING AN SSH IDENTITY> above. + +=item B<-o> OUTPUT + +=item B<--output> OUTPUT + +Write kiwi configuration to the C<OUTPUT> folder. If not specified, the default is +F<p2v.kiwi> in the current directory. + +=item B<-V> + +=item B<--version> + +Display version number and exit. + +=back + +=head1 FILES + +=over 4 + +=item F<$libexecdir/virt-p2v> + +The L<virt-p2v(1)> binary which is copied into the kiwi configuration. + +The location of the binary can be changed by setting the +C<VIRT_P2V_DATA_DIR> environment variable. + +=item F<$datadir/virt-p2v/issue> + +=item F<$datadir/virt-p2v/launch-virt-p2v.in> + +=item F<$datadir/virt-p2v/kiwi> + +=item F<$datadir/virt-p2v/p2v.service> + +Various data files that are used to make the kiwi appliance. + +The location of these files can be changed by setting the +C<VIRT_P2V_DATA_DIR> environment variable. + +=back + +=head1 ENVIRONMENT VARIABLES + +=over 4 + +=item C<VIRT_P2V_DATA_DIR> + +The directory where virt-p2v-make-kiwi looks for data files and +the virt-p2v binary (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<kiwi(1)>, +L<http://libguestfs.org/>. + +=head1 AUTHORS + +Cédric Bosdonnat + +=head1 COPYRIGHT + +Copyright (C) 2016 SUSE Ltd. diff --git a/p2v/virt-p2v.pod b/p2v/virt-p2v.pod index 945d8c2..d013fcf 100644 --- a/p2v/virt-p2v.pod +++ b/p2v/virt-p2v.pod @@ -757,6 +757,7 @@ the graphical UI. L<virt-p2v-make-disk(1)>, L<virt-p2v-make-kickstart(1)>, +L<virt-p2v-make-kiwi(1)>, L<virt-v2v(1)>, L<qemu-nbd(1)>, L<ssh(1)>, -- 2.6.6
Cédric Bosdonnat
2016-Jun-22 11:49 UTC
[Libguestfs] [PATCH v2 4/4] p2v: add -x option to nm-online
On distros not running NetworkManager, use the nm-online -x parameter to exit quickly. The network connection will be checked just after anyway when attempting to connect to the conversion server using ssh. --- p2v/utils.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/p2v/utils.c b/p2v/utils.c index c4f82cd..746093b 100644 --- a/p2v/utils.c +++ b/p2v/utils.c @@ -139,7 +139,7 @@ get_if_vendor (const char *if_name, int truncate) } /* XXX We could make this configurable. */ -#define NETWORK_ONLINE_COMMAND "nm-online -t 30" +#define NETWORK_ONLINE_COMMAND "nm-online -t 30 -x" /** * Wait for the network to come online, but don't error out if that -- 2.6.6
Maybe Matching Threads
- [PATCH v3 0/4] virt-p2v support for openSUSE / SLES
- [PATCH 0/4] virt-p2v support for openSUSE / SLES
- [PATCH 0/2] Remove virt-p2v from libguestfs
- [PATCH] p2v: Compress virt-p2v binary and store it in $libdir/virt-p2v (RHBZ#1382275).
- [PATCH] p2v: kiwi: make sure launch-virt-p2v is executable