[libvirt] [PATCH] storage: Fix problem of creating a volume in LVM pool

Osier Yang jyang at redhat.com
Thu Jun 30 10:40:20 UTC 2011


LVM allows one specify the VG with VG path like "/dev/lv_pool", and
it gets the correct VG name internally by skipping "/dev".

<snip>
    vg_name = skip_dev_dir(cmd, argv[0], NULL);

    if (strrchr(vg_name, '/')) {
        log_error("Volume group name expected "
                  "(no slash)");
        return 0;
    }
</snip>

However, if the path is like "/dev/t/lv_pool", the VG name will be
"/t/lv_pool" then, definitely it's not a valid VG name, and LVM will
complain and fail.

This patch change the codes to use "pool->def->source.name" instead
of "pool->def->target.path" to avoid the problem.
---
 src/storage/storage_backend_logical.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/src/storage/storage_backend_logical.c b/src/storage/storage_backend_logical.c
index 4de5442..8fe69ea 100644
--- a/src/storage/storage_backend_logical.c
+++ b/src/storage/storage_backend_logical.c
@@ -562,7 +562,7 @@ virStorageBackendLogicalCreateVol(virConnectPtr conn,
     char size[100];
     const char *cmdargvnew[] = {
         LVCREATE, "--name", vol->name, "-L", size,
-        pool->def->target.path, NULL
+        pool->def->source.name, NULL
     };
     const char *cmdargvsnap[] = {
         LVCREATE, "--name", vol->name, "-L", size,
-- 
1.7.4




More information about the libvir-list mailing list