Bug 1171007 - RFE: support qcow2 format image creation when the backend is rbd server
Summary: RFE: support qcow2 format image creation when the backend is rbd server
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Enterprise Linux Advanced Virtualization
Classification: Red Hat
Component: qemu-kvm
Version: ---
Hardware: x86_64
OS: All
medium
high
Target Milestone: rc
: ---
Assignee: Stefano Garzarella
QA Contact: Tingting Mao
URL:
Whiteboard:
: 1642304 (view as bug list)
Depends On: 1171005
Blocks: 1200230 1558351
TreeView+ depends on / blocked
 
Reported: 2014-12-05 09:29 UTC by Jun Li
Modified: 2019-11-06 07:11 UTC (History)
21 users (show)

Fixed In Version: qemu-kvm-4.1.0-1.module+el8.1.0+3966+4a23dca1
Doc Type: Enhancement
Doc Text:
Clone Of: 1171005
: 1200230 1642304 (view as bug list)
Environment:
Last Closed: 2019-11-06 07:10:39 UTC
Type: Feature Request
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Red Hat Product Errata RHBA-2019:3723 0 None None None 2019-11-06 07:11:24 UTC

Description Jun Li 2014-12-05 09:29:36 UTC
+++ This bug was initially created as a clone of Bug #1171005 +++

Description of problem:
qemu-img can not create qcow2 format image when backend is rbd server.

Version-Release number of selected component (if applicable):
qemu-kvm-1.5.3-83.el7.x86_64

How reproducible:
100%

Steps to Reproduce:
1.create qcow2 format image via qemu-img.
# qemu-img create -f qcow2 rbd:qemu-kvm-pool/juli-test30.qcow2:mon_host=$IP 10M
2.
3.

Actual results:
After step1, qemu-img will give error message and can not create a correct qcow2 format image.
# qemu-img create -f qcow2 rbd:qemu-kvm-pool/juli-test30.qcow2:mon_host=$IP 10M
Formatting 'rbd:qemu-kvm-pool/juli-test30.qcow2:mon_host=$IP', fmt=qcow2 size=10485760 encryption=off cluster_size=65536 lazy_refcounts=off 
qemu-img: rbd:qemu-kvm-pool/juli-test30.qcow2:mon_host=$IP: Could not write qcow2 header: Input/output error

Expected results:
can create qcow2 image successfully.

Additional info:

Comment 1 Jun Li 2014-12-05 09:30:34 UTC
Version of components:
qemu-kvm-rhev-2.1.2-14.el7.x86_64

Comment 6 Ping Li 2017-03-14 10:02:24 UTC
Hi Kevin,

As the flag rhel-7.4.0? is set, qe wonder to know whether the issue will be fixed in rhel 7.4? Then qe can add it to RHEL 7.4 test plan for disk format. Thanks.

Comment 7 Kevin Wolf 2017-03-14 14:30:19 UTC
No, this is still not a priority, so upstream didn't add the functionality yet.

Comment 8 Longxiang Lyu 2017-11-17 09:27:14 UTC
I test the creation of qcow2 image on cephfs with preallocation mode, it succeeded.

# qemu-img create -f qcow2 -o preallocation=full rbd:kvm-test/test1.qcow2:mon_host=10.73.199.64 1G
Formatting 'rbd:kvm-test/test1.qcow2:mon_host=10.73.199.64', fmt=qcow2 size=1073741824 cluster_size=65536 preallocation=full lazy_refcounts=off refcount_bits=16
# qemu-img info rbd:kvm-test/test1.qcow2:mon_host=10.73.199.64
image: json:{"driver": "qcow2", "file": {"pool": "kvm-test", "image": "test1.qcow2", "driver": "rbd", "=keyvalue-pairs": "[\"mon_host\", \"10.73.199.64\"]"}}
file format: qcow2
virtual size: 1.0G (1073741824 bytes)
disk size: unavailable
cluster_size: 65536
Format specific information:
    compat: 1.1
    lazy refcounts: false
    refcount bits: 16
    corrupt: false

Comment 9 Xueqiang Wei 2018-01-26 10:14:39 UTC
I test the creation of qcow2 image on cephfs with preallocation=full, it succeeded. But with "luks-inside-qcow2", it is failed.

(1) preallocation=full, passed
# qemu-img create -f qcow2 -o preallocation=full  rbd:kvm-test/system.qcow2:mon_host=10.73.199.64 25G
Formatting 'rbd:kvm-test/system.qcow2:mon_host=10.73.199.64', fmt=qcow2 size=26843545600 cluster_size=65536 preallocation=full lazy_refcounts=off refcount_bits=16

