]> xenbits.xensource.com Git - people/liuw/libxenctrl-split/libvirt.git/commitdiff
qemu: Build channel autosocket directory at driver startup
authorCole Robinson <crobinso@redhat.com>
Thu, 23 Apr 2015 23:24:50 +0000 (19:24 -0400)
committerCole Robinson <crobinso@redhat.com>
Fri, 24 Apr 2015 14:30:42 +0000 (10:30 -0400)
Rather than depend on the RPM to put it in place, since this doesn't
cover the qemu:///session case. Currently auto allocated socket path is
completely busted with qemu:///session

https://bugzilla.redhat.com/show_bug.cgi?id=1105274

And because we chown the directory at driver startup now, this also fixes
autosocket startup failures when using user/group=root

https://bugzilla.redhat.com/show_bug.cgi?id=1044561
https://bugzilla.redhat.com/show_bug.cgi?id=1146886

libvirt.spec.in
src/Makefile.am
src/qemu/qemu_conf.c
src/qemu/qemu_conf.h
src/qemu/qemu_domain.c
src/qemu/qemu_driver.c

index b32b68aa831c16170cfce6bd381c610781755673..2f19c7f9918bdd36afdf0990bea1ddc3186276a0 100644 (file)
@@ -1985,8 +1985,6 @@ exit 0
 %dir %attr(0700, root, root) %{_localstatedir}/log/libvirt/qemu/
 %ghost %dir %attr(0700, root, root) %{_localstatedir}/run/libvirt/qemu/
 %dir %attr(0750, %{qemu_user}, %{qemu_group}) %{_localstatedir}/lib/libvirt/qemu/
-%dir %attr(0750, %{qemu_user}, %{qemu_group}) %{_localstatedir}/lib/libvirt/qemu/channel/
-%dir %attr(0750, %{qemu_user}, %{qemu_group}) %{_localstatedir}/lib/libvirt/qemu/channel/target/
 %dir %attr(0711, %{qemu_user}, %{qemu_group}) %{_localstatedir}/lib/libvirt/qemu/nvram/
 %dir %attr(0750, %{qemu_user}, %{qemu_group}) %{_localstatedir}/cache/libvirt/qemu/
 %{_datadir}/augeas/lenses/libvirtd_qemu.aug
@@ -2091,8 +2089,6 @@ exit 0
 %config(noreplace) %{_sysconfdir}/logrotate.d/libvirtd.qemu
 %ghost %dir %attr(0700, root, root) %{_localstatedir}/run/libvirt/qemu/
 %dir %attr(0750, %{qemu_user}, %{qemu_group}) %{_localstatedir}/lib/libvirt/qemu/
-%dir %attr(0750, %{qemu_user}, %{qemu_group}) %{_localstatedir}/lib/libvirt/qemu/channel/
-%dir %attr(0750, %{qemu_user}, %{qemu_group}) %{_localstatedir}/lib/libvirt/qemu/channel/target/
 %dir %attr(0711, %{qemu_user}, %{qemu_group}) %{_localstatedir}/lib/libvirt/qemu/nvram/
 %dir %attr(0750, %{qemu_user}, %{qemu_group}) %{_localstatedir}/cache/libvirt/qemu/
 %{_datadir}/augeas/lenses/libvirtd_qemu.aug
index 9a5f16cb9edc6b373c8e7c68ed3696bda291b0ca..dd41b45e41fa1533a00b55c74caca6ac1ba79590 100644 (file)
@@ -2705,7 +2705,6 @@ if WITH_SANLOCK
 endif WITH_SANLOCK
 if WITH_QEMU
        $(MKDIR_P) "$(DESTDIR)$(localstatedir)/lib/libvirt/qemu"
-       $(MKDIR_P) "$(DESTDIR)$(localstatedir)/lib/libvirt/qemu/channel/target"
        $(MKDIR_P) "$(DESTDIR)$(localstatedir)/lib/libvirt/qemu/nvram"
        $(MKDIR_P) "$(DESTDIR)$(localstatedir)/run/libvirt/qemu"
        $(MKDIR_P) "$(DESTDIR)$(localstatedir)/cache/libvirt/qemu"
index 1075e26c628b443f30b742529f9c8da929f24d1a..4b5fa392f8304ac3c4ca8abf3942fb5193046cb4 100644 (file)
@@ -205,6 +205,9 @@ virQEMUDriverConfigPtr virQEMUDriverConfigNew(bool privileged)
             goto error;
         if (virAsprintf(&cfg->autoDumpPath, "%s/dump", cfg->libDir) < 0)
             goto error;
