changeset 22770:4970452f21b6

tools/xend: check for device model if path is not specified

this is the patch to check for device model (in when the
device_model had no path specified, i.e. XenD was trying to read the
file on the auxbin path. Without this patch applied the meaningless
python error "coercing to Unicode: need string or buffer, NoneType
found" occurred:

[2010-11-30 13:56:47 5255] ERROR (xmlrpclib2:181) Internal error
handling xend.domain.create
Traceback (most recent call last):
File "/usr/lib64/python2.4/site-packages/xen/util/",
line 134, in _marshaled_dispatch
response = self._dispatch(method, params)
File "/usr/lib64/python2.4/", line 406, in _dispatch
return func(*params)
line 80, in domain_create
info = XendDomain.instance().domain_create(config)
File "/usr/lib64/python2.4/site-packages/xen/xend/",
line 1001, in domain_create
dominfo = XendDomainInfo.create(config)
File "/usr/lib64/python2.4/site-packages/xen/xend/",
line 97, in create
domconfig = XendConfig.XendConfig(sxp_obj = config)
File "/usr/lib64/python2.4/site-packages/xen/xend/",
line 367, in __init__
File "/usr/lib64/python2.4/site-packages/xen/xend/",
line 558, in validate
File "/usr/lib64/python2.4/site-packages/xen/xend/",
line 502, in _platform_sanity_check
if not os.path.exists(self['platform']['device_model']):
File "/usr/lib64/python2.4/", line 171, in exists
st = os.stat(path)
TypeError: coercing to Unicode: need string or buffer, NoneType found

This patch raises VmError with message that no valid device model was
specified if None type was found in the device_model specification.

It's been tested on non-existing device model where the message is being
printed. If an invalid (but existing) device_model is set in the
configuration file the domain was destroyed because it crashed. If there
is a path specified (i.e. it's not using auxbin path) it bails with
error that the device model was not found (which was already implemented

Signed-off-by: Michal Novotny <>
Committed-by: Ian Jackson <>
author Michal Novotny <>
date Tue Jan 11 18:51:28 2011 +0000 (2011-01-11)
parents 0bb8685eab9b
children b0c06d6e176d
files tools/python/xen/xend/
line diff
     1.1 --- a/tools/python/xen/xend/	Tue Jan 11 18:44:41 2011 +0000
     1.2 +++ b/tools/python/xen/xend/	Tue Jan 11 18:51:28 2011 +0000
     1.3 @@ -498,6 +498,10 @@ class XendConfig(dict):
     1.4              if os.path.dirname(self['platform']['device_model']) == "":
     1.5                  self['platform']['device_model'] = \
     1.6                      auxbin.pathTo(self['platform']['device_model'])
     1.7 +            # If the device_model is not set the os.path.exists() would raise
     1.8 +            # an exception so we return our error message instead if applicable
     1.9 +            if not self['platform']['device_model']:
    1.10 +                raise VmError("No valid device model specified")
    1.11              if not os.path.exists(self['platform']['device_model']):
    1.12                  raise VmError("device model '%s' not found" % str(self['platform']['device_model']))