From: Keir Fraser Date: Tue, 19 May 2009 00:37:19 +0000 (+0100) Subject: xend: solve issues with xm block-configure command. X-Git-Url: http://xenbits.xensource.com/gitweb?a=commitdiff_plain;h=9528ca9f77fe92a4e014543d9b6badeb6e6245df;p=people%2Fliuw%2Flibxenctrl-split%2Fxen.git xend: solve issues with xm block-configure command. In the case of inactive managed domains: The following error occurs currently. We cannot change the configuration of the VBD by using xm block-configure. Of course, using xm block-detach and xm block-attach instead of xm block-configure, we can change it. However, I'd like to change it by using xm block-configure. In the case of active domains: Another problem occurs after a domain was rebooted. Even if we change a configuration of a VBD in the domain by using xm block-configure, the configuration of the VBD is reverted to previous configuration after the domain was rebooted. Signed-off-by: Masaki Kanno --- diff --git a/tools/python/xen/xend/XendDomainInfo.py b/tools/python/xen/xend/XendDomainInfo.py index c4492f6edd..c4da7fba79 100644 --- a/tools/python/xen/xend/XendDomainInfo.py +++ b/tools/python/xen/xend/XendDomainInfo.py @@ -1048,14 +1048,41 @@ class XendDomainInfo: except IndexError: pass - # use DevController.reconfigureDevice to change device config dev_control = self.getDeviceController(dev_class) - dev_uuid = dev_control.reconfigureDevice(devid, dev_config) + if devid is None: + dev = dev_config.get('dev', '') + if not dev: + raise VmError('Block device must have virtual details specified') + if 'ioemu:' in dev: + (_, dev) = dev.split(':', 1) + try: + (dev, _) = dev.split(':', 1) # Remove ":disk" or ":cdrom" + except ValueError: + pass + devid = dev_control.convertToDeviceNumber(dev) + dev_info = self._getDeviceInfo_vbd(devid) + if dev_info is None: + raise VmError("Device %s not connected" % devid) + dev_uuid = sxp.child_value(dev_info, 'uuid') + + if self.domid is not None: + # use DevController.reconfigureDevice to change device config + dev_control.reconfigureDevice(devid, dev_config) + else: + (_, new_b, new_f) = dev_control.getDeviceDetails(dev_config) + if (new_f['device-type'] == 'cdrom' and + sxp.child_value(dev_info, 'dev').endswith(':cdrom') and + new_b['mode'] == 'r' and + sxp.child_value(dev_info, 'mode') == 'r'): + pass + else: + raise VmError('Refusing to reconfigure device %s:%d to %s' % + (dev_class, devid, dev_config)) # update XendConfig with new device info - if dev_uuid: - self.info.device_update(dev_uuid, dev_sxp) - + self.info.device_update(dev_uuid, dev_sxp) + xen.xend.XendDomain.instance().managed_config_save(self) + return True def waitForDevices(self):