[XEND][XM] Restore old state string in xm.
authorAlastair Tse <atse@xensource.com>
Fri, 3 Nov 2006 10:39:32 +0000 (10:39 +0000)
committerAlastair Tse <atse@xensource.com>
Fri, 3 Nov 2006 10:39:32 +0000 (10:39 +0000)
Signed-off-by: Alastair Tse <atse@xensource.com>
tools/python/xen/xend/XendConfig.py
tools/python/xen/xm/main.py

index 823ffedd73b0618e59999b158e516b575bc96b23..aff91825af5c576468e329068a93c4be7eac97ca 100644 (file)
@@ -603,7 +603,17 @@ class XendConfig(dict):
 
     def _populate_from_python_config(self, parsed_py):
         raise NotImplementedError
-        
+
+    def _get_old_state_string(self):
+        state_string = ''
+        for state_name in CONFIG_OLD_DOM_STATES:
+            on_off = self.get(state_name, 0)
+            if on_off:
+                state_string += state_name[0]
+            else:
+                state_string += '-'
+
+        return state_string
 
     def get_sxp(self, domain = None, ignore_devices = False, ignore = []):
         """ Get SXP representation of this config object.
@@ -650,6 +660,8 @@ class XendConfig(dict):
         else:
             sxpr.append(['status', str(DOM_STATE_HALTED)])
 
+        sxpr.append(['state', self._get_old_state_string()])
+
         # For save/restore migration
         if domain:
             if domain.store_mfn:
index cfa75460924a06a2e5b48007d603e0057b835eb0..2a3778c7c8ed37348e13d4f136fef851469c27ca 100644 (file)
@@ -542,7 +542,7 @@ def parse_doms_info(info):
         'name'     : get_info('name',         str,   '??'),
         'mem'      : get_info('memory',       int,   0),
         'vcpus'    : get_info('online_vcpus', int,   0),
-        'status'   : get_status('status',     int,   DOM_STATE_HALTED),
+        'state'    : get_info('state',        str,    ''),
         'cpu_time' : get_info('cpu_time',     float, 0),
         'up_time'  : get_info('up_time',      float, -1),
         'seclabel' : security.get_security_printlabel(info),
@@ -566,7 +566,7 @@ def xm_brief_list(doms):
     print '%-40s %3s %5s %5s %10s %9s' % \
           ('Name', 'ID', 'Mem', 'VCPUs', 'State', 'Time(s)')
     
-    format = "%(name)-40s %(domid)3d %(mem)5d %(vcpus)5d %(status)10s " \
+    format = "%(name)-40s %(domid)3d %(mem)5d %(vcpus)5d %(state)10s " \
              "%(cpu_time)8.1f"
     
     for dom in doms:
@@ -578,7 +578,7 @@ def xm_label_list(doms):
           ('Name', 'ID', 'Mem', 'VCPUs', 'State', 'Time(s)', 'Label')
     
     output = []
-    format = '%(name)-32s %(domid)3d %(mem)5d %(vcpus)5d %(status)10s ' \
+    format = '%(name)-32s %(domid)3d %(mem)5d %(vcpus)5d %(state)10s ' \
              '%(cpu_time)8.1f %(seclabel)9s'
     
     for dom in doms: