mirror of https://github.com/xqemu/xqemu.git
Merge remote-tracking branch 'quintela/migration.next' into staging
# By Isaku Yamahata (4) and others # Via Juan Quintela * quintela/migration.next: migration: ram_handle_compressed arch_init: make is_zero_page accept size migration: Fix debug print type migration: add version supporting macros for struct pointer rdma: constify ram_chunk_{index, start, end} rdma: clean up of qemu_rdma_cleanup() arch_init: right return for ram_save_iterate savevm: fix wrong initialization by ram_control_load_hook savevm: add comments for qemu_file_get_error() Message-id: 1380024203-25897-1-git-send-email-quintela@redhat.com
This commit is contained in:
commit
8429d63b0e
33
arch_init.c
33
arch_init.c
|
@ -150,10 +150,9 @@ int qemu_read_default_config_files(bool userconfig)
|
||||||
return 0;
|
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) ==
|
return buffer_find_nonzero_offset(p, size) == size;
|
||||||
TARGET_PAGE_SIZE;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* struct contains XBZRLE cache and a static page
|
/* 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++;
|
acct_info.dup_pages++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (is_zero_page(p)) {
|
} else if (is_zero_range(p, TARGET_PAGE_SIZE)) {
|
||||||
acct_info.dup_pages++;
|
acct_info.dup_pages++;
|
||||||
bytes_sent = save_block_hdr(f, block, offset, cont,
|
bytes_sent = save_block_hdr(f, block, offset, cont,
|
||||||
RAM_SAVE_FLAG_COMPRESS);
|
RAM_SAVE_FLAG_COMPRESS);
|
||||||
|
@ -710,15 +709,20 @@ static int ram_save_iterate(QEMUFile *f, void *opaque)
|
||||||
*/
|
*/
|
||||||
ram_control_after_iterate(f, RAM_CONTROL_ROUND);
|
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) {
|
if (ret < 0) {
|
||||||
bytes_transferred += total_sent;
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
qemu_put_be64(f, RAM_SAVE_FLAG_EOS);
|
|
||||||
total_sent += 8;
|
|
||||||
bytes_transferred += total_sent;
|
|
||||||
|
|
||||||
return total_sent;
|
return total_sent;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -844,13 +848,14 @@ static inline void *host_from_stream_offset(QEMUFile *f,
|
||||||
*/
|
*/
|
||||||
void ram_handle_compressed(void *host, uint8_t ch, uint64_t size)
|
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, size)) {
|
||||||
memset(host, ch, size);
|
memset(host, ch, size);
|
||||||
#ifndef _WIN32
|
#ifndef _WIN32
|
||||||
if (ch == 0 &&
|
if (ch == 0 && (!kvm_enabled() || kvm_has_sync_mmu())) {
|
||||||
(!kvm_enabled() || kvm_has_sync_mmu()) &&
|
size = size & ~(getpagesize() - 1);
|
||||||
getpagesize() <= TARGET_PAGE_SIZE) {
|
if (size > 0) {
|
||||||
qemu_madvise(host, TARGET_PAGE_SIZE, QEMU_MADV_DONTNEED);
|
qemu_madvise(host, size, QEMU_MADV_DONTNEED);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
|
@ -310,8 +310,18 @@ extern const VMStateInfo vmstate_info_bitmap;
|
||||||
.offset = vmstate_offset_value(_state, _field, _type), \
|
.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)), \
|
.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), \
|
.field_exists = (_test), \
|
||||||
.vmsd = &(_vmsd), \
|
.vmsd = &(_vmsd), \
|
||||||
.size = sizeof(_type), \
|
.size = sizeof(_type), \
|
||||||
|
@ -497,7 +507,10 @@ extern const VMStateInfo vmstate_info_bitmap;
|
||||||
VMSTATE_STRUCT_TEST(_field, _state, NULL, _version, _vmsd, _type)
|
VMSTATE_STRUCT_TEST(_field, _state, NULL, _version, _vmsd, _type)
|
||||||
|
|
||||||
#define VMSTATE_STRUCT_POINTER(_field, _state, _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) \
|
#define VMSTATE_STRUCT_ARRAY(_field, _state, _num, _version, _vmsd, _type) \
|
||||||
VMSTATE_STRUCT_ARRAY_TEST(_field, _state, _num, NULL, _version, \
|
VMSTATE_STRUCT_ARRAY_TEST(_field, _state, _num, NULL, _version, \
|
||||||
|
|
|
@ -356,6 +356,7 @@ typedef struct RDMAContext {
|
||||||
*/
|
*/
|
||||||
struct rdma_cm_id *cm_id; /* connection manager ID */
|
struct rdma_cm_id *cm_id; /* connection manager ID */
|
||||||
struct rdma_cm_id *listen_id;
|
struct rdma_cm_id *listen_id;
|
||||||
|
bool connected;
|
||||||
|
|
||||||
struct ibv_context *verbs;
|
struct ibv_context *verbs;
|
||||||
struct rdma_event_channel *channel;
|
struct rdma_event_channel *channel;
|
||||||
|
@ -510,19 +511,21 @@ static int qemu_rdma_exchange_send(RDMAContext *rdma, RDMAControlHeader *head,
|
||||||
int *resp_idx,
|
int *resp_idx,
|
||||||
int (*callback)(RDMAContext *rdma));
|
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;
|
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)
|
uint64_t i)
|
||||||
{
|
{
|
||||||
return (uint8_t *) (((uintptr_t) rdma_ram_block->local_host_addr)
|
return (uint8_t *) (((uintptr_t) rdma_ram_block->local_host_addr)
|
||||||
+ (i << RDMA_REG_CHUNK_SHIFT));
|
+ (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) +
|
uint8_t *result = ram_chunk_start(rdma_ram_block, i) +
|
||||||
(1UL << RDMA_REG_CHUNK_SHIFT);
|
(1UL << RDMA_REG_CHUNK_SHIFT);
|
||||||
|
@ -2194,7 +2197,7 @@ static void qemu_rdma_cleanup(RDMAContext *rdma)
|
||||||
struct rdma_cm_event *cm_event;
|
struct rdma_cm_event *cm_event;
|
||||||
int ret, idx;
|
int ret, idx;
|
||||||
|
|
||||||
if (rdma->cm_id) {
|
if (rdma->cm_id && rdma->connected) {
|
||||||
if (rdma->error_state) {
|
if (rdma->error_state) {
|
||||||
RDMAControlHeader head = { .len = 0,
|
RDMAControlHeader head = { .len = 0,
|
||||||
.type = RDMA_CONTROL_ERROR,
|
.type = RDMA_CONTROL_ERROR,
|
||||||
|
@ -2213,7 +2216,7 @@ static void qemu_rdma_cleanup(RDMAContext *rdma)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
DDPRINTF("Disconnected.\n");
|
DDPRINTF("Disconnected.\n");
|
||||||
rdma->cm_id = NULL;
|
rdma->connected = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
g_free(rdma->block);
|
g_free(rdma->block);
|
||||||
|
@ -2235,7 +2238,7 @@ static void qemu_rdma_cleanup(RDMAContext *rdma)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (rdma->qp) {
|
if (rdma->qp) {
|
||||||
ibv_destroy_qp(rdma->qp);
|
rdma_destroy_qp(rdma->cm_id);
|
||||||
rdma->qp = NULL;
|
rdma->qp = NULL;
|
||||||
}
|
}
|
||||||
if (rdma->cq) {
|
if (rdma->cq) {
|
||||||
|
@ -2372,6 +2375,7 @@ static int qemu_rdma_connect(RDMAContext *rdma, Error **errp)
|
||||||
rdma->cm_id = NULL;
|
rdma->cm_id = NULL;
|
||||||
goto err_rdma_source_connect;
|
goto err_rdma_source_connect;
|
||||||
}
|
}
|
||||||
|
rdma->connected = true;
|
||||||
|
|
||||||
memcpy(&cap, cm_event->param.conn.private_data, sizeof(cap));
|
memcpy(&cap, cm_event->param.conn.private_data, sizeof(cap));
|
||||||
network_to_caps(&cap);
|
network_to_caps(&cap);
|
||||||
|
@ -2906,6 +2910,7 @@ static int qemu_rdma_accept(RDMAContext *rdma)
|
||||||
}
|
}
|
||||||
|
|
||||||
rdma_ack_cm_event(cm_event);
|
rdma_ack_cm_event(cm_event);
|
||||||
|
rdma->connected = true;
|
||||||
|
|
||||||
ret = qemu_rdma_post_recv_control(rdma, RDMA_WRID_READY);
|
ret = qemu_rdma_post_recv_control(rdma, RDMA_WRID_READY);
|
||||||
if (ret) {
|
if (ret) {
|
||||||
|
|
|
@ -567,7 +567,8 @@ static void *migration_thread(void *opaque)
|
||||||
if (!qemu_file_rate_limit(s->file)) {
|
if (!qemu_file_rate_limit(s->file)) {
|
||||||
DPRINTF("iterate\n");
|
DPRINTF("iterate\n");
|
||||||
pending_size = qemu_savevm_state_pending(s->file, max_size);
|
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) {
|
if (pending_size && pending_size >= max_size) {
|
||||||
qemu_savevm_state_iterate(s->file);
|
qemu_savevm_state_iterate(s->file);
|
||||||
} else {
|
} else {
|
||||||
|
|
9
savevm.c
9
savevm.c
|
@ -566,6 +566,13 @@ QEMUFile *qemu_fopen_ops(void *opaque, const QEMUFileOps *ops)
|
||||||
return f;
|
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)
|
int qemu_file_get_error(QEMUFile *f)
|
||||||
{
|
{
|
||||||
return f->last_error;
|
return f->last_error;
|
||||||
|
@ -642,7 +649,7 @@ void ram_control_after_iterate(QEMUFile *f, uint64_t flags)
|
||||||
|
|
||||||
void ram_control_load_hook(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) {
|
if (f->ops->hook_ram_load) {
|
||||||
ret = f->ops->hook_ram_load(f, f->opaque, flags);
|
ret = f->ops->hook_ram_load(f, f->opaque, flags);
|
||||||
|
|
Loading…
Reference in New Issue