[PATCH 10 of 11] virt-install: correct pygrub path

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

 



# HG changeset patch
# User john.levon@xxxxxxx
# Date 1215697572 25200
# Node ID 92de696f634f80d47b9413b9db5101de0edf9b7f
# Parent  443b42b45ee6f799020a9418388440b93d9ab78c
virt-install: correct pygrub path

The path to pygrub differs between OS hosts. Properly speaking, this is a
property of the hypervisor capabilities, and we'd get it from there. However,
traditionally the loader value is empty for PV Xen hosts, so we can't rely on
it, so we hard-code it based upon the current host.

Signed-off-by: John Levon <john.levon@xxxxxxx>

diff --git a/virtinst/DistroManager.py b/virtinst/DistroManager.py
--- a/virtinst/DistroManager.py
+++ b/virtinst/DistroManager.py
@@ -218,7 +218,7 @@
         else:
             self._prepare_kernel_and_initrd(guest, distro, meter)
 
-    def _get_osblob(self, install, hvm, arch = None, loader = None):
+    def _get_osblob(self, install, hvm, arch = None, loader = None, conn = None):
         osblob = ""
         if install or hvm:
             osblob = "<os>\n"
@@ -248,7 +248,7 @@
 
             osblob += "  </os>"
         else:
-            osblob += "<bootloader>/usr/bin/pygrub</bootloader>"
+            osblob += "<bootloader>%s</bootloader>" % util.pygrub_path(conn)
 
         return osblob
 
@@ -275,7 +275,7 @@
     def prepare(self, guest, meter, distro = None):
         pass
 
-    def _get_osblob(self, install, hvm, arch = None, loader = None):
+    def _get_osblob(self, install, hvm, arch = None, loader = None, conn = None):
         osblob = ""
         if install or hvm:
             osblob = "<os>\n"
@@ -300,7 +300,7 @@
 
             osblob += "  </os>"
         else:
-            osblob += "<bootloader>/usr/bin/pygrub</bootloader>"
+            osblob += "<bootloader>%s</bootloader>" % util.pygrub_path(conn)
 
         return osblob
 
diff --git a/virtinst/FullVirtGuest.py b/virtinst/FullVirtGuest.py
--- a/virtinst/FullVirtGuest.py
+++ b/virtinst/FullVirtGuest.py
@@ -203,7 +203,8 @@
         return ret + "  </features>"
 
     def _get_osblob(self, install):
-        osblob = self.installer._get_osblob(install, True, self.arch, self.loader)
+        osblob = self.installer._get_osblob(install, hvm = True,
+            arch = self.arch, loader = self.loader, conn = self.conn)
         if osblob is None:
             return None
 
diff --git a/virtinst/ImageManager.py b/virtinst/ImageManager.py
--- a/virtinst/ImageManager.py
+++ b/virtinst/ImageManager.py
@@ -106,7 +106,7 @@
 
             guest._install_disks.append(d)
 
-    def _get_osblob(self, install, hvm, arch = None, loader = None):
+    def _get_osblob(self, install, hvm, arch = None, loader = None, conn = None):
         osblob = "<os>\n"
 
         if hvm:
@@ -136,7 +136,7 @@
             osblob += "  </os>"
         elif self.boot_caps.loader == "pygrub" or (self.boot_caps.loader is None and self.boot_caps.type == "xen"):
             osblob += "  </os>\n"
-            osblob += "  <bootloader>/usr/bin/pygrub</bootloader>"
+            osblob += "  <bootloader>%s</bootloader>" % util.pygrub_path(conn)
 
         return osblob
 
diff --git a/virtinst/LiveCDInstaller.py b/virtinst/LiveCDInstaller.py
--- a/virtinst/LiveCDInstaller.py
+++ b/virtinst/LiveCDInstaller.py
@@ -55,7 +55,7 @@
                                  readOnly = True)
         guest._install_disks.insert(0, disk)
 
-    def _get_osblob(self, install, hvm, arch = None, loader = None):
+    def _get_osblob(self, install, hvm, arch = None, loader = None, conn = None):
         if install:
             return None
 
diff --git a/virtinst/ParaVirtGuest.py b/virtinst/ParaVirtGuest.py
--- a/virtinst/ParaVirtGuest.py
+++ b/virtinst/ParaVirtGuest.py
@@ -33,7 +33,7 @@
         self.disknode = "xvd"
 
     def _get_osblob(self, install):
-        return self.installer._get_osblob(install, hvm = False)
+        return self.installer._get_osblob(install, hvm = False, conn = self.conn)
 
     def get_input_device(self):
         return ("mouse", "xen")
diff --git a/virtinst/util.py b/virtinst/util.py
--- a/virtinst/util.py
+++ b/virtinst/util.py
@@ -19,6 +19,7 @@
 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
 # MA 02110-1301 USA.
 
+import platform
 import random
 import os.path
 import re
@@ -27,6 +28,8 @@
 
 import libvirt
 from virtinst import _virtinst as _
+from virtinst import CapabilitiesParser
+
 
 KEYBOARD_DIR = "/etc/sysconfig/keyboard"
 
@@ -277,3 +280,18 @@
         f.close()
     return keymap
 
+def pygrub_path(conn=None):
+    """
+    Return the pygrub path for the current host, or connection if
+    available.
+    """
+    if conn:
+        cap = CapabilitiesParser.parse(conn.getCapabilities())
+        if (cap.host.arch == "i86pc"):
+            return "/usr/lib/xen/bin/pygrub"
+        else:
+            return "/usr/bin/pygrub"
+
+    if platform.system() == "SunOS":
+        return "/usr/lib/xen/bin/pygrub"
+    return "/usr/bin/pygrub"

_______________________________________________
et-mgmt-tools mailing list
et-mgmt-tools@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/et-mgmt-tools

[Index of Archives]     [Fedora Users]     [Fedora Legacy List]     [Fedora Maintainers]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]

  Powered by Linux