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

[Libguestfs] [PATCH v2v] config: 'os' and 'distro' fields should be matched separately.



-- 
Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones
libguestfs lets you edit virtual machines.  Supports shell scripting,
bindings from many languages.  http://et.redhat.com/~rjones/libguestfs/
See what it can do: http://et.redhat.com/~rjones/libguestfs/recipes.html
>From ca375bb29295523238e297820d4f641db01d9742 Mon Sep 17 00:00:00 2001
From: Richard Jones <rjones redhat com>
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 <app> 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
        All of these RPMS are from RHEL 5.3, which was the first version of RHEL
        5 to support VirtIO -->
-  <app os='rhel' major='5' arch='i686' name='kernel'>
+  <app distro='rhel' major='5' arch='i686' name='kernel'>
     <path>rhel/5/kernel-2.6.18-128.el5.i686.rpm</path>
     <dep>ecryptfs-utils</dep>
     <dep>lvm2</dep>
   </app>
-  <app os='rhel' major='5' arch='i686' name='kernel-PAE'>
+  <app distro='rhel' major='5' arch='i686' name='kernel-PAE'>
     <path>rhel/5/kernel-PAE-2.6.18-128.el5.i686.rpm</path>
     <dep>ecryptfs-utils</dep>
     <dep>lvm2</dep>
   </app>
-  <app os='rhel' major='5' arch='x86_64' name='kernel'>
+  <app distro='rhel' major='5' arch='x86_64' name='kernel'>
     <path>rhel/5/kernel-2.6.18-128.el5.x86_64.rpm</path>
     <dep>ecryptfs-utils</dep>
     <dep>lvm2</dep>
   </app>
 
   <!-- RHEL 5 Kernel dependencies -->
-  <app os='rhel' major='5' arch='x86_64' name='ecryptfs-utils'>
+  <app distro='rhel' major='5' arch='x86_64' name='ecryptfs-utils'>
     <path>rhel/5/ecryptfs-utils-56-8.el5.x86_64.rpm</path>
   </app>
-  <app os='rhel' major='5' arch='i386' name='ecryptfs-utils'>
+  <app distro='rhel' major='5' arch='i386' name='ecryptfs-utils'>
     <path>rhel/5/ecryptfs-utils-56-8.el5.i386.rpm</path>
   </app>
-  <app os='rhel' major='5' arch='x86_64' name='lvm2'>
+  <app distro='rhel' major='5' arch='x86_64' name='lvm2'>
     <path>rhel/5/lvm2-2.02.40-6.el5.x86_64.rpm</path>
     <dep>device-mapper</dep>
     <dep>device-mapper-event</dep>
   </app>
-  <app os='rhel' major='5' arch='i386' name='lvm2'>
+  <app distro='rhel' major='5' arch='i386' name='lvm2'>
     <path>rhel/5/lvm2-2.02.40-6.el5.i386.rpm</path>
     <dep>device-mapper</dep>
     <dep>device-mapper-event</dep>
   </app>
-  <app os='rhel' major='5' arch='x86_64' name='device-mapper'>
+  <app distro='rhel' major='5' arch='x86_64' name='device-mapper'>
     <path>rhel/5/device-mapper-1.02.28-2.el5.x86_64.rpm</path>
   </app>
-  <app os='rhel' major='5' arch='i386' name='device-mapper'>
+  <app distro='rhel' major='5' arch='i386' name='device-mapper'>
     <path>rhel/5/device-mapper-1.02.28-2.el5.i386.rpm</path>
   </app>
-  <app os='rhel' major='5' arch='x86_64' name='device-mapper-event'>
+  <app distro='rhel' major='5' arch='x86_64' name='device-mapper-event'>
     <path>rhel/5/device-mapper-event-1.02.28-2.el5.x86_64.rpm</path>
   </app>
-  <app os='rhel' major='5' arch='i386' name='device-mapper-event'>
+  <app distro='rhel' major='5' arch='i386' name='device-mapper-event'>
     <path>rhel/5/device-mapper-event-1.02.28-2.el5.i386.rpm</path>
   </app>
 
   <!-- RHEL 4
        All of these RPMs are from RHEL 4.8, which was the first version of RHEL
        4 to support VirtIO -->
-  <app os='rhel' major='4' arch='i686' name='kernel'>
+  <app distro='rhel' major='4' arch='i686' name='kernel'>
     <path>rhel/4/kernel-2.6.9-89.EL.i686.rpm</path>
   </app>
-  <app os='rhel' major='4' arch='i686' name='kernel-smp'>
+  <app distro='rhel' major='4' arch='i686' name='kernel-smp'>
     <path>rhel/4/kernel-smp-2.6.9-89.EL.i686.rpm</path>
   </app>
-  <app os='rhel' major='4' arch='i686' name='kernel-hugemem'>
+  <app distro='rhel' major='4' arch='i686' name='kernel-hugemem'>
     <path>rhel/4/kernel-hugemem-2.6.9-89.EL.i686.rpm</path>
   </app>
-  <app os='rhel' major='4' arch='x86_64' name='kernel'>
+  <app distro='rhel' major='4' arch='x86_64' name='kernel'>
     <path>rhel/4/kernel-2.6.9-89.EL.x86_64.rpm</path>
   </app>
-  <app os='rhel' major='4' arch='x86_64' name='kernel-smp'>
+  <app distro='rhel' major='4' arch='x86_64' name='kernel-smp'>
     <path>rhel/4/kernel-smp-2.6.9-89.EL.x86_64.rpm</path>
   </app>
-  <app os='rhel' major='4' arch='x86_64' name='kernel-largesmp'>
+  <app distro='rhel' major='4' arch='x86_64' name='kernel-largesmp'>
     <path>rhel/4/kernel-largesmp-2.6.9-89.EL.x86_64.rpm</path>
   </app>
 
-- 
1.6.6.1


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