pvs/vgs/lvs commands working now.
[libguestfs.git] / src / guestfs.h
1 /* libguestfs
2  * Copyright (C) 2009 Red Hat Inc. 
3  *
4  * This library is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Lesser General Public
6  * License as published by the Free Software Foundation; either
7  * version 2 of the License, or (at your option) any later version.
8  *
9  * This library is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12  * Lesser General Public License for more details.
13  *
14  * You should have received a copy of the GNU Lesser General Public
15  * License along with this library; if not, write to the Free Software
16  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
17  */
18
19 #ifndef GUESTFS_H_
20 #define GUESTFS_H_
21
22 /* IMPORTANT NOTE!
23  * All API documentation is in the manual page --> guestfs(3) <--
24  * Go and read it now, I'll wait.
25  */
26
27 #include <rpc/xdr.h>
28
29 typedef struct guestfs_h guestfs_h;
30
31 /* Connection management. */
32 extern guestfs_h *guestfs_create (void);
33 extern void guestfs_close (guestfs_h *g);
34 extern int guestfs_launch (guestfs_h *g);
35 extern int guestfs_wait_ready (guestfs_h *g);
36 extern int guestfs_kill_subprocess (guestfs_h *g);
37
38 /* Configuration management. */
39 extern int guestfs_config (guestfs_h *g,
40                            const char *qemu_param, const char *qemu_value);
41 extern int guestfs_add_drive (guestfs_h *g, const char *filename);
42 extern int guestfs_add_cdrom (guestfs_h *g, const char *filename);
43
44 /* Error handling. */
45 typedef void (*guestfs_error_handler_cb) (guestfs_h *g, void *data, const char *msg);
46 typedef void (*guestfs_abort_cb) (void);
47
48 extern void guestfs_set_error_handler (guestfs_h *g, guestfs_error_handler_cb cb, void *data);
49 extern guestfs_error_handler_cb guestfs_get_error_handler (guestfs_h *g, void **data_rtn);
50
51 extern void guestfs_set_out_of_memory_handler (guestfs_h *g, guestfs_abort_cb);
52 extern guestfs_abort_cb guestfs_get_out_of_memory_handler (guestfs_h *g);
53
54 /* Misc. */
55 extern void guestfs_set_verbose (guestfs_h *g, int verbose);
56 extern int guestfs_get_verbose (guestfs_h *g);
57 extern void guestfs_set_autosync (guestfs_h *g, int a);
58 extern int guestfs_get_autosync (guestfs_h *g);
59 extern void guestfs_set_path (guestfs_h *g, const char *path);
60 extern const char *guestfs_get_path (guestfs_h *g);
61
62 #include <guestfs-structs.h>
63 #include <guestfs-actions.h>
64
65 extern void guestfs_free_lvm_pv_list (struct guestfs_lvm_pv_list *);
66 extern void guestfs_free_lvm_vg_list (struct guestfs_lvm_vg_list *);
67 extern void guestfs_free_lvm_lv_list (struct guestfs_lvm_lv_list *);
68
69 /* Low-level event API. */
70 typedef void (*guestfs_reply_cb) (guestfs_h *g, void *data, XDR *xdr);
71 typedef void (*guestfs_log_message_cb) (guestfs_h *g, void *data, char *buf, int len);
72 typedef void (*guestfs_subprocess_quit_cb) (guestfs_h *g, void *data);
73 typedef void (*guestfs_launch_done_cb) (guestfs_h *g, void *data);
74
75 extern void guestfs_set_reply_callback (guestfs_h *g, guestfs_reply_cb cb, void *opaque);
76 extern void guestfs_set_log_message_callback (guestfs_h *g, guestfs_log_message_cb cb, void *opaque);
77 extern void guestfs_set_subprocess_quit_callback (guestfs_h *g, guestfs_subprocess_quit_cb cb, void *opaque);
78 extern void guestfs_set_launch_done_callback (guestfs_h *g, guestfs_launch_done_cb cb, void *opaque);
79
80 /* Main loop. */
81 #define GUESTFS_HANDLE_READABLE 0x1
82 #define GUESTFS_HANDLE_WRITABLE 0x2
83 #define GUESTFS_HANDLE_HANGUP   0x4
84 #define GUESTFS_HANDLE_ERROR    0x8
85
86 typedef void (*guestfs_handle_event_cb) (void *data, int watch, int fd, int events);
87 typedef int (*guestfs_add_handle_cb) (guestfs_h *g, int fd, int events, guestfs_handle_event_cb cb, void *data);
88 typedef int (*guestfs_remove_handle_cb) (guestfs_h *g, int watch);
89 typedef void (*guestfs_handle_timeout_cb) (void *data, int timer);
90 typedef int (*guestfs_add_timeout_cb) (guestfs_h *g, int interval, guestfs_handle_timeout_cb cb, void *data);
91 typedef int (*guestfs_remove_timeout_cb) (guestfs_h *g, int timer);
92 typedef void (*guestfs_main_loop_run_cb) (guestfs_h *g);
93 typedef void (*guestfs_main_loop_quit_cb) (guestfs_h *g);
94
95 struct guestfs_main_loop {
96   guestfs_add_handle_cb add_handle;
97   guestfs_remove_handle_cb remove_handle;
98   guestfs_add_timeout_cb add_timeout;
99   guestfs_remove_timeout_cb remove_timeout;
100   guestfs_main_loop_run_cb main_loop_run;
101   guestfs_main_loop_quit_cb main_loop_quit;
102 };
103 typedef struct guestfs_main_loop guestfs_main_loop;
104
105 extern void guestfs_set_main_loop (guestfs_main_loop *);
106 extern void guestfs_main_loop_run (void);
107 extern void guestfs_main_loop_quit (void);
108
109 #endif /* GUESTFS_H_ */