Bug 1776747 - 'qemu-img create' should restrict the 'size' input while there is both '-o size' and size value at the last argument
Summary: 'qemu-img create' should restrict the 'size' input while there is both '-o si...
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Enterprise Linux Advanced Virtualization
Classification: Red Hat
Component: qemu-kvm
Version: 8.2
Hardware: Unspecified
OS: Unspecified
low
low
Target Milestone: rc
: ---
Assignee: Kevin Wolf
QA Contact: Xueqiang Wei
URL:
Whiteboard:
Depends On:
Blocks: 1849930
TreeView+ depends on / blocked
 
Reported: 2019-11-26 10:04 UTC by Tingting Mao
Modified: 2020-11-17 17:46 UTC (History)
7 users (show)

Fixed In Version: qemu-kvm-5.0.0-0.module+el8.3.0+6620+5d5e1420
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
: 1849930 (view as bug list)
Environment:
Last Closed: 2020-11-17 17:45:34 UTC
Type: Bug
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)

Description Tingting Mao 2019-11-26 10:04:40 UTC
Description of problem:
As subject. Confirmed with Kevin Wolf via IRC. He agree that we can improve this issue. Thanks Kevin.


Version-Release number of selected component (if applicable):
qemu-kvm-4.2.0-1.module+el8.2.0+4793+b09dd2fb
kernel-4.18.0-148.el8


How reproducible:
100%


Steps to Reproduce:
For qcow2:
# qemu-img create -f qcow2 -o size=2G test.qcow2 3G
Formatting 'test.qcow2', fmt=qcow2 size=2147483648 cluster_size=65536 lazy_refcounts=off refcount_bits=16

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


For raw:
# qemu-img create -f raw -o size=2G test.img 3G
Formatting 'test.img', fmt=raw size=2147483648

# qemu-img info test.img 
image: test.img
file format: raw
virtual size: 2 GiB (2147483648 bytes)
disk size: 4 KiB


Actual results:
As above. Created with no error.


Expected results:
Maybe creating failed with prompt that can not input the size via '-o size' and at the last argument simultaneously?


Additional info:

Comment 1 Ademar Reis 2019-11-26 18:33:26 UTC
Looks like Kevin sent out a patch while I was editing this BZ. Reassigning:

Date: Tue, 26 Nov 2019 16:48:35 +0100
From: Kevin Wolf <kwolf>
Subject: [PATCH] block: Error out on image creation with conflicting size options
To: qemu-block
Cc: kwolf, qemu-devel

If both the create options (qemu-img create -o ...) and the size
parameter were given, the size parameter was silently ignored. Instead,
make specifying two sizes an error.

Signed-off-by: Kevin Wolf <kwolf>
---
 block.c                    | 10 ++++++++--
 tests/qemu-iotests/049     |  5 +++++
 tests/qemu-iotests/049.out |  5 +++++
 3 files changed, 18 insertions(+), 2 deletions(-)

Comment 2 Ademar Reis 2020-02-05 23:09:01 UTC
QEMU has been recently split into sub-components and as a one-time operation to avoid breakage of tools, we are setting the QEMU sub-component of this BZ to "General". Please review and change the sub-component if necessary the next time you review this BZ. Thanks

Comment 3 Kevin Wolf 2020-02-07 08:39:17 UTC
This is upstream commit f6dc1c31d3. Probably not worth a backport, so we'll get it by rebase.

Comment 6 Xueqiang Wei 2020-06-23 07:48:11 UTC
Also hit it on rhel8.2.1

versions:
kernel-4.18.0-193.1.2.el8_2.x86_64
qemu-kvm-4.2.0-26.module+el8.2.1+7079+67e06423

For qcow2:
# qemu-img create -f qcow2 -o size=2G test.qcow2 3G
Formatting 'test.qcow2', fmt=qcow2 size=2147483648 cluster_size=65536 lazy_refcounts=off refcount_bits=16
# qemu-img info test.qcow2 
image: test.qcow2
file format: qcow2
virtual size: 2 GiB (2147483648 bytes)
disk size: 196 KiB
cluster_size: 65536
Format specific information:
    compat: 1.1
    lazy refcounts: false
    refcount bits: 16
    corrupt: false

For raw:
# qemu-img create -f raw -o size=2G test.img 3G
Formatting 'test.img', fmt=raw size=2147483648
# qemu-img info test.img 
image: test.img
file format: raw
virtual size: 2 GiB (2147483648 bytes)
disk size: 4 KiB


For luks:
# qemu-img create -f luks --object secret,id=sec0,data=redhat  -o key-secret=sec0,size=2G  base.luks 3G
Formatting 'base.luks', fmt=luks size=2147483648 key-secret=sec0
# qemu-img info base.luks 
image: base.luks
file format: luks
virtual size: 2 GiB (2147483648 bytes)
disk size: 256 KiB
encrypted: yes
Format specific information:
    ivgen alg: plain64
    hash alg: sha256
    cipher alg: aes-256
    uuid: f62a42ea-0e6b-421e-80e8-36b507283c08
    cipher mode: xts
    slots:
        [0]:
            active: true
            iters: 1141742
            key offset: 4096
            stripes: 4000
        [1]:
            active: false
            key offset: 262144
        [2]:
            active: false
            key offset: 520192
        [3]:
            active: false
            key offset: 778240
        [4]:
            active: false
            key offset: 1036288
        [5]:
            active: false
            key offset: 1294336
        [6]:
            active: false
            key offset: 1552384
        [7]:
            active: false
            key offset: 1810432
    payload offset: 2068480
    master key iters: 286007

Comment 7 Xueqiang Wei 2020-06-23 08:04:08 UTC
Tested it on rhel8.3.0 fast train, not hit this issue.

Versions:
kernel-4.18.0-209.el8.x86_64
qemu-kvm-5.0.0-0.module+el8.3.0+6620+5d5e1420


For qcow2:
# qemu-img create -f qcow2 -o size=2G test.qcow2 3G
qemu-img: test.qcow2: The image size must be specified only once

For raw:
# qemu-img create -f raw -o size=2G test.img 3G
qemu-img: test.img: The image size must be specified only once

For luks:
# qemu-img create -f luks --object secret,id=sec0,data=redhat  -o key-secret=sec0,size=2G  base.luks 3G
qemu-img: base.luks: The image size must be specified only once

Comment 10 Xueqiang Wei 2020-06-30 05:51:38 UTC
According to Comment 7, set status to VERIFIED. Thanks.

Comment 13 errata-xmlrpc 2020-11-17 17:45:34 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 (virt:8.3 bug fix and enhancement update), 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/RHBA-2020:5137


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