Bug 1811877

Summary: 'qemu-img create' snapshot files should restrict the options for backing files
Product: Red Hat Enterprise Linux 9 Reporter: Tingting Mao <timao>
Component: qemu-kvmAssignee: Virtualization Maintenance <virt-maint>
qemu-kvm sub component: Storage QA Contact: Tingting Mao <timao>
Status: CLOSED WONTFIX Docs Contact:
Severity: low    
Priority: low CC: coli, jinzhao, juzhang, kwolf, virt-maint, xuwei
Version: 9.0Keywords: Triaged
Target Milestone: rc   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2021-09-10 07:27:15 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:

Description Tingting Mao 2020-03-10 02:44:36 UTC
Description of problem:
As subject.


Version-Release number of selected component (if applicable):
qemu-kvm-4.2.0-13.module+el8.2.0+5898+fb4bceae
kernel-4.18.0-176.el8


How reproducible:
100%


Steps to Reproduce:
Steps:
1. Create a base image.
# qemu-img create -f raw base.img 2G

2. Create snapshot file based on the image with both '-F' and '-o backing_fmt'.
# qemu-img create -f qcow2 -b base.img -F raw -o backing_fmt=raw sn.qcow2
Formatting 'sn.qcow2', fmt=qcow2 size=2147483648 backing_file=base.img backing_fmt=raw cluster_size=65536 lazy_refcounts=off refcount_bits=16

# echo $?
0

# qemu-img info sn.qcow2 
image: sn.qcow2
file format: qcow2
virtual size: 2 GiB (2147483648 bytes)
disk size: 196 KiB
cluster_size: 65536
backing file: base.img
backing file format: raw
Format specific information:
    compat: 1.1
    lazy refcounts: false
    refcount bits: 16
    corrupt: false

3. Create snapshot file based on the image with both '-b' and '-o backing_file'.
# qemu-img create -f qcow2 -b base.img -F raw -o backing_file=base.img sn.qcow2
Formatting 'sn.qcow2', fmt=qcow2 size=2147483648 backing_file=base.img backing_fmt=raw cluster_size=65536 lazy_refcounts=off refcount_bits=16

# echo $?
0

# qemu-img info sn.qcow2 
image: sn.qcow2
file format: qcow2
virtual size: 2 GiB (2147483648 bytes)
disk size: 196 KiB
cluster_size: 65536
backing file: base.img
backing file format: raw
Format specific information:
    compat: 1.1
    lazy refcounts: false
    refcount bits: 16
    corrupt: false

4. Create snapshot file based on the image with both '-b', '-F' and '-o backing_file,backing_fmt'.
# qemu-img create -f qcow2 -b base.img -F raw -o backing_file=base.img,backing_fmt=raw sn.qcow2
Formatting 'sn.qcow2', fmt=qcow2 size=2147483648 backing_file=base.img backing_fmt=raw cluster_size=65536 lazy_refcounts=off refcount_bits=16

# echo $?
0

# qemu-img info sn.qcow2 
image: sn.qcow2
file format: qcow2
virtual size: 2 GiB (2147483648 bytes)
disk size: 196 KiB
cluster_size: 65536
backing file: base.img
backing file format: raw
Format specific information:
    compat: 1.1
    lazy refcounts: false
    refcount bits: 16
    corrupt: false


Actual results:
As above. when '-F xx -b xx' and '-o' appear together, there is no error hint info.


Expected results:
Maybe creating failed with prompt "Can not input '-F xx -b xx' and '-o backing_fmt=xx,backing_file=xx' simultaneously"?


Additional info:
"-b xxx -F" part makes work when '-F xx -b xx' and '-o' appear together. 
# qemu-img create -f qcow2 -b base.img -F raw -o backing_file=xxxxx,backing_fmt=xxx sn.qcow2
Formatting 'sn.qcow2', fmt=qcow2 size=2147483648 backing_file=base.img backing_fmt=raw cluster_size=65536 lazy_refcounts=off refcount_bits=16

# echo $?
0

# qemu-img info sn.qcow2 
image: sn.qcow2
file format: qcow2
virtual size: 2 GiB (2147483648 bytes)
disk size: 196 KiB
cluster_size: 65536
backing file: base.img
backing file format: raw
Format specific information:
    compat: 1.1
    lazy refcounts: false
    refcount bits: 16
    corrupt: false

# qemu-img create -f qcow2 -b xxx -F xxx -o backing_file=base.img,backing_fmt=raw sn.qcow2
qemu-img: sn.qcow2: Unknown driver 'xxx'
Could not open backing image to determine size.
# echo $?
1

Comment 4 John Ferlan 2021-09-08 21:38:57 UTC
Move RHEL-AV bugs to RHEL9. If necessary to resolve in RHEL8, then clone to the current RHEL8 release.

Comment 5 RHEL Program Management 2021-09-10 07:27:15 UTC
After evaluating this issue, there are no plans to address it further or fix it in an upcoming release.  Therefore, it is being closed.  If plans change such that this issue will be fixed in an upcoming release, then the bug can be reopened.