
On Mon, Jul 25, 2016 at 12:46:52PM +0100, Zeeshan Ali (Khattak) wrote:
+void gvir_config_domain_hostdev_pci_set_address(GVirConfigDomainHostdevPci *hostdev, + GVirConfigDomainAddressPci *address) +{ + GVirConfigObject *source; + xmlNodePtr node; + xmlAttrPtr attr; + + g_return_if_fail(GVIR_CONFIG_IS_DOMAIN_HOSTDEV_PCI(hostdev)); + g_return_if_fail(GVIR_CONFIG_IS_DOMAIN_ADDRESS_PCI(address)); + node = gvir_config_object_get_xml_node(GVIR_CONFIG_OBJECT(address)); + g_return_if_fail(node != NULL); + + source = gvir_config_object_replace_child(GVIR_CONFIG_OBJECT(hostdev), + "source"); + /* Because of https://bugzilla.redhat.com/show_bug.cgi?id=1327577, we can't + * just use GVirConfigDomainAddressPci's node, as is, since it contains + * a 'type' attribute, which is not accepted by libvirt. So we create a + * copy for our use and just delete the 'type' attribute from it. + */ + node = xmlCopyNode(node, 1); + for (attr = node->properties; attr; attr = attr->next) { + if (g_strcmp0 ("type", (char *)attr->name) == 0) { + xmlRemoveProp (attr); + break; + } + }
For what it's worth, introducing a gvir_config_object_remove_attribute() would probably have been nicer than doing the removal on the raw XML here (yeah, fairly late to think about this suggestion ;) Christophe