This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
Home Products Support Community News


Re: [Xen-devel] XCP: python SR plugin questions

To: YAMAMOTO Takashi <yamamoto@xxxxxxxxxxxxx>
Subject: Re: [Xen-devel] XCP: python SR plugin questions
From: Jonathan Ludlam <Jonathan.Ludlam@xxxxxxxxxxxxx>
Date: Thu, 20 May 2010 09:49:59 +0100
Accept-language: en-US
Acceptlanguage: en-US
Cc: "xen-devel@xxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxx>
Delivery-date: Thu, 20 May 2010 01:51:10 -0700
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
In-reply-to: <20100520014601.2E35B71901@xxxxxxxxxxxxxxxx>
List-help: <mailto:xen-devel-request@lists.xensource.com?subject=help>
List-id: Xen developer discussion <xen-devel.lists.xensource.com>
List-post: <mailto:xen-devel@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=unsubscribe>
References: <6CC2BAAB-E1DC-4288-BF7E-A9355591B776@xxxxxxxxxxxxx> <20100520014601.2E35B71901@xxxxxxxxxxxxxxxx>
Sender: xen-devel-bounces@xxxxxxxxxxxxxxxxxxx
Thread-index: Acr3+W9fmk2sbkCNSNOo/hUNS2DeMQ==
Thread-topic: [Xen-devel] XCP: python SR plugin questions

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 
'sm_config' map.
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 
step 1).
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 VDI:


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 
would create
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:

> hi,
>>>>> 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 
>>>>> map
>>>>> to xcp's vdi.  i generate name-based uuid from the 32-bit id in sr.scan 
>>>>> and
>>>>> 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