[v3,07/13] monitor/hmp: move hmp_snapshot_* to block-hmp-cmds.c
diff mbox series

Message ID 20200127103647.17761-8-mlevitsk@redhat.com
State New
Headers show
Series
  • RFC: [for 5.0]: HMP monitor handlers cleanups
Related show

Commit Message

Maxim Levitsky Jan. 27, 2020, 10:36 a.m. UTC
Signed-off-by: Maxim Levitsky <mlevitsk@redhat.com>
---
 block/monitor/block-hmp-cmds.c     | 47 ++++++++++++++++++++++++++++++
 include/block/block-hmp-commands.h |  4 +++
 include/monitor/hmp.h              |  3 --
 monitor/hmp-cmds.c                 | 47 ------------------------------
 4 files changed, 51 insertions(+), 50 deletions(-)

Comments

Dr. David Alan Gilbert Jan. 28, 2020, 6:53 p.m. UTC | #1
* Maxim Levitsky (mlevitsk@redhat.com) wrote:
> Signed-off-by: Maxim Levitsky <mlevitsk@redhat.com>

Reviewed-by: Dr. David Alan Gilbert <dgilbert@redhat.com>

> ---
>  block/monitor/block-hmp-cmds.c     | 47 ++++++++++++++++++++++++++++++
>  include/block/block-hmp-commands.h |  4 +++
>  include/monitor/hmp.h              |  3 --
>  monitor/hmp-cmds.c                 | 47 ------------------------------
>  4 files changed, 51 insertions(+), 50 deletions(-)
> 
> diff --git a/block/monitor/block-hmp-cmds.c b/block/monitor/block-hmp-cmds.c
> index ed3c350143..9aa94ea6e0 100644
> --- a/block/monitor/block-hmp-cmds.c
> +++ b/block/monitor/block-hmp-cmds.c
> @@ -280,3 +280,50 @@ void hmp_block_job_complete(Monitor *mon, const QDict *qdict)
>  
>      hmp_handle_error(mon, error);
>  }
> +
> +void hmp_snapshot_blkdev(Monitor *mon, const QDict *qdict)
> +{
> +    const char *device = qdict_get_str(qdict, "device");
> +    const char *filename = qdict_get_try_str(qdict, "snapshot-file");
> +    const char *format = qdict_get_try_str(qdict, "format");
> +    bool reuse = qdict_get_try_bool(qdict, "reuse", false);
> +    enum NewImageMode mode;
> +    Error *err = NULL;
> +
> +    if (!filename) {
> +        /* In the future, if 'snapshot-file' is not specified, the snapshot
> +           will be taken internally. Today it's actually required. */
> +        error_setg(&err, QERR_MISSING_PARAMETER, "snapshot-file");
> +        hmp_handle_error(mon, err);
> +        return;
> +    }
> +
> +    mode = reuse ? NEW_IMAGE_MODE_EXISTING : NEW_IMAGE_MODE_ABSOLUTE_PATHS;
> +    qmp_blockdev_snapshot_sync(true, device, false, NULL,
> +                               filename, false, NULL,
> +                               !!format, format,
> +                               true, mode, &err);
> +    hmp_handle_error(mon, err);
> +}
> +
> +void hmp_snapshot_blkdev_internal(Monitor *mon, const QDict *qdict)
> +{
> +    const char *device = qdict_get_str(qdict, "device");
> +    const char *name = qdict_get_str(qdict, "name");
> +    Error *err = NULL;
> +
> +    qmp_blockdev_snapshot_internal_sync(device, name, &err);
> +    hmp_handle_error(mon, err);
> +}
> +
> +void hmp_snapshot_delete_blkdev_internal(Monitor *mon, const QDict *qdict)
> +{
> +    const char *device = qdict_get_str(qdict, "device");
> +    const char *name = qdict_get_str(qdict, "name");
> +    const char *id = qdict_get_try_str(qdict, "id");
> +    Error *err = NULL;
> +
> +    qmp_blockdev_snapshot_delete_internal_sync(device, !!id, id,
> +                                               true, name, &err);
> +    hmp_handle_error(mon, err);
> +}
> diff --git a/include/block/block-hmp-commands.h b/include/block/block-hmp-commands.h
> index ea6578a5f6..3fc2daf3a9 100644
> --- a/include/block/block-hmp-commands.h
> +++ b/include/block/block-hmp-commands.h
> @@ -17,4 +17,8 @@ void hmp_block_job_pause(Monitor *mon, const QDict *qdict);
>  void hmp_block_job_resume(Monitor *mon, const QDict *qdict);
>  void hmp_block_job_complete(Monitor *mon, const QDict *qdict);
>  
> +void hmp_snapshot_blkdev(Monitor *mon, const QDict *qdict);
> +void hmp_snapshot_blkdev_internal(Monitor *mon, const QDict *qdict);
> +void hmp_snapshot_delete_blkdev_internal(Monitor *mon, const QDict *qdict);
> +
>  #endif
> diff --git a/include/monitor/hmp.h b/include/monitor/hmp.h
> index 592ce0ccfe..6d34e29bb6 100644
> --- a/include/monitor/hmp.h
> +++ b/include/monitor/hmp.h
> @@ -61,9 +61,6 @@ void hmp_set_link(Monitor *mon, const QDict *qdict);
>  void hmp_block_passwd(Monitor *mon, const QDict *qdict);
>  void hmp_balloon(Monitor *mon, const QDict *qdict);
>  void hmp_block_resize(Monitor *mon, const QDict *qdict);
> -void hmp_snapshot_blkdev(Monitor *mon, const QDict *qdict);
> -void hmp_snapshot_blkdev_internal(Monitor *mon, const QDict *qdict);
> -void hmp_snapshot_delete_blkdev_internal(Monitor *mon, const QDict *qdict);
>  void hmp_loadvm(Monitor *mon, const QDict *qdict);
>  void hmp_savevm(Monitor *mon, const QDict *qdict);
>  void hmp_delvm(Monitor *mon, const QDict *qdict);
> diff --git a/monitor/hmp-cmds.c b/monitor/hmp-cmds.c
> index 996ce96430..46b46b6dd7 100644
> --- a/monitor/hmp-cmds.c
> +++ b/monitor/hmp-cmds.c
> @@ -1337,53 +1337,6 @@ void hmp_block_resize(Monitor *mon, const QDict *qdict)
>      hmp_handle_error(mon, err);
>  }
>  
> -void hmp_snapshot_blkdev(Monitor *mon, const QDict *qdict)
> -{
> -    const char *device = qdict_get_str(qdict, "device");
> -    const char *filename = qdict_get_try_str(qdict, "snapshot-file");
> -    const char *format = qdict_get_try_str(qdict, "format");
> -    bool reuse = qdict_get_try_bool(qdict, "reuse", false);
> -    enum NewImageMode mode;
> -    Error *err = NULL;
> -
> -    if (!filename) {
> -        /* In the future, if 'snapshot-file' is not specified, the snapshot
> -           will be taken internally. Today it's actually required. */
> -        error_setg(&err, QERR_MISSING_PARAMETER, "snapshot-file");
> -        hmp_handle_error(mon, err);
> -        return;
> -    }
> -
> -    mode = reuse ? NEW_IMAGE_MODE_EXISTING : NEW_IMAGE_MODE_ABSOLUTE_PATHS;
> -    qmp_blockdev_snapshot_sync(true, device, false, NULL,
> -                               filename, false, NULL,
> -                               !!format, format,
> -                               true, mode, &err);
> -    hmp_handle_error(mon, err);
> -}
> -
> -void hmp_snapshot_blkdev_internal(Monitor *mon, const QDict *qdict)
> -{
> -    const char *device = qdict_get_str(qdict, "device");
> -    const char *name = qdict_get_str(qdict, "name");
> -    Error *err = NULL;
> -
> -    qmp_blockdev_snapshot_internal_sync(device, name, &err);
> -    hmp_handle_error(mon, err);
> -}
> -
> -void hmp_snapshot_delete_blkdev_internal(Monitor *mon, const QDict *qdict)
> -{
> -    const char *device = qdict_get_str(qdict, "device");
> -    const char *name = qdict_get_str(qdict, "name");
> -    const char *id = qdict_get_try_str(qdict, "id");
> -    Error *err = NULL;
> -
> -    qmp_blockdev_snapshot_delete_internal_sync(device, !!id, id,
> -                                               true, name, &err);
> -    hmp_handle_error(mon, err);
> -}
> -
>  void hmp_loadvm(Monitor *mon, const QDict *qdict)
>  {
>      int saved_vm_running  = runstate_is_running();
> -- 
> 2.17.2
> 
--
Dr. David Alan Gilbert / dgilbert@redhat.com / Manchester, UK

Patch
diff mbox series

diff --git a/block/monitor/block-hmp-cmds.c b/block/monitor/block-hmp-cmds.c
index ed3c350143..9aa94ea6e0 100644
--- a/block/monitor/block-hmp-cmds.c
+++ b/block/monitor/block-hmp-cmds.c
@@ -280,3 +280,50 @@  void hmp_block_job_complete(Monitor *mon, const QDict *qdict)
 
     hmp_handle_error(mon, error);
 }
