[Libvir] Proposal for virtual devices described in XML

Daniel P. Berrange berrange at redhat.com
Wed Sep 27 17:43:35 UTC 2006

On Wed, Sep 27, 2006 at 05:21:33PM +0200, michel.ponceau at bull.net wrote:
> After comments from Daniel P. Berrange and from Bull people, my proposal 
> is reduced to following 2 functions:
> /* Create a virtual device attachment to backend */
> int virDomainAttachDevice(virDomainPtr domain, char *xml);

This is definitely a good way forward - it lets us re-use the existing
code for parsing device descriptions very easily.

> /* Destroy a virtual device attachment to backend */
> int virDomainDetachDevice(virDomainPtr domain, char *xml);
> /* @domain: pointer to domain object
> * @xml: pointer to XML description of one device
> * Returns 0 in case of success, -1 in case of failure. */

I was wondering whether we need to have the full XML block passed in
for detaching devices. Perhaps it is sufficient to just pass i nthe
target name of the device. Then again, some implementations may prefer
to have the full XML blob available to allow greater sanity checking
when detaching, so its probably worth while.

> The XML would be in same form as the part of domain description for a 
> single device, either <disk.../disk> or <interface.../interface>.

Very nice.

> The device is identified by its target name. This attribute is optional 
> for "interface" in domain description, but would become mandatory in 
> Attach/Detach description. It is not yet processed in Libvirt-0.1.6 source 
> xml.c (function virDomainParseXMLIfDesc). I have successfully tried the attached patch, which tranlates "target" 
> into Xen "vifname". (It processes "ip" attribute in same way, but my try 
> failed, maybe because address value was invalid for Xen).

I'm not sure I like the idea of having to explicitly set a vif name for
every guest NIC we define - principally because there's no straightforward
way for a user of this API to determine what VIF names are already in use,
vs free. It also seems XenD does not tell us what the vifname for running
domains are - although I think the info is in xenstore somewhere. I can see
why we need the vifname to detach the device though.

If we can find a way to fill in the vifname when dumping the XML, then this
would let a caller uniquely identify an existing device, without us 
requireing that vifnames are used when creating a domain/attaching a new
device (& thus let Xen still auto-allocate them)

|=- Red Hat, Engineering, Emerging Technologies, Boston.  +1 978 392 2496 -=|
|=-           Perl modules: http://search.cpan.org/~danberr/              -=|
|=-               Projects: http://freshmeat.net/~danielpb/               -=|
|=-  GnuPG: 7D3B9505   F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505  -=| 

More information about the libvir-list mailing list