Here's a sample vdi_create call:
There is only a sr_uuid here, and no vdi_uuid at all.
The way it works is:
1. Xapi receives a VDI.create XenAPI call
2. Xapi checks the SR, figures out which host should do the operation, checks
it has its PBD attached and various other checks
3. On the host in question, Xapi calls out to the SM backend to do a vdi_create
operation. It only tells the SM backend the size of the disk and the
4. The SM backend creates the actual object - a vhd, or an ISO, or an LVM
partition or whatever
5. The SM backend then introduces a VDI record using the XenAPI call
'VDI.db_introduce' - this API call takes a uuid which was made up by the SM
backend. Xapi ensures that the uuid is globally unique and that the location
field is unique within the SR.
6. The SM backend returns control to Xapi, returning a small structure
containing the uuid that it has just made up as well as the location.
7. Xapi looks up the VDI by uuid, and then overwrites several of the fields
(including name_label) with the parameters of the XenAPI VDI.create call (from
8. The VDI.create call finishes, returning the reference of the VDI object.
On all subsequent calls to the backend associated with this VDI (vdi_attach,
vdi_clone, etc.), Xapi will always pass in the reference, uuid and location of
The idea is that the location field is used to identify which VDI xapi is
talking about. For you, in the vdi_create call, the _db_introduce function
the VDI record with your 32 bit id in the location field. All subsequent calls
about that VDI will contain that location field as well as the VDI's uuid, so
the uuid isn't
really important as far as your backend is concerned - all you need is the
location to identify your VDI. You *could* base the uuid of the VDI on your 32
bit id, but it's not necessary.
Hope this helps,
On 20 May 2010, at 02:46, YAMAMOTO Takashi wrote:
>>>>> i'm writing a python sr plugin for our product and have a few questions.
>>>>> - our product has 32-bit id, not uuid, for each volumes, which i want to
>>>>> to xcp's vdi. i generate name-based uuid from the 32-bit id in sr.scan
>>>>> vdi.create. is this a reasonable approach?
>>>> You can use the 'location' field in the VDI to contain your 32 bit id -
>>>> then the uuid is irrelevant. I'd like to move more of the storage backends
>>>> in this direction - currently I believe only the ISO SR does it this way.
>>> ok. in that case, xapi generates random uuids for me, right?
>> Actually the backends are responsible for creating the uuid.
> then, what is vdi_create's uuid argument for?
> (my current plugin code simply ignores the argument and
> return generated uuid via vdi_info. is it ok?)
> our product itself doesn't provide uuids at all. so someone should
> generate ones so that xapi can use them.
> i plan to make my sr plugin generate name-based uuid from our product's
> 32-bit id. does it sound ok for you?
> i'm not sure how your suggestion to use vdi location is related to
> the uuid issue. can you please elaborate a bit?
> YAMAMOTO Takashi
Xen-devel mailing list