Hi, Here is a set of patches which start to implement functionality to libvirt-gconfig. The end result is that the "name", "memory" and "features" properties are implemented for the Domain class. Most of the work is about reworking the low-level plumbing to make the implementation as easy as possible. I chose to remove the xmlDocPtr and the xml string that were stored in GVirConfigObject objects and to replace this with a xmlNodePtr. This is useful when creating children objects (eg devices) when parsing a domain XML because the xmlNodePtr will point at the right position in the XML document. One caveat with that approach is that we need to refcount the xmlDocPtr associated with the xmlNodePtr to know when to free it, but this is not implemented yet (though gupnp seems to have code doing exactly this). Then most of the work is adding properties and helpers to make the code easier to write. And thinking about what API we want to expose to clients :) The two test programs should show how the API can be used as it is now. While writing this, I realized we had to do some "useless" work to return strings from libxml2 to glib, ie I g_strdup the string and xmlFree the source so that the caller can free it with g_free. While writing this code, there were at least 2 questions that arose, some input would be welcome :) * I don't know how to handle XMLs where the same node appears multiple times (eg "name"). If it's the latest name that wins, what do we do when changing the name on such an XML document? only modify the last name node? Drop all the redundant name nodes? * I'm also not sure how to make it possible to check whether a given property is set or not. For strings, this is easy, NULL means that the property was not set, but for integers, this is less obvious. Any thoughts on that? Next I'll have to start looking at more complicated properties :) More API questions on the way I guess... Christophe Christophe Fergeau (23): Add helpers in libvirt-gconfig-helpers.[ch] gvir_config_object_parse: don't parse empty documents Add getters for GVirConfig xmlNode and xmlDoc Add GVirConfigObject::node property Add GVir::Config::Domain::name property Rename gvir_config_domain_new Add gvir_config_domain_new to create an empty domain Implement gvir_config_domain_set_name Make the GVirConfigDomain::name property writable Add gvir_config_object_to_xml Use gvir_config_object_to_xml Add domain creation/parsing test Remove GVirConfigObject::docHandle Remove xml parsing from gvir_config_*_new functions Only do XML parsing when creating config objects Remove GError argument from GVirConfigObject::node getter Remove GVirConfigObject::doc Add gvir_config_object_get_node_content Add gvir_config_object_set_node_content Add test-domain-duplicate.xml which currently fails Validate document in parsing test Add GVirConfigDomain::memory Add GVirConfigDomain::features configure.ac | 1 + examples/Makefile.am | 1 + libvirt-gconfig/Makefile.am | 4 + libvirt-gconfig/libvirt-gconfig-capabilities.c | 10 +- libvirt-gconfig/libvirt-gconfig-capabilities.h | 2 +- libvirt-gconfig/libvirt-gconfig-domain-snapshot.c | 9 +- libvirt-gconfig/libvirt-gconfig-domain-snapshot.h | 2 +- libvirt-gconfig/libvirt-gconfig-domain.c | 186 ++++++++++++++++- libvirt-gconfig/libvirt-gconfig-domain.h | 12 +- libvirt-gconfig/libvirt-gconfig-helpers.c | 179 +++++++++++++++ libvirt-gconfig/libvirt-gconfig-helpers.h | 48 ++++ libvirt-gconfig/libvirt-gconfig-interface.c | 12 +- libvirt-gconfig/libvirt-gconfig-interface.h | 2 +- libvirt-gconfig/libvirt-gconfig-network-filter.c | 8 +- libvirt-gconfig/libvirt-gconfig-network-filter.h | 2 +- libvirt-gconfig/libvirt-gconfig-network.c | 8 +- libvirt-gconfig/libvirt-gconfig-network.h | 2 +- libvirt-gconfig/libvirt-gconfig-node-device.c | 9 +- libvirt-gconfig/libvirt-gconfig-node-device.h | 2 +- libvirt-gconfig/libvirt-gconfig-object.c | 244 ++++++++++++--------- libvirt-gconfig/libvirt-gconfig-object.h | 17 ++- libvirt-gconfig/libvirt-gconfig-secret.c | 8 +- libvirt-gconfig/libvirt-gconfig-secret.h | 2 +- libvirt-gconfig/libvirt-gconfig-storage-pool.c | 8 +- libvirt-gconfig/libvirt-gconfig-storage-pool.h | 2 +- libvirt-gconfig/libvirt-gconfig-storage-vol.c | 12 +- libvirt-gconfig/libvirt-gconfig-storage-vol.h | 2 +- libvirt-gconfig/libvirt-gconfig.h | 2 + libvirt-gconfig/libvirt-gconfig.sym | 11 +- libvirt-gconfig/tests/Makefile.am | 16 ++ libvirt-gconfig/tests/test-domain-create.c | 68 ++++++ libvirt-gconfig/tests/test-domain-duplicate.xml | 7 + libvirt-gconfig/tests/test-domain-invalid.xml | 6 + libvirt-gconfig/tests/test-domain-noname.xml | 4 + libvirt-gconfig/tests/test-domain-parse.c | 87 ++++++++ libvirt-gconfig/tests/test-domain.xml | 7 + libvirt-gobject/Makefile.am | 2 + libvirt-gobject/libvirt-gobject-connection.c | 2 +- libvirt-gobject/libvirt-gobject-domain-snapshot.c | 3 + libvirt-gobject/libvirt-gobject-domain.c | 6 +- libvirt-gobject/libvirt-gobject-interface.c | 3 + libvirt-gobject/libvirt-gobject-network-filter.c | 3 + libvirt-gobject/libvirt-gobject-network.c | 3 + libvirt-gobject/libvirt-gobject-node-device.c | 4 + libvirt-gobject/libvirt-gobject-secret.c | 4 + libvirt-gobject/libvirt-gobject-storage-pool.c | 5 +- libvirt-gobject/libvirt-gobject-storage-vol.c | 3 + 47 files changed, 895 insertions(+), 145 deletions(-) create mode 100644 libvirt-gconfig/libvirt-gconfig-helpers.c create mode 100644 libvirt-gconfig/libvirt-gconfig-helpers.h create mode 100644 libvirt-gconfig/tests/Makefile.am create mode 100644 libvirt-gconfig/tests/test-domain-create.c create mode 100644 libvirt-gconfig/tests/test-domain-duplicate.xml create mode 100644 libvirt-gconfig/tests/test-domain-invalid.xml create mode 100644 libvirt-gconfig/tests/test-domain-noname.xml create mode 100644 libvirt-gconfig/tests/test-domain-parse.c create mode 100644 libvirt-gconfig/tests/test-domain.xml -- 1.7.6.4 -- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list