clone: Disable domain startup and unpause while cloning

This commit is contained in:
Cole Robinson 2010-05-13 10:37:31 -04:00
parent 3e30e02710
commit cb1385e465
2 changed files with 28 additions and 9 deletions

View File

@ -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)))

View File

@ -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()