Migration mini-cleanup
Subsystems (2)
v3 cover Migration mini-cleanup
Hi
Due to popular demand, and to make reviews easier, I just split the big cleanup series (41 patches) in small chunks. This chunk just include the easy patches:
- create several include files foo.h for functcions exported from foo.c
- split channel operations in channel.c
- move colo headers to migration/
- split vmstate-types.c from vmstate.c (now it only contains the interpreter)
- untangle qemu-file.h, vmstate.h and migration.h. Now none include the other fix all callers.
- Remove uses of migration.h that are not needed
Please, review.
Thanks, Juan.
Juan Quintela (12):
migration: Create migration/xbzrle.h
migration: Split migration/channel.c for channel operations
migration: Export qemu-file-channel.c functions in its own file
migration: Remove migration.h from colo.h
migration: Move colo.h to migration/
migration: Move failover.h to migration/colo-failover.h
migration: Move page_cache.c to migration/
migration: Move qjson.h to migration/
migration: Split vmstate-types.c from vmstate.c
migration: Remove qemu-file.h from vmstate.h
migration: Remove vmstate.h from migration.h
migration: migration.h was not needed
MAINTAINERS | 4 +-
Makefile.objs | 1 -
block/qed.c | 1 -
hw/i386/pc_q35.c | 1 -
hw/virtio/vhost-user.c | 1 -
hw/virtio/vhost-vsock.c | 1 -
hw/virtio/virtio.c | 1 -
include/hw/hw.h | 1 +
include/migration/migration.h | 13 +-
include/migration/qemu-file.h | 4 -
include/migration/vmstate.h | 3 -
migration/Makefile.objs | 4 +-
migration/block.c | 2 +
migration/channel.c | 70 +++
migration/channel.h | 25 +
migration/colo-comm.c | 4 +-
migration/colo-failover.c | 4 +-
.../failover.h => migration/colo-failover.h | 0
migration/colo.c | 5 +-
{include/migration => migration}/colo.h | 1 -
migration/exec.c | 1 +
migration/fd.c | 1 +
migration/migration.c | 54 +-
page_cache.c => migration/page_cache.c | 0
{include/migration => migration}/page_cache.h | 0
migration/postcopy-ram.c | 1 +
migration/qemu-file-channel.c | 1 +
migration/qemu-file-channel.h | 21 +
migration/qjson.c | 2 +-
{include/migration => migration}/qjson.h | 0
migration/ram.c | 5 +-
migration/rdma.c | 1 +
migration/savevm.c | 1 +
migration/socket.c | 1 +
migration/tls.c | 1 +
migration/vmstate-types.c | 676 +++++++++++++++++++++
migration/vmstate.c | 671 +-------------------
migration/xbzrle.c | 2 +-
migration/xbzrle.h | 21 +
monitor.c | 1 -
tests/Makefile.include | 4 +-
tests/test-vmstate.c | 2 +
tests/test-xbzrle.c | 2 +-
43 files changed, 880 insertions(+), 735 deletions(-)
create mode 100644 migration/channel.c
create mode 100644 migration/channel.h
rename include/migration/failover.h => migration/colo-failover.h (100%)
rename {include/migration => migration}/colo.h (96%)
rename page_cache.c => migration/page_cache.c (100%)
rename {include/migration => migration}/page_cache.h (100%)
create mode 100644 migration/qemu-file-channel.h
rename {include/migration => migration}/qjson.h (100%)
create mode 100644 migration/vmstate-types.c
create mode 100644 migration/xbzrle.hSignature · 1 line
2.9.3
PATCH v3 1/12 migration: Create migration/xbzrle.h
--- include/migration/migration.h | 4 ---- migration/ram.c | 1 + migration/xbzrle.c | 2 +- migration/xbzrle.h | 21 +++++++++++++++++++++ tests/test-xbzrle.c | 2 +- 5 files changed, 24 insertions(+), 6 deletions(-) create mode 100644 migration/xbzrle.h
include/migration/migration.h +0 -4
@@ -270,10 +270,6 @@ bool migrate_zero_blocks(void);bool migrate_auto_converge (void ); -int xbzrle_encode_buffer (uint8_t *old_buf,uint8_t *new_buf,int slen, -uint8_t *dst,int dlen); -int xbzrle_decode_buffer (uint8_t *src,int slen,uint8_t *dst,int dlen); -int migrate_use_xbzrle (void );int64_t migrate_xbzrle_cache_size (void );bool migrate_colo_enabled (void );
migration/ram.c +1 -0
@@ -35,6 +35,7 @@#include "qemu/bitmap.h" #include "qemu/timer.h" #include "qemu/main-loop.h" +#include "xbzrle.h" #include "migration/migration.h" #include "postcopy-ram.h" #include "exec/address-spaces.h"
migration/xbzrle.c +1 -1
@@ -12,7 +12,7 @@*/ #include "qemu/osdep.h" #include "qemu/cutils.h" -#include "include/migration/migration.h" +#include "xbzrle.h" /* page = zrun nzrun
migration/xbzrle.h new file +21 -0
@@ -0,0 +1,21 @@ +/* +* QEMU live migration +* +* Copyright IBM, Corp. 2008 +* +* Authors: +* Anthony Liguori <[email protected]> +* +* This work is licensed under the terms of the GNU GPL, version 2. See +* the COPYING file in the top-level directory. +* +*/ + +#ifndef QEMU_MIGRATION_XBZRLE_H +#define QEMU_MIGRATION_XBZRLE_H + +int xbzrle_encode_buffer (uint8_t *old_buf,uint8_t *new_buf,int slen, +uint8_t *dst,int dlen); + +int xbzrle_decode_buffer (uint8_t *src,int slen,uint8_t *dst,int dlen); +#endif
tests/test-xbzrle.c +1 -1
@@ -13,7 +13,7 @@#include "qemu/osdep.h" #include "qemu-common.h" #include "qemu/cutils.h" -#include "include/migration/migration.h" +#include "../migration/xbzrle.h" #define PAGE_SIZE 4096
Signature · 1 line
2.9.3
PATCH v3 2/12 migration: Split migration/channel.c for channel operations
In reply to Juan QuintelaCreate an include for its exported functions.
--- include/migration/migration.h | 7 ----- migration/Makefile.objs | 2 +- migration/channel.c | 69 +++++++++++++++++++++++++++++++++++++++++++ migration/channel.h | 25 ++++++++++++++++ migration/exec.c | 1 + migration/fd.c | 1 + migration/migration.c | 50 ------------------------------- migration/socket.c | 1 + migration/tls.c | 1 + 9 files changed, 99 insertions(+), 58 deletions(-) create mode 100644 migration/channel.c create mode 100644 migration/channel.h
include/migration/migration.h +0 -7
@@ -176,17 +176,10 @@ void migration_fd_process_incoming(QEMUFile *f);void qemu_start_incoming_migration (const char *uri,Error **errp); -void migration_channel_process_incoming (MigrationState *s, -QIOChannel *ioc); -void migration_tls_channel_process_incoming (MigrationState *s,QIOChannel *ioc,Error **errp); -void migration_channel_connect (MigrationState *s, -QIOChannel *ioc, -const char *hostname); - void migration_tls_channel_connect(MigrationState *s, QIOChannel *ioc, const char *hostname,
migration/Makefile.objs +1 -1
@@ -1,5 +1,5 @@ common-obj-y += migration.o socket.o fd.o exec.o -common-obj-y += tls.o +common-obj-y += tls.o channel.o common-obj-y += colo-comm.o colo.o colo-failover.o common-obj-y += vmstate.o common-obj-y += qemu-file.o
migration/channel.c new file +69 -0
69 lines not on this page · raw message
migration/channel.h new file +25 -0
@@ -0,0 +1,25 @@ +/* +* QEMU live migration channel functions +* +* Copyright IBM, Corp. 2008 +* +* Authors: +* Anthony Liguori <[email protected]> +* +* This work is licensed under the terms of the GNU GPL, version 2. See +* the COPYING file in the top-level directory. +* +*/ + +#ifndef QEMU_MIGRATION_CHANNEL_H +#define QEMU_MIGRATION_CHANNEL_H + +#include "io/channel.h" + +void migration_channel_process_incoming (MigrationState *s, +QIOChannel *ioc); + +void migration_channel_connect (MigrationState *s, +QIOChannel *ioc, +const char *hostname); +#endif
migration/exec.c +1 -0
@@ -20,6 +20,7 @@#include "qemu/osdep.h" #include "qapi/error.h" #include "qemu-common.h" +#include "channel.h" #include "migration/migration.h" #include "io/channel-command.h" #include "trace.h"
migration/fd.c +1 -0
@@ -17,6 +17,7 @@#include "qemu/osdep.h" #include "qapi/error.h" #include "qemu-common.h" +#include "channel.h" #include "migration/migration.h" #include "monitor/monitor.h" #include "io/channel-util.h"
migration/migration.c +0 -50
56 lines not on this page · raw message
migration/socket.c +1 -0
@@ -19,6 +19,7 @@#include "qemu-common.h" #include "qemu/error-report.h" #include "qapi/error.h" +#include "channel.h" #include "migration/migration.h" #include "migration/qemu-file.h" #include "io/channel-socket.h"
migration/tls.c +1 -0
@@ -19,6 +19,7 @@*/ #include "qemu/osdep.h" +#include "channel.h" #include "migration/migration.h" #include "io/channel-tls.h" #include "crypto/tlscreds.h"
Signature · 1 line
2.9.3
PATCH v3 3/12 migration: Export qemu-file-channel.c functions in its own file
In reply to Juan Quintela--- include/migration/migration.h | 1 + include/migration/qemu-file.h | 4 ---- migration/channel.c | 1 + migration/colo.c | 1 + migration/migration.c | 1 + migration/qemu-file-channel.c | 1 + migration/qemu-file-channel.h | 21 +++++++++++++++++++++ migration/rdma.c | 1 + migration/savevm.c | 1 + tests/test-vmstate.c | 1 + 10 files changed, 29 insertions(+), 4 deletions(-) create mode 100644 migration/qemu-file-channel.h
include/migration/migration.h +1 -0
@@ -19,6 +19,7 @@#include "qemu/thread.h" #include "qemu/notify.h" #include "migration/vmstate.h" +#include "io/channel.h" #include "qapi-types.h" #include "exec/cpu-common.h" #include "qemu/coroutine_int.h"
include/migration/qemu-file.h +0 -4
@@ -27,8 +27,6 @@#include "qemu-common.h" #include "exec/cpu-common.h" -#include "io/channel.h" -/* Read a chunk of data from a file at the given position. The pos argument * can be ignored if the file is only be used for streaming. The number of
@@ -119,8 +117,6 @@ typedef struct QEMUFileHooks { } QEMUFileHooks;QEMUFile *qemu_fopen_ops (void *opaque,const QEMUFileOps *ops); -QEMUFile *qemu_fopen_channel_input (QIOChannel *ioc); -QEMUFile *qemu_fopen_channel_output (QIOChannel *ioc);void qemu_file_set_hooks (QEMUFile *f,const QEMUFileHooks *hooks);int qemu_get_fd (QEMUFile *f);int qemu_fclose (QEMUFile *f);
migration/channel.c +1 -0
@@ -16,6 +16,7 @@#include "qemu/osdep.h" #include "channel.h" #include "migration/migration.h" +#include "qemu-file-channel.h" #include "trace.h" #include "qapi/error.h" #include "io/channel-tls.h"
migration/colo.c +1 -0
@@ -13,6 +13,7 @@#include "qemu/osdep.h" #include "qemu/timer.h" #include "sysemu/sysemu.h" +#include "qemu-file-channel.h" #include "migration/colo.h" #include "migration/block.h" #include "io/channel-buffer.h"
migration/migration.c +1 -0
@@ -19,6 +19,7 @@#include "qemu/main-loop.h" #include "migration/blocker.h" #include "migration/migration.h" +#include "qemu-file-channel.h" #include "migration/qemu-file.h" #include "sysemu/sysemu.h" #include "block/block.h"
migration/qemu-file-channel.c +1 -0
@@ -23,6 +23,7 @@*/ #include "qemu/osdep.h" +#include "qemu-file-channel.h" #include "migration/qemu-file.h" #include "io/channel-socket.h" #include "qemu/iov.h"
migration/qemu-file-channel.h new file +21 -0
@@ -0,0 +1,21 @@ +/* +* QEMU migration file channel operations +* +* Copyright IBM, Corp. 2008 +* +* Authors: +* Anthony Liguori <[email protected]> +* +* This work is licensed under the terms of the GNU GPL, version 2. See +* the COPYING file in the top-level directory. +* +*/ + +#ifndef QEMU_FILE_CHANNEL_H +#define QEMU_FILE_CHANNEL_H + +#include "io/channel.h" + +QEMUFile *qemu_fopen_channel_input (QIOChannel *ioc); +QEMUFile *qemu_fopen_channel_output (QIOChannel *ioc); +#endif
migration/rdma.c +1 -0
@@ -20,6 +20,7 @@#include "migration/migration.h" #include "migration/qemu-file.h" #include "exec/cpu-common.h" +#include "qemu-file-channel.h" #include "qemu/error-report.h" #include "qemu/main-loop.h" #include "qemu/sockets.h"
migration/savevm.c +1 -0
@@ -36,6 +36,7 @@#include "sysemu/sysemu.h" #include "qemu/timer.h" #include "migration/migration.h" +#include "qemu-file-channel.h" #include "postcopy-ram.h" #include "qapi/qmp/qerror.h" #include "qemu/error-report.h"
tests/test-vmstate.c +1 -0
@@ -27,6 +27,7 @@#include "qemu-common.h" #include "migration/migration.h" #include "migration/vmstate.h" +#include "../migration/qemu-file-channel.h" #include "qemu/coroutine.h" #include "io/channel-file.h"
Signature · 1 line
2.9.3
PATCH v3 4/12 migration: Remove migration.h from colo.h
In reply to Juan Quintelamigration.h is not included in any includes now.
--- include/migration/colo.h | 1 - migration/colo-comm.c | 3 ++- migration/colo.c | 1 + 3 files changed, 3 insertions(+), 2 deletions(-)
include/migration/colo.h +0 -1
@@ -14,7 +14,6 @@#define QEMU_COLO_H #include "qemu-common.h" -#include "migration/migration.h" #include "qemu/coroutine_int.h" #include "qemu/thread.h" #include "qemu/main-loop.h"
migration/colo-comm.c +2 -1
@@ -12,7 +12,8 @@*/ #include "qemu/osdep.h" -#include <migration/colo.h> +#include "migration/migration.h" +#include "migration/colo.h" #include "trace.h" typedef struct {
migration/colo.c +1 -0
@@ -14,6 +14,7 @@#include "qemu/timer.h" #include "sysemu/sysemu.h" #include "qemu-file-channel.h" +#include "migration/migration.h" #include "migration/colo.h" #include "migration/block.h" #include "io/channel-buffer.h"
Signature · 1 line
2.9.3
PATCH v3 5/12 migration: Move colo.h to migration/
In reply to Juan QuintelaThere are functions only used by migration code.
---
MAINTAINERS | 2 +-
migration/colo-comm.c | 2 +-
migration/colo-failover.c | 2 +-
{include/migration => migration}/colo.h | 0
migration/migration.c | 2 +-
migration/ram.c | 2 +-
6 files changed, 5 insertions(+), 5 deletions(-)
rename {include/migration => migration}/colo.h (100%)MAINTAINERS +1 -1
@@ -1537,7 +1537,7 @@ COLO Framework M: zhanghailiang <[email protected]> S: Maintained F: migration/colo* -F: include/migration/colo.h +F: migration/colo.h F: include/migration/failover.h F: docs/COLO-FT.txt
migration/colo-comm.c +1 -1
@@ -13,7 +13,7 @@#include "qemu/osdep.h" #include "migration/migration.h" -#include "migration/colo.h" +#include "colo.h" #include "trace.h" typedef struct {
migration/colo-failover.c +1 -1
@@ -11,7 +11,7 @@*/ #include "qemu/osdep.h" -#include "migration/colo.h" +#include "colo.h" #include "migration/failover.h" #include "qmp-commands.h" #include "qapi/qmp/qerror.h"
migration/colo.h renamed from include/migration/colo.h +0 -0
migration/migration.c +1 -1
@@ -38,7 +38,7 @@#include "exec/address-spaces.h" #include "io/channel-buffer.h" #include "io/channel-tls.h" -#include "migration/colo.h" +#include "colo.h" #define MAX_THROTTLE (32 << 20)/* Migration transfer speed throttling */
migration/ram.c +1 -1
@@ -44,7 +44,7 @@#include "trace.h" #include "exec/ram_addr.h" #include "qemu/rcu_queue.h" -#include "migration/colo.h" +#include "colo.h" /***********************************************************/ /* ram save/restore */
Signature · 1 line
2.9.3
Re: [Qemu-devel] [PATCH 05/12] migration: Move colo.h to migration/
Quoted 1 line · * Juan Quintela ([email protected]) wrote:
There are functions only used by migration code.
That's only mostly true; see the current 'integrate colo frame with block replication and net compare' series (posted 22nd April). That adds colo_handle_shutdown to this header and calls it from vl.c ( https://lists.gnu.org/archive/html/qemu-devel/2017-04/msg03901.html ) where should that go?
There's also a net/colo.h as well, so using the
#include "colo.h" in migration is correct but that's
really scary when there are two files of the same name.
Dave
Quoted 83 lines
Signed-off-by Juan Quintela <[email protected]>--- MAINTAINERS | 2 +- migration/colo-comm.c | 2 +- migration/colo-failover.c | 2 +- {include/migration => migration}/colo.h | 0 migration/migration.c | 2 +- migration/ram.c | 2 +- 6 files changed, 5 insertions(+), 5 deletions(-) rename {include/migration => migration}/colo.h (100%)MAINTAINERS +1
-1@@ -1537,7 +1537,7 @@ COLO Framework M: zhanghailiang <[email protected]> S: Maintained F: migration/colo* -F: include/migration/colo.h +F: migration/colo.h F: include/migration/failover.h F: docs/COLO-FT.txtmigration/colo-comm.c +1
-1@@ -13,7 +13,7 @@#include "qemu/osdep.h" #include "migration/migration.h" -#include "migration/colo.h" +#include "colo.h" #include "trace.h" typedef struct {migration/colo-failover.c +1
-1@@ -11,7 +11,7 @@*/ #include "qemu/osdep.h" -#include "migration/colo.h" +#include "colo.h" #include "migration/failover.h" #include "qmp-commands.h" #include "qapi/qmp/qerror.h" migration/colo.h renamed from include/migration/colo.h +0
-0migration/migration.c +1
-1@@ -38,7 +38,7 @@#include "exec/address-spaces.h" #include "io/channel-buffer.h" #include "io/channel-tls.h" -#include "migration/colo.h" +#include "colo.h" #define MAX_THROTTLE (32 << 20)/* Migration transfer speed throttling */ migration/ram.c +1
-1@@ -44,7 +44,7 @@#include "trace.h" #include "exec/ram_addr.h" #include "qemu/rcu_queue.h" -#include "migration/colo.h" +#include "colo.h" /***********************************************************/ /* ram save/restore */ Signature · 1 line
2.9.3
--
Dr. David Alan Gilbert / [email protected] / Manchester, UK
Re: [Qemu-devel] [PATCH 05/12] migration: Move colo.h to migration/
"Dr. David Alan Gilbert" <[email protected]> wrote:
Quoted 7 lines · D> * Juan Quintela ([email protected]) wrote:
Quoted 1 line
There are functions only used by migration code.
That's only mostly true; see the current 'integrate colo frame with block replication and net compare' series (posted 22nd April). That adds
colo_handle_shutdownto this header and calls it fromvl.c( https://lists.gnu.org/archive/html/qemu-devel/2017-04/msg03901.html ) where should that go?
Dropped.
It compiled, but who knows O:-)
Quoted 3 lines
There's also a
net/colo.has 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 ...
Re: [Qemu-devel] [PATCH 05/12] migration: Move colo.h to migration/
Quoted 15 lines · Juan Quintela
"Dr. David Alan Gilbert" <[email protected]> wrote:
Quoted 6 lines · D> * Juan Quintela ([email protected]) wrote:
Quoted 1 line
There are functions only used by migration code.
That's only mostly true; see the current 'integrate colo frame with block replication and net compare' series (posted 22nd April). That adds
colo_handle_shutdownto this header and calls it fromvl.c( https://lists.gnu.org/archive/html/qemu-devel/2017-04/msg03901.html ) where should that go?Dropped.
It compiled, but who knows O:-)
Quoted 3 lines
There's also a
net/colo.has 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:-) )
Quoted 4 lines
Yeap, it is scary ...
PATCH v3 6/12 migration: Move failover.h to migration/colo-failover.h
In reply to Juan QuintelaThis file is internal for migration/colo code.
--- MAINTAINERS | 2 +- migration/colo-failover.c | 2 +- include/migration/failover.h => migration/colo-failover.h | 0 migration/colo.c | 2 +- 4 files changed, 3 insertions(+), 3 deletions(-) rename include/migration/failover.h => migration/colo-failover.h (100%)
MAINTAINERS +1 -1
@@ -1538,7 +1538,7 @@ M: zhanghailiang <[email protected]> S: Maintained F: migration/colo* F: migration/colo.h -F: include/migration/failover.h +F: migration/colo-failover.h F: docs/COLO-FT.txt COLO Proxy
migration/colo-failover.c +1 -1
@@ -12,7 +12,7 @@#include "qemu/osdep.h" #include "colo.h" -#include "migration/failover.h" +#include "colo-failover.h" #include "qmp-commands.h" #include "qapi/qmp/qerror.h" #include "qemu/error-report.h"
migration/colo-failover.h renamed from include/migration/failover.h +0 -0
migration/colo.c +1 -1
@@ -21,7 +21,7 @@#include "trace.h" #include "qemu/error-report.h" #include "qapi/error.h" -#include "migration/failover.h" +#include "colo-failover.h" #include "replication.h" #include "qmp-commands.h"
Signature · 1 line
2.9.3
PATCH v3 7/12 migration: Move page_cache.c to migration/
In reply to Juan QuintelaIt is only used by migration, so move it there.
---
Makefile.objs | 1 -
migration/Makefile.objs | 2 +-
page_cache.c => migration/page_cache.c | 0
{include/migration => migration}/page_cache.h | 0
tests/Makefile.include | 2 +-
5 files changed, 2 insertions(+), 3 deletions(-)
rename page_cache.c => migration/page_cache.c (100%)
rename {include/migration => migration}/page_cache.h (100%)Makefile.objs +0 -1
@@ -49,7 +49,6 @@ common-obj-$(CONFIG_POSIX) += os-posix.o common-obj-$(CONFIG_LINUX) += fsdev/ common-obj-y += migration/ -common-obj-y += page_cache.o #aio.o common-obj-$(CONFIG_SPICE) += spice-qemu-char.o
migration/Makefile.objs +1 -1
@@ -1,7 +1,7 @@ common-obj-y += migration.o socket.o fd.o exec.o common-obj-y += tls.o channel.o common-obj-y += colo-comm.o colo.o colo-failover.o -common-obj-y += vmstate.o +common-obj-y += vmstate.o page_cache.o common-obj-y += qemu-file.o common-obj-y += qemu-file-channel.o common-obj-y += xbzrle.o postcopy-ram.o
migration/page_cache.c renamed from page_cache.c +0 -0
migration/page_cache.h renamed from include/migration/page_cache.h +0 -0
tests/Makefile.include +1 -1
@@ -550,7 +550,7 @@ tests/test-thread-pool$(EXESUF): tests/test-thread-pool.o $(test-block-obj-y) tests/test-iov$(EXESUF): tests/test-iov.o $(test-util-obj-y) tests/test-hbitmap$(EXESUF): tests/test-hbitmap.o $(test-util-obj-y) tests/test-x86-cpuid$(EXESUF): tests/test-x86-cpuid.o -tests/test-xbzrle$(EXESUF): tests/test-xbzrle.o migration/xbzrle.o page_cache.o $(test-util-obj-y) +tests/test-xbzrle$(EXESUF): tests/test-xbzrle.o migration/xbzrle.o migration/page_cache.o $(test-util-obj-y) tests/test-cutils$(EXESUF): tests/test-cutils.o util/cutils.o tests/test-int128$(EXESUF): tests/test-int128.o tests/rcutorture$(EXESUF): tests/rcutorture.o $(test-util-obj-y)
Signature · 1 line
2.9.3
PATCH v3 8/12 migration: Move qjson.h to migration/
In reply to Juan QuintelaIt is only used for migration code.
---
migration/qjson.c | 2 +-
{include/migration => migration}/qjson.h | 0
migration/vmstate.c | 2 +-
3 files changed, 2 insertions(+), 2 deletions(-)
rename {include/migration => migration}/qjson.h (100%)migration/qjson.c +1 -1
@@ -25,7 +25,7 @@#include "qemu/osdep.h" #include "qapi/qmp/qstring.h" -#include "migration/qjson.h" +#include "qjson.h" struct QJSON {QString *str;
migration/qjson.h renamed from include/migration/qjson.h +0 -0
migration/vmstate.c +1 -1
@@ -7,7 +7,7 @@#include "qemu/error-report.h" #include "qemu/queue.h" #include "trace.h" -#include "migration/qjson.h" +#include "qjson.h" static void vmstate_subsection_save (QEMUFile *f,const VMStateDescription *vmsd,void *opaque,QJSON *vmdesc);
Signature · 1 line
2.9.3
PATCH v3 9/12 migration: Split vmstate-types.c from vmstate.c
In reply to Juan QuintelaNow one just has the interperter, and the other has the basic types. Once there, add copyright boilerplate.
--- migration/Makefile.objs | 2 +- migration/vmstate-types.c | 676 ++++++++++++++++++++++++++++++++++++++++++++++ migration/vmstate.c | 669 ++------------------------------------------- tests/Makefile.include | 2 +- 4 files changed, 705 insertions(+), 644 deletions(-) create mode 100644 migration/vmstate-types.c
migration/Makefile.objs +1 -1
@@ -1,7 +1,7 @@ common-obj-y += migration.o socket.o fd.o exec.o common-obj-y += tls.o channel.o common-obj-y += colo-comm.o colo.o colo-failover.o -common-obj-y += vmstate.o page_cache.o +common-obj-y += vmstate.o vmstate-types.o page_cache.o common-obj-y += qemu-file.o common-obj-y += qemu-file-channel.o common-obj-y += xbzrle.o postcopy-ram.o
migration/vmstate-types.c new file +676 -0
676 lines not on this page · raw message
migration/vmstate.c +27 -642
681 lines not on this page · raw message
tests/Makefile.include +1 -1
@@ -570,7 +570,7 @@ tests/test-qdev-global-props$(EXESUF): tests/test-qdev-global-props.o \ hw/core/reset.o \ $(test-qapi-obj-y) tests/test-vmstate$(EXESUF): tests/test-vmstate.o \ - migration/vmstate.o migration/qemu-file.o \ + migration/vmstate.o migration/vmstate-types.o migration/qemu-file.o \ migration/qemu-file-channel.o migration/qjson.o \ $(test-io-obj-y) tests/test-timed-average$(EXESUF): tests/test-timed-average.o $(test-util-obj-y)
Signature · 1 line
2.9.3
Re: [Qemu-devel] [PATCH 09/12] migration: Split vmstate-types.c from vmstate.c
Quoted 4 lines · * Juan Quintela ([email protected]) wrote:
Now one just has the interperter, and the other has the basic types. Once there, add copyright boilerplate.
Signed-off-by Juan Quintela <[email protected]>
I think this is generally OK, but as discussed on IRC, I think you need to check the licenses.
Dave
Quoted 1,407 lines
--- migration/Makefile.objs | 2 +- migration/vmstate-types.c | 676 ++++++++++++++++++++++++++++++++++++++++++++++ migration/vmstate.c | 669 ++------------------------------------------- tests/Makefile.include | 2 +- 4 files changed, 705 insertions(+), 644 deletions(-) create mode 100644 migration/vmstate-types.cmigration/Makefile.objs +1
-1@@ -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.omigration/vmstate-types.c new file +676
-0@@ -0,0 +1,676 @@ +/* +* QEMU System Emulator +* +* Copyright (c) 2009-2017 Red Hat Inc +* +* Authors: +* Juan Quintela <[email protected]> +* +* Permission is hereby granted, free of charge, to any person obtaining a copy +* of this software and associated documentation files (the "Software"), to deal +* in the Software without restriction, including without limitation the rights +* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +* copies of the Software, and to permit persons to whom the Software is +* furnished to do so, subject to the following conditions: +* +* The above copyright notice and this permission notice shall be included in +* all copies or substantial portions of the Software. +* +* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL +* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +* THE SOFTWARE. +*/ + +#include "qemu/osdep.h" +#include "qemu-common.h" +#include "migration/migration.h" +#include "migration/qemu-file.h" +#include "migration/vmstate.h" +#include "qemu/error-report.h" +#include "qemu/queue.h" +#include "trace.h" + +/* bool */ + +static int get_bool (QEMUFile *f,void *pv,size_t size,VMStateField *field) +{ +bool *v = pv; + *v =qemu_get_byte (f); +return 0 ; +} + +static int put_bool (QEMUFile *f,void *pv,size_t size,VMStateField *field, +QJSON *vmdesc) +{ +bool *v = pv; +qemu_put_byte (f, *v); +return 0 ; +} + +const VMStateInfo vmstate_info_bool = { + .name ="bool" , + .get = get_bool, + .put = put_bool, +}; + +/* 8 bit int */ + +static int get_int8 (QEMUFile *f,void *pv,size_t size,VMStateField *field) +{ +int8_t *v = pv; +qemu_get_s8s (f, v); +return 0 ; +} + +static int put_int8 (QEMUFile *f,void *pv,size_t size,VMStateField *field, +QJSON *vmdesc) +{ +int8_t *v = pv; +qemu_put_s8s (f, v); +return 0 ; +} + +const VMStateInfo vmstate_info_int8 = { + .name ="int8" , + .get = get_int8, + .put = put_int8, +}; + +/* 16 bit int */ + +static int get_int16 (QEMUFile *f,void *pv,size_t size,VMStateField *field) +{ +int16_t *v = pv; +qemu_get_sbe16s (f, v); +return 0 ; +} + +static int put_int16 (QEMUFile *f,void *pv,size_t size,VMStateField *field, +QJSON *vmdesc) +{ +int16_t *v = pv; +qemu_put_sbe16s (f, v); +return 0 ; +} + +const VMStateInfo vmstate_info_int16 = { + .name ="int16" , + .get = get_int16, + .put = put_int16, +}; + +/* 32 bit int */ + +static int get_int32 (QEMUFile *f,void *pv,size_t size,VMStateField *field) +{ +int32_t *v = pv; +qemu_get_sbe32s (f, v); +return 0 ; +} + +static int put_int32 (QEMUFile *f,void *pv,size_t size,VMStateField *field, +QJSON *vmdesc) +{ +int32_t *v = pv; +qemu_put_sbe32s (f, v); +return 0 ; +} + +const VMStateInfo vmstate_info_int32 = { + .name ="int32" , + .get = get_int32, + .put = put_int32, +}; + +/* 32 bit int. See that the received value is the same than the one +in the field */ + +static int get_int32_equal (QEMUFile *f,void *pv,size_t size, +VMStateField *field) +{ +int32_t *v = pv; +int32_t v2; +qemu_get_sbe32s (f, &v2); + +if (*v == v2) { +return 0 ; + } +error_report ("%" PRIx32" != %" PRIx32, *v, v2); +return -EINVAL ; +} + +const VMStateInfo vmstate_info_int32_equal = { + .name ="int32 equal" , + .get = get_int32_equal, + .put = put_int32, +}; + +/* 32 bit int. Check that the received value is non-negative +* and less than or equal to the one in the field. +*/ + +static int get_int32_le (QEMUFile *f,void *pv,size_t size,VMStateField *field) +{ +int32_t *cur = pv; +int32_t loaded; +qemu_get_sbe32s (f, &loaded); + +if (loaded >=0 && loaded <= *cur) { + *cur = loaded; +return 0 ; + } +error_report ("Invalid value %" PRId32 +" expecting positive value <= %" PRId32, + loaded, *cur); +return -EINVAL ; +} + +const VMStateInfo vmstate_info_int32_le = { + .name ="int32 le" , + .get = get_int32_le, + .put = put_int32, +}; + +/* 64 bit int */ + +static int get_int64 (QEMUFile *f,void *pv,size_t size,VMStateField *field) +{ +int64_t *v = pv; +qemu_get_sbe64s (f, v); +return 0 ; +} + +static int put_int64 (QEMUFile *f,void *pv,size_t size,VMStateField *field, +QJSON *vmdesc) +{ +int64_t *v = pv; +qemu_put_sbe64s (f, v); +return 0 ; +} + +const VMStateInfo vmstate_info_int64 = { + .name ="int64" , + .get = get_int64, + .put = put_int64, +}; + +/* 8 bit unsigned int */ + +static int get_uint8 (QEMUFile *f,void *pv,size_t size,VMStateField *field) +{ +uint8_t *v = pv; +qemu_get_8s (f, v); +return 0 ; +} + +static int put_uint8 (QEMUFile *f,void *pv,size_t size,VMStateField *field, +QJSON *vmdesc) +{ +uint8_t *v = pv; +qemu_put_8s (f, v); +return 0 ; +} + +const VMStateInfo vmstate_info_uint8 = { + .name ="uint8" , + .get = get_uint8, + .put = put_uint8, +}; + +/* 16 bit unsigned int */ + +static int get_uint16 (QEMUFile *f,void *pv,size_t size,VMStateField *field) +{ +uint16_t *v = pv; +qemu_get_be16s (f, v); +return 0 ; +} + +static int put_uint16 (QEMUFile *f,void *pv,size_t size,VMStateField *field, +QJSON *vmdesc) +{ +uint16_t *v = pv; +qemu_put_be16s (f, v); +return 0 ; +} + +const VMStateInfo vmstate_info_uint16 = { + .name ="uint16" , + .get = get_uint16, + .put = put_uint16, +}; + +/* 32 bit unsigned int */ + +static int get_uint32 (QEMUFile *f,void *pv,size_t size,VMStateField *field) +{ +uint32_t *v = pv; +qemu_get_be32s (f, v); +return 0 ; +} + +static int put_uint32 (QEMUFile *f,void *pv,size_t size,VMStateField *field, +QJSON *vmdesc) +{ +uint32_t *v = pv; +qemu_put_be32s (f, v); +return 0 ; +} + +const VMStateInfo vmstate_info_uint32 = { + .name ="uint32" , + .get = get_uint32, + .put = put_uint32, +}; + +/* 32 bit uint. See that the received value is the same than the one +in the field */ + +static int get_uint32_equal (QEMUFile *f,void *pv,size_t size, +VMStateField *field) +{ +uint32_t *v = pv; +uint32_t v2; +qemu_get_be32s (f, &v2); + +if (*v == v2) { +return 0 ; + } +error_report ("%" PRIx32" != %" PRIx32, *v, v2); +return -EINVAL ; +} + +const VMStateInfo vmstate_info_uint32_equal = { + .name ="uint32 equal" , + .get = get_uint32_equal, + .put = put_uint32, +}; + +/* 64 bit unsigned int */ + +static int get_uint64 (QEMUFile *f,void *pv,size_t size,VMStateField *field) +{ +uint64_t *v = pv; +qemu_get_be64s (f, v); +return 0 ; +} + +static int put_uint64 (QEMUFile *f,void *pv,size_t size,VMStateField *field, +QJSON *vmdesc) +{ +uint64_t *v = pv; +qemu_put_be64s (f, v); +return 0 ; +} + +const VMStateInfo vmstate_info_uint64 = { + .name ="uint64" , + .get = get_uint64, + .put = put_uint64, +}; + +static int get_nullptr (QEMUFile *f,void *pv,size_t size,VMStateField *field) + +{ +if (qemu_get_byte (f) ==VMS_NULLPTR_MARKER ) { +return 0 ; + } +error_report ("vmstate: get_nullptr expected VMS_NULLPTR_MARKER" ); +return -EINVAL ; +} + +static int put_nullptr (QEMUFile *f,void *pv,size_t size, +VMStateField *field,QJSON *vmdesc) + +{ +if (pv ==NULL ) { +qemu_put_byte (f,VMS_NULLPTR_MARKER ); +return 0 ; + } +error_report ("vmstate: put_nullptr must be called with pv == NULL" ); +return -EINVAL ; +} + +const VMStateInfo vmstate_info_nullptr = { + .name ="uint64" , + .get = get_nullptr, + .put = put_nullptr, +}; + +/* 64 bit unsigned int. See that the received value is the same than the one +in the field */ + +static int get_uint64_equal (QEMUFile *f,void *pv,size_t size, +VMStateField *field) +{ +uint64_t *v = pv; +uint64_t v2; +qemu_get_be64s (f, &v2); + +if (*v == v2) { +return 0 ; + } +error_report ("%" PRIx64" != %" PRIx64, *v, v2); +return -EINVAL ; +} + +const VMStateInfo vmstate_info_uint64_equal = { + .name ="int64 equal" , + .get = get_uint64_equal, + .put = put_uint64, +}; + +/* 8 bit int. See that the received value is the same than the one +in the field */ + +static int get_uint8_equal (QEMUFile *f,void *pv,size_t size, +VMStateField *field) +{ +uint8_t *v = pv; +uint8_t v2; +qemu_get_8s (f, &v2); + +if (*v == v2) { +return 0 ; + } +error_report ("%x != %x" , *v, v2); +return -EINVAL ; +} + +const VMStateInfo vmstate_info_uint8_equal = { + .name ="uint8 equal" , + .get = get_uint8_equal, + .put = put_uint8, +}; + +/* 16 bit unsigned int int. See that the received value is the same than the one +in the field */ + +static int get_uint16_equal (QEMUFile *f,void *pv,size_t size, +VMStateField *field) +{ +uint16_t *v = pv; +uint16_t v2; +qemu_get_be16s (f, &v2); + +if (*v == v2) { +return 0 ; + } +error_report ("%x != %x" , *v, v2); +return -EINVAL ; +} + +const VMStateInfo vmstate_info_uint16_equal = { + .name ="uint16 equal" , + .get = get_uint16_equal, + .put = put_uint16, +}; + +/* floating point */ + +static int get_float64 (QEMUFile *f,void *pv,size_t size, +VMStateField *field) +{ +float64 *v = pv; + + *v =make_float64 (qemu_get_be64 (f)); +return 0 ; +} + +static int put_float64 (QEMUFile *f,void *pv,size_t size,VMStateField *field, +QJSON *vmdesc) +{ +uint64_t *v = pv; + +qemu_put_be64 (f,float64_val (*v)); +return 0 ; +} + +const VMStateInfo vmstate_info_float64 = { + .name ="float64" , + .get = get_float64, + .put = put_float64, +}; + +/* CPU_DoubleU type */ + +static int get_cpudouble (QEMUFile *f,void *pv,size_t size, +VMStateField *field) +{ +CPU_DoubleU *v = pv; +qemu_get_be32s (f, &v->l.upper); +qemu_get_be32s (f, &v->l.lower); +return 0 ; +} + +static int put_cpudouble (QEMUFile *f,void *pv,size_t size, +VMStateField *field,QJSON *vmdesc) +{ +CPU_DoubleU *v = pv; +qemu_put_be32s (f, &v->l.upper); +qemu_put_be32s (f, &v->l.lower); +return 0 ; +} + +const VMStateInfo vmstate_info_cpudouble = { + .name ="CPU_Double_U" , + .get = get_cpudouble, + .put = put_cpudouble, +}; + +/* uint8_t buffers */ + +static int get_buffer (QEMUFile *f,void *pv,size_t size, +VMStateField *field) +{ +uint8_t *v = pv; +qemu_get_buffer (f, v, size); +return 0 ; +} + +static int put_buffer (QEMUFile *f,void *pv,size_t size,VMStateField *field, +QJSON *vmdesc) +{ +uint8_t *v = pv; +qemu_put_buffer (f, v, size); +return 0 ; +} + +const VMStateInfo vmstate_info_buffer = { + .name ="buffer" , + .get = get_buffer, + .put = put_buffer, +}; + +/* unused buffers: space that was used for some fields that are +not useful anymore */ + +static int get_unused_buffer (QEMUFile *f,void *pv,size_t size, +VMStateField *field) +{ +uint8_t buf[1024 ]; +int block_len; + +while (size >0 ) { + block_len =MIN (sizeof (buf), size); + size -= block_len; +qemu_get_buffer (f, buf, block_len); + } +return 0 ; +} + +static int put_unused_buffer (QEMUFile *f,void *pv,size_t size, +VMStateField *field,QJSON *vmdesc) +{ +static const uint8_t buf[1024 ]; +int block_len; + +while (size >0 ) { + block_len =MIN (sizeof (buf), size); + size -= block_len; +qemu_put_buffer (f, buf, block_len); + } + +return 0 ; +} + +const VMStateInfo vmstate_info_unused_buffer = { + .name ="unused_buffer" , + .get = get_unused_buffer, + .put = put_unused_buffer, +}; + +/* vmstate_info_tmp, see VMSTATE_WITH_TMP, the idea is that we allocate +* a temporary buffer and the pre_load/pre_save methods in the child vmsd +* copy stuff from the parent into the child and do calculations to fill +* in fields that don't really exist in the parent but need to be in the +* stream. +*/ +static int get_tmp (QEMUFile *f,void *pv,size_t size,VMStateField *field) +{ +int ret; +const VMStateDescription *vmsd = field->vmsd; +int version_id = field->version_id; +void *tmp =g_malloc (size); + +/* Writes the parent field which is at the start of the tmp */ + *(void **)tmp = pv; + ret =vmstate_load_state (f, vmsd, tmp, version_id); +g_free (tmp); +return ret; +} + +static int put_tmp (QEMUFile *f,void *pv,size_t size,VMStateField *field, +QJSON *vmdesc) +{ +const VMStateDescription *vmsd = field->vmsd; +void *tmp =g_malloc (size); + +/* Writes the parent field which is at the start of the tmp */ + *(void **)tmp = pv; +vmstate_save_state (f, vmsd, tmp, vmdesc); +g_free (tmp); + +return 0 ; +} + +const VMStateInfo vmstate_info_tmp = { + .name ="tmp" , + .get = get_tmp, + .put = put_tmp, +}; + +/* bitmaps (as defined by bitmap.h). Note that size here is the size +* of the bitmap in bits. The on-the-wire format of a bitmap is 64 +* bit words with the bits in big endian order. The in-memory format +* is an array of 'unsigned long', which may be either 32 or 64 bits. +*/ +/* This is the number of 64 bit words sent over the wire */ +#define BITS_TO_U64S (nr) DIV_ROUND_UP(nr, 64) +static int get_bitmap (QEMUFile *f,void *pv,size_t size,VMStateField *field) +{ +unsigned long *bmp = pv; +int i, idx =0 ; +for (i =0 ; i <BITS_TO_U64S (size); i++) { +uint64_t w =qemu_get_be64 (f); + bmp[idx++] = w; +if (sizeof (unsigned long ) ==4 && idx <BITS_TO_LONGS (size)) { + bmp[idx++] = w >>32 ; + } + } +return 0 ; +} + +static int put_bitmap (QEMUFile *f,void *pv,size_t size,VMStateField *field, +QJSON *vmdesc) +{ +unsigned long *bmp = pv; +int i, idx =0 ; +for (i =0 ; i <BITS_TO_U64S (size); i++) { +uint64_t w = bmp[idx++]; +if (sizeof (unsigned long ) ==4 && idx <BITS_TO_LONGS (size)) { + w |= ((uint64_t )bmp[idx++]) <<32 ; + } +qemu_put_be64 (f, w); + } + +return 0 ; +} + +const VMStateInfo vmstate_info_bitmap = { + .name ="bitmap" , + .get = get_bitmap, + .put = put_bitmap, +}; + +/* get for QTAILQ +* meta data about the QTAILQ is encoded in a VMStateField structure +*/ +static int get_qtailq (QEMUFile *f,void *pv,size_t unused_size, +VMStateField *field) +{ +int ret =0 ; +const VMStateDescription *vmsd = field->vmsd; +/* size of a QTAILQ element */ +size_t size = field->size; +/* offset of the QTAILQ entry in a QTAILQ element */ +size_t entry_offset = field->start; +int version_id = field->version_id; +void *elm; + +trace_get_qtailq (vmsd->name, version_id); +if (version_id > vmsd->version_id) { +error_report ("%s %s" , vmsd->name,"too new" ); +trace_get_qtailq_end (vmsd->name,"too new" , -EINVAL ); + +return -EINVAL ; + } +if (version_id < vmsd->minimum_version_id) { +error_report ("%s %s" , vmsd->name,"too old" ); +trace_get_qtailq_end (vmsd->name,"too old" , -EINVAL ); +return -EINVAL ; + } + +while (qemu_get_byte (f)) { + elm =g_malloc (size); + ret =vmstate_load_state (f, vmsd, elm, version_id); +if (ret) { +return ret; + } +QTAILQ_RAW_INSERT_TAIL (pv, elm, entry_offset); + } + +trace_get_qtailq_end (vmsd->name,"end" , ret); +return ret; +} + +/* put for QTAILQ */ +static int put_qtailq (QEMUFile *f,void *pv,size_t unused_size, +VMStateField *field,QJSON *vmdesc) +{ +const VMStateDescription *vmsd = field->vmsd; +/* offset of the QTAILQ entry in a QTAILQ element*/ +size_t entry_offset = field->start; +void *elm; + +trace_put_qtailq (vmsd->name, vmsd->version_id); + + QTAILQ_RAW_FOREACH(elm, pv, entry_offset) { +qemu_put_byte (f, true); +vmstate_save_state (f, vmsd, elm, vmdesc); + } +qemu_put_byte (f, false); + +trace_put_qtailq_end (vmsd->name,"end" ); + +return 0 ; +} +const VMStateInfo vmstate_info_qtailq = { + .name ="qtailq" , + .get = get_qtailq, + .put = put_qtailq, +};migration/vmstate.c +27
-642@@ -1,3 +1,30 @@ +/* +* QEMU System Emulator +* +* Copyright (c) 2009-2017 Red Hat Inc +* +* Authors: +* Juan Quintela <[email protected]> +* +* Permission is hereby granted, free of charge, to any person obtaining a copy +* of this software and associated documentation files (the "Software"), to deal +* in the Software without restriction, including without limitation the rights +* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +* copies of the Software, and to permit persons to whom the Software is +* furnished to do so, subject to the following conditions: +* +* The above copyright notice and this permission notice shall be included in +* all copies or substantial portions of the Software. +* +* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL +* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +* THE SOFTWARE. +*/ +#include "qemu/osdep.h" #include "qemu-common.h" #include "migration/migration.h" @@ -5,7 +32,6 @@#include "migration/vmstate.h" #include "qemu/bitops.h" #include "qemu/error-report.h" -#include "qemu/queue.h" #include "trace.h" #include "qjson.h" @@ -475,644 +501,3 @@ static void vmstate_subsection_save(QEMUFile *f, const VMStateDescription *vmsd,json_end_array (vmdesc); } } - -/* bool */ - -static int get_bool (QEMUFile *f,void *pv,size_t size,VMStateField *field) -{ -bool *v = pv; - *v =qemu_get_byte (f); -return 0 ; -} - -static int put_bool (QEMUFile *f,void *pv,size_t size,VMStateField *field, -QJSON *vmdesc) -{ -bool *v = pv; -qemu_put_byte (f, *v); -return 0 ; -} - -const VMStateInfo vmstate_info_bool = { - .name ="bool" , - .get = get_bool, - .put = put_bool, -}; - -/* 8 bit int */ - -static int get_int8 (QEMUFile *f,void *pv,size_t size,VMStateField *field) -{ -int8_t *v = pv; -qemu_get_s8s (f, v); -return 0 ; -} - -static int put_int8 (QEMUFile *f,void *pv,size_t size,VMStateField *field, -QJSON *vmdesc) -{ -int8_t *v = pv; -qemu_put_s8s (f, v); -return 0 ; -} - -const VMStateInfo vmstate_info_int8 = { - .name ="int8" , - .get = get_int8, - .put = put_int8, -}; - -/* 16 bit int */ - -static int get_int16 (QEMUFile *f,void *pv,size_t size,VMStateField *field) -{ -int16_t *v = pv; -qemu_get_sbe16s (f, v); -return 0 ; -} - -static int put_int16 (QEMUFile *f,void *pv,size_t size,VMStateField *field, -QJSON *vmdesc) -{ -int16_t *v = pv; -qemu_put_sbe16s (f, v); -return 0 ; -} - -const VMStateInfo vmstate_info_int16 = { - .name ="int16" , - .get = get_int16, - .put = put_int16, -}; - -/* 32 bit int */ - -static int get_int32 (QEMUFile *f,void *pv,size_t size,VMStateField *field) -{ -int32_t *v = pv; -qemu_get_sbe32s (f, v); -return 0 ; -} - -static int put_int32 (QEMUFile *f,void *pv,size_t size,VMStateField *field, -QJSON *vmdesc) -{ -int32_t *v = pv; -qemu_put_sbe32s (f, v); -return 0 ; -} - -const VMStateInfo vmstate_info_int32 = { - .name ="int32" , - .get = get_int32, - .put = put_int32, -}; - -/* 32 bit int. See that the received value is the same than the one -in the field */ - -static int get_int32_equal (QEMUFile *f,void *pv,size_t size, -VMStateField *field) -{ -int32_t *v = pv; -int32_t v2; -qemu_get_sbe32s (f, &v2); - -if (*v == v2) { -return 0 ; - } -error_report ("%" PRIx32" != %" PRIx32, *v, v2); -return -EINVAL ; -} - -const VMStateInfo vmstate_info_int32_equal = { - .name ="int32 equal" , - .get = get_int32_equal, - .put = put_int32, -}; - -/* 32 bit int. Check that the received value is non-negative -* and less than or equal to the one in the field. -*/ - -static int get_int32_le (QEMUFile *f,void *pv,size_t size,VMStateField *field) -{ -int32_t *cur = pv; -int32_t loaded; -qemu_get_sbe32s (f, &loaded); - -if (loaded >=0 && loaded <= *cur) { - *cur = loaded; -return 0 ; - } -error_report ("Invalid value %" PRId32 -" expecting positive value <= %" PRId32, - loaded, *cur); -return -EINVAL ; -} - -const VMStateInfo vmstate_info_int32_le = { - .name ="int32 le" , - .get = get_int32_le, - .put = put_int32, -}; - -/* 64 bit int */ - -static int get_int64 (QEMUFile *f,void *pv,size_t size,VMStateField *field) -{ -int64_t *v = pv; -qemu_get_sbe64s (f, v); -return 0 ; -} - -static int put_int64 (QEMUFile *f,void *pv,size_t size,VMStateField *field, -QJSON *vmdesc) -{ -int64_t *v = pv; -qemu_put_sbe64s (f, v); -return 0 ; -} - -const VMStateInfo vmstate_info_int64 = { - .name ="int64" , - .get = get_int64, - .put = put_int64, -}; - -/* 8 bit unsigned int */ - -static int get_uint8 (QEMUFile *f,void *pv,size_t size,VMStateField *field) -{ -uint8_t *v = pv; -qemu_get_8s (f, v); -return 0 ; -} - -static int put_uint8 (QEMUFile *f,void *pv,size_t size,VMStateField *field, -QJSON *vmdesc) -{ -uint8_t *v = pv; -qemu_put_8s (f, v); -return 0 ; -} - -const VMStateInfo vmstate_info_uint8 = { - .name ="uint8" , - .get = get_uint8, - .put = put_uint8, -}; - -/* 16 bit unsigned int */ - -static int get_uint16 (QEMUFile *f,void *pv,size_t size,VMStateField *field) -{ -uint16_t *v = pv; -qemu_get_be16s (f, v); -return 0 ; -} - -static int put_uint16 (QEMUFile *f,void *pv,size_t size,VMStateField *field, -QJSON *vmdesc) -{ -uint16_t *v = pv; -qemu_put_be16s (f, v); -return 0 ; -} - -const VMStateInfo vmstate_info_uint16 = { - .name ="uint16" , - .get = get_uint16, - .put = put_uint16, -}; - -/* 32 bit unsigned int */ - -static int get_uint32 (QEMUFile *f,void *pv,size_t size,VMStateField *field) -{ -uint32_t *v = pv; -qemu_get_be32s (f, v); -return 0 ; -} - -static int put_uint32 (QEMUFile *f,void *pv,size_t size,VMStateField *field, -QJSON *vmdesc) -{ -uint32_t *v = pv; -qemu_put_be32s (f, v); -return 0 ; -} - -const VMStateInfo vmstate_info_uint32 = { - .name ="uint32" , - .get = get_uint32, - .put = put_uint32, -}; - -/* 32 bit uint. See that the received value is the same than the one -in the field */ - -static int get_uint32_equal (QEMUFile *f,void *pv,size_t size, -VMStateField *field) -{ -uint32_t *v = pv; -uint32_t v2; -qemu_get_be32s (f, &v2); - -if (*v == v2) { -return 0 ; - } -error_report ("%" PRIx32" != %" PRIx32, *v, v2); -return -EINVAL ; -} - -const VMStateInfo vmstate_info_uint32_equal = { - .name ="uint32 equal" , - .get = get_uint32_equal, - .put = put_uint32, -}; - -/* 64 bit unsigned int */ - -static int get_uint64 (QEMUFile *f,void *pv,size_t size,VMStateField *field) -{ -uint64_t *v = pv; -qemu_get_be64s (f, v); -return 0 ; -} - -static int put_uint64 (QEMUFile *f,void *pv,size_t size,VMStateField *field, -QJSON *vmdesc) -{ -uint64_t *v = pv; -qemu_put_be64s (f, v); -return 0 ; -} - -const VMStateInfo vmstate_info_uint64 = { - .name ="uint64" , - .get = get_uint64, - .put = put_uint64, -}; - -static int get_nullptr (QEMUFile *f,void *pv,size_t size,VMStateField *field) - -{ -if (qemu_get_byte (f) ==VMS_NULLPTR_MARKER ) { -return 0 ; - } -error_report ("vmstate: get_nullptr expected VMS_NULLPTR_MARKER" ); -return -EINVAL ; -} - -static int put_nullptr (QEMUFile *f,void *pv,size_t size, -VMStateField *field,QJSON *vmdesc) - -{ -if (pv ==NULL ) { -qemu_put_byte (f,VMS_NULLPTR_MARKER ); -return 0 ; - } -error_report ("vmstate: put_nullptr must be called with pv == NULL" ); -return -EINVAL ; -} - -const VMStateInfo vmstate_info_nullptr = { - .name ="uint64" , - .get = get_nullptr, - .put = put_nullptr, -}; - -/* 64 bit unsigned int. See that the received value is the same than the one -in the field */ - -static int get_uint64_equal (QEMUFile *f,void *pv,size_t size, -VMStateField *field) -{ -uint64_t *v = pv; -uint64_t v2; -qemu_get_be64s (f, &v2); - -if (*v == v2) { -return 0 ; - } -error_report ("%" PRIx64" != %" PRIx64, *v, v2); -return -EINVAL ; -} - -const VMStateInfo vmstate_info_uint64_equal = { - .name ="int64 equal" , - .get = get_uint64_equal, - .put = put_uint64, -}; - -/* 8 bit int. See that the received value is the same than the one -in the field */ - -static int get_uint8_equal (QEMUFile *f,void *pv,size_t size, -VMStateField *field) -{ -uint8_t *v = pv; -uint8_t v2; -qemu_get_8s (f, &v2); - -if (*v == v2) { -return 0 ; - } -error_report ("%x != %x" , *v, v2); -return -EINVAL ; -} - -const VMStateInfo vmstate_info_uint8_equal = { - .name ="uint8 equal" , - .get = get_uint8_equal, - .put = put_uint8, -}; - -/* 16 bit unsigned int int. See that the received value is the same than the one -in the field */ - -static int get_uint16_equal (QEMUFile *f,void *pv,size_t size, -VMStateField *field) -{ -uint16_t *v = pv; -uint16_t v2; -qemu_get_be16s (f, &v2); - -if (*v == v2) { -return 0 ; - } -error_report ("%x != %x" , *v, v2); -return -EINVAL ; -} - -const VMStateInfo vmstate_info_uint16_equal = { - .name ="uint16 equal" , - .get = get_uint16_equal, - .put = put_uint16, -}; - -/* floating point */ - -static int get_float64 (QEMUFile *f,void *pv,size_t size, -VMStateField *field) -{ -float64 *v = pv; - - *v =make_float64 (qemu_get_be64 (f)); -return 0 ; -} - -static int put_float64 (QEMUFile *f,void *pv,size_t size,VMStateField *field, -QJSON *vmdesc) -{ -uint64_t *v = pv; - -qemu_put_be64 (f,float64_val (*v)); -return 0 ; -} - -const VMStateInfo vmstate_info_float64 = { - .name ="float64" , - .get = get_float64, - .put = put_float64, -}; - -/* CPU_DoubleU type */ - -static int get_cpudouble (QEMUFile *f,void *pv,size_t size, -VMStateField *field) -{ -CPU_DoubleU *v = pv; -qemu_get_be32s (f, &v->l.upper); -qemu_get_be32s (f, &v->l.lower); -return 0 ; -} - -static int put_cpudouble (QEMUFile *f,void *pv,size_t size, -VMStateField *field,QJSON *vmdesc) -{ -CPU_DoubleU *v = pv; -qemu_put_be32s (f, &v->l.upper); -qemu_put_be32s (f, &v->l.lower); -return 0 ; -} - -const VMStateInfo vmstate_info_cpudouble = { - .name ="CPU_Double_U" , - .get = get_cpudouble, - .put = put_cpudouble, -}; - -/* uint8_t buffers */ - -static int get_buffer (QEMUFile *f,void *pv,size_t size, -VMStateField *field) -{ -uint8_t *v = pv; -qemu_get_buffer (f, v, size); -return 0 ; -} - -static int put_buffer (QEMUFile *f,void *pv,size_t size,VMStateField *field, -QJSON *vmdesc) -{ -uint8_t *v = pv; -qemu_put_buffer (f, v, size); -return 0 ; -} - -const VMStateInfo vmstate_info_buffer = { - .name ="buffer" , - .get = get_buffer, - .put = put_buffer, -}; - -/* unused buffers: space that was used for some fields that are -not useful anymore */ - -static int get_unused_buffer (QEMUFile *f,void *pv,size_t size, -VMStateField *field) -{ -uint8_t buf[1024 ]; -int block_len; - -while (size >0 ) { - block_len =MIN (sizeof (buf), size); - size -= block_len; -qemu_get_buffer (f, buf, block_len); - } -return 0 ; -} - -static int put_unused_buffer (QEMUFile *f,void *pv,size_t size, -VMStateField *field,QJSON *vmdesc) -{ -static const uint8_t buf[1024 ]; -int block_len; - -while (size >0 ) { - block_len =MIN (sizeof (buf), size); - size -= block_len; -qemu_put_buffer (f, buf, block_len); - } - -return 0 ; -} - -const VMStateInfo vmstate_info_unused_buffer = { - .name ="unused_buffer" , - .get = get_unused_buffer, - .put = put_unused_buffer, -}; - -/* vmstate_info_tmp, see VMSTATE_WITH_TMP, the idea is that we allocate -* a temporary buffer and the pre_load/pre_save methods in the child vmsd -* copy stuff from the parent into the child and do calculations to fill -* in fields that don't really exist in the parent but need to be in the -* stream. -*/ -static int get_tmp (QEMUFile *f,void *pv,size_t size,VMStateField *field) -{ -int ret; -const VMStateDescription *vmsd = field->vmsd; -int version_id = field->version_id; -void *tmp =g_malloc (size); - -/* Writes the parent field which is at the start of the tmp */ - *(void **)tmp = pv; - ret =vmstate_load_state (f, vmsd, tmp, version_id); -g_free (tmp); -return ret; -} - -static int put_tmp (QEMUFile *f,void *pv,size_t size,VMStateField *field, -QJSON *vmdesc) -{ -const VMStateDescription *vmsd = field->vmsd; -void *tmp =g_malloc (size); - -/* Writes the parent field which is at the start of the tmp */ - *(void **)tmp = pv; -vmstate_save_state (f, vmsd, tmp, vmdesc); -g_free (tmp); - -return 0 ; -} - -const VMStateInfo vmstate_info_tmp = { - .name ="tmp" , - .get = get_tmp, - .put = put_tmp, -}; - -/* bitmaps (as defined by bitmap.h). Note that size here is the size -* of the bitmap in bits. The on-the-wire format of a bitmap is 64 -* bit words with the bits in big endian order. The in-memory format -* is an array of 'unsigned long', which may be either 32 or 64 bits. -*/ -/* This is the number of 64 bit words sent over the wire */ -#define BITS_TO_U64S (nr) DIV_ROUND_UP(nr, 64) -static int get_bitmap (QEMUFile *f,void *pv,size_t size,VMStateField *field) -{ -unsigned long *bmp = pv; -int i, idx =0 ; -for (i =0 ; i <BITS_TO_U64S (size); i++) { -uint64_t w =qemu_get_be64 (f); - bmp[idx++] = w; -if (sizeof (unsigned long ) ==4 && idx <BITS_TO_LONGS (size)) { - bmp[idx++] = w >>32 ; - } - } -return 0 ; -} - -static int put_bitmap (QEMUFile *f,void *pv,size_t size,VMStateField *field, -QJSON *vmdesc) -{ -unsigned long *bmp = pv; -int i, idx =0 ; -for (i =0 ; i <BITS_TO_U64S (size); i++) { -uint64_t w = bmp[idx++]; -if (sizeof (unsigned long ) ==4 && idx <BITS_TO_LONGS (size)) { - w |= ((uint64_t )bmp[idx++]) <<32 ; - } -qemu_put_be64 (f, w); - } - -return 0 ; -} - -const VMStateInfo vmstate_info_bitmap = { - .name ="bitmap" , - .get = get_bitmap, - .put = put_bitmap, -}; - -/* get for QTAILQ -* meta data about the QTAILQ is encoded in a VMStateField structure -*/ -static int get_qtailq (QEMUFile *f,void *pv,size_t unused_size, -VMStateField *field) -{ -int ret =0 ; -const VMStateDescription *vmsd = field->vmsd; -/* size of a QTAILQ element */ -size_t size = field->size; -/* offset of the QTAILQ entry in a QTAILQ element */ -size_t entry_offset = field->start; -int version_id = field->version_id; -void *elm; - -trace_get_qtailq (vmsd->name, version_id); -if (version_id > vmsd->version_id) { -error_report ("%s %s" , vmsd->name,"too new" ); -trace_get_qtailq_end (vmsd->name,"too new" , -EINVAL ); - -return -EINVAL ; - } -if (version_id < vmsd->minimum_version_id) { -error_report ("%s %s" , vmsd->name,"too old" ); -trace_get_qtailq_end (vmsd->name,"too old" , -EINVAL ); -return -EINVAL ; - } - -while (qemu_get_byte (f)) { - elm =g_malloc (size); - ret =vmstate_load_state (f, vmsd, elm, version_id); -if (ret) { -return ret; - } -QTAILQ_RAW_INSERT_TAIL (pv, elm, entry_offset); - } - -trace_get_qtailq_end (vmsd->name,"end" , ret); -return ret; -} - -/* put for QTAILQ */ -static int put_qtailq (QEMUFile *f,void *pv,size_t unused_size, -VMStateField *field,QJSON *vmdesc) -{ -const VMStateDescription *vmsd = field->vmsd; -/* offset of the QTAILQ entry in a QTAILQ element*/ -size_t entry_offset = field->start; -void *elm; - -trace_put_qtailq (vmsd->name, vmsd->version_id); - - QTAILQ_RAW_FOREACH(elm, pv, entry_offset) { -qemu_put_byte (f, true); -vmstate_save_state (f, vmsd, elm, vmdesc); - } -qemu_put_byte (f, false); - -trace_put_qtailq_end (vmsd->name,"end" ); - -return 0 ; -} -const VMStateInfo vmstate_info_qtailq = { - .name ="qtailq" , - .get = get_qtailq, - .put = put_qtailq, -};tests/Makefile.include +1
-1@@ -570,7 +570,7 @@ tests/test-qdev-global-props$(EXESUF): tests/test-qdev-global-props.o \ hw/core/reset.o \ $(test-qapi-obj-y) tests/test-vmstate$(EXESUF): tests/test-vmstate.o \ - migration/vmstate.o migration/qemu-file.o \ + migration/vmstate.o migration/vmstate-types.o migration/qemu-file.o \ migration/qemu-file-channel.o migration/qjson.o \ $(test-io-obj-y) tests/test-timed-average$(EXESUF): tests/test-timed-average.o $(test-util-obj-y)Signature · 1 line
2.9.3
--
Dr. David Alan Gilbert / [email protected] / Manchester, UK
Re: [Qemu-devel] [PATCH 09/12] migration: Split vmstate-types.c from vmstate.c
Quoted 8 lines · Dr. David Alan Gilbert
Quoted 4 lines · * Juan Quintela ([email protected]) wrote:
Now one just has the interperter, and the other has the basic types. Once there, add copyright boilerplate.
Signed-off-by Juan Quintela <[email protected]>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.
PATCH v3 10/12 migration: Remove qemu-file.h from vmstate.h
In reply to Juan Quintela--
minor rearangements due to the rebase
--- include/hw/hw.h | 1 + include/migration/vmstate.h | 3 --- migration/block.c | 1 + migration/colo.c | 1 + migration/postcopy-ram.c | 1 + migration/ram.c | 1 + tests/test-vmstate.c | 1 + 7 files changed, 6 insertions(+), 3 deletions(-)
include/hw/hw.h +1 -0
@@ -11,6 +11,7 @@#include "exec/memory.h" #include "hw/irq.h" #include "migration/vmstate.h" +#include "migration/qemu-file.h" #include "qemu/module.h" #include "sysemu/reset.h"
include/migration/vmstate.h +0 -3
@@ -27,9 +27,6 @@#ifndef QEMU_VMSTATE_H #define QEMU_VMSTATE_H -#ifndef CONFIG_USER_ONLY -#include "migration/qemu-file.h" -#endif #include "migration/qjson.h" typedef void SaveStateHandler (QEMUFile *f,void *opaque);
migration/block.c +1 -0
@@ -26,6 +26,7 @@#include "migration/block.h" #include "migration/migration.h" #include "sysemu/blockdev.h" +#include "migration/qemu-file.h" #include "sysemu/block-backend.h" #define BLOCK_SIZE (1 << 20)
migration/colo.c +1 -0
@@ -15,6 +15,7 @@#include "sysemu/sysemu.h" #include "qemu-file-channel.h" #include "migration/migration.h" +#include "migration/qemu-file.h" #include "migration/colo.h" #include "migration/block.h" #include "io/channel-buffer.h"
migration/postcopy-ram.c +1 -0
@@ -20,6 +20,7 @@#include "qemu-common.h" #include "migration/migration.h" +#include "migration/qemu-file.h" #include "postcopy-ram.h" #include "sysemu/sysemu.h" #include "sysemu/balloon.h"
migration/ram.c +1 -0
@@ -37,6 +37,7 @@#include "qemu/main-loop.h" #include "xbzrle.h" #include "migration/migration.h" +#include "migration/qemu-file.h" #include "postcopy-ram.h" #include "exec/address-spaces.h" #include "migration/page_cache.h"
tests/test-vmstate.c +1 -0
@@ -27,6 +27,7 @@#include "qemu-common.h" #include "migration/migration.h" #include "migration/vmstate.h" +#include "migration/qemu-file.h" #include "../migration/qemu-file-channel.h" #include "qemu/coroutine.h" #include "io/channel-file.h"
Signature · 1 line
2.9.3
PATCH v3 11/12 migration: Remove vmstate.h from migration.h
In reply to Juan Quintela--
Minor rearrangements due to rebase
--- include/migration/migration.h | 1 - migration/block.c | 1 + migration/colo-comm.c | 1 + migration/migration.c | 1 + migration/ram.c | 1 + 5 files changed, 4 insertions(+), 1 deletion(-)
include/migration/migration.h +0 -1
@@ -18,7 +18,6 @@#include "qemu-common.h" #include "qemu/thread.h" #include "qemu/notify.h" -#include "migration/vmstate.h" #include "io/channel.h" #include "qapi-types.h" #include "exec/cpu-common.h"
migration/block.c +1 -0
@@ -27,6 +27,7 @@#include "migration/migration.h" #include "sysemu/blockdev.h" #include "migration/qemu-file.h" +#include "migration/vmstate.h" #include "sysemu/block-backend.h" #define BLOCK_SIZE (1 << 20)
migration/colo-comm.c +1 -0
@@ -13,6 +13,7 @@#include "qemu/osdep.h" #include "migration/migration.h" +#include "migration/vmstate.h" #include "colo.h" #include "trace.h"
migration/migration.c +1 -0
@@ -21,6 +21,7 @@#include "migration/migration.h" #include "qemu-file-channel.h" #include "migration/qemu-file.h" +#include "migration/vmstate.h" #include "sysemu/sysemu.h" #include "block/block.h" #include "qapi/qmp/qerror.h"
migration/ram.c +1 -0
@@ -38,6 +38,7 @@#include "xbzrle.h" #include "migration/migration.h" #include "migration/qemu-file.h" +#include "migration/vmstate.h" #include "postcopy-ram.h" #include "exec/address-spaces.h" #include "migration/page_cache.h"
Signature · 1 line
2.9.3
Re: [Qemu-devel] [PATCH 11/12] migration: Remove vmstate.h from migration.h
Quoted 2 lines · Juan Quintela
Signed-off-by Juan Quintela <[email protected]>Reviewed-by Dr. David Alan Gilbert <[email protected]>
Quoted 73 lines
--
Minor rearrangements due to rebase
--- include/migration/migration.h | 1 - migration/block.c | 1 + migration/colo-comm.c | 1 + migration/migration.c | 1 + migration/ram.c | 1 + 5 files changed, 4 insertions(+), 1 deletion(-)include/migration/migration.h +0
-1@@ -18,7 +18,6 @@#include "qemu-common.h" #include "qemu/thread.h" #include "qemu/notify.h" -#include "migration/vmstate.h" #include "io/channel.h" #include "qapi-types.h" #include "exec/cpu-common.h" migration/block.c +1
-0@@ -27,6 +27,7 @@#include "migration/migration.h" #include "sysemu/blockdev.h" #include "migration/qemu-file.h" +#include "migration/vmstate.h" #include "sysemu/block-backend.h" #define BLOCK_SIZE (1 << 20)migration/colo-comm.c +1
-0@@ -13,6 +13,7 @@#include "qemu/osdep.h" #include "migration/migration.h" +#include "migration/vmstate.h" #include "colo.h" #include "trace.h" migration/migration.c +1
-0@@ -21,6 +21,7 @@#include "migration/migration.h" #include "qemu-file-channel.h" #include "migration/qemu-file.h" +#include "migration/vmstate.h" #include "sysemu/sysemu.h" #include "block/block.h" #include "qapi/qmp/qerror.h" migration/ram.c +1
-0@@ -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"
PATCH v3 12/12 migration: migration.h was not needed
In reply to Juan QuintelaThis files don't use any function from migration.h, so drop it.
--- block/qed.c | 1 - hw/i386/pc_q35.c | 1 - hw/virtio/vhost-user.c | 1 - hw/virtio/vhost-vsock.c | 1 - hw/virtio/virtio.c | 1 - monitor.c | 1 - 6 files changed, 6 deletions(-)
block/qed.c +0 -1
@@ -19,7 +19,6 @@#include "trace.h" #include "qed.h" #include "qapi/qmp/qerror.h" -#include "migration/migration.h" #include "sysemu/block-backend.h" static const AIOCBInfo qed_aiocb_info = {
hw/i386/pc_q35.c +0 -1
@@ -46,7 +46,6 @@#include "hw/ide/ahci.h" #include "hw/usb.h" #include "qemu/error-report.h" -#include "migration/migration.h" /* ICH9 AHCI has 6 ports */ #define MAX_SATA_PORTS 6
hw/virtio/vhost-user.c +0 -1
@@ -17,7 +17,6 @@#include "sysemu/kvm.h" #include "qemu/error-report.h" #include "qemu/sockets.h" -#include "migration/migration.h" #include <sys/ioctl.h> #include <sys/socket.h>
hw/virtio/vhost-vsock.c +0 -1
@@ -17,7 +17,6 @@#include "qapi/error.h" #include "hw/virtio/virtio-bus.h" #include "hw/virtio/virtio-access.h" -#include "migration/migration.h" #include "qemu/error-report.h" #include "hw/virtio/vhost-vsock.h" #include "qemu/iov.h"
hw/virtio/virtio.c +0 -1
@@ -21,7 +21,6 @@#include "hw/virtio/virtio.h" #include "qemu/atomic.h" #include "hw/virtio/virtio-bus.h" -#include "migration/migration.h" #include "hw/virtio/virtio-access.h" #include "sysemu/dma.h"
monitor.c +0 -1
@@ -49,7 +49,6 @@#include "disas/disas.h" #include "sysemu/balloon.h" #include "qemu/timer.h" -#include "migration/migration.h" #include "sysemu/hw_accel.h" #include "qemu/acl.h" #include "sysemu/tpm.h"
Signature · 1 line
2.9.3
Re: [Qemu-devel] [PATCH 12/12] migration: migration.h was not needed
Quoted 53 lines · * Juan Quintela ([email protected]) wrote:
This files don't use any function from
migration.h, so drop it.Signed-off-by Juan Quintela <[email protected]>--- block/qed.c | 1 - hw/i386/pc_q35.c | 1 - hw/virtio/vhost-user.c | 1 - hw/virtio/vhost-vsock.c | 1 - hw/virtio/virtio.c | 1 - monitor.c | 1 - 6 files changed, 6 deletions(-)block/qed.c +0
-1@@ -19,7 +19,6 @@#include "trace.h" #include "qed.h" #include "qapi/qmp/qerror.h" -#include "migration/migration.h" #include "sysemu/block-backend.h" static const AIOCBInfo qed_aiocb_info = {hw/i386/pc_q35.c +0
-1@@ -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 6hw/virtio/vhost-user.c +0
-1@@ -17,7 +17,6 @@#include "sysemu/kvm.h" #include "qemu/error-report.h" #include "qemu/sockets.h" -#include "migration/migration.h" #include <sys/ioctl.h> #include <sys/socket.h> hw/virtio/vhost-vsock.c +0
-0
hw/virtio/vhost-vsock.c line 22
Quoted 7 lines
hw/virtio/vhost-vsock.c +0
-1@@ -17,7 +17,6 @@#include "qapi/error.h" #include "hw/virtio/virtio-bus.h" #include "hw/virtio/virtio-access.h" -#include "migration/migration.h" #include "qemu/error-report.h" #include "hw/virtio/vhost-vsock.h" #include "qemu/iov.h"
Aren't these including it to get vmstate macros?
but have they picked up that instead somewhere?
Dave
Quoted 27 lines
hw/virtio/virtio.c +0
-1@@ -21,7 +21,6 @@#include "hw/virtio/virtio.h" #include "qemu/atomic.h" #include "hw/virtio/virtio-bus.h" -#include "migration/migration.h" #include "hw/virtio/virtio-access.h" #include "sysemu/dma.h" monitor.c +0
-1@@ -49,7 +49,6 @@#include "disas/disas.h" #include "sysemu/balloon.h" #include "qemu/timer.h" -#include "migration/migration.h" #include "sysemu/hw_accel.h" #include "qemu/acl.h" #include "sysemu/tpm.h" Signature · 1 line
2.9.3
--
Dr. David Alan Gilbert / [email protected] / Manchester, UK
Re: [Qemu-devel] [PATCH 12/12] migration: migration.h was not needed
Quoted 56 lines · Dr. David Alan Gilbert
Quoted 55 lines · * Juan Quintela ([email protected]) wrote:
This files don't use any function from
migration.h, so drop it.Signed-off-by Juan Quintela <[email protected]>--- block/qed.c | 1 - hw/i386/pc_q35.c | 1 - hw/virtio/vhost-user.c | 1 - hw/virtio/vhost-vsock.c | 1 - hw/virtio/virtio.c | 1 - monitor.c | 1 - 6 files changed, 6 deletions(-)block/qed.c +0
-1@@ -19,7 +19,6 @@#include "trace.h" #include "qed.h" #include "qapi/qmp/qerror.h" -#include "migration/migration.h" #include "sysemu/block-backend.h" static const AIOCBInfo qed_aiocb_info = {hw/i386/pc_q35.c +0
-1@@ -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 6hw/virtio/vhost-user.c +0
-1@@ -17,7 +17,6 @@#include "sysemu/kvm.h" #include "qemu/error-report.h" #include "qemu/sockets.h" -#include "migration/migration.h" #include <sys/ioctl.h> #include <sys/socket.h> hw/virtio/vhost-vsock.c +0
-0@@ -17,7 +17,6 @@#include "qapi/error.h" #include "hw/virtio/virtio-bus.h"
Quoted 8 lines
hw/virtio/vhost-vsock.c line 22
Quoted 5 lines
hw/virtio/vhost-vsock.c +0
-1#include "hw/virtio/virtio-access.h" -#include "migration/migration.h" #include "qemu/error-report.h" #include "hw/virtio/vhost-vsock.h" #include "qemu/iov.h" Aren't these including it to get vmstate macros?
but have they picked up that instead somewhere?
hw/hw.h
hw/virtio/vhost-vsock.h -> hw/virtio/virtio.h -> hw/hw.h
Dropping vmstate.h from that file would have mean have to add one hundred new includes or so. And I didn't see any good reason for that.
My understanding is that all devices end including hw/hw.h one way or another, so the only reason to add migration include files right now is:
- you use old registartion functions
- you use blockers
- you use migration notifiers
Otherwise, if you just use vmstate macros, they are there by hw/hw.h.
Later, Juan.