[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-devel] [BUG, PATCH] xen-4.1-3 xend/XendDomainInfo.py#device_configure() TypeError

  • To: "xen-devel" <xen-devel@xxxxxxxxxxxxx>
  • From: Philipp Hahn <hahn@xxxxxxxxxxxxx>
  • Date: Fri, 24 May 2013 19:53:10 +0200
  • Delivery-date: Fri, 24 May 2013 17:53:34 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xen.org>


I noticed a bug in Xen-4.1-3, which is also still present in xen+git.
I know that the Python xend is deprecated, but I'm stuck with xen-4.1 until xen 
is usable with libvirt, so my patch might still be helpful for others.
This is a follow-up to 
<http://lists.xen.org/archives/html/xen-users/2012-11/msg00069.html>, which 
still keeps me busy.

/xen/xend/server/SrvDomain.py declares, that "dev" is a string:
    def op_device_configure(self, _, req):
        return self.call(self.dom.device_configure,
                         [['config', 'sxpr'],
                          ['dev',    'str']],

but in xen/xend/XendDomainInfo.py "devid" is expected to be an integer:
    def device_configure(self, dev_sxp, devid = None):
        """Configure an existing device.
        @param devid:      device id
        @type  devid:      int

This leads to an error when I try to change the media of an CDROM device:
ERROR (SrvBase:88) Request device_configure failed.
Traceback (most recent call last):
  File "/usr/lib/python2.6/dist-packages/xen/web/SrvBase.py", line 85, in 
    return op_method(op, req)
  File "/usr/lib/python2.6/dist-packages/xen/xend/server/SrvDomain.py", line 
216, in op_device_configure
  File "/usr/lib/python2.6/dist-packages/xen/xend/server/SrvDomain.py", line 
186, in call
    return FormFn(fn, args)(req.args)
  File "/usr/lib/python2.6/dist-packages/xen/xend/Args.py", line 166, in 
    return self.call_with_form_args(self.fn, fargs, xargs=xargs)
  File "/usr/lib/python2.6/dist-packages/xen/xend/Args.py", line 138, in 
    return fn(*params, **keys)
  File "/usr/lib/python2.6/dist-packages/xen/xend/XendDomainInfo.py", line 
1214, in device_configure
    raise VmError("Device %s not connected" % devid)
VmError: Device 768 not connected

This is because devid="768" != dev=768:
    def _getDeviceInfo_vbd(self, devid):
        for dev_type, dev_info in self.info.all_devices_sxpr():
            if dev_type != 'vbd' and dev_type != 'tap' and dev_type != 'tap2':
            dev = sxp.child_value(dev_info, 'dev')
            dev = dev.split(':')[0]
            dev = self.getDeviceController(dev_type).convertToDeviceNumber(dev)
            if devid == dev:
                return dev_info

After applying the attached patch, I can successfully change the media using 
# virsh change-media ucs31-64-hvm hda --eject --live --config
# virsh change-media ucs31-64-hvm hda 
/var/lib/libvirt/images/UCS_3.1-1-amd64.iso --live --config

Philipp Hahn
Philipp Hahn           Open Source Software Engineer      hahn@xxxxxxxxxxxxx
Univention GmbH        be open.                       fon: +49 421 22 232- 0
Mary-Somerville-Str.1  D-28359 Bremen                 fax: +49 421 22 232-99

Attachment: 23394_xen-change-media.diff
Description: Text Data

Xen-devel mailing list



Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.