Hi, attached a patch proposal for virt-v2v to support converting VirtualBox guests with VirtualBox Guest Additions [1] installed. With the patch applied a VirtualBox RHEL 6 guest with Guest Additions can be converted with: # qemu-img convert virtual-rhel.vdi /var/lib/libvirt/images/virtual-rhel.img # virsh --connect qemu:///system pool-refresh default # virt-v2v -i libvirtxml -os default /tmp/virtual-rhel.xml I've tested this patch on a RHEL 6.2 host running VirtualBox 4.1.8 using a RHEL 6.2 guest, the guest works as expected with libvirt and all of Guest Additions except for few log files were removed. However, as can be seen from the patch it uses a hard-coded path to the Guest Additions uninstallation script [2] - something like this on a local file system would do the trick to locate the proper uninstallation script to run: find /opt/VBoxGuestAdditions* -wholename '/opt/VBoxGuestAdditions-*/uninstall.sh' -print | sort | tail -n 1 But since we're talking about a guest fs I'm not sure what would be the most elegant way to achieve the same with the libguestfs API? guestfs_find [3] is available but I'm not sure would be ok to run something corresponding to "find /opt" and then go through the results in RedHat.pm (considering that in theory we might hit the message protocol transfer limit if the /opt of the guest contains a huge amount of files)? 1) http://www.virtualbox.org/manual/ch04.html 2) http://www.virtualbox.org/manual/ch04.html#idp11370256 3) http://libguestfs.org/guestfs.3.html#guestfs_find Thanks, -- Marko Myllynen
>From 2b286ac92d21e2812481d2d70b7d9df2b6b6dcd4 Mon Sep 17 00:00:00 2001 From: Marko Myllynen <myllynen@xxxxxxxxxx> Date: Wed, 8 Feb 2012 16:20:32 +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 | 35 +++++++++++++++++++++++++++++++ 1 files changed, 35 insertions(+), 0 deletions(-) diff --git a/lib/Sys/VirtConvert/Converter/RedHat.pm b/lib/Sys/VirtConvert/Converter/RedHat.pm index d31924f..c0c354f 100644 --- a/lib/Sys/VirtConvert/Converter/RedHat.pm +++ b/lib/Sys/VirtConvert/Converter/RedHat.pm @@ -872,6 +872,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); } @@ -937,6 +938,40 @@ sub _unconfigure_xen } } +# Unconfigure VirtualBox specific guest modifications +sub _unconfigure_vbox +{ + my ($g, $desc, $apps) = @_; + + # Uninstall VirtualBox Guest Additions + foreach my $app (@$apps) { + my $name = $app->{app_name}; + + if ($name eq "virtualbox-guest-additions") { + _remove_application($name, $g); + } + } + + # 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 $vboxadditions = '/opt/VBoxGuestAdditions-4.1.8/uninstall.sh'; + if ($g->exists($vboxadditions)) { + eval { $g->command([$vboxadditions]) }; + 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 { -- 1.7.1