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

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

On Thu, Jun 30, 2011 at 06:40:20PM +0800, Osier Yang wrote:
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.
Isn't that just a user error for specifying an invalid <path> for the target in the XML then ? Daniel -- |: http://berrange.com -o- http://www.flickr.com/photos/dberrange/ :| |: http://libvirt.org -o- http://virt-manager.org :| |: http://autobuild.org -o- http://search.cpan.org/~danberr/ :| |: http://entangle-photo.org -o- http://live.gnome.org/gtk-vnc :|

于 2011年06月30日 18:22, Daniel P. Berrange 写道:
On Thu, Jun 30, 2011 at 06:40:20PM +0800, Osier Yang wrote:
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.
Isn't that just a user error for specifying an invalid<path> for the target in the XML then ?
Daniel
If I'm correct, it can be a path of a nest VG. Regards Osier
participants (2)
-
Daniel P. Berrange
-
Osier Yang