From nobody Sat Oct 25 08:55:14 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1520421397098441.5518494940634; Wed, 7 Mar 2018 03:16:37 -0800 (PST) Received: from localhost ([::1]:60812 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1etX3k-000228-B9 for importer@patchew.org; Wed, 07 Mar 2018 06:16:36 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:59849) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1etWoV-00057S-1R for qemu-devel@nongnu.org; Wed, 07 Mar 2018 06:00:56 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1etWoS-0006M6-10 for qemu-devel@nongnu.org; Wed, 07 Mar 2018 06:00:51 -0500 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:36526 helo=mx1.redhat.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1etWoR-0006Lm-S2 for qemu-devel@nongnu.org; Wed, 07 Mar 2018 06:00:47 -0500 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 5C6F4D142B for ; Wed, 7 Mar 2018 11:00:47 +0000 (UTC) Received: from secure.mitica (ovpn-116-34.ams2.redhat.com [10.36.116.34]) by smtp.corp.redhat.com (Postfix) with ESMTP id 430FE215CDA7; Wed, 7 Mar 2018 11:00:46 +0000 (UTC) From: Juan Quintela To: qemu-devel@nongnu.org Date: Wed, 7 Mar 2018 12:00:07 +0100 Message-Id: <20180307110010.2205-22-quintela@redhat.com> In-Reply-To: <20180307110010.2205-1-quintela@redhat.com> References: <20180307110010.2205-1-quintela@redhat.com> X-Scanned-By: MIMEDefang 2.78 on 10.11.54.6 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.2]); Wed, 07 Mar 2018 11:00:47 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.2]); Wed, 07 Mar 2018 11:00:47 +0000 (UTC) for IP:'10.11.54.6' DOMAIN:'int-mx06.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'quintela@redhat.com' RCPT:'' X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 66.187.233.73 Subject: [Qemu-devel] [PATCH v10 21/24] migration: Transmit initial package through the multifd channels X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: lvivier@redhat.com, dgilbert@redhat.com, peterx@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Signed-off-by: Juan Quintela --- migration/ram.c | 50 +++++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 45 insertions(+), 5 deletions(-) diff --git a/migration/ram.c b/migration/ram.c index 1aab96bd5e..4efac0c20c 100644 --- a/migration/ram.c +++ b/migration/ram.c @@ -52,6 +52,8 @@ #include "qemu/rcu_queue.h" #include "migration/colo.h" #include "migration/block.h" +#include "sysemu/sysemu.h" +#include "qemu/uuid.h" =20 /***********************************************************/ /* ram save/restore */ @@ -491,12 +493,30 @@ static void multifd_send_sync_main(void) trace_multifd_send_sync_main(); } =20 +typedef struct { + uint32_t version; + unsigned char uuid[16]; /* QemuUUID */ + uint8_t id; +} __attribute__((packed)) MultiFDInit_t; + static void *multifd_send_thread(void *opaque) { MultiFDSendParams *p =3D opaque; + MultiFDInit_t msg; + Error *local_err =3D NULL; + size_t ret; =20 trace_multifd_send_thread_start(p->id); =20 + msg.version =3D 1; + msg.id =3D p->id; + memcpy(msg.uuid, &qemu_uuid.data, sizeof(msg.uuid)); + ret =3D qio_channel_write_all(p->c, (char *)&msg, sizeof(msg), &local_= err); + if (ret !=3D 0) { + terminate_multifd_send_threads(local_err); + return NULL; + } + while (true) { qemu_sem_wait(&p->sem); qemu_mutex_lock(&p->mutex); @@ -730,12 +750,32 @@ bool multifd_recv_all_channels_created(void) void multifd_recv_new_channel(QIOChannel *ioc) { MultiFDRecvParams *p; - /* we need to invent channels id's until we transmit */ - /* we will remove this on a later patch */ - static int i =3D 0; + MultiFDInit_t msg; + Error *local_err =3D NULL; + size_t ret; =20 - p =3D &multifd_recv_state->params[i]; - i++; + ret =3D qio_channel_read_all(ioc, (char *)&msg, sizeof(msg), &local_er= r); + if (ret !=3D 0) { + terminate_multifd_recv_threads(local_err); + return; + } + + if (memcmp(msg.uuid, &qemu_uuid, sizeof(qemu_uuid))) { + char *uuid =3D qemu_uuid_unparse_strdup(&qemu_uuid); + error_setg(&local_err, "multifd: received uuid '%s' and expected " + "uuid '%s' for channel %hhd", msg.uuid, uuid, msg.id); + g_free(uuid); + terminate_multifd_recv_threads(local_err); + return; + } + + p =3D &multifd_recv_state->params[msg.id]; + if (p->c !=3D NULL) { + error_setg(&local_err, "multifd: received id '%d' already setup'", + msg.id); + terminate_multifd_recv_threads(local_err); + return; + } p->c =3D ioc; socket_recv_channel_ref(ioc); =20 --=20 2.14.3