Add new XCP sm backend – a trial for tapdisk ram driver
Recently, I try to figure out how to add a new tapdisk driver and integrate it into Xen Cloud Platform(XCP). For the other Xen based product, the README in source tree is good enough. However, XCP has its own way. We much follow the Storage Manager API(SM API) and implement them under /opt/xensource/sm directory in your XCP/XenServer dom0 filesystem.
If your new storage backend does not rely on tapdisk, the DummySR.py and the VASSR.py( under /opt/xensource/sm ) are good references. and you have no reason to read following. 😛
Here is a trivial dirty hack to show how to integrate SM API and ram type tapdisk. Before we start, you should know there are few tapdisk driver types not enabled in XCP/XenServer (In fact, they only enable aio and vhd by default). The ram type is one of them.
If you would like to give a try, please using the command tap-ctl create -a ram:/tmp/itone.img . The response is your new block device. Here is tap-ctl detail usage and sample.
And, here we go:
- Copy DummySR.py to ramSR.py. Link ramSR.py to ramSR.
- edit ramSR.py, rename Dummy with ram.
- Find the line TYPE = ‘dummy’, this would be used in ramSR.handles(), in ramSR.py, it should be TYPE = ‘ram’
- Find load() method in class ramSR, only one statement in the method body, self.sr_vditype = ‘phy’. the sr_vditype will hint tapdisk to use which kind of driver type. So, here should be ‘ram‘
- next and the most dirty work: Find your method load() in class ramVDI, assign /tmp/itone.img to self.path
- Final, blktap2.py should allow new tapdisk driver type. So we add ‘ram’ to TYPES list in class Tapdisk, map ‘ram’ : ‘ram’ in VDI._tap_type() method, and add mapping ‘ram’ : ‘tap’, into VDI_PLUG_TYPE in class VDI.
Done. If someone try to integrate Parallax , this could, might, should help.
But I have another plan… ^^
If you have something share or correct me, you may write to my wordpress host(before the first dot part) AT gmail. Thank you.
supplement: self.path will bypass into your td_open() as the second parameter “const char* name“. ( normally, in the block-xxx_type.c file)