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

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



On Fri, May 07, 2010 at 01:24:55PM +0100, Matthew Booth wrote:
> On 07/05/10 11:28, Richard W.M. Jones wrote:
> > You say in the documentation that matching happens in this order:
> > 
> >        ·   os, distro, major, minor, arch
> > 
> >        ·   os, distro, major, minor
> > 
> >        ·   os, distro, major, arch
> > 
> >        ·   os, distro, major
> > 
> >        ·   os, distro
> > 
> >        ·   os
> > 
> > but is that really true?
> 
> I belived so when I wrote it :) If it isn't it's a bug.

I left this bit in, and removed the inline virt-v2v.conf (referring
instead to the external file which we bundle in %docdir).

Please ACK the attached complete patch which I propose to push.

Rich.

-- 
Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones
virt-top is 'top' for virtual machines.  Tiny program with many
powerful monitoring features, net stats, disk stats, logging, etc.
http://et.redhat.com/~rjones/virt-top
>From ffdaeef59f81c46ef84a827ba3f4ec39dbf7e85c 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.

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 <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>
 
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 E<lt>appE<gt> element, which is a
 child of the root element. The configuration can specify any number of
-E<lt>appE<gt> elements. E<lt>appE<gt> can have 5 attributes:
+E<lt>appE<gt> elements. E<lt>appE<gt> 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:
  <path-root>/var/lib/virt-v2v/software</path-root>
  <iso-path>/var/lib/virt-v2v/transfer.iso</iso-path>
 
- <app os='rhel' major='5' arch='i686' name='kernel'>
+ <app os='linux' 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='i386' name='ecryptfs-utils'>
+ <app os='linux' 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='i386' name='lvm2'>
+ <app os='linux' 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>
@@ -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.
-
- <virt-v2v>
-   <path-root>/var/lib/virt-v2v/software</path-root>
-   <iso-path>/var/lib/virt-v2v/transfer.iso</iso-path>
-
-   <!-- 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'>
-     <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'>
-     <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'>
-     <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'>
-     <path>rhel/5/ecryptfs-utils-56-8.el5.x86_64.rpm</path>
-   </app>
-   <app os='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'>
-     <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'>
-     <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'>
-     <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'>
-     <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'>
-     <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'>
-     <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'>
-     <path>rhel/4/kernel-2.6.9-89.EL.i686.rpm</path>
-   </app>
-   <app os='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'>
-     <path>rhel/4/kernel-hugemem-2.6.9-89.EL.i686.rpm</path>
-   </app>
-   <app os='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'>
-     <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'>
-     <path>rhel/4/kernel-largesmp-2.6.9-89.EL.x86_64.rpm</path>
-   </app>
-
-   <!-- Networks -->
-   <!-- Mappings for the defaults in Xen, ESX and libvirt/KVM
-        to the default in libvirt/KVM -->
-   <!--
-   <network type='bridge' name='xenbr1'>
-     <network type='network' name='default'/>
-   </network>
-
-   <network type='bridge' name='VM Network'>
-     <network type='network' name='default'/>
-   </network>
-
-   <network type='network' name='default'>
-     <network type='network' name='default'/>
-   </network>
-   -->
-
-   <!-- If importing to RHEV, you may want to use the default network name
-        'rhevm' instead -->
-   <!--
-   <network type='bridge' name='xenbr1'>
-     <network type='network' name='rhevm'/>
-   </network>
-
-   <network type='bridge' name='VM Network'>
-     <network type='network' name='rhevm'/>
-   </network>
-
-   <network type='network' name='default'>
-     <network type='network' name='rhevm'/>
-   </network>
-   -->
- </virt-v2v>
-
 =head1 COPYRIGHT
 
 Copyright (C) 2009,2010 Red Hat Inc.
 
 =head1 SEE ALSO
 
+Example virt-v2v.conf in the documentation directory,
 L<virt-v2v(1)>,
+L<virt-inspector(1)>,
 L<http://libguestfs.org/>
-- 
1.6.6.1


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