On Thu, May 02, 2013 at 02:06:16PM -0400, Laine Stump wrote:
-#define NETWORK_PID_DIR LOCALSTATEDIR "/run/libvirt/network"
-#define NETWORK_STATE_DIR LOCALSTATEDIR "/lib/libvirt/network"
+#define NETWORK_PID_DIR "/run/libvirt/network"
+#define NETWORK_STATE_DIR "/lib/libvirt/network"
-#define DNSMASQ_STATE_DIR LOCALSTATEDIR "/lib/libvirt/dnsmasq"
-#define RADVD_STATE_DIR LOCALSTATEDIR "/lib/libvirt/radvd"
+#define DNSMASQ_STATE_DIR "/lib/libvirt/dnsmasq"
+#define RADVD_STATE_DIR "/lib/libvirt/radvd"
This kind of approach doesn't really work I'm afraid.
The '/lib' and '/run' prefixes are only relevant for
the privileged daemon.
if (privileged) {
- if (virAsprintf(&driverState->logDir,
- "%s/log/libvirt/qemu", LOCALSTATEDIR) == -1)
- goto out_of_memory;
-
- if ((base = strdup(SYSCONFDIR "/libvirt")) == NULL)
+ if (((base = strdup(SYSCONFDIR "/libvirt")) == NULL) ||
+ ((driverState->logDir
+ = strdup(LOCALSTATEDIR "/log/libvirt/qemu")) == NULL) ||
+ ((driverState->stateDir
+ = strdup(LOCALSTATEDIR NETWORK_STATE_DIR)) == NULL) ||
+ ((driverState->pidDir
+ = strdup(LOCALSTATEDIR NETWORK_PID_DIR)) == NULL) ||
+ ((driverState->dnsmasqStateDir
+ = strdup(LOCALSTATEDIR DNSMASQ_STATE_DIR)) == NULL) ||
+ ((driverState->radvdStateDir
+ = strdup(LOCALSTATEDIR RADVD_STATE_DIR)) == NULL)) {
goto out_of_memory;
+ }
} else {
char *userdir = virGetUserCacheDirectory();
if (!userdir)
goto error;
+ userdir = virGetUserConfigDirectory();
+ if (virAsprintf(&base, "%s", userdir) < 0) {
+ VIR_FREE(userdir);
+ goto out_of_memory;
+ }
+ VIR_FREE(userdir);
+
if (virAsprintf(&driverState->logDir,
- "%s/qemu/log", userdir) == -1) {
+ "%s/qemu/log", userdir) < 0) {
VIR_FREE(userdir);
goto out_of_memory;
}
VIR_FREE(userdir);
- userdir = virGetUserConfigDirectory();
- if (virAsprintf(&base, "%s", userdir) == -1) {
+ if (!(userdir = virGetUserRuntimeDirectory()))
+ goto error;
+
+ if (virAsprintf(&driverState->stateDir,
+ "%s" NETWORK_STATE_DIR, userdir) < 0) {
+ VIR_FREE(userdir);
+ goto out_of_memory;
+ }
+ if (virAsprintf(&driverState->pidDir,
+ "%s" NETWORK_PID_DIR, userdir) < 0) {
+ VIR_FREE(userdir);
+ goto out_of_memory;
+ }
+ if (virAsprintf(&driverState->dnsmasqStateDir,
+ "%s" DNSMASQ_STATE_DIR, userdir) < 0) {
+ VIR_FREE(userdir);
+ goto out_of_memory;
+ }
+ if (virAsprintf(&driverState->radvdStateDir,
+ "%s" RADVD_STATE_DIR, userdir) < 0) {
VIR_FREE(userdir);
goto out_of_memory;
}
These cause the state dirs to become
$XDG_RUNTIME_DIR/lib/libvirt/network
$XDG_RUNTIME_DIR/run/libvirt/network
$XDG_RUNTIME_DIR/lib/libvirt/dnsmasq
$XDG_RUNTIME_DIR/lib/libvirt/radvd
when in fact we want them to be
$XDG_RUNTIME_DIR/libvirt/network/lib
$XDG_RUNTIME_DIR/libvirt/network/run
$XDG_RUNTIME_DIR/libvirt/dnsmasq/lib
$XDG_RUNTIME_DIR/libvirt/radvd/lib
Take a look at how QEMU sets this up in virQEMUDriverConfigNew
Daniel
--
|:
http://berrange.com -o-
http://www.flickr.com/photos/dberrange/ :|
|:
http://libvirt.org -o-
http://virt-manager.org :|
|:
http://autobuild.org -o-
http://search.cpan.org/~danberr/ :|
|:
http://entangle-photo.org -o-
http://live.gnome.org/gtk-vnc :|