XendConfig does not create VDI
PATCH 1/1 XendConfig does not create VDI
Hi again,
After a xend restart or a migration, we lose API VDI information for a given VBD:
Quoted 1 line
Quoted 1 line
Quoted 1 line
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 ->
Quoted 1 line
Quoted 1 line
Quoted 1 line
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.
Signature · 2 lines
\o/ Pascal Bouchareine - Gandi g 0170393757 15, place de la Nation - 75011 Paris
tools/python/xen/xend/XendConfig.py +21 -0
@@ -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'):
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel