From: Pascal Bouchareine Subject: RFC: Migration and VBD/SR/VDI creation Date: Fri, 18 May 2007 16:10:46 +0200 Message-ID: <20070518141046.GA98723@bar.gandi.net> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="gKMricLos+KVdGMg" 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 --gKMricLos+KVdGMg Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Hi, When migrating a domain, the VDI definition is not recreated building the VBD, hence loosing API access to the VBD location & al ({'VDI' : ''}). The attached patch is an attempt to recreate the VDI in XendConfig.device_add (in the 'Local' SR, eventually some other) when using an sxp_obj (I guess the SR/VDI is always defined when using a xenapi_cfg). Is this an acceptable idea ? I missed a lot of things reading the code, so someone might want to check this is not too horrible and doesn't break anything. Cheers, Pascal -- \o/ Pascal Bouchareine - Gandi g 0170393757 15, place de la Nation - 75011 Paris --gKMricLos+KVdGMg Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename="XendConfig_create_vdi.diff" diff -r aee991c7723a tools/python/xen/xend/XendConfig.py --- a/tools/python/xen/xend/XendConfig.py Wed May 9 16:34:47 2007 +0100 +++ b/tools/python/xen/xend/XendConfig.py Fri May 18 16:09:08 2007 +0200 @@ -27,6 +27,7 @@ from xen.xend.XendDevices import XendDev from xen.xend.XendDevices import XendDevices from xen.xend.PrettyPrint import prettyprintstring from xen.xend.XendConstants import DOM_STATE_HALTED +from xen.xend import XendNode log = logging.getLogger("xend.XendConfig") log.setLevel(logging.WARN) @@ -981,6 +982,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'): --gKMricLos+KVdGMg 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 --gKMricLos+KVdGMg--