[PATCH v4] migration: using trace_ to replace DPRINTF
Signed-off-by: Bihong Yu --- migration/block.c | 36 ++-- migration/page_cache.c | 13 +++-- migration/trace-events | 13 + 3 files changed, 34 insertions(+), 28 deletions(-) diff --git a/migration/block.c b/migration/block.c index 273392b..a950977 100644 --- a/migration/block.c +++ b/migration/block.c @@ -26,6 +26,7 @@ #include "qemu-file.h" #include "migration/vmstate.h" #include "sysemu/block-backend.h" +#include "trace.h" #define BLK_MIG_BLOCK_SIZE (1 << 20) #define BDRV_SECTORS_PER_DIRTY_CHUNK (BLK_MIG_BLOCK_SIZE >> BDRV_SECTOR_BITS) @@ -434,10 +435,9 @@ static int init_blk_migration(QEMUFile *f) block_mig_state.total_sector_sum += sectors; if (bmds->shared_base) { -DPRINTF("Start migration for %s with shared base image\n", -bdrv_get_device_name(bs)); +trace_migration_block_init_shared(bdrv_get_device_name(bs)); } else { -DPRINTF("Start full migration for %s\n", bdrv_get_device_name(bs)); +trace_migration_block_init_full(bdrv_get_device_name(bs)); } QSIMPLEQ_INSERT_TAIL(_mig_state.bmds_list, bmds, entry); @@ -592,7 +592,7 @@ static int mig_save_device_dirty(QEMUFile *f, BlkMigDevState *bmds, return (bmds->cur_dirty >= bmds->total_sectors); error: -DPRINTF("Error reading sector %" PRId64 "\n", sector); +trace_migration_block_save_device_dirty(sector); g_free(blk->buf); g_free(blk); return ret; @@ -628,9 +628,9 @@ static int flush_blks(QEMUFile *f) BlkMigBlock *blk; int ret = 0; -DPRINTF("%s Enter submitted %d read_done %d transferred %d\n", -__func__, block_mig_state.submitted, block_mig_state.read_done, -block_mig_state.transferred); +trace_migration_block_flush_blks("Enter", block_mig_state.submitted, + block_mig_state.read_done, + block_mig_state.transferred); blk_mig_lock(); while ((blk = QSIMPLEQ_FIRST(_mig_state.blk_list)) != NULL) { @@ -656,9 +656,9 @@ static int flush_blks(QEMUFile *f) } blk_mig_unlock(); -DPRINTF("%s Exit submitted %d read_done %d transferred %d\n", __func__, -block_mig_state.submitted, block_mig_state.read_done, -block_mig_state.transferred); +trace_migration_block_flush_blks("Exit", block_mig_state.submitted, + block_mig_state.read_done, + block_mig_state.transferred); return ret; } @@ -727,8 +727,8 @@ static int block_save_setup(QEMUFile *f, void *opaque) { int ret; -DPRINTF("Enter save live setup submitted %d transferred %d\n", -block_mig_state.submitted, block_mig_state.transferred); +trace_migration_block_save("setup", block_mig_state.submitted, + block_mig_state.transferred); qemu_mutex_lock_iothread(); ret = init_blk_migration(f); @@ -759,8 +759,8 @@ static int block_save_iterate(QEMUFile *f, void *opaque) int64_t last_ftell = qemu_ftell(f); int64_t delta_ftell; -DPRINTF("Enter save live iterate submitted %d transferred %d\n", -block_mig_state.submitted, block_mig_state.transferred); +trace_migration_block_save("iterate", block_mig_state.submitted, + block_mig_state.transferred); ret = flush_blks(f); if (ret) { @@ -825,8 +825,8 @@ static int block_save_complete(QEMUFile *f, void *opaque) { int ret; -DPRINTF("Enter save live complete submitted %d transferred %d\n", -block_mig_state.submitted, block_mig_state.transferred); +trace_migration_block_save("complete", block_mig_state.submitted, + block_mig_state.transferred); ret = flush_blks(f); if (ret) { @@ -851,7 +851,7 @@ static int block_save_complete(QEMUFile *f, void *opaque) /* report completion */ qemu_put_be64(f, (100 << BDRV_SECTOR_BITS) | BLK_MIG_FLAG_PROGRESS); -DPRINTF("Block migration completed\n"); +trace_migration_block_save_complete(); qemu_put_be64(f, BLK_MIG_FLAG_EOS); @@ -884,7 +884,7 @@ static void block_save_pending(QEMUFile *f, void *opaque, uint64_t max_size, pending = max_size + BLK_MIG_BLOCK_SIZE; } -DPRINTF("Enter save live pending %" PRIu64 "\n", pending); +trace_migration_block_save_pending(pending); /* We don't do postcopy */ *res_precopy_only += pending; } diff --git a/migration/page_cache.c b/migration/page_cache.c index 775582f..098b436 100644 --- a/migration/page_cache.c +++ b/migration/page_cache.c @@ -
[PATCH v3] migration: using trace_ to replace DPRINTF
Signed-off-by: Bihong Yu --- migration/block.c | 36 ++-- migration/page_cache.c | 13 +++-- migration/trace-events | 13 + 3 files changed, 34 insertions(+), 28 deletions(-) diff --git a/migration/block.c b/migration/block.c index 273392b..a950977 100644 --- a/migration/block.c +++ b/migration/block.c @@ -26,6 +26,7 @@ #include "qemu-file.h" #include "migration/vmstate.h" #include "sysemu/block-backend.h" +#include "trace.h" #define BLK_MIG_BLOCK_SIZE (1 << 20) #define BDRV_SECTORS_PER_DIRTY_CHUNK (BLK_MIG_BLOCK_SIZE >> BDRV_SECTOR_BITS) @@ -434,10 +435,9 @@ static int init_blk_migration(QEMUFile *f) block_mig_state.total_sector_sum += sectors; if (bmds->shared_base) { -DPRINTF("Start migration for %s with shared base image\n", -bdrv_get_device_name(bs)); +trace_migration_block_init_shared(bdrv_get_device_name(bs)); } else { -DPRINTF("Start full migration for %s\n", bdrv_get_device_name(bs)); +trace_migration_block_init_full(bdrv_get_device_name(bs)); } QSIMPLEQ_INSERT_TAIL(_mig_state.bmds_list, bmds, entry); @@ -592,7 +592,7 @@ static int mig_save_device_dirty(QEMUFile *f, BlkMigDevState *bmds, return (bmds->cur_dirty >= bmds->total_sectors); error: -DPRINTF("Error reading sector %" PRId64 "\n", sector); +trace_migration_block_save_device_dirty(sector); g_free(blk->buf); g_free(blk); return ret; @@ -628,9 +628,9 @@ static int flush_blks(QEMUFile *f) BlkMigBlock *blk; int ret = 0; -DPRINTF("%s Enter submitted %d read_done %d transferred %d\n", -__func__, block_mig_state.submitted, block_mig_state.read_done, -block_mig_state.transferred); +trace_migration_block_flush_blks("Enter", block_mig_state.submitted, + block_mig_state.read_done, + block_mig_state.transferred); blk_mig_lock(); while ((blk = QSIMPLEQ_FIRST(_mig_state.blk_list)) != NULL) { @@ -656,9 +656,9 @@ static int flush_blks(QEMUFile *f) } blk_mig_unlock(); -DPRINTF("%s Exit submitted %d read_done %d transferred %d\n", __func__, -block_mig_state.submitted, block_mig_state.read_done, -block_mig_state.transferred); +trace_migration_block_flush_blks("Exit", block_mig_state.submitted, + block_mig_state.read_done, + block_mig_state.transferred); return ret; } @@ -727,8 +727,8 @@ static int block_save_setup(QEMUFile *f, void *opaque) { int ret; -DPRINTF("Enter save live setup submitted %d transferred %d\n", -block_mig_state.submitted, block_mig_state.transferred); +trace_migration_block_save("setup", block_mig_state.submitted, + block_mig_state.transferred); qemu_mutex_lock_iothread(); ret = init_blk_migration(f); @@ -759,8 +759,8 @@ static int block_save_iterate(QEMUFile *f, void *opaque) int64_t last_ftell = qemu_ftell(f); int64_t delta_ftell; -DPRINTF("Enter save live iterate submitted %d transferred %d\n", -block_mig_state.submitted, block_mig_state.transferred); +trace_migration_block_save("iterate", block_mig_state.submitted, + block_mig_state.transferred); ret = flush_blks(f); if (ret) { @@ -825,8 +825,8 @@ static int block_save_complete(QEMUFile *f, void *opaque) { int ret; -DPRINTF("Enter save live complete submitted %d transferred %d\n", -block_mig_state.submitted, block_mig_state.transferred); +trace_migration_block_save("complete", block_mig_state.submitted, + block_mig_state.transferred); ret = flush_blks(f); if (ret) { @@ -851,7 +851,7 @@ static int block_save_complete(QEMUFile *f, void *opaque) /* report completion */ qemu_put_be64(f, (100 << BDRV_SECTOR_BITS) | BLK_MIG_FLAG_PROGRESS); -DPRINTF("Block migration completed\n"); +trace_migration_block_save_complete(); qemu_put_be64(f, BLK_MIG_FLAG_EOS); @@ -884,7 +884,7 @@ static void block_save_pending(QEMUFile *f, void *opaque, uint64_t max_size, pending = max_size + BLK_MIG_BLOCK_SIZE; } -DPRINTF("Enter save live pending %" PRIu64 "\n", pending); +trace_migration_block_save_pending(pending); /* We don't do postcopy */ *res_precopy_only += pending; } diff --git a/migration/page_cache.c b/migration/page_cache.c index 775582f..098b436 100644 --- a/migration/page_cache.c +++ b/migration/page_cache.c @@ -
Re: [PATCH v2] migration: using trace_ to replace DPRINTF
OK, thank you for your help. On 2020/10/20 15:18, Philippe Mathieu-Daudé wrote: > On 10/20/20 9:07 AM, Bihong Yu wrote: >> >> >> On 2020/10/20 14:54, Philippe Mathieu-Daudé wrote: >>> On 10/20/20 8:42 AM, Bihong Yu wrote: >>>> Signed-off-by: Bihong Yu >>>> --- >>>> migration/block.c | 36 ++-- >>>> migration/page_cache.c | 13 +++-- >>>> migration/trace-events | 13 + >>>> 3 files changed, 34 insertions(+), 28 deletions(-) >>>> >>>> diff --git a/migration/block.c b/migration/block.c >>>> index 273392b..1e76a9f 100644 >>>> --- a/migration/block.c >>>> +++ b/migration/block.c >>>> @@ -26,6 +26,7 @@ >>>> #include "qemu-file.h" >>>> #include "migration/vmstate.h" >>>> #include "sysemu/block-backend.h" >>>> +#include "trace.h" >>>> #define BLK_MIG_BLOCK_SIZE (1 << 20) >>>> #define BDRV_SECTORS_PER_DIRTY_CHUNK (BLK_MIG_BLOCK_SIZE >> >>>> BDRV_SECTOR_BITS) >>>> @@ -434,10 +435,9 @@ static int init_blk_migration(QEMUFile *f) >>>> block_mig_state.total_sector_sum += sectors; >>>> if (bmds->shared_base) { >>>> - DPRINTF("Start migration for %s with shared base image\n", >>>> - bdrv_get_device_name(bs)); >>>> + trace_init_blk_migration_shared(bdrv_get_device_name(bs)); >>>> } else { >>>> - DPRINTF("Start full migration for %s\n", >>>> bdrv_get_device_name(bs)); >>>> + trace_init_blk_migration_full(bdrv_get_device_name(bs)); >>>> } >>>> QSIMPLEQ_INSERT_TAIL(_mig_state.bmds_list, bmds, entry); >>>> @@ -592,7 +592,7 @@ static int mig_save_device_dirty(QEMUFile *f, >>>> BlkMigDevState *bmds, >>>> return (bmds->cur_dirty >= bmds->total_sectors); >>>> error: >>>> - DPRINTF("Error reading sector %" PRId64 "\n", sector); >>>> + trace_mig_save_device_dirty(sector); >>>> g_free(blk->buf); >>>> g_free(blk); >>>> return ret; >>>> @@ -628,9 +628,9 @@ static int flush_blks(QEMUFile *f) >>>> BlkMigBlock *blk; >>>> int ret = 0; >>>> - DPRINTF("%s Enter submitted %d read_done %d transferred %d\n", >>>> - __func__, block_mig_state.submitted, >>>> block_mig_state.read_done, >>>> - block_mig_state.transferred); >>>> + trace_flush_blks("Enter", block_mig_state.submitted, >>>> + block_mig_state.read_done, >>>> + block_mig_state.transferred); >>>> blk_mig_lock(); >>>> while ((blk = QSIMPLEQ_FIRST(_mig_state.blk_list)) != NULL) { >>>> @@ -656,9 +656,9 @@ static int flush_blks(QEMUFile *f) >>>> } >>>> blk_mig_unlock(); >>>> - DPRINTF("%s Exit submitted %d read_done %d transferred %d\n", >>>> __func__, >>>> - block_mig_state.submitted, block_mig_state.read_done, >>>> - block_mig_state.transferred); >>>> + trace_flush_blks("Exit", block_mig_state.submitted, >>>> + block_mig_state.read_done, >>>> + block_mig_state.transferred); >>>> return ret; >>>> } >>>> @@ -727,8 +727,8 @@ static int block_save_setup(QEMUFile *f, void >>>> *opaque) >>>> { >>>> int ret; >>>> - DPRINTF("Enter save live setup submitted %d transferred %d\n", >>>> - block_mig_state.submitted, block_mig_state.transferred); >>>> + trace_migration_block_save("setup", block_mig_state.submitted, >>>> + block_mig_state.transferred); >>>> qemu_mutex_lock_iothread(); >>>> ret = init_blk_migration(f); >>>> @@ -759,8 +759,8 @@ static int block_save_iterate(QEMUFile *f, void >>>> *opaque) >>>> int64_t last_ftell = qemu_ftell(f); >>>> int64_t delta_ftell; >>>> - DPRINTF("Enter save live iterate submitted %d t
Re: [PATCH v2] migration: using trace_ to replace DPRINTF
On 2020/10/20 14:54, Philippe Mathieu-Daudé wrote: > On 10/20/20 8:42 AM, Bihong Yu wrote: >> Signed-off-by: Bihong Yu >> --- >> migration/block.c | 36 ++-- >> migration/page_cache.c | 13 +++-- >> migration/trace-events | 13 + >> 3 files changed, 34 insertions(+), 28 deletions(-) >> >> diff --git a/migration/block.c b/migration/block.c >> index 273392b..1e76a9f 100644 >> --- a/migration/block.c >> +++ b/migration/block.c >> @@ -26,6 +26,7 @@ >> #include "qemu-file.h" >> #include "migration/vmstate.h" >> #include "sysemu/block-backend.h" >> +#include "trace.h" >> #define BLK_MIG_BLOCK_SIZE (1 << 20) >> #define BDRV_SECTORS_PER_DIRTY_CHUNK (BLK_MIG_BLOCK_SIZE >> >> BDRV_SECTOR_BITS) >> @@ -434,10 +435,9 @@ static int init_blk_migration(QEMUFile *f) >> block_mig_state.total_sector_sum += sectors; >> if (bmds->shared_base) { >> - DPRINTF("Start migration for %s with shared base image\n", >> - bdrv_get_device_name(bs)); >> + trace_init_blk_migration_shared(bdrv_get_device_name(bs)); >> } else { >> - DPRINTF("Start full migration for %s\n", >> bdrv_get_device_name(bs)); >> + trace_init_blk_migration_full(bdrv_get_device_name(bs)); >> } >> QSIMPLEQ_INSERT_TAIL(_mig_state.bmds_list, bmds, entry); >> @@ -592,7 +592,7 @@ static int mig_save_device_dirty(QEMUFile *f, >> BlkMigDevState *bmds, >> return (bmds->cur_dirty >= bmds->total_sectors); >> error: >> - DPRINTF("Error reading sector %" PRId64 "\n", sector); >> + trace_mig_save_device_dirty(sector); >> g_free(blk->buf); >> g_free(blk); >> return ret; >> @@ -628,9 +628,9 @@ static int flush_blks(QEMUFile *f) >> BlkMigBlock *blk; >> int ret = 0; >> - DPRINTF("%s Enter submitted %d read_done %d transferred %d\n", >> - __func__, block_mig_state.submitted, block_mig_state.read_done, >> - block_mig_state.transferred); >> + trace_flush_blks("Enter", block_mig_state.submitted, >> + block_mig_state.read_done, >> + block_mig_state.transferred); >> blk_mig_lock(); >> while ((blk = QSIMPLEQ_FIRST(_mig_state.blk_list)) != NULL) { >> @@ -656,9 +656,9 @@ static int flush_blks(QEMUFile *f) >> } >> blk_mig_unlock(); >> - DPRINTF("%s Exit submitted %d read_done %d transferred %d\n", >> __func__, >> - block_mig_state.submitted, block_mig_state.read_done, >> - block_mig_state.transferred); >> + trace_flush_blks("Exit", block_mig_state.submitted, >> + block_mig_state.read_done, >> + block_mig_state.transferred); >> return ret; >> } >> @@ -727,8 +727,8 @@ static int block_save_setup(QEMUFile *f, void *opaque) >> { >> int ret; >> - DPRINTF("Enter save live setup submitted %d transferred %d\n", >> - block_mig_state.submitted, block_mig_state.transferred); >> + trace_migration_block_save("setup", block_mig_state.submitted, >> + block_mig_state.transferred); >> qemu_mutex_lock_iothread(); >> ret = init_blk_migration(f); >> @@ -759,8 +759,8 @@ static int block_save_iterate(QEMUFile *f, void *opaque) >> int64_t last_ftell = qemu_ftell(f); >> int64_t delta_ftell; >> - DPRINTF("Enter save live iterate submitted %d transferred %d\n", >> - block_mig_state.submitted, block_mig_state.transferred); >> + trace_migration_block_save("iterate", block_mig_state.submitted, >> + block_mig_state.transferred); >> ret = flush_blks(f); >> if (ret) { >> @@ -825,8 +825,8 @@ static int block_save_complete(QEMUFile *f, void *opaque) >> { >> int ret; >> - DPRINTF("Enter save live complete submitted %d transferred %d\n", >> - block_mig_state.submitted, block_mig_state.transferred); >> + trace_migration_block_save("complete", block_mig_state.submitted, >> + block_mig_state.transferred); >> ret = flush_blks(f); >> if (ret) { >> @@
[PATCH v2] migration: using trace_ to replace DPRINTF
Signed-off-by: Bihong Yu --- migration/block.c | 36 ++-- migration/page_cache.c | 13 +++-- migration/trace-events | 13 + 3 files changed, 34 insertions(+), 28 deletions(-) diff --git a/migration/block.c b/migration/block.c index 273392b..1e76a9f 100644 --- a/migration/block.c +++ b/migration/block.c @@ -26,6 +26,7 @@ #include "qemu-file.h" #include "migration/vmstate.h" #include "sysemu/block-backend.h" +#include "trace.h" #define BLK_MIG_BLOCK_SIZE (1 << 20) #define BDRV_SECTORS_PER_DIRTY_CHUNK (BLK_MIG_BLOCK_SIZE >> BDRV_SECTOR_BITS) @@ -434,10 +435,9 @@ static int init_blk_migration(QEMUFile *f) block_mig_state.total_sector_sum += sectors; if (bmds->shared_base) { -DPRINTF("Start migration for %s with shared base image\n", -bdrv_get_device_name(bs)); +trace_init_blk_migration_shared(bdrv_get_device_name(bs)); } else { -DPRINTF("Start full migration for %s\n", bdrv_get_device_name(bs)); +trace_init_blk_migration_full(bdrv_get_device_name(bs)); } QSIMPLEQ_INSERT_TAIL(_mig_state.bmds_list, bmds, entry); @@ -592,7 +592,7 @@ static int mig_save_device_dirty(QEMUFile *f, BlkMigDevState *bmds, return (bmds->cur_dirty >= bmds->total_sectors); error: -DPRINTF("Error reading sector %" PRId64 "\n", sector); +trace_mig_save_device_dirty(sector); g_free(blk->buf); g_free(blk); return ret; @@ -628,9 +628,9 @@ static int flush_blks(QEMUFile *f) BlkMigBlock *blk; int ret = 0; -DPRINTF("%s Enter submitted %d read_done %d transferred %d\n", -__func__, block_mig_state.submitted, block_mig_state.read_done, -block_mig_state.transferred); +trace_flush_blks("Enter", block_mig_state.submitted, + block_mig_state.read_done, + block_mig_state.transferred); blk_mig_lock(); while ((blk = QSIMPLEQ_FIRST(_mig_state.blk_list)) != NULL) { @@ -656,9 +656,9 @@ static int flush_blks(QEMUFile *f) } blk_mig_unlock(); -DPRINTF("%s Exit submitted %d read_done %d transferred %d\n", __func__, -block_mig_state.submitted, block_mig_state.read_done, -block_mig_state.transferred); +trace_flush_blks("Exit", block_mig_state.submitted, + block_mig_state.read_done, + block_mig_state.transferred); return ret; } @@ -727,8 +727,8 @@ static int block_save_setup(QEMUFile *f, void *opaque) { int ret; -DPRINTF("Enter save live setup submitted %d transferred %d\n", -block_mig_state.submitted, block_mig_state.transferred); +trace_migration_block_save("setup", block_mig_state.submitted, + block_mig_state.transferred); qemu_mutex_lock_iothread(); ret = init_blk_migration(f); @@ -759,8 +759,8 @@ static int block_save_iterate(QEMUFile *f, void *opaque) int64_t last_ftell = qemu_ftell(f); int64_t delta_ftell; -DPRINTF("Enter save live iterate submitted %d transferred %d\n", -block_mig_state.submitted, block_mig_state.transferred); +trace_migration_block_save("iterate", block_mig_state.submitted, + block_mig_state.transferred); ret = flush_blks(f); if (ret) { @@ -825,8 +825,8 @@ static int block_save_complete(QEMUFile *f, void *opaque) { int ret; -DPRINTF("Enter save live complete submitted %d transferred %d\n", -block_mig_state.submitted, block_mig_state.transferred); +trace_migration_block_save("complete", block_mig_state.submitted, + block_mig_state.transferred); ret = flush_blks(f); if (ret) { @@ -851,7 +851,7 @@ static int block_save_complete(QEMUFile *f, void *opaque) /* report completion */ qemu_put_be64(f, (100 << BDRV_SECTOR_BITS) | BLK_MIG_FLAG_PROGRESS); -DPRINTF("Block migration completed\n"); +trace_migration_block_save_complete(); qemu_put_be64(f, BLK_MIG_FLAG_EOS); @@ -884,7 +884,7 @@ static void block_save_pending(QEMUFile *f, void *opaque, uint64_t max_size, pending = max_size + BLK_MIG_BLOCK_SIZE; } -DPRINTF("Enter save live pending %" PRIu64 "\n", pending); +trace_migration_block_save_pending(pending); /* We don't do postcopy */ *res_precopy_only += pending; } diff --git a/migration/page_cache.c b/migration/page_cache.c index 775582f..d554efa 100644 --- a/migration/page_cache.c +++ b/migration/page_cache.c @@ -18,14 +18,7 @@ #include "qapi/error.h" #include "qemu/host-utils.h" #include "page_cache.
[PATCH v3 8/8] migration: Delete redundant spaces
Signed-off-by: Bihong Yu Reviewed-by: Chuan Zheng Reviewed-by: Dr. David Alan Gilbert --- migration/rdma.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/migration/rdma.c b/migration/rdma.c index ca4d315..00eac34 100644 --- a/migration/rdma.c +++ b/migration/rdma.c @@ -855,7 +855,7 @@ static int qemu_rdma_broken_ipv6_kernel(struct ibv_context *verbs, Error **errp) */ if (!verbs) { int num_devices, x; -struct ibv_device ** dev_list = ibv_get_device_list(_devices); +struct ibv_device **dev_list = ibv_get_device_list(_devices); bool roce_found = false; bool ib_found = false; -- 1.8.3.1
[PATCH v3 2/8] migration: Don't use '#' flag of printf format
Signed-off-by: Bihong Yu Reviewed-by: Chuan Zheng Reviewed-by: Dr. David Alan Gilbert --- migration/block.c | 2 +- migration/ram.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/migration/block.c b/migration/block.c index 4b8576b..273392b 100644 --- a/migration/block.c +++ b/migration/block.c @@ -998,7 +998,7 @@ static int block_load(QEMUFile *f, void *opaque, int version_id) (addr == 100) ? '\n' : '\r'); fflush(stdout); } else if (!(flags & BLK_MIG_FLAG_EOS)) { -fprintf(stderr, "Unknown block migration flags: %#x\n", flags); +fprintf(stderr, "Unknown block migration flags: 0x%x\n", flags); return -EINVAL; } ret = qemu_file_get_error(f); diff --git a/migration/ram.c b/migration/ram.c index 433489d..6ed4f9e 100644 --- a/migration/ram.c +++ b/migration/ram.c @@ -3298,7 +3298,7 @@ static int ram_load_postcopy(QEMUFile *f) multifd_recv_sync_main(); break; default: -error_report("Unknown combination of migration flags: %#x" +error_report("Unknown combination of migration flags: 0x%x" " (postcopy mode)", flags); ret = -EINVAL; break; @@ -3576,7 +3576,7 @@ static int ram_load_precopy(QEMUFile *f) if (flags & RAM_SAVE_FLAG_HOOK) { ram_control_load_hook(f, RAM_CONTROL_HOOK, NULL); } else { -error_report("Unknown combination of migration flags: %#x", +error_report("Unknown combination of migration flags: 0x%x", flags); ret = -EINVAL; } -- 1.8.3.1
[PATCH v3 5/8] migration: Add braces {} for if statement
Signed-off-by: Bihong Yu Reviewed-by: Chuan Zheng Reviewed-by: Dr. David Alan Gilbert --- migration/ram.c | 6 -- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/migration/ram.c b/migration/ram.c index 0aea78f..09178cc 100644 --- a/migration/ram.c +++ b/migration/ram.c @@ -101,14 +101,16 @@ static struct { static void XBZRLE_cache_lock(void) { -if (migrate_use_xbzrle()) +if (migrate_use_xbzrle()) { qemu_mutex_lock(); +} } static void XBZRLE_cache_unlock(void) { -if (migrate_use_xbzrle()) +if (migrate_use_xbzrle()) { qemu_mutex_unlock(); +} } /** -- 1.8.3.1
[PATCH v3 7/8] migration: Open brace '{' following function declarations go on the next line
Signed-off-by: Bihong Yu Reviewed-by: Chuan Zheng Reviewed-by: Dr. David Alan Gilbert --- migration/rdma.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/migration/rdma.c b/migration/rdma.c index 0eb42b7..ca4d315 100644 --- a/migration/rdma.c +++ b/migration/rdma.c @@ -273,7 +273,8 @@ static uint64_t htonll(uint64_t v) return u.llv; } -static uint64_t ntohll(uint64_t v) { +static uint64_t ntohll(uint64_t v) +{ union { uint32_t lv[2]; uint64_t llv; } u; u.llv = v; return ((uint64_t)ntohl(u.lv[0]) << 32) | (uint64_t) ntohl(u.lv[1]); -- 1.8.3.1
[PATCH v3 3/8] migration: Add spaces around operator
Signed-off-by: Bihong Yu Reviewed-by: Chuan Zheng Reviewed-by: Dr. David Alan Gilbert --- migration/migration.c| 4 ++-- migration/postcopy-ram.c | 2 +- migration/ram.c | 2 +- migration/savevm.c | 2 +- migration/vmstate.c | 10 +- 5 files changed, 10 insertions(+), 10 deletions(-) diff --git a/migration/migration.c b/migration/migration.c index 0575ecb..e050f57 100644 --- a/migration/migration.c +++ b/migration/migration.c @@ -2478,8 +2478,8 @@ static void migrate_handle_rp_req_pages(MigrationState *ms, const char* rbname, * Since we currently insist on matching page sizes, just sanity check * we're being asked for whole host pages. */ -if (start & (our_host_ps-1) || - (len & (our_host_ps-1))) { +if (start & (our_host_ps - 1) || + (len & (our_host_ps - 1))) { error_report("%s: Misaligned page request, start: " RAM_ADDR_FMT " len: %zd", __func__, start, len); mark_source_rp_bad(ms); diff --git a/migration/postcopy-ram.c b/migration/postcopy-ram.c index 0a2f88a8..eea92bb 100644 --- a/migration/postcopy-ram.c +++ b/migration/postcopy-ram.c @@ -403,7 +403,7 @@ bool postcopy_ram_supported_by_host(MigrationIncomingState *mis) strerror(errno)); goto out; } -g_assert(((size_t)testarea & (pagesize-1)) == 0); +g_assert(((size_t)testarea & (pagesize - 1)) == 0); reg_struct.range.start = (uintptr_t)testarea; reg_struct.range.len = pagesize; diff --git a/migration/ram.c b/migration/ram.c index 6ed4f9e..0aea78f 100644 --- a/migration/ram.c +++ b/migration/ram.c @@ -1563,7 +1563,7 @@ int ram_save_queue_pages(const char *rbname, ram_addr_t start, ram_addr_t len) rs->last_req_rb = ramblock; } trace_ram_save_queue_pages(ramblock->idstr, start, len); -if (start+len > ramblock->used_length) { +if (start + len > ramblock->used_length) { error_report("%s request overrun start=" RAM_ADDR_FMT " len=" RAM_ADDR_FMT " blocklen=" RAM_ADDR_FMT, __func__, start, len, ramblock->used_length); diff --git a/migration/savevm.c b/migration/savevm.c index d2e141f..b21f1c1 100644 --- a/migration/savevm.c +++ b/migration/savevm.c @@ -521,7 +521,7 @@ static const VMStateDescription vmstate_configuration = { VMSTATE_VBUFFER_ALLOC_UINT32(name, SaveState, 0, NULL, len), VMSTATE_END_OF_LIST() }, -.subsections = (const VMStateDescription*[]) { +.subsections = (const VMStateDescription *[]) { _target_page_bits, _capabilites, _uuid, diff --git a/migration/vmstate.c b/migration/vmstate.c index bafa890..e9d2aef 100644 --- a/migration/vmstate.c +++ b/migration/vmstate.c @@ -32,13 +32,13 @@ static int vmstate_n_elems(void *opaque, const VMStateField *field) if (field->flags & VMS_ARRAY) { n_elems = field->num; } else if (field->flags & VMS_VARRAY_INT32) { -n_elems = *(int32_t *)(opaque+field->num_offset); +n_elems = *(int32_t *)(opaque + field->num_offset); } else if (field->flags & VMS_VARRAY_UINT32) { -n_elems = *(uint32_t *)(opaque+field->num_offset); +n_elems = *(uint32_t *)(opaque + field->num_offset); } else if (field->flags & VMS_VARRAY_UINT16) { -n_elems = *(uint16_t *)(opaque+field->num_offset); +n_elems = *(uint16_t *)(opaque + field->num_offset); } else if (field->flags & VMS_VARRAY_UINT8) { -n_elems = *(uint8_t *)(opaque+field->num_offset); +n_elems = *(uint8_t *)(opaque + field->num_offset); } if (field->flags & VMS_MULTIPLY_ELEMENTS) { @@ -54,7 +54,7 @@ static int vmstate_size(void *opaque, const VMStateField *field) int size = field->size; if (field->flags & VMS_VBUFFER) { -size = *(int32_t *)(opaque+field->size_offset); +size = *(int32_t *)(opaque + field->size_offset); if (field->flags & VMS_MULTIPLY) { size *= field->size; } -- 1.8.3.1
[PATCH v3 4/8] migration: Open brace '{' following struct go on the same line
Signed-off-by: Bihong Yu Reviewed-by: Chuan Zheng Reviewed-by: Dr. David Alan Gilbert --- migration/migration.h | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/migration/migration.h b/migration/migration.h index deb411a..99784b4 100644 --- a/migration/migration.h +++ b/migration/migration.h @@ -124,8 +124,7 @@ struct MigrationClass { DeviceClass parent_class; }; -struct MigrationState -{ +struct MigrationState { /*< private >*/ DeviceState parent_obj; -- 1.8.3.1
[PATCH v3 6/8] migration: Do not initialise statics and globals to 0 or NULL
Signed-off-by: Bihong Yu Reviewed-by: Chuan Zheng Reviewed-by: Dr. David Alan Gilbert --- migration/ram.c| 2 +- migration/savevm.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/migration/ram.c b/migration/ram.c index 09178cc..2da2b62 100644 --- a/migration/ram.c +++ b/migration/ram.c @@ -2743,7 +2743,7 @@ static int load_xbzrle(QEMUFile *f, ram_addr_t addr, void *host) */ static inline RAMBlock *ram_block_from_stream(QEMUFile *f, int flags) { -static RAMBlock *block = NULL; +static RAMBlock *block; char id[256]; uint8_t len; diff --git a/migration/savevm.c b/migration/savevm.c index b21f1c1..57368bd 100644 --- a/migration/savevm.c +++ b/migration/savevm.c @@ -64,7 +64,7 @@ #include "qemu/bitmap.h" #include "net/announce.h" -const unsigned int postcopy_ram_discard_version = 0; +const unsigned int postcopy_ram_discard_version; /* Subcommands for QEMU_VM_COMMAND */ enum qemu_vm_cmd { -- 1.8.3.1
[PATCH v3 0/8] Fix some style problems in migration
Recently I am reading migration related code, find some style problems in migration directory while using checkpatch.pl to check migration code. Fix the error style problems. v2: - fix Signed-off-by error - fix printf format error: "%0x" -> "0x%x" v3: - change "VMStateDescription * []" to "VMStateDescription *[]" Bihong Yu (8): migration: Do not use C99 // comments migration: Don't use '#' flag of printf format migration: Add spaces around operator migration: Open brace '{' following struct go on the same line migration: Add braces {} for if statement migration: Do not initialise statics and globals to 0 or NULL migration: Open brace '{' following function declarations go on the next line migration: Delete redundant spaces migration/block.c| 4 ++-- migration/migration.c| 4 ++-- migration/migration.h| 3 +-- migration/postcopy-ram.c | 2 +- migration/ram.c | 14 -- migration/rdma.c | 7 --- migration/savevm.c | 4 ++-- migration/vmstate.c | 10 +- 8 files changed, 25 insertions(+), 23 deletions(-) -- 1.8.3.1
[PATCH v3 1/8] migration: Do not use C99 // comments
Signed-off-by: Bihong Yu Reviewed-by: Chuan Zheng Reviewed-by: Dr. David Alan Gilbert --- migration/block.c | 2 +- migration/rdma.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/migration/block.c b/migration/block.c index 737b649..4b8576b 100644 --- a/migration/block.c +++ b/migration/block.c @@ -40,7 +40,7 @@ #define MAX_IO_BUFFERS 512 #define MAX_PARALLEL_IO 16 -//#define DEBUG_BLK_MIGRATION +/* #define DEBUG_BLK_MIGRATION */ #ifdef DEBUG_BLK_MIGRATION #define DPRINTF(fmt, ...) \ diff --git a/migration/rdma.c b/migration/rdma.c index 0340841..0eb42b7 100644 --- a/migration/rdma.c +++ b/migration/rdma.c @@ -1288,7 +1288,7 @@ const char *print_wrid(int wrid) * workload information or LRU information is available, do not attempt to use * this feature except for basic testing. */ -//#define RDMA_UNREGISTRATION_EXAMPLE +/* #define RDMA_UNREGISTRATION_EXAMPLE */ /* * Perform a non-optimized memory unregistration after every transfer -- 1.8.3.1
Re: [PATCH v2 3/8] migration: Add spaces around operator
OK, I will change it to "VMStateDescription *[]". Thank you for your review. On 2020/10/19 19:59, Markus Armbruster wrote: > Bihong Yu writes: > >> Yes, I used to think "const VMStateDescription *[]" was right, but when I >> search >> similar expressions, most of all are "xxx * []". Such as: >> fsdev/qemu-fsdev.c:54:.opts = (const char * []) >> hw/intc/s390_flic_kvm.c:567:.subsections = (const VMStateDescription * >> []) >> ... > > All three variations occur in the code: no space, space on both sides, > space only on the left. > >> So, I keep the same style. Should I change it to "const VMStateDescription >> *[]"? > > Dropping the change to savevm.c should be fine. > > Changing it to "VMStateDescription *[]" should be also fine. > > I figure you can keep David's R-by in both cases. > > [...] > > . >
Re: [PATCH v2 3/8] migration: Add spaces around operator
Yes, I used to think "const VMStateDescription *[]" was right, but when I search similar expressions, most of all are "xxx * []". Such as: fsdev/qemu-fsdev.c:54:.opts = (const char * []) hw/intc/s390_flic_kvm.c:567:.subsections = (const VMStateDescription * []) ... So, I keep the same style. Should I change it to "const VMStateDescription *[]"? On 2020/10/19 16:24, Markus Armbruster wrote: > "Dr. David Alan Gilbert" writes: > >> * Bihong Yu (yubih...@huawei.com) wrote: >>> Signed-off-by: Bihong Yu >>> Reviewed-by: Chuan Zheng >> >> Yes that's OK, I'm a bit sturprised we need the space afte rthe * in the >> VMStateDescription case, I wouldn't necessarily go and change them all. > > We don't: it's not the binary multiplication operator *, where we want a > space on both sides, it's a pointer declarator, where we want a space on > the left only. > > Example: > > int *pa, *pb, *pc; > *pa = *pb * *pc; > > Note the space on both side of binary operator * (multiplication), but > only on the left side of the pointer declarator's * and the unary > operator * (indirection). > >> Reviewed-by: Dr. David Alan Gilbert > [...] >>> diff --git a/migration/savevm.c b/migration/savevm.c >>> index d2e141f..9e95df1 100644 >>> --- a/migration/savevm.c >>> +++ b/migration/savevm.c >>> @@ -521,7 +521,7 @@ static const VMStateDescription vmstate_configuration = >>> { >>> VMSTATE_VBUFFER_ALLOC_UINT32(name, SaveState, 0, NULL, len), >>> VMSTATE_END_OF_LIST() >>> }, >>> -.subsections = (const VMStateDescription*[]) { >>> +.subsections = (const VMStateDescription * []) { >>> _target_page_bits, >>> _capabilites, >>> _uuid, > > Should be > >.subsections = (const VMStateDescription *[]) { > > [...] > > . >
Re: [PATCH v1] migration: using trace_ to replace DPRINTF
Thank you for your review.OK ,I will adapt them. On 2020/10/17 17:57, Philippe Mathieu-Daudé wrote: > On 10/17/20 11:35 AM, Bihong Yu wrote: >> Signed-off-by: Bihong Yu >> --- >> migration/block.c | 36 ++-- >> migration/page_cache.c | 13 +++-- >> migration/trace-events | 13 + >> 3 files changed, 34 insertions(+), 28 deletions(-) > ... >> diff --git a/migration/trace-events b/migration/trace-events >> index 338f38b..772bb81 100644 >> --- a/migration/trace-events >> +++ b/migration/trace-events >> @@ -325,3 +325,16 @@ get_ramblock_vfn_hash(const char *idstr, uint64_t vfn, >> uint32_t crc) "ramblock n >> calc_page_dirty_rate(const char *idstr, uint32_t new_crc, uint32_t >> old_crc) "ramblock name: %s, new crc: %" PRIu32 ", old crc: %" PRIu32 >> skip_sample_ramblock(const char *idstr, uint64_t ramblock_size) "ramblock >> name: %s, ramblock size: %" PRIu64 >> find_page_matched(const char *idstr) "ramblock %s addr or size changed" >> + >> +# block.c >> +init_blk_migration_shared(const char *blk_device_name) "Start migration for >> %s with shared base image" >> +init_blk_migration_full(const char *blk_device_name) "Start full migration >> for %s" >> +mig_save_device_dirty(int64_t sector) "Error reading sector %" PRId64 >> +flush_blks(const char *action, int submitted, int read_done, int >> transferred) "%s submitted %d read_done %d transferred %d" >> +block_save(const char *mig_stage, int submitted, int transferred) "Enter >> save live %s submitted %d transferred %d" >> +block_save_complete(void) "Block migration completed" >> +block_save_pending(uint64_t pending) "Enter save live pending %" PRIu64 >> + >> +# page_cache.c >> +cache_init(int64_t max_num_items) "Setting cache buckets to %" PRId64 >> +cache_insert(void) "Error allocating page" > > The patch is good, but I strongly recommend to have trace events > starting with the subsystem prefix (here migration). So we can > keep using the 'block*' rule to match all events from the block > subsystem, without including the migration events. > > Thanks, > > Phil. > > .
[PATCH v1] migration: using trace_ to replace DPRINTF
Signed-off-by: Bihong Yu --- migration/block.c | 36 ++-- migration/page_cache.c | 13 +++-- migration/trace-events | 13 + 3 files changed, 34 insertions(+), 28 deletions(-) diff --git a/migration/block.c b/migration/block.c index 273392b..1c3e261 100644 --- a/migration/block.c +++ b/migration/block.c @@ -26,6 +26,7 @@ #include "qemu-file.h" #include "migration/vmstate.h" #include "sysemu/block-backend.h" +#include "trace.h" #define BLK_MIG_BLOCK_SIZE (1 << 20) #define BDRV_SECTORS_PER_DIRTY_CHUNK (BLK_MIG_BLOCK_SIZE >> BDRV_SECTOR_BITS) @@ -434,10 +435,9 @@ static int init_blk_migration(QEMUFile *f) block_mig_state.total_sector_sum += sectors; if (bmds->shared_base) { -DPRINTF("Start migration for %s with shared base image\n", -bdrv_get_device_name(bs)); +trace_init_blk_migration_shared(bdrv_get_device_name(bs)); } else { -DPRINTF("Start full migration for %s\n", bdrv_get_device_name(bs)); +trace_init_blk_migration_full(bdrv_get_device_name(bs)); } QSIMPLEQ_INSERT_TAIL(_mig_state.bmds_list, bmds, entry); @@ -592,7 +592,7 @@ static int mig_save_device_dirty(QEMUFile *f, BlkMigDevState *bmds, return (bmds->cur_dirty >= bmds->total_sectors); error: -DPRINTF("Error reading sector %" PRId64 "\n", sector); +trace_mig_save_device_dirty(sector); g_free(blk->buf); g_free(blk); return ret; @@ -628,9 +628,9 @@ static int flush_blks(QEMUFile *f) BlkMigBlock *blk; int ret = 0; -DPRINTF("%s Enter submitted %d read_done %d transferred %d\n", -__func__, block_mig_state.submitted, block_mig_state.read_done, -block_mig_state.transferred); +trace_flush_blks("Enter", block_mig_state.submitted, + block_mig_state.read_done, + block_mig_state.transferred); blk_mig_lock(); while ((blk = QSIMPLEQ_FIRST(_mig_state.blk_list)) != NULL) { @@ -656,9 +656,9 @@ static int flush_blks(QEMUFile *f) } blk_mig_unlock(); -DPRINTF("%s Exit submitted %d read_done %d transferred %d\n", __func__, -block_mig_state.submitted, block_mig_state.read_done, -block_mig_state.transferred); +trace_flush_blks("Exit", block_mig_state.submitted, + block_mig_state.read_done, + block_mig_state.transferred); return ret; } @@ -727,8 +727,8 @@ static int block_save_setup(QEMUFile *f, void *opaque) { int ret; -DPRINTF("Enter save live setup submitted %d transferred %d\n", -block_mig_state.submitted, block_mig_state.transferred); +trace_block_save("setup", block_mig_state.submitted, + block_mig_state.transferred); qemu_mutex_lock_iothread(); ret = init_blk_migration(f); @@ -759,8 +759,8 @@ static int block_save_iterate(QEMUFile *f, void *opaque) int64_t last_ftell = qemu_ftell(f); int64_t delta_ftell; -DPRINTF("Enter save live iterate submitted %d transferred %d\n", -block_mig_state.submitted, block_mig_state.transferred); +trace_block_save("iterate", block_mig_state.submitted, + block_mig_state.transferred); ret = flush_blks(f); if (ret) { @@ -825,8 +825,8 @@ static int block_save_complete(QEMUFile *f, void *opaque) { int ret; -DPRINTF("Enter save live complete submitted %d transferred %d\n", -block_mig_state.submitted, block_mig_state.transferred); +trace_block_save("complete", block_mig_state.submitted, + block_mig_state.transferred); ret = flush_blks(f); if (ret) { @@ -851,7 +851,7 @@ static int block_save_complete(QEMUFile *f, void *opaque) /* report completion */ qemu_put_be64(f, (100 << BDRV_SECTOR_BITS) | BLK_MIG_FLAG_PROGRESS); -DPRINTF("Block migration completed\n"); +trace_block_save_complete(); qemu_put_be64(f, BLK_MIG_FLAG_EOS); @@ -884,7 +884,7 @@ static void block_save_pending(QEMUFile *f, void *opaque, uint64_t max_size, pending = max_size + BLK_MIG_BLOCK_SIZE; } -DPRINTF("Enter save live pending %" PRIu64 "\n", pending); +trace_block_save_pending(pending); /* We don't do postcopy */ *res_precopy_only += pending; } diff --git a/migration/page_cache.c b/migration/page_cache.c index 775582f..d554efa 100644 --- a/migration/page_cache.c +++ b/migration/page_cache.c @@ -18,14 +18,7 @@ #include "qapi/error.h" #include "qemu/host-utils.h" #include "page_cache.h" - -#ifdef DEBUG_CACHE -#define DPRINTF(fmt, ...) \ -do { fprint
Re: [PATCH v2 1/8] migration: Do not use C99 // comments
OK, I will modify it later. On 2020/10/14 9:29, Zheng Chuan wrote: > Also DEBUG_CACHE in migration/page_cache.c is need to rebase on trace_calls. > > On 2020/10/13 21:20, Bihong Yu wrote: >> Thank you for your review. OK, I will try to rewrite the DPRINTF to use >> trace_ instead. >> >> On 2020/10/13 17:39, Dr. David Alan Gilbert wrote: >>> * Bihong Yu (yubih...@huawei.com) wrote: >>>> Signed-off-by: Bihong Yu >>>> Reviewed-by: Chuan Zheng >>> >>> Reviewed-by: Dr. David Alan Gilbert >>> >>> another task at some point would be to rewrite the DPRINTF's in >>> migration/block.c to use trace_ instead. >>> >>>> --- >>>> migration/block.c | 2 +- >>>> migration/rdma.c | 2 +- >>>> 2 files changed, 2 insertions(+), 2 deletions(-) >>>> >>>> diff --git a/migration/block.c b/migration/block.c >>>> index 737b649..4b8576b 100644 >>>> --- a/migration/block.c >>>> +++ b/migration/block.c >>>> @@ -40,7 +40,7 @@ >>>> #define MAX_IO_BUFFERS 512 >>>> #define MAX_PARALLEL_IO 16 >>>> >>>> -//#define DEBUG_BLK_MIGRATION >>>> +/* #define DEBUG_BLK_MIGRATION */ >>>> >>>> #ifdef DEBUG_BLK_MIGRATION >>>> #define DPRINTF(fmt, ...) \ >>>> diff --git a/migration/rdma.c b/migration/rdma.c >>>> index 0340841..0eb42b7 100644 >>>> --- a/migration/rdma.c >>>> +++ b/migration/rdma.c >>>> @@ -1288,7 +1288,7 @@ const char *print_wrid(int wrid) >>>> * workload information or LRU information is available, do not attempt >>>> to use >>>> * this feature except for basic testing. >>>> */ >>>> -//#define RDMA_UNREGISTRATION_EXAMPLE >>>> +/* #define RDMA_UNREGISTRATION_EXAMPLE */ >>>> >>>> /* >>>> * Perform a non-optimized memory unregistration after every transfer >>>> -- >>>> 1.8.3.1 >>>> >> . >> >
Re: [PATCH v2 1/8] migration: Do not use C99 // comments
Thank you for your review. OK, I will try to rewrite the DPRINTF to use trace_ instead. On 2020/10/13 17:39, Dr. David Alan Gilbert wrote: > * Bihong Yu (yubih...@huawei.com) wrote: >> Signed-off-by: Bihong Yu >> Reviewed-by: Chuan Zheng > > Reviewed-by: Dr. David Alan Gilbert > > another task at some point would be to rewrite the DPRINTF's in > migration/block.c to use trace_ instead. > >> --- >> migration/block.c | 2 +- >> migration/rdma.c | 2 +- >> 2 files changed, 2 insertions(+), 2 deletions(-) >> >> diff --git a/migration/block.c b/migration/block.c >> index 737b649..4b8576b 100644 >> --- a/migration/block.c >> +++ b/migration/block.c >> @@ -40,7 +40,7 @@ >> #define MAX_IO_BUFFERS 512 >> #define MAX_PARALLEL_IO 16 >> >> -//#define DEBUG_BLK_MIGRATION >> +/* #define DEBUG_BLK_MIGRATION */ >> >> #ifdef DEBUG_BLK_MIGRATION >> #define DPRINTF(fmt, ...) \ >> diff --git a/migration/rdma.c b/migration/rdma.c >> index 0340841..0eb42b7 100644 >> --- a/migration/rdma.c >> +++ b/migration/rdma.c >> @@ -1288,7 +1288,7 @@ const char *print_wrid(int wrid) >> * workload information or LRU information is available, do not attempt to >> use >> * this feature except for basic testing. >> */ >> -//#define RDMA_UNREGISTRATION_EXAMPLE >> +/* #define RDMA_UNREGISTRATION_EXAMPLE */ >> >> /* >> * Perform a non-optimized memory unregistration after every transfer >> -- >> 1.8.3.1 >>
Re: [PATCH v1 2/8] migration: Don't use '#' flag of printf format
Thank you for your review. OK,I have fixed the problem in v2. On 2020/10/12 2:19, Peter Maydell wrote: > On Sun, 11 Oct 2020 at 14:52, Bihong Yu wrote: >> @@ -998,7 +998,7 @@ static int block_load(QEMUFile *f, void *opaque, int >> version_id) >> (addr == 100) ? '\n' : '\r'); >> fflush(stdout); >> } else if (!(flags & BLK_MIG_FLAG_EOS)) { >> -fprintf(stderr, "Unknown block migration flags: %#x\n", flags); >> +fprintf(stderr, "Unknown block migration flags: %0x\n", flags); > > This doesn't look right. "%#x" will print a number in hex with a leading '0x'. > To get the same effect without using "#" you need "0x%x" (that is, > the format string provides the 0x characters literally). > What you've written is '%0x", which is a format string where the '0' is > a request to print with zero padding (which is ignored since there's no > field width given), so the result is the same as if you'd just said '%x', > and there is no '0x' in the output. > > $ cat /tmp/zz9.c > #include > int main(void) { > printf("%#x\n", 42); > printf("%0x\n", 42); > printf("0x%x\n", 42); > return 0; > } > $ gcc -g -Wall -o /tmp/zz9 /tmp/zz9.c > $ /tmp/zz9 > 0x2a > 2a > 0x2a > >> default: >> -error_report("Unknown combination of migration flags: %#x" >> +error_report("Unknown combination of migration flags: %0x" >> " (postcopy mode)", flags); >> ret = -EINVAL; >> break; >> @@ -3576,7 +3576,7 @@ static int ram_load_precopy(QEMUFile *f) >> if (flags & RAM_SAVE_FLAG_HOOK) { >> ram_control_load_hook(f, RAM_CONTROL_HOOK, NULL); >> } else { >> -error_report("Unknown combination of migration flags: %#x", >> +error_report("Unknown combination of migration flags: %0x", >> flags); >> ret = -EINVAL; >> } > > These two similarly should be "0x%x". > > thanks > -- PMM > . >
[PATCH v2 7/8] migration: Open brace '{' following function declarations go on the next line
Signed-off-by: Bihong Yu Reviewed-by: Chuan Zheng --- migration/rdma.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/migration/rdma.c b/migration/rdma.c index 0eb42b7..ca4d315 100644 --- a/migration/rdma.c +++ b/migration/rdma.c @@ -273,7 +273,8 @@ static uint64_t htonll(uint64_t v) return u.llv; } -static uint64_t ntohll(uint64_t v) { +static uint64_t ntohll(uint64_t v) +{ union { uint32_t lv[2]; uint64_t llv; } u; u.llv = v; return ((uint64_t)ntohl(u.lv[0]) << 32) | (uint64_t) ntohl(u.lv[1]); -- 1.8.3.1
[PATCH v2 6/8] migration: Do not initialise statics and globals to 0 or NULL
Signed-off-by: Bihong Yu Reviewed-by: Chuan Zheng --- migration/ram.c| 2 +- migration/savevm.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/migration/ram.c b/migration/ram.c index 09178cc..2da2b62 100644 --- a/migration/ram.c +++ b/migration/ram.c @@ -2743,7 +2743,7 @@ static int load_xbzrle(QEMUFile *f, ram_addr_t addr, void *host) */ static inline RAMBlock *ram_block_from_stream(QEMUFile *f, int flags) { -static RAMBlock *block = NULL; +static RAMBlock *block; char id[256]; uint8_t len; diff --git a/migration/savevm.c b/migration/savevm.c index 9e95df1..f808bc2 100644 --- a/migration/savevm.c +++ b/migration/savevm.c @@ -64,7 +64,7 @@ #include "qemu/bitmap.h" #include "net/announce.h" -const unsigned int postcopy_ram_discard_version = 0; +const unsigned int postcopy_ram_discard_version; /* Subcommands for QEMU_VM_COMMAND */ enum qemu_vm_cmd { -- 1.8.3.1
[PATCH v2 5/8] migration: Add braces {} for if statement
Signed-off-by: Bihong Yu Reviewed-by: Chuan Zheng --- migration/ram.c | 6 -- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/migration/ram.c b/migration/ram.c index 0aea78f..09178cc 100644 --- a/migration/ram.c +++ b/migration/ram.c @@ -101,14 +101,16 @@ static struct { static void XBZRLE_cache_lock(void) { -if (migrate_use_xbzrle()) +if (migrate_use_xbzrle()) { qemu_mutex_lock(); +} } static void XBZRLE_cache_unlock(void) { -if (migrate_use_xbzrle()) +if (migrate_use_xbzrle()) { qemu_mutex_unlock(); +} } /** -- 1.8.3.1
[PATCH v2 4/8] migration: Open brace '{' following struct go on the same line
Signed-off-by: Bihong Yu Reviewed-by: Chuan Zheng --- migration/migration.h | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/migration/migration.h b/migration/migration.h index deb411a..99784b4 100644 --- a/migration/migration.h +++ b/migration/migration.h @@ -124,8 +124,7 @@ struct MigrationClass { DeviceClass parent_class; }; -struct MigrationState -{ +struct MigrationState { /*< private >*/ DeviceState parent_obj; -- 1.8.3.1
[PATCH v2 8/8] migration: Delete redundant spaces
Signed-off-by: Bihong Yu Reviewed-by: Chuan Zheng --- migration/rdma.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/migration/rdma.c b/migration/rdma.c index ca4d315..00eac34 100644 --- a/migration/rdma.c +++ b/migration/rdma.c @@ -855,7 +855,7 @@ static int qemu_rdma_broken_ipv6_kernel(struct ibv_context *verbs, Error **errp) */ if (!verbs) { int num_devices, x; -struct ibv_device ** dev_list = ibv_get_device_list(_devices); +struct ibv_device **dev_list = ibv_get_device_list(_devices); bool roce_found = false; bool ib_found = false; -- 1.8.3.1
[PATCH v2 0/8] Fix some style problems in migration
Recently I am reading migration related code, find some style problems in migration directory while using checkpatch.pl to check migration code. Fix the error style problems. v2: - fix Signed-off-by error - fix printf format error: "%0x" -> "0x%x" Bihong Yu (8): migration: Do not use C99 // comments migration: Don't use '#' flag of printf format migration: Add spaces around operator migration: Open brace '{' following struct go on the same line migration: Add braces {} for if statement migration: Do not initialise statics and globals to 0 or NULL migration: Open brace '{' following function declarations go on the next line migration: Delete redundant spaces migration/block.c| 4 ++-- migration/migration.c| 4 ++-- migration/migration.h| 3 +-- migration/postcopy-ram.c | 2 +- migration/ram.c | 14 -- migration/rdma.c | 7 --- migration/savevm.c | 4 ++-- migration/vmstate.c | 10 +- 8 files changed, 25 insertions(+), 23 deletions(-) -- 1.8.3.1
[PATCH v2 3/8] migration: Add spaces around operator
Signed-off-by: Bihong Yu Reviewed-by: Chuan Zheng --- migration/migration.c| 4 ++-- migration/postcopy-ram.c | 2 +- migration/ram.c | 2 +- migration/savevm.c | 2 +- migration/vmstate.c | 10 +- 5 files changed, 10 insertions(+), 10 deletions(-) diff --git a/migration/migration.c b/migration/migration.c index 0575ecb..e050f57 100644 --- a/migration/migration.c +++ b/migration/migration.c @@ -2478,8 +2478,8 @@ static void migrate_handle_rp_req_pages(MigrationState *ms, const char* rbname, * Since we currently insist on matching page sizes, just sanity check * we're being asked for whole host pages. */ -if (start & (our_host_ps-1) || - (len & (our_host_ps-1))) { +if (start & (our_host_ps - 1) || + (len & (our_host_ps - 1))) { error_report("%s: Misaligned page request, start: " RAM_ADDR_FMT " len: %zd", __func__, start, len); mark_source_rp_bad(ms); diff --git a/migration/postcopy-ram.c b/migration/postcopy-ram.c index 0a2f88a8..eea92bb 100644 --- a/migration/postcopy-ram.c +++ b/migration/postcopy-ram.c @@ -403,7 +403,7 @@ bool postcopy_ram_supported_by_host(MigrationIncomingState *mis) strerror(errno)); goto out; } -g_assert(((size_t)testarea & (pagesize-1)) == 0); +g_assert(((size_t)testarea & (pagesize - 1)) == 0); reg_struct.range.start = (uintptr_t)testarea; reg_struct.range.len = pagesize; diff --git a/migration/ram.c b/migration/ram.c index 6ed4f9e..0aea78f 100644 --- a/migration/ram.c +++ b/migration/ram.c @@ -1563,7 +1563,7 @@ int ram_save_queue_pages(const char *rbname, ram_addr_t start, ram_addr_t len) rs->last_req_rb = ramblock; } trace_ram_save_queue_pages(ramblock->idstr, start, len); -if (start+len > ramblock->used_length) { +if (start + len > ramblock->used_length) { error_report("%s request overrun start=" RAM_ADDR_FMT " len=" RAM_ADDR_FMT " blocklen=" RAM_ADDR_FMT, __func__, start, len, ramblock->used_length); diff --git a/migration/savevm.c b/migration/savevm.c index d2e141f..9e95df1 100644 --- a/migration/savevm.c +++ b/migration/savevm.c @@ -521,7 +521,7 @@ static const VMStateDescription vmstate_configuration = { VMSTATE_VBUFFER_ALLOC_UINT32(name, SaveState, 0, NULL, len), VMSTATE_END_OF_LIST() }, -.subsections = (const VMStateDescription*[]) { +.subsections = (const VMStateDescription * []) { _target_page_bits, _capabilites, _uuid, diff --git a/migration/vmstate.c b/migration/vmstate.c index bafa890..e9d2aef 100644 --- a/migration/vmstate.c +++ b/migration/vmstate.c @@ -32,13 +32,13 @@ static int vmstate_n_elems(void *opaque, const VMStateField *field) if (field->flags & VMS_ARRAY) { n_elems = field->num; } else if (field->flags & VMS_VARRAY_INT32) { -n_elems = *(int32_t *)(opaque+field->num_offset); +n_elems = *(int32_t *)(opaque + field->num_offset); } else if (field->flags & VMS_VARRAY_UINT32) { -n_elems = *(uint32_t *)(opaque+field->num_offset); +n_elems = *(uint32_t *)(opaque + field->num_offset); } else if (field->flags & VMS_VARRAY_UINT16) { -n_elems = *(uint16_t *)(opaque+field->num_offset); +n_elems = *(uint16_t *)(opaque + field->num_offset); } else if (field->flags & VMS_VARRAY_UINT8) { -n_elems = *(uint8_t *)(opaque+field->num_offset); +n_elems = *(uint8_t *)(opaque + field->num_offset); } if (field->flags & VMS_MULTIPLY_ELEMENTS) { @@ -54,7 +54,7 @@ static int vmstate_size(void *opaque, const VMStateField *field) int size = field->size; if (field->flags & VMS_VBUFFER) { -size = *(int32_t *)(opaque+field->size_offset); +size = *(int32_t *)(opaque + field->size_offset); if (field->flags & VMS_MULTIPLY) { size *= field->size; } -- 1.8.3.1
[PATCH v2 1/8] migration: Do not use C99 // comments
Signed-off-by: Bihong Yu Reviewed-by: Chuan Zheng --- migration/block.c | 2 +- migration/rdma.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/migration/block.c b/migration/block.c index 737b649..4b8576b 100644 --- a/migration/block.c +++ b/migration/block.c @@ -40,7 +40,7 @@ #define MAX_IO_BUFFERS 512 #define MAX_PARALLEL_IO 16 -//#define DEBUG_BLK_MIGRATION +/* #define DEBUG_BLK_MIGRATION */ #ifdef DEBUG_BLK_MIGRATION #define DPRINTF(fmt, ...) \ diff --git a/migration/rdma.c b/migration/rdma.c index 0340841..0eb42b7 100644 --- a/migration/rdma.c +++ b/migration/rdma.c @@ -1288,7 +1288,7 @@ const char *print_wrid(int wrid) * workload information or LRU information is available, do not attempt to use * this feature except for basic testing. */ -//#define RDMA_UNREGISTRATION_EXAMPLE +/* #define RDMA_UNREGISTRATION_EXAMPLE */ /* * Perform a non-optimized memory unregistration after every transfer -- 1.8.3.1
[PATCH v2 2/8] migration: Don't use '#' flag of printf format
Signed-off-by: Bihong Yu Reviewed-by: Chuan Zheng --- migration/block.c | 2 +- migration/ram.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/migration/block.c b/migration/block.c index 4b8576b..273392b 100644 --- a/migration/block.c +++ b/migration/block.c @@ -998,7 +998,7 @@ static int block_load(QEMUFile *f, void *opaque, int version_id) (addr == 100) ? '\n' : '\r'); fflush(stdout); } else if (!(flags & BLK_MIG_FLAG_EOS)) { -fprintf(stderr, "Unknown block migration flags: %#x\n", flags); +fprintf(stderr, "Unknown block migration flags: 0x%x\n", flags); return -EINVAL; } ret = qemu_file_get_error(f); diff --git a/migration/ram.c b/migration/ram.c index 433489d..6ed4f9e 100644 --- a/migration/ram.c +++ b/migration/ram.c @@ -3298,7 +3298,7 @@ static int ram_load_postcopy(QEMUFile *f) multifd_recv_sync_main(); break; default: -error_report("Unknown combination of migration flags: %#x" +error_report("Unknown combination of migration flags: 0x%x" " (postcopy mode)", flags); ret = -EINVAL; break; @@ -3576,7 +3576,7 @@ static int ram_load_precopy(QEMUFile *f) if (flags & RAM_SAVE_FLAG_HOOK) { ram_control_load_hook(f, RAM_CONTROL_HOOK, NULL); } else { -error_report("Unknown combination of migration flags: %#x", +error_report("Unknown combination of migration flags: 0x%x", flags); ret = -EINVAL; } -- 1.8.3.1
[PATCH v1 5/8] migration: Add braces {} for if statement
Signed-off-by:Bihong Yu Reviewed-by: Chuan Zheng Signed-off-by: Bihong Yu --- migration/ram.c | 6 -- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/migration/ram.c b/migration/ram.c index 90b277b..12e7296 100644 --- a/migration/ram.c +++ b/migration/ram.c @@ -101,14 +101,16 @@ static struct { static void XBZRLE_cache_lock(void) { -if (migrate_use_xbzrle()) +if (migrate_use_xbzrle()) { qemu_mutex_lock(); +} } static void XBZRLE_cache_unlock(void) { -if (migrate_use_xbzrle()) +if (migrate_use_xbzrle()) { qemu_mutex_unlock(); +} } /** -- 1.8.3.1
[PATCH v1 4/8] migration: Open brace '{' following struct go on the same line
Signed-off-by:Bihong Yu Reviewed-by: Chuan Zheng Signed-off-by: Bihong Yu --- migration/migration.h | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/migration/migration.h b/migration/migration.h index deb411a..99784b4 100644 --- a/migration/migration.h +++ b/migration/migration.h @@ -124,8 +124,7 @@ struct MigrationClass { DeviceClass parent_class; }; -struct MigrationState -{ +struct MigrationState { /*< private >*/ DeviceState parent_obj; -- 1.8.3.1
[PATCH v1 6/8] migration: Do not initialise statics and globals to 0 or NULL
Signed-off-by:Bihong Yu Reviewed-by: Chuan Zheng Signed-off-by: Bihong Yu --- migration/ram.c| 2 +- migration/savevm.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/migration/ram.c b/migration/ram.c index 12e7296..f71ff2b 100644 --- a/migration/ram.c +++ b/migration/ram.c @@ -2743,7 +2743,7 @@ static int load_xbzrle(QEMUFile *f, ram_addr_t addr, void *host) */ static inline RAMBlock *ram_block_from_stream(QEMUFile *f, int flags) { -static RAMBlock *block = NULL; +static RAMBlock *block; char id[256]; uint8_t len; diff --git a/migration/savevm.c b/migration/savevm.c index 9e95df1..f808bc2 100644 --- a/migration/savevm.c +++ b/migration/savevm.c @@ -64,7 +64,7 @@ #include "qemu/bitmap.h" #include "net/announce.h" -const unsigned int postcopy_ram_discard_version = 0; +const unsigned int postcopy_ram_discard_version; /* Subcommands for QEMU_VM_COMMAND */ enum qemu_vm_cmd { -- 1.8.3.1
[PATCH v1 2/8] migration: Don't use '#' flag of printf format
Signed-off-by:Bihong Yu Reviewed-by: Chuan Zheng Signed-off-by: Bihong Yu --- migration/block.c | 2 +- migration/ram.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/migration/block.c b/migration/block.c index 4b8576b..399dfb8 100644 --- a/migration/block.c +++ b/migration/block.c @@ -998,7 +998,7 @@ static int block_load(QEMUFile *f, void *opaque, int version_id) (addr == 100) ? '\n' : '\r'); fflush(stdout); } else if (!(flags & BLK_MIG_FLAG_EOS)) { -fprintf(stderr, "Unknown block migration flags: %#x\n", flags); +fprintf(stderr, "Unknown block migration flags: %0x\n", flags); return -EINVAL; } ret = qemu_file_get_error(f); diff --git a/migration/ram.c b/migration/ram.c index 433489d..59bdd15 100644 --- a/migration/ram.c +++ b/migration/ram.c @@ -3298,7 +3298,7 @@ static int ram_load_postcopy(QEMUFile *f) multifd_recv_sync_main(); break; default: -error_report("Unknown combination of migration flags: %#x" +error_report("Unknown combination of migration flags: %0x" " (postcopy mode)", flags); ret = -EINVAL; break; @@ -3576,7 +3576,7 @@ static int ram_load_precopy(QEMUFile *f) if (flags & RAM_SAVE_FLAG_HOOK) { ram_control_load_hook(f, RAM_CONTROL_HOOK, NULL); } else { -error_report("Unknown combination of migration flags: %#x", +error_report("Unknown combination of migration flags: %0x", flags); ret = -EINVAL; } -- 1.8.3.1
[PATCH v1 3/8] migration: Add spaces around operator
Signed-off-by:Bihong Yu Reviewed-by: Chuan Zheng Signed-off-by: Bihong Yu --- migration/migration.c| 4 ++-- migration/postcopy-ram.c | 2 +- migration/ram.c | 2 +- migration/savevm.c | 2 +- migration/vmstate.c | 10 +- 5 files changed, 10 insertions(+), 10 deletions(-) diff --git a/migration/migration.c b/migration/migration.c index 0575ecb..e050f57 100644 --- a/migration/migration.c +++ b/migration/migration.c @@ -2478,8 +2478,8 @@ static void migrate_handle_rp_req_pages(MigrationState *ms, const char* rbname, * Since we currently insist on matching page sizes, just sanity check * we're being asked for whole host pages. */ -if (start & (our_host_ps-1) || - (len & (our_host_ps-1))) { +if (start & (our_host_ps - 1) || + (len & (our_host_ps - 1))) { error_report("%s: Misaligned page request, start: " RAM_ADDR_FMT " len: %zd", __func__, start, len); mark_source_rp_bad(ms); diff --git a/migration/postcopy-ram.c b/migration/postcopy-ram.c index 0a2f88a8..eea92bb 100644 --- a/migration/postcopy-ram.c +++ b/migration/postcopy-ram.c @@ -403,7 +403,7 @@ bool postcopy_ram_supported_by_host(MigrationIncomingState *mis) strerror(errno)); goto out; } -g_assert(((size_t)testarea & (pagesize-1)) == 0); +g_assert(((size_t)testarea & (pagesize - 1)) == 0); reg_struct.range.start = (uintptr_t)testarea; reg_struct.range.len = pagesize; diff --git a/migration/ram.c b/migration/ram.c index 59bdd15..90b277b 100644 --- a/migration/ram.c +++ b/migration/ram.c @@ -1563,7 +1563,7 @@ int ram_save_queue_pages(const char *rbname, ram_addr_t start, ram_addr_t len) rs->last_req_rb = ramblock; } trace_ram_save_queue_pages(ramblock->idstr, start, len); -if (start+len > ramblock->used_length) { +if (start + len > ramblock->used_length) { error_report("%s request overrun start=" RAM_ADDR_FMT " len=" RAM_ADDR_FMT " blocklen=" RAM_ADDR_FMT, __func__, start, len, ramblock->used_length); diff --git a/migration/savevm.c b/migration/savevm.c index d2e141f..9e95df1 100644 --- a/migration/savevm.c +++ b/migration/savevm.c @@ -521,7 +521,7 @@ static const VMStateDescription vmstate_configuration = { VMSTATE_VBUFFER_ALLOC_UINT32(name, SaveState, 0, NULL, len), VMSTATE_END_OF_LIST() }, -.subsections = (const VMStateDescription*[]) { +.subsections = (const VMStateDescription * []) { _target_page_bits, _capabilites, _uuid, diff --git a/migration/vmstate.c b/migration/vmstate.c index bafa890..e9d2aef 100644 --- a/migration/vmstate.c +++ b/migration/vmstate.c @@ -32,13 +32,13 @@ static int vmstate_n_elems(void *opaque, const VMStateField *field) if (field->flags & VMS_ARRAY) { n_elems = field->num; } else if (field->flags & VMS_VARRAY_INT32) { -n_elems = *(int32_t *)(opaque+field->num_offset); +n_elems = *(int32_t *)(opaque + field->num_offset); } else if (field->flags & VMS_VARRAY_UINT32) { -n_elems = *(uint32_t *)(opaque+field->num_offset); +n_elems = *(uint32_t *)(opaque + field->num_offset); } else if (field->flags & VMS_VARRAY_UINT16) { -n_elems = *(uint16_t *)(opaque+field->num_offset); +n_elems = *(uint16_t *)(opaque + field->num_offset); } else if (field->flags & VMS_VARRAY_UINT8) { -n_elems = *(uint8_t *)(opaque+field->num_offset); +n_elems = *(uint8_t *)(opaque + field->num_offset); } if (field->flags & VMS_MULTIPLY_ELEMENTS) { @@ -54,7 +54,7 @@ static int vmstate_size(void *opaque, const VMStateField *field) int size = field->size; if (field->flags & VMS_VBUFFER) { -size = *(int32_t *)(opaque+field->size_offset); +size = *(int32_t *)(opaque + field->size_offset); if (field->flags & VMS_MULTIPLY) { size *= field->size; } -- 1.8.3.1
[PATCH v1 1/8] migration: Do not use C99 // comments
Signed-off-by:Bihong Yu Reviewed-by: Chuan Zheng Signed-off-by: Bihong Yu --- migration/block.c | 2 +- migration/rdma.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/migration/block.c b/migration/block.c index 737b649..4b8576b 100644 --- a/migration/block.c +++ b/migration/block.c @@ -40,7 +40,7 @@ #define MAX_IO_BUFFERS 512 #define MAX_PARALLEL_IO 16 -//#define DEBUG_BLK_MIGRATION +/* #define DEBUG_BLK_MIGRATION */ #ifdef DEBUG_BLK_MIGRATION #define DPRINTF(fmt, ...) \ diff --git a/migration/rdma.c b/migration/rdma.c index 0340841..0eb42b7 100644 --- a/migration/rdma.c +++ b/migration/rdma.c @@ -1288,7 +1288,7 @@ const char *print_wrid(int wrid) * workload information or LRU information is available, do not attempt to use * this feature except for basic testing. */ -//#define RDMA_UNREGISTRATION_EXAMPLE +/* #define RDMA_UNREGISTRATION_EXAMPLE */ /* * Perform a non-optimized memory unregistration after every transfer -- 1.8.3.1
[PATCH v1 0/8] Fix some style problems in migration
Recently I am reading migration related code, find some style problems in migration directory while using checkpatch.pl to check migration code. Fix the error style problems. Bihong Yu (8): migration: Do not use C99 // comments migration: Don't use '#' flag of printf format migration: Add spaces around operator migration: Open brace '{' following struct go on the same line migration: Add braces {} for if statement migration: Do not initialise statics and globals to 0 or NULL migration: Open brace '{' following function declarations go on the next line migration: Delete redundant spaces migration/block.c| 4 ++-- migration/migration.c| 4 ++-- migration/migration.h| 3 +-- migration/postcopy-ram.c | 2 +- migration/ram.c | 14 -- migration/rdma.c | 7 --- migration/savevm.c | 4 ++-- migration/vmstate.c | 10 +- 8 files changed, 25 insertions(+), 23 deletions(-) -- 1.8.3.1
[PATCH v1 5/8] migration: Add braces {} for if statement
Signed-off-by:Bihong Yu Reviewed-by: Chuan Zheng Signed-off-by: Bihong Yu --- migration/ram.c | 6 -- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/migration/ram.c b/migration/ram.c index 90b277b..12e7296 100644 --- a/migration/ram.c +++ b/migration/ram.c @@ -101,14 +101,16 @@ static struct { static void XBZRLE_cache_lock(void) { -if (migrate_use_xbzrle()) +if (migrate_use_xbzrle()) { qemu_mutex_lock(); +} } static void XBZRLE_cache_unlock(void) { -if (migrate_use_xbzrle()) +if (migrate_use_xbzrle()) { qemu_mutex_unlock(); +} } /** -- 1.8.3.1
[PATCH v1 0/8] Fix some style problems in migration
Recently I am reading migration related code, find some style problems in migration directory while using checkpatch.pl to check migration code. Fix the error style problems. Bihong Yu (8): migration: Do not use C99 // comments migration: Don't use '#' flag of printf format migration: Add spaces around operator migration: Open brace '{' following struct go on the same line migration: Add braces {} for if statement migration: Do not initialise statics and globals to 0 or NULL migration: Open brace '{' following function declarations go on the next line migration: Delete redundant spaces migration/block.c| 4 ++-- migration/migration.c| 4 ++-- migration/migration.h| 3 +-- migration/postcopy-ram.c | 2 +- migration/ram.c | 14 -- migration/rdma.c | 7 --- migration/savevm.c | 4 ++-- migration/vmstate.c | 10 +- 8 files changed, 25 insertions(+), 23 deletions(-) -- 1.8.3.1
[PATCH v1 6/8] migration: Do not initialise statics and globals to 0 or NULL
Signed-off-by:Bihong Yu Reviewed-by: Chuan Zheng Signed-off-by: Bihong Yu --- migration/ram.c| 2 +- migration/savevm.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/migration/ram.c b/migration/ram.c index 12e7296..f71ff2b 100644 --- a/migration/ram.c +++ b/migration/ram.c @@ -2743,7 +2743,7 @@ static int load_xbzrle(QEMUFile *f, ram_addr_t addr, void *host) */ static inline RAMBlock *ram_block_from_stream(QEMUFile *f, int flags) { -static RAMBlock *block = NULL; +static RAMBlock *block; char id[256]; uint8_t len; diff --git a/migration/savevm.c b/migration/savevm.c index 9e95df1..f808bc2 100644 --- a/migration/savevm.c +++ b/migration/savevm.c @@ -64,7 +64,7 @@ #include "qemu/bitmap.h" #include "net/announce.h" -const unsigned int postcopy_ram_discard_version = 0; +const unsigned int postcopy_ram_discard_version; /* Subcommands for QEMU_VM_COMMAND */ enum qemu_vm_cmd { -- 1.8.3.1
[PATCH v1 8/8] migration: Delete redundant spaces
Signed-off-by:Bihong Yu Reviewed-by: Chuan Zheng Signed-off-by: Bihong Yu --- migration/rdma.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/migration/rdma.c b/migration/rdma.c index ca4d315..00eac34 100644 --- a/migration/rdma.c +++ b/migration/rdma.c @@ -855,7 +855,7 @@ static int qemu_rdma_broken_ipv6_kernel(struct ibv_context *verbs, Error **errp) */ if (!verbs) { int num_devices, x; -struct ibv_device ** dev_list = ibv_get_device_list(_devices); +struct ibv_device **dev_list = ibv_get_device_list(_devices); bool roce_found = false; bool ib_found = false; -- 1.8.3.1
[PATCH v1 7/8] migration: Open brace '{' following function declarations go on the next line
Signed-off-by:Bihong Yu Reviewed-by: Chuan Zheng Signed-off-by: Bihong Yu --- migration/rdma.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/migration/rdma.c b/migration/rdma.c index 0eb42b7..ca4d315 100644 --- a/migration/rdma.c +++ b/migration/rdma.c @@ -273,7 +273,8 @@ static uint64_t htonll(uint64_t v) return u.llv; } -static uint64_t ntohll(uint64_t v) { +static uint64_t ntohll(uint64_t v) +{ union { uint32_t lv[2]; uint64_t llv; } u; u.llv = v; return ((uint64_t)ntohl(u.lv[0]) << 32) | (uint64_t) ntohl(u.lv[1]); -- 1.8.3.1
[PATCH v1 4/8] migration: Open brace '{' following struct go on the same line
Signed-off-by:Bihong Yu Reviewed-by: Chuan Zheng Signed-off-by: Bihong Yu --- migration/migration.h | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/migration/migration.h b/migration/migration.h index deb411a..99784b4 100644 --- a/migration/migration.h +++ b/migration/migration.h @@ -124,8 +124,7 @@ struct MigrationClass { DeviceClass parent_class; }; -struct MigrationState -{ +struct MigrationState { /*< private >*/ DeviceState parent_obj; -- 1.8.3.1
[PATCH v1 1/8] migration: Do not use C99 // comments
Signed-off-by:Bihong Yu Reviewed-by: Chuan Zheng Signed-off-by: Bihong Yu --- migration/block.c | 2 +- migration/rdma.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/migration/block.c b/migration/block.c index 737b649..4b8576b 100644 --- a/migration/block.c +++ b/migration/block.c @@ -40,7 +40,7 @@ #define MAX_IO_BUFFERS 512 #define MAX_PARALLEL_IO 16 -//#define DEBUG_BLK_MIGRATION +/* #define DEBUG_BLK_MIGRATION */ #ifdef DEBUG_BLK_MIGRATION #define DPRINTF(fmt, ...) \ diff --git a/migration/rdma.c b/migration/rdma.c index 0340841..0eb42b7 100644 --- a/migration/rdma.c +++ b/migration/rdma.c @@ -1288,7 +1288,7 @@ const char *print_wrid(int wrid) * workload information or LRU information is available, do not attempt to use * this feature except for basic testing. */ -//#define RDMA_UNREGISTRATION_EXAMPLE +/* #define RDMA_UNREGISTRATION_EXAMPLE */ /* * Perform a non-optimized memory unregistration after every transfer -- 1.8.3.1
[PATCH v1 4/8] migration: Open brace '{' following struct go on the same line
Signed-off-by:Bihong Yu Reviewed-by: Chuan Zheng Signed-off-by: Bihong Yu --- migration/migration.h | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/migration/migration.h b/migration/migration.h index deb411a..99784b4 100644 --- a/migration/migration.h +++ b/migration/migration.h @@ -124,8 +124,7 @@ struct MigrationClass { DeviceClass parent_class; }; -struct MigrationState -{ +struct MigrationState { /*< private >*/ DeviceState parent_obj; -- 1.8.3.1
[PATCH v1 2/8] migration: Don't use '#' flag of printf format
Signed-off-by:Bihong Yu Reviewed-by: Chuan Zheng Signed-off-by: Bihong Yu --- migration/block.c | 2 +- migration/ram.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/migration/block.c b/migration/block.c index 4b8576b..399dfb8 100644 --- a/migration/block.c +++ b/migration/block.c @@ -998,7 +998,7 @@ static int block_load(QEMUFile *f, void *opaque, int version_id) (addr == 100) ? '\n' : '\r'); fflush(stdout); } else if (!(flags & BLK_MIG_FLAG_EOS)) { -fprintf(stderr, "Unknown block migration flags: %#x\n", flags); +fprintf(stderr, "Unknown block migration flags: %0x\n", flags); return -EINVAL; } ret = qemu_file_get_error(f); diff --git a/migration/ram.c b/migration/ram.c index 433489d..59bdd15 100644 --- a/migration/ram.c +++ b/migration/ram.c @@ -3298,7 +3298,7 @@ static int ram_load_postcopy(QEMUFile *f) multifd_recv_sync_main(); break; default: -error_report("Unknown combination of migration flags: %#x" +error_report("Unknown combination of migration flags: %0x" " (postcopy mode)", flags); ret = -EINVAL; break; @@ -3576,7 +3576,7 @@ static int ram_load_precopy(QEMUFile *f) if (flags & RAM_SAVE_FLAG_HOOK) { ram_control_load_hook(f, RAM_CONTROL_HOOK, NULL); } else { -error_report("Unknown combination of migration flags: %#x", +error_report("Unknown combination of migration flags: %0x", flags); ret = -EINVAL; } -- 1.8.3.1
[PATCH v1 1/8] migration: Do not use C99 // comments
Signed-off-by:Bihong Yu Reviewed-by: Chuan Zheng Signed-off-by: Bihong Yu --- migration/block.c | 2 +- migration/rdma.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/migration/block.c b/migration/block.c index 737b649..4b8576b 100644 --- a/migration/block.c +++ b/migration/block.c @@ -40,7 +40,7 @@ #define MAX_IO_BUFFERS 512 #define MAX_PARALLEL_IO 16 -//#define DEBUG_BLK_MIGRATION +/* #define DEBUG_BLK_MIGRATION */ #ifdef DEBUG_BLK_MIGRATION #define DPRINTF(fmt, ...) \ diff --git a/migration/rdma.c b/migration/rdma.c index 0340841..0eb42b7 100644 --- a/migration/rdma.c +++ b/migration/rdma.c @@ -1288,7 +1288,7 @@ const char *print_wrid(int wrid) * workload information or LRU information is available, do not attempt to use * this feature except for basic testing. */ -//#define RDMA_UNREGISTRATION_EXAMPLE +/* #define RDMA_UNREGISTRATION_EXAMPLE */ /* * Perform a non-optimized memory unregistration after every transfer -- 1.8.3.1
[PATCH v1 2/8] migration: Don't use '#' flag of printf format
Signed-off-by:Bihong Yu Reviewed-by: Chuan Zheng Signed-off-by: Bihong Yu --- migration/block.c | 2 +- migration/ram.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/migration/block.c b/migration/block.c index 4b8576b..399dfb8 100644 --- a/migration/block.c +++ b/migration/block.c @@ -998,7 +998,7 @@ static int block_load(QEMUFile *f, void *opaque, int version_id) (addr == 100) ? '\n' : '\r'); fflush(stdout); } else if (!(flags & BLK_MIG_FLAG_EOS)) { -fprintf(stderr, "Unknown block migration flags: %#x\n", flags); +fprintf(stderr, "Unknown block migration flags: %0x\n", flags); return -EINVAL; } ret = qemu_file_get_error(f); diff --git a/migration/ram.c b/migration/ram.c index 433489d..59bdd15 100644 --- a/migration/ram.c +++ b/migration/ram.c @@ -3298,7 +3298,7 @@ static int ram_load_postcopy(QEMUFile *f) multifd_recv_sync_main(); break; default: -error_report("Unknown combination of migration flags: %#x" +error_report("Unknown combination of migration flags: %0x" " (postcopy mode)", flags); ret = -EINVAL; break; @@ -3576,7 +3576,7 @@ static int ram_load_precopy(QEMUFile *f) if (flags & RAM_SAVE_FLAG_HOOK) { ram_control_load_hook(f, RAM_CONTROL_HOOK, NULL); } else { -error_report("Unknown combination of migration flags: %#x", +error_report("Unknown combination of migration flags: %0x", flags); ret = -EINVAL; } -- 1.8.3.1
[PATCH v1 7/8] migration: Open brace '{' following function declarations go on the next line
Signed-off-by:Bihong Yu Reviewed-by: Chuan Zheng Signed-off-by: Bihong Yu --- migration/rdma.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/migration/rdma.c b/migration/rdma.c index 0eb42b7..ca4d315 100644 --- a/migration/rdma.c +++ b/migration/rdma.c @@ -273,7 +273,8 @@ static uint64_t htonll(uint64_t v) return u.llv; } -static uint64_t ntohll(uint64_t v) { +static uint64_t ntohll(uint64_t v) +{ union { uint32_t lv[2]; uint64_t llv; } u; u.llv = v; return ((uint64_t)ntohl(u.lv[0]) << 32) | (uint64_t) ntohl(u.lv[1]); -- 1.8.3.1
[PATCH v1 8/8] migration: Delete redundant spaces
Signed-off-by:Bihong Yu Reviewed-by: Chuan Zheng Signed-off-by: Bihong Yu --- migration/rdma.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/migration/rdma.c b/migration/rdma.c index ca4d315..00eac34 100644 --- a/migration/rdma.c +++ b/migration/rdma.c @@ -855,7 +855,7 @@ static int qemu_rdma_broken_ipv6_kernel(struct ibv_context *verbs, Error **errp) */ if (!verbs) { int num_devices, x; -struct ibv_device ** dev_list = ibv_get_device_list(_devices); +struct ibv_device **dev_list = ibv_get_device_list(_devices); bool roce_found = false; bool ib_found = false; -- 1.8.3.1
[PATCH v1 0/8] Fix some style problems in migration
Recently I am reading migration related code, find some style problems in migration directory while using checkpatch.pl to check migration code. Fix the error style problems. Bihong Yu (8): migration: Do not use C99 // comments migration: Don't use '#' flag of printf format migration: Add spaces around operator migration: Open brace '{' following struct go on the same line migration: Add braces {} for if statement migration: Do not initialise statics and globals to 0 or NULL migration: Open brace '{' following function declarations go on the next line migration: Delete redundant spaces migration/block.c| 4 ++-- migration/migration.c| 4 ++-- migration/migration.h| 3 +-- migration/postcopy-ram.c | 2 +- migration/ram.c | 14 -- migration/rdma.c | 7 --- migration/savevm.c | 4 ++-- migration/vmstate.c | 10 +- 8 files changed, 25 insertions(+), 23 deletions(-) -- 1.8.3.1
[PATCH v1 8/8] migration: Delete redundant spaces
Signed-off-by:Bihong Yu Reviewed-by: Chuan Zheng Signed-off-by: Bihong Yu --- migration/rdma.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/migration/rdma.c b/migration/rdma.c index ca4d315..00eac34 100644 --- a/migration/rdma.c +++ b/migration/rdma.c @@ -855,7 +855,7 @@ static int qemu_rdma_broken_ipv6_kernel(struct ibv_context *verbs, Error **errp) */ if (!verbs) { int num_devices, x; -struct ibv_device ** dev_list = ibv_get_device_list(_devices); +struct ibv_device **dev_list = ibv_get_device_list(_devices); bool roce_found = false; bool ib_found = false; -- 1.8.3.1
[PATCH v1 6/8] migration: Do not initialise statics and globals to 0 or NULL
Signed-off-by:Bihong Yu Reviewed-by: Chuan Zheng Signed-off-by: Bihong Yu --- migration/ram.c| 2 +- migration/savevm.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/migration/ram.c b/migration/ram.c index 12e7296..f71ff2b 100644 --- a/migration/ram.c +++ b/migration/ram.c @@ -2743,7 +2743,7 @@ static int load_xbzrle(QEMUFile *f, ram_addr_t addr, void *host) */ static inline RAMBlock *ram_block_from_stream(QEMUFile *f, int flags) { -static RAMBlock *block = NULL; +static RAMBlock *block; char id[256]; uint8_t len; diff --git a/migration/savevm.c b/migration/savevm.c index 9e95df1..f808bc2 100644 --- a/migration/savevm.c +++ b/migration/savevm.c @@ -64,7 +64,7 @@ #include "qemu/bitmap.h" #include "net/announce.h" -const unsigned int postcopy_ram_discard_version = 0; +const unsigned int postcopy_ram_discard_version; /* Subcommands for QEMU_VM_COMMAND */ enum qemu_vm_cmd { -- 1.8.3.1
[PATCH v1 5/8] migration: Add braces {} for if statement
Signed-off-by:Bihong Yu Reviewed-by: Chuan Zheng Signed-off-by: Bihong Yu --- migration/ram.c | 6 -- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/migration/ram.c b/migration/ram.c index 90b277b..12e7296 100644 --- a/migration/ram.c +++ b/migration/ram.c @@ -101,14 +101,16 @@ static struct { static void XBZRLE_cache_lock(void) { -if (migrate_use_xbzrle()) +if (migrate_use_xbzrle()) { qemu_mutex_lock(); +} } static void XBZRLE_cache_unlock(void) { -if (migrate_use_xbzrle()) +if (migrate_use_xbzrle()) { qemu_mutex_unlock(); +} } /** -- 1.8.3.1
[PATCH v1 3/8] migration: Add spaces around operator
Signed-off-by:Bihong Yu Reviewed-by: Chuan Zheng Signed-off-by: Bihong Yu --- migration/migration.c| 4 ++-- migration/postcopy-ram.c | 2 +- migration/ram.c | 2 +- migration/savevm.c | 2 +- migration/vmstate.c | 10 +- 5 files changed, 10 insertions(+), 10 deletions(-) diff --git a/migration/migration.c b/migration/migration.c index 0575ecb..e050f57 100644 --- a/migration/migration.c +++ b/migration/migration.c @@ -2478,8 +2478,8 @@ static void migrate_handle_rp_req_pages(MigrationState *ms, const char* rbname, * Since we currently insist on matching page sizes, just sanity check * we're being asked for whole host pages. */ -if (start & (our_host_ps-1) || - (len & (our_host_ps-1))) { +if (start & (our_host_ps - 1) || + (len & (our_host_ps - 1))) { error_report("%s: Misaligned page request, start: " RAM_ADDR_FMT " len: %zd", __func__, start, len); mark_source_rp_bad(ms); diff --git a/migration/postcopy-ram.c b/migration/postcopy-ram.c index 0a2f88a8..eea92bb 100644 --- a/migration/postcopy-ram.c +++ b/migration/postcopy-ram.c @@ -403,7 +403,7 @@ bool postcopy_ram_supported_by_host(MigrationIncomingState *mis) strerror(errno)); goto out; } -g_assert(((size_t)testarea & (pagesize-1)) == 0); +g_assert(((size_t)testarea & (pagesize - 1)) == 0); reg_struct.range.start = (uintptr_t)testarea; reg_struct.range.len = pagesize; diff --git a/migration/ram.c b/migration/ram.c index 59bdd15..90b277b 100644 --- a/migration/ram.c +++ b/migration/ram.c @@ -1563,7 +1563,7 @@ int ram_save_queue_pages(const char *rbname, ram_addr_t start, ram_addr_t len) rs->last_req_rb = ramblock; } trace_ram_save_queue_pages(ramblock->idstr, start, len); -if (start+len > ramblock->used_length) { +if (start + len > ramblock->used_length) { error_report("%s request overrun start=" RAM_ADDR_FMT " len=" RAM_ADDR_FMT " blocklen=" RAM_ADDR_FMT, __func__, start, len, ramblock->used_length); diff --git a/migration/savevm.c b/migration/savevm.c index d2e141f..9e95df1 100644 --- a/migration/savevm.c +++ b/migration/savevm.c @@ -521,7 +521,7 @@ static const VMStateDescription vmstate_configuration = { VMSTATE_VBUFFER_ALLOC_UINT32(name, SaveState, 0, NULL, len), VMSTATE_END_OF_LIST() }, -.subsections = (const VMStateDescription*[]) { +.subsections = (const VMStateDescription * []) { _target_page_bits, _capabilites, _uuid, diff --git a/migration/vmstate.c b/migration/vmstate.c index bafa890..e9d2aef 100644 --- a/migration/vmstate.c +++ b/migration/vmstate.c @@ -32,13 +32,13 @@ static int vmstate_n_elems(void *opaque, const VMStateField *field) if (field->flags & VMS_ARRAY) { n_elems = field->num; } else if (field->flags & VMS_VARRAY_INT32) { -n_elems = *(int32_t *)(opaque+field->num_offset); +n_elems = *(int32_t *)(opaque + field->num_offset); } else if (field->flags & VMS_VARRAY_UINT32) { -n_elems = *(uint32_t *)(opaque+field->num_offset); +n_elems = *(uint32_t *)(opaque + field->num_offset); } else if (field->flags & VMS_VARRAY_UINT16) { -n_elems = *(uint16_t *)(opaque+field->num_offset); +n_elems = *(uint16_t *)(opaque + field->num_offset); } else if (field->flags & VMS_VARRAY_UINT8) { -n_elems = *(uint8_t *)(opaque+field->num_offset); +n_elems = *(uint8_t *)(opaque + field->num_offset); } if (field->flags & VMS_MULTIPLY_ELEMENTS) { @@ -54,7 +54,7 @@ static int vmstate_size(void *opaque, const VMStateField *field) int size = field->size; if (field->flags & VMS_VBUFFER) { -size = *(int32_t *)(opaque+field->size_offset); +size = *(int32_t *)(opaque + field->size_offset); if (field->flags & VMS_MULTIPLY) { size *= field->size; } -- 1.8.3.1
[PATCH v1 7/8] migration: Open brace '{' following function declarations go on the next line
Signed-off-by:Bihong Yu Reviewed-by: Chuan Zheng Signed-off-by: Bihong Yu --- migration/rdma.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/migration/rdma.c b/migration/rdma.c index 0eb42b7..ca4d315 100644 --- a/migration/rdma.c +++ b/migration/rdma.c @@ -273,7 +273,8 @@ static uint64_t htonll(uint64_t v) return u.llv; } -static uint64_t ntohll(uint64_t v) { +static uint64_t ntohll(uint64_t v) +{ union { uint32_t lv[2]; uint64_t llv; } u; u.llv = v; return ((uint64_t)ntohl(u.lv[0]) << 32) | (uint64_t) ntohl(u.lv[1]); -- 1.8.3.1
[PATCH v1 3/8] migration: Add spaces around operator
Signed-off-by:Bihong Yu Reviewed-by: Chuan Zheng Signed-off-by: Bihong Yu --- migration/migration.c| 4 ++-- migration/postcopy-ram.c | 2 +- migration/ram.c | 2 +- migration/savevm.c | 2 +- migration/vmstate.c | 10 +- 5 files changed, 10 insertions(+), 10 deletions(-) diff --git a/migration/migration.c b/migration/migration.c index 0575ecb..e050f57 100644 --- a/migration/migration.c +++ b/migration/migration.c @@ -2478,8 +2478,8 @@ static void migrate_handle_rp_req_pages(MigrationState *ms, const char* rbname, * Since we currently insist on matching page sizes, just sanity check * we're being asked for whole host pages. */ -if (start & (our_host_ps-1) || - (len & (our_host_ps-1))) { +if (start & (our_host_ps - 1) || + (len & (our_host_ps - 1))) { error_report("%s: Misaligned page request, start: " RAM_ADDR_FMT " len: %zd", __func__, start, len); mark_source_rp_bad(ms); diff --git a/migration/postcopy-ram.c b/migration/postcopy-ram.c index 0a2f88a8..eea92bb 100644 --- a/migration/postcopy-ram.c +++ b/migration/postcopy-ram.c @@ -403,7 +403,7 @@ bool postcopy_ram_supported_by_host(MigrationIncomingState *mis) strerror(errno)); goto out; } -g_assert(((size_t)testarea & (pagesize-1)) == 0); +g_assert(((size_t)testarea & (pagesize - 1)) == 0); reg_struct.range.start = (uintptr_t)testarea; reg_struct.range.len = pagesize; diff --git a/migration/ram.c b/migration/ram.c index 59bdd15..90b277b 100644 --- a/migration/ram.c +++ b/migration/ram.c @@ -1563,7 +1563,7 @@ int ram_save_queue_pages(const char *rbname, ram_addr_t start, ram_addr_t len) rs->last_req_rb = ramblock; } trace_ram_save_queue_pages(ramblock->idstr, start, len); -if (start+len > ramblock->used_length) { +if (start + len > ramblock->used_length) { error_report("%s request overrun start=" RAM_ADDR_FMT " len=" RAM_ADDR_FMT " blocklen=" RAM_ADDR_FMT, __func__, start, len, ramblock->used_length); diff --git a/migration/savevm.c b/migration/savevm.c index d2e141f..9e95df1 100644 --- a/migration/savevm.c +++ b/migration/savevm.c @@ -521,7 +521,7 @@ static const VMStateDescription vmstate_configuration = { VMSTATE_VBUFFER_ALLOC_UINT32(name, SaveState, 0, NULL, len), VMSTATE_END_OF_LIST() }, -.subsections = (const VMStateDescription*[]) { +.subsections = (const VMStateDescription * []) { _target_page_bits, _capabilites, _uuid, diff --git a/migration/vmstate.c b/migration/vmstate.c index bafa890..e9d2aef 100644 --- a/migration/vmstate.c +++ b/migration/vmstate.c @@ -32,13 +32,13 @@ static int vmstate_n_elems(void *opaque, const VMStateField *field) if (field->flags & VMS_ARRAY) { n_elems = field->num; } else if (field->flags & VMS_VARRAY_INT32) { -n_elems = *(int32_t *)(opaque+field->num_offset); +n_elems = *(int32_t *)(opaque + field->num_offset); } else if (field->flags & VMS_VARRAY_UINT32) { -n_elems = *(uint32_t *)(opaque+field->num_offset); +n_elems = *(uint32_t *)(opaque + field->num_offset); } else if (field->flags & VMS_VARRAY_UINT16) { -n_elems = *(uint16_t *)(opaque+field->num_offset); +n_elems = *(uint16_t *)(opaque + field->num_offset); } else if (field->flags & VMS_VARRAY_UINT8) { -n_elems = *(uint8_t *)(opaque+field->num_offset); +n_elems = *(uint8_t *)(opaque + field->num_offset); } if (field->flags & VMS_MULTIPLY_ELEMENTS) { @@ -54,7 +54,7 @@ static int vmstate_size(void *opaque, const VMStateField *field) int size = field->size; if (field->flags & VMS_VBUFFER) { -size = *(int32_t *)(opaque+field->size_offset); +size = *(int32_t *)(opaque + field->size_offset); if (field->flags & VMS_MULTIPLY) { size *= field->size; } -- 1.8.3.1