aboutsummaryrefslogtreecommitdiffstats
path: root/vconsole.h
blob: c637bb3932e8acfe67795655fbdc53f3903a0c32 (plain)
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
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
#include <errno.h>
#include <fcntl.h>
#include <assert.h>
#include <inttypes.h>

#include <sys/stat.h>
#include <sys/time.h>

#include <gtk/gtk.h>
#include <vte/vte.h>

#include <libvirt/libvirt.h>

/* ------------------------------------------------------------------ */

enum vconsole_cols {
    /* common */
    NAME_COL,

    /* hosts only */
    CPTR_COL,  // vconsole_connect
    URI_COL,

    /* guests only */
    DPTR_COL,  // vconsole_domain
    ID_COL,
    STATE_COL,
    NR_CPUS_COL,
    LOAD_STR_COL,
    LOAD_INT_COL,
    MEMORY_COL,

    /* flags */
    IS_RUNNING_COL,
    HAS_MEMCPU_COL,

    /* beautify */
    FOREGROUND_COL,
    WEIGHT_COL,

    /* end of list */
    N_COLUMNS
};

struct vconsole_window {
    /* toplevel window */
    GtkWidget                 *toplevel;
    GtkWidget                 *notebook;
    GtkUIManager              *ui;
    gboolean                  fullscreen;

    /* recent hosts */
    GtkActionGroup            *r_ag;
    guint                     r_id;

    /* domain list tab */
    GtkTreeStore              *store;
    GtkWidget                 *tree;

    /* options */
    gboolean                  tty_blink;
    char                      *tty_font;
    char                      *tty_fg;
    char                      *tty_bg;
    gboolean                  vm_logging;
};

extern int debug;
extern GKeyFile *config;

void config_write(void);

/* ------------------------------------------------------------------ */

struct vconsole_connect {
    struct vconsole_window    *win;
    virConnectPtr             ptr;
};

struct vconsole_connect *connect_init(struct vconsole_window *win,
                                      const char *uri);
/* ------------------------------------------------------------------ */

struct vconsole_domain {
    struct vconsole_connect   *conn;
    char                      uuid[VIR_UUID_STRING_BUFLEN];
    int                       id;
    const char                *name;

    GtkWidget                 *vbox, *vte, *status;
    virStreamPtr              stream;
    virDomainInfo             info;
    gboolean                  saved;

    struct timeval            ts;
    struct timeval            last_ts;
    virDomainInfo             last_info;
    int                       load;

    FILE                      *logfp;
    char                      *logname;
};

void domain_start(struct vconsole_domain *dom);
void domain_pause(struct vconsole_domain *dom);
void domain_save(struct vconsole_domain *dom);
void domain_reboot(struct vconsole_domain *dom);
void domain_shutdown(struct vconsole_domain *dom);
void domain_reset(struct vconsole_domain *dom);
void domain_kill(struct vconsole_domain *dom);

void domain_free(struct vconsole_domain *dom);
void domain_update(struct vconsole_connect *conn,
                   virDomainPtr d, virDomainEventType event);
void domain_activate(struct vconsole_domain *dom);
void domain_configure_all_vtes(struct vconsole_window *win);
void domain_configure_all_logging(struct vconsole_window *win);
struct vconsole_domain *domain_find_current_tab(struct vconsole_window *win);
void domain_close_current_tab(struct vconsole_window *win);

void domain_update_all(struct vconsole_window *win);