migration queue
Hi Anthony
This are the migration patches on the list at the moment, could you apply?
* cleanup patches from Isaku
* change is_zero_page() prototype
* cleanups from Lei Li
* cleanup from Christoffer Dall
* new VMSTATE macro from Alexey
They are quite easy, passed virt-test without trouble.
Thanks, Juan.
The following changes since commit f828a4c8faa118e0ebab3e353ac6840f3b2a0318:
Merge remote-tracking branch 'stefanha/tracing' into staging (2013-09-23 11:53:22 -0500)
are available in the git repository at:
git://github.com/juanquintela/qemu.git migration.next
for you to fetch changes up to d613a56f845788412a442c6b5aff88b38244f99a:
migration: ram_handle_compressed (2013-09-24 13:22:50 +0200)
----------------------------------------------------------------
Alexey Kardashevskiy (1):
migration: add version supporting macros for struct pointer
Christoffer Dall (1):
migration: Fix debug print type
Isaku Yamahata (4):
rdma: clean up of qemu_rdma_cleanup()
rdma: constify ram_chunk_{index, start, end}
arch_init: make is_zero_page accept size
migration: ram_handle_compressed
Lei Li (3):
savevm: add comments for qemu_file_get_error()
savevm: fix wrong initialization by ram_control_load_hook
arch_init: right return for ram_save_iterate
arch_init.c | 33 +++++++++++++++++++-------------- include/migration/vmstate.h | 17 +++++++++++++++-- migration-rdma.c | 17 +++++++++++------ migration.c | 3 ++- savevm.c | 9 ++++++++- 5 files changed, 55 insertions(+), 24 deletions(-)
PATCH 1/9 savevm: add comments for qemu_file_get_error()
From: Lei Li <[email protected]>
Add comments for qemu_file_get_error(), as its return value is not very clear.
--- savevm.c | 7 +++++++ 1 file changed, 7 insertions(+)
savevm.c +7 -0
@@ -566,6 +566,13 @@ QEMUFile *qemu_fopen_ops(void *opaque, const QEMUFileOps *ops)return f; } +/* +* Get last error for stream f +* +* Return negative error value if there has been an error on previous +* operations, return 0 if no error happened. +* +*/ int qemu_file_get_error (QEMUFile *f) {return f->last_error;
Signature · 1 line
1.8.3.1
PATCH 2/9 savevm: fix wrong initialization by ram_control_load_hook
In reply to Juan QuintelaFrom: Lei Li <[email protected]>
It should set negative error value rather than 0 in QEMUFile if there has been an error.
--- savevm.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
savevm.c +1 -1
@@ -649,7 +649,7 @@ void ram_control_after_iterate(QEMUFile *f, uint64_t flags)void ram_control_load_hook (QEMUFile *f,uint64_t flags) { -int ret =0 ; +int ret = -EINVAL ;if (f->ops->hook_ram_load) { ret = f->ops->hook_ram_load (f, f->opaque, flags);
Signature · 1 line
1.8.3.1
PATCH 3/9 arch_init: right return for ram_save_iterate
In reply to Juan QuintelaFrom: Lei Li <[email protected]>
qemu_file_rate_limit() never return negative value since the refactor by Commit 1964a39, this patch gets rid of the negative check for it, adjust bytes_transferred and return value correspondingly in ram_save_iterate().
--- arch_init.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-)
arch_init.c +10 -5
@@ -710,15 +710,20 @@ static int ram_save_iterate(QEMUFile *f, void *opaque)*/ ram_control_after_iterate (f,RAM_CONTROL_ROUND ); + bytes_transferred += total_sent; + +/* +* Do not count these 8 bytes into total_sent, so that we can +* return 0 if no page had been dirtied. +*/ +qemu_put_be64 (f,RAM_SAVE_FLAG_EOS ); + bytes_transferred +=8 ; + + ret =qemu_file_get_error (f);if (ret <0 ) { - bytes_transferred += total_sent;return ret; } -qemu_put_be64 (f,RAM_SAVE_FLAG_EOS ); - total_sent +=8 ; - bytes_transferred += total_sent; -return total_sent; }
Signature · 1 line
1.8.3.1
PATCH 4/9 rdma: clean up of qemu_rdma_cleanup()
In reply to Juan QuintelaFrom: Isaku Yamahata <[email protected]>
- It can't be determined by RDMAContext::cm_id != NULL if the connection is established or not.
- RDMAContext::cm_id is leaked and not destroyed because it is set to NULL too early.
- RDMAContext::qp is created by rdma_create_qp() so that it should be destroyed by rdma_destroy_qp(). not ibv_destroy_qp()
--- migration-rdma.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-)
migration-rdma.c +6 -3
@@ -356,6 +356,7 @@ typedef struct RDMAContext {*/ struct rdma_cm_id *cm_id;/* connection manager ID */ struct rdma_cm_id *listen_id; +bool connected;struct ibv_context *verbs;struct rdma_event_channel *channel;
@@ -2194,7 +2195,7 @@ static void qemu_rdma_cleanup(RDMAContext *rdma)struct rdma_cm_event *cm_event;int ret, idx; -if (rdma->cm_id) { +if (rdma->cm_id && rdma->connected) {if (rdma->error_state) {RDMAControlHeader head = { .len =0 , .type = RDMA_CONTROL_ERROR,
@@ -2213,7 +2214,7 @@ static void qemu_rdma_cleanup(RDMAContext *rdma) } }DDPRINTF ("Disconnected.\n" ); - rdma->cm_id =NULL ; + rdma->connected = false; }g_free (rdma->block);
@@ -2235,7 +2236,7 @@ static void qemu_rdma_cleanup(RDMAContext *rdma) }if (rdma->qp) { -ibv_destroy_qp (rdma->qp); +rdma_destroy_qp (rdma->cm_id); rdma->qp =NULL ; }if (rdma->cq) {
@@ -2372,6 +2373,7 @@ static int qemu_rdma_connect(RDMAContext *rdma, Error **errp) rdma->cm_id =NULL ; goto err_rdma_source_connect; } + rdma->connected = true;memcpy (&cap, cm_event->param.conn.private_data,sizeof (cap));network_to_caps (&cap);
@@ -2906,6 +2908,7 @@ static int qemu_rdma_accept(RDMAContext *rdma) }rdma_ack_cm_event (cm_event); + rdma->connected = true; ret =qemu_rdma_post_recv_control (rdma,RDMA_WRID_READY );if (ret) {
Signature · 1 line
1.8.3.1
PATCH 5/9 rdma: constify ram_chunk_{index, start, end}
In reply to Juan QuintelaFrom: Isaku Yamahata <[email protected]>
--- migration-rdma.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-)
migration-rdma.c +5 -3
@@ -511,19 +511,21 @@ static int qemu_rdma_exchange_send(RDMAContext *rdma, RDMAControlHeader *head,int *resp_idx, int (*callback)(RDMAContext *rdma)); -static inline uint64_t ram_chunk_index (uint8_t *start,uint8_t *host) +static inline uint64_t ram_chunk_index (const uint8_t *start, +const uint8_t *host) {return ((uintptr_t ) host - (uintptr_t ) start) >>RDMA_REG_CHUNK_SHIFT ; } -static inline uint8_t *ram_chunk_start (RDMALocalBlock *rdma_ram_block, +static inline uint8_t *ram_chunk_start (const RDMALocalBlock *rdma_ram_block,uint64_t i) {return (uint8_t *) (((uintptr_t ) rdma_ram_block->local_host_addr) + (i <<RDMA_REG_CHUNK_SHIFT )); } -static inline uint8_t *ram_chunk_end (RDMALocalBlock *rdma_ram_block,uint64_t i) +static inline uint8_t *ram_chunk_end (const RDMALocalBlock *rdma_ram_block, +uint64_t i) {uint8_t *result =ram_chunk_start (rdma_ram_block, i) + (1UL <<RDMA_REG_CHUNK_SHIFT );
Signature · 1 line
1.8.3.1
PATCH 6/9 migration: add version supporting macros for struct pointer
In reply to Juan QuintelaFrom: Alexey Kardashevskiy <[email protected]>
This adds version supporting macros VMSTATE_STRUCT_POINTER_TEST_V and VMSTATE_STRUCT_POINTER_V in addition to the already existing VMSTATE_STRUCT_POINTER and VMSTATE_STRUCT_POINTER_TEST macros.
--- include/migration/vmstate.h | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-)
include/migration/vmstate.h +15 -2
@@ -310,8 +310,18 @@ extern const VMStateInfo vmstate_info_bitmap; .offset = vmstate_offset_value(_state, _field, _type), \ } -#define VMSTATE_STRUCT_POINTER_TEST (_field, _state, _test, _vmsd, _type) { \ +#define VMSTATE_STRUCT_POINTER_V (_field, _state, _version, _vmsd, _type) { \ .name = (stringify(_field)), \ + .version_id = (_version), \ + .vmsd = &(_vmsd), \ + .size = sizeof(_type), \ + .flags = VMS_STRUCT|VMS_POINTER, \ + .offset = vmstate_offset_value(_state, _field, _type), \ +} + +#define VMSTATE_STRUCT_POINTER_TEST_V (_field, _state, _test, _version, _vmsd, _type) { \ + .name = (stringify(_field)), \ + .version_id = (_version), \ .field_exists = (_test), \ .vmsd = &(_vmsd), \ .size = sizeof(_type), \
@@ -497,7 +507,10 @@ extern const VMStateInfo vmstate_info_bitmap; VMSTATE_STRUCT_TEST(_field, _state, NULL, _version, _vmsd, _type)#define VMSTATE_STRUCT_POINTER (_field, _state, _vmsd, _type) \ - VMSTATE_STRUCT_POINTER_TEST(_field, _state, NULL, _vmsd, _type) + VMSTATE_STRUCT_POINTER_V(_field, _state, 0, _vmsd, _type) + +#define VMSTATE_STRUCT_POINTER_TEST (_field, _state, _test, _vmsd, _type) \ + VMSTATE_STRUCT_POINTER_TEST_V(_field, _state, _test, 0, _vmsd, _type)#define VMSTATE_STRUCT_ARRAY (_field, _state, _num, _version, _vmsd, _type) \ VMSTATE_STRUCT_ARRAY_TEST(_field, _state, _num, NULL, _version, \
Signature · 1 line
1.8.3.1
PATCH 7/9 migration: Fix debug print type
In reply to Juan QuintelaFrom: Christoffer Dall <[email protected]>
The printf args are uint64_t and with -Werr QEMU doesn't compile with migration debugging turned on unless this is fixed. Fix it.
--- migration.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
migration.c +2 -1
@@ -567,7 +567,8 @@ static void *migration_thread(void *opaque)if (!qemu_file_rate_limit (s->file)) {DPRINTF ("iterate\n" ); pending_size =qemu_savevm_state_pending (s->file, max_size); -DPRINTF ("pending size %lu max %lu\n" , pending_size, max_size); +DPRINTF ("pending size %" PRIu64" max %" PRIu64"\n" , + pending_size, max_size);if (pending_size && pending_size >= max_size) {qemu_savevm_state_iterate (s->file); }else {
Signature · 1 line
1.8.3.1
PATCH 8/9 arch_init: make is_zero_page accept size
In reply to Juan QuintelaFrom: Isaku Yamahata <[email protected]>
Later is_zero_page will be used for non TARGET_PAGE_SIZE range.
And rename it to is_zero_range as it isn't page size any more.
--- arch_init.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-)
arch_init.c +4 -5
@@ -150,10 +150,9 @@ int qemu_read_default_config_files(bool userconfig)return 0 ; } -static inline bool is_zero_page (uint8_t *p) +static inline bool is_zero_range (uint8_t *p,uint64_t size) { -return buffer_find_nonzero_offset (p,TARGET_PAGE_SIZE ) == -TARGET_PAGE_SIZE ; +return buffer_find_nonzero_offset (p, size) == size; }/* struct contains XBZRLE cache and a static page
@@ -497,7 +496,7 @@ static int ram_save_block(QEMUFile *f, bool last_stage) acct_info.dup_pages++; } } - }else if (is_zero_page (p)) { + }else if (is_zero_range (p,TARGET_PAGE_SIZE )) { acct_info.dup_pages++; bytes_sent =save_block_hdr (f, block, offset, cont,RAM_SAVE_FLAG_COMPRESS );
@@ -849,7 +848,7 @@ static inline void *host_from_stream_offset(QEMUFile *f,*/ void ram_handle_compressed (void *host,uint8_t ch,uint64_t size) { -if (ch !=0 || !is_zero_page (host)) { +if (ch !=0 || !is_zero_range (host,TARGET_PAGE_SIZE )) {memset (host, ch, size);#ifndef _WIN32 if (ch == 0 &&
Signature · 1 line
1.8.3.1
Re: [Qemu-devel] [PATCH 8/9] arch_init: make is_zero_page accept size
Quoted 17 lines · Juan Quintela
From: Isaku Yamahata <[email protected]>
Later
is_zero_pagewill be used for nonTARGET_PAGE_SIZErange.
And rename it tois_zero_rangeas it isn't page size any more.Signed-off-by Isaku Yamahata <[email protected]>Signed-off-by Juan Quintela <[email protected]>--- arch_init.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-)arch_init.c +0
-0
arch_init.c int qemu_read_default_config_files(bool userconfig) · line 156
Quoted 10 lines
arch_init.c +2
-3@@ -150,10 +150,9 @@ int qemu_read_default_config_files(bool userconfig)return 0 ; } -static inline bool is_zero_page (uint8_t *p) +static inline bool is_zero_range (uint8_t *p,uint64_t size) { -return buffer_find_nonzero_offset (p,TARGET_PAGE_SIZE ) == -TARGET_PAGE_SIZE ; +return buffer_find_nonzero_offset (p, size) == size; }
this is buffer_is_zero(p, size); maybe this function should be used.
Peter
PATCH 9/9 migration: ram_handle_compressed
In reply to Juan QuintelaFrom: Isaku Yamahata <[email protected]>
ram_handle_compressed() should be aware of size > TARGET_PAGE_SIZE. migration-rdma can call it with larger size.
--- arch_init.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-)
arch_init.c +6 -5
@@ -848,13 +848,14 @@ static inline void *host_from_stream_offset(QEMUFile *f,*/ void ram_handle_compressed (void *host,uint8_t ch,uint64_t size) { -if (ch !=0 || !is_zero_range (host,TARGET_PAGE_SIZE )) { +if (ch !=0 || !is_zero_range (host, size)) {memset (host, ch, size);#ifndef _WIN32 -if (ch ==0 && - (!kvm_enabled () ||kvm_has_sync_mmu ()) && -getpagesize () <=TARGET_PAGE_SIZE ) { -qemu_madvise (host,TARGET_PAGE_SIZE ,QEMU_MADV_DONTNEED ); +if (ch ==0 && (!kvm_enabled () ||kvm_has_sync_mmu ())) { + size = size & ~(getpagesize () -1 ); +if (size >0 ) { +qemu_madvise (host, size,QEMU_MADV_DONTNEED ); + } }#endif }
Signature · 1 line
1.8.3.1