[PATCH v5 0/4] qemu: Support rbd namespace in rbd source name

v4: https://www.redhat.com/archives/libvir-list/2020-August/msg00351.html Difference from v4: - rebase to last master tree - parse namspace from name attribute and update the documents - add caps test xml for 5.2.0 x86_64 - adapt to DO_TEST_CAPS_ARCH_LATEST in qemuxml2xmltest in case of the test failure caused by missing caps test xml of 5.x at s390. git branch: https://gitlab.com/hhan2/libvirt/-/tree/rbd-namespace-v5 Han Han (4): qemu_capabilities: Add QEMU_CAPS_RBD_NAMESPACE conf: Support to parse rbd namespace from source name qemu: Implement rbd namespace to the source name attribute news: qemu: Support rbd namespace NEWS.rst | 8 ++++ docs/formatdomain.rst | 12 ++++-- src/conf/domain_conf.c | 35 ++++++++++++++-- src/qemu/qemu_block.c | 1 + src/qemu/qemu_capabilities.c | 4 ++ src/qemu/qemu_capabilities.h | 3 ++ src/qemu/qemu_domain.c | 8 ++++ src/util/virstoragefile.c | 1 + src/util/virstoragefile.h | 1 + .../caps_5.0.0.aarch64.xml | 1 + .../qemucapabilitiesdata/caps_5.0.0.ppc64.xml | 1 + .../caps_5.0.0.riscv64.xml | 1 + .../caps_5.0.0.x86_64.xml | 1 + .../caps_5.1.0.x86_64.xml | 1 + .../caps_5.2.0.x86_64.xml | 1 + ...k-network-rbd-namespace.x86_64-latest.args | 41 +++++++++++++++++++ .../disk-network-rbd-namespace.xml | 33 +++++++++++++++ tests/qemuxml2argvtest.c | 1 + ...sk-network-rbd-namespace.x86_64-latest.xml | 41 +++++++++++++++++++ tests/qemuxml2xmltest.c | 1 + 20 files changed, 189 insertions(+), 7 deletions(-) create mode 100644 tests/qemuxml2argvdata/disk-network-rbd-namespace.x86_64-latest.args create mode 100644 tests/qemuxml2argvdata/disk-network-rbd-namespace.xml create mode 100644 tests/qemuxml2xmloutdata/disk-network-rbd-namespace.x86_64-latest.xml -- 2.28.0

