Bug 470693

Summary: Colon as a delimiter to parse the 'lvs' is not always working
Product: [Community] Virtualization Tools Reporter: Niklas Hagman <redhat>
Component: libvirtAssignee: Daniel Veillard <veillard>
Status: CLOSED UPSTREAM QA Contact:
Severity: medium Docs Contact:
Priority: medium    
Version: unspecifiedCC: berrange, crobinso
Target Milestone: ---   
Target Release: ---   
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2008-12-02 16:39:44 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Attachments:
Description Flags
Logfile from autogen.sh
none
Switch the delimiter to a comma none

Description Niklas Hagman 2008-11-08 23:12:31 UTC
Description of problem:
Am having problem starting a logical volume pool. It has worked before but stopped starting a couple of months back. I run "pool-start vg" and get error. The output from libvirt is below and so is my xml file. Why is libvirt trying to open /dev/vg/root:6V34m5-Jvrt-Mbdp-wgiY-DiMk-ssZk-xFoqFq when I run "pool-start vg"?

Am using libvirt 0.4.6 compiled from source. Ubuntu 8.10.

Libvirt output:
9 logical volume(s) in volume group "vg" now active
cannot open volume '/dev/vg/root:6V34m5-Jvrt-Mbdp-wgiY-DiMk-ssZk-xFoqFq': No such file or directorylibvir: Storage error : cannot open volume '/dev/vg/root:6V34m5-Jvrt-Mbdp-wgiY-DiMk-ssZk-xFoqFq': No such file or directory
lvs command failedlibvir: Storage error : lvs command failed
Can't deactivate volume group "vg" with 5 open logical volume(s)
libvir: error : /sbin/vgchange exited with non-zero status 5 and signal 0

Volume group storage pool xml:
<pool type="logical">
  <name>vg</name>
  <source>
    <name>vg</name>
  </source>
  <target>
    <path>/dev/vg</path>
  </target>
</pool>

Comment 1 Cole Robinson 2008-11-10 14:41:31 UTC
I believe there were some regressions in 0.4.6 wrt logical pools. These should be fixed upstream. Can you try with latest upstream?

git clone git://git.et.redhat.com/libvirt.git

Comment 2 Niklas Hagman 2008-11-10 23:19:43 UTC
Created attachment 323132 [details]
Logfile from autogen.sh

Having problem compiling libvirt from git. Am not an expert at this so am probably doing something wrong. See the attachment for my errors. Using ubuntu 8.10 server...

Comment 3 Niklas Hagman 2008-11-11 20:03:34 UTC
I figure out what I was missing. I did not have automake. Sorry about that.

Okay, I tested the latest git and it produces the same error for me. So no go...

Comment 4 Niklas Hagman 2008-11-11 20:21:01 UTC
I can see now that it was a slightly difference in the error output from libvirt taken from git:

libvir: Storage error : internal error cannot open volume '/dev/vg/root:6V34m5-Jvrt-Mbdp-wgiY-DiMk-ssZk-xFoqFq': No such file or directory
libvir: Storage error : internal error lvs command failed
libvir: error : internal error '/sbin/vgchange -an vg' exited with non-zero status 5 and signal 0:   Can't deactivate volume group "vg" with 5 open logical volume(s)

Comment 5 Cole Robinson 2008-11-11 20:45:36 UTC
Okay, we debugged this on IRC.

Libvirt uses the a colon as a delimiter to parse the 'lvs' command when starting a pool. Unfortunately, on ubuntu, lvs prints a colon in the physical device name, so our parsing is all messed up.

Ubuntu output:
  root:6V34m5-Jvrt-Mbdp-wgiY-DiMk-ssZk-xFoqFq:/dev/block/254:0(0):9663676416:4194304

Fedora output:
lvhome:fktHK1-MC62-tjuz-AxrR-js47-waBp-6clGPh:/dev/sda2(0):50331648000:33554432

Notice the extra ':' between the device name and (0).

We verified that the use of : is hardcoded, since specifying a different separator (tested with '#') shows the expected output format.

So we should probably change our call in libvirt to not use ':'.

Comment 6 Daniel Berrangé 2008-11-11 21:29:19 UTC
Ah, i see the actual device name is "/dev/block/254:0" which is a little wierd. 

While changing the separator will be needed, we may also need to do some extra magic to turn '/dev/block/254:0' back into a /dev/sdXXX  type name. This is because if you have an iSCSI / disk pool you want to be able to correlate LVM pvs against the devices in other pools. 

For separator, using ';' or ',' or '|' would be possible choices.

Comment 7 Niklas Hagman 2008-11-11 21:45:20 UTC
For your information, '/dev/block/254:0' is a encrypted volume with lvm inside. The encrypted volume is mounted with the command "cryptsetup luksOpen /dev/sda cryptroot" that will give the source path "/dev/mapper/cryptroot" for this encrypted volume with lvm inside. After mounting this encrypted volume, ubuntu is setting up lvm2 automatic.

Comment 8 Daniel Berrangé 2008-11-11 21:49:44 UTC
Thanks, that's useful info - its almost certainly not Ubuntu specific then - I imagine if we did an encrypted phys device in LVM on Fedora we'd hit the same issue.

Comment 9 Cole Robinson 2008-11-12 21:32:51 UTC
Created attachment 323389 [details]
Switch the delimiter to a comma

Niklas, can you test this patch and see if it fixes your problem?

Comment 10 Niklas Hagman 2008-11-13 07:28:12 UTC
Yes, it seems to work.
virt-manager can see the list of lvs. Have created and deleted a lv from within virt-manager at it works.

But virt-install (within virt-manager) don't allow me to choose a disk as virtual harddrive. But that is another problem/bug.

You can mark this bug solved when ready. Nice done!

Comment 11 Cole Robinson 2008-12-02 16:39:44 UTC
This was fixed upstream and is in version 0.5.0:

http://git.et.redhat.com/?p=libvirt.git;a=commit;h=c6b0d780cc0b245226e668bada94d02bf4cd9831

Closing as UPSTREAM.