-static int select_add_handle (guestfs_main_loop *ml, guestfs_h *g, int fd, int events, guestfs_handle_event_cb cb, void *data);
-static int select_remove_handle (guestfs_main_loop *ml, guestfs_h *g, int watch);
-static int select_add_timeout (guestfs_main_loop *ml, guestfs_h *g, int interval, guestfs_handle_timeout_cb cb, void *data);
-static int select_remove_timeout (guestfs_main_loop *ml, guestfs_h *g, int timer);
-static int select_main_loop_run (guestfs_main_loop *ml, guestfs_h *g);
-static int select_main_loop_quit (guestfs_main_loop *ml, guestfs_h *g);
-
-/* Default select-based main loop. */
-struct select_handle_cb_data {
- guestfs_handle_event_cb cb;
- guestfs_h *g;
- void *data;
-};
-
-struct select_main_loop {
- /* NB. These fields must be the same as in struct guestfs_main_loop: */
- guestfs_add_handle_cb add_handle;
- guestfs_remove_handle_cb remove_handle;
- guestfs_add_timeout_cb add_timeout;
- guestfs_remove_timeout_cb remove_timeout;
- guestfs_main_loop_run_cb main_loop_run;
- guestfs_main_loop_quit_cb main_loop_quit;
-
- /* Additional private data: */
- int is_running;
-
- fd_set rset;
- fd_set wset;
- fd_set xset;
-
- int max_fd;
- int nr_fds;
- struct select_handle_cb_data *handle_cb_data;
-};
-
-/* Default main loop. */
-static struct select_main_loop default_main_loop = {
- .add_handle = select_add_handle,
- .remove_handle = select_remove_handle,
- .add_timeout = select_add_timeout,
- .remove_timeout = select_remove_timeout,
- .main_loop_run = select_main_loop_run,
- .main_loop_quit = select_main_loop_quit,
-
- /* XXX hopefully .rset, .wset, .xset are initialized to the empty
- * set by the normal action of everything being initialized to zero.
- */
- .is_running = 0,
- .max_fd = -1,
- .nr_fds = 0,
- .handle_cb_data = NULL,
-};
-
-#define UNIX_PATH_MAX 108
-
-/* Also in guestfsd.c */
-#define VMCHANNEL_PORT 6666
-#define VMCHANNEL_ADDR "10.0.2.4"
-
-/* GuestFS handle and connection. */
-enum state { CONFIG, LAUNCHING, READY, BUSY, NO_HANDLE };
-
-struct guestfs_h
-{
- struct guestfs_h *next; /* Linked list of open handles. */
-
- /* State: see the state machine diagram in the man page guestfs(3). */
- enum state state;
-
- int fd[2]; /* Stdin/stdout of qemu. */
- int sock; /* Daemon communications socket. */
- int pid; /* Qemu PID. */
- time_t start_t; /* The time when we started qemu. */
-
- int stdout_watch; /* Watches qemu stdout for log messages. */
- int sock_watch; /* Watches daemon comm socket. */
-
- char *tmpdir; /* Temporary directory containing socket. */
-
- char **cmdline; /* Qemu command line. */
- int cmdline_size;
-
- int verbose;
- int autosync;
-
- const char *path;
-
- char *last_error;
-
- /* Callbacks. */
- guestfs_abort_cb abort_cb;
- guestfs_error_handler_cb error_cb;
- void * error_cb_data;
- guestfs_send_cb send_cb;
- void * send_cb_data;
- guestfs_reply_cb reply_cb;
- void * reply_cb_data;
- guestfs_log_message_cb log_message_cb;
- void * log_message_cb_data;
- guestfs_subprocess_quit_cb subprocess_quit_cb;
- void * subprocess_quit_cb_data;
- guestfs_launch_done_cb launch_done_cb;
- void * launch_done_cb_data;
-
- /* Main loop used by this handle. */
- guestfs_main_loop *main_loop;
-
- /* Messages sent and received from the daemon. */
- char *msg_in;
- int msg_in_size, msg_in_allocated;
- char *msg_out;
- int msg_out_size, msg_out_pos;
-
- int msg_next_serial;
-};
-