From nobody Tue Feb 10 17:13:33 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=yandex-team.ru ARC-Seal: i=1; a=rsa-sha256; t=1555072085; cv=none; d=zoho.com; s=zohoarc; b=TslBZD9HdgbwR0viglrqfriLyK5VFUfIiUnOBsfDPRScEJCrXWlBJxKl28TFp1Zw/9B8DYIoVAkc5HtTYqRtGlnQvVDiw/F4nUVrgKZ21kac2KaHdxARUljLFWcjEHj4V2oj0GY2jGlSm6PsnN+XkB6TwjU3FimG9MXZimDeEFA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1555072085; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=5scv9afxgsXH+WoOpf/RiIfo5/lFARF+RM03UY8Vi64=; b=YS8qvot9UH5gIEmILD1F9FGhJ/d1UUTBs8KE6oyTjzV1G0Y13Rq7qb5NLpq7KA6d/jofVA6kJjvCDEm4JZ+EU5MkrFkkzkx9RKUlWuZgrc/cG377h5MAfh0p5nIzHjH5X3th9cmdsfxSPFINbtd4WcORapJhs7z+y00zMYv+708= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1555072085655213.47993109069353; Fri, 12 Apr 2019 05:28:05 -0700 (PDT) Received: from localhost ([127.0.0.1]:35630 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hEvHl-0004ge-JI for importer@patchew.org; Fri, 12 Apr 2019 08:28:01 -0400 Received: from eggs.gnu.org ([209.51.188.92]:37271) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hEvAt-00066j-Aa for qemu-devel@nongnu.org; Fri, 12 Apr 2019 08:20:56 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hEvAs-00070P-0Q for qemu-devel@nongnu.org; Fri, 12 Apr 2019 08:20:55 -0400 Received: from forwardcorp1o.mail.yandex.net ([95.108.205.193]:38070) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hEvAr-0006ze-Jc for qemu-devel@nongnu.org; Fri, 12 Apr 2019 08:20:53 -0400 Received: from mxbackcorp1j.mail.yandex.net (mxbackcorp1j.mail.yandex.net [IPv6:2a02:6b8:0:1619::162]) by forwardcorp1o.mail.yandex.net (Yandex) with ESMTP id 5D4A32E128D; Fri, 12 Apr 2019 15:20:52 +0300 (MSK) Received: from smtpcorp1p.mail.yandex.net (smtpcorp1p.mail.yandex.net [2a02:6b8:0:1472:2741:0:8b6:10]) by mxbackcorp1j.mail.yandex.net (nwsmtp/Yandex) with ESMTP id VEn76H1FkC-KpMWKQuW; Fri, 12 Apr 2019 15:20:52 +0300 Received: from dynamic-red.dhcp.yndx.net (dynamic-red.dhcp.yndx.net [2a02:6b8:0:40c:3404:6cb5:5ab:ed68]) by smtpcorp1p.mail.yandex.net (nwsmtp/Yandex) with ESMTPSA id m4LakqlT7Q-Kp0WqXeM; Fri, 12 Apr 2019 15:20:51 +0300 (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA256 (128/128 bits)) (Client certificate not present) Precedence: bulk DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yandex-team.ru; s=default; t=1555071652; bh=flDSQI+j21sPI4CmZ6PSn1OkpHEK4JepGKApSy2Uy2E=; h=In-Reply-To:Message-Id:References:Date:Subject:To:From:Cc; b=h/QxOBabfAIa4SQQPBUo07Osv0+2fitr/xvA/BEmeLlHk9DfNDIvo9u4VHwFrw86O oAX/HAWHbxRiVIbuSB4TLd6zxzIS4Zfu86t//s0CHv9v67fC9obBj0/sn5ILkEC3Wn oHzkoZF8ppaBCii+/+Nm6guocbebtvhpIYWvBi0g= Authentication-Results: mxbackcorp1j.mail.yandex.net; dkim=pass header.i=@yandex-team.ru From: Yury Kotov To: Juan Quintela , "Dr. David Alan Gilbert" , Markus Armbruster , Thomas Huth , Laurent Vivier , Paolo Bonzini Date: Fri, 12 Apr 2019 15:20:27 +0300 Message-Id: <20190412122028.7067-3-yury-kotov@yandex-team.ru> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190412122028.7067-1-yury-kotov@yandex-team.ru> References: <20190412122028.7067-1-yury-kotov@yandex-team.ru> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 95.108.205.193 Subject: [Qemu-devel] [PATCH 2/3] migration: Add inline-fd protocol X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: "open list:All patches CC here" , yc-core@yandex-team.ru Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" Existing 'fd:' proto works with previously added fd by getfd or add-fd comm= ands. If client doesn't want to work with this fd before or after migration then = it's easier to send an fd with the migrate-* command. Also, client shouldn't mai= ntain this fd. So, add 'inline-fd:' proto to work with sent fd. Usage: { 'execute': 'migrate', 'arguments': { 'uri': 'inline-fd:' } } { 'execute': 'migrate-incoming', 'arguments': { 'uri': 'inline-fd:' } } Signed-off-by: Yury Kotov --- migration/Makefile.objs | 2 +- migration/inline-fd.c | 89 +++++++++++++++++++++++++++++++++++++++++ migration/inline-fd.h | 22 ++++++++++ migration/migration.c | 15 +++++++ migration/trace-events | 4 ++ 5 files changed, 131 insertions(+), 1 deletion(-) create mode 100644 migration/inline-fd.c create mode 100644 migration/inline-fd.h diff --git a/migration/Makefile.objs b/migration/Makefile.objs index a4f3bafd86..f4bb6c5803 100644 --- a/migration/Makefile.objs +++ b/migration/Makefile.objs @@ -1,4 +1,4 @@ -common-obj-y +=3D migration.o socket.o fd.o exec.o +common-obj-y +=3D migration.o socket.o fd.o inline-fd.o exec.o common-obj-y +=3D tls.o channel.o savevm.o common-obj-y +=3D colo.o colo-failover.o common-obj-y +=3D vmstate.o vmstate-types.o page_cache.o diff --git a/migration/inline-fd.c b/migration/inline-fd.c new file mode 100644 index 0000000000..90a0dc079f --- /dev/null +++ b/migration/inline-fd.c @@ -0,0 +1,89 @@ +/* + * QEMU live migration via generic fd passed with command + * + * Copyright Yandex, Inc. 2019 + * + * Authors: + * Yury Kotov + * + * This work is licensed under the terms of the GNU GPL, version 2. See + * the COPYING file in the top-level directory. + * + * Contributions after 2012-01-13 are licensed under the terms of the + * GNU GPL, version 2 or (at your option) any later version. + */ + +#include "qemu/osdep.h" +#include "qapi/error.h" +#include "channel.h" +#include "inline-fd.h" +#include "monitor/monitor.h" +#include "io/channel-util.h" +#include "trace.h" + + +void inline_fd_start_outgoing_migration(MigrationState *s, Error **errp) +{ + QIOChannel *ioc; + int fd; + + if (!cur_mon) { + error_setg(errp, "Monitor is disabled"); + return; + } + + fd =3D monitor_recv_fd(cur_mon, errp); + if (fd =3D=3D -1) { + return; + } + + trace_migration_inline_fd_outgoing(fd); + ioc =3D qio_channel_new_fd(fd, errp); + if (!ioc) { + close(fd); + return; + } + + qio_channel_set_name(QIO_CHANNEL(ioc), "migration-infd-outgoing"); + migration_channel_connect(s, ioc, NULL, NULL); + object_unref(OBJECT(ioc)); +} + +static gboolean inline_fd_accept_incoming_migration(QIOChannel *ioc, + GIOCondition condition, + gpointer opaque) +{ + migration_channel_process_incoming(ioc); + object_unref(OBJECT(ioc)); + return G_SOURCE_REMOVE; +} + +void inline_fd_start_incoming_migration(Error **errp) +{ + QIOChannel *ioc; + int fd; + + if (!cur_mon) { + error_setg(errp, "Monitor is disabled"); + return; + } + + fd =3D monitor_recv_fd(cur_mon, errp); + if (fd =3D=3D -1) { + return; + } + + trace_migration_inline_fd_incoming(fd); + ioc =3D qio_channel_new_fd(fd, errp); + if (!ioc) { + close(fd); + return; + } + + qio_channel_set_name(QIO_CHANNEL(ioc), "migration-infd-incoming"); + qio_channel_add_watch(ioc, + G_IO_IN, + inline_fd_accept_incoming_migration, + NULL, + NULL); +} diff --git a/migration/inline-fd.h b/migration/inline-fd.h new file mode 100644 index 0000000000..5b23ce314d --- /dev/null +++ b/migration/inline-fd.h @@ -0,0 +1,22 @@ +/* + * QEMU live migration via generic fd passed with command + * + * Copyright Yandex, Inc. 2019 + * + * Authors: + * Yury Kotov + * + * This work is licensed under the terms of the GNU GPL, version 2. See + * the COPYING file in the top-level directory. + * + * Contributions after 2012-01-13 are licensed under the terms of the + * GNU GPL, version 2 or (at your option) any later version. + */ + +#ifndef QEMU_MIGRATION_INLINE_FD_H +#define QEMU_MIGRATION_INLINE_FD_H + +void inline_fd_start_incoming_migration(Error **errp); +void inline_fd_start_outgoing_migration(MigrationState *s, Error **errp); + +#endif diff --git a/migration/migration.c b/migration/migration.c index 609e0df5d0..7b9fafe218 100644 --- a/migration/migration.c +++ b/migration/migration.c @@ -19,6 +19,7 @@ #include "migration/blocker.h" #include "exec.h" #include "fd.h" +#include "inline-fd.h" #include "socket.h" #include "rdma.h" #include "ram.h" @@ -364,6 +365,13 @@ void qemu_start_incoming_migration(const char *uri, Er= ror **errp) unix_start_incoming_migration(p, errp); } else if (strstart(uri, "fd:", &p)) { fd_start_incoming_migration(p, errp); + } else if (strstart(uri, "inline-fd:", &p)) { + if (!*p) { + inline_fd_start_incoming_migration(errp); + } else { + error_setg(errp, QERR_INVALID_PARAMETER_VALUE, "uri", + "an empty path for 'inline-fd:' protocol"); + } } else { error_setg(errp, "unknown migration protocol: %s", uri); } @@ -1924,6 +1932,13 @@ void qmp_migrate(const char *uri, bool has_blk, bool= blk, unix_start_outgoing_migration(s, p, &local_err); } else if (strstart(uri, "fd:", &p)) { fd_start_outgoing_migration(s, p, &local_err); + } else if (strstart(uri, "inline-fd:", &p)) { + if (!*p) { + inline_fd_start_outgoing_migration(s, &local_err); + } else { + error_setg(errp, QERR_INVALID_PARAMETER_VALUE, "uri", + "an empty path for 'inline-fd:' protocol"); + } } else { error_setg(errp, QERR_INVALID_PARAMETER_VALUE, "uri", "a valid migration protocol"); diff --git a/migration/trace-events b/migration/trace-events index de2e136e57..1afd11eab5 100644 --- a/migration/trace-events +++ b/migration/trace-events @@ -261,6 +261,10 @@ migration_exec_incoming(const char *cmd) "cmd=3D%s" migration_fd_outgoing(int fd) "fd=3D%d" migration_fd_incoming(int fd) "fd=3D%d" =20 +# inline-fd.c +migration_inline_fd_outgoing(int fd) "fd=3D%d" +migration_inline_fd_incoming(int fd) "fd=3D%d" + # socket.c migration_socket_incoming_accepted(void) "" migration_socket_outgoing_connected(const char *hostname) "hostname=3D%s" --=20 2.21.0