The following patches add RHEL 6 guest support to virt-v2v. This was actually quite a lot easier than I expected. * [PATCH 1/4] Update virt-v2v.conf for RHEL 6 virtio support * [PATCH 2/4] Check kudzu exists before attempting to disable it * [PATCH 3/4] Use dracut rather than mkinitrd if it's available * [PATCH 4/4] Properly convert RHEL 6 guest console
Matthew Booth
2010-Jul-28 09:16 UTC
[Libguestfs] [PATCH 1/4] Update virt-v2v.conf for RHEL 6 virtio support
RHEL 6 has always supported virtio, so no dependencies are required.
---
v2v/virt-v2v.conf | 3 +++
1 files changed, 3 insertions(+), 0 deletions(-)
diff --git a/v2v/virt-v2v.conf b/v2v/virt-v2v.conf
index c3dfd30..a79f3a8 100644
--- a/v2v/virt-v2v.conf
+++ b/v2v/virt-v2v.conf
@@ -37,6 +37,9 @@
You shouldn't need to modify these.
-->
+ <!-- RHEL 6 has always supported virtio -->
+ <capability os='linux' distro='rhel' major='6'
name='virtio'/>
+
<capability os='linux' distro='rhel' major='5'
name='virtio'>
<dep name='kernel' minversion='2.6.18-128.el5'/>
<dep name='lvm2' minversion='2.02.40-6.el5'/>
--
1.7.2
Matthew Booth
2010-Jul-28 09:16 UTC
[Libguestfs] [PATCH 2/4] Check kudzu exists before attempting to disable it
chkconfig will return an error if kudzu isn't installed, which will cause
the
conversion to fail.
---
lib/Sys/VirtV2V/GuestOS/RedHat.pm | 4 +++-
1 files changed, 3 insertions(+), 1 deletions(-)
diff --git a/lib/Sys/VirtV2V/GuestOS/RedHat.pm
b/lib/Sys/VirtV2V/GuestOS/RedHat.pm
index 563e6f1..f04beb3 100644
--- a/lib/Sys/VirtV2V/GuestOS/RedHat.pm
+++ b/lib/Sys/VirtV2V/GuestOS/RedHat.pm
@@ -1789,7 +1789,9 @@ sub prepare_bootable
# require manual intervention, or
# disable the network interface
# Neither of these behaviours is desirable.
- $g->command(['/sbin/chkconfig', 'kudzu',
'off']);
+ if ($g->exists('/etc/init.d/kudzu')) {
+ $g->command(['/sbin/chkconfig', 'kudzu',
'off']);
+ }
}
=item supports_virtio(kernel)
--
1.7.2
Matthew Booth
2010-Jul-28 09:16 UTC
[Libguestfs] [PATCH 3/4] Use dracut rather than mkinitrd if it's available
---
lib/Sys/VirtV2V/GuestOS/RedHat.pm | 48 ++++++++++++++++++++----------------
1 files changed, 27 insertions(+), 21 deletions(-)
diff --git a/lib/Sys/VirtV2V/GuestOS/RedHat.pm
b/lib/Sys/VirtV2V/GuestOS/RedHat.pm
index f04beb3..f5531a5 100644
--- a/lib/Sys/VirtV2V/GuestOS/RedHat.pm
+++ b/lib/Sys/VirtV2V/GuestOS/RedHat.pm
@@ -1755,33 +1755,39 @@ sub prepare_bootable
# Backup the original initrd
$g->mv($initrd, "$initrd.pre-v2v") if
($g->exists($initrd));
- # Create a new initrd which probes the required kernel modules
- my @module_args = ();
- foreach my $module (@modules) {
- push(@module_args, "--with=$module");
+ if ($g->exists('/sbin/dracut')) {
+ $g->command(['/sbin/dracut', '--add-drivers',
join(" ", @modules),
+ $initrd, $version]);
}
- # mkinitrd reads configuration which we've probably changed
- eval {
- $g->aug_save();
- };
+ elsif ($g->exists('/sbin/mkinitrd')) {
+ # Create a new initrd which probes the required kernel modules
+ my @module_args = ();
+ foreach my $module (@modules) {
+ push(@module_args, "--with=$module");
+ }
- $self->_augeas_error($@) if ($@);
+ # We explicitly modprobe ext2 here. This is required by mkinitrd on
+ # RHEL 3, and shouldn't hurt on other OSs. We don't care if
this
+ # fails.
+ eval {
+ $g->modprobe('ext2');
+ };
- # We explicitly modprobe ext2 here. This is required by mkinitrd on
RHEL
- # 3, and shouldn't hurt on other OSs. We don't care if this
fails.
- eval {
- $g->modprobe("ext2");
- };
+ # loop is a module in RHEL 5. Try to load it. Doesn't matter
for
+ # other OSs if it doesn't exist, but RHEL 5 will complain:
+ # All of your loopback devices are in use.
+ eval {
+ $g->modprobe('loop');
+ };
- # loop is a module in RHEL 5. Try to load it. Doesn't matter for
other
- # OSs if it doesn't exist, but RHEL 5 will complain:
- # All of your loopback devices are in use.
- eval {
- $g->modprobe("loop");
- };
+ $g->command(['/sbin/mkinitrd', @module_args, $initrd,
$version]);
+ }
- $g->command(["/sbin/mkinitrd", @module_args, $initrd,
$version]);
+ else {
+ die user_message(__"Didn't find mkinitrd or dracut. Unable
to ".
+ "update initrd");
+ }
}
# Disable kudzu in the guest
--
1.7.2
Matthew Booth
2010-Jul-28 09:16 UTC
[Libguestfs] [PATCH 4/4] Properly convert RHEL 6 guest console
RHEL 6 Xen uses hvc0. Although KVM provides virtio-console on hvc0, libvirt
doesn't yet support this, so we must use ttyS0 instead.
---
lib/Sys/VirtV2V/Converter/Linux.pm | 21 ++++++++++++++-------
1 files changed, 14 insertions(+), 7 deletions(-)
diff --git a/lib/Sys/VirtV2V/Converter/Linux.pm
b/lib/Sys/VirtV2V/Converter/Linux.pm
index ffcf9eb..890ae7c 100644
--- a/lib/Sys/VirtV2V/Converter/Linux.pm
+++ b/lib/Sys/VirtV2V/Converter/Linux.pm
@@ -195,27 +195,34 @@ sub _configure_kernel_modules
}
# We configure a console on ttyS0. Make sure existing console references use
it.
+# N.B. Note that the RHEL 6 xen guest kernel presents a console device called
+# /dev/hvc0, whereas previous xen guest kernels presented /dev/xvc0. The
regular
+# kernel running under KVM also presents a virtio console device called
+# /dev/hvc0, so ideally we would just leave it alone. However, RHEL 6 libvirt
+# doesn't yet support this device so we can't attach to it. We
therefore use
+# /dev/ttyS0 for RHEL 6 anyway.
sub _configure_console
{
my ($g) = @_;
- # Look for gettys which use xvc0
+ # Look for gettys which use xvc0 or hvc0
+ # RHEL 6 doesn't use /etc/inittab, but this doesn't hurt
foreach my $augpath
($g->aug_match("/files/etc/inittab/*/process")) {
my $proc = $g->aug_get($augpath);
# If the process mentions xvc0, change it to ttyS0
- if ($proc =~ /\bxvc0\b/) {
- $proc =~ s/\bxvc0\b/ttyS0/g;
+ if ($proc =~ /\b(x|h)vc0\b/) {
+ $proc =~ s/\b(x|h)vc0\b/ttyS0/g;
$g->aug_set($augpath, $proc);
}
}
- # Replace any mention of xvc0 in /etc/securetty with ttyS0
+ # Replace any mention of xvc0 or hvc0 in /etc/securetty with ttyS0
my $size = 0;
my @lines = ();
foreach my $line ($g->read_lines('/etc/securetty')) {
- if($line eq "xvc0") {
+ if($line eq "xvc0" || $line eq "hvc0") {
$line = "ttyS0";
}
@@ -230,8 +237,8 @@ sub _configure_console
($g->aug_match("/files/boot/grub/menu.lst/title/kernel/console"))
{
my $console = $g->aug_get($augpath);
- if ($console =~ /\bxvc0\b/) {
- $console =~ s/\bxvc0\b/ttyS0/g;
+ if ($console =~ /\b(x|h)vc0\b/) {
+ $console =~ s/\b(x|h)vc0\b/ttyS0/g;
$g->aug_set($augpath, $console);
}
}
--
1.7.2
On Wed, Jul 28, 2010 at 10:16:23AM +0100, Matthew Booth wrote:> The following patches add RHEL 6 guest support to virt-v2v. This was actually > quite a lot easier than I expected. > > * [PATCH 1/4] Update virt-v2v.conf for RHEL 6 virtio support > * [PATCH 2/4] Check kudzu exists before attempting to disable it > * [PATCH 3/4] Use dracut rather than mkinitrd if it's available > * [PATCH 4/4] Properly convert RHEL 6 guest consoleYes, these patches all look very simple and obvious. ACK. Rich. -- Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones Read my programming blog: http://rwmj.wordpress.com Fedora now supports 80 OCaml packages (the OPEN alternative to F#) http://cocan.org/getting_started_with_ocaml_on_red_hat_and_fedora