[Libvir] RFC: get/set properties

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: /* * 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); Sample command-line usage: virsh # setprop solaris-pv-0 foo bar virsh # setprop solaris-pv-0 blah 3 virsh # getprop solaris-pv-0 foo foo: bar 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> Looking at the Xen code, I'll need to do a bit of work on that API before I can implement this. I don't know how well this will fit into the other hypervisors that Libvirt supports, so I'll leave those implementations up to someone else :) Any thoughts? -Ryan

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

Daniel P. Berrange wrote:
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.
One thing we have in mind is driver/software version numbers. For example, the control tools may change the domain configuration based on whether a certain driver has the support for a new feature. If we create the domain's xml with the driver information, we can make this decision quickly, on the fly, in dom0. While this information is related to domain configuration, it's not hypervisor-specific, so I'm not sure where else we would put it in the domain's XML description. This gives the control tools someplace to store that information, rather than having to create some separate storage for each domain.
/* * 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.
This wasn't meant to be a generic solution to handle storage of all domain information. For your example below, if someone wants more information on the console, the API should be extended to allow that. However, extending the API to every piece of information for a domain seems to be overkill. That's why we just want a simple name/value pair. -Ryan
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,

On Tue, Apr 15, 2008 at 02:23:53PM -0700, Ryan Scott wrote:
Daniel P. Berrange wrote:
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.
One thing we have in mind is driver/software version numbers. For example, the control tools may change the domain configuration based on whether a certain driver has the support for a new feature. If we create the domain's xml with the driver information, we can make this decision quickly, on the fly, in dom0.
Taking the specific example of driver support I think it's far better to express that as part of the device description of the domain. If it's about the Guest OS currently we only have a generic <domain> <os> <type> ...</type> having a version attribute there sounds reasonable. If it's about the emulated hardware, for example the number of crypto engine like in the lDOM description the proper place would under <domain> <features>
While this information is related to domain configuration, it's not hypervisor-specific, so I'm not sure where else we would put it in the domain's XML description.
Domain configuration pertains to the XML domain description for sure but this need to be added in a structured way.
This gives the control tools someplace to store that information, rather than having to create some separate storage for each domain.
I think every new addition to the structure need to be examined on a case by case basis, in order to keep libvirt API and the tools buit on top of them coherent. It is certainly more complex than opening the gate to a completely unstructured mechanism but like any API design, it takes a bit of time and efforts to find the proper syntactic constructs. The effort pays off on the long term IMHO. Daniel -- Red Hat Virtualization group http://redhat.com/virtualization/ Daniel Veillard | virtualization library http://libvirt.org/ veillard@redhat.com | libxml GNOME XML XSLT toolkit http://xmlsoft.org/ http://veillard.com/ | Rpmfind RPM search engine http://rpmfind.net/

On Wed, Apr 16, 2008 at 03:58:16AM -0400, Daniel Veillard wrote:
One thing we have in mind is driver/software version numbers. For example, the control tools may change the domain configuration based on whether a certain driver has the support for a new feature. If we create the domain's xml with the driver information, we can make this decision quickly, on the fly, in dom0.
Taking the specific example of driver support I think it's far better to express that as part of the device description of the domain.
There's a wider usage case though. Management tools can often need to track assets, and the UUID is not necessarily sufficient for that. Tools want to be able to associate textual descriptions of the asset, or define ownership. All of these are higher-level values that don't necessarily have any meaning to the v12n technology itself. More crucially they can be specific to the management tool, and lack any reasonable generalization.
This gives the control tools someplace to store that information, rather than having to create some separate storage for each domain.
I think every new addition to the structure need to be examined on a case by case basis, in order to keep libvirt API and the tools buit on top of them coherent.
I agree with this personally... regards john

On Wed, Apr 16, 2008 at 12:13:09PM +0100, John Levon wrote:
On Wed, Apr 16, 2008 at 03:58:16AM -0400, Daniel Veillard wrote:
One thing we have in mind is driver/software version numbers. For example, the control tools may change the domain configuration based on whether a certain driver has the support for a new feature. If we create the domain's xml with the driver information, we can make this decision quickly, on the fly, in dom0.
Taking the specific example of driver support I think it's far better to express that as part of the device description of the domain.
There's a wider usage case though. Management tools can often need to track assets, and the UUID is not necessarily sufficient for that. Tools
Hum, why is UUID insufficient for tracking ? I understand that maintaining coherency and access to metadata is not easy, but I don't see why the UUID is insufficient to make the binding, or did I misunderstood ?
want to be able to associate textual descriptions of the asset, or define ownership. All of these are higher-level values that don't necessarily have any meaning to the v12n technology itself. More crucially they can be specific to the management tool, and lack any reasonable generalization.
I agree. The point is that the XML used by libvirt for domains is a view of the domain sufficient to create it on the hypervisor and able to be recreated just from the hypervisor data. The fact that Xen embbeded some kind of database as part of the hypervisor and exposed it on the stack is just bad design taste IMHO and can't be generalized to all hypervisors. Of course there is a need higher in the stack to associate metadata with the domain instance, but the fact this can be put in the hypervisor is a Xen specific as far as I can tell, and I'm reluctant to put this in the libvirt XML format, because this is not hypervisor domain data, and would break portability as far as I can tell. Daniel -- Red Hat Virtualization group http://redhat.com/virtualization/ Daniel Veillard | virtualization library http://libvirt.org/ veillard@redhat.com | libxml GNOME XML XSLT toolkit http://xmlsoft.org/ http://veillard.com/ | Rpmfind RPM search engine http://rpmfind.net/

On Wed, Apr 16, 2008 at 08:34:23AM -0400, Daniel Veillard wrote:
want to be able to associate textual descriptions of the asset, or define ownership. All of these are higher-level values that don't necessarily have any meaning to the v12n technology itself. More crucially they can be specific to the management tool, and lack any reasonable generalization.
Of course there is a need higher in the stack to associate metadata with the domain instance, but the fact this can be put in the hypervisor is a Xen specific as far as I can tell, and I'm reluctant to put this
Then this seems to be an argument for improving the other solutions not crippling libvirt. Or at the very least providing a mechanism that won't work on the other implementations, as happens with many libvirt facilities already.
in the libvirt XML format, because this is not hypervisor domain data, and would break portability as far as I can tell.
What do you mean by "break portability" ? regards john

On Wed, Apr 16, 2008 at 12:13:09PM +0100, John Levon wrote:
On Wed, Apr 16, 2008 at 03:58:16AM -0400, Daniel Veillard wrote:
One thing we have in mind is driver/software version numbers. For example, the control tools may change the domain configuration based on whether a certain driver has the support for a new feature. If we create the domain's xml with the driver information, we can make this decision quickly, on the fly, in dom0.
Taking the specific example of driver support I think it's far better to express that as part of the device description of the domain.
There's a wider usage case though. Management tools can often need to track assets, and the UUID is not necessarily sufficient for that. Tools want to be able to associate textual descriptions of the asset, or define ownership. All of these are higher-level values that don't necessarily have any meaning to the v12n technology itself. More crucially they can be specific to the management tool, and lack any reasonable generalization.
This kind of information doesn't really belong in the domain XML. The domain XML is describing an instantiation of a VM on a particular machine. If you have a application managing a bunch of VMs & hosts across the data center you're not going to be relying on the hosts running the VMs as your master storage repository for information about a VM. You have to expect any host in the data center is expendible and can go away at any time. The management app will have its own storage database of some form where it keeps its master copy of all configs so it can re-deploy the VM to another host upon failure of a physical host. This is the logical place for asset / ownership data and any other metadata of this kind, along with the master copy of the VM configuration (which may or may not be stored in the libvirt XML format). The VM configuration need only be pushed out to individual hosts when a VM is deployed / run, and does not need to include asset / ownership metadata. 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 :|

On Tue, Apr 15, 2008 at 02:23:53PM -0700, Ryan Scott wrote:
Daniel P. Berrange wrote:
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.
One thing we have in mind is driver/software version numbers. For example, the control tools may change the domain configuration based on whether a certain driver has the support for a new feature. If we create the domain's xml with the driver information, we can make this decision quickly, on the fly, in dom0.
What are the drivers for ? As an example, if you're refering to drivers for the backend disk devices assigned to a guest, then we alreayd have a <driver/> element for <disk> devices, where we can add a 'version=' attribute. If its not per-domain specific, then we have the 'capabilities' XML format which can be used to expose information about the capabilities of a hypervisor. For now we expose information about supported migration protocols, supported OS types & architectures. There's clearly scope for defining further bits of metadata here. So unless more concrete examples of properties come to light I'm still not seeing any compelling argument for generic key,value pairs.
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.
This wasn't meant to be a generic solution to handle storage of all domain information. For your example below, if someone wants more information on the console, the API should be extended to allow that.
However, extending the API to every piece of information for a domain seems to be overkill. That's why we just want a simple name/value pair.
While extending the XML format for every piece of information is clearly more work than a generic name/value pair, this is a worthwhile tradeoff because it forces us to think about the scope of everything we add, and hopefully come up with an optimal way of representing it. 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 :|

My first thought as a layman is that libvirt should only contain information related to the actual running of the virtual machine i.e. not things that might concern say, customer data (this may not be your use case). I would say that's up to the end user to manage with their own databases, cross referenced with a virtual machine name or similar unique identifier. I'd be interested to hear what those who've actually contributed to the project think though! :p Henri 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:
/* * 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);
Sample command-line usage:
virsh # setprop solaris-pv-0 foo bar
virsh # setprop solaris-pv-0 blah 3
virsh # getprop solaris-pv-0 foo foo: bar
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>
Looking at the Xen code, I'll need to do a bit of work on that API before I can implement this. I don't know how well this will fit into the other hypervisors that Libvirt supports, so I'll leave those implementations up to someone else :)
Any thoughts?
-Ryan
-- Libvir-list mailing list Libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list

Henri Cook wrote:
My first thought as a layman is that libvirt should only contain information related to the actual running of the virtual machine i.e. not things that might concern say, customer data (this may not be your use case).
I would say that's up to the end user to manage with their own databases, cross referenced with a virtual machine name or similar unique identifier.
The end users are free to do that, but this presents a simplified administration model. Why create a separate database, when the information we need can be stored in the domain description? -Ryan
I'd be interested to hear what those who've actually contributed to the project think though! :p
Henri
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:
/* * 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);
Sample command-line usage:
virsh # setprop solaris-pv-0 foo bar
virsh # setprop solaris-pv-0 blah 3
virsh # getprop solaris-pv-0 foo foo: bar
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>
Looking at the Xen code, I'll need to do a bit of work on that API before I can implement this. I don't know how well this will fit into the other hypervisors that Libvirt supports, so I'll leave those implementations up to someone else :)
Any thoughts?
-Ryan
-- Libvir-list mailing list Libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list

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:
/* * 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);
Sample command-line usage:
virsh # setprop solaris-pv-0 foo bar
virsh # setprop solaris-pv-0 blah 3
virsh # getprop solaris-pv-0 foo foo: bar
Would you have a meaningful concrete example instead ?
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>
The XML is a part of the API. This allows some flexibility but I think should be kept under control. I don't understand what need this should fullfill and I'm afraid this open the door to a lot of problems. Experience proved that you really need the xmldump result for a domain to really match what is used to crate it. So you can't use it for application input, it really has to represent data that the hypervisor knows about the domain. I have a bit of experience with XML and markup language too and dropping control for the structure in that way means a depreciation of the value of the data. This means for example it would become impossible to build XSLT stylesheet transforming the XML, because suddenly the language is not fully defined anymore by the libvirt project description. I really don't understand what you are trying to achieve, and I'm wondering if this means we need to extend existing structure, or if this is just not hypervisor related. Daniel -- Red Hat Virtualization group http://redhat.com/virtualization/ Daniel Veillard | virtualization library http://libvirt.org/ veillard@redhat.com | libxml GNOME XML XSLT toolkit http://xmlsoft.org/ http://veillard.com/ | Rpmfind RPM search engine http://rpmfind.net/
participants (5)
-
Daniel P. Berrange
-
Daniel Veillard
-
Henri Cook
-
John Levon
-
Ryan Scott