The capability flag will be used for rbd namespace option. The rbd namespace is introduced since ceph Nautilus and qemu v5.0.0. Signed-off-by: Han Han <hhan@redhat.com> --- src/qemu/qemu_capabilities.c | 4 ++++ src/qemu/qemu_capabilities.h | 3 +++ tests/qemucapabilitiesdata/caps_5.0.0.aarch64.xml | 1 + tests/qemucapabilitiesdata/caps_5.0.0.ppc64.xml | 1 + tests/qemucapabilitiesdata/caps_5.0.0.riscv64.xml | 1 + tests/qemucapabilitiesdata/caps_5.0.0.x86_64.xml | 1 + tests/qemucapabilitiesdata/caps_5.1.0.x86_64.xml | 1 + tests/qemucapabilitiesdata/caps_5.2.0.x86_64.xml | 1 + 8 files changed, 13 insertions(+) diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c index 2cc0c61588..4d0dd23c9e 100644 --- a/src/qemu/qemu_capabilities.c +++ b/src/qemu/qemu_capabilities.c @@ -597,6 +597,9 @@ VIR_ENUM_IMPL(virQEMUCaps, "spapr-tpm-proxy", "numa.hmat", "blockdev-hostdev-scsi", + + /* 380 */ + "rbd.namespace", ); @@ -1526,6 +1529,7 @@ static struct virQEMUCapsStringFlags virQEMUCapsQMPSchemaQueries[] = { { "migrate-set-parameters/arg-type/downtime-limit", QEMU_CAPS_MIGRATION_PARAM_DOWNTIME }, { "migrate-set-parameters/arg-type/xbzrle-cache-size", QEMU_CAPS_MIGRATION_PARAM_XBZRLE_CACHE_SIZE }, { "set-numa-node/arg-type/+hmat-lb", QEMU_CAPS_NUMA_HMAT }, + { "blockdev-add/arg-type/+rbd/namespace", QEMU_CAPS_RBD_NAMESPACE }, }; typedef struct _virQEMUCapsObjectTypeProps virQEMUCapsObjectTypeProps; diff --git a/src/qemu/qemu_capabilities.h b/src/qemu/qemu_capabilities.h index 5d08941538..ef7ea9aa20 100644 --- a/src/qemu/qemu_capabilities.h +++ b/src/qemu/qemu_capabilities.h @@ -578,6 +578,9 @@ typedef enum { /* virQEMUCapsFlags grouping marker for syntax-check */ QEMU_CAPS_NUMA_HMAT, /* -numa hmat */ QEMU_CAPS_BLOCKDEV_HOSTDEV_SCSI, /* -blockdev used for (i)SCSI hostdevs */ + /* 380 */ + QEMU_CAPS_RBD_NAMESPACE, /* -blockdev '{"driver":"rbd",...,"namespace":str}' */ + QEMU_CAPS_LAST /* this must always be the last item */ } virQEMUCapsFlags; diff --git a/tests/qemucapabilitiesdata/caps_5.0.0.aarch64.xml b/tests/qemucapabilitiesdata/caps_5.0.0.aarch64.xml index 928af2a01c..75622ca5fd 100644 --- a/tests/qemucapabilitiesdata/caps_5.0.0.aarch64.xml +++ b/tests/qemucapabilitiesdata/caps_5.0.0.aarch64.xml @@ -199,6 +199,7 @@ <flag name='migration-param.xbzrle-cache-size'/> <flag name='numa.hmat'/> <flag name='blockdev-hostdev-scsi'/> + <flag name='rbd.namespace'/> <version>5000000</version> <kvmVersion>0</kvmVersion> <microcodeVersion>61700241</microcodeVersion> diff --git a/tests/qemucapabilitiesdata/caps_5.0.0.ppc64.xml b/tests/qemucapabilitiesdata/caps_5.0.0.ppc64.xml index e8668a25a9..1780c8a5bc 100644 --- a/tests/qemucapabilitiesdata/caps_5.0.0.ppc64.xml +++ b/tests/qemucapabilitiesdata/caps_5.0.0.ppc64.xml @@ -208,6 +208,7 @@ <flag name='spapr-tpm-proxy'/> <flag name='numa.hmat'/> <flag name='blockdev-hostdev-scsi'/> + <flag name='rbd.namespace'/> <version>5000000</version> <kvmVersion>0</kvmVersion> <microcodeVersion>42900241</microcodeVersion> diff --git a/tests/qemucapabilitiesdata/caps_5.0.0.riscv64.xml b/tests/qemucapabilitiesdata/caps_5.0.0.riscv64.xml index 85a8a46dac..d885bd9bb3 100644 --- a/tests/qemucapabilitiesdata/caps_5.0.0.riscv64.xml +++ b/tests/qemucapabilitiesdata/caps_5.0.0.riscv64.xml @@ -195,6 +195,7 @@ <flag name='migration-param.xbzrle-cache-size'/> <flag name='numa.hmat'/> <flag name='blockdev-hostdev-scsi'/> + <flag name='rbd.namespace'/> <version>5000000</version> <kvmVersion>0</kvmVersion> <microcodeVersion>0</microcodeVersion> diff --git a/tests/qemucapabilitiesdata/caps_5.0.0.x86_64.xml b/tests/qemucapabilitiesdata/caps_5.0.0.x86_64.xml index 546b9b0422..e93483f0c6 100644 --- a/tests/qemucapabilitiesdata/caps_5.0.0.x86_64.xml +++ b/tests/qemucapabilitiesdata/caps_5.0.0.x86_64.xml @@ -243,6 +243,7 @@ <flag name='intel-iommu.aw-bits'/> <flag name='numa.hmat'/> <flag name='blockdev-hostdev-scsi'/> + <flag name='rbd.namespace'/> <version>5000000</version> <kvmVersion>0</kvmVersion> <microcodeVersion>43100241</microcodeVersion> diff --git a/tests/qemucapabilitiesdata/caps_5.1.0.x86_64.xml b/tests/qemucapabilitiesdata/caps_5.1.0.x86_64.xml index 7496ff1379..d1bd5b29e4 100644 --- a/tests/qemucapabilitiesdata/caps_5.1.0.x86_64.xml +++ b/tests/qemucapabilitiesdata/caps_5.1.0.x86_64.xml @@ -242,6 +242,7 @@ <flag name='intel-iommu.aw-bits'/> <flag name='numa.hmat'/> <flag name='blockdev-hostdev-scsi'/> + <flag name='rbd.namespace'/> <version>5001000</version> <kvmVersion>0</kvmVersion> <microcodeVersion>43100242</microcodeVersion> diff --git a/tests/qemucapabilitiesdata/caps_5.2.0.x86_64.xml b/tests/qemucapabilitiesdata/caps_5.2.0.x86_64.xml index 151bd18137..d00e255191 100644 --- a/tests/qemucapabilitiesdata/caps_5.2.0.x86_64.xml +++ b/tests/qemucapabilitiesdata/caps_5.2.0.x86_64.xml @@ -242,6 +242,7 @@ <flag name='intel-iommu.aw-bits'/> <flag name='numa.hmat'/> <flag name='blockdev-hostdev-scsi'/> + <flag name='rbd.namespace'/> <version>5001050</version> <kvmVersion>0</kvmVersion> <microcodeVersion>43100243</microcodeVersion> -- 2.28.0

