[PATCH] xml: namespaces: use uri instead of href

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Store the namespace URI as const char*, instead of in a function.

Suggested-by: Jiri Denemark <jdenemar@xxxxxxxxxx>
Signed-off-by: Ján Tomko <jtomko@xxxxxxxxxx>
---
 src/bhyve/bhyve_domain.c          | 11 ++---------
 src/lxc/lxc_domain.c              |  9 +--------
 src/network/bridge_driver.c       | 11 +----------
 src/qemu/qemu_domain.c            | 10 +---------
 src/storage/storage_backend_fs.c  |  9 +--------
 src/storage/storage_backend_rbd.c | 11 +----------
 src/test/test_driver.c            | 11 ++---------
 src/util/virxml.c                 |  6 +++---
 src/util/virxml.h                 |  2 +-
 src/vmx/vmx.c                     |  8 +-------
 10 files changed, 14 insertions(+), 74 deletions(-)

diff --git a/src/bhyve/bhyve_domain.c b/src/bhyve/bhyve_domain.c
index ea4bd54969..ed281d7c68 100644
--- a/src/bhyve/bhyve_domain.c
+++ b/src/bhyve/bhyve_domain.c
@@ -31,8 +31,6 @@
 
 VIR_LOG_INIT("bhyve.bhyve_domain");
 
