Bug 1045107 - RFE: virsh: Support network disk parameters for attach-disk
Summary: RFE: virsh: Support network disk parameters for attach-disk
Alias: None
Product: Virtualization Tools
Classification: Community
Component: libvirt
Version: unspecified
Hardware: Unspecified
OS: Unspecified
Target Milestone: ---
Assignee: Libvirt Maintainers
QA Contact:
Whiteboard: LibvirtFirstBug
Depends On:
TreeView+ depends on / blocked
Reported: 2013-12-19 15:53 UTC by Shanzhi Yu
Modified: 2020-04-17 16:49 UTC (History)
7 users (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Last Closed: 2020-04-17 16:49:12 UTC

Attachments (Terms of Use)

Description Shanzhi Yu 2013-12-19 15:53:57 UTC
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):


How reproducible:


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'/>
<target dev='vdb' bus='virtio'/>

#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.

Comment 4 Yang Yang 2014-11-27 08:02:31 UTC
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

Comment 5 Zhang MIn 2015-05-18 04:16:47 UTC
virsh # pool-dumpxml testvol
<pool type='gluster'>
  <capacity unit='bytes'>39700525056</capacity>
  <allocation unit='bytes'>15881662464</allocation>
  <available unit='bytes'>23818862592</available>
    <host name=''/>
    <dir path='/'/>

virsh # vol-list testvol
 名称               路径
 123.img              gluster://
 456                  gluster://
 centos.img           gluster://
 test.img             gluster://

virsh # start centos
错误:开始域 centos 失败
错误:Cannot access storage file 'gluster://' (as uid:107, gid:107): 没有那个文件或目录

virsh #

Comment 6 Peter Krempa 2015-09-29 15:10:13 UTC
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.

Comment 7 Cole Robinson 2016-04-15 15:24:27 UTC
An example commit extending virsh attach-disk with the --iothread option:

commit bc5a8090afa84095634ccee1e1a6ca9a2a9b177a
Author: John Ferlan <jferlan@redhat.com>
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-host-name (maybe take host:port syntax too)

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'/>
      <target dev='vdaa' bus='virtio'/>
    <disk type='network' device='disk'>
      <driver name='qemu' type='raw'/>
      <source protocol='nbd'>
        <host transport='unix' socket='/var/run/nbdsock'/>
      <target dev='vdab' bus='virtio'/>
    <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'/>
      <target dev='vdac' bus='virtio'/>
    <disk type='network' device='disk'>
      <driver name='qemu' type='raw'/>
      <source protocol='sheepdog' name='image,with,commas'>
        <host name='example.org' port='6000'/>
      <target dev='vdad' bus='virtio'/>
    <disk type='network' device='disk'>
      <driver name='qemu' type='raw'/>
      <source protocol='gluster' name='test-volume/test-gluster2.raw'>
        <host name=''/>
      <target dev='vdae' bus='virtio'/>

Comment 9 Daniel Berrangé 2020-04-17 16:49:12 UTC
This issue is now tracked in https://gitlab.com/libvirt/libvirt/-/issues/16

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