Note: This is a public test instance of Red Hat Bugzilla. The data contained within is a snapshot of the live data so any changes you make will not be reflected in the production Bugzilla. Email is disabled so feel free to test any aspect of the site that you want. File any problems you find or give feedback at bugzilla.redhat.com.
RHEL Engineering is moving the tracking of its product development work on RHEL 6 through RHEL 9 to Red Hat Jira (issues.redhat.com). If you're a Red Hat customer, please continue to file support cases via the Red Hat customer portal. If you're not, please head to the "RHEL project" in Red Hat Jira and file new tickets here. Individual Bugzilla bugs in the statuses "NEW", "ASSIGNED", and "POST" are being migrated throughout September 2023. Bugs of Red Hat partners with an assigned Engineering Partner Manager (EPM) are migrated in late September as per pre-agreed dates. Bugs against components "kernel", "kernel-rt", and "kpatch" are only migrated if still in "NEW" or "ASSIGNED". If you cannot log in to RH Jira, please consult article #7032570. That failing, please send an e-mail to the RH Jira admins at rh-issues@redhat.com to troubleshoot your issue as a user management inquiry. The email creates a ServiceNow ticket with Red Hat. Individual Bugzilla bugs that are migrated will be moved to status "CLOSED", resolution "MIGRATED", and set with "MigratedToJIRA" in "Keywords". The link to the successor Jira issue will be found under "Links", have a little "two-footprint" icon next to it, and direct you to the "RHEL project" in Red Hat Jira (issue links are of type "https://issues.redhat.com/browse/RHEL-XXXX", where "X" is a digit). This same link will be available in a blue banner at the top of the page informing you that that bug has been migrated.
Bug 1451557 - Update json parsing in libvirt
Summary: Update json parsing in libvirt
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Enterprise Linux 7
Classification: Red Hat
Component: libvirt
Version: 7.4
Hardware: x86_64
OS: Linux
high
unspecified
Target Milestone: rc
: ---
Assignee: Peter Krempa
QA Contact: Han Han
URL:
Whiteboard:
Depends On:
Blocks: 1473046
TreeView+ depends on / blocked
 
Reported: 2017-05-17 04:31 UTC by Yanqiu Zhang
Modified: 2018-05-24 03:41 UTC (History)
12 users (show)

Fixed In Version: libvirt-3.7.0-1.el7
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed: 2018-04-10 10:44:33 UTC
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)
libvirtd.log (deleted)
2017-05-17 04:31 UTC, Yanqiu Zhang
no flags Details


Links
System ID Private Priority Status Summary Last Updated
Red Hat Bugzilla 1371758 0 unspecified CLOSED RFE:Add json pseudo protocol support for rbd 2021-02-22 00:41:40 UTC
Red Hat Bugzilla 1461638 0 unspecified CLOSED "blockjob --pivot" after shallow blockcommit get unexpected result 2021-02-22 00:41:40 UTC
Red Hat Product Errata RHEA-2018:0704 0 None None None 2018-04-10 10:46:10 UTC

Internal Links: 1371758 1461638

Description Yanqiu Zhang 2017-05-17 04:31:28 UTC
Created attachment 1279524 [details]
libvirtd.log

Description of problem:
qemu involved in "pool image" json format for rbd protocol from 8a47e8eb, libvirt failed to parse it.

Version-Release number of selected component (if applicable):
libvirt-3.2.0-5.el7.x86_64
qemu-kvm-rhev-2.9.0-5.el7.x86_64

How reproducible:
100%

Steps to Reproduce:
1.# qemu-img create -f qcow2 -b 'json:{"driver": "raw", "file": {"pool": "rbd", "image": "rbd.img", "driver": "rbd", "=keyvalue-pairs": "[\"mon_host\", \"10.73.75.52\"]"}}' /var/lib/libvirt/images/rbd.img
Formatting '/var/lib/libvirt/images/rbd.img', fmt=qcow2 size=5368709120 backing_file=json:{"driver": "raw",, "file": {"pool": "rbd",, "image": "rbd.img",, "driver": "rbd",, "=keyvalue-pairs": "[\"mon_host\",, \"10.73.75.52\"]"}} encryption=off cluster_size=65536 lazy_refcounts=off refcount_bits=16

2.# virsh pool-refresh default  
error: Failed to refresh pool default
error: invalid argument: missing RBD filename in JSON backing volume definition

3.# virsh pool-list --all
 Name                 State      Autostart
-------------------------------------------
 default              inactive   yes      


Actual results:
As in step2, libvirt failed to parse "pool image" json format for rbd protocol

