From patchwork Thu Jul 1 09:11:26 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zhang Chen X-Patchwork-Id: 12353769 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.8 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id E1953C11F64 for ; Thu, 1 Jul 2021 09:19:38 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id AB3E460249 for ; Thu, 1 Jul 2021 09:19:38 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org AB3E460249 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=intel.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:53320 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lysrB-0001Ui-St for qemu-devel@archiver.kernel.org; Thu, 01 Jul 2021 05:19:37 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:42432) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lysqH-0007T2-GX for qemu-devel@nongnu.org; Thu, 01 Jul 2021 05:18:41 -0400 Received: from mga09.intel.com ([134.134.136.24]:16185) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lysqF-00007Y-OU for qemu-devel@nongnu.org; Thu, 01 Jul 2021 05:18:41 -0400 X-IronPort-AV: E=McAfee;i="6200,9189,10031"; a="208454115" X-IronPort-AV: E=Sophos;i="5.83,313,1616482800"; d="scan'208";a="208454115" Received: from fmsmga007.fm.intel.com ([10.253.24.52]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 01 Jul 2021 02:18:38 -0700 X-IronPort-AV: E=Sophos;i="5.83,313,1616482800"; d="scan'208";a="420335032" Received: from unknown (HELO localhost.localdomain) ([10.239.13.19]) by fmsmga007-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 01 Jul 2021 02:18:36 -0700 From: Zhang Chen To: Jason Wang Subject: [PULL V2 2/6] util/qemu-sockets.c: Add inet_parse_base to handle InetSocketAddressBase Date: Thu, 1 Jul 2021 17:11:26 +0800 Message-Id: <20210701091130.3022093-3-chen.zhang@intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210701091130.3022093-1-chen.zhang@intel.com> References: <20210701091130.3022093-1-chen.zhang@intel.com> MIME-Version: 1.0 Received-SPF: pass client-ip=134.134.136.24; envelope-from=chen.zhang@intel.com; helo=mga09.intel.com X-Spam_score_int: -41 X-Spam_score: -4.2 X-Spam_bar: ---- X-Spam_report: (-4.2 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_DNSWL_MED=-2.3, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Lukas Straub , =?utf-8?q?Daniel_P=2E_Berrang=C3=A9?= , Li Zhijian , qemu-dev , Markus Armbruster , Zhang Chen , Gerd Hoffmann , Eric Blake , "Dr. David Alan Gilbert" Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" No need to carry the flag all the time in many scenarios. Signed-off-by: Zhang Chen --- include/qemu/sockets.h | 1 + util/qemu-sockets.c | 14 ++++++++++++++ 2 files changed, 15 insertions(+) diff --git a/include/qemu/sockets.h b/include/qemu/sockets.h index 0c34bf2398..3a0f8fa8f2 100644 --- a/include/qemu/sockets.h +++ b/include/qemu/sockets.h @@ -32,6 +32,7 @@ int socket_set_fast_reuse(int fd); int inet_ai_family_from_address(InetSocketAddress *addr, Error **errp); int inet_parse(InetSocketAddress *addr, const char *str, Error **errp); +int inet_parse_base(InetSocketAddressBase *addr, const char *str, Error **errp); int inet_connect(const char *str, Error **errp); int inet_connect_saddr(InetSocketAddress *saddr, Error **errp); diff --git a/util/qemu-sockets.c b/util/qemu-sockets.c index 080a240b74..cd7fa0b884 100644 --- a/util/qemu-sockets.c +++ b/util/qemu-sockets.c @@ -713,6 +713,20 @@ int inet_parse(InetSocketAddress *addr, const char *str, Error **errp) return 0; } +int inet_parse_base(InetSocketAddressBase *base, const char *str, Error **errp) +{ + InetSocketAddress *addr; + int ret = 0; + + addr = g_new0(InetSocketAddress, 1); + ret = inet_parse(addr, str, errp); + + base->host = addr->host; + base->port = addr->port; + + g_free(addr); + return ret; +} /** * Create a blocking socket and connect it to an address.