Skip to contentSkip to conversation

Migration mini-cleanup

PATCH Superseded Juan Quintela 4 participants 21 messages May 12, 2017 – May 15, 2017

Subsystems (2)

v3 of 5 Superseded Latest is v5 →

lore
Share & tools
lore
#0 lore raw

v3 cover Migration mini-cleanup

Hi

Due to popular demand, and to make reviews easier, I just split the big cleanup series (41 patches) in small chunks. This chunk just include the easy patches:

- create several include files foo.h for functcions exported from foo.c
- split channel operations in channel.c
- move colo headers to migration/
- split vmstate-types.c from vmstate.c (now it only contains the interpreter)
- untangle qemu-file.h, vmstate.h and migration.h. Now none include the other fix all callers.
- Remove uses of migration.h that are not needed

Please, review.

Thanks, Juan.

Juan Quintela (12):
migration: Create migration/xbzrle.h
migration: Split migration/channel.c for channel operations
migration: Export qemu-file-channel.c functions in its own file
migration: Remove migration.h from colo.h
migration: Move colo.h to migration/
migration: Move failover.h to migration/colo-failover.h
migration: Move page_cache.c to migration/
migration: Move qjson.h to migration/
migration: Split vmstate-types.c from vmstate.c
migration: Remove qemu-file.h from vmstate.h
migration: Remove vmstate.h from migration.h
migration: migration.h was not needed

 MAINTAINERS                                        |   4 +-
 Makefile.objs                                      |   1 -
 block/qed.c                                        |   1 -
 hw/i386/pc_q35.c                                   |   1 -
 hw/virtio/vhost-user.c                             |   1 -
 hw/virtio/vhost-vsock.c                            |   1 -
 hw/virtio/virtio.c                                 |   1 -
 include/hw/hw.h                                    |   1 +
 include/migration/migration.h                      |  13 +-
 include/migration/qemu-file.h                      |   4 -
 include/migration/vmstate.h                        |   3 -
 migration/Makefile.objs                            |   4 +-
 migration/block.c                                  |   2 +
 migration/channel.c                                |  70 +++
 migration/channel.h                                |  25 +
 migration/colo-comm.c                              |   4 +-
 migration/colo-failover.c                          |   4 +-
 .../failover.h => migration/colo-failover.h        |   0
 migration/colo.c                                   |   5 +-
 {include/migration => migration}/colo.h            |   1 -
 migration/exec.c                                   |   1 +
 migration/fd.c                                     |   1 +
 migration/migration.c                              |  54 +-
 page_cache.c => migration/page_cache.c             |   0
 {include/migration => migration}/page_cache.h      |   0
 migration/postcopy-ram.c                           |   1 +
 migration/qemu-file-channel.c                      |   1 +
 migration/qemu-file-channel.h                      |  21 +
 migration/qjson.c                                  |   2 +-
 {include/migration => migration}/qjson.h           |   0
 migration/ram.c                                    |   5 +-
 migration/rdma.c                                   |   1 +
 migration/savevm.c                                 |   1 +
 migration/socket.c                                 |   1 +
 migration/tls.c                                    |   1 +
 migration/vmstate-types.c                          | 676 +++++++++++++++++++++
 migration/vmstate.c                                | 671 +-------------------
 migration/xbzrle.c                                 |   2 +-
 migration/xbzrle.h                                 |  21 +
 monitor.c                                          |   1 -
 tests/Makefile.include                             |   4 +-
 tests/test-vmstate.c                               |   2 +
 tests/test-xbzrle.c                                |   2 +-
 43 files changed, 880 insertions(+), 735 deletions(-)
 create mode 100644 migration/channel.c
 create mode 100644 migration/channel.h
 rename include/migration/failover.h => migration/colo-failover.h (100%)
 rename {include/migration => migration}/colo.h (96%)
 rename page_cache.c => migration/page_cache.c (100%)
 rename {include/migration => migration}/page_cache.h (100%)
 create mode 100644 migration/qemu-file-channel.h
 rename {include/migration => migration}/qjson.h (100%)
 create mode 100644 migration/vmstate-types.c
 create mode 100644 migration/xbzrle.h
Signature · 1 line
2.9.3
#1 lore raw

PATCH v3 1/12 migration: Create migration/xbzrle.h

---
 include/migration/migration.h |  4 ----
 migration/ram.c               |  1 +
 migration/xbzrle.c            |  2 +-
 migration/xbzrle.h            | 21 +++++++++++++++++++++
 tests/test-xbzrle.c           |  2 +-
 5 files changed, 24 insertions(+), 6 deletions(-)
 create mode 100644 migration/xbzrle.h
include/migration/migration.h +0 -4
index 7ce3a7e..ae181a4 100644
@@ -270,10 +270,6 @@ bool migrate_zero_blocks(void);
 
 bool migrate_auto_converge(void);
 
-int xbzrle_encode_buffer(uint8_t *old_buf, uint8_t *new_buf, int slen,
-                         uint8_t *dst, int dlen);
-int xbzrle_decode_buffer(uint8_t *src, int slen, uint8_t *dst, int dlen);
-
 int migrate_use_xbzrle(void);
 int64_t migrate_xbzrle_cache_size(void);
 bool migrate_colo_enabled(void);
migration/ram.c +1 -0
index 76c118c..2564c00 100644
@@ -35,6 +35,7 @@
 #include "qemu/bitmap.h"
 #include "qemu/timer.h"
 #include "qemu/main-loop.h"
+#include "xbzrle.h"
 #include "migration/migration.h"
 #include "postcopy-ram.h"
 #include "exec/address-spaces.h"
migration/xbzrle.c +1 -1
index c858339..1ba482d 100644
@@ -12,7 +12,7 @@
  */
 #include "qemu/osdep.h"
 #include "qemu/cutils.h"
-#include "include/migration/migration.h"
+#include "xbzrle.h"
 
 /*
   page = zrun nzrun
migration/xbzrle.h new file +21 -0
new file mode 100644
index 0000000..a0db507
@@ -0,0 +1,21 @@
+/*
+ * QEMU live migration
+ *
+ * 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_XBZRLE_H
+#define QEMU_MIGRATION_XBZRLE_H
+
+int xbzrle_encode_buffer(uint8_t *old_buf, uint8_t *new_buf, int slen,
+                         uint8_t *dst, int dlen);
+
+int xbzrle_decode_buffer(uint8_t *src, int slen, uint8_t *dst, int dlen);
+#endif
tests/test-xbzrle.c +1 -1
index 49f6419..f5e08de 100644
@@ -13,7 +13,7 @@
 #include "qemu/osdep.h"
 #include "qemu-common.h"
 #include "qemu/cutils.h"
-#include "include/migration/migration.h"
+#include "../migration/xbzrle.h"
 
 #define PAGE_SIZE 4096
 
Signature · 1 line
2.9.3
#2 lore raw

PATCH v3 2/12 migration: Split migration/channel.c for channel operations

In reply to Juan Quintela

Create an include for its exported functions.

---
 include/migration/migration.h |  7 -----
 migration/Makefile.objs       |  2 +-
 migration/channel.c           | 69 +++++++++++++++++++++++++++++++++++++++++++
 migration/channel.h           | 25 ++++++++++++++++
 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 migration/channel.c
 create mode 100644 migration/channel.h
include/migration/migration.h +0 -7
index ae181a4..5f1136c 100644
@@ -176,17 +176,10 @@ void migration_fd_process_incoming(QEMUFile *f);
 
 void qemu_start_incoming_migration(const char *uri, Error **errp);
 
-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/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
migration/exec.c +1 -0
index aba9089..57a9335 100644
@@ -20,6 +20,7 @@
 #include "qemu/osdep.h"
 #include "qapi/error.h"
 #include "qemu-common.h"
+#include "channel.h"
 #include "migration/migration.h"
 #include "io/channel-command.h"
 #include "trace.h"
migration/fd.c +1 -0
index 58cb51a..05e0a5c 100644
@@ -17,6 +17,7 @@
 #include "qemu/osdep.h"
 #include "qapi/error.h"
 #include "qemu-common.h"
+#include "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 1cfbe81..53f9d61 100644
@@ -19,6 +19,7 @@
 #include "qemu-common.h"
 #include "qemu/error-report.h"
 #include "qapi/error.h"
+#include "channel.h"
 #include "migration/migration.h"
 #include "migration/qemu-file.h"
 #include "io/channel-socket.h"
migration/tls.c +1 -0
index a33ecb7..34ad121 100644
@@ -19,6 +19,7 @@
  */
 
 #include "qemu/osdep.h"
+#include "channel.h"
 #include "migration/migration.h"
 #include "io/channel-tls.h"
 #include "crypto/tlscreds.h"
Signature · 1 line
2.9.3
#3 lore raw

PATCH v3 3/12 migration: Export qemu-file-channel.c functions in its own file

In reply to Juan Quintela
---
 include/migration/migration.h |  1 +
 include/migration/qemu-file.h |  4 ----
 migration/channel.c           |  1 +
 migration/colo.c              |  1 +
 migration/migration.c         |  1 +
 migration/qemu-file-channel.c |  1 +
 migration/qemu-file-channel.h | 21 +++++++++++++++++++++
 migration/rdma.c              |  1 +
 migration/savevm.c            |  1 +
 tests/test-vmstate.c          |  1 +
 10 files changed, 29 insertions(+), 4 deletions(-)
 create mode 100644 migration/qemu-file-channel.h
include/migration/migration.h +1 -0
index 5f1136c..5ae21e6 100644
@@ -19,6 +19,7 @@
 #include "qemu/thread.h"
 #include "qemu/notify.h"
 #include "migration/vmstate.h"
+#include "io/channel.h"
 #include "qapi-types.h"
 #include "exec/cpu-common.h"
 #include "qemu/coroutine_int.h"
include/migration/qemu-file.h +0 -4
index 0cd648a..b5ac800 100644
@@ -27,8 +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
  * can be ignored if the file is only be used for streaming.  The number of
@@ -119,8 +117,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 -0
index 6104de5..fed8563 100644
@@ -16,6 +16,7 @@
 #include "qemu/osdep.h"
 #include "channel.h"
 #include "migration/migration.h"
+#include "qemu-file-channel.h"
 #include "trace.h"
 #include "qapi/error.h"
 #include "io/channel-tls.h"
migration/colo.c +1 -0
index 430bae5..65993d3 100644
@@ -13,6 +13,7 @@
 #include "qemu/osdep.h"
 #include "qemu/timer.h"
 #include "sysemu/sysemu.h"
+#include "qemu-file-channel.h"
 #include "migration/colo.h"
 #include "migration/block.h"
 #include "io/channel-buffer.h"
