From patchwork Thu Jul 21 19:56:14 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Het Gala X-Patchwork-Id: 12925739 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 2AAEAC433EF for ; Thu, 21 Jul 2022 20:01:23 +0000 (UTC) Received: from localhost ([::1]:37768 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oEcMM-0004VQ-3I for qemu-devel@archiver.kernel.org; Thu, 21 Jul 2022 16:01:22 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:38622) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oEcHv-00050E-8l for qemu-devel@nongnu.org; Thu, 21 Jul 2022 15:56:47 -0400 Received: from mx0b-002c1b01.pphosted.com ([148.163.155.12]:40440) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oEcHo-0006aX-R0 for qemu-devel@nongnu.org; Thu, 21 Jul 2022 15:56:46 -0400 Received: from pps.filterd (m0127844.ppops.net [127.0.0.1]) by mx0b-002c1b01.pphosted.com (8.17.1.5/8.17.1.5) with ESMTP id 26LIKtfk027882; Thu, 21 Jul 2022 12:56:38 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nutanix.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-transfer-encoding : content-type : mime-version; s=proofpoint20171006; bh=MTCDmLTNV67iF/RKDptn6o8I0Uk1BpY+Tae2pJSdK0E=; b=zQd7hkHy64Z6NUzNOXHfxMS38XZ/3K+Eogtab4krRJENI3+Z4i4o2AAqDM2cm/VMO9y9 fXpqEJovupUWpr+xgg7sEB5rr7eu5MgnVeho8LM4IOXkIgPdFPWMZrRFZ2yRnU+d8EBT PDDQ8VdckBDyVvrw/4yAYAH0OJgsxErrI4JhhiynjntkvwkdrDItf5olp7Is5bKir6TC xkIVoNoIasA9s1bCIPg0VfI2+kBcz9jlAM2H+sJSNDydstEvQ3GC71pUH7oQA3jS1sHk pv6sRBilZ4FDbdeJ6/xxgW67rt9dM/eFzKgaUzHcMWX7rvV4yvLSB9NpEDIPCm/4xi4y yQ== Received: from nam11-bn8-obe.outbound.protection.outlook.com (mail-bn8nam11lp2168.outbound.protection.outlook.com [104.47.58.168]) by mx0b-002c1b01.pphosted.com (PPS) with ESMTPS id 3hbvv244d6-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 21 Jul 2022 12:56:38 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=MXaOc5AZ5Y1psS8lgJxpBo09jzGgb+CWZXNBRsUVmtYsh0CTnxzAEKs0+cpMijsTqY5HSRUhyjwXuHqxl5JDbD3Yb4AmPgJN86sCGMncBFe7dlFQymrvmGweJWSewP31A9n7sBpyJja8+0mynLN1gPChc+AmqYSZTyTg3PFMQU65785ebawlr4yiwyydEL+gMFda5RjYGV1zWyiM2Llwsu3UTn3jK3KHX7pLCfPsbnMxfMnCsgK8zimT6eltv/Q125y4lGspTtrajX52kxVsniuqJJZ39tcY/XCZvOJUsyowWmjsjav6P24XPu1Cxa6hAYQJfUL8GDQ0PNpuKP+iQg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=MTCDmLTNV67iF/RKDptn6o8I0Uk1BpY+Tae2pJSdK0E=; b=YNBua7shTvsmjACiy9QuSY6crf1zynSoB2OuD4HS6udGaUmzNVaJDQE2nUxt7pjT0qZY+PreK5stJF6UEonoY3SD8h8YGWUBWEsQ2wX6nsUnpTWkoGSM8VMmtJ/lsqKy2Wq98npKe/Ltifdcbh8o8Yz7214bapC0LHZRJKor+T4jByYZMgrrGXbGdLcq+2SDZGNszuG7anUtio1IHXvIdGVWpgcyZpgzYEoM44+hWa/i07c99Tb5Lv6LEl239Jpw/ss+QYIg7JNV2VtdXkciM343d4Jwf6KO4NUuYMRux8UKosO/w9Y2KJK24K8jSvIbVUi/ZXtLz9e9Ik9qgOWDFA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nutanix.com; dmarc=pass action=none header.from=nutanix.com; dkim=pass header.d=nutanix.com; arc=none Received: from BYAPR02MB4343.namprd02.prod.outlook.com (2603:10b6:a03:57::18) by DM5PR02MB2825.namprd02.prod.outlook.com (2603:10b6:3:108::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5438.14; Thu, 21 Jul 2022 19:56:35 +0000 Received: from BYAPR02MB4343.namprd02.prod.outlook.com ([fe80::1493:404b:3242:8e0f]) by BYAPR02MB4343.namprd02.prod.outlook.com ([fe80::1493:404b:3242:8e0f%5]) with mapi id 15.20.5438.023; Thu, 21 Jul 2022 19:56:35 +0000 From: Het Gala To: qemu-devel@nongnu.org Cc: quintela@redhat.com, dgilbert@redhat.com, pbonzini@redhat.com, berrange@redhat.com, armbru@redhat.com, eblake@redhat.com, prerna.saxena@nutanix.com, Het Gala , Manish Mishra Subject: [PATCH v2 1/7] multifd: adding more helper functions in util files for live migration Date: Thu, 21 Jul 2022 19:56:14 +0000 Message-Id: <20220721195620.123837-2-het.gala@nutanix.com> X-Mailer: git-send-email 2.22.3 In-Reply-To: <20220721195620.123837-1-het.gala@nutanix.com> References: <20220721195620.123837-1-het.gala@nutanix.com> X-ClientProxiedBy: BY5PR16CA0035.namprd16.prod.outlook.com (2603:10b6:a03:1a0::48) To BYAPR02MB4343.namprd02.prod.outlook.com (2603:10b6:a03:57::18) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 0c0ef3f7-dd4b-4766-ed82-08da6b531def X-MS-TrafficTypeDiagnostic: DM5PR02MB2825:EE_ x-proofpoint-crosstenant: true X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: M2cYFFPn4/4Pv248Eh22yTnHJPv6gp1TQKKnxTat+lwICj6ZWzUsYM3Nl37ZeSMgAFr1pA9Mhy7d69LxHzxKM5J9KvutIFx2bvzivC9SkJ4uYMPlkRNixX7OCDyMisU5r2P2xiWu2P8tCfARfGb82nJKZYol397hsZGccl7LD2Qkpl9+Q9r9a4kvoHD74S8CheuwphxqbvfMog074kdzBM8NUvCa1ew8LZVl4t72YtN0yWdQBKnga4mlDsfDECFkeRfCBPSM+vQklrPGMvAKx/affYSuhTtWyLgFzG3+vzj/URkHplfZivsXN+2atm8aK6xvphNVo5bUdxJvrq246uRkHWQu82+wP0MkNvV/tn5e9QODBtEPBy5JudoJVB2881U1wy3pcbDxl8ScxZ2e+g2EUbRS70NtnHsYXDGdgHG8W5dQWNvBtFcjzSXyNmjUG16utdXB1jRBtv0x9IYen1jVbiVjGYXZYMCjwyl/VBE592gDW4HSFtKaJLqxE00H5+0/I3jsKhliyJLhEecPcm+vLydEfrr3nxh3Qt3XdSNPAL1MFpVmiP6I1wX46tJLmAsQTfnv43zOb9jSvNnEhAr5DC/mInExDf79/o54nHVem7sDJnL+GHVM/RkZ1TTscUoepWNT9WmCD5vByAVpIVVIjP4I1YT/TirHcB0Kr4ufRhaoa/GpX9ZZbcukW5uN+9zaQ3PUbkxPETjvVH9Jt8QxGcN8OxqLXl/WchHg4g5fe+b3gkOUGizoNnnr1nhLuZaOBbafWzETvHOET6m11bb+72ntuJVGjY1+G3OqSNbJSyy03HREji6CJ6IrvXy/zVSMEdzau2JlqPn900RnQA== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:BYAPR02MB4343.namprd02.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230016)(39860400002)(136003)(346002)(376002)(396003)(366004)(38350700002)(38100700002)(1076003)(83380400001)(36756003)(186003)(2616005)(26005)(86362001)(107886003)(6512007)(316002)(54906003)(478600001)(66946007)(6916009)(66556008)(52116002)(6506007)(41300700001)(5660300002)(4326008)(8676002)(8936002)(44832011)(6486002)(6666004)(66476007)(2906002)(309714004); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: EIKJLjFHWuFd0EXNq1ia67GxyFCXHGpM2eMDxlJSEgD0sCYcuKfmzrsFpyJxtUyOxmARbbWfvbuKrSkTVCinb+qpwRBzewJpX1RsKCUTwOmZrE2Fb8cw/nwCLhQd9mYSuraHBY2yEWVu2RU2IY68WD1KBtjBRoFj1dj1EKwima0FlhwDgOF4jnKCS3sViSb1CEFrB2nyqTQOaPcYWE0p1k7Y7OtrnVAbNM89C5X61Jbds2/jgw/vTpEsJIH/UX0zxPYzQPqb1beNVLjR+PvsAvhkmpgZr4IJvv669NdTKsUeHcPumgpHnWzNJixtPD4Jex/Pi7/PPMFvodRRA8tKVWNbai+lB6RqNQ669P16kWlhbeZwtY4tOr7GnOjw/jOWLo9NXob+0TQA97fygevTkXaQyO+ueComeWBiE7La9b03v83dNVyBgTjBG3jopRWvCZpc5ffd2h6uJvE8D6POUQQV3yb1uX5Thj817Oh3VKipBNmCRufv1b4vUY7aEISWCLWBkiVOkOZpPIH12vAn6nSgyrzfsvXtDWl06oK3wfQ18XAitwOfdj9KeyPiTEP2/2z+RENvVP4syaRcRSxATQDyvWVcG4ahi39JgKxIthIpnVaRvC+G83MncGJBrVvdJazjJQw4xvKOntX85XTKZWTCfvkkSLdd1RW7MU+dleAGB1C5JG58mX0t2yQZxmGhe9LbwXOIfOmExOyAFMAvqFGx6dtDomk1Fzffxk5PQyqmi2E7Ms747grEu3r5WSkGaGeFDr/Y+iu8+ZPKu/3J0WYCnCCWss2DpDDgcUdZL7wv7m3yMVgL1VsQhaGJYEez1l3qxJ1jfPl/eLFpJ+akQOIj0QHbQMiBrj8E5hpc9I2icdc2TMa4WjzUQfpOsWwzjhVUHh2/llkrzT/6tkvsPxVpYjMTgUBGHykknGlbfB2nUwMX0vuo4DnGKPjvkFHTOG58UehVtEs0L9cs36Xq8zzVk2CqwQnYrQsW/g+c31ISHCh0/4AOmrq5XvgQqz9FfdzgH2ZmGK0TWkV9Gk1Ebk8vJYmgAmMN82Weo99WnY6V/864SxpWRpS/cbPSOUqjVEOKrtS6NBxxeJ6rPnxuccvaZh93xhZhYxCcubSLs46FnTU16zOE9VAI82w0KaKgsVWFdYvcbXKwlXh+MK7wrxKEzGaW4PNvcC/wsRKqmRpWJGssJR/y38TtylulZ36LA5//FBMK96RDMPciOLEjbIyWB6REFmDg015597MEqNvf/0VxVhCgP7ts6qnS9/AkSqEqVHud4G+5MMUCJff8JbUIyfOIOnm5p3vRl9VumOnlGLE1M3Zu+Npo5cmUUIPqr4IVFu+55TnSy6BMgYAhD+jr3UbOCQsqBu+LTX8SFdo+8SzGG53hlFZLeFwbBdSYcTlYpli6pCyPbc4/QDHaCwmEn5frjQIrXmy4cGms2L9MHzPVb1zaZiQ0g1FqLoCNWiXwerfavRmE8efrZajXyqpdK65txgFYG/bKlU6kSsTjpjFa7PlECbvHo+nehUJuPBCQP75BZVQ6R8d3cOZz9LKQU+g+HTdniLcpYMA4PLQiauem6SZrBy5DJ+lF4qSI X-OriginatorOrg: nutanix.com X-MS-Exchange-CrossTenant-Network-Message-Id: 0c0ef3f7-dd4b-4766-ed82-08da6b531def X-MS-Exchange-CrossTenant-AuthSource: BYAPR02MB4343.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Jul 2022 19:56:35.6629 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: bb047546-786f-4de1-bd75-24e5b6f79043 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: +LbuxuBilR3bfSpR8Rg4L01iEb9vkjTSQ6BoxpFLyTbFUlvKTQhHgJDYPkvgmyThxJ9QNaNf8C9THWHTruA1CA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM5PR02MB2825 X-Proofpoint-ORIG-GUID: x7tIdFbDgcw6AqwhryEItGPreBUdRvA3 X-Proofpoint-GUID: x7tIdFbDgcw6AqwhryEItGPreBUdRvA3 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.883,Hydra:6.0.517,FMLib:17.11.122.1 definitions=2022-07-21_27,2022-07-21_02,2022-06-22_01 X-Proofpoint-Spam-Reason: safe Received-SPF: pass client-ip=148.163.155.12; envelope-from=het.gala@nutanix.com; helo=mx0b-002c1b01.pphosted.com X-Spam_score_int: -21 X-Spam_score: -2.2 X-Spam_bar: -- X-Spam_report: (-2.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.082, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" i) strList_from_string() shifted from hm-cmds.c -> qapi-util.c ii) Adding qemu_string_count_delim() helper func. in qapi-util.c and QAPI_LIST_LENGTH() macro defined func. in util.h Suggested-by: Manish Mishra Signed-off-by: Het Gala --- include/qapi/util.h | 12 ++++++++++++ monitor/hmp-cmds.c | 31 +++---------------------------- qapi/qapi-util.c | 35 +++++++++++++++++++++++++++++++++++ 3 files changed, 50 insertions(+), 28 deletions(-) diff --git a/include/qapi/util.h b/include/qapi/util.h index 81a2b13a33..36164ca7ba 100644 --- a/include/qapi/util.h +++ b/include/qapi/util.h @@ -29,6 +29,8 @@ bool qapi_bool_parse(const char *name, const char *value, bool *obj, Error **errp); int parse_qapi_name(const char *name, bool complete); +struct strList *strList_from_string(const char *in, char c); +int qemu_string_count_delim(const char *str, char delim); /* * For any GenericList @list, insert @element at the front. @@ -56,4 +58,14 @@ int parse_qapi_name(const char *name, bool complete); (tail) = &(*(tail))->next; \ } while (0) +/* provides the length of any type of list */ +#define QAPI_LIST_LENGTH(list) ({ \ + size_t _len = 0; \ + typeof(list) _elem; \ + for (_elem = list; _elem != NULL; _elem = _elem->next) { \ + _len++; \ + } \ + _len; \ +}) + #endif diff --git a/monitor/hmp-cmds.c b/monitor/hmp-cmds.c index a6dc79e0d5..6bb6424215 100644 --- a/monitor/hmp-cmds.c +++ b/monitor/hmp-cmds.c @@ -43,6 +43,7 @@ #include "qapi/qapi-commands-stats.h" #include "qapi/qapi-commands-tpm.h" #include "qapi/qapi-commands-ui.h" +#include "qapi/util.h" #include "qapi/qapi-visit-net.h" #include "qapi/qapi-visit-migration.h" #include "qapi/qmp/qdict.h" @@ -71,32 +72,6 @@ bool hmp_handle_error(Monitor *mon, Error *err) return false; } -/* - * Produce a strList from a comma separated list. - * A NULL or empty input string return NULL. - */ -static strList *strList_from_comma_list(const char *in) -{ - strList *res = NULL; - strList **tail = &res; - - while (in && in[0]) { - char *comma = strchr(in, ','); - char *value; - - if (comma) { - value = g_strndup(in, comma - in); - in = comma + 1; /* skip the , */ - } else { - value = g_strdup(in); - in = NULL; - } - QAPI_LIST_APPEND(tail, value); - } - - return res; -} - void hmp_info_name(Monitor *mon, const QDict *qdict) { NameInfo *info; @@ -1121,7 +1096,7 @@ void hmp_announce_self(Monitor *mon, const QDict *qdict) migrate_announce_params()); qapi_free_strList(params->interfaces); - params->interfaces = strList_from_comma_list(interfaces_str); + params->interfaces = strList_from_string(interfaces_str, ','); params->has_interfaces = params->interfaces != NULL; params->id = g_strdup(id); params->has_id = !!params->id; @@ -2399,7 +2374,7 @@ static StatsFilter *stats_filter(StatsTarget target, const char *names, request->provider = provider_idx; if (names && !g_str_equal(names, "*")) { request->has_names = true; - request->names = strList_from_comma_list(names); + request->names = strList_from_string(names, ','); } QAPI_LIST_PREPEND(request_list, request); } diff --git a/qapi/qapi-util.c b/qapi/qapi-util.c index 63596e11c5..9672ac6018 100644 --- a/qapi/qapi-util.c +++ b/qapi/qapi-util.c @@ -152,3 +152,38 @@ int parse_qapi_name(const char *str, bool complete) } return p - str; } + +/* + * Produce a strList from a delimiter separated list. + * A NULL or empty input string return NULL. + */ +strList *strList_from_string(const char *in, char c) +{ + strList *res = NULL; + strList **tail = &res; + + while (in && in[0]) { + char *ch = strchr(in, c); + char *value; + + if (ch) { + value = g_strndup(in, ch - in); + in = ch + 1; /* skip the , */ + } else { + value = g_strdup(in); + in = NULL; + } + QAPI_LIST_APPEND(tail, value); + } + + return res; +} + +int qemu_string_count_delim(const char *str, char delim) +{ + int count = 0; + for (int i = 0; i < strlen(str); i++) { + count += (str[i] == delim); + } + return count; +} From patchwork Thu Jul 21 19:56:15 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Het Gala X-Patchwork-Id: 12925736 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id CC910C43334 for ; Thu, 21 Jul 2022 19:58:26 +0000 (UTC) Received: from localhost ([::1]:57910 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oEcJV-0007Ty-P4 for qemu-devel@archiver.kernel.org; Thu, 21 Jul 2022 15:58:25 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:38584) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oEcHs-0004vs-MR for qemu-devel@nongnu.org; Thu, 21 Jul 2022 15:56:44 -0400 Received: from mx0b-002c1b01.pphosted.com ([148.163.155.12]:29290) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oEcHq-0006aZ-DF for qemu-devel@nongnu.org; Thu, 21 Jul 2022 15:56:44 -0400 Received: from pps.filterd (m0127844.ppops.net [127.0.0.1]) by mx0b-002c1b01.pphosted.com (8.17.1.5/8.17.1.5) with ESMTP id 26LIKtfm027882; Thu, 21 Jul 2022 12:56:39 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nutanix.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-transfer-encoding : content-type : mime-version; s=proofpoint20171006; bh=fmmRx1Hp8obNbvbVCxieQ6aM7aAPcZ0/V4Wm/KC9XEU=; b=qYZA/Uk5lFfZF9sa7+9VOQb15PEY4FJ493W2COY3pCNtDRyua0BIfl9Elv1522RzHjBg g+qTaqpFYKwfF3AEs9cVX8saBOcjEJqzsczFXgMK/GfThvUy8IdOs6VVBQPk7JF1qv1I MDrRbR325eF8u7f2LhK5KLBIzujjmpn4PEU1M3UJrXXFOQkvk7BMdJRr1e7AtHhzAxRz iCBx/3LunTmdX+jOK5eTdRYUEBOCxXreSJj97jhxSIzaJn0iUkSSmi9RuIaJT+aDSJuv r70XpBKD0gu0krnhFCcAhAE5pPxXuDTDdfcI6R8JALwUjaaLxyYf16IFTtlDO2n1XXRK 7Q== Received: from nam11-bn8-obe.outbound.protection.outlook.com (mail-bn8nam11lp2168.outbound.protection.outlook.com [104.47.58.168]) by mx0b-002c1b01.pphosted.com (PPS) with ESMTPS id 3hbvv244d6-2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 21 Jul 2022 12:56:39 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=gAHd8XwQVJoMggeMFmAQf2fj0Nuzj01WtlKHljgW5UbXiNZYVavCcz/egGfpb8Szrj05gWWu/LR3I2OSTBO/L+eLX8KyKoI+q3mzF7vToadm683tFwijOVogac58lDFt/jT8HpB+VKRZ71GDaZI1T0D4vGRXCAMvESHgSxJQHjK/wOsVaJf/NK19inWg6Byy7GQsNSPdO2mdeAK7j9eTrK8Xy++/PqaW5dXevdhH8Sy8rriEEPk5qRktUHgX0YDHDQU5dZnIvNPj3ig0hTcWvwgJYGMyu+MZf0HvY6A0btH+E1zdkw+jE8H9AOiXxUI7EuFR56+JsIrv2mtKjrO5bQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=fmmRx1Hp8obNbvbVCxieQ6aM7aAPcZ0/V4Wm/KC9XEU=; b=SlEKw6VTGKJIVM5QH/IRMyYI4VtN3sK38ODHaqv4+KOUweiB6u6h1tgvh8UZXR9p3EtqexBdbn8r10v8Lige6bWLoz5BsllJW6swrsRHNVuImxwF4py7HiD0Rt2ggXi3pINbu1ll+IZIMO2Nq6h3JRos1tktmvDKvGg4WPIDoMv45+S6EKgch40JnxIf0uCCY9TVFaZkArD5Yeh11p3dXSnsrceMtstiFDJ7XyWytsmtwtRtGVLDO0n/pRvf7mWJ/a7lWBzCf1OYAjW8fqwqjZ3ucbw0AgtIsjQwOod5QgUpGzPIu7pONxjhE8e60dSgvTq19wUhO/bINceWlupDyQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nutanix.com; dmarc=pass action=none header.from=nutanix.com; dkim=pass header.d=nutanix.com; arc=none Received: from BYAPR02MB4343.namprd02.prod.outlook.com (2603:10b6:a03:57::18) by DM5PR02MB2825.namprd02.prod.outlook.com (2603:10b6:3:108::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5438.14; Thu, 21 Jul 2022 19:56:37 +0000 Received: from BYAPR02MB4343.namprd02.prod.outlook.com ([fe80::1493:404b:3242:8e0f]) by BYAPR02MB4343.namprd02.prod.outlook.com ([fe80::1493:404b:3242:8e0f%5]) with mapi id 15.20.5438.023; Thu, 21 Jul 2022 19:56:37 +0000 From: Het Gala To: qemu-devel@nongnu.org Cc: quintela@redhat.com, dgilbert@redhat.com, pbonzini@redhat.com, berrange@redhat.com, armbru@redhat.com, eblake@redhat.com, prerna.saxena@nutanix.com, Het Gala , Manish Mishra Subject: [PATCH v2 2/7] multifd: modifying 'migrate' qmp command to add multifd socket on particular src and dest pair Date: Thu, 21 Jul 2022 19:56:15 +0000 Message-Id: <20220721195620.123837-3-het.gala@nutanix.com> X-Mailer: git-send-email 2.22.3 In-Reply-To: <20220721195620.123837-1-het.gala@nutanix.com> References: <20220721195620.123837-1-het.gala@nutanix.com> X-ClientProxiedBy: BY5PR16CA0035.namprd16.prod.outlook.com (2603:10b6:a03:1a0::48) To BYAPR02MB4343.namprd02.prod.outlook.com (2603:10b6:a03:57::18) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 72e8852c-1a9d-4f74-2b4b-08da6b531ef6 X-MS-TrafficTypeDiagnostic: DM5PR02MB2825:EE_ x-proofpoint-crosstenant: true X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: zWWLnw9QYxozF22iYPYa7Uu6DoH6zTzt97zWE0DfO4+lHj+OyNDSlxIuHIx/jFwlkXnkw/lTkEIq+GQg2I4kObYHySGBsqj1XSp29jNLgu9Jk1P7bLrnpP2j+snreO8cem4cqRvfFRrwM9MCJc0AET797+56MnnBzUZLB/lRfk1Z4D4dTd9tRKGugj77Eh/5h/T7N8osHX+N2aTmVZDidHqmdAWAwTd9fJqXbbn/VGjq25jBGLKChE5JMIBiHd1D3RNjlSy13ABEbBzjKQRQK4w90ETkD1cPwwaSHOXzVDU9wjOmTfA3pC5UIs0oAhMja9aNxrko/YqzhSAKw+dtgmXgMImNINXzTRXynv8YRl3EFFhQh/K5N/ey27wtDGP4cpDvUhrwwlprwUedzgIffzXK5LGqJgbXMNGe0i1iUrYkpLIYpsUH29jq+ddBXPxmVgXwQpKnKx5gvunxXQZcTZiMM4SkkyuCuf2KGnVm+Fos+qAfQiN3bVqXYYRJBc4+A1VVNaiHJJKoK9crqChT14KYWfkwpk4Tp2TrCWQ1LMxy+OnUNafRZ7eughMscx+DQd59lK4y+J7qSn65PIcPmQKJjUqvwVNv63duTNanAaaxLm0Whxcdqa1k4ShH556YFTM8rDmTN7BBWkDudQ4gkzo1nZop+WINxBkNF2RrSwOUvxYGfZ+J/jna7054R6gl5obbpNS5Q33/Di1fnUDWdwzc8J+YH2q+9gd5GejLEHL1m2COWlS641BJS5KMnOiIo/MH79qezjPOVEgyGPywD+wXHgmtNIXRiExjJe4+oiM= X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:BYAPR02MB4343.namprd02.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230016)(39860400002)(136003)(346002)(376002)(396003)(366004)(38350700002)(38100700002)(1076003)(83380400001)(36756003)(186003)(2616005)(26005)(86362001)(107886003)(6512007)(316002)(54906003)(478600001)(66946007)(6916009)(66556008)(52116002)(6506007)(41300700001)(5660300002)(30864003)(4326008)(8676002)(8936002)(44832011)(6486002)(6666004)(66476007)(2906002); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: FyFb5iUaczZtoIqljx0vA4fxaURinbYOG7vcFz1Sl+afM4H58wUswoSX8qPVW3z37Par9VhnABgobM3JMxXNHHH695p+qUPkrXtrU7eFqblI84rP6sktBlzDh5JWiXZfIqF6JR0U06p5srJ8nFByBRlMtLQRQtUcRuk16gcTICfI11Tr2uIc76Drv0oSMmDyxU8KHr1iMivRX/t//SzXFfWR5qlWRFiARG2i3n02y+UbfMn1vP3WsSWAOAyzCccLf2mepi9uHEPc/C0xU8Nul48qeppfwffvFkz7t4jmlkoFwmgiQTpHVQ3GOdMgOUTqrzdXM8WFMWmw1xvbBPwqITsjTtUHlmzV3ZGfyz94YiezU4D2UE5j8oMs3vo7GXZx9QEteze3AWDbpIpWO6Bv6wdIaAEmvBftLDrQmcd7YN/3J84seZKcVgNBEwWrjS7R1yLJxb9dBO3qXRjgmSARuIS/rfOI2GyjfmglaSTXtwXUrrU1d0+h/ZWAjrCNvo+Jb9Q/FwsRzDseB0eYp5bw/Ww7sMxzMTy6fFY6n1c10WY0ucVC5n0Nbj+xvuGFqVDS/6D1o3hmeBFbPe6Eq5L0P5ufE3GHaNs7llvfwDioEeHAnILtbbVCtPbAmj9prrDx+muXMEUUCQGXRKXKVp6JI2HjYa0H50Hcc9dUQNhkMlpieeOH9+Rtohdif+caq5+4zdUNW35GTeD/HiVpLifN6rg/umFz0frCR3VosZ9JCvPfdP7W1OfWAkAjuS7SWnO5BD9ZiXXoGrt5zk9z43GB6icGy8yaSbdICrMWqaEM6g7zQgSKqHGwx9PQrAQOKH7YFqYUYKk0Zty3bPYeGPhE6dmuergPKQQixyjkJYEndCN11i+/0wPi/H1ddr1e8si1ZNSPfFTAb186PXg7KN8vLmKFXgW7hGyoF6iFCKQO0ddgHbCfqy8rDYDgdgZRRZYda8l097xZszMr5MZIRt1BwtABrc99L4I8xXWs2+3YNTynNqWZHLiptxkrZz77gaIU3IlLjehA4OUoakiKJOGRhLydZDUG4QrKovvjwpWmSKI5U5mqEw98Sd38KVBuv2uN6y/k4RoClyvCP6PyN9ZIXNGUv8E0zg4XYXYxExTnBWnrTbgwVsYkWPBTZThp9rpK9+1sEkkDUCmgSbRIPOe4lNo4W8sLVQg3rVNvFTHUyl2ikKA7huO7oVXzZ74FSTDy7L6KmWyFaRP8xJnvlG4BO7tt5kXrGHYhe6G770eTL4vwJ45hKv/7LDw5X32joV01crJXCnYWQwscDIX3eDSSyKMicqAX1Ka8p6parfAgY/9juTejQRJ1eeBZGaXFHgIYPlSepg6PFLRzAhCsVb8sUFUONm6cMkApc+a6rrJidgSDrBRlTn9Dbn/9ceNQinnbTkinJK0DlzVzL/J6mG55H7AQXQ3bBVGvFfjoh43tpABX7W8JFIRjwrHaLW6FeKbpPNwWbnPXKtmzSBYc2OiO4qrREoNzu8JCZfVykD1EIQY3aIZ23L9ThHR/8t30E2U2Hyn2qjvTzq9KjvssVMcLk/6OofWxTfnhZ0DakrT70esf96W7lDLrQPQ/EFY2quWM X-OriginatorOrg: nutanix.com X-MS-Exchange-CrossTenant-Network-Message-Id: 72e8852c-1a9d-4f74-2b4b-08da6b531ef6 X-MS-Exchange-CrossTenant-AuthSource: BYAPR02MB4343.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Jul 2022 19:56:37.4284 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: bb047546-786f-4de1-bd75-24e5b6f79043 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: burV58CEAWiLeFa4gMpskW4zX8P7o5W7Oz+PczVkZG7DpF5xbjlzhMpIlzG6TPZ9G+rLoO5OXUIY1oMnjqYTug== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM5PR02MB2825 X-Proofpoint-ORIG-GUID: lvBuuuIrF4UIvT7DGUnuPC-Zg79Yc7lW X-Proofpoint-GUID: lvBuuuIrF4UIvT7DGUnuPC-Zg79Yc7lW X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.883,Hydra:6.0.517,FMLib:17.11.122.1 definitions=2022-07-21_27,2022-07-21_02,2022-06-22_01 X-Proofpoint-Spam-Reason: safe Received-SPF: pass client-ip=148.163.155.12; envelope-from=het.gala@nutanix.com; helo=mx0b-002c1b01.pphosted.com X-Spam_score_int: -21 X-Spam_score: -2.2 X-Spam_bar: -- X-Spam_report: (-2.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.082, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" i) Modified the format of the qemu monitor command : 'migrate' by adding a list, each element in the list consisting of multifd connection parameters: source uri, destination uri and of the number of multifd channels between each pair. ii) Information of all multifd connection parameters' list and length of the list is stored in 'OutgoingMigrateParams' struct. Suggested-by: Manish Mishra Signed-off-by: Het Gala --- migration/migration.c | 52 +++++++++++++++++++++++++++++-------- migration/socket.c | 60 ++++++++++++++++++++++++++++++++++++++++--- migration/socket.h | 19 +++++++++++++- monitor/hmp-cmds.c | 1 + qapi/migration.json | 47 +++++++++++++++++++++++++++++---- 5 files changed, 160 insertions(+), 19 deletions(-) diff --git a/migration/migration.c b/migration/migration.c index e03f698a3c..572b909423 100644 --- a/migration/migration.c +++ b/migration/migration.c @@ -2380,13 +2380,14 @@ static bool migrate_prepare(MigrationState *s, bool blk, bool blk_inc, return true; } -void qmp_migrate(const char *uri, bool has_blk, bool blk, +void qmp_migrate(const char *uri, bool has_multi_fd_uri_list, + MigrateUriParameterList *cap, bool has_blk, bool blk, bool has_inc, bool inc, bool has_detach, bool detach, bool has_resume, bool resume, Error **errp) { Error *local_err = NULL; MigrationState *s = migrate_get_current(); - const char *p = NULL; + const char *dst_ptr = NULL; if (!migrate_prepare(s, has_blk && blk, has_inc && inc, has_resume && resume, errp)) { @@ -2400,20 +2401,51 @@ void qmp_migrate(const char *uri, bool has_blk, bool blk, } } + /* + * In case of Multi-FD migration, source and destination uri + * supports only tcp network protocol. + */ + if (has_multi_fd_uri_list) { + int length = QAPI_LIST_LENGTH(cap); + init_multifd_array(length); + for (int i = 0; i < length; i++) { + const char *pd = NULL, *ps = NULL; + const char *multifd_dst_uri = cap->value->destination_uri; + const char *multifd_src_uri = cap->value->source_uri; + uint8_t multifd_channels = cap->value->multifd_channels; + if (!strstart(multifd_dst_uri, "tcp:", &pd) || + !strstart(multifd_src_uri, "tcp:", &ps)) { + error_setg(errp, "multi-fd destination and multi-fd source " + "uri, both should be present and follows tcp protocol only"); + return; + } else { + store_multifd_migration_params(pd ? pd : multifd_dst_uri, + ps ? ps : multifd_src_uri, + multifd_channels, i, &local_err); + } + cap = cap->next; + } + + if (outgoing_param_total_multifds() != migrate_multifd_channels()) { + error_setg(errp, "Total multifd channel number mismatch"); + return; + } + } + migrate_protocol_allow_multi_channels(false); - if (strstart(uri, "tcp:", &p) || + if (strstart(uri, "tcp:", &dst_ptr) || strstart(uri, "unix:", NULL) || strstart(uri, "vsock:", NULL)) { migrate_protocol_allow_multi_channels(true); - socket_start_outgoing_migration(s, p ? p : uri, &local_err); + socket_start_outgoing_migration(s, dst_ptr ? dst_ptr : uri, &local_err); #ifdef CONFIG_RDMA - } else if (strstart(uri, "rdma:", &p)) { - rdma_start_outgoing_migration(s, p, &local_err); + } else if (strstart(uri, "rdma:", &dst_ptr)) { + rdma_start_outgoing_migration(s, dst_ptr, &local_err); #endif - } else if (strstart(uri, "exec:", &p)) { - exec_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, "exec:", &dst_ptr)) { + exec_start_outgoing_migration(s, dst_ptr, &local_err); + } else if (strstart(uri, "fd:", &dst_ptr)) { + fd_start_outgoing_migration(s, dst_ptr, &local_err); } else { if (!(has_resume && resume)) { yank_unregister_instance(MIGRATION_YANK_INSTANCE); diff --git a/migration/socket.c b/migration/socket.c index e6fdf3c5e1..f199430bc2 100644 --- a/migration/socket.c +++ b/migration/socket.c @@ -32,6 +32,28 @@ struct SocketOutgoingArgs { SocketAddress *saddr; } outgoing_args; +struct SocketArgs { + struct SrcDestAddr address; + uint8_t multifd_channels; +}; + +struct OutgoingMigrateParams { + struct SocketArgs *socket_args; + size_t socket_args_arr_len; +} outgoing_migrate_params; + +int outgoing_param_total_multifds(void) +{ + size_t len = outgoing_migrate_params.socket_args_arr_len; + uint64_t total_multifd_channels = 0; + + for (int i = 0; i < len; i++) { + total_multifd_channels += + outgoing_migrate_params.socket_args[i].multifd_channels; + } + return total_multifd_channels; +} + void socket_send_channel_create(QIOTaskFunc f, void *data) { QIOChannelSocket *sioc = qio_channel_socket_new(); @@ -65,6 +87,9 @@ int socket_send_channel_destroy(QIOChannel *send) qapi_free_SocketAddress(outgoing_args.saddr); outgoing_args.saddr = NULL; } + g_free(outgoing_migrate_params.socket_args); + outgoing_migrate_params.socket_args = NULL; + outgoing_migrate_params.socket_args_arr_len = 0; return 0; } @@ -135,17 +160,46 @@ socket_start_outgoing_migration_internal(MigrationState *s, } void socket_start_outgoing_migration(MigrationState *s, - const char *str, + const char *dst_str, Error **errp) { Error *err = NULL; - SocketAddress *saddr = socket_parse(str, &err); + SocketAddress *dst_saddr = socket_parse(dst_str, &err); if (!err) { - socket_start_outgoing_migration_internal(s, saddr, &err); + socket_start_outgoing_migration_internal(s, dst_saddr, &err); } error_propagate(errp, err); } +void init_multifd_array(int length) +{ + outgoing_migrate_params.socket_args = g_new0(struct SocketArgs, length); + outgoing_migrate_params.socket_args_arr_len = length; +} + +void store_multifd_migration_params(const char *dst_uri, + const char *src_uri, + uint8_t multifd_channels, + int idx, Error **errp) +{ + struct SocketArgs *sa = &outgoing_migrate_params.socket_args[idx]; + SocketAddress *src_addr, *dst_addr; + + src_addr = socket_parse(src_uri, errp); + if (!src_addr) { + return; + } + + dst_addr = socket_parse(dst_uri, errp); + if (!dst_addr) { + return; + } + + sa->address.dst_addr = dst_addr; + sa->address.src_addr = src_addr; + sa->multifd_channels = multifd_channels; +} + static void socket_accept_incoming_migration(QIONetListener *listener, QIOChannelSocket *cioc, gpointer opaque) diff --git a/migration/socket.h b/migration/socket.h index dc54df4e6c..0cbb7220ac 100644 --- a/migration/socket.h +++ b/migration/socket.h @@ -19,13 +19,30 @@ #include "io/channel.h" #include "io/task.h" +#include "migration.h" +/* info regarding destination and source uri */ +typedef struct SrcDestAddr { + SocketAddress *dst_addr; + SocketAddress *src_addr; +} SrcDestAddr; + + +int outgoing_param_total_multifds(void); void socket_send_channel_create(QIOTaskFunc f, void *data); QIOChannel *socket_send_channel_create_sync(Error **errp); int socket_send_channel_destroy(QIOChannel *send); void socket_start_incoming_migration(const char *str, Error **errp); -void socket_start_outgoing_migration(MigrationState *s, const char *str, +void socket_start_outgoing_migration(MigrationState *s, const char *dst_str, Error **errp); + +int multifd_list_length(MigrateUriParameterList *list); + +void init_multifd_array(int length); + +void store_multifd_migration_params(const char *dst_uri, const char *src_uri, + uint8_t multifd_channels, int idx, + Error **erp); #endif diff --git a/monitor/hmp-cmds.c b/monitor/hmp-cmds.c index 6bb6424215..8d25fee4be 100644 --- a/monitor/hmp-cmds.c +++ b/monitor/hmp-cmds.c @@ -59,6 +59,7 @@ #include "migration/snapshot.h" #include "migration/misc.h" + #ifdef CONFIG_SPICE #include #endif diff --git a/qapi/migration.json b/qapi/migration.json index 81185d4311..456247af8f 100644 --- a/qapi/migration.json +++ b/qapi/migration.json @@ -1449,12 +1449,37 @@ ## { 'command': 'migrate-continue', 'data': {'state': 'MigrationStatus'} } +## +# @MigrateUriParameter: +# +# Information regarding which source interface is connected to which +# destination interface and number of multifd channels over each interface. +# +# @source-uri: uri of the source VM. Default port number is 0. +# +# @destination-uri: uri of the destination VM +# +# @multifd-channels: number of parallel multifd channels used to migrate data +# for specific source-uri and destination-uri. Default value +# in this case is 2 (Since 7.1) +# +## +{ 'struct' : 'MigrateUriParameter', + 'data' : { 'source-uri' : 'str', + 'destination-uri' : 'str', + '*multifd-channels' : 'uint8'} } + ## # @migrate: # # Migrates the current running guest to another Virtual Machine. # # @uri: the Uniform Resource Identifier of the destination VM +# for migration thread +# +# @multi-fd-uri-list: list of pair of source and destination VM Uniform +# Resource Identifiers with number of multifd-channels +# for each pair # # @blk: do block migration (full disk copy) # @@ -1474,20 +1499,32 @@ # 1. The 'query-migrate' command should be used to check migration's progress # and final result (this information is provided by the 'status' member) # -# 2. All boolean arguments default to false +# 2. The uri argument should have the Uniform Resource Identifier of default +# destination VM. This connection will be bound to default network # -# 3. The user Monitor's "detach" argument is invalid in QMP and should not +# 3. All boolean arguments default to false +# +# 4. The user Monitor's "detach" argument is invalid in QMP and should not # be used # # Example: # -# -> { "execute": "migrate", "arguments": { "uri": "tcp:0:4446" } } +# -> { "execute": "migrate", +# "arguments": { +# "uri": "tcp:0:4446", +# "multi-fd-uri-list": [ { "source-uri": "tcp::6900", +# "destination-uri": "tcp:0:4480", +# "multifd-channels": 4}, +# { "source-uri": "tcp:10.0.0.0: ", +# "destination-uri": "tcp:11.0.0.0:7789", +# "multifd-channels": 5} ] } } # <- { "return": {} } # ## { 'command': 'migrate', - 'data': {'uri': 'str', '*blk': 'bool', '*inc': 'bool', - '*detach': 'bool', '*resume': 'bool' } } + 'data': {'uri': 'str', '*multi-fd-uri-list': ['MigrateUriParameter'], + '*blk': 'bool', '*inc': 'bool', '*detach': 'bool', + '*resume': 'bool' } } ## # @migrate-incoming: From patchwork Thu Jul 21 19:56:16 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Het Gala X-Patchwork-Id: 12925737 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 795F5C433EF for ; Thu, 21 Jul 2022 19:58:30 +0000 (UTC) Received: from localhost ([::1]:58252 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oEcJZ-0007hS-GO for qemu-devel@archiver.kernel.org; Thu, 21 Jul 2022 15:58:29 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:38618) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oEcHv-0004zg-3I for qemu-devel@nongnu.org; Thu, 21 Jul 2022 15:56:47 -0400 Received: from mx0b-002c1b01.pphosted.com ([148.163.155.12]:30700) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oEcHq-0006af-Lq for qemu-devel@nongnu.org; Thu, 21 Jul 2022 15:56:46 -0400 Received: from pps.filterd (m0127843.ppops.net [127.0.0.1]) by mx0b-002c1b01.pphosted.com (8.17.1.5/8.17.1.5) with ESMTP id 26LIKn6g028504; Thu, 21 Jul 2022 12:56:41 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nutanix.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-transfer-encoding : content-type : mime-version; s=proofpoint20171006; bh=spXeaXNZ4Rat3K8aTDPyI/u9V4NSR4MKjyRlHVxRLP0=; b=WyGfIkY9naBMD4q24i2OgBNLpGykhw26AOGnnztLy5awlHfk5NiR6/3jBhGwfgZgl1tc EfcQKhqEHp/sqXRxU36YaWhuLuR3zDRO8RnACDYPMDG+JAYsRwiAGAhwsCcTaGMDVYrU OXSfsQhhQndvADR0Uri6q1Oca95VmNznI3jeE+aCWdj9PM63Ixh8JkhZ2uVlqSuhni1d JQPzhxWsMb+gplx3eXYKpapzR7KV49Ceb17tVnkjmIdM4UbnFR4N8rVLmAGfOoURA4qO e5Sl0Rhu0ab6iilasM6QTRlvfMgR8Pe1Win3uFdbsP68OxQAzb4BatSIc83PX0xfjeGc Gg== Received: from nam11-bn8-obe.outbound.protection.outlook.com (mail-bn8nam11lp2168.outbound.protection.outlook.com [104.47.58.168]) by mx0b-002c1b01.pphosted.com (PPS) with ESMTPS id 3hbuehv8s3-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 21 Jul 2022 12:56:41 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Xv7rqdfNZ1/sahaYU7uEKdVKx0T6fP6uLgSIu5S8l8jLc+Tz0SscU7Xe0EP4V0B+h8MWsS3NryMbNhebMtKENKOPtZARioekqYP+lcpSVY5mvdlu2ojKmeLGn0QI2+97v2fKuCpeMnuQUMUOeyTqueTmKf6IOwLl6adSPw/udVmyUTvPdAD8qm+B60nI2Hj1j4t2ktO9ocpLuLILWDKgG2rAvyyc3dnVuoSzWXEeCzv8XSin8jpqOoCtbhHG70kUviOpwewg9KtFal2RTZ7QmDiAo0xvSOtQstgKAkHTuXo/7tLHAV/LuFKBvcZZ+wIszUv3Ts2DbbMlzDGMw5k9/w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=spXeaXNZ4Rat3K8aTDPyI/u9V4NSR4MKjyRlHVxRLP0=; b=H3ty+VbsDncfgBWQlIpHukXt7Hda4Er+91blwcFe/WcRBePywB0BuXi9EuM73aWAW9neu4uWPCeHjnB+BLWARpWYLMRZWvVi6SXxLlEZO6qOSF4MS/nmZqRBSsgtAaI+e9GGQX4o4oDYMdGfxxoUwO3YcpRJzNzkhffrCkD2F9TrDkKcVY/QaD8TTtNryQE2M/amcbHNa61Fn0DoRVB0ciFRGtbtJvFcdU/szyX5Kk1mOtoe6Zt8w+soSrIRgzXHXV9SYPu0lhKvDanBmiJvnBHaOJEDYPh5XKQQC62+GH97LxBQL+VvVHbaPPkTJDwZ7vMDLS3bnqVZ/niK8k4GwQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nutanix.com; dmarc=pass action=none header.from=nutanix.com; dkim=pass header.d=nutanix.com; arc=none Received: from BYAPR02MB4343.namprd02.prod.outlook.com (2603:10b6:a03:57::18) by DM5PR02MB2825.namprd02.prod.outlook.com (2603:10b6:3:108::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5438.14; Thu, 21 Jul 2022 19:56:39 +0000 Received: from BYAPR02MB4343.namprd02.prod.outlook.com ([fe80::1493:404b:3242:8e0f]) by BYAPR02MB4343.namprd02.prod.outlook.com ([fe80::1493:404b:3242:8e0f%5]) with mapi id 15.20.5438.023; Thu, 21 Jul 2022 19:56:39 +0000 From: Het Gala To: qemu-devel@nongnu.org Cc: quintela@redhat.com, dgilbert@redhat.com, pbonzini@redhat.com, berrange@redhat.com, armbru@redhat.com, eblake@redhat.com, prerna.saxena@nutanix.com, Het Gala , Manish Mishra Subject: [PATCH v2 3/7] multifd: adding multi-interface support for multifd on destination side Date: Thu, 21 Jul 2022 19:56:16 +0000 Message-Id: <20220721195620.123837-4-het.gala@nutanix.com> X-Mailer: git-send-email 2.22.3 In-Reply-To: <20220721195620.123837-1-het.gala@nutanix.com> References: <20220721195620.123837-1-het.gala@nutanix.com> X-ClientProxiedBy: BY5PR16CA0035.namprd16.prod.outlook.com (2603:10b6:a03:1a0::48) To BYAPR02MB4343.namprd02.prod.outlook.com (2603:10b6:a03:57::18) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: b65b1676-d94d-41dd-7b83-08da6b53200f X-MS-TrafficTypeDiagnostic: DM5PR02MB2825:EE_ x-proofpoint-crosstenant: true X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: uJ33dR4RkQRjE1C+6gLpoOgvUhqoh1wvtvqTjpy1aacu/Xvhc5APrymmsWZ7VM1goL2YWDMJUbcImx40eyLZzZCZnUK6l86fV8UIfjLtHGZROaXE/MeX0ZKAPOljhq5jd/c0M/czv6d5JBLcw9tdP/yXLyd16Q8BAENfzMT5PT8PHKUE5O6LeQOdJZCgJO4o6Lk8pSUaM2wHWc5Vjk7cbC8GvWqzy8PhFkx1NxRKYJj4QC7XfZa51jOvA6NshMWVMg9lsJKLvuW5Pme/qw6qBDsUjYzq37JwiSt1Ruklu8N8AlgU4bxezJv4r3Ksx/NOk3n29RRWvHL4edWw8vTm6cDq3+0VP+9n8J4vwsyuRG8xaVq2OaGW6MBp0h/dppn5sw3Xmm5N9gMxRT+CbHFwX0X7pmrzT+GMnSzsC6ZQckxJTM0yVi3mgSlds2ZrZGrWyZEg0vnm1izM0YXrsP7vdR1uB7zItRWNuNh03u1IFecBNxTjB67VjJ3xHzFgqomh8Qp8eIJX1GLXZlUbfIb9A52XwIlNMhddkD4WMxFuchvPnfx6A5bL3mAkxqkX4z4gpWJEnxc065uCEihlmN3J4aPdIwVT1dy/clot3E1WwSJBsz81eQmvJsqMA29lqhd3YEhGhQwslQLWN0LsqhV8MOQUm7LXOV+TvtLG1wpBrgxdeU7MYJ8xypV8bDKnl2I/MWjAi4A0+NHQSfeJXZU7wCUPqx0L2GB9z7DuObZxksyToNXtLEIlEdH/B5D+kXCuHdxOgrXwh4Ke/bQYO5YqGAz9fw7UI+Kk53AGuDbuHNc= X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:BYAPR02MB4343.namprd02.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230016)(39860400002)(136003)(346002)(376002)(396003)(366004)(38350700002)(38100700002)(1076003)(83380400001)(36756003)(186003)(2616005)(26005)(86362001)(107886003)(6512007)(316002)(54906003)(478600001)(66946007)(6916009)(66556008)(52116002)(6506007)(41300700001)(5660300002)(30864003)(4326008)(8676002)(8936002)(44832011)(6486002)(6666004)(66476007)(2906002); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: pG6NAsz8+jIt8L0IzdkDinuLiY6ONlchBRLvwqbHt6JOExHiBCvOKzQS/8XQxUOyYQ2uXLQEjZPP6/rSdBLXqbJq3iU8FzW+x3GpjwaRiPORyP2WLM9L+v0l7wwKpiIH1IlbO1LLYxKDUETjLQX0ZoQ0zEDPKmERO9zwAynmhZ3obYNt+siSQsWI8gKU/qYnKksrPnnegYn2lBVvPkoS4mjwZfr/flxnh/jnCAbH2weVMB8/BL5xWibobUaR+hSu7k951/7dC3DihsMx9ftNSF1+/ahdwujOInD7AnXLort1qXMJ2WuwusCzGv33USv7rUVQoLAvsVPDDlgYiM9U4WVLj56z7L5h/ppldapFkRHbBWye8Uqc6tsOANPIDG/HjZLndiIYVNuVruHjF9zsXcuF8btTwADgiGjnwffYoCWfGC+Q6ZMsiytS+rgLEYqONAkzwmzCLEIzPEiB4xB3jp3BiqeW2XVtX0K/SJZWl9Vo7otFx+EdRTHie/8pQjEBXCTidALb9GY6Q6aNJWEGS1SQkAEnAUN0u58AYYHYgzKLdp7RtU4rrv99okJqOxiQLnS4TBjAacnvSl5we+U1FVigdDzkWfoBPg0O2rDnzLHOSZ6YE76GSkfFyK+oJTnWeiTJcPFUEdqP/7r80BKOg/J39X0K2NifYYzVfJPeLBItaSuXx4v6nOTk7JAKmFNP89p4cVa0mzhy5NMfcZLnXxt3QxGHghsljeJTPJy3ogUg46yIL/F+4crD2XY7VP318TEi4l5Zp7mBaf9u9RvEhbXaIN/sMCUQqeDiPLmwuJS86GfrNtFf1Eg/ZLmwFP2jR5D2C9J0fK/soM9nJUpzln8PRFF42Vh8kw4Z8uy/Ghuv3gMNz1dzDpt1cGrcxFBytEi1jj9eQVCOPbbbE2zIdwPd/+RlXxUVSPoCs5EjAgl3PWeHWpEhFH836wKPfs5JV8kartxN6K2qBOcLGCbD26/v9wBYTCkDVgvK215pcc/u1LH4yxQJ/EmGAAb12wTQNlUoh/vf5Gw48aIjFUfTjYDMCoHIcUcnC2IuFv2C4vsnaLGraD+/8CxgWyRz4OYKSmo8EqYWqyBbRq2SKZocaz2vOIilNj1BmQ04IlPVfUu48EXrXhzv4Er3SWFr9Dh3btQeHPjklMnNaLnkUADvtsQcyCPtx7EqwxdsIviv/qEa0rUUzRSyzHGBWQ+Z98tmKwefzdA4HX3sOOTGqbT8KVNwNtphIzOalPQtKlNRYChaKLXyIm1Rr2mmFkEY8vDNGIhdOLNRiQZtEqmpa8aucSeBs0DI7l8ECl1IR8mY7kcvd1KnhC6t+XI8aLh2SzsHJvJbi1LIsfPl3oj84LNNdYzksR79WYbD8lH1A2zWlPDyo72T5mXbJcr2h1C8MsPhw3MpBLU/Fvxc8wySO/YhlLoE53W94Qko/RqxBrX69574HC4oRMgxx4jSqrQldNodAHNYIWmVJofIFoMCu/7C+2p3NBa7LcbfqwG/Ewa2mZpjmeLaABXUwzs3bUHqs8Pg8MaBC9b30ez4WY2I11sxx3nofxMO84Kf0o/7K3JcOYnYNW6vhHcbEnqsCcVSMwet X-OriginatorOrg: nutanix.com X-MS-Exchange-CrossTenant-Network-Message-Id: b65b1676-d94d-41dd-7b83-08da6b53200f X-MS-Exchange-CrossTenant-AuthSource: BYAPR02MB4343.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Jul 2022 19:56:39.2564 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: bb047546-786f-4de1-bd75-24e5b6f79043 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: IXWKLu+reRIVZUVGfNV5WsF2x+1NC41sPiSOYOAiNwvj6XqO8sH1HOqCNAPx/0VOIs6N5QXiDo+4C/s3/WTO4g== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM5PR02MB2825 X-Proofpoint-GUID: Fpffya1FQdscpHlny4zOrfAbc_FW03NS X-Proofpoint-ORIG-GUID: Fpffya1FQdscpHlny4zOrfAbc_FW03NS X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.883,Hydra:6.0.517,FMLib:17.11.122.1 definitions=2022-07-21_27,2022-07-21_02,2022-06-22_01 X-Proofpoint-Spam-Reason: safe Received-SPF: pass client-ip=148.163.155.12; envelope-from=het.gala@nutanix.com; helo=mx0b-002c1b01.pphosted.com X-Spam_score_int: -21 X-Spam_score: -2.2 X-Spam_bar: -- X-Spam_report: (-2.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.082, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" i) Modified the format of qemu monitor command: 'migrate-incoming' by adding a list, each element in the list to open socket listeners with a given number of multifd channels. ii) Qemu starts with -incoming flag defer and -multi-fd-incoming defer to allow the modified 'migrate-incoming' command to be used. iii) Format for -multi-fd-incoming flag as a comma separated string has been added with each substring containing listener socket address and number of sockets to open. Suggested-by: Manish Mishra Signed-off-by: Het Gala --- migration/migration.c | 143 ++++++++++++++++++++++++++++++++++++------ migration/migration.h | 2 + migration/socket.c | 11 ++-- migration/socket.h | 3 +- qapi/migration.json | 46 ++++++++++++-- qapi/qapi-util.c | 3 +- qemu-options.hx | 18 ++++++ softmmu/vl.c | 30 ++++++++- 8 files changed, 221 insertions(+), 35 deletions(-) diff --git a/migration/migration.c b/migration/migration.c index 572b909423..c58b81576c 100644 --- a/migration/migration.c +++ b/migration/migration.c @@ -486,28 +486,41 @@ void migrate_add_address(SocketAddress *address) QAPI_CLONE(SocketAddress, address)); } -static void qemu_start_incoming_migration(const char *uri, Error **errp) +static void qemu_start_incoming_migration(const char *uri, + uint8_t multifd_count, int idx, + Error **errp) { const char *p = NULL; - migrate_protocol_allow_multi_channels(false); /* reset it anyway */ - qapi_event_send_migration(MIGRATION_STATUS_SETUP); - if (strstart(uri, "tcp:", &p) || - strstart(uri, "unix:", NULL) || - strstart(uri, "vsock:", NULL)) { - migrate_protocol_allow_multi_channels(true); - socket_start_incoming_migration(p ? p : uri, errp); -#ifdef CONFIG_RDMA - } else if (strstart(uri, "rdma:", &p)) { - rdma_start_incoming_migration(p, errp); -#endif - } else if (strstart(uri, "exec:", &p)) { - exec_start_incoming_migration(p, errp); - } else if (strstart(uri, "fd:", &p)) { - fd_start_incoming_migration(p, errp); + if (multifd_count == 0) { + migrate_protocol_allow_multi_channels(false); /* reset it anyway */ + qapi_event_send_migration(MIGRATION_STATUS_SETUP); + if (strstart(uri, "tcp:", &p) || + strstart(uri, "unix:", NULL) || + strstart(uri, "vsock:", NULL)) { + migrate_protocol_allow_multi_channels(true); + #ifdef CONFIG_RDMA + } else if (strstart(uri, "rdma:", &p)) { + rdma_start_incoming_migration(p, errp); + #endif + } else if (strstart(uri, "exec:", &p)) { + exec_start_incoming_migration(p, errp); + } else if (strstart(uri, "fd:", &p)) { + fd_start_incoming_migration(p, errp); + } else { + error_setg(errp, "unknown migration protocol: %s", uri); + } } else { - error_setg(errp, "unknown migration protocol: %s", uri); + /* multi-FD parameters only support tcp network protocols */ + if (!strstart(uri, "tcp:", &p)) { + error_setg(errp, "multifd-destination uri supports " + "tcp protocol only"); + return; + } + store_multifd_migration_params(p ? p : uri, NULL, multifd_count, + idx, errp); } + socket_start_incoming_migration(p ? p : uri, multifd_count, errp); } static void process_incoming_migration_bh(void *opaque) @@ -2192,7 +2205,8 @@ void migrate_del_blocker(Error *reason) migration_blockers = g_slist_remove(migration_blockers, reason); } -void qmp_migrate_incoming(const char *uri, Error **errp) +/* migrate_incoming function is for -incoming flag process */ +void migrate_incoming(const char *uri, Error **errp) { Error *local_err = NULL; static bool once = true; @@ -2210,7 +2224,7 @@ void qmp_migrate_incoming(const char *uri, Error **errp) return; } - qemu_start_incoming_migration(uri, &local_err); + qemu_start_incoming_migration(uri, 0, 0, &local_err); if (local_err) { yank_unregister_instance(MIGRATION_YANK_INSTANCE); @@ -2221,6 +2235,95 @@ void qmp_migrate_incoming(const char *uri, Error **errp) once = false; } +/* + * multi_fd_migrate_incoming function is for -multi-fd-migrate-incoming + * flag process + */ +void multi_fd_migrate_incoming(const char *uri, Error **errp) +{ + Error *local_err = NULL; + static bool once = true; + + if (!once) { + error_setg(errp, "The incoming migration has already been started"); + return; + } + if (!runstate_check(RUN_STATE_INMIGRATE)) { + error_setg(errp, "'-multi-fd-incoming' was not specified on the command line"); + return; + } + + strList *st = strList_from_string(uri, ','); + strList *r = st; + int length = QAPI_LIST_LENGTH(st); + init_multifd_array(length); + + for (int i = 0; i < length; i++) { + const char *uri = NULL, *ret = NULL; + const char *str = r->value; + uint8_t multifd_channels = DEFAULT_MIGRATE_MULTIFD_CHANNELS; + int parse_count = qemu_string_count_delim(str, ':'); + if (parse_count < 2 || parse_count > 3) { + error_setg(errp, "Invalid format of string-id %d in " + "'-multi-fd-incoming' flag", i); + return; + } + if (parse_count == 3) { + ret = strrchr(str, ':'); + uri = g_strndup(str, strlen(str) - strlen(ret)); + multifd_channels = atoi(ret + 1); + } + qemu_start_incoming_migration(parse_count == 2 ? str : uri, + multifd_channels, i, &local_err); + r = r->next; + } + if (local_err) { + yank_unregister_instance(MIGRATION_YANK_INSTANCE); + error_propagate(errp, local_err); + return; + } + + once = false; +} + +/* qmp_migrate_incoming comes from qemu qmp monitor command */ +void qmp_migrate_incoming(const char *uri, bool has_multi_fd_uri_list, + MigrateIncomingUriList *cap, Error **errp) +{ + Error *local_err = NULL; + static bool once = true; + + if (!once) { + error_setg(errp, "The incoming migration has already been started"); + return; + } + + if (!yank_register_instance(MIGRATION_YANK_INSTANCE, errp)) { + return; + } + + /* For migration thread */ + qemu_start_incoming_migration(uri, 0, 0, &local_err); + + /* For Multi-FD */ + int length = QAPI_LIST_LENGTH(cap); + init_multifd_array(length); + for (int i = 0; i < length; i++) { + const char *multifd_dst_uri = cap->value->destination_uri; + uint8_t multifd_channels = cap->value->multifd_channels; + qemu_start_incoming_migration(multifd_dst_uri, multifd_channels, + i, &local_err); + cap = cap->next; + } + + if (local_err) { + yank_unregister_instance(MIGRATION_YANK_INSTANCE); + error_propagate(errp, local_err); + return; + } + once = false; +} + void qmp_migrate_recover(const char *uri, Error **errp) { MigrationIncomingState *mis = migration_incoming_get_current(); @@ -2246,7 +2349,7 @@ void qmp_migrate_recover(const char *uri, Error **errp) * only re-setup the migration stream and poke existing migration * to continue using that newly established channel. */ - qemu_start_incoming_migration(uri, errp); + qemu_start_incoming_migration(uri, 0, 0, errp); } void qmp_migrate_pause(Error **errp) diff --git a/migration/migration.h b/migration/migration.h index cdad8aceaa..4cb81f7cf0 100644 --- a/migration/migration.h +++ b/migration/migration.h @@ -394,6 +394,8 @@ bool migration_is_setup_or_active(int state); bool migration_is_running(int state); void migrate_init(MigrationState *s); +void migrate_incoming(const char *uri, Error **errp); +void multi_fd_migrate_incoming(const char *uri_str, Error **errp); bool migration_is_blocked(Error **errp); /* True if outgoing migration has entered postcopy phase */ bool migration_in_postcopy(void); diff --git a/migration/socket.c b/migration/socket.c index f199430bc2..dab872a0fe 100644 --- a/migration/socket.c +++ b/migration/socket.c @@ -227,17 +227,17 @@ socket_incoming_migration_end(void *opaque) static void socket_start_incoming_migration_internal(SocketAddress *saddr, - Error **errp) + uint8_t multifd_count, Error **errp) { QIONetListener *listener = qio_net_listener_new(); MigrationIncomingState *mis = migration_incoming_get_current(); size_t i; - int num = 1; + uint8_t num = 1; qio_net_listener_set_name(listener, "migration-socket-listener"); if (migrate_use_multifd()) { - num = migrate_multifd_channels(); + num = multifd_count; } else if (migrate_postcopy_preempt()) { num = RAM_CHANNEL_MAX; } @@ -266,12 +266,13 @@ socket_start_incoming_migration_internal(SocketAddress *saddr, } } -void socket_start_incoming_migration(const char *str, Error **errp) +void socket_start_incoming_migration(const char *str, + uint8_t multifd_count, Error **errp) { Error *err = NULL; SocketAddress *saddr = socket_parse(str, &err); if (!err) { - socket_start_incoming_migration_internal(saddr, &err); + socket_start_incoming_migration_internal(saddr, multifd_count, &err); } qapi_free_SocketAddress(saddr); error_propagate(errp, err); diff --git a/migration/socket.h b/migration/socket.h index 0cbb7220ac..7c82278d33 100644 --- a/migration/socket.h +++ b/migration/socket.h @@ -33,7 +33,8 @@ void socket_send_channel_create(QIOTaskFunc f, void *data); QIOChannel *socket_send_channel_create_sync(Error **errp); int socket_send_channel_destroy(QIOChannel *send); -void socket_start_incoming_migration(const char *str, Error **errp); +void socket_start_incoming_migration(const char *str, uint8_t number, + Error **errp); void socket_start_outgoing_migration(MigrationState *s, const char *dst_str, Error **errp); diff --git a/qapi/migration.json b/qapi/migration.json index 456247af8f..3908c9096c 100644 --- a/qapi/migration.json +++ b/qapi/migration.json @@ -1526,14 +1526,36 @@ '*blk': 'bool', '*inc': 'bool', '*detach': 'bool', '*resume': 'bool' } } +## +# @MigrateIncomingUri: +# +# Information regarding which destination listening interface to be connected +# and number of multifd channels over that interface. +# +# @destination-uri: the Uniform Resource Identifier of the destination VM +# +# @multifd-channels: number of channels used to migrate data in parallel for +# for specific source-uri and destination-uri. +# Default value in this case is 2 (Since 4.0) +# +## +{ 'struct' : 'MigrateIncomingUri', + 'data' : { 'destination-uri' : 'str', + '*multifd-channels' : 'uint8'} } + ## # @migrate-incoming: # # Start an incoming migration, the qemu must have been started -# with -incoming defer +# with -incoming defer. qemu can also be started with optional +# -multi-fd-incoming defer for opening multifd listening sockets # # @uri: The Uniform Resource Identifier identifying the source or -# address to listen on +# address to listen on. +# +# @multi-fd-uri-list: list of pair of source and destination VM Uniform +# Resource Identifiers with number of multifd-channels +# for each pair. # # Returns: nothing on success # @@ -1545,19 +1567,31 @@ # compatible with -incoming and the format of the uri is already exposed # above libvirt. # -# 2. QEMU must be started with -incoming defer to allow migrate-incoming to +# 2. multi-fd-uri-list will have list of destination uri as listening sockets +# and multi-fd number of channels on each listening socket. +# +# 3. QEMU must be started with -incoming defer to allow migrate-incoming to # be used. # -# 3. The uri format is the same as for -incoming +# 4. multi-fd-uri-list format is not the same as for -multi-fd-incoming flag. +# For -multi-fd-incoming flag, it is a comma separated list of listener +# sockets with multifd channels. +# Example: -multi-fd-incoming "tcp::6900:4,tcp:11.0.0.0:7789:5". # # Example: # # -> { "execute": "migrate-incoming", -# "arguments": { "uri": "tcp::4446" } } +# "arguments": { +# "uri": "tcp::6789", +# "multi-fd-uri-list" : [ { "destination-uri" : "tcp::6900", +# "multifd-channels": 4}, +# { "destination-uri" : "tcp:11.0.0.0:7789", +# "multifd-channels": 5} ] } } # <- { "return": {} } # ## -{ 'command': 'migrate-incoming', 'data': {'uri': 'str' } } +{ 'command': 'migrate-incoming', + 'data': {'uri': 'str', '*multi-fd-uri-list': ['MigrateIncomingUri'] } } ## # @xen-save-devices-state: diff --git a/qapi/qapi-util.c b/qapi/qapi-util.c index 9672ac6018..a256f12ad2 100644 --- a/qapi/qapi-util.c +++ b/qapi/qapi-util.c @@ -15,6 +15,7 @@ #include "qapi/error.h" #include "qemu/ctype.h" #include "qapi/qmp/qerror.h" +#include "qapi/qapi-builtin-types.h" CompatPolicy compat_policy; @@ -157,7 +158,7 @@ int parse_qapi_name(const char *str, bool complete) * Produce a strList from a delimiter separated list. * A NULL or empty input string return NULL. */ -strList *strList_from_string(const char *in, char c) +struct strList *strList_from_string(const char *in, char c) { strList *res = NULL; strList **tail = &res; diff --git a/qemu-options.hx b/qemu-options.hx index 79e00916a1..5555f0d2fd 100644 --- a/qemu-options.hx +++ b/qemu-options.hx @@ -4479,6 +4479,24 @@ SRST to issuing the migrate\_incoming to allow the migration to begin. ERST +DEF("multi-fd-incoming", HAS_ARG, QEMU_OPTION_multi_fd_incoming, \ + "-multi-fd-incoming tcp:[host]:port[:channel][,to=maxport][,ipv4=on|off][,ipv6=on|off]\n" \ + "-multi-fd-incoming defer\n" \ + " wait for the URI to be specified via\n" \ + " multi_fd_migrate_incoming\n", + QEMU_ARCH_ALL) +SRST +``-multi-fd-incoming tcp:[host]:port[:channel][,to=maxport][,ipv4=on|off][,ipv6=on|off]`` + Prepare for multi-fd incoming migration, with multi-fd listening sockets + on that connection. Default number of multi-fd channels is 2. + +``-multi-fd-incoming defer`` + Wait for the URI to be specified via multi_fd_migrate\_incoming. The + monitor can be used to change settings (such as migration parameters) + prior to issuing the multi_fd_migrate\_incoming to allow the migration + to begin. +ERST + DEF("only-migratable", 0, QEMU_OPTION_only_migratable, \ "-only-migratable allow only migratable devices\n", QEMU_ARCH_ALL) SRST diff --git a/softmmu/vl.c b/softmmu/vl.c index aabd82e09a..07c33ded20 100644 --- a/softmmu/vl.c +++ b/softmmu/vl.c @@ -45,7 +45,7 @@ #include "sysemu/seccomp.h" #include "sysemu/tcg.h" #include "sysemu/xen.h" - +#include "migration/migration.h" #include "qemu/error-report.h" #include "qemu/sockets.h" #include "qemu/accel.h" @@ -160,6 +160,7 @@ typedef struct DeviceOption { static const char *cpu_option; static const char *mem_path; static const char *incoming; +static const char *multi_fd_incoming; static const char *loadvm; static const char *accelerators; static bool have_custom_ram_size; @@ -2312,6 +2313,11 @@ static void qemu_validate_options(const QDict *machine_opts) error_report("'preconfig' supports '-incoming defer' only"); exit(EXIT_FAILURE); } + if (multi_fd_incoming && preconfig_requested && + strcmp(multi_fd_incoming, "defer") != 0) { + error_report("'preconfig' supports '-multi-fd-incoming defer' only"); + exit(EXIT_FAILURE); + } #ifdef CONFIG_CURSES if (is_daemonized() && dpy.type == DISPLAY_TYPE_CURSES) { @@ -2600,7 +2606,7 @@ void qmp_x_exit_preconfig(Error **errp) if (incoming) { Error *local_err = NULL; if (strcmp(incoming, "defer") != 0) { - qmp_migrate_incoming(incoming, &local_err); + migrate_incoming(incoming, &local_err); if (local_err) { error_reportf_err(local_err, "-incoming %s: ", incoming); exit(1); @@ -2609,6 +2615,20 @@ void qmp_x_exit_preconfig(Error **errp) } else if (autostart) { qmp_cont(NULL); } + + if (multi_fd_incoming) { + Error *local_err = NULL; + if (strcmp(multi_fd_incoming, "defer") != 0) { + multi_fd_migrate_incoming(multi_fd_incoming, &local_err); + if (local_err) { + error_reportf_err(local_err, "-multi-fd-incoming %s: ", + multi_fd_incoming); + exit(1); + } + } + } else if (autostart) { + qmp_cont(NULL); + } } void qemu_init(int argc, char **argv, char **envp) @@ -3331,6 +3351,12 @@ void qemu_init(int argc, char **argv, char **envp) } incoming = optarg; break; + case QEMU_OPTION_multi_fd_incoming: + if (!multi_fd_incoming) { + runstate_set(RUN_STATE_INMIGRATE); + } + multi_fd_incoming = optarg; + break; case QEMU_OPTION_only_migratable: only_migratable = 1; break; From patchwork Thu Jul 21 19:56:17 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Het Gala X-Patchwork-Id: 12925740 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 97833C43334 for ; Thu, 21 Jul 2022 20:02:16 +0000 (UTC) Received: from localhost ([::1]:38670 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oEcND-00058T-G6 for qemu-devel@archiver.kernel.org; Thu, 21 Jul 2022 16:02:15 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:38606) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oEcHu-0004xm-U7 for qemu-devel@nongnu.org; Thu, 21 Jul 2022 15:56:46 -0400 Received: from mx0b-002c1b01.pphosted.com ([148.163.155.12]:18156) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oEcHr-0006ak-NV for qemu-devel@nongnu.org; Thu, 21 Jul 2022 15:56:45 -0400 Received: from pps.filterd (m0127842.ppops.net [127.0.0.1]) by mx0b-002c1b01.pphosted.com (8.17.1.5/8.17.1.5) with ESMTP id 26LIKx6n025446; Thu, 21 Jul 2022 12:56:42 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nutanix.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-transfer-encoding : content-type : mime-version; s=proofpoint20171006; bh=q8tnXKFAvEcaHbJYVt/Ib60A8gi2RFP2dCWAR7BpDV8=; b=mR+AHLfOF3y4mzgd6ivqRXwZ6faJ4C04Jd6uWJ+fpCZPJV+yfWjOy/O5uRdssLJS46Ij NLdD1y0od7z4SLuxnmJ3Ow6SBXBoXDxAs3cUX8vacYoijSQTppe/fKbob6dKoCK9v950 hlmjveWPZl5++KNhcdjeXCW3+GVbaz/jn3zlHdnYsCC2+LnRM8zjO8+g4AnyFIDUdzbs rDrxuTWHDlYEPRpEwLiVyGwEfGHnb+cTqQ0Hw5p399rKye8V3VlAHmug410tkl7L8x7+ BDV6iVAI73qz/ygnzHVnB5qteYE+rD0U1hcQz33i8XXf0B+5RzMfV29gzORUOGO5BoEE TQ== Received: from nam11-bn8-obe.outbound.protection.outlook.com (mail-bn8nam11lp2168.outbound.protection.outlook.com [104.47.58.168]) by mx0b-002c1b01.pphosted.com (PPS) with ESMTPS id 3hbvngm5f6-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 21 Jul 2022 12:56:42 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ZKMSiI6lQGnQQb9RUJwuxvO9zQsQxXj4XVsF4Hx45w8zT5qLug8BQeBM/DQb7KnhU2C8v8TL93vXTBwtY2RO4T4SCs6WCaWZSrAmtQtcwnu5iV0WEC33tVmfdrlg+RcPFDdJbawOpygLHLHv27T8uK+b3Y2qRn/BSLkZKTMchEihvGH9kYGEXaS6QR5mjWQWIfjBMOZ1x3nVtvwRlbNc3zEUiV8tEeB7skF0HA/MuavdMq4pMnQkdJErq8z/1Pbr+Zq5oEgkjwCQTJ40gxI/COKagqVcst6PovpsexDQ5XgjMoVjoKbuWNSCjfSZcs6g8EOikiQjRgd7lil36IqPQQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=q8tnXKFAvEcaHbJYVt/Ib60A8gi2RFP2dCWAR7BpDV8=; b=aWpc79BrXtSu7GvX82f4mWEOXiTfQN6ObBOOe1XJTK6BkAe51E+A9R+2hOf/zrPnJjnd2sB/hzhAiZFal1unvg1QBOjrQdeIv5+iEVfEMqP3LVnn+xNUuVH7ceclv401zvJze6BKLoCVBcKT0DXx1OTjtJOcmH1PXjIhsijpVowRI/4utYzuJaILqCafevu64clvt8bAXLe9zDnOi7ns5MO7xCWYkQAniI6zC8L38jeIaIHvPZU2YB/Zn9QxvhlbcWBLSKF6wTMKA0yhrwkcjf5TiwpI+CnVEW/wAXtzQQiQjg8/opcJ5DlX1Q0HhTMvGO2X9gAvzXKurpCFqqNASA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nutanix.com; dmarc=pass action=none header.from=nutanix.com; dkim=pass header.d=nutanix.com; arc=none Received: from BYAPR02MB4343.namprd02.prod.outlook.com (2603:10b6:a03:57::18) by DM5PR02MB2825.namprd02.prod.outlook.com (2603:10b6:3:108::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5438.14; Thu, 21 Jul 2022 19:56:41 +0000 Received: from BYAPR02MB4343.namprd02.prod.outlook.com ([fe80::1493:404b:3242:8e0f]) by BYAPR02MB4343.namprd02.prod.outlook.com ([fe80::1493:404b:3242:8e0f%5]) with mapi id 15.20.5438.023; Thu, 21 Jul 2022 19:56:41 +0000 From: Het Gala To: qemu-devel@nongnu.org Cc: quintela@redhat.com, dgilbert@redhat.com, pbonzini@redhat.com, berrange@redhat.com, armbru@redhat.com, eblake@redhat.com, prerna.saxena@nutanix.com, Het Gala , Manish Mishra Subject: [PATCH v2 4/7] multifd: HMP changes for multifd source and destination side Date: Thu, 21 Jul 2022 19:56:17 +0000 Message-Id: <20220721195620.123837-5-het.gala@nutanix.com> X-Mailer: git-send-email 2.22.3 In-Reply-To: <20220721195620.123837-1-het.gala@nutanix.com> References: <20220721195620.123837-1-het.gala@nutanix.com> X-ClientProxiedBy: BY5PR16CA0035.namprd16.prod.outlook.com (2603:10b6:a03:1a0::48) To BYAPR02MB4343.namprd02.prod.outlook.com (2603:10b6:a03:57::18) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: c137869a-b09d-4772-2e15-08da6b53212b X-MS-TrafficTypeDiagnostic: DM5PR02MB2825:EE_ x-proofpoint-crosstenant: true X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 7Kz63LEbWDrEYCFlOOsxn1jMquzu2ET4hilDrEtWnzpvVMRAdyot5tngvX2Ozw+tPpfiUhdZZ2IaaVU2LMcv55BZuHzQL4TqMeI7OhtQdFayGz4q89mmMnCPvD9AcJ3AeK/CPxCRm9J54lLo6yTh8wpmOz/EImbL8AiB+ULNh9ekmO7ppLjqLBWKf4YvLJfv20CV6n4nCkR0D/yNmUqK/pkXpGG67PffZztIRSfbBYq/u+u5SEbOQgch0r4Vq3HNdqaKTExHKX6mvvPApCXFO95Zz0WludvnodRL+Fx4yDWj9lPrlQDbFLs9+EqoWUeo03DLhLRKoJ7Oa8iZYg4TqnTzdOgNPfwovSY2freQBT0yuMwfu/4boe7HO1CR+Uqs2c5W8ClJy7IWnGKsc8vG+Ot8jgbYX4bR8PT4eK2k+ZrhSRy7oOh9tcz14RgDka4lGRL8JJbHR2UA5NZsT4iKp5UpxfOC+FZS2PjxibRCyM5F6SBxf40bkKbe6Fykm51QK5Tv772j2sKIgvN8M3rdf3ANR4wkzB5aqcuMLhuKEKaH9efGgim3delROdmwlCDO90JTGkXRt1tfRq/1/MFnY+GcmyJPNq9q5FOVavNI+1/n7rn27i/lYGIKo4D/K4s33JCQvCakgNcrksfHUwH4K2wm7jZCyL/eVKiy0y7pXGaPyP113gJU09/nOztL8U9Fxp3l48aHRV59tMIucvaMnzNwP0rrcFdIATlS6cnEN/MZgoHkk7txDJdC9ry/CgdWgU0t79vIu05bnlFqU7gZZ9lvSScHrAZyxQE+LOf7SoSEM7/QYL+eWfOSHFl2xbRdTI5l2UytF4Lj0fiwGl3X4Q== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:BYAPR02MB4343.namprd02.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230016)(39860400002)(136003)(346002)(376002)(396003)(366004)(38350700002)(38100700002)(1076003)(83380400001)(36756003)(186003)(2616005)(26005)(86362001)(107886003)(6512007)(316002)(54906003)(478600001)(66946007)(6916009)(66556008)(52116002)(6506007)(41300700001)(5660300002)(4326008)(8676002)(8936002)(44832011)(6486002)(6666004)(66476007)(2906002)(309714004); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: qtJGyxRilBMw/D1rnoznyfPw/gkOotSry4r+emWT+zHNBEg0+96XuV6LxXsNW+0naWX9drdNl5V0vKDZUcFIfhZVnEewizVi+kJVUiU9C64Gnihzdd0wEuo5gktpkJbHOJ0XeGHsj8wDCWJBcsEg7e8ZyTPg9MAiOxvqP4WJJWFvOpn1Sxee0v7fgkUK7Dfvw2PPBSP9ScFEvRZobvhYtCzxOy7n59MWdYnmtI3B2WN07V5YTwhv82moivE6TE6lt7+O5kNpvMoUSMixVimuLbyQt4mOoXl6r5u9B6PD3CAXOyvXYd81lhjv9FeiiqiN1hnKORWO1Kp0/mvTSF6L2EQmxQemFGLrgtQB9krde+cb2z07zPU8ZeqXwjZ34eXjAV14PA7EO83FKvGWYhjEY1+CYl9lqSsdCbMYdP1ZQhhKSH1euzFr38LV/TpQvrBA5ofppnDg/6TLsjWO8dGpOyL+NxHOKLIwfpTI+C/DlqFGCS8vOH6pm3J9drlg23EDgCbmZK1h/9k6f0czftJ8WVmQ1wWUxkAwcvvLYC33pExrQxVtPjLDdlo4Catqxb7QD7Wgj7ug3h2FhQGU6hEa90VTIxJqDYS8i/tUGxPthzDjNEUT4sb3euSSDwW1XeIOZ8n2SB9M0DpWvfimWa4XaIQlMXS9vFuAbeQjTwss9+YM/Qztx8M4eA6GXQjo5etKTqfOcDf6YXGrraizwM7rBHQax0C5Xzw0d+yrLB6LEIJTT4yJQVu4kZH95zPBJ8FkyweCbjgPEGMnze7injx11ytciVOWz3+crLNz4I7VQvX1XyHZTK/MXf34WQnMGSNK757Qzzz0srAZDWzqq1V0rUAFGK+LTL23xtPv/liW5CkH+o0MDzuoGHwVXilCskRY3ErkEVCIjnP7QpUBd2YQexgoowmNoI2Y8NxmqwiKj4KoZsrR3mTuW4OF7VfZ8jaEd+bV+zTOGWYJe9yTzBXgjpHb8z1Tqp5VEgHD/XCSZcAPghITzHZjev3YofPI1WZbfbn+U/gUdLlFk+Ysd7A26m0GYZuMHmY22ZALYGpelsiqKIXr6mazHjnXHwl6j5+bGu2YRnYfxLuodXzGFZlngeRTsP+TrTczrSIw1MWbxRJkZVj1MhAiAzPgQWa3ngL9oqiwewh9DoUdZDWN4WlWlF5uP4Ww5T/DBzRaUweoJ5FSLh8l7YMSBcdhtzhsB3Mq45XfFYD1lY8/WWjFsqL5dhReOeFMyZClv3gcgN6nG3CsQtyXh1dVZgw4s5fI649Efb0dkezbm5wQUzXX8ivep7sbHGhqqI/vAv7Fg8jGozoFWsN5dRIzXstadCAyN9ZyLEK9GM3qZ5A8d6ELOSl6kDa8DeGtWlYNwJo2jhUtgZDb0XyBNHApL0L1h7FTRl+36s/KOJqA3sMqbq3ORsuT3yB2IMMBmkZPW12HKBTdAhOfRpc6R9/fGQqBZ11u6L3IM44hAUYGXbivI336h58xB3EYmZmXrWfcTaUIjdKsruFrRl7gjlp6qyG67JbPHOveS/4tP34zQTsB1XkIyr/12QWk5wj5cYZrziQV8vlB/4RFn4xxpUU5BVHeQp1LEv45 X-OriginatorOrg: nutanix.com X-MS-Exchange-CrossTenant-Network-Message-Id: c137869a-b09d-4772-2e15-08da6b53212b X-MS-Exchange-CrossTenant-AuthSource: BYAPR02MB4343.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Jul 2022 19:56:41.0844 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: bb047546-786f-4de1-bd75-24e5b6f79043 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: v+CrINmLTTDy60pngi8Cl4UNY8Rgl09yNDGaT1z0KDsDxxhBgtIjadIpmBJ3reaMR1ZKla8nGtvD4uDWoXnp0A== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM5PR02MB2825 X-Proofpoint-GUID: kLBMetCWQJHiiXKQpSFxFRjiPSwL4bfq X-Proofpoint-ORIG-GUID: kLBMetCWQJHiiXKQpSFxFRjiPSwL4bfq X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.883,Hydra:6.0.517,FMLib:17.11.122.1 definitions=2022-07-21_27,2022-07-21_02,2022-06-22_01 X-Proofpoint-Spam-Reason: safe Received-SPF: pass client-ip=148.163.155.12; envelope-from=het.gala@nutanix.com; helo=mx0b-002c1b01.pphosted.com X-Spam_score_int: -21 X-Spam_score: -2.2 X-Spam_bar: -- X-Spam_report: (-2.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.082, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" i) hmp_migrate and hmp_migrate_incoming functions are modified according to the modified qmp monitor commands. Suggested-by: Manish Mishra Signed-off-by: Het Gala --- monitor/hmp-cmds.c | 34 +++++++++++++++++++++++++++++++--- 1 file changed, 31 insertions(+), 3 deletions(-) diff --git a/monitor/hmp-cmds.c b/monitor/hmp-cmds.c index 8d25fee4be..ec12b950db 100644 --- a/monitor/hmp-cmds.c +++ b/monitor/hmp-cmds.c @@ -60,6 +60,9 @@ #include "migration/misc.h" +/* Default number of multi-fd channels */ +#define DEFAULT_MIGRATE_MULTIFD_CHANNELS 2 + #ifdef CONFIG_SPICE #include #endif @@ -1127,8 +1130,19 @@ void hmp_migrate_incoming(Monitor *mon, const QDict *qdict) { Error *err = NULL; const char *uri = qdict_get_str(qdict, "uri"); + const char *dst_uri = qdict_get_str(qdict, "destination-uri"); + uint8_t multifd_channels = qdict_get_try_int(qdict, "multifd-channels", + DEFAULT_MIGRATE_MULTIFD_CHANNELS); + MigrateIncomingUriList *caps = NULL; + MigrateIncomingUri *value; + + value = g_malloc0(sizeof(*value)); + value->destination_uri = (char *)dst_uri; + value->multifd_channels = multifd_channels; + QAPI_LIST_PREPEND(caps, value); - qmp_migrate_incoming(uri, &err); + qmp_migrate_incoming(uri, !!caps, caps, &err); + qapi_free_MigrateIncomingUriList(caps); hmp_handle_error(mon, err); } @@ -1551,10 +1565,24 @@ void hmp_migrate(Monitor *mon, const QDict *qdict) bool inc = qdict_get_try_bool(qdict, "inc", false); bool resume = qdict_get_try_bool(qdict, "resume", false); const char *uri = qdict_get_str(qdict, "uri"); + + const char *src_uri = qdict_get_str(qdict, "source-uri"); + const char *dst_uri = qdict_get_str(qdict, "destination-uri"); + uint8_t multifd_channels = qdict_get_try_int(qdict, "multifd-channels", + DEFAULT_MIGRATE_MULTIFD_CHANNELS); Error *err = NULL; + MigrateUriParameterList *caps = NULL; + MigrateUriParameter *value; + + value = g_malloc0(sizeof(*value)); + value->source_uri = (char *)src_uri; + value->destination_uri = (char *)dst_uri; + value->multifd_channels = multifd_channels; + QAPI_LIST_PREPEND(caps, value); - qmp_migrate(uri, !!blk, blk, !!inc, inc, - false, false, true, resume, &err); + qmp_migrate(uri, !!caps, caps, !!blk, blk, !!inc, + inc, false, false, true, resume, &err); + qapi_free_MigrateUriParameterList(caps); if (hmp_handle_error(mon, err)) { return; } From patchwork Thu Jul 21 19:56:18 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Het Gala X-Patchwork-Id: 12925750 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id DA6B0C43334 for ; Thu, 21 Jul 2022 20:06:19 +0000 (UTC) Received: from localhost ([::1]:42976 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oEcR8-0008MV-OX for qemu-devel@archiver.kernel.org; Thu, 21 Jul 2022 16:06:18 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:38638) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oEcHx-00053F-BV for qemu-devel@nongnu.org; Thu, 21 Jul 2022 15:56:49 -0400 Received: from mx0b-002c1b01.pphosted.com ([148.163.155.12]:22786) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oEcHt-0006aw-HH for qemu-devel@nongnu.org; Thu, 21 Jul 2022 15:56:49 -0400 Received: from pps.filterd (m0127841.ppops.net [127.0.0.1]) by mx0b-002c1b01.pphosted.com (8.17.1.5/8.17.1.5) with ESMTP id 26LIKoY4019486; Thu, 21 Jul 2022 12:56:44 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nutanix.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-transfer-encoding : content-type : mime-version; s=proofpoint20171006; bh=sOyP9siBVjbvFR0Z5mhQ5bDp7hvEyxgWNv718nT/dcY=; b=n0hN2AnB0bbXXy8N7tO8NkKF+imITJa/+moiNUDuHJ9rIyxZdhIv2Qoih7gU4mOkAnB1 gze/0MvnMcEr3FmKn7I20ALSVW62fTxzy/wxDanbozyKVy4y8n4pbD3Iq9mMFpC9WOXC kuGhyrDQNCrTOADgJQkmJHy8zVVNCrEB1bMryVfbQup13BZKcuFK+nuviRCxLZltv84J ohdXmz8j1cHbJjq3QoT2Zwn4fgTzuIuqo2qCnT/uLYB3he7N9LJIjuAob/STOwgq7lWe mAmHuUxjFrEXxFQ+GssSSLjHe2aMIy+e+Mjf4bMHd+iEk42vb73QnkKHHb+a3zTCvdv/ 8g== Received: from nam11-bn8-obe.outbound.protection.outlook.com (mail-bn8nam11lp2169.outbound.protection.outlook.com [104.47.58.169]) by mx0b-002c1b01.pphosted.com (PPS) with ESMTPS id 3hbtv9v9ya-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 21 Jul 2022 12:56:44 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=N3ItxjxFx7kk9N6JRhkxpfeGJsH5ZG7mKfTK4+TVMGXuPixw3dUSACFPZ2xUwaCC/tBrMLrIb+nWoCqff4mgj/INEeRy6jP5ttb1MI0ugDJ/wwN+Yhrphp70Vh/YHbtXhjyAgSmyy6U6/rs7Q6W6khO9bEK/eYAhLDZQXjYbgg4SroqXnwZmXDOfUjZxKpUHUVE8aERhWsENK0oawGzfGrYtRZ5I4IKDyznzBsQgrxvh0KG16KKjpoifP4ahNPhgVMV86utF+bfyRKk51RNTK+wVovaq1plDnPr6nbRvXvZ85evuNDnZAZLhEu0vmh9YITA4kA3Nj72fuC3Lskeo+A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=sOyP9siBVjbvFR0Z5mhQ5bDp7hvEyxgWNv718nT/dcY=; b=P+1hVgbrus9Ho5M0wlfmZb+2bE5nn9npupgRvg0w6E8slzPQUeoio+vDCrRY+x5HvlGexhTlZSiFJXyaGHKS6f3EyROMGidh/8O/2EWlXsjGRbslcW45wV0tbkH6MMrlRcYeq1yLIxNBxoXuYhLI0qAsoKHPJ92gv71dQXeiRcX472FupKuHVKciisAoEzkL09iEOsU1pTaTpkBkIndJ8l+J8BHC2LTJlc21+XKj5/AwkggkC45t1J//RLng+8WSuShgXBewaXuV5o3kbeXU8LCrDSki1Bi+mqT0HDuImX0WRUm3+6URin0ys/YC3Z9B9fovgEUjyvDimb2UEFEhSg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nutanix.com; dmarc=pass action=none header.from=nutanix.com; dkim=pass header.d=nutanix.com; arc=none Received: from BYAPR02MB4343.namprd02.prod.outlook.com (2603:10b6:a03:57::18) by DM5PR02MB2825.namprd02.prod.outlook.com (2603:10b6:3:108::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5438.14; Thu, 21 Jul 2022 19:56:42 +0000 Received: from BYAPR02MB4343.namprd02.prod.outlook.com ([fe80::1493:404b:3242:8e0f]) by BYAPR02MB4343.namprd02.prod.outlook.com ([fe80::1493:404b:3242:8e0f%5]) with mapi id 15.20.5438.023; Thu, 21 Jul 2022 19:56:42 +0000 From: Het Gala To: qemu-devel@nongnu.org Cc: quintela@redhat.com, dgilbert@redhat.com, pbonzini@redhat.com, berrange@redhat.com, armbru@redhat.com, eblake@redhat.com, prerna.saxena@nutanix.com, Het Gala , Manish Mishra Subject: [PATCH v2 5/7] multifd: establishing connection between any non-default src and dest pair Date: Thu, 21 Jul 2022 19:56:18 +0000 Message-Id: <20220721195620.123837-6-het.gala@nutanix.com> X-Mailer: git-send-email 2.22.3 In-Reply-To: <20220721195620.123837-1-het.gala@nutanix.com> References: <20220721195620.123837-1-het.gala@nutanix.com> X-ClientProxiedBy: BY5PR16CA0035.namprd16.prod.outlook.com (2603:10b6:a03:1a0::48) To BYAPR02MB4343.namprd02.prod.outlook.com (2603:10b6:a03:57::18) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 0ad3c59a-d520-4d7c-d02a-08da6b532214 X-MS-TrafficTypeDiagnostic: DM5PR02MB2825:EE_ x-proofpoint-crosstenant: true X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: wwQm18WWqTKKeiWq30BEOmm56CUZuU80HmmJOwr6TpPBcj/r19ZARz/1d+RB2hKl1/cm2l6f0WVXsNwGC8oQ1if+OGJ7Rr44ipiObA9X8PULC7pb4k7TrrNPXZoJxqRS6MxbNbms0i94u6+cF/6X7ntN6c9xDuvXQ2zW6KmCR/ux7Ao7EWqHtWJX2Rno87vQmBksqDaOeCWjk/MgeMk25gOaRO9hfDuDgvJzOVteg0J8+zci/wxwTAZzVpXdYFHaB65jk2bv0h4do/hm+lAbZ7PTszPyrpR8xz8WvI8UyBMFelEvHO/FHWH2IlRTJ35N9XOonIlUTlraa5Wl1ApAu0Pg87BG723V3zNTWo36hlaGB4ySprV8cPwOiv7AV8fitfYd68iO+yiMr//ufsssTZx/2wObjkYmQjhThbxAQkq3be9RuAN6Qtnf4KikO3TWWIDdhuuj+KJ48kju8aUQ4qkIl0feW1pfdHs3BE8pXRfRmU41IUpQSHnFH/dPDqqmBt94heLc+dPKY5o1xy+0P+0OyV8jm/nn0tJFAD9G7C1dnb4KYGSdUSCY6P305otfxdM6KIqie6L8XsCMZUD3990tgyi9zC6fV1Sc2QVY3iG3ZMqd2lh5MWgJ1WD4MtiyEjkBC5x3fdq6RO1iCBTfo1mF+iEM7wxcUSZuCBfzalh6c+1/cvROyRrwexSlb8bBWPAcVmhDOTcbUwicKtSaWiVD2izydzIqnvq8gZaRNiiMiVZs3FIWZiM6PhdrFQCA0QQUzo7kNRckLC+levdU7g01Mry2HYiOEhpryu100mY= X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:BYAPR02MB4343.namprd02.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230016)(39860400002)(136003)(346002)(376002)(396003)(366004)(38350700002)(66574015)(38100700002)(1076003)(83380400001)(36756003)(186003)(2616005)(26005)(86362001)(107886003)(6512007)(316002)(54906003)(478600001)(66946007)(6916009)(66556008)(52116002)(6506007)(41300700001)(5660300002)(30864003)(4326008)(8676002)(8936002)(44832011)(6486002)(6666004)(66476007)(2906002); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: RqQDHmGWHhIgHk4cDWLIr950jqSMRai1doGIYfj5dkSxEOjm2bkhyw02iDZPquhaHijU/JwRmFlHu1JWFsJyqTbPW1VPWRmfxzWNzSlEo42Yz8K0DQmub5Wfuwi7hhOFFQXSawhNk3nmsagTy+OPifsBU7qdoIwtVAHG/8dvVJ2B6lfkWbdvVJAl+YZjvm9kxInKMyHUncwJ668X5XSIvGJARpW5fujbHRbBfTdCjdjTAUNiBiJ+6xobmzhTILSnhPS1nZ8VBL2iOFS3QBE8nX/FhsyC6RQvyC/aOpIAUH9IKhOgXIBST97lJtGUYPRMYuzfacyloe8PcfHK6Opj3vW8ckeAIZyv3DDI2UmmG/1xTzySzvUeVNrXPlIWDLeFOAZYJ0Sl7V8UYZatHi+IW9sxb+q0MRxJB2JEEgf+qXz9eLheNv7yMTykotGKDbRTB0vZIi/AkJt4t5zqpp6MIgwI74s+aXjNJwmKzzGIiXPN6MhVStJ/sAHPuOexqIDVLQ7UC2VwyqAshZmaqK6v41g7Voh6tdSWRp/EbVb5j6JzNEogWJ6Z3r1b7oE7JNF2Xn+7wlgaH09EcbytkVp+jywi8RFFpzmlVTSZ+9rcEMxaer9je/sBhwtGFSH08vHZgwfK37zdPNJCDmDqjR58eDRroJVP6368HSQCO5D2ec440dgDMhmuc0Wj/XjUpUTYJ2kzKi61/b7GrNtFFJI8iIEfKWTMwkdavGOux+cfjOZlMWi3rJrAAupYVkNb8G8shVRl2D4+D4jPGv9PQSF2unJpioXmaECSo0Cis5FgnHRBxb/Ll/7GxGaTxCV7nqlSV/y5q4G5FlpJCkmrZCIomL5d6C9iguqIFT8R6t9QIX2u7O02SNjZ6rOQYSUdpRSGerXHRw7VcE+YfhFnTDV7eEynLGgUmUIThGmOl8BDyYCZjxUidIJkvYzh19aRW4Nl1ZNd4Coixs7iqMkSL81ZD5cauNK6UEx3ckHgSVmD4QMT9Dx6wSWNkSRvaYinzXkJvgFPve9NbIcHmEAskNmgx6bu5rvmuncOKm9zh3pqdSmeXJ4G4aWEZ9tsXWj0Jr5nZLi2d9vl6PTGyU3w5bZ0CZrasbhm+lpfJhOKk0l1qra7dgb9+5BV78MNM9dzGtS9OjGr2ebzGJ3tAiw8RQW0vI7L/prFG8s7n/NFjE2FrgEdFciPG1b1gdFeO1sl63DKbcBQmwghDrvQO4dhpcVLKuJTyRMQPzcEhdnsSN0iNWefrjFdEENc6Xk8cWS7kOzgcLYYAjb67CWsN+X/XEHmb6TAKp9oA3/Bxt4cBho+wwRi/U8Z61/D1PRioN2lJlnv07rNY8lHyoqX9b+OMEJFq+PX7Nc6DJourQaU50j8LjmRPB2LicE7lhdUpgKBC94nCLG6ZMpjjeWWEZiNmY9TRY0yLTbr3xCUHODU6zPDXuPAc+6E1PW75uPTjAM1M74VE3sOGr514ra4bXAF+BsGNw+G1QFRazvazWr4XPDHMoooimb2fgrKZLv/wZzAE25vZeMdHcedGtfSfc3kOSBB5jLBJNcfRbohUZBJ0JpGa5d2rPVMoXPuO4WpUj36duHX X-OriginatorOrg: nutanix.com X-MS-Exchange-CrossTenant-Network-Message-Id: 0ad3c59a-d520-4d7c-d02a-08da6b532214 X-MS-Exchange-CrossTenant-AuthSource: BYAPR02MB4343.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Jul 2022 19:56:42.6155 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: bb047546-786f-4de1-bd75-24e5b6f79043 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: D+fdF/4vaz9ArI0PFOa+sQ8O4p36COX+wRIVX/HQOYpDkMGCZ7IIr1eN8HgRIdo63HVvAI9b4LirYRIFAZiSIw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM5PR02MB2825 X-Proofpoint-ORIG-GUID: 7tIMceh-LFBU9p8pnoO8DjJiqVeR46VH X-Proofpoint-GUID: 7tIMceh-LFBU9p8pnoO8DjJiqVeR46VH X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.883,Hydra:6.0.517,FMLib:17.11.122.1 definitions=2022-07-21_27,2022-07-21_02,2022-06-22_01 X-Proofpoint-Spam-Reason: safe Received-SPF: pass client-ip=148.163.155.12; envelope-from=het.gala@nutanix.com; helo=mx0b-002c1b01.pphosted.com X-Spam_score_int: -21 X-Spam_score: -2.2 X-Spam_bar: -- X-Spam_report: (-2.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.082, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" i) Binding of the socket to source ip address and port on the non-default interface has been implemented for multi-FD connection, which was not necessary earlier because the binding was on the default interface itself. ii) Created an end to end connection between all multi-FD source and destination pairs. Suggested-by: Manish Mishra Signed-off-by: Het Gala --- include/io/channel-socket.h | 44 ++++++++++++++++ include/qemu/sockets.h | 6 ++- io/channel-socket.c | 93 ++++++++++++++++++++++++++-------- migration/socket.c | 4 +- tests/unit/test-util-sockets.c | 16 +++--- util/qemu-sockets.c | 90 +++++++++++++++++++++++--------- 6 files changed, 196 insertions(+), 57 deletions(-) diff --git a/include/io/channel-socket.h b/include/io/channel-socket.h index 513c428fe4..8168866b06 100644 --- a/include/io/channel-socket.h +++ b/include/io/channel-socket.h @@ -211,6 +211,50 @@ void qio_channel_socket_dgram_async(QIOChannelSocket *ioc, GMainContext *context); +/** + * qio_channel_socket_connect_all_sync: + * @ioc: the socket channel object + * @dst_addr: the destination address to connect to + * @src_addr: the source address to be connected + * @errp: pointer to a NULL-initialized error object + * + * Attempt to connect to the address @dst_addr with @src_addr. + * This method will run in the foreground so the caller will not + * regain execution control until the connection is established or + * an error occurs. + */ +int qio_channel_socket_connect_all_sync(QIOChannelSocket *ioc, + SocketAddress *dst_addr, + SocketAddress *src_addr, + Error **errp); + +/** + * qio_channel_socket_connect_all_async: + * @ioc: the socket channel object + * @dst_addr: the destination address to connect to + * @callback: the function to invoke on completion + * @opaque: user data to pass to @callback + * @destroy: the function to free @opaque + * @context: the context to run the async task. If %NULL, the default + * context will be used. + * @src_addr: the source address to be connected + * + * Attempt to connect to the address @dst_addr with the @src_addr. + * This method will run in the background so the caller will regain + * execution control immediately. The function @callback + * will be invoked on completion or failure. The @dst_addr + * parameter will be copied, so may be freed as soon + * as this function returns without waiting for completion. + */ +void qio_channel_socket_connect_all_async(QIOChannelSocket *ioc, + SocketAddress *dst_addr, + QIOTaskFunc callback, + gpointer opaque, + GDestroyNotify destroy, + GMainContext *context, + SocketAddress *src_addr); + + /** * qio_channel_socket_get_local_address: * @ioc: the socket channel object diff --git a/include/qemu/sockets.h b/include/qemu/sockets.h index 038faa157f..dc863c3df8 100644 --- a/include/qemu/sockets.h +++ b/include/qemu/sockets.h @@ -33,7 +33,8 @@ int inet_ai_family_from_address(InetSocketAddress *addr, Error **errp); int inet_parse(InetSocketAddress *addr, const char *str, Error **errp); int inet_connect(const char *str, Error **errp); -int inet_connect_saddr(InetSocketAddress *saddr, Error **errp); +int inet_connect_saddr(InetSocketAddress *dst_addr, + InetSocketAddress *src_addr, Error **errp); NetworkAddressFamily inet_netfamily(int family); @@ -41,7 +42,8 @@ int unix_listen(const char *path, Error **errp); int unix_connect(const char *path, Error **errp); SocketAddress *socket_parse(const char *str, Error **errp); -int socket_connect(SocketAddress *addr, Error **errp); +int socket_connect(SocketAddress *dst_addr, SocketAddress *src_addr, + Error **errp); int socket_listen(SocketAddress *addr, int num, Error **errp); void socket_listen_cleanup(int fd, Error **errp); int socket_dgram(SocketAddress *remote, SocketAddress *local, Error **errp); diff --git a/io/channel-socket.c b/io/channel-socket.c index 74a936cc1f..142298469b 100644 --- a/io/channel-socket.c +++ b/io/channel-socket.c @@ -144,14 +144,15 @@ qio_channel_socket_new_fd(int fd, } -int qio_channel_socket_connect_sync(QIOChannelSocket *ioc, - SocketAddress *addr, - Error **errp) +int qio_channel_socket_connect_all_sync(QIOChannelSocket *ioc, + SocketAddress *dst_addr, + SocketAddress *src_addr, + Error **errp) { int fd; - trace_qio_channel_socket_connect_sync(ioc, addr); - fd = socket_connect(addr, errp); + trace_qio_channel_socket_connect_sync(ioc, dst_addr); + fd = socket_connect(dst_addr, src_addr, errp); if (fd < 0) { trace_qio_channel_socket_connect_fail(ioc); return -1; @@ -177,19 +178,78 @@ int qio_channel_socket_connect_sync(QIOChannelSocket *ioc, } -static void qio_channel_socket_connect_worker(QIOTask *task, - gpointer opaque) +struct ConnectData { + SocketAddress *dst_addr; + SocketAddress *src_addr; +}; + + +static void qio_channel_socket_all_worker_free(gpointer opaque) +{ + struct ConnectData *data = opaque; + if (!data) { + return; + } + qapi_free_SocketAddress(data->dst_addr); + qapi_free_SocketAddress(data->src_addr); + g_free(data); +} + +static void qio_channel_socket_connect_all_worker(QIOTask *task, + gpointer opaque) { QIOChannelSocket *ioc = QIO_CHANNEL_SOCKET(qio_task_get_source(task)); - SocketAddress *addr = opaque; + struct ConnectData *data = opaque; Error *err = NULL; - qio_channel_socket_connect_sync(ioc, addr, &err); + qio_channel_socket_connect_all_sync(ioc, data->dst_addr, + data->src_addr, &err); qio_task_set_error(task, err); } +void qio_channel_socket_connect_all_async(QIOChannelSocket *ioc, + SocketAddress *dst_addr, + QIOTaskFunc callback, + gpointer opaque, + GDestroyNotify destroy, + GMainContext *context, + SocketAddress *src_addr) +{ + QIOTask *task = qio_task_new( + OBJECT(ioc), callback, opaque, destroy); + struct ConnectData *data = g_new0(struct ConnectData, 1); + + data->dst_addr = QAPI_CLONE(SocketAddress, dst_addr); + if (src_addr) { + data->src_addr = QAPI_CLONE(SocketAddress, src_addr); + } else { + data->src_addr = NULL; + } + /* + * socket_connect() does a non-blocking connect(), but it + * still blocks in DNS lookups, so we must use a thread + */ + trace_qio_channel_socket_connect_async(ioc, dst_addr); + qio_task_run_in_thread(task, + qio_channel_socket_connect_all_worker, + data, + qio_channel_socket_all_worker_free, + context); +} + + +int qio_channel_socket_connect_sync(QIOChannelSocket *ioc, + SocketAddress *addr, + Error **errp) +{ + qio_channel_socket_connect_all_sync(ioc, addr, NULL, errp); + + return 0; +} + + void qio_channel_socket_connect_async(QIOChannelSocket *ioc, SocketAddress *addr, QIOTaskFunc callback, @@ -197,20 +257,9 @@ void qio_channel_socket_connect_async(QIOChannelSocket *ioc, GDestroyNotify destroy, GMainContext *context) { - QIOTask *task = qio_task_new( - OBJECT(ioc), callback, opaque, destroy); - SocketAddress *addrCopy; - - addrCopy = QAPI_CLONE(SocketAddress, addr); + qio_channel_socket_connect_all_async(ioc, addr, callback, opaque, + destroy, context, NULL); - /* socket_connect() does a non-blocking connect(), but it - * still blocks in DNS lookups, so we must use a thread */ - trace_qio_channel_socket_connect_async(ioc, addr); - qio_task_run_in_thread(task, - qio_channel_socket_connect_worker, - addrCopy, - (GDestroyNotify)qapi_free_SocketAddress, - context); } diff --git a/migration/socket.c b/migration/socket.c index dab872a0fe..69fda774ba 100644 --- a/migration/socket.c +++ b/migration/socket.c @@ -57,8 +57,8 @@ int outgoing_param_total_multifds(void) void socket_send_channel_create(QIOTaskFunc f, void *data) { QIOChannelSocket *sioc = qio_channel_socket_new(); - qio_channel_socket_connect_async(sioc, outgoing_args.saddr, - f, data, NULL, NULL); + qio_channel_socket_connect_all_async(sioc, outgoing_args.saddr, + f, data, NULL, NULL, NULL); } QIOChannel *socket_send_channel_create_sync(Error **errp) diff --git a/tests/unit/test-util-sockets.c b/tests/unit/test-util-sockets.c index 63909ccb2b..aa26630045 100644 --- a/tests/unit/test-util-sockets.c +++ b/tests/unit/test-util-sockets.c @@ -89,7 +89,7 @@ static void test_socket_fd_pass_name_good(void) addr.type = SOCKET_ADDRESS_TYPE_FD; addr.u.fd.str = g_strdup(mon_fdname); - fd = socket_connect(&addr, &error_abort); + fd = socket_connect(&addr, NULL, &error_abort); g_assert_cmpint(fd, !=, -1); g_assert_cmpint(fd, !=, mon_fd); close(fd); @@ -121,7 +121,7 @@ static void test_socket_fd_pass_name_bad(void) addr.type = SOCKET_ADDRESS_TYPE_FD; addr.u.fd.str = g_strdup(mon_fdname); - fd = socket_connect(&addr, &err); + fd = socket_connect(&addr, NULL, &err); g_assert_cmpint(fd, ==, -1); error_free_or_abort(&err); @@ -148,7 +148,7 @@ static void test_socket_fd_pass_name_nomon(void) addr.type = SOCKET_ADDRESS_TYPE_FD; addr.u.fd.str = g_strdup("myfd"); - fd = socket_connect(&addr, &err); + fd = socket_connect(&addr, NULL, &err); g_assert_cmpint(fd, ==, -1); error_free_or_abort(&err); @@ -172,7 +172,7 @@ static void test_socket_fd_pass_num_good(void) addr.type = SOCKET_ADDRESS_TYPE_FD; addr.u.fd.str = g_strdup_printf("%d", sfd); - fd = socket_connect(&addr, &error_abort); + fd = socket_connect(&addr, NULL, &error_abort); g_assert_cmpint(fd, ==, sfd); fd = socket_listen(&addr, 1, &error_abort); @@ -194,7 +194,7 @@ static void test_socket_fd_pass_num_bad(void) addr.type = SOCKET_ADDRESS_TYPE_FD; addr.u.fd.str = g_strdup_printf("%d", sfd); - fd = socket_connect(&addr, &err); + fd = socket_connect(&addr, NULL, &err); g_assert_cmpint(fd, ==, -1); error_free_or_abort(&err); @@ -217,7 +217,7 @@ static void test_socket_fd_pass_num_nocli(void) addr.type = SOCKET_ADDRESS_TYPE_FD; addr.u.fd.str = g_strdup_printf("%d", STDOUT_FILENO); - fd = socket_connect(&addr, &err); + fd = socket_connect(&addr, NULL, &err); g_assert_cmpint(fd, ==, -1); error_free_or_abort(&err); @@ -246,10 +246,10 @@ static gpointer unix_client_thread_func(gpointer user_data) for (i = 0; i < ABSTRACT_SOCKET_VARIANTS; i++) { if (row->expect_connect[i]) { - fd = socket_connect(row->client[i], &error_abort); + fd = socket_connect(row->client[i], NULL, &error_abort); g_assert_cmpint(fd, >=, 0); } else { - fd = socket_connect(row->client[i], &err); + fd = socket_connect(row->client[i], NULL, &err); g_assert_cmpint(fd, ==, -1); error_free_or_abort(&err); } diff --git a/util/qemu-sockets.c b/util/qemu-sockets.c index 13b5b197f9..491e2f2bc9 100644 --- a/util/qemu-sockets.c +++ b/util/qemu-sockets.c @@ -358,8 +358,10 @@ listen_ok: ((rc) == -EINPROGRESS) #endif -static int inet_connect_addr(const InetSocketAddress *saddr, - struct addrinfo *addr, Error **errp) +static int inet_connect_addr(const InetSocketAddress *dst_addr, + const InetSocketAddress *src_addr, + struct addrinfo *addr, struct addrinfo *saddr, + Error **errp) { int sock, rc; @@ -371,8 +373,28 @@ static int inet_connect_addr(const InetSocketAddress *saddr, } socket_set_fast_reuse(sock); + /* to bind the socket if src_addr is available */ + + if (src_addr) { + struct sockaddr_in servaddr; + + /* bind to a specific interface in the internet domain */ + /* to make sure the sin_zero filed is cleared */ + memset(&servaddr, 0, sizeof(servaddr)); + + servaddr.sin_family = AF_INET; + servaddr.sin_addr.s_addr = inet_addr(src_addr->host); + servaddr.sin_port = 0; + + if (bind(sock, (struct sockaddr *)&servaddr, sizeof(servaddr)) < 0) { + error_setg_errno(errp, errno, "Failed to bind socket"); + return -1; + } + } + /* connect to peer */ do { + rc = 0; if (connect(sock, addr->ai_addr, addr->ai_addrlen) < 0) { rc = -errno; @@ -380,8 +402,14 @@ static int inet_connect_addr(const InetSocketAddress *saddr, } while (rc == -EINTR); if (rc < 0) { - error_setg_errno(errp, errno, "Failed to connect to '%s:%s'", - saddr->host, saddr->port); + if (src_addr) { + error_setg_errno(errp, errno, "Failed to connect '%s:%s' to " + "'%s:%s'", dst_addr->host, dst_addr->port, + src_addr->host, src_addr->port); + } else { + error_setg_errno(errp, errno, "Failed to connect '%s:%s'", + dst_addr->host, dst_addr->port); + } closesocket(sock); return -1; } @@ -446,41 +474,55 @@ static struct addrinfo *inet_parse_connect_saddr(InetSocketAddress *saddr, * * Returns: -1 on error, file descriptor on success. */ -int inet_connect_saddr(InetSocketAddress *saddr, Error **errp) +int inet_connect_saddr(InetSocketAddress *dst_addr, + InetSocketAddress *src_addr, Error **errp) { Error *local_err = NULL; - struct addrinfo *res, *e; + struct addrinfo *res_d, *res_s, *e, *x; int sock = -1; - res = inet_parse_connect_saddr(saddr, errp); - if (!res) { + res_d = inet_parse_connect_saddr(dst_addr, errp); + if (!res_d) { return -1; } - for (e = res; e != NULL; e = e->ai_next) { + if (src_addr) { + res_s = inet_parse_connect_saddr(src_addr, errp); + if (!res_s) { + return -1; + } + } + + for (e = res_d; e != NULL; e = e->ai_next) { error_free(local_err); local_err = NULL; #ifdef HAVE_IPPROTO_MPTCP - if (saddr->has_mptcp && saddr->mptcp) { + if (dst_addr->has_mptcp && dst_addr->mptcp) { e->ai_protocol = IPPROTO_MPTCP; } #endif + for (x = res_s; x != NULL; x = x->ai_next) { + if (!src_addr || e->ai_family == x->ai_family) { - sock = inet_connect_addr(saddr, e, &local_err); - if (sock >= 0) { - break; + sock = inet_connect_addr(dst_addr, src_addr, + e, x, &local_err); + if (sock >= 0) { + break; + } + } } } - freeaddrinfo(res); + freeaddrinfo(res_d); + freeaddrinfo(res_s); if (sock < 0) { error_propagate(errp, local_err); return sock; } - if (saddr->keep_alive) { + if (dst_addr->keep_alive) { int val = 1; int ret = setsockopt(sock, SOL_SOCKET, SO_KEEPALIVE, &val, sizeof(val)); @@ -506,7 +548,7 @@ static int inet_dgram_saddr(InetSocketAddress *sraddr, Error *err = NULL; /* lookup peer addr */ - memset(&ai,0, sizeof(ai)); + memset(&ai,0,sizeof(ai)); ai.ai_flags = AI_CANONNAME | AI_V4MAPPED | AI_ADDRCONFIG; ai.ai_family = inet_ai_family_from_address(sraddr, &err); ai.ai_socktype = SOCK_DGRAM; @@ -727,7 +769,7 @@ int inet_connect(const char *str, Error **errp) InetSocketAddress *addr = g_new(InetSocketAddress, 1); if (!inet_parse(addr, str, errp)) { - sock = inet_connect_saddr(addr, errp); + sock = inet_connect_saddr(addr, NULL, errp); } qapi_free_InetSocketAddress(addr); return sock; @@ -1182,25 +1224,27 @@ int socket_address_parse_named_fd(SocketAddress *addr, Error **errp) return 0; } -int socket_connect(SocketAddress *addr, Error **errp) +int socket_connect(SocketAddress *dst_addr, + SocketAddress *src_addr, Error **errp) { int fd; - switch (addr->type) { + switch (dst_addr->type) { case SOCKET_ADDRESS_TYPE_INET: - fd = inet_connect_saddr(&addr->u.inet, errp); + fd = inet_connect_saddr(&dst_addr->u.inet, src_addr ? + &src_addr->u.inet : NULL, errp); break; case SOCKET_ADDRESS_TYPE_UNIX: - fd = unix_connect_saddr(&addr->u.q_unix, errp); + fd = unix_connect_saddr(&dst_addr->u.q_unix, errp); break; case SOCKET_ADDRESS_TYPE_FD: - fd = socket_get_fd(addr->u.fd.str, errp); + fd = socket_get_fd(dst_addr->u.fd.str, errp); break; case SOCKET_ADDRESS_TYPE_VSOCK: - fd = vsock_connect_saddr(&addr->u.vsock, errp); + fd = vsock_connect_saddr(&dst_addr->u.vsock, errp); break; default: From patchwork Thu Jul 21 19:56:19 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Het Gala X-Patchwork-Id: 12925749 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id BC231C43334 for ; Thu, 21 Jul 2022 20:05:46 +0000 (UTC) Received: from localhost ([::1]:42088 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oEcQb-0007lc-Q7 for qemu-devel@archiver.kernel.org; Thu, 21 Jul 2022 16:05:45 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:38636) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oEcHw-00052M-Jv for qemu-devel@nongnu.org; Thu, 21 Jul 2022 15:56:48 -0400 Received: from mx0b-002c1b01.pphosted.com ([148.163.155.12]:3018) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oEcHu-0006b4-M8 for qemu-devel@nongnu.org; Thu, 21 Jul 2022 15:56:48 -0400 Received: from pps.filterd (m0127844.ppops.net [127.0.0.1]) by mx0b-002c1b01.pphosted.com (8.17.1.5/8.17.1.5) with ESMTP id 26LIKtfn027882; Thu, 21 Jul 2022 12:56:45 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nutanix.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-transfer-encoding : content-type : mime-version; s=proofpoint20171006; bh=Jf+Mn09f0Jt3Jmxo4/DD0fulIHWMmHuh/55weR3xCew=; b=p+9f/1wVx+znVBKAGSVbP0uQ1MHdWqfdy5D5T7u8vBTNNXsjvA1PH09nB+PW+e9RhTpI vCqyYHtGIR+2vZy4yOuNCwWA6W4Y5lkS5HQzuiUy1Ufgg2k/cE4zM1LdFV1aSj1WYPd9 e7EMPRfpOrJ5jpoHD+lQ2CDBza/Xz+MW0Qbg4XCcLqCb3fXtBjtxPcgEnZ+9tuBsd/g9 YEVFJFqFsumIAiiHVy2+lla6eb4WIpvGvSPyzOhtwPw2LgwMOc6TyhZwg+Iv39cXiEvY ghfhzPTdSpepQToYEdWTIpJPOWIe3yqWRAA0QCqxviCkasw0pApw7r+P10epae11S8IU rw== Received: from nam11-bn8-obe.outbound.protection.outlook.com (mail-bn8nam11lp2169.outbound.protection.outlook.com [104.47.58.169]) by mx0b-002c1b01.pphosted.com (PPS) with ESMTPS id 3hbvv244dh-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 21 Jul 2022 12:56:45 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=FS5mQ3CKPGBpfTazdSGG0Jzq+oRU16pIjaZgGMMRZw5g0vXuijqnaxo3rqRoRKjaVF7XhoMkoEM2qHNksUNZDyAs/rKBHGn/dSj3KKgEb4hB6dItU7s7ZzgUZQNTXectfOAMxBqCOCbKwPIvXlIJgF7AOOJmAoYCkkpHHqy9OrJRZhWrRK0N6nwVMc/UCS8PEmQ4ySvnPBupRgeSJbishav2Z5V3UJMFywJmdOqBr9uXdzC+W1WOenCq212UlVUozUJYNtPCU3kwmYdZJCM4S1oAKxeY3Tq3u+svlFzwnIk3drPf/MzaQ7PYdDAy0Vl1HJNC2+n10xyL3gDoZ3ClxQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=Jf+Mn09f0Jt3Jmxo4/DD0fulIHWMmHuh/55weR3xCew=; b=XQugevJVj0JXMslklk68ONzZF6WAvyKmWyw9/gyhbXhgVjFQsPNMJU1WmMdyRO8fqNIK1qaeJqIIH2eE5QGPjng4bKKK9HaM+WajgnEWlR/vqSJXhps8rP8o9ayZUHSOL0iMDgyBYn+l1CdFcXbEmPrCKYk80do3hf8H2WQXRQsTRVG7N01XfWAh/6AGaWT3I2fnMaGaVUMq/yTvFePxkOPkJpQ4izTdu67AB7ET+A6B3ebxZJmu+wXyEw4Q9oLQ9M5+fTpofrmRBzInpCZtoFKGVjtp26Nm1RaHziMx8fHJcDrG9fKqAkMM7Hn1522IBJ7Q+GjxBBcgbnrQfBHDsg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nutanix.com; dmarc=pass action=none header.from=nutanix.com; dkim=pass header.d=nutanix.com; arc=none Received: from BYAPR02MB4343.namprd02.prod.outlook.com (2603:10b6:a03:57::18) by DM5PR02MB2825.namprd02.prod.outlook.com (2603:10b6:3:108::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5438.14; Thu, 21 Jul 2022 19:56:44 +0000 Received: from BYAPR02MB4343.namprd02.prod.outlook.com ([fe80::1493:404b:3242:8e0f]) by BYAPR02MB4343.namprd02.prod.outlook.com ([fe80::1493:404b:3242:8e0f%5]) with mapi id 15.20.5438.023; Thu, 21 Jul 2022 19:56:44 +0000 From: Het Gala To: qemu-devel@nongnu.org Cc: quintela@redhat.com, dgilbert@redhat.com, pbonzini@redhat.com, berrange@redhat.com, armbru@redhat.com, eblake@redhat.com, prerna.saxena@nutanix.com, Het Gala , Manish Mishra Subject: [PATCH v2 6/7] muitlfd: Correcting nit : whitespace error changes in qemu-sockets.c file Date: Thu, 21 Jul 2022 19:56:19 +0000 Message-Id: <20220721195620.123837-7-het.gala@nutanix.com> X-Mailer: git-send-email 2.22.3 In-Reply-To: <20220721195620.123837-1-het.gala@nutanix.com> References: <20220721195620.123837-1-het.gala@nutanix.com> X-ClientProxiedBy: BY5PR16CA0035.namprd16.prod.outlook.com (2603:10b6:a03:1a0::48) To BYAPR02MB4343.namprd02.prod.outlook.com (2603:10b6:a03:57::18) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: de1cee82-971a-488e-0fea-08da6b5322fc X-MS-TrafficTypeDiagnostic: DM5PR02MB2825:EE_ x-proofpoint-crosstenant: true X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: G1+pNYITKdXtpCi7TZ01HMFbDNGn7B/13AjFV/I9btKNYsBLr1i41meJ74bd+cHp6FsXT9FOaKSyPCrJxRyMZUfQ8Laq/dXP9xLUicfpG8OYH05vMGBMPla2YvXxcuAAYgNcGo4/jf8HN95NYu0qwIPpTECrUqXcNN6dAW4ir1K/+nDul+p+swTDFEwH5YWdwo7tIutBEsdLZFmXZVaI282hebq/4Fsppv/SL4f+TCMpDe/lo6G2pDbzGmxs3+gA+XCnl7Jris3dAEtu29lkkwk4KLymbTc79drNhB0grr9wvDKnddzSk/mxfXXIVlR6I5jTRrlgSn8sHm6KtJn7HA2wXZS9p4cdspqA+wKbbUCpMgVC6MIYF6nOxb+K1Bb3No6R+nNu3sVLXVCg6jGnMogLzIM+wz7IHS2h4X25lmfa/GUdhOvgp2gWhdGluRcsAdXgGHpdnquQdo9RcquUbAcx5sXWTUCBKJeKgLJ1yb2BIDYG+OVsDM1U/vcNzRrZbNZPAMrPr584/n14NssKaLr95T9g3inE3qw4g4GM16H6NMqFHGL/YjlTw9BlGrddrWdFkL/nnhqG07oO5uGvpiAhmhMXHyqjz6V6cQMVPXdgCPOxbF3EYy+rAmviyt0cR6Hos5JQUH3TSLHRgdEsnWuRAlDct3hups5mE3XakseHp4IkBcsKFhgvzcl520Y1JNBsHNbVRFyLRFBa0yk1+77Y+9QiFuirQ+G/6k/+1u1MEWSF5xsxTfsD3j7bTUKY0Xu0cbDRYWBS49LbGBI3mQaLdm7p8PcJKWe68+qNhqA= X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:BYAPR02MB4343.namprd02.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230016)(39860400002)(136003)(346002)(376002)(396003)(366004)(38350700002)(38100700002)(1076003)(83380400001)(36756003)(186003)(2616005)(26005)(86362001)(107886003)(6512007)(316002)(54906003)(478600001)(66946007)(6916009)(66556008)(52116002)(6506007)(41300700001)(5660300002)(4326008)(8676002)(8936002)(44832011)(6486002)(6666004)(66476007)(2906002); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: pGJo+FDcUFpAt88y5T5289t92gbCdSmVnKRbPnqqqFiyjfJRGdo0/CI6GzGn55S3dD/MhAIKp8wiLJ9S0E3Ahw9xY/wRQTFU0MR7DaUSjFYbfsgZn02nOJXcsFuJkpmGV7OH0RODpJri8wU5Zn8YZ/0c676lbncOTk6kT41gz27pq386YtimaWw5Wnmpv0V6aANAaexvVmRIzvTtsLD5VsVGDGEGjzEVjTSBoVhVCe5Aaz4xkvNgP6LHnSpddZOSJnlpc5zYZcBL+IHYS2ZfjCYKO2m1/AjKO9FSZ+2Fldbk279WUXdkTOC10Gz2o+uxaH72Jh+9cWHcPPHfpfta8E0J1v9/QXJnbv2vV4SEo2UEe+40b9MxvDlmyoPQdTcLQWD8hWIuUP7d0SwmGhiudmeArHmdKIP23REcKPueUR9dzfbSs1Jx57NrX967B0gdYZp3ODMslL+6YImahIYOEH0ntMCYuDb3QolLzqYxIMXa3LBY0eb+5zWSZMqolwxGNJ/+yjT/3IXMVIJXyEnYzc69htn5heYrycwndBtdmXB//nFkI8IiYGQ1TXFLUKHVTY+11U0uyoM2/wvfV8yMiNqqSDN8bNbVaZJ2rXTMIJTDGYtRdxAzqwScUK/5GC2UYC+aDYp8hMrD+pvvB3yRn5WmwwBL+U1sE68QXz30jMQk7aHaemkb4xmzJbbvSOyVJex3/NQ5GIdg7GCFGw3iWY3OCnA/fWIH9MrkNWPdAjQhpg1lNGYFWAIQ6lsCdVMiiHQVMKFpo28WtLy7xTOR51376YqFQIetgW0LZytIVdFqqweEGtdP+o7poDNOVJjNFs4Hwo2ZUZ5+0hXTuKnrMXXo80Nf7gtom0SIiXUOq+CjRU2+7evS9LymQVaSNK7QuKyhX2BL889qJm8YerhJxCZkc1dTMN8wj8/zDEzvSgNLk9MGQQBnTfLsZuaUKX0Edm4bFUeOUrFrPwG8yyNIkBxf4uf5s9PGf4abYDEUmexq/WqVCbIX8H9DCyEupRgi7khKFwJ4eCspxjzfmUgVhAJifQ0vLUDsc0NJsgZu0rGRRAF5DN6aBwxh4LHtvBZBciFCNOvSTOJne8L1km/lW72/shwm8oBtPA1g/2edskET/RfkH+bKt8D6ENYgyY1h2WsAbA0XJexJoKr7wUK88bOb9UoQ5f7e+bHLrDquboO3lK+Ddn+UZfXcOThjqoljJWkBsnPlzbOAH/dbaF8sv0ymW1TFgQPek1UTZw1HRGWEyowEv0xYPTJl2TmiG/Tku2Cl6F50h1W+SMGCC02k/OJEOEBOiS6jVwgjf4yEGIaEzmr4bmYGykjQ8oNo7s3swbRNXpZefKmw3z9VBSADNL3EkdygoFX98Br0mb1Ner3P5AXw2Xm4GYbFNTGz4jYfN1UXe6GhdobwowSrdenbq3wDOUwWLa86WQ2Gw8DTOW800NnxypsSapHOoIvtEkcPkBnkmvXRS5xmW+IGP4lVYs6MtGnLYqVERlj0pLSpJucspk70pa53fSSFt4q7w8x4LUGiWRB9obD8zdMV+EAQzDHM1QaXVS/KUjB8YxRQLO8cDOj6ovsFSLqhL6YyAX4B X-OriginatorOrg: nutanix.com X-MS-Exchange-CrossTenant-Network-Message-Id: de1cee82-971a-488e-0fea-08da6b5322fc X-MS-Exchange-CrossTenant-AuthSource: BYAPR02MB4343.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Jul 2022 19:56:44.1623 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: bb047546-786f-4de1-bd75-24e5b6f79043 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: ud4H+T8moOeLTzcRAWTUKqiTWokqMof3mitF0kzMJlbSPGD8BbYt2fD27+6SBx9GzdR4fYsdJZ37Ui+rVCPZdg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM5PR02MB2825 X-Proofpoint-ORIG-GUID: mAd_fflclkwPmjy2oonnBJAqiyYWUWKv X-Proofpoint-GUID: mAd_fflclkwPmjy2oonnBJAqiyYWUWKv X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.883,Hydra:6.0.517,FMLib:17.11.122.1 definitions=2022-07-21_27,2022-07-21_02,2022-06-22_01 X-Proofpoint-Spam-Reason: safe Received-SPF: pass client-ip=148.163.155.12; envelope-from=het.gala@nutanix.com; helo=mx0b-002c1b01.pphosted.com X-Spam_score_int: -21 X-Spam_score: -2.2 X-Spam_bar: -- X-Spam_report: (-2.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.082, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" Suggested-by: Manish Mishra Signed-off-by: Het Gala --- util/qemu-sockets.c | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/util/qemu-sockets.c b/util/qemu-sockets.c index 491e2f2bc9..724c081e6c 100644 --- a/util/qemu-sockets.c +++ b/util/qemu-sockets.c @@ -52,10 +52,10 @@ static int inet_getport(struct addrinfo *e) switch (e->ai_family) { case PF_INET6: - i6 = (void*)e->ai_addr; + i6 = (void *)e->ai_addr; return ntohs(i6->sin6_port); case PF_INET: - i4 = (void*)e->ai_addr; + i4 = (void *)e->ai_addr; return ntohs(i4->sin_port); default: return 0; @@ -69,11 +69,11 @@ static void inet_setport(struct addrinfo *e, int port) switch (e->ai_family) { case PF_INET6: - i6 = (void*)e->ai_addr; + i6 = (void *)e->ai_addr; i6->sin6_port = htons(port); break; case PF_INET: - i4 = (void*)e->ai_addr; + i4 = (void *)e->ai_addr; i4->sin_port = htons(port); break; } @@ -210,9 +210,9 @@ static int inet_listen_saddr(InetSocketAddress *saddr, int num, Error **errp) { - struct addrinfo ai,*res,*e; + struct addrinfo ai, *res, *e; char port[33]; - char uaddr[INET6_ADDRSTRLEN+1]; + char uaddr[INET6_ADDRSTRLEN + 1]; char uport[33]; int rc, port_min, port_max, p; int slisten = -1; @@ -226,7 +226,7 @@ static int inet_listen_saddr(InetSocketAddress *saddr, return -1; } - memset(&ai,0, sizeof(ai)); + memset(&ai, 0, sizeof(ai)); ai.ai_flags = AI_PASSIVE; if (saddr->has_numeric && saddr->numeric) { ai.ai_flags |= AI_NUMERICHOST | AI_NUMERICSERV; @@ -282,8 +282,8 @@ static int inet_listen_saddr(InetSocketAddress *saddr, e->ai_protocol = IPPROTO_MPTCP; } #endif - getnameinfo((struct sockaddr*)e->ai_addr,e->ai_addrlen, - uaddr,INET6_ADDRSTRLEN,uport,32, + getnameinfo((struct sockaddr *)e->ai_addr, e->ai_addrlen, + uaddr, INET6_ADDRSTRLEN, uport, 32, NI_NUMERICHOST | NI_NUMERICSERV); port_min = inet_getport(e); @@ -548,7 +548,7 @@ static int inet_dgram_saddr(InetSocketAddress *sraddr, Error *err = NULL; /* lookup peer addr */ - memset(&ai,0,sizeof(ai)); + memset(&ai, 0, sizeof(ai)); ai.ai_flags = AI_CANONNAME | AI_V4MAPPED | AI_ADDRCONFIG; ai.ai_family = inet_ai_family_from_address(sraddr, &err); ai.ai_socktype = SOCK_DGRAM; @@ -575,7 +575,7 @@ static int inet_dgram_saddr(InetSocketAddress *sraddr, } /* lookup local addr */ - memset(&ai,0, sizeof(ai)); + memset(&ai, 0, sizeof(ai)); ai.ai_flags = AI_PASSIVE; ai.ai_family = peer->ai_family; ai.ai_socktype = SOCK_DGRAM; @@ -616,7 +616,7 @@ static int inet_dgram_saddr(InetSocketAddress *sraddr, } /* connect to peer */ - if (connect(sock,peer->ai_addr,peer->ai_addrlen) < 0) { + if (connect(sock, peer->ai_addr, peer->ai_addrlen) < 0) { error_setg_errno(errp, errno, "Failed to connect to '%s:%s'", addr, port); goto err; From patchwork Thu Jul 21 19:56:20 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Het Gala X-Patchwork-Id: 12925738 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id EBFB0C43334 for ; Thu, 21 Jul 2022 19:58:36 +0000 (UTC) Received: from localhost ([::1]:58566 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oEcJf-0007vL-RD for qemu-devel@archiver.kernel.org; Thu, 21 Jul 2022 15:58:35 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:38656) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oEcI1-0005BW-2u for qemu-devel@nongnu.org; Thu, 21 Jul 2022 15:56:53 -0400 Received: from mx0a-002c1b01.pphosted.com ([148.163.151.68]:58670) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oEcHz-0006bV-4M for qemu-devel@nongnu.org; Thu, 21 Jul 2022 15:56:52 -0400 Received: from pps.filterd (m0127840.ppops.net [127.0.0.1]) by mx0a-002c1b01.pphosted.com (8.17.1.5/8.17.1.5) with ESMTP id 26LILQ1B000706; Thu, 21 Jul 2022 12:56:48 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nutanix.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-transfer-encoding : content-type : mime-version; s=proofpoint20171006; bh=sZTXp567vcy7/0uIP/3KWo0eV+kVn7bZBPPSysGJoj0=; b=KpnBRrANioPVTW7pLX+ZPp+6Yn82G3vBda3Q7BLzK40iMzVVN8YkIlwux4/CJ9qyJ8Cy k/d7vPfU2XyRtcVsCvxV5oedTs49ims3DJVsKyT0Pa0fkrtxaeA+MnB2rbTtzFrlLsva HG1uFbfy1+wfWwfK1w9bwyTJCGsKqdc7KzysusxfA9zu6ThiowtBDsOe7StZR9UNv0cM uArRNsS0SiUb5WJ4xBlYiJ8wJAiGfy4aG+RagLzbPiDvdOunMiVv9NJkzBInuqa/6OqE chO854gpMneyDaXoFWv+Gqm5UiGwc4URsdJ33wDazeWXkcr3BqSJFM6svLPSq49q8swT DA== Received: from nam11-bn8-obe.outbound.protection.outlook.com (mail-bn8nam11lp2169.outbound.protection.outlook.com [104.47.58.169]) by mx0a-002c1b01.pphosted.com (PPS) with ESMTPS id 3hbsnv4901-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 21 Jul 2022 12:56:48 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=RAoVleewxj/2V+zjf/Hr0CBJ7N5/2coSubGlBRrf4Y0MZafKdNwePEGFnccVQ8qobBDKuiJ9xSHbQ2wQrBSpM7/TeVP6xyL8D3v8wA85dDdzh4MUdTXEHYxoluge7EIarCnXpVLxunlk/Kt6maeIlZIKnCXGQNzaSfND377YrHgzLdrkTRIRdhv9Q5DhFEk5P4KfKb6pu6O74bYRvN67E4M+xz1o6KVFTRPmhmxeFhLREJdVsI0Y5jF6R6i4jzAmWqFzVZH/nGPnae7xBtoPHdmB/jk4UzxHLYEF93etqMnAPEFkcafDD642jna6OwpIukq0IFS814+ohLcV5ZdkXg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=sZTXp567vcy7/0uIP/3KWo0eV+kVn7bZBPPSysGJoj0=; b=VfXBfkiSQJGZQSejfCsaaZF+Q7+BcTenAAuIfqywaaEpDGJLFeVw4W0c3aRT3rUgoMQOhPRtBLF/jg7izcpRR6rPKo1EdCscUpGU3TJNtu41JMMS3TJMW2TcbO/ek5oG40AW2U12R4hTly7V1EXdVAv3ZZtfG4IJp6HMLy4kTun1QygmBf/1Fn85Uo6+/HZQ/u6py/t9aqrFL/s1prOofefp6qHy1hSSYBQn5yd0iadR5enpGIKQsuJxcnZgbYbIdgpulp9V3Yu07+6f6pTw1PmNuyEWh6i1VDHN/vjyo0gUJWtWvSnzRPuNLgFSYjmsYAvKSLPQWYzE0l+zGSFaWQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nutanix.com; dmarc=pass action=none header.from=nutanix.com; dkim=pass header.d=nutanix.com; arc=none Received: from BYAPR02MB4343.namprd02.prod.outlook.com (2603:10b6:a03:57::18) by DM5PR02MB2825.namprd02.prod.outlook.com (2603:10b6:3:108::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5438.14; Thu, 21 Jul 2022 19:56:46 +0000 Received: from BYAPR02MB4343.namprd02.prod.outlook.com ([fe80::1493:404b:3242:8e0f]) by BYAPR02MB4343.namprd02.prod.outlook.com ([fe80::1493:404b:3242:8e0f%5]) with mapi id 15.20.5438.023; Thu, 21 Jul 2022 19:56:46 +0000 From: Het Gala To: qemu-devel@nongnu.org Cc: quintela@redhat.com, dgilbert@redhat.com, pbonzini@redhat.com, berrange@redhat.com, armbru@redhat.com, eblake@redhat.com, prerna.saxena@nutanix.com, Het Gala , Manish Mishra Subject: [PATCH v2 7/7] multifd: adding support for multifd connections dynamically Date: Thu, 21 Jul 2022 19:56:20 +0000 Message-Id: <20220721195620.123837-8-het.gala@nutanix.com> X-Mailer: git-send-email 2.22.3 In-Reply-To: <20220721195620.123837-1-het.gala@nutanix.com> References: <20220721195620.123837-1-het.gala@nutanix.com> X-ClientProxiedBy: BY5PR16CA0035.namprd16.prod.outlook.com (2603:10b6:a03:1a0::48) To BYAPR02MB4343.namprd02.prod.outlook.com (2603:10b6:a03:57::18) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: db5de992-6718-47d9-d6ee-08da6b53240b X-MS-TrafficTypeDiagnostic: DM5PR02MB2825:EE_ x-proofpoint-crosstenant: true X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: A/Jv7H9Ws9um0SjZpH2ZOPS781LHaSNcqYLH3ZUGvWjqX69G2FCHIDJYkAclAMh+SI9pCWWxYrHPaKO2AzGRkrZ7VYX1kjhjdD8JnXmC81oEQm1NtLQOzY9ugo1FYYRva8AM81zHsWyPwZpO7sJ709E3qFnu1p1oT6tljiACTgvdeStgrqsNg56GfKInDEdJRy2ldmqbXZFfeVYYzbDrC9rYw+NA9Wx3m/oVT1zs5n2k2Dqs3v98JwNyFirfMqJ1nmUHVU9UoCMWa2NXsFQcN+rMde394gmKLxmZOHnH5EV7nDyzIdPHedMUSZN6GDEBms22IwtAQ8L05/eU7ppByy19HzxAy0GONvp+xLH0sf275iZl8pji6vN0bAjYadxdiqfbrxbRgpnpT0xrom0jeuP14OfIl5rtgy2MkTUblEv/yKAbMbxCT7AcF5lMf31oeC0Le/OByHTJL230zkiB6d2r/WSCJCssZ6aEAtk83Wor9MWKsDkP87b4wP4abZpbOYG2xS8y2VoF07U1/gCrju971ypuDtxSzP2mKINch6kf0XW/XoZhylyEWe87bK9g8R+ZgOQPvsHtscUoaTUDQXDUPFwn1YnchjYr7T6Kx9gCVHwMM96rZhqKIED662pEVUV5gl1Of+wQDVZStD800fdA5Grc7815qCKtd0CjGP8GQEL3qV6hQ88PovLejrGaVN/DdSY3ThWxpxqxuaH6naUgBPQhd+j7i2TGJnv4qvqurk9lUJulicA5hGUIactLTP2rHacfhIGkb8gN7fqqyE8c4SGhDrkeryFSuJcvulU= X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:BYAPR02MB4343.namprd02.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230016)(39860400002)(136003)(346002)(376002)(396003)(366004)(38350700002)(38100700002)(1076003)(83380400001)(36756003)(186003)(2616005)(26005)(86362001)(107886003)(6512007)(316002)(54906003)(478600001)(66946007)(6916009)(66556008)(52116002)(6506007)(41300700001)(5660300002)(4326008)(8676002)(8936002)(44832011)(6486002)(6666004)(66476007)(2906002); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: w2UA6IN4Diz+o+VNcRdJrqI0NOnuyGo0KcwGfHqUmIJsj3enUzf94bqlVmuV0oTILhJhIJuxVtCFim3GghR3dL8w1JmufdKor+Fut8tY2ryIQJh2TKtYzf7Rh2vXggKWoY9sGqXkn/uzy3MfkrRs9mXqGJtZrhP8+Vow1Nurc5DFQXj9x1U8RLBAwAKrdH7jCPIf+DZsI9v2CS+wjhSjpQpEbnrYBMR675ek1ZUJclzglzjDkytvaRG8AhhSbNBzrnxQABm6/MVJnoJS+SzwD5lvv+3/qz9XMTLY6imiRmV15zKakYNJhTISc4dkMW/YgyZRcMXGjDKFFXZ/MnSUjw8GCYjNUaWJUEuuR7/suftUEIlk29pM+TuH5dKc27XIGXUMAUi3R9KSsFp4OXXVI4gIH9075hVa5dc/+ihY+pLALZdHGD5CJORIyqJFAwckBKK03i/OkvAVcgXZA1j2IcaxboL3plY2+63/jPh0lhmq3xtN79XMABwd3Tg2Fd16ctB+PUJE2gNXNSYqS6/2QuEOhN2OKy66Dtd62Y0DBxtS6rS8XVvuXoBOZPGIdWpxjpay8T/YNzJxOMsr3SNEyaBtt/IwfmqZx89vnfOdnpM2AKyuVRKCaSN9/rPlU69NqG5wMmYDP7rjtr7mNUC9gp3WjJRUaLjcq15FGAf0ItlcZCldVyT2WcnNbmwSEaJ6+2NY9Gqrn+J1QUxZk0Sapc3ICD8njWbTFFogs1HZ8XwV8I9OD5mO+M73S4tlwlq5PWDfI3iSJGYezVtvDOYUp1IJ3T3/FO+EOPBda3seiUcRjVVCXopKfJ/+Iya0Ac4TPeKbv5SkT7kCH/VXskQQUGkF0qGzsny2eKqM5KSwQFttFd5RT6e8syMDKXXLWn6HqQm2C6dMf978xpPokauZVOI8bE6z0Pnt5ms7s7+jxANwlqgsxtc9MJoBpzS+srlJimgYtkkgRrndWpIyOMYEaJ5W7vtV2I2RHlctDX43wvsSZ4rC7/AOCNgmBQBQL4JjtJ4A1tTxnvlw/R8usnCDR8VLHgPxwDVcP/SyPbPHtZhKoM9SyGUWcfNyQwe7su6Nq7+A4nmGi4gpjUybwxN41FnH9X0bfqpOk2I54bNLXWuHvFOPAoG88ivhGyt+1QvJql3l+inSyDq4GrgRkpF1aDatGdbFYq4zIQMW9JUvdYFaZikEIOuX7j0lMgnjUa4WxXX8MrxwKXj5fT1iWNWnZnA3vty4tcXCLxyLCVdM/F4iIHQZkYeqlUUemII87ZVaCmMe8kz8/5UQSl92UHFtVduwOLqHh3lAdDH5vTPrRU120AS61/wBvVZdxLGjc1yzxH6Efk+DPF1JypvlW2zm/lH+pSs7TvCfvtUefZ0MhXjL3gL4ZUGwvpZygL8zGISOP62yPP/NPaSpuqAQICBzIy27lHErkH5L5VN/gaVKsGEXhybl1HxHXjObCGbE811CBXNAIGzHmI37BM2/axOrwOXbw30/esooW4oua8dNzpknlrcP2XUdIuQW4wkIQNUT7SrG4zrtVIv5dIVc0MV54LsrrZsEA8esOFcDjSfxdD6JR3sihye2JSN1j/WOxv75 X-OriginatorOrg: nutanix.com X-MS-Exchange-CrossTenant-Network-Message-Id: db5de992-6718-47d9-d6ee-08da6b53240b X-MS-Exchange-CrossTenant-AuthSource: BYAPR02MB4343.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Jul 2022 19:56:45.9278 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: bb047546-786f-4de1-bd75-24e5b6f79043 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: csbI6hCRGbWD0h2blYqpO69lK55o/AtcClWUNjhiCqRUj94j2ROm8Q/yCGBbEkoVcyjGwMpii+RtZuUZhObrDA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM5PR02MB2825 X-Proofpoint-GUID: rwTbE4B69u0v8PjHOff8JDdb2oqI9MvZ X-Proofpoint-ORIG-GUID: rwTbE4B69u0v8PjHOff8JDdb2oqI9MvZ X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.883,Hydra:6.0.517,FMLib:17.11.122.1 definitions=2022-07-21_27,2022-07-21_02,2022-06-22_01 X-Proofpoint-Spam-Reason: safe Received-SPF: pass client-ip=148.163.151.68; envelope-from=het.gala@nutanix.com; helo=mx0a-002c1b01.pphosted.com X-Spam_score_int: -21 X-Spam_score: -2.2 X-Spam_bar: -- X-Spam_report: (-2.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.082, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" i) Dynamically decide appropriate source and destination ip pairs for the corresponding multifd channel to be connected. Suggested-by: Manish Mishra Signed-off-by: Het Gala --- migration/multifd.c | 6 +++--- migration/socket.c | 37 ++++++++++++++++++++++--------------- migration/socket.h | 3 ++- 3 files changed, 27 insertions(+), 19 deletions(-) diff --git a/migration/multifd.c b/migration/multifd.c index 586ddc9d65..2d9d50239a 100644 --- a/migration/multifd.c +++ b/migration/multifd.c @@ -903,7 +903,7 @@ int multifd_save_setup(Error **errp) int thread_count; uint32_t page_count = MULTIFD_PACKET_SIZE / qemu_target_page_size(); uint8_t i; - + int idx; if (!migrate_use_multifd()) { return 0; } @@ -945,8 +945,8 @@ int multifd_save_setup(Error **errp) } else { p->write_flags = 0; } - - socket_send_channel_create(multifd_new_send_channel_async, p); + idx = multifd_index(i); + socket_send_channel_create(multifd_new_send_channel_async, p, idx); } for (i = 0; i < thread_count; i++) { diff --git a/migration/socket.c b/migration/socket.c index 69fda774ba..b81b819584 100644 --- a/migration/socket.c +++ b/migration/socket.c @@ -28,10 +28,6 @@ #include "trace.h" #include "postcopy-ram.h" -struct SocketOutgoingArgs { - SocketAddress *saddr; -} outgoing_args; - struct SocketArgs { struct SrcDestAddr address; uint8_t multifd_channels; @@ -54,11 +50,30 @@ int outgoing_param_total_multifds(void) return total_multifd_channels; } -void socket_send_channel_create(QIOTaskFunc f, void *data) + +int multifd_index(int i) +{ + int length = outgoing_migrate_params.socket_args_arr_len; + int j = 0; + int runn_sum = 0; + while (j < length) { + runn_sum += outgoing_migrate_params.socket_args[j].multifd_channels; + if (i >= runn_sum) { + j++; + } else { + break; + } + } + return j; +} + + void socket_send_channel_create(QIOTaskFunc f, void *data, int idx) { QIOChannelSocket *sioc = qio_channel_socket_new(); - qio_channel_socket_connect_all_async(sioc, outgoing_args.saddr, - f, data, NULL, NULL, NULL); + qio_channel_socket_connect_all_async(sioc, + outgoing_migrate_params.socket_args[idx].address.dst_addr, + f, data, NULL, NULL, + outgoing_migrate_params.socket_args[idx].address.src_addr); } QIOChannel *socket_send_channel_create_sync(Error **errp) @@ -83,10 +98,6 @@ int socket_send_channel_destroy(QIOChannel *send) { /* Remove channel */ object_unref(OBJECT(send)); - if (outgoing_args.saddr) { - qapi_free_SocketAddress(outgoing_args.saddr); - outgoing_args.saddr = NULL; - } g_free(outgoing_migrate_params.socket_args); outgoing_migrate_params.socket_args = NULL; outgoing_migrate_params.socket_args_arr_len = 0; @@ -142,10 +153,6 @@ socket_start_outgoing_migration_internal(MigrationState *s, data->s = s; - /* in case previous migration leaked it */ - qapi_free_SocketAddress(outgoing_args.saddr); - outgoing_args.saddr = saddr; - if (saddr->type == SOCKET_ADDRESS_TYPE_INET) { data->hostname = g_strdup(saddr->u.inet.host); } diff --git a/migration/socket.h b/migration/socket.h index 7c82278d33..80d03fc7d6 100644 --- a/migration/socket.h +++ b/migration/socket.h @@ -29,7 +29,8 @@ typedef struct SrcDestAddr { int outgoing_param_total_multifds(void); -void socket_send_channel_create(QIOTaskFunc f, void *data); +int multifd_index(int i); +void socket_send_channel_create(QIOTaskFunc f, void *data, int idx); QIOChannel *socket_send_channel_create_sync(Error **errp); int socket_send_channel_destroy(QIOChannel *send);