Product SiteDocumentation Site

7.5.2. Activating an interface

virInterfaceDestroy makes the given interface inactive ("down"). On success, it returns 0. If there is any problem making the interface acrive, -1 is returned.
virInterfacePtr iface;

iface = virInterfaceLookupByName("eth2");
if (!iface) {
    printf("Interface eth2 not found.\n");
} else {
    if (virInterfaceDestroy(iface) != 0) {
        fprintf(stderr, "failed to destroy (deactivate) interface eth2.\n");
    } else
        /* do whatever you wanted to do with interface down */
        if (virInterfaceCreate(iface) != 0) {
        fprintf(stderr, "failed to create (activate) interface eth2.\n");
        }
    }
    free(iface);
}
Example 7.13. Temporarily bring down eth2, then bring it back up