Re: [libvirt] [PATCH] netcf backend for virInterface*.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Mon, Jul 20, 2009 at 01:42:07PM -0400, Laine Stump wrote:
> +static char *interfaceGetXMLDesc(virInterfacePtr ifinfo,
> +                                 unsigned int flags ATTRIBUTE_UNUSED)
> +{
> +    struct interface_driver *driver = ifinfo->conn->interfacePrivateData;
> +    struct netcf_if *iface = NULL;
> +    char *ret = NULL;
> +
> +    interfaceDriverLock(driver);
> +
> +    iface = interfaceDriverGetNetcfIF(driver->netcf, ifinfo);
> +    if (!iface) {
> +        /* helper already reported error */
> +        goto cleanup;
> +    }
> +
> +    ret = ncf_if_xml_desc(iface);
> +    if (!ret) {
> +        const char *errmsg, *details;
> +        int errcode = ncf_error(driver->netcf, &errmsg, &details);
> +        interfaceReportError(ifinfo->conn, NULL, ifinfo, netcf_to_vir_err(errcode),
> +                             "could not get interface XML description (netcf: %s - %s)",
> +                            errmsg, details ? details : "");
> +        goto cleanup;
> +    }
> +
> +cleanup:
> +    ncf_if_free(iface);
> +    interfaceDriverUnlock(driver);
> +    return ret;
> +}
> +
> +static virInterfacePtr interfaceDefineXML(virConnectPtr conn,
> +                                          const char *xml,
> +                                          unsigned int flags ATTRIBUTE_UNUSED)
> +{
> +    struct interface_driver *driver = conn->interfacePrivateData;
> +    struct netcf_if *iface = NULL;
> +    virInterfacePtr ret = NULL;
> +
> +    interfaceDriverLock(driver);
> +
> +    /*
> +     * This is where we will want to validate the XML, and possibly
> +     * transform it before sending it on.
> +     */
> +
> +    iface = ncf_define(driver->netcf, xml);
> +    if (!iface) {
> +        const char *errmsg, *details;
> +        int errcode = ncf_error(driver->netcf, &errmsg, &details);
> +        interfaceReportError(conn, NULL, NULL, netcf_to_vir_err(errcode),
> +                             "could not get interface XML description (netcf: %s - %s)",
> +                            errmsg, details ? details : "");
> +        goto cleanup;
> +    }
> +
> +    ret = virGetInterface(conn, ncf_if_name(iface), ncf_if_mac_string(iface));
> +
> +cleanup:
> +    ncf_if_free(iface);
> +    interfaceDriverUnlock(driver);
> +    return ret;
> +}

These two method should be round-tripping the XML via the virInterfaceDef
parse/format methods really.


Daniel
-- 
|: Red Hat, Engineering, London   -o-   http://people.redhat.com/berrange/ :|
|: http://libvirt.org  -o-  http://virt-manager.org  -o-  http://ovirt.org :|
|: http://autobuild.org       -o-         http://search.cpan.org/~danberr/ :|
|: GnuPG: 7D3B9505  -o-  F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505 :|

--
Libvir-list mailing list
Libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list

[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]