migration/migration.c +1 -0
index 303dfba..ad5ed14 100644
@@ -19,6 +19,7 @@
 #include "qemu/main-loop.h"
 #include "migration/blocker.h"
 #include "migration/migration.h"
+#include "qemu-file-channel.h"
 #include "migration/qemu-file.h"
 #include "sysemu/sysemu.h"
 #include "block/block.h"
migration/qemu-file-channel.c +1 -0
index 45c13f1..dc991c9 100644
@@ -23,6 +23,7 @@
  */
 
 #include "qemu/osdep.h"
+#include "qemu-file-channel.h"
 #include "migration/qemu-file.h"
 #include "io/channel-socket.h"
 #include "qemu/iov.h"
migration/qemu-file-channel.h new file +21 -0
new file mode 100644
index 0000000..d1bd5ff
@@ -0,0 +1,21 @@
+/*
+ * QEMU migration file channel operations
+ *
+ * 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 "io/channel.h"
+
+QEMUFile *qemu_fopen_channel_input(QIOChannel *ioc);
+QEMUFile *qemu_fopen_channel_output(QIOChannel *ioc);
+#endif
migration/rdma.c +1 -0
index 7eaaf96..166cd60 100644
@@ -20,6 +20,7 @@
 #include "migration/migration.h"
 #include "migration/qemu-file.h"
 #include "exec/cpu-common.h"
+#include "qemu-file-channel.h"
 #include "qemu/error-report.h"
 #include "qemu/main-loop.h"
 #include "qemu/sockets.h"
migration/savevm.c +1 -0
index de85e06..5120c51 100644
@@ -36,6 +36,7 @@
 #include "sysemu/sysemu.h"
 #include "qemu/timer.h"
 #include "migration/migration.h"
+#include "qemu-file-channel.h"
 #include "postcopy-ram.h"
 #include "qapi/qmp/qerror.h"
 #include "qemu/error-report.h"
tests/test-vmstate.c +1 -0
index f694a89..1c13570 100644
@@ -27,6 +27,7 @@
 #include "qemu-common.h"
 #include "migration/migration.h"
 #include "migration/vmstate.h"
+#include "../migration/qemu-file-channel.h"
 #include "qemu/coroutine.h"
 #include "io/channel-file.h"
 
Signature · 1 line
2.9.3
#4 lore raw

PATCH v3 4/12 migration: Remove migration.h from colo.h

In reply to Juan Quintela

migration.h is not included in any includes now.

---
 include/migration/colo.h | 1 -
 migration/colo-comm.c    | 3 ++-
 migration/colo.c         | 1 +
 3 files changed, 3 insertions(+), 2 deletions(-)
include/migration/colo.h +0 -1
index 2bbff9e..ba0bb6e 100644
@@ -14,7 +14,6 @@
 #define QEMU_COLO_H
 
 #include "qemu-common.h"
-#include "migration/migration.h"
 #include "qemu/coroutine_int.h"
 #include "qemu/thread.h"
 #include "qemu/main-loop.h"
migration/colo-comm.c +2 -1
index 20b60ec..3d91798 100644
@@ -12,7 +12,8 @@
  */
 
 #include "qemu/osdep.h"
-#include <migration/colo.h>
+#include "migration/migration.h"
+#include "migration/colo.h"
 #include "trace.h"
 
 typedef struct {
migration/colo.c +1 -0
index 65993d3..a3834e6 100644
@@ -14,6 +14,7 @@
 #include "qemu/timer.h"
 #include "sysemu/sysemu.h"
 #include "qemu-file-channel.h"
+#include "migration/migration.h"
 #include "migration/colo.h"
 #include "migration/block.h"
 #include "io/channel-buffer.h"
Signature · 1 line
2.9.3
#5 lore raw

PATCH v3 5/12 migration: Move colo.h to migration/

In reply to Juan Quintela

There are functions only used by migration code.

---
 MAINTAINERS                             | 2 +-
 migration/colo-comm.c                   | 2 +-
 migration/colo-failover.c               | 2 +-
 {include/migration => migration}/colo.h | 0
 migration/migration.c                   | 2 +-
 migration/ram.c                         | 2 +-
 6 files changed, 5 insertions(+), 5 deletions(-)
 rename {include/migration => migration}/colo.h (100%)
MAINTAINERS +1 -1
index 0e8d731..e834876 100644
@@ -1537,7 +1537,7 @@ COLO Framework
 M: zhanghailiang <[email protected]>
 S: Maintained
 F: migration/colo*
-F: include/migration/colo.h
+F: migration/colo.h
 F: include/migration/failover.h
 F: docs/COLO-FT.txt
 
migration/colo-comm.c +1 -1
index 3d91798..9b35027 100644
@@ -13,7 +13,7 @@
 
 #include "qemu/osdep.h"
 #include "migration/migration.h"
-#include "migration/colo.h"
+#include "colo.h"
 #include "trace.h"
 
 typedef struct {
migration/colo-failover.c +1 -1
index cc229f5..29b8d63 100644
@@ -11,7 +11,7 @@
  */
 
 #include "qemu/osdep.h"
-#include "migration/colo.h"
+#include "colo.h"
 #include "migration/failover.h"
 #include "qmp-commands.h"
 #include "qapi/qmp/qerror.h"
migration/colo.h renamed from include/migration/colo.h +0 -0
similarity index 100%
rename from include/migration/colo.h
rename to migration/colo.h
migration/migration.c +1 -1
index ad5ed14..a5a17fe 100644
@@ -38,7 +38,7 @@
 #include "exec/address-spaces.h"
 #include "io/channel-buffer.h"
 #include "io/channel-tls.h"
-#include "migration/colo.h"
+#include "colo.h"
 
 #define MAX_THROTTLE  (32 << 20)      /* Migration transfer speed throttling */
 
migration/ram.c +1 -1
index 2564c00..7a5f5fa 100644
@@ -44,7 +44,7 @@
 #include "trace.h"
 #include "exec/ram_addr.h"
 #include "qemu/rcu_queue.h"
-#include "migration/colo.h"
+#include "colo.h"
 
 /***********************************************************/
 /* ram save/restore */
Signature · 1 line
2.9.3
#6 lore raw

Re: [Qemu-devel] [PATCH 05/12] migration: Move colo.h to migration/

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

There are functions only used by migration code.

That's only mostly true; see the current 'integrate colo frame with block replication and net compare' series (posted 22nd April). That adds colo_handle_shutdown to this header and calls it from vl.c ( https://lists.gnu.org/archive/html/qemu-devel/2017-04/msg03901.html ) where should that go?

There's also a net/colo.h as well, so using the
#include "colo.h" in migration is correct but that's
really scary when there are two files of the same name.

Dave

Quoted 83 lines
---
 MAINTAINERS                             | 2 +-
 migration/colo-comm.c                   | 2 +-
 migration/colo-failover.c               | 2 +-
 {include/migration => migration}/colo.h | 0
 migration/migration.c                   | 2 +-
 migration/ram.c                         | 2 +-
 6 files changed, 5 insertions(+), 5 deletions(-)
 rename {include/migration => migration}/colo.h (100%)
MAINTAINERS +1 -1
index 0e8d731..e834876 100644
@@ -1537,7 +1537,7 @@ COLO Framework
 M: zhanghailiang <[email protected]>
 S: Maintained
 F: migration/colo*
-F: include/migration/colo.h
+F: migration/colo.h
 F: include/migration/failover.h
 F: docs/COLO-FT.txt
 
migration/colo-comm.c +1 -1
index 3d91798..9b35027 100644
@@ -13,7 +13,7 @@
 
 #include "qemu/osdep.h"
 #include "migration/migration.h"
-#include "migration/colo.h"
+#include "colo.h"
 #include "trace.h"
 
 typedef struct {
migration/colo-failover.c +1 -1
index cc229f5..29b8d63 100644
@@ -11,7 +11,7 @@
  */
 
 #include "qemu/osdep.h"
-#include "migration/colo.h"
+#include "colo.h"
 #include "migration/failover.h"
 #include "qmp-commands.h"
 #include "qapi/qmp/qerror.h"
migration/colo.h renamed from include/migration/colo.h +0 -0
similarity index 100%
rename from include/migration/colo.h
rename to migration/colo.h
migration/migration.c +1 -1
index ad5ed14..a5a17fe 100644
@@ -38,7 +38,7 @@
 #include "exec/address-spaces.h"
 #include "io/channel-buffer.h"
 #include "io/channel-tls.h"
-#include "migration/colo.h"
+#include "colo.h"
 
 #define MAX_THROTTLE  (32 << 20)      /* Migration transfer speed throttling */
 
migration/ram.c +1 -1
index 2564c00..7a5f5fa 100644
@@ -44,7 +44,7 @@
 #include "trace.h"
 #include "exec/ram_addr.h"
 #include "qemu/rcu_queue.h"
-#include "migration/colo.h"
+#include "colo.h"
 
 /***********************************************************/
 /* ram save/restore */
Signature · 1 line
2.9.3

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

#7 lore raw

Re: [Qemu-devel] [PATCH 05/12] migration: Move colo.h to migration/

"Dr. David Alan Gilbert" <[email protected]> wrote:

Quoted 7 lines · D> * Juan Quintela ([email protected]) wrote:
Quoted 1 line

There are functions only used by migration code.

That's only mostly true; see the current 'integrate colo frame with block replication and net compare' series (posted 22nd April). That adds colo_handle_shutdown to this header and calls it from vl.c ( https://lists.gnu.org/archive/html/qemu-devel/2017-04/msg03901.html ) where should that go?

Dropped.

It compiled, but who knows O:-)

Quoted 3 lines

There's also a net/colo.h as well, so using the
#include "colo.h" in migration is correct but that's
really scary when there are two files of the same name.

Yeap, it is scary ...

#8 lore raw

Re: [Qemu-devel] [PATCH 05/12] migration: Move colo.h to migration/

Quoted 15 lines · Juan Quintela

"Dr. David Alan Gilbert" <[email protected]> wrote:

Quoted 6 lines · D> * Juan Quintela ([email protected]) wrote:
Quoted 1 line

There are functions only used by migration code.

That's only mostly true; see the current 'integrate colo frame with block replication and net compare' series (posted 22nd April). That adds colo_handle_shutdown to this header and calls it from vl.c ( https://lists.gnu.org/archive/html/qemu-devel/2017-04/msg03901.html ) where should that go?

Dropped.

It compiled, but who knows O:-)

Quoted 3 lines

There's also a net/colo.h as well, so using the
#include "colo.h" in migration is correct but that's
really scary when there are two files of the same name.

Ha, I'd like to suggest it be renamed as colo-proxy.h (colo-net.h ? ) for net/colo.h, which is saner, hmm, together with colo.c, colo-proxy.c ? colo-net.c ? Or any other proper name ? ( I didn't notice that until it went into upstream. O:-) )