Signed-off-by: Han Han <hhan@redhat.com> --- docs/formatdomain.rst | 12 +++++++++--- src/conf/domain_conf.c | 35 +++++++++++++++++++++++++++++++---- src/util/virstoragefile.c | 1 + src/util/virstoragefile.h | 1 + 4 files changed, 42 insertions(+), 7 deletions(-) diff --git a/docs/formatdomain.rst b/docs/formatdomain.rst index 1979dfb8d3..4d730a4446 100644 --- a/docs/formatdomain.rst +++ b/docs/formatdomain.rst @@ -2256,7 +2256,7 @@ paravirtualized driver is specified via the ``disk`` element. </disk> <disk type='network'> <driver name="qemu" type="raw"/> - <source protocol="rbd" name="image_name2"> + <source protocol="rbd" name="pool/namespace/image"> <host name="hostname" port="7000"/> <snapshot name="snapname"/> <config file="/path/to/file"/> @@ -2485,8 +2485,8 @@ paravirtualized driver is specified via the ``disk`` element. requested image. Possible values are "nbd", "iscsi", "rbd", "sheepdog", "gluster", "vxhs", "http", "https", "ftp", ftps", or "tftp". - For any ``protocol`` other than ``nbd`` an additional attribute ``name`` - is mandatory to specify which volume/image will be used. + For any ``protocol`` other than ``nbd`` or ``rbd`` an additional attribute + ``name`` is mandatory to specify which volume/image will be used. For "nbd", the ``name`` attribute is optional. TLS transport for NBD can be enabled by setting the ``tls`` attribute to ``yes``. For the QEMU @@ -2494,6 +2494,12 @@ paravirtualized driver is specified via the ``disk`` element. the host by the ``nbd_tls`` and ``nbd_tls_x509_cert_dir`` in /etc/libvirt/qemu.conf. ('tls' :since:`Since 4.5.0` ) + For "rbd", the ``name`` attribute could be two formats: the format of + ``pool_name/image_name`` includes the rbd pool name and image name with + default rbd pool namespace; for the customized namespace, the format is + ``pool_name/namespace/image_name``. 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 72ac4f4191..5ece5f515d 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -9624,8 +9624,7 @@ virDomainDiskSourceNetworkParse(xmlNodePtr node, /* for historical reasons we store the volume and image name in one XML * element although it complicates thing when attempting to access them. */ if (src->path && - (src->protocol == VIR_STORAGE_NET_PROTOCOL_GLUSTER || - src->protocol == VIR_STORAGE_NET_PROTOCOL_RBD)) { + src->protocol == VIR_STORAGE_NET_PROTOCOL_GLUSTER) { char *tmp; if (!(tmp = strchr(src->path, '/')) || tmp == src->path) { @@ -9642,6 +9641,30 @@ virDomainDiskSourceNetworkParse(xmlNodePtr node, tmp[0] = '\0'; } + /* the name of rbd could be <pool>/<image> or <pool>/<namespace>/<image> */ + if (src->path && + src->protocol == VIR_STORAGE_NET_PROTOCOL_RBD) { + char *first_slash = strchr(src->path, '/'); + char *last_slash = strrchr(src->path, '/'); + if (!first_slash || + first_slash == src->path || + !last_slash || + last_slash[1] == '\0') { + virReportError(VIR_ERR_XML_ERROR, + _("can't split path '%s' into pool name, pool " + "namespace and image name"), src->path); + return -1; + } + + src->volume = src->path; + src->path = g_strdup(last_slash + 1); + src->ns = NULL; + first_slash[0] = '\0'; + last_slash[0] = '\0'; + if (first_slash != last_slash) + src->ns = g_strdup(first_slash + 1); + } + /* snapshot currently works only for remote disks */ src->snapshot = virXPathString("string(./snapshot/@name)", ctxt); @@ -25211,8 +25234,12 @@ virDomainDiskSourceFormatNetwork(virBufferPtr attrBuf, virBufferAsprintf(attrBuf, " protocol='%s'", virStorageNetProtocolTypeToString(src->protocol)); - if (src->volume) - path = g_strdup_printf("%s/%s", src->volume, src->path); + if (src->volume) { + if (src->ns) + path = g_strdup_printf("%s/%s/%s", src->volume, src->ns, src->path); + else + path = g_strdup_printf("%s/%s", src->volume, src->path); + } virBufferEscapeString(attrBuf, " name='%s'", path ? path : src->path); virBufferEscapeString(attrBuf, " query='%s'", src->query); diff --git a/src/util/virstoragefile.c b/src/util/virstoragefile.c index 97a346db28..e7aaeebdb6 100644 --- a/src/util/virstoragefile.c +++ b/src/util/virstoragefile.c @@ -2666,6 +2666,7 @@ virStorageSourceClear(virStorageSourcePtr def) VIR_FREE(def->path); VIR_FREE(def->volume); + VIR_FREE(def->ns); VIR_FREE(def->snapshot); VIR_FREE(def->configFile); VIR_FREE(def->query); diff --git a/src/util/virstoragefile.h b/src/util/virstoragefile.h index f73b3ee005..f027989462 100644 --- a/src/util/virstoragefile.h +++ b/src/util/virstoragefile.h @@ -284,6 +284,7 @@ struct _virStorageSource { char *snapshot; /* for storage systems supporting internal snapshots */ char *configFile; /* some storage systems use config file as part of the source definition */ + char *ns; /* for the storage systems supporting namespace */ char *query; /* query string for HTTP based protocols */ size_t nhosts; virStorageNetHostDefPtr hosts; -- 2.28.0

