[PATCHv2 4/6] Use virGetUninstalledDir() in src/storage/storage_backend_disk.c

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

 



src/storage/storage_backend_disk.c:
   *Check if libvirtd is running uninstalled from a build tree and change
    parthelper_path accordingly

---
 src/storage/storage_backend_disk.c |   28 ++++++++++++++++++++++++++--
 1 files changed, 26 insertions(+), 2 deletions(-)

diff --git a/src/storage/storage_backend_disk.c b/src/storage/storage_backend_disk.c
index 81201fd..bb29d39 100644
--- a/src/storage/storage_backend_disk.c
+++ b/src/storage/storage_backend_disk.c
@@ -261,7 +261,18 @@ virStorageBackendDiskReadPartitions(virStoragePoolObjPtr pool,
      * -              normal   metadata 100027630080 100030242304      2612736
      *
      */
-    virCommandPtr cmd = virCommandNewArgList(PARTHELPER,
+
+    char *uninstalledDir = virGetUninstalledDir();
+    char *parthelper_path = NULL;
+
+    if (uninstalledDir && virAsprintf(&parthelper_path,
+                                      "%s/../../src/libvirt_parthelper",
+                                      uninstalledDir) < 0)
+        return -1;
+    else if (virAsprintf(&parthelper_path, PARTHELPER) < 0)
+        return -1;
+
+    virCommandPtr cmd = virCommandNewArgList(parthelper_path,
                                              pool->def->source.devices[0].path,
                                              NULL);
     struct virStorageBackendDiskPoolVolData cbdata = {
@@ -277,6 +288,7 @@ virStorageBackendDiskReadPartitions(virStoragePoolObjPtr pool,
                            virStorageBackendDiskMakeVol,
                            &cbdata);
     virCommandFree(cmd);
+    VIR_FREE(parthelper_path);
     return ret;
 }
 
@@ -301,7 +313,18 @@ virStorageBackendDiskMakePoolGeometry(size_t ntok ATTRIBUTE_UNUSED,
 static int
 virStorageBackendDiskReadGeometry(virStoragePoolObjPtr pool)
 {
-    virCommandPtr cmd = virCommandNewArgList(PARTHELPER,
+    char *uninstalledDir = virGetUninstalledDir();
+    char *parthelper_path = NULL;
+
+    if (uninstalledDir && virAsprintf(&parthelper_path,
+                                      "%s/../../src/libvirt_parthelper",
+                                      uninstalledDir) < 0)
+        return -1;
+    else if (virAsprintf(&parthelper_path, PARTHELPER) < 0)
+        return -1;
+
+
+    virCommandPtr cmd = virCommandNewArgList(parthelper_path,
                                              pool->def->source.devices[0].path,
                                              "-g",
                                              NULL);
@@ -312,6 +335,7 @@ virStorageBackendDiskReadGeometry(virStoragePoolObjPtr pool)
                            virStorageBackendDiskMakePoolGeometry,
                            pool);
     virCommandFree(cmd);
+    VIR_FREE(parthelper_path);
     return ret;
 }
 
-- 
1.7.1

--
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]