7a3408
From ebf1ada37c3566d07c6eb81a2dfe0135394b657a Mon Sep 17 00:00:00 2001
7a3408
Message-Id: <ebf1ada37c3566d07c6eb81a2dfe0135394b657a@dist-git>
7a3408
From: Martin Kletzander <mkletzan@redhat.com>
7a3408
Date: Wed, 26 Aug 2015 11:27:38 +0200
7a3408
Subject: [PATCH] qemu: Label correct per-VM path when starting
7a3408
7a3408
Commit f1f68ca33433825ce0deed2d96f1990200bc6618 overused mdir_name()
7a3408
event though it was not needed in the latest version, hence labelling
7a3408
directory one level up in the tree and not the one it should.
7a3408
7a3408
If anyone with SElinux managed to try run a domain with guest agent set
7a3408
up, it's highly possible that they will need to run 'restorecon -F
7a3408
/var/lib/libvirt/qemu/channel/target' to fix what was done.
7a3408
7a3408
Reported-by: Luyao Huang <lhuang@redhat.com>
7a3408
Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
7a3408
(cherry picked from commit f674dc6794e0946f89313f477aa7886a4a28188e)
7a3408
7a3408
https://bugzilla.redhat.com/show_bug.cgi?id=1146886
7a3408
7a3408
Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
7a3408
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
7a3408
---
7a3408
 src/qemu/qemu_process.c | 16 +++-------------
7a3408
 1 file changed, 3 insertions(+), 13 deletions(-)
7a3408
7a3408
diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c
7a3408
index 8cda456..317ef78 100644
7a3408
--- a/src/qemu/qemu_process.c
7a3408
+++ b/src/qemu/qemu_process.c
7a3408
@@ -46,7 +46,6 @@
7a3408
 
7a3408
 #include "cpu/cpu.h"
7a3408
 #include "datatypes.h"
7a3408
-#include "dirname.h"
7a3408
 #include "virlog.h"
7a3408
 #include "virerror.h"
7a3408
 #include "viralloc.h"
7a3408
@@ -4394,7 +4393,7 @@ int qemuProcessStart(virConnectPtr conn,
7a3408
     unsigned int hostdev_flags = 0;
7a3408
     size_t nnicindexes = 0;
7a3408
     int *nicindexes = NULL;
7a3408
-    char *tmppath = NULL, *tmpdirpath = NULL;
7a3408
+    char *tmppath = NULL;
7a3408
 
7a3408
     VIR_DEBUG("vm=%p name=%s id=%d pid=%llu",
7a3408
               vm, vm->def->name, vm->def->id,
7a3408
@@ -4741,15 +4740,11 @@ int qemuProcessStart(virConnectPtr conn,
7a3408
     if (virFileMakePath(tmppath) < 0)
7a3408
         goto cleanup;
7a3408
 
7a3408
-    if (!(tmpdirpath = mdir_name(tmppath)))
7a3408
-        goto cleanup;
7a3408
-
7a3408
     if (virSecurityManagerDomainSetDirLabel(driver->securityManager,
7a3408
-                                            vm->def, tmpdirpath) < 0)
7a3408
+                                            vm->def, tmppath) < 0)
7a3408
         goto cleanup;
7a3408
 
7a3408
     VIR_FREE(tmppath);
7a3408
-    VIR_FREE(tmpdirpath);
7a3408
 
7a3408
     if (virAsprintf(&tmppath, "%s/domain-%s",
7a3408
                     cfg->channelTargetDir, vm->def->name) < 0)
7a3408
@@ -4758,14 +4753,10 @@ int qemuProcessStart(virConnectPtr conn,
7a3408
     if (virFileMakePath(tmppath) < 0)
7a3408
         goto cleanup;
7a3408
 
7a3408
-    if (!(tmpdirpath = mdir_name(tmppath)))
7a3408
-        goto cleanup;
7a3408
-
7a3408
     if (virSecurityManagerDomainSetDirLabel(driver->securityManager,
7a3408
-                                            vm->def, tmpdirpath) < 0)
7a3408
+                                            vm->def, tmppath) < 0)
7a3408
         goto cleanup;
7a3408
 
7a3408
-    VIR_FREE(tmpdirpath);
7a3408
     VIR_FREE(tmppath);
7a3408
 
7a3408
     /* now that we know it is about to start call the hook if present */
7a3408
@@ -5122,7 +5113,6 @@ int qemuProcessStart(virConnectPtr conn,
7a3408
      * if we failed to initialize the now running VM. kill it off and
7a3408
      * pretend we never started it */
7a3408
     VIR_FREE(tmppath);
7a3408
-    VIR_FREE(tmpdirpath);
7a3408
     VIR_FREE(nodeset);
7a3408
     virCommandFree(cmd);
7a3408
     VIR_FORCE_CLOSE(logfile);
7a3408
-- 
7a3408
2.5.1
7a3408