Cc Zhang Chen <[email protected]>
Quoted 4 lines

Yeap, it is scary ...

#9 lore raw

PATCH v3 6/12 migration: Move failover.h to migration/colo-failover.h

In reply to Juan Quintela

This file is internal for migration/colo code.

---
 MAINTAINERS                                               | 2 +-
 migration/colo-failover.c                                 | 2 +-
 include/migration/failover.h => migration/colo-failover.h | 0
 migration/colo.c                                          | 2 +-
 4 files changed, 3 insertions(+), 3 deletions(-)
 rename include/migration/failover.h => migration/colo-failover.h (100%)
MAINTAINERS +1 -1
index e834876..65cfb05 100644
@@ -1538,7 +1538,7 @@ M: zhanghailiang <[email protected]>
 S: Maintained
 F: migration/colo*
 F: migration/colo.h
-F: include/migration/failover.h
+F: migration/colo-failover.h
 F: docs/COLO-FT.txt
 
 COLO Proxy
migration/colo-failover.c +1 -1
index 29b8d63..85c4526 100644
@@ -12,7 +12,7 @@
 
 #include "qemu/osdep.h"
 #include "colo.h"
-#include "migration/failover.h"
+#include "colo-failover.h"
 #include "qmp-commands.h"
 #include "qapi/qmp/qerror.h"
 #include "qemu/error-report.h"
migration/colo-failover.h renamed from include/migration/failover.h +0 -0
similarity index 100%
rename from include/migration/failover.h
rename to migration/colo-failover.h
migration/colo.c +1 -1
index a3834e6..4b9a23c 100644
@@ -21,7 +21,7 @@
 #include "trace.h"
 #include "qemu/error-report.h"
 #include "qapi/error.h"
-#include "migration/failover.h"
+#include "colo-failover.h"
 #include "replication.h"
 #include "qmp-commands.h"
 
Signature · 1 line
2.9.3
#10 lore raw

PATCH v3 7/12 migration: Move page_cache.c to migration/

In reply to Juan Quintela

It is only used by migration, so move it there.

---
 Makefile.objs                                 | 1 -
 migration/Makefile.objs                       | 2 +-
 page_cache.c => migration/page_cache.c        | 0
 {include/migration => migration}/page_cache.h | 0
 tests/Makefile.include                        | 2 +-
 5 files changed, 2 insertions(+), 3 deletions(-)
 rename page_cache.c => migration/page_cache.c (100%)
 rename {include/migration => migration}/page_cache.h (100%)
Makefile.objs +0 -1
index 6167e7b..2100845 100644
@@ -49,7 +49,6 @@ common-obj-$(CONFIG_POSIX) += os-posix.o
 common-obj-$(CONFIG_LINUX) += fsdev/
 
 common-obj-y += migration/
-common-obj-y += page_cache.o #aio.o
 
 common-obj-$(CONFIG_SPICE) += spice-qemu-char.o
 
migration/Makefile.objs +1 -1
index c83ca92..ce8ce12 100644
@@ -1,7 +1,7 @@
 common-obj-y += migration.o socket.o fd.o exec.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 += vmstate.o page_cache.o
 common-obj-y += qemu-file.o
 common-obj-y += qemu-file-channel.o
 common-obj-y += xbzrle.o postcopy-ram.o
migration/page_cache.c renamed from page_cache.c +0 -0
similarity index 100%
rename from page_cache.c
rename to migration/page_cache.c
migration/page_cache.h renamed from include/migration/page_cache.h +0 -0
similarity index 100%
rename from include/migration/page_cache.h
rename to migration/page_cache.h
tests/Makefile.include +1 -1
index 31931c0..abdea89 100644
@@ -550,7 +550,7 @@ tests/test-thread-pool$(EXESUF): tests/test-thread-pool.o $(test-block-obj-y)
 tests/test-iov$(EXESUF): tests/test-iov.o $(test-util-obj-y)
 tests/test-hbitmap$(EXESUF): tests/test-hbitmap.o $(test-util-obj-y)
 tests/test-x86-cpuid$(EXESUF): tests/test-x86-cpuid.o
-tests/test-xbzrle$(EXESUF): tests/test-xbzrle.o migration/xbzrle.o page_cache.o $(test-util-obj-y)
+tests/test-xbzrle$(EXESUF): tests/test-xbzrle.o migration/xbzrle.o migration/page_cache.o $(test-util-obj-y)
 tests/test-cutils$(EXESUF): tests/test-cutils.o util/cutils.o
 tests/test-int128$(EXESUF): tests/test-int128.o
 tests/rcutorture$(EXESUF): tests/rcutorture.o $(test-util-obj-y)
Signature · 1 line
2.9.3
#11 lore raw

PATCH v3 8/12 migration: Move qjson.h to migration/

In reply to Juan Quintela

It is only used for migration code.

---
 migration/qjson.c                        | 2 +-
 {include/migration => migration}/qjson.h | 0
 migration/vmstate.c                      | 2 +-
 3 files changed, 2 insertions(+), 2 deletions(-)
 rename {include/migration => migration}/qjson.h (100%)
migration/qjson.c +1 -1
index f345904..9d7f6eb 100644
@@ -25,7 +25,7 @@
 
 #include "qemu/osdep.h"
 #include "qapi/qmp/qstring.h"
