diff --git a/src/virtManager/clone.py b/src/virtManager/clone.py index e68045454..736747942 100644 --- a/src/virtManager/clone.py +++ b/src/virtManager/clone.py @@ -742,17 +742,23 @@ class vmmCloneVM(gobject.GObject): details = None try: - # Open a seperate connection to install on since this is async - logging.debug("Threading off connection to clone VM.") - newconn = util.dup_conn(self.config, self.conn) - meter = vmmCreateMeter(asyncjob) + try: + self.orig_vm.set_cloning(True) - self.clone_design.orig_connection = newconn - for d in self.clone_design.clone_virtual_disks: - d.conn = newconn + # Open a seperate connection to install on since this is async + logging.debug("Threading off connection to clone VM.") + 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: error = (_("Error creating virtual machine clone '%s': %s") % (self.clone_design.clone_name, str(e))) diff --git a/src/virtManager/domain.py b/src/virtManager/domain.py index 00a9b0ca5..d996bf130 100644 --- a/src/virtManager/domain.py +++ b/src/virtManager/domain.py @@ -74,6 +74,7 @@ class vmmDomainBase(vmmLibvirtObject): self._backend = backend self.uuid = uuid + self.cloning = False self._startup_vcpus = None @@ -122,6 +123,11 @@ class vmmDomainBase(vmmLibvirtObject): def get_autostart(self): raise NotImplementedError() + def get_cloning(self): + return self.cloning + def set_cloning(self, val): + self.cloning = bool(val) + # Device/XML altering API def set_autostart(self, val): raise NotImplementedError() @@ -1295,6 +1301,9 @@ class vmmDomain(vmmDomainBase): self._update_status() def startup(self): + if self.get_cloning(): + raise RuntimeError(_("Cannot start guest while cloning " + "operation in progress")) self._backend.create() self._update_status() @@ -1306,6 +1315,10 @@ class vmmDomain(vmmDomainBase): self._backend.undefine() def resume(self): + if self.get_cloning(): + raise RuntimeError(_("Cannot resume guest while cloning " + "operation in progress")) + self._backend.resume() self._update_status()