From ea134caa08ca86689a56665f30bebeb38c5cd1ab Mon Sep 17 00:00:00 2001 From: Greg Kurz Date: Fri, 8 Jun 2018 10:39:09 +0200 Subject: typedefs: add QJSON Since commit 83ee768d6247b, we now have two places that define the QJSON type: $ git grep 'typedef struct QJSON QJSON' include/migration/vmstate.h:typedef struct QJSON QJSON; migration/qjson.h:typedef struct QJSON QJSON; This breaks docker-test-build@centos6: In file included from /tmp/qemu-test/src/migration/savevm.c:59: /tmp/qemu-test/src/migration/qjson.h:16: error: redefinition of typedef 'QJSON' /tmp/qemu-test/src/include/migration/vmstate.h:30: note: previous declaration of 'QJSON' was here make: *** [migration/savevm.o] Error 1 This happens because CentOS 6 has an old GCC 4.4.7. Even if redefining a typedef with the same type is permitted since GCC 4.6, unless -pedantic is passed, we don't really need to do that on purpose. Let's have a single definition in instead. Signed-off-by: Greg Kurz Message-Id: <152844714981.11789.3657734445739553287.stgit@bahia.lan> Reviewed-by: Dr. David Alan Gilbert Signed-off-by: Dr. David Alan Gilbert --- include/migration/vmstate.h | 2 -- include/qemu/typedefs.h | 1 + 2 files changed, 1 insertion(+), 2 deletions(-) (limited to 'include') diff --git a/include/migration/vmstate.h b/include/migration/vmstate.h index 3747110f95..42b946ce90 100644 --- a/include/migration/vmstate.h +++ b/include/migration/vmstate.h @@ -27,8 +27,6 @@ #ifndef QEMU_VMSTATE_H #define QEMU_VMSTATE_H -typedef struct QJSON QJSON; - typedef struct VMStateInfo VMStateInfo; typedef struct VMStateDescription VMStateDescription; typedef struct VMStateField VMStateField; diff --git a/include/qemu/typedefs.h b/include/qemu/typedefs.h index 325c72de33..3ec0e13a96 100644 --- a/include/qemu/typedefs.h +++ b/include/qemu/typedefs.h @@ -97,6 +97,7 @@ typedef struct QEMUTimer QEMUTimer; typedef struct QEMUTimerListGroup QEMUTimerListGroup; typedef struct QBool QBool; typedef struct QDict QDict; +typedef struct QJSON QJSON; typedef struct QList QList; typedef struct QNull QNull; typedef struct QNum QNum; -- cgit v1.2.3-55-g7522 From 343f632c70ab401b1343140c3b19c9fb99395323 Mon Sep 17 00:00:00 2001 From: Dr. David Alan Gilbert Date: Tue, 5 Jun 2018 17:25:45 +0100 Subject: migration: Poison ramblock loops in migration The migration code should be using the RAMBLOCK_FOREACH_MIGRATABLE and qemu_ram_foreach_block_migratable not the all-block versions; poison them so that we can't accidentally use them. Signed-off-by: Dr. David Alan Gilbert Message-Id: <20180605162545.80778-3-dgilbert@redhat.com> Reviewed-by: Peter Xu Reviewed-by: Cédric Le Goater Signed-off-by: Dr. David Alan Gilbert --- include/exec/ramlist.h | 4 +++- migration/migration.h | 3 +++ migration/ram.c | 4 +++- 3 files changed, 9 insertions(+), 2 deletions(-) (limited to 'include') diff --git a/include/exec/ramlist.h b/include/exec/ramlist.h index 2e2ac6cb99..bc4faa1b00 100644 --- a/include/exec/ramlist.h +++ b/include/exec/ramlist.h @@ -56,8 +56,10 @@ typedef struct RAMList { extern RAMList ram_list; /* Should be holding either ram_list.mutex, or the RCU lock. */ -#define RAMBLOCK_FOREACH(block) \ +#define INTERNAL_RAMBLOCK_FOREACH(block) \ QLIST_FOREACH_RCU(block, &ram_list.blocks, next) +/* Never use the INTERNAL_ version except for defining other macros */ +#define RAMBLOCK_FOREACH(block) INTERNAL_RAMBLOCK_FOREACH(block) void qemu_mutex_lock_ramlist(void); void qemu_mutex_unlock_ramlist(void); diff --git a/migration/migration.h b/migration/migration.h index 5af57d616c..31d3ed12dc 100644 --- a/migration/migration.h +++ b/migration/migration.h @@ -284,4 +284,7 @@ void migrate_send_rp_resume_ack(MigrationIncomingState *mis, uint32_t value); void dirty_bitmap_mig_before_vm_start(void); void init_dirty_bitmap_incoming_migration(void); +#define qemu_ram_foreach_block \ + #warning "Use qemu_ram_foreach_block_migratable in migration code" + #endif diff --git a/migration/ram.c b/migration/ram.c index a7807cea84..e0d19305ee 100644 --- a/migration/ram.c +++ b/migration/ram.c @@ -159,9 +159,11 @@ out: /* Should be holding either ram_list.mutex, or the RCU lock. */ #define RAMBLOCK_FOREACH_MIGRATABLE(block) \ - RAMBLOCK_FOREACH(block) \ + INTERNAL_RAMBLOCK_FOREACH(block) \ if (!qemu_ram_is_migratable(block)) {} else +#undef RAMBLOCK_FOREACH + static void ramblock_recv_map_init(void) { RAMBlock *rb; -- cgit v1.2.3-55-g7522