-#include "migration/qjson.h"
+#include "qjson.h"
 
 struct QJSON {
     QString *str;
migration/qjson.h renamed from include/migration/qjson.h +0 -0
similarity index 100%
rename from include/migration/qjson.h
rename to migration/qjson.h
migration/vmstate.c +1 -1
index 7b4a607..66c50ee 100644
@@ -7,7 +7,7 @@
 #include "qemu/error-report.h"
 #include "qemu/queue.h"
 #include "trace.h"
-#include "migration/qjson.h"
+#include "qjson.h"
 
 static void vmstate_subsection_save(QEMUFile *f, const VMStateDescription *vmsd,
                                     void *opaque, QJSON *vmdesc);
Signature · 1 line
2.9.3
#12 lore raw

PATCH v3 9/12 migration: Split vmstate-types.c from vmstate.c

In reply to Juan Quintela

Now one just has the interperter, and the other has the basic types. Once there, add copyright boilerplate.

---
 migration/Makefile.objs   |   2 +-
 migration/vmstate-types.c | 676 ++++++++++++++++++++++++++++++++++++++++++++++
 migration/vmstate.c       | 669 ++-------------------------------------------
 tests/Makefile.include    |   2 +-
 4 files changed, 705 insertions(+), 644 deletions(-)
 create mode 100644 migration/vmstate-types.c
migration/Makefile.objs +1 -1
index ce8ce12..812b2ec 100644
@@ -1,7 +1,7 @@
 common-obj-y += migration.o socket.o fd.o exec.o
 common-obj-y += tls.o channel.o
 common-obj-y += colo-comm.o colo.o colo-failover.o
-common-obj-y += vmstate.o page_cache.o
+common-obj-y += vmstate.o vmstate-types.o page_cache.o
 common-obj-y += qemu-file.o
 common-obj-y += qemu-file-channel.o
 common-obj-y += xbzrle.o postcopy-ram.o
migration/vmstate-types.c new file +676 -0

676 lines not on this page · raw message

migration/vmstate.c +27 -642

681 lines not on this page · raw message

tests/Makefile.include +1 -1
index abdea89..f1f03b5 100644
@@ -570,7 +570,7 @@ tests/test-qdev-global-props$(EXESUF): tests/test-qdev-global-props.o \
 	hw/core/reset.o \
 	$(test-qapi-obj-y)
 tests/test-vmstate$(EXESUF): tests/test-vmstate.o \
-	migration/vmstate.o migration/qemu-file.o \
+	migration/vmstate.o migration/vmstate-types.o migration/qemu-file.o \
         migration/qemu-file-channel.o migration/qjson.o \
 	$(test-io-obj-y)
 tests/test-timed-average$(EXESUF): tests/test-timed-average.o $(test-util-obj-y)
Signature · 1 line
2.9.3
#13 lore raw

Re: [Qemu-devel] [PATCH 09/12] migration: Split vmstate-types.c from vmstate.c

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

Now one just has the interperter, and the other has the basic types. Once there, add copyright boilerplate.

I think this is generally OK, but as discussed on IRC, I think you need to check the licenses.

Dave

Quoted 1,407 lines
---
 migration/Makefile.objs   |   2 +-
 migration/vmstate-types.c | 676 ++++++++++++++++++++++++++++++++++++++++++++++
 migration/vmstate.c       | 669 ++-------------------------------------------
 tests/Makefile.include    |   2 +-
 4 files changed, 705 insertions(+), 644 deletions(-)
 create mode 100644 migration/vmstate-types.c
migration/Makefile.objs +1 -1
index ce8ce12..812b2ec 100644
@@ -1,7 +1,7 @@
 common-obj-y += migration.o socket.o fd.o exec.o
 common-obj-y += tls.o channel.o
 common-obj-y += colo-comm.o colo.o colo-failover.o
-common-obj-y += vmstate.o page_cache.o
+common-obj-y += vmstate.o vmstate-types.o page_cache.o
 common-obj-y += qemu-file.o
 common-obj-y += qemu-file-channel.o
 common-obj-y += xbzrle.o postcopy-ram.o
migration/vmstate-types.c new file +676 -0
new file mode 100644
index 0000000..0cf14d4
@@ -0,0 +1,676 @@
+/*
+ * QEMU System Emulator
+ *
+ * Copyright (c) 2009-2017 Red Hat Inc
+ *
+ * Authors:
+ *  Juan Quintela <[email protected]>
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
+
+#include "qemu/osdep.h"
+#include "qemu-common.h"
+#include "migration/migration.h"
+#include "migration/qemu-file.h"
+#include "migration/vmstate.h"
+#include "qemu/error-report.h"
+#include "qemu/queue.h"
+#include "trace.h"
+
+/* bool */
+
+static int get_bool(QEMUFile *f, void *pv, size_t size, VMStateField *field)
+{
+    bool *v = pv;
+    *v = qemu_get_byte(f);
+    return 0;
+}
+
+static int put_bool(QEMUFile *f, void *pv, size_t size, VMStateField *field,
+                    QJSON *vmdesc)
+{
+    bool *v = pv;
+    qemu_put_byte(f, *v);
+    return 0;
+}
+
+const VMStateInfo vmstate_info_bool = {
+    .name = "bool",
+    .get  = get_bool,
+    .put  = put_bool,
+};
+
+/* 8 bit int */
+
+static int get_int8(QEMUFile *f, void *pv, size_t size, VMStateField *field)
+{
+    int8_t *v = pv;
+    qemu_get_s8s(f, v);
+    return 0;
+}
+
+static int put_int8(QEMUFile *f, void *pv, size_t size, VMStateField *field,
+                     QJSON *vmdesc)
+{
+    int8_t *v = pv;
+    qemu_put_s8s(f, v);
+    return 0;
+}
+
+const VMStateInfo vmstate_info_int8 = {
+    .name = "int8",
+    .get  = get_int8,
+    .put  = put_int8,
+};
+
+/* 16 bit int */
+
+static int get_int16(QEMUFile *f, void *pv, size_t size, VMStateField *field)
+{
+    int16_t *v = pv;
+    qemu_get_sbe16s(f, v);
+    return 0;
+}
+
+static int put_int16(QEMUFile *f, void *pv, size_t size, VMStateField *field,
+                     QJSON *vmdesc)
+{
+    int16_t *v = pv;
+    qemu_put_sbe16s(f, v);
+    return 0;
+}
+
+const VMStateInfo vmstate_info_int16 = {
+    .name = "int16",
+    .get  = get_int16,
+    .put  = put_int16,
+};
+
+/* 32 bit int */
+
+static int get_int32(QEMUFile *f, void *pv, size_t size, VMStateField *field)
+{
+    int32_t *v = pv;
+    qemu_get_sbe32s(f, v);
+    return 0;
+}
+
+static int put_int32(QEMUFile *f, void *pv, size_t size, VMStateField *field,
+                     QJSON *vmdesc)
+{
+    int32_t *v = pv;
+    qemu_put_sbe32s(f, v);
+    return 0;
+}
+
+const VMStateInfo vmstate_info_int32 = {
+    .name = "int32",
+    .get  = get_int32,
+    .put  = put_int32,
+};
+
+/* 32 bit int. See that the received value is the same than the one
+   in the field */
+
+static int get_int32_equal(QEMUFile *f, void *pv, size_t size,
+                           VMStateField *field)
+{
+    int32_t *v = pv;
+    int32_t v2;
+    qemu_get_sbe32s(f, &v2);
+
+    if (*v == v2) {
+        return 0;
+    }
+    error_report("%" PRIx32 " != %" PRIx32, *v, v2);
+    return -EINVAL;
+}
+
+const VMStateInfo vmstate_info_int32_equal = {
+    .name = "int32 equal",
+    .get  = get_int32_equal,
+    .put  = put_int32,
+};
+
+/* 32 bit int. Check that the received value is non-negative
+ * and less than or equal to the one in the field.
+ */
+
+static int get_int32_le(QEMUFile *f, void *pv, size_t size, VMStateField *field)
+{
+    int32_t *cur = pv;
+    int32_t loaded;
+    qemu_get_sbe32s(f, &loaded);
+
+    if (loaded >= 0 && loaded <= *cur) {
+        *cur = loaded;
+        return 0;
+    }
+    error_report("Invalid value %" PRId32
+                 " expecting positive value <= %" PRId32,
+                 loaded, *cur);
+    return -EINVAL;
+}
+
+const VMStateInfo vmstate_info_int32_le = {
+    .name = "int32 le",
+    .get  = get_int32_le,
+    .put  = put_int32,
+};
+
+/* 64 bit int */
+
+static int get_int64(QEMUFile *f, void *pv, size_t size, VMStateField *field)
+{
+    int64_t *v = pv;
+    qemu_get_sbe64s(f, v);
+    return 0;
+}
+
+static int put_int64(QEMUFile *f, void *pv, size_t size, VMStateField *field,
+                      QJSON *vmdesc)
+{
+    int64_t *v = pv;
+    qemu_put_sbe64s(f, v);
+    return 0;
+}
+
+const VMStateInfo vmstate_info_int64 = {
+    .name = "int64",
+    .get  = get_int64,
+    .put  = put_int64,
+};
+
+/* 8 bit unsigned int */
+
+static int get_uint8(QEMUFile *f, void *pv, size_t size, VMStateField *field)
+{
+    uint8_t *v = pv;
+    qemu_get_8s(f, v);
+    return 0;
+}
+
+static int put_uint8(QEMUFile *f, void *pv, size_t size, VMStateField *field,
+                     QJSON *vmdesc)
+{
+    uint8_t *v = pv;
+    qemu_put_8s(f, v);
+    return 0;
+}
+
+const VMStateInfo vmstate_info_uint8 = {
+    .name = "uint8",
+    .get  = get_uint8,
+    .put  = put_uint8,
+};
+
+/* 16 bit unsigned int */
+
+static int get_uint16(QEMUFile *f, void *pv, size_t size, VMStateField *field)
+{
+    uint16_t *v = pv;
+    qemu_get_be16s(f, v);
+    return 0;
+}
+
+static int put_uint16(QEMUFile *f, void *pv, size_t size, VMStateField *field,
+                      QJSON *vmdesc)
+{
+    uint16_t *v = pv;
+    qemu_put_be16s(f, v);
+    return 0;
+}
+
+const VMStateInfo vmstate_info_uint16 = {
+    .name = "uint16",
+    .get  = get_uint16,
+    .put  = put_uint16,
+};
+
+/* 32 bit unsigned int */
+
+static int get_uint32(QEMUFile *f, void *pv, size_t size, VMStateField *field)
+{
+    uint32_t *v = pv;
+    qemu_get_be32s(f, v);
+    return 0;
+}
+
+static int put_uint32(QEMUFile *f, void *pv, size_t size, VMStateField *field,
+                      QJSON *vmdesc)
+{
+    uint32_t *v = pv;
+    qemu_put_be32s(f, v);
+    return 0;
+}
+
+const VMStateInfo vmstate_info_uint32 = {
+    .name = "uint32",
+    .get  = get_uint32,
+    .put  = put_uint32,
+};
+
+/* 32 bit uint. See that the received value is the same than the one
+   in the field */
+
+static int get_uint32_equal(QEMUFile *f, void *pv, size_t size,
+                            VMStateField *field)
+{
+    uint32_t *v = pv;
+    uint32_t v2;
+    qemu_get_be32s(f, &v2);
+
+    if (*v == v2) {
+        return 0;
+    }
+    error_report("%" PRIx32 " != %" PRIx32, *v, v2);
+    return -EINVAL;
+}
+
+const VMStateInfo vmstate_info_uint32_equal = {
+    .name = "uint32 equal",
+    .get  = get_uint32_equal,
+    .put  = put_uint32,
+};
+
+/* 64 bit unsigned int */
+
+static int get_uint64(QEMUFile *f, void *pv, size_t size, VMStateField *field)
+{
+    uint64_t *v = pv;
+    qemu_get_be64s(f, v);
+    return 0;
+}
+
+static int put_uint64(QEMUFile *f, void *pv, size_t size, VMStateField *field,
+                      QJSON *vmdesc)
+{
+    uint64_t *v = pv;
+    qemu_put_be64s(f, v);
+    return 0;
+}
+
+const VMStateInfo vmstate_info_uint64 = {
+    .name = "uint64",
+    .get  = get_uint64,
+    .put  = put_uint64,
+};
+
+static int get_nullptr(QEMUFile *f, void *pv, size_t size, VMStateField *field)
+
+{
+    if (qemu_get_byte(f) == VMS_NULLPTR_MARKER) {
+        return  0;
+    }
+    error_report("vmstate: get_nullptr expected VMS_NULLPTR_MARKER");
+    return -EINVAL;
+}
+
+static int put_nullptr(QEMUFile *f, void *pv, size_t size,
+                        VMStateField *field, QJSON *vmdesc)
+
+{
+    if (pv == NULL) {
+        qemu_put_byte(f, VMS_NULLPTR_MARKER);
+        return 0;
+    }
+    error_report("vmstate: put_nullptr must be called with pv == NULL");
+    return -EINVAL;
+}
+
+const VMStateInfo vmstate_info_nullptr = {
+    .name = "uint64",
+    .get  = get_nullptr,
+    .put  = put_nullptr,
+};
+
+/* 64 bit unsigned int. See that the received value is the same than the one
+   in the field */
+
+static int get_uint64_equal(QEMUFile *f, void *pv, size_t size,
+                            VMStateField *field)
+{
+    uint64_t *v = pv;
+    uint64_t v2;
+    qemu_get_be64s(f, &v2);
+
+    if (*v == v2) {
+        return 0;
+    }
+    error_report("%" PRIx64 " != %" PRIx64, *v, v2);
+    return -EINVAL;
+}
+
+const VMStateInfo vmstate_info_uint64_equal = {
+    .name = "int64 equal",
+    .get  = get_uint64_equal,
+    .put  = put_uint64,
+};
+
+/* 8 bit int. See that the received value is the same than the one
+   in the field */
+
+static int get_uint8_equal(QEMUFile *f, void *pv, size_t size,
+                           VMStateField *field)
+{
+    uint8_t *v = pv;
+    uint8_t v2;
+    qemu_get_8s(f, &v2);
+
+    if (*v == v2) {
+        return 0;
+    }
+    error_report("%x != %x", *v, v2);
+    return -EINVAL;
+}
+
+const VMStateInfo vmstate_info_uint8_equal = {
+    .name = "uint8 equal",
+    .get  = get_uint8_equal,
+    .put  = put_uint8,
+};
+
+/* 16 bit unsigned int int. See that the received value is the same than the one
+   in the field */
+
+static int get_uint16_equal(QEMUFile *f, void *pv, size_t size,
+                            VMStateField *field)
+{
+    uint16_t *v = pv;
+    uint16_t v2;
+    qemu_get_be16s(f, &v2);
+
+    if (*v == v2) {
+        return 0;
+    }
+    error_report("%x != %x", *v, v2);
+    return -EINVAL;
+}
+
+const VMStateInfo vmstate_info_uint16_equal = {
+    .name = "uint16 equal",
+    .get  = get_uint16_equal,
+    .put  = put_uint16,
+};
+
+/* floating point */
+
+static int get_float64(QEMUFile *f, void *pv, size_t size,
+                       VMStateField *field)
+{
+    float64 *v = pv;
+
+    *v = make_float64(qemu_get_be64(f));
+    return 0;
+}
+
+static int put_float64(QEMUFile *f, void *pv, size_t size, VMStateField *field,
+                       QJSON *vmdesc)
+{
+    uint64_t *v = pv;
+
+    qemu_put_be64(f, float64_val(*v));
+    return 0;
+}
+
+const VMStateInfo vmstate_info_float64 = {
+    .name = "float64",
+    .get  = get_float64,
+    .put  = put_float64,
+};
+
+/* CPU_DoubleU type */
+
+static int get_cpudouble(QEMUFile *f, void *pv, size_t size,
+                         VMStateField *field)
+{
+    CPU_DoubleU *v = pv;
+    qemu_get_be32s(f, &v->l.upper);
+    qemu_get_be32s(f, &v->l.lower);
+    return 0;
+}
+
+static int put_cpudouble(QEMUFile *f, void *pv, size_t size,
+                         VMStateField *field, QJSON *vmdesc)
+{
+    CPU_DoubleU *v = pv;
+    qemu_put_be32s(f, &v->l.upper);
+    qemu_put_be32s(f, &v->l.lower);
+    return 0;
+}
+
+const VMStateInfo vmstate_info_cpudouble = {
+    .name = "CPU_Double_U",
+    .get  = get_cpudouble,
+    .put  = put_cpudouble,
+};
+
+/* uint8_t buffers */
+
+static int get_buffer(QEMUFile *f, void *pv, size_t size,
+                      VMStateField *field)
+{
+    uint8_t *v = pv;
+    qemu_get_buffer(f, v, size);
+    return 0;
+}
+
+static int put_buffer(QEMUFile *f, void *pv, size_t size, VMStateField *field,
+                      QJSON *vmdesc)
+{
+    uint8_t *v = pv;
+    qemu_put_buffer(f, v, size);
+    return 0;
+}
+
+const VMStateInfo vmstate_info_buffer = {
+    .name = "buffer",
+    .get  = get_buffer,
+    .put  = put_buffer,
+};
+
+/* unused buffers: space that was used for some fields that are
+   not useful anymore */
+
+static int get_unused_buffer(QEMUFile *f, void *pv, size_t size,
+                             VMStateField *field)
+{
+    uint8_t buf[1024];
+    int block_len;
+
+    while (size > 0) {
+        block_len = MIN(sizeof(buf), size);
+        size -= block_len;
+        qemu_get_buffer(f, buf, block_len);
+    }
+   return 0;
+}
+
+static int put_unused_buffer(QEMUFile *f, void *pv, size_t size,
+                             VMStateField *field, QJSON *vmdesc)
+{
+    static const uint8_t buf[1024];
+    int block_len;
+
+    while (size > 0) {
+        block_len = MIN(sizeof(buf), size);
+        size -= block_len;
+        qemu_put_buffer(f, buf, block_len);
+    }
+
+    return 0;
+}
+
+const VMStateInfo vmstate_info_unused_buffer = {
+    .name = "unused_buffer",
+    .get  = get_unused_buffer,
+    .put  = put_unused_buffer,
+};
+
+/* vmstate_info_tmp, see VMSTATE_WITH_TMP, the idea is that we allocate
+ * a temporary buffer and the pre_load/pre_save methods in the child vmsd
+ * copy stuff from the parent into the child and do calculations to fill
+ * in fields that don't really exist in the parent but need to be in the
+ * stream.
+ */
+static int get_tmp(QEMUFile *f, void *pv, size_t size, VMStateField *field)
+{
+    int ret;
+    const VMStateDescription *vmsd = field->vmsd;
+    int version_id = field->version_id;
+    void *tmp = g_malloc(size);
+
+    /* Writes the parent field which is at the start of the tmp */
+    *(void **)tmp = pv;
+    ret = vmstate_load_state(f, vmsd, tmp, version_id);
+    g_free(tmp);
+    return ret;
+}
+
+static int put_tmp(QEMUFile *f, void *pv, size_t size, VMStateField *field,
+                    QJSON *vmdesc)
+{
+    const VMStateDescription *vmsd = field->vmsd;
+    void *tmp = g_malloc(size);
+
+    /* Writes the parent field which is at the start of the tmp */
+    *(void **)tmp = pv;
+    vmstate_save_state(f, vmsd, tmp, vmdesc);
+    g_free(tmp);
+
+    return 0;
+}
+
+const VMStateInfo vmstate_info_tmp = {
+    .name = "tmp",
+    .get = get_tmp,
+    .put = put_tmp,
+};
+
+/* bitmaps (as defined by bitmap.h). Note that size here is the size
+ * of the bitmap in bits. The on-the-wire format of a bitmap is 64
+ * bit words with the bits in big endian order. The in-memory format
+ * is an array of 'unsigned long', which may be either 32 or 64 bits.
+ */
+/* This is the number of 64 bit words sent over the wire */
+#define BITS_TO_U64S(nr) DIV_ROUND_UP(nr, 64)
+static int get_bitmap(QEMUFile *f, void *pv, size_t size, VMStateField *field)
+{
+    unsigned long *bmp = pv;
+    int i, idx = 0;
+    for (i = 0; i < BITS_TO_U64S(size); i++) {
+        uint64_t w = qemu_get_be64(f);
+        bmp[idx++] = w;
+        if (sizeof(unsigned long) == 4 && idx < BITS_TO_LONGS(size)) {
+            bmp[idx++] = w >> 32;
+        }
+    }
+    return 0;
+}
+
+static int put_bitmap(QEMUFile *f, void *pv, size_t size, VMStateField *field,
+                      QJSON *vmdesc)
+{
+    unsigned long *bmp = pv;
+    int i, idx = 0;
+    for (i = 0; i < BITS_TO_U64S(size); i++) {
+        uint64_t w = bmp[idx++];
+        if (sizeof(unsigned long) == 4 && idx < BITS_TO_LONGS(size)) {
+            w |= ((uint64_t)bmp[idx++]) << 32;
+        }
+        qemu_put_be64(f, w);
+    }
+
+    return 0;
+}
+
+const VMStateInfo vmstate_info_bitmap = {
+    .name = "bitmap",
+    .get = get_bitmap,
+    .put = put_bitmap,
+};
+
+/* get for QTAILQ
+ * meta data about the QTAILQ is encoded in a VMStateField structure
+ */
+static int get_qtailq(QEMUFile *f, void *pv, size_t unused_size,
+                      VMStateField *field)
+{
+    int ret = 0;
+    const VMStateDescription *vmsd = field->vmsd;
+    /* size of a QTAILQ element */
+    size_t size = field->size;
+    /* offset of the QTAILQ entry in a QTAILQ element */
+    size_t entry_offset = field->start;
+    int version_id = field->version_id;
+    void *elm;
+
+    trace_get_qtailq(vmsd->name, version_id);
+    if (version_id > vmsd->version_id) {
+        error_report("%s %s",  vmsd->name, "too new");
+        trace_get_qtailq_end(vmsd->name, "too new", -EINVAL);
+
+        return -EINVAL;
+    }
+    if (version_id < vmsd->minimum_version_id) {
+        error_report("%s %s",  vmsd->name, "too old");
+        trace_get_qtailq_end(vmsd->name, "too old", -EINVAL);
+        return -EINVAL;
+    }
+
+    while (qemu_get_byte(f)) {
+        elm = g_malloc(size);
+        ret = vmstate_load_state(f, vmsd, elm, version_id);
+        if (ret) {
+            return ret;
+        }
+        QTAILQ_RAW_INSERT_TAIL(pv, elm, entry_offset);
+    }
+
+    trace_get_qtailq_end(vmsd->name, "end", ret);
+    return ret;
+}
+
+/* put for QTAILQ */
+static int put_qtailq(QEMUFile *f, void *pv, size_t unused_size,
+                      VMStateField *field, QJSON *vmdesc)
+{
+    const VMStateDescription *vmsd = field->vmsd;
+    /* offset of the QTAILQ entry in a QTAILQ element*/
+    size_t entry_offset = field->start;
+    void *elm;
+
+    trace_put_qtailq(vmsd->name, vmsd->version_id);
+
+    QTAILQ_RAW_FOREACH(elm, pv, entry_offset) {
+        qemu_put_byte(f, true);
+        vmstate_save_state(f, vmsd, elm, vmdesc);
+    }
+    qemu_put_byte(f, false);
+
+    trace_put_qtailq_end(vmsd->name, "end");
+
+    return 0;
+}
+const VMStateInfo vmstate_info_qtailq = {
+    .name = "qtailq",
+    .get  = get_qtailq,
+    .put  = put_qtailq,
+};
migration/vmstate.c +27 -642
index 66c50ee..c284769 100644
@@ -1,3 +1,30 @@
+/*
+ * QEMU System Emulator
+ *
+ * Copyright (c) 2009-2017 Red Hat Inc
+ *
+ * Authors:
+ *  Juan Quintela <[email protected]>
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
+
 #include "qemu/osdep.h"
 #include "qemu-common.h"
 #include "migration/migration.h"
@@ -5,7 +32,6 @@
 #include "migration/vmstate.h"
 #include "qemu/bitops.h"
 #include "qemu/error-report.h"
-#include "qemu/queue.h"
 #include "trace.h"
 #include "qjson.h"
 
@@ -475,644 +501,3 @@ static void vmstate_subsection_save(QEMUFile *f, const VMStateDescription *vmsd,
         json_end_array(vmdesc);
     }
 }
-
-/* bool */
-
-static int get_bool(QEMUFile *f, void *pv, size_t size, VMStateField *field)
-{
-    bool *v = pv;
-    *v = qemu_get_byte(f);
-    return 0;
-}
-
-static int put_bool(QEMUFile *f, void *pv, size_t size, VMStateField *field,
-                    QJSON *vmdesc)
-{
-    bool *v = pv;
-    qemu_put_byte(f, *v);
-    return 0;
-}
-
-const VMStateInfo vmstate_info_bool = {
-    .name = "bool",
-    .get  = get_bool,
-    .put  = put_bool,
-};
-
-/* 8 bit int */
-
-static int get_int8(QEMUFile *f, void *pv, size_t size, VMStateField *field)
-{
-    int8_t *v = pv;
-    qemu_get_s8s(f, v);
-    return 0;
-}
-
-static int put_int8(QEMUFile *f, void *pv, size_t size, VMStateField *field,
-                     QJSON *vmdesc)
-{
-    int8_t *v = pv;
-    qemu_put_s8s(f, v);
-    return 0;
-}
-
-const VMStateInfo vmstate_info_int8 = {
-    .name = "int8",
-    .get  = get_int8,
-    .put  = put_int8,
-};
-
-/* 16 bit int */
-
-static int get_int16(QEMUFile *f, void *pv, size_t size, VMStateField *field)
-{
-    int16_t *v = pv;
-    qemu_get_sbe16s(f, v);
-    return 0;
-}
-
-static int put_int16(QEMUFile *f, void *pv, size_t size, VMStateField *field,
-                     QJSON *vmdesc)
-{
-    int16_t *v = pv;
-    qemu_put_sbe16s(f, v);
-    return 0;
-}
-
-const VMStateInfo vmstate_info_int16 = {
-    .name = "int16",
-    .get  = get_int16,
-    .put  = put_int16,
-};
-
-/* 32 bit int */
-
-static int get_int32(QEMUFile *f, void *pv, size_t size, VMStateField *field)
-{
-    int32_t *v = pv;
-    qemu_get_sbe32s(f, v);
-    return 0;
-}
-
-static int put_int32(QEMUFile *f, void *pv, size_t size, VMStateField *field,
-                     QJSON *vmdesc)
-{
-    int32_t *v = pv;
-    qemu_put_sbe32s(f, v);
-    return 0;
-}
-
-const VMStateInfo vmstate_info_int32 = {
-    .name = "int32",
-    .get  = get_int32,
-    .put  = put_int32,
-};
-
-/* 32 bit int. See that the received value is the same than the one
-   in the field */
-
-static int get_int32_equal(QEMUFile *f, void *pv, size_t size,
-                           VMStateField *field)
-{
-    int32_t *v = pv;
-    int32_t v2;
-    qemu_get_sbe32s(f, &v2);
-
-    if (*v == v2) {
-        return 0;
-    }
-    error_report("%" PRIx32 " != %" PRIx32, *v, v2);
-    return -EINVAL;
-}
-
-const VMStateInfo vmstate_info_int32_equal = {
-    .name = "int32 equal",
-    .get  = get_int32_equal,
-    .put  = put_int32,
-};
-
-/* 32 bit int. Check that the received value is non-negative
- * and less than or equal to the one in the field.
- */
-
-static int get_int32_le(QEMUFile *f, void *pv, size_t size, VMStateField *field)
-{
-    int32_t *cur = pv;
-    int32_t loaded;
-    qemu_get_sbe32s(f, &loaded);
-
-    if (loaded >= 0 && loaded <= *cur) {
-        *cur = loaded;
-        return 0;
-    }
-    error_report("Invalid value %" PRId32
-                 " expecting positive value <= %" PRId32,
-                 loaded, *cur);
-    return -EINVAL;
-}
-
-const VMStateInfo vmstate_info_int32_le = {
-    .name = "int32 le",
-    .get  = get_int32_le,
-    .put  = put_int32,
-};
-
-/* 64 bit int */
-
-static int get_int64(QEMUFile *f, void *pv, size_t size, VMStateField *field)
-{
-    int64_t *v = pv;
-    qemu_get_sbe64s(f, v);
-    return 0;
-}
-
-static int put_int64(QEMUFile *f, void *pv, size_t size, VMStateField *field,
-                      QJSON *vmdesc)
-{
-    int64_t *v = pv;
-    qemu_put_sbe64s(f, v);
-    return 0;
-}
-
-const VMStateInfo vmstate_info_int64 = {
-    .name = "int64",
-    .get  = get_int64,
-    .put  = put_int64,
-};
-
-/* 8 bit unsigned int */
-
-static int get_uint8(QEMUFile *f, void *pv, size_t size, VMStateField *field)
-{
-    uint8_t *v = pv;
-    qemu_get_8s(f, v);
-    return 0;
-}
-
-static int put_uint8(QEMUFile *f, void *pv, size_t size, VMStateField *field,
-                     QJSON *vmdesc)
-{
-    uint8_t *v = pv;
-    qemu_put_8s(f, v);
-    return 0;
-}
-
-const VMStateInfo vmstate_info_uint8 = {
-    .name = "uint8",
-    .get  = get_uint8,
-    .put  = put_uint8,
-};
-
-/* 16 bit unsigned int */
-
-static int get_uint16(QEMUFile *f, void *pv, size_t size, VMStateField *field)
-{
-    uint16_t *v = pv;
-    qemu_get_be16s(f, v);
-    return 0;
-}
-
-static int put_uint16(QEMUFile *f, void *pv, size_t size, VMStateField *field,
-                      QJSON *vmdesc)
-{
-    uint16_t *v = pv;
-    qemu_put_be16s(f, v);
-    return 0;
-}
-
-const VMStateInfo vmstate_info_uint16 = {
-    .name = "uint16",
-    .get  = get_uint16,
-    .put  = put_uint16,
-};
-
-/* 32 bit unsigned int */
-
-static int get_uint32(QEMUFile *f, void *pv, size_t size, VMStateField *field)
-{
-    uint32_t *v = pv;
-    qemu_get_be32s(f, v);
-    return 0;
-}
-
-static int put_uint32(QEMUFile *f, void *pv, size_t size, VMStateField *field,
-                      QJSON *vmdesc)
-{
-    uint32_t *v = pv;
-    qemu_put_be32s(f, v);
-    return 0;
-}
-
-const VMStateInfo vmstate_info_uint32 = {
-    .name = "uint32",
-    .get  = get_uint32,
-    .put  = put_uint32,
-};
-
-/* 32 bit uint. See that the received value is the same than the one
-   in the field */
-
-static int get_uint32_equal(QEMUFile *f, void *pv, size_t size,
-                            VMStateField *field)
-{
-    uint32_t *v = pv;
-    uint32_t v2;
-    qemu_get_be32s(f, &v2);
-
-    if (*v == v2) {
-        return 0;
-    }
-    error_report("%" PRIx32 " != %" PRIx32, *v, v2);
-    return -EINVAL;
-}
-
-const VMStateInfo vmstate_info_uint32_equal = {
-    .name = "uint32 equal",
-    .get  = get_uint32_equal,
-    .put  = put_uint32,
-};
-
-/* 64 bit unsigned int */
-
-static int get_uint64(QEMUFile *f, void *pv, size_t size, VMStateField *field)
-{
-    uint64_t *v = pv;
-    qemu_get_be64s(f, v);
-    return 0;
-}
-
-static int put_uint64(QEMUFile *f, void *pv, size_t size, VMStateField *field,
-                      QJSON *vmdesc)
-{
-    uint64_t *v = pv;
-    qemu_put_be64s(f, v);
-    return 0;
-}
-
-const VMStateInfo vmstate_info_uint64 = {
-    .name = "uint64",
-    .get  = get_uint64,
-    .put  = put_uint64,
-};
-
-static int get_nullptr(QEMUFile *f, void *pv, size_t size, VMStateField *field)
-
-{
-    if (qemu_get_byte(f) == VMS_NULLPTR_MARKER) {
-        return  0;
-    }
-    error_report("vmstate: get_nullptr expected VMS_NULLPTR_MARKER");
-    return -EINVAL;
-}
-
-static int put_nullptr(QEMUFile *f, void *pv, size_t size,
-                        VMStateField *field, QJSON *vmdesc)
-
-{
-    if (pv == NULL) {
-        qemu_put_byte(f, VMS_NULLPTR_MARKER);
-        return 0;
-    }
-    error_report("vmstate: put_nullptr must be called with pv == NULL");
-    return -EINVAL;
-}
-
-const VMStateInfo vmstate_info_nullptr = {
-    .name = "uint64",
-    .get  = get_nullptr,
-    .put  = put_nullptr,
-};
-
-/* 64 bit unsigned int. See that the received value is the same than the one
-   in the field */
-
-static int get_uint64_equal(QEMUFile *f, void *pv, size_t size,
-                            VMStateField *field)
-{
-    uint64_t *v = pv;
-    uint64_t v2;
-    qemu_get_be64s(f, &v2);
-
-    if (*v == v2) {
-        return 0;
-    }
-    error_report("%" PRIx64 " != %" PRIx64, *v, v2);
-    return -EINVAL;
-}
-
-const VMStateInfo vmstate_info_uint64_equal = {
-    .name = "int64 equal",
-    .get  = get_uint64_equal,
-    .put  = put_uint64,
-};
-
-/* 8 bit int. See that the received value is the same than the one
-   in the field */
-
-static int get_uint8_equal(QEMUFile *f, void *pv, size_t size,
-                           VMStateField *field)
-{
-    uint8_t *v = pv;
-    uint8_t v2;
-    qemu_get_8s(f, &v2);
-
-    if (*v == v2) {
-        return 0;
-    }
-    error_report("%x != %x", *v, v2);
-    return -EINVAL;
-}
-
-const VMStateInfo vmstate_info_uint8_equal = {
-    .name = "uint8 equal",
-    .get  = get_uint8_equal,
-    .put  = put_uint8,
-};
-
-/* 16 bit unsigned int int. See that the received value is the same than the one
-   in the field */
-
-static int get_uint16_equal(QEMUFile *f, void *pv, size_t size,
-                            VMStateField *field)
-{
-    uint16_t *v = pv;
-    uint16_t v2;
-    qemu_get_be16s(f, &v2);
-
-    if (*v == v2) {
-        return 0;
-    }
-    error_report("%x != %x", *v, v2);
-    return -EINVAL;
-}
-
-const VMStateInfo vmstate_info_uint16_equal = {
-    .name = "uint16 equal",
-    .get  = get_uint16_equal,
-    .put  = put_uint16,
-};
-
-/* floating point */
-
-static int get_float64(QEMUFile *f, void *pv, size_t size,
-                       VMStateField *field)
-{
-    float64 *v = pv;
-
-    *v = make_float64(qemu_get_be64(f));
-    return 0;
-}
-
-static int put_float64(QEMUFile *f, void *pv, size_t size, VMStateField *field,
-                       QJSON *vmdesc)
-{
-    uint64_t *v = pv;
-
-    qemu_put_be64(f, float64_val(*v));
-    return 0;
-}
-
-const VMStateInfo vmstate_info_float64 = {
-    .name = "float64",
-    .get  = get_float64,
-    .put  = put_float64,
-};
-
-/* CPU_DoubleU type */
-
-static int get_cpudouble(QEMUFile *f, void *pv, size_t size,
-                         VMStateField *field)
-{
-    CPU_DoubleU *v = pv;
-    qemu_get_be32s(f, &v->l.upper);
-    qemu_get_be32s(f, &v->l.lower);
-    return 0;
-}
-
-static int put_cpudouble(QEMUFile *f, void *pv, size_t size,
-                         VMStateField *field, QJSON *vmdesc)
-{
-    CPU_DoubleU *v = pv;
-    qemu_put_be32s(f, &v->l.upper);
-    qemu_put_be32s(f, &v->l.lower);
-    return 0;
-}
-
-const VMStateInfo vmstate_info_cpudouble = {
-    .name = "CPU_Double_U",
-    .get  = get_cpudouble,
-    .put  = put_cpudouble,
-};
-
-/* uint8_t buffers */
-
-static int get_buffer(QEMUFile *f, void *pv, size_t size,
-                      VMStateField *field)
-{
-    uint8_t *v = pv;
-    qemu_get_buffer(f, v, size);
-    return 0;
-}
-
-static int put_buffer(QEMUFile *f, void *pv, size_t size, VMStateField *field,
-                      QJSON *vmdesc)
-{
-    uint8_t *v = pv;
-    qemu_put_buffer(f, v, size);
-    return 0;
-}
-
-const VMStateInfo vmstate_info_buffer = {
-    .name = "buffer",
-    .get  = get_buffer,
-    .put  = put_buffer,
-};
-
-/* unused buffers: space that was used for some fields that are
-   not useful anymore */
-
-static int get_unused_buffer(QEMUFile *f, void *pv, size_t size,
-                             VMStateField *field)
-{
-    uint8_t buf[1024];
-    int block_len;
-
-    while (size > 0) {
-        block_len = MIN(sizeof(buf), size);
-        size -= block_len;
-        qemu_get_buffer(f, buf, block_len);
-    }
-   return 0;
-}
-
-static int put_unused_buffer(QEMUFile *f, void *pv, size_t size,
-                             VMStateField *field, QJSON *vmdesc)
-{
-    static const uint8_t buf[1024];
-    int block_len;
-
-    while (size > 0) {
-        block_len = MIN(sizeof(buf), size);
-        size -= block_len;
-        qemu_put_buffer(f, buf, block_len);
-    }
-
-    return 0;
-}
-
-const VMStateInfo vmstate_info_unused_buffer = {
-    .name = "unused_buffer",
-    .get  = get_unused_buffer,
-    .put  = put_unused_buffer,
-};
-
-/* vmstate_info_tmp, see VMSTATE_WITH_TMP, the idea is that we allocate
- * a temporary buffer and the pre_load/pre_save methods in the child vmsd
- * copy stuff from the parent into the child and do calculations to fill
- * in fields that don't really exist in the parent but need to be in the
- * stream.
- */
-static int get_tmp(QEMUFile *f, void *pv, size_t size, VMStateField *field)
-{
-    int ret;
-    const VMStateDescription *vmsd = field->vmsd;
-    int version_id = field->version_id;
-    void *tmp = g_malloc(size);
-
-    /* Writes the parent field which is at the start of the tmp */
-    *(void **)tmp = pv;
-    ret = vmstate_load_state(f, vmsd, tmp, version_id);
-    g_free(tmp);
-    return ret;
-}
-
-static int put_tmp(QEMUFile *f, void *pv, size_t size, VMStateField *field,
-                    QJSON *vmdesc)
-{
-    const VMStateDescription *vmsd = field->vmsd;
-    void *tmp = g_malloc(size);
-
-    /* Writes the parent field which is at the start of the tmp */
-    *(void **)tmp = pv;
-    vmstate_save_state(f, vmsd, tmp, vmdesc);
-    g_free(tmp);
-
-    return 0;
-}
-
-const VMStateInfo vmstate_info_tmp = {
-    .name = "tmp",
-    .get = get_tmp,
-    .put = put_tmp,
-};
-
-/* bitmaps (as defined by bitmap.h). Note that size here is the size
- * of the bitmap in bits. The on-the-wire format of a bitmap is 64
- * bit words with the bits in big endian order. The in-memory format
- * is an array of 'unsigned long', which may be either 32 or 64 bits.
- */
-/* This is the number of 64 bit words sent over the wire */
-#define BITS_TO_U64S(nr) DIV_ROUND_UP(nr, 64)
-static int get_bitmap(QEMUFile *f, void *pv, size_t size, VMStateField *field)
-{
-    unsigned long *bmp = pv;
-    int i, idx = 0;
-    for (i = 0; i < BITS_TO_U64S(size); i++) {
-        uint64_t w = qemu_get_be64(f);
-        bmp[idx++] = w;
-        if (sizeof(unsigned long) == 4 && idx < BITS_TO_LONGS(size)) {
-            bmp[idx++] = w >> 32;
-        }
-    }
-    return 0;
-}
-
-static int put_bitmap(QEMUFile *f, void *pv, size_t size, VMStateField *field,
-                      QJSON *vmdesc)
-{
-    unsigned long *bmp = pv;
-    int i, idx = 0;
-    for (i = 0; i < BITS_TO_U64S(size); i++) {
-        uint64_t w = bmp[idx++];
-        if (sizeof(unsigned long) == 4 && idx < BITS_TO_LONGS(size)) {
-            w |= ((uint64_t)bmp[idx++]) << 32;
-        }
-        qemu_put_be64(f, w);
-    }
-
-    return 0;
-}
-
-const VMStateInfo vmstate_info_bitmap = {
-    .name = "bitmap",
-    .get = get_bitmap,
-    .put = put_bitmap,
-};
-
-/* get for QTAILQ
- * meta data about the QTAILQ is encoded in a VMStateField structure
- */
-static int get_qtailq(QEMUFile *f, void *pv, size_t unused_size,
-                      VMStateField *field)
-{
-    int ret = 0;
-    const VMStateDescription *vmsd = field->vmsd;
-    /* size of a QTAILQ element */
-    size_t size = field->size;
-    /* offset of the QTAILQ entry in a QTAILQ element */
-    size_t entry_offset = field->start;
-    int version_id = field->version_id;
-    void *elm;
-
-    trace_get_qtailq(vmsd->name, version_id);
-    if (version_id > vmsd->version_id) {
-        error_report("%s %s",  vmsd->name, "too new");
-        trace_get_qtailq_end(vmsd->name, "too new", -EINVAL);
-
-        return -EINVAL;
-    }
-    if (version_id < vmsd->minimum_version_id) {
-        error_report("%s %s",  vmsd->name, "too old");
-        trace_get_qtailq_end(vmsd->name, "too old", -EINVAL);
-        return -EINVAL;
-    }
-
-    while (qemu_get_byte(f)) {
-        elm = g_malloc(size);
-        ret = vmstate_load_state(f, vmsd, elm, version_id);
-        if (ret) {
-            return ret;
-        }
-        QTAILQ_RAW_INSERT_TAIL(pv, elm, entry_offset);
-    }
-
-    trace_get_qtailq_end(vmsd->name, "end", ret);
-    return ret;
-}
-
-/* put for QTAILQ */
-static int put_qtailq(QEMUFile *f, void *pv, size_t unused_size,
-                      VMStateField *field, QJSON *vmdesc)
-{
-    const VMStateDescription *vmsd = field->vmsd;
-    /* offset of the QTAILQ entry in a QTAILQ element*/
-    size_t entry_offset = field->start;
-    void *elm;
-
-    trace_put_qtailq(vmsd->name, vmsd->version_id);
-
-    QTAILQ_RAW_FOREACH(elm, pv, entry_offset) {
-        qemu_put_byte(f, true);
-        vmstate_save_state(f, vmsd, elm, vmdesc);
-    }
-    qemu_put_byte(f, false);
-
-    trace_put_qtailq_end(vmsd->name, "end");
-
-    return 0;
-}
-const VMStateInfo vmstate_info_qtailq = {
-    .name = "qtailq",
-    .get  = get_qtailq,
-    .put  = put_qtailq,
-};
tests/Makefile.include +1 -1
index abdea89..f1f03b5 100644
@@ -570,7 +570,7 @@ tests/test-qdev-global-props$(EXESUF): tests/test-qdev-global-props.o \
 	hw/core/reset.o \
 	$(test-qapi-obj-y)
 tests/test-vmstate$(EXESUF): tests/test-vmstate.o \
-	migration/vmstate.o migration/qemu-file.o \
+	migration/vmstate.o migration/vmstate-types.o migration/qemu-file.o \
         migration/qemu-file-channel.o migration/qjson.o \
 	$(test-io-obj-y)
 tests/test-timed-average$(EXESUF): tests/test-timed-average.o $(test-util-obj-y)
Signature · 1 line
2.9.3

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

#14 lore raw

Re: [Qemu-devel] [PATCH 09/12] migration: Split vmstate-types.c from vmstate.c

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

Now one just has the interperter, and the other has the basic types. Once there, add copyright boilerplate.

I think this is generally OK, but as discussed on IRC, I think you need to check the licenses.

Changed to GPLv2 or later.

I just copied that from savevm.c, I should have known better and read it O:-)

