mirror of
https://github.com/virt-manager/virt-manager.git
synced 2025-01-11 05:17:59 +03:00
clone: Disable domain startup and unpause while cloning
This commit is contained in:
parent
3e30e02710
commit
cb1385e465
@ -742,17 +742,23 @@ class vmmCloneVM(gobject.GObject):
|
|||||||
details = None
|
details = None
|
||||||
|
|
||||||
try:
|
try:
|
||||||
# Open a seperate connection to install on since this is async
|
try:
|
||||||
logging.debug("Threading off connection to clone VM.")
|
self.orig_vm.set_cloning(True)
|
||||||
newconn = util.dup_conn(self.config, self.conn)
|
|
||||||
meter = vmmCreateMeter(asyncjob)
|
|
||||||
|
|
||||||
self.clone_design.orig_connection = newconn
|
# Open a seperate connection to install on since this is async
|
||||||
for d in self.clone_design.clone_virtual_disks:
|
logging.debug("Threading off connection to clone VM.")
|
||||||
d.conn = newconn
|
newconn = util.dup_conn(self.config, self.conn)
|
||||||
|
meter = vmmCreateMeter(asyncjob)
|
||||||
|
|
||||||
|
self.clone_design.orig_connection = newconn
|
||||||
|
for d in self.clone_design.clone_virtual_disks:
|
||||||
|
d.conn = newconn
|
||||||
|
|
||||||
|
self.clone_design.setup()
|
||||||
|
CloneManager.start_duplicate(self.clone_design, meter)
|
||||||
|
finally:
|
||||||
|
self.orig_vm.set_cloning(False)
|
||||||
|
|
||||||
self.clone_design.setup()
|
|
||||||
CloneManager.start_duplicate(self.clone_design, meter)
|
|
||||||
except Exception, e:
|
except Exception, e:
|
||||||
error = (_("Error creating virtual machine clone '%s': %s") %
|
error = (_("Error creating virtual machine clone '%s': %s") %
|
||||||
(self.clone_design.clone_name, str(e)))
|
(self.clone_design.clone_name, str(e)))
|
||||||
|
@ -74,6 +74,7 @@ class vmmDomainBase(vmmLibvirtObject):
|
|||||||
|
|
||||||
self._backend = backend
|
self._backend = backend
|
||||||
self.uuid = uuid
|
self.uuid = uuid
|
||||||
|
self.cloning = False
|
||||||
|
|
||||||
self._startup_vcpus = None
|
self._startup_vcpus = None
|
||||||
|
|
||||||
@ -122,6 +123,11 @@ class vmmDomainBase(vmmLibvirtObject):
|
|||||||
def get_autostart(self):
|
def get_autostart(self):
|
||||||
raise NotImplementedError()
|
raise NotImplementedError()
|
||||||
|
|
||||||
|
def get_cloning(self):
|
||||||
|
return self.cloning
|
||||||
|
def set_cloning(self, val):
|
||||||
|
self.cloning = bool(val)
|
||||||
|
|
||||||
# Device/XML altering API
|
# Device/XML altering API
|
||||||
def set_autostart(self, val):
|
def set_autostart(self, val):
|
||||||
raise NotImplementedError()
|
raise NotImplementedError()
|
||||||
@ -1295,6 +1301,9 @@ class vmmDomain(vmmDomainBase):
|
|||||||
self._update_status()
|
self._update_status()
|
||||||
|
|
||||||
def startup(self):
|
def startup(self):
|
||||||
|
if self.get_cloning():
|
||||||
|
raise RuntimeError(_("Cannot start guest while cloning "
|
||||||
|
"operation in progress"))
|
||||||
self._backend.create()
|
self._backend.create()
|
||||||
self._update_status()
|
self._update_status()
|
||||||
|
|
||||||
@ -1306,6 +1315,10 @@ class vmmDomain(vmmDomainBase):
|
|||||||
self._backend.undefine()
|
self._backend.undefine()
|
||||||
|
|
||||||
def resume(self):
|
def resume(self):
|
||||||
|
if self.get_cloning():
|
||||||
|
raise RuntimeError(_("Cannot resume guest while cloning "
|
||||||
|
"operation in progress"))
|
||||||
|
|
||||||
self._backend.resume()
|
self._backend.resume()
|
||||||
self._update_status()
|
self._update_status()
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user