(2) luks-inside-qcow2, failed
# qemu-img create --object secret,id=sec0,data=backing -f qcow2 -o encrypt.format=luks,encrypt.key-secret=sec0 rbd:kvm-test/system1.qcow2:mon_host=10.73.199.64 5G
Formatting 'rbd:kvm-test/system1.qcow2:mon_host=10.73.199.64', fmt=qcow2 size=5368709120 encrypt.format=luks encrypt.key-secret=sec0 cluster_size=65536 lazy_refcounts=off refcount_bits=16
qemu-img: rbd:kvm-test/system1.qcow2:mon_host=10.73.199.64: Could not write qcow2 header: Invalid argument

(3) preallocation=full + luks-inside-qcow2, failed 
# qemu-img create --object secret,id=sec0,data=backing -f qcow2 -o preallocation=full,encrypt.format=luks,encrypt.key-secret=sec0 rbd:kvm-test/system2.qcow2:mon_host=10.73.199.64 5G
Formatting 'rbd:kvm-test/system2.qcow2:mon_host=10.73.199.64', fmt=qcow2 size=5368709120 encrypt.format=luks encrypt.key-secret=sec0 cluster_size=65536 preallocation=full lazy_refcounts=off refcount_bits=16
qemu-img: rbd:kvm-test/system2.qcow2:mon_host=10.73.199.64: Could not preallocate metadata: Invalid argument 

(4) preallocation=metadata + luks-inside-qcow2, failed
# qemu-img create --object secret,id=sec0,data=backing -f qcow2 -o preallocation=metadata,encrypt.format=luks,encrypt.key-secret=sec0 rbd:kvm-test/system3.qcow2:mon_host=10.73.199.64 5G
Formatting 'rbd:kvm-test/system3.qcow2:mon_host=10.73.199.64', fmt=qcow2 size=5368709120 encrypt.format=luks encrypt.key-secret=sec0 cluster_size=65536 preallocation=metadata lazy_refcounts=off refcount_bits=16
qemu-img: rbd:kvm-test/system3.qcow2:mon_host=10.73.199.64: Could not write qcow2 header: Invalid argument

(5) preallocation=falloc + luks-inside-qcow2, failed
# qemu-img create --object secret,id=sec0,data=backing -f qcow2 -o preallocation=falloc,encrypt.format=luks,encrypt.key-secret=sec0 rbd:kvm-test/system4.qcow2:mon_host=10.73.199.64 5G
Formatting 'rbd:kvm-test/system4.qcow2:mon_host=10.73.199.64', fmt=qcow2 size=5368709120 encrypt.format=luks encrypt.key-secret=sec0 cluster_size=65536 preallocation=falloc lazy_refcounts=off refcount_bits=16
qemu-img: rbd:kvm-test/system4.qcow2:mon_host=10.73.199.64: Could not preallocate metadata: Invalid argument

(6) preallocation=off + luks-inside-qcow2, failed
# qemu-img create --object secret,id=sec0,data=backing -f qcow2 -o preallocation=off,encrypt.format=luks,encrypt.key-secret=sec0 rbd:kvm-test/system5.qcow2:mon_host=10.73.199.64 5G
Formatting 'rbd:kvm-test/system5.qcow2:mon_host=10.73.199.64', fmt=qcow2 size=5368709120 encrypt.format=luks encrypt.key-secret=sec0 cluster_size=65536 preallocation=off lazy_refcounts=off refcount_bits=16
qemu-img: rbd:kvm-test/system5.qcow2:mon_host=10.73.199.64: Could not write qcow2 header: Invalid argument

Comment 11 Ademar Reis 2019-02-06 17:56:29 UTC
*** Bug 1642304 has been marked as a duplicate of this bug. ***

Comment 12 Stefano Garzarella 2019-04-11 16:25:33 UTC
I proposed a patch upstream with a workaround to fix this issue, but Jason Dillaman [1] pointed out a good observation:
> What's the use-case for storing qcow2 images within a RBD image? RBD
> images are already thinly provisioned, they support snapshots, they
> can form a parent/child linked image hierarchy.

Do you have in mind some use cases?

One use case could be if you have a qcow2 image and you want to put it in the RBD pool without converting it, but I don't know if it is a practical use case.


[1] https://lists.gnu.org/archive/html/qemu-devel/2019-04/msg01870.html