+
+void hmp_snapshot_blkdev(Monitor *mon, const QDict *qdict)
+{
+    const char *device = qdict_get_str(qdict, "device");
+    const char *filename = qdict_get_try_str(qdict, "snapshot-file");
+    const char *format = qdict_get_try_str(qdict, "format");
+    bool reuse = qdict_get_try_bool(qdict, "reuse", false);
+    enum NewImageMode mode;
+    Error *err = NULL;
+
+    if (!filename) {
+        /* In the future, if 'snapshot-file' is not specified, the snapshot
+           will be taken internally. Today it's actually required. */
+        error_setg(&err, QERR_MISSING_PARAMETER, "snapshot-file");
+        hmp_handle_error(mon, err);
+        return;
+    }
+
+    mode = reuse ? NEW_IMAGE_MODE_EXISTING : NEW_IMAGE_MODE_ABSOLUTE_PATHS;
+    qmp_blockdev_snapshot_sync(true, device, false, NULL,
+                               filename, false, NULL,
+                               !!format, format,
+                               true, mode, &err);
+    hmp_handle_error(mon, err);
+}
+
+void hmp_snapshot_blkdev_internal(Monitor *mon, const QDict *qdict)
+{
+    const char *device = qdict_get_str(qdict, "device");
+    const char *name = qdict_get_str(qdict, "name");
+    Error *err = NULL;
+
+    qmp_blockdev_snapshot_internal_sync(device, name, &err);
+    hmp_handle_error(mon, err);
+}
+
+void hmp_snapshot_delete_blkdev_internal(Monitor *mon, const QDict *qdict)
+{
+    const char *device = qdict_get_str(qdict, "device");
+    const char *name = qdict_get_str(qdict, "name");
+    const char *id = qdict_get_try_str(qdict, "id");
+    Error *err = NULL;
+
+    qmp_blockdev_snapshot_delete_internal_sync(device, !!id, id,
+                                               true, name, &err);
+    hmp_handle_error(mon, err);
+}
diff --git a/include/block/block-hmp-commands.h b/include/block/block-hmp-commands.h
index ea6578a5f6..3fc2daf3a9 100644
--- a/include/block/block-hmp-commands.h
+++ b/include/block/block-hmp-commands.h
@@ -17,4 +17,8 @@  void hmp_block_job_pause(Monitor *mon, const QDict *qdict);
 void hmp_block_job_resume(Monitor *mon, const QDict *qdict);
 void hmp_block_job_complete(Monitor *mon, const QDict *qdict);
 