Expected results:
qemu involved in "pool image" json format from 8a47e8eb, libvirt should support this.

Additional info:
# cat /var/log/libvirt/libvirtd.log|grep ' error '
2017-05-17 03:22:33.848+0000: 59387: error : virStorageSourceParseBackingJSONRBD:3053 : invalid argument: missing RBD filename in JSON backing volume definition

Comment 2 Han Han 2017-05-19 09:23:15 UTC
Since the new json interfaces added in qemu-2.9, the former json formats in BZ1134878 and BZ1371758 don't work. Libvirt should update codes in json parsing to catch up with changes in qemu-2.9.

Comment 3 Yanqiu Zhang 2017-06-19 09:00:01 UTC
Also reproduce for gluster ServerType is 'inet': 

Pkgs version:
libvirt-3.2.0-10.virtcov.el7.x86_64
qemu-kvm-rhev-2.9.0-10.el7.x86_64


Steps:
1.# qemu-img create -f qcow2 -b 'json:{"file.driver":"gluster","file.volume":"gluster-vol1","file.path":"R.qcow2","file.logfile":"/tmp/log","file.debug":9,"file.server":[ {"type":"inet","host":"10.66.*.*","port":"24007"}]}' /var/lib/libvirt/images/gluster_socket.img
Formatting '/var/lib/libvirt/images/gluster_socket.img', fmt=qcow2 size=104857600 backing_file=json:{"file.driver":"gluster",,"file.volume":"gluster-vol1",,"file.path":"R.qcow2",,"file.logfile":"/tmp/log",,"file.debug":9,,"file.server":[ {"type":"inet",,"host":"10.66.*.*",,"port":"24007"}]} encryption=off cluster_size=65536 lazy_refcounts=off refcount_bits=16

# ls /var/lib/libvirt/images/
gluster_socket.img

2.# virsh pool-refresh default
error: Failed to refresh pool default
error: internal error: unknown backing store transport protocol 'inet'

Comment 4 Han Han 2017-06-19 09:42:06 UTC
Inet type for gluster is added since commit fce5d538 in qemu-2.9.

Comment 5 Peter Krempa 2017-06-20 08:07:07 UTC
Upstream fixes the issues pointed out in this bug by:

commit 1f915d40a220c6bb05d8630507eed045cabfba34
Author: Peter Krempa <pkrempa>
Date:   Mon Jun 19 14:37:47 2017 +0200

    util: storage: Add support for type 'inet' in virStorageSourceParseBackingJSONSocketAddress
    
    'SocketAddress' structure was changed to contain 'inet' instead of
    'tcp' since qemu commit c5f1ae3ae7b. Existing entries have a backward
    compatibility layer.


commit 4fac5a1935041254964313ed722fa8d59f8fa2de
Author: Peter Krempa <pkrempa>
Date:   Thu Jun 15 17:44:18 2017 +0200

    util: storage: adapt to changes in JSON format for ceph/rbd
    
    Since qemu 2.9 the options changed from a monolithic string into fine
    grained options for the json pseudo-protocol object.

Comment 6 Han Han 2017-06-21 07:56:29 UTC
Hi Peter,
Please add the patches 'util: storage: adapt to changes in JSON format for sheepdog' because libvirt also couldn't recognize the new json format in sheepdog.

Comment 7 Peter Krempa 2017-06-21 08:08:05 UTC
Well, here is the rest of the upstream commits not mentioned above:

commit b16133b114fd0d787de1cda6bf2ff0110c523a32
Author: Peter Krempa <pkrempa>
Date:   Thu Jun 15 17:44:18 2017 +0200

    util: storage: adapt to changes in JSON format for sheepdog
    
    Since qemu 2.9 the options changed from a monolithic string into fine
    grained options for the json pseudo-protocol object.

commit ea2c418ac30628d1db021f351f0ea5440ba5e4e4
Author: Peter Krempa <pkrempa>
Date:   Thu Jun 15 17:44:18 2017 +0200

    util: storage: adapt to changes in JSON format for ssh
    
    Since qemu 2.9 the options changed from a monolithic string into fine
    grained options for the json pseudo-protocol object.

commit 35d23f90b2266adb93079755161515699a401932
Author: Peter Krempa <pkrempa>
Date:   Thu Jun 15 17:44:18 2017 +0200

    util: storage: adapt to changes in JSON format for NBD
    
    Since 2.9 the host and port for NBD are no longer directly under the
    json pseudo-protocol object, but rather belong to a sub-object called
    'server'.

