]> xenbits.xensource.com Git - libvirt.git/commitdiff
storage: Skips backingStore of virtual snapshot lv
authorOsier Yang <jyang@redhat.com>
Fri, 18 Nov 2011 11:15:10 +0000 (19:15 +0800)
committerOsier Yang <jyang@redhat.com>
Mon, 21 Nov 2011 03:26:54 +0000 (11:26 +0800)
lvs outputs "[$lvname_vorigin]" for the virtual snapshot lv
(created with "--virtualsize"), and the original device pointed
by "$lvname_vorigin" is just for lvm internal use, one should
never use it.

Per lvm's nameing rules, "[" is not valid as part of the vg/lv name.
(man 8 lvm).

<quote>
VALID NAMES
The following characters are valid for VG and LV names: a-z A-Z 0-9 + _
. -

VG and LV names cannot begin with a hyphen.   There  are  also  various
reserved  names that are used internally by lvm that can not be used as
LV or VG names.  A VG cannot be called anything that exists in /dev/ at
the time of creation, nor can it be called '.' or '..'.  A LV cannot be
called '.' '..' 'snapshot' or 'pvmove'. The LV name may also  not  con‐
tain the strings '_mlog' or '_mimage'
</quote>

So we can skip the set the lv's backingStore by checking if the name
begins with a "[".

src/storage/storage_backend_logical.c

index 3c3e7363029562a725262aa454761eb522136d84..8118d0898f9df713a180b6b6b9ebd146f605b4c0 100644 (file)
@@ -121,7 +121,14 @@ virStorageBackendLogicalMakeVol(virStoragePoolObjPtr pool,
         }
     }
 
-    if (groups[1] && !STREQ(groups[1], "")) {
+    /* Skips the backingStore of lv created with "--virtualsize",
+     * its original device "/dev/$vgname/$lvname_vorigin" is
+     * just for lvm internal use, one should never use it.
+     *
+     * (lvs outputs "[$lvname_vorigin] for field "origin" if the
+     *  lv is created with "--virtualsize").
+     */
+    if (groups[1] && !STREQ(groups[1], "") && (groups[1][0] != '[')) {
         if (virAsprintf(&vol->backingStore.path, "%s/%s",
                         pool->def->target.path, groups[1]) < 0) {
             virReportOOMError();