Bug 714986 - lvcreate is called with wrong parameters
Summary: lvcreate is called with wrong parameters
Keywords:
Status: CLOSED UPSTREAM
Alias: None
Product: Virtualization Tools
Classification: Community
Component: libvirt
Version: unspecified
Hardware: x86_64
OS: Linux
unspecified
medium
Target Milestone: ---
Assignee: Cole Robinson
QA Contact:
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2011-06-21 14:15 UTC by Lex van Roon
Modified: 2012-04-16 14:27 UTC (History)
3 users (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2012-04-16 14:27:01 UTC
Embargoed:


Attachments (Terms of Use)

Description Lex van Roon 2011-06-21 14:15:29 UTC
Description of problem:
When trying to create a LV using virsh, libvirt calls lvcreate with the wrong parameters causing the creation of the LV to fail.

Version-Release number of selected component (if applicable):
lvm: 2.02.84-3
libvirt: 0.9.2-1
OS: Debian/Squeeze

How reproducible:
Fully reproducible.

Steps to Reproduce:
1. Create a LVM-based storage pool
2. Create a LVM-based volume on this storage pool

  
Actual results:
(Note that I'm using a nested VG for this example)

$ virsh pool-define-as virtpool logical /dev/storage/virtpool
Pool virtpool defined

$ virsh pool-autostart virtpool
Pool virtpool marked as autostarted

$ virsh pool-start virtpool
Pool virtpool started

$ virsh vol-create-as virtpool machine1 3G
error: Failed to create vol machine1
error: internal error '/sbin/lvcreate --name machine1 -L 3145728K /dev/storage/virtpool' exited unexpectedly: exit status 3

$ sudo lvcreate --name machine1 -L 3145728K /dev/storage/virtpool
  Volume group name expected (no slash)
  Run `lvcreate --help' for more information.

$ sudo lvcreate --name machine1 -L 3145728K virtpool
  Logical volume "machine1" created

Expected results:
Creation of the LVM-based volume.

Additional info:
Looking up this error within the LVM source code, I find the following snippet:
...
                        if (strrchr(vg_name, '/')) {
                                log_error("Volume group name expected "
                                          "(no slash)");
                                return 0;
                        }
...
(http://sources.redhat.com/cgi-bin/cvsweb.cgi/LVM2/tools/lvcreate.c?rev=1.231&content-type=text/x-cvsweb-markup&cvsroot=lvm2)

When I lookup the hook within the the libvirt source code, I find the following snippet:
...
    const char *cmdargvnew[] = {
        LVCREATE, "--name", vol->name, "-L", size,
        pool->def->target.path, NULL
    };
...
(http://libvirt.org/git/?p=libvirt.git;a=blob_plain;f=src/storage/storage_backend_logical.c;hb=HEAD)

Judging by the code, 'pool->def->target.path' should be changed to 'pool->def->source.name', however, my knowledge of C is very limited.

Comment 1 Cole Robinson 2012-01-25 17:44:47 UTC
For having limited C knowledge that was a great analysis! I think you are right, but I'd like to test this. Problem is I have no idea how you created a nested volume group (fedora 16 doesn't seem to want to put a volume group routed anywhere except /dev, which does work in the lvcreate command because lvm strips it off).

Can you provide instructions?

Comment 2 Cole Robinson 2012-03-02 15:20:45 UTC
Lex, any thoughts on comment #1, particularly instructions on how to reproduce this issue?

Comment 3 Cole Robinson 2012-04-16 14:27:01 UTC
I managed to reproduce using a symlink, upstream is now patched:

http://libvirt.org/git/?p=libvirt.git;a=commit;h=cab1a9dee83142dcc795e58d42325a726c100463


Note You need to log in before you can comment on or make changes to this bug.