Later, Juan.

#15 lore raw

PATCH v3 10/12 migration: Remove qemu-file.h from vmstate.h

In reply to Juan Quintela

--

minor rearangements due to the rebase

---
 include/hw/hw.h             | 1 +
 include/migration/vmstate.h | 3 ---
 migration/block.c           | 1 +
 migration/colo.c            | 1 +
 migration/postcopy-ram.c    | 1 +
 migration/ram.c             | 1 +
 tests/test-vmstate.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 dacb052..f97411d 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 fcfa823..d2923b3 100644
@@ -26,6 +26,7 @@
 #include "migration/block.h"
 #include "migration/migration.h"
 #include "sysemu/blockdev.h"
+#include "migration/qemu-file.h"
 #include "sysemu/block-backend.h"
 
 #define BLOCK_SIZE                       (1 << 20)
migration/colo.c +1 -0
index 4b9a23c..95f5b6e2 100644
@@ -15,6 +15,7 @@
 #include "sysemu/sysemu.h"
 #include "qemu-file-channel.h"
 #include "migration/migration.h"
+#include "migration/qemu-file.h"
 #include "migration/colo.h"
 #include "migration/block.h"
 #include "io/channel-buffer.h"
migration/postcopy-ram.c +1 -0
index cdadaf6..019e031 100644
@@ -20,6 +20,7 @@
 
 #include "qemu-common.h"
 #include "migration/migration.h"
