Product SiteDocumentation Site

7.4.2. Undefining an inteface configuration

virInterfaceUndefine completely and permanently removes the configuration for the given interface from tho host's configuration files. If you might want to recreate this configuration again in the future, you should call virInterfacegetXMLDesc and save the string prior to the undefine.
virInterfaceUndefine does not free the virInterfacePtr itself, it only removes the configuration from the host. You must still free the virInterfacePtr with virInterfaceFree.
virInterfacePtr iface;
char *xml = NULL;;

iface = virInterfaceLookupByName("br0");
if (!iface) {
    printf ("Interface br0 not found.\n");
} else {
    xml = virinterfaceGetXMLDesc(iface, 0);
    virInterfaceUndefine(iface);
    virinterfaceFree(iface);
}
/* you must also free the buffer at xml when you're finished with it */
--------------
Example 7.12. Undefining br0 interface after saving its XML data