Container: call shutdown() in parallel to speed up cleanup
This commit is contained in:
parent
abe5fc6972
commit
9d383e3fd9
|
@ -201,6 +201,17 @@ class Container(util.LibvirtObject):
|
||||||
|
|
||||||
self.lxc_container = self.conn.createXML(xml)
|
self.lxc_container = self.conn.createXML(xml)
|
||||||
|
|
||||||
|
def notify_cleanup(self):
|
||||||
|
""" This method can be called before `cleanup` to notify the host that a
|
||||||
|
cleanup will be performed soon, speeding the process up. """
|
||||||
|
if self.lxc_container:
|
||||||
|
try:
|
||||||
|
self.lxc_container.shutdown()
|
||||||
|
except libvirt.libvirtError as exn:
|
||||||
|
if not str(exn).startswith("Domain not found:"):
|
||||||
|
raise exn
|
||||||
|
# Else, the machine was already stopped: everything is fine
|
||||||
|
|
||||||
def cleanup(self):
|
def cleanup(self):
|
||||||
if self.lxc_container:
|
if self.lxc_container:
|
||||||
try:
|
try:
|
||||||
|
|
|
@ -52,8 +52,8 @@ class Topology:
|
||||||
self.conn = conn
|
self.conn = conn
|
||||||
self.parsed = False
|
self.parsed = False
|
||||||
|
|
||||||
self.domains = None
|
self.domains = []
|
||||||
self.links = None
|
self.links = []
|
||||||
|
|
||||||
@requires_parsed
|
@requires_parsed
|
||||||
@requires_id_in_link_range
|
@requires_id_in_link_range
|
||||||
|
@ -159,6 +159,10 @@ class Topology:
|
||||||
print("{} domains: ".format("Starting" if state else "Stopping"), end="\t")
|
print("{} domains: ".format("Starting" if state else "Stopping"), end="\t")
|
||||||
sys.stdout.flush()
|
sys.stdout.flush()
|
||||||
|
|
||||||
|
if state is False:
|
||||||
|
for dom in self.domains:
|
||||||
|
dom.notify_cleanup()
|
||||||
|
|
||||||
for dom_id in range(len(self.domains)):
|
for dom_id in range(len(self.domains)):
|
||||||
self.dom_setstate_single(dom_id, state, verbose, verbose_inline=True)
|
self.dom_setstate_single(dom_id, state, verbose, verbose_inline=True)
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue