コード例 #1
0
ファイル: test-gconfig.c プロジェクト: agx/libvirt-glib
static void test_domain_device_network(void)
{
    GVirConfigDomain *domain;
    GVirConfigDomainInterface *interface;

    domain = gvir_config_domain_new();

    interface = GVIR_CONFIG_DOMAIN_INTERFACE(gvir_config_domain_interface_network_new());
    gvir_config_domain_interface_network_set_source(GVIR_CONFIG_DOMAIN_INTERFACE_NETWORK(interface),
                                                    "default");
    gvir_config_domain_add_device(domain, GVIR_CONFIG_DOMAIN_DEVICE(interface));
    g_object_unref(G_OBJECT(interface));

    interface = GVIR_CONFIG_DOMAIN_INTERFACE(gvir_config_domain_interface_user_new());
    gvir_config_domain_interface_set_ifname(interface, "eth0");
    gvir_config_domain_interface_set_link_state(interface,
                                                GVIR_CONFIG_DOMAIN_INTERFACE_LINK_STATE_UP);
    gvir_config_domain_interface_set_mac(interface, "00:11:22:33:44:55");
    gvir_config_domain_interface_set_model(interface, "foo");
    gvir_config_domain_add_device(domain, GVIR_CONFIG_DOMAIN_DEVICE(interface));
    g_object_unref(G_OBJECT(interface));

    check_xml(domain, "gconfig-domain-device-network.xml");

    g_object_unref(G_OBJECT(domain));
}
コード例 #2
0
static const gchar *gvir_domain_interface_get_path(GVirDomainInterface *self)
{
    GVirConfigDomainDevice *config;
    const gchar *path = NULL;

    config = gvir_domain_device_get_config(GVIR_DOMAIN_DEVICE(self));
    if (GVIR_CONFIG_IS_DOMAIN_INTERFACE_USER(self))
        /* FIXME: One of the limitations of user-mode networking of libvirt */
        g_debug("Statistics gathering for user-mode network not yet supported");
    else
        path = gvir_config_domain_interface_get_ifname(GVIR_CONFIG_DOMAIN_INTERFACE (config));

    g_object_unref (config);

    return path;
}