[libvirt] [PATCHv2] network: fix network driver startup for qemu:///session
Daniel P. Berrange
berrange at redhat.com
Fri May 3 13:01:58 UTC 2013
On Fri, May 03, 2013 at 08:24:14AM -0400, Laine Stump wrote:
> Changes since V1:
>
> * change user directory names as outlined by danpb.
>
> * eliminate the "base" string which caused so much bad code, and
> otherwise simplify the logic
>
> * get rid of logDir, since it's never used.
>
> * eliminage the *_DIR #defines, since they're now each only used once,
> and they just serve to obscure what's being done.
>
> src/network/bridge_driver.c | 182 +++++++++++++++++++++++++-------------------
> 1 file changed, 102 insertions(+), 80 deletions(-)
>
> diff --git a/src/network/bridge_driver.c b/src/network/bridge_driver.c
> index e828997..543b098 100644
> --- a/src/network/bridge_driver.c
> +++ b/src/network/bridge_driver.c
> @@ -373,43 +374,53 @@ networkStateInitialize(bool privileged,
> }
> networkDriverLock(driverState);
>
> + /* Configuration paths one of
> + * ~/.libvirt/... (old style session/unprivileged)
This comment isn't relevant anymore - we don't have code using that.
> + * ~/.config/libvirt/... (new XDG session/unprivileged)
> + * /etc/libvirt/... && /var/(run|lib)/libvirt/... (system/privileged).
> + *
> + * NB: The qemu driver puts its domain state in /var/run, and I
> + * think the network driver should have used /var/run too (instead
> + * of /var/lib), but it's been this way for a long time, and we
> + * probably should change it now.
s/should/shouldn't/
> + */
> if (privileged) {
> - if (virAsprintf(&driverState->logDir,
> - "%s/log/libvirt/qemu", LOCALSTATEDIR) == -1)
> - goto out_of_memory;
> -
> - if ((base = strdup(SYSCONFDIR "/libvirt")) == NULL)
> + if (!(driverState->networkConfigDir
> + = strdup(SYSCONFDIR "/libvirt/qemu/networks")) ||
> + !(driverState->networkAutostartDir
> + = strdup(SYSCONFDIR "/libvirt/qemu/networks/autostart")) ||
> + !(driverState->stateDir
> + = strdup(LOCALSTATEDIR "/lib/libvirt/network")) ||
> + !(driverState->pidDir
> + = strdup(LOCALSTATEDIR "/run/libvirt/network")) ||
> + !(driverState->dnsmasqStateDir
> + = strdup(LOCALSTATEDIR "/lib/libvirt/dnsmasq")) ||
> + !(driverState->radvdStateDir
> + = strdup(LOCALSTATEDIR "/lib/libvirt/radvd"))) {
> goto out_of_memory;
> + }
> } else {
> - char *userdir = virGetUserCacheDirectory();
> -
> - if (!userdir)
> + configdir = virGetUserConfigDirectory();
> + rundir = virGetUserRuntimeDirectory();
> + if (!(configdir && rundir))
> goto error;
>
> - if (virAsprintf(&driverState->logDir,
> - "%s/qemu/log", userdir) == -1) {
> - VIR_FREE(userdir);
> + if ((virAsprintf(&driverState->networkConfigDir,
> + "%s/qemu/networks", configdir) < 0) ||
> + (virAsprintf(&driverState->networkAutostartDir,
> + "%s/qemu/networks/autostart", configdir) < 0) ||
> + (virAsprintf(&driverState->stateDir,
> + "%s/network/lib", rundir) < 0) ||
> + (virAsprintf(&driverState->pidDir,
> + "%s/network/run", rundir) < 0) ||
> + (virAsprintf(&driverState->dnsmasqStateDir,
> + "%s/dnsmasq/lib", rundir) < 0) ||
> + (virAsprintf(&driverState->radvdStateDir,
> + "%s/radvd/lib", rundir) < 0)) {
> goto out_of_memory;
> }
ACK with the tweaks
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 :|
More information about the libvir-list
mailing list