Comment 13 Tingting Mao 2019-04-12 06:45:22 UTC
(In reply to Stefano Garzarella from comment #12)
> I proposed a patch upstream with a workaround to fix this issue, but Jason
> Dillaman [1] pointed out a good observation:
> > What's the use-case for storing qcow2 images within a RBD image? RBD
> > images are already thinly provisioned, they support snapshots, they
> > can form a parent/child linked image hierarchy.
> 
Honestly, I am not that clear about the snapshots within a RBD image. But after a simply test according to the official doc[1], I noticed that the snapshots created by 'rbd' command seems are internal snapshots, and work as Read-only? 

While for qcow2, we could use external snapshots. And we recommend users use external snapshots, which are more stable and maintained easier.

> Do you have in mind some use cases?

For qcow2, I think one of the most features is Copy-on-write, where the image only represents changes made to an underlying disk image. And optional compression and encryption. 


[1]http://docs.ceph.com/docs/giant/rbd/rbd-snapshot/

Comment 14 Jason Dillaman 2019-04-14 15:19:15 UTC
(In reply to Tingting Mao from comment #13)
> (In reply to Stefano Garzarella from comment #12)
> > I proposed a patch upstream with a workaround to fix this issue, but Jason
> > Dillaman [1] pointed out a good observation:
> > > What's the use-case for storing qcow2 images within a RBD image? RBD
> > > images are already thinly provisioned, they support snapshots, they
> > > can form a parent/child linked image hierarchy.
> > 
> Honestly, I am not that clear about the snapshots within a RBD image. But
> after a simply test according to the official doc[1], I noticed that the
> snapshots created by 'rbd' command seems are internal snapshots, and work as
> Read-only? 

Yes.

> While for qcow2, we could use external snapshots. And we recommend users use
> external snapshots, which are more stable and maintained easier.

You can create a snapshot and clone an image to a new copy-on-write image for such a use-case. It would be way more efficient that having to copy the entire base qcow2 image to a new backing RBD image.

> > Do you have in mind some use cases?
> 
> For qcow2, I think one of the most features is Copy-on-write, where the
> image only represents changes made to an underlying disk image. And optional
> compression and encryption. 

Ceph supports at-rest compression and you can run LUKS on top of an image to support encryption. Is there an actual end-user use-case here that I am missing?

> 
> [1]http://docs.ceph.com/docs/giant/rbd/rbd-snapshot/

Comment 15 Stefano Garzarella 2019-07-03 07:38:46 UTC
The patch that allows the creation of qcow2 with rbd backend is upstream:

commit d24f80234b39d2d5c0d91e63b5e4569d37b2399e
Author: Stefano Garzarella <sgarzare>
Date:   Thu May 9 16:59:27 2019 +0200

    block/rbd: increase dynamically the image size

    RBD APIs don't allow us to write more than the size set with
    rbd_create() or rbd_resize().
    In order to support growing images (eg. qcow2), we resize the
    image before write operations that exceed the current size.
    
    Signed-off-by: Stefano Garzarella <sgarzare>
    Message-id: 20190509145927.293369-1-sgarzare
    Signed-off-by: Max Reitz <mreitz>

Comment 20 Tingting Mao 2019-08-28 10:52:39 UTC
Verified this bug by regression test[1] - qcow2 with rbd. Besides below bugs, other functionality works well. So set this bug as verified. Thanks.

New/existed bugs:
Bug 1642332 - QEMU should refuse to boot a running image based on RBD
Bug 1514373 - RFE: support preallocation=falloc/full/off when create raw image on cephfs
Bug 1703923 - [upstream] Creating qcow2: external data file images over libiscsi fails
Bug 1745885 - 'qemu-img create' an overlay over RBD should look up the directory containing the overlay to find it's backing file
Bug 1746393 - There is some error msg in guest with qcow2 format over RBD after writing data in it


[1]https://polarion.engineering.redhat.com/polarion/#/project/RedHatEnterpriseLinux7/workitems?query=project.id%3ARedHatEnterpriseLinux7%20AND%20type%3Atestcase%20AND%20linkedWorkItems%3ARHEL%5C-113419%20AND%20(NOT%20TEST_RECORDS%3A(%22RedHatEnterpriseLinux7%2FVirtkvmqe-x86-qcow2-rbd-manual-qemu-kvm-4-1-0-4-module-el8-1-0-RHEL-8-1%22%2C%40any))&sidebar=testrun&testrun=RedHatEnterpriseLinux7%2FVirtkvmqe-x86-qcow2-rbd-manual-qemu-kvm-4-1-0-4-module-el8-1-0-RHEL-8-1

Comment 22 errata-xmlrpc 2019-11-06 07:10:39 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/RHBA-2019:3723


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