[libvirt] [PATCH] storage: Skips backingStore of virtual snapshot lv

Osier Yang jyang at redhat.com
Fri Nov 18 10:54:56 UTC 2011


于 2011年11月18日 19:15, Osier Yang 写道:
> 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.

Forgot to mention the problem. If one creates a virtual snapshot lv,
the pool won't be abled to started or refreshed.

>
> 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 |    9 ++++++++-
>   1 files changed, 8 insertions(+), 1 deletions(-)
>
> diff --git a/src/storage/storage_backend_logical.c b/src/storage/storage_backend_logical.c
> index 3c3e736..8118d08 100644
> --- a/src/storage/storage_backend_logical.c
> +++ b/src/storage/storage_backend_logical.c
> @@ -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();




More information about the libvir-list mailing list