[Libguestfs] virt-p2v on RHEL 5
Richard W.M. Jones
rjones at redhat.com
Sat Jan 21 13:23:03 UTC 2017
When virtualizing a physical machine ("P2V"), the conversion step is
done by virt-v2v, but there is a small GUI / front end component
called virt-p2v which has to run on the source physical machine in a
special environment.
http://libguestfs.org/virt-p2v.1.html#network-setup
Because the nature of the problem is that we want to virtualize old
machines, this means virt-p2v sometimes has to be run with old drivers
or on machines which would be considered obsolete today as servers
(eg. 32 bit machines).
We have a customer who wishes to virtualize a machine with an ancient
LSI controller that is only supported by a proprietary kernel module
for RHEL 5, and so I spent some time getting virt-p2v to compile and
run on RHEL 5.
These are my notes in case anyone needs to reproduce this (or *I* need
to reproduce it at some later date).
I needed both virt-p2v with the Gtk GUI, and qemu-nbd (also not
available on RHEL 5).
I started with libguestfs from git. I have added a few upstreamable
RHEL 5 patches. I also needed the attached patches which are not
upstreamable.
You will need to run bootstrap and/or autogen.sh on more recent
machine, since autotools on RHEL 5 is far too old. (This was easy for
me because I was building on an NFS homedir shared between Fedora 25
and RHEL 5).
Configure libguestfs like this:
export vmchannel_test=no
export LIBTINFO_CFLAGS=-D_GNU_SOURCE
export LIBTINFO_LIBS=-lncurses
export YAJL_CFLAGS=-D_GNU_SOURCE
export YAJL_LIBS=-lyajl
./configure \
--prefix /usr \
--libdir /usr/lib64 \
--disable-static \
--disable-appliance --disable-daemon \
--disable-ocaml --disable-perl --disable-python --disable-ruby \
--disable-php --disable-lua \
--with-qemu=no
We only want virt-p2v to be compiled, so at this point you can do one
of:
make -k
make -C p2v
This should get you a virt-p2v binary.
For qemu-nbd, the latest qemu is not even close to compiling on RHEL
5. However going back to qemu tag v1.5.0 worked, and it compiled
easily from git. This will give you a qemu-nbd binary.
Provided that both qemu-nbd and virt-p2v are available on the $PATH,
you can now run virt-p2v as normal. Note that you should run it
against virt-v2v on a modern machine (conversion server).
There is a case for making virt-p2v work with other NBD servers
(eg. nbd or nbdkit), or with a minimal built-in NBD server.
To build the RHEL 5 virt-p2v ISO, I had to quite heavily modify the
p2v.ks (kickstart) file. The file is rather large so I could not
attach it, but I placed it here instead:
http://oirase.annexia.org/tmp/p2v-rhel-5.ks
Rich.
--
Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones
Read my programming and virtualization blog: http://rwmj.wordpress.com
Fedora Windows cross-compiler. Compile Windows programs, test, and
build Windows installers. Over 100 libraries supported.
http://fedoraproject.org/wiki/MinGW
-------------- next part --------------
>From 46d4bfd3a773a6117ee6116b4c23cc3a52196544 Mon Sep 17 00:00:00 2001
From: "Richard W.M. Jones" <rjones at redhat.com>
Date: Sat, 21 Jan 2017 09:58:09 +0000
Subject: [PATCH 1/3] RHEL 5 ONLY REMOVE UNSUPPORTED CFLAGS
---
m4/guestfs_c.m4 | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/m4/guestfs_c.m4 b/m4/guestfs_c.m4
index 58ca24c..8748af1 100644
--- a/m4/guestfs_c.m4
+++ b/m4/guestfs_c.m4
@@ -117,7 +117,7 @@ AM_PROG_CC_C_O
# Kill -fstrict-overflow which is a license for the C compiler to make
# dubious and often unsafe optimizations, in a time-wasting attempt to
# deal with CPU architectures that do not exist.
-CFLAGS="$CFLAGS -fno-strict-overflow -Wno-strict-overflow"
+#CFLAGS="$CFLAGS -fno-strict-overflow -Wno-strict-overflow"
dnl Work out how to specify the linker script to the linker.
VERSION_SCRIPT_FLAGS=-Wl,--version-script=
--
1.8.2.3
-------------- next part --------------
>From 901244e97eb138949f80ea305b2fbf3042738659 Mon Sep 17 00:00:00 2001
From: "Richard W.M. Jones" <rjones at redhat.com>
Date: Sat, 21 Jan 2017 05:30:40 -0500
Subject: [PATCH 2/3] RHEL 5 ONLY DISABLE AUTOMATIC REMOTE PORT ALLOCATION
---
p2v/ssh.c | 15 ++++++++++++++-
1 file changed, 14 insertions(+), 1 deletion(-)
diff --git a/p2v/ssh.c b/p2v/ssh.c
index 2dbc109..b1a07fe 100644
--- a/p2v/ssh.c
+++ b/p2v/ssh.c
@@ -1051,11 +1051,22 @@ open_data_connection (struct config *config, int *local_port, int *remote_port)
"-N",
NULL
};
+#if 0
CLEANUP_FREE char *port_str = NULL;
const int ovecsize = 12;
int ovector[ovecsize];
+#endif
- snprintf (remote_arg, sizeof remote_arg, "0:localhost:%d", nbd_local_port);
+ /* RHEL 5 hack: ssh does not print the "Allocated port ..." string,
+ * so we cannot find the remotely allocated port. Instead just
+ * assign a random port and hope for the best.
+ */
+ static int next_remote_port = 58123;
+
+ snprintf (remote_arg, sizeof remote_arg, "%d:localhost:%d",
+ next_remote_port, nbd_local_port);
+ *remote_port = next_remote_port;
+ next_remote_port++;
*local_port = nbd_local_port;
nbd_local_port++;
@@ -1063,6 +1074,7 @@ open_data_connection (struct config *config, int *local_port, int *remote_port)
if (h == NULL)
return NULL;
+#if 0
switch (mexp_expect (h,
(mexp_regexp[]) {
{ 100, .re = portfwd_re },
@@ -1103,6 +1115,7 @@ open_data_connection (struct config *config, int *local_port, int *remote_port)
mexp_close (h);
return NULL;
}
+#endif
return h;
}
--
1.8.2.3
-------------- next part --------------
>From 54bd99f91fd4252f2c7a3531f47d0ed541a8c97e Mon Sep 17 00:00:00 2001
From: "Richard W.M. Jones" <rjones at redhat.com>
Date: Sat, 21 Jan 2017 05:57:17 -0500
Subject: [PATCH 3/3] RHEL 5 ONLY QEMU-NBD 1.4 HAS NO -f OPTION
---
p2v/conversion.c | 1 -
1 file changed, 1 deletion(-)
diff --git a/p2v/conversion.c b/p2v/conversion.c
index 3c379cb..0d71d8f 100644
--- a/p2v/conversion.c
+++ b/p2v/conversion.c
@@ -491,7 +491,6 @@ start_qemu_nbd (int port, const char *device)
"-r", /* readonly (vital!) */
"-p", port_str, /* listening port */
"-t", /* persistent */
- "-f", "raw", /* force raw format */
"-b", "localhost", /* listen only on loopback interface */
"--cache=unsafe", /* use unsafe caching for speed */
device, /* a device like /dev/sda */
--
1.8.2.3
More information about the Libguestfs
mailing list