[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

[Libguestfs] [PATCH 0/8] Implement user cancellation

This patch series implements user cancellation.  What this means is
that the "user" (or any library caller) can cancel certain
long-running operations.  Currently it is only possible to cancel
upload and download operations (ie. anything in the generator which
uses FileIn and FileOut).

The mechanism in the protocol to implement cancellation already
exists, and it is already used to cancel transfers where there is an
error.  For example, if the library gets an error while reading a
local file during an upload, it already cancels the transfer.

Therefore the only thing left to do is to expose cancellation to
library callers.  This is done through the new API call:

  void guestfs_user_cancel (guestfs_h *g);

This call is signal safe and thread safe.  It is, in fact, designed to
be called from a SIGINT signal handler (to handle ^C being pressed by
the user during a transfer).  You could also wire it up to a cancel
button called from another thread, or use it in other ways.

There are three main complexities to this patch series:

(1) We need to implement process groups (see patch 2/8).  This is
because otherwise the terminal sends ^C to the qemu process (because
it is in the same process group as the parent), killing it.  In order
to catch ^C in guestfish, we need guestfish and the subprocesses to be
in different process groups.

(2) The language bindings need to be signal safe.  This turns out to
be simple for OCaml, Perl and Ruby.  However Python doesn't have any
clear way to make functions signal safe, and so I did not implement a
Python binding for now.

(3) There is a multithreaded test program (capitests/test-user-cancel.c)
which performs an upload and a download and attempts to cancel it at
the same time.


Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones
libguestfs lets you edit virtual machines.  Supports shell scripting,
bindings from many languages.  http://libguestfs.org

[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]