The way it's done is just a band-aid though. The need for this 'type' member in GVirConfigInterface and GVirConfigDeviceDisk is a clear indication that they should be separate class. --- libvirt-gconfig/libvirt-gconfig-interface.c | 30 ++++++++++++++++++++++++++- libvirt-gconfig/libvirt-gconfig-interface.h | 2 + libvirt-gconfig/libvirt-gconfig.sym | 1 + 3 files changed, 32 insertions(+), 1 deletions(-) diff --git a/libvirt-gconfig/libvirt-gconfig-interface.c b/libvirt-gconfig/libvirt-gconfig-interface.c index d112123..0993ab9 100644 --- a/libvirt-gconfig/libvirt-gconfig-interface.c +++ b/libvirt-gconfig/libvirt-gconfig-interface.c @@ -36,7 +36,7 @@ extern gboolean debugFlag; struct _GVirConfigInterfacePrivate { - gboolean unused; + GVirConfigInterfaceNetworkType type; }; G_DEFINE_TYPE(GVirConfigInterface, gvir_config_interface, GVIR_TYPE_CONFIG_DEVICE); @@ -96,5 +96,33 @@ void gvir_config_interface_set_network_type(GVirConfigInterface *interface, type); if (type_str != NULL) { xmlNewProp(node, (xmlChar*)"type", (xmlChar*)type_str); + interface->priv->type = type; } } + +void gvir_config_interface_set_source(GVirConfigInterface *interface, + const char *source) +{ + xmlNodePtr source_node; + const char *attribute_name; + + if (interface->priv->type != GVIR_CONFIG_INTERFACE_TYPE_NETWORK) { + /* I don't know what attribute name to use for 'dir' */ + g_warning("set_source not implemented for non-'network' interface nodes"); + return; + } + + source_node = gvir_config_object_new_child(GVIR_CONFIG_OBJECT(interface), + "source", TRUE); + if (source_node == NULL) + return; + + switch (interface->priv->type) { + case GVIR_CONFIG_INTERFACE_TYPE_NETWORK: + attribute_name = "network"; + break; + default: + g_return_if_reached(); + } + xmlNewProp(source_node, (xmlChar*)attribute_name, (xmlChar*)source); +} diff --git a/libvirt-gconfig/libvirt-gconfig-interface.h b/libvirt-gconfig/libvirt-gconfig-interface.h index 9618611..8de3334 100644 --- a/libvirt-gconfig/libvirt-gconfig-interface.h +++ b/libvirt-gconfig/libvirt-gconfig-interface.h @@ -74,6 +74,8 @@ GVirConfigInterface *gvir_config_interface_new_from_xml(const gchar *xml, void gvir_config_interface_set_network_type(GVirConfigInterface *interface, GVirConfigInterfaceNetworkType type); +void gvir_config_interface_set_source(GVirConfigInterface *interface, + const char *source); G_END_DECLS #endif /* __LIBVIRT_GCONFIG_INTERFACE_H__ */ diff --git a/libvirt-gconfig/libvirt-gconfig.sym b/libvirt-gconfig/libvirt-gconfig.sym index e9f1513..886690e 100644 --- a/libvirt-gconfig/libvirt-gconfig.sym +++ b/libvirt-gconfig/libvirt-gconfig.sym @@ -53,6 +53,7 @@ LIBVIRT_GOBJECT_0.0.1 { gvir_config_interface_new; gvir_config_interface_new_from_xml; gvir_config_interface_set_network_type; + gvir_config_interface_set_source; gvir_config_network_get_type; gvir_config_network_new; -- 1.7.7 -- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list