[PATCH v4 2/4] conf: Support to parse rbd namespace attribute

Han Han hhan at redhat.com
Fri Aug 7 09:49:13 UTC 2020


Signed-off-by: Han Han <hhan at redhat.com>
---
 docs/formatdomain.rst         | 5 ++++-
 docs/schemas/domaincommon.rng | 3 +++
 src/conf/domain_conf.c        | 4 ++++
 src/util/virstoragefile.h     | 1 +
 4 files changed, 12 insertions(+), 1 deletion(-)

diff --git a/docs/formatdomain.rst b/docs/formatdomain.rst
index 218f0c1718..431abc6f56 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="image_name2" namespace="ns"">
          <host name="hostname" port="7000"/>
          <snapshot name="snapname"/>
          <config file="/path/to/file"/>
@@ -2497,6 +2497,9 @@ paravirtualized driver is specified via the ``disk`` element.
       For protocols ``http`` and ``https`` an optional attribute ``query``
       specifies the query string. ( :since:`Since 6.2.0` )
 
+      For protocol ``rbd``, an optional attribute ``namespace`` specifies the
+      namespace of a rbd pool. ( :since:`Since 6.7.0 and QEMU 5.0.0` )
+
       For "iscsi" ( :since:`since 1.0.4` ), the ``name`` attribute may include a
       logical unit number, separated from the target's name by a slash (e.g.,
       ``iqn.2013-07.com.example:iscsi-pool/1``). If not specified, the default
diff --git a/docs/schemas/domaincommon.rng b/docs/schemas/domaincommon.rng
index 0d0dcbc5ce..ee09da3c7c 100644
--- a/docs/schemas/domaincommon.rng
+++ b/docs/schemas/domaincommon.rng
@@ -1762,6 +1762,9 @@
         <optional>
           <attribute name="name"/>
         </optional>
+        <optional>
+          <attribute name="namespace"/>
+        </optional>
         <zeroOrMore>
           <ref name="diskSourceNetworkHost"/>
         </zeroOrMore>
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index ef67efa1da..4b5e752c6f 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -9601,6 +9601,7 @@ virDomainDiskSourceNetworkParse(xmlNodePtr node,
 
     /* config file currently only works with remote disks */
     src->configFile = virXPathString("string(./config/@file)", ctxt);
+    src->ns = virXPathString("string(./@namespace)", ctxt);
 
     if (src->protocol == VIR_STORAGE_NET_PROTOCOL_HTTP ||
         src->protocol == VIR_STORAGE_NET_PROTOCOL_HTTPS)
@@ -25083,6 +25084,9 @@ virDomainDiskSourceFormatNetwork(virBufferPtr attrBuf,
         path = g_strdup_printf("%s/%s", src->volume, src->path);
 
     virBufferEscapeString(attrBuf, " name='%s'", path ? path : src->path);
+    if (src->ns)
+        virBufferEscapeString(attrBuf, " namespace='%s'", src->ns);
+
     virBufferEscapeString(attrBuf, " query='%s'", src->query);
 
     if (src->haveTLS != VIR_TRISTATE_BOOL_ABSENT &&
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.27.0




More information about the libvir-list mailing list