[libvirt] [libvirt-glib v8 3/5] gconfig: Add GVirConfigDomainHostdevPci

Christophe Fergeau cfergeau at redhat.com
Mon Jul 25 15:55:40 UTC 2016


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
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20160725/81f2ed31/attachment-0001.sig>


More information about the libvir-list mailing list