Signed-off-by: Lucio Correia <luciojhc(a)linux.vnet.ibm.com>
---
kvmusertests.py | 13 ++++++++++---
1 file changed, 10 insertions(+), 3 deletions(-)
diff --git a/kvmusertests.py b/kvmusertests.py
index a3fb273..3b3a603 100644
--- a/kvmusertests.py
+++ b/kvmusertests.py
@@ -1,6 +1,6 @@
# Project Kimchi
#
-# Copyright IBM Corp, 2015-2016
+# Copyright IBM Corp, 2015-2017
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
@@ -17,6 +17,7 @@
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
import libvirt
+import os
import platform
import psutil
import threading
@@ -56,12 +57,18 @@ class UserTests(object):
with RollbackContext() as rollback:
with cls.lock:
- conn = libvirt.open(None)
+ conn = libvirt.open("qemu:///session")
rollback.prependDefer(conn.close)
f = libvirt.VIR_DOMAIN_START_AUTODESTROY
dom = conn.createXML(xml, flags=f)
rollback.prependDefer(dom.destroy)
- filename = '/var/run/libvirt/qemu/%s.pid' % KVMUSERTEST_VM_NAME
+
+ # find pid file for VM
+ uid = str(os.getuid())
+ filedir = os.path.join('/run/user', uid,
'libvirt/qemu/run')
+ if uid == '0':
+ filedir = '/var/run/libvirt/qemu'
+ filename = os.path.join(filedir, KVMUSERTEST_VM_NAME + ".pid")
with open(filename) as f:
pidStr = f.read()
p = psutil.Process(int(pidStr))
--
2.7.4