提交 66025510 编写于 作者: J Ján Tomko

xml: namespaces: use uri instead of href

Store the namespace URI as const char*, instead of in a function.
Suggested-by: NJiri Denemark <jdenemar@redhat.com>
Signed-off-by: NJán Tomko <jtomko@redhat.com>
Reviewed-by: NJiri Denemark <jdenemar@redhat.com>
上级 6f2819ef
...@@ -31,8 +31,6 @@ ...@@ -31,8 +31,6 @@
VIR_LOG_INIT("bhyve.bhyve_domain"); VIR_LOG_INIT("bhyve.bhyve_domain");
#define BHYVE_NAMESPACE_HREF "http://libvirt.org/schemas/domain/bhyve/1.0"
static void * static void *
bhyveDomainObjPrivateAlloc(void *opaque ATTRIBUTE_UNUSED) bhyveDomainObjPrivateAlloc(void *opaque ATTRIBUTE_UNUSED)
{ {
...@@ -258,16 +256,11 @@ bhyveDomainDefNamespaceFormatXML(virBufferPtr buf, ...@@ -258,16 +256,11 @@ bhyveDomainDefNamespaceFormatXML(virBufferPtr buf,
return 0; return 0;
} }
static const char *
bhyveDomainDefNamespaceHref(void)
{
return BHYVE_NAMESPACE_HREF;
}
virXMLNamespace virBhyveDriverDomainXMLNamespace = { virXMLNamespace virBhyveDriverDomainXMLNamespace = {
.parse = bhyveDomainDefNamespaceParse, .parse = bhyveDomainDefNamespaceParse,
.free = bhyveDomainDefNamespaceFree, .free = bhyveDomainDefNamespaceFree,
.format = bhyveDomainDefNamespaceFormatXML, .format = bhyveDomainDefNamespaceFormatXML,
.prefix = "bhyve", .prefix = "bhyve",
.href = bhyveDomainDefNamespaceHref, .uri = "http://libvirt.org/schemas/domain/bhyve/1.0",
}; };
...@@ -34,7 +34,6 @@ ...@@ -34,7 +34,6 @@
#include "virinitctl.h" #include "virinitctl.h"
#define VIR_FROM_THIS VIR_FROM_LXC #define VIR_FROM_THIS VIR_FROM_LXC
#define LXC_NAMESPACE_HREF "http://libvirt.org/schemas/domain/lxc/1.0"
VIR_ENUM_IMPL(virLXCDomainJob, VIR_ENUM_IMPL(virLXCDomainJob,
LXC_JOB_LAST, LXC_JOB_LAST,
...@@ -302,19 +301,13 @@ lxcDomainDefNamespaceFormatXML(virBufferPtr buf, ...@@ -302,19 +301,13 @@ lxcDomainDefNamespaceFormatXML(virBufferPtr buf,
return 0; return 0;
} }
static const char *
lxcDomainDefNamespaceHref(void)
{
return LXC_NAMESPACE_HREF;
}
virXMLNamespace virLXCDriverDomainXMLNamespace = { virXMLNamespace virLXCDriverDomainXMLNamespace = {
.parse = lxcDomainDefNamespaceParse, .parse = lxcDomainDefNamespaceParse,
.free = lxcDomainDefNamespaceFree, .free = lxcDomainDefNamespaceFree,
.format = lxcDomainDefNamespaceFormatXML, .format = lxcDomainDefNamespaceFormatXML,
.prefix = "lxc", .prefix = "lxc",
.href = lxcDomainDefNamespaceHref, .uri = "http://libvirt.org/schemas/domain/lxc/1.0",
}; };
......
...@@ -83,8 +83,6 @@ ...@@ -83,8 +83,6 @@
VIR_LOG_INIT("network.bridge_driver"); VIR_LOG_INIT("network.bridge_driver");
#define DNSMASQ_NAMESPACE_HREF "http://libvirt.org/schemas/network/dnsmasq/1.0"
static virNetworkDriverStatePtr network_driver; static virNetworkDriverStatePtr network_driver;
...@@ -231,19 +229,12 @@ networkDnsmasqDefNamespaceFormatXML(virBufferPtr buf, ...@@ -231,19 +229,12 @@ networkDnsmasqDefNamespaceFormatXML(virBufferPtr buf,
} }
static const char *
networkDnsmasqDefNamespaceHref(void)
{
return DNSMASQ_NAMESPACE_HREF;
}
virXMLNamespace networkDnsmasqXMLNamespace = { virXMLNamespace networkDnsmasqXMLNamespace = {
.parse = networkDnsmasqDefNamespaceParse, .parse = networkDnsmasqDefNamespaceParse,
.free = networkDnsmasqDefNamespaceFree, .free = networkDnsmasqDefNamespaceFree,
.format = networkDnsmasqDefNamespaceFormatXML, .format = networkDnsmasqDefNamespaceFormatXML,
.prefix = "dnsmasq", .prefix = "dnsmasq",
.href = networkDnsmasqDefNamespaceHref, .uri = "http://libvirt.org/schemas/network/dnsmasq/1.0",
}; };
......
...@@ -81,8 +81,6 @@ ...@@ -81,8 +81,6 @@
VIR_LOG_INIT("qemu.qemu_domain"); VIR_LOG_INIT("qemu.qemu_domain");
#define QEMU_NAMESPACE_HREF "http://libvirt.org/schemas/domain/qemu/1.0"
VIR_ENUM_IMPL(qemuDomainJob, VIR_ENUM_IMPL(qemuDomainJob,
QEMU_JOB_LAST, QEMU_JOB_LAST,
"none", "none",
...@@ -3713,19 +3711,13 @@ qemuDomainDefNamespaceFormatXML(virBufferPtr buf, ...@@ -3713,19 +3711,13 @@ qemuDomainDefNamespaceFormatXML(virBufferPtr buf,
return 0; return 0;
} }
static const char *
qemuDomainDefNamespaceHref(void)
{
return QEMU_NAMESPACE_HREF;
}
virXMLNamespace virQEMUDriverDomainXMLNamespace = { virXMLNamespace virQEMUDriverDomainXMLNamespace = {
.parse = qemuDomainDefNamespaceParse, .parse = qemuDomainDefNamespaceParse,
.free = qemuDomainDefNamespaceFree, .free = qemuDomainDefNamespaceFree,
.format = qemuDomainDefNamespaceFormatXML, .format = qemuDomainDefNamespaceFormatXML,
.prefix = "qemu", .prefix = "qemu",
.href = qemuDomainDefNamespaceHref, .uri = "http://libvirt.org/schemas/domain/qemu/1.0",
}; };
......
...@@ -528,7 +528,6 @@ virStorageBackendFileSystemBuild(virStoragePoolObjPtr pool, ...@@ -528,7 +528,6 @@ virStorageBackendFileSystemBuild(virStoragePoolObjPtr pool,
#if WITH_STORAGE_FS #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 /* 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 * be added to the mount -o {options_list} command line that are not otherwise
...@@ -624,12 +623,6 @@ virStoragePoolDefFSNamespaceFormatXML(virBufferPtr buf, ...@@ -624,12 +623,6 @@ virStoragePoolDefFSNamespaceFormatXML(virBufferPtr buf,
} }
static const char *
virStoragePoolDefFSNamespaceHref(void)
{
return STORAGE_POOL_FS_NAMESPACE_HREF;
}
#endif /* WITH_STORAGE_FS */ #endif /* WITH_STORAGE_FS */
...@@ -697,7 +690,7 @@ static virXMLNamespace virStoragePoolFSXMLNamespace = { ...@@ -697,7 +690,7 @@ static virXMLNamespace virStoragePoolFSXMLNamespace = {
.free = virStoragePoolDefFSNamespaceFree, .free = virStoragePoolDefFSNamespaceFree,
.format = virStoragePoolDefFSNamespaceFormatXML, .format = virStoragePoolDefFSNamespaceFormatXML,
.prefix = "fs", .prefix = "fs",
.href = virStoragePoolDefFSNamespaceHref, .uri = "http://libvirt.org/schemas/storagepool/fs/1.0",
}; };
#endif /* WITH_STORAGE_FS */ #endif /* WITH_STORAGE_FS */
......
...@@ -58,8 +58,6 @@ struct _virStoragePoolRBDConfigOptionsDef { ...@@ -58,8 +58,6 @@ struct _virStoragePoolRBDConfigOptionsDef {
char **values; char **values;
}; };
#define STORAGE_POOL_RBD_NAMESPACE_HREF "http://libvirt.org/schemas/storagepool/rbd/1.0"
static void static void
virStoragePoolDefRBDNamespaceFree(void *nsdata) virStoragePoolDefRBDNamespaceFree(void *nsdata)
{ {
...@@ -166,13 +164,6 @@ virStoragePoolDefRBDNamespaceFormatXML(virBufferPtr buf, ...@@ -166,13 +164,6 @@ virStoragePoolDefRBDNamespaceFormatXML(virBufferPtr buf,
} }
static const char *
virStoragePoolDefRBDNamespaceHref(void)
{
return STORAGE_POOL_RBD_NAMESPACE_HREF;
}
static int static int
virStorageBackendRBDRADOSConfSet(rados_t cluster, virStorageBackendRBDRADOSConfSet(rados_t cluster,
const char *option, const char *option,
...@@ -1538,7 +1529,7 @@ static virXMLNamespace virStoragePoolRBDXMLNamespace = { ...@@ -1538,7 +1529,7 @@ static virXMLNamespace virStoragePoolRBDXMLNamespace = {
.free = virStoragePoolDefRBDNamespaceFree, .free = virStoragePoolDefRBDNamespaceFree,
.format = virStoragePoolDefRBDNamespaceFormatXML, .format = virStoragePoolDefRBDNamespaceFormatXML,
.prefix = "rbd", .prefix = "rbd",
.href = virStoragePoolDefRBDNamespaceHref, .uri = "http://libvirt.org/schemas/storagepool/rbd/1.0",
}; };
......
...@@ -167,8 +167,6 @@ testDriverDispose(void *obj) ...@@ -167,8 +167,6 @@ testDriverDispose(void *obj)
virObjectUnref(driver->eventState); virObjectUnref(driver->eventState);
} }
#define TEST_NAMESPACE_HREF "http://libvirt.org/schemas/domain/test/1.0"
typedef struct _testDomainNamespaceDef testDomainNamespaceDef; typedef struct _testDomainNamespaceDef testDomainNamespaceDef;
typedef testDomainNamespaceDef *testDomainNamespaceDefPtr; typedef testDomainNamespaceDef *testDomainNamespaceDefPtr;
struct _testDomainNamespaceDef { struct _testDomainNamespaceDef {
...@@ -180,12 +178,6 @@ struct _testDomainNamespaceDef { ...@@ -180,12 +178,6 @@ struct _testDomainNamespaceDef {
xmlNodePtr *snap_nodes; xmlNodePtr *snap_nodes;
}; };
static const char*
testDomainDefNamespaceHref(void)
{
return TEST_NAMESPACE_HREF;
}
static void static void
testDomainDefNamespaceFree(void *data) testDomainDefNamespaceFree(void *data)
{ {
...@@ -427,7 +419,7 @@ testDriverNew(void) ...@@ -427,7 +419,7 @@ testDriverNew(void)
.parse = testDomainDefNamespaceParse, .parse = testDomainDefNamespaceParse,
.free = testDomainDefNamespaceFree, .free = testDomainDefNamespaceFree,
.prefix = "test", .prefix = "test",
.href = testDomainDefNamespaceHref, .uri = "http://libvirt.org/schemas/domain/test/1.0",
}; };
virDomainDefParserConfig config = { virDomainDefParserConfig config = {
.features = VIR_DOMAIN_DEF_FEATURE_MEMORY_HOTPLUG | .features = VIR_DOMAIN_DEF_FEATURE_MEMORY_HOTPLUG |
......
...@@ -1416,7 +1416,7 @@ void ...@@ -1416,7 +1416,7 @@ void
virXMLNamespaceFormatNS(virBufferPtr buf, virXMLNamespaceFormatNS(virBufferPtr buf,
virXMLNamespace const *ns) 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, ...@@ -1426,10 +1426,10 @@ virXMLNamespaceRegister(xmlXPathContextPtr ctxt,
{ {
if (xmlXPathRegisterNs(ctxt, if (xmlXPathRegisterNs(ctxt,
BAD_CAST ns->prefix, BAD_CAST ns->prefix,
BAD_CAST ns->href()) < 0) { BAD_CAST ns->uri) < 0) {
virReportError(VIR_ERR_INTERNAL_ERROR, virReportError(VIR_ERR_INTERNAL_ERROR,
_("Failed to register xml namespace '%s'"), _("Failed to register xml namespace '%s'"),
ns->href()); ns->uri);
return -1; return -1;
} }
......
...@@ -257,7 +257,7 @@ struct _virXMLNamespace { ...@@ -257,7 +257,7 @@ struct _virXMLNamespace {
virXMLNamespaceFree free; virXMLNamespaceFree free;
virXMLNamespaceFormat format; virXMLNamespaceFormat format;
const char *prefix; const char *prefix;
virXMLNamespaceHref href; const char *uri;
}; };
typedef struct _virXMLNamespace virXMLNamespace; typedef struct _virXMLNamespace virXMLNamespace;
typedef virXMLNamespace *virXMLNamespacePtr; typedef virXMLNamespace *virXMLNamespacePtr;
......
...@@ -597,18 +597,12 @@ virVMXDomainDefNamespaceFormatXML(virBufferPtr buf, void *nsdata) ...@@ -597,18 +597,12 @@ virVMXDomainDefNamespaceFormatXML(virBufferPtr buf, void *nsdata)
return 0; return 0;
} }
static const char *
virVMXDomainDefNamespaceHref(void)
{
return "http://libvirt.org/schemas/domain/vmware/1.0";
}
static virXMLNamespace virVMXDomainXMLNamespace = { static virXMLNamespace virVMXDomainXMLNamespace = {
.parse = NULL, .parse = NULL,
.free = virVMXDomainDefNamespaceFree, .free = virVMXDomainDefNamespaceFree,
.format = virVMXDomainDefNamespaceFormatXML, .format = virVMXDomainDefNamespaceFormatXML,
.prefix = "vmware", .prefix = "vmware",
.href = virVMXDomainDefNamespaceHref, .uri = "http://libvirt.org/schemas/domain/vmware/1.0",
}; };
virDomainXMLOptionPtr virDomainXMLOptionPtr
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册