From: Pascal Bouchareine Subject: [PATCH] [API] XendConfig does not create VDI Date: Fri, 13 Jul 2007 13:50:55 +0200 Message-ID: <20070713115055.GA22744@bar.gandi.net> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="gBBFr7Ir9EOA20Yy" Return-path: Content-Disposition: inline List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xensource.com Errors-To: xen-devel-bounces@lists.xensource.com To: xen-devel@lists.xensource.com List-Id: xen-devel@lists.xenproject.org --gBBFr7Ir9EOA20Yy Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Hi again, After a xend restart or a migration, we lose API VDI information for a given VBD: >>> x2.VBD.get_record(s2, 'ffdbd103-9c5f-9439-22a0-8685c8599213') {'Status': 'Success', 'Value': {'uuid': 'ffdbd103-9c5f-9439-22a0-8685c8599213', 'bootable': '0', 'runtime_properties': {}, 'VM': '1d73ea95-966b-4a54-1c86-ae17381a3c8b', 'metrics': 'ffdbd103-9c5f-9439-22a0-8685c8599213', 'VDI': 'c695a71e-b8d3-660f-577f-c77b225decd6', 'mode': 'RW', 'device': 'xvda', 'type': 'Disk'}} <- xend restart -> >>> x2.VBD.get_record(s2, 'ffdbd103-9c5f-9439-22a0-8685c8599213') {'Status': 'Success', 'Value': {'uuid': 'ffdbd103-9c5f-9439-22a0-8685c8599213', 'bootable': '1', 'runtime_properties': {}, 'VM': '1d73ea95-966b-4a54-1c86-ae17381a3c8b', 'metrics': 'ffdbd103-9c5f-9439-22a0-8685c8599213', 'VDI': '', 'mode': 'RW', 'device': 'xvda', 'type': 'Disk'}} This behaviour is a bit annoying here. Any idea for this to get fixed ? I'm currently using the attached patch but it's not very clean and I'm affraid this breaks things. -- \o/ Pascal Bouchareine - Gandi g 0170393757 15, place de la Nation - 75011 Paris --gBBFr7Ir9EOA20Yy Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename="XendConfig_create_vdi.diff" diff -r 93b9161fc920 tools/python/xen/xend/XendConfig.py --- a/tools/python/xen/xend/XendConfig.py Mon Jul 2 00:24:59 2007 +0100 +++ b/tools/python/xen/xend/XendConfig.py Fri Jul 13 13:45:26 2007 +0200 @@ -29,6 +29,7 @@ from xen.xend.XendConstants import DOM_S from xen.xend.XendConstants import DOM_STATE_HALTED from xen.xend.server.netif import randomMAC from xen.util.blkif import blkdev_name_to_number +from xen.xend import XendNode log = logging.getLogger("xend.XendConfig") log.setLevel(logging.WARN) @@ -1056,6 +1057,26 @@ class XendConfig(dict): dev_uuid = uuid.createString() dev_info['uuid'] = dev_uuid + if dev_type in ('vbd', 'tap') and not dev_info.get('VDI'): + xennode = XendNode.instance() + sr_name = dev_info.get('SR', 'Local') + sr_matching = xennode.get_sr_by_name(sr_name) + if len(sr_matching): + sr_ref = sr_matching[0] + sr = xennode.srs[sr_ref] + for vdi_ref in sr.get_vdis(): + vdi = sr.get_vdi_by_uuid(vdi_ref) + if vdi.get_location() == dev_info['uname']: + vdi.addVBD(dev_info['uuid']) + dev_info['VDI'] = vdi_ref + + if not dev_info.get('VDI'): + vdi_ref = sr.create_vdi({'other_config': + {'location':dev_info['uname']}}) + vdi = sr.get_vdi_by_uuid(vdi_ref) + vdi.addVBD(dev_info['uuid']) + dev_info['VDI'] = vdi_ref + # store dev references by uuid for certain device types target['devices'][dev_uuid] = (dev_type, dev_info) if dev_type in ('vif', 'vbd', 'vtpm'): --gBBFr7Ir9EOA20Yy Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel --gBBFr7Ir9EOA20Yy--