>From ffdaeef59f81c46ef84a827ba3f4ec39dbf7e85c Mon Sep 17 00:00:00 2001 From: Richard Jones Date: Thu, 6 May 2010 17:51:58 +0100 Subject: [PATCH 1/2] config: 'os' and 'distro' fields should be matched separately. This is particularly important for Windows guests, because these only have os='windows' and distro is not set. This commit also updates the virt-v2v.conf documentation. --- lib/Sys/VirtV2V/Config.pm | 30 +++++--- v2v/virt-v2v.conf | 34 +++++----- v2v/virt-v2v.conf.pod | 163 +++++++-------------------------------------- 3 files changed, 60 insertions(+), 167 deletions(-) diff --git a/lib/Sys/VirtV2V/Config.pm b/lib/Sys/VirtV2V/Config.pm index 57bf24a..caeb7d0 100644 --- a/lib/Sys/VirtV2V/Config.pm +++ b/lib/Sys/VirtV2V/Config.pm @@ -187,11 +187,14 @@ sub get_app_search { my ($desc, $name, $arch) = @_; + my $os = $desc->{os}; my $distro = $desc->{distro}; my $major = $desc->{major_version}; my $minor = $desc->{minor_version}; - my $search = "distro='$distro' name='$name'"; + my $search = "os='$os'"; + $search .= " name='$name'"; + $search .= " distro='$distro'" if (defined ($distro)); $search .= " major='$major'" if (defined($major)); $search .= " minor='$minor'" if (defined($minor)); $search .= " arch='$arch'"; @@ -216,29 +219,30 @@ sub match_app my $dom = $self->{dom}; + my $os = $desc->{os}; my $distro = $desc->{distro}; my $major = $desc->{major_version}; my $minor = $desc->{minor_version}; - # Check we've got at least a distro from OS detection - die(user_message(__"Didn't detect OS distribution")) - unless (defined($distro)); + # Check we've got at least the {os} field from OS detection. + die(user_message(__"Didn't detect operating system")) + unless defined $os; # Create a list of xpath queries against the config which look for a # matching config entry in descending order of specificity my @queries; if (defined($major)) { if (defined($minor)) { - push(@queries, _app_query($name, $distro, $major, $minor, $arch)); - push(@queries, _app_query($name, $distro, $major, $minor, undef)); + push(@queries, _app_query($name, $os, $distro, $major, $minor, $arch)); + push(@queries, _app_query($name, $os, $distro, $major, $minor, undef)); } - push(@queries, _app_query($name, $distro, $major, undef, $arch)); - push(@queries, _app_query($name, $distro, $major, undef, undef)); + push(@queries, _app_query($name, $os, $distro, $major, undef, $arch)); + push(@queries, _app_query($name, $os, $distro, $major, undef, undef)); } - push(@queries, _app_query($name, $distro, undef, undef, $arch)); - push(@queries, _app_query($name, $distro, undef, undef, undef)); + push(@queries, _app_query($name, $os, $distro, undef, undef, $arch)); + push(@queries, _app_query($name, $os, $distro, undef, undef, undef)); # Use the results of the first query which returns a result my $app; @@ -276,9 +280,11 @@ sub match_app sub _app_query { - my ($name, $distro, $major, $minor, $arch) = @_; + my ($name, $os, $distro, $major, $minor, $arch) = @_; - my $query = "/virt-v2v/app[\@name='$name' and \@os='$distro' and "; + my $query = "/virt-v2v/app[\@name='$name' and \@os='$os' and "; + $query .= defined($distro) ? "\@distro='$distro'" : 'not(@distro)'; + $query .= ' and '; $query .= defined($major) ? "\@major='$major'" : 'not(@major)'; $query .= ' and '; $query .= defined($minor) ? "\@minor='$minor'" : 'not(@minor)'; diff --git a/v2v/virt-v2v.conf b/v2v/virt-v2v.conf index 0ea3c9f..75a2a20 100644 --- a/v2v/virt-v2v.conf +++ b/v2v/virt-v2v.conf @@ -5,71 +5,71 @@ - + rhel/5/kernel-2.6.18-128.el5.i686.rpm ecryptfs-utils lvm2 - + rhel/5/kernel-PAE-2.6.18-128.el5.i686.rpm ecryptfs-utils lvm2 - + rhel/5/kernel-2.6.18-128.el5.x86_64.rpm ecryptfs-utils lvm2 - + rhel/5/ecryptfs-utils-56-8.el5.x86_64.rpm - + rhel/5/ecryptfs-utils-56-8.el5.i386.rpm - + rhel/5/lvm2-2.02.40-6.el5.x86_64.rpm device-mapper device-mapper-event - + rhel/5/lvm2-2.02.40-6.el5.i386.rpm device-mapper device-mapper-event - + rhel/5/device-mapper-1.02.28-2.el5.x86_64.rpm - + rhel/5/device-mapper-1.02.28-2.el5.i386.rpm - + rhel/5/device-mapper-event-1.02.28-2.el5.x86_64.rpm - + rhel/5/device-mapper-event-1.02.28-2.el5.i386.rpm - + rhel/4/kernel-2.6.9-89.EL.i686.rpm - + rhel/4/kernel-smp-2.6.9-89.EL.i686.rpm - + rhel/4/kernel-hugemem-2.6.9-89.EL.i686.rpm - + rhel/4/kernel-2.6.9-89.EL.x86_64.rpm - + rhel/4/kernel-smp-2.6.9-89.EL.x86_64.rpm - + rhel/4/kernel-largesmp-2.6.9-89.EL.x86_64.rpm diff --git a/v2v/virt-v2v.conf.pod b/v2v/virt-v2v.conf.pod index 85651f6..b9bd893 100644 --- a/v2v/virt-v2v.conf.pod +++ b/v2v/virt-v2v.conf.pod @@ -70,7 +70,7 @@ normal kernel. This software will be specific to the guest operating system. Software to be installed is specified in the EappE element, which is a child of the root element. The configuration can specify any number of -EappE elements. EappE can have 5 attributes: +EappE elements. EappE can have these attributes: =over @@ -81,20 +81,27 @@ attribute. =item os -The name of the guest operating system, as returned by libguestfs. +The name of the guest operating system, as returned by virt-inspector. +This will be a string, like 'linux' or 'windows'. + +=item distro + +When os='linux', this is the Linux distribution as returned by +virt-inspector. Possible values include 'rhel', 'debian'. =item major The major version name of the guest operating system, as returned by -libguestfs. +virt-inspector. =item minor -The minor version name of the guest operating system, as returned by libguestfs. +The minor version name of the guest operating system, as returned by +virt-inspector. =item arch -The guest architecture, as returned by libguestfs. +The guest architecture, as returned by virt-inspector. =back @@ -108,19 +115,23 @@ match. Specifically, it searches in the following order: =item * -os, major, minor, arch +os, distro, major, minor, arch + +=item * + +os, distro, major, minor =item * -os, major, minor +os, distro, major, arch =item * -os, major, arch +os, distro, major =item * -os, major +os, distro =item * @@ -157,15 +168,15 @@ versions, on i686: /var/lib/virt-v2v/software /var/lib/virt-v2v/transfer.iso - + rhel/5/kernel-2.6.18-128.el5.i686.rpm ecryptfs-utils lvm2 - + rhel/5/ecryptfs-utils-56-8.el5.i386.rpm - + rhel/5/lvm2-2.02.40-6.el5.i386.rpm device-mapper device-mapper-event @@ -180,137 +191,13 @@ dependency paths are also relative to /var/lib/virt-v2v/software. virt-v2v will create a transfer iso image containing all paths and dependencies at /var/lib/virt-v2v/transfer.iso. -=head1 EXAMPLE - -The following example is the default example configuration file included in the -virt-v2v distribution. The majority of the file specifies the locations of -replacement FV kernels for RHEL 4 and RHEL 5. These will be required when -converting Xen guests which use a PV kernel. - -It also contains 2 example network mappings, both commented out, which provide -mappings for: - -* a bridge called 'xenbr1' (the Xen default) -* a network called 'VM Network' (the VMware ESX default) -* a network called 'default' (the libvirt default) - -The first commented out section will map all of the above to the libvirt -default, the second to the RHEV default. - - - /var/lib/virt-v2v/software - /var/lib/virt-v2v/transfer.iso - - - - rhel/5/kernel-2.6.18-128.el5.i686.rpm - ecryptfs-utils - lvm2 - - - rhel/5/kernel-PAE-2.6.18-128.el5.i686.rpm - ecryptfs-utils - lvm2 - - - rhel/5/kernel-2.6.18-128.el5.x86_64.rpm - ecryptfs-utils - lvm2 - - - - - rhel/5/ecryptfs-utils-56-8.el5.x86_64.rpm - - - rhel/5/ecryptfs-utils-56-8.el5.i386.rpm - - - rhel/5/lvm2-2.02.40-6.el5.x86_64.rpm - device-mapper - device-mapper-event - - - rhel/5/lvm2-2.02.40-6.el5.i386.rpm - device-mapper - device-mapper-event - - - rhel/5/device-mapper-1.02.28-2.el5.x86_64.rpm - - - rhel/5/device-mapper-1.02.28-2.el5.i386.rpm - - - rhel/5/device-mapper-event-1.02.28-2.el5.x86_64.rpm - - - rhel/5/device-mapper-event-1.02.28-2.el5.i386.rpm - - - - - rhel/4/kernel-2.6.9-89.EL.i686.rpm - - - rhel/4/kernel-smp-2.6.9-89.EL.i686.rpm - - - rhel/4/kernel-hugemem-2.6.9-89.EL.i686.rpm - - - rhel/4/kernel-2.6.9-89.EL.x86_64.rpm - - - rhel/4/kernel-smp-2.6.9-89.EL.x86_64.rpm - - - rhel/4/kernel-largesmp-2.6.9-89.EL.x86_64.rpm - - - - - - - - - - =head1 COPYRIGHT Copyright (C) 2009,2010 Red Hat Inc. =head1 SEE ALSO +Example virt-v2v.conf in the documentation directory, L, +L, L -- 1.6.6.1