diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/guestfs-internal.h | 4 | ||||
-rw-r--r-- | src/guestfs.pod | 33 | ||||
-rw-r--r-- | src/launch.c | 3 | ||||
-rw-r--r-- | src/proto.c | 77 |
4 files changed, 31 insertions, 86 deletions
diff --git a/src/guestfs-internal.h b/src/guestfs-internal.h index 0492c9ea..a41212da 100644 --- a/src/guestfs-internal.h +++ b/src/guestfs-internal.h @@ -142,7 +142,7 @@ #define ROUTER "169.254.2.2" /* GuestFS handle and connection. */ -enum state { CONFIG, LAUNCHING, READY, BUSY, NO_HANDLE }; +enum state { CONFIG, LAUNCHING, READY, NO_HANDLE }; /* Attach method. */ enum attach_method { ATTACH_METHOD_APPLIANCE = 0, ATTACH_METHOD_UNIX }; @@ -406,8 +406,6 @@ extern void guestfs___free_fuse (guestfs_h *g); #endif extern void guestfs___free_inspect_info (guestfs_h *g); extern void guestfs___free_drives (struct drive **drives); -extern int guestfs___set_busy (guestfs_h *g); -extern int guestfs___end_busy (guestfs_h *g); extern int guestfs___send (guestfs_h *g, int proc_nr, uint64_t progress_hint, uint64_t optargs_bitmask, xdrproc_t xdrp, char *args); extern int guestfs___recv (guestfs_h *g, const char *fn, struct guestfs_message_header *hdr, struct guestfs_message_error *err, xdrproc_t xdrp, char *ret); extern int guestfs___recv_discard (guestfs_h *g, const char *fn); diff --git a/src/guestfs.pod b/src/guestfs.pod index 3f5410a2..d22fa64f 100644 --- a/src/guestfs.pod +++ b/src/guestfs.pod @@ -2400,23 +2400,23 @@ libguestfs uses a state machine to model the child process: / \ | CONFIG | \__________/ - ^ ^ ^ \ - / | \ \ guestfs_launch - / | _\__V______ - / | / \ - / | | LAUNCHING | - / | \___________/ - / | / - / | guestfs_launch - / | / - ______ / __|____V - / \ ------> / \ - | BUSY | | READY | - \______/ <------ \________/ + ^ ^ \ + | \ \ guestfs_launch + | _\__V______ + | / \ + | | LAUNCHING | + | \___________/ + | / + | guestfs_launch + | / + __|____V + / \ + | READY | + \________/ The normal transitions are (1) CONFIG (when the handle is created, but there is no child process), (2) LAUNCHING (when the child process is -booting up), (3) alternating between READY and BUSY as commands are +booting up), (3) READY meaning the appliance is up, actions can be issued to, and carried out by, the child process. The guest may be killed by L</guestfs_kill_subprocess>, or may die @@ -2434,9 +2434,8 @@ while it is running. API actions such as L</guestfs_mount> can only be issued when in the READY state. These API calls block waiting for the command to be -carried out (ie. the state to transition to BUSY and then back to -READY). There are no non-blocking versions, and no way to issue more -than one command per handle at the same time. +carried out. There are no non-blocking versions, and no way to issue +more than one command per handle at the same time. Finally, the child process sends asynchronous messages back to the main program, such as kernel log messages. You can register a diff --git a/src/launch.c b/src/launch.c index b61c538a..c66cbacc 100644 --- a/src/launch.c +++ b/src/launch.c @@ -1456,7 +1456,8 @@ guestfs__is_ready (guestfs_h *g) int guestfs__is_busy (guestfs_h *g) { - return g->state == BUSY; + /* There used to be a BUSY state but it was removed in 1.17.36. */ + return 0; } int diff --git a/src/proto.c b/src/proto.c index 16cff4fc..95d619f2 100644 --- a/src/proto.c +++ b/src/proto.c @@ -84,30 +84,24 @@ * (2) A simple RPC (eg. "mount"). We write the request, then read * the reply. The sequence of calls is: * - * guestfs___set_busy * guestfs___send * guestfs___recv - * guestfs___end_busy * * (3) An RPC with FileOut parameters (eg. "upload"). We write the * request, then write the file(s), then read the reply. The sequence * of calls is: * - * guestfs___set_busy * guestfs___send * guestfs___send_file (possibly multiple times) * guestfs___recv - * guestfs___end_busy * * (4) An RPC with FileIn parameters (eg. "download"). We write the * request, then read the reply, then read the file(s). The sequence * of calls is: * - * guestfs___set_busy * guestfs___send * guestfs___recv * guestfs___recv_file (possibly multiple times) - * guestfs___end_busy * * (5) Both FileOut and FileIn parameters. There are no calls like * this in the current API, but they would be implemented as a @@ -181,39 +175,6 @@ message_summary (const void *buf, size_t n, char *workspace) return workspace; } -int -guestfs___set_busy (guestfs_h *g) -{ - if (g->state != READY) { - error (g, _("guestfs_set_busy: called when in state %d != READY"), - g->state); - return -1; - } - g->state = BUSY; - return 0; -} - -int -guestfs___end_busy (guestfs_h *g) -{ - switch (g->state) - { - case BUSY: - g->state = READY; - break; - case CONFIG: - case READY: - break; - - case LAUNCHING: - case NO_HANDLE: - default: - error (g, _("guestfs_end_busy: called when in state %d"), g->state); - return -1; - } - return 0; -} - /* This is called if we detect EOF, ie. qemu died. */ static void child_cleanup (guestfs_h *g) @@ -395,6 +356,7 @@ check_for_daemon_cancellation_or_eof (guestfs_h *g, int fd) /* Read and process progress messages that happen during FileIn. */ if (flag == GUESTFS_PROGRESS_FLAG) { char buf[PROGRESS_MESSAGE_SIZE]; + guestfs_progress message; n = really_read_from_socket (g, fd, buf, PROGRESS_MESSAGE_SIZE); if (n == -1) @@ -404,15 +366,11 @@ check_for_daemon_cancellation_or_eof (guestfs_h *g, int fd) return -1; } - if (g->state == BUSY) { - guestfs_progress message; - - xdrmem_create (&xdr, buf, PROGRESS_MESSAGE_SIZE, XDR_DECODE); - xdr_guestfs_progress (&xdr, &message); - xdr_destroy (&xdr); + xdrmem_create (&xdr, buf, PROGRESS_MESSAGE_SIZE, XDR_DECODE); + xdr_guestfs_progress (&xdr, &message); + xdr_destroy (&xdr); - guestfs___progress_message_callback (g, &message); - } + guestfs___progress_message_callback (g, &message); return 0; } @@ -713,15 +671,14 @@ guestfs___recv_from_daemon (guestfs_h *g, uint32_t *size_rtn, void **buf_rtn) #endif if (*size_rtn == GUESTFS_PROGRESS_FLAG) { - if (g->state == BUSY) { - guestfs_progress message; - XDR xdr; - xdrmem_create (&xdr, *buf_rtn, PROGRESS_MESSAGE_SIZE, XDR_DECODE); - xdr_guestfs_progress (&xdr, &message); - xdr_destroy (&xdr); + guestfs_progress message; + XDR xdr; - guestfs___progress_message_callback (g, &message); - } + xdrmem_create (&xdr, *buf_rtn, PROGRESS_MESSAGE_SIZE, XDR_DECODE); + xdr_guestfs_progress (&xdr, &message); + xdr_destroy (&xdr); + + guestfs___progress_message_callback (g, &message); free (*buf_rtn); *buf_rtn = NULL; @@ -806,11 +763,6 @@ guestfs___send (guestfs_h *g, int proc_nr, char *msg_out; size_t msg_out_size; - if (g->state != BUSY) { - error (g, _("guestfs___send: state %d != BUSY"), g->state); - return -1; - } - /* We have to allocate this message buffer on the heap because * it is quite large (although will be mostly unused). We * can't allocate it on the stack because in some environments @@ -987,11 +939,6 @@ send_file_chunk (guestfs_h *g, int cancel, const char *buf, size_t buflen) char *msg_out; size_t msg_out_size; - if (g->state != BUSY) { - error (g, _("send_file_chunk: state %d != READY"), g->state); - return -1; - } - /* Allocate the chunk buffer. Don't use the stack to avoid * excessive stack usage and unnecessary copies. */ |