* [Qemu-devel] [PATCH v3 00/12] Migration mini-cleanup
@ 2017-05-12 16:00 Juan Quintela
2017-05-12 16:00 ` [Qemu-devel] [PATCH 01/12] migration: Create migration/xbzrle.h Juan Quintela
` (11 more replies)
0 siblings, 12 replies; 21+ messages in thread
From: Juan Quintela @ 2017-05-12 16:00 UTC (permalink / raw)
To: qemu-devel; +Cc: dgilbert, lvivier, peterx
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
--
2.9.3
^ permalink raw reply [flat|nested] 21+ messages in thread
* [Qemu-devel] [PATCH 01/12] migration: Create migration/xbzrle.h
2017-05-12 16:00 [Qemu-devel] [PATCH v3 00/12] Migration mini-cleanup Juan Quintela
@ 2017-05-12 16:00 ` Juan Quintela
2017-05-12 16:00 ` [Qemu-devel] [PATCH 02/12] migration: Split migration/channel.c for channel operations Juan Quintela
` (10 subsequent siblings)
11 siblings, 0 replies; 21+ messages in thread
From: Juan Quintela @ 2017-05-12 16:00 UTC (permalink / raw)
To: qemu-devel; +Cc: dgilbert, lvivier, peterx
Signed-off-by: Juan Quintela <quintela@redhat.com>
---
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
diff --git a/include/migration/migration.h b/include/migration/migration.h
index 7ce3a7e..ae181a4 100644
--- a/include/migration/migration.h
+++ b/include/migration/migration.h
@@ -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);
diff --git a/migration/ram.c b/migration/ram.c
index 76c118c..2564c00 100644
--- a/migration/ram.c
+++ b/migration/ram.c
@@ -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"
diff --git a/migration/xbzrle.c b/migration/xbzrle.c
index c858339..1ba482d 100644
--- a/migration/xbzrle.c
+++ b/migration/xbzrle.c
@@ -12,7 +12,7 @@
*/
#include "qemu/osdep.h"
#include "qemu/cutils.h"
-#include "include/migration/migration.h"
+#include "xbzrle.h"
/*
page = zrun nzrun
diff --git a/migration/xbzrle.h b/migration/xbzrle.h
new file mode 100644
index 0000000..a0db507
--- /dev/null
+++ b/migration/xbzrle.h
@@ -0,0 +1,21 @@
+/*
+ * QEMU live migration
+ *
+ * Copyright IBM, Corp. 2008
+ *
+ * Authors:
+ * Anthony Liguori <aliguori@us.ibm.com>
+ *
+ * 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
diff --git a/tests/test-xbzrle.c b/tests/test-xbzrle.c
index 49f6419..f5e08de 100644
--- a/tests/test-xbzrle.c
+++ b/tests/test-xbzrle.c
@@ -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
--
2.9.3
^ permalink raw reply related [flat|nested] 21+ messages in thread
* [Qemu-devel] [PATCH 02/12] migration: Split migration/channel.c for channel operations
2017-05-12 16:00 [Qemu-devel] [PATCH v3 00/12] Migration mini-cleanup Juan Quintela
2017-05-12 16:00 ` [Qemu-devel] [PATCH 01/12] migration: Create migration/xbzrle.h Juan Quintela
@ 2017-05-12 16:00 ` Juan Quintela
2017-05-12 16:00 ` [Qemu-devel] [PATCH 03/12] migration: Export qemu-file-channel.c functions in its own file Juan Quintela
` (9 subsequent siblings)
11 siblings, 0 replies; 21+ messages in thread
From: Juan Quintela @ 2017-05-12 16:00 UTC (permalink / raw)
To: qemu-devel; +Cc: dgilbert, lvivier, peterx
Create an include for its exported functions.
Signed-off-by: Juan Quintela <quintela@redhat.com>
---
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
diff --git a/include/migration/migration.h b/include/migration/migration.h
index ae181a4..5f1136c 100644
--- a/include/migration/migration.h
+++ b/include/migration/migration.h
@@ -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,
diff --git a/migration/Makefile.objs b/migration/Makefile.objs
index 480dd49..c83ca92 100644
--- a/migration/Makefile.objs
+++ b/migration/Makefile.objs
@@ -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
diff --git a/migration/channel.c b/migration/channel.c
new file mode 100644
index 0000000..6104de5
--- /dev/null
+++ b/migration/channel.c
@@ -0,0 +1,69 @@
+/*
+ * QEMU live migration
+ *
+ * Copyright IBM, Corp. 2008
+ *
+ * Authors:
+ * Anthony Liguori <aliguori@us.ibm.com>
+ *
+ * This work is licensed under the terms of the GNU GPL, version 2. See
+ * the COPYING file in the top-level directory.
+ *
+ * Contributions after 2012-01-13 are licensed under the terms of the
+ * GNU GPL, version 2 or (at your option) any later version.
+ */
+
+#include "qemu/osdep.h"
+#include "channel.h"
+#include "migration/migration.h"
+#include "trace.h"
+#include "qapi/error.h"
+#include "io/channel-tls.h"
+
+void migration_channel_process_incoming(MigrationState *s,
+ QIOChannel *ioc)
+{
+ trace_migration_set_incoming_channel(
+ ioc, object_get_typename(OBJECT(ioc)));
+
+ if (s->parameters.tls_creds &&
+ *s->parameters.tls_creds &&
+ !object_dynamic_cast(OBJECT(ioc),
+ TYPE_QIO_CHANNEL_TLS)) {
+ Error *local_err = NULL;
+ migration_tls_channel_process_incoming(s, ioc, &local_err);
+ if (local_err) {
+ error_report_err(local_err);
+ }
+ } else {
+ QEMUFile *f = qemu_fopen_channel_input(ioc);
+ migration_fd_process_incoming(f);
+ }
+}
+
+
+void migration_channel_connect(MigrationState *s,
+ QIOChannel *ioc,
+ const char *hostname)
+{
+ trace_migration_set_outgoing_channel(
+ ioc, object_get_typename(OBJECT(ioc)), hostname);
+
+ if (s->parameters.tls_creds &&
+ *s->parameters.tls_creds &&
+ !object_dynamic_cast(OBJECT(ioc),
+ TYPE_QIO_CHANNEL_TLS)) {
+ Error *local_err = NULL;
+ migration_tls_channel_connect(s, ioc, hostname, &local_err);
+ if (local_err) {
+ migrate_fd_error(s, local_err);
+ error_free(local_err);
+ }
+ } else {
+ QEMUFile *f = qemu_fopen_channel_output(ioc);
+
+ s->to_dst_file = f;
+
+ migrate_fd_connect(s);
+ }
+}
diff --git a/migration/channel.h b/migration/channel.h
new file mode 100644
index 0000000..618acb7
--- /dev/null
+++ b/migration/channel.h
@@ -0,0 +1,25 @@
+/*
+ * QEMU live migration channel functions
+ *
+ * Copyright IBM, Corp. 2008
+ *
+ * Authors:
+ * Anthony Liguori <aliguori@us.ibm.com>
+ *
+ * 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
diff --git a/migration/exec.c b/migration/exec.c
index aba9089..57a9335 100644
--- a/migration/exec.c
+++ b/migration/exec.c
@@ -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"
diff --git a/migration/fd.c b/migration/fd.c
index 58cb51a..05e0a5c 100644
--- a/migration/fd.c
+++ b/migration/fd.c
@@ -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"
diff --git a/migration/migration.c b/migration/migration.c
index 55c3958..303dfba 100644
--- a/migration/migration.c
+++ b/migration/migration.c
@@ -460,56 +460,6 @@ void migration_fd_process_incoming(QEMUFile *f)
qemu_coroutine_enter(co);
}
-
-void migration_channel_process_incoming(MigrationState *s,
- QIOChannel *ioc)
-{
- trace_migration_set_incoming_channel(
- ioc, object_get_typename(OBJECT(ioc)));
-
- if (s->parameters.tls_creds &&
- *s->parameters.tls_creds &&
- !object_dynamic_cast(OBJECT(ioc),
- TYPE_QIO_CHANNEL_TLS)) {
- Error *local_err = NULL;
- migration_tls_channel_process_incoming(s, ioc, &local_err);
- if (local_err) {
- error_report_err(local_err);
- }
- } else {
- QEMUFile *f = qemu_fopen_channel_input(ioc);
- migration_fd_process_incoming(f);
- }
-}
-
-
-void migration_channel_connect(MigrationState *s,
- QIOChannel *ioc,
- const char *hostname)
-{
- trace_migration_set_outgoing_channel(
- ioc, object_get_typename(OBJECT(ioc)), hostname);
-
- if (s->parameters.tls_creds &&
- *s->parameters.tls_creds &&
- !object_dynamic_cast(OBJECT(ioc),
- TYPE_QIO_CHANNEL_TLS)) {
- Error *local_err = NULL;
- migration_tls_channel_connect(s, ioc, hostname, &local_err);
- if (local_err) {
- migrate_fd_error(s, local_err);
- error_free(local_err);
- }
- } else {
- QEMUFile *f = qemu_fopen_channel_output(ioc);
-
- s->to_dst_file = f;
-
- migrate_fd_connect(s);
- }
-}
-
-
/*
* Send a message on the return channel back to the source
* of the migration.
diff --git a/migration/socket.c b/migration/socket.c
index 1cfbe81..53f9d61 100644
--- a/migration/socket.c
+++ b/migration/socket.c
@@ -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"
diff --git a/migration/tls.c b/migration/tls.c
index a33ecb7..34ad121 100644
--- a/migration/tls.c
+++ b/migration/tls.c
@@ -19,6 +19,7 @@
*/
#include "qemu/osdep.h"
+#include "channel.h"
#include "migration/migration.h"
#include "io/channel-tls.h"
#include "crypto/tlscreds.h"
--
2.9.3
^ permalink raw reply related [flat|nested] 21+ messages in thread
* [Qemu-devel] [PATCH 03/12] migration: Export qemu-file-channel.c functions in its own file
2017-05-12 16:00 [Qemu-devel] [PATCH v3 00/12] Migration mini-cleanup Juan Quintela
2017-05-12 16:00 ` [Qemu-devel] [PATCH 01/12] migration: Create migration/xbzrle.h Juan Quintela
2017-05-12 16:00 ` [Qemu-devel] [PATCH 02/12] migration: Split migration/channel.c for channel operations Juan Quintela
@ 2017-05-12 16:00 ` Juan Quintela
2017-05-12 16:00 ` [Qemu-devel] [PATCH 04/12] migration: Remove migration.h from colo.h Juan Quintela
` (8 subsequent siblings)
11 siblings, 0 replies; 21+ messages in thread
From: Juan Quintela @ 2017-05-12 16:00 UTC (permalink / raw)
To: qemu-devel; +Cc: dgilbert, lvivier, peterx
Signed-off-by: Juan Quintela <quintela@redhat.com>
---
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
diff --git a/include/migration/migration.h b/include/migration/migration.h
index 5f1136c..5ae21e6 100644
--- a/include/migration/migration.h
+++ b/include/migration/migration.h
@@ -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"
diff --git a/include/migration/qemu-file.h b/include/migration/qemu-file.h
index 0cd648a..b5ac800 100644
--- a/include/migration/qemu-file.h
+++ b/include/migration/qemu-file.h
@@ -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);
diff --git a/migration/channel.c b/migration/channel.c
index 6104de5..fed8563 100644
--- a/migration/channel.c
+++ b/migration/channel.c
@@ -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"
diff --git a/migration/colo.c b/migration/colo.c
index 430bae5..65993d3 100644
--- a/migration/colo.c
+++ b/migration/colo.c
@@ -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"
diff --git a/migration/migration.c b/migration/migration.c
index 303dfba..ad5ed14 100644
--- a/migration/migration.c
+++ b/migration/migration.c
@@ -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"
diff --git a/migration/qemu-file-channel.c b/migration/qemu-file-channel.c
index 45c13f1..dc991c9 100644
--- a/migration/qemu-file-channel.c
+++ b/migration/qemu-file-channel.c
@@ -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"
diff --git a/migration/qemu-file-channel.h b/migration/qemu-file-channel.h
new file mode 100644
index 0000000..d1bd5ff
--- /dev/null
+++ b/migration/qemu-file-channel.h
@@ -0,0 +1,21 @@
+/*
+ * QEMU migration file channel operations
+ *
+ * Copyright IBM, Corp. 2008
+ *
+ * Authors:
+ * Anthony Liguori <aliguori@us.ibm.com>
+ *
+ * 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
diff --git a/migration/rdma.c b/migration/rdma.c
index 7eaaf96..166cd60 100644
--- a/migration/rdma.c
+++ b/migration/rdma.c
@@ -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"
diff --git a/migration/savevm.c b/migration/savevm.c
index de85e06..5120c51 100644
--- a/migration/savevm.c
+++ b/migration/savevm.c
@@ -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"
diff --git a/tests/test-vmstate.c b/tests/test-vmstate.c
index f694a89..1c13570 100644
--- a/tests/test-vmstate.c
+++ b/tests/test-vmstate.c
@@ -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"
--
2.9.3
^ permalink raw reply related [flat|nested] 21+ messages in thread
* [Qemu-devel] [PATCH 04/12] migration: Remove migration.h from colo.h
2017-05-12 16:00 [Qemu-devel] [PATCH v3 00/12] Migration mini-cleanup Juan Quintela
` (2 preceding siblings ...)
2017-05-12 16:00 ` [Qemu-devel] [PATCH 03/12] migration: Export qemu-file-channel.c functions in its own file Juan Quintela
@ 2017-05-12 16:00 ` Juan Quintela
2017-05-12 16:00 ` [Qemu-devel] [PATCH 05/12] migration: Move colo.h to migration/ Juan Quintela
` (7 subsequent siblings)
11 siblings, 0 replies; 21+ messages in thread
From: Juan Quintela @ 2017-05-12 16:00 UTC (permalink / raw)
To: qemu-devel; +Cc: dgilbert, lvivier, peterx
migration.h is not included in any includes now.
Signed-off-by: Juan Quintela <quintela@redhat.com>
---
include/migration/colo.h | 1 -
migration/colo-comm.c | 3 ++-
migration/colo.c | 1 +
3 files changed, 3 insertions(+), 2 deletions(-)
diff --git a/include/migration/colo.h b/include/migration/colo.h
index 2bbff9e..ba0bb6e 100644
--- a/include/migration/colo.h
+++ b/include/migration/colo.h
@@ -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"
diff --git a/migration/colo-comm.c b/migration/colo-comm.c
index 20b60ec..3d91798 100644
--- a/migration/colo-comm.c
+++ b/migration/colo-comm.c
@@ -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 {
diff --git a/migration/colo.c b/migration/colo.c
index 65993d3..a3834e6 100644
--- a/migration/colo.c
+++ b/migration/colo.c
@@ -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"
--
2.9.3
^ permalink raw reply related [flat|nested] 21+ messages in thread
* [Qemu-devel] [PATCH 05/12] migration: Move colo.h to migration/
2017-05-12 16:00 [Qemu-devel] [PATCH v3 00/12] Migration mini-cleanup Juan Quintela
` (3 preceding siblings ...)
2017-05-12 16:00 ` [Qemu-devel] [PATCH 04/12] migration: Remove migration.h from colo.h Juan Quintela
@ 2017-05-12 16:00 ` Juan Quintela
2017-05-12 17:51 ` Dr. David Alan Gilbert
2017-05-12 16:00 ` [Qemu-devel] [PATCH 06/12] migration: Move failover.h to migration/colo-failover.h Juan Quintela
` (6 subsequent siblings)
11 siblings, 1 reply; 21+ messages in thread
From: Juan Quintela @ 2017-05-12 16:00 UTC (permalink / raw)
To: qemu-devel; +Cc: dgilbert, lvivier, peterx
There are functions only used by migration code.
Signed-off-by: Juan Quintela <quintela@redhat.com>
---
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%)
diff --git a/MAINTAINERS b/MAINTAINERS
index 0e8d731..e834876 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -1537,7 +1537,7 @@ COLO Framework
M: zhanghailiang <zhang.zhanghailiang@huawei.com>
S: Maintained
F: migration/colo*
-F: include/migration/colo.h
+F: migration/colo.h
F: include/migration/failover.h
F: docs/COLO-FT.txt
diff --git a/migration/colo-comm.c b/migration/colo-comm.c
index 3d91798..9b35027 100644
--- a/migration/colo-comm.c
+++ b/migration/colo-comm.c
@@ -13,7 +13,7 @@
#include "qemu/osdep.h"
#include "migration/migration.h"
-#include "migration/colo.h"
+#include "colo.h"
#include "trace.h"
typedef struct {
diff --git a/migration/colo-failover.c b/migration/colo-failover.c
index cc229f5..29b8d63 100644
--- a/migration/colo-failover.c
+++ b/migration/colo-failover.c
@@ -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"
diff --git a/include/migration/colo.h b/migration/colo.h
similarity index 100%
rename from include/migration/colo.h
rename to migration/colo.h
diff --git a/migration/migration.c b/migration/migration.c
index ad5ed14..a5a17fe 100644
--- a/migration/migration.c
+++ b/migration/migration.c
@@ -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 */
diff --git a/migration/ram.c b/migration/ram.c
index 2564c00..7a5f5fa 100644
--- a/migration/ram.c
+++ b/migration/ram.c
@@ -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 */
--
2.9.3
^ permalink raw reply related [flat|nested] 21+ messages in thread
* [Qemu-devel] [PATCH 06/12] migration: Move failover.h to migration/colo-failover.h
2017-05-12 16:00 [Qemu-devel] [PATCH v3 00/12] Migration mini-cleanup Juan Quintela
` (4 preceding siblings ...)
2017-05-12 16:00 ` [Qemu-devel] [PATCH 05/12] migration: Move colo.h to migration/ Juan Quintela
@ 2017-05-12 16:00 ` Juan Quintela
2017-05-12 16:00 ` [Qemu-devel] [PATCH 07/12] migration: Move page_cache.c to migration/ Juan Quintela
` (5 subsequent siblings)
11 siblings, 0 replies; 21+ messages in thread
From: Juan Quintela @ 2017-05-12 16:00 UTC (permalink / raw)
To: qemu-devel; +Cc: dgilbert, lvivier, peterx
This file is internal for migration/colo code.
Signed-off-by: Juan Quintela <quintela@redhat.com>
---
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%)
diff --git a/MAINTAINERS b/MAINTAINERS
index e834876..65cfb05 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -1538,7 +1538,7 @@ M: zhanghailiang <zhang.zhanghailiang@huawei.com>
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
diff --git a/migration/colo-failover.c b/migration/colo-failover.c
index 29b8d63..85c4526 100644
--- a/migration/colo-failover.c
+++ b/migration/colo-failover.c
@@ -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"
diff --git a/include/migration/failover.h b/migration/colo-failover.h
similarity index 100%
rename from include/migration/failover.h
rename to migration/colo-failover.h
diff --git a/migration/colo.c b/migration/colo.c
index a3834e6..4b9a23c 100644
--- a/migration/colo.c
+++ b/migration/colo.c
@@ -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"
--
2.9.3
^ permalink raw reply related [flat|nested] 21+ messages in thread
* [Qemu-devel] [PATCH 07/12] migration: Move page_cache.c to migration/
2017-05-12 16:00 [Qemu-devel] [PATCH v3 00/12] Migration mini-cleanup Juan Quintela
` (5 preceding siblings ...)
2017-05-12 16:00 ` [Qemu-devel] [PATCH 06/12] migration: Move failover.h to migration/colo-failover.h Juan Quintela
@ 2017-05-12 16:00 ` Juan Quintela
2017-05-12 16:00 ` [Qemu-devel] [PATCH 08/12] migration: Move qjson.h " Juan Quintela
` (4 subsequent siblings)
11 siblings, 0 replies; 21+ messages in thread
From: Juan Quintela @ 2017-05-12 16:00 UTC (permalink / raw)
To: qemu-devel; +Cc: dgilbert, lvivier, peterx
It is only used by migration, so move it there.
Signed-off-by: Juan Quintela <quintela@redhat.com>
---
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%)
diff --git a/Makefile.objs b/Makefile.objs
index 6167e7b..2100845 100644
--- a/Makefile.objs
+++ b/Makefile.objs
@@ -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
diff --git a/migration/Makefile.objs b/migration/Makefile.objs
index c83ca92..ce8ce12 100644
--- a/migration/Makefile.objs
+++ b/migration/Makefile.objs
@@ -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
diff --git a/page_cache.c b/migration/page_cache.c
similarity index 100%
rename from page_cache.c
rename to migration/page_cache.c
diff --git a/include/migration/page_cache.h b/migration/page_cache.h
similarity index 100%
rename from include/migration/page_cache.h
rename to migration/page_cache.h
diff --git a/tests/Makefile.include b/tests/Makefile.include
index 31931c0..abdea89 100644
--- a/tests/Makefile.include
+++ b/tests/Makefile.include
@@ -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)
--
2.9.3
^ permalink raw reply related [flat|nested] 21+ messages in thread
* [Qemu-devel] [PATCH 08/12] migration: Move qjson.h to migration/
2017-05-12 16:00 [Qemu-devel] [PATCH v3 00/12] Migration mini-cleanup Juan Quintela
` (6 preceding siblings ...)
2017-05-12 16:00 ` [Qemu-devel] [PATCH 07/12] migration: Move page_cache.c to migration/ Juan Quintela
@ 2017-05-12 16:00 ` Juan Quintela
2017-05-12 16:00 ` [Qemu-devel] [PATCH 09/12] migration: Split vmstate-types.c from vmstate.c Juan Quintela
` (3 subsequent siblings)
11 siblings, 0 replies; 21+ messages in thread
From: Juan Quintela @ 2017-05-12 16:00 UTC (permalink / raw)
To: qemu-devel; +Cc: dgilbert, lvivier, peterx
It is only used for migration code.
Signed-off-by: Juan Quintela <quintela@redhat.com>
---
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%)
diff --git a/migration/qjson.c b/migration/qjson.c
index f345904..9d7f6eb 100644
--- a/migration/qjson.c
+++ b/migration/qjson.c
@@ -25,7 +25,7 @@
#include "qemu/osdep.h"
#include "qapi/qmp/qstring.h"
-#include "migration/qjson.h"
+#include "qjson.h"
struct QJSON {
QString *str;
diff --git a/include/migration/qjson.h b/migration/qjson.h
similarity index 100%
rename from include/migration/qjson.h
rename to migration/qjson.h
diff --git a/migration/vmstate.c b/migration/vmstate.c
index 7b4a607..66c50ee 100644
--- a/migration/vmstate.c
+++ b/migration/vmstate.c
@@ -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);
--
2.9.3
^ permalink raw reply related [flat|nested] 21+ messages in thread
* [Qemu-devel] [PATCH 09/12] migration: Split vmstate-types.c from vmstate.c
2017-05-12 16:00 [Qemu-devel] [PATCH v3 00/12] Migration mini-cleanup Juan Quintela
` (7 preceding siblings ...)
2017-05-12 16:00 ` [Qemu-devel] [PATCH 08/12] migration: Move qjson.h " Juan Quintela
@ 2017-05-12 16:00 ` Juan Quintela
2017-05-12 17:54 ` Dr. David Alan Gilbert
2017-05-12 16:00 ` [Qemu-devel] [PATCH 10/12] migration: Remove qemu-file.h from vmstate.h Juan Quintela
` (2 subsequent siblings)
11 siblings, 1 reply; 21+ messages in thread
From: Juan Quintela @ 2017-05-12 16:00 UTC (permalink / raw)
To: qemu-devel; +Cc: dgilbert, lvivier, peterx
Now one just has the interperter, and the other has the basic types.
Once there, add copyright boilerplate.
Signed-off-by: Juan Quintela <quintela@redhat.com>
---
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
diff --git a/migration/Makefile.objs b/migration/Makefile.objs
index ce8ce12..812b2ec 100644
--- a/migration/Makefile.objs
+++ b/migration/Makefile.objs
@@ -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
diff --git a/migration/vmstate-types.c b/migration/vmstate-types.c
new file mode 100644
index 0000000..0cf14d4
--- /dev/null
+++ b/migration/vmstate-types.c
@@ -0,0 +1,676 @@
+/*
+ * QEMU System Emulator
+ *
+ * Copyright (c) 2009-2017 Red Hat Inc
+ *
+ * Authors:
+ * Juan Quintela <quintela@redhat.com>
+ *
+ * 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,
+};
diff --git a/migration/vmstate.c b/migration/vmstate.c
index 66c50ee..c284769 100644
--- a/migration/vmstate.c
+++ b/migration/vmstate.c
@@ -1,3 +1,30 @@
+/*
+ * QEMU System Emulator
+ *
+ * Copyright (c) 2009-2017 Red Hat Inc
+ *
+ * Authors:
+ * Juan Quintela <quintela@redhat.com>
+ *
+ * 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,
-};
diff --git a/tests/Makefile.include b/tests/Makefile.include
index abdea89..f1f03b5 100644
--- a/tests/Makefile.include
+++ b/tests/Makefile.include
@@ -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)
--
2.9.3
^ permalink raw reply related [flat|nested] 21+ messages in thread
* [Qemu-devel] [PATCH 10/12] migration: Remove qemu-file.h from vmstate.h
2017-05-12 16:00 [Qemu-devel] [PATCH v3 00/12] Migration mini-cleanup Juan Quintela
` (8 preceding siblings ...)
2017-05-12 16:00 ` [Qemu-devel] [PATCH 09/12] migration: Split vmstate-types.c from vmstate.c Juan Quintela
@ 2017-05-12 16:00 ` Juan Quintela
2017-05-12 16:00 ` [Qemu-devel] [PATCH 11/12] migration: Remove vmstate.h from migration.h Juan Quintela
2017-05-12 16:00 ` [Qemu-devel] [PATCH 12/12] migration: migration.h was not needed Juan Quintela
11 siblings, 0 replies; 21+ messages in thread
From: Juan Quintela @ 2017-05-12 16:00 UTC (permalink / raw)
To: qemu-devel; +Cc: dgilbert, lvivier, peterx
Signed-off-by: Juan Quintela <quintela@redhat.com>
Reviewed-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
--
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(-)
diff --git a/include/hw/hw.h b/include/hw/hw.h
index e22d4ce..af9eae1 100644
--- a/include/hw/hw.h
+++ b/include/hw/hw.h
@@ -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"
diff --git a/include/migration/vmstate.h b/include/migration/vmstate.h
index dacb052..f97411d 100644
--- a/include/migration/vmstate.h
+++ b/include/migration/vmstate.h
@@ -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);
diff --git a/migration/block.c b/migration/block.c
index fcfa823..d2923b3 100644
--- a/migration/block.c
+++ b/migration/block.c
@@ -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)
diff --git a/migration/colo.c b/migration/colo.c
index 4b9a23c..95f5b6e2 100644
--- a/migration/colo.c
+++ b/migration/colo.c
@@ -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"
diff --git a/migration/postcopy-ram.c b/migration/postcopy-ram.c
index cdadaf6..019e031 100644
--- a/migration/postcopy-ram.c
+++ b/migration/postcopy-ram.c
@@ -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"
diff --git a/migration/ram.c b/migration/ram.c
index 7a5f5fa..ce5019b 100644
--- a/migration/ram.c
+++ b/migration/ram.c
@@ -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"
diff --git a/tests/test-vmstate.c b/tests/test-vmstate.c
index 1c13570..25389bc 100644
--- a/tests/test-vmstate.c
+++ b/tests/test-vmstate.c
@@ -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"
--
2.9.3
^ permalink raw reply related [flat|nested] 21+ messages in thread
* [Qemu-devel] [PATCH 11/12] migration: Remove vmstate.h from migration.h
2017-05-12 16:00 [Qemu-devel] [PATCH v3 00/12] Migration mini-cleanup Juan Quintela
` (9 preceding siblings ...)
2017-05-12 16:00 ` [Qemu-devel] [PATCH 10/12] migration: Remove qemu-file.h from vmstate.h Juan Quintela
@ 2017-05-12 16:00 ` Juan Quintela
2017-05-13 21:09 ` Philippe Mathieu-Daudé
2017-05-12 16:00 ` [Qemu-devel] [PATCH 12/12] migration: migration.h was not needed Juan Quintela
11 siblings, 1 reply; 21+ messages in thread
From: Juan Quintela @ 2017-05-12 16:00 UTC (permalink / raw)
To: qemu-devel; +Cc: dgilbert, lvivier, peterx
Signed-off-by: Juan Quintela <quintela@redhat.com>
Reviewed-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
--
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(-)
diff --git a/include/migration/migration.h b/include/migration/migration.h
index 5ae21e6..a564ecd 100644
--- a/include/migration/migration.h
+++ b/include/migration/migration.h
@@ -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"
diff --git a/migration/block.c b/migration/block.c
index d2923b3..c919787 100644
--- a/migration/block.c
+++ b/migration/block.c
@@ -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)
diff --git a/migration/colo-comm.c b/migration/colo-comm.c
index 9b35027..b4288b8 100644
--- a/migration/colo-comm.c
+++ b/migration/colo-comm.c
@@ -13,6 +13,7 @@
#include "qemu/osdep.h"
#include "migration/migration.h"
+#include "migration/vmstate.h"
#include "colo.h"
#include "trace.h"
diff --git a/migration/migration.c b/migration/migration.c
index a5a17fe..7ac09f0 100644
--- a/migration/migration.c
+++ b/migration/migration.c
@@ -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"
diff --git a/migration/ram.c b/migration/ram.c
index ce5019b..abd97d9 100644
--- a/migration/ram.c
+++ b/migration/ram.c
@@ -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"
--
2.9.3
^ permalink raw reply related [flat|nested] 21+ messages in thread
* [Qemu-devel] [PATCH 12/12] migration: migration.h was not needed
2017-05-12 16:00 [Qemu-devel] [PATCH v3 00/12] Migration mini-cleanup Juan Quintela
` (10 preceding siblings ...)
2017-05-12 16:00 ` [Qemu-devel] [PATCH 11/12] migration: Remove vmstate.h from migration.h Juan Quintela
@ 2017-05-12 16:00 ` Juan Quintela
2017-05-12 17:58 ` Dr. David Alan Gilbert
11 siblings, 1 reply; 21+ messages in thread
From: Juan Quintela @ 2017-05-12 16:00 UTC (permalink / raw)
To: qemu-devel; +Cc: dgilbert, lvivier, peterx
This files don't use any function from migration.h, so drop it.
Signed-off-by: Juan Quintela <quintela@redhat.com>
---
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(-)
diff --git a/block/qed.c b/block/qed.c
index fd76817..8d899fd 100644
--- a/block/qed.c
+++ b/block/qed.c
@@ -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 = {
diff --git a/hw/i386/pc_q35.c b/hw/i386/pc_q35.c
index dd792a8..76b08f8 100644
--- a/hw/i386/pc_q35.c
+++ b/hw/i386/pc_q35.c
@@ -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
diff --git a/hw/virtio/vhost-user.c b/hw/virtio/vhost-user.c
index 9334a8a..ebc8ccf 100644
--- a/hw/virtio/vhost-user.c
+++ b/hw/virtio/vhost-user.c
@@ -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>
diff --git a/hw/virtio/vhost-vsock.c b/hw/virtio/vhost-vsock.c
index b481562..49e0022 100644
--- a/hw/virtio/vhost-vsock.c
+++ b/hw/virtio/vhost-vsock.c
@@ -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"
diff --git a/hw/virtio/virtio.c b/hw/virtio/virtio.c
index 03592c5..2d2b6bf 100644
--- a/hw/virtio/virtio.c
+++ b/hw/virtio/virtio.c
@@ -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"
diff --git a/monitor.c b/monitor.c
index 078cba5..fa295c4 100644
--- a/monitor.c
+++ b/monitor.c
@@ -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"
--
2.9.3
^ permalink raw reply related [flat|nested] 21+ messages in thread
* Re: [Qemu-devel] [PATCH 05/12] migration: Move colo.h to migration/
2017-05-12 16:00 ` [Qemu-devel] [PATCH 05/12] migration: Move colo.h to migration/ Juan Quintela
@ 2017-05-12 17:51 ` Dr. David Alan Gilbert
2017-05-15 11:04 ` Juan Quintela
0 siblings, 1 reply; 21+ messages in thread
From: Dr. David Alan Gilbert @ 2017-05-12 17:51 UTC (permalink / raw)
To: Juan Quintela; +Cc: qemu-devel, lvivier, peterx
* Juan Quintela (quintela@redhat.com) 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
> Signed-off-by: Juan Quintela <quintela@redhat.com>
> ---
> 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%)
>
> diff --git a/MAINTAINERS b/MAINTAINERS
> index 0e8d731..e834876 100644
> --- a/MAINTAINERS
> +++ b/MAINTAINERS
> @@ -1537,7 +1537,7 @@ COLO Framework
> M: zhanghailiang <zhang.zhanghailiang@huawei.com>
> S: Maintained
> F: migration/colo*
> -F: include/migration/colo.h
> +F: migration/colo.h
> F: include/migration/failover.h
> F: docs/COLO-FT.txt
>
> diff --git a/migration/colo-comm.c b/migration/colo-comm.c
> index 3d91798..9b35027 100644
> --- a/migration/colo-comm.c
> +++ b/migration/colo-comm.c
> @@ -13,7 +13,7 @@
>
> #include "qemu/osdep.h"
> #include "migration/migration.h"
> -#include "migration/colo.h"
> +#include "colo.h"
> #include "trace.h"
>
> typedef struct {
> diff --git a/migration/colo-failover.c b/migration/colo-failover.c
> index cc229f5..29b8d63 100644
> --- a/migration/colo-failover.c
> +++ b/migration/colo-failover.c
> @@ -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"
> diff --git a/include/migration/colo.h b/migration/colo.h
> similarity index 100%
> rename from include/migration/colo.h
> rename to migration/colo.h
> diff --git a/migration/migration.c b/migration/migration.c
> index ad5ed14..a5a17fe 100644
> --- a/migration/migration.c
> +++ b/migration/migration.c
> @@ -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 */
>
> diff --git a/migration/ram.c b/migration/ram.c
> index 2564c00..7a5f5fa 100644
> --- a/migration/ram.c
> +++ b/migration/ram.c
> @@ -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 */
> --
> 2.9.3
>
--
Dr. David Alan Gilbert / dgilbert@redhat.com / Manchester, UK
^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: [Qemu-devel] [PATCH 09/12] migration: Split vmstate-types.c from vmstate.c
2017-05-12 16:00 ` [Qemu-devel] [PATCH 09/12] migration: Split vmstate-types.c from vmstate.c Juan Quintela
@ 2017-05-12 17:54 ` Dr. David Alan Gilbert
2017-05-15 11:05 ` Juan Quintela
0 siblings, 1 reply; 21+ messages in thread
From: Dr. David Alan Gilbert @ 2017-05-12 17:54 UTC (permalink / raw)
To: Juan Quintela; +Cc: qemu-devel, lvivier, peterx
* Juan Quintela (quintela@redhat.com) wrote:
> Now one just has the interperter, and the other has the basic types.
> Once there, add copyright boilerplate.
>
> Signed-off-by: Juan Quintela <quintela@redhat.com>
I think this is generally OK, but as discussed on IRC, I think
you need to check the licenses.
Dave
> ---
> 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
>
> diff --git a/migration/Makefile.objs b/migration/Makefile.objs
> index ce8ce12..812b2ec 100644
> --- a/migration/Makefile.objs
> +++ b/migration/Makefile.objs
> @@ -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
> diff --git a/migration/vmstate-types.c b/migration/vmstate-types.c
> new file mode 100644
> index 0000000..0cf14d4
> --- /dev/null
> +++ b/migration/vmstate-types.c
> @@ -0,0 +1,676 @@
> +/*
> + * QEMU System Emulator
> + *
> + * Copyright (c) 2009-2017 Red Hat Inc
> + *
> + * Authors:
> + * Juan Quintela <quintela@redhat.com>
> + *
> + * 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,
> +};
> diff --git a/migration/vmstate.c b/migration/vmstate.c
> index 66c50ee..c284769 100644
> --- a/migration/vmstate.c
> +++ b/migration/vmstate.c
> @@ -1,3 +1,30 @@
> +/*
> + * QEMU System Emulator
> + *
> + * Copyright (c) 2009-2017 Red Hat Inc
> + *
> + * Authors:
> + * Juan Quintela <quintela@redhat.com>
> + *
> + * 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,
> -};
> diff --git a/tests/Makefile.include b/tests/Makefile.include
> index abdea89..f1f03b5 100644
> --- a/tests/Makefile.include
> +++ b/tests/Makefile.include
> @@ -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)
> --
> 2.9.3
>
--
Dr. David Alan Gilbert / dgilbert@redhat.com / Manchester, UK
^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: [Qemu-devel] [PATCH 12/12] migration: migration.h was not needed
2017-05-12 16:00 ` [Qemu-devel] [PATCH 12/12] migration: migration.h was not needed Juan Quintela
@ 2017-05-12 17:58 ` Dr. David Alan Gilbert
2017-05-15 11:10 ` Juan Quintela
0 siblings, 1 reply; 21+ messages in thread
From: Dr. David Alan Gilbert @ 2017-05-12 17:58 UTC (permalink / raw)
To: Juan Quintela; +Cc: qemu-devel, lvivier, peterx
* Juan Quintela (quintela@redhat.com) wrote:
> This files don't use any function from migration.h, so drop it.
>
> Signed-off-by: Juan Quintela <quintela@redhat.com>
> ---
> 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(-)
>
> diff --git a/block/qed.c b/block/qed.c
> index fd76817..8d899fd 100644
> --- a/block/qed.c
> +++ b/block/qed.c
> @@ -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 = {
> diff --git a/hw/i386/pc_q35.c b/hw/i386/pc_q35.c
> index dd792a8..76b08f8 100644
> --- a/hw/i386/pc_q35.c
> +++ b/hw/i386/pc_q35.c
> @@ -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
> diff --git a/hw/virtio/vhost-user.c b/hw/virtio/vhost-user.c
> index 9334a8a..ebc8ccf 100644
> --- a/hw/virtio/vhost-user.c
> +++ b/hw/virtio/vhost-user.c
> @@ -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>
> diff --git a/hw/virtio/vhost-vsock.c b/hw/virtio/vhost-vsock.c
> index b481562..49e0022 100644
> --- a/hw/virtio/vhost-vsock.c
> +++ b/hw/virtio/vhost-vsock.c
> @@ -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
> diff --git a/hw/virtio/virtio.c b/hw/virtio/virtio.c
> index 03592c5..2d2b6bf 100644
> --- a/hw/virtio/virtio.c
> +++ b/hw/virtio/virtio.c
> @@ -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"
>
> diff --git a/monitor.c b/monitor.c
> index 078cba5..fa295c4 100644
> --- a/monitor.c
> +++ b/monitor.c
> @@ -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"
> --
> 2.9.3
>
--
Dr. David Alan Gilbert / dgilbert@redhat.com / Manchester, UK
^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: [Qemu-devel] [PATCH 11/12] migration: Remove vmstate.h from migration.h
2017-05-12 16:00 ` [Qemu-devel] [PATCH 11/12] migration: Remove vmstate.h from migration.h Juan Quintela
@ 2017-05-13 21:09 ` Philippe Mathieu-Daudé
0 siblings, 0 replies; 21+ messages in thread
From: Philippe Mathieu-Daudé @ 2017-05-13 21:09 UTC (permalink / raw)
To: Juan Quintela, qemu-devel; +Cc: lvivier, dgilbert, peterx
On 05/12/2017 01:00 PM, Juan Quintela wrote:
> Signed-off-by: Juan Quintela <quintela@redhat.com>
> Reviewed-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
>
> --
>
> 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(-)
>
> diff --git a/include/migration/migration.h b/include/migration/migration.h
> index 5ae21e6..a564ecd 100644
> --- a/include/migration/migration.h
> +++ b/include/migration/migration.h
> @@ -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"
> diff --git a/migration/block.c b/migration/block.c
> index d2923b3..c919787 100644
> --- a/migration/block.c
> +++ b/migration/block.c
> @@ -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)
> diff --git a/migration/colo-comm.c b/migration/colo-comm.c
> index 9b35027..b4288b8 100644
> --- a/migration/colo-comm.c
> +++ b/migration/colo-comm.c
> @@ -13,6 +13,7 @@
>
> #include "qemu/osdep.h"
> #include "migration/migration.h"
> +#include "migration/vmstate.h"
> #include "colo.h"
> #include "trace.h"
>
> diff --git a/migration/migration.c b/migration/migration.c
> index a5a17fe..7ac09f0 100644
> --- a/migration/migration.c
> +++ b/migration/migration.c
> @@ -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"
> diff --git a/migration/ram.c b/migration/ram.c
> index ce5019b..abd97d9 100644
> --- a/migration/ram.c
> +++ b/migration/ram.c
> @@ -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"
>
^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: [Qemu-devel] [PATCH 05/12] migration: Move colo.h to migration/
2017-05-12 17:51 ` Dr. David Alan Gilbert
@ 2017-05-15 11:04 ` Juan Quintela
2017-05-15 12:44 ` Hailiang Zhang
0 siblings, 1 reply; 21+ messages in thread
From: Juan Quintela @ 2017-05-15 11:04 UTC (permalink / raw)
To: Dr. David Alan Gilbert; +Cc: qemu-devel, lvivier, peterx
"Dr. David Alan Gilbert" <dgilbert@redhat.com> wrote:
D> * Juan Quintela (quintela@redhat.com) 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?
Dropped.
It compiled, but who knows O:-)
> 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 ...
^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: [Qemu-devel] [PATCH 09/12] migration: Split vmstate-types.c from vmstate.c
2017-05-12 17:54 ` Dr. David Alan Gilbert
@ 2017-05-15 11:05 ` Juan Quintela
0 siblings, 0 replies; 21+ messages in thread
From: Juan Quintela @ 2017-05-15 11:05 UTC (permalink / raw)
To: Dr. David Alan Gilbert; +Cc: qemu-devel, lvivier, peterx
"Dr. David Alan Gilbert" <dgilbert@redhat.com> wrote:
> * Juan Quintela (quintela@redhat.com) wrote:
>> Now one just has the interperter, and the other has the basic types.
>> Once there, add copyright boilerplate.
>>
>> Signed-off-by: Juan Quintela <quintela@redhat.com>
>
> 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.
^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: [Qemu-devel] [PATCH 12/12] migration: migration.h was not needed
2017-05-12 17:58 ` Dr. David Alan Gilbert
@ 2017-05-15 11:10 ` Juan Quintela
0 siblings, 0 replies; 21+ messages in thread
From: Juan Quintela @ 2017-05-15 11:10 UTC (permalink / raw)
To: Dr. David Alan Gilbert; +Cc: qemu-devel, lvivier, peterx
"Dr. David Alan Gilbert" <dgilbert@redhat.com> wrote:
> * Juan Quintela (quintela@redhat.com) wrote:
>> This files don't use any function from migration.h, so drop it.
>>
>> Signed-off-by: Juan Quintela <quintela@redhat.com>
>> ---
>> 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(-)
>>
>> diff --git a/block/qed.c b/block/qed.c
>> index fd76817..8d899fd 100644
>> --- a/block/qed.c
>> +++ b/block/qed.c
>> @@ -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 = {
>> diff --git a/hw/i386/pc_q35.c b/hw/i386/pc_q35.c
>> index dd792a8..76b08f8 100644
>> --- a/hw/i386/pc_q35.c
>> +++ b/hw/i386/pc_q35.c
>> @@ -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
>> diff --git a/hw/virtio/vhost-user.c b/hw/virtio/vhost-user.c
>> index 9334a8a..ebc8ccf 100644
>> --- a/hw/virtio/vhost-user.c
>> +++ b/hw/virtio/vhost-user.c
>> @@ -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>
>> diff --git a/hw/virtio/vhost-vsock.c b/hw/virtio/vhost-vsock.c
>> index b481562..49e0022 100644
>> --- a/hw/virtio/vhost-vsock.c
>> +++ b/hw/virtio/vhost-vsock.c
>> @@ -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?
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.
^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: [Qemu-devel] [PATCH 05/12] migration: Move colo.h to migration/
2017-05-15 11:04 ` Juan Quintela
@ 2017-05-15 12:44 ` Hailiang Zhang
0 siblings, 0 replies; 21+ messages in thread
From: Hailiang Zhang @ 2017-05-15 12:44 UTC (permalink / raw)
To: quintela, Dr. David Alan Gilbert, Tkid; +Cc: lvivier, qemu-devel, peterx
On 2017/5/15 19:04, Juan Quintela wrote:
> "Dr. David Alan Gilbert" <dgilbert@redhat.com> wrote:
> D> * Juan Quintela (quintela@redhat.com) 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?
> Dropped.
>
> It compiled, but who knows O:-)
>
>> 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 <zhangchen.fnst@cn.fujitsu.com>
> Yeap, it is scary ...
>
>
>
^ permalink raw reply [flat|nested] 21+ messages in thread
end of thread, other threads:[~2017-05-15 12:45 UTC | newest]
Thread overview: 21+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-05-12 16:00 [Qemu-devel] [PATCH v3 00/12] Migration mini-cleanup Juan Quintela
2017-05-12 16:00 ` [Qemu-devel] [PATCH 01/12] migration: Create migration/xbzrle.h Juan Quintela
2017-05-12 16:00 ` [Qemu-devel] [PATCH 02/12] migration: Split migration/channel.c for channel operations Juan Quintela
2017-05-12 16:00 ` [Qemu-devel] [PATCH 03/12] migration: Export qemu-file-channel.c functions in its own file Juan Quintela
2017-05-12 16:00 ` [Qemu-devel] [PATCH 04/12] migration: Remove migration.h from colo.h Juan Quintela
2017-05-12 16:00 ` [Qemu-devel] [PATCH 05/12] migration: Move colo.h to migration/ Juan Quintela
2017-05-12 17:51 ` Dr. David Alan Gilbert
2017-05-15 11:04 ` Juan Quintela
2017-05-15 12:44 ` Hailiang Zhang
2017-05-12 16:00 ` [Qemu-devel] [PATCH 06/12] migration: Move failover.h to migration/colo-failover.h Juan Quintela
2017-05-12 16:00 ` [Qemu-devel] [PATCH 07/12] migration: Move page_cache.c to migration/ Juan Quintela
2017-05-12 16:00 ` [Qemu-devel] [PATCH 08/12] migration: Move qjson.h " Juan Quintela
2017-05-12 16:00 ` [Qemu-devel] [PATCH 09/12] migration: Split vmstate-types.c from vmstate.c Juan Quintela
2017-05-12 17:54 ` Dr. David Alan Gilbert
2017-05-15 11:05 ` Juan Quintela
2017-05-12 16:00 ` [Qemu-devel] [PATCH 10/12] migration: Remove qemu-file.h from vmstate.h Juan Quintela
2017-05-12 16:00 ` [Qemu-devel] [PATCH 11/12] migration: Remove vmstate.h from migration.h Juan Quintela
2017-05-13 21:09 ` Philippe Mathieu-Daudé
2017-05-12 16:00 ` [Qemu-devel] [PATCH 12/12] migration: migration.h was not needed Juan Quintela
2017-05-12 17:58 ` Dr. David Alan Gilbert
2017-05-15 11:10 ` Juan Quintela
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).