[Libvir] [Patch 1/4] Xen inactive domains: config file APIs

This patch adds an extra API to the config file management API. This API lets you add a new config parameter to the file. Previously you could only modify existing values, not define extra ones. It also exposes an API for creating a new empty config file record, which is needed if you're creating a brand new config file, rathre than processing an existing one. Dan. -- |=- 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 -=|

On Mon, Sep 04, 2006 at 01:29:55AM +0100, Daniel P. Berrange wrote:
This patch adds an extra API to the config file management API. This API lets you add a new config parameter to the file. Previously you could only modify existing values, not define extra ones. It also exposes an API for creating a new empty config file record, which is needed if you're creating a brand new config file, rathre than processing an existing one.
Okay it all make sense, I was expecting the SetValue to be the first request go ahead :-) ! [...]
+ * virConfGetValue:
it's SetValue :-)
+ * @conf: a configuration file handle + * @entry: the name of the entry + * @value: the new configuration value + * + * Set (or replace) the value associated to this entry in the configuration + * file. + * + * Returns 0 on success, or -1 on failure. Upon success, the passed in + * value will be owned by the conf object & should not be freed.
Hum, it's sometimes interesting to get the previous value when doing a set as a result. Also the need to free only in case of error can lead to problems I have seen in the past similar API which returned the previous value. I wonder if such an API would not be more systematic, maybe it's more troubles than it needs to, and being jet-lag and tired it might be very wrong too :-) 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 Mon, Sep 04, 2006 at 04:59:58AM -0400, Daniel Veillard wrote:
+ * virConfGetValue:
it's SetValue :-)
Opps :-)
+ * @conf: a configuration file handle + * @entry: the name of the entry + * @value: the new configuration value + * + * Set (or replace) the value associated to this entry in the configuration + * file. + * + * Returns 0 on success, or -1 on failure. Upon success, the passed in + * value will be owned by the conf object & should not be freed.
Hum, it's sometimes interesting to get the previous value when doing a set as a result. Also the need to free only in case of error can lead to problems I have seen in the past similar API which returned the previous value. I wonder if such an API would not be more systematic, maybe it's more troubles than it needs to, and being jet-lag and tired it might be very wrong too :-)
Ok, I'll change it so that even in case of error, the virConfSetValue method will free the passed in value. I think returning the old value would unneccessarily complicate things - the caller would then have to worry about free()ing the returned old value even though they didn't want it in the first place! If they did want the old value it wouldn't be much more difficult to get it via virConfGetValue ahead of time. Regards, Dan. -- |=- 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 -=|
participants (2)
-
Daniel P. Berrange
-
Daniel Veillard