From nobody Sun Dec 14 06:37:30 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.libvirt.org designates 8.43.85.245 as permitted sender) client-ip=8.43.85.245; envelope-from=devel-bounces@lists.libvirt.org; helo=lists.libvirt.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of lists.libvirt.org designates 8.43.85.245 as permitted sender) smtp.mailfrom=devel-bounces@lists.libvirt.org; dmarc=pass(p=reject dis=none) header.from=lists.libvirt.org ARC-Seal: i=1; a=rsa-sha256; t=1750867408; cv=none; d=zohomail.com; s=zohoarc; b=chy6xEPocnhPEsOXLuMSBM7sv+65IoxymfDWtV9YPF01yFh9wulSWh5jukFzQOCE6n5EH214sM0qZwavCFh4bBXep5kjyK645K8Jjln21LaZ1N39+e3+9JUFEQcEXvdrAN81lcIPXA65fEhevOR1onlEJDlPiojYPYHhL6Gfr3A= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1750867408; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:Reply-To:References:Subject:Subject:To:To:Message-Id; bh=6IpBQ1NCgSJnLbl0yE6GtByKzkXnyq2Kd8WHCteh6Xs=; b=IW6jJVVSENfNZPEW1bNlIuS5rY9Fb8nPJPnnvzVtUBklCsd64f+kNbHf0pW3ohONPbTFUutCqYWH56g3hshHzRZ0qgA7taUrbNLG+oNiZ70qe3QhriKnI145u3FzPqNbcPccLh31ruReKoAxvGkKgYtb95ctOb8pK/i3WRh2XMk= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of lists.libvirt.org designates 8.43.85.245 as permitted sender) smtp.mailfrom=devel-bounces@lists.libvirt.org; dmarc=pass header.from= (p=reject dis=none) Return-Path: Received: from lists.libvirt.org (lists.libvirt.org [8.43.85.245]) by mx.zohomail.com with SMTPS id 175086740849879.30898167549469; Wed, 25 Jun 2025 09:03:28 -0700 (PDT) Received: by lists.libvirt.org (Postfix, from userid 996) id 7450F13D9; Wed, 25 Jun 2025 12:03:27 -0400 (EDT) Received: from lists.libvirt.org (localhost [IPv6:::1]) by lists.libvirt.org (Postfix) with ESMTP id C71C61531; Wed, 25 Jun 2025 11:57:23 -0400 (EDT) Received: by lists.libvirt.org (Postfix, from userid 996) id 82E6A864; Wed, 25 Jun 2025 11:57:21 -0400 (EDT) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by lists.libvirt.org (Postfix) with ESMTPS id AA137864 for ; Wed, 25 Jun 2025 11:57:17 -0400 (EDT) Received: from mx-prod-mc-08.mail-002.prod.us-west-2.aws.redhat.com (ec2-35-165-154-97.us-west-2.compute.amazonaws.com [35.165.154.97]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-192-eoRmyB4kMxyDWPxu3VV8Wg-1; Wed, 25 Jun 2025 11:57:15 -0400 Received: from mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.93]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 4A56718C10B1; Wed, 25 Jun 2025 15:56:51 +0000 (UTC) Received: from speedmetal.redhat.com (unknown [10.45.242.5]) by mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id ABC3918003FC; Wed, 25 Jun 2025 15:56:48 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on lists.libvirt.org X-Spam-Level: X-Spam-Status: No, score=-0.8 required=5.0 tests=DKIM_INVALID,DKIM_SIGNED, MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H5, RCVD_IN_MSPIKE_WL,RCVD_IN_VALIDITY_RPBL_BLOCKED, RCVD_IN_VALIDITY_SAFE_BLOCKED,SPF_HELO_NONE autolearn=unavailable autolearn_force=no version=3.4.4 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1750867037; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=M3My8gUfwPOelRyqBU28b+KdtlQ3nVBjGMTZoDEIe4k=; b=Q/KYAqcOhklQUBcLE93omXEFjPnvcsKrHmBFdr2Dq9HmWuub62a5C+prL3sc1u4BHre90K UJjH8DQ7rP/M6gjmqYzCdqKWf7nj2K6mws9DB3IvAmPWHOgua5RtasaEdEkSJg6zFdxKOx DOhXF7iSf6EtxNcdM8crjDr/91m1p2A= X-MC-Unique: eoRmyB4kMxyDWPxu3VV8Wg-1 X-Mimecast-MFC-AGG-ID: eoRmyB4kMxyDWPxu3VV8Wg_1750867035 To: devel@lists.libvirt.org Subject: [PATCH 4/4] qemu: Add support for RBD namespace. Date: Wed, 25 Jun 2025 17:56:37 +0200 Message-ID: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.93 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: Yc9q92DxFVBA9KtVaI_bP4EihWA2jUfaWZ6wTslB8Qo_1750867035 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Message-ID-Hash: ZFAOMT724KZKILONR2QWOCBPEIT373M4 X-Message-ID-Hash: ZFAOMT724KZKILONR2QWOCBPEIT373M4 X-MailFrom: pkrempa@redhat.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-config-1; header-match-config-2; header-match-config-3; header-match-devel.lists.libvirt.org-0; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; suspicious-header CC: Rodrigo Prieto , Peter Krempa , Han Han X-Mailman-Version: 3.2.2 Precedence: list List-Id: Development discussions about the libvirt library & tools Archived-At: List-Archive: List-Help: List-Post: List-Subscribe: List-Unsubscribe: From: Peter Krempa via Devel Reply-To: Peter Krempa X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1750867442996116600 Content-Type: text/plain; charset="utf-8" From: Han Han Since Nautilus ceph supports separate image namespaces within a pool for tenant isolation and QEMU adds it as a rbd blockdev options from 5.0.0. The source name with format "//" could be used to access a rbd image with namespace. Add unit tests for this attribute. https://bugzilla.redhat.com/show_bug.cgi?id=3D1816909 Closes: https://gitlab.com/libvirt/libvirt/-/issues/405 Signed-off-by: Han Han Signed-off-by: Peter Krempa --- docs/formatdomain.rst | 6 +++ src/conf/domain_conf.c | 3 +- src/conf/storage_source_conf.c | 47 ++++++++++++++----- src/conf/storage_source_conf.h | 1 + src/qemu/qemu_block.c | 6 ++- .../storage_file_backend_gluster.c | 2 +- .../storage_source_backingstore.c | 2 +- .../disk-network-rbd.x86_64-latest.args | 4 +- .../disk-network-rbd.x86_64-latest.xml | 4 +- tests/qemuxmlconfdata/disk-network-rbd.xml | 4 +- 10 files changed, 56 insertions(+), 23 deletions(-) diff --git a/docs/formatdomain.rst b/docs/formatdomain.rst index 9a2f065590..e8022e502d 100644 --- a/docs/formatdomain.rst +++ b/docs/formatdomain.rst @@ -2958,6 +2958,12 @@ paravirtualized driver is specified via the ``disk``= element. the optional attribute ``tlsHostname`` can be used to override the expected host name of the NBD server used for TLS certificate verifi= cation. + For "rbd", the ``name`` attribute could be two formats: the format of + ``pool_name/image_name`` includes the rbd pool name and image name w= ith + default rbd pool namespace; for the customized namespace, the format= is + ``pool_name/namespace/image_name`` ( :since:`Since 11.6.0 and QEMU 5= .0` ). + The pool name, namespace and image are separated by slash. + For protocols ``http`` and ``https`` an optional attribute ``query`` specifies the query string. ( :since:`Since 6.2.0` ) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index c7bad53ae6..7a8713771c 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -7381,7 +7381,8 @@ virDomainDiskSourceNetworkParse(xmlNodePtr node, return -1; } - if (virStorageSourceNetworkProtocolPathSplit(src->path, src->protocol,= NULL, NULL) < 0) + if (virStorageSourceNetworkProtocolPathSplit(src->path, src->protocol, + NULL, NULL, NULL) < 0) return -1; if (virXMLPropTristateBool(node, "tls", VIR_XML_PROP_NONE, diff --git a/src/conf/storage_source_conf.c b/src/conf/storage_source_conf.c index 9014fa37e6..dd46ea695b 100644 --- a/src/conf/storage_source_conf.c +++ b/src/conf/storage_source_conf.c @@ -1449,6 +1449,7 @@ virStorageSourceFDTupleNew(void) * @path: path to split * @protocol: protocol * @pool: filled with pool name (may be NULL) + * @namespace: filed with namespace (may be NULL) * @image: filled with image name (may be NULL) * * Historically libvirt accepted the specification of Gluster's volume and @@ -1463,35 +1464,57 @@ int virStorageSourceNetworkProtocolPathSplit(const char *path, virStorageNetProtocol protocol, char **pool, + char **namespace, char **image) { - - g_autofree char *pathcopy =3D g_strdup(path); - char *tmp; + g_auto(GStrv) tokens =3D NULL; + int components_max =3D 2; + size_t ncomponents =3D 0; + size_t i; if (protocol !=3D VIR_STORAGE_NET_PROTOCOL_GLUSTER && protocol !=3D VIR_STORAGE_NET_PROTOCOL_RBD) { if (image) - *image =3D g_steal_pointer(&pathcopy); + *image =3D g_strdup(path); return 0; } - if (!(tmp =3D strchr(pathcopy, '/')) || tmp =3D=3D pathcopy) { - virReportError(VIR_ERR_XML_ERROR, - _("can't split path '%1$s' into pool name and image= name"), - pathcopy); - return -1; + if (protocol =3D=3D VIR_STORAGE_NET_PROTOCOL_RBD) { + /* the name of rbd can be / or // */ + components_max =3D 3; } - tmp[0] =3D '\0'; + if ((tokens =3D g_strsplit(path, "/", components_max))) + ncomponents =3D g_strv_length(tokens); + + if (ncomponents < 2) + goto error; + + for (i =3D 0; i < ncomponents; i++) { + if (*tokens[i] =3D=3D '\0') + goto error; + } if (pool) - *pool =3D g_steal_pointer(&pathcopy); + *pool =3D g_strdup(tokens[0]); + + if (namespace) { + if (ncomponents =3D=3D 3) + *namespace =3D g_strdup(tokens[1]); + else + *namespace =3D NULL; + } if (image) - *image =3D g_strdup(tmp + 1); + *image =3D g_strdup(tokens[ncomponents - 1]); return 0; + + error: + virReportError(VIR_ERR_XML_ERROR, + _("failed to split path '%1$s' into 'pool/image' or 'po= ol/namespace/image' components"), + path); + return -1; } diff --git a/src/conf/storage_source_conf.h b/src/conf/storage_source_conf.h index 798ca20ac4..aa4efda9ad 100644 --- a/src/conf/storage_source_conf.h +++ b/src/conf/storage_source_conf.h @@ -601,4 +601,5 @@ int virStorageSourceNetworkProtocolPathSplit(const char *path, virStorageNetProtocol protocol, char **pool, + char **namespace, char **image); diff --git a/src/qemu/qemu_block.c b/src/qemu/qemu_block.c index 9b370d4c7c..daefeb2f45 100644 --- a/src/qemu/qemu_block.c +++ b/src/qemu/qemu_block.c @@ -405,7 +405,7 @@ qemuBlockStorageSourceGetGlusterProps(virStorageSource = *src, if (virStorageSourceNetworkProtocolPathSplit(src->path, VIR_STORAGE_NET_PROTOCOL_= GLUSTER, - &volume, &path) < 0) + &volume, NULL, &path) < 0) return NULL; /* { driver:"gluster", @@ -666,11 +666,12 @@ qemuBlockStorageSourceGetRBDProps(virStorageSource *s= rc, g_autoptr(virJSONValue) authmodes =3D NULL; const char *keysecret =3D NULL; g_autofree char *pool =3D NULL; + g_autofree char *namespace =3D NULL; g_autofree char *image =3D NULL; if (virStorageSourceNetworkProtocolPathSplit(src->path, VIR_STORAGE_NET_PROTOCOL_= RBD, - &pool, &image) < 0) + &pool, &namespace, &image= ) < 0) return NULL; if (src->nhosts > 0 && @@ -726,6 +727,7 @@ qemuBlockStorageSourceGetRBDProps(virStorageSource *src, if (virJSONValueObjectAdd(&ret, "s:pool", pool, + "S:namespace", namespace, "s:image", image, "S:snapshot", src->snapshot, "S:conf", src->configFile, diff --git a/src/storage_file/storage_file_backend_gluster.c b/src/storage_= file/storage_file_backend_gluster.c index 8778995b6c..4682b85903 100644 --- a/src/storage_file/storage_file_backend_gluster.c +++ b/src/storage_file/storage_file_backend_gluster.c @@ -106,7 +106,7 @@ virStorageFileBackendGlusterInit(virStorageSource *src) if (virStorageSourceNetworkProtocolPathSplit(src->path, VIR_STORAGE_NET_PROTOCOL_= GLUSTER, - &volume, &image) < 0) + &volume, NULL, &image) < = 0) return -1; priv =3D g_new0(virStorageFileBackendGlusterPriv, 1); diff --git a/src/storage_file/storage_source_backingstore.c b/src/storage_f= ile/storage_source_backingstore.c index 700a2f5dcb..821378883c 100644 --- a/src/storage_file/storage_source_backingstore.c +++ b/src/storage_file/storage_source_backingstore.c @@ -109,7 +109,7 @@ virStorageSourceParseBackingURI(virStorageSource *src, if (src->protocol =3D=3D VIR_STORAGE_NET_PROTOCOL_GLUSTER) { if (virStorageSourceNetworkProtocolPathSplit(src->path, src->proto= col, - NULL, NULL) < 0) + NULL, NULL, NULL) < 0) return -1; } diff --git a/tests/qemuxmlconfdata/disk-network-rbd.x86_64-latest.args b/te= sts/qemuxmlconfdata/disk-network-rbd.x86_64-latest.args index f344b57371..a15263c884 100644 --- a/tests/qemuxmlconfdata/disk-network-rbd.x86_64-latest.args +++ b/tests/qemuxmlconfdata/disk-network-rbd.x86_64-latest.args @@ -36,9 +36,9 @@ XDG_CONFIG_HOME=3D/var/lib/libvirt/qemu/domain--1-QEMUGue= st1/.config \ -blockdev '{"driver":"rbd","pool":"pool","image":"image","snapshot":"foo",= "conf":"/blah/test.conf","node-name":"libvirt-3-storage","read-only":false}= ' \ -device '{"driver":"virtio-blk-pci","bus":"pci.0","addr":"0x5","drive":"li= bvirt-3-storage","id":"virtio-disk3"}' \ -object '{"qom-type":"secret","id":"libvirt-2-storage-auth-secret0","data"= :"9eao5F8qtkGt+seB1HYivWIxbtwUu6MQtg1zpj/oDtUsPr1q8wBYM91uEHCn6j/1","keyid"= :"masterKey0","iv":"AAECAwQFBgcICQoLDA0ODw=3D=3D","format":"base64"}' \ --blockdev '{"driver":"rbd","pool":"pool","image":"image","server":[{"host"= :"mon1.example.org","port":"6321"},{"host":"mon2.example.org","port":"6322"= },{"host":"mon3.example.org","port":"6322"}],"user":"myname","auth-client-r= equired":["cephx","none"],"key-secret":"libvirt-2-storage-auth-secret0","no= de-name":"libvirt-2-storage","read-only":false}' \ +-blockdev '{"driver":"rbd","pool":"pool","namespace":"namespace","image":"= image","server":[{"host":"mon1.example.org","port":"6321"},{"host":"mon2.ex= ample.org","port":"6322"},{"host":"mon3.example.org","port":"6322"}],"user"= :"myname","auth-client-required":["cephx","none"],"key-secret":"libvirt-2-s= torage-auth-secret0","node-name":"libvirt-2-storage","read-only":false}' \ -device '{"driver":"virtio-blk-pci","bus":"pci.0","addr":"0x6","drive":"li= bvirt-2-storage","id":"virtio-disk4"}' \ --blockdev '{"driver":"rbd","pool":"pool","image":"image","server":[{"host"= :"::1","port":"6321"},{"host":"example.org","port":"6789"},{"host":"ffff:12= 34:567:abc::0f","port":"6322"},{"host":"2001:db8::ff00:42:8329","port":"632= 2"}],"node-name":"libvirt-1-storage","read-only":false}' \ +-blockdev '{"driver":"rbd","pool":"pool","namespace":"namespace","image":"= image","server":[{"host":"::1","port":"6321"},{"host":"example.org","port":= "6789"},{"host":"ffff:1234:567:abc::0f","port":"6322"},{"host":"2001:db8::f= f00:42:8329","port":"6322"}],"node-name":"libvirt-1-storage","read-only":fa= lse}' \ -device '{"driver":"virtio-blk-pci","bus":"pci.0","addr":"0x7","drive":"li= bvirt-1-storage","id":"virtio-disk5"}' \ -audiodev '{"id":"audio1","driver":"none"}' \ -sandbox on,obsolete=3Ddeny,elevateprivileges=3Ddeny,spawn=3Ddeny,resource= control=3Ddeny \ diff --git a/tests/qemuxmlconfdata/disk-network-rbd.x86_64-latest.xml b/tes= ts/qemuxmlconfdata/disk-network-rbd.x86_64-latest.xml index 6da7185d18..cfb10a701c 100644 --- a/tests/qemuxmlconfdata/disk-network-rbd.x86_64-latest.xml +++ b/tests/qemuxmlconfdata/disk-network-rbd.x86_64-latest.xml @@ -60,7 +60,7 @@ - + @@ -70,7 +70,7 @@ - + diff --git a/tests/qemuxmlconfdata/disk-network-rbd.xml b/tests/qemuxmlconf= data/disk-network-rbd.xml index c427fbea83..0973f50ecc 100644 --- a/tests/qemuxmlconfdata/disk-network-rbd.xml +++ b/tests/qemuxmlconfdata/disk-network-rbd.xml @@ -53,7 +53,7 @@ - + @@ -62,7 +62,7 @@ - + --=20 2.49.0