[libvirt] [PATCH] Use XDG Base Directories instead of storing in home directory
by William Jon McCann
As defined in:
http://standards.freedesktop.org/basedir-spec/basedir-spec-latest.html
This offers a number of advantages:
* Allows sharing a home directory between different machines, or
sessions (eg. using NFS)
* Cleanly separates cache, runtime (eg. sockets), or app data from
user settings
* Supports performing smart or selective migration of settings
between different OS versions
* Supports reseting settings without breaking things
* Makes it possible to clear cache data to make room when the disk
is filling up
* Allows us to write a robust and efficient backup solution
* Allows an admin flexibility to change where data and settings are stored
* Dramatically reduces the complexity and incoherence of the
system for administrators
---
AUTHORS | 1 +
daemon/libvirtd-config.c | 10 +--
daemon/libvirtd.c | 143 +++++++++++++++++++++++++++++++++-------
daemon/libvirtd.pod.in | 2 +-
docs/auth.html.in | 2 +-
docs/uri.html.in | 2 +-
src/libvirt.c | 4 +-
src/libvirt_private.syms | 4 ++
src/network/bridge_driver.c | 8 ++-
src/nwfilter/nwfilter_driver.c | 11 +---
src/qemu/qemu_driver.c | 32 +++++----
src/remote/remote_driver.c | 4 +-
src/remote/remote_driver.h | 2 +-
src/secret/secret_driver.c | 11 +---
src/storage/storage_driver.c | 13 +---
src/uml/uml_driver.c | 10 +--
src/util/util.c | 67 +++++++++++++++++++
src/util/util.h | 4 ++
src/util/virauth.c | 4 +-
tools/virsh.c | 6 +-
20 files changed, 251 insertions(+), 89 deletions(-)
diff --git a/AUTHORS b/AUTHORS
index 06b830a..668eca1 100644
--- a/AUTHORS
+++ b/AUTHORS
@@ -234,6 +234,7 @@ Patches have also been contributed by:
Jan Kiszka <jan.kiszka(a)siemens.com>
Ryan Woodsmall <rwoodsmall(a)gmail.com>
Wido den Hollander <wido(a)widodh.nl>
+ William Jon McCann <jmccann(a)redhat.com>
[....send patches to get your name here....]
diff --git a/daemon/libvirtd-config.c b/daemon/libvirtd-config.c
index 471236c..8b95969 100644
--- a/daemon/libvirtd-config.c
+++ b/daemon/libvirtd-config.c
@@ -205,16 +205,16 @@ daemonConfigFilePath(bool privileged, char **configfile)
if (!(*configfile = strdup(SYSCONFDIR "/libvirt/libvirtd.conf")))
goto no_memory;
} else {
- char *userdir = NULL;
+ char *configdir = NULL;
- if (!(userdir = virGetUserDirectory(geteuid())))
+ if (!(configdir = virGetUserConfigDirectory(geteuid())))
goto error;
- if (virAsprintf(configfile, "%s/.libvirt/libvirtd.conf", userdir) < 0) {
- VIR_FREE(userdir);
+ if (virAsprintf(configfile, "%s/libvirtd.conf", configdir) < 0) {
+ VIR_FREE(configdir);
goto no_memory;
}
- VIR_FREE(userdir);
+ VIR_FREE(configdir);
}
return 0;
diff --git a/daemon/libvirtd.c b/daemon/libvirtd.c
index b098f6a..bb25678 100644
--- a/daemon/libvirtd.c
+++ b/daemon/libvirtd.c
@@ -239,17 +239,25 @@ daemonPidFilePath(bool privileged,
if (!(*pidfile = strdup(LOCALSTATEDIR "/run/libvirtd.pid")))
goto no_memory;
} else {
- char *userdir = NULL;
+ char *rundir = NULL;
+ mode_t old_umask;
- if (!(userdir = virGetUserDirectory(geteuid())))
+ if (!(rundir = virGetUserRuntimeDirectory(geteuid())))
goto error;
- if (virAsprintf(pidfile, "%s/.libvirt/libvirtd.pid", userdir) < 0) {
- VIR_FREE(userdir);
+ old_umask = umask(077);
+ if (virFileMakePath(rundir) < 0) {
+ umask(old_umask);
+ goto error;
+ }
+ umask(old_umask);
+
+ if (virAsprintf(pidfile, "%s/libvirtd.pid", rundir) < 0) {
+ VIR_FREE(rundir);
goto no_memory;
}
- VIR_FREE(userdir);
+ VIR_FREE(rundir);
}
return 0;
@@ -279,17 +287,25 @@ daemonUnixSocketPaths(struct daemonConfig *config,
if (!(*rosockfile = strdup(LOCALSTATEDIR "/run/libvirt/libvirt-sock-ro")))
goto no_memory;
} else {
- char *userdir = NULL;
+ char *rundir = NULL;
+ mode_t old_umask;
- if (!(userdir = virGetUserDirectory(geteuid())))
+ if (!(rundir = virGetUserRuntimeDirectory(geteuid())))
goto error;
- if (virAsprintf(sockfile, "@%s/.libvirt/libvirt-sock", userdir) < 0) {
- VIR_FREE(userdir);
+ old_umask = umask(077);
+ if (virFileMakePath(rundir) < 0) {
+ umask(old_umask);
+ goto error;
+ }
+ umask(old_umask);
+
+ if (virAsprintf(sockfile, "@%s/libvirt-sock", rundir) < 0) {
+ VIR_FREE(rundir);
goto no_memory;
}
- VIR_FREE(userdir);
+ VIR_FREE(rundir);
}
}
return 0;
@@ -593,16 +609,25 @@ daemonSetupLogging(struct daemonConfig *config,
LOCALSTATEDIR) == -1)
goto no_memory;
} else {
- char *userdir = virGetUserDirectory(geteuid());
- if (!userdir)
+ char *logdir = virGetUserCacheDirectory(geteuid());
+ mode_t old_umask;
+
+ if (!logdir)
+ goto error;
+
+ old_umask = umask(077);
+ if (virFileMakePath(logdir) < 0) {
+ umask(old_umask);
goto error;
+ }
+ umask(old_umask);
- if (virAsprintf(&tmp, "%d:file:%s/.libvirt/libvirtd.log",
- virLogGetDefaultPriority(), userdir) == -1) {
- VIR_FREE(userdir);
+ if (virAsprintf(&tmp, "%d:file:%s/libvirtd.log",
+ virLogGetDefaultPriority(), logdir) == -1) {
+ VIR_FREE(logdir);
goto no_memory;
}
- VIR_FREE(userdir);
+ VIR_FREE(logdir);
}
} else {
if (virAsprintf(&tmp, "%d:stderr", virLogGetDefaultPriority()) < 0)
@@ -722,6 +747,75 @@ static int daemonStateInit(virNetServerPtr srv)
return 0;
}
+static int migrateProfile(void)
+{
+ char *old_base = NULL;
+ char *updated = NULL;
+ char *home = NULL;
+ char *xdg_dir = NULL;
+ char *config_dir = NULL;
+ const char *config_home;
+ int ret = -1;
+ mode_t old_umask;
+
+ if (!(home = virGetUserDirectory(geteuid())))
+ goto cleanup;
+
+ if (virAsprintf(&old_base, "%s/.libvirt", home) < 0) {
+ goto cleanup;
+ }
+
+ /* if the new directory is there or the old one is not: do nothing */
+ if (!(config_dir = virGetUserConfigDirectory(geteuid())))
+ goto cleanup;
+
+ if (!virFileIsDir(old_base) || virFileExists(config_dir)) {
+ goto cleanup;
+ }
+
+ /* test if we already attempted to migrate first */
+ if (virAsprintf(&updated, "%s/DEPRECATED-DIRECTORY", old_base) < 0) {
+ goto cleanup;
+ }
+ if (virFileExists(updated)) {
+ goto cleanup;
+ }
+
+ config_home = getenv("XDG_CONFIG_HOME");
+ if (config_home && config_home[0] != '\0') {
+ xdg_dir = strdup(config_home);
+ } else {
+ if (virAsprintf(&xdg_dir, "%s/.config", home) < 0) {
+ goto cleanup;
+ }
+ }
+
+ old_umask = umask(077);
+ if (virFileMakePath(xdg_dir) < 0) {
+ umask(old_umask);
+ goto cleanup;
+ }
+ umask(old_umask);
+
+ if (rename(old_base, config_dir) < 0) {
+ int fd = creat(updated, 0600);
+ VIR_FORCE_CLOSE(fd);
+ VIR_ERROR(_("Unable to migrate %s to %s"), old_base, config_dir);
+ goto cleanup;
+ }
+
+ ret = 0;
+
+ cleanup:
+ VIR_FREE(home);
+ VIR_FREE(old_base);
+ VIR_FREE(xdg_dir);
+ VIR_FREE(config_dir);
+ VIR_FREE(updated);
+
+ return ret;
+}
+
/* Print command-line usage. */
static void
daemonUsage(const char *argv0, bool privileged)
@@ -775,10 +869,10 @@ libvirt management daemon:\n"), argv0);
Default paths:\n\
\n\
Configuration file (unless overridden by -f):\n\
- $HOME/.libvirt/libvirtd.conf\n\
+ $XDG_CONFIG_HOME/libvirt/libvirtd.conf\n\
\n\
Sockets:\n\
- $HOME/.libvirt/libvirt-sock (in UNIX abstract namespace)\n\
+ $XDG_RUNTIME_HOME/libvirt/libvirt-sock (in UNIX abstract namespace)\n\
\n\
TLS:\n\
CA certificate: $HOME/.pki/libvirt/cacert.pem\n\
@@ -786,7 +880,7 @@ libvirt management daemon:\n"), argv0);
Server private key: $HOME/.pki/libvirt/serverkey.pem\n\
\n\
PID file:\n\
- $HOME/.libvirt/libvirtd.pid\n\
+ $XDG_RUNTIME_HOME/libvirt/libvirtd.pid\n\
\n"));
}
}
@@ -931,6 +1025,9 @@ int main(int argc, char **argv) {
exit(EXIT_FAILURE);
}
+ if (migrateProfile() < 0)
+ exit(EXIT_FAILURE);
+
if (config->host_uuid &&
virSetHostUUIDStr(config->host_uuid) < 0) {
VIR_ERROR(_("invalid host UUID: %s"), config->host_uuid);
@@ -977,21 +1074,19 @@ int main(int argc, char **argv) {
if (privileged) {
run_dir = strdup(LOCALSTATEDIR "/run/libvirt");
} else {
- char *user_dir = virGetUserDirectory(geteuid());
+ run_dir = virGetUserRuntimeDirectory(geteuid());
- if (!user_dir) {
+ if (!run_dir) {
VIR_ERROR(_("Can't determine user directory"));
goto cleanup;
}
- ignore_value(virAsprintf(&run_dir, "%s/.libvirt/", user_dir));
- VIR_FREE(user_dir);
}
if (!run_dir) {
virReportOOMError();
goto cleanup;
}
- old_umask = umask(022);
+ old_umask = umask(077);
if (virFileMakePath(run_dir) < 0) {
char ebuf[1024];
VIR_ERROR(_("unable to create rundir %s: %s"), run_dir,
diff --git a/daemon/libvirtd.pod.in b/daemon/libvirtd.pod.in
index 6e699b8..ea6c37d 100644
--- a/daemon/libvirtd.pod.in
+++ b/daemon/libvirtd.pod.in
@@ -85,7 +85,7 @@ command line using the B<-f>|B<--config> option.
The sockets libvirtd will use when B<run as root>.
-=item F<$HOME/.libvirt/libvirt-sock>
+=item F<$XDG_RUNTIME_DIR/libvirt/libvirt-sock>
The socket libvirtd will use when run as a B<non-root> user.
diff --git a/docs/auth.html.in b/docs/auth.html.in
index ecff0fc..60e4f11 100644
--- a/docs/auth.html.in
+++ b/docs/auth.html.in
@@ -25,7 +25,7 @@ for the authentication file using the following sequence:
variable.</li>
<li>The file path specified by the "authfile=/some/file" URI
query parameter</li>
- <li>The file $HOME/.libvirt/auth.conf</li>
+ <li>The file $XDG_CONFIG_DIR/libvirt/auth.conf</li>
<li>The file /etc/libvirt/auth.conf</li>
</ol>
diff --git a/docs/uri.html.in b/docs/uri.html.in
index 2f76e8f..5812ca9 100644
--- a/docs/uri.html.in
+++ b/docs/uri.html.in
@@ -30,7 +30,7 @@ virConnectPtr conn = virConnectOpenReadOnly (<b>"test:///default"</b>);
<p>
To simplify life for administrators, it is possible to setup URI aliases in a
libvirt client configuration file. The configuration file is <code>/etc/libvirt/libvirt.conf</code>
-for the root user, or <code>$HOME/.libvirt/libvirt.conf</code> for any unprivileged user.
+for the root user, or <code>$XDG_CONFIG_DIR/libvirt/libvirt.conf</code> for any unprivileged user.
In this file, the following syntax can be used to setup aliases
</p>
diff --git a/src/libvirt.c b/src/libvirt.c
index cfd7711..22fc863 100644
--- a/src/libvirt.c
+++ b/src/libvirt.c
@@ -969,11 +969,11 @@ virConnectGetConfigFilePath(void)
SYSCONFDIR) < 0)
goto no_memory;
} else {
- char *userdir = virGetUserDirectory(geteuid());
+ char *userdir = virGetUserConfigDirectory(geteuid());
if (!userdir)
goto error;
- if (virAsprintf(&path, "%s/.libvirt/libvirt.conf",
+ if (virAsprintf(&path, "%s/libvirt.conf",
userdir) < 0) {
VIR_FREE(userdir);
goto no_memory;
diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
index d4038b2..06d5823 100644
--- a/src/libvirt_private.syms
+++ b/src/libvirt_private.syms
@@ -1109,6 +1109,7 @@ virFileFindMountPoint;
virFileHasSuffix;
virFileIsExecutable;
virFileIsLink;
+virFileIsDir;
virFileLinkPointsTo;
virFileLock;
virFileMakePath;
@@ -1129,6 +1130,9 @@ virGetGroupID;
virGetGroupName;
virGetHostname;
virGetUserDirectory;
+virGetUserConfigDirectory;
+virGetUserCacheDirectory;
+virGetUserRuntimeDirectory;
virGetUserID;
virGetUserName;
virHexToBin;
diff --git a/src/network/bridge_driver.c b/src/network/bridge_driver.c
index d82212f..cea87c2 100644
--- a/src/network/bridge_driver.c
+++ b/src/network/bridge_driver.c
@@ -280,18 +280,20 @@ networkStartup(int privileged) {
if ((base = strdup (SYSCONFDIR "/libvirt")) == NULL)
goto out_of_memory;
} else {
- char *userdir = virGetUserDirectory(uid);
+ char *userdir = virGetUserCacheDirectory(uid);
if (!userdir)
goto error;
if (virAsprintf(&driverState->logDir,
- "%s/.libvirt/qemu/log", userdir) == -1) {
+ "%s/qemu/log", userdir) == -1) {
VIR_FREE(userdir);
goto out_of_memory;
}
+ VIR_FREE(userdir);
- if (virAsprintf(&base, "%s/.libvirt", userdir) == -1) {
+ userdir = virGetUserConfigDirectory(uid);
+ if (virAsprintf(&base, "%s", userdir) == -1) {
VIR_FREE(userdir);
goto out_of_memory;
}
diff --git a/src/nwfilter/nwfilter_driver.c b/src/nwfilter/nwfilter_driver.c
index ffb4b5d..3d732ab 100644
--- a/src/nwfilter/nwfilter_driver.c
+++ b/src/nwfilter/nwfilter_driver.c
@@ -87,16 +87,9 @@ nwfilterDriverStartup(int privileged) {
goto out_of_memory;
} else {
uid_t uid = geteuid();
- char *userdir = virGetUserDirectory(uid);
-
- if (!userdir)
+ base = virGetUserConfigDirectory(uid);
+ if (!base)
goto error;
-
- if (virAsprintf(&base, "%s/.libvirt", userdir) == -1) {
- VIR_FREE(userdir);
- goto out_of_memory;
- }
- VIR_FREE(userdir);
}
if (virAsprintf(&driverState->configDir,
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index 86e82d6..6d98abd 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -520,28 +520,38 @@ qemudStartup(int privileged) {
goto out_of_memory;
} else {
uid_t uid = geteuid();
- char *userdir = virGetUserDirectory(uid);
- if (!userdir)
+ char *rundir;
+ char *cachedir;
+
+ cachedir = virGetUserCacheDirectory(uid);
+ if (!cachedir)
goto error;
if (virAsprintf(&qemu_driver->logDir,
- "%s/.libvirt/qemu/log", userdir) == -1) {
- VIR_FREE(userdir);
+ "%s/qemu/log", cachedir) == -1) {
+ VIR_FREE(cachedir);
goto out_of_memory;
}
-
- if (virAsprintf(&base, "%s/.libvirt", userdir) == -1) {
- VIR_FREE(userdir);
+ if (virAsprintf(&qemu_driver->cacheDir, "%s/qemu/cache", cachedir) == -1) {
+ VIR_FREE(cachedir);
goto out_of_memory;
}
- VIR_FREE(userdir);
+ VIR_FREE(cachedir);
- if (virAsprintf(&qemu_driver->stateDir, "%s/qemu/run", base) == -1)
+ rundir = virGetUserRuntimeDirectory(uid);
+ if (!rundir)
+ goto error;
+ if (virAsprintf(&qemu_driver->stateDir, "%s/qemu/run", rundir) == -1) {
+ VIR_FREE(rundir);
goto out_of_memory;
+ }
+ VIR_FREE(rundir);
+
+ base = virGetUserConfigDirectory(uid);
+ if (!base)
+ goto error;
if (virAsprintf(&qemu_driver->libDir, "%s/qemu/lib", base) == -1)
goto out_of_memory;
- if (virAsprintf(&qemu_driver->cacheDir, "%s/qemu/cache", base) == -1)
- goto out_of_memory;
if (virAsprintf(&qemu_driver->saveDir, "%s/qemu/save", base) == -1)
goto out_of_memory;
if (virAsprintf(&qemu_driver->snapshotDir, "%s/qemu/snapshot", base) == -1)
diff --git a/src/remote/remote_driver.c b/src/remote/remote_driver.c
index 7863b73..4a9299a 100644
--- a/src/remote/remote_driver.c
+++ b/src/remote/remote_driver.c
@@ -578,12 +578,12 @@ doRemoteOpen (virConnectPtr conn,
case trans_unix:
if (!sockname) {
if (flags & VIR_DRV_OPEN_REMOTE_USER) {
- char *userdir = virGetUserDirectory(getuid());
+ char *userdir = virGetUserRuntimeDirectory(getuid());
if (!userdir)
goto failed;
- if (virAsprintf(&sockname, "@%s" LIBVIRTD_USER_UNIX_SOCKET, userdir) < 0) {
+ if (virAsprintf(&sockname, "@%s/" LIBVIRTD_USER_UNIX_SOCKET, userdir) < 0) {
VIR_FREE(userdir);
goto out_of_memory;
}
diff --git a/src/remote/remote_driver.h b/src/remote/remote_driver.h
index 1504eec..aca9412 100644
--- a/src/remote/remote_driver.h
+++ b/src/remote/remote_driver.h
@@ -37,7 +37,7 @@ unsigned long remoteVersion(void);
# define LIBVIRTD_TCP_PORT "16509"
# define LIBVIRTD_PRIV_UNIX_SOCKET LOCALSTATEDIR "/run/libvirt/libvirt-sock"
# define LIBVIRTD_PRIV_UNIX_SOCKET_RO LOCALSTATEDIR "/run/libvirt/libvirt-sock-ro"
-# define LIBVIRTD_USER_UNIX_SOCKET "/.libvirt/libvirt-sock"
+# define LIBVIRTD_USER_UNIX_SOCKET "libvirt-sock"
# define LIBVIRTD_CONFIGURATION_FILE SYSCONFDIR "/libvirtd.conf"
/* Defaults for PKI directory. */
diff --git a/src/secret/secret_driver.c b/src/secret/secret_driver.c
index 088a243..f3fcce2 100644
--- a/src/secret/secret_driver.c
+++ b/src/secret/secret_driver.c
@@ -1013,16 +1013,9 @@ secretDriverStartup(int privileged)
goto out_of_memory;
} else {
uid_t uid = geteuid();
- char *userdir = virGetUserDirectory(uid);
-
- if (!userdir)
+ base = virGetUserConfigDirectory(uid);
+ if (!base)
goto error;
-
- if (virAsprintf(&base, "%s/.libvirt", userdir) == -1) {
- VIR_FREE(userdir);
- goto out_of_memory;
- }
- VIR_FREE(userdir);
}
if (virAsprintf(&driverState->directory, "%s/secrets", base) == -1)
goto out_of_memory;
diff --git a/src/storage/storage_driver.c b/src/storage/storage_driver.c
index f23ec7e..fd762c0 100644
--- a/src/storage/storage_driver.c
+++ b/src/storage/storage_driver.c
@@ -146,19 +146,12 @@ storageDriverStartup(int privileged)
goto out_of_memory;
} else {
uid_t uid = geteuid();
- char *userdir = virGetUserDirectory(uid);
-
- if (!userdir)
+ base = virGetUserConfigDirectory(uid);
+ if (!base)
goto error;
-
- if (virAsprintf(&base, "%s/.libvirt", userdir) == -1) {
- VIR_FREE(userdir);
- goto out_of_memory;
- }
- VIR_FREE(userdir);
}
- /* Configuration paths are either ~/.libvirt/storage/... (session) or
+ /* Configuration paths are either $USER_CONFIG_HOME/libvirt/storage/... (session) or
* /etc/libvirt/storage/... (system).
*/
if (virAsprintf(&driverState->configDir,
diff --git a/src/uml/uml_driver.c b/src/uml/uml_driver.c
index 4e640ff..8a39d73 100644
--- a/src/uml/uml_driver.c
+++ b/src/uml/uml_driver.c
@@ -434,12 +434,12 @@ umlStartup(int privileged)
"%s/run/libvirt/uml-guest", LOCALSTATEDIR) == -1)
goto out_of_memory;
} else {
+ base = virGetUserConfigDirectory(uid);
+ if (!base)
+ goto error;
if (virAsprintf(¨_driver->logDir,
- "%s/.libvirt/uml/log", userdir) == -1)
- goto out_of_memory;
-
- if (virAsprintf(&base, "%s/.libvirt", userdir) == -1)
+ "%s/uml/log", base) == -1)
goto out_of_memory;
if (virAsprintf(¨_driver->monitorDir,
@@ -447,7 +447,7 @@ umlStartup(int privileged)
goto out_of_memory;
}
- /* Configuration paths are either ~/.libvirt/uml/... (session) or
+ /* Configuration paths are either $XDG_CONFIG_HOME/libvirt/uml/... (session) or
* /etc/libvirt/uml/... (system).
*/
if (virAsprintf(¨_driver->configDir, "%s/uml", base) == -1)
diff --git a/src/util/util.c b/src/util/util.c
index 48358b2..447b7b7 100644
--- a/src/util/util.c
+++ b/src/util/util.c
@@ -665,6 +665,12 @@ char *virFindFileInPath(const char *file)
return fullpath;
}
+bool virFileIsDir(const char *path)
+{
+ struct stat s;
+ return (stat (path, &s) == 0) && S_ISDIR (s.st_mode);
+}
+
bool virFileExists(const char *path)
{
return access(path, F_OK) == 0;
@@ -2304,6 +2310,67 @@ char *virGetUserDirectory(uid_t uid)
return virGetUserEnt(uid, VIR_USER_ENT_DIRECTORY);
}
+static char *virGetXDGDirectory(uid_t uid, const char *xdgenvname, const char *xdgdefdir)
+{
+ char *path = NULL;
+ virBuffer buf = VIR_BUFFER_INITIALIZER;
+
+ if (uid == getuid ())
+ path = getenv(xdgenvname);
+
+ if (path && path[0]) {
+ virBufferAsprintf(&buf, "%s/libvirt/", path);
+ } else {
+ char *home;
+ home = virGetUserEnt(uid, VIR_USER_ENT_DIRECTORY);
+ virBufferAsprintf(&buf, "%s/%s/libvirt/", home, xdgdefdir);
+ VIR_FREE(home);
+ }
+ VIR_FREE(path);
+
+ if (virBufferError(&buf)) {
+ virBufferFreeAndReset(&buf);
+ virReportOOMError();
+ return NULL;
+ }
+
+ return virBufferContentAndReset(&buf);
+}
+
+char *virGetUserConfigDirectory(uid_t uid)
+{
+ return virGetXDGDirectory(uid, "XDG_CONFIG_HOME", ".config");
+}
+
+char *virGetUserCacheDirectory(uid_t uid)
+{
+ return virGetXDGDirectory(uid, "XDG_CACHE_HOME", ".cache");
+}
+
+char *virGetUserRuntimeDirectory(uid_t uid)
+{
+ char *path = NULL;
+ virBuffer buf = VIR_BUFFER_INITIALIZER;
+
+ if (uid == getuid ())
+ path = getenv("XDG_RUNTIME_DIR");
+
+ if (!path || !path[0]) {
+ return virGetUserCacheDirectory(uid);
+ } else {
+ virBufferAsprintf(&buf, "%s/libvirt/", path);
+ VIR_FREE(path);
+
+ if (virBufferError(&buf)) {
+ virBufferFreeAndReset(&buf);
+ virReportOOMError();
+ return NULL;
+ }
+
+ return virBufferContentAndReset(&buf);
+ }
+}
+
char *virGetUserName(uid_t uid)
{
return virGetUserEnt(uid, VIR_USER_ENT_NAME);
diff --git a/src/util/util.h b/src/util/util.h
index 85e8bd6..f5fa876 100644
--- a/src/util/util.h
+++ b/src/util/util.h
@@ -85,6 +85,7 @@ int virFileIsLink(const char *linkpath)
char *virFindFileInPath(const char *file);
+bool virFileIsDir (const char *file) ATTRIBUTE_NONNULL(1);
bool virFileExists(const char *file) ATTRIBUTE_NONNULL(1);
bool virFileIsExecutable(const char *file) ATTRIBUTE_NONNULL(1);
@@ -228,6 +229,9 @@ char *virGetHostname(virConnectPtr conn);
int virKillProcess(pid_t pid, int sig);
char *virGetUserDirectory(uid_t uid);
+char *virGetUserConfigDirectory(uid_t uid);
+char *virGetUserCacheDirectory(uid_t uid);
+char *virGetUserRuntimeDirectory(uid_t uid);
char *virGetUserName(uid_t uid);
char *virGetGroupName(gid_t gid);
int virGetUserID(const char *name,
diff --git a/src/util/virauth.c b/src/util/virauth.c
index c59c55a..92ecb7c 100644
--- a/src/util/virauth.c
+++ b/src/util/virauth.c
@@ -65,10 +65,10 @@ int virAuthGetConfigFilePath(virConnectPtr conn,
}
}
- if (!(userdir = virGetUserDirectory(geteuid())))
+ if (!(userdir = virGetUserConfigDirectory(geteuid())))
goto cleanup;
- if (virAsprintf(path, "%s/.libvirt/auth.conf", userdir) < 0)
+ if (virAsprintf(path, "%s/auth.conf", userdir) < 0)
goto no_memory;
VIR_DEBUG("Checking for readability of '%s'", *path);
diff --git a/tools/virsh.c b/tools/virsh.c
index 1207ac9..2ae9b71 100644
--- a/tools/virsh.c
+++ b/tools/virsh.c
@@ -19864,15 +19864,15 @@ vshReadlineInit(vshControl *ctl)
/* Limit the total size of the history buffer */
stifle_history(500);
- /* Prepare to read/write history from/to the ~/.virsh/history file */
- userdir = virGetUserDirectory(getuid());
+ /* Prepare to read/write history from/to the $XDG_CACHE_HOME/virsh/history file */
+ userdir = virGetUserCacheDirectory(getuid());
if (userdir == NULL) {
vshError(ctl, "%s", _("Could not determine home directory"));
return -1;
}
- if (virAsprintf(&ctl->historydir, "%s/.virsh", userdir) < 0) {
+ if (virAsprintf(&ctl->historydir, "%s/virsh", userdir) < 0) {
vshError(ctl, "%s", _("Out of memory"));
VIR_FREE(userdir);
return -1;
--
1.7.10
12 years, 6 months
[libvirt] [PATCH v2 0/3]usb devices with same vendorID, productID hotplug support
by Guannan Ren
https://bugzilla.redhat.com/show_bug.cgi?id=815755
The set of patch tries to fix the issue when multiple usb devices with
same idVendor, idProduct are availible on host, the usb device with
lowest bus:device will be attached to guest if usb xml file is given like
this:
<hostdev mode='subsystem' type='usb' managed='yes'>
<source>
<vendor id='0x15e1'/>
<product id='0x2007'/>
</source>
</hostdev>
The reason is that the usb hotplug function searchs usb device in system files
to match vendor and product id, the file with lowest number is always found
first.
After fix, in this case, libvirt will report an error as follows:
At the same time, the usb part of domain initilization is also update in patch 2/3
# virsh attach-device rhel6u1 /tmp/usb.xml
error: Failed to attach device from /tmp/usb.xml
error: XML error: multiple USB deivces 15e1:2007, use <address> to specify one.
The patch also fix the problem when using the following xml, the usb device could
be hotplugged in two domains without raising errors.
<hostdev mode='subsystem' type='usb' managed='yes'>
<source>
<address bus='6' device='4'/>
</source>
</hostdev>
12 years, 6 months
[libvirt] [PATCH 1/1] Correct indent errors in the function qemuDomainNetsRestart
by Li Zhang
There are three spapces for a indent every line in the
function qemuDomainNetsRestart.
This patch is to correct it.
Signed-off-by: Li Zhang <zhlcindy(a)linux.vnet.ibm.com>
---
src/qemu/qemu_driver.c | 42 +++++++++++++++++++++---------------------
1 file changed, 21 insertions(+), 21 deletions(-)
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index 86e82d6..bed8edb 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -420,28 +420,28 @@ static void qemuDomainNetsRestart(void *payload,
const void *name ATTRIBUTE_UNUSED,
void *data ATTRIBUTE_UNUSED)
{
- int i;
- virDomainObjPtr vm = (virDomainObjPtr)payload;
- virDomainDefPtr def = vm->def;
-
- virDomainObjLock(vm);
-
- for (i = 0; i < def->nnets; i++) {
- virDomainNetDefPtr net = def->nets[i];
- if (virDomainNetGetActualType(net) == VIR_DOMAIN_NET_TYPE_DIRECT &&
- virDomainNetGetActualDirectMode(net) == VIR_NETDEV_MACVLAN_MODE_VEPA) {
- VIR_DEBUG("VEPA mode device %s active in domain %s. Reassociating.",
- net->ifname, def->name);
- ignore_value(virNetDevMacVLanRestartWithVPortProfile(net->ifname,
- net->mac,
- virDomainNetGetActualDirectDev(net),
- def->uuid,
- virDomainNetGetActualVirtPortProfile(net),
- VIR_NETDEV_VPORT_PROFILE_OP_CREATE));
- }
- }
+ int i;
+ virDomainObjPtr vm = (virDomainObjPtr)payload;
+ virDomainDefPtr def = vm->def;
+
+ virDomainObjLock(vm);
- virDomainObjUnlock(vm);
+ for (i = 0; i < def->nnets; i++) {
+ virDomainNetDefPtr net = def->nets[i];
+ if (virDomainNetGetActualType(net) == VIR_DOMAIN_NET_TYPE_DIRECT &&
+ virDomainNetGetActualDirectMode(net) == VIR_NETDEV_MACVLAN_MODE_VEPA) {
+ VIR_DEBUG("VEPA mode device %s active in domain %s. Reassociating.",
+ net->ifname, def->name);
+ ignore_value(virNetDevMacVLanRestartWithVPortProfile(net->ifname,
+ net->mac,
+ virDomainNetGetActualDirectDev(net),
+ def->uuid,
+ virDomainNetGetActualVirtPortProfile(net),
+ VIR_NETDEV_VPORT_PROFILE_OP_CREATE));
+ }
+ }
+
+ virDomainObjUnlock(vm);
}
/**
--
1.7.9.5
12 years, 6 months
[libvirt] [PATCH] Use XDG Base Directories instead of storing in home
by William Jon McCann
Hi,
New to the list so hopefully I'm following the correct protocol.
Attached is a patch (mostly untested at the moment) to change the
default storage location from .libvirt to the locations defined in the
XDG Base Directory Specification
(http://standards.freedesktop.org/basedir-spec/basedir-spec-latest.html).
This has a number of advantages for us:
It allows sharing a home directory between different machines, or
sessions (eg. using NFS)
Cleanly separates cache, runtime (eg. sockets), or app data from
user settings
Supports performing smart or selective migration of settings
between different OS versions
Supports reseting settings without breaking things
Makes it possible to clear cache data to make room when the disk
is filling up
Allows us to write a robust and efficient backup solution
Allows an admin flexibility to change where data and settings are stored
It dramatically reduces the complexity and incoherence of the
system for administrators
This is a pretty important set of features for both enterprise and
individual use cases.
I hope you will please consider the change.
Thanks,
Jon
PS. This is also related to a goal for upstream GNOME
https://live.gnome.org/GnomeGoals/XDGConfigFolders
12 years, 6 months
[libvirt] [libvirt-docs PATCH] Added Snooze cloud manager to the IaaS section
by Eugen Feller
---
docs/apps.html.in | 8 ++++++++
1 files changed, 8 insertions(+), 0 deletions(-)
diff --git a/docs/apps.html.in b/docs/apps.html.in
index 29bebbd..10ea6bf 100644
--- a/docs/apps.html.in
+++ b/docs/apps.html.in
@@ -219,6 +219,14 @@
community. It uses libvirt for communication with all KVM and Xen
virtual machines.
</dd>
+
+ <dt><a href="http://snooze.inria.fr">Snooze</a></dt>
+ <dd>
+ Snooze is an open-source scalable, autonomic, and energy-efficient
+ virtual machine (VM) management framework for private clouds. It
+ integrates libvirt for VM monitoring, live migration, and life-cycle
+ management.
+ </dd>
</dl>
<h2><a name="libraries">Libraries</a></h2>
--
1.7.2.5
12 years, 6 months
[libvirt] [PATCH v5 0/9] Add basic driver for Parallels Virtuozzo Server
by Dmitry Guryanov
Parallels Virtuozzo Server is a cloud-ready virtualization
solution that allows users to simultaneously run multiple virtual
machines and containers on the same physical server.
Current name of this product is Parallels Server Bare Metal and
more information about it can be found here -
http://www.parallels.com/products/server/baremetal/sp/.
This driver will work with PVS version 6.0 , beta version
scheduled at 2012 Q2.
changes in v5:
* rebased to current version
changes in v4:
* fix errors, found by 'make syntax-check'
Dmitry Guryanov (9):
pvs: add driver skeleton
util: add functions for interating over json object
pvs: add functions to list domains and get info
pvs: implement functions for domain life cycle management
pvs: get info about serial ports
pvs: add support of VNC remote display
pvs: implement virDomainDefineXML operation for existing domains
pvs: add storage driver
pvs: implement VM creation
AUTHORS | 1 +
cfg.mk | 1 +
configure.ac | 23 +
docs/drvpvs.html.in | 28 +
include/libvirt/virterror.h | 1 +
libvirt.spec.in | 7 +
mingw32-libvirt.spec.in | 6 +
po/POTFILES.in | 3 +
src/Makefile.am | 23 +
src/conf/domain_conf.c | 3 +-
src/conf/domain_conf.h | 1 +
src/driver.h | 1 +
src/libvirt.c | 12 +
src/pvs/pvs_driver.c | 1280 +++++++++++++++++++++++++++++++++++++
src/pvs/pvs_driver.h | 75 +++
src/pvs/pvs_storage.c | 1458 +++++++++++++++++++++++++++++++++++++++++++
src/pvs/pvs_utils.c | 143 +++++
src/util/json.c | 30 +
src/util/json.h | 4 +
src/util/virterror.c | 3 +
20 files changed, 3102 insertions(+), 1 deletions(-)
create mode 100644 docs/drvpvs.html.in
create mode 100644 src/pvs/pvs_driver.c
create mode 100644 src/pvs/pvs_driver.h
create mode 100644 src/pvs/pvs_storage.c
create mode 100644 src/pvs/pvs_utils.c
12 years, 6 months
[libvirt] [PATCH] Use XDG Base Directories instead of storing in home directory
by William Jon McCann
As defined in:
http://standards.freedesktop.org/basedir-spec/basedir-spec-latest.html
This offers a number of advantages:
* Allows sharing a home directory between different machines, or
sessions (eg. using NFS)
* Cleanly separates cache, runtime (eg. sockets), or app data from
user settings
* Supports performing smart or selective migration of settings
between different OS versions
* Supports reseting settings without breaking things
* Makes it possible to clear cache data to make room when the disk
is filling up
* Allows us to write a robust and efficient backup solution
* Allows an admin flexibility to change where data and settings are stored
* Dramatically reduces the complexity and incoherence of the
system for administrators
---
AUTHORS | 1 +
daemon/libvirtd-config.c | 10 +--
daemon/libvirtd.c | 140 +++++++++++++++++++++++++++++++++-------
daemon/libvirtd.pod.in | 2 +-
docs/auth.html.in | 2 +-
docs/uri.html.in | 2 +-
src/libvirt.c | 4 +-
src/libvirt_private.syms | 4 ++
src/network/bridge_driver.c | 8 ++-
src/nwfilter/nwfilter_driver.c | 11 +---
src/qemu/qemu_driver.c | 32 +++++----
src/remote/remote_driver.c | 4 +-
src/remote/remote_driver.h | 2 +-
src/secret/secret_driver.c | 11 +---
src/storage/storage_driver.c | 13 +---
src/uml/uml_driver.c | 10 +--
src/util/util.c | 67 +++++++++++++++++++
src/util/util.h | 4 ++
src/util/virauth.c | 4 +-
tools/virsh.c | 6 +-
20 files changed, 248 insertions(+), 89 deletions(-)
diff --git a/AUTHORS b/AUTHORS
index 06b830a..668eca1 100644
--- a/AUTHORS
+++ b/AUTHORS
@@ -234,6 +234,7 @@ Patches have also been contributed by:
Jan Kiszka <jan.kiszka(a)siemens.com>
Ryan Woodsmall <rwoodsmall(a)gmail.com>
Wido den Hollander <wido(a)widodh.nl>
+ William Jon McCann <jmccann(a)redhat.com>
[....send patches to get your name here....]
diff --git a/daemon/libvirtd-config.c b/daemon/libvirtd-config.c
index 471236c..8b95969 100644
--- a/daemon/libvirtd-config.c
+++ b/daemon/libvirtd-config.c
@@ -205,16 +205,16 @@ daemonConfigFilePath(bool privileged, char **configfile)
if (!(*configfile = strdup(SYSCONFDIR "/libvirt/libvirtd.conf")))
goto no_memory;
} else {
- char *userdir = NULL;
+ char *configdir = NULL;
- if (!(userdir = virGetUserDirectory(geteuid())))
+ if (!(configdir = virGetUserConfigDirectory(geteuid())))
goto error;
- if (virAsprintf(configfile, "%s/.libvirt/libvirtd.conf", userdir) < 0) {
- VIR_FREE(userdir);
+ if (virAsprintf(configfile, "%s/libvirtd.conf", configdir) < 0) {
+ VIR_FREE(configdir);
goto no_memory;
}
- VIR_FREE(userdir);
+ VIR_FREE(configdir);
}
return 0;
diff --git a/daemon/libvirtd.c b/daemon/libvirtd.c
index b098f6a..0272fe7 100644
--- a/daemon/libvirtd.c
+++ b/daemon/libvirtd.c
@@ -239,17 +239,25 @@ daemonPidFilePath(bool privileged,
if (!(*pidfile = strdup(LOCALSTATEDIR "/run/libvirtd.pid")))
goto no_memory;
} else {
- char *userdir = NULL;
+ char *rundir = NULL;
+ mode_t old_umask;
- if (!(userdir = virGetUserDirectory(geteuid())))
+ if (!(rundir = virGetUserRuntimeDirectory(geteuid())))
goto error;
- if (virAsprintf(pidfile, "%s/.libvirt/libvirtd.pid", userdir) < 0) {
- VIR_FREE(userdir);
+ old_umask = umask(077);
+ if (virFileMakePath(rundir) < 0) {
+ umask(old_umask);
+ goto error;
+ }
+ umask(old_umask);
+
+ if (virAsprintf(pidfile, "%s/libvirtd.pid", rundir) < 0) {
+ VIR_FREE(rundir);
goto no_memory;
}
- VIR_FREE(userdir);
+ VIR_FREE(rundir);
}
return 0;
@@ -279,17 +287,25 @@ daemonUnixSocketPaths(struct daemonConfig *config,
if (!(*rosockfile = strdup(LOCALSTATEDIR "/run/libvirt/libvirt-sock-ro")))
goto no_memory;
} else {
- char *userdir = NULL;
+ char *rundir = NULL;
+ mode_t old_umask;
- if (!(userdir = virGetUserDirectory(geteuid())))
+ if (!(rundir = virGetUserRuntimeDirectory(geteuid())))
goto error;
- if (virAsprintf(sockfile, "@%s/.libvirt/libvirt-sock", userdir) < 0) {
- VIR_FREE(userdir);
+ old_umask = umask(077);
+ if (virFileMakePath(rundir) < 0) {
+ umask(old_umask);
+ goto error;
+ }
+ umask(old_umask);
+
+ if (virAsprintf(sockfile, "@%s/libvirt-sock", rundir) < 0) {
+ VIR_FREE(rundir);
goto no_memory;
}
- VIR_FREE(userdir);
+ VIR_FREE(rundir);
}
}
return 0;
@@ -593,16 +609,25 @@ daemonSetupLogging(struct daemonConfig *config,
LOCALSTATEDIR) == -1)
goto no_memory;
} else {
- char *userdir = virGetUserDirectory(geteuid());
- if (!userdir)
+ char *logdir = virGetUserCacheDirectory(geteuid());
+ mode_t old_umask;
+
+ if (!logdir)
+ goto error;
+
+ old_umask = umask(077);
+ if (virFileMakePath(logdir) < 0) {
+ umask(old_umask);
goto error;
+ }
+ umask(old_umask);
- if (virAsprintf(&tmp, "%d:file:%s/.libvirt/libvirtd.log",
- virLogGetDefaultPriority(), userdir) == -1) {
- VIR_FREE(userdir);
+ if (virAsprintf(&tmp, "%d:file:%s/libvirtd.log",
+ virLogGetDefaultPriority(), logdir) == -1) {
+ VIR_FREE(logdir);
goto no_memory;
}
- VIR_FREE(userdir);
+ VIR_FREE(logdir);
}
} else {
if (virAsprintf(&tmp, "%d:stderr", virLogGetDefaultPriority()) < 0)
@@ -722,6 +747,72 @@ static int daemonStateInit(virNetServerPtr srv)
return 0;
}
+static int migrateProfile(void)
+{
+ char *old_base = NULL;
+ char *updated = NULL;
+ char *home = NULL;
+ char *xdg_dir = NULL;
+ char *config_dir = NULL;
+ int ret = -1;
+ mode_t old_umask;
+
+ if (!(home = virGetUserDirectory(geteuid())))
+ goto cleanup;
+
+ if (virAsprintf(&old_base, "%s/.libvirt", home) < 0) {
+ goto cleanup;
+ }
+
+ /* if the new directory is there or the old one is not: do nothing */
+ if (!(config_dir = virGetUserConfigDirectory(geteuid())))
+ goto cleanup;
+
+ if (!virFileIsDir(old_base) || virFileExists(config_dir)) {
+ goto cleanup;
+ }
+
+ /* test if we already attempted to migrate first */
+ if (virAsprintf(&updated, "%s/DEPRECATED-DIRECTORY", old_base) < 0) {
+ goto cleanup;
+ }
+ if (virFileExists(updated)) {
+ goto cleanup;
+ }
+
+ xdg_dir = strdup(getenv("XDG_CONFIG_HOME"));
+ if (!xdg_dir || xdg_dir[0] == '\0') {
+ if (virAsprintf(&xdg_dir, "%s/.config", home) < 0) {
+ goto cleanup;
+ }
+ }
+
+ old_umask = umask(077);
+ if (virFileMakePath(xdg_dir) < 0) {
+ umask(old_umask);
+ goto cleanup;
+ }
+ umask(old_umask);
+
+ if (rename(old_base, config_dir) < 0) {
+ int fd = creat(updated, 0600);
+ VIR_FORCE_CLOSE(fd);
+ VIR_ERROR(_("Unable to migrate %s to %s"), old_base, config_dir);
+ goto cleanup;
+ }
+
+ ret = 0;
+
+ cleanup:
+ VIR_FREE(home);
+ VIR_FREE(old_base);
+ VIR_FREE(xdg_dir);
+ VIR_FREE(config_dir);
+ VIR_FREE(updated);
+
+ return ret;
+}
+
/* Print command-line usage. */
static void
daemonUsage(const char *argv0, bool privileged)
@@ -775,10 +866,10 @@ libvirt management daemon:\n"), argv0);
Default paths:\n\
\n\
Configuration file (unless overridden by -f):\n\
- $HOME/.libvirt/libvirtd.conf\n\
+ $XDG_CONFIG_HOME/libvirt/libvirtd.conf\n\
\n\
Sockets:\n\
- $HOME/.libvirt/libvirt-sock (in UNIX abstract namespace)\n\
+ $XDG_RUNTIME_HOME/libvirt/libvirt-sock (in UNIX abstract namespace)\n\
\n\
TLS:\n\
CA certificate: $HOME/.pki/libvirt/cacert.pem\n\
@@ -786,7 +877,7 @@ libvirt management daemon:\n"), argv0);
Server private key: $HOME/.pki/libvirt/serverkey.pem\n\
\n\
PID file:\n\
- $HOME/.libvirt/libvirtd.pid\n\
+ $XDG_RUNTIME_HOME/libvirt/libvirtd.pid\n\
\n"));
}
}
@@ -931,6 +1022,9 @@ int main(int argc, char **argv) {
exit(EXIT_FAILURE);
}
+ if (migrateProfile() < 0)
+ exit(EXIT_FAILURE);
+
if (config->host_uuid &&
virSetHostUUIDStr(config->host_uuid) < 0) {
VIR_ERROR(_("invalid host UUID: %s"), config->host_uuid);
@@ -977,21 +1071,19 @@ int main(int argc, char **argv) {
if (privileged) {
run_dir = strdup(LOCALSTATEDIR "/run/libvirt");
} else {
- char *user_dir = virGetUserDirectory(geteuid());
+ run_dir = virGetUserRuntimeDirectory(geteuid());
- if (!user_dir) {
+ if (!run_dir) {
VIR_ERROR(_("Can't determine user directory"));
goto cleanup;
}
- ignore_value(virAsprintf(&run_dir, "%s/.libvirt/", user_dir));
- VIR_FREE(user_dir);
}
if (!run_dir) {
virReportOOMError();
goto cleanup;
}
- old_umask = umask(022);
+ old_umask = umask(077);
if (virFileMakePath(run_dir) < 0) {
char ebuf[1024];
VIR_ERROR(_("unable to create rundir %s: %s"), run_dir,
diff --git a/daemon/libvirtd.pod.in b/daemon/libvirtd.pod.in
index 6e699b8..ea6c37d 100644
--- a/daemon/libvirtd.pod.in
+++ b/daemon/libvirtd.pod.in
@@ -85,7 +85,7 @@ command line using the B<-f>|B<--config> option.
The sockets libvirtd will use when B<run as root>.
-=item F<$HOME/.libvirt/libvirt-sock>
+=item F<$XDG_RUNTIME_DIR/libvirt/libvirt-sock>
The socket libvirtd will use when run as a B<non-root> user.
diff --git a/docs/auth.html.in b/docs/auth.html.in
index ecff0fc..60e4f11 100644
--- a/docs/auth.html.in
+++ b/docs/auth.html.in
@@ -25,7 +25,7 @@ for the authentication file using the following sequence:
variable.</li>
<li>The file path specified by the "authfile=/some/file" URI
query parameter</li>
- <li>The file $HOME/.libvirt/auth.conf</li>
+ <li>The file $XDG_CONFIG_DIR/libvirt/auth.conf</li>
<li>The file /etc/libvirt/auth.conf</li>
</ol>
diff --git a/docs/uri.html.in b/docs/uri.html.in
index 2f76e8f..5812ca9 100644
--- a/docs/uri.html.in
+++ b/docs/uri.html.in
@@ -30,7 +30,7 @@ virConnectPtr conn = virConnectOpenReadOnly (<b>"test:///default"</b>);
<p>
To simplify life for administrators, it is possible to setup URI aliases in a
libvirt client configuration file. The configuration file is <code>/etc/libvirt/libvirt.conf</code>
-for the root user, or <code>$HOME/.libvirt/libvirt.conf</code> for any unprivileged user.
+for the root user, or <code>$XDG_CONFIG_DIR/libvirt/libvirt.conf</code> for any unprivileged user.
In this file, the following syntax can be used to setup aliases
</p>
diff --git a/src/libvirt.c b/src/libvirt.c
index cfd7711..22fc863 100644
--- a/src/libvirt.c
+++ b/src/libvirt.c
@@ -969,11 +969,11 @@ virConnectGetConfigFilePath(void)
SYSCONFDIR) < 0)
goto no_memory;
} else {
- char *userdir = virGetUserDirectory(geteuid());
+ char *userdir = virGetUserConfigDirectory(geteuid());
if (!userdir)
goto error;
- if (virAsprintf(&path, "%s/.libvirt/libvirt.conf",
+ if (virAsprintf(&path, "%s/libvirt.conf",
userdir) < 0) {
VIR_FREE(userdir);
goto no_memory;
diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
index d4038b2..06d5823 100644
--- a/src/libvirt_private.syms
+++ b/src/libvirt_private.syms
@@ -1109,6 +1109,7 @@ virFileFindMountPoint;
virFileHasSuffix;
virFileIsExecutable;
virFileIsLink;
+virFileIsDir;
virFileLinkPointsTo;
virFileLock;
virFileMakePath;
@@ -1129,6 +1130,9 @@ virGetGroupID;
virGetGroupName;
virGetHostname;
virGetUserDirectory;
+virGetUserConfigDirectory;
+virGetUserCacheDirectory;
+virGetUserRuntimeDirectory;
virGetUserID;
virGetUserName;
virHexToBin;
diff --git a/src/network/bridge_driver.c b/src/network/bridge_driver.c
index d82212f..cea87c2 100644
--- a/src/network/bridge_driver.c
+++ b/src/network/bridge_driver.c
@@ -280,18 +280,20 @@ networkStartup(int privileged) {
if ((base = strdup (SYSCONFDIR "/libvirt")) == NULL)
goto out_of_memory;
} else {
- char *userdir = virGetUserDirectory(uid);
+ char *userdir = virGetUserCacheDirectory(uid);
if (!userdir)
goto error;
if (virAsprintf(&driverState->logDir,
- "%s/.libvirt/qemu/log", userdir) == -1) {
+ "%s/qemu/log", userdir) == -1) {
VIR_FREE(userdir);
goto out_of_memory;
}
+ VIR_FREE(userdir);
- if (virAsprintf(&base, "%s/.libvirt", userdir) == -1) {
+ userdir = virGetUserConfigDirectory(uid);
+ if (virAsprintf(&base, "%s", userdir) == -1) {
VIR_FREE(userdir);
goto out_of_memory;
}
diff --git a/src/nwfilter/nwfilter_driver.c b/src/nwfilter/nwfilter_driver.c
index ffb4b5d..3d732ab 100644
--- a/src/nwfilter/nwfilter_driver.c
+++ b/src/nwfilter/nwfilter_driver.c
@@ -87,16 +87,9 @@ nwfilterDriverStartup(int privileged) {
goto out_of_memory;
} else {
uid_t uid = geteuid();
- char *userdir = virGetUserDirectory(uid);
-
- if (!userdir)
+ base = virGetUserConfigDirectory(uid);
+ if (!base)
goto error;
-
- if (virAsprintf(&base, "%s/.libvirt", userdir) == -1) {
- VIR_FREE(userdir);
- goto out_of_memory;
- }
- VIR_FREE(userdir);
}
if (virAsprintf(&driverState->configDir,
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index 78899a4..e3c0594 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -520,28 +520,38 @@ qemudStartup(int privileged) {
goto out_of_memory;
} else {
uid_t uid = geteuid();
- char *userdir = virGetUserDirectory(uid);
- if (!userdir)
+ char *rundir;
+ char *cachedir;
+
+ cachedir = virGetUserCacheDirectory(uid);
+ if (!cachedir)
goto error;
if (virAsprintf(&qemu_driver->logDir,
- "%s/.libvirt/qemu/log", userdir) == -1) {
- VIR_FREE(userdir);
+ "%s/qemu/log", cachedir) == -1) {
+ VIR_FREE(cachedir);
goto out_of_memory;
}
-
- if (virAsprintf(&base, "%s/.libvirt", userdir) == -1) {
- VIR_FREE(userdir);
+ if (virAsprintf(&qemu_driver->cacheDir, "%s/qemu/cache", cachedir) == -1) {
+ VIR_FREE(cachedir);
goto out_of_memory;
}
- VIR_FREE(userdir);
+ VIR_FREE(cachedir);
- if (virAsprintf(&qemu_driver->stateDir, "%s/qemu/run", base) == -1)
+ rundir = virGetUserRuntimeDirectory(uid);
+ if (!rundir)
+ goto error;
+ if (virAsprintf(&qemu_driver->stateDir, "%s/qemu/run", rundir) == -1) {
+ VIR_FREE(rundir);
goto out_of_memory;
+ }
+ VIR_FREE(rundir);
+
+ base = virGetUserConfigDirectory(uid);
+ if (!base)
+ goto error;
if (virAsprintf(&qemu_driver->libDir, "%s/qemu/lib", base) == -1)
goto out_of_memory;
- if (virAsprintf(&qemu_driver->cacheDir, "%s/qemu/cache", base) == -1)
- goto out_of_memory;
if (virAsprintf(&qemu_driver->saveDir, "%s/qemu/save", base) == -1)
goto out_of_memory;
if (virAsprintf(&qemu_driver->snapshotDir, "%s/qemu/snapshot", base) == -1)
diff --git a/src/remote/remote_driver.c b/src/remote/remote_driver.c
index 7863b73..4a9299a 100644
--- a/src/remote/remote_driver.c
+++ b/src/remote/remote_driver.c
@@ -578,12 +578,12 @@ doRemoteOpen (virConnectPtr conn,
case trans_unix:
if (!sockname) {
if (flags & VIR_DRV_OPEN_REMOTE_USER) {
- char *userdir = virGetUserDirectory(getuid());
+ char *userdir = virGetUserRuntimeDirectory(getuid());
if (!userdir)
goto failed;
- if (virAsprintf(&sockname, "@%s" LIBVIRTD_USER_UNIX_SOCKET, userdir) < 0) {
+ if (virAsprintf(&sockname, "@%s/" LIBVIRTD_USER_UNIX_SOCKET, userdir) < 0) {
VIR_FREE(userdir);
goto out_of_memory;
}
diff --git a/src/remote/remote_driver.h b/src/remote/remote_driver.h
index 1504eec..aca9412 100644
--- a/src/remote/remote_driver.h
+++ b/src/remote/remote_driver.h
@@ -37,7 +37,7 @@ unsigned long remoteVersion(void);
# define LIBVIRTD_TCP_PORT "16509"
# define LIBVIRTD_PRIV_UNIX_SOCKET LOCALSTATEDIR "/run/libvirt/libvirt-sock"
# define LIBVIRTD_PRIV_UNIX_SOCKET_RO LOCALSTATEDIR "/run/libvirt/libvirt-sock-ro"
-# define LIBVIRTD_USER_UNIX_SOCKET "/.libvirt/libvirt-sock"
+# define LIBVIRTD_USER_UNIX_SOCKET "libvirt-sock"
# define LIBVIRTD_CONFIGURATION_FILE SYSCONFDIR "/libvirtd.conf"
/* Defaults for PKI directory. */
diff --git a/src/secret/secret_driver.c b/src/secret/secret_driver.c
index 088a243..f3fcce2 100644
--- a/src/secret/secret_driver.c
+++ b/src/secret/secret_driver.c
@@ -1013,16 +1013,9 @@ secretDriverStartup(int privileged)
goto out_of_memory;
} else {
uid_t uid = geteuid();
- char *userdir = virGetUserDirectory(uid);
-
- if (!userdir)
+ base = virGetUserConfigDirectory(uid);
+ if (!base)
goto error;
-
- if (virAsprintf(&base, "%s/.libvirt", userdir) == -1) {
- VIR_FREE(userdir);
- goto out_of_memory;
- }
- VIR_FREE(userdir);
}
if (virAsprintf(&driverState->directory, "%s/secrets", base) == -1)
goto out_of_memory;
diff --git a/src/storage/storage_driver.c b/src/storage/storage_driver.c
index f23ec7e..fd762c0 100644
--- a/src/storage/storage_driver.c
+++ b/src/storage/storage_driver.c
@@ -146,19 +146,12 @@ storageDriverStartup(int privileged)
goto out_of_memory;
} else {
uid_t uid = geteuid();
- char *userdir = virGetUserDirectory(uid);
-
- if (!userdir)
+ base = virGetUserConfigDirectory(uid);
+ if (!base)
goto error;
-
- if (virAsprintf(&base, "%s/.libvirt", userdir) == -1) {
- VIR_FREE(userdir);
- goto out_of_memory;
- }
- VIR_FREE(userdir);
}
- /* Configuration paths are either ~/.libvirt/storage/... (session) or
+ /* Configuration paths are either $USER_CONFIG_HOME/libvirt/storage/... (session) or
* /etc/libvirt/storage/... (system).
*/
if (virAsprintf(&driverState->configDir,
diff --git a/src/uml/uml_driver.c b/src/uml/uml_driver.c
index 4e640ff..8a39d73 100644
--- a/src/uml/uml_driver.c
+++ b/src/uml/uml_driver.c
@@ -434,12 +434,12 @@ umlStartup(int privileged)
"%s/run/libvirt/uml-guest", LOCALSTATEDIR) == -1)
goto out_of_memory;
} else {
+ base = virGetUserConfigDirectory(uid);
+ if (!base)
+ goto error;
if (virAsprintf(¨_driver->logDir,
- "%s/.libvirt/uml/log", userdir) == -1)
- goto out_of_memory;
-
- if (virAsprintf(&base, "%s/.libvirt", userdir) == -1)
+ "%s/uml/log", base) == -1)
goto out_of_memory;
if (virAsprintf(¨_driver->monitorDir,
@@ -447,7 +447,7 @@ umlStartup(int privileged)
goto out_of_memory;
}
- /* Configuration paths are either ~/.libvirt/uml/... (session) or
+ /* Configuration paths are either $XDG_CONFIG_HOME/libvirt/uml/... (session) or
* /etc/libvirt/uml/... (system).
*/
if (virAsprintf(¨_driver->configDir, "%s/uml", base) == -1)
diff --git a/src/util/util.c b/src/util/util.c
index 48358b2..447b7b7 100644
--- a/src/util/util.c
+++ b/src/util/util.c
@@ -665,6 +665,12 @@ char *virFindFileInPath(const char *file)
return fullpath;
}
+bool virFileIsDir(const char *path)
+{
+ struct stat s;
+ return (stat (path, &s) == 0) && S_ISDIR (s.st_mode);
+}
+
bool virFileExists(const char *path)
{
return access(path, F_OK) == 0;
@@ -2304,6 +2310,67 @@ char *virGetUserDirectory(uid_t uid)
return virGetUserEnt(uid, VIR_USER_ENT_DIRECTORY);
}
+static char *virGetXDGDirectory(uid_t uid, const char *xdgenvname, const char *xdgdefdir)
+{
+ char *path = NULL;
+ virBuffer buf = VIR_BUFFER_INITIALIZER;
+
+ if (uid == getuid ())
+ path = getenv(xdgenvname);
+
+ if (path && path[0]) {
+ virBufferAsprintf(&buf, "%s/libvirt/", path);
+ } else {
+ char *home;
+ home = virGetUserEnt(uid, VIR_USER_ENT_DIRECTORY);
+ virBufferAsprintf(&buf, "%s/%s/libvirt/", home, xdgdefdir);
+ VIR_FREE(home);
+ }
+ VIR_FREE(path);
+
+ if (virBufferError(&buf)) {
+ virBufferFreeAndReset(&buf);
+ virReportOOMError();
+ return NULL;
+ }
+
+ return virBufferContentAndReset(&buf);
+}
+
+char *virGetUserConfigDirectory(uid_t uid)
+{
+ return virGetXDGDirectory(uid, "XDG_CONFIG_HOME", ".config");
+}
+
+char *virGetUserCacheDirectory(uid_t uid)
+{
+ return virGetXDGDirectory(uid, "XDG_CACHE_HOME", ".cache");
+}
+
+char *virGetUserRuntimeDirectory(uid_t uid)
+{
+ char *path = NULL;
+ virBuffer buf = VIR_BUFFER_INITIALIZER;
+
+ if (uid == getuid ())
+ path = getenv("XDG_RUNTIME_DIR");
+
+ if (!path || !path[0]) {
+ return virGetUserCacheDirectory(uid);
+ } else {
+ virBufferAsprintf(&buf, "%s/libvirt/", path);
+ VIR_FREE(path);
+
+ if (virBufferError(&buf)) {
+ virBufferFreeAndReset(&buf);
+ virReportOOMError();
+ return NULL;
+ }
+
+ return virBufferContentAndReset(&buf);
+ }
+}
+
char *virGetUserName(uid_t uid)
{
return virGetUserEnt(uid, VIR_USER_ENT_NAME);
diff --git a/src/util/util.h b/src/util/util.h
index 85e8bd6..f5fa876 100644
--- a/src/util/util.h
+++ b/src/util/util.h
@@ -85,6 +85,7 @@ int virFileIsLink(const char *linkpath)
char *virFindFileInPath(const char *file);
+bool virFileIsDir (const char *file) ATTRIBUTE_NONNULL(1);
bool virFileExists(const char *file) ATTRIBUTE_NONNULL(1);
bool virFileIsExecutable(const char *file) ATTRIBUTE_NONNULL(1);
@@ -228,6 +229,9 @@ char *virGetHostname(virConnectPtr conn);
int virKillProcess(pid_t pid, int sig);
char *virGetUserDirectory(uid_t uid);
+char *virGetUserConfigDirectory(uid_t uid);
+char *virGetUserCacheDirectory(uid_t uid);
+char *virGetUserRuntimeDirectory(uid_t uid);
char *virGetUserName(uid_t uid);
char *virGetGroupName(gid_t gid);
int virGetUserID(const char *name,
diff --git a/src/util/virauth.c b/src/util/virauth.c
index c59c55a..92ecb7c 100644
--- a/src/util/virauth.c
+++ b/src/util/virauth.c
@@ -65,10 +65,10 @@ int virAuthGetConfigFilePath(virConnectPtr conn,
}
}
- if (!(userdir = virGetUserDirectory(geteuid())))
+ if (!(userdir = virGetUserConfigDirectory(geteuid())))
goto cleanup;
- if (virAsprintf(path, "%s/.libvirt/auth.conf", userdir) < 0)
+ if (virAsprintf(path, "%s/auth.conf", userdir) < 0)
goto no_memory;
VIR_DEBUG("Checking for readability of '%s'", *path);
diff --git a/tools/virsh.c b/tools/virsh.c
index e177684..ee14c02 100644
--- a/tools/virsh.c
+++ b/tools/virsh.c
@@ -19863,15 +19863,15 @@ vshReadlineInit(vshControl *ctl)
/* Limit the total size of the history buffer */
stifle_history(500);
- /* Prepare to read/write history from/to the ~/.virsh/history file */
- userdir = virGetUserDirectory(getuid());
+ /* Prepare to read/write history from/to the $XDG_CACHE_HOME/virsh/history file */
+ userdir = virGetUserCacheDirectory(getuid());
if (userdir == NULL) {
vshError(ctl, "%s", _("Could not determine home directory"));
return -1;
}
- if (virAsprintf(&ctl->historydir, "%s/.virsh", userdir) < 0) {
+ if (virAsprintf(&ctl->historydir, "%s/virsh", userdir) < 0) {
vshError(ctl, "%s", _("Out of memory"));
VIR_FREE(userdir);
return -1;
--
1.7.10
12 years, 6 months
[libvirt] [libvirt-glib] Corrections to satisfy latest GIR
by Zeeshan Ali (Khattak)
From: "Zeeshan Ali (Khattak)" <zeeshanak(a)gnome.org>
---
libvirt-gconfig/libvirt-gconfig-domain.c | 1 +
libvirt-gobject/libvirt-gobject-domain-snapshot.c | 1 +
libvirt-gobject/libvirt-gobject-domain.c | 3 +++
libvirt-gobject/libvirt-gobject-interface.c | 2 ++
libvirt-gobject/libvirt-gobject-manager.c | 2 ++
libvirt-gobject/libvirt-gobject-network-filter.c | 2 ++
libvirt-gobject/libvirt-gobject-network.c | 2 ++
libvirt-gobject/libvirt-gobject-node-device.c | 2 ++
libvirt-gobject/libvirt-gobject-secret.c | 2 ++
libvirt-gobject/libvirt-gobject-storage-pool.c | 6 ++++++
libvirt-gobject/libvirt-gobject-storage-vol.c | 4 ++++
libvirt-gobject/libvirt-gobject-stream.c | 18 +++++++++++-------
libvirt-gobject/libvirt-gobject-stream.h | 2 ++
13 files changed, 40 insertions(+), 7 deletions(-)
diff --git a/libvirt-gconfig/libvirt-gconfig-domain.c b/libvirt-gconfig/libvirt-gconfig-domain.c
index 33a69e3..c8cd1c5 100644
--- a/libvirt-gconfig/libvirt-gconfig-domain.c
+++ b/libvirt-gconfig/libvirt-gconfig-domain.c
@@ -277,6 +277,7 @@ static gboolean add_feature(xmlNodePtr node, gpointer opaque)
/**
* gvir_config_domain_get_features:
+ *
* Returns: (transfer full):
*/
GStrv gvir_config_domain_get_features(GVirConfigDomain *domain)
diff --git a/libvirt-gobject/libvirt-gobject-domain-snapshot.c b/libvirt-gobject/libvirt-gobject-domain-snapshot.c
index 6097952..dbf0c51 100644
--- a/libvirt-gobject/libvirt-gobject-domain-snapshot.c
+++ b/libvirt-gobject/libvirt-gobject-domain-snapshot.c
@@ -184,6 +184,7 @@ const gchar *gvir_domain_snapshot_get_name(GVirDomainSnapshot *snapshot)
* gvir_domain_snapshot_get_config:
* @snapshot: the domain_snapshot
* @flags: the flags
+ *
* Returns: (transfer full): the config
*/
GVirConfigDomainSnapshot *gvir_domain_snapshot_get_config
diff --git a/libvirt-gobject/libvirt-gobject-domain.c b/libvirt-gobject/libvirt-gobject-domain.c
index 67ca257..e5113d4 100644
--- a/libvirt-gobject/libvirt-gobject-domain.c
+++ b/libvirt-gobject/libvirt-gobject-domain.c
@@ -337,6 +337,7 @@ gboolean gvir_domain_start(GVirDomain *dom,
/**
* gvir_domain_resume:
* @dom: the domain
+ * @err: Place-holder for possible errors
*
* Returns: TRUE on success
*/
@@ -453,6 +454,7 @@ gboolean gvir_domain_reboot(GVirDomain *dom,
* gvir_domain_get_config:
* @dom: the domain
* @flags: the flags
+ *
* Returns: (transfer full): the config
*/
GVirConfigDomain *gvir_domain_get_config(GVirDomain *dom,
@@ -546,6 +548,7 @@ gboolean gvir_domain_set_config(GVirDomain *domain,
/**
* gvir_domain_get_info:
* @dom: the domain
+ *
* Returns: (transfer full): the info
*/
GVirDomainInfo *gvir_domain_get_info(GVirDomain *dom,
diff --git a/libvirt-gobject/libvirt-gobject-interface.c b/libvirt-gobject/libvirt-gobject-interface.c
index 892db8b..a8e299c 100644
--- a/libvirt-gobject/libvirt-gobject-interface.c
+++ b/libvirt-gobject/libvirt-gobject-interface.c
@@ -175,6 +175,8 @@ const gchar *gvir_interface_get_name(GVirInterface *iface)
* gvir_interface_get_config:
* @iface: the interface
* @flags: the flags
+ * @err: Place-holder for possible errors
+ *
* Returns: (transfer full): the config
*/
GVirConfigInterface *gvir_interface_get_config(GVirInterface *iface,
diff --git a/libvirt-gobject/libvirt-gobject-manager.c b/libvirt-gobject/libvirt-gobject-manager.c
index da5d31d..010e8da 100644
--- a/libvirt-gobject/libvirt-gobject-manager.c
+++ b/libvirt-gobject/libvirt-gobject-manager.c
@@ -160,6 +160,7 @@ void gvir_manager_remove_connection(GVirManager *man,
/**
* gvir_manager_get_connections:
+ *
* Returns: (transfer full)(element-type GVirConnection): the connections
*/
GList *gvir_manager_get_connections(GVirManager *man)
@@ -179,6 +180,7 @@ GList *gvir_manager_get_connections(GVirManager *man)
/**
* gvir_manager_find_connection_by_uri:
+ *
* Returns: (transfer full)(allow-none): the connection,or NULL
*/
GVirConnection *gvir_manager_find_connection_by_uri(GVirManager *man,
diff --git a/libvirt-gobject/libvirt-gobject-network-filter.c b/libvirt-gobject/libvirt-gobject-network-filter.c
index 5956a3d..103174b 100644
--- a/libvirt-gobject/libvirt-gobject-network-filter.c
+++ b/libvirt-gobject/libvirt-gobject-network-filter.c
@@ -206,6 +206,8 @@ const gchar *gvir_network_filter_get_uuid(GVirNetworkFilter *filter)
* gvir_network_filter_get_config:
* @filter: the network_filter
* @flags: the flags
+ * @err: Place-holder for possible errors
+ *
* Returns: (transfer full): the config
*/
GVirConfigNetworkFilter *gvir_network_filter_get_config
diff --git a/libvirt-gobject/libvirt-gobject-network.c b/libvirt-gobject/libvirt-gobject-network.c
index 16cd2f1..2d195d9 100644
--- a/libvirt-gobject/libvirt-gobject-network.c
+++ b/libvirt-gobject/libvirt-gobject-network.c
@@ -203,6 +203,8 @@ const gchar *gvir_network_get_uuid(GVirNetwork *network)
* gvir_network_get_config:
* @network: the network
* @flags: the flags
+ * @err: Place-holder for possible errors
+ *
* Returns: (transfer full): the config
*/
GVirConfigNetwork *gvir_network_get_config(GVirNetwork *network,
diff --git a/libvirt-gobject/libvirt-gobject-node-device.c b/libvirt-gobject/libvirt-gobject-node-device.c
index b565052..6f81f1a 100644
--- a/libvirt-gobject/libvirt-gobject-node-device.c
+++ b/libvirt-gobject/libvirt-gobject-node-device.c
@@ -175,6 +175,8 @@ const gchar *gvir_node_device_get_name(GVirNodeDevice *device)
* gvir_node_device_get_config:
* @device: the node_device
* @flags: the flags
+ * @err: Place-holder for possible errors
+ *
* Returns: (transfer full): the config
*/
GVirConfigNodeDevice *gvir_node_device_get_config(GVirNodeDevice *device,
diff --git a/libvirt-gobject/libvirt-gobject-secret.c b/libvirt-gobject/libvirt-gobject-secret.c
index 3c9da86..299fdca 100644
--- a/libvirt-gobject/libvirt-gobject-secret.c
+++ b/libvirt-gobject/libvirt-gobject-secret.c
@@ -191,6 +191,8 @@ const gchar *gvir_secret_get_uuid(GVirSecret *secret)
* gvir_secret_get_config:
* @secret: the secret
* @flags: the flags
+ * @err: Place-holder for possible errors
+ *
* Returns: (transfer full): the config
*/
GVirConfigSecret *gvir_secret_get_config(GVirSecret *secret,
diff --git a/libvirt-gobject/libvirt-gobject-storage-pool.c b/libvirt-gobject/libvirt-gobject-storage-pool.c
index 1d89496..f09f122 100644
--- a/libvirt-gobject/libvirt-gobject-storage-pool.c
+++ b/libvirt-gobject/libvirt-gobject-storage-pool.c
@@ -235,6 +235,8 @@ const gchar *gvir_storage_pool_get_uuid(GVirStoragePool *pool)
* gvir_storage_pool_get_config:
* @pool: the storage_pool
* @flags: the flags
+ * @err: Place-holder for possible errors
+ *
* Returns: (transfer full): the config
*/
GVirConfigStoragePool *gvir_storage_pool_get_config(GVirStoragePool *pool,
@@ -260,6 +262,8 @@ GVirConfigStoragePool *gvir_storage_pool_get_config(GVirStoragePool *pool,
/**
* gvir_storage_pool_get_info:
* @pool: the storage_pool
+ * @err: Place-holder for possible errors
+ *
* Returns: (transfer full): the info
*/
GVirStoragePoolInfo *gvir_storage_pool_get_info(GVirStoragePool *pool,
@@ -526,6 +530,8 @@ GVirStorageVol *gvir_storage_pool_get_volume(GVirStoragePool *pool,
* gvir_storage_pool_create_volume:
* @pool: the storage pool in which to create the volume
* @conf: the configuration for the new volume
+ * @err: Place-holder for possible errors
+ *
* Returns: (transfer full): the newly created volume
*/
GVirStorageVol *gvir_storage_pool_create_volume
diff --git a/libvirt-gobject/libvirt-gobject-storage-vol.c b/libvirt-gobject/libvirt-gobject-storage-vol.c
index 78ce76e..cd02b38 100644
--- a/libvirt-gobject/libvirt-gobject-storage-vol.c
+++ b/libvirt-gobject/libvirt-gobject-storage-vol.c
@@ -225,6 +225,8 @@ const gchar *gvir_storage_vol_get_path(GVirStorageVol *vol, GError **error)
* gvir_storage_vol_get_config:
* @vol: the storage_vol
* @flags: the flags
+ * @err: Place-holder for possible errors
+ *
* Returns: (transfer full): the config
*/
GVirConfigStorageVol *gvir_storage_vol_get_config(GVirStorageVol *vol,
@@ -250,6 +252,8 @@ GVirConfigStorageVol *gvir_storage_vol_get_config(GVirStorageVol *vol,
/**
* gvir_storage_vol_get_info:
* @vol: the storage_vol
+ * @err: Place-holder for possible errors
+ *
* Returns: (transfer full): the info
*/
GVirStorageVolInfo *gvir_storage_vol_get_info(GVirStorageVol *vol,
diff --git a/libvirt-gobject/libvirt-gobject-stream.c b/libvirt-gobject/libvirt-gobject-stream.c
index 5486b95..60da4bc 100644
--- a/libvirt-gobject/libvirt-gobject-stream.c
+++ b/libvirt-gobject/libvirt-gobject-stream.c
@@ -355,18 +355,20 @@ stream_sink(virStreamPtr st G_GNUC_UNUSED,
* @cancellable: cancellation notifier
* @func: (scope notified): the callback for writing data to application
* @user_data: (closure): data to be passed to @callback
- * Returns: the number of bytes consumed or -1 upon error
+ * @error: #GError for error reporting, or %NULL to ignore.
*
* Receive the entire data stream, sending the data to the
* requested data sink. This is simply a convenient alternative
* to virStreamRecv, for apps that do blocking-I/o.
+ *
+ * Returns: the number of bytes consumed or -1 upon error
*/
gssize
gvir_stream_receive_all(GVirStream *self,
GCancellable *cancellable,
GVirStreamSinkFunc func,
gpointer user_data,
- GError **err)
+ GError **error)
{
struct stream_sink_helper helper = {
.self = self,
@@ -381,7 +383,7 @@ gvir_stream_receive_all(GVirStream *self,
r = virStreamRecvAll(self->priv->handle, stream_sink, &helper);
if (r < 0) {
- gvir_set_error_literal(err, GVIR_STREAM_ERROR,
+ gvir_set_error_literal(error, GVIR_STREAM_ERROR,
0,
"Unable to perform RecvAll");
}
@@ -465,18 +467,20 @@ stream_source(virStreamPtr st G_GNUC_UNUSED,
* @cancellable: cancellation notifier
* @func: (scope notified): the callback for writing data to application
* @user_data: (closure): data to be passed to @callback
- * Returns: the number of bytes consumed or -1 upon error
+ * @error: #GError for error reporting, or %NULL to ignore.
*
* Send the entire data stream, sending the data to the
* requested data source. This is simply a convenient alternative
* to virStreamRecv, for apps that do blocking-I/o.
+ *
+ * Returns: the number of bytes consumed or -1 upon error
*/
gssize
gvir_stream_send_all(GVirStream *self,
GCancellable *cancellable,
GVirStreamSourceFunc func,
gpointer user_data,
- GError **err)
+ GError **error)
{
struct stream_source_helper helper = {
.self = self,
@@ -491,7 +495,7 @@ gvir_stream_send_all(GVirStream *self,
r = virStreamSendAll(self->priv->handle, stream_source, &helper);
if (r < 0) {
- gvir_set_error_literal(err, GVIR_STREAM_ERROR,
+ gvir_set_error_literal(error, GVIR_STREAM_ERROR,
0,
"Unable to perform SendAll");
}
@@ -618,7 +622,7 @@ GSourceFuncs gvir_stream_source_funcs = {
/**
- * gvir_stream_add_watch: (skip):
+ * gvir_stream_add_watch: (skip)
* @stream: the stream
* @cond: the conditions to watch for (bitfield of #GVirStreamIOCondition)
* @func: (closure opaque): the function to call when the condition is satisfied
diff --git a/libvirt-gobject/libvirt-gobject-stream.h b/libvirt-gobject/libvirt-gobject-stream.h
index c84f2a2..4da83ac 100644
--- a/libvirt-gobject/libvirt-gobject-stream.h
+++ b/libvirt-gobject/libvirt-gobject-stream.h
@@ -68,6 +68,7 @@ struct _GVirStreamClass
* @buf: (out) (array length=nbytes) (transfer none): data pointer
* @nbytes: data size
* @user_data: user data passed to the function
+ *
* Returns: the number of bytes filled, 0 upon end
* of file, or -1 upon error
*/
@@ -82,6 +83,7 @@ typedef gint (* GVirStreamSinkFunc)(GVirStream *stream,
* @buf: (out) (array length=nbytes) (transfer none): data pointer
* @nbytes: data size
* @user_data: user data passed to the function
+ *
* Returns: the number of bytes filled, 0 upon end
* of file, or -1 upon error
*/
--
1.7.7.6
12 years, 6 months
[libvirt] [PATCH qemu v2 0/6] -no-user-config option, move CPU models to /usr/share
by Eduardo Habkost
Changes v1 -> v2:
- Move qemu_read_default_config_files() prototype to qemu-config.h
- Make defconfig and userconfig variable bool
- Coding style change
Patches 1 to 4 just move some code around, patch 5 just adds the new option
without adding any new config file. Patch 6 finally creates a /usr/share/qemu
/cpus-x86_64.conf file, with the CPU models we currently have on Qemu.
Reference to previous discussion:
- http://marc.info/?l=qemu-devel&m=133278877315665
Eduardo Habkost (6):
move code to read default config files to a separate function (v2)
eliminate arch_config_name variable
move list of default config files to an array
vl.c: change 'defconfig' variable to bool
implement -no-user-config command-line option (v2)
move CPU definitions to /usr/share/qemu/cpus-x86_64.conf (v2)
Makefile | 12 +++-
arch_init.c | 32 ++++++++-
arch_init.h | 2 -
qemu-config.h | 4 +
qemu-options.hx | 16 ++++-
sysconfigs/target/cpus-x86_64.conf | 128 ++++++++++++++++++++++++++++++++++
sysconfigs/target/target-x86_64.conf | 128 ----------------------------------
vl.c | 18 ++---
8 files changed, 193 insertions(+), 147 deletions(-)
create mode 100644 sysconfigs/target/cpus-x86_64.conf
--
1.7.3.2
12 years, 6 months