Skip to contentSkip to conversation

Migration cleanup

PATCH In review Juan Quintela 4 participants 43 messages Apr 17, 2017 – Apr 25, 2017

lore
Share & tools
lore
#0 lore raw

cover Migration cleanup

Hi

This is a cleanup on top of my previous series. It does:
- create one .h file for each migration/* file
- export with meaningful include names the migration functions that we export
- untangle the includes mess (migration.h in8cluded vmstate.h who included qemu-file.h). Fixed all callers.
- once there, old MigrationParams are gone. Now block migration can be configured with migration capabilities like everything else in migration (old command line parameters are maintained, but on top of this)
- start moving hmp* functions to monitor.c

ToDo:
- move the two remaining hmp commands to monitor.c

really I should move them to block/* something, because they all use block functions, nothing from migration.c.

- savevm.c/vmstate.c/migration.c: they are still tangled, but I wanted to send the easy parts for review.

- half of the savevm.c functions are still exported from sysemu/sysemu.h moving that to a different file, have to think about it to make patches easier to understand.

- split capabilities/qmp commands/... from migration.c they don't belong there, and once they are out it would be easier to untangle the remaining bits.

- goal is still untangle normal migration/xbzrle/compression and rdma, they are still too untangled together.

- I can still remove some includes that are not needed, but with the current code, it gets really complicated until there is more cleanup there.

Please, comment.

Juan Quintela (19):
migration: to_dst_file at that point is NULL
migration: They are called vmstate_foo, move them to vmstate.c
migration: Split migration/channel.c for channel operations
migration: Remove MigrationState from migration_channel_incomming()
migration: Export exec.c functions in its own file
migration: Export fd.c functions in its own file
migration: Export socket.c functions in its own file
migration: Export tls.c functions in its own file
migration: Create block capabilities for shared and enable
migration: Remove use of old MigrationParams
migration: Remove old MigrationParams
migration: Remove unneeded includes
migration: Remove qemu-file.h from vmstate.h
migration: Remove vmstate.h from migration.h
migration: Export qemu-file-channel.c functions in its own file
migration: Export ram.c functions in its own file
migration: Export rdma.c functions in its own file
monitor: move hmp_savevm() to monitor.c
monitor: remove monitor parameter from save_vmstate

 include/hw/hw.h                       |   1 +
 include/migration/channel.h           |  24 +++++++
 include/migration/colo.h              |   3 -
 include/migration/exec.h              |  20 ++++++
 include/migration/fd.h                |  20 ++++++
 include/migration/migration.h         |  86 ++-----------------------
 include/migration/qemu-file-channel.h |  22 +++++++
 include/migration/qemu-file.h         |   3 -
 include/migration/ram.h               |  54 ++++++++++++++++
 include/migration/rdma.h              |  22 +++++++
 include/migration/socket.h            |  25 ++++++++
 include/migration/tls.h               |  27 ++++++++
 include/migration/vmstate.h           |   4 --
 include/qemu/typedefs.h               |   1 -
 include/sysemu/sysemu.h               |   6 +-
 migration/Makefile.objs               |   2 +-
 migration/block.c                     |  26 ++------
 migration/channel.c                   |  72 +++++++++++++++++++++
 migration/colo-comm.c                 |   2 +-
 migration/colo-failover.c             |   1 +
 migration/colo.c                      |   8 +--
 migration/exec.c                      |   6 +-
 migration/fd.c                        |   6 +-
 migration/migration.c                 | 116 +++++++++++++++-------------------
 migration/postcopy-ram.c              |   4 +-
 migration/qemu-file-channel.c         |   2 +-
 migration/qemu-file.c                 |   4 +-
 migration/ram.c                       |   5 +-
 migration/rdma.c                      |   5 +-
 migration/savevm.c                    |  63 ++++--------------
 migration/socket.c                    |   6 +-
 migration/tls.c                       |   5 +-
 migration/vmstate.c                   |  16 +++++
 monitor.c                             |   5 ++
 qapi-schema.json                      |   7 +-
 replay/replay-snapshot.c              |   2 +-
 36 files changed, 417 insertions(+), 264 deletions(-)
 create mode 100644 include/migration/channel.h
 create mode 100644 include/migration/exec.h
 create mode 100644 include/migration/fd.h
 create mode 100644 include/migration/qemu-file-channel.h
 create mode 100644 include/migration/ram.h
 create mode 100644 include/migration/rdma.h
 create mode 100644 include/migration/socket.h
 create mode 100644 include/migration/tls.h
 create mode 100644 migration/channel.c
Signature · 1 line
2.9.3
#1 lore raw

PATCH 1/19 migration: to_dst_file at that point is NULL

We have just arrived as:

migration.c: qemu_migrate()
....
s = migrate_init() <- puts it to NULL
....
{tcp,unix}_start_outgoing_migration ->
socket_outgoing_migration
migration_channel_connect()
sets to_dst_file

if tls is enabled, we do another round through migrate_channel_tls_connect(), but we only set it up if there is no error. So we don't need the assignation. I am removing it to remove in the follwing patches the knowledge about MigrationState in that two files.

---
 migration/socket.c | 1 -
 migration/tls.c    | 1 -
 2 files changed, 2 deletions(-)
migration/socket.c +0 -1
index 13966f1..dc88812 100644
@@ -79,7 +79,6 @@ static void socket_outgoing_migration(QIOTask *task,
 
     if (qio_task_propagate_error(task, &err)) {
         trace_migration_socket_outgoing_error(error_get_pretty(err));
-        data->s->to_dst_file = NULL;
         migrate_fd_error(data->s, err);
         error_free(err);
     } else {
migration/tls.c +0 -1
index 45bec44..a33ecb7 100644
@@ -116,7 +116,6 @@ static void migration_tls_outgoing_handshake(QIOTask *task,
 
     if (qio_task_propagate_error(task, &err)) {
         trace_migration_tls_outgoing_handshake_error(error_get_pretty(err));
-        s->to_dst_file = NULL;
         migrate_fd_error(s, err);
         error_free(err);
     } else {
Signature · 1 line
2.9.3
#2 lore raw

PATCH 2/19 migration: They are called vmstate_foo, move them to vmstate.c

In reply to Juan Quintela
---
 migration/savevm.c  | 17 -----------------
 migration/vmstate.c | 16 ++++++++++++++++
 2 files changed, 16 insertions(+), 17 deletions(-)
migration/savevm.c +0 -17
index cc9c086..c47b209 100644
@@ -45,7 +45,6 @@
 #include "qemu/sockets.h"
 #include "qemu/queue.h"
 #include "sysemu/cpus.h"
-#include "exec/memory.h"
 #include "qmp-commands.h"
 #include "trace.h"
 #include "qemu/bitops.h"
@@ -2465,19 +2464,3 @@ void hmp_info_snapshots(Monitor *mon, const QDict *qdict)
     g_free(global_snapshots);
 
 }
-
-void vmstate_register_ram(MemoryRegion *mr, DeviceState *dev)
-{
-    qemu_ram_set_idstr(mr->ram_block,
-                       memory_region_name(mr), dev);
-}
-
-void vmstate_unregister_ram(MemoryRegion *mr, DeviceState *dev)
-{
-    qemu_ram_unset_idstr(mr->ram_block);
-}
-
-void vmstate_register_ram_global(MemoryRegion *mr)
-{
-    vmstate_register_ram(mr, NULL);
-}
migration/vmstate.c +16 -0
index 8a71349..174c490 100644
@@ -1,5 +1,6 @@
 #include "qemu/osdep.h"
 #include "qemu-common.h"
+#include "exec/memory.h"
 #include "migration/migration.h"
 #include "migration/qemu-file.h"
 #include "migration/vmstate.h"
@@ -1127,3 +1128,18 @@ bool vmstate_device_is_migratable(const VMStateDescription *vmsd)
     return true;
 }
 
+void vmstate_register_ram(MemoryRegion *mr, DeviceState *dev)
+{
+    qemu_ram_set_idstr(mr->ram_block,
+                       memory_region_name(mr), dev);
+}
+
+void vmstate_unregister_ram(MemoryRegion *mr, DeviceState *dev)
+{
+    qemu_ram_unset_idstr(mr->ram_block);
+}
+
+void vmstate_register_ram_global(MemoryRegion *mr)
+{
+    vmstate_register_ram(mr, NULL);
+}
Signature · 1 line
2.9.3
Reviewed-by on v1 2/19
#3 lore raw

Re: [Qemu-devel] [PATCH 02/19] migration: They are called vmstate_foo, move them to vmstate.c

Quoted 5 lines · * Juan Quintela ([email protected]) wrote:
---
 migration/savevm.c  | 17 -----------------
 migration/vmstate.c | 16 ++++++++++++++++
 2 files changed, 16 insertions(+), 17 deletions(-)

OK, but it's a little odd, savevm.c still has the vmstate_register_with_alias_id and vmstate-unregister, so this is just the simple ram cases.

Quoted 65 lines
migration/savevm.c +0 -17
index cc9c086..c47b209 100644
@@ -45,7 +45,6 @@
 #include "qemu/sockets.h"
 #include "qemu/queue.h"
 #include "sysemu/cpus.h"
-#include "exec/memory.h"
 #include "qmp-commands.h"
 #include "trace.h"
 #include "qemu/bitops.h"
@@ -2465,19 +2464,3 @@ void hmp_info_snapshots(Monitor *mon, const QDict *qdict)
     g_free(global_snapshots);
 
 }
-
-void vmstate_register_ram(MemoryRegion *mr, DeviceState *dev)
-{
-    qemu_ram_set_idstr(mr->ram_block,
-                       memory_region_name(mr), dev);
-}
-
-void vmstate_unregister_ram(MemoryRegion *mr, DeviceState *dev)
-{
-    qemu_ram_unset_idstr(mr->ram_block);
-}
-
-void vmstate_register_ram_global(MemoryRegion *mr)
-{
-    vmstate_register_ram(mr, NULL);
-}
migration/vmstate.c +16 -0
index 8a71349..174c490 100644
@@ -1,5 +1,6 @@
 #include "qemu/osdep.h"
 #include "qemu-common.h"
+#include "exec/memory.h"
 #include "migration/migration.h"
 #include "migration/qemu-file.h"
 #include "migration/vmstate.h"
@@ -1127,3 +1128,18 @@ bool vmstate_device_is_migratable(const VMStateDescription *vmsd)
     return true;
 }
 
+void vmstate_register_ram(MemoryRegion *mr, DeviceState *dev)
+{
+    qemu_ram_set_idstr(mr->ram_block,
+                       memory_region_name(mr), dev);
+}
+
+void vmstate_unregister_ram(MemoryRegion *mr, DeviceState *dev)
+{
+    qemu_ram_unset_idstr(mr->ram_block);
+}
+
+void vmstate_register_ram_global(MemoryRegion *mr)
+{
+    vmstate_register_ram(mr, NULL);
+}
Signature · 1 line
2.9.3

--
Dr. David Alan Gilbert / [email protected] / Manchester, UK

#4 lore raw

Re: [Qemu-devel] [PATCH 02/19] migration: They are called vmstate_foo, move them to vmstate.c

Quoted 9 lines · Dr. David Alan Gilbert
Quoted 5 lines · * Juan Quintela ([email protected]) wrote:
---
 migration/savevm.c  | 17 -----------------
 migration/vmstate.c | 16 ++++++++++++++++
 2 files changed, 16 insertions(+), 17 deletions(-)

OK, but it's a little odd, savevm.c still has the vmstate_register_with_alias_id and vmstate-unregister, so this is just the simple ram cases.

This are the easy bits, for others I need to rearrange headers elsewhere.

Thanks, Juan.

#5 lore raw

Re: [Qemu-devel] [PATCH 02/19] migration: They are called vmstate_foo, move them to vmstate.c

In reply to Dr. David Alan Gilbert
Quoted 9 lines · Dr. David Alan Gilbert
Quoted 5 lines · * Juan Quintela ([email protected]) wrote:
---
 migration/savevm.c  | 17 -----------------
 migration/vmstate.c | 16 ++++++++++++++++
 2 files changed, 16 insertions(+), 17 deletions(-)

OK, but it's a little odd, savevm.c still has the vmstate_register_with_alias_id and vmstate-unregister, so this is just the simple ram cases.

Dropped the patch.

vmstate.c ends only having the interpreter on it.

#6 lore raw

PATCH 3/19 migration: Split migration/channel.c for channel operations

In reply to Juan Quintela
---
 include/migration/channel.h   | 25 ++++++++++++++++
 include/migration/migration.h |  7 -----
 migration/Makefile.objs       |  2 +-
 migration/channel.c           | 69 +++++++++++++++++++++++++++++++++++++++++++
 migration/exec.c              |  1 +
 migration/fd.c                |  1 +
 migration/migration.c         | 50 -------------------------------
 migration/socket.c            |  1 +
 migration/tls.c               |  1 +
 9 files changed, 99 insertions(+), 58 deletions(-)
 create mode 100644 include/migration/channel.h
 create mode 100644 migration/channel.c
include/migration/channel.h new file +25 -0
new file mode 100644
index 0000000..618acb7
@@ -0,0 +1,25 @@
+/*
+ * QEMU live migration channel functions
+ *
+ * Copyright IBM, Corp. 2008
+ *
+ * Authors:
+ *  Anthony Liguori   <[email protected]>
+ *
+ * This work is licensed under the terms of the GNU GPL, version 2.  See
+ * the COPYING file in the top-level directory.
+ *
+ */
+
+#ifndef QEMU_MIGRATION_CHANNEL_H
+#define QEMU_MIGRATION_CHANNEL_H
+
+#include "io/channel.h"
+
+void migration_channel_process_incoming(MigrationState *s,
+                                        QIOChannel *ioc);
+
+void migration_channel_connect(MigrationState *s,
+                               QIOChannel *ioc,
+                               const char *hostname);
+#endif
include/migration/migration.h +0 -7
index fabfb32..3f54a7c 100644
@@ -183,17 +183,10 @@ void migrate_set_state(int *state, int old_state, int new_state);
 
 void migration_fd_process_incoming(QEMUFile *f);
 
-void migration_channel_process_incoming(MigrationState *s,
-                                        QIOChannel *ioc);
-
 void migration_tls_channel_process_incoming(MigrationState *s,
                                             QIOChannel *ioc,
                                             Error **errp);
 
