Chun Yan Liu
2010-Jun-22 03:04 UTC
[Xen-devel][PATCH]Fix bug that incorrect mac address is saved into VM config info and causes VM fail to restart
Check "mac" address sooner in device_create function, before doing device_add. In XendDomainInfo.py device_create function, when device type is "vif", it has a paragraph to check the validity of "mac" address. Before checking validity, device_add has been done. But after checking validity, if the mac address is invlid, it raises VmError and exits directly without doing clean work like removing the device item from config info. This will cause that the incorrect mac address is saved into VM Config file and VM fails to restart. If check "mac" validity before doing device_add, there will be no problem. Signed-off-by Chunyan Liu <CYLiu@novell.com> diff -r 71bb47f16ec8 tools/python/xen/xend/XendDomainInfo.py --- a/tools/python/xen/xend/XendDomainInfo.pyFri Jun 18 15:53:05 2010 +0800 +++ b/tools/python/xen/xend/XendDomainInfo.pyTue Jun 22 10:34:10 2010 +0800 @@ -851,9 +851,6 @@ """ log.debug("XendDomainInfo.device_create: %s" % scrub_password(dev_config)) dev_type = sxp.name(dev_config) - dev_uuid = self.info.device_add(dev_type, cfg_sxp = dev_config) - dev_config_dict = self.info[''devices''][dev_uuid][1] - log.debug("XendDomainInfo.device_create: %s" % scrub_password(dev_config_dict)) if dev_type == ''vif'': for x in dev_config: @@ -862,6 +859,10 @@ log.error("Virtual network interface creation error - invalid MAC Address entered: %s", x[1]) raise VmError("Cannot create a new virtual network interface - MAC address is not valid!"); + dev_uuid = self.info.device_add(dev_type, cfg_sxp = dev_config) + dev_config_dict = self.info[''devices''][dev_uuid][1] + log.debug("XendDomainInfo.device_create: %s" % scrub_password(dev_config_dict)) + if self.domid is not None: try: dev_config_dict[''devid''] = devid = \ _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel
Ian Jackson
2010-Jun-22 15:03 UTC
Re: [Xen-devel][PATCH]Fix bug that incorrect mac address is saved into VM config info and causes VM fail to restart
Chun Yan Liu writes ("[Xen-devel][PATCH]Fix bug that incorrect mac address is saved into VM config info and causes VM fail to restart"):> Check "mac" address sooner in device_create function, before doing > device_add.Great, thanks. Ian. _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel
Chun Yan Liu
2010-Jun-25 02:32 UTC
[Xen-devel][PATCH]Something wrong in changeset 21653 and 21656
In changeset 21653, http://xenbits.xensource.com/xen-unstable.hg?rev/9da3abe88c90 dev_type = sxp.name(dev_config) should not be moved, otherwise, the checking "mac" paragraph if dev_type == ''vif'': for x in dev_config: if x != ''vif'' and x[0] == ''mac'': if not re.match(''^([0-9a-f]{2}:){5}[0-9a-f]{2}$'', x[1], re.I): log.error("Virtual network interface creation error - invalid MAC Address entered: %s", x[1]) raise VmError("Cannot create a new virtual network interface - MAC address is not valid!"); will become of no use. Just change the other three lines. Please refer to the original patch submitted as below.>>> "Chun Yan Liu" <cyliu@novell.com> 6/22/2010 11:04 上午 >>>Check "mac" address sooner in device_create function, before doing device_add. In XendDomainInfo.py device_create function, when device type is "vif", it has a paragraph to check the validity of "mac" address. Before checking validity, device_add has been done. But after checking validity, if the mac address is invlid, it raises VmError and exits directly without doing clean work like removing the device item from config info. This will cause that the incorrect mac address is saved into VM Config file and VM fails to restart. If check "mac" validity before doing device_add, there will be no problem. Signed-off-by Chunyan Liu <CYLiu@novell.com> diff -r 71bb47f16ec8 tools/python/xen/xend/XendDomainInfo.py --- a/tools/python/xen/xend/XendDomainInfo.pyFri Jun 18 15:53:05 2010 +0800 +++ b/tools/python/xen/xend/XendDomainInfo.pyTue Jun 22 10:34:10 2010 +0800 @@ -851,9 +851,6 @@ """ log.debug("XendDomainInfo.device_create: %s" % scrub_password(dev_config)) dev_type = sxp.name(dev_config) - dev_uuid = self.info.device_add(dev_type, cfg_sxp = dev_config) - dev_config_dict = self.info[''devices''][dev_uuid][1] - log.debug("XendDomainInfo.device_create: %s" % scrub_password(dev_config_dict)) if dev_type == ''vif'': for x in dev_config: @@ -862,6 +859,10 @@ log.error("Virtual network interface creation error - invalid MAC Address entered: %s", x[1]) raise VmError("Cannot create a new virtual network interface - MAC address is not valid!"); + dev_uuid = self.info.device_add(dev_type, cfg_sxp = dev_config) + dev_config_dict = self.info[''devices''][dev_uuid][1] + log.debug("XendDomainInfo.device_create: %s" % scrub_password(dev_config_dict)) + if self.domid is not None: try: dev_config_dict[''devid''] = devid = \ _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel
Ian Jackson
2010-Jun-25 14:14 UTC
Re: [Xen-devel][PATCH]Something wrong in changeset 21653 and 21656
Chun Yan Liu writes ("[Xen-devel][PATCH]Something wrong in changeset 21653 and 21656"):> In changeset 21653, > http://xenbits.xensource.com/xen-unstable.hg?rev/9da3abe88c90 > dev_type = sxp.name(dev_config) > should not be moved, otherwise, the checking "mac" paragraphThanks, sorry about that.> Just change the other three lines. Please refer to the original > patch submitted as below.I couldn''t use your patch directly as it had been badly mangled by your mail program. I made the change by hand and diffed the results against your patch and evidently I failed to spot my mistake in the interdiff. Sorry. Ian. _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel