Merge branch 'master' of git://git.qubes-os.org/marmarek/core-admin

This commit is contained in:
Joanna Rutkowska 2013-11-02 11:35:41 -04:00
commit 124a8f6892
5 changed files with 60 additions and 4 deletions

View File

@ -562,7 +562,10 @@ class QubesVm(object):
elif dominfo['crashed']:
return "Crashed"
elif dominfo['shutdown']:
return "Halting"
if dominfo['shutdown_reason'] == 2:
return "Suspended"
else:
return "Halting"
elif dominfo['dying']:
return "Dying"
else:
@ -1532,6 +1535,42 @@ class QubesVm(object):
subprocess.call (['/usr/sbin/xl', 'destroy', str(xid) if xid is not None else self.name])
def suspend(self):
if dry_run:
return
if not self.is_running() and not self.is_paused():
raise QubesException ("VM already stopped!")
if len (self.pcidevs) > 0:
xs_path = '/local/domain/%d/control/shutdown' % self.get_xid()
xs.write('', xs_path, 'suspend')
tries = 0
while self.get_power_state() != "Suspended":
tries += 1
if tries > 15:
# fallback to pause
print >>sys.stderr, "Failed to suspend domain %s, falling back to pause method" % self.name
self.pause()
break
time.sleep(0.2)
else:
self.pause()
def resume(self):
if dry_run:
return
xc_info = self.get_xc_dominfo()
if not xc_info:
raise QubesException ("VM isn't started (cannot get xc_dominfo)!")
if xc_info['shutdown_reason'] == 2:
# suspended
xc.domain_resume(xc_info['domid'], 1)
else:
self.unpause()
def pause(self):
if dry_run:
return

View File

@ -63,6 +63,9 @@ class QubesDom0NetVm(QubesNetVm):
def start(self, **kwargs):
raise QubesException ("Cannot start Dom0 fake domain!")
def suspend(self):
return
def get_xl_dominfo(self):
if dry_run:
return

View File

@ -269,6 +269,15 @@ class QubesHVm(QubesVm):
self.wait_for_session(notify_function=kwargs.get('notify_function', None))
def suspend(self):
if dry_run:
return
if not self.is_running() and not self.is_paused():
raise QubesException ("VM not running!")
self.pause()
def pause(self):
if dry_run:
return

View File

@ -51,7 +51,9 @@ class SystemState:
if self.domdict.has_key(id):
self.domdict[id].memory_actual = domain['mem_kb']*1024
self.domdict[id].memory_maximum = self.xs.read('', '/local/domain/%s/memory/static-max' % str(id))
if not self.domdict[id].memory_maximum:
if self.domdict[id].memory_maximum:
self.domdict[id].memory_maximum = int(self.domdict[id].memory_maximum)*1024
else:
self.domdict[id].memory_maximum = self.ALL_PHYS_MEM
# the previous line used to be
# self.domdict[id].memory_maximum = domain['maxmem_kb']*1024

View File

@ -154,6 +154,8 @@ def main():
vms_list = [vm for vm in qvm_collection.values()]
if len(args) > 0:
vms_list = [vm for vm in vms_list if vm.name in args]
no_vms = len (vms_list)
vms_to_display = []
# Frist, the NetVMs...
@ -161,9 +163,10 @@ def main():
if netvm.is_netvm():
vms_to_display.append (netvm)
# Now, the AppVMs without template...
# Now, the AppVMs without template (or with template not included in the list)...
for appvm in vms_list:
if appvm.is_appvm() and appvm.template is None:
if appvm.is_appvm() and (appvm.template is None or \
appvm.template not in vms_list):
vms_to_display.append (appvm)
# Now, the template, and all its AppVMs...