From: Roger Pau Monne <roger.pau@citrix.com>
To: xen-devel@lists.xen.org
Cc: Ian Jackson <ian.jackson@eu.citrix.com>,
Roger Pau Monne <roger.pau@citrix.com>
Subject: [PATCH v10 05/19] libxl: move bootloader data strucutres and prototypes
Date: Fri, 20 Jul 2012 15:12:14 +0100 [thread overview]
Message-ID: <1342793548-10239-6-git-send-email-roger.pau@citrix.com> (raw)
In-Reply-To: <1342793548-10239-1-git-send-email-roger.pau@citrix.com>
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.
Cc: Ian Jackson <ian.jackson@eu.citrix.com>
Acked-by: Ian Jackson <ian.jackson@eu.citrix.com>
Signed-off-by: Roger Pau Monne <roger.pau@citrix.com>
---
tools/libxl/libxl_internal.h | 322 +++++++++++++++++++++---------------------
1 files changed, 161 insertions(+), 161 deletions(-)
diff --git a/tools/libxl/libxl_internal.h b/tools/libxl/libxl_internal.h
index 562ca61..52d79a9 100644
--- a/tools/libxl/libxl_internal.h
+++ b/tools/libxl/libxl_internal.h
@@ -1747,6 +1747,167 @@ _hidden const char *libxl__xen_script_dir_path(void);
_hidden const char *libxl__lock_dir_path(void);
_hidden const char *libxl__run_dir_path(void);
+/*----- device addition/removal -----*/
+
+/* Action to perform (either connect or disconnect) */
+typedef enum {
+ DEVICE_CONNECT,
+ DEVICE_DISCONNECT
+} libxl__device_action;
+
+typedef struct libxl__ao_device libxl__ao_device;
+typedef struct libxl__ao_devices libxl__ao_devices;
+typedef void libxl__device_callback(libxl__egc*, libxl__ao_device*);
+
+/* This functions sets the necessary libxl__ao_device struct values to use
+ * safely inside functions. It marks the operation as "active"
+ * since we need to be sure that all device status structs are set
+ * to active before start queueing events, or we might call
+ * ao_complete before all devices had finished
+ *
+ * libxl__initiate_device_{remove/addition} should not be called without
+ * calling libxl__prepare_ao_device first, since it initializes the private
+ * fields of the struct libxl__ao_device to what this functions expect.
+ *
+ * Once _prepare has been called on a libxl__ao_device, it is safe to just
+ * discard this struct, there's no need to call any destroy function.
+ * _prepare can also be called multiple times with the same libxl__ao_device.
+ */
+_hidden void libxl__prepare_ao_device(libxl__ao *ao, libxl__ao_device *aodev);
+
+/* Prepare a bunch of devices for addition/removal. Every ao_device in
+ * ao_devices is set to 'active', and the ao_device 'base' field is set to
+ * the one pointed by aodevs.
+ */
+_hidden void libxl__prepare_ao_devices(libxl__ao *ao,
+ libxl__ao_devices *aodevs);
+
+/* Generic callback to use when adding/removing several devices, this will
+ * check if the given aodev is the last one, and call the callback in the
+ * parent libxl__ao_devices struct, passing the appropriate error if found.
+ */
+_hidden void libxl__ao_devices_callback(libxl__egc *egc,
+ libxl__ao_device *aodev);
+
+struct libxl__ao_device {
+ /* filled in by user */
+ libxl__ao *ao;
+ libxl__device_action action;
+ libxl__device *dev;
+ int force;
+ libxl__device_callback *callback;
+ /* private for implementation */
+ int active;
+ int rc;
+ libxl__ev_devstate backend_ds;
+ /* Bodge for Qemu devices */
+ libxl__ev_time timeout;
+ /* Used internally to have a reference to the upper libxl__ao_devices
+ * struct when present */
+ libxl__ao_devices *aodevs;
+};
+
+/* Helper struct to simply the plug/unplug of multiple devices at the same
+ * time.
+ *
+ * This structure holds several devices, and the callback is only called
+ * when all the devices inside of the array have finished.
+ */
+typedef void libxl__devices_callback(libxl__egc*, libxl__ao_devices*, int rc);
+struct libxl__ao_devices {
+ libxl__ao_device *array;
+ int size;
+ libxl__devices_callback *callback;
+};
+
+/*
+ * Algorithm for handling device removal (including domain
+ * destruction). This is somewhat subtle because we may already have
+ * killed the domain and caused the death of qemu.
+ *
+ * In current versions of qemu there is no mechanism for ensuring that
+ * the resources used by its devices (both emulated and any PV devices
+ * provided by qemu) are freed (eg, fds closed) before it shuts down,
+ * and no confirmation from a terminating qemu back to the toolstack.
+ *
+ * This will need to be fixed in Xen 4.3. In the meantime (Xen 4.2)
+ * we implement a bodge.
+ *
+ * WE WANT TO UNPLUG WE WANT TO SHUT DOWN OR DESTROY
+ * | |
+ * | LIBXL SENDS SIGHUP TO QEMU
+ * | .....................|........................
+ * | : XEN 4.3+ PLANNED | :
+ * | : QEMU TEARS DOWN ALL DEVICES :
+ * | : FREES RESOURCES (closing fds) :
+ * | : SETS PV BACKENDS TO STATE 5, :
+ * | : waits for PV frontends to shut down :
+ * | : SETS PV BACKENDS TO STATE 6 :
+ * | : | :
+ * | : QEMU NOTIFIES TOOLSTACK (via :
+ * | : xenstore) that it is exiting :
+ * | : QEMU EXITS (parent may be init) :
+ * | : | :
+ * | : TOOLSTACK WAITS FOR QEMU :
+ * | : notices qemu has finished :
+ * | :....................|.......................:
+ * | .--------------------'
+ * V V
+ * for each device
+ * we want to unplug/remove
+ * ..................|...........................................
+ * : V XEN 4.2 RACY BODGE :
+ * : device is provided by qemu :
+ * : | `-----------. :
+ * : something| V :
+ * : else, eg| domain (that is domain for which :
+ * : blkback| this PV device is the backend, :
+ * : | which might be the stub dm) :
+ * : | is still alive? :
+ * : | | | :
+ * : | |alive |dead :
+ * : |<-----------------' | :
+ * : | hopefully qemu is | :
+ * : | still running | :
+ * :............|................. | :
+ * ,----->| : we may be racing :
+ * | backend state? : with qemu's death :
+ * ^ | | : | :
+ * xenstore| |other |6 : WAIT 2.0s :
+ * conflict| | | : TIMEOUT :
+ * | WRITE B.E. | : | :
+ * | STATE:=5 | : hopefully qemu has :
+ * `---' | | : gone by now and :
+ * |ok | : freed its resources :
+ * | | : | :
+ * WAIT FOR | : SET B.E. :
+ * STATE==6 | : STATE:=6 :
+ * / | | :..........|...................:
+ * timeout/ ok| | |
+ * / | | |
+ * | RUN HOTPLUG <-'<----------------'
+ * | SCRIPT
+ * | |
+ * `---> NUKE
+ * BACKEND
+ * |
+ * DONE.
+ */
+
+/* Arranges that dev will be removed to the guest, and the
+ * hotplug scripts will be executed (if necessary). When
+ * this is done (or an error happens), the callback in
+ * aodev->callback will be called.
+ *
+ * The libxl__ao_device passed to this function should be
+ * prepared using libxl__prepare_ao_device prior to calling
+ * this function.
+ *
+ * Once finished, aodev->callback will be executed.
+ */
+_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;
@@ -1968,167 +2129,6 @@ _hidden void libxl__bootloader_init(libxl__bootloader_state *bl);
* 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) */
-typedef enum {
- DEVICE_CONNECT,
- DEVICE_DISCONNECT
-} libxl__device_action;
-
-typedef struct libxl__ao_device libxl__ao_device;
-typedef struct libxl__ao_devices libxl__ao_devices;
-typedef void libxl__device_callback(libxl__egc*, libxl__ao_device*);
-
-/* This functions sets the necessary libxl__ao_device struct values to use
- * safely inside functions. It marks the operation as "active"
- * since we need to be sure that all device status structs are set
- * to active before start queueing events, or we might call
- * ao_complete before all devices had finished
- *
- * libxl__initiate_device_{remove/addition} should not be called without
- * calling libxl__prepare_ao_device first, since it initializes the private
- * fields of the struct libxl__ao_device to what this functions expect.
- *
- * Once _prepare has been called on a libxl__ao_device, it is safe to just
- * discard this struct, there's no need to call any destroy function.
- * _prepare can also be called multiple times with the same libxl__ao_device.
- */
-_hidden void libxl__prepare_ao_device(libxl__ao *ao, libxl__ao_device *aodev);
-
-/* Prepare a bunch of devices for addition/removal. Every ao_device in
- * ao_devices is set to 'active', and the ao_device 'base' field is set to
- * the one pointed by aodevs.
- */
-_hidden void libxl__prepare_ao_devices(libxl__ao *ao,
- libxl__ao_devices *aodevs);
-
-/* Generic callback to use when adding/removing several devices, this will
- * check if the given aodev is the last one, and call the callback in the
- * parent libxl__ao_devices struct, passing the appropriate error if found.
- */
-_hidden void libxl__ao_devices_callback(libxl__egc *egc,
- libxl__ao_device *aodev);
-
-struct libxl__ao_device {
- /* filled in by user */
- libxl__ao *ao;
- libxl__device_action action;
- libxl__device *dev;
- int force;
- libxl__device_callback *callback;
- /* private for implementation */
- int active;
- int rc;
- libxl__ev_devstate backend_ds;
- /* Bodge for Qemu devices */
- libxl__ev_time timeout;
- /* Used internally to have a reference to the upper libxl__ao_devices
- * struct when present */
- libxl__ao_devices *aodevs;
-};
-
-/* Helper struct to simply the plug/unplug of multiple devices at the same
- * time.
- *
- * This structure holds several devices, and the callback is only called
- * when all the devices inside of the array have finished.
- */
-typedef void libxl__devices_callback(libxl__egc*, libxl__ao_devices*, int rc);
-struct libxl__ao_devices {
- libxl__ao_device *array;
- int size;
- libxl__devices_callback *callback;
-};
-
-/*
- * Algorithm for handling device removal (including domain
- * destruction). This is somewhat subtle because we may already have
- * killed the domain and caused the death of qemu.
- *
- * In current versions of qemu there is no mechanism for ensuring that
- * the resources used by its devices (both emulated and any PV devices
- * provided by qemu) are freed (eg, fds closed) before it shuts down,
- * and no confirmation from a terminating qemu back to the toolstack.
- *
- * This will need to be fixed in Xen 4.3. In the meantime (Xen 4.2)
- * we implement a bodge.
- *
- * WE WANT TO UNPLUG WE WANT TO SHUT DOWN OR DESTROY
- * | |
- * | LIBXL SENDS SIGHUP TO QEMU
- * | .....................|........................
- * | : XEN 4.3+ PLANNED | :
- * | : QEMU TEARS DOWN ALL DEVICES :
- * | : FREES RESOURCES (closing fds) :
- * | : SETS PV BACKENDS TO STATE 5, :
- * | : waits for PV frontends to shut down :
- * | : SETS PV BACKENDS TO STATE 6 :
- * | : | :
- * | : QEMU NOTIFIES TOOLSTACK (via :
- * | : xenstore) that it is exiting :
- * | : QEMU EXITS (parent may be init) :
- * | : | :
- * | : TOOLSTACK WAITS FOR QEMU :
- * | : notices qemu has finished :
- * | :....................|.......................:
- * | .--------------------'
- * V V
- * for each device
- * we want to unplug/remove
- * ..................|...........................................
- * : V XEN 4.2 RACY BODGE :
- * : device is provided by qemu :
- * : | `-----------. :
- * : something| V :
- * : else, eg| domain (that is domain for which :
- * : blkback| this PV device is the backend, :
- * : | which might be the stub dm) :
- * : | is still alive? :
- * : | | | :
- * : | |alive |dead :
- * : |<-----------------' | :
- * : | hopefully qemu is | :
- * : | still running | :
- * :............|................. | :
- * ,----->| : we may be racing :
- * | backend state? : with qemu's death :
- * ^ | | : | :
- * xenstore| |other |6 : WAIT 2.0s :
- * conflict| | | : TIMEOUT :
- * | WRITE B.E. | : | :
- * | STATE:=5 | : hopefully qemu has :
- * `---' | | : gone by now and :
- * |ok | : freed its resources :
- * | | : | :
- * WAIT FOR | : SET B.E. :
- * STATE==6 | : STATE:=6 :
- * / | | :..........|...................:
- * timeout/ ok| | |
- * / | | |
- * | RUN HOTPLUG <-'<----------------'
- * | SCRIPT
- * | |
- * `---> NUKE
- * BACKEND
- * |
- * DONE.
- */
-
-/* Arranges that dev will be removed to the guest, and the
- * hotplug scripts will be executed (if necessary). When
- * this is done (or an error happens), the callback in
- * aodev->callback will be called.
- *
- * The libxl__ao_device passed to this function should be
- * prepared using libxl__prepare_ao_device prior to calling
- * this function.
- *
- * Once finished, aodev->callback will be executed.
- */
-_hidden void libxl__initiate_device_remove(libxl__egc *egc,
- libxl__ao_device *aodev);
-
/*----- Domain destruction -----*/
/* Domain destruction has been split into two functions:
--
1.7.7.5 (Apple Git-26)
next prev parent reply other threads:[~2012-07-20 14:12 UTC|newest]
Thread overview: 44+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-07-20 14:12 [PATCH v10 01/19] execute hotplug scripts from libxl v10 Roger Pau Monne
2012-07-20 14:12 ` [PATCH v10 01/19] libxl: check backend state before setting it to "closing" Roger Pau Monne
2012-07-20 14:12 ` [PATCH v10 02/19] libxl: change ao_device_remove to ao_device Roger Pau Monne
2012-07-20 16:35 ` Ian Jackson
2012-07-20 14:12 ` [PATCH v10 03/19] libxl: move device model creation prototypes Roger Pau Monne
2012-07-20 14:12 ` [PATCH v10 04/19] libxl: convert libxl_domain_destroy to an async op Roger Pau Monne
2012-07-20 14:12 ` Roger Pau Monne [this message]
2012-07-20 17:21 ` [PATCH v10 05/19] libxl: move bootloader data strucutres and prototypes Ian Jackson
2012-07-20 14:12 ` [PATCH v10 06/19] libxl: refactor disk addition to take a helper Roger Pau Monne
2012-07-20 17:24 ` Ian Jackson
2012-07-20 14:12 ` [PATCH v10 07/19] libxl: convert libxl__device_disk_local_attach to an async op Roger Pau Monne
2012-07-20 18:03 ` Ian Jackson
2012-07-23 11:32 ` Roger Pau Monne
2012-07-20 14:12 ` [PATCH v10 08/19] libxl: rename vifs to nics Roger Pau Monne
2012-07-20 14:12 ` [PATCH v10 09/19] libxl: convert libxl_device_disk_add to an async op Roger Pau Monne
2012-07-20 18:04 ` Ian Jackson
2012-07-20 14:12 ` [PATCH v10 10/19] libxl: convert libxl_device_nic_add to an async operation Roger Pau Monne
2012-07-20 14:12 ` [PATCH v10 11/19] libxl: add option to choose who executes hotplug scripts Roger Pau Monne
2012-07-20 14:12 ` [PATCH v10 12/19] libxl: rename _IOEMU nic type to VIF_IOEMU Roger Pau Monne
2012-07-20 16:34 ` Ian Campbell
2012-07-20 16:39 ` Ian Campbell
2012-07-20 14:12 ` [PATCH v10 13/19] libxl: set correct nic type depending on the guest Roger Pau Monne
2012-07-20 18:06 ` Ian Jackson
2012-07-20 14:12 ` [PATCH v10 14/19] libxl: use libxl__xs_path_cleanup on device_destroy Roger Pau Monne
2012-07-20 15:38 ` Ian Campbell
2012-07-20 14:12 ` [PATCH v10 15/19] libxl: call hotplug scripts for disk devices from libxl Roger Pau Monne
2012-07-20 15:20 ` Ian Campbell
2012-07-20 14:12 ` [PATCH v10 16/19] libxl: call hotplug scripts for nic " Roger Pau Monne
2012-07-20 16:01 ` Ian Campbell
2012-07-20 16:12 ` Ian Campbell
2012-07-20 16:36 ` Ian Campbell
2012-07-23 9:22 ` Roger Pau Monne
2012-07-20 16:03 ` Ian Campbell
2012-07-20 14:12 ` [PATCH v10 17/19] libxl: convert libxl_device_vkb_add to an async operation Roger Pau Monne
2012-07-20 18:08 ` Ian Jackson
2012-07-23 8:58 ` Roger Pau Monne
2012-07-23 9:26 ` Ian Campbell
2012-07-23 11:44 ` Ian Jackson
2012-07-20 14:12 ` [PATCH v10 18/19] libxl: convert libxl_device_vfb_add " Roger Pau Monne
2012-07-20 18:11 ` Ian Jackson
2012-07-23 11:58 ` Roger Pau Monne
2012-07-20 14:12 ` [PATCH v10 19/19] xl: main_blockdetach don't call destroy if remove succeeds Roger Pau Monne
2012-07-20 14:55 ` Ian Campbell
2012-07-23 12:17 ` [PATCH v10 01/19] execute hotplug scripts from libxl v10 Ian Campbell
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1342793548-10239-6-git-send-email-roger.pau@citrix.com \
--to=roger.pau@citrix.com \
--cc=ian.jackson@eu.citrix.com \
--cc=xen-devel@lists.xen.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).