This file is indexed.

/usr/share/doc/libvirt-glib-1.0-dev/examples/conn-test.c is in libvirt-glib-1.0-dev 0.2.2-0.1ubuntu1.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
/*
 * conn-test.c: test libvirt gobject integration
 *
 * Copyright (C) 2010-2011 Red Hat, Inc.
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library. If not, see
 * <http://www.gnu.org/licenses/>.
 *
 * Author: Daniel P. Berrange <berrange@redhat.com>
 */

#include <config.h>

#include <libvirt-gobject/libvirt-gobject.h>

static void
do_connection_open(GObject *source,
                   GAsyncResult *res,
                   gpointer opaque G_GNUC_UNUSED)
{
    GVirConnection *conn = GVIR_CONNECTION(source);
    GError *err = NULL;
    gchar *hv_name = NULL;
    gulong hv_version = 0;
    guint major, minor, micro;

    if (!gvir_connection_open_finish(conn, res, &err)) {
        g_error("%s", err->message);
    }

    g_print("Connected to libvirt\n");

    if (!(hv_name = gvir_connection_get_hypervisor_name(conn, &err))) {
        g_error("%s", err->message);
    }

    g_print("Hypervisor name: %s\n", hv_name);

    if (!(hv_version = gvir_connection_get_version(conn, &err))) {
        g_error("%s", err->message);
    }

    major = hv_version / 1000000;
    hv_version %= 1000000;
    minor = hv_version / 1000;
    micro = hv_version % 1000;
    g_print("Hypervisor version: %u.%u.%u\n", major, minor, micro);

    g_free(hv_name);
    g_object_unref(conn);
}

static void quit(gpointer data,
                 GObject *where_the_object_was G_GNUC_UNUSED)
{
    GMainLoop *loop = data;

    g_main_loop_quit(loop);
}

int main(int argc, char **argv)
{
    GVirConnection *conn;
    GMainLoop *loop;

    gvir_init_object(&argc, &argv);

    if (argc != 2) {
        g_error("syntax: %s URI", argv[0]);
        return 1;
    }

    loop = g_main_loop_new(g_main_context_default(),
                           TRUE);

    conn = gvir_connection_new(argv[1]);
    g_object_weak_ref(G_OBJECT(conn), quit, loop);

    gvir_connection_open_async(conn, NULL, do_connection_open, loop);

    g_main_loop_run(loop);


    return 0;
}