[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-changelog] [xen-unstable] libxl: move bootloader data strucutres and prototypes
# HG changeset patch # User Roger Pau Monne <roger.pau@xxxxxxxxxx> # Date 1343045382 -3600 # Node ID 4e0221514a57e1530dcae4b403d44b72cfbc193d # Parent b01fe9f834a2148a7d99fbd7a71fbd85b595e14d libxl: move bootloader data strucutres and prototypes Move bootloader and related data after all the device stuff, since libxl__bootloader_state will depend on libxl__ao_device (to perform the local attach of a device). This is pure code motion. Signed-off-by: Roger Pau Monne <roger.pau@xxxxxxxxxx> Acked-by: Ian Jackson <ian.jackson@xxxxxxxxxxxxx> Committed-by: Ian Campbell <ian.campbell@xxxxxxxxxx> --- diff -r b01fe9f834a2 -r 4e0221514a57 tools/libxl/libxl_internal.h --- a/tools/libxl/libxl_internal.h Mon Jul 23 13:09:42 2012 +0100 +++ b/tools/libxl/libxl_internal.h Mon Jul 23 13:09:42 2012 +0100 @@ -1747,227 +1747,6 @@ _hidden const char *libxl__xen_script_di _hidden const char *libxl__lock_dir_path(void); _hidden const char *libxl__run_dir_path(void); -/*----- datacopier: copies data from one fd to another -----*/ - -typedef struct libxl__datacopier_state libxl__datacopier_state; -typedef struct libxl__datacopier_buf libxl__datacopier_buf; - -/* onwrite==1 means failure happened when writing, logged, errnoval is valid - * onwrite==0 means failure happened when reading - * errnoval==0 means we got eof and all data was written - * errnoval!=0 means we had a read error, logged - * onwrite==-1 means some other internal failure, errnoval not valid, logged - * in all cases copier is killed before calling this callback */ -typedef void libxl__datacopier_callback(libxl__egc *egc, - libxl__datacopier_state *dc, int onwrite, int errnoval); - -struct libxl__datacopier_buf { - /* private to datacopier */ - LIBXL_TAILQ_ENTRY(libxl__datacopier_buf) entry; - int used; - char buf[1000]; -}; - -struct libxl__datacopier_state { - /* caller must fill these in, and they must all remain valid */ - libxl__ao *ao; - int readfd, writefd; - ssize_t maxsz; - const char *copywhat, *readwhat, *writewhat; /* for error msgs */ - FILE *log; /* gets a copy of everything */ - libxl__datacopier_callback *callback; - /* remaining fields are private to datacopier */ - libxl__ev_fd toread, towrite; - ssize_t used; - LIBXL_TAILQ_HEAD(libxl__datacopier_bufs, libxl__datacopier_buf) bufs; -}; - -_hidden void libxl__datacopier_init(libxl__datacopier_state *dc); -_hidden void libxl__datacopier_kill(libxl__datacopier_state *dc); -_hidden int libxl__datacopier_start(libxl__datacopier_state *dc); - -/* Inserts literal data into the output stream. The data is copied. - * May safely be used only immediately after libxl__datacopier_start - * (before the ctx is unlocked). But may be called multiple times. - * NB exceeding maxsz will fail an assertion! */ -_hidden void libxl__datacopier_prefixdata(libxl__egc*, libxl__datacopier_state*, - const void *data, size_t len); - -/*----- Save/restore helper (used by creation and suspend) -----*/ - -typedef struct libxl__srm_save_callbacks { - libxl__srm_save_autogen_callbacks a; - int (*toolstack_save)(uint32_t domid, uint8_t **buf, - uint32_t *len, void *data); -} libxl__srm_save_callbacks; - -typedef struct libxl__srm_restore_callbacks { - libxl__srm_restore_autogen_callbacks a; -} libxl__srm_restore_callbacks; - -/* a pointer to this struct is also passed as "user" to the - * save callout helper callback functions */ -typedef struct libxl__save_helper_state { - /* public, caller of run_helper initialises */ - libxl__ao *ao; - uint32_t domid; - union { - libxl__srm_save_callbacks save; - libxl__srm_restore_callbacks restore; - } callbacks; - int (*recv_callback)(const unsigned char *msg, uint32_t len, void *user); - void (*completion_callback)(libxl__egc *egc, void *caller_state, - int rc, int retval, int errnoval); - void *caller_state; - int need_results; /* set to 0 or 1 by caller of run_helper; - * if set to 1 then the ultimate caller's - * results function must set it to 0 */ - /* private */ - int rc; - int completed; /* retval/errnoval valid iff completed */ - int retval, errnoval; /* from xc_domain_save / xc_domain_restore */ - libxl__carefd *pipes[2]; /* 0 = helper's stdin, 1 = helper's stdout */ - libxl__ev_fd readable; - libxl__ev_child child; - const char *stdin_what, *stdout_what; - FILE *toolstack_data_file; - - libxl__egc *egc; /* valid only for duration of each event callback; - * is here in this struct for the benefit of the - * marshalling and xc callback functions */ -} libxl__save_helper_state; - - -/*----- Domain suspend (save) state structure -----*/ - -typedef struct libxl__domain_suspend_state libxl__domain_suspend_state; - -typedef void libxl__domain_suspend_cb(libxl__egc*, - libxl__domain_suspend_state*, int rc); -typedef void libxl__save_device_model_cb(libxl__egc*, - libxl__domain_suspend_state*, int rc); - -typedef struct libxl__logdirty_switch { - const char *cmd; - const char *cmd_path; - const char *ret_path; - libxl__ev_xswatch watch; - libxl__ev_time timeout; -} libxl__logdirty_switch; - -struct libxl__domain_suspend_state { - /* set by caller of libxl__domain_suspend */ - libxl__ao *ao; - libxl__domain_suspend_cb *callback; - - uint32_t domid; - int fd; - libxl_domain_type type; - int live; - int debug; - const libxl_domain_remus_info *remus; - /* private */ - xc_evtchn *xce; /* event channel handle */ - int suspend_eventchn; - int hvm; - int xcflags; - int guest_responded; - const char *dm_savefile; - int interval; /* checkpoint interval (for Remus) */ - libxl__save_helper_state shs; - libxl__logdirty_switch logdirty; - /* private for libxl__domain_save_device_model */ - libxl__save_device_model_cb *save_dm_callback; - libxl__datacopier_state save_dm_datacopier; -}; - - -/*----- openpty -----*/ - -/* - * opens count (>0) ptys like count calls to openpty, and then - * calls back. On entry, all op[].master and op[].slave must be - * 0. On callback, either rc==0 and master and slave are non-0, - * or rc is a libxl error and they are both 0. If libxl__openpty - * returns non-0 no callback will happen and everything is left - * cleaned up. - */ - -typedef struct libxl__openpty_state libxl__openpty_state; -typedef struct libxl__openpty_result libxl__openpty_result; -typedef void libxl__openpty_callback(libxl__egc *egc, libxl__openpty_state *op); - -struct libxl__openpty_state { - /* caller must fill these in, and they must all remain valid */ - libxl__ao *ao; - libxl__openpty_callback *callback; - int count; - libxl__openpty_result *results; /* actual size is count, out parameter */ - /* public, result, caller may only read in callback */ - int rc; - /* private for implementation */ - libxl__ev_child child; -}; - -struct libxl__openpty_result { - libxl__carefd *master, *slave; -}; - -int libxl__openptys(libxl__openpty_state *op, - struct termios *termp, - struct winsize *winp); - - -/*----- bootloader -----*/ - -typedef struct libxl__bootloader_state libxl__bootloader_state; -typedef void libxl__run_bootloader_callback(libxl__egc*, - libxl__bootloader_state*, int rc); -typedef void libxl__bootloader_console_callback(libxl__egc*, - libxl__bootloader_state*); - -struct libxl__bootloader_state { - /* caller must fill these in, and they must all remain valid */ - libxl__ao *ao; - libxl__run_bootloader_callback *callback; - libxl__bootloader_console_callback *console_available; - const libxl_domain_build_info *info; - libxl_device_disk *disk; - /* Should be zeroed by caller on entry. Will be filled in by - * bootloader machinery; represents the local attachment of the - * disk for the benefit of the bootloader. Must be detached by - * the caller using libxl__device_disk_local_detach, but only - * after the domain's kernel and initramfs have been loaded into - * memory and the file references disposed of. */ - libxl_device_disk localdisk; - uint32_t domid; - /* outputs: - * - caller must initialise kernel and ramdisk to point to file - * references, these will be updated and mapped; - * - caller must initialise cmdline to NULL, it will be updated with a - * string allocated from the gc; - */ - libxl__file_reference *kernel, *ramdisk; - const char *cmdline; - /* private to libxl__run_bootloader */ - char *outputpath, *outputdir, *logfile; - char *diskpath; /* not from gc, represents actually attached disk */ - libxl__openpty_state openpty; - libxl__openpty_result ptys[2]; /* [0] is for bootloader */ - libxl__ev_child child; - libxl__domaindeathcheck deathcheck; - int nargs, argsspace; - const char **args; - libxl__datacopier_state keystrokes, display; - int rc; -}; - -_hidden void libxl__bootloader_init(libxl__bootloader_state *bl); - -/* Will definitely call st->callback, perhaps reentrantly. - * If callback is passed rc==0, will have updated st->info appropriately */ -_hidden void libxl__bootloader_run(libxl__egc*, libxl__bootloader_state *st); - /*----- device addition/removal -----*/ /* Action to perform (either connect or disconnect) */ @@ -2129,6 +1908,227 @@ struct libxl__ao_devices { _hidden void libxl__initiate_device_remove(libxl__egc *egc, libxl__ao_device *aodev); +/*----- datacopier: copies data from one fd to another -----*/ + +typedef struct libxl__datacopier_state libxl__datacopier_state; +typedef struct libxl__datacopier_buf libxl__datacopier_buf; + +/* onwrite==1 means failure happened when writing, logged, errnoval is valid + * onwrite==0 means failure happened when reading + * errnoval==0 means we got eof and all data was written + * errnoval!=0 means we had a read error, logged + * onwrite==-1 means some other internal failure, errnoval not valid, logged + * in all cases copier is killed before calling this callback */ +typedef void libxl__datacopier_callback(libxl__egc *egc, + libxl__datacopier_state *dc, int onwrite, int errnoval); + +struct libxl__datacopier_buf { + /* private to datacopier */ + LIBXL_TAILQ_ENTRY(libxl__datacopier_buf) entry; + int used; + char buf[1000]; +}; + +struct libxl__datacopier_state { + /* caller must fill these in, and they must all remain valid */ + libxl__ao *ao; + int readfd, writefd; + ssize_t maxsz; + const char *copywhat, *readwhat, *writewhat; /* for error msgs */ + FILE *log; /* gets a copy of everything */ + libxl__datacopier_callback *callback; + /* remaining fields are private to datacopier */ + libxl__ev_fd toread, towrite; + ssize_t used; + LIBXL_TAILQ_HEAD(libxl__datacopier_bufs, libxl__datacopier_buf) bufs; +}; + +_hidden void libxl__datacopier_init(libxl__datacopier_state *dc); +_hidden void libxl__datacopier_kill(libxl__datacopier_state *dc); +_hidden int libxl__datacopier_start(libxl__datacopier_state *dc); + +/* Inserts literal data into the output stream. The data is copied. + * May safely be used only immediately after libxl__datacopier_start + * (before the ctx is unlocked). But may be called multiple times. + * NB exceeding maxsz will fail an assertion! */ +_hidden void libxl__datacopier_prefixdata(libxl__egc*, libxl__datacopier_state*, + const void *data, size_t len); + +/*----- Save/restore helper (used by creation and suspend) -----*/ + +typedef struct libxl__srm_save_callbacks { + libxl__srm_save_autogen_callbacks a; + int (*toolstack_save)(uint32_t domid, uint8_t **buf, + uint32_t *len, void *data); +} libxl__srm_save_callbacks; + +typedef struct libxl__srm_restore_callbacks { + libxl__srm_restore_autogen_callbacks a; +} libxl__srm_restore_callbacks; + +/* a pointer to this struct is also passed as "user" to the + * save callout helper callback functions */ +typedef struct libxl__save_helper_state { + /* public, caller of run_helper initialises */ + libxl__ao *ao; + uint32_t domid; + union { + libxl__srm_save_callbacks save; + libxl__srm_restore_callbacks restore; + } callbacks; + int (*recv_callback)(const unsigned char *msg, uint32_t len, void *user); + void (*completion_callback)(libxl__egc *egc, void *caller_state, + int rc, int retval, int errnoval); + void *caller_state; + int need_results; /* set to 0 or 1 by caller of run_helper; + * if set to 1 then the ultimate caller's + * results function must set it to 0 */ + /* private */ + int rc; + int completed; /* retval/errnoval valid iff completed */ + int retval, errnoval; /* from xc_domain_save / xc_domain_restore */ + libxl__carefd *pipes[2]; /* 0 = helper's stdin, 1 = helper's stdout */ + libxl__ev_fd readable; + libxl__ev_child child; + const char *stdin_what, *stdout_what; + FILE *toolstack_data_file; + + libxl__egc *egc; /* valid only for duration of each event callback; + * is here in this struct for the benefit of the + * marshalling and xc callback functions */ +} libxl__save_helper_state; + + +/*----- Domain suspend (save) state structure -----*/ + +typedef struct libxl__domain_suspend_state libxl__domain_suspend_state; + +typedef void libxl__domain_suspend_cb(libxl__egc*, + libxl__domain_suspend_state*, int rc); +typedef void libxl__save_device_model_cb(libxl__egc*, + libxl__domain_suspend_state*, int rc); + +typedef struct libxl__logdirty_switch { + const char *cmd; + const char *cmd_path; + const char *ret_path; + libxl__ev_xswatch watch; + libxl__ev_time timeout; +} libxl__logdirty_switch; + +struct libxl__domain_suspend_state { + /* set by caller of libxl__domain_suspend */ + libxl__ao *ao; + libxl__domain_suspend_cb *callback; + + uint32_t domid; + int fd; + libxl_domain_type type; + int live; + int debug; + const libxl_domain_remus_info *remus; + /* private */ + xc_evtchn *xce; /* event channel handle */ + int suspend_eventchn; + int hvm; + int xcflags; + int guest_responded; + const char *dm_savefile; + int interval; /* checkpoint interval (for Remus) */ + libxl__save_helper_state shs; + libxl__logdirty_switch logdirty; + /* private for libxl__domain_save_device_model */ + libxl__save_device_model_cb *save_dm_callback; + libxl__datacopier_state save_dm_datacopier; +}; + + +/*----- openpty -----*/ + +/* + * opens count (>0) ptys like count calls to openpty, and then + * calls back. On entry, all op[].master and op[].slave must be + * 0. On callback, either rc==0 and master and slave are non-0, + * or rc is a libxl error and they are both 0. If libxl__openpty + * returns non-0 no callback will happen and everything is left + * cleaned up. + */ + +typedef struct libxl__openpty_state libxl__openpty_state; +typedef struct libxl__openpty_result libxl__openpty_result; +typedef void libxl__openpty_callback(libxl__egc *egc, libxl__openpty_state *op); + +struct libxl__openpty_state { + /* caller must fill these in, and they must all remain valid */ + libxl__ao *ao; + libxl__openpty_callback *callback; + int count; + libxl__openpty_result *results; /* actual size is count, out parameter */ + /* public, result, caller may only read in callback */ + int rc; + /* private for implementation */ + libxl__ev_child child; +}; + +struct libxl__openpty_result { + libxl__carefd *master, *slave; +}; + +int libxl__openptys(libxl__openpty_state *op, + struct termios *termp, + struct winsize *winp); + + +/*----- bootloader -----*/ + +typedef struct libxl__bootloader_state libxl__bootloader_state; +typedef void libxl__run_bootloader_callback(libxl__egc*, + libxl__bootloader_state*, int rc); +typedef void libxl__bootloader_console_callback(libxl__egc*, + libxl__bootloader_state*); + +struct libxl__bootloader_state { + /* caller must fill these in, and they must all remain valid */ + libxl__ao *ao; + libxl__run_bootloader_callback *callback; + libxl__bootloader_console_callback *console_available; + const libxl_domain_build_info *info; + libxl_device_disk *disk; + /* Should be zeroed by caller on entry. Will be filled in by + * bootloader machinery; represents the local attachment of the + * disk for the benefit of the bootloader. Must be detached by + * the caller using libxl__device_disk_local_detach, but only + * after the domain's kernel and initramfs have been loaded into + * memory and the file references disposed of. */ + libxl_device_disk localdisk; + uint32_t domid; + /* outputs: + * - caller must initialise kernel and ramdisk to point to file + * references, these will be updated and mapped; + * - caller must initialise cmdline to NULL, it will be updated with a + * string allocated from the gc; + */ + libxl__file_reference *kernel, *ramdisk; + const char *cmdline; + /* private to libxl__run_bootloader */ + char *outputpath, *outputdir, *logfile; + char *diskpath; /* not from gc, represents actually attached disk */ + libxl__openpty_state openpty; + libxl__openpty_result ptys[2]; /* [0] is for bootloader */ + libxl__ev_child child; + libxl__domaindeathcheck deathcheck; + int nargs, argsspace; + const char **args; + libxl__datacopier_state keystrokes, display; + int rc; +}; + +_hidden void libxl__bootloader_init(libxl__bootloader_state *bl); + +/* Will definitely call st->callback, perhaps reentrantly. + * If callback is passed rc==0, will have updated st->info appropriately */ +_hidden void libxl__bootloader_run(libxl__egc*, libxl__bootloader_state *st); + /*----- Domain destruction -----*/ /* Domain destruction has been split into two functions: _______________________________________________ Xen-changelog mailing list Xen-changelog@xxxxxxxxxxxxx http://lists.xensource.com/xen-changelog
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |