Bug 1540022

Summary: Fail to dump vol xml of json backing images
Product: Red Hat Enterprise Linux 7 Reporter: Han Han <hhan>
Component: libvirtAssignee: Peter Krempa <pkrempa>
Status: CLOSED ERRATA QA Contact: Han Han <hhan>
Severity: high Docs Contact:
Priority: high    
Version: 7.5CC: dyuan, jiyan, lmen, lmiksik, mtessun, pkrempa, rbalakri, xuzhang, yisun
Target Milestone: rcKeywords: Regression
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: libvirt-3.9.0-10.el7 Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of:
: 1540136 (view as bug list) Environment:
Last Closed: 2018-04-10 11:04:21 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:    
Bug Blocks: 1539427, 1540136, 1664924    
Attachments:
Description Flags
The log of step3 none

Description Han Han 2018-01-30 05:59:56 UTC
Created attachment 1388151 [details]
The log of step3

Description of problem:
As subject

Version-Release number of selected component (if applicable):
libvirt-3.9.0-9.el7.x86_64
qemu-kvm-rhev-2.10.0-18.el7.x86_64

How reproducible:
100%

Steps to Reproduce:
1. Prepare a running dir storage pool:
# virsh pool-list 
 Name                 State      Autostart 
-------------------------------------------    
 default              active     no  

# virsh pool-dumpxml default               
<pool type='dir'>
  <name>default</name>
  <uuid>03a38a8d-a7fc-4f6a-be13-b9c4b6935758</uuid>
  <capacity unit='bytes'>150297640960</capacity>
  <allocation unit='bytes'>108864774144</allocation>
  <available unit='bytes'>41432866816</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>

2. Create a json backing image with http backend and refresh the pool
# qemu-img create -f qcow2 -b 'json:{"file.driver":"http","file.url":"http://ftp.sjtu.edu.cn/ubuntu-cd/12.04/ubuntu-12.04.5-alternate-amd64.iso"}' /var/lib/libvirt/images/http.img -o backing_fmt=raw
Formatting '/var/lib/libvirt/images/http.img', fmt=qcow2 size=797966336 backing_file=json:{"file.driver":"http",,"file.url":"http://ftp.sjtu.edu.cn/ubuntu-cd/12.04/ubuntu-12.04.5-alternate-amd64.iso"} backing_fmt=raw cluster_size=65536 lazy_refcounts=off refcount_bits=16

# virsh pool-refresh default
Pool default refreshed

3. dump vol xml of the image
# virsh vol-dumpxml http.img --pool default
error: An error occurred, but the cause is unknown


Actual results:
As step3

Expected results:
Dump the vol xml.

Additional info:

Comment 2 Han Han 2018-01-30 06:26:28 UTC
It works on libvirt-3.2.0-14.el7_4.9.x86_64 qemu-kvm-rhev-2.9.0-16.el7_4.14.x86_64:
# qemu-img info /var/lib/libvirt/images/http.img
image: /var/lib/libvirt/images/http.img
file format: qcow2
virtual size: 761M (797966336 bytes)
disk size: 196K
cluster_size: 65536
backing file: json:{"file.driver":"http","file.url":"http://ftp.sjtu.edu.cn/ubuntu-cd/12.04/ubuntu-12.04.5-alternate-amd64.iso"}
backing file format: raw
Format specific information:
    compat: 1.1
    lazy refcounts: false
    refcount bits: 16
    corrupt: false

