>From ca375bb29295523238e297820d4f641db01d9742 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. --- lib/Sys/VirtV2V/Config.pm | 30 ++++++++++++++++++------------ v2v/virt-v2v.conf | 34 +++++++++++++++++----------------- 2 files changed, 35 insertions(+), 29 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 -- 1.6.6.1