+void hmp_snapshot_blkdev(Monitor *mon, const QDict *qdict);
+void hmp_snapshot_blkdev_internal(Monitor *mon, const QDict *qdict);
+void hmp_snapshot_delete_blkdev_internal(Monitor *mon, const QDict *qdict);
+
 #endif
diff --git a/include/monitor/hmp.h b/include/monitor/hmp.h
index 592ce0ccfe..6d34e29bb6 100644
--- a/include/monitor/hmp.h
+++ b/include/monitor/hmp.h
@@ -61,9 +61,6 @@  void hmp_set_link(Monitor *mon, const QDict *qdict);
 void hmp_block_passwd(Monitor *mon, const QDict *qdict);
 void hmp_balloon(Monitor *mon, const QDict *qdict);
 void hmp_block_resize(Monitor *mon, const QDict *qdict);
-void hmp_snapshot_blkdev(Monitor *mon, const QDict *qdict);
-void hmp_snapshot_blkdev_internal(Monitor *mon, const QDict *qdict);
-void hmp_snapshot_delete_blkdev_internal(Monitor *mon, const QDict *qdict);
 void hmp_loadvm(Monitor *mon, const QDict *qdict);
 void hmp_savevm(Monitor *mon, const QDict *qdict);
 void hmp_delvm(Monitor *mon, const QDict *qdict);