+#include "migration/qemu-file.h"
 #include "postcopy-ram.h"
 #include "sysemu/sysemu.h"
 #include "sysemu/balloon.h"
migration/ram.c +1 -0
index 7a5f5fa..ce5019b 100644
@@ -37,6 +37,7 @@
 #include "qemu/main-loop.h"
 #include "xbzrle.h"
 #include "migration/migration.h"
+#include "migration/qemu-file.h"
 #include "postcopy-ram.h"
 #include "exec/address-spaces.h"
 #include "migration/page_cache.h"
tests/test-vmstate.c +1 -0
index 1c13570..25389bc 100644
@@ -27,6 +27,7 @@
 #include "qemu-common.h"
 #include "migration/migration.h"
 #include "migration/vmstate.h"
+#include "migration/qemu-file.h"
 #include "../migration/qemu-file-channel.h"
 #include "qemu/coroutine.h"
 #include "io/channel-file.h"
Signature · 1 line
2.9.3
#16 lore raw

PATCH v3 11/12 migration: Remove vmstate.h from migration.h

In reply to Juan Quintela

--

Minor rearrangements due to rebase

---
 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 5ae21e6..a564ecd 100644
@@ -18,7 +18,6 @@
 #include "qemu-common.h"
 #include "qemu/thread.h"
 #include "qemu/notify.h"