+        if (virAsprintf(&cfg->channelTargetDir,
+                        "%s/channel/target", cfg->libDir) < 0)
+            goto error;
     } else {
         char *rundir;
         char *cachedir;
@@ -244,6 +247,9 @@ virQEMUDriverConfigPtr virQEMUDriverConfigNew(bool privileged)
             goto error;
         if (virAsprintf(&cfg->autoDumpPath, "%s/qemu/dump", cfg->configBaseDir) < 0)
             goto error;
+        if (virAsprintf(&cfg->channelTargetDir,
+                        "%s/qemu/channel/target", cfg->configBaseDir) < 0)
+            goto error;
     }
 
     if (virAsprintf(&cfg->configDir, "%s/qemu", cfg->configBaseDir) < 0)
@@ -342,6 +348,7 @@ static void virQEMUDriverConfigDispose(void *obj)
     VIR_FREE(cfg->cacheDir);
     VIR_FREE(cfg->saveDir);
     VIR_FREE(cfg->snapshotDir);
+    VIR_FREE(cfg->channelTargetDir);
 
     VIR_FREE(cfg->vncTLSx509certdir);
     VIR_FREE(cfg->vncListen);
index 4b02d1980948d4cea4089d89142c08ba498ce505..6e9f8153a9272a2bbeed4b23cbdfdf510528afae 100644 (file)
@@ -104,6 +104,7 @@ struct _virQEMUDriverConfig {
     char *cacheDir;
     char *saveDir;
     char *snapshotDir;
+    char *channelTargetDir;
 
     bool vncAutoUnixSocket;
     bool vncTLS;
index 6c480c6daf00f50dc46be3f2ca019b39828527a3..39973a918278bd2e174ffe37848fa9f85e2748df 100644 (file)
@@ -1193,12 +1193,11 @@ qemuDomainDeviceDefPostParse(virDomainDeviceDefPtr dev,
         dev->data.chr->targetType == VIR_DOMAIN_CHR_CHANNEL_TARGET_TYPE_VIRTIO &&
         dev->data.chr->source.type == VIR_DOMAIN_CHR_TYPE_UNIX &&
         !dev->data.chr->source.data.nix.path && cfg) {
-
-        if (virAsprintf(&dev->data.chr->source.data.nix.path,
-                        "%s/channel/target/%s.%s",
-                        cfg->libDir, def->name,
-                        dev->data.chr->target.name) < 0)
+        if (virAsprintf(&dev->data.chr->source.data.nix.path, "%s/%s.%s",
+                        cfg->channelTargetDir,
+                        def->name, dev->data.chr->target.name) < 0)
             goto cleanup;
+
         dev->data.chr->source.data.nix.listen = true;
     }
 
index 101f9dd1ff5924108887fba9e97fb237ace8d52f..e59aec4ada749000251bf4fda22858159c42e274 100644 (file)
@@ -98,6 +98,7 @@
 #include "domain_capabilities.h"
 #include "vircgroup.h"
 #include "virnuma.h"
+#include "dirname.h"
 
 #define VIR_FROM_THIS VIR_FROM_QEMU
 
@@ -702,6 +703,12 @@ qemuStateInitialize(bool privileged,
                   cfg->autoDumpPath, virStrerror(errno, ebuf, sizeof(ebuf)));
         goto error;
     }
+    if (virFileMakePath(cfg->channelTargetDir) < 0) {
+        VIR_ERROR(_("Failed to create channel target dir '%s': %s"),
+                  cfg->channelTargetDir,
+                  virStrerror(errno, ebuf, sizeof(ebuf)));
+        goto error;
+    }
 
     qemu_driver->qemuImgBinary = virFindFileInPath("kvm-img");
     if (!qemu_driver->qemuImgBinary)
@@ -761,6 +768,8 @@ qemuStateInitialize(bool privileged,
         goto error;
 
     if (privileged) {
+        char *channeldir;
+
         if (chown(cfg->libDir, cfg->user, cfg->group) < 0) {
             virReportSystemError(errno,
                                  _("unable to set ownership of '%s' to user %d:%d"),
@@ -796,6 +805,26 @@ qemuStateInitialize(bool privileged,
                                  (int) cfg->group);
             goto error;
         }
+        if (!(channeldir = mdir_name(cfg->channelTargetDir))) {
+            virReportOOMError();
+            goto error;
+        }
+        if (chown(channeldir, cfg->user, cfg->group) < 0) {
+            virReportSystemError(errno,
+                                 _("unable to set ownership of '%s' to %d:%d"),
+                                 channeldir, (int) cfg->user,
+                                 (int) cfg->group);
+            VIR_FREE(channeldir);
+            goto error;
+        }
+        VIR_FREE(channeldir);
+        if (chown(cfg->channelTargetDir, cfg->user, cfg->group) < 0) {
+            virReportSystemError(errno,
+                                 _("unable to set ownership of '%s' to %d:%d"),
+                                 cfg->channelTargetDir, (int) cfg->user,
+                                 (int) cfg->group);
+            goto error;
+        }
 
         run_uid = cfg->user;
         run_gid = cfg->group;