commit b24bc54080b4bc444e60560c0db00c5867e74000
Author: Peter Krempa <pkrempa>
Date:   Thu Jun 15 17:12:01 2017 +0200

    util: storage: Add JSON parser for new options in iSCSI protocol
    
    Starting from qemu 2.9, more granular options are supported. Add parser
    for the relevant bits.
    
    With this patch libvirt is able to parse the host and target IQN of from
    the JSON pseudo-protocol specification.
    
    This corresponds to BlockdevOptionsIscsi in qemu qapi.

Comment 9 Han Han 2017-11-10 09:09:04 UTC
Verified on qemu-kvm-rhev-2.10.0-5.el7.x86_64 libvirt-3.9.0-1.el7.x86_64

##################################################
Prepare json backing images
####################
1. On rbd protocol
Build ceph server environment

i. with "conf" key
Prepare a ceoh conf file:
# cat /tmp/ceph.conf
[global]
fsid = ab720744-845c-4f18-bd3c-fa61d62f0840
mon_initial_members = mon, osd1, osd2
mon_host = XX.XX.XX.XX,XX.XX.XX.XX,XX.XX.XX.XX
auth_cluster_required = none 
auth_service_required = none
auth_client_required = none
filestore_xattr_use_omap = true

# qemu-img create -b 'json:{"file": { "driver": "rbd", "pool": "rbd", "image": "lmen.img","conf": "/tmp/ceph.conf" } }' -f qcow2 /var/lib/libvirt/images/ceph-conf.qcow2
Formatting '/var/lib/libvirt/images/ceph-conf.qcow2', fmt=qcow2 size=104857600 backing_file=json:{"file": { "driver": "rbd",, "pool": "rbd",, "image": "lmen.img",,"conf": "/tmp/ceph.conf" } } cluster_size=65536 lazy_refcounts=off refcount_bits=16