On Wed, Sep 02, 2020 at 16:05:19 +0800, Han Han wrote:
Signed-off-by: Han Han <hhan@redhat.com> --- docs/formatdomain.rst | 12 +++++++++--- src/conf/domain_conf.c | 35 +++++++++++++++++++++++++++++++---- src/util/virstoragefile.c | 1 + src/util/virstoragefile.h | 1 + 4 files changed, 42 insertions(+), 7 deletions(-)
diff --git a/docs/formatdomain.rst b/docs/formatdomain.rst index 1979dfb8d3..4d730a4446 100644 --- a/docs/formatdomain.rst +++ b/docs/formatdomain.rst @@ -2256,7 +2256,7 @@ paravirtualized driver is specified via the ``disk`` element. </disk> <disk type='network'> <driver name="qemu" type="raw"/> - <source protocol="rbd" name="image_name2"> + <source protocol="rbd" name="pool/namespace/image">
Please add another example rather than modifying this one.
<host name="hostname" port="7000"/> <snapshot name="snapname"/> <config file="/path/to/file"/> @@ -2485,8 +2485,8 @@ paravirtualized driver is specified via the ``disk`` element. requested image. Possible values are "nbd", "iscsi", "rbd", "sheepdog", "gluster", "vxhs", "http", "https", "ftp", ftps", or "tftp".
- For any ``protocol`` other than ``nbd`` an additional attribute ``name`` - is mandatory to specify which volume/image will be used. + For any ``protocol`` other than ``nbd`` or ``rbd`` an additional attribute + ``name`` is mandatory to specify which volume/image will be used.
You made the sentence misleading. 'name' is still mandatory for 'rbd'.
For "nbd", the ``name`` attribute is optional. TLS transport for NBD can be enabled by setting the ``tls`` attribute to ``yes``. For the QEMU @@ -2494,6 +2494,12 @@ paravirtualized driver is specified via the ``disk`` element. the host by the ``nbd_tls`` and ``nbd_tls_x509_cert_dir`` in /etc/libvirt/qemu.conf. ('tls' :since:`Since 4.5.0` )
+ For "rbd", the ``name`` attribute could be two formats: the format of + ``pool_name/image_name`` includes the rbd pool name and image name with + default rbd pool namespace; for the customized namespace, the format is + ``pool_name/namespace/image_name``. The pool name, namespace and image are + separated by slash.
Missing since tag.
+ 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 72ac4f4191..5ece5f515d 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -9624,8 +9624,7 @@ virDomainDiskSourceNetworkParse(xmlNodePtr node, /* for historical reasons we store the volume and image name in one XML * element although it complicates thing when attempting to access them. */ if (src->path && - (src->protocol == VIR_STORAGE_NET_PROTOCOL_GLUSTER || - src->protocol == VIR_STORAGE_NET_PROTOCOL_RBD)) { + src->protocol == VIR_STORAGE_NET_PROTOCOL_GLUSTER) { char *tmp; if (!(tmp = strchr(src->path, '/')) || tmp == src->path) { @@ -9642,6 +9641,30 @@ virDomainDiskSourceNetworkParse(xmlNodePtr node, tmp[0] = '\0'; }
+ /* the name of rbd could be <pool>/<image> or <pool>/<namespace>/<image> */ + if (src->path && + src->protocol == VIR_STORAGE_NET_PROTOCOL_RBD) {
The following algorithm became very ugly and unobvious. Please reimplement this using virStringSplit.
+ char *first_slash = strchr(src->path, '/'); + char *last_slash = strrchr(src->path, '/'); + if (!first_slash || + first_slash == src->path || + !last_slash || + last_slash[1] == '\0') { + virReportError(VIR_ERR_XML_ERROR, + _("can't split path '%s' into pool name, pool " + "namespace and image name"), src->path); + return -1; + } + + src->volume = src->path; + src->path = g_strdup(last_slash + 1); + src->ns = NULL; + first_slash[0] = '\0'; + last_slash[0] = '\0'; + if (first_slash != last_slash) + src->ns = g_strdup(first_slash + 1); + } + /* snapshot currently works only for remote disks */ src->snapshot = virXPathString("string(./snapshot/@name)", ctxt);
@@ -25211,8 +25234,12 @@ virDomainDiskSourceFormatNetwork(virBufferPtr attrBuf, virBufferAsprintf(attrBuf, " protocol='%s'", virStorageNetProtocolTypeToString(src->protocol));
- if (src->volume) - path = g_strdup_printf("%s/%s", src->volume, src->path); + if (src->volume) { + if (src->ns) + path = g_strdup_printf("%s/%s/%s", src->volume, src->ns, src->path); + else + path = g_strdup_printf("%s/%s", src->volume, src->path); + }
[...]
diff --git a/src/util/virstoragefile.h b/src/util/virstoragefile.h index f73b3ee005..f027989462 100644 --- a/src/util/virstoragefile.h +++ b/src/util/virstoragefile.h @@ -284,6 +284,7 @@ struct _virStorageSource { char *snapshot; /* for storage systems supporting internal snapshots */ char *configFile; /* some storage systems use config file as part of the source definition */ + char *ns; /* for the storage systems supporting namespace */
struct virStorageSource has a deep copy function which must be updated with any addition to it.
char *query; /* query string for HTTP based protocols */ size_t nhosts; virStorageNetHostDefPtr hosts; -- 2.28.0

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 "<pool>/<namespace>/<image>" could be used to access a rbd image with namespace. Add unit tests for this attribute. https://bugzilla.redhat.com/show_bug.cgi?id=1816909 Signed-off-by: Han Han <hhan@redhat.com> --- src/qemu/qemu_block.c | 1 + src/qemu/qemu_domain.c | 8 ++++ ...k-network-rbd-namespace.x86_64-latest.args | 41 +++++++++++++++++++ .../disk-network-rbd-namespace.xml | 33 +++++++++++++++ tests/qemuxml2argvtest.c | 1 + ...sk-network-rbd-namespace.x86_64-latest.xml | 41 +++++++++++++++++++ tests/qemuxml2xmltest.c | 1 + 7 files changed, 126 insertions(+) create mode 100644 tests/qemuxml2argvdata/disk-network-rbd-namespace.x86_64-latest.args create mode 100644 tests/qemuxml2argvdata/disk-network-rbd-namespace.xml create mode 100644 tests/qemuxml2xmloutdata/disk-network-rbd-namespace.x86_64-latest.xml diff --git a/src/qemu/qemu_block.c b/src/qemu/qemu_block.c index 26c1b42428..d698bdec67 100644 --- a/src/qemu/qemu_block.c +++ b/src/qemu/qemu_block.c @@ -872,6 +872,7 @@ qemuBlockStorageSourceGetRBDProps(virStorageSourcePtr src, "s:pool", src->volume, "s:image", src->path, "S:snapshot", src->snapshot, + "S:namespace", src->ns, "S:conf", src->configFile, "A:server", &servers, "S:user", username, diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index b1884b6c84..10e1afd586 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -4683,6 +4683,14 @@ qemuDomainValidateStorageSource(virStorageSourcePtr src, return -1; } + if (src->protocol == VIR_STORAGE_NET_PROTOCOL_RBD && + src->ns && + !virQEMUCapsGet(qemuCaps, QEMU_CAPS_RBD_NAMESPACE)) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("rbd namespace is not supported by this QEMU")); + return -1; + } + return 0; } diff --git a/tests/qemuxml2argvdata/disk-network-rbd-namespace.x86_64-latest.args b/tests/qemuxml2argvdata/disk-network-rbd-namespace.x86_64-latest.args new file mode 100644 index 0000000000..a744805d74 --- /dev/null +++ b/tests/qemuxml2argvdata/disk-network-rbd-namespace.x86_64-latest.args @@ -0,0 +1,41 @@ +LC_ALL=C \ +PATH=/bin \ +HOME=/tmp/lib/domain--1-QEMUGuest1 \ +USER=test \ +LOGNAME=test \ +XDG_DATA_HOME=/tmp/lib/domain--1-QEMUGuest1/.local/share \ +XDG_CACHE_HOME=/tmp/lib/domain--1-QEMUGuest1/.cache \ +XDG_CONFIG_HOME=/tmp/lib/domain--1-QEMUGuest1/.config \ +QEMU_AUDIO_DRV=none \ +/usr/bin/qemu-system-x86_64 \ +-name guest=QEMUGuest1,debug-threads=on \ +-S \ +-object secret,id=masterKey0,format=raw,\ +file=/tmp/lib/domain--1-QEMUGuest1/master-key.aes \ +-machine pc,accel=tcg,usb=off,dump-guest-core=off \ +-cpu qemu64 \ +-m 214 \ +-overcommit mem-lock=off \ +-smp 1,sockets=1,cores=1,threads=1 \ +-uuid c7a5fdbd-edaf-9455-926a-d65c16db1809 \ +-display none \ +-no-user-config \ +-nodefaults \ +-chardev socket,id=charmonitor,fd=1729,server,nowait \ +-mon chardev=charmonitor,id=monitor,mode=control \ +-rtc base=utc \ +-no-shutdown \ +-no-acpi \ +-boot strict=on \ +-device piix3-usb-uhci,id=usb,bus=pci.0,addr=0x1.0x2 \ +-blockdev '{"driver":"rbd","pool":"pool","image":"image","namespace":"ns",\ +"server":[{"host":"mon1.example.org","port":"6321"},{"host":"mon2.example.org",\ +"port":"6322"},{"host":"mon3.example.org","port":"6322"}],\ +"node-name":"libvirt-1-storage","auto-read-only":true,"discard":"unmap"}' \ +-blockdev '{"node-name":"libvirt-1-format","read-only":false,"driver":"raw",\ +"file":"libvirt-1-storage"}' \ +-device virtio-blk-pci,bus=pci.0,addr=0x2,drive=libvirt-1-format,\ +id=virtio-disk0,bootindex=1 \ +-sandbox on,obsolete=deny,elevateprivileges=deny,spawn=deny,\ +resourcecontrol=deny \ +-msg timestamp=on diff --git a/tests/qemuxml2argvdata/disk-network-rbd-namespace.xml b/tests/qemuxml2argvdata/disk-network-rbd-namespace.xml new file mode 100644 index 0000000000..c451db186b --- /dev/null +++ b/tests/qemuxml2argvdata/disk-network-rbd-namespace.xml @@ -0,0 +1,33 @@ +<domain type='qemu'> + <name>QEMUGuest1</name> + <uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid> + <memory unit='KiB'>219136</memory> + <currentMemory unit='KiB'>219136</currentMemory> + <vcpu placement='static'>1</vcpu> + <os> + <type arch='x86_64' machine='pc'>hvm</type> + <boot dev='hd'/> + </os> + <clock offset='utc'/> + <on_poweroff>destroy</on_poweroff> + <on_reboot>restart</on_reboot> + <on_crash>destroy</on_crash> + <devices> + <emulator>/usr/bin/qemu-system-x86_64</emulator> + <disk type='network' device='disk'> + <driver name='qemu' type='raw'/> + <source protocol='rbd' name='pool/ns/image'> + <host name='mon1.example.org' port='6321'/> + <host name='mon2.example.org' port='6322'/> + <host name='mon3.example.org' port='6322'/> + </source> + <target dev='vda' bus='virtio'/> + </disk> + <controller type='usb' index='0'/> + <controller type='ide' index='0'/> + <controller type='pci' index='0' model='pci-root'/> + <input type='mouse' bus='ps2'/> + <input type='keyboard' bus='ps2'/> + <memballoon model='none'/> + </devices> +</domain> diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c index e93948e3fc..bfbb843458 100644 --- a/tests/qemuxml2argvtest.c +++ b/tests/qemuxml2argvtest.c @@ -1174,6 +1174,7 @@ mymain(void) DO_TEST_CAPS_VER("disk-network-rbd", "2.5.0"); DO_TEST_CAPS_VER("disk-network-rbd", "2.12.0"); DO_TEST_CAPS_LATEST("disk-network-rbd"); + DO_TEST_CAPS_LATEST("disk-network-rbd-namespace"); DO_TEST_FAILURE("disk-network-rbd-no-colon", NONE); DO_TEST("disk-network-sheepdog", NONE); DO_TEST_CAPS_VER("disk-network-sheepdog", "2.12.0"); diff --git a/tests/qemuxml2xmloutdata/disk-network-rbd-namespace.x86_64-latest.xml b/tests/qemuxml2xmloutdata/disk-network-rbd-namespace.x86_64-latest.xml new file mode 100644 index 0000000000..9840aae95c --- /dev/null +++ b/tests/qemuxml2xmloutdata/disk-network-rbd-namespace.x86_64-latest.xml @@ -0,0 +1,41 @@ +<domain type='qemu'> + <name>QEMUGuest1</name> + <uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid> + <memory unit='KiB'>219136</memory> + <currentMemory unit='KiB'>219136</currentMemory> + <vcpu placement='static'>1</vcpu> + <os> + <type arch='x86_64' machine='pc'>hvm</type> + <boot dev='hd'/> + </os> + <cpu mode='custom' match='exact' check='none'> + <model fallback='forbid'>qemu64</model> + </cpu> + <clock offset='utc'/> + <on_poweroff>destroy</on_poweroff> + <on_reboot>restart</on_reboot> + <on_crash>destroy</on_crash> + <devices> + <emulator>/usr/bin/qemu-system-x86_64</emulator> + <disk type='network' device='disk'> + <driver name='qemu' type='raw'/> + <source protocol='rbd' name='pool/ns/image'> + <host name='mon1.example.org' port='6321'/> + <host name='mon2.example.org' port='6322'/> + <host name='mon3.example.org' port='6322'/> + </source> + <target dev='vda' bus='virtio'/> + <address type='pci' domain='0x0000' bus='0x00' slot='0x02' function='0x0'/> + </disk> + <controller type='usb' index='0' model='piix3-uhci'> + <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x2'/> + </controller> + <controller type='ide' index='0'> + <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x1'/> + </controller> + <controller type='pci' index='0' model='pci-root'/> + <input type='mouse' bus='ps2'/> + <input type='keyboard' bus='ps2'/> + <memballoon model='none'/> + </devices> +</domain> diff --git a/tests/qemuxml2xmltest.c b/tests/qemuxml2xmltest.c index 6eb008c8d2..197a717b08 100644 --- a/tests/qemuxml2xmltest.c +++ b/tests/qemuxml2xmltest.c @@ -347,6 +347,7 @@ mymain(void) DO_TEST("disk-network-iscsi", QEMU_CAPS_VIRTIO_SCSI); DO_TEST("disk-network-gluster", NONE); DO_TEST("disk-network-rbd", NONE); + DO_TEST_CAPS_ARCH_LATEST("disk-network-rbd-namespace", "x86_64"); DO_TEST("disk-network-source-auth", NONE); DO_TEST("disk-network-sheepdog", NONE); DO_TEST("disk-network-vxhs", NONE); -- 2.28.0

Signed-off-by: Han Han <hhan@redhat.com> --- NEWS.rst | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/NEWS.rst b/NEWS.rst index e4b71e6563..8537da1747 100644 --- a/NEWS.rst +++ b/NEWS.rst @@ -20,6 +20,14 @@ v6.8.0 (unreleased) attribute of the device's ``<source>`` element can be used to disable the filtering and allow all guest writes to the configuration space. + * qemu: Support rbd pool namespace in the source name + + The namespaces is for the tenant isolation within a rbd pool, introduced + from Ceph Nautilus, supported since ``QEMU 5.0.0``. In libvirt, the format + of rbd source name like ``<pool>/<namespace>/<image>`` could be used to + access a certain namespace of a rbd pool. And the format ``<pool>/<image>`` + is reserved for the default namespace of a rbd pool. + * **Improvements** * **Bug fixes** -- 2.28.0
participants (2)
-
Han Han
-
Peter Krempa