migration: Postcopy preemption preparation on channel creation

Create a new socket for postcopy to be prepared to send postcopy requested
pages via this specific channel, so as to not get blocked by precopy pages.

A new thread is also created on dest qemu to receive data from this new channel
based on the ram_load_postcopy() routine.

The ram_load_postcopy(POSTCOPY) branch and the thread has not started to
function, and that'll be done in follow up patches.

Cleanup the new sockets on both src/dst QEMUs, meanwhile look after the new
thread too to make sure it'll be recycled properly.

Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
Reviewed-by: Juan Quintela <quintela@redhat.com>
Signed-off-by: Peter Xu <peterx@redhat.com>
Message-Id: <20220707185502.27149-1-peterx@redhat.com>
Signed-off-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
  dgilbert: With Peter's fix to quieten compiler warning on
       start_migration
This commit is contained in:
Peter Xu 2022-07-07 14:55:02 -04:00 committed by Dr. David Alan Gilbert
parent ce5b0f4afc
commit 36f62f11e4
10 changed files with 219 additions and 31 deletions

View file

@ -26,7 +26,7 @@
#include "io/channel-socket.h"
#include "io/net-listener.h"
#include "trace.h"
#include "postcopy-ram.h"
struct SocketOutgoingArgs {
SocketAddress *saddr;
@ -39,6 +39,24 @@ void socket_send_channel_create(QIOTaskFunc f, void *data)
f, data, NULL, NULL);
}
QIOChannel *socket_send_channel_create_sync(Error **errp)
{
QIOChannelSocket *sioc = qio_channel_socket_new();
if (!outgoing_args.saddr) {
object_unref(OBJECT(sioc));
error_setg(errp, "Initial sock address not set!");
return NULL;
}
if (qio_channel_socket_connect_sync(sioc, outgoing_args.saddr, errp) < 0) {
object_unref(OBJECT(sioc));
return NULL;
}
return QIO_CHANNEL(sioc);
}
int socket_send_channel_destroy(QIOChannel *send)
{
/* Remove channel */
@ -166,6 +184,8 @@ socket_start_incoming_migration_internal(SocketAddress *saddr,
if (migrate_use_multifd()) {
num = migrate_multifd_channels();
} else if (migrate_postcopy_preempt()) {
num = RAM_CHANNEL_MAX;
}
if (qio_net_listener_open_sync(listener, saddr, num, errp) < 0) {