[PATCH v3 2/5] conf: Support to parse rbd namespace attribute

Han Han posted 5 patches 5 years, 6 months ago
There is a newer version of this series
[PATCH v3 2/5] conf: Support to parse rbd namespace attribute
Posted by Han Han 5 years, 6 months ago
Signed-off-by: Han Han <hhan@redhat.com>
---
 src/conf/domain_conf.c    | 4 ++++
 src/util/virstoragefile.h | 1 +
 2 files changed, 5 insertions(+)

diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index ef67efa1da..163c934428 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->namespace = 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->namespace)
+        virBufferEscapeString(attrBuf, " namespace='%s'", src->namespace);
+
     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..0364fe5e7e 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 *namespace; /* for the storage systems supporting namespace */
     char *query; /* query string for HTTP based protocols */
     size_t nhosts;
     virStorageNetHostDefPtr hosts;
-- 
2.27.0

Re: [PATCH v3 2/5] conf: Support to parse rbd namespace attribute
Posted by Peter Krempa 5 years, 6 months ago
On Thu, Aug 06, 2020 at 19:41:43 +0800, Han Han wrote:
> Signed-off-by: Han Han <hhan@redhat.com>
> ---
>  src/conf/domain_conf.c    | 4 ++++
>  src/util/virstoragefile.h | 1 +
>  2 files changed, 5 insertions(+)

[...]

> diff --git a/src/util/virstoragefile.h b/src/util/virstoragefile.h
> index f73b3ee005..0364fe5e7e 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 *namespace; /* for the storage systems supporting namespace */

'namespace' is a c++ keyword. Consider using a different identifier.