[elbe-devel] [PATCH v2 06/10] initvmaction: use systemwide libvirt instance

Torben Hohn torben.hohn at linutronix.de
Tue Apr 17 12:39:37 CEST 2018


this change allows several users to share the initvm, because using
the same filesystem image with more than one user results in hard
to debug deadlocking problems with domain start and creation.

This move makes it necessary, that the initvm domain name is configured
to a different name, when more than one initvm shall be running on a
single host.

Due to soap tcp port conflicts, we need special configuration of SOAP
Ports already, so this just requires one more thing that needs to be
configured, when more than one initvm shall run on a single host.

With this patch applied, elbe users need be part of the libvirt group.

Signed-off-by: Torben Hohn <torben.hohn at linutronix.de>
---
 elbepack/initvmaction.py | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/elbepack/initvmaction.py b/elbepack/initvmaction.py
index b9fcdeb6..05ebf877 100644
--- a/elbepack/initvmaction.py
+++ b/elbepack/initvmaction.py
@@ -81,7 +81,7 @@ class InitVMAction(object):
     def __init__(self, node, initvmNeeded=True):
         # The tag initvmNeeded is required in order to be able to run `elbe
         # initvm create`
-        self.conn = libvirt.open("qemu:///session")
+        self.conn = libvirt.open("qemu:///system")
         try:
             self.initvm = self.conn.lookupByName(cfg['initvm_domain'])
         except libvirt.libvirtError:
@@ -180,7 +180,7 @@ class AttachAction(InitVMAction):
             sys.exit(20)
 
         print('Attaching to initvm console.')
-        system('virsh console %s' % cfg['initvm_domain'])
+        system('virsh --connect qemu:///system console %s' % cfg['initvm_domain'])
 
 
 InitVMAction.register(AttachAction)
@@ -227,12 +227,12 @@ class CreateAction(InitVMAction):
             print("If you want to build in your old initvm, "
                   "use `elbe initvm submit <xml>`.")
             print("If you want to remove your old initvm from libvirt "
-                    "run `virsh undefine %s`.\n" % cfg['initvm_domain'])
+                    "run `virsh --connect qemu:///system undefine %s`.\n" % cfg['initvm_domain'])
             print("Note:")
             print("\t1) You can reimport your old initvm via "
-                    "`virsh define <file>`")
+                    "`virsh --connect qemu:///system define <file>`")
             print("\t   where <file> is the corresponding libvirt.xml")
-            print("\t2) virsh undefine does not delete the image "
+            print("\t2) virsh --connect qemu:///system undefine does not delete the image "
                   "of your old initvm.")
             sys.exit(20)
 
@@ -341,7 +341,7 @@ class CreateAction(InitVMAction):
             self.conn.defineXML(xml)
         except CommandError:
             print('Registering initvm in libvirt failed', file=sys.stderr)
-            print('Try `virsh undefine %s` to delete existing initvm' % cfg['initvm_domain'],
+            print('Try `virsh --connect qemu:///system undefine %s` to delete existing initvm' % cfg['initvm_domain'],
                   file=sys.stderr)
             sys.exit(20)
 
-- 
2.11.0




More information about the elbe-devel mailing list