[Libvir] RFC: get/set properties

Daniel P. Berrange berrange at redhat.com
Tue Apr 15 18:46:06 UTC 2008


On Tue, Apr 15, 2008 at 11:31:32AM -0700, Ryan Scott wrote:
> 
>   I'd like to get some comments on the following...
> 
>   We would like to use libvirt to store some properties related to a 
> domain.  This can be done by adding a simple get/set API as follows:

What are the properties ?  I'm not really very enthusiastic about the
idea of adding API / XML for generic key,value properties. I think it
will quickly be abused as a way to add arbitrary, non-standardized 
hypervisor / driver specific configuration which would be better 
represented with explicit schema.

> /*
>  * Domain property get/set interfaces
>  *
>  * For GetProp, the return value must be freed by the caller.
>  */
> char *          virDomainGetProp    (virDomainPtr domain,
>                         const char *propName);
> 
> int         virDomainSetProp    (virDomainPtr domain,
>                         const char *propName,
>                         const char *value);

>   The XML would look something like this:
> 
> virsh # dumpxml solaris-pv-0
> <domain type='xen' id='-1'>
> [ snip ]
>   <properties>
>     <blah value="3"/>
>     <foo value="bar"/>
>   </properties>
> </domain>

One of the key ideas behind libvirt is that we try to provide a consistent
set of configuration options across all drivers. NB, I'm not saying we need
the lowest-common denominator - just that we try to formalize a way to
represent every configuration option in such a away that it could be applied
to any driver.  I don't think simple  key,value pairs are sufficient in the
general case. 

As an example, you could define a property 'console' which takes a pty path
as its value. But  if you want to generalize this to different types of
console access, then a single value becomes insufficient.eg need a host+port
for a console accessed over TCP. The more explicit specialized <console>
tag allows us the flexibility of adding attributes and sub-elements as 
needed, not restricting ourselves to key,value pairs.

Dan,
-- 
|: Red Hat, Engineering, Boston   -o-   http://people.redhat.com/berrange/ :|
|: http://libvirt.org  -o-  http://virt-manager.org  -o-  http://ovirt.org :|
|: http://autobuild.org       -o-         http://search.cpan.org/~danberr/ :|
|: GnuPG: 7D3B9505  -o-  F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505 :|




More information about the libvir-list mailing list