[PATCH] libxl: do not use hardcoded pygrub path

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

 



According to the Xen documentation the full path was only needed
for versions prior to 4.1: "Note: For older versions of Xen Project
software (4.1 or earlier) you need to know where in the filesystem
pygrub lies. (...) Newer versions of the toolstack know how to look
for the path themselves." [1]

[1] http://wiki.xen.org/wiki/PyGrub

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1104695
Signed-off-by: Alvaro Lopez Garcia <aloga@xxxxxxxxxxxxxx>
---
 src/libxl/libxl_conf.c   | 13 +++++++++++--
 src/libxl/libxl_conf.h   |  5 ++++-
 src/libxl/libxl_domain.c |  2 +-
 3 files changed, 16 insertions(+), 4 deletions(-)

diff --git a/src/libxl/libxl_conf.c b/src/libxl/libxl_conf.c
index 1210500..896ea8d 100644
--- a/src/libxl/libxl_conf.c
+++ b/src/libxl/libxl_conf.c
@@ -100,6 +100,7 @@ libxlDriverConfigDispose(void *obj)
     VIR_FREE(cfg->libDir);
     VIR_FREE(cfg->saveDir);
     VIR_FREE(cfg->autoDumpDir);
+    VIR_FREE(cfg->bootloader);
 }
 
 static int
@@ -570,6 +571,7 @@ libxlMakeChrdevStr(virDomainChrDefPtr def, char **buf)
 
 static int
 libxlMakeDomBuildInfo(virDomainDefPtr def,
+                      libxlDriverConfigPtr cfg,
                       libxl_ctx *ctx,
                       libxl_domain_config *d_config)
 {
@@ -688,7 +690,7 @@ libxlMakeDomBuildInfo(virDomainDefPtr def,
             if (VIR_STRDUP(b_info->u.pv.bootloader, def->os.bootloader) < 0)
                 goto error;
         } else if (def->os.kernel == NULL) {
-            if (VIR_STRDUP(b_info->u.pv.bootloader, LIBXL_BOOTLOADER_PATH) < 0)
+            if (VIR_STRDUP(b_info->u.pv.bootloader, cfg->bootloader) < 0)
                 goto error;
         }
         if (def->os.bootloaderArgs) {
@@ -1241,6 +1243,12 @@ libxlDriverConfigNew(void)
     cfg->version = (cfg->verInfo->xen_version_major * 1000000) +
         (cfg->verInfo->xen_version_minor * 1000);
 
+    /*
+     * Versions prior to 4.2 need the full pygrub path
+     */
+    if (VIR_STRDUP(cfg->bootloader, cfg->version >= 4002000 ? LIBXL_BOOTLOADER : LIBXL_BOOTLOADER_PATH) < 0)
+        goto error;
+
     /* This will fill xenstore info about free and dom0 memory if missing,
      * should be called before starting first domain */
     if (libxl_get_free_memory(cfg->ctx, &free_mem)) {
@@ -1399,6 +1407,7 @@ libxlMakeCapabilities(libxl_ctx *ctx)
 int
 libxlBuildDomainConfig(virPortAllocatorPtr graphicsports,
                        virDomainDefPtr def,
+                       libxlDriverConfigPtr cfg,
                        libxl_ctx *ctx,
                        libxl_domain_config *d_config)
 {
@@ -1407,7 +1416,7 @@ libxlBuildDomainConfig(virPortAllocatorPtr graphicsports,
     if (libxlMakeDomCreateInfo(ctx, def, &d_config->c_info) < 0)
         return -1;
 
-    if (libxlMakeDomBuildInfo(def, ctx, d_config) < 0)
+    if (libxlMakeDomBuildInfo(def, cfg, ctx, d_config) < 0)
         return -1;
 
     if (libxlMakeDiskList(def, d_config) < 0)
diff --git a/src/libxl/libxl_conf.h b/src/libxl/libxl_conf.h
index da66b4e..9d18c4b 100644
--- a/src/libxl/libxl_conf.h
+++ b/src/libxl/libxl_conf.h
@@ -53,7 +53,8 @@
 # define LIBXL_LIB_DIR LOCALSTATEDIR "/lib/libvirt/libxl"
 # define LIBXL_SAVE_DIR LIBXL_LIB_DIR "/save"
 # define LIBXL_DUMP_DIR LIBXL_LIB_DIR "/dump"
-# define LIBXL_BOOTLOADER_PATH BINDIR "/pygrub"
+# define LIBXL_BOOTLOADER "pygrub"
+# define LIBXL_BOOTLOADER_PATH BINDIR "/" LIBXL_BOOTLOADER
 
 /* libxl interface for setting VCPU affinity changed in 4.5. In fact, a new
  * parameter has been added, representative of 'VCPU soft affinity'. If one
@@ -99,6 +100,7 @@ struct _libxlDriverConfig {
     char *libDir;
     char *saveDir;
     char *autoDumpDir;
+    char *bootloader;
 };
 
 
@@ -181,6 +183,7 @@ libxlCreateXMLConf(void);
 int
 libxlBuildDomainConfig(virPortAllocatorPtr graphicsports,
                        virDomainDefPtr def,
+                       libxlDriverConfigPtr cfg,
                        libxl_ctx *ctx,
                        libxl_domain_config *d_config);
 
diff --git a/src/libxl/libxl_domain.c b/src/libxl/libxl_domain.c
index cdac82c..14f048a 100644
--- a/src/libxl/libxl_domain.c
+++ b/src/libxl/libxl_domain.c
@@ -1199,7 +1199,7 @@ libxlDomainStart(libxlDriverPrivatePtr driver, virDomainObjPtr vm,
         VIR_FREE(managed_save_path);
     }
 
-    if (libxlBuildDomainConfig(driver->reservedVNCPorts, vm->def,
+    if (libxlBuildDomainConfig(driver->reservedVNCPorts, vm->def, cfg,
                                priv->ctx, &d_config) < 0)
         goto endjob;
 
-- 
2.1.0.rc1

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list




[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]