|
|
e76f14 |
From 57b9f5b7827c0545ee286b3f0cfab7ae5fcadeb1 Mon Sep 17 00:00:00 2001
|
|
|
e76f14 |
From: "Richard W.M. Jones" <rjones@redhat.com>
|
|
|
e76f14 |
Date: Wed, 27 Jan 2016 11:48:53 +0000
|
|
|
e76f14 |
Subject: [PATCH] p2v: virt-p2v-make-disk: Make os-version parameter optional.
|
|
|
e76f14 |
|
|
|
e76f14 |
Having to choose the os-version of the virt-p2v disk was confusing.
|
|
|
e76f14 |
Users thought it had something to do with the physical machine being
|
|
|
e76f14 |
converted.
|
|
|
e76f14 |
|
|
|
e76f14 |
In some cases, virt-p2v-make-disk can now choose a suitable os-version
|
|
|
e76f14 |
for the user. Usually it's the latest numeric version of Fedora or
|
|
|
e76f14 |
Debian, depending on the host distro. If we don't recognize the host
|
|
|
e76f14 |
distro, we bail and ask the user to choose, but this is still an
|
|
|
e76f14 |
improvement.
|
|
|
e76f14 |
|
|
|
e76f14 |
(cherry picked from commit 3aaa4c9419d539dada31004b47121bbaac5241c6)
|
|
|
e76f14 |
---
|
|
|
e76f14 |
p2v/virt-p2v-make-disk.in | 26 ++++++++++++++++++++++----
|
|
|
e76f14 |
p2v/virt-p2v-make-disk.pod | 30 ++++++++++++++++++------------
|
|
|
e76f14 |
2 files changed, 40 insertions(+), 16 deletions(-)
|
|
|
e76f14 |
|
|
|
e76f14 |
diff --git a/p2v/virt-p2v-make-disk.in b/p2v/virt-p2v-make-disk.in
|
|
|
e76f14 |
index 6769707..88c171f 100644
|
|
|
e76f14 |
--- a/p2v/virt-p2v-make-disk.in
|
|
|
e76f14 |
+++ b/p2v/virt-p2v-make-disk.in
|
|
|
e76f14 |
@@ -38,7 +38,7 @@ upload=
|
|
|
e76f14 |
usage ()
|
|
|
e76f14 |
{
|
|
|
e76f14 |
echo "Usage:"
|
|
|
e76f14 |
- echo " $program [--options] -o /dev/sdX os-version"
|
|
|
e76f14 |
+ echo " $program [--options] -o /dev/sdX [os-version]"
|
|
|
e76f14 |
echo
|
|
|
e76f14 |
echo "Read $program(1) man page for more information."
|
|
|
e76f14 |
exit $1
|
|
|
e76f14 |
@@ -71,12 +71,30 @@ if [ -z "$output" ]; then
|
|
|
e76f14 |
exit 1
|
|
|
e76f14 |
fi
|
|
|
e76f14 |
|
|
|
e76f14 |
-if [ $# -ne 1 ]; then
|
|
|
e76f14 |
- echo "$program: Missing os-version. See $program(1)."
|
|
|
e76f14 |
+if [ $# -gt 1 ]; then
|
|
|
e76f14 |
+ echo "$program: Too many parameters. See $program(1)."
|
|
|
e76f14 |
exit 1
|
|
|
e76f14 |
fi
|
|
|
e76f14 |
|
|
|
e76f14 |
-osversion="$1"
|
|
|
e76f14 |
+if [ $# -eq 1 ]; then
|
|
|
e76f14 |
+ osversion="$1"
|
|
|
e76f14 |
+else
|
|
|
e76f14 |
+ # If osversion was not set, then we must guess a good value
|
|
|
e76f14 |
+ # based on the host distro.
|
|
|
e76f14 |
+ if test -f /etc/redhat-release; then
|
|
|
e76f14 |
+ osversion="$(virt-builder -l | sort |
|
|
|
e76f14 |
+ @AWK@ '/^fedora-[1-9]/ {print $1}' | tail -1)"
|
|
|
e76f14 |
+ elif test -f /etc/debian_version; then
|
|
|
e76f14 |
+ osversion="$(virt-builder -l | sort |
|
|
|
e76f14 |
+ @AWK@ '/^debian-[1-9]/ {print $1}' | tail -1)"
|
|
|
e76f14 |
+ fi
|
|
|
e76f14 |
+ if [ "x$osversion" = "x" ]; then
|
|
|
e76f14 |
+ echo "$program: unable to guess a suitable os-version."
|
|
|
e76f14 |
+ echo "You must supply one on the command line and output of 'virt-builder -l'."
|
|
|
e76f14 |
+ echo "See $program(1) for further details."
|
|
|
e76f14 |
+ exit 1
|
|
|
e76f14 |
+ fi
|
|
|
e76f14 |
+fi
|
|
|
e76f14 |
|
|
|
e76f14 |
# Create a temporary directory and clean it up when we finish.
|
|
|
e76f14 |
tmpdir="$(mktemp -d)"
|
|
|
e76f14 |
diff --git a/p2v/virt-p2v-make-disk.pod b/p2v/virt-p2v-make-disk.pod
|
|
|
e76f14 |
index d401097..79bf499 100644
|
|
|
e76f14 |
--- a/p2v/virt-p2v-make-disk.pod
|
|
|
e76f14 |
+++ b/p2v/virt-p2v-make-disk.pod
|
|
|
e76f14 |
@@ -4,7 +4,7 @@ virt-p2v-make-disk - Build the virt-p2v disk using virt-builder
|
|
|
e76f14 |
|
|
|
e76f14 |
=head1 SYNOPSIS
|
|
|
e76f14 |
|
|
|
e76f14 |
- virt-p2v-make-disk -o /dev/sdX os-version
|
|
|
e76f14 |
+ virt-p2v-make-disk -o /dev/sdX [os-version]
|
|
|
e76f14 |
|
|
|
e76f14 |
=head1 DESCRIPTION
|
|
|
e76f14 |
|
|
|
e76f14 |
@@ -17,28 +17,34 @@ virt-p2v-make-disk is a script which creates a bootable disk image or
|
|
|
e76f14 |
USB key containing virt-p2v. It uses L<virt-builder(1)> to do this,
|
|
|
e76f14 |
and is just a small shell script around virt-builder.
|
|
|
e76f14 |
|
|
|
e76f14 |
-virt-p2v-make-disk has two required parameters:
|
|
|
e76f14 |
+The required I<-o> parameter specifies where the output should go, for
|
|
|
e76f14 |
+example to a USB key (eg. C<-o /dev/sdX>) or to a file. If you pass a
|
|
|
e76f14 |
+device name, then B<the existing contents of the device will be erased>.
|
|
|
e76f14 |
|
|
|
e76f14 |
-The I<-o> parameter specifies where the output should go, for example
|
|
|
e76f14 |
-to a USB key (eg. C<-o /dev/sdX>) or to a file. If you pass a device
|
|
|
e76f14 |
-name, then B<the existing contents of the device will be erased>.
|
|
|
e76f14 |
+=head2 C<os-version> parameter
|
|
|
e76f14 |
|
|
|
e76f14 |
-The C<os-version> parameter is the base Linux distro to use for the
|
|
|
e76f14 |
-operating system on the ISO. To list possible C<os-version>
|
|
|
e76f14 |
-combinations, do:
|
|
|
e76f14 |
+The optional C<os-version> parameter is the base Linux distro to use
|
|
|
e76f14 |
+for the operating system on the ISO. If you don't set this parameter,
|
|
|
e76f14 |
+the script tries to choose a suitable default for you. Most users
|
|
|
e76f14 |
+should I<not> use the C<os-version> parameter.
|
|
|
e76f14 |
+
|
|
|
e76f14 |
+The base OS selected for virt-p2v is not related in any way to the OS
|
|
|
e76f14 |
+of the physical machine that you are trying to convert.
|
|
|
e76f14 |
+
|
|
|
e76f14 |
+To list possible C<os-version> combinations, do:
|
|
|
e76f14 |
|
|
|
e76f14 |
virt-builder -l
|
|
|
e76f14 |
|
|
|
e76f14 |
-=head2 EXAMPLES
|
|
|
e76f14 |
+=head1 EXAMPLES
|
|
|
e76f14 |
|
|
|
e76f14 |
Write a virt-p2v bootable USB key on F</dev/sdX> (any existing content
|
|
|
e76f14 |
-is erased), using Fedora 20 as the base distribution:
|
|
|
e76f14 |
+on F</dev/sdX> is erased):
|
|
|
e76f14 |
|
|
|
e76f14 |
- virt-p2v-make-disk -o /dev/sdX fedora-20
|
|
|
e76f14 |
+ virt-p2v-make-disk -o /dev/sdX
|
|
|
e76f14 |
|
|
|
e76f14 |
Write a virt-p2v bootable virtual disk image, and boot it under qemu:
|
|
|
e76f14 |
|
|
|
e76f14 |
- virt-p2v-make-disk -o /var/tmp/p2v.img fedora-20
|
|
|
e76f14 |
+ virt-p2v-make-disk -o /var/tmp/p2v.img
|
|
|
e76f14 |
qemu-kvm -m 1024 -boot c \
|
|
|
e76f14 |
-drive file=/var/tmp/p2v.img,if=virtio,index=0 \
|
|
|
e76f14 |
-drive file=/var/tmp/guest.img,if=virtio,index=1
|
|
|
e76f14 |
--
|
|
|
7af31e |
1.8.3.1
|
|
|
e76f14 |
|