-void migration_channel_connect(MigrationState *s,
-                               QIOChannel *ioc,
-                               const char *hostname);
-
 void migration_tls_channel_connect(MigrationState *s,
                                    QIOChannel *ioc,
                                    const char *hostname,
migration/Makefile.objs +1 -1
index 480dd49..c83ca92 100644
@@ -1,5 +1,5 @@
 common-obj-y += migration.o socket.o fd.o exec.o
-common-obj-y += tls.o
+common-obj-y += tls.o channel.o
 common-obj-y += colo-comm.o colo.o colo-failover.o
 common-obj-y += vmstate.o
 common-obj-y += qemu-file.o
migration/channel.c new file +69 -0

69 lines not on this page · raw message

migration/exec.c +1 -0
index 9157721..7d13fc3 100644
@@ -20,6 +20,7 @@
 #include "qemu/osdep.h"
 #include "qapi/error.h"
 #include "qemu-common.h"
+#include "migration/channel.h"
 #include "migration/migration.h"
 #include "io/channel-command.h"
 #include "trace.h"
migration/fd.c +1 -0
index 58cb51a..f9c230e 100644
@@ -17,6 +17,7 @@
 #include "qemu/osdep.h"
 #include "qapi/error.h"
 #include "qemu-common.h"
+#include "migration/channel.h"
 #include "migration/migration.h"
 #include "monitor/monitor.h"
 #include "io/channel-util.h"
migration/migration.c +0 -50

56 lines not on this page · raw message

migration/socket.c +1 -0
index dc88812..7171635 100644
@@ -19,6 +19,7 @@
 #include "qemu-common.h"
 #include "qemu/error-report.h"
 #include "qapi/error.h"
+#include "migration/channel.h"
 #include "migration/migration.h"
 #include "migration/qemu-file.h"
 #include "io/channel-socket.h"
migration/tls.c +1 -0
index a33ecb7..4ee3349 100644
@@ -19,6 +19,7 @@
  */
 
 #include "qemu/osdep.h"
+#include "migration/channel.h"
 #include "migration/migration.h"
 #include "io/channel-tls.h"
 #include "crypto/tlscreds.h"
Signature · 1 line
2.9.3
#7 lore raw

PATCH 4/19 migration: Remove MigrationState from migration_channel_incomming()

In reply to Juan Quintela

All callers were calling migrate_get_current(), so do it inside the function.

---
 include/migration/channel.h | 3 +--
 migration/channel.c         | 5 +++--
 migration/exec.c            | 2 +-
 migration/fd.c              | 2 +-
 migration/socket.c          | 3 +--
 migration/tls.c             | 2 +-
 6 files changed, 8 insertions(+), 9 deletions(-)
include/migration/channel.h +1 -2
index 618acb7..fbc4bfb 100644
@@ -16,8 +16,7 @@
 
 #include "io/channel.h"
 
-void migration_channel_process_incoming(MigrationState *s,
-                                        QIOChannel *ioc);
+void migration_channel_process_incoming(QIOChannel *ioc);
 
 void migration_channel_connect(MigrationState *s,
                                QIOChannel *ioc,
migration/channel.c +3 -2
index c66c6db..6f11a1a 100644
@@ -20,9 +20,10 @@
 #include "qapi/error.h"
 #include "io/channel-tls.h"
 
-void migration_channel_process_incoming(MigrationState *s,
-                                        QIOChannel *ioc)
+void migration_channel_process_incoming(QIOChannel *ioc)
 {
+    MigrationState *s = migrate_get_current();
+
     trace_migration_set_incoming_channel(
         ioc, object_get_typename(OBJECT(ioc)));
 
migration/exec.c +1 -1
index 7d13fc3..2779c9c 100644
@@ -48,7 +48,7 @@ static gboolean exec_accept_incoming_migration(QIOChannel *ioc,
                                                GIOCondition condition,
                                                gpointer opaque)
 {
-    migration_channel_process_incoming(migrate_get_current(), ioc);
+    migration_channel_process_incoming(ioc);
     object_unref(OBJECT(ioc));
     return FALSE; /* unregister */
 }
migration/fd.c +1 -1
index f9c230e..fba3852 100644
@@ -48,7 +48,7 @@ static gboolean fd_accept_incoming_migration(QIOChannel *ioc,
                                              GIOCondition condition,
                                              gpointer opaque)
 {
-    migration_channel_process_incoming(migrate_get_current(), ioc);
+    migration_channel_process_incoming(ioc);
     object_unref(OBJECT(ioc));
     return FALSE; /* unregister */
 }
migration/socket.c +1 -2
index 7171635..b06cde3 100644
@@ -149,8 +149,7 @@ static gboolean socket_accept_incoming_migration(QIOChannel *ioc,
     trace_migration_socket_incoming_accepted();
 
     qio_channel_set_name(QIO_CHANNEL(sioc), "migration-socket-incoming");
-    migration_channel_process_incoming(migrate_get_current(),
-                                       QIO_CHANNEL(sioc));
+    migration_channel_process_incoming(QIO_CHANNEL(sioc));
     object_unref(OBJECT(sioc));
 
 out:
migration/tls.c +1 -1
index 4ee3349..2b28ebd 100644
@@ -73,7 +73,7 @@ static void migration_tls_incoming_handshake(QIOTask *task,
         error_report_err(err);
     } else {
         trace_migration_tls_incoming_handshake_complete();
-        migration_channel_process_incoming(migrate_get_current(), ioc);
+        migration_channel_process_incoming(ioc);
     }
     object_unref(OBJECT(ioc));
 }
Signature · 1 line
2.9.3
#8 lore raw

PATCH 5/19 migration: Export exec.c functions in its own file

In reply to Juan Quintela
---
 include/migration/exec.h      | 20 ++++++++++++++++++++
 include/migration/migration.h |  4 ----
 migration/exec.c              |  2 +-
 migration/migration.c         |  1 +
 4 files changed, 22 insertions(+), 5 deletions(-)
 create mode 100644 include/migration/exec.h
include/migration/exec.h new file +20 -0
new file mode 100644
index 0000000..c97a7e9
@@ -0,0 +1,20 @@
+/*
+ * QEMU live migration exec functions
+ *
+ * Copyright IBM, Corp. 2008
+ *
+ * Authors:
+ *  Anthony Liguori   <[email protected]>
+ *
+ * This work is licensed under the terms of the GNU GPL, version 2.  See
+ * the COPYING file in the top-level directory.
+ *
+ */
+
+#ifndef QEMU_MIGRATION_EXEC_H
+#define QEMU_MIGRATION_EXEC_H
+void exec_start_incoming_migration(const char *host_port, Error **errp);
+
+void exec_start_outgoing_migration(MigrationState *s, const char *host_port,
+                                   Error **errp);
+#endif
include/migration/migration.h +0 -4
index 3f54a7c..eb0150b 100644
@@ -194,10 +194,6 @@ void migration_tls_channel_connect(MigrationState *s,
 
 uint64_t migrate_max_downtime(void);
 
-void exec_start_incoming_migration(const char *host_port, Error **errp);
-
-void exec_start_outgoing_migration(MigrationState *s, const char *host_port, Error **errp);
-
 void tcp_start_incoming_migration(const char *host_port, Error **errp);
 
 void tcp_start_outgoing_migration(MigrationState *s, const char *host_port, Error **errp);
migration/exec.c +1 -1
index 2779c9c..1a2d5c2 100644
@@ -21,7 +21,7 @@
 #include "qapi/error.h"
 #include "qemu-common.h"
 #include "migration/channel.h"
-#include "migration/migration.h"
+#include "migration/exec.h"
 #include "io/channel-command.h"
 #include "trace.h"
 
migration/migration.c +1 -0
index 17d22eb..076c42a 100644
@@ -21,6 +21,7 @@
 #include "migration/machine.h"
 #include "migration/state.h"
 #include "migration/init.h"
+#include "migration/exec.h"
 #include "migration/migration.h"
 #include "migration/qemu-file.h"
 #include "sysemu/sysemu.h"
Signature · 1 line
2.9.3
#9 lore raw

Re: [Qemu-devel] [PATCH 05/19] migration: Export exec.c functions in its own file

Quoted 3 lines · Juan Quintela
---
 include/migration/exec.h      | 20 ++++++++++++++++++++

Good cleanup, but please move it to migration/exec.h and include it with "exec.h". This is the standard for files that are not needed outside that particular directory.

Paolo

Quoted 73 lines
 include/migration/migration.h |  4 ----
 migration/exec.c              |  2 +-
 migration/migration.c         |  1 +
 4 files changed, 22 insertions(+), 5 deletions(-)
 create mode 100644 include/migration/exec.h
include/migration/exec.h new file +20 -0
new file mode 100644
index 0000000..c97a7e9
@@ -0,0 +1,20 @@
+/*
+ * QEMU live migration exec functions
+ *
+ * Copyright IBM, Corp. 2008
+ *
+ * Authors:
+ *  Anthony Liguori   <[email protected]>
+ *
+ * This work is licensed under the terms of the GNU GPL, version 2.  See
+ * the COPYING file in the top-level directory.
+ *
+ */
+
+#ifndef QEMU_MIGRATION_EXEC_H
+#define QEMU_MIGRATION_EXEC_H
+void exec_start_incoming_migration(const char *host_port, Error **errp);
+
+void exec_start_outgoing_migration(MigrationState *s, const char *host_port,
+                                   Error **errp);
+#endif
include/migration/migration.h +0 -4
index 3f54a7c..eb0150b 100644
@@ -194,10 +194,6 @@ void migration_tls_channel_connect(MigrationState *s,
 
 uint64_t migrate_max_downtime(void);
 
-void exec_start_incoming_migration(const char *host_port, Error **errp);
-
-void exec_start_outgoing_migration(MigrationState *s, const char *host_port, Error **errp);
-
 void tcp_start_incoming_migration(const char *host_port, Error **errp);
 
 void tcp_start_outgoing_migration(MigrationState *s, const char *host_port, Error **errp);
migration/exec.c +1 -1
index 2779c9c..1a2d5c2 100644
@@ -21,7 +21,7 @@
 #include "qapi/error.h"
 #include "qemu-common.h"
 #include "migration/channel.h"
-#include "migration/migration.h"
+#include "migration/exec.h"
 #include "io/channel-command.h"
 #include "trace.h"
 
migration/migration.c +1 -0
index 17d22eb..076c42a 100644
@@ -21,6 +21,7 @@
 #include "migration/machine.h"
 #include "migration/state.h"
 #include "migration/init.h"
+#include "migration/exec.h"
 #include "migration/migration.h"
 #include "migration/qemu-file.h"
 #include "sysemu/sysemu.h"
#10 lore raw

Re: [Qemu-devel] [PATCH 05/19] migration: Export exec.c functions in its own file

Quoted 8 lines · Paolo Bonzini
Quoted 3 lines · Juan Quintela
---
 include/migration/exec.h      | 20 ++++++++++++++++++++

Good cleanup, but please move it to migration/exec.h and include it with "exec.h". This is the standard for files that are not needed outside that particular directory.

Aha, thanks. I was thinking about creating something "internal", but that makes sense.

Later, Juan.

#11 lore raw

PATCH 6/19 migration: Export fd.c functions in its own file

In reply to Juan Quintela
---
 include/migration/fd.h        | 20 ++++++++++++++++++++
 include/migration/migration.h |  4 ----
 migration/fd.c                |  2 +-
 migration/migration.c         |  1 +
 4 files changed, 22 insertions(+), 5 deletions(-)
 create mode 100644 include/migration/fd.h
include/migration/fd.h new file +20 -0
new file mode 100644
index 0000000..4ec3298
@@ -0,0 +1,20 @@
+/*
+ * QEMU live migration fd functions
+ *
+ * Copyright IBM, Corp. 2008
+ *
+ * Authors:
+ *  Anthony Liguori   <[email protected]>
+ *
+ * This work is licensed under the terms of the GNU GPL, version 2.  See
+ * the COPYING file in the top-level directory.
+ *
+ */
+
+#ifndef QEMU_MIGRATION_FD_H
+#define QEMU_MIGRATION_FD_H
+void fd_start_incoming_migration(const char *path, Error **errp);
+
+void fd_start_outgoing_migration(MigrationState *s, const char *fdname,
+                                 Error **errp);
+#endif
include/migration/migration.h +0 -4
index eb0150b..077b75b 100644
@@ -202,10 +202,6 @@ void unix_start_incoming_migration(const char *path, Error **errp);
 
 void unix_start_outgoing_migration(MigrationState *s, const char *path, Error **errp);
 
-void fd_start_incoming_migration(const char *path, Error **errp);
-
-void fd_start_outgoing_migration(MigrationState *s, const char *fdname, Error **errp);
-
 void rdma_start_outgoing_migration(void *opaque, const char *host_port, Error **errp);
 
 void rdma_start_incoming_migration(const char *host_port, Error **errp);
migration/fd.c +1 -1
index fba3852..78ebd5b 100644
@@ -18,7 +18,7 @@
 #include "qapi/error.h"
 #include "qemu-common.h"
 #include "migration/channel.h"
-#include "migration/migration.h"
+#include "migration/fd.h"
 #include "monitor/monitor.h"
 #include "io/channel-util.h"
 #include "trace.h"
migration/migration.c +1 -0
index 076c42a..a608faa 100644
@@ -22,6 +22,7 @@
 #include "migration/state.h"
 #include "migration/init.h"
 #include "migration/exec.h"
+#include "migration/fd.h"
 #include "migration/migration.h"
 #include "migration/qemu-file.h"
 #include "sysemu/sysemu.h"
Signature · 1 line
2.9.3
#12 lore raw

PATCH 7/19 migration: Export socket.c functions in its own file

In reply to Juan Quintela
---
 include/migration/migration.h |  8 --------
 include/migration/socket.h    | 25 +++++++++++++++++++++++++
 migration/migration.c         |  1 +
 migration/socket.c            |  1 +
 4 files changed, 27 insertions(+), 8 deletions(-)
 create mode 100644 include/migration/socket.h
include/migration/migration.h +0 -8
index 077b75b..0c6dae5 100644
@@ -194,14 +194,6 @@ void migration_tls_channel_connect(MigrationState *s,
 
 uint64_t migrate_max_downtime(void);
 
-void tcp_start_incoming_migration(const char *host_port, Error **errp);
-
-void tcp_start_outgoing_migration(MigrationState *s, const char *host_port, Error **errp);
-
-void unix_start_incoming_migration(const char *path, Error **errp);
-
-void unix_start_outgoing_migration(MigrationState *s, const char *path, Error **errp);
-
 void rdma_start_outgoing_migration(void *opaque, const char *host_port, Error **errp);
 
 void rdma_start_incoming_migration(const char *host_port, Error **errp);
include/migration/socket.h new file +25 -0
new file mode 100644
index 0000000..800fde1
@@ -0,0 +1,25 @@
+/*
+ * QEMU live migration socket functions
+ *
+ * Copyright IBM, Corp. 2008
+ *
+ * Authors:
+ *  Anthony Liguori   <[email protected]>
+ *
+ * This work is licensed under the terms of the GNU GPL, version 2.  See
+ * the COPYING file in the top-level directory.
+ *
+ */
+
+#ifndef QEMU_MIGRATION_SOCKET_H
+#define QEMU_MIGRATION_SOCKET_H
+void tcp_start_incoming_migration(const char *host_port, Error **errp);
+
+void tcp_start_outgoing_migration(MigrationState *s, const char *host_port,
+                                  Error **errp);
+
+void unix_start_incoming_migration(const char *path, Error **errp);
+
+void unix_start_outgoing_migration(MigrationState *s, const char *path,
+                                   Error **errp);
+#endif
migration/migration.c +1 -0
index a608faa..181839b 100644
@@ -23,6 +23,7 @@
 #include "migration/init.h"
 #include "migration/exec.h"
 #include "migration/fd.h"
+#include "migration/socket.h"
 #include "migration/migration.h"
 #include "migration/qemu-file.h"
 #include "sysemu/sysemu.h"
migration/socket.c +1 -0
index b06cde3..71a8439 100644
@@ -20,6 +20,7 @@
 #include "qemu/error-report.h"
 #include "qapi/error.h"
 #include "migration/channel.h"
+#include "migration/socket.h"
 #include "migration/migration.h"
 #include "migration/qemu-file.h"
 #include "io/channel-socket.h"
Signature · 1 line
2.9.3
#13 lore raw

Re: [Qemu-devel] [PATCH 07/19] migration: Export socket.c functions in its own file

Quoted 18 lines · * Juan Quintela ([email protected]) wrote:
---
 include/migration/migration.h |  8 --------
 include/migration/socket.h    | 25 +++++++++++++++++++++++++
 migration/migration.c         |  1 +
 migration/socket.c            |  1 +
 4 files changed, 27 insertions(+), 8 deletions(-)
 create mode 100644 include/migration/socket.h
include/migration/migration.h +0 -1
index 077b75b..0c6dae5 100644
@@ -194,14 +194,6 @@ void migration_tls_channel_connect(MigrationState *s,
 
 uint64_t migrate_max_downtime(void);
 
-void tcp_start_incoming_migration(const char *host_port, Error **errp);

include/migration/migration.h void migration_tls_channel_connect(MigrationState *s, · line 199

Quoted 10 lines
include/migration/migration.h +0 -7
-
-void tcp_start_outgoing_migration(MigrationState *s, const char *host_port, Error **errp);
-
-void unix_start_incoming_migration(const char *path, Error **errp);
-
-void unix_start_outgoing_migration(MigrationState *s, const char *path, Error **errp);
-
 void rdma_start_outgoing_migration(void *opaque, const char *host_port, Error **errp);
 
 void rdma_start_incoming_migration(const char *host_port, Error **errp);

Have you considered a header with just the transports in it?

There doesn't seem to be that much point with one with just the rdma's in, and one iwth just the tcp's in etc.

Dave

Quoted 58 lines
include/migration/socket.h new file +25 -0
new file mode 100644
index 0000000..800fde1
@@ -0,0 +1,25 @@
+/*
+ * QEMU live migration socket functions
+ *
+ * Copyright IBM, Corp. 2008
+ *
+ * Authors:
+ *  Anthony Liguori   <[email protected]>
+ *
+ * This work is licensed under the terms of the GNU GPL, version 2.  See
+ * the COPYING file in the top-level directory.
+ *
+ */
+
+#ifndef QEMU_MIGRATION_SOCKET_H
+#define QEMU_MIGRATION_SOCKET_H
+void tcp_start_incoming_migration(const char *host_port, Error **errp);
+
+void tcp_start_outgoing_migration(MigrationState *s, const char *host_port,
+                                  Error **errp);
+
+void unix_start_incoming_migration(const char *path, Error **errp);
+
+void unix_start_outgoing_migration(MigrationState *s, const char *path,
+                                   Error **errp);
+#endif
migration/migration.c +1 -0
index a608faa..181839b 100644
@@ -23,6 +23,7 @@
 #include "migration/init.h"
 #include "migration/exec.h"
 #include "migration/fd.h"
+#include "migration/socket.h"
 #include "migration/migration.h"
 #include "migration/qemu-file.h"
 #include "sysemu/sysemu.h"
migration/socket.c +1 -0
index b06cde3..71a8439 100644
@@ -20,6 +20,7 @@
 #include "qemu/error-report.h"
 #include "qapi/error.h"
 #include "migration/channel.h"
+#include "migration/socket.h"
 #include "migration/migration.h"
 #include "migration/qemu-file.h"
 #include "io/channel-socket.h"
Signature · 1 line
2.9.3

--
Dr. David Alan Gilbert / [email protected] / Manchester, UK

#14 lore raw

Re: [Qemu-devel] [PATCH 07/19] migration: Export socket.c functions in its own file

Quoted 31 lines · Dr. David Alan Gilbert
Quoted 30 lines · * Juan Quintela ([email protected]) wrote:
---
 include/migration/migration.h |  8 --------
 include/migration/socket.h    | 25 +++++++++++++++++++++++++
 migration/migration.c         |  1 +
 migration/socket.c            |  1 +
 4 files changed, 27 insertions(+), 8 deletions(-)
 create mode 100644 include/migration/socket.h
include/migration/migration.h +0 -8
index 077b75b..0c6dae5 100644
@@ -194,14 +194,6 @@ void migration_tls_channel_connect(MigrationState *s,
 
 uint64_t migrate_max_downtime(void);
 
-void tcp_start_incoming_migration(const char *host_port, Error **errp);
-
-void tcp_start_outgoing_migration(MigrationState *s, const char
 *host_port, Error **errp);
-
-void unix_start_incoming_migration(const char *path, Error **errp);
-
-void unix_start_outgoing_migration(MigrationState *s, const char
 *path, Error **errp);
-
 void rdma_start_outgoing_migration(void *opaque, const char

*host_port, Error **errp);

Quoted 6 lines
Quoted 1 line

void rdma_start_incoming_migration(const char *host_port, Error **errp);

Have you considered a header with just the transports in it?

There doesn't seem to be that much point with one with just the rdma's in, and one iwth just the tcp's in etc.

In the future, the transports should be using module_type() and no need of this stuff at all. It should make easier to compile transports out (famous last words).

Later, Juan.

#15 lore raw

PATCH 8/19 migration: Export tls.c functions in its own file

In reply to Juan Quintela

Just for the functions exported from tls.c. Notice that we can't remove the migration/migration.h include from tls.c because it access directly MigrationState for the tls params.

---
 include/migration/migration.h |  9 ---------
 include/migration/tls.h       | 27 +++++++++++++++++++++++++++
 migration/channel.c           |  1 +
 migration/migration.c         |  1 -
 migration/tls.c               |  1 +
 5 files changed, 29 insertions(+), 10 deletions(-)
 create mode 100644 include/migration/tls.h
include/migration/migration.h +0 -9
index 0c6dae5..d6f2e94 100644
@@ -183,15 +183,6 @@ void migrate_set_state(int *state, int old_state, int new_state);
 
 void migration_fd_process_incoming(QEMUFile *f);
 
-void migration_tls_channel_process_incoming(MigrationState *s,
-                                            QIOChannel *ioc,
-                                            Error **errp);
-
-void migration_tls_channel_connect(MigrationState *s,
-                                   QIOChannel *ioc,
-                                   const char *hostname,
-                                   Error **errp);
-
 uint64_t migrate_max_downtime(void);
 
 void rdma_start_outgoing_migration(void *opaque, const char *host_port, Error **errp);
include/migration/tls.h new file +27 -0
new file mode 100644
index 0000000..1d63263
@@ -0,0 +1,27 @@
+/*
+ * QEMU live migration tls functions
+ *
+ * Copyright IBM, Corp. 2008
+ *
+ * Authors:
+ *  Anthony Liguori   <[email protected]>
+ *
+ * This work is licensed under the terms of the GNU GPL, version 2.  See
+ * the COPYING file in the top-level directory.
+ *
+ */
+
+#ifndef QEMU_MIGRATION_TLS_H
+#define QEMU_MIGRATION_TLS_H
+
+#include "io/channel.h"
+
+void migration_tls_channel_process_incoming(MigrationState *s,
+                                            QIOChannel *ioc,
+                                            Error **errp);
+
+void migration_tls_channel_connect(MigrationState *s,
+                                   QIOChannel *ioc,
+                                   const char *hostname,
+                                   Error **errp);
+#endif
migration/channel.c +1 -0
index 6f11a1a..10416e0 100644
@@ -15,6 +15,7 @@
 
 #include "qemu/osdep.h"
 #include "migration/channel.h"
+#include "migration/tls.h"
 #include "migration/migration.h"
 #include "trace.h"
 #include "qapi/error.h"
migration/migration.c +0 -1
index 181839b..ce34be5 100644
@@ -42,7 +42,6 @@
 #include "exec/memory.h"
 #include "exec/address-spaces.h"
 #include "io/channel-buffer.h"
-#include "io/channel-tls.h"
 #include "migration/colo.h"
 
 #define MAX_THROTTLE  (32 << 20)      /* Migration transfer speed throttling */
migration/tls.c +1 -0
index 2b28ebd..b9e1791 100644
@@ -21,6 +21,7 @@
 #include "qemu/osdep.h"
 #include "migration/channel.h"
 #include "migration/migration.h"
+#include "migration/tls.h"
 #include "io/channel-tls.h"
 #include "crypto/tlscreds.h"
 #include "qemu/error-report.h"
Signature · 1 line
2.9.3
#16 lore raw

PATCH 9/19 migration: Create block capabilities for shared and enable

In reply to Juan Quintela

This two capabilites were added through the command line. Notice that we just created them. This is just the boilerplate.

---
 include/migration/migration.h |  3 +++
 migration/migration.c         | 36 ++++++++++++++++++++++++++++++++++++
 qapi-schema.json              |  7 ++++++-
 3 files changed, 45 insertions(+), 1 deletion(-)
include/migration/migration.h +3 -0
index d6f2e94..5c78ae1 100644
@@ -242,6 +242,9 @@ bool migrate_colo_enabled(void);
 
 int64_t xbzrle_cache_resize(int64_t new_size);
 
+bool migrate_use_block_enabled(void);
+bool migrate_use_block_shared(void);
+
 bool migrate_use_compression(void);
 int migrate_compress_level(void);
 int migrate_compress_threads(void);
migration/migration.c +36 -0
index ce34be5..2f10657 100644
@@ -1151,6 +1151,16 @@ bool migration_is_blocked(Error **errp)
     return false;
 }
 
+static void migrate_set_block_shared(MigrationState *s)
+{
+    s->enabled_capabilities[MIGRATION_CAPABILITY_BLOCK_SHARED] = true;
+}
+
+static void migrate_set_block_enabled(MigrationState *s)
+{
+    s->enabled_capabilities[MIGRATION_CAPABILITY_BLOCK_ENABLED] = true;
+}
+
 void qmp_migrate(const char *uri, bool has_blk, bool blk,
                  bool has_inc, bool inc, bool has_detach, bool detach,
                  Error **errp)
@@ -1180,6 +1190,14 @@ void qmp_migrate(const char *uri, bool has_blk, bool blk,
 
     s = migrate_init(&params);
 
+    if (has_blk && blk) {
+        migrate_set_block_enabled(s);
+    }
+
+    if (has_inc && inc) {
+        migrate_set_block_shared(s);
+    }
+
     if (strstart(uri, "tcp:", &p)) {
         tcp_start_outgoing_migration(s, p, &local_err);
 #ifdef CONFIG_RDMA
@@ -1375,6 +1393,24 @@ int64_t migrate_xbzrle_cache_size(void)
     return s->xbzrle_cache_size;
 }
 
+bool migrate_use_block_enabled(void)
+{
+    MigrationState *s;
+
+    s = migrate_get_current();
+
+    return s->enabled_capabilities[MIGRATION_CAPABILITY_BLOCK_ENABLED];
+}
+
+bool migrate_use_block_shared(void)
+{
+    MigrationState *s;
+
+    s = migrate_get_current();
+
+    return s->enabled_capabilities[MIGRATION_CAPABILITY_BLOCK_SHARED];
+}
+
 /* migration thread support */
 /*
  * Something bad happened to the RP stream, mark an error
qapi-schema.json +6 -1
index 01b087f..e963bb3 100644
@@ -894,11 +894,16 @@
 # @release-ram: if enabled, qemu will free the migrated ram pages on the source
 #        during postcopy-ram migration. (since 2.9)
 #
+# @block-enabled: enable block migration (Since 2.10)
+#
+# @block-shared: enable block shared migration (Since 2.10)
+#
 # Since: 1.2
 ##
 { 'enum': 'MigrationCapability',
   'data': ['xbzrle', 'rdma-pin-all', 'auto-converge', 'zero-blocks',
-           'compress', 'events', 'postcopy-ram', 'x-colo', 'release-ram'] }
+           'compress', 'events', 'postcopy-ram', 'x-colo', 'release-ram',
+           'block-enabled', 'block-shared' ] }
 
 ##
 # @MigrationCapabilityStatus:
Signature · 1 line
2.9.3
Reviewed-by on v1 9/19
#17 lore raw

Re: [Qemu-devel] [PATCH 09/19] migration: Create block capabilities for shared and enable

Quoted 1 line · Juan Quintela

This two capabilites were added through the command line. Notice that

s/This/These/
s/capabilites/capabilities/

Quoted 8 lines

we just created them. This is just the boilerplate.

---
 include/migration/migration.h |  3 +++
 migration/migration.c         | 36 ++++++++++++++++++++++++++++++++++++
 qapi-schema.json              |  7 ++++++-
 3 files changed, 45 insertions(+), 1 deletion(-)

I think this is a nice cleanup, even if it is exposing the internal block migration (the 'migrate -b' stuff) that we really don't like (it is one of the things causing grief at the 2.9-rc4 stage), because users should be favoring NBD migration over internal block migration these days.

Signature · 3 lines
Eric Blake, Principal Software Engineer
Red Hat, Inc.           +1-919-301-3266
Virtualization:  qemu.org | libvirt.org
#18 lore raw

Re: [Qemu-devel] [PATCH 09/19] migration: Create block capabilities for shared and enable

Quoted 15 lines · Eric Blake
Quoted 1 line · Juan Quintela

This two capabilites were added through the command line. Notice that

s/This/These/
s/capabilites/capabilities/

Quoted 8 lines

we just created them. This is just the boilerplate.

---
 include/migration/migration.h |  3 +++
 migration/migration.c         | 36 ++++++++++++++++++++++++++++++++++++
 qapi-schema.json              |  7 ++++++-
 3 files changed, 45 insertions(+), 1 deletion(-)
Quoted 4 lines

I think this is a nice cleanup, even if it is exposing the internal block migration (the 'migrate -b' stuff) that we really don't like (it is one of the things causing grief at the 2.9-rc4 stage), because users should be favoring NBD migration over internal block migration these days.

I am 1st in the queue to remove it, but each time that we talk about removing it, somebody appears to came to fix it :-p

So, if it has to stay, just update it with the times.

Quoted 1 line
#19 lore raw

PATCH 10/19 migration: Remove use of old MigrationParams

In reply to Juan Quintela

We have change in the previous patch to use migration capabilities for it. Notice that we continue using the old command line flags from migrate command from the time being. Remove the set_params method as now it is empty.

---
 include/migration/migration.h |  2 --
 migration/block.c             | 17 ++---------------
 migration/colo.c              |  3 ---
 migration/migration.c         |  8 +++++---
 migration/savevm.c            |  2 --
 5 files changed, 7 insertions(+), 25 deletions(-)
include/migration/migration.h +0 -2
index 5c78ae1..09d3188 100644
@@ -41,8 +41,6 @@
 extern int only_migratable;
 
 struct MigrationParams {
-    bool blk;
-    bool shared;
 };
 
 /* Messages sent on the return path from destination to source */
migration/block.c +2 -15
index 7734ff7..9490343 100644
@@ -94,9 +94,6 @@ typedef struct BlkMigBlock {
 } BlkMigBlock;
 
 typedef struct BlkMigState {
-    /* Written during setup phase.  Can be read without a lock.  */
-    int blk_enable;
-    int shared_base;
     QSIMPLEQ_HEAD(bmds_list, BlkMigDevState) bmds_list;
     int64_t total_sector_sum;
     bool zero_blocks;
@@ -425,7 +422,7 @@ static int init_blk_migration(QEMUFile *f)
         bmds->bulk_completed = 0;
         bmds->total_sectors = sectors;
         bmds->completed_sectors = 0;
-        bmds->shared_base = block_mig_state.shared_base;
+        bmds->shared_base = migrate_use_block_shared();
 
         assert(i < num_bs);
         bmds_bs[i].bmds = bmds;
@@ -963,22 +960,12 @@ static int block_load(QEMUFile *f, void *opaque, int version_id)
     return 0;
 }
 
-static void block_set_params(const MigrationParams *params, void *opaque)
-{
-    block_mig_state.blk_enable = params->blk;
-    block_mig_state.shared_base = params->shared;
-
-    /* shared base means that blk_enable = 1 */
-    block_mig_state.blk_enable |= params->shared;
-}
-
 static bool block_is_active(void *opaque)
 {
-    return block_mig_state.blk_enable == 1;
+    return migrate_use_block_enabled();
 }
 
 static SaveVMHandlers savevm_block_handlers = {
-    .set_params = block_set_params,
     .save_live_setup = block_save_setup,
     .save_live_iterate = block_save_iterate,
     .save_live_complete_precopy = block_save_complete,
migration/colo.c +0 -3
index eec1959..4c2365e 100644
@@ -333,9 +333,6 @@ static int colo_do_checkpoint_transaction(MigrationState *s,
         goto out;
     }
 
-    /* Disable block migration */
-    s->params.blk = 0;
-    s->params.shared = 0;
     qemu_savevm_state_header(fb);
     qemu_savevm_state_begin(fb, &s->params);
     qemu_mutex_lock_iothread();
migration/migration.c +5 -3
index 2f10657..39b4a41 100644
@@ -743,6 +743,10 @@ void qmp_migrate_set_capabilities(MigrationCapabilityStatusList *params,
         s->enabled_capabilities[cap->value->capability] = cap->value->state;
     }
 
+    if (s->enabled_capabilities[MIGRATION_CAPABILITY_BLOCK_SHARED]) {
+        s->enabled_capabilities[MIGRATION_CAPABILITY_BLOCK_ENABLED] = true;
+    }
+
     if (migrate_postcopy_ram()) {
         if (migrate_use_compression()) {
             /* The decompression threads asynchronously write into RAM
@@ -1170,9 +1174,6 @@ void qmp_migrate(const char *uri, bool has_blk, bool blk,
     MigrationParams params;
     const char *p;
 
-    params.blk = has_blk && blk;
-    params.shared = has_inc && inc;
-
     if (migration_is_setup_or_active(s->state) ||
         s->state == MIGRATION_STATUS_CANCELLING ||
         s->state == MIGRATION_STATUS_COLO) {
@@ -1195,6 +1196,7 @@ void qmp_migrate(const char *uri, bool has_blk, bool blk,
     }
 
     if (has_inc && inc) {
+        migrate_set_block_enabled(s);
         migrate_set_block_shared(s);
     }
 
migration/savevm.c +0 -2
index c47b209..c4435e1 100644
@@ -1237,8 +1237,6 @@ static int qemu_savevm_state(QEMUFile *f, Error **errp)
 {
     int ret;
     MigrationParams params = {
-        .blk = 0,
-        .shared = 0
     };
     MigrationState *ms = migrate_init(&params);
     MigrationStatus status;
Signature · 1 line
2.9.3
#20 lore raw

Re: [Qemu-devel] [PATCH 10/19] migration: Remove use of old MigrationParams

Quoted 19 lines · * Juan Quintela ([email protected]) wrote:

We have change in the previous patch to use migration capabilities for it. Notice that we continue using the old command line flags from migrate command from the time being. Remove the set_params method as now it is empty.

---
 include/migration/migration.h |  2 --
 migration/block.c             | 17 ++---------------
 migration/colo.c              |  3 ---
 migration/migration.c         |  8 +++++---
 migration/savevm.c            |  2 --
 5 files changed, 7 insertions(+), 25 deletions(-)
include/migration/migration.h +0 -0
index 5c78ae1..09d3188 100644

include/migration/migration.h line 44

Quoted 6 lines
include/migration/migration.h +0 -2
@@ -41,8 +41,6 @@
 extern int only_migratable;
 
 struct MigrationParams {
-    bool blk;
-    bool shared;
 };

I'm not sure that's portable C - some suggests that empty struct's are a GNU addition.
I suggest either leaving them here, or merging this with the next patch.

Dave

Quoted 111 lines
include/migration/migration.h +0 -0
 /* Messages sent on the return path from destination to source */
migration/block.c +2 -15
index 7734ff7..9490343 100644
@@ -94,9 +94,6 @@ typedef struct BlkMigBlock {
 } BlkMigBlock;
 
 typedef struct BlkMigState {
-    /* Written during setup phase.  Can be read without a lock.  */
-    int blk_enable;
-    int shared_base;
     QSIMPLEQ_HEAD(bmds_list, BlkMigDevState) bmds_list;
     int64_t total_sector_sum;
     bool zero_blocks;
@@ -425,7 +422,7 @@ static int init_blk_migration(QEMUFile *f)
         bmds->bulk_completed = 0;
         bmds->total_sectors = sectors;
         bmds->completed_sectors = 0;
-        bmds->shared_base = block_mig_state.shared_base;
+        bmds->shared_base = migrate_use_block_shared();
 
         assert(i < num_bs);
         bmds_bs[i].bmds = bmds;
@@ -963,22 +960,12 @@ static int block_load(QEMUFile *f, void *opaque, int version_id)
     return 0;
 }
 
-static void block_set_params(const MigrationParams *params, void *opaque)
-{
-    block_mig_state.blk_enable = params->blk;
-    block_mig_state.shared_base = params->shared;
-
-    /* shared base means that blk_enable = 1 */
-    block_mig_state.blk_enable |= params->shared;
-}
-
 static bool block_is_active(void *opaque)
 {
-    return block_mig_state.blk_enable == 1;
+    return migrate_use_block_enabled();
 }
 
 static SaveVMHandlers savevm_block_handlers = {
-    .set_params = block_set_params,
     .save_live_setup = block_save_setup,
     .save_live_iterate = block_save_iterate,
     .save_live_complete_precopy = block_save_complete,
migration/colo.c +0 -3
index eec1959..4c2365e 100644
@@ -333,9 +333,6 @@ static int colo_do_checkpoint_transaction(MigrationState *s,
         goto out;
     }
 
-    /* Disable block migration */
-    s->params.blk = 0;
-    s->params.shared = 0;
     qemu_savevm_state_header(fb);
     qemu_savevm_state_begin(fb, &s->params);
     qemu_mutex_lock_iothread();
migration/migration.c +5 -3
index 2f10657..39b4a41 100644
@@ -743,6 +743,10 @@ void qmp_migrate_set_capabilities(MigrationCapabilityStatusList *params,
         s->enabled_capabilities[cap->value->capability] = cap->value->state;
     }
 
+    if (s->enabled_capabilities[MIGRATION_CAPABILITY_BLOCK_SHARED]) {
+        s->enabled_capabilities[MIGRATION_CAPABILITY_BLOCK_ENABLED] = true;
+    }
+
     if (migrate_postcopy_ram()) {
         if (migrate_use_compression()) {
             /* The decompression threads asynchronously write into RAM
@@ -1170,9 +1174,6 @@ void qmp_migrate(const char *uri, bool has_blk, bool blk,
     MigrationParams params;
     const char *p;
 
-    params.blk = has_blk && blk;
-    params.shared = has_inc && inc;
-
     if (migration_is_setup_or_active(s->state) ||
         s->state == MIGRATION_STATUS_CANCELLING ||
         s->state == MIGRATION_STATUS_COLO) {
@@ -1195,6 +1196,7 @@ void qmp_migrate(const char *uri, bool has_blk, bool blk,
     }
 
     if (has_inc && inc) {
+        migrate_set_block_enabled(s);
         migrate_set_block_shared(s);
     }
 
migration/savevm.c +0 -2
index c47b209..c4435e1 100644
@@ -1237,8 +1237,6 @@ static int qemu_savevm_state(QEMUFile *f, Error **errp)
 {
     int ret;
     MigrationParams params = {
-        .blk = 0,
-        .shared = 0
     };
     MigrationState *ms = migrate_init(&params);
     MigrationStatus status;
Signature · 1 line
2.9.3

--
Dr. David Alan Gilbert / [email protected] / Manchester, UK

#21 lore raw

Re: [Qemu-devel] [PATCH 10/19] migration: Remove use of old MigrationParams

Quoted 22 lines · Dr. David Alan Gilbert
Quoted 21 lines · * Juan Quintela ([email protected]) wrote:

We have change in the previous patch to use migration capabilities for it. Notice that we continue using the old command line flags from migrate command from the time being. Remove the set_params method as now it is empty.

---
 include/migration/migration.h |  2 --
 migration/block.c             | 17 ++---------------
 migration/colo.c              |  3 ---
 migration/migration.c         |  8 +++++---
 migration/savevm.c            |  2 --
 5 files changed, 7 insertions(+), 25 deletions(-)
include/migration/migration.h +0 -0
index 5c78ae1..09d3188 100644
@@ -41,8 +41,6 @@
 extern int only_migratable;
 
Quoted 9 lines

include/migration/migration.h line 44

Quoted 4 lines
include/migration/migration.h +0 -2
 struct MigrationParams {
-    bool blk;
-    bool shared;
 };

I'm not sure that's portable C - some suggests that empty struct's are a GNU addition.
I suggest either leaving them here, or merging this with the next patch.

Added an unused bool. I think it is clearer in two patches.

Thanks, Juan.

#22 lore raw

PATCH 11/19 migration: Remove old MigrationParams

In reply to Juan Quintela

Not used anymore after moving block migration to use capabilities.

---
 include/migration/migration.h | 10 +++-------
 include/migration/vmstate.h   |  1 -
 include/qemu/typedefs.h       |  1 -
 include/sysemu/sysemu.h       |  3 +--
 migration/colo.c              |  2 +-
 migration/migration.c         |  8 +++-----
 migration/savevm.c            | 16 +++-------------
 7 files changed, 11 insertions(+), 30 deletions(-)
include/migration/migration.h +3 -7
index 09d3188..3353de1 100644
@@ -40,9 +40,6 @@
 /* for vl.c */
 extern int only_migratable;
 
-struct MigrationParams {
-};
-
 /* Messages sent on the return path from destination to source */
 enum mig_rp_message_type {
     MIG_RP_MSG_INVALID = 0,  /* Must be 0 */
@@ -132,12 +129,10 @@ struct MigrationState
     QEMUBH *cleanup_bh;
     QEMUFile *to_dst_file;
 
-    /* New style params from 'migrate-set-parameters' */
+    /* params from 'migrate-set-parameters' */
     MigrationParameters parameters;
 
     int state;
-    /* Old style params from 'migrate' command */
-    MigrationParams params;
 
     /* State related to return path */
     struct {
@@ -191,7 +186,8 @@ void migrate_fd_error(MigrationState *s, const Error *error);
 
 void migrate_fd_connect(MigrationState *s);
 
-MigrationState *migrate_init(const MigrationParams *params);
+MigrationState *migrate_init(void);
+
 bool migration_is_blocked(Error **errp);
 /* True if outgoing migration has entered postcopy phase */
 bool migration_in_postcopy(void);
include/migration/vmstate.h +0 -1
index 624aa0d..f4c5bed 100644
@@ -37,7 +37,6 @@ typedef int LoadStateHandler(QEMUFile *f, void *opaque, int version_id);
 
 typedef struct SaveVMHandlers {
     /* This runs inside the iothread lock.  */
-    void (*set_params)(const MigrationParams *params, void * opaque);
     SaveStateHandler *save_state;
 
     void (*cleanup)(void *opaque);
include/qemu/typedefs.h +0 -1
index e95f28c..7e6021c 100644
@@ -48,7 +48,6 @@ typedef struct MemoryRegion MemoryRegion;
 typedef struct MemoryRegionCache MemoryRegionCache;
 typedef struct MemoryRegionSection MemoryRegionSection;
 typedef struct MigrationIncomingState MigrationIncomingState;
-typedef struct MigrationParams MigrationParams;
 typedef struct MigrationState MigrationState;
 typedef struct Monitor Monitor;
 typedef struct MonitorDef MonitorDef;
include/sysemu/sysemu.h +1 -2
index 16175f7..5f2f21d 100644
@@ -105,8 +105,7 @@ enum qemu_vm_cmd {
 #define MAX_VM_CMD_PACKAGED_SIZE (1ul << 24)
 
 bool qemu_savevm_state_blocked(Error **errp);
-void qemu_savevm_state_begin(QEMUFile *f,
-                             const MigrationParams *params);
+void qemu_savevm_state_begin(QEMUFile *f);
 void qemu_savevm_state_header(QEMUFile *f);
 int qemu_savevm_state_iterate(QEMUFile *f, bool postcopy);
 void qemu_savevm_state_cleanup(void);
migration/colo.c +1 -1
index 4c2365e..2924602 100644
@@ -334,7 +334,7 @@ static int colo_do_checkpoint_transaction(MigrationState *s,
     }
 
     qemu_savevm_state_header(fb);
-    qemu_savevm_state_begin(fb, &s->params);
+    qemu_savevm_state_begin(fb);
     qemu_mutex_lock_iothread();
     qemu_savevm_state_complete_precopy(fb, false);
     qemu_mutex_unlock_iothread();
migration/migration.c +3 -5
index 39b4a41..9ab66b6 100644
@@ -1058,7 +1058,7 @@ bool migration_is_idle(void)
     return false;
 }
 
-MigrationState *migrate_init(const MigrationParams *params)
+MigrationState *migrate_init(void)
 {
     MigrationState *s = migrate_get_current();
 
@@ -1072,7 +1072,6 @@ MigrationState *migrate_init(const MigrationParams *params)
     s->cleanup_bh = 0;
     s->to_dst_file = NULL;
     s->state = MIGRATION_STATUS_NONE;
-    s->params = *params;
     s->rp_state.from_dst_file = NULL;
     s->rp_state.error = false;
     s->mbps = 0.0;
@@ -1171,7 +1170,6 @@ void qmp_migrate(const char *uri, bool has_blk, bool blk,
 {
     Error *local_err = NULL;
     MigrationState *s = migrate_get_current();
-    MigrationParams params;
     const char *p;
 
     if (migration_is_setup_or_active(s->state) ||
@@ -1189,7 +1187,7 @@ void qmp_migrate(const char *uri, bool has_blk, bool blk,
         return;
     }
 
-    s = migrate_init(&params);
+    s = migrate_init();
 
     if (has_blk && blk) {
         migrate_set_block_enabled(s);
@@ -1917,7 +1915,7 @@ static void *migration_thread(void *opaque)
         qemu_savevm_send_postcopy_advise(s->to_dst_file);
     }
 
-    qemu_savevm_state_begin(s->to_dst_file, &s->params);
+    qemu_savevm_state_begin(s->to_dst_file);
 
     s->setup_time = qemu_clock_get_ms(QEMU_CLOCK_HOST) - setup_start;
     current_active_state = MIGRATION_STATUS_ACTIVE;
migration/savevm.c +3 -13
index c4435e1..96cf6db 100644
@@ -970,21 +970,13 @@ void qemu_savevm_state_header(QEMUFile *f)
 
 }
 
-void qemu_savevm_state_begin(QEMUFile *f,
-                             const MigrationParams *params)
+void qemu_savevm_state_begin(QEMUFile *f)
 {
     SaveStateEntry *se;
     int ret;
 
     trace_savevm_state_begin();
     QTAILQ_FOREACH(se, &savevm_state.handlers, entry) {
-        if (!se->ops || !se->ops->set_params) {
-            continue;
-        }
-        se->ops->set_params(params, se->opaque);
-    }
-
-    QTAILQ_FOREACH(se, &savevm_state.handlers, entry) {
         if (!se->ops || !se->ops->save_live_setup) {
             continue;
         }
@@ -1236,9 +1228,7 @@ void qemu_savevm_state_cleanup(void)
 static int qemu_savevm_state(QEMUFile *f, Error **errp)
 {
     int ret;
-    MigrationParams params = {
-    };
-    MigrationState *ms = migrate_init(&params);
+    MigrationState *ms = migrate_init();
     MigrationStatus status;
     ms->to_dst_file = f;
 
@@ -1249,7 +1239,7 @@ static int qemu_savevm_state(QEMUFile *f, Error **errp)
 
     qemu_mutex_unlock_iothread();
     qemu_savevm_state_header(f);
-    qemu_savevm_state_begin(f, &params);
+    qemu_savevm_state_begin(f);
     qemu_mutex_lock_iothread();
 
     while (qemu_file_get_error(f) == 0) {
Signature · 1 line
2.9.3
#23 lore raw

PATCH 12/19 migration: Remove unneeded includes

In reply to Juan Quintela

I just removed includes that allow me to still compile everything.

---
 include/migration/colo.h  | 3 ---
 migration/block.c         | 7 -------
 migration/colo-comm.c     | 1 -
 migration/colo-failover.c | 1 +
 migration/colo.c          | 2 --
 migration/exec.c          | 1 -
 migration/fd.c            | 1 -
 migration/migration.c     | 5 -----
 migration/postcopy-ram.c  | 2 --
 migration/qemu-file.c     | 4 +---
 migration/ram.c           | 2 --
 migration/rdma.c          | 1 -
 migration/savevm.c        | 5 -----
 13 files changed, 2 insertions(+), 33 deletions(-)
include/migration/colo.h +0 -3
index ba0bb6e..be6beba 100644
@@ -14,9 +14,6 @@
 #define QEMU_COLO_H
 
 #include "qemu-common.h"
-#include "qemu/coroutine_int.h"
-#include "qemu/thread.h"
-#include "qemu/main-loop.h"
 
 bool colo_supported(void);
 void colo_info_init(void);
migration/block.c +0 -7
index 9490343..0722837 100644
@@ -15,17 +15,10 @@
 
 #include "qemu/osdep.h"
 #include "qapi/error.h"
-#include "qemu-common.h"
-#include "block/block.h"
 #include "qemu/error-report.h"
-#include "qemu/main-loop.h"
-#include "hw/hw.h"
 #include "qemu/cutils.h"
-#include "qemu/queue.h"
-#include "qemu/timer.h"
 #include "migration/block.h"
 #include "migration/migration.h"
-#include "sysemu/blockdev.h"
 #include "sysemu/block-backend.h"
 
 #define BLOCK_SIZE                       (1 << 20)
migration/colo-comm.c +0 -1
index 3d91798..4161242 100644
@@ -14,7 +14,6 @@
 #include "qemu/osdep.h"
 #include "migration/migration.h"
 #include "migration/colo.h"
-#include "trace.h"
 
 typedef struct {
      bool colo_requested;
migration/colo-failover.c +1 -0
index cc229f5..1c0025b 100644
@@ -11,6 +11,7 @@
  */
 
 #include "qemu/osdep.h"
+#include "qemu/main-loop.h"
 #include "migration/colo.h"
 #include "migration/failover.h"
 #include "qmp-commands.h"
migration/colo.c +0 -2
index 2924602..d455884 100644
@@ -11,14 +11,12 @@
  */
 
 #include "qemu/osdep.h"
-#include "qemu/timer.h"
 #include "sysemu/sysemu.h"
 #include "migration/migration.h"
 #include "migration/colo.h"
 #include "io/channel-buffer.h"
 #include "trace.h"
 #include "qemu/error-report.h"
-#include "qapi/error.h"
 #include "migration/failover.h"
 #include "replication.h"
 #include "qmp-commands.h"
migration/exec.c +0 -1
index 1a2d5c2..7939c95 100644
@@ -19,7 +19,6 @@
 
 #include "qemu/osdep.h"
 #include "qapi/error.h"
-#include "qemu-common.h"
 #include "migration/channel.h"
 #include "migration/exec.h"
 #include "io/channel-command.h"
migration/fd.c +0 -1
index 78ebd5b..ae41b06 100644
@@ -16,7 +16,6 @@
 
 #include "qemu/osdep.h"
 #include "qapi/error.h"
-#include "qemu-common.h"
 #include "migration/channel.h"
 #include "migration/fd.h"
 #include "monitor/monitor.h"
migration/migration.c +0 -5
index 9ab66b6..9990c46 100644
@@ -16,7 +16,6 @@
 #include "qemu/osdep.h"
 #include "qemu/cutils.h"
 #include "qemu/error-report.h"
-#include "qemu/main-loop.h"
 #include "migration/blocker.h"
 #include "migration/machine.h"
 #include "migration/state.h"
@@ -30,7 +29,6 @@
 #include "block/block.h"
 #include "qapi/qmp/qerror.h"
 #include "qapi/util.h"
-#include "qemu/sockets.h"
 #include "qemu/rcu.h"
 #include "migration/block.h"
 #include "migration/postcopy-ram.h"
@@ -38,9 +36,6 @@
 #include "qmp-commands.h"
 #include "trace.h"
 #include "qapi-event.h"
-#include "qom/cpu.h"
-#include "exec/memory.h"
-#include "exec/address-spaces.h"
 #include "io/channel-buffer.h"
 #include "migration/colo.h"
 
migration/postcopy-ram.c +0 -2
index 85fd8d7..11b24c6 100644
@@ -17,8 +17,6 @@
  */
 
 #include "qemu/osdep.h"
-
-#include "qemu-common.h"
 #include "migration/migration.h"
 #include "migration/postcopy-ram.h"
 #include "sysemu/sysemu.h"
migration/qemu-file.c +1 -3
index 195fa94..460e536 100644
@@ -26,10 +26,8 @@
 #include "qemu-common.h"
 #include "qemu/error-report.h"
 #include "qemu/iov.h"
-#include "qemu/sockets.h"
-#include "qemu/coroutine.h"
-#include "migration/migration.h"
 #include "migration/qemu-file.h"
+#include "migration/migration.h"
 #include "trace.h"
 
 #define IO_BUF_SIZE 32768
migration/ram.c +0 -2
index 1bd8599..4f49622 100644
@@ -33,13 +33,11 @@
 #include "qemu/cutils.h"
 #include "qemu/bitops.h"
 #include "qemu/bitmap.h"
-#include "qemu/timer.h"
 #include "qemu/main-loop.h"
 #include "migration/xbzrle.h"
 #include "migration/init.h"
 #include "migration/migration.h"
 #include "migration/postcopy-ram.h"
-#include "exec/address-spaces.h"
 #include "migration/page_cache.h"
 #include "qemu/error-report.h"
 #include "trace.h"
migration/rdma.c +0 -1
index 674ccab..94d4840 100644
@@ -19,7 +19,6 @@
 #include "qemu/cutils.h"
 #include "migration/migration.h"
 #include "migration/qemu-file.h"
-#include "exec/cpu-common.h"
 #include "qemu/error-report.h"
 #include "qemu/main-loop.h"
 #include "qemu/sockets.h"
migration/savevm.c +0 -5
index 96cf6db..b03973a 100644
@@ -29,13 +29,10 @@
 #include "qemu/osdep.h"
 #include "cpu.h"
 #include "hw/boards.h"
-#include "hw/hw.h"
-#include "hw/qdev.h"
 #include "hw/xen/xen.h"
 #include "net/net.h"
 #include "monitor/monitor.h"
 #include "sysemu/sysemu.h"
-#include "qemu/timer.h"
 #include "audio/audio.h"
 #include "migration/machine.h"
 #include "migration/migration.h"
@@ -43,11 +40,9 @@
 #include "qapi/qmp/qerror.h"
 #include "qemu/error-report.h"
 #include "qemu/sockets.h"
-#include "qemu/queue.h"
 #include "sysemu/cpus.h"
 #include "qmp-commands.h"
 #include "trace.h"
-#include "qemu/bitops.h"
 #include "qemu/iov.h"
 #include "block/snapshot.h"
 #include "block/qapi.h"
Signature · 1 line
2.9.3
#24 lore raw

PATCH 13/19 migration: Remove qemu-file.h from vmstate.h

In reply to Juan Quintela
---
 include/hw/hw.h             | 1 +
 include/migration/vmstate.h | 3 ---
 migration/block.c           | 1 +
 migration/channel.c         | 1 +
 migration/colo.c            | 1 +
 migration/postcopy-ram.c    | 1 +
 migration/ram.c             | 1 +
 7 files changed, 6 insertions(+), 3 deletions(-)
include/hw/hw.h +1 -0
index e22d4ce..af9eae1 100644
@@ -11,6 +11,7 @@
 #include "exec/memory.h"
 #include "hw/irq.h"
 #include "migration/vmstate.h"
+#include "migration/qemu-file.h"
 #include "qemu/module.h"
 #include "sysemu/reset.h"
 
include/migration/vmstate.h +0 -3
index f4c5bed..1e6fcb5 100644
@@ -27,9 +27,6 @@
 #ifndef QEMU_VMSTATE_H
 #define QEMU_VMSTATE_H
 
-#ifndef CONFIG_USER_ONLY
-#include "migration/qemu-file.h"
-#endif
 #include "migration/qjson.h"
 
 typedef void SaveStateHandler(QEMUFile *f, void *opaque);
migration/block.c +1 -0
index 0722837..e45a42d 100644
@@ -19,6 +19,7 @@
 #include "qemu/cutils.h"
 #include "migration/block.h"
 #include "migration/migration.h"
+#include "migration/qemu-file.h"
 #include "sysemu/block-backend.h"
 
 #define BLOCK_SIZE                       (1 << 20)
migration/channel.c +1 -0
index 10416e0..04a26c5 100644
@@ -17,6 +17,7 @@
 #include "migration/channel.h"
 #include "migration/tls.h"
 #include "migration/migration.h"
+#include "migration/qemu-file.h"
 #include "trace.h"
 #include "qapi/error.h"
 #include "io/channel-tls.h"
migration/colo.c +1 -0
index d455884..e2eaccd 100644
@@ -13,6 +13,7 @@
 #include "qemu/osdep.h"
 #include "sysemu/sysemu.h"
 #include "migration/migration.h"
+#include "migration/qemu-file.h"
 #include "migration/colo.h"
 #include "io/channel-buffer.h"
 #include "trace.h"
migration/postcopy-ram.c +1 -0
index 11b24c6..5aea2ff 100644
@@ -18,6 +18,7 @@
 
 #include "qemu/osdep.h"
 #include "migration/migration.h"
+#include "migration/qemu-file.h"
 #include "migration/postcopy-ram.h"
 #include "sysemu/sysemu.h"
 #include "sysemu/balloon.h"
migration/ram.c +1 -0
index 4f49622..b0759ac 100644
@@ -37,6 +37,7 @@
 #include "migration/xbzrle.h"
 #include "migration/init.h"
 #include "migration/migration.h"
+#include "migration/qemu-file.h"
 #include "migration/postcopy-ram.h"
 #include "migration/page_cache.h"
 #include "qemu/error-report.h"
Signature · 1 line
2.9.3
Reviewed-by on v1 13/19
#25 lore raw

Re: [Qemu-devel] [PATCH 13/19] migration: Remove qemu-file.h from vmstate.h

Quoted 1 line · * Juan Quintela ([email protected]) wrote:
Quoted 99 lines
---
 include/hw/hw.h             | 1 +
 include/migration/vmstate.h | 3 ---
 migration/block.c           | 1 +
 migration/channel.c         | 1 +
 migration/colo.c            | 1 +
 migration/postcopy-ram.c    | 1 +
 migration/ram.c             | 1 +
 7 files changed, 6 insertions(+), 3 deletions(-)
include/hw/hw.h +1 -0
index e22d4ce..af9eae1 100644
@@ -11,6 +11,7 @@
 #include "exec/memory.h"
 #include "hw/irq.h"
 #include "migration/vmstate.h"
+#include "migration/qemu-file.h"
 #include "qemu/module.h"
 #include "sysemu/reset.h"
 
include/migration/vmstate.h +0 -3
index f4c5bed..1e6fcb5 100644
@@ -27,9 +27,6 @@
 #ifndef QEMU_VMSTATE_H
 #define QEMU_VMSTATE_H
 
-#ifndef CONFIG_USER_ONLY
-#include "migration/qemu-file.h"
-#endif
 #include "migration/qjson.h"
 
 typedef void SaveStateHandler(QEMUFile *f, void *opaque);
migration/block.c +1 -0
index 0722837..e45a42d 100644
@@ -19,6 +19,7 @@
 #include "qemu/cutils.h"
 #include "migration/block.h"
 #include "migration/migration.h"
+#include "migration/qemu-file.h"
 #include "sysemu/block-backend.h"
 
 #define BLOCK_SIZE                       (1 << 20)
migration/channel.c +1 -0
index 10416e0..04a26c5 100644
@@ -17,6 +17,7 @@
 #include "migration/channel.h"
 #include "migration/tls.h"
 #include "migration/migration.h"
+#include "migration/qemu-file.h"
 #include "trace.h"
 #include "qapi/error.h"
 #include "io/channel-tls.h"
migration/colo.c +1 -0
index d455884..e2eaccd 100644
@@ -13,6 +13,7 @@
 #include "qemu/osdep.h"
 #include "sysemu/sysemu.h"
 #include "migration/migration.h"
+#include "migration/qemu-file.h"
 #include "migration/colo.h"
 #include "io/channel-buffer.h"
 #include "trace.h"
migration/postcopy-ram.c +1 -0
index 11b24c6..5aea2ff 100644
@@ -18,6 +18,7 @@
 
 #include "qemu/osdep.h"
 #include "migration/migration.h"
+#include "migration/qemu-file.h"
 #include "migration/postcopy-ram.h"
 #include "sysemu/sysemu.h"
 #include "sysemu/balloon.h"
migration/ram.c +1 -0
index 4f49622..b0759ac 100644
@@ -37,6 +37,7 @@
 #include "migration/xbzrle.h"
 #include "migration/init.h"
 #include "migration/migration.h"
+#include "migration/qemu-file.h"
 #include "migration/postcopy-ram.h"
 #include "migration/page_cache.h"
 #include "qemu/error-report.h"
Signature · 1 line
2.9.3

--
Dr. David Alan Gilbert / [email protected] / Manchester, UK

#26 lore raw

PATCH 14/19 migration: Remove vmstate.h from migration.h

In reply to Juan Quintela
---
 include/migration/migration.h | 1 -
 migration/block.c             | 1 +
 migration/colo-comm.c         | 1 +
 migration/migration.c         | 1 +
 migration/ram.c               | 1 +
 5 files changed, 4 insertions(+), 1 deletion(-)
include/migration/migration.h +0 -1
index 3353de1..1451067 100644
@@ -17,7 +17,6 @@
 #include "qapi/qmp/qdict.h"
 #include "qemu-common.h"
 #include "qemu/thread.h"
-#include "migration/vmstate.h"
 #include "qapi-types.h"
 #include "exec/cpu-common.h"
 #include "qemu/coroutine_int.h"
migration/block.c +1 -0
index e45a42d..3048088 100644
@@ -20,6 +20,7 @@
 #include "migration/block.h"
 #include "migration/migration.h"
 #include "migration/qemu-file.h"
+#include "migration/vmstate.h"
 #include "sysemu/block-backend.h"
 
 #define BLOCK_SIZE                       (1 << 20)
migration/colo-comm.c +1 -0
index 4161242..f11fa81 100644
@@ -13,6 +13,7 @@
 
 #include "qemu/osdep.h"
 #include "migration/migration.h"
+#include "migration/vmstate.h"
 #include "migration/colo.h"
 
 typedef struct {
migration/migration.c +1 -0
index 9990c46..c2c25fe 100644
@@ -25,6 +25,7 @@
 #include "migration/socket.h"
 #include "migration/migration.h"
 #include "migration/qemu-file.h"
+#include "migration/vmstate.h"
 #include "sysemu/sysemu.h"
 #include "block/block.h"
 #include "qapi/qmp/qerror.h"
migration/ram.c +1 -0
index b0759ac..49e518f 100644
@@ -38,6 +38,7 @@
 #include "migration/init.h"
 #include "migration/migration.h"
 #include "migration/qemu-file.h"
+#include "migration/vmstate.h"
 #include "migration/postcopy-ram.h"
 #include "migration/page_cache.h"
 #include "qemu/error-report.h"
Signature · 1 line
2.9.3
Reviewed-by on v1 14/19
#27 lore raw

Re: [Qemu-devel] [PATCH 14/19] migration: Remove vmstate.h from migration.h

Quoted 1 line · * Juan Quintela ([email protected]) wrote:

You probably need to do a build of all combos to make sure nothing is depending on the migration.h when it uses VMSTATE_ macros.

Dave

Quoted 71 lines
---
 include/migration/migration.h | 1 -
 migration/block.c             | 1 +
 migration/colo-comm.c         | 1 +
 migration/migration.c         | 1 +
 migration/ram.c               | 1 +
 5 files changed, 4 insertions(+), 1 deletion(-)
include/migration/migration.h +0 -1
index 3353de1..1451067 100644
@@ -17,7 +17,6 @@
 #include "qapi/qmp/qdict.h"
 #include "qemu-common.h"
 #include "qemu/thread.h"
-#include "migration/vmstate.h"
 #include "qapi-types.h"
 #include "exec/cpu-common.h"
 #include "qemu/coroutine_int.h"
migration/block.c +1 -0
index e45a42d..3048088 100644
@@ -20,6 +20,7 @@
 #include "migration/block.h"
 #include "migration/migration.h"
 #include "migration/qemu-file.h"
+#include "migration/vmstate.h"
 #include "sysemu/block-backend.h"
 
 #define BLOCK_SIZE                       (1 << 20)
migration/colo-comm.c +1 -0
index 4161242..f11fa81 100644
@@ -13,6 +13,7 @@
 
 #include "qemu/osdep.h"
 #include "migration/migration.h"
+#include "migration/vmstate.h"
 #include "migration/colo.h"
 
 typedef struct {
migration/migration.c +1 -0
index 9990c46..c2c25fe 100644
@@ -25,6 +25,7 @@
 #include "migration/socket.h"
 #include "migration/migration.h"
 #include "migration/qemu-file.h"
+#include "migration/vmstate.h"
 #include "sysemu/sysemu.h"
 #include "block/block.h"
 #include "qapi/qmp/qerror.h"
migration/ram.c +1 -0
index b0759ac..49e518f 100644
@@ -38,6 +38,7 @@
 #include "migration/init.h"
 #include "migration/migration.h"
 #include "migration/qemu-file.h"
+#include "migration/vmstate.h"
 #include "migration/postcopy-ram.h"
 #include "migration/page_cache.h"
 #include "qemu/error-report.h"
Signature · 1 line
2.9.3

--
Dr. David Alan Gilbert / [email protected] / Manchester, UK

#28 lore raw

PATCH 15/19 migration: Export qemu-file-channel.c functions in its own file

In reply to Juan Quintela
---
 include/migration/qemu-file-channel.h | 22 ++++++++++++++++++++++
 include/migration/qemu-file.h         |  3 ---
 migration/channel.c                   |  2 +-
 migration/colo.c                      |  2 +-
 migration/migration.c                 |  2 +-
 migration/qemu-file-channel.c         |  2 +-
 migration/rdma.c                      |  2 +-
 migration/savevm.c                    |  1 +
 8 files changed, 28 insertions(+), 8 deletions(-)
 create mode 100644 include/migration/qemu-file-channel.h
include/migration/qemu-file-channel.h new file +22 -0
new file mode 100644
index 0000000..bbbf36d
@@ -0,0 +1,22 @@
+/*
+ * QEMU migration blockers
+ *
+ * Copyright IBM, Corp. 2008
+ *
+ * Authors:
+ *  Anthony Liguori   <[email protected]>
+ *
+ * This work is licensed under the terms of the GNU GPL, version 2.  See
+ * the COPYING file in the top-level directory.
+ *
+ */
+
+#ifndef QEMU_FILE_CHANNEL_H
+#define QEMU_FILE_CHANNEL_H
+
+#include "migration/qemu-file.h"
+#include "io/channel.h"
+
+QEMUFile *qemu_fopen_channel_input(QIOChannel *ioc);
+QEMUFile *qemu_fopen_channel_output(QIOChannel *ioc);
+#endif
include/migration/qemu-file.h +0 -3
index 0cd648a..ec73647 100644
@@ -27,7 +27,6 @@
 
 #include "qemu-common.h"
 #include "exec/cpu-common.h"
-#include "io/channel.h"
 
 
 /* Read a chunk of data from a file at the given position.  The pos argument
@@ -119,8 +118,6 @@ typedef struct QEMUFileHooks {
 } QEMUFileHooks;
 
 QEMUFile *qemu_fopen_ops(void *opaque, const QEMUFileOps *ops);
-QEMUFile *qemu_fopen_channel_input(QIOChannel *ioc);
-QEMUFile *qemu_fopen_channel_output(QIOChannel *ioc);
 void qemu_file_set_hooks(QEMUFile *f, const QEMUFileHooks *hooks);
 int qemu_get_fd(QEMUFile *f);
 int qemu_fclose(QEMUFile *f);
migration/channel.c +1 -1
index 04a26c5..e4a0443 100644
@@ -17,7 +17,7 @@
 #include "migration/channel.h"
 #include "migration/tls.h"
 #include "migration/migration.h"
-#include "migration/qemu-file.h"
+#include "migration/qemu-file-channel.h"
 #include "trace.h"
 #include "qapi/error.h"
 #include "io/channel-tls.h"
migration/colo.c +1 -1
index e2eaccd..150ac6a 100644
@@ -13,7 +13,7 @@
 #include "qemu/osdep.h"
 #include "sysemu/sysemu.h"
 #include "migration/migration.h"
-#include "migration/qemu-file.h"
+#include "migration/qemu-file-channel.h"
 #include "migration/colo.h"
 #include "io/channel-buffer.h"
 #include "trace.h"
migration/migration.c +1 -1
index c2c25fe..6e32be0 100644
@@ -24,7 +24,7 @@
 #include "migration/fd.h"
 #include "migration/socket.h"
 #include "migration/migration.h"
-#include "migration/qemu-file.h"
+#include "migration/qemu-file-channel.h"
 #include "migration/vmstate.h"
 #include "sysemu/sysemu.h"
 #include "block/block.h"
migration/qemu-file-channel.c +1 -1
index 45c13f1..87e44ec 100644
@@ -23,7 +23,7 @@
  */
 
 #include "qemu/osdep.h"
-#include "migration/qemu-file.h"
+#include "migration/qemu-file-channel.h"
 #include "io/channel-socket.h"
 #include "qemu/iov.h"
 
migration/rdma.c +1 -1
index 94d4840..d9a2d64 100644
@@ -18,7 +18,7 @@
 #include "qemu-common.h"
 #include "qemu/cutils.h"
 #include "migration/migration.h"
-#include "migration/qemu-file.h"
+#include "migration/qemu-file-channel.h"
 #include "qemu/error-report.h"
 #include "qemu/main-loop.h"
 #include "qemu/sockets.h"
migration/savevm.c +1 -0
index b03973a..1e6cf79 100644
@@ -36,6 +36,7 @@
 #include "audio/audio.h"
 #include "migration/machine.h"
 #include "migration/migration.h"
+#include "migration/qemu-file-channel.h"
 #include "migration/postcopy-ram.h"
 #include "qapi/qmp/qerror.h"
 #include "qemu/error-report.h"
Signature · 1 line
2.9.3
#29 lore raw

PATCH 16/19 migration: Export ram.c functions in its own file

In reply to Juan Quintela
---
 include/migration/migration.h | 36 -----------------------------
 include/migration/ram.h       | 54 +++++++++++++++++++++++++++++++++++++++++++
 migration/migration.c         |  1 +
 migration/postcopy-ram.c      |  1 +
 migration/ram.c               |  1 +
 migration/rdma.c              |  1 +
 migration/savevm.c            |  1 +
 7 files changed, 59 insertions(+), 36 deletions(-)
 create mode 100644 include/migration/ram.h
include/migration/migration.h +0 -36
index 1451067..3e5d106 100644
@@ -192,36 +192,6 @@ bool migration_is_blocked(Error **errp);
 bool migration_in_postcopy(void);
 MigrationState *migrate_get_current(void);
 
-void migrate_compress_threads_create(void);
-void migrate_compress_threads_join(void);
-void migrate_decompress_threads_create(void);
-void migrate_decompress_threads_join(void);
-uint64_t ram_bytes_remaining(void);
-uint64_t ram_bytes_transferred(void);
-uint64_t ram_bytes_total(void);
-uint64_t ram_dirty_sync_count(void);
-uint64_t ram_dirty_pages_rate(void);
-uint64_t ram_postcopy_requests(void);
-void free_xbzrle_decoded_buf(void);
-
-void acct_update_position(QEMUFile *f, size_t size, bool zero);
-
-uint64_t dup_mig_pages_transferred(void);
-uint64_t norm_mig_pages_transferred(void);
-uint64_t xbzrle_mig_bytes_transferred(void);
-uint64_t xbzrle_mig_pages_transferred(void);
-uint64_t xbzrle_mig_pages_overflow(void);
-uint64_t xbzrle_mig_pages_cache_miss(void);
-double xbzrle_mig_cache_miss_rate(void);
-
-void ram_handle_compressed(void *host, uint8_t ch, uint64_t size);
-void ram_debug_dump_bitmap(unsigned long *todump, bool expected);
-/* For outgoing discard bitmap */
-int ram_postcopy_send_discard_bitmap(MigrationState *ms);
-/* For incoming postcopy discard */
-int ram_discard_range(const char *block_name, uint64_t start, size_t length);
-int ram_postcopy_incoming_init(MigrationIncomingState *mis);
-void ram_postcopy_migrated_memory_release(MigrationState *ms);
 
 bool migrate_release_ram(void);
 bool migrate_postcopy_ram(void);
@@ -233,8 +203,6 @@ int migrate_use_xbzrle(void);
 int64_t migrate_xbzrle_cache_size(void);
 bool migrate_colo_enabled(void);
 
-int64_t xbzrle_cache_resize(int64_t new_size);
-
 bool migrate_use_block_enabled(void);
 bool migrate_use_block_shared(void);
 
@@ -273,10 +241,6 @@ size_t ram_control_save_page(QEMUFile *f, ram_addr_t block_offset,
                              ram_addr_t offset, size_t size,
                              uint64_t *bytes_sent);
 
-void migration_page_queue_free(void);
-int ram_save_queue_pages(const char *rbname, ram_addr_t start, ram_addr_t len);
-uint64_t ram_pagesize_summary(void);
-
 PostcopyState postcopy_state_get(void);
 /* Set the state and return the old state */
 PostcopyState postcopy_state_set(PostcopyState new_state);
include/migration/ram.h new file +54 -0

54 lines not on this page · raw message

migration/migration.c +1 -0
index 6e32be0..ba01ea2 100644
@@ -23,6 +23,7 @@
 #include "migration/exec.h"
 #include "migration/fd.h"
 #include "migration/socket.h"
+#include "migration/ram.h"
 #include "migration/migration.h"
 #include "migration/qemu-file-channel.h"
 #include "migration/vmstate.h"
migration/postcopy-ram.c +1 -0
index 5aea2ff..aec40c3 100644
@@ -19,6 +19,7 @@
 #include "qemu/osdep.h"
 #include "migration/migration.h"
 #include "migration/qemu-file.h"
+#include "migration/ram.h"
 #include "migration/postcopy-ram.h"
 #include "sysemu/sysemu.h"
 #include "sysemu/balloon.h"
migration/ram.c +1 -0
index 49e518f..eb1ec1b 100644
@@ -36,6 +36,7 @@
 #include "qemu/main-loop.h"
 #include "migration/xbzrle.h"
 #include "migration/init.h"
+#include "migration/ram.h"
 #include "migration/migration.h"
 #include "migration/qemu-file.h"
 #include "migration/vmstate.h"
migration/rdma.c +1 -0
index d9a2d64..3b06fe6 100644
@@ -18,6 +18,7 @@
 #include "qemu-common.h"
 #include "qemu/cutils.h"
 #include "migration/migration.h"
+#include "migration/ram.h"
 #include "migration/qemu-file-channel.h"
 #include "qemu/error-report.h"
 #include "qemu/main-loop.h"
migration/savevm.c +1 -0
index 1e6cf79..f628d01 100644
@@ -36,6 +36,7 @@
 #include "audio/audio.h"
 #include "migration/machine.h"
 #include "migration/migration.h"
+#include "migration/ram.h"
 #include "migration/qemu-file-channel.h"
 #include "migration/postcopy-ram.h"
 #include "qapi/qmp/qerror.h"
Signature · 1 line
2.9.3
Reviewed-by on v1 16/19
#30 lore raw

Re: [Qemu-devel] [PATCH 16/19] migration: Export ram.c functions in its own file

Quoted 79 lines · * Juan Quintela ([email protected]) wrote:
---
 include/migration/migration.h | 36 -----------------------------
 include/migration/ram.h       | 54 +++++++++++++++++++++++++++++++++++++++++++
 migration/migration.c         |  1 +
 migration/postcopy-ram.c      |  1 +
 migration/ram.c               |  1 +
 migration/rdma.c              |  1 +
 migration/savevm.c            |  1 +
 7 files changed, 59 insertions(+), 36 deletions(-)
 create mode 100644 include/migration/ram.h
include/migration/migration.h +0 -36
index 1451067..3e5d106 100644
@@ -192,36 +192,6 @@ bool migration_is_blocked(Error **errp);
 bool migration_in_postcopy(void);
 MigrationState *migrate_get_current(void);
 
-void migrate_compress_threads_create(void);
-void migrate_compress_threads_join(void);
-void migrate_decompress_threads_create(void);
-void migrate_decompress_threads_join(void);
-uint64_t ram_bytes_remaining(void);
-uint64_t ram_bytes_transferred(void);
-uint64_t ram_bytes_total(void);
-uint64_t ram_dirty_sync_count(void);
-uint64_t ram_dirty_pages_rate(void);
-uint64_t ram_postcopy_requests(void);
-void free_xbzrle_decoded_buf(void);
-
-void acct_update_position(QEMUFile *f, size_t size, bool zero);
-
-uint64_t dup_mig_pages_transferred(void);
-uint64_t norm_mig_pages_transferred(void);
-uint64_t xbzrle_mig_bytes_transferred(void);
-uint64_t xbzrle_mig_pages_transferred(void);
-uint64_t xbzrle_mig_pages_overflow(void);
-uint64_t xbzrle_mig_pages_cache_miss(void);
-double xbzrle_mig_cache_miss_rate(void);
-
-void ram_handle_compressed(void *host, uint8_t ch, uint64_t size);
-void ram_debug_dump_bitmap(unsigned long *todump, bool expected);
-/* For outgoing discard bitmap */
-int ram_postcopy_send_discard_bitmap(MigrationState *ms);
-/* For incoming postcopy discard */
-int ram_discard_range(const char *block_name, uint64_t start, size_t length);
-int ram_postcopy_incoming_init(MigrationIncomingState *mis);
-void ram_postcopy_migrated_memory_release(MigrationState *ms);
 
 bool migrate_release_ram(void);
 bool migrate_postcopy_ram(void);
@@ -233,8 +203,6 @@ int migrate_use_xbzrle(void);
 int64_t migrate_xbzrle_cache_size(void);
 bool migrate_colo_enabled(void);
 
-int64_t xbzrle_cache_resize(int64_t new_size);
-
 bool migrate_use_block_enabled(void);
 bool migrate_use_block_shared(void);
 
@@ -273,10 +241,6 @@ size_t ram_control_save_page(QEMUFile *f, ram_addr_t block_offset,
                              ram_addr_t offset, size_t size,
                              uint64_t *bytes_sent);
 
-void migration_page_queue_free(void);
-int ram_save_queue_pages(const char *rbname, ram_addr_t start, ram_addr_t len);
-uint64_t ram_pagesize_summary(void);
-
 PostcopyState postcopy_state_get(void);
 /* Set the state and return the old state */
 PostcopyState postcopy_state_set(PostcopyState new_state);
include/migration/ram.h new file +0 -0
new file mode 100644
index 0000000..c3653b3

include/migration/ram.h line 7

Quoted 7 lines
include/migration/ram.h new file +7 -0
@@ -0,0 +1,54 @@
+/*
+ * QEMU migration ram
+ *
+ * Copyright IBM, Corp. 2008
+ *
+ * Authors:
+ *  Anthony Liguori   <[email protected]>

Shouldn't that be updated a bit?

Other than that,

Quoted 9 lines
include/migration/ram.h new file +9 -0
+ * This work is licensed under the terms of the GNU GPL, version 2.  See
+ * the COPYING file in the top-level directory.
+ *
+ */
+
+#ifndef QEMU_MIGRATION_RAM_H
+#define QEMU_MIGRATION_RAM_H
+
+#include "qemu-common.h"

include/migration/ram.h line 27

Quoted 10 lines
include/migration/ram.h new file +10 -0
+#include "exec/cpu-common.h"
+
+int64_t xbzrle_cache_resize(int64_t new_size);
+uint64_t dup_mig_pages_transferred(void);
+uint64_t norm_mig_pages_transferred(void);
+uint64_t xbzrle_mig_bytes_transferred(void);
+uint64_t xbzrle_mig_pages_transferred(void);
+uint64_t xbzrle_mig_pages_cache_miss(void);
+double xbzrle_mig_cache_miss_rate(void);
+uint64_t xbzrle_mig_pages_overflow(void);

Most of hese only exist to fill in MigrationInfo's xbzrle_cache states; see get_xbzrle_cache_stats - perhaps it should be moved into ram.c and then just that exposed?

Dave

Quoted 90 lines
include/migration/ram.h new file +27 -0
+uint64_t ram_bytes_transferred(void);
+uint64_t ram_bytes_remaining(void);
+uint64_t ram_dirty_sync_count(void);
+uint64_t ram_dirty_pages_rate(void);
+uint64_t ram_postcopy_requests(void);
+uint64_t ram_bytes_total(void);
+
+void migrate_compress_threads_create(void);
+void migrate_compress_threads_join(void);
+void migrate_decompress_threads_create(void);
+void migrate_decompress_threads_join(void);
+
+uint64_t ram_pagesize_summary(void);
+void migration_page_queue_free(void);
+int ram_save_queue_pages(const char *rbname, ram_addr_t start, ram_addr_t len);
+void acct_update_position(QEMUFile *f, size_t size, bool zero);
+void free_xbzrle_decoded_buf(void);
+void ram_debug_dump_bitmap(unsigned long *todump, bool expected);
+void ram_postcopy_migrated_memory_release(MigrationState *ms);
+/* For outgoing discard bitmap */
+int ram_postcopy_send_discard_bitmap(MigrationState *ms);
+/* For incoming postcopy discard */
+int ram_discard_range(const char *block_name, uint64_t start, size_t length);
+int ram_postcopy_incoming_init(MigrationIncomingState *mis);
+
+void ram_handle_compressed(void *host, uint8_t ch, uint64_t size);
+#endif
migration/migration.c +1 -0
index 6e32be0..ba01ea2 100644
@@ -23,6 +23,7 @@
 #include "migration/exec.h"
 #include "migration/fd.h"
 #include "migration/socket.h"
+#include "migration/ram.h"
 #include "migration/migration.h"
 #include "migration/qemu-file-channel.h"
 #include "migration/vmstate.h"
migration/postcopy-ram.c +1 -0
index 5aea2ff..aec40c3 100644
@@ -19,6 +19,7 @@
 #include "qemu/osdep.h"
 #include "migration/migration.h"
 #include "migration/qemu-file.h"
+#include "migration/ram.h"
 #include "migration/postcopy-ram.h"
 #include "sysemu/sysemu.h"
 #include "sysemu/balloon.h"
migration/ram.c +1 -0
index 49e518f..eb1ec1b 100644
@@ -36,6 +36,7 @@
 #include "qemu/main-loop.h"
 #include "migration/xbzrle.h"
 #include "migration/init.h"
+#include "migration/ram.h"
 #include "migration/migration.h"
 #include "migration/qemu-file.h"
 #include "migration/vmstate.h"
migration/rdma.c +1 -0
index d9a2d64..3b06fe6 100644
@@ -18,6 +18,7 @@
 #include "qemu-common.h"
 #include "qemu/cutils.h"
 #include "migration/migration.h"
+#include "migration/ram.h"
 #include "migration/qemu-file-channel.h"
 #include "qemu/error-report.h"
 #include "qemu/main-loop.h"
migration/savevm.c +1 -0
index 1e6cf79..f628d01 100644
@@ -36,6 +36,7 @@
 #include "audio/audio.h"
 #include "migration/machine.h"
 #include "migration/migration.h"
+#include "migration/ram.h"
 #include "migration/qemu-file-channel.h"
 #include "migration/postcopy-ram.h"
 #include "qapi/qmp/qerror.h"
Signature · 1 line
2.9.3

--
Dr. David Alan Gilbert / [email protected] / Manchester, UK

#31 lore raw

Re: [Qemu-devel] [PATCH 16/19] migration: Export ram.c functions in its own file

Quoted 90 lines · Dr. David Alan Gilbert
Quoted 79 lines · * Juan Quintela ([email protected]) wrote:
---
 include/migration/migration.h | 36 -----------------------------
 include/migration/ram.h       | 54 +++++++++++++++++++++++++++++++++++++++++++
 migration/migration.c         |  1 +
 migration/postcopy-ram.c      |  1 +
 migration/ram.c               |  1 +
 migration/rdma.c              |  1 +
 migration/savevm.c            |  1 +
 7 files changed, 59 insertions(+), 36 deletions(-)
 create mode 100644 include/migration/ram.h
include/migration/migration.h +0 -36
index 1451067..3e5d106 100644
@@ -192,36 +192,6 @@ bool migration_is_blocked(Error **errp);
 bool migration_in_postcopy(void);
 MigrationState *migrate_get_current(void);
 
-void migrate_compress_threads_create(void);
-void migrate_compress_threads_join(void);
-void migrate_decompress_threads_create(void);
-void migrate_decompress_threads_join(void);
-uint64_t ram_bytes_remaining(void);
-uint64_t ram_bytes_transferred(void);
-uint64_t ram_bytes_total(void);
-uint64_t ram_dirty_sync_count(void);
-uint64_t ram_dirty_pages_rate(void);
-uint64_t ram_postcopy_requests(void);
-void free_xbzrle_decoded_buf(void);
-
-void acct_update_position(QEMUFile *f, size_t size, bool zero);
-
-uint64_t dup_mig_pages_transferred(void);
-uint64_t norm_mig_pages_transferred(void);
-uint64_t xbzrle_mig_bytes_transferred(void);
-uint64_t xbzrle_mig_pages_transferred(void);
-uint64_t xbzrle_mig_pages_overflow(void);
-uint64_t xbzrle_mig_pages_cache_miss(void);
-double xbzrle_mig_cache_miss_rate(void);
-
-void ram_handle_compressed(void *host, uint8_t ch, uint64_t size);
-void ram_debug_dump_bitmap(unsigned long *todump, bool expected);
-/* For outgoing discard bitmap */
-int ram_postcopy_send_discard_bitmap(MigrationState *ms);
-/* For incoming postcopy discard */
-int ram_discard_range(const char *block_name, uint64_t start, size_t length);
-int ram_postcopy_incoming_init(MigrationIncomingState *mis);
-void ram_postcopy_migrated_memory_release(MigrationState *ms);
 
 bool migrate_release_ram(void);
 bool migrate_postcopy_ram(void);
@@ -233,8 +203,6 @@ int migrate_use_xbzrle(void);
 int64_t migrate_xbzrle_cache_size(void);
 bool migrate_colo_enabled(void);
 
-int64_t xbzrle_cache_resize(int64_t new_size);
-
 bool migrate_use_block_enabled(void);
 bool migrate_use_block_shared(void);
 
@@ -273,10 +241,6 @@ size_t ram_control_save_page(QEMUFile *f, ram_addr_t block_offset,
                              ram_addr_t offset, size_t size,
                              uint64_t *bytes_sent);
 
-void migration_page_queue_free(void);
-int ram_save_queue_pages(const char *rbname, ram_addr_t start, ram_addr_t len);
-uint64_t ram_pagesize_summary(void);
-
 PostcopyState postcopy_state_get(void);
 /* Set the state and return the old state */
 PostcopyState postcopy_state_set(PostcopyState new_state);
include/migration/ram.h new file +0 -0
new file mode 100644
index 0000000..c3653b3

include/migration/ram.h line 7

Quoted 7 lines
include/migration/ram.h new file +7 -0
@@ -0,0 +1,54 @@
+/*
+ * QEMU migration ram
+ *
+ * Copyright IBM, Corp. 2008
+ *
+ * Authors:
+ *  Anthony Liguori   <[email protected]>

Shouldn't that be updated a bit?

Quoted 1 line

Other than that,

With what?

I can put myself there, but it is just copying a lot of function prototypes, i.e. not as if I had done lot of work there right now.

But I am open to suggestions.

Quoted 14 lines
Quoted 11 lines
include/migration/ram.h new file +11 -0
+ * This work is licensed under the terms of the GNU GPL, version 2.  See
+ * the COPYING file in the top-level directory.
+ *
+ */
+
+#ifndef QEMU_MIGRATION_RAM_H
+#define QEMU_MIGRATION_RAM_H
+
+#include "qemu-common.h"
+#include "exec/cpu-common.h"
+
Quoted 8 lines

include/migration/ram.h line 27

Quoted 8 lines
include/migration/ram.h new file +8 -0
+int64_t xbzrle_cache_resize(int64_t new_size);
+uint64_t dup_mig_pages_transferred(void);
+uint64_t norm_mig_pages_transferred(void);
+uint64_t xbzrle_mig_bytes_transferred(void);
+uint64_t xbzrle_mig_pages_transferred(void);
+uint64_t xbzrle_mig_pages_cache_miss(void);
+double xbzrle_mig_cache_miss_rate(void);
+uint64_t xbzrle_mig_pages_overflow(void);

Will try to take a look at that, but on the other hand, I am trying to get the qmp code out of migration.c in its own file. One can't have everything.

Thanks, Juan.

#32 lore raw

PATCH 17/19 migration: Export rdma.c functions in its own file

In reply to Juan Quintela
---
 include/migration/migration.h |  4 ----
 include/migration/rdma.h      | 22 ++++++++++++++++++++++
 migration/migration.c         |  1 +
 migration/rdma.c              |  1 +
 4 files changed, 24 insertions(+), 4 deletions(-)
 create mode 100644 include/migration/rdma.h
include/migration/migration.h +0 -4
index 3e5d106..64c1ff3 100644
@@ -177,10 +177,6 @@ void migration_fd_process_incoming(QEMUFile *f);
 
 uint64_t migrate_max_downtime(void);
 
-void rdma_start_outgoing_migration(void *opaque, const char *host_port, Error **errp);
-
-void rdma_start_incoming_migration(const char *host_port, Error **errp);
-
 void migrate_fd_error(MigrationState *s, const Error *error);
 
 void migrate_fd_connect(MigrationState *s);
include/migration/rdma.h new file +22 -0
new file mode 100644
index 0000000..d2cf481
@@ -0,0 +1,22 @@
+/*
+ * QEMU migration rdma functions
+ *
+ * Copyright IBM, Corp. 2008
+ *
+ * Authors:
+ *  Anthony Liguori   <[email protected]>
+ *
+ * This work is licensed under the terms of the GNU GPL, version 2.  See
+ * the COPYING file in the top-level directory.
+ *
+ */
+
+#ifndef QEMU_MIGRATION_RDMA_H
+#define QEMU_MIGRATION_RDMA_H
+
+void rdma_start_outgoing_migration(void *opaque, const char *host_port,
+                                   Error **errp);
+
+void rdma_start_incoming_migration(const char *host_port, Error **errp);
+
+#endif
migration/migration.c +1 -0
index ba01ea2..04aa9ad 100644
@@ -23,6 +23,7 @@
 #include "migration/exec.h"
 #include "migration/fd.h"
 #include "migration/socket.h"
+#include "migration/rdma.h"
 #include "migration/ram.h"
 #include "migration/migration.h"
 #include "migration/qemu-file-channel.h"
migration/rdma.c +1 -0
index 3b06fe6..2b4276b 100644
@@ -17,6 +17,7 @@
 #include "qapi/error.h"
 #include "qemu-common.h"
 #include "qemu/cutils.h"
+#include "migration/rdma.h"
 #include "migration/migration.h"
 #include "migration/ram.h"
 #include "migration/qemu-file-channel.h"
Signature · 1 line
2.9.3
#33 lore raw

PATCH 18/19 monitor: move hmp_savevm() to monitor.c

In reply to Juan Quintela

hmp_loadvm is already there, so be consistent.

---
 include/sysemu/sysemu.h | 1 -
 migration/savevm.c      | 5 -----
 monitor.c               | 5 +++++
 3 files changed, 5 insertions(+), 6 deletions(-)
include/sysemu/sysemu.h +0 -1
index 5f2f21d..146a0dc 100644
@@ -75,7 +75,6 @@ void qemu_remove_exit_notifier(Notifier *notify);
 void qemu_add_machine_init_done_notifier(Notifier *notify);
 void qemu_remove_machine_init_done_notifier(Notifier *notify);
 
-void hmp_savevm(Monitor *mon, const QDict *qdict);
 int save_vmstate(Monitor *mon, const char *name);
 int load_vmstate(const char *name);
 void hmp_delvm(Monitor *mon, const QDict *qdict);
migration/savevm.c +0 -5
index f628d01..cbd7e0d 100644
@@ -2156,11 +2156,6 @@ int save_vmstate(Monitor *mon, const char *name)
     return ret;
 }
 
-void hmp_savevm(Monitor *mon, const QDict *qdict)
-{
-    save_vmstate(mon, qdict_get_try_str(qdict, "name"));
-}
-
 void qmp_xen_save_devices_state(const char *filename, Error **errp)
 {
     QEMUFile *f;
monitor.c +5 -0
index ceb0489..2fca4fb 100644
@@ -1854,6 +1854,11 @@ static void hmp_loadvm(Monitor *mon, const QDict *qdict)
     }
 }
 
+static void hmp_savevm(Monitor *mon, const QDict *qdict)
+{
+    save_vmstate(mon, qdict_get_try_str(qdict, "name"));
+}
+
 int monitor_get_fd(Monitor *mon, const char *fdname, Error **errp)
 {
     mon_fd_t *monfd;
Signature · 1 line
2.9.3
#34 lore raw

Re: [Qemu-devel] [PATCH 18/19] monitor: move hmp_savevm() to monitor.c

Quoted 1 line · Juan Quintela

hmp_loadvm is already there, so be consistent.

Can you move both to hmp.c instead?

Paolo

Quoted 52 lines
---
 include/sysemu/sysemu.h | 1 -
 migration/savevm.c      | 5 -----
 monitor.c               | 5 +++++
 3 files changed, 5 insertions(+), 6 deletions(-)
include/sysemu/sysemu.h +0 -1
index 5f2f21d..146a0dc 100644
@@ -75,7 +75,6 @@ void qemu_remove_exit_notifier(Notifier *notify);
 void qemu_add_machine_init_done_notifier(Notifier *notify);
 void qemu_remove_machine_init_done_notifier(Notifier *notify);
 
-void hmp_savevm(Monitor *mon, const QDict *qdict);
 int save_vmstate(Monitor *mon, const char *name);
 int load_vmstate(const char *name);
 void hmp_delvm(Monitor *mon, const QDict *qdict);
migration/savevm.c +0 -5
index f628d01..cbd7e0d 100644
@@ -2156,11 +2156,6 @@ int save_vmstate(Monitor *mon, const char *name)
     return ret;
 }
 
-void hmp_savevm(Monitor *mon, const QDict *qdict)
-{
-    save_vmstate(mon, qdict_get_try_str(qdict, "name"));
-}
-
 void qmp_xen_save_devices_state(const char *filename, Error **errp)
 {
     QEMUFile *f;
monitor.c +5 -0
index ceb0489..2fca4fb 100644
@@ -1854,6 +1854,11 @@ static void hmp_loadvm(Monitor *mon, const QDict *qdict)
     }
 }
 
+static void hmp_savevm(Monitor *mon, const QDict *qdict)
+{
+    save_vmstate(mon, qdict_get_try_str(qdict, "name"));
+}
+
 int monitor_get_fd(Monitor *mon, const char *fdname, Error **errp)
 {
     mon_fd_t *monfd;
#35 lore raw

Re: [Qemu-devel] [PATCH 18/19] monitor: move hmp_savevm() to monitor.c

Quoted 4 lines · Paolo Bonzini
Quoted 1 line · Juan Quintela

hmp_loadvm is already there, so be consistent.

Can you move both to hmp.c instead?

Discussed on irc with David. On my tree is already on hmp.c.

Thanks, Juan.

#36 lore raw

PATCH 19/19 monitor: remove monitor parameter from save_vmstate

In reply to Juan Quintela

load_vmstate() already use error_report, so be consistent.

---
 include/sysemu/sysemu.h  |  2 +-
 migration/savevm.c       | 16 ++++++++--------
 monitor.c                |  2 +-
 replay/replay-snapshot.c |  2 +-
 4 files changed, 11 insertions(+), 11 deletions(-)
include/sysemu/sysemu.h +1 -1
index 146a0dc..d2582fa 100644
@@ -75,7 +75,7 @@ void qemu_remove_exit_notifier(Notifier *notify);
 void qemu_add_machine_init_done_notifier(Notifier *notify);
 void qemu_remove_machine_init_done_notifier(Notifier *notify);
 
-int save_vmstate(Monitor *mon, const char *name);
+int save_vmstate(const char *name);
 int load_vmstate(const char *name);
 void hmp_delvm(Monitor *mon, const QDict *qdict);
 void hmp_info_snapshots(Monitor *mon, const QDict *qdict);
migration/savevm.c +8 -8
index cbd7e0d..36a6002 100644
@@ -2055,7 +2055,7 @@ int qemu_loadvm_state(QEMUFile *f)
     return ret;
 }
 
-int save_vmstate(Monitor *mon, const char *name)
+int save_vmstate(const char *name)
 {
     BlockDriverState *bs, *bs1;
     QEMUSnapshotInfo sn1, *sn = &sn1, old_sn1, *old_sn = &old_sn1;
@@ -2069,8 +2069,8 @@ int save_vmstate(Monitor *mon, const char *name)
     AioContext *aio_context;
 
     if (!bdrv_all_can_snapshot(&bs)) {
-        monitor_printf(mon, "Device '%s' is writable but does not "
-                       "support snapshots.\n", bdrv_get_device_name(bs));
+        error_report("Device '%s' is writable but does not support snapshots.",
+                     bdrv_get_device_name(bs));
         return ret;
     }
 
@@ -2087,7 +2087,7 @@ int save_vmstate(Monitor *mon, const char *name)
 
     bs = bdrv_all_find_vmstate_bs();
     if (bs == NULL) {
-        monitor_printf(mon, "No block device can accept snapshots\n");
+        error_report("No block device can accept snapshots");
         return ret;
     }
     aio_context = bdrv_get_aio_context(bs);
@@ -2096,7 +2096,7 @@ int save_vmstate(Monitor *mon, const char *name)
 
     ret = global_state_store();
     if (ret) {
-        monitor_printf(mon, "Error saving global state\n");
+        error_report("Error saving global state");
         return ret;
     }
     vm_stop(RUN_STATE_SAVE_VM);
@@ -2128,7 +2128,7 @@ int save_vmstate(Monitor *mon, const char *name)
     /* save the VM state */
     f = qemu_fopen_bdrv(bs, 1);
     if (!f) {
-        monitor_printf(mon, "Could not open VM state file\n");
+        error_report("Could not open VM state file");
         goto the_end;
     }
     ret = qemu_savevm_state(f, &local_err);
@@ -2141,8 +2141,8 @@ int save_vmstate(Monitor *mon, const char *name)
 
     ret = bdrv_all_create_snapshot(sn, bs, vm_state_size, &bs);
     if (ret < 0) {
-        monitor_printf(mon, "Error while creating snapshot on '%s'\n",
-                       bdrv_get_device_name(bs));
+        error_report("Error while creating snapshot on '%s'",
+                     bdrv_get_device_name(bs));
         goto the_end;
     }
 
monitor.c +1 -1
index 2fca4fb..9e79a97 100644
@@ -1856,7 +1856,7 @@ static void hmp_loadvm(Monitor *mon, const QDict *qdict)
 
 static void hmp_savevm(Monitor *mon, const QDict *qdict)
 {
-    save_vmstate(mon, qdict_get_try_str(qdict, "name"));
+    save_vmstate(qdict_get_try_str(qdict, "name"));
 }
 
 int monitor_get_fd(Monitor *mon, const char *fdname, Error **errp)
replay/replay-snapshot.c +1 -1
index 65e2d37..8cced46 100644
@@ -64,7 +64,7 @@ void replay_vmstate_init(void)
 {
     if (replay_snapshot) {
         if (replay_mode == REPLAY_MODE_RECORD) {
-            if (save_vmstate(cur_mon, replay_snapshot) != 0) {
+            if (save_vmstate(replay_snapshot) != 0) {
                 error_report("Could not create snapshot for icount record");
                 exit(1);
             }
Signature · 1 line
2.9.3
#37 lore raw

Re: [Qemu-devel] [PATCH 19/19] monitor: remove monitor parameter from save_vmstate

Quoted 1 line · Juan Quintela

load_vmstate() already use error_report, so be consistent.

Better: make both return Error* via an Error** parameter, and add

    hmp_handle_error(mon, &err);

to hmp_savevm and error_report_err(err) on the loading side.

Paolo

Quoted 110 lines
---
 include/sysemu/sysemu.h  |  2 +-
 migration/savevm.c       | 16 ++++++++--------
 monitor.c                |  2 +-
 replay/replay-snapshot.c |  2 +-
 4 files changed, 11 insertions(+), 11 deletions(-)
include/sysemu/sysemu.h +1 -1
index 146a0dc..d2582fa 100644
@@ -75,7 +75,7 @@ void qemu_remove_exit_notifier(Notifier *notify);
 void qemu_add_machine_init_done_notifier(Notifier *notify);
 void qemu_remove_machine_init_done_notifier(Notifier *notify);
 
-int save_vmstate(Monitor *mon, const char *name);
+int save_vmstate(const char *name);
 int load_vmstate(const char *name);
 void hmp_delvm(Monitor *mon, const QDict *qdict);
 void hmp_info_snapshots(Monitor *mon, const QDict *qdict);
migration/savevm.c +8 -8
index cbd7e0d..36a6002 100644
@@ -2055,7 +2055,7 @@ int qemu_loadvm_state(QEMUFile *f)
     return ret;
 }
 
-int save_vmstate(Monitor *mon, const char *name)
+int save_vmstate(const char *name)
 {
     BlockDriverState *bs, *bs1;
     QEMUSnapshotInfo sn1, *sn = &sn1, old_sn1, *old_sn = &old_sn1;
@@ -2069,8 +2069,8 @@ int save_vmstate(Monitor *mon, const char *name)
     AioContext *aio_context;
 
     if (!bdrv_all_can_snapshot(&bs)) {
-        monitor_printf(mon, "Device '%s' is writable but does not "
-                       "support snapshots.\n", bdrv_get_device_name(bs));
+        error_report("Device '%s' is writable but does not support snapshots.",
+                     bdrv_get_device_name(bs));
         return ret;
     }
 
@@ -2087,7 +2087,7 @@ int save_vmstate(Monitor *mon, const char *name)
 
     bs = bdrv_all_find_vmstate_bs();
     if (bs == NULL) {
-        monitor_printf(mon, "No block device can accept snapshots\n");
+        error_report("No block device can accept snapshots");
         return ret;
     }
     aio_context = bdrv_get_aio_context(bs);
@@ -2096,7 +2096,7 @@ int save_vmstate(Monitor *mon, const char *name)
 
     ret = global_state_store();
     if (ret) {
-        monitor_printf(mon, "Error saving global state\n");
+        error_report("Error saving global state");
         return ret;
     }
     vm_stop(RUN_STATE_SAVE_VM);
@@ -2128,7 +2128,7 @@ int save_vmstate(Monitor *mon, const char *name)
     /* save the VM state */
     f = qemu_fopen_bdrv(bs, 1);
     if (!f) {
-        monitor_printf(mon, "Could not open VM state file\n");
+        error_report("Could not open VM state file");
         goto the_end;
     }
     ret = qemu_savevm_state(f, &local_err);
@@ -2141,8 +2141,8 @@ int save_vmstate(Monitor *mon, const char *name)
 
     ret = bdrv_all_create_snapshot(sn, bs, vm_state_size, &bs);
     if (ret < 0) {
-        monitor_printf(mon, "Error while creating snapshot on '%s'\n",
-                       bdrv_get_device_name(bs));
+        error_report("Error while creating snapshot on '%s'",
+                     bdrv_get_device_name(bs));
         goto the_end;
     }
 
monitor.c +1 -1
index 2fca4fb..9e79a97 100644
@@ -1856,7 +1856,7 @@ static void hmp_loadvm(Monitor *mon, const QDict *qdict)
 
 static void hmp_savevm(Monitor *mon, const QDict *qdict)
 {
-    save_vmstate(mon, qdict_get_try_str(qdict, "name"));
+    save_vmstate(qdict_get_try_str(qdict, "name"));
 }
 
 int monitor_get_fd(Monitor *mon, const char *fdname, Error **errp)
replay/replay-snapshot.c +1 -1
index 65e2d37..8cced46 100644
@@ -64,7 +64,7 @@ void replay_vmstate_init(void)
 {
     if (replay_snapshot) {
         if (replay_mode == REPLAY_MODE_RECORD) {
-            if (save_vmstate(cur_mon, replay_snapshot) != 0) {
+            if (save_vmstate(replay_snapshot) != 0) {
                 error_report("Could not create snapshot for icount record");
                 exit(1);
             }
#38 lore raw

Re: [Qemu-devel] [PATCH 19/19] monitor: remove monitor parameter from save_vmstate

Quoted 10 lines · Paolo Bonzini
Quoted 1 line · Juan Quintela

load_vmstate() already use error_report, so be consistent.

Better: make both return Error* via an Error** parameter, and add

    hmp_handle_error(mon, &err);

to hmp_savevm and error_report_err(err) on the loading side.

Not really, loadvm is also a monitor command (I was confusing it with -incoming). So it can use hmp_handle_error too.

Paolo

Quoted 113 lines

Paolo

Quoted 110 lines
---
 include/sysemu/sysemu.h  |  2 +-
 migration/savevm.c       | 16 ++++++++--------
 monitor.c                |  2 +-
 replay/replay-snapshot.c |  2 +-
 4 files changed, 11 insertions(+), 11 deletions(-)
include/sysemu/sysemu.h +1 -1
index 146a0dc..d2582fa 100644
@@ -75,7 +75,7 @@ void qemu_remove_exit_notifier(Notifier *notify);
 void qemu_add_machine_init_done_notifier(Notifier *notify);
 void qemu_remove_machine_init_done_notifier(Notifier *notify);
 
-int save_vmstate(Monitor *mon, const char *name);
+int save_vmstate(const char *name);
 int load_vmstate(const char *name);
 void hmp_delvm(Monitor *mon, const QDict *qdict);
 void hmp_info_snapshots(Monitor *mon, const QDict *qdict);
migration/savevm.c +8 -8
index cbd7e0d..36a6002 100644
@@ -2055,7 +2055,7 @@ int qemu_loadvm_state(QEMUFile *f)
     return ret;
 }
 
-int save_vmstate(Monitor *mon, const char *name)
+int save_vmstate(const char *name)
 {
     BlockDriverState *bs, *bs1;
     QEMUSnapshotInfo sn1, *sn = &sn1, old_sn1, *old_sn = &old_sn1;
@@ -2069,8 +2069,8 @@ int save_vmstate(Monitor *mon, const char *name)
     AioContext *aio_context;
 
     if (!bdrv_all_can_snapshot(&bs)) {
-        monitor_printf(mon, "Device '%s' is writable but does not "
-                       "support snapshots.\n", bdrv_get_device_name(bs));
+        error_report("Device '%s' is writable but does not support snapshots.",
+                     bdrv_get_device_name(bs));
         return ret;
     }
 
@@ -2087,7 +2087,7 @@ int save_vmstate(Monitor *mon, const char *name)
 
     bs = bdrv_all_find_vmstate_bs();
     if (bs == NULL) {
-        monitor_printf(mon, "No block device can accept snapshots\n");
+        error_report("No block device can accept snapshots");
         return ret;
     }
     aio_context = bdrv_get_aio_context(bs);
@@ -2096,7 +2096,7 @@ int save_vmstate(Monitor *mon, const char *name)
 
     ret = global_state_store();
     if (ret) {
-        monitor_printf(mon, "Error saving global state\n");
+        error_report("Error saving global state");
         return ret;
     }
     vm_stop(RUN_STATE_SAVE_VM);
@@ -2128,7 +2128,7 @@ int save_vmstate(Monitor *mon, const char *name)
     /* save the VM state */
     f = qemu_fopen_bdrv(bs, 1);
     if (!f) {
-        monitor_printf(mon, "Could not open VM state file\n");
+        error_report("Could not open VM state file");
         goto the_end;
     }
     ret = qemu_savevm_state(f, &local_err);
@@ -2141,8 +2141,8 @@ int save_vmstate(Monitor *mon, const char *name)
 
     ret = bdrv_all_create_snapshot(sn, bs, vm_state_size, &bs);
     if (ret < 0) {
-        monitor_printf(mon, "Error while creating snapshot on '%s'\n",
-                       bdrv_get_device_name(bs));
+        error_report("Error while creating snapshot on '%s'",
+                     bdrv_get_device_name(bs));
         goto the_end;
     }
 
monitor.c +1 -1
index 2fca4fb..9e79a97 100644
@@ -1856,7 +1856,7 @@ static void hmp_loadvm(Monitor *mon, const QDict *qdict)
 
 static void hmp_savevm(Monitor *mon, const QDict *qdict)
 {
-    save_vmstate(mon, qdict_get_try_str(qdict, "name"));
+    save_vmstate(qdict_get_try_str(qdict, "name"));
 }
 
 int monitor_get_fd(Monitor *mon, const char *fdname, Error **errp)
replay/replay-snapshot.c +1 -1
index 65e2d37..8cced46 100644
@@ -64,7 +64,7 @@ void replay_vmstate_init(void)
 {
     if (replay_snapshot) {
         if (replay_mode == REPLAY_MODE_RECORD) {
-            if (save_vmstate(cur_mon, replay_snapshot) != 0) {
+            if (save_vmstate(replay_snapshot) != 0) {
                 error_report("Could not create snapshot for icount record");
                 exit(1);
             }
#39 lore raw

Re: [Qemu-devel] [PATCH 19/19] monitor: remove monitor parameter from save_vmstate

Quoted 6 lines · Paolo Bonzini
Quoted 5 lines · Paolo Bonzini
Quoted 1 line · Juan Quintela

load_vmstate() already use error_report, so be consistent.

Quoted 8 lines
Quoted 5 lines

Better: make both return Error* via an Error** parameter, and add

    hmp_handle_error(mon, &err);

to hmp_savevm and error_report_err(err) on the loading side.

Not really, loadvm is also a monitor command (I was confusing it with -incoming). So it can use hmp_handle_error too.

ok. I did't kenw about that one.

Thanks.

#40 lore raw

Re: [Qemu-devel] [PATCH 19/19] monitor: remove monitor parameter from save_vmstate

In reply to Paolo Bonzini
Quoted 6 lines · Paolo Bonzini
Quoted 5 lines · Paolo Bonzini
Quoted 1 line · Juan Quintela

load_vmstate() already use error_report, so be consistent.

Quoted 8 lines
Quoted 5 lines

Better: make both return Error* via an Error** parameter, and add

    hmp_handle_error(mon, &err);

to hmp_savevm and error_report_err(err) on the loading side.

Not really, loadvm is also a monitor command (I was confusing it with -incoming). So it can use hmp_handle_error too.

I think that I *understood* (famous last words) how the error should be done on hmp commands. We will see on next respin.

Later, Juan.

#41 lore raw

Re: [Qemu-devel] [PATCH 19/19] monitor: remove monitor parameter from save_vmstate

In reply to Juan Quintela
Quoted 3 lines · * Juan Quintela ([email protected]) wrote:

load_vmstate() already use error_report, so be consistent.

See https://lists.nongnu.org/archive/html/qemu-devel/2017-03/msg03927.html

Dave

Quoted 111 lines
---
 include/sysemu/sysemu.h  |  2 +-
 migration/savevm.c       | 16 ++++++++--------
 monitor.c                |  2 +-
 replay/replay-snapshot.c |  2 +-
 4 files changed, 11 insertions(+), 11 deletions(-)
include/sysemu/sysemu.h +1 -1
index 146a0dc..d2582fa 100644
@@ -75,7 +75,7 @@ void qemu_remove_exit_notifier(Notifier *notify);
 void qemu_add_machine_init_done_notifier(Notifier *notify);
 void qemu_remove_machine_init_done_notifier(Notifier *notify);
 
-int save_vmstate(Monitor *mon, const char *name);
+int save_vmstate(const char *name);
 int load_vmstate(const char *name);
 void hmp_delvm(Monitor *mon, const QDict *qdict);
 void hmp_info_snapshots(Monitor *mon, const QDict *qdict);
migration/savevm.c +8 -8
index cbd7e0d..36a6002 100644
@@ -2055,7 +2055,7 @@ int qemu_loadvm_state(QEMUFile *f)
     return ret;
 }
 
-int save_vmstate(Monitor *mon, const char *name)
+int save_vmstate(const char *name)
 {
     BlockDriverState *bs, *bs1;
     QEMUSnapshotInfo sn1, *sn = &sn1, old_sn1, *old_sn = &old_sn1;
@@ -2069,8 +2069,8 @@ int save_vmstate(Monitor *mon, const char *name)
     AioContext *aio_context;
 
     if (!bdrv_all_can_snapshot(&bs)) {
-        monitor_printf(mon, "Device '%s' is writable but does not "
-                       "support snapshots.\n", bdrv_get_device_name(bs));
+        error_report("Device '%s' is writable but does not support snapshots.",
+                     bdrv_get_device_name(bs));
         return ret;
     }
 
@@ -2087,7 +2087,7 @@ int save_vmstate(Monitor *mon, const char *name)
 
     bs = bdrv_all_find_vmstate_bs();
     if (bs == NULL) {
-        monitor_printf(mon, "No block device can accept snapshots\n");
+        error_report("No block device can accept snapshots");
         return ret;
     }
     aio_context = bdrv_get_aio_context(bs);
@@ -2096,7 +2096,7 @@ int save_vmstate(Monitor *mon, const char *name)
 
     ret = global_state_store();
     if (ret) {
-        monitor_printf(mon, "Error saving global state\n");
+        error_report("Error saving global state");
         return ret;
     }
     vm_stop(RUN_STATE_SAVE_VM);
@@ -2128,7 +2128,7 @@ int save_vmstate(Monitor *mon, const char *name)
     /* save the VM state */
     f = qemu_fopen_bdrv(bs, 1);
     if (!f) {
-        monitor_printf(mon, "Could not open VM state file\n");
+        error_report("Could not open VM state file");
         goto the_end;
     }
     ret = qemu_savevm_state(f, &local_err);
@@ -2141,8 +2141,8 @@ int save_vmstate(Monitor *mon, const char *name)
 
     ret = bdrv_all_create_snapshot(sn, bs, vm_state_size, &bs);
     if (ret < 0) {
-        monitor_printf(mon, "Error while creating snapshot on '%s'\n",
-                       bdrv_get_device_name(bs));
+        error_report("Error while creating snapshot on '%s'",
+                     bdrv_get_device_name(bs));
         goto the_end;
     }
 
monitor.c +1 -1
index 2fca4fb..9e79a97 100644
@@ -1856,7 +1856,7 @@ static void hmp_loadvm(Monitor *mon, const QDict *qdict)
 
 static void hmp_savevm(Monitor *mon, const QDict *qdict)
 {
-    save_vmstate(mon, qdict_get_try_str(qdict, "name"));
+    save_vmstate(qdict_get_try_str(qdict, "name"));
 }
 
 int monitor_get_fd(Monitor *mon, const char *fdname, Error **errp)
replay/replay-snapshot.c +1 -1
index 65e2d37..8cced46 100644
@@ -64,7 +64,7 @@ void replay_vmstate_init(void)
 {
     if (replay_snapshot) {
         if (replay_mode == REPLAY_MODE_RECORD) {
-            if (save_vmstate(cur_mon, replay_snapshot) != 0) {
+            if (save_vmstate(replay_snapshot) != 0) {
                 error_report("Could not create snapshot for icount record");
                 exit(1);
             }
Signature · 1 line
2.9.3

--
Dr. David Alan Gilbert / [email protected] / Manchester, UK