Bug 1873925

Summary: rbd image cannot be listed when it is create by qemu-img with a non-exsit rbd namespace
Product: Red Hat Enterprise Linux 9 Reporter: Han Han <hhan>
Component: qemu-kvmAssignee: Stefano Garzarella <sgarzare>
qemu-kvm sub component: Ceph QA Contact: Tingting Mao <timao>
Status: CLOSED CURRENTRELEASE Docs Contact:
Severity: low    
Priority: low CC: coli, jinzhao, juzhang, sgarzare, timao, virt-maint, xuwei
Version: 9.0Keywords: Reopened, 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: 2022-05-17 02:49:41 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 Han Han 2020-08-31 03:46:38 UTC
Description of problem:
As subject

Version-Release number of selected component (if applicable):
qemu-img-5.1.0-4.module+el8.3.0+7846+ae9b566f.x86_64
librbd1-12.2.7-9.el8.x86_64

How reproducible:
100%

Steps to Reproduce:
1. Create the image with path rbd/aa/new3(aa is a non-exist namespace):
➜  ~ qemu-img create 'rbd:rbd/aa/new3:conf=/root/.ceph/ceph.conf:id=admin:key=XXXX' 1M
Formatting 'rbd:rbd/aa/new3:conf=/root/.ceph/ceph.conf:id=admin:key=XXXX', fmt=raw size=1048576
➜  ~ qemu-img create 'rbd:rbd/aa/new3:conf=/root/.ceph/ceph.conf:id=admin:key=XXXX' 1M
Formatting 'rbd:rbd/aa/new3:conf=/root/.ceph/ceph.conf:id=admin:key=XXXX', fmt=raw size=1048576
qemu-img: rbd:rbd/aa/new3:conf=/root/.ceph/ceph.conf:id=admin:key=XXXX: error rbd create: File exist

Check if new3 in aa or default rbd namespace
➜ rbd -c ~/.ceph/ceph.conf -k ~/.ceph/ceph.client.admin.keyring -p rbd namespace ls
NAME 
hhan 
test 

➜  ~ rbd -c ~/.ceph/ceph.conf -k ~/.ceph/ceph.client.admin.keyring -p rbd ls|grep new3

The image is neither in aa or default rbd namespace. However it can be listed by   qemu-img:
➜  ~ qemu-img info 'rbd:rbd/aa/new3:conf=/root/.ceph/ceph.conf:id=admin:key=XXXX'   
image: json:{"driver": "raw", "file": {"pool": "rbd", "image": "new3", "conf": "/root/.ceph/ceph.conf", "driver": "rbd", "user": "admin"}}
file format: raw
virtual size: 1 MiB (1048576 bytes)
disk size: unavailable
cluster_size: 4194304


Actual results:
As above

Expected results:
Referring to the info provide by Jason Dillaman in https://www.redhat.com/archives/libvir-list/2020-August/msg00904.html , qemu should refuse to create a image for a non-exsit namespace.

Additional info:

Comment 2 John Ferlan 2021-09-08 22:01:06 UTC
Bulk update: Move RHEL-AV bugs to RHEL9. If necessary to resolve in RHEL8, then clone to the current RHEL8 release.

Comment 4 RHEL Program Management 2022-03-03 07:27:20 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.

Comment 5 Tingting Mao 2022-03-04 03:14:09 UTC
Reopen the issue for still hitting the issue. 

And one thing I want to highlight is that I can not delete the image from server side for I can not find the image.

Comment 7 Stefano Garzarella 2022-05-13 15:42:27 UTC
@timao I'm not able to replicate on CentOS Stream 8 and 9.

In both cases, I have the following behavior (note: 'aa' namespace not exists)

$ qemu-img create rbd:rbd/aa/new3 1M
Formatting 'rbd:rbd/aa/new3', fmt=raw size=1048576
qemu-img: rbd:rbd/aa/new3: error rbd create: No such file or directory


c8s packages:
qemu-img-15:6.2.0-12.module_el8.7.0+1140+ff0772f9.x86_64
librbd1-2:14.2.22-2.el8s.x86_64

c9s packages:
qemu-img-17:7.0.0-1.el9.x86_64
librbd1-2:16.2.7-1.el9s.x86_64


Are you able to replicate with the latest RHEL versions?

Comment 9 Tingting Mao 2022-05-16 02:13:21 UTC
Yes, in latest qemu, there is no the issue. 
But the error info is 'No such file or directory', maybe we could give it a more clear error hint info like "No a namespace named 'aa'"?



In rhel8.7 tested with:
qemu-kvm-6.2.0-13.module+el8.7.0+15131+941fbd8d
librbd1-14.2.11-208.el8cp.x86_64

Steps:
# qemu-img create 'rbd:rbd/aa/new3:conf=/etc/ceph/ceph.conf:id=admin:key=AQBwUmlfB9VwKhAA0HwqNhKCfarcItKtCR9ulg==' 1M
Formatting 'rbd:rbd/aa/new3:conf=/etc/ceph/ceph.conf:id=admin:key=AQBwUmlfB9VwKhAA0HwqNhKCfarcItKtCR9ulg==', fmt=raw size=1048576
qemu-img: rbd:rbd/aa/new3:conf=/etc/ceph/ceph.conf:id=admin:key=AQBwUmlfB9VwKhAA0HwqNhKCfarcItKtCR9ulg==: error rbd create: No such file or directory

Results:
As above, created failed with ' No such file or directory'.



In latest rhel9.1 tested with:
qemu-kvm-7.0.0-3.el9
librbd1-16.2.4-5.el9.x86_64

Steps:
# qemu-img create 'rbd:rbd/aa/new3:conf=/etc/ceph/ceph.conf:id=admin:key=AQBwUmlfB9VwKhAA0HwqNhKCfarcItKtCR9ulg==' 1M
Formatting 'rbd:rbd/aa/new3:conf=/etc/ceph/ceph.conf:id=admin:key=AQBwUmlfB9VwKhAA0HwqNhKCfarcItKtCR9ulg==', fmt=raw size=1048576
qemu-img: rbd:rbd/aa/new3:conf=/etc/ceph/ceph.conf:id=admin:key=AQBwUmlfB9VwKhAA0HwqNhKCfarcItKtCR9ulg==: error rbd create: No such file or directory

# qemu-img create rbd:rbd/aa/testtt.img 1G
Formatting 'rbd:rbd/aa/testtt.img', fmt=raw size=1073741824
qemu-img: rbd:rbd/aa/testtt.img: error rbd create: No such file or directory

Results:
As above, created failed with ' No such file or directory'.

Comment 10 Stefano Garzarella 2022-05-16 10:10:32 UTC
(In reply to Tingting Mao from comment #9)
> Yes, in latest qemu, there is no the issue. 

Thanks for checking!
Do you think it would be better to close this BZ and open another one for the error message?

QEMU simply reports the error returned by rbd_create() (-ENOENT), so it makes me think that this problem was in librbd and not in QEMU.

> But the error info is 'No such file or directory', maybe we could give it a
> more clear error hint info like "No a namespace named 'aa'"?

Yep, maybe that would be better. 
I just posted an upstream patch here: https://lore.kernel.org/qemu-devel/20220516100324.61122-1-sgarzare@redhat.com/T/#u