diff options
author | Richard W.M. Jones <rjones@redhat.com> | 2012-07-20 14:24:10 +0100 |
---|---|---|
committer | Richard W.M. Jones <rjones@redhat.com> | 2012-07-20 15:10:46 +0100 |
commit | ec8e3b6cad170d08ac18b580792dfb137eb171dc (patch) | |
tree | 785058598dc6975e63332c7302220e9b38ba5be6 /src/guestfs.c | |
parent | 08cad543492c9624be0659dfb18b7a8b21de8fba (diff) | |
download | libguestfs-ec8e3b6cad170d08ac18b580792dfb137eb171dc.tar.gz libguestfs-ec8e3b6cad170d08ac18b580792dfb137eb171dc.tar.xz libguestfs-ec8e3b6cad170d08ac18b580792dfb137eb171dc.zip |
launch: Abstract attach method operations.
g->attach_ops points to a structure which contains the
operations supported by each attach method backend
(ie. appliance, unix, etc.).
Diffstat (limited to 'src/guestfs.c')
-rw-r--r-- | src/guestfs.c | 47 |
1 files changed, 2 insertions, 45 deletions
diff --git a/src/guestfs.c b/src/guestfs.c index 00a32db5..e848ff83 100644 --- a/src/guestfs.c +++ b/src/guestfs.c @@ -247,9 +247,6 @@ guestfs_close (guestfs_h *g) free (g->path); free (g->qemu); free (g->append); - free (g->qemu_help); - free (g->qemu_version); - free (g->qemu_devices); free (g); } @@ -258,7 +255,6 @@ int guestfs__shutdown (guestfs_h *g) { int ret = 0; - int status, sig; if (g->state == CONFIG) return 0; @@ -269,13 +265,6 @@ guestfs__shutdown (guestfs_h *g) ret = -1; } - /* Signal qemu to shutdown cleanly, and kill the recovery process. */ - if (g->pid > 0) { - debug (g, "sending SIGTERM to process %d", g->pid); - kill (g->pid, SIGTERM); - } - if (g->recoverypid > 0) kill (g->recoverypid, 9); - /* Close sockets. */ if (g->fd[0] >= 0) close (g->fd[0]); @@ -287,30 +276,9 @@ guestfs__shutdown (guestfs_h *g) g->fd[1] = -1; g->sock = -1; - /* Wait for subprocess(es) to exit. */ - if (g->pid > 0) { - if (waitpid (g->pid, &status, 0) == -1) { - perrorf (g, "waitpid (qemu)"); - ret = -1; - } - else if (WIFEXITED (status) && WEXITSTATUS (status) != 0) { - error (g, "qemu failed (status %d)", WEXITSTATUS (status)); - ret = -1; - } - else if (WIFSIGNALED (status)) { - sig = WTERMSIG (status); - error (g, "qemu terminated by signal %d (%s)", sig, strsignal (sig)); - ret = -1; - } - else if (WIFSTOPPED (status)) { - sig = WSTOPSIG (status); - error (g, "qemu stopped by signal %d (%s)", sig, strsignal (sig)); - ret = -1; - } - } - if (g->recoverypid > 0) waitpid (g->recoverypid, NULL, 0); + if (g->attach_ops->shutdown (g) == -1) + ret = -1; - g->pid = g->recoverypid = 0; g->state = CONFIG; return ret; @@ -705,17 +673,6 @@ guestfs__get_selinux (guestfs_h *g) return g->selinux; } -int -guestfs__get_pid (guestfs_h *g) -{ - if (g->pid > 0) - return g->pid; - else { - error (g, "get_pid: no qemu subprocess"); - return -1; - } -} - struct guestfs_version * guestfs__version (guestfs_h *g) { |