
On Tue, Jan 31, 2012 at 12:02:05PM +0100, Christophe Fergeau wrote:
Based on a patch from Zeeshan Ali (Khattak) <zeeshanak@gnome.org> --- libvirt-gconfig/libvirt-gconfig-domain.c | 60 +++++++++++++++++++++ libvirt-gconfig/libvirt-gconfig-domain.h | 7 +++ libvirt-gconfig/libvirt-gconfig-helpers-private.h | 1 + libvirt-gconfig/libvirt-gconfig-helpers.c | 23 ++++++++- libvirt-gconfig/libvirt-gconfig-object-private.h | 3 + libvirt-gconfig/libvirt-gconfig-object.c | 20 +++++++ libvirt-gconfig/libvirt-gconfig.sym | 2 + 7 files changed, 115 insertions(+), 1 deletions(-)
ACK, if one question is answered.
diff --git a/libvirt-gconfig/libvirt-gconfig-domain.c b/libvirt-gconfig/libvirt-gconfig-domain.c index 61af625..606f5a4 100644 --- a/libvirt-gconfig/libvirt-gconfig-domain.c +++ b/libvirt-gconfig/libvirt-gconfig-domain.c @@ -449,3 +449,63 @@ GList *gvir_config_domain_get_devices(GVirConfigDomain *domain)
return data.devices; } + +gboolean gvir_config_domain_set_custom_xml(GVirConfigDomain *domain, + const gchar *xml, + const gchar *ns, + const gchar *ns_uri, + GError **error) +{ + GVirConfigObject *metadata; + GVirConfigObject *custom_xml; + + g_return_val_if_fail(GVIR_CONFIG_IS_DOMAIN(domain), FALSE); + g_return_val_if_fail(xml != NULL, FALSE);
Shouldn't we allow NULL 'xml' here, as a means to remove the existing element under that namespace ? Alternatively we can add an explicit API to delete custom XML nodes.
+ g_return_val_if_fail(error == NULL || *error == NULL, FALSE); + + metadata = gvir_config_object_add_child(GVIR_CONFIG_OBJECT(domain), "metadata"); + + custom_xml = gvir_config_object_new_from_xml(GVIR_CONFIG_TYPE_OBJECT, NULL, NULL, xml, error); + if (error != NULL && *error != NULL) + return FALSE; + + gvir_config_object_set_namespace(custom_xml, ns, ns_uri); + + gvir_config_object_attach_replace(metadata, custom_xml); + + return TRUE; +}
Daniel -- |: http://berrange.com -o- http://www.flickr.com/photos/dberrange/ :| |: http://libvirt.org -o- http://virt-manager.org :| |: http://autobuild.org -o- http://search.cpan.org/~danberr/ :| |: http://entangle-photo.org -o- http://live.gnome.org/gtk-vnc :|