-#define BHYVE_NAMESPACE_HREF "http://libvirt.org/schemas/domain/bhyve/1.0";
-
 static void *
 bhyveDomainObjPrivateAlloc(void *opaque ATTRIBUTE_UNUSED)
 {
@@ -258,16 +256,11 @@ bhyveDomainDefNamespaceFormatXML(virBufferPtr buf,
     return 0;
 }
 
-static const char *
-bhyveDomainDefNamespaceHref(void)
-{
-    return BHYVE_NAMESPACE_HREF;
-}
-
 virXMLNamespace virBhyveDriverDomainXMLNamespace = {
     .parse = bhyveDomainDefNamespaceParse,
     .free = bhyveDomainDefNamespaceFree,
     .format = bhyveDomainDefNamespaceFormatXML,
     .prefix = "bhyve",
-    .href = bhyveDomainDefNamespaceHref,
+    .uri = "http://libvirt.org/schemas/domain/bhyve/1.0";,
+
 };
diff --git a/src/lxc/lxc_domain.c b/src/lxc/lxc_domain.c
index 00362e4c7f..c4360f25f6 100644
--- a/src/lxc/lxc_domain.c
+++ b/src/lxc/lxc_domain.c
@@ -34,7 +34,6 @@
 #include "virinitctl.h"
 
 #define VIR_FROM_THIS VIR_FROM_LXC
-#define LXC_NAMESPACE_HREF "http://libvirt.org/schemas/domain/lxc/1.0";
 
 VIR_ENUM_IMPL(virLXCDomainJob,
               LXC_JOB_LAST,
@@ -302,19 +301,13 @@ lxcDomainDefNamespaceFormatXML(virBufferPtr buf,
     return 0;
 }
 
-static const char *
-lxcDomainDefNamespaceHref(void)
-{
-    return LXC_NAMESPACE_HREF;
-}
-
 
 virXMLNamespace virLXCDriverDomainXMLNamespace = {
     .parse = lxcDomainDefNamespaceParse,
     .free = lxcDomainDefNamespaceFree,
     .format = lxcDomainDefNamespaceFormatXML,
     .prefix = "lxc",
-    .href = lxcDomainDefNamespaceHref,
+    .uri = "http://libvirt.org/schemas/domain/lxc/1.0";,
 };
 
 
diff --git a/src/network/bridge_driver.c b/src/network/bridge_driver.c
index dd4f111cc0..86e2035b85 100644
--- a/src/network/bridge_driver.c
+++ b/src/network/bridge_driver.c
@@ -83,8 +83,6 @@
 
 VIR_LOG_INIT("network.bridge_driver");
 
-#define DNSMASQ_NAMESPACE_HREF "http://libvirt.org/schemas/network/dnsmasq/1.0";
-
 static virNetworkDriverStatePtr network_driver;
 
 
@@ -231,19 +229,12 @@ networkDnsmasqDefNamespaceFormatXML(virBufferPtr buf,
 }
 
 
-static const char *
-networkDnsmasqDefNamespaceHref(void)
-{
-    return DNSMASQ_NAMESPACE_HREF;
-}
-
-
 virXMLNamespace networkDnsmasqXMLNamespace = {
     .parse = networkDnsmasqDefNamespaceParse,
     .free = networkDnsmasqDefNamespaceFree,
     .format = networkDnsmasqDefNamespaceFormatXML,
     .prefix = "dnsmasq",
-    .href = networkDnsmasqDefNamespaceHref,
+    .uri = "http://libvirt.org/schemas/network/dnsmasq/1.0";,
 };
 
 
diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
index 6d770d3c13..8a3755c6fe 100644
--- a/src/qemu/qemu_domain.c
+++ b/src/qemu/qemu_domain.c
@@ -81,8 +81,6 @@
 
 VIR_LOG_INIT("qemu.qemu_domain");
 
-#define QEMU_NAMESPACE_HREF "http://libvirt.org/schemas/domain/qemu/1.0";
-
 VIR_ENUM_IMPL(qemuDomainJob,
               QEMU_JOB_LAST,
               "none",
@@ -3713,19 +3711,13 @@ qemuDomainDefNamespaceFormatXML(virBufferPtr buf,
     return 0;
 }
 
-static const char *
-qemuDomainDefNamespaceHref(void)
-{
-    return QEMU_NAMESPACE_HREF;
-}
-
 
 virXMLNamespace virQEMUDriverDomainXMLNamespace = {
     .parse = qemuDomainDefNamespaceParse,
     .free = qemuDomainDefNamespaceFree,
     .format = qemuDomainDefNamespaceFormatXML,
     .prefix = "qemu",
-    .href = qemuDomainDefNamespaceHref,
+    .uri = "http://libvirt.org/schemas/domain/qemu/1.0";,
 };
 
 
diff --git a/src/storage/storage_backend_fs.c b/src/storage/storage_backend_fs.c
index d947beac2c..d793ac19e8 100644
--- a/src/storage/storage_backend_fs.c
+++ b/src/storage/storage_backend_fs.c
@@ -528,7 +528,6 @@ virStorageBackendFileSystemBuild(virStoragePoolObjPtr pool,
 
 #if WITH_STORAGE_FS
 
-# define STORAGE_POOL_FS_NAMESPACE_HREF "http://libvirt.org/schemas/storagepool/fs/1.0";
 
 /* Backend XML Namespace handling for fs or netfs specific mount options to
  * be added to the mount -o {options_list} command line that are not otherwise
@@ -624,12 +623,6 @@ virStoragePoolDefFSNamespaceFormatXML(virBufferPtr buf,
 }
 
 
-static const char *
-virStoragePoolDefFSNamespaceHref(void)
-{
-    return STORAGE_POOL_FS_NAMESPACE_HREF;
-}
-
 #endif /* WITH_STORAGE_FS */
 
 
@@ -697,7 +690,7 @@ static virXMLNamespace virStoragePoolFSXMLNamespace = {
     .free = virStoragePoolDefFSNamespaceFree,
     .format = virStoragePoolDefFSNamespaceFormatXML,
     .prefix = "fs",
-    .href = virStoragePoolDefFSNamespaceHref,
+    .uri = "http://libvirt.org/schemas/storagepool/fs/1.0";,
 };
 #endif /* WITH_STORAGE_FS */
 
diff --git a/src/storage/storage_backend_rbd.c b/src/storage/storage_backend_rbd.c
index 22caa189d7..c4781debd8 100644
--- a/src/storage/storage_backend_rbd.c
+++ b/src/storage/storage_backend_rbd.c
@@ -58,8 +58,6 @@ struct _virStoragePoolRBDConfigOptionsDef {
     char **values;
 };
 
-#define STORAGE_POOL_RBD_NAMESPACE_HREF "http://libvirt.org/schemas/storagepool/rbd/1.0";
-
 static void
 virStoragePoolDefRBDNamespaceFree(void *nsdata)
 {
@@ -166,13 +164,6 @@ virStoragePoolDefRBDNamespaceFormatXML(virBufferPtr buf,
 }
 
 
-static const char *
-virStoragePoolDefRBDNamespaceHref(void)
-{
-    return STORAGE_POOL_RBD_NAMESPACE_HREF;
-}
-
-
 static int
 virStorageBackendRBDRADOSConfSet(rados_t cluster,
                                  const char *option,
@@ -1538,7 +1529,7 @@ static virXMLNamespace virStoragePoolRBDXMLNamespace = {
     .free = virStoragePoolDefRBDNamespaceFree,
     .format = virStoragePoolDefRBDNamespaceFormatXML,
     .prefix = "rbd",
-    .href = virStoragePoolDefRBDNamespaceHref,
+    .uri = "http://libvirt.org/schemas/storagepool/rbd/1.0";,
 };
 
 
diff --git a/src/test/test_driver.c b/src/test/test_driver.c
index 57d54c05b3..6a694d8b1f 100644
--- a/src/test/test_driver.c
+++ b/src/test/test_driver.c
@@ -167,8 +167,6 @@ testDriverDispose(void *obj)
     virObjectUnref(driver->eventState);
 }
 
-#define TEST_NAMESPACE_HREF "http://libvirt.org/schemas/domain/test/1.0";
-
 typedef struct _testDomainNamespaceDef testDomainNamespaceDef;
 typedef testDomainNamespaceDef *testDomainNamespaceDefPtr;
 struct _testDomainNamespaceDef {
@@ -180,12 +178,6 @@ struct _testDomainNamespaceDef {
     xmlNodePtr *snap_nodes;
 };
 
-static const char*
-testDomainDefNamespaceHref(void)
-{
-    return TEST_NAMESPACE_HREF;
-}
-
 static void
 testDomainDefNamespaceFree(void *data)
 {
@@ -427,7 +419,8 @@ testDriverNew(void)
         .parse = testDomainDefNamespaceParse,
         .free = testDomainDefNamespaceFree,
         .prefix = "test",
-        .href = testDomainDefNamespaceHref,
+        .uri = "http://libvirt.org/schemas/domain/test/1.0";,
+
     };
     virDomainDefParserConfig config = {
         .features = VIR_DOMAIN_DEF_FEATURE_MEMORY_HOTPLUG |
diff --git a/src/util/virxml.c b/src/util/virxml.c
index 84b824f432..f9c117dd58 100644
--- a/src/util/virxml.c
+++ b/src/util/virxml.c
@@ -1416,7 +1416,7 @@ void
 virXMLNamespaceFormatNS(virBufferPtr buf,
                         virXMLNamespace const *ns)
 {
-    virBufferAsprintf(buf, " xmlns:%s='%s'", ns->prefix, ns->href());
+    virBufferAsprintf(buf, " xmlns:%s='%s'", ns->prefix, ns->uri);
 }
 
 
@@ -1426,10 +1426,10 @@ virXMLNamespaceRegister(xmlXPathContextPtr ctxt,
 {
     if (xmlXPathRegisterNs(ctxt,
                            BAD_CAST ns->prefix,
-                           BAD_CAST ns->href()) < 0) {
+                           BAD_CAST ns->uri) < 0) {
         virReportError(VIR_ERR_INTERNAL_ERROR,
                        _("Failed to register xml namespace '%s'"),
-                       ns->href());
+                       ns->uri);
         return -1;
     }
 
diff --git a/src/util/virxml.h b/src/util/virxml.h
index be2abd23f7..30cc895436 100644
--- a/src/util/virxml.h
+++ b/src/util/virxml.h
@@ -257,7 +257,7 @@ struct _virXMLNamespace {
     virXMLNamespaceFree free;
     virXMLNamespaceFormat format;
     const char *prefix;
-    virXMLNamespaceHref href;
+    const char *uri;
 };
 typedef struct _virXMLNamespace virXMLNamespace;
 typedef virXMLNamespace *virXMLNamespacePtr;
diff --git a/src/vmx/vmx.c b/src/vmx/vmx.c
index c4e90537f8..2cc0995783 100644
--- a/src/vmx/vmx.c
+++ b/src/vmx/vmx.c
@@ -597,18 +597,12 @@ virVMXDomainDefNamespaceFormatXML(virBufferPtr buf, void *nsdata)
     return 0;
 }
 
-static const char *
-virVMXDomainDefNamespaceHref(void)
-{
-    return "http://libvirt.org/schemas/domain/vmware/1.0";;
-}
-
 static virXMLNamespace virVMXDomainXMLNamespace = {
     .parse = NULL,
     .free = virVMXDomainDefNamespaceFree,
     .format = virVMXDomainDefNamespaceFormatXML,
     .prefix = "vmware",
-    .href = virVMXDomainDefNamespaceHref,
+    .uri = "http://libvirt.org/schemas/domain/vmware/1.0";,
 };
 
 virDomainXMLOptionPtr
-- 
2.19.2

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list




[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]

  Powered by Linux