libxl: provide a mechanism to define a device 'safe remove' function...
authorPaul Durrant <pdurrant@amazon.com>
Tue, 15 Sep 2020 14:10:06 +0000 (15:10 +0100)
committerWei Liu <wl@xen.org>
Thu, 1 Oct 2020 09:32:25 +0000 (09:32 +0000)
commit6df07f9fbe1e9b65a40183f79a6171200dc877dd
treee213e40bae183f9792856e15c0e9b88a63392cfa
parent11852c7bb070a18c3708b4c001772a23e7d4fc27
libxl: provide a mechanism to define a device 'safe remove' function...

... and use it to define libxl_device_disk_safe_remove().

This patch builds on the existent macro magic by using a new value of the
'force' field in in libxl__ao_device.
It is currently defined as an int but is used in a boolean manner where
1 means the operation is forced and 0 means it is not (but is actually forced
after a 10s time-out). In adding a third value, this patch re-defines 'force'
as a struct type (libxl__force) with a single 'flag' field taking an
enumerated value:

LIBXL__FORCE_AUTO - corresponding to the old 0 value
LIBXL__FORCE_ON   - corresponding to the old 1 value
LIBXL__FORCE_OFF  - the new value

The LIBXL_DEFINE_DEVICE_REMOVE() macro is then modified to define the
libxl_device_<type>_remove() and libxl_device_<type>_destroy() functions,
setting LIBXL__FORCE_AUTO and LIBXL__FORCE_ON (respectively) in the
libxl__ao_device passed to libxl__initiate_device_generic_remove() and a
new macro, LIBXL_DEFINE_DEVICE_SAFE_REMOVE(), is defined that sets
LIBXL__FORCE_OFF instead. This macro is used to define the new
libxl_device_disk_safe_remove() function.

Signed-off-by: Paul Durrant <pdurrant@amazon.com>
Reviewed-by: Roger Pau Monné <roger.pau@citrix.com>
Reviewed-by: Wei Liu <wl@xen.org>
tools/libxl/libxl.h
tools/libxl/libxl_device.c
tools/libxl/libxl_disk.c
tools/libxl/libxl_domain.c
tools/libxl/libxl_internal.h