[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-changelog] [xen-unstable] [XEND][XM] Fixes for xm list output
# HG changeset patch # User Alastair Tse <atse@xxxxxxxxxxxxx> # Node ID 41ad2c673fdb39524d4388c82bb8b04f1a0c0042 # Parent 70687bcb82dd0b2d5813e6125c95ff908e25c94d [XEND][XM] Fixes for xm list output Do not output image, security if they are empty Change xm list slightly to be more informative about state. Add back store_mfn and console_mfn to the SXP so save/restore can work again. Signed-off-by: Alastair Tse <atse@xxxxxxxxxxxxx> --- tools/python/xen/xend/XendConfig.py | 52 +++++++++--------------------------- tools/python/xen/xm/main.py | 20 ++++++++----- 2 files changed, 26 insertions(+), 46 deletions(-) diff -r 70687bcb82dd -r 41ad2c673fdb tools/python/xen/xend/XendConfig.py --- a/tools/python/xen/xend/XendConfig.py Thu Nov 02 07:46:06 2006 +0000 +++ b/tools/python/xen/xend/XendConfig.py Thu Nov 02 14:26:01 2006 +0000 @@ -24,47 +24,13 @@ from xen.xend.XendDevices import XendDev from xen.xend.XendDevices import XendDevices from xen.xend.XendLogging import log from xen.xend.PrettyPrint import prettyprintstring +from xen.xend.XendConstants import DOM_STATE_HALTED """ XendConfig API XendConfig will try to mirror as closely the Xen API VM Struct providing a backwards compatibility mode for SXP dumping, loading. - -XendConfig is a subclass of the python dict in order to emulate the -previous behaviour of the XendDomainInfo.info dictionary. However, -the new dictionary also exposes a set of attributes that implement -the Xen API VM configuration interface. - -Example: - ->>> cfg = XendConfig(cfg = dict_from_xc_domain_getinfo) ->>> cfg.name_label -Domain-0 ->>> cfg['name'] -Domain-0 ->>> cfg.kernel_kernel -/boot/vmlinuz-xen ->>> cfg.kernel_initrd -/root/initrd ->>> cfg.kernel_args -root=/dev/sda1 ro ->>> cfg['image'] -(linux - (kernel /boot/vmlinuz-xen) - (ramdisk /root/initrd) - (root '/dev/sda1 ro')) ->>> - -Internally, XendConfig will make sure changes via the old 'dict' -interface get reflected, if possible, to the attribute store. - -It does this by overriding __setitem__, __getitem__, __hasitem__, -__getattr__, __setattr__, __hasattr__. - -What this means is that as code is moved from the SXP interface to -the Xen API interface, we can spot unported code by tracing calls -to __getitem__ and __setitem__. """ @@ -665,9 +631,9 @@ class XendConfig(dict): if self[cfg] != None: sxpr.append([cfg, self[cfg]]) - if 'image' in self: + if 'image' in self and self['image'] != None: sxpr.append(['image', self['image']]) - if 'security' in self: + if 'security' in self and self['security']: sxpr.append(['security', self['security']]) if 'shutdown_reason' in self: sxpr.append(['shutdown_reason', self['shutdown_reason']]) @@ -684,7 +650,17 @@ class XendConfig(dict): sxpr.append(['on_xend_start', self.get('on_xend_start', 'ignore')]) sxpr.append(['on_xend_stop', self.get('on_xend_stop', 'ignore')]) - sxpr.append(['status', domain.state]) + if domain: + sxpr.append(['status', domain.state]) + else: + sxpr.append(['status', DOM_STATE_HALTED]) + + # For save/restore migration + if domain: + if domain.store_mfn: + sxpr.append(['store_mfn', domain.store_mfn]) + if domain.console_mfn: + sxpr.append(['console_mfn', domain.console_mfn]) # Marshall devices (running or from configuration) if not ignore_devices: diff -r 70687bcb82dd -r 41ad2c673fdb tools/python/xen/xm/main.py --- a/tools/python/xen/xm/main.py Thu Nov 02 07:46:06 2006 +0000 +++ b/tools/python/xen/xm/main.py Thu Nov 02 14:26:01 2006 +0000 @@ -39,6 +39,7 @@ from xen.xend import sxp from xen.xend import sxp from xen.xend import XendClient from xen.xend.XendClient import server +from xen.xend.XendConstants import * from xen.xm.opts import OptionError, Opts, wrap, set_true from xen.xm import console @@ -532,13 +533,16 @@ def parse_doms_info(info): def parse_doms_info(info): def get_info(n, t, d): return t(sxp.child_value(info, n, d)) + + def get_status(n, t, d): + return DOM_STATES[t(sxp.child_value(info, n, d))] return { 'domid' : get_info('domid', int, -1), 'name' : get_info('name', str, '??'), 'mem' : get_info('memory', int, 0), 'vcpus' : get_info('online_vcpus', int, 0), - 'state' : get_info('state', str, '??'), + 'status' : get_status('status', int, DOM_STATE_HALTED), 'cpu_time' : get_info('cpu_time', float, 0), 'up_time' : get_info('up_time', float, -1), 'seclabel' : security.get_security_printlabel(info), @@ -559,10 +563,10 @@ def parse_sedf_info(info): } def xm_brief_list(doms): - print '%-40s %3s %8s %5s %5s %9s' % \ - ('Name', 'ID', 'Mem(MiB)', 'VCPUs', 'State', 'Time(s)') - - format = "%(name)-40s %(domid)3d %(mem)8d %(vcpus)5d %(state)5s " \ + 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 " \ "%(cpu_time)8.1f" for dom in doms: @@ -570,11 +574,11 @@ def xm_brief_list(doms): print format % d def xm_label_list(doms): - print '%-32s %3s %8s %5s %5s %9s %-8s' % \ - ('Name', 'ID', 'Mem(MiB)', 'VCPUs', 'State', 'Time(s)', 'Label') + print '%-32s %3s %5s %5s %5s %9s %-8s' % \ + ('Name', 'ID', 'Mem', 'VCPUs', 'State', 'Time(s)', 'Label') output = [] - format = '%(name)-32s %(domid)3d %(mem)8d %(vcpus)5d %(state)5s ' \ + format = '%(name)-32s %(domid)3d %(mem)5d %(vcpus)5d %(status)10s ' \ '%(cpu_time)8.1f %(seclabel)9s' for dom in doms: _______________________________________________ Xen-changelog mailing list Xen-changelog@xxxxxxxxxxxxxxxxxxx http://lists.xensource.com/xen-changelog
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |