[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

[libvirt] Issues with qemu-nbd over AF_UNIX and virDomainAttachDevice

Hi List,
Facing issues trying to use virDomainAttachDevice API of libvirt from python.

Here is what I am trying to do

1) Setup qemu-nbd to export a qcow2 disk image over unix socket on my localhost
qemu-nbd -t -k /tmp/mysock2 /home/dpkshetty/work/img/iscsi_disk

The above blocks. and i am able to use
qemu-system-x86_64 -drive file=nbd:unix:/tmp/mysock2

Just to test it...and it works. Since currently the disk is a blank disk.. I see "No bootable device" and QEMU stops.. whcih is expected
So qemu-nbd is setup and working properly

>>> print nbdxml
<disk type='network' device='disk'>
  <driver name="qemu" type="qcow2"/>
  <source protocol="nbd">
<host name="deepakcs-lx" port="10809" transport="unix" socket="/tmp/mysock2" />
  <target dev="vdc" bus="virtio" />
>>> dom.attachDevice(nbdxml)
libvir: QEMU error : operation failed: open disk image file failed
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
File "/usr/lib64/python2.7/site-packages/libvirt.py", line 400, in attachDevice if ret == -1: raise libvirtError ('virDomainAttachDevice() failed', dom=self)
libvirt.libvirtError: operation failed: open disk image file failed

and I see... in the VM's log....

inet_connect_opts: connect(ipv4,deepakcs-lx.local.lan,,10809): Connection refused

3) I tried usign virsh attach-device.. and the same problem happens

4) firewall/iptables are not running. SELinux is permissive

5) I tried appending -p 1111 to the qemu-nbd cmdline and using port="1111" in the XML.. but that doesn't help, see the same error

Questions/Observations :

1) What am i doing wrong here ? In the <host> tag, port attr is mandatory.. but looking at `netstat -nptl` I don't see any process listeing on 10809 or 1111 (when i gave -p 1111 ). So does this mean there is no way for libvirt to just directly open the socket and use it.. Its trying to connect to the port i give in the XML and since no one is listening there.. it fails.. hence the error seen in the VM logs.... Has anybody tryign usign qemu-nbd and attaching that disk as I am doign above ? Is it legal, if not, why ?

2) The VM/Domain is active during all of the above steps.

3) IIUC... for the above usecase... port attr of <host> should be optional... such that libvirt can directly do the equivalent of ` -drive file=nbd:unix:/tmp/mysock2` and add this as a NBD device to the runnign guest/Domain... but currently port and hostname are mandatory. For unix sockets... hostname will always be local...so i feel both hostname & port should be optional for the above usecase ?

4) I haven't yet tried doing the above when guest/Domain is Inactive.

5) I haven't yet tried doing the above usign nbd-server or qemu-nbd usign -c option (which i believe starts qemu-nbd in server mode, but need nbd.ko kernel module to be loaded). I am hoping using either of these might get it working... since we have a process listening on a port on the host... but I wanted to get this working using plain unix sockets.. lightweight and doesn't need nbd.ko

Comments/Suggestions appreciated.


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]