-#include "migration/vmstate.h"
 #include "io/channel.h"
 #include "qapi-types.h"
 #include "exec/cpu-common.h"
migration/block.c +1 -0
index d2923b3..c919787 100644
@@ -27,6 +27,7 @@
 #include "migration/migration.h"
 #include "sysemu/blockdev.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 9b35027..b4288b8 100644
@@ -13,6 +13,7 @@
 
 #include "qemu/osdep.h"
 #include "migration/migration.h"
+#include "migration/vmstate.h"
 #include "colo.h"
 #include "trace.h"
 
migration/migration.c +1 -0
index a5a17fe..7ac09f0 100644
@@ -21,6 +21,7 @@
 #include "migration/migration.h"
 #include "qemu-file-channel.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 ce5019b..abd97d9 100644
@@ -38,6 +38,7 @@
 #include "xbzrle.h"
 #include "migration/migration.h"
 #include "migration/qemu-file.h"
+#include "migration/vmstate.h"
 #include "postcopy-ram.h"
 #include "exec/address-spaces.h"
 #include "migration/page_cache.h"
Signature · 1 line
2.9.3
Reviewed-by on v3 11/12
#17 lore raw

Re: [Qemu-devel] [PATCH 11/12] migration: Remove vmstate.h from migration.h

Quoted 2 lines · Juan Quintela
Quoted 73 lines