ii. with "server" key
# qemu-img create -b 'json:{"file": { "driver": "rbd", "pool": "rbd", "image": "lmen.img", "server": [{"host": "XX.XX.XX.XX", "port": "6789"}] } }' -f qcow2 /var/lib/libvir
t/images/ceph-server.qcow2
Formatting '/var/lib/libvirt/images/ceph-server.qcow2', fmt=qcow2 size=104857600 backing_file=json:{"file": { "driver": "rbd",, "pool": "rbd",, "image": "lmen.img",, "serve
r": [{"host": "XX.XX.XX.XX",, "port": "6789"}] } } cluster_size=65536 lazy_refcounts=off refcount_bits=16

iii. with snapshot
# qemu-img create -b 'json:{"file": { "driver": "rbd", "pool": "rbd", "image": "lmen.img","conf": "/tmp/ceph.conf", "snapshot": "sn1" } }' -f qcow2 /var/lib/libvirt/images/ceph-server-snap.qcow2
Formatting '/var/lib/libvirt/images/ceph-server-snap.qcow2', fmt=qcow2 size=104857600 backing_file=json:{"file": { "driver": "rbd",, "pool": "rbd",, "image": "lmen.img",,"conf": "/tmp/ceph.conf",, "snapshot": "sn1" } } cluster_size=65536 lazy_refcounts=off refcount_bits=16


2. On sheepdog protocol:
Build sheepdog server

# qemu-img create -b 'json:{"file":{"driver":"sheepdog","server":{"host":"XX.XX.XX.XX","port":"7000","type":"inet"},"tag":"","vdi":"Alice"}}' -f qcow2 /var/lib/libvirt/images/sheepdog.qcow2
Formatting '/var/lib/libvirt/images/sheepdog.qcow2', fmt=qcow2 size=5368709120 backing_file=json:{"file":{"driver":"sheepdog",,"server":{"host":"XX.XX.XX.XX",,"port":"7000",,"type":"inet"},,"tag":"",,"vdi":"Alice"}} cluster_size=65536 lazy_refcounts=off refcount_bits=16

3. On ssh protocol:
# eval ssh-agent
# ssh-add /root/.ssh/id_rsa
Identity added: /root/.ssh/id_rsa (/root/.ssh/id_rsa)

# qemu-img create -b 'json:{"file":{"driver":"ssh","server":{"host":"XX.XX.XX.XX","port":"22"},"path":"/tmp/ssh","user":"root","host_key_check":"no"}}' -f qcow2 /var/lib/libvirt/images/ssh.qcow2
Formatting '/var/lib/libvirt/images/ssh.qcow2', fmt=qcow2 size=104857600 backing_file=json:{"file":{"driver":"ssh",,"server":{"host":"XX.XX.XX.XX",,"port":"22"},,"path":"/tmp/ssh",,"user":"root",,"host_key_check":"no"}} cluster_size=65536 lazy_refcounts=off refcount_bits=16

4. On nbd protocol:
Setup nbd server, one with exportname, one without exportname

# qemu-img create -b 'json:{"file":{"driver":"nbd","server":{"host":"XX.XX.XX.XX","port":"10000", "type":"inet"}}}' -f qcow2 /var/lib/libvirt/images/nbd.qcow2
Formatting '/var/lib/libvirt/images/nbd.qcow2', fmt=qcow2 size=1073741824 backing_file=json:{"file":{"driver":"nbd",,"server":{"host":"XX.XX.XX.XX",,"port":"10000",, "type":"inet"}}} cluster_size=65536 lazy_refcounts=off refcount_bits=16

# qemu-img create -b 'json:{"file":{"driver":"nbd","server":{"host":"XX.XX.XX.XX","port":"10001", "type":"inet"}, "export": "nbd"}}' -f qcow2 /var/lib/libvirt/images/nbd-export.qcow2
Formatting '/var/lib/libvirt/images/nbd-export.qcow2', fmt=qcow2 size=1073741824 backing_file=json:{"file":{"driver":"nbd",,"server":{"host":"XX.XX.XX.XX",,"port":"10001",, "type":"inet"},, "export": "nbd"}} cluster_size=65536 lazy_refcounts=off refcount_bits=16

5. On iscsi protocol:
Setup iscsi server

# qemu-img create -b 'json:{"file":{"driver":"iscsi", "transport": "tcp", "portal": "XX.XX.XX.XX:3260", "target": "iqn.2017-08.com.virttest:emulated-iscsi-noauth.target1"}}' -f qcow2 /var/lib/libvirt/images/iscsi.qcow2
Formatting '/var/lib/libvirt/images/iscsi.qcow2', fmt=qcow2 size=0 backing_file=json:{"file":{"driver":"iscsi",, "transport": "tcp",, "portal": "XX.XX.XX.XX:3260",, "target": "iqn.2017-08.com.virttest:emulated-iscsi-noauth.target1"}} cluster_size=65536 lazy_refcounts=off refcount_bits=16

##################################################
Pool refresh
####################
Refresh the pool where images are located in
# virsh pool-dumpxml default                                          
<pool type='dir'>
  <name>default</name>
  <uuid>03a38a8d-a7fc-4f6a-be13-b9c4b6935758</uuid>
  <capacity unit='bytes'>107347968000</capacity>
  <allocation unit='bytes'>40656568320</allocation>
  <available unit='bytes'>66691399680</available>
  <source>
  </source>
  <target>
    <path>/var/lib/libvirt/images</path>
    <permissions>
      <mode>0711</mode>
      <owner>0</owner>
      <group>0</group>
      <label>system_u:object_r:virt_image_t:s0</label>
    </permissions>
  </target>
</pool>

# virsh pool-refresh default                                                             
Pool default refreshed

Pool refresh operation works well.

##################################################
Attach/detach backing images
####################
Images backing on rbd, nbd, iscsi supports attach/detach operations

# virsh list
 Id    Name                           State
----------------------------------------------------
 2     V                              running

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

# virsh attach-disk V /var/lib/libvirt/images/ceph-server.qcow2 vdc --subdriver qcow2
Disk attached successfully

# virsh attach-disk V /var/lib/libvirt/images/ceph-server-snap.qcow2 vdd --subdriver qcow2
Disk attached successfully

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

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

# virsh attach-disk V /var/lib/libvirt/images/iscsi.qcow2 vdg --subdriver qcow2
Disk attached successfully

# virsh domblklist V
Target     Source
------------------------------------------------
vda        /var/lib/libvirt/images/V.qcow2
vdb        /var/lib/libvirt/images/ceph-conf.qcow2
vdc        /var/lib/libvirt/images/ceph-server.qcow2
vdd        /var/lib/libvirt/images/ceph-server-snap.qcow2
vde        /var/lib/libvirt/images/nbd.qcow2
vdf        /var/lib/libvirt/images/nbd-export.qcow2
vdg        /var/lib/libvirt/images/iscsi.qcow2

# virsh domstats V
Domain: 'V'
  state.state=1
  state.reason=1
  cpu.time=26280337141
  cpu.user=2470000000
  cpu.system=4630000000
  balloon.current=1048576
  balloon.maximum=1048576
  balloon.swap_in=0
  balloon.swap_out=0
  balloon.major_fault=194
  balloon.minor_fault=174428
  balloon.unused=899064
  balloon.available=1016140
  balloon.usable=848020
  balloon.last-update=1510294598
  balloon.rss=493100
  vcpu.current=1
  vcpu.maximum=1
  vcpu.0.state=1
  vcpu.0.time=20610000000
  vcpu.0.wait=0
  vcpu.0.halted=yes
  net.count=1
  net.0.name=vnet0
  net.0.rx.bytes=2461498
  net.0.rx.pkts=32506
  net.0.rx.errs=0
  net.0.rx.drop=0
  net.0.tx.bytes=26284
  net.0.tx.pkts=353
  net.0.tx.errs=0
  net.0.tx.drop=0
  block.count=7
  block.0.name=vda
  block.0.path=/var/lib/libvirt/images/V.qcow2
  block.0.rd.reqs=5436
  block.0.rd.bytes=134632960
  block.0.rd.times=20979604363
  block.0.wr.reqs=879
  block.0.wr.bytes=15651328
  block.0.wr.times=701348343
  block.0.fl.reqs=325
  block.0.fl.times=5570312840
  block.0.allocation=1091702784
  block.0.capacity=10737418240
  block.0.physical=1336868864
  block.1.name=vdb
  block.1.path=/var/lib/libvirt/images/ceph-conf.qcow2
  block.1.rd.reqs=45
  block.1.rd.bytes=1069056
  block.1.rd.times=4312097
  block.1.wr.reqs=0
  block.1.wr.bytes=0
  block.1.wr.times=0
  block.1.fl.reqs=0
  block.1.fl.times=0
  block.1.allocation=0
  block.1.capacity=104857600
  block.1.physical=200704
  block.2.name=vdc
  block.2.path=/var/lib/libvirt/images/ceph-server.qcow2
  block.2.rd.reqs=45
  block.2.rd.bytes=1069056
  block.2.rd.times=4373913
  block.2.wr.reqs=0
  block.2.wr.bytes=0
  block.2.wr.times=0
  block.2.fl.reqs=0
  block.2.fl.times=0
  block.2.allocation=0
  block.2.capacity=104857600
  block.2.physical=200704
  block.3.name=vdd                                                                                                                                                                                                                                                                                                                                                               [139/785]
  block.3.path=/var/lib/libvirt/images/ceph-server-snap.qcow2
  block.3.rd.reqs=45
  block.3.rd.bytes=1069056
  block.3.rd.times=2498727
  block.3.wr.reqs=0
  block.3.wr.bytes=0
  block.3.wr.times=0
  block.3.fl.reqs=0
  block.3.fl.times=0
  block.3.allocation=0
  block.3.capacity=104857600
  block.3.physical=200704
  block.4.name=vde
  block.4.path=/var/lib/libvirt/images/nbd.qcow2
  block.4.rd.reqs=45
  block.4.rd.bytes=1069056
  block.4.rd.times=146089292
  block.4.wr.reqs=0
  block.4.wr.bytes=0
  block.4.wr.times=0
  block.4.fl.reqs=0
  block.4.fl.times=0
  block.4.allocation=0
  block.4.capacity=1073741824
  block.4.physical=200704
  block.5.name=vdf
  block.5.path=/var/lib/libvirt/images/nbd-export.qcow2
  block.5.rd.reqs=42
  block.5.rd.bytes=1015808
  block.5.rd.times=45997635
  block.5.wr.reqs=0
  block.5.wr.bytes=0
  block.5.wr.times=0
  block.5.fl.reqs=0
  block.5.fl.times=0
  block.5.allocation=0
  block.5.capacity=1073741824
  block.5.physical=200704
  block.6.name=vdg
  block.6.path=/var/lib/libvirt/images/iscsi.qcow2
  block.6.rd.reqs=0
  block.6.rd.bytes=0
  block.6.rd.times=0
  block.6.wr.reqs=0
  block.6.wr.bytes=0
  block.6.wr.times=0
  block.6.fl.reqs=0
  block.6.fl.times=0
  block.6.allocation=0
  block.6.physical=196608

# virsh detach-disk V /var/lib/libvirt/images/ceph-conf.qcow2
Disk detached successfully

# virsh detach-disk V /var/lib/libvirt/images/ceph-server.qcow2
Disk detached successfully

# virsh detach-disk V /var/lib/libvirt/images/ceph-server-snap.qcow2
Disk detached successfully

# virsh detach-disk V /var/lib/libvirt/images/nbd.qcow2
Disk detached successfully

# virsh detach-disk V /var/lib/libvirt/images/nbd-export.qcow2
Disk detached successfully

# virsh detach-disk V /var/lib/libvirt/images/iscsi.qcow2
Disk detached successfully

Attach/detach works well.

Bug fixed.

Comment 13 errata-xmlrpc 2018-04-10 10:44:33 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-2018:0704


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