[libvirt] [PATCH]: vgscan before doing logical pool discovery

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

 



Assume that you have an iSCSI target available, and on that iSCSI target 1 LUN
is exported.  On that 1 LUN, you have an LVM volume group (say, myvg), with 2
logical volumes (say, lv1 and lv2).  Now you execute the following sequence of
commands:

1)  virsh define iscsi_pool.xml
2)  virsh start iscsi_pool
3)  virsh find-storage-pool-sources-as logical

With that sequence, you would expect step 3) to return XML similar to:

<sources><source><name>myvg</name><device path='/dev/sdb'/></source></sources>

However, what you instead get is: <sources/>.  That's because if you just try to
do storage pool discovery on a logical pool without ever touching the logical
pool in any fashion, pvs (what we use to do discovery) doesn't return anything.
 If you touch the logical volume group at all (say, with vgscan), they then
suddenly appear.  To make sure we see all of the potential volume groups when
doing pool discovery, make sure to run vgscan before we run pvs.  With this
patch in place, logical discovery just does the right thing.

Signed-off-by: Chris Lalancette <clalance@xxxxxxxxxx>
Index: configure.in
===================================================================
RCS file: /data/cvs/libvirt/configure.in,v
retrieving revision 1.177
diff -u -r1.177 configure.in
--- a/configure.in	24 Oct 2008 13:10:30 -0000	1.177
+++ b/configure.in	4 Nov 2008 13:21:47 -0000
@@ -734,6 +734,7 @@
   AC_PATH_PROG([VGREMOVE], [vgremove], [], [$PATH:/sbin:/usr/sbin])
   AC_PATH_PROG([LVREMOVE], [lvremove], [], [$PATH:/sbin:/usr/sbin])
   AC_PATH_PROG([VGCHANGE], [vgchange], [], [$PATH:/sbin:/usr/sbin])
+  AC_PATH_PROG([VGSCAN], [vgscan], [], [$PATH:/sbin:/usr/sbin])
   AC_PATH_PROG([PVS], [pvs], [], [$PATH:/sbin:/usr/sbin])
   AC_PATH_PROG([VGS], [vgs], [], [$PATH:/sbin:/usr/sbin])
   AC_PATH_PROG([LVS], [lvs], [], [$PATH:/sbin:/usr/sbin])
@@ -746,6 +747,7 @@
     if test -z "$VGREMOVE" ; then AC_MSG_ERROR([We need vgremove for LVM storage driver]) ; fi
     if test -z "$LVREMOVE" ; then AC_MSG_ERROR([We need lvremove for LVM storage driver]) ; fi
     if test -z "$VGCHANGE" ; then AC_MSG_ERROR([We need vgchange for LVM storage driver]) ; fi
+    if test -z "$VGSCAN" ; then AC_MSG_ERROR([We need vgscan for LVM storage driver]) ; fi
     if test -z "$PVS" ; then AC_MSG_ERROR([We need pvs for LVM storage driver]) ; fi
     if test -z "$VGS" ; then AC_MSG_ERROR([We need vgs for LVM storage driver]) ; fi
     if test -z "$LVS" ; then AC_MSG_ERROR([We need lvs for LVM storage driver]) ; fi
@@ -756,7 +758,8 @@
     if test -z "$PVREMOVE" ; then with_storage_lvm=no ; fi
     if test -z "$VGREMOVE" ; then with_storage_lvm=no ; fi
     if test -z "$LVREMOVE" ; then with_storage_lvm=no ; fi
-    if test -z "VGCHANGE" ; then with_storage_lvm=no ; fi
+    if test -z "$VGCHANGE" ; then with_storage_lvm=no ; fi
+    if test -z "$VGSCAN" ; then with_storage_lvm=no ; fi
     if test -z "$PVS" ; then with_storage_lvm=no ; fi
     if test -z "$VGS" ; then with_storage_lvm=no ; fi
     if test -z "$LVS" ; then with_storage_lvm=no ; fi
@@ -773,6 +776,7 @@
     AC_DEFINE_UNQUOTED([VGREMOVE],["$VGREMOVE"],[Location of vgcreate program])
     AC_DEFINE_UNQUOTED([LVREMOVE],["$LVREMOVE"],[Location of lvcreate program])
     AC_DEFINE_UNQUOTED([VGCHANGE],["$VGCHANGE"],[Location of vgchange program])
+    AC_DEFINE_UNQUOTED([VGSCAN],["$VGSCAN"],[Location of vgscan program])
     AC_DEFINE_UNQUOTED([PVS],["$PVS"],[Location of pvs program])
     AC_DEFINE_UNQUOTED([VGS],["$VGS"],[Location of vgs program])
     AC_DEFINE_UNQUOTED([LVS],["$LVS"],[Location of lvs program])
Index: src/storage_backend_logical.c
===================================================================
RCS file: /data/cvs/libvirt/src/storage_backend_logical.c,v
retrieving revision 1.21
diff -u -r1.21 storage_backend_logical.c
--- a/src/storage_backend_logical.c	23 Oct 2008 11:39:53 -0000	1.21
+++ b/src/storage_backend_logical.c	4 Nov 2008 13:23:58 -0000
@@ -325,11 +325,19 @@
         2
     };
     const char *const prog[] = { PVS, "--noheadings", "-o", "pv_name,vg_name", NULL };
+    const char *const scanprog[] = { VGSCAN, NULL };
     int exitstatus;
     char *retval = NULL;
     virStoragePoolSourceList sourceList;
     int i;
 
+    /*
+     * NOTE: ignoring errors here; this is just to "touch" any logical volumes
+     * that might be hanging around, so if this fails for some reason, the
+     *  worst that happens is that scanning doesn't pick everything up
+     */
+    virRun(conn, scanprog, &exitstatus);
+
     memset(&sourceList, 0, sizeof(sourceList));
     if (virStorageBackendRunProgRegex(conn, NULL, prog, 1, regexes, vars,
                                       virStorageBackendLogicalFindPoolSourcesFunc,
--
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]