Marko Myllynen
2012-Mar-12 10:56 UTC
[Libguestfs] [PATCH] virt-v2v: Support for Converting VirtualBox Guests
Hi, attached is an updated [1] patch for virt-v2v to support converting VirtualBox guests with VirtualBox Guest Additions [2] installed. With the patch applied a VirtualBox RHEL 6 guest with Guest Additions can be converted with the steps documented in the manual page. 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 on libvirt/KVM and all traces of Guest Additions except for few log files were removed. This version uses VirtualBox Guest Additions configuration file to locate the script to uninstall [3]. If it would be possible to skip some of the needed steps and support VirtualBox directly from the command line that'd be great - if so, please adjust the patch as needed. 1) https://www.redhat.com/archives/virt-tools-list/2012-February/msg00064.html 2) http://www.virtualbox.org/manual/ch04.html 3) http://www.virtualbox.org/manual/ch04.html#idp11370256 Cheers, -- Marko Myllynen -------------- next part -------------- An embedded and charset-unspecified text was scrubbed... Name: 0001-virt-v2v-Support-for-Converting-VirtualBox-Guests.patch URL: <http://listman.redhat.com/archives/libguestfs/attachments/20120312/a551770f/attachment.ksh>
Matthew Booth
2012-Mar-12 15:10 UTC
[Libguestfs] [PATCH] virt-v2v: Support for Converting VirtualBox Guests
On 03/12/2012 10:56 AM, Marko Myllynen wrote:> Hi, > > attached is an updated [1] patch for virt-v2v to support converting > VirtualBox guests with VirtualBox Guest Additions [2] installed. With > the patch applied a VirtualBox RHEL 6 guest with Guest Additions can be > converted with the steps documented in the manual page. > > 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 on libvirt/KVM and all > traces of Guest Additions except for few log files were removed. This > version uses VirtualBox Guest Additions configuration file to locate the > script to uninstall [3]. > > If it would be possible to skip some of the needed steps and support > VirtualBox directly from the command line that'd be great - if so, > please adjust the patch as needed. > > 1) > https://www.redhat.com/archives/virt-tools-list/2012-February/msg00064.html > 2) http://www.virtualbox.org/manual/ch04.html > 3) http://www.virtualbox.org/manual/ch04.html#idp11370256 > > Cheers, > > -- > Marko Myllynen > > 0001-virt-v2v-Support-for-Converting-VirtualBox-Guests.patch > > >> From 543d23c76b2ab68eaf2776b7d4cd007a8d29ae93 Mon Sep 17 00:00:00 2001 > From: Marko Myllynen<myllynen at redhat.com> > Date: Mon, 12 Mar 2012 12:45:27 +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 | 41 +++++++++++++++++++++++++++++++ > v2v/virt-v2v.pl | 29 +++++++++++++++++++--- > 2 files changed, 66 insertions(+), 4 deletions(-) > > diff --git a/lib/Sys/VirtConvert/Converter/RedHat.pm b/lib/Sys/VirtConvert/Converter/RedHat.pm > index 2efce8a..b299b58 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,46 @@ 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); > + } > + }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?> + # 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.Eurgh, not another one. Augeas, ftw!> + 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. > +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.> =head2 Converting to run on libvirt/KVM > > =head3 Create a local storage pool for transferred storage > -- 1.7.1This looks great. If you could do the rebase to fix _remove_application() I'll push it as-is. We can think about Windows later. Thanks, Matt -- Matthew Booth, RHCA, RHCSS Red Hat Engineering, Virtualisation Team GPG ID: D33C3490 GPG FPR: 3733 612D 2D05 5458 8A8A 1600 3441 EA19 D33C 3490
Maybe Matching Threads
- [PATCH 0/4] Add SUSE guest converter to virt-v2v
- [PATCH 0/4] virt-v2v: Add support for SUSE guest conversions
- Re: [PATCH] virt-v2v: Convert RedHat.pm to Linux.pm - for SUSE support
- Re: [PATCH] virt-v2v: Convert RedHat.pm to Linux.pm - for SUSE support
- Virtio: 32bit CentOS 6.4 on VirtualBox to oVirt on Fedora 19 64bit via virt-v2v