|
@@ -12,6 +12,7 @@
|
|
|
|
|
|
#include "qemu/osdep.h"
|
|
#include "qemu/osdep.h"
|
|
#include "qemu/cutils.h"
|
|
#include "qemu/cutils.h"
|
|
|
|
+#include "qemu/iov.h"
|
|
#include "qemu/rcu.h"
|
|
#include "qemu/rcu.h"
|
|
#include "exec/target_page.h"
|
|
#include "exec/target_page.h"
|
|
#include "system/system.h"
|
|
#include "system/system.h"
|
|
@@ -19,6 +20,7 @@
|
|
#include "qemu/error-report.h"
|
|
#include "qemu/error-report.h"
|
|
#include "qapi/error.h"
|
|
#include "qapi/error.h"
|
|
#include "file.h"
|
|
#include "file.h"
|
|
|
|
+#include "migration/misc.h"
|
|
#include "migration.h"
|
|
#include "migration.h"
|
|
#include "migration-stats.h"
|
|
#include "migration-stats.h"
|
|
#include "savevm.h"
|
|
#include "savevm.h"
|
|
@@ -111,7 +113,9 @@ MultiFDSendData *multifd_send_data_alloc(void)
|
|
* added to the union in the future are larger than
|
|
* added to the union in the future are larger than
|
|
* (MultiFDPages_t + flex array).
|
|
* (MultiFDPages_t + flex array).
|
|
*/
|
|
*/
|
|
- max_payload_size = MAX(multifd_ram_payload_size(), sizeof(MultiFDPayload));
|
|
|
|
|
|
+ max_payload_size = MAX(multifd_ram_payload_size(),
|
|
|
|
+ multifd_device_state_payload_size());
|
|
|
|
+ max_payload_size = MAX(max_payload_size, sizeof(MultiFDPayload));
|
|
|
|
|
|
/*
|
|
/*
|
|
* Account for any holes the compiler might insert. We can't pack
|
|
* Account for any holes the compiler might insert. We can't pack
|
|
@@ -130,6 +134,9 @@ void multifd_send_data_clear(MultiFDSendData *data)
|
|
}
|
|
}
|
|
|
|
|
|
switch (data->type) {
|
|
switch (data->type) {
|
|
|
|
+ case MULTIFD_PAYLOAD_DEVICE_STATE:
|
|
|
|
+ multifd_send_data_clear_device_state(&data->u.device_state);
|
|
|
|
+ break;
|
|
default:
|
|
default:
|
|
/* Nothing to do */
|
|
/* Nothing to do */
|
|
break;
|
|
break;
|
|
@@ -232,6 +239,7 @@ static int multifd_recv_initial_packet(QIOChannel *c, Error **errp)
|
|
return msg.id;
|
|
return msg.id;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+/* Fills a RAM multifd packet */
|
|
void multifd_send_fill_packet(MultiFDSendParams *p)
|
|
void multifd_send_fill_packet(MultiFDSendParams *p)
|
|
{
|
|
{
|
|
MultiFDPacket_t *packet = p->packet;
|
|
MultiFDPacket_t *packet = p->packet;
|
|
@@ -524,6 +532,7 @@ static bool multifd_send_cleanup_channel(MultiFDSendParams *p, Error **errp)
|
|
p->name = NULL;
|
|
p->name = NULL;
|
|
g_clear_pointer(&p->data, multifd_send_data_free);
|
|
g_clear_pointer(&p->data, multifd_send_data_free);
|
|
p->packet_len = 0;
|
|
p->packet_len = 0;
|
|
|
|
+ g_clear_pointer(&p->packet_device_state, g_free);
|
|
g_free(p->packet);
|
|
g_free(p->packet);
|
|
p->packet = NULL;
|
|
p->packet = NULL;
|
|
multifd_send_state->ops->send_cleanup(p, errp);
|
|
multifd_send_state->ops->send_cleanup(p, errp);
|
|
@@ -536,6 +545,7 @@ static void multifd_send_cleanup_state(void)
|
|
{
|
|
{
|
|
file_cleanup_outgoing_migration();
|
|
file_cleanup_outgoing_migration();
|
|
socket_cleanup_outgoing_migration();
|
|
socket_cleanup_outgoing_migration();
|
|
|
|
+ multifd_device_state_send_cleanup();
|
|
qemu_sem_destroy(&multifd_send_state->channels_created);
|
|
qemu_sem_destroy(&multifd_send_state->channels_created);
|
|
qemu_sem_destroy(&multifd_send_state->channels_ready);
|
|
qemu_sem_destroy(&multifd_send_state->channels_ready);
|
|
qemu_mutex_destroy(&multifd_send_state->multifd_send_mutex);
|
|
qemu_mutex_destroy(&multifd_send_state->multifd_send_mutex);
|
|
@@ -694,16 +704,32 @@ static void *multifd_send_thread(void *opaque)
|
|
* qatomic_store_release() in multifd_send().
|
|
* qatomic_store_release() in multifd_send().
|
|
*/
|
|
*/
|
|
if (qatomic_load_acquire(&p->pending_job)) {
|
|
if (qatomic_load_acquire(&p->pending_job)) {
|
|
|
|
+ bool is_device_state = multifd_payload_device_state(p->data);
|
|
|
|
+ size_t total_size;
|
|
|
|
+
|
|
p->flags = 0;
|
|
p->flags = 0;
|
|
p->iovs_num = 0;
|
|
p->iovs_num = 0;
|
|
assert(!multifd_payload_empty(p->data));
|
|
assert(!multifd_payload_empty(p->data));
|
|
|
|
|
|
- ret = multifd_send_state->ops->send_prepare(p, &local_err);
|
|
|
|
- if (ret != 0) {
|
|
|
|
- break;
|
|
|
|
|
|
+ if (is_device_state) {
|
|
|
|
+ multifd_device_state_send_prepare(p);
|
|
|
|
+ } else {
|
|
|
|
+ ret = multifd_send_state->ops->send_prepare(p, &local_err);
|
|
|
|
+ if (ret != 0) {
|
|
|
|
+ break;
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ /*
|
|
|
|
+ * The packet header in the zerocopy RAM case is accounted for
|
|
|
|
+ * in multifd_nocomp_send_prepare() - where it is actually
|
|
|
|
+ * being sent.
|
|
|
|
+ */
|
|
|
|
+ total_size = iov_size(p->iov, p->iovs_num);
|
|
|
|
+
|
|
if (migrate_mapped_ram()) {
|
|
if (migrate_mapped_ram()) {
|
|
|
|
+ assert(!is_device_state);
|
|
|
|
+
|
|
ret = file_write_ramblock_iov(p->c, p->iov, p->iovs_num,
|
|
ret = file_write_ramblock_iov(p->c, p->iov, p->iovs_num,
|
|
&p->data->u.ram, &local_err);
|
|
&p->data->u.ram, &local_err);
|
|
} else {
|
|
} else {
|
|
@@ -716,8 +742,7 @@ static void *multifd_send_thread(void *opaque)
|
|
break;
|
|
break;
|
|
}
|
|
}
|
|
|
|
|
|
- stat64_add(&mig_stats.multifd_bytes,
|
|
|
|
- (uint64_t)p->next_packet_size + p->packet_len);
|
|
|
|
|
|
+ stat64_add(&mig_stats.multifd_bytes, total_size);
|
|
|
|
|
|
p->next_packet_size = 0;
|
|
p->next_packet_size = 0;
|
|
multifd_send_data_clear(p->data);
|
|
multifd_send_data_clear(p->data);
|
|
@@ -938,6 +963,9 @@ bool multifd_send_setup(void)
|
|
p->packet_len = sizeof(MultiFDPacket_t)
|
|
p->packet_len = sizeof(MultiFDPacket_t)
|
|
+ sizeof(uint64_t) * page_count;
|
|
+ sizeof(uint64_t) * page_count;
|
|
p->packet = g_malloc0(p->packet_len);
|
|
p->packet = g_malloc0(p->packet_len);
|
|
|
|
+ p->packet_device_state = g_malloc0(sizeof(*p->packet_device_state));
|
|
|
|
+ p->packet_device_state->hdr.magic = cpu_to_be32(MULTIFD_MAGIC);
|
|
|
|
+ p->packet_device_state->hdr.version = cpu_to_be32(MULTIFD_VERSION);
|
|
}
|
|
}
|
|
p->name = g_strdup_printf(MIGRATION_THREAD_SRC_MULTIFD, i);
|
|
p->name = g_strdup_printf(MIGRATION_THREAD_SRC_MULTIFD, i);
|
|
p->write_flags = 0;
|
|
p->write_flags = 0;
|
|
@@ -973,6 +1001,8 @@ bool multifd_send_setup(void)
|
|
assert(p->iov);
|
|
assert(p->iov);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ multifd_device_state_send_setup();
|
|
|
|
+
|
|
return true;
|
|
return true;
|
|
|
|
|
|
err:
|
|
err:
|