--

Minor rearrangements due to rebase

---
 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 5ae21e6..a564ecd 100644
@@ -18,7 +18,6 @@
 #include "qemu-common.h"
 #include "qemu/thread.h"
 #include "qemu/notify.h"
-#include "migration/vmstate.h"
 #include "io/channel.h"
 #include "qapi-types.h"
 #include "exec/cpu-common.h"
migration/block.c +1 -0
index d2923b3..c919787 100644
@@ -27,6 +27,7 @@
 #include "migration/migration.h"
 #include "sysemu/blockdev.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 9b35027..b4288b8 100644
@@ -13,6 +13,7 @@
 
 #include "qemu/osdep.h"
 #include "migration/migration.h"
+#include "migration/vmstate.h"
 #include "colo.h"
 #include "trace.h"
 
migration/migration.c +1 -0
index a5a17fe..7ac09f0 100644
@@ -21,6 +21,7 @@
 #include "migration/migration.h"
 #include "qemu-file-channel.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 ce5019b..abd97d9 100644
@@ -38,6 +38,7 @@
 #include "xbzrle.h"
 #include "migration/migration.h"
 #include "migration/qemu-file.h"
+#include "migration/vmstate.h"
 #include "postcopy-ram.h"
 #include "exec/address-spaces.h"
 #include "migration/page_cache.h"
#18 lore raw

PATCH v3 12/12 migration: migration.h was not needed

In reply to Juan Quintela

This files don't use any function from migration.h, so drop it.

---
 block/qed.c             | 1 -
 hw/i386/pc_q35.c        | 1 -
 hw/virtio/vhost-user.c  | 1 -
 hw/virtio/vhost-vsock.c | 1 -
 hw/virtio/virtio.c      | 1 -
 monitor.c               | 1 -
 6 files changed, 6 deletions(-)
block/qed.c +0 -1
index fd76817..8d899fd 100644
@@ -19,7 +19,6 @@
 #include "trace.h"
 #include "qed.h"
 #include "qapi/qmp/qerror.h"
-#include "migration/migration.h"
 #include "sysemu/block-backend.h"
 
 static const AIOCBInfo qed_aiocb_info = {
hw/i386/pc_q35.c +0 -1
index dd792a8..76b08f8 100644
@@ -46,7 +46,6 @@
 #include "hw/ide/ahci.h"
 #include "hw/usb.h"
 #include "qemu/error-report.h"
-#include "migration/migration.h"
 
 /* ICH9 AHCI has 6 ports */
 #define MAX_SATA_PORTS     6
hw/virtio/vhost-user.c +0 -1
index 9334a8a..ebc8ccf 100644
@@ -17,7 +17,6 @@
 #include "sysemu/kvm.h"
 #include "qemu/error-report.h"
 #include "qemu/sockets.h"
-#include "migration/migration.h"
 
 #include <sys/ioctl.h>
 #include <sys/socket.h>
hw/virtio/vhost-vsock.c +0 -1
index b481562..49e0022 100644
@@ -17,7 +17,6 @@
 #include "qapi/error.h"
 #include "hw/virtio/virtio-bus.h"
 #include "hw/virtio/virtio-access.h"
-#include "migration/migration.h"
 #include "qemu/error-report.h"
 #include "hw/virtio/vhost-vsock.h"
 #include "qemu/iov.h"
hw/virtio/virtio.c +0 -1
index 03592c5..2d2b6bf 100644
@@ -21,7 +21,6 @@
 #include "hw/virtio/virtio.h"
 #include "qemu/atomic.h"
 #include "hw/virtio/virtio-bus.h"
-#include "migration/migration.h"
 #include "hw/virtio/virtio-access.h"
 #include "sysemu/dma.h"
 
monitor.c +0 -1
index 078cba5..fa295c4 100644
@@ -49,7 +49,6 @@
 #include "disas/disas.h"
 #include "sysemu/balloon.h"
 #include "qemu/timer.h"
-#include "migration/migration.h"
 #include "sysemu/hw_accel.h"
 #include "qemu/acl.h"
 #include "sysemu/tpm.h"
Signature · 1 line
2.9.3
#19 lore raw

Re: [Qemu-devel] [PATCH 12/12] migration: migration.h was not needed

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

This files don't use any function from migration.h, so drop it.

---
 block/qed.c             | 1 -
 hw/i386/pc_q35.c        | 1 -
 hw/virtio/vhost-user.c  | 1 -
 hw/virtio/vhost-vsock.c | 1 -
 hw/virtio/virtio.c      | 1 -
 monitor.c               | 1 -
 6 files changed, 6 deletions(-)
block/qed.c +0 -1
index fd76817..8d899fd 100644
@@ -19,7 +19,6 @@
 #include "trace.h"
 #include "qed.h"
 #include "qapi/qmp/qerror.h"
-#include "migration/migration.h"
 #include "sysemu/block-backend.h"
 
 static const AIOCBInfo qed_aiocb_info = {
hw/i386/pc_q35.c +0 -1
index dd792a8..76b08f8 100644
@@ -46,7 +46,6 @@
 #include "hw/ide/ahci.h"
 #include "hw/usb.h"
 #include "qemu/error-report.h"
-#include "migration/migration.h"
 
 /* ICH9 AHCI has 6 ports */
 #define MAX_SATA_PORTS     6
hw/virtio/vhost-user.c +0 -1
index 9334a8a..ebc8ccf 100644
@@ -17,7 +17,6 @@
 #include "sysemu/kvm.h"
 #include "qemu/error-report.h"
 #include "qemu/sockets.h"
-#include "migration/migration.h"
 
 #include <sys/ioctl.h>
 #include <sys/socket.h>
hw/virtio/vhost-vsock.c +0 -0
index b481562..49e0022 100644

hw/virtio/vhost-vsock.c line 22

Quoted 7 lines
hw/virtio/vhost-vsock.c +0 -1
@@ -17,7 +17,6 @@
 #include "qapi/error.h"
 #include "hw/virtio/virtio-bus.h"
 #include "hw/virtio/virtio-access.h"
-#include "migration/migration.h"
 #include "qemu/error-report.h"
 #include "hw/virtio/vhost-vsock.h"
 #include "qemu/iov.h"

Aren't these including it to get vmstate macros?
but have they picked up that instead somewhere?

Dave

Quoted 27 lines
hw/virtio/virtio.c +0 -1
index 03592c5..2d2b6bf 100644
@@ -21,7 +21,6 @@
 #include "hw/virtio/virtio.h"
 #include "qemu/atomic.h"
 #include "hw/virtio/virtio-bus.h"
-#include "migration/migration.h"
 #include "hw/virtio/virtio-access.h"
 #include "sysemu/dma.h"
 
monitor.c +0 -1
index 078cba5..fa295c4 100644
@@ -49,7 +49,6 @@
 #include "disas/disas.h"
 #include "sysemu/balloon.h"
 #include "qemu/timer.h"
-#include "migration/migration.h"
 #include "sysemu/hw_accel.h"
 #include "qemu/acl.h"
 #include "sysemu/tpm.h"
Signature · 1 line
2.9.3

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

#20 lore raw

Re: [Qemu-devel] [PATCH 12/12] migration: migration.h was not needed

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

This files don't use any function from migration.h, so drop it.

---
 block/qed.c             | 1 -
 hw/i386/pc_q35.c        | 1 -
 hw/virtio/vhost-user.c  | 1 -
 hw/virtio/vhost-vsock.c | 1 -
 hw/virtio/virtio.c      | 1 -
 monitor.c               | 1 -
 6 files changed, 6 deletions(-)
block/qed.c +0 -1
index fd76817..8d899fd 100644
@@ -19,7 +19,6 @@
 #include "trace.h"
 #include "qed.h"
 #include "qapi/qmp/qerror.h"
-#include "migration/migration.h"
 #include "sysemu/block-backend.h"
 
 static const AIOCBInfo qed_aiocb_info = {
hw/i386/pc_q35.c +0 -1
index dd792a8..76b08f8 100644
@@ -46,7 +46,6 @@
 #include "hw/ide/ahci.h"
 #include "hw/usb.h"
 #include "qemu/error-report.h"
-#include "migration/migration.h"
 
 /* ICH9 AHCI has 6 ports */
 #define MAX_SATA_PORTS     6
hw/virtio/vhost-user.c +0 -1
index 9334a8a..ebc8ccf 100644
@@ -17,7 +17,6 @@
 #include "sysemu/kvm.h"
 #include "qemu/error-report.h"
 #include "qemu/sockets.h"
-#include "migration/migration.h"
 
 #include <sys/ioctl.h>
 #include <sys/socket.h>
hw/virtio/vhost-vsock.c +0 -0
index b481562..49e0022 100644
@@ -17,7 +17,6 @@
 #include "qapi/error.h"
 #include "hw/virtio/virtio-bus.h"
Quoted 8 lines

hw/virtio/vhost-vsock.c line 22

Quoted 5 lines
hw/virtio/vhost-vsock.c +0 -1
 #include "hw/virtio/virtio-access.h"
-#include "migration/migration.h"
 #include "qemu/error-report.h"
 #include "hw/virtio/vhost-vsock.h"
 #include "qemu/iov.h"

Aren't these including it to get vmstate macros?
but have they picked up that instead somewhere?

hw/hw.h

hw/virtio/vhost-vsock.h -> hw/virtio/virtio.h -> hw/hw.h

Dropping vmstate.h from that file would have mean have to add one hundred new includes or so. And I didn't see any good reason for that.

My understanding is that all devices end including hw/hw.h one way or another, so the only reason to add migration include files right now is:
- you use old registartion functions
- you use blockers
- you use migration notifiers

Otherwise, if you just use vmstate macros, they are there by hw/hw.h.

Later, Juan.