diff --git a/monitor/hmp-cmds.c b/monitor/hmp-cmds.c
index 996ce96430..46b46b6dd7 100644
--- a/monitor/hmp-cmds.c
+++ b/monitor/hmp-cmds.c
@@ -1337,53 +1337,6 @@  void hmp_block_resize(Monitor *mon, const QDict *qdict)
     hmp_handle_error(mon, err);
 }
 
-void hmp_snapshot_blkdev(Monitor *mon, const QDict *qdict)
-{
-    const char *device = qdict_get_str(qdict, "device");
-    const char *filename = qdict_get_try_str(qdict, "snapshot-file");
-    const char *format = qdict_get_try_str(qdict, "format");
-    bool reuse = qdict_get_try_bool(qdict, "reuse", false);
-    enum NewImageMode mode;
-    Error *err = NULL;
-
-    if (!filename) {
-        /* In the future, if 'snapshot-file' is not specified, the snapshot
-           will be taken internally. Today it's actually required. */
-        error_setg(&err, QERR_MISSING_PARAMETER, "snapshot-file");
-        hmp_handle_error(mon, err);
-        return;
-    }
-
-    mode = reuse ? NEW_IMAGE_MODE_EXISTING : NEW_IMAGE_MODE_ABSOLUTE_PATHS;
-    qmp_blockdev_snapshot_sync(true, device, false, NULL,
-                               filename, false, NULL,
-                               !!format, format,
-                               true, mode, &err);
-    hmp_handle_error(mon, err);
-}
-
-void hmp_snapshot_blkdev_internal(Monitor *mon, const QDict *qdict)
-{
-    const char *device = qdict_get_str(qdict, "device");
-    const char *name = qdict_get_str(qdict, "name");
-    Error *err = NULL;
-
-    qmp_blockdev_snapshot_internal_sync(device, name, &err);
-    hmp_handle_error(mon, err);
-}
-
-void hmp_snapshot_delete_blkdev_internal(Monitor *mon, const QDict *qdict)
-{
-    const char *device = qdict_get_str(qdict, "device");
-    const char *name = qdict_get_str(qdict, "name");
-    const char *id = qdict_get_try_str(qdict, "id");
-    Error *err = NULL;
-
-    qmp_blockdev_snapshot_delete_internal_sync(device, !!id, id,
-                                               true, name, &err);
-    hmp_handle_error(mon, err);
-}
-
 void hmp_loadvm(Monitor *mon, const QDict *qdict)
 {
     int saved_vm_running  = runstate_is_running();