Description of problem: attach-disk doesn't work when use it to attach an gluster volume to guest Version-Release number of selected component (if applicable): libvirt-1.1.1-16.el7.x86_64 qemu-kvm-rhev-1.5.3-21.el7.x86_64 How reproducible: 100% Steps to Reproduce: 1. prepare glusterfs server 2. attach disk by attach-device #cat disk-gluster-volume.xml <disk type='network' device='disk'> <driver name='qemu' type='qcow2'/> <source protocol='gluster' name='gluster-vol2/test.img'> <host name='glusterfs server'/> </source> <target dev='vdb' bus='virtio'/> </disk> #virsh attach-device rhel6 disk-gluster-volume.xml Device attached successfully 3. attach disk by attach-disk # qemu-img info gluster://glusterfs server/gluster-vol2/test.img image: gluster://glusterfs server/gluster-vol2/test.img file format: qcow2 virtual size: 1.0G (1073741824 bytes) disk size: 49M cluster_size: 65536 Format specific information: compat: 0.10 # virsh attach-disk rhel6 gluster://glusterfs server/gluster-vol2/test.img vdb error: Failed to attach disk error: Failed to open file 'gluster://glusterfs server/gluster-vol2/test.img': No such file or directory Actual results: Expected results: attach-disk should can attach gluster volume to guest Additional info: Confirm with Peter, it is a virsh issue. snapshot-create-as also can't create an external disk-only snapshot while it is support by libvirt(snapshot-create with snapshot xml file work well). so track this issue here together.
Met the same issue when hotplugging a rbd based storage disk by using attach-disk. # qemu-img info rbd:libvirt-pool/test1.img image: rbd:libvirt-pool/test1.img file format: raw virtual size: 1.0G (1073741824 bytes) disk size: unavailable cluster_size: 4194304 # virsh attach-disk vm1 rbd:libvirt-pool/test1.img vdb error: Failed to attach disk error: Cannot access storage file 'rbd:libvirt-pool/test1.img' (as uid:107, gid:107): No such file or directory
virsh # pool-dumpxml testvol <pool type='gluster'> <name>testvol</name> <uuid>910525a3-1119-4b97-a873-8342544a1507</uuid> <capacity unit='bytes'>39700525056</capacity> <allocation unit='bytes'>15881662464</allocation> <available unit='bytes'>23818862592</available> <source> <host name='192.168.199.5'/> <dir path='/'/> <name>testvol</name> </source> </pool> virsh # vol-list testvol 名称 路径 ------------------------------------------------------------------------------ 123.img gluster://192.168.199.5/testvol/123.img 456 gluster://192.168.199.5/testvol/456 centos.img gluster://192.168.199.5/testvol/centos.img test.img gluster://192.168.199.5/testvol/test.img virsh # start centos 错误:开始域 centos 失败 错误:Cannot access storage file 'gluster://192.168.199.5/testvol/123.img' (as uid:107, gid:107): 没有那个文件或目录 virsh #
Moving to upstream tracker, since the BZ traces just the fact that 'virsh attach-disk' isn't able to generate the XML for network disks. Networked disks can be attached via 'virsh attach-device' when providing the correct XML. This is a user interface enhancement.
An example commit extending virsh attach-disk with the --iothread option: https://github.com/libvirt/libvirt/commit/bc5a8090afa84095634ccee1e1a6ca9a2a9b177a commit bc5a8090afa84095634ccee1e1a6ca9a2a9b177a Author: John Ferlan <jferlan> Date: Tue Sep 2 11:20:41 2014 -0400 virsh: Add iothread to 'attach-disk' All the parameters to add for network disk support: --source-protocol --source-name --source-host-name (maybe take host:port syntax too) --source-host-transport --source-host-socket Then the extra bit would be teaching it to decode gluster:// style URLs into those correct parameters. Here's several example disk configs that we'd want to be able to generate: <disk type='network' device='disk'> <driver name='qemu' type='raw'/> <source protocol='http' name='/my-file.img'> <host name='example.org'/> </source> <target dev='vdaa' bus='virtio'/> </disk> <disk type='network' device='disk'> <driver name='qemu' type='raw'/> <source protocol='nbd'> <host transport='unix' socket='/var/run/nbdsock'/> </source> <target dev='vdab' bus='virtio'/> </disk> <disk type='network' device='disk'> <driver name='qemu' type='raw'/> <source protocol='rbd' name='pool/image'> <host name='mon1.example.org' port='6321'/> <host name='mon2.example.org' port='6322'/> <host name='mon3.example.org' port='6322'/> </source> <target dev='vdac' bus='virtio'/> </disk> <disk type='network' device='disk'> <driver name='qemu' type='raw'/> <source protocol='sheepdog' name='image,with,commas'> <host name='example.org' port='6000'/> </source> <target dev='vdad' bus='virtio'/> </disk> <disk type='network' device='disk'> <driver name='qemu' type='raw'/> <source protocol='gluster' name='test-volume/test-gluster2.raw'> <host name='192.168.1.100'/> </source> <target dev='vdae' bus='virtio'/> </disk>
This issue is now tracked in https://gitlab.com/libvirt/libvirt/-/issues/16