Bug 1371758

Summary: RFE:Add json pseudo protocol support for rbd
Product: Red Hat Enterprise Linux 7 Reporter: Han Han <hhan>
Component: libvirtAssignee: Peter Krempa <pkrempa>
Status: CLOSED ERRATA QA Contact: lijuan men <lmen>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: 7.4CC: dyuan, jdenemar, mtessun, rbalakri, rjones, xuzhang, yanyang
Target Milestone: rcKeywords: FutureFeature
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: libvirt-2.5.0-1.el7 Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2017-08-01 17:14:13 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:
Bug Depends On: 1457088    
Bug Blocks:    

Description Han Han 2016-08-31 03:09:04 UTC
Just like what we did in BZ1134878 and pacthes http://post-office.corp.redhat.com/archives/rhvirt-patches/2016-August/msg00280.html . Add rbd json backing support in libvirt.

Comment 2 Peter Krempa 2016-09-06 12:07:47 UTC
Added upstream:

commit 3de7da9448a5edb8440eeeb32b98f282880229e1
Author: Peter Krempa <pkrempa>
Date:   Mon Sep 5 15:15:22 2016 +0200

    util: storage: Add json pseudo protocol support for legacy RBD strings
    
    RBD in qemu still uses only the legacy 'filename' syntax.

Comment 3 Han Han 2016-09-07 08:15:19 UTC
It works well with upstream libvirt:
# qemu-img create -f qcow2 -b 'json:{"file.driver":"rbd","file.filename":"rbd:rbd/hhan:mon_host=10.73.75.52"}' /var/lib/libvirt/images/rbd.img
Formatting '/var/lib/libvirt/images/rbd.img', fmt=qcow2 size=104857600 backing_file=json:{"file.driver":"rbd",,"file.filename":"rbd:rbd/hhan:mon_host=10.73.75.52"} encryption=off cluster_size=65536 lazy_refcounts=off refcount_bits=16

# virsh attach-disk V  /var/lib/libvirt/images/nbd.img vdb --subdriver qcow2  
Disk attached successfully

Read/Write on the image works well.
# virsh dumpxml V|awk '/<disk/,/<\/disk/'                                     
    <disk type='file' device='disk'>
      <driver name='qemu' type='qcow2'/>
      <source file='/var/lib/libvirt/images/V.qcow2'/>
      <backingStore/>
      <target dev='vda' bus='virtio'/>
      <alias name='virtio-disk0'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x07' function='0x0'/>
    </disk>
    <disk type='file' device='disk'>
      <driver name='qemu' type='qcow2'/>
      <source file='/var/lib/libvirt/images/nbd.img'/>
      <backingStore type='network' index='1'>
        <format type='raw'/>
        <source protocol='nbd'>
          <host name='10.66.6.236' port='8888'/>
        </source>
        <backingStore/>
      </backingStore>
      <target dev='vdb' bus='virtio'/>
      <alias name='virtio-disk1'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x0e' function='0x0'/>
    </disk>
# virsh detach-disk V vdb                
Disk detached successfully

Comment 5 lijuan men 2017-04-17 09:33:31 UTC
verify the bug

version:
libvirt-3.2.0-2.el7.x86_64
qemu-kvm-rhev-2.8.0-6.el7.x86_64

steps:

[root@lmen1 ~]# qemu-img create -f qcow2 -b 'json:{"file.driver":"rbd","file.filename":"rbd:lmen/test.img:mon_host=10.73.75.52"}' /var/lib/libvirt/images/test1.qcow2
Formatting '/var/lib/libvirt/images/test1.qcow2', fmt=qcow2 size=104857600 backing_file=json:{"file.driver":"rbd",,"file.filename":"rbd:lmen/test.img:mon_host=10.73.75.52"} encryption=off cluster_size=65536 lazy_refcounts=off refcount_bits=16


[root@lmen1 ~]# qemu-img info /var/lib/libvirt/images/test1.qcow2
image: /var/lib/libvirt/images/test1.qcow2
file format: qcow2
virtual size: 100M (104857600 bytes)
disk size: 196K
cluster_size: 65536
backing file: json:{"file.driver":"rbd","file.filename":"rbd:lmen/test.img:mon_host=10.73.75.52"}
Format specific information:
    compat: 1.1
    lazy refcounts: false
    refcount bits: 16
    corrupt: false


[root@lmen1 ~]# virsh attach-disk test /var/lib/libvirt/images/test1.qcow2 sda --subdriver qcow2  
Disk attached successfully

[root@lmen1 ~]# virsh domblklist test
Target     Source
------------------------------------------------
hda        /var/lib/libvirt/images/test.qcow2
sda        /var/lib/libvirt/images/test1.qcow2


