Bug 1366049

Summary: RFE: libvirt backend: support handling disks stored as volume name in a pool
Product: [Community] Virtualization Tools Reporter: Subra Dhulipala <sudhulip>
Component: libguestfsAssignee: Richard W.M. Jones <rjones>
Status: CLOSED UPSTREAM QA Contact:
Severity: medium Docs Contact:
Priority: unspecified    
Version: unspecifiedCC: ptoscano, rbalakri
Target Milestone: ---   
Target Release: ---   
Hardware: x86_64   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2016-09-22 15:52:34 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Subra Dhulipala 2016-08-10 21:43:04 UTC
Description of problem:
If a vm is created whose xml description of a disk contains "diskType='volume', the guestfsmod.add_domain fails with the error mentioned in the summary. 
This test has been done using python guestfs module.

If a vm is created whose xml description of a disk contains "diskType='file'", guestfs.add_domain() works fine. 


Version-Release number of selected component (if applicable):
># virt-v2v --version
virt-v2v 1.28.1

# rpm -qa | grep libguestfs
libguestfs-tools-c-1.28.1-1.55.el7.x86_64
python-libguestfs-1.28.1-1.55.el7.x86_64
libguestfs-1.28.1-1.55.el7.x86_64
libguestfs-winsupport-7.2-1.el7.x86_64


How reproducible:
Very

Steps to Reproduce:
Assumption: kvm and libvirt are installed and running. A storage pool called
"default" has been defined whose path points to "/home/vms". 

1. virt-v2v -i ova -of qcow2  -os default -on vsm_vm3 vsm_vmware.ova
  
   Converts ova to a vm with name vsm_vm3. Can see the vm through virsh.
2. Run the script mentioned in the "Additional info". Fails with error mentioned.


Actual results:
#>./test_add_domain.py vsm_vm3
Traceback (most recent call last):
  File "./test_add_domain.py", line 13, in <module>
    g.add_domain(sys.argv[1])
  File "/usr/lib64/python2.7/site-packages/guestfs.py", line 340, in add_domain
    r = libguestfsmod.add_domain (self._o, dom, libvirturi, readonly, iface, live, allowuuid, readonlydisk, cachemode, discard, copyonread)
RuntimeError: libvirt domain has no disks


Expected results:
Expected libguestfsmod.add_domain() to pass instead of throwing a runtime error.

Additional info:
The workaround I found was to:
1.  virt-v2v -i ova -of qcow2 -o local -os /home/vms/ -on vsm_vmware.ova
2. virsh define /home/vms/vsm_vm2.xml
3. This creates a disk of diskType file. Then libguestfs.add_domain() goes through.

Failed VMs xml description of disk:
 <devices>
    <emulator>/usr/libexec/qemu-kvm</emulator>
    <disk type='volume' device='disk'>
      <driver name='qemu' type='qcow2' cache='none'/>
      <source pool='default' volume='vsm_vm3-sda'/>
      <target dev='vda' bus='virtio'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x05' function='0x0'/
>
    </disk>


Successful VM's xml description of disk:
  <devices>
    <emulator>/usr/libexec/qemu-kvm</emulator>
    <disk type='file' device='disk'>
      <driver name='qemu' type='qcow2' cache='none'/>
      <source file='/home/vms/vsm_vm2-sda'/>
      <target dev='vda' bus='virtio'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x05' function='0x0'/
>
    </disk>


Test script:

#!/usr/bin/env python
import sys
import guestfs

if len(sys.argv) < 2:
    print "Usage: %s <vm name>" % sys.argv[0]
    sys.exit(1)

g = guestfs.GuestFS(python_return_dict=True)

g.add_domain(sys.argv[1])

Comment 1 Richard W.M. Jones 2016-08-10 22:17:06 UTC
I'm a bit confused about the mixture of python & virt-v2v in the
bug report.  For virt-v2v, this issue was supposed to have been
addressed by bug 1146832.

For the guestfs_add_domain API (which is not used by virt-v2v),
the problem still exists.

BTW you probably want to try out the RHEL 7.3 preview packages
which are available here:

https://people.redhat.com/~rjones/libguestfs-RHEL-7.3-preview/

Comment 2 Subra Dhulipala 2016-08-10 23:05:05 UTC
To be clear, I did not have any problem with virt-v2v. In fact, I should not have mentioned it. The problem is with guestfsmod.add_domain() with diskType of volume.

Comment 3 Pino Toscano 2016-08-11 08:19:24 UTC
You can try also without Python, just using other libguestfs tools: for example

  $ virt-inspector -d vsm_vm3 > out.xml

If it works, then out.xml contains information (such as OS, distribution, mountpoints, installed applications) in XML format of the guest.  In case of error, out.xml will be empty and an error message will be printed.

The issue is that basically we don't support yet <disk type='volume'> as disk from libvirt domains.

Comment 4 Pino Toscano 2016-09-21 08:46:55 UTC
Patch posted:
  https://www.redhat.com/archives/libguestfs/2016-September/msg00143.html

Comment 5 Pino Toscano 2016-09-22 15:52:34 UTC
Fixed with
https://github.com/libguestfs/libguestfs/commit/4c3968f262e8a45f65f8980d6af39144bd52f0ea
which is in libguestfs >= 1.35.6.