diff mbox

[RFC,v2,11/12] VMState test: cancel mechanism for an already running vmstate testing process

Message ID 1406302776-2306-12-git-send-email-sanidhya.iiith@gmail.com
State New
Headers show

Commit Message

Sanidhya Kashyap July 25, 2014, 3:39 p.m. UTC
Signed-off-by: Sanidhya Kashyap <sanidhya.iiith@gmail.com>
---
 qapi-schema.json |  9 +++++++++
 qmp-commands.hx  | 19 +++++++++++++++++++
 savevm.c         | 16 ++++++++++++++--
 3 files changed, 42 insertions(+), 2 deletions(-)

Comments

Eric Blake July 29, 2014, 4:50 p.m. UTC | #1
On 07/25/2014 09:39 AM, Sanidhya Kashyap wrote:
> Signed-off-by: Sanidhya Kashyap <sanidhya.iiith@gmail.com>
> ---
>  qapi-schema.json |  9 +++++++++
>  qmp-commands.hx  | 19 +++++++++++++++++++
>  savevm.c         | 16 ++++++++++++++--
>  3 files changed, 42 insertions(+), 2 deletions(-)
> 
> diff --git a/qapi-schema.json b/qapi-schema.json
> index 13e922e..91f1672 100644
> --- a/qapi-schema.json
> +++ b/qapi-schema.json
> @@ -3574,3 +3574,12 @@
>  ##
>  { 'command' : 'test-vmstates-set-period',
>    'data'    : { 'period': 'int' } }
> +
> +##
> +# @log-dirty-bitmap-cancel
> +#
> +# cancel the testing vmstates process
> +#
> +# Since 2.2
> +##
> +{ 'command': 'test-vmstates-cancel' }

Command name doesn't match documentation.


> +
> +SQMP
> +test-vmstates-cancel
> +--------------

Make the ---- line up to the command name.


> +++ b/savevm.c
> @@ -1365,8 +1365,12 @@ static void vmstate_test_cb(void *opaque)
>          if (saved_vm_running) {
>              vm_start();
>          }
> -        timer_mod(v->timer, qemu_clock_get_ms(QEMU_CLOCK_REALTIME) +
> -                                              v->period);
> +       if (v->active_state) {

Indentation is off.
diff mbox

Patch

diff --git a/qapi-schema.json b/qapi-schema.json
index 13e922e..91f1672 100644
--- a/qapi-schema.json
+++ b/qapi-schema.json
@@ -3574,3 +3574,12 @@ 
 ##
 { 'command' : 'test-vmstates-set-period',
   'data'    : { 'period': 'int' } }
+
+##
+# @log-dirty-bitmap-cancel
+#
+# cancel the testing vmstates process
+#
+# Since 2.2
+##
+{ 'command': 'test-vmstates-cancel' }
diff --git a/qmp-commands.hx b/qmp-commands.hx
index 2f019b0..1035885 100644
--- a/qmp-commands.hx
+++ b/qmp-commands.hx
@@ -3865,3 +3865,22 @@  Example:
 <- { "return": {} }
 EQMP
 
+	{
+        .name       = "test-vmstates-cancel",
+        .args_type  = "",
+        .mhandler.cmd_new = qmp_marshal_input_test_vmstates_cancel,
+    },
+
+SQMP
+test-vmstates-cancel
+--------------
+
+Cancel the current vmstate testing process.
+
+Arguments: None.
+
+Example:
+
+-> { "execute": "test-vmstates-cancel" }
+<- { "return": {} }
+EQMP
diff --git a/savevm.c b/savevm.c
index 8b75691..66597db 100644
--- a/savevm.c
+++ b/savevm.c
@@ -1365,8 +1365,12 @@  static void vmstate_test_cb(void *opaque)
         if (saved_vm_running) {
             vm_start();
         }
-        timer_mod(v->timer, qemu_clock_get_ms(QEMU_CLOCK_REALTIME) +
-                                              v->period);
+       if (v->active_state) {
+            timer_mod(v->timer, v->period +
+                      qemu_clock_get_ms(QEMU_CLOCK_REALTIME));
+        } else {
+            goto testing_end;
+        }
         return;
     }
 
@@ -1482,6 +1486,14 @@  void qmp_test_vmstates_set_period(int64_t period, Error **errp)
     v->period = period;
 }
 
+void qmp_test_vmstates_cancel(Error **errp)
+{
+    VMStateLogState *v = vmstate_current_state();
+    if (v->active_state) {
+        v->active_state = false;
+    }
+}
+
 void qmp_xen_save_devices_state(const char *filename, Error **errp)
 {
     QEMUFile *f;