[Libguestfs] [PATCH] Converter: Prefer detected arch of OS if it's available

Matthew Booth mbooth at redhat.com
Mon Feb 8 11:29:25 UTC 2010


A 32bit VMware host will boot a 64bit OS. However, 32bit KVM won't. This means
that if you accidentally selected a 32bit machine type at VM creation time on
ESX, then installed a 64bit OS, chances are you won't notice until you convert
it and it doesn't work any more. To get round this, we always use the detected
architecture of the OS if it's available. This will mean that your 32bit machine
will become a 64bit machine if it has a 64bit OS on it.
---
 lib/Sys/VirtV2V/Converter.pm |    5 ++---
 1 files changed, 2 insertions(+), 3 deletions(-)

diff --git a/lib/Sys/VirtV2V/Converter.pm b/lib/Sys/VirtV2V/Converter.pm
index ff4bc05..81abb02 100644
--- a/lib/Sys/VirtV2V/Converter.pm
+++ b/lib/Sys/VirtV2V/Converter.pm
@@ -224,9 +224,8 @@ sub _configure_os
         $os->appendChild($type);
     }
 
-    # Set type/@arch unless it's already set
-    my $arch_attr = $type->getAttributes()->getNamedItem('arch');
-    $type->setAttribute('arch', $arch) unless(defined($arch_attr));
+    # Set type/@arch based on the detected OS architecture
+    $type->setAttribute('arch', $arch) if (defined($arch));
 }
 
 sub _configure_default_devices
-- 
1.6.6




More information about the Libguestfs mailing list