[root@lmen1 ~]# virsh dumpxml test
...
 <disk type='file' device='disk'>
      <driver name='qemu' type='qcow2'/>
      <source file='/var/lib/libvirt/images/test1.qcow2'/>
      <backingStore type='network' index='1'>
        <format type='raw'/>
        <source protocol='rbd' name='lmen/test.img'>
          <host name='10.73.75.52'/>
        </source>
        <backingStore/>
      </backingStore>
      <target dev='sda' bus='scsi'/>
      <alias name='scsi0-0-0-0'/>
      <address type='drive' controller='0' bus='0' target='0' unit='0'/>
    </disk>

...

the disk can be read/wrote in the guest

[root@lmen1 ~]# virsh detach-disk test sda
Disk detached successfully

Comment 6 Han Han 2017-05-31 06:23:01 UTC
Blocked by BZ1457088 in RHEL7.4.

Comment 7 lijuan men 2017-06-21 06:18:21 UTC
verify the bug 

version:
libvirt-3.2.0-11.el7.x86_64
qemu-kvm-rhev-2.9.0-12.el7.x86_64

steps:

1)create the img

[root@lmen1 ~]# qemu-img create -f qcow2 -b 'json:{"file.driver":"rbd","file.filename":"rbd:lmen/test.img:mon_host=10.73.75.52"}' /var/lib/libvirt/images/test1.qcow2
qemu-img: Warning: 'filename' option specified. This is an unsupported option, and may be deprecated in the future
Formatting '/var/lib/libvirt/images/test1.qcow2', fmt=qcow2 size=104857600 backing_file=json:{"file.driver":"rbd",,"file.filename":"rbd:lmen/test.img:mon_host=10.73.75.52"} encryption=off cluster_size=65536 lazy_refcounts=off refcount_bits=16


[root@lmen1 ~]# qemu-img info /var/lib/libvirt/images/test1.qcow2
image: /var/lib/libvirt/images/test1.qcow2
file format: qcow2
virtual size: 100M (104857600 bytes)
disk size: 196K
cluster_size: 65536
backing file: json:{"file.driver":"rbd","file.filename":"rbd:lmen/test.img:mon_host=10.73.75.52"}
Format specific information:
    compat: 1.1
    lazy refcounts: false
    refcount bits: 16
    corrupt: false

2)hotplug

[root@lmen1 ~]# virsh attach-disk test /var/lib/libvirt/images/test1.qcow2 sdb --subdriver qcow2  
Disk attached successfully

[root@lmen1 ~]# virsh domblklist test
Target     Source
------------------------------------------------
hda        /var/lib/libvirt/images/RHEL-7.4-x86_64-latest.qcow2
sda        rhel7.3.iso
sdb        /var/lib/libvirt/images/test1.qcow2

[root@lmen1 ~]# virsh dumpxml test
...
 <disk type='file' device='disk'>
      <driver name='qemu' type='qcow2'/>
      <source file='/var/lib/libvirt/images/test1.qcow2'/>
      <backingStore type='network' index='1'>
        <format type='raw'/>
        <source protocol='rbd' name='lmen/test.img'>
          <host name='10.73.75.52'/>
        </source>
        <backingStore/>
      </backingStore>
      <target dev='sdb' bus='scsi'/>
      <alias name='scsi0-0-0-1'/>
      <address type='drive' controller='0' bus='0' target='0' unit='1'/>
    </disk>
...

the disk can be read/wrote in the guest

[root@lmen1 ~]# virsh detach-disk test sdb
Disk detached successfully

[root@lmen1 ~]# virsh domblklist test
Target     Source
------------------------------------------------
hda        /var/lib/libvirt/images/RHEL-7.4-x86_64-latest.qcow2
sda        rhel7.3.iso

there is not the disk in the guest

3)coldplug

start a guest with xml:
  <disk type='file' device='disk'>
      <driver name='qemu' type='qcow2'/>
      <source file='/var/lib/libvirt/images/test1.qcow2'/>
      <target dev='sdb' bus='scsi'/>
      <address type='drive' controller='0' bus='0' target='0' unit='1'/>
    </disk>

[root@lmen1 ~]# virsh start test
Domain test started

[root@lmen1 ~]# virsh dumpxml test
...
<disk type='file' device='disk'>
      <driver name='qemu' type='qcow2'/>
      <source file='/var/lib/libvirt/images/test1.qcow2'/>
      <backingStore type='network' index='1'>
        <format type='raw'/>
        <source protocol='rbd' name='lmen/test.img'>
          <host name='10.73.75.52'/>
        </source>
        <backingStore/>
      </backingStore>
      <target dev='sdb' bus='scsi'/>
      <alias name='scsi0-0-0-1'/>
      <address type='drive' controller='0' bus='0' target='0' unit='1'/>
    </disk>
...

the disk can be read/wrote in the guest

Comment 8 errata-xmlrpc 2017-08-01 17:14:13 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory, and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

https://access.redhat.com/errata/RHEA-2017:1846

Comment 9 errata-xmlrpc 2017-08-01 23:55:08 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory, and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

https://access.redhat.com/errata/RHEA-2017:1846

Comment 10 errata-xmlrpc 2017-08-02 01:27:35 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory, and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

https://access.redhat.com/errata/RHEA-2017:1846