virConnectGetConfig and virConnectGetConfigPath were static libvirt
methods, merely because there hasn't been any need for having them
internally exported yet. Since libvirt-admin also needs to reference
libvirt config file, 'xGetConfig' should be exported.
Besides moving, this patch also renames the methods accordingly,
as they are libvirt config specific.
---
src/libvirt.c | 55 +-----------------------------------------------
src/libvirt_private.syms | 1 +
src/util/virconf.c | 52 +++++++++++++++++++++++++++++++++++++++++++++
src/util/virconf.h | 2 +-
4 files changed, 55 insertions(+), 55 deletions(-)
diff --git a/src/libvirt.c b/src/libvirt.c
index 2602dde..5ee41ef 100644
--- a/src/libvirt.c
+++ b/src/libvirt.c
@@ -908,59 +908,6 @@ virGetVersion(unsigned long *libVer, const char *type
ATTRIBUTE_UNUSED,
return -1;
}
-
-static char *
-virConnectGetConfigFilePath(void)
-{
- char *path;
- if (geteuid() == 0) {
- if (virAsprintf(&path, "%s/libvirt/libvirt.conf",
- SYSCONFDIR) < 0)
- return NULL;
- } else {
- char *userdir = virGetUserConfigDirectory();
- if (!userdir)
- return NULL;
-
- if (virAsprintf(&path, "%s/libvirt.conf",
- userdir) < 0) {
- VIR_FREE(userdir);
- return NULL;
- }
- VIR_FREE(userdir);
- }
-
- return path;
-}
-
-
-static int
-virConnectGetConfigFile(virConfPtr *conf)
-{
- char *filename = NULL;
- int ret = -1;
-
- *conf = NULL;
-
- if (!(filename = virConnectGetConfigFilePath()))
- goto cleanup;
-
- if (!virFileExists(filename)) {
- ret = 0;
- goto cleanup;
- }
-
- VIR_DEBUG("Loading config file '%s'", filename);
- if (!(*conf = virConfReadFile(filename, 0)))
- goto cleanup;
-
- ret = 0;
-
- cleanup:
- VIR_FREE(filename);
- return ret;
-}
-
#define URI_ALIAS_CHARS
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789_-"
@@ -1078,7 +1025,7 @@ do_open(const char *name,
if (ret == NULL)
return NULL;
- if (virConnectGetConfigFile(&conf) < 0)
+ if (virGetLibvirtConfigFile(&conf) < 0)
goto failed;
if (name && name[0] == '\0')
diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
index be6ee19..b72a0ee 100644
--- a/src/libvirt_private.syms
+++ b/src/libvirt_private.syms
@@ -1332,6 +1332,7 @@ virConfTypeToString;
virConfWalk;
virConfWriteFile;
virConfWriteMem;
+virGetLibvirtConfigFile;
# util/vircrypto.h
diff --git a/src/util/virconf.c b/src/util/virconf.c
index 9f2d116..0b3d7da 100644
--- a/src/util/virconf.c
+++ b/src/util/virconf.c
@@ -38,6 +38,7 @@
#include "viralloc.h"
#include "virfile.h"
#include "virstring.h"
+#include "configmake.h"
#define VIR_FROM_THIS VIR_FROM_CONF
@@ -1053,3 +1054,54 @@ virConfWriteMem(char *memory, int *len, virConfPtr conf)
*len = use;
return use;
}
+
+static char *
+virGetLibvirtConfigFilePath(void)
+{
+ char *path;
+ if (geteuid() == 0) {
+ if (virAsprintf(&path, "%s/libvirt/libvirt.conf",
+ SYSCONFDIR) < 0)
+ return NULL;
+ } else {
+ char *userdir = virGetUserConfigDirectory();
+ if (!userdir)
+ return NULL;
+
+ if (virAsprintf(&path, "%s/libvirt.conf",
+ userdir) < 0) {
+ VIR_FREE(userdir);
+ return NULL;
+ }
+ VIR_FREE(userdir);
+ }
+
+ return path;
+}
+
+int
+virGetLibvirtConfigFile(virConfPtr *conf)
+{
+ char *filename = NULL;
+ int ret = -1;
+
+ *conf = NULL;
+
+ if (!(filename = virGetLibvirtConfigFilePath()))
+ goto cleanup;
+
+ if (!virFileExists(filename)) {
+ ret = 0;
+ goto cleanup;
+ }
+
+ VIR_DEBUG("Loading config file '%s'", filename);
+ if (!(*conf = virConfReadFile(filename, 0)))
+ goto cleanup;
+
+ ret = 0;
+
+ cleanup:
+ VIR_FREE(filename);
+ return ret;
+}
diff --git a/src/util/virconf.h b/src/util/virconf.h
index 8037956..dad7dba 100644
--- a/src/util/virconf.h
+++ b/src/util/virconf.h
@@ -96,5 +96,5 @@ int virConfWriteFile(const char *filename,
int virConfWriteMem(char *memory,
int *len,
virConfPtr conf);
-
+int virGetLibvirtConfigFile(virConfPtr *conf);
#endif /* __VIR_CONF_H__ */
--
2.4.3