[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

Re: [Libguestfs] [PATCH] virt-v2v: Support for Converting VirtualBox Guests



Hi,

+ # Uninstall VirtualBox Guest Additions
+ foreach my $app (@$apps) {
+ my $name = $app->{app_name};
+
+ if ($name eq "virtualbox-guest-additions") {
+ _remove_application($name, $g);

Can you rebase this to the latest upstream? _remove_application() became
_remove_applications(). Can you store up the apps to be removed and
uninstall them all in a single transaction?

right, I had missed that change since my first patch - I've updated the patch to be similar as the Xen code.

Do you know if it's possible to uninstall VirtualBox after conversion? I
actually have code locally to do this for VMware tools, but it doesn't
work because the VMware tools uninstaller is brain dead. If VirtualBox
isn't brain dead we could integrate this too.

Yes, the uninstaller works fine also after conversion. If you do not remove the Guest Additions during conversion and boot with them on KVM you'll see errors from VirtualBox kernel modules complaining about the missing VirtualBox PCI device alongside few services starting up.

This looks great. If you could do the rebase to fix
_remove_application() I'll push it as-is. We can think about Windows later.

Please see the updated patch attached.

Thanks,

--
Marko Myllynen
>From 3edbca26e9a93afe730d709bb3dd622b6ec48b73 Mon Sep 17 00:00:00 2001
From: Marko Myllynen <myllynen redhat com>
Date: Mon, 12 Mar 2012 17:37:45 +0200
Subject: [PATCH] virt-v2v: Support for Converting VirtualBox Guests

Add support for converting VirtualBox guests with VirtualBox
Guest Additions installed.

http://www.virtualbox.org/manual/ch04.html
---
 lib/Sys/VirtConvert/Converter/RedHat.pm |   43 +++++++++++++++++++++++++++++++
 v2v/virt-v2v.pl                         |   29 ++++++++++++++++++---
 2 files changed, 68 insertions(+), 4 deletions(-)

diff --git a/lib/Sys/VirtConvert/Converter/RedHat.pm b/lib/Sys/VirtConvert/Converter/RedHat.pm
index 2efce8a..0429fa6 100644
--- a/lib/Sys/VirtConvert/Converter/RedHat.pm
+++ b/lib/Sys/VirtConvert/Converter/RedHat.pm
@@ -875,6 +875,7 @@ sub _unconfigure_hv
     my @apps = $g->inspect_list_applications($root);
 
     _unconfigure_xen($g, $desc, \ apps);
+    _unconfigure_vbox($g, $desc, \ apps);
     _unconfigure_vmware($g, $desc, \ apps);
 }
 
@@ -939,6 +940,48 @@ sub _unconfigure_xen
     }
 }
 
+# Unconfigure VirtualBox specific guest modifications
+sub _unconfigure_vbox
+{
+    my ($g, $desc, $apps) = @_;
+
+    # Uninstall VirtualBox Guest Additions
+    my @remove;
+    foreach my $app (@$apps) {
+        my $name = $app->{app_name};
+
+        if ($name eq "virtualbox-guest-additions") {
+            push(@remove, $name);
+        }
+    }
+    _remove_applications($g, @remove);
+
+    # VirtualBox Guest Additions may have been installed from tarball, in which
+    # case the above won't detect it. Look for the uninstall tool, and run it
+    # if it's present.
+    #
+    # Note that it's important we do this early in the conversion process, as
+    # this uninstallation script naively overwrites configuration files with
+    # versions it cached prior to installation.
+    my $vboxconfig = '/var/lib/VBoxGuestAdditions/config';
+    my $vboxuninstall;
+    foreach (split /\n/, $g->cat($vboxconfig)) {
+        if ($_ =~ /^INSTALL_DIR=(.*$)/) {
+	    $vboxuninstall = $1 . '/uninstall.sh';
+        }
+    }
+    if ($g->exists($vboxuninstall)) {
+        eval { $g->command([$vboxuninstall]) };
+        logmsg WARN, __x('VirtualBox Guest Additions were detected, but '.
+                         'uninstallation failed. The error message was: '.
+                         '{error}', error => $@) if $@;
+
+        # Reload augeas to detect changes made by vbox tools uninstallation
+        eval { $g->aug_load() };
+        augeas_error($g, $@) if $@;
+    }
+}
+
 # Unconfigure VMware specific guest modifications
 sub _unconfigure_vmware
 {
diff --git a/v2v/virt-v2v.pl b/v2v/virt-v2v.pl
index 8961ff9..2e28722 100755
--- a/v2v/virt-v2v.pl
+++ b/v2v/virt-v2v.pl
@@ -54,10 +54,11 @@ virt-v2v - Convert a guest to use KVM
 
 =head1 DESCRIPTION
 
-virt-v2v converts guests from a foreign hypervisor to run on KVM, managed by
-libvirt or Red Hat Enterprise Virtualisation (RHEV) version 2.2 or later. It can
-currently convert Red Hat Enterprise Linux and Windows guests running on Xen and
-VMware ESX. It will enable VirtIO drivers in the converted guest if possible.
+virt-v2v converts guests from a foreign hypervisor to run on KVM, managed by 
+libvirt or Red Hat Enterprise Virtualisation (RHEV) version 2.2 or later. It 
+can currently convert Red Hat Enterprise Linux and Windows guests running on 
+Xen, VirtualBox, and VMware ESX. It will enable VirtIO drivers in the 
+converted guest if possible.
 
 =head1 OPTIONS
 
@@ -776,6 +777,26 @@ This will require a reboot if the host running Xen is the same host that will
 run KVM. This is because libvirt needs to connect to a running xen hypervisor to
 obtain its metadata.
 
+=head2 Local VirtualBox guests
+
+The following is required when converting guests which used to run VirtualBox 
+and are being converted to KVM. The conversion needs a guest XML definition 
+file which needs to be adjusted for the guest to be converted (at least name, 
+uuid, image path, image type, and MAC address):
+
+ qemu-img convert -O qcow2 /tmp/v-rhel.vdi /var/lib/libvirt/images/v-rhel.img
+ virsh --connect qemu:///system pool-refresh default
+ virt-cat /var/lib/libvirt/images/v-rhel.img \
+  /etc/sysconfig/network-scripts/ifcfg-eth0 | grep ^HWADDR
+ # Replace the MAC address in the guest XML definition file or adjust 
+ # ifcfg-eth0 after booting up the guest to match the MAC address defined in 
+ # XML file
+ virt-v2v -i libvirtxml -os default /tmp/v-rhel.xml
+
+B<N.B.> For the time being when converting VirtualBox Windows guests the
+VirtualBox Guest Additions need to be manually uninstalled on the guest
+when still running on VirtualBox.
+
 =head2 Converting to run on libvirt/KVM
 
 =head3 Create a local storage pool for transferred storage
-- 
1.7.1


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]