# virsh vol-dumpxml --pool default http.img
<volume type='file'>
  <name>http.img</name>
  <key>/var/lib/libvirt/images/http.img</key>
  <source>
  </source>
  <capacity unit='bytes'>797966336</capacity>
  <allocation unit='bytes'>200704</allocation>
  <physical unit='bytes'>196624</physical>
  <target>
    <path>/var/lib/libvirt/images/http.img</path>
    <format type='qcow2'/>
    <permissions>
      <mode>0644</mode>
      <owner>0</owner>
      <group>0</group>
      <label>unconfined_u:object_r:virt_image_t:s0</label>
    </permissions>
    <timestamps>
      <atime>1517293323.129138576</atime>
      <mtime>1517293310.520066855</mtime>
      <ctime>1517293310.520066855</ctime>
    </timestamps>
    <compat>1.1</compat>
    <features/>
  </target>
  <backingStore>
    <path>json:{&quot;file.driver&quot;:&quot;http&quot;,&quot;file.url&quot;:&quot;http://ftp.sjtu.edu.cn/ubuntu-cd/12.04/ubuntu-12.04.5-alternate-amd64.iso&quot;}</path>
    <format type='raw'/>
  </backingStore>
</volume>

Comment 4 Peter Krempa 2018-01-30 10:53:31 UTC
(In reply to Han Han from comment #2)

[...]

>   <backingStore>
>    
> <path>json:{&quot;file.driver&quot;:&quot;http&quot;,&quot;file.url&quot;:
> &quot;http://ftp.sjtu.edu.cn/ubuntu-cd/12.04/ubuntu-12.04.5-alternate-amd64.
> iso&quot;}</path>

This is still wrong. I cloned this bug as https://bugzilla.redhat.com/show_bug.cgi?id=1540136 to track that part.

Comment 5 Peter Krempa 2018-01-30 12:02:23 UTC
Failure to print the XML when the backing volume is described by JSON string or inacessible was fixed upstream:

commit b2c5f28a72465bf047311828c8c66112c8ca84e5 
Author: Peter Krempa <pkrempa>
Date:   Tue Jan 30 11:41:59 2018 +0100

    storage: util: Properly ignore errors when backing volume is inaccessible
    
    Commit 000e9504559 tried to fix improper bracketing when refreshing disk
    volume stats for a backing volume. Unfortunately the condition is still
    wrong as in cases as the backing store being inaccessible
    storageBackendUpdateVolTargetInfo returns -2 if instructed to ignore
    errors. The condition does not take this into account.
    
    Dumping XML of a volume which has inacessible backing store would then
    result into:
    
     # virsh vol-dumpxml http.img --pool default
     error: An error occurred, but the cause is unknown
    
    Properly ignore -2 for backing volumes.

Comment 8 Han Han 2018-02-01 06:12:53 UTC
Verified on libvirt-3.9.0-10.el7.x86_64 qemu-kvm-rhev-2.10.0-18.el7.x86_64:
SC1: Verified on raw backed image
1. Create a json backing image with http backend and refresh the pool
# qemu-img create -f qcow2 -b 'json:{"file.driver":"http","file.url":"http://ftp.sjtu.edu.cn/ubuntu-cd/12.04/ubuntu-12.04.5-alternate-amd64.iso"}' /var/lib/libvirt/images/http.img -o backing_fmt=raw
Formatting '/var/lib/libvirt/images/http.img', fmt=qcow2 size=797966336 backing_file=json:{"file.driver":"http",,"file.url":"http://ftp.sjtu.edu.cn/ubuntu-cd/12.04/ubuntu-12.04.5-alternate-amd64.iso"} backing_fmt=raw cluster_size=65536 lazy_refcounts=off refcount_bits=16

# virsh pool-refresh default
Pool default refreshed

2. Dump the volume xml of backing image:
# virsh vol-dumpxml --pool default http.img      
<volume type='file'>
  <name>http.img</name>
  <key>/var/lib/libvirt/images/http.img</key>
  <source>
  </source>
  <capacity unit='bytes'>797966336</capacity>
  <allocation unit='bytes'>200704</allocation>
  <physical unit='bytes'>196624</physical>
  <target>
    <path>/var/lib/libvirt/images/http.img</path>
    <format type='qcow2'/>
    <permissions>
      <mode>0644</mode>
      <owner>0</owner>
      <group>0</group>
      <label>unconfined_u:object_r:virt_image_t:s0</label>
    </permissions>
    <timestamps>
      <atime>1517465148.440388257</atime>
      <mtime>1517465148.440388257</mtime>
      <ctime>1517465148.440388257</ctime>
    </timestamps>
    <compat>1.1</compat>
    <features/>
  </target>
  <backingStore>
    <path>json:{&quot;file.driver&quot;:&quot;http&quot;,&quot;file.url&quot;:&quot;http://ftp.sjtu.edu.cn/ubuntu-cd/12.04/ubuntu-12.04.5-alternate-amd64.iso&quot;}</path>
    <format type='raw'/>
  </backingStore>
</volume>


SC2: Verified on raw backed image
1. Create a json backing image with http backend and refresh the pool
# qemu-img create -f qcow2 -b 'json:{"file.driver":"http","file.url":"http://xx.xx.xx.xx/libvirt-CI-resources/RHEL-7.5-x86_64-latest.qcow2"}' /var/lib/libvirt/images/http_qcow2.img -o backing_fmt=qcow2
Formatting '/var/lib/libvirt/images/http_qcow2.img', fmt=qcow2 size=10737418240 backing_file=json:{"file.driver":"http",,"file.url":"http://xx.xx.xx.xx/libvirt-CI-resources/RHEL-7.5-x86_64-latest.qcow2"} backing_fmt=qcow2 cluster_size=65536 lazy_refcounts=off refcount_bits=16

# virsh pool-refresh default
Pool default refreshed

2. Dump the volume xml of backing image:
# virsh vol-dumpxml --pool default http_qcow2.img
<volume type='file'>
  <name>http_qcow2.img</name>
  <key>/var/lib/libvirt/images/http_qcow2.img</key>
  <source>
  </source>
  <capacity unit='bytes'>10737418240</capacity>
  <allocation unit='bytes'>200704</allocation>
  <physical unit='bytes'>196768</physical>
  <target>
    <path>/var/lib/libvirt/images/http_qcow2.img</path>
    <format type='qcow2'/>
    <permissions>
      <mode>0644</mode>
      <owner>0</owner>
      <group>0</group>
      <label>unconfined_u:object_r:virt_image_t:s0</label>
    </permissions>
    <timestamps>
      <atime>1517465440.967904362</atime>
      <mtime>1517465297.359669149</mtime>
      <ctime>1517465297.359669149</ctime>
    </timestamps>
    <compat>1.1</compat>
    <features/>
  </target>
  <backingStore>
    <path>json:{&quot;file.driver&quot;:&quot;http&quot;,&quot;file.url&quot;:&quot;http://xx.xx.xx.xx/libvirt-CI-resources/RHEL-7.5-x86_64-latest.qcow2&quot;}</path>
    <format type='raw'/>
  </backingStore>
</volume>

Though the backingStore foramt is not correct, the issue will be tracked on BZ1540136

Comment 12 errata-xmlrpc 2018-04-10 11:04:21 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