From patchwork Fri Aug 30 11:56:32 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steven Sistare X-Patchwork-Id: 13785027 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 6053ECA0FE4 for ; Fri, 30 Aug 2024 11:58:05 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sk0FL-0007bw-U1; Fri, 30 Aug 2024 07:56:55 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sk0FI-0007N9-KI for qemu-devel@nongnu.org; Fri, 30 Aug 2024 07:56:52 -0400 Received: from mx0b-00069f02.pphosted.com ([205.220.177.32]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sk0FF-0002rB-Oz for qemu-devel@nongnu.org; Fri, 30 Aug 2024 07:56:51 -0400 Received: from pps.filterd (m0333520.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 47U7tVM5014619; Fri, 30 Aug 2024 11:56:40 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h= from:to:cc:subject:date:message-id:in-reply-to:references; s= corp-2023-11-20; bh=lTkdRg+GBBI4tZWpYzx20rweRuoFZnawHnP0zLPVa+0=; b= EBqQfFVUGFeavupf7pa2syaeY9MGcRFJU4tGtnP5uJB0LvINND+i/W50DJhApLWo 3w6CwImhgh7ksH5jvRY7TNj9gdDmj7OLQTun5xEdikgEtGRQgwcFqSKJV/v09l4O iILWspN3kIXQ4fOML1ZSZ+iP5qbhfbhOK5kpWJlvoEMjD7q8+ene8B7yEsMcsF7q W1FzVgY4hnAk/wPGYYrkTpyg4JYcudBkTWP1Lm9LOIKVOhQsKjU0VK5NiUXGC29t SNpPwSh2Jxgh4ReiFucMLESMk829GHuo+l831VsVcFyCYgHo9PJR/ryOSTZcY/NH nFYghu3ZS4O3QY3lPJpU1A== Received: from iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta03.appoci.oracle.com [130.35.103.27]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 419pugxg18-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 30 Aug 2024 11:56:40 +0000 (GMT) Received: from pps.filterd (iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com [127.0.0.1]) by iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (8.18.1.2/8.18.1.2) with ESMTP id 47UA5gQc036621; Fri, 30 Aug 2024 11:56:40 GMT Received: from pps.reinject (localhost [127.0.0.1]) by iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 4189jpg9b9-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 30 Aug 2024 11:56:39 +0000 Received: from iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 47UBucxI028887; Fri, 30 Aug 2024 11:56:39 GMT Received: from ca-dev63.us.oracle.com (ca-dev63.us.oracle.com [10.211.8.221]) by iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTP id 4189jpg9ae-2; Fri, 30 Aug 2024 11:56:39 +0000 From: Steve Sistare To: qemu-devel@nongnu.org Cc: "Michael S. Tsirkin" , Jason Wang , Peter Xu , Fabiano Rosas , Euan Turner , Steve Sistare Subject: [RFC V1 1/6] Revert "vhost-backend: remove vhost_kernel_reset_device()" Date: Fri, 30 Aug 2024 04:56:32 -0700 Message-Id: <1725018997-363706-2-git-send-email-steven.sistare@oracle.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1725018997-363706-1-git-send-email-steven.sistare@oracle.com> References: <1725018997-363706-1-git-send-email-steven.sistare@oracle.com> X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1039,Hydra:6.0.680,FMLib:17.12.28.16 definitions=2024-08-30_06,2024-08-30_01,2024-05-17_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 spamscore=0 mlxscore=0 suspectscore=0 phishscore=0 malwarescore=0 bulkscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2407110000 definitions=main-2408300090 X-Proofpoint-GUID: 2p8eCbpzXUOL3tlXJerM-UIXTz5--a0y X-Proofpoint-ORIG-GUID: 2p8eCbpzXUOL3tlXJerM-UIXTz5--a0y Received-SPF: pass client-ip=205.220.177.32; envelope-from=steven.sistare@oracle.com; helo=mx0b-00069f02.pphosted.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_MED=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, 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-bounces+qemu-devel=archiver.kernel.org@nongnu.org This reverts commit e6383293eb01928692047e617665a742cca87e23. The reset function is needed for CPR. Signed-off-by: Steve Sistare Signed-off-by: Steve Sistare --- hw/virtio/vhost-backend.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/hw/virtio/vhost-backend.c b/hw/virtio/vhost-backend.c index 833804d..9b75141 100644 --- a/hw/virtio/vhost-backend.c +++ b/hw/virtio/vhost-backend.c @@ -221,6 +221,11 @@ static int vhost_kernel_set_owner(struct vhost_dev *dev) return vhost_kernel_call(dev, VHOST_SET_OWNER, NULL); } +static int vhost_kernel_reset_device(struct vhost_dev *dev) +{ + return vhost_kernel_call(dev, VHOST_RESET_OWNER, NULL); +} + static int vhost_kernel_get_vq_index(struct vhost_dev *dev, int idx) { assert(idx >= dev->vq_index && idx < dev->vq_index + dev->nvqs); @@ -345,6 +350,7 @@ const VhostOps kernel_ops = { .vhost_get_features = vhost_kernel_get_features, .vhost_set_backend_cap = vhost_kernel_set_backend_cap, .vhost_set_owner = vhost_kernel_set_owner, + .vhost_reset_device = vhost_kernel_reset_device, .vhost_get_vq_index = vhost_kernel_get_vq_index, .vhost_vsock_set_guest_cid = vhost_kernel_vsock_set_guest_cid, .vhost_vsock_set_running = vhost_kernel_vsock_set_running, From patchwork Fri Aug 30 11:56:33 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steven Sistare X-Patchwork-Id: 13785024 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 AB5E4CA0FE4 for ; Fri, 30 Aug 2024 11:57:29 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sk0FH-0007Nh-VI; Fri, 30 Aug 2024 07:56:52 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sk0FD-0007JK-JQ for qemu-devel@nongnu.org; Fri, 30 Aug 2024 07:56:47 -0400 Received: from mx0b-00069f02.pphosted.com ([205.220.177.32]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sk0FA-0002rI-Aq for qemu-devel@nongnu.org; Fri, 30 Aug 2024 07:56:47 -0400 Received: from pps.filterd (m0333520.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 47U8J4QJ024207; Fri, 30 Aug 2024 11:56:41 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h= from:to:cc:subject:date:message-id:in-reply-to:references; s= corp-2023-11-20; bh=YykiUFUS3fjKKIu1+BZQB3cUpbX+vd0IQVv6qwmtIgE=; b= fH6eIu9dEx6BwCD4cyxN6lO4p+APhwqF/V8i/0v69KoX5FykkPNMsWvMBKQ36Hfh 7LOBqQAkYPKWwIFXpkAx1Zda3BMRPWQRj5wB341smNaic/YZvSu48lnO4ZhgskgA cKpPapkSOJpfxG7eM1huW0d8tcgE5m/y3ir+4gylZ7qZd2tXAmhiu98Ce3dCiC9e Vb/zys3UpnCxls84vDFtSImSQWjfvOQk0ntAmDjbssXzBvVmI/JFpL1lnbSo+C+z Sz7pNYN9tN+60UzyzfRmWjZK9gJETG6Vhhn8fzEx/yhU1lzt5GSu5Wq3JFXzMXRu Hu3/lZEn9fKEaQSJJWhXBQ== Received: from iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta03.appoci.oracle.com [130.35.103.27]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 419pugxg19-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 30 Aug 2024 11:56:41 +0000 (GMT) Received: from pps.filterd (iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com [127.0.0.1]) by iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (8.18.1.2/8.18.1.2) with ESMTP id 47UBTMmO036757; Fri, 30 Aug 2024 11:56:41 GMT Received: from pps.reinject (localhost [127.0.0.1]) by iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 4189jpg9bn-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 30 Aug 2024 11:56:40 +0000 Received: from iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 47UBucxK028887; Fri, 30 Aug 2024 11:56:40 GMT Received: from ca-dev63.us.oracle.com (ca-dev63.us.oracle.com [10.211.8.221]) by iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTP id 4189jpg9ae-3; Fri, 30 Aug 2024 11:56:40 +0000 From: Steve Sistare To: qemu-devel@nongnu.org Cc: "Michael S. Tsirkin" , Jason Wang , Peter Xu , Fabiano Rosas , Euan Turner , Steve Sistare Subject: [RFC V1 2/6] tap: common return label Date: Fri, 30 Aug 2024 04:56:33 -0700 Message-Id: <1725018997-363706-3-git-send-email-steven.sistare@oracle.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1725018997-363706-1-git-send-email-steven.sistare@oracle.com> References: <1725018997-363706-1-git-send-email-steven.sistare@oracle.com> X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1039,Hydra:6.0.680,FMLib:17.12.28.16 definitions=2024-08-30_06,2024-08-30_01,2024-05-17_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 spamscore=0 mlxscore=0 suspectscore=0 phishscore=0 malwarescore=0 bulkscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2407110000 definitions=main-2408300090 X-Proofpoint-GUID: Cx-TmqVeJ5LluYpH3yQJxGrHt7HkuqUD X-Proofpoint-ORIG-GUID: Cx-TmqVeJ5LluYpH3yQJxGrHt7HkuqUD Received-SPF: pass client-ip=205.220.177.32; envelope-from=steven.sistare@oracle.com; helo=mx0b-00069f02.pphosted.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_MED=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, 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-bounces+qemu-devel=archiver.kernel.org@nongnu.org Modify net_init_tap so every return branches to a common label, for common cleanup in a subsequent patch. No functional change. Signed-off-by: Steve Sistare --- net/tap.c | 54 ++++++++++++++++++++++++++++++++++++------------------ 1 file changed, 36 insertions(+), 18 deletions(-) diff --git a/net/tap.c b/net/tap.c index 51f7aec..8deabcb 100644 --- a/net/tap.c +++ b/net/tap.c @@ -774,7 +774,8 @@ int net_init_tap(const Netdev *netdev, const char *name, * For -netdev, peer is always NULL. */ if (peer && (tap->has_queues || tap->fds || tap->vhostfds)) { error_setg(errp, "Multiqueue tap cannot be used with hubs"); - return -1; + ret = -1; + goto out; } if (tap->fd) { @@ -784,25 +785,29 @@ int net_init_tap(const Netdev *netdev, const char *name, error_setg(errp, "ifname=, script=, downscript=, vnet_hdr=, " "helper=, queues=, fds=, and vhostfds= " "are invalid with fd="); - return -1; + ret = -1; + goto out; } fd = monitor_fd_param(monitor_cur(), tap->fd, errp); if (fd == -1) { - return -1; + ret = -1; + goto out; } if (!g_unix_set_fd_nonblocking(fd, true, NULL)) { error_setg_errno(errp, errno, "%s: Can't use file descriptor %d", name, fd); close(fd); - return -1; + ret = -1; + goto out; } vnet_hdr = tap_probe_vnet_hdr(fd, errp); if (vnet_hdr < 0) { close(fd); - return -1; + ret = -1; + goto out; } net_init_tap_one(tap, peer, "tap", name, NULL, @@ -811,7 +816,8 @@ int net_init_tap(const Netdev *netdev, const char *name, if (err) { error_propagate(errp, err); close(fd); - return -1; + ret = -1; + goto out; } } else if (tap->fds) { char **fds; @@ -824,7 +830,8 @@ int net_init_tap(const Netdev *netdev, const char *name, error_setg(errp, "ifname=, script=, downscript=, vnet_hdr=, " "helper=, queues=, and vhostfd= " "are invalid with fds="); - return -1; + ret = -1; + goto out; } fds = g_new0(char *, MAX_TAP_QUEUES); @@ -888,30 +895,35 @@ free_fail: } g_free(fds); g_free(vhost_fds); - return ret; + goto out; + } else if (tap->helper) { if (tap->ifname || tap->script || tap->downscript || tap->has_vnet_hdr || tap->has_queues || tap->vhostfds) { error_setg(errp, "ifname=, script=, downscript=, vnet_hdr=, " "queues=, and vhostfds= are invalid with helper="); - return -1; + ret = -1; + goto out; } fd = net_bridge_run_helper(tap->helper, tap->br ?: DEFAULT_BRIDGE_INTERFACE, errp); if (fd == -1) { - return -1; + ret = -1; + goto out; } if (!g_unix_set_fd_nonblocking(fd, true, NULL)) { error_setg_errno(errp, errno, "Failed to set FD nonblocking"); - return -1; + ret = -1; + goto out; } vnet_hdr = tap_probe_vnet_hdr(fd, errp); if (vnet_hdr < 0) { close(fd); - return -1; + ret = -1; + goto out; } net_init_tap_one(tap, peer, "bridge", name, ifname, @@ -920,14 +932,16 @@ free_fail: if (err) { error_propagate(errp, err); close(fd); - return -1; + ret = -1; + goto out; } } else { g_autofree char *default_script = NULL; g_autofree char *default_downscript = NULL; if (tap->vhostfds) { error_setg(errp, "vhostfds= is invalid if fds= wasn't specified"); - return -1; + ret = -1; + goto out; } if (!script) { @@ -948,14 +962,16 @@ free_fail: fd = net_tap_init(tap, &vnet_hdr, i >= 1 ? "no" : script, ifname, sizeof ifname, queues > 1, errp); if (fd == -1) { - return -1; + ret = -1; + goto out; } if (queues > 1 && i == 0 && !tap->ifname) { if (tap_fd_get_ifname(fd, ifname)) { error_setg(errp, "Fail to get ifname"); close(fd); - return -1; + ret = -1; + goto out; } } @@ -966,12 +982,14 @@ free_fail: if (err) { error_propagate(errp, err); close(fd); - return -1; + ret = -1; + goto out; } } } - return 0; +out: + return ret; } VHostNetState *tap_get_vhost_net(NetClientState *nc) From patchwork Fri Aug 30 11:56:34 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steven Sistare X-Patchwork-Id: 13785023 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 25696CA0FE1 for ; Fri, 30 Aug 2024 11:57:24 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sk0FG-0007JV-4b; Fri, 30 Aug 2024 07:56:50 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sk0FC-0007I6-17 for qemu-devel@nongnu.org; Fri, 30 Aug 2024 07:56:46 -0400 Received: from mx0b-00069f02.pphosted.com ([205.220.177.32]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sk0FA-0002rR-Aq for qemu-devel@nongnu.org; Fri, 30 Aug 2024 07:56:45 -0400 Received: from pps.filterd (m0246630.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 47U7tZTw031532; Fri, 30 Aug 2024 11:56:43 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h= from:to:cc:subject:date:message-id:in-reply-to:references; s= corp-2023-11-20; bh=ROwlq54X8+1gliWKwzPqTLa3CsUyWttmLlk2LsjV5yk=; b= M3nA2L4CEEfIb+hUn3tA8/8rKmptI/LfUTgxi8N7p3b+8MVInL1fHoVSZhxhOk0z YmTX7JVuUBGRNkbc8b4tjC6EHuaRx3jIubSDmqeKYnZBfF/kXUHbFPBM567Teb1d QeIZ3DdedDlroFz59B7fxDTEbolWxEKbFx29xbWHbuyNo4ftlf6+n1P4RndWFRNe h/EQZ1rFJxOKvtqOY6Q8Q4wXb/HuBCN0lGuOJnI7CHLkVH2228NuwVuHl01dagSd 1DGdJ1O0vYqF59ZqWRKrtH3d4QNP6cUw+AMHsyR9LHraAliEbba1zyU7vG1+nURw q5qgGoPvJlGoYpF62ZPquw== Received: from iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta03.appoci.oracle.com [130.35.103.27]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 41b9v7gdmf-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 30 Aug 2024 11:56:42 +0000 (GMT) Received: from pps.filterd (iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com [127.0.0.1]) by iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (8.18.1.2/8.18.1.2) with ESMTP id 47UA25Ga036638; Fri, 30 Aug 2024 11:56:41 GMT Received: from pps.reinject (localhost [127.0.0.1]) by iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 4189jpg9ca-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 30 Aug 2024 11:56:41 +0000 Received: from iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 47UBucxM028887; Fri, 30 Aug 2024 11:56:41 GMT Received: from ca-dev63.us.oracle.com (ca-dev63.us.oracle.com [10.211.8.221]) by iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTP id 4189jpg9ae-4; Fri, 30 Aug 2024 11:56:41 +0000 From: Steve Sistare To: qemu-devel@nongnu.org Cc: "Michael S. Tsirkin" , Jason Wang , Peter Xu , Fabiano Rosas , Euan Turner , Steve Sistare Subject: [RFC V1 3/6] tap: fix net_init_tap() return code Date: Fri, 30 Aug 2024 04:56:34 -0700 Message-Id: <1725018997-363706-4-git-send-email-steven.sistare@oracle.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1725018997-363706-1-git-send-email-steven.sistare@oracle.com> References: <1725018997-363706-1-git-send-email-steven.sistare@oracle.com> X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1039,Hydra:6.0.680,FMLib:17.12.28.16 definitions=2024-08-30_06,2024-08-30_01,2024-05-17_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 spamscore=0 mlxscore=0 suspectscore=0 phishscore=0 malwarescore=0 bulkscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2407110000 definitions=main-2408300090 X-Proofpoint-GUID: NFb72nmgwvntJ81V_2PunCe6wkYbQ0ke X-Proofpoint-ORIG-GUID: NFb72nmgwvntJ81V_2PunCe6wkYbQ0ke Received-SPF: pass client-ip=205.220.177.32; envelope-from=steven.sistare@oracle.com; helo=mx0b-00069f02.pphosted.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_MED=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, 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-bounces+qemu-devel=archiver.kernel.org@nongnu.org When net_init_tap() succeeds for a multi-queue device, it returns a non-zero ret=1 code to its caller, because of this code where ret becomes 1 when g_unix_set_fd_nonblocking succeeds. Luckily, the only current call site checks for negative, rather than non-zero. ret = g_unix_set_fd_nonblocking(fd, true, NULL); if (!ret) { ... goto free_fail; Also, if g_unix_set_fd_nonblocking fails (though unlikely), ret=0 is returned, and the caller will use a broken interface. Signed-off-by: Steve Sistare --- net/tap.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/net/tap.c b/net/tap.c index 8deabcb..20e4dae 100644 --- a/net/tap.c +++ b/net/tap.c @@ -855,8 +855,8 @@ int net_init_tap(const Netdev *netdev, const char *name, goto free_fail; } - ret = g_unix_set_fd_nonblocking(fd, true, NULL); - if (!ret) { + if (!g_unix_set_fd_nonblocking(fd, true, NULL)) { + ret = -1; error_setg_errno(errp, errno, "%s: Can't use file descriptor %d", name, fd); goto free_fail; From patchwork Fri Aug 30 11:56:35 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steven Sistare X-Patchwork-Id: 13785029 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 A1275CA0FE4 for ; Fri, 30 Aug 2024 11:58:10 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sk0FK-0007VK-0l; Fri, 30 Aug 2024 07:56:54 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sk0FD-0007JJ-Al for qemu-devel@nongnu.org; Fri, 30 Aug 2024 07:56:47 -0400 Received: from mx0b-00069f02.pphosted.com ([205.220.177.32]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sk0FA-0002rV-Fz for qemu-devel@nongnu.org; Fri, 30 Aug 2024 07:56:46 -0400 Received: from pps.filterd (m0333520.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 47U7tVM6014619; Fri, 30 Aug 2024 11:56:43 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h= from:to:cc:subject:date:message-id:in-reply-to:references; s= corp-2023-11-20; bh=t08mOsZ64EUWO6kYmUjbH59vvPkEfVV+gDSxH4efXhI=; b= aK4x0cbd807BAqsayROfyft/tRCO3/ToFqnrNyLw8vlriKkzG0TgKh9EzMTAIrGk 8PJPscjGmeH/yj5TFq6rXkrZDtsBx4Sgt3nz9Niy4SqSIkEpthxa6jsF01PgaR1a gGUb4dXbfZ+fP0r+VtLcOpHhh66r2BwdF9FMUP5wi989qmUVZfWXZTEtJl5gImlV ZDDWwzRVREcUB0SLmNuYCauGXMEDsUwoxT9xGGKBIeGxGfqzGF9BP3+z0H9cm8xe EmKNGPpAIaIH17K5J+J5NFuG+3tz+LoXxf5dUgRefPM+N/zZOBLl2FYxLq7XYqQj eDtiyatTxM0+wLMB9AYe/Q== Received: from iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta03.appoci.oracle.com [130.35.103.27]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 419pugxg1b-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 30 Aug 2024 11:56:43 +0000 (GMT) Received: from pps.filterd (iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com [127.0.0.1]) by iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (8.18.1.2/8.18.1.2) with ESMTP id 47UArKZo036567; Fri, 30 Aug 2024 11:56:42 GMT Received: from pps.reinject (localhost [127.0.0.1]) by iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 4189jpg9d0-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 30 Aug 2024 11:56:42 +0000 Received: from iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 47UBucxO028887; Fri, 30 Aug 2024 11:56:42 GMT Received: from ca-dev63.us.oracle.com (ca-dev63.us.oracle.com [10.211.8.221]) by iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTP id 4189jpg9ae-5; Fri, 30 Aug 2024 11:56:42 +0000 From: Steve Sistare To: qemu-devel@nongnu.org Cc: "Michael S. Tsirkin" , Jason Wang , Peter Xu , Fabiano Rosas , Euan Turner , Steve Sistare Subject: [RFC V1 4/6] migration: cpr_get_fd_param helper Date: Fri, 30 Aug 2024 04:56:35 -0700 Message-Id: <1725018997-363706-5-git-send-email-steven.sistare@oracle.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1725018997-363706-1-git-send-email-steven.sistare@oracle.com> References: <1725018997-363706-1-git-send-email-steven.sistare@oracle.com> X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1039,Hydra:6.0.680,FMLib:17.12.28.16 definitions=2024-08-30_06,2024-08-30_01,2024-05-17_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 spamscore=0 mlxscore=0 suspectscore=0 phishscore=0 malwarescore=0 bulkscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2407110000 definitions=main-2408300090 X-Proofpoint-GUID: At_FfmOTgp4eWg-cOiJQuDg-B1ZSf7SZ X-Proofpoint-ORIG-GUID: At_FfmOTgp4eWg-cOiJQuDg-B1ZSf7SZ Received-SPF: pass client-ip=205.220.177.32; envelope-from=steven.sistare@oracle.com; helo=mx0b-00069f02.pphosted.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_MED=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, 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-bounces+qemu-devel=archiver.kernel.org@nongnu.org Add the helper function cpr_get_fd_param, for use by tap and vdpa. Signed-off-by: Steve Sistare Reviewed-by: Fabiano Rosas --- include/migration/cpr.h | 2 ++ migration/cpr.c | 26 ++++++++++++++++++++++++++ 2 files changed, 28 insertions(+) diff --git a/include/migration/cpr.h b/include/migration/cpr.h index 9a76365..b5fa264 100644 --- a/include/migration/cpr.h +++ b/include/migration/cpr.h @@ -27,6 +27,8 @@ void cpr_set_cpr_uri(const char *uri); int cpr_state_save(Error **errp); int cpr_state_load(Error **errp); bool cpr_needed_for_reuse(void *opaque); +int cpr_get_fd_param(const char *name, const char *fdname, + int index, Error **errp); QEMUFile *cpr_exec_output(Error **errp); QEMUFile *cpr_exec_input(Error **errp); diff --git a/migration/cpr.c b/migration/cpr.c index 096d684..0940ee2 100644 --- a/migration/cpr.c +++ b/migration/cpr.c @@ -13,6 +13,7 @@ #include "migration/qemu-file.h" #include "migration/savevm.h" #include "migration/vmstate.h" +#include "monitor/monitor.h" #include "sysemu/runstate.h" #include "trace.h" @@ -268,3 +269,28 @@ bool cpr_needed_for_reuse(void *opaque) MigMode mode = migrate_mode(); return mode == MIG_MODE_CPR_EXEC || mode == MIG_MODE_CPR_TRANSFER; } + +int cpr_get_fd_param(const char *name, const char *fdname, int index, + Error **errp) +{ + int fd; + + /* + * fd's are passed by name to the monitor when a NIC is hot plugged, but + * the name is not known to qemu after cpr. The manager can pass -1 for + * the fd "name" in the new qemu args to indicate that qemu should search + * for a saved name. + */ + if (!strcmp(fdname, "-1")) { + fd = cpr_find_fd(name, index); + if (fd < 0) { + error_setg(errp, "cannot find saved value for fd %s", fdname); + } + } else { + fd = monitor_fd_param(monitor_cur(), fdname, errp); + } + if (fd >= 0) { + cpr_resave_fd(name, index, fd); + } + return fd; +} From patchwork Fri Aug 30 11:56:36 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steven Sistare X-Patchwork-Id: 13785025 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 D70FDCA0FE1 for ; Fri, 30 Aug 2024 11:57:55 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sk0FI-0007Qh-QX; Fri, 30 Aug 2024 07:56:52 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sk0FE-0007JW-1f for qemu-devel@nongnu.org; Fri, 30 Aug 2024 07:56:49 -0400 Received: from mx0b-00069f02.pphosted.com ([205.220.177.32]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sk0FB-0002re-UQ for qemu-devel@nongnu.org; Fri, 30 Aug 2024 07:56:47 -0400 Received: from pps.filterd (m0246630.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 47U7tZTx031532; Fri, 30 Aug 2024 11:56:45 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h= from:to:cc:subject:date:message-id:in-reply-to:references; s= corp-2023-11-20; bh=d4mw0GEC9DP1mJClU2NH6S671GGFTg7HXk6f9Xqv14U=; b= I7PFEvV8LBORqheIVl2qhpzT1K0KSyLQG6g0e66XkVhZpAq5LjyWHGQbMepi/5Aj mXV9gLEZUapmSkQ5UuovVbnHjCuXUCNRcWmbm/+AKQgfDEo1XqP1nsouaGrcIzb/ Ok80cohlSttf2cKHjgxizJNZPYt7iDTC+sDbx5AlmTAyA+4eHcPC8YlYo2KlWINW 7aYnIvhLJ5MHa55MEWS1PP2hoDiECImiljVU7iWX4b26ipJtNgsP45biVzn0DjWE J3/OKeGarwUNcKTQltsrLaXIEoAPItszCQP2GnuPWaIjIH1LWTqybug8r4Uealxi WhWp+U/J55DHUGzeguiHJw== Received: from iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta03.appoci.oracle.com [130.35.103.27]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 41b9v7gdmj-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 30 Aug 2024 11:56:44 +0000 (GMT) Received: from pps.filterd (iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com [127.0.0.1]) by iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (8.18.1.2/8.18.1.2) with ESMTP id 47UBJONJ036495; Fri, 30 Aug 2024 11:56:44 GMT Received: from pps.reinject (localhost [127.0.0.1]) by iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 4189jpg9ds-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 30 Aug 2024 11:56:44 +0000 Received: from iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 47UBucxQ028887; Fri, 30 Aug 2024 11:56:43 GMT Received: from ca-dev63.us.oracle.com (ca-dev63.us.oracle.com [10.211.8.221]) by iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTP id 4189jpg9ae-6; Fri, 30 Aug 2024 11:56:43 +0000 From: Steve Sistare To: qemu-devel@nongnu.org Cc: "Michael S. Tsirkin" , Jason Wang , Peter Xu , Fabiano Rosas , Euan Turner , Steve Sistare Subject: [RFC V1 5/6] tap: cpr support Date: Fri, 30 Aug 2024 04:56:36 -0700 Message-Id: <1725018997-363706-6-git-send-email-steven.sistare@oracle.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1725018997-363706-1-git-send-email-steven.sistare@oracle.com> References: <1725018997-363706-1-git-send-email-steven.sistare@oracle.com> X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1039,Hydra:6.0.680,FMLib:17.12.28.16 definitions=2024-08-30_06,2024-08-30_01,2024-05-17_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 spamscore=0 mlxscore=0 suspectscore=0 phishscore=0 malwarescore=0 bulkscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2407110000 definitions=main-2408300090 X-Proofpoint-GUID: OZFRBhtBQkQFOj3enZpoMkMc6d7wGoAj X-Proofpoint-ORIG-GUID: OZFRBhtBQkQFOj3enZpoMkMc6d7wGoAj Received-SPF: pass client-ip=205.220.177.32; envelope-from=steven.sistare@oracle.com; helo=mx0b-00069f02.pphosted.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_MED=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, 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-bounces+qemu-devel=archiver.kernel.org@nongnu.org Save all tap fd's in canonical order, leveraging the index argument of cpr_save_fd. For the i'th queue, the tap device fd is saved at index 2*i, and the vhostfd (if any) at index 2*i+1. tap and vhost fd's are passed by name to the monitor when a NIC is hot plugged, but the name is not known to qemu after cpr-exec. Allow the manager to pass -1 for the fd "name" in the new qemu args to indicate that qemu should search for a saved value. Example: -netdev tap,id=hostnet2,fds=-1:-1,vhostfds=-1:-1 Signed-off-by: Steve Sistare --- net/tap.c | 55 +++++++++++++++++++++++++++++++++++++++++-------------- 1 file changed, 41 insertions(+), 14 deletions(-) diff --git a/net/tap.c b/net/tap.c index 20e4dae..4d57a53 100644 --- a/net/tap.c +++ b/net/tap.c @@ -35,6 +35,7 @@ #include "net/eth.h" #include "net/net.h" #include "clients.h" +#include "migration/cpr.h" #include "monitor/monitor.h" #include "sysemu/sysemu.h" #include "qapi/error.h" @@ -290,6 +291,8 @@ static void tap_cleanup(NetClientState *nc) { TAPState *s = DO_UPCAST(TAPState, nc, nc); + cpr_delete_fd_all(nc->name); + if (s->vhost_net) { vhost_net_cleanup(s->vhost_net); g_free(s->vhost_net); @@ -636,13 +639,17 @@ static int net_tap_init(const NetdevTapOptions *tap, int *vnet_hdr, return fd; } +/* CPR fd's for each queue are saved at these indices */ +#define TAP_FD_INDEX(queue) (2 * (queue) + 0) +#define TAP_VHOSTFD_INDEX(queue) (2 * (queue) + 1) + #define MAX_TAP_QUEUES 1024 static void net_init_tap_one(const NetdevTapOptions *tap, NetClientState *peer, const char *model, const char *name, const char *ifname, const char *script, const char *downscript, const char *vhostfdname, - int vnet_hdr, int fd, Error **errp) + int vnet_hdr, int fd, int index, Error **errp) { Error *err = NULL; TAPState *s = net_tap_fd_init(peer, model, name, fd, vnet_hdr); @@ -682,7 +689,7 @@ static void net_init_tap_one(const NetdevTapOptions *tap, NetClientState *peer, } if (vhostfdname) { - vhostfd = monitor_fd_param(monitor_cur(), vhostfdname, &err); + vhostfd = cpr_get_fd_param(name, vhostfdname, index, &err); if (vhostfd == -1) { error_propagate(errp, err); goto failed; @@ -693,7 +700,10 @@ static void net_init_tap_one(const NetdevTapOptions *tap, NetClientState *peer, goto failed; } } else { - vhostfd = open("/dev/vhost-net", O_RDWR); + vhostfd = cpr_find_fd(name, index); + if (vhostfd < 0) { + vhostfd = open("/dev/vhost-net", O_RDWR); + } if (vhostfd < 0) { error_setg_errno(errp, errno, "tap: open vhost char device failed"); @@ -703,6 +713,7 @@ static void net_init_tap_one(const NetdevTapOptions *tap, NetClientState *peer, error_setg_errno(errp, errno, "Failed to set FD nonblocking"); goto failed; } + cpr_resave_fd(name, index, vhostfd); } options.opaque = (void *)(uintptr_t)vhostfd; options.nvqs = 2; @@ -721,6 +732,7 @@ static void net_init_tap_one(const NetdevTapOptions *tap, NetClientState *peer, return; failed: + cpr_delete_fd_all(name); qemu_del_net_client(&s->nc); } @@ -789,7 +801,7 @@ int net_init_tap(const Netdev *netdev, const char *name, goto out; } - fd = monitor_fd_param(monitor_cur(), tap->fd, errp); + fd = cpr_get_fd_param(name, tap->fd, TAP_FD_INDEX(0), errp); if (fd == -1) { ret = -1; goto out; @@ -812,13 +824,14 @@ int net_init_tap(const Netdev *netdev, const char *name, net_init_tap_one(tap, peer, "tap", name, NULL, script, downscript, - vhostfdname, vnet_hdr, fd, &err); + vhostfdname, vnet_hdr, fd, TAP_VHOSTFD_INDEX(0), &err); if (err) { error_propagate(errp, err); close(fd); ret = -1; goto out; } + } else if (tap->fds) { char **fds; char **vhost_fds; @@ -849,7 +862,7 @@ int net_init_tap(const Netdev *netdev, const char *name, } for (i = 0; i < nfds; i++) { - fd = monitor_fd_param(monitor_cur(), fds[i], errp); + fd = cpr_get_fd_param(name, fds[i], TAP_FD_INDEX(i), errp); if (fd == -1) { ret = -1; goto free_fail; @@ -878,7 +891,7 @@ int net_init_tap(const Netdev *netdev, const char *name, net_init_tap_one(tap, peer, "tap", name, ifname, script, downscript, tap->vhostfds ? vhost_fds[i] : NULL, - vnet_hdr, fd, &err); + vnet_hdr, fd, TAP_VHOSTFD_INDEX(i), &err); if (err) { error_propagate(errp, err); ret = -1; @@ -906,9 +919,12 @@ free_fail: goto out; } - fd = net_bridge_run_helper(tap->helper, - tap->br ?: DEFAULT_BRIDGE_INTERFACE, - errp); + fd = cpr_find_fd(name, TAP_FD_INDEX(0)); + if (fd < 0) { + fd = net_bridge_run_helper(tap->helper, + tap->br ?: DEFAULT_BRIDGE_INTERFACE, + errp); + } if (fd == -1) { ret = -1; goto out; @@ -928,13 +944,15 @@ free_fail: net_init_tap_one(tap, peer, "bridge", name, ifname, script, downscript, vhostfdname, - vnet_hdr, fd, &err); + vnet_hdr, fd, TAP_VHOSTFD_INDEX(0), &err); if (err) { error_propagate(errp, err); close(fd); ret = -1; goto out; } + cpr_resave_fd(name, TAP_FD_INDEX(0), fd); + } else { g_autofree char *default_script = NULL; g_autofree char *default_downscript = NULL; @@ -959,8 +977,11 @@ free_fail: } for (i = 0; i < queues; i++) { - fd = net_tap_init(tap, &vnet_hdr, i >= 1 ? "no" : script, - ifname, sizeof ifname, queues > 1, errp); + fd = cpr_find_fd(name, TAP_FD_INDEX(i)); + if (fd < 0) { + fd = net_tap_init(tap, &vnet_hdr, i >= 1 ? "no" : script, + ifname, sizeof ifname, queues > 1, errp); + } if (fd == -1) { ret = -1; goto out; @@ -978,17 +999,23 @@ free_fail: net_init_tap_one(tap, peer, "tap", name, ifname, i >= 1 ? "no" : script, i >= 1 ? "no" : downscript, - vhostfdname, vnet_hdr, fd, &err); + vhostfdname, vnet_hdr, + fd, TAP_VHOSTFD_INDEX(i), + &err); if (err) { error_propagate(errp, err); close(fd); ret = -1; goto out; } + cpr_resave_fd(name, TAP_FD_INDEX(i), fd); } } out: + if (ret) { + cpr_delete_fd_all(name); + } return ret; } From patchwork Fri Aug 30 11:56:37 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steven Sistare X-Patchwork-Id: 13785028 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 219FACA0FE5 for ; Fri, 30 Aug 2024 11:58:07 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sk0FK-0007WM-Bi; Fri, 30 Aug 2024 07:56:54 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sk0FE-0007KQ-Or for qemu-devel@nongnu.org; Fri, 30 Aug 2024 07:56:50 -0400 Received: from mx0b-00069f02.pphosted.com ([205.220.177.32]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sk0FD-0002s0-4L for qemu-devel@nongnu.org; Fri, 30 Aug 2024 07:56:48 -0400 Received: from pps.filterd (m0333520.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 47U7tVQT014580; Fri, 30 Aug 2024 11:56:46 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h= from:to:cc:subject:date:message-id:in-reply-to:references; s= corp-2023-11-20; bh=GDzThzEZjoZ6r7+i+SAGovwAeyGq4pC0eUTNr/TivRk=; b= K7qCk4///GOcVFvAwvOu6Qi2SKIDsLtHnBOvIdIEk7DELo/n9UEC0NZmgKYtVYHX CBvSXaaTsqeaoVoDGRvsQ0G5d30dkLDfpwbV+gvUGpHSqgvsGQk1YXUKySMsV+AC mdT18N3S+zWpK3xnzoXiMQvKlRof0+N41Fik60jDtm6YC7IYvKUqf2nJWkIlZ6FW lb/kX1dkJS2OSf6eSS1f+8twwcOO4NOsoeepYlFLiEydUcLeISEgLF+1PPh3sq67 u2Y8tAQ26EYfVO52UAFhPti9LpxgSpuJNZd3DkYsy74OLKjZvMUgXMaSHf/eniiF MXS3kliRe5PbuXERHuFS1A== Received: from iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta03.appoci.oracle.com [130.35.103.27]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 419pugxg1d-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 30 Aug 2024 11:56:46 +0000 (GMT) Received: from pps.filterd (iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com [127.0.0.1]) by iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (8.18.1.2/8.18.1.2) with ESMTP id 47UAv4Rk036491; Fri, 30 Aug 2024 11:56:45 GMT Received: from pps.reinject (localhost [127.0.0.1]) by iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 4189jpg9eh-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 30 Aug 2024 11:56:45 +0000 Received: from iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 47UBucxS028887; Fri, 30 Aug 2024 11:56:44 GMT Received: from ca-dev63.us.oracle.com (ca-dev63.us.oracle.com [10.211.8.221]) by iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTP id 4189jpg9ae-7; Fri, 30 Aug 2024 11:56:44 +0000 From: Steve Sistare To: qemu-devel@nongnu.org Cc: "Michael S. Tsirkin" , Jason Wang , Peter Xu , Fabiano Rosas , Euan Turner , Steve Sistare Subject: [RFC V1 6/6] tap: postload fix for cpr Date: Fri, 30 Aug 2024 04:56:37 -0700 Message-Id: <1725018997-363706-7-git-send-email-steven.sistare@oracle.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1725018997-363706-1-git-send-email-steven.sistare@oracle.com> References: <1725018997-363706-1-git-send-email-steven.sistare@oracle.com> X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1039,Hydra:6.0.680,FMLib:17.12.28.16 definitions=2024-08-30_06,2024-08-30_01,2024-05-17_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 spamscore=0 mlxscore=0 suspectscore=0 phishscore=0 malwarescore=0 bulkscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2407110000 definitions=main-2408300090 X-Proofpoint-GUID: 5Bzsy_u5n_DDYWkv1Pcif_Yx3eeg_gXv X-Proofpoint-ORIG-GUID: 5Bzsy_u5n_DDYWkv1Pcif_Yx3eeg_gXv Received-SPF: pass client-ip=205.220.177.32; envelope-from=steven.sistare@oracle.com; helo=mx0b-00069f02.pphosted.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_MED=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, 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-bounces+qemu-devel=archiver.kernel.org@nongnu.org After cpr-exec of a multi-queue NIC, if any queues are unused, then the corresponding tap is marked enabled in userland, but it is disabled in the kernel for the fd that was preserved across exec. One cannot call tap_disable() during postload, because that eventually calls IFF_DETACH_QUEUE, which fails because the queue is already detached. Define tap_disable_postload to avoid IFF_DETACH_QUEUE. Signed-off-by: Steve Sistare --- hw/net/virtio-net.c | 20 ++++++++++++++++++++ include/net/tap.h | 1 + net/tap.c | 17 +++++++++++++++++ 3 files changed, 38 insertions(+) diff --git a/hw/net/virtio-net.c b/hw/net/virtio-net.c index 8f30972..8dc0a02 100644 --- a/hw/net/virtio-net.c +++ b/hw/net/virtio-net.c @@ -728,6 +728,25 @@ static int peer_detach(VirtIONet *n, int index) return tap_disable(nc->peer); } +/* + * Set the disabled flag on unused queue pairs after vmstate load, without + * calling IFF_DETACH_QUEUE, which fails because the queue is already detached. + */ +static void virtio_net_postload_queue_pairs(VirtIONet *n) +{ + int i; + MigMode mode = migrate_mode(); + + if (mode == MIG_MODE_CPR_EXEC || mode == MIG_MODE_CPR_TRANSFER) { + for (i = n->curr_queue_pairs; i < n->max_queue_pairs; i++) { + NetClientState *nc = qemu_get_subqueue(n->nic, i); + if (nc->peer && nc->peer->info->type == NET_CLIENT_DRIVER_TAP) { + tap_disable_postload(nc->peer); + } + } + } +} + static void virtio_net_set_queue_pairs(VirtIONet *n) { int i; @@ -3056,6 +3075,7 @@ static int virtio_net_post_load_device(void *opaque, int version_id) */ n->saved_guest_offloads = n->curr_guest_offloads; + virtio_net_postload_queue_pairs(n); virtio_net_set_queue_pairs(n); /* Find the first multicast entry in the saved MAC filter */ diff --git a/include/net/tap.h b/include/net/tap.h index 5d58551..9456abe 100644 --- a/include/net/tap.h +++ b/include/net/tap.h @@ -30,6 +30,7 @@ int tap_enable(NetClientState *nc); int tap_disable(NetClientState *nc); +void tap_disable_postload(NetClientState *nc); int tap_get_fd(NetClientState *nc); diff --git a/net/tap.c b/net/tap.c index 4d57a53..abc4994 100644 --- a/net/tap.c +++ b/net/tap.c @@ -1060,3 +1060,20 @@ int tap_disable(NetClientState *nc) return ret; } } + +/* + * On cpr restart, the tap is marked enabled in userland, but it might be + * disabled in the kernel, and IFF_DETACH_QUEUE will fail because it is + * already detached. This function disables without calling IFF_DETACH_QUEUE. + */ +void tap_disable_postload(NetClientState *nc) +{ + TAPState *s = DO_UPCAST(TAPState, nc, nc); + + if (s->enabled == 0) { + return; + } else { + s->enabled = false; + tap_update_fd_handler(s); + } +}