typedef msg_host_priv_t msg_vm_priv_t;
typedef enum {
-msg_vm_state_created,
-msg_vm_state_running,
-msg_vm_state_sleeping,
-msg_vm_state_migrating,
-msg_vm_state_resuming,
-msg_vm_state_suspended,
-msg_vm_state_saved,
-msg_vm_state_restoring,
+ /* created, but not yet started */
+ msg_vm_state_created,
+
+ msg_vm_state_running,
+ msg_vm_state_migrating,
+
+ /* Suspend/resume does not involve disk I/O, so we assume there is no transition states. */
+ msg_vm_state_suspended,
+
+ /* Save/restore involves disk I/O, so there should be transition states. */
+ msg_vm_state_saving,
+ msg_vm_state_saved,
+ msg_vm_state_restoring,
+
} e_msg_vm_state_t;
static inline msg_vm_priv_t MSG_vm_priv(msg_vm_t vm){
return MSG_host_get_name(vm);
}
+
+/* **** Check state of a VM **** */
+static inline int __MSG_vm_is_state(msg_vm_t vm, e_msg_vm_state_t state) {
+ return simcall_vm_get_state(vm) == state;
+}
+
+/** @brief Returns whether the given VM has just reated, not running.
+ * @ingroup msg_VMs
+ */
+int MSG_vm_is_created(msg_vm_t vm)
+{
+ return __MSG_vm_is_state(vm, msg_vm_state_created);
+}
+
+/** @brief Returns whether the given VM is currently running
+ * @ingroup msg_VMs
+ */
+int MSG_vm_is_running(msg_vm_t vm)
+{
+ return __MSG_vm_is_state(vm, msg_vm_state_running);
+}
+
+/** @brief Returns whether the given VM is currently migrating
+ * @ingroup msg_VMs
+ */
+int MSG_vm_is_migrating(msg_vm_t vm)
+{
+ return __MSG_vm_is_state(vm, msg_vm_state_migrating);
+}
+
+/** @brief Returns whether the given VM is currently suspended, not running.
+ * @ingroup msg_VMs
+ */
+int MSG_vm_is_suspended(msg_vm_t vm)
+{
+ return __MSG_vm_is_state(vm, msg_vm_state_suspended);
+}
+
+/** @brief Returns whether the given VM is being saved (FIXME: live saving or not?).
+ * @ingroup msg_VMs
+ */
+int MSG_vm_is_saving(msg_vm_t vm)
+{
+ return __MSG_vm_is_state(vm, msg_vm_state_saving);
+}
+
+/** @brief Returns whether the given VM has been saved, not running.
+ * @ingroup msg_VMs
+ */
+int MSG_vm_is_saved(msg_vm_t vm)
+{
+ return __MSG_vm_is_state(vm, msg_vm_state_saved);
+}
+
+/** @brief Returns whether the given VM is being restored, not running.
+ * @ingroup msg_VMs
+ */
+int MSG_vm_is_restoring(msg_vm_t vm)
+{
+ return __MSG_vm_is_state(vm, msg_vm_state_restoring);
+}
+
+
+
+/* ------------------------------------------------------------------------- */
+/* ------------------------------------------------------------------------- */
+
/* **** ******** MSG vm actions ********* **** */
/** @brief Create a new VM (the VM is just attached to the location but it is not started yet).
#endif
}
-/* **** Check state of a VM **** */
-int __MSG_vm_is_state(msg_vm_t vm, e_msg_vm_state_t state) {
- return simcall_vm_get_state(vm) == state ;
-}
-
-/** @brief Returns whether the given VM is currently suspended
- * @ingroup msg_VMs
- */
-int MSG_vm_is_suspended(msg_vm_t vm) {
- return __MSG_vm_is_state(vm, msg_vm_state_suspended);
-}
-/** @brief Returns whether the given VM is currently running
- * @ingroup msg_VMs
- */
-int MSG_vm_is_running(msg_vm_t vm) {
- return __MSG_vm_is_state(vm, msg_vm_state_running);
-}
-
-// TODO Implement the functions for the different state
/** @brief Immediately kills all processes within the given VM. Any memory that they allocated will be leaked.