From nobody Wed May 22 00:43:24 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1655857679; cv=none; d=zohomail.com; s=zohoarc; b=lZPB5b6gFAFMzORLCPR4DKpOH9Z/e0pkWJSosrhM6nIPfllU/q3Ysiz/8hI3k4b2O27mnYkh3s62vUdTG/32phcjpYrSGhW2tYucQc5eOtNfZG4xCn5ebIoCOF+fIRbNNy9PXWY59L1fiF2+3ZIcRs8MisYs03JNq67d/nk1D64= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1655857679; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=yXY9UaOLOHZekARGoLUWEpyTmTRyRK28nCnNtTKK9EA=; b=d27urmOEHnqv35AE2ltcBChS9L+aSSJxMKbXXVAQKcrIDZIdILinSldoqTKbFHvLok656I/opP3LeZ7lNyn1ChvmqD/1McCaAx2rB8eLHoFhfIqMF6dj1HXZgGcRV8eSUftXYYIMhqP3wp6EchOd7vWQM6gSwkdYTHWZCMuz80g= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1655857679917136.24726813528923; Tue, 21 Jun 2022 17:27:59 -0700 (PDT) Received: from localhost ([::1]:54078 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1o3oDu-00052b-69 for importer@patchew.org; Tue, 21 Jun 2022 20:27:58 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:56052) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1o3oBy-0002A0-HU for qemu-devel@nongnu.org; Tue, 21 Jun 2022 20:25:58 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:25382) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1o3oBw-00064P-7n for qemu-devel@nongnu.org; Tue, 21 Jun 2022 20:25:58 -0400 Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-648-2NZWqlrYOtGYCf8o03D7Zw-1; Tue, 21 Jun 2022 20:25:52 -0400 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.rdu2.redhat.com [10.11.54.7]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 40CED3804501; Wed, 22 Jun 2022 00:25:52 +0000 (UTC) Received: from secure.mitica (unknown [10.39.192.22]) by smtp.corp.redhat.com (Postfix) with ESMTP id 8A2EC141510D; Wed, 22 Jun 2022 00:25:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1655857555; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=yXY9UaOLOHZekARGoLUWEpyTmTRyRK28nCnNtTKK9EA=; b=iIJ9hDO8tw9Eqe3Yl0bJRMapCgotwzfcOsneCGmn/YmN0Pv9i68aM9Mcim069E4dPpIwhM jdULKvP7xE6hFtdQWea5EcUMDUS7Vx6tdRS0b2iwxJ9s7qQTdYId3lLtzyPvDAXIyiwgAk 2syflB/b5i5Ao0A8S60dOPWX1ETApYQ= X-MC-Unique: 2NZWqlrYOtGYCf8o03D7Zw-1 From: Juan Quintela To: qemu-devel@nongnu.org Cc: Hailiang Zhang , Eric Blake , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , Fam Zheng , "Dr. David Alan Gilbert" , Juan Quintela , qemu-block@nongnu.org, Stefan Hajnoczi , Markus Armbruster Subject: [PULL 01/25] migration: Remove RDMA_UNREGISTRATION_EXAMPLE Date: Wed, 22 Jun 2022 02:25:23 +0200 Message-Id: <20220622002547.64784-2-quintela@redhat.com> In-Reply-To: <20220622002547.64784-1-quintela@redhat.com> References: <20220622002547.64784-1-quintela@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 2.85 on 10.11.54.7 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=quintela@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -28 X-Spam_score: -2.9 X-Spam_bar: -- X-Spam_report: (-2.9 / 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, RCVD_IN_DNSWL_LOW=-0.7, 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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1655857682272100001 Nobody has ever showed up to unregister individual pages, and another set of patches written by Daniel P. Berrang=C3=A9 just remove qemu_rdma_signal_unregister() function needed here. Signed-off-by: Juan Quintela Reviewed-by: Dr. David Alan Gilbert --- migration/rdma.c | 41 ----------------------------------------- 1 file changed, 41 deletions(-) diff --git a/migration/rdma.c b/migration/rdma.c index 672d1958a9..8504152f39 100644 --- a/migration/rdma.c +++ b/migration/rdma.c @@ -1370,30 +1370,6 @@ const char *print_wrid(int wrid) return wrid_desc[wrid]; } =20 -/* - * RDMA requires memory registration (mlock/pinning), but this is not good= for - * overcommitment. - * - * In preparation for the future where LRU information or workload-specific - * writable writable working set memory access behavior is available to QE= MU - * it would be nice to have in place the ability to UN-register/UN-pin - * particular memory regions from the RDMA hardware when it is determine t= hat - * those regions of memory will likely not be accessed again in the near f= uture. - * - * While we do not yet have such information right now, the following - * compile-time option allows us to perform a non-optimized version of this - * behavior. - * - * By uncommenting this option, you will cause *all* RDMA transfers to be - * unregistered immediately after the transfer completes on both sides of = the - * connection. This has no effect in 'rdma-pin-all' mode, only regular mod= e. - * - * This will have a terrible impact on migration performance, so until fut= ure - * workload information or LRU information is available, do not attempt to= use - * this feature except for basic testing. - */ -/* #define RDMA_UNREGISTRATION_EXAMPLE */ - /* * Perform a non-optimized memory unregistration after every transfer * for demonstration purposes, only if pin-all is not requested. @@ -1571,18 +1547,6 @@ static uint64_t qemu_rdma_poll(RDMAContext *rdma, st= ruct ibv_cq *cq, if (rdma->nb_sent > 0) { rdma->nb_sent--; } - - if (!rdma->pin_all) { - /* - * FYI: If one wanted to signal a specific chunk to be unregis= tered - * using LRU or workload-specific information, this is the fun= ction - * you would call to do so. That chunk would then get asynchro= nously - * unregistered later. - */ -#ifdef RDMA_UNREGISTRATION_EXAMPLE - qemu_rdma_signal_unregister(rdma, index, chunk, wc.wr_id); -#endif - } } else { trace_qemu_rdma_poll_other(print_wrid(wr_id), wr_id, rdma->nb_sent= ); } @@ -2137,11 +2101,6 @@ retry: =20 chunk_end =3D ram_chunk_end(block, chunk + chunks); =20 - if (!rdma->pin_all) { -#ifdef RDMA_UNREGISTRATION_EXAMPLE - qemu_rdma_unregister_waiting(rdma); -#endif - } =20 while (test_bit(chunk, block->transit_bitmap)) { (void)count; --=20 2.35.3 From nobody Wed May 22 00:43:24 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1655857688; cv=none; d=zohomail.com; s=zohoarc; b=R63hVhIHZIkw/0QksmlsCIV4VNgQ87fTKB0UqKurkahtnhxM3dBc+V9JAO+0PmcjmFvbDXkE0rnr/etJ2xHXXgoXI5CnbY7V5P/9/xFnS3JyCmHPsGLbN125RUo5N+jvEPkJS7jn7oxSU5q4ev9SXosR9pGOjutEllkEYWbZrfc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1655857688; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=LvLz0dylLIAZgBBtEdu0udbi/OT3v4WCnIuoEhOif5o=; b=YPQSlYqCzn4kllq7eQ1B39Fs+hsMdz0JRNddm95/BD0g6te0Zc7g1PM3nA8js9U7dUEALKGc/Hljj/NHJxGeZzkP8k/sG1IkZz7/llrKwNFfpx7iMrzm8JQo4Gwo/CICRgWgXbhCKiO75GGh+vest/Fbz1mZzFAMgsVdDq2z8yE= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 165585768835167.22980558811582; Tue, 21 Jun 2022 17:28:08 -0700 (PDT) Received: from localhost ([::1]:54762 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1o3oE3-0005V5-Aa for importer@patchew.org; Tue, 21 Jun 2022 20:28:07 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:56082) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1o3oC1-0002DF-4s for qemu-devel@nongnu.org; Tue, 21 Jun 2022 20:26:01 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:34657) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1o3oBy-00064k-JM for qemu-devel@nongnu.org; Tue, 21 Jun 2022 20:25:59 -0400 Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-516-fJWm86y8Mzqv74ZzuzgPAQ-1; Tue, 21 Jun 2022 20:25:54 -0400 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.rdu2.redhat.com [10.11.54.7]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 9075880029D; Wed, 22 Jun 2022 00:25:54 +0000 (UTC) Received: from secure.mitica (unknown [10.39.192.22]) by smtp.corp.redhat.com (Postfix) with ESMTP id 8C121141510D; Wed, 22 Jun 2022 00:25:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1655857558; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=LvLz0dylLIAZgBBtEdu0udbi/OT3v4WCnIuoEhOif5o=; b=KCajLZjVuyF+FKlWXKLhiXYskSz/fb1A04t0D8OyPRN1FTCCSS3YZB5XjpsWxivINWtbeZ HAzhLB70IMfexjPireyHZ4WvRfPPWiWfYGZcodyYqA8jYgf+JP8qq9r98W1oCcFQQft2ZP NwlNCFW3o6GZjfdSwQ6nChVqxARAFcU= X-MC-Unique: fJWm86y8Mzqv74ZzuzgPAQ-1 From: Juan Quintela To: qemu-devel@nongnu.org Cc: Hailiang Zhang , Eric Blake , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , Fam Zheng , "Dr. David Alan Gilbert" , Juan Quintela , qemu-block@nongnu.org, Stefan Hajnoczi , Markus Armbruster , Leonardo Bras , Peter Xu Subject: [PULL 02/25] QIOChannelSocket: Introduce assert and reduce ifdefs to improve readability Date: Wed, 22 Jun 2022 02:25:24 +0200 Message-Id: <20220622002547.64784-3-quintela@redhat.com> In-Reply-To: <20220622002547.64784-1-quintela@redhat.com> References: <20220622002547.64784-1-quintela@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 2.85 on 10.11.54.7 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=quintela@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -28 X-Spam_score: -2.9 X-Spam_bar: -- X-Spam_report: (-2.9 / 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, RCVD_IN_DNSWL_LOW=-0.7, 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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1655857689948100003 From: Leonardo Bras During implementation of MSG_ZEROCOPY feature, a lot of #ifdefs were introduced, particularly at qio_channel_socket_writev(). Rewrite some of those changes so it's easier to read. Also, introduce an assert to help detect incorrect zero-copy usage is when it's disabled on build. Signed-off-by: Leonardo Bras Reviewed-by: Daniel P. Berrang=C3=A9 Reviewed-by: Juan Quintela Reviewed-by: Peter Xu Signed-off-by: Juan Quintela --- io/channel-socket.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/io/channel-socket.c b/io/channel-socket.c index dc9c165de1..dac9e60c20 100644 --- a/io/channel-socket.c +++ b/io/channel-socket.c @@ -578,11 +578,17 @@ static ssize_t qio_channel_socket_writev(QIOChannel *= ioc, memcpy(CMSG_DATA(cmsg), fds, fdsize); } =20 -#ifdef QEMU_MSG_ZEROCOPY if (flags & QIO_CHANNEL_WRITE_FLAG_ZERO_COPY) { +#ifdef QEMU_MSG_ZEROCOPY sflags =3D MSG_ZEROCOPY; - } +#else + /* + * We expect QIOChannel class entry point to have + * blocked this code path already + */ + g_assert_unreachable(); #endif + } =20 retry: ret =3D sendmsg(sioc->fd, &msg, sflags); @@ -592,15 +598,13 @@ static ssize_t qio_channel_socket_writev(QIOChannel *= ioc, return QIO_CHANNEL_ERR_BLOCK; case EINTR: goto retry; -#ifdef QEMU_MSG_ZEROCOPY case ENOBUFS: - if (sflags & MSG_ZEROCOPY) { + if (flags & QIO_CHANNEL_WRITE_FLAG_ZERO_COPY) { error_setg_errno(errp, errno, "Process can't lock enough memory for usi= ng MSG_ZEROCOPY"); return -1; } break; -#endif } =20 error_setg_errno(errp, errno, --=20 2.35.3 From nobody Wed May 22 00:43:24 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1655857841; cv=none; d=zohomail.com; s=zohoarc; b=jjoApX9+IbBqQC+O4RDKUF5gWY921rdLxff7kjA4o/LfRi7onFVzmtIqV1azVufJkh598JCYGKaade8bfXB/W//4WPeUMO1sK9e/kM8x6reY7z3Opke2XXyZ2EKH6bD4pdoYtB8oIdnG47zw0A870E8rZPVaiYS2LzlytYmhG/M= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1655857841; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=voM1ellYkNR6y416oOlo4EKUeHkTIl14Sv9O9xoldmQ=; b=PtmBU5kTU1B64iWmveW6Okzzlcg67UF3OBjbUH73avoV/+JXMfbiAfRCMRhAnFxpMmiZ/Uf/4qwG8PKYd4TTiWRPeTDqLwZzlHWMfxvwvPYTCuBzjCkg/aVC6XMb8On2mSy0vYYoiuGVSmPPLdh7rlx63gqrpxi1IDlphrD7JoI= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1655857841279309.55231523336033; Tue, 21 Jun 2022 17:30:41 -0700 (PDT) Received: from localhost ([::1]:34974 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1o3oGW-0002fw-8T for importer@patchew.org; Tue, 21 Jun 2022 20:30:40 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:56134) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1o3oC4-0002NI-SR for qemu-devel@nongnu.org; Tue, 21 Jun 2022 20:26:04 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:55635) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1o3oC3-00065a-8h for qemu-devel@nongnu.org; Tue, 21 Jun 2022 20:26:04 -0400 Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-210-xAS5XSocPZ6y2CuwpykQxQ-1; Tue, 21 Jun 2022 20:25:57 -0400 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.rdu2.redhat.com [10.11.54.7]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 116B12999B47; Wed, 22 Jun 2022 00:25:57 +0000 (UTC) Received: from secure.mitica (unknown [10.39.192.22]) by smtp.corp.redhat.com (Postfix) with ESMTP id DCF70141510D; Wed, 22 Jun 2022 00:25:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1655857562; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=voM1ellYkNR6y416oOlo4EKUeHkTIl14Sv9O9xoldmQ=; b=XIHajeCgQAJYDQxbj0kPV65dLnldM6rgEl86+eBNjX9iv7Qs2HAs7FGtc3KRQfsbZzDyp9 eAyUi6+nznYvk8u0Qpc/Tq4wbiW/eMMh4stYgmrELA9tu/ug4C/n6dhKBA+qr6pel8cL5H r59GJ6mcwje9/nYcJLB+JhFHJRIw3VY= X-MC-Unique: xAS5XSocPZ6y2CuwpykQxQ-1 From: Juan Quintela To: qemu-devel@nongnu.org Cc: Hailiang Zhang , Eric Blake , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , Fam Zheng , "Dr. David Alan Gilbert" , Juan Quintela , qemu-block@nongnu.org, Stefan Hajnoczi , Markus Armbruster , Leonardo Bras , =?UTF-8?q?=E5=BE=90=E9=97=AF?= , Peter Xu Subject: [PULL 03/25] QIOChannelSocket: Fix zero-copy send so socket flush works Date: Wed, 22 Jun 2022 02:25:25 +0200 Message-Id: <20220622002547.64784-4-quintela@redhat.com> In-Reply-To: <20220622002547.64784-1-quintela@redhat.com> References: <20220622002547.64784-1-quintela@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 2.85 on 10.11.54.7 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=quintela@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -28 X-Spam_score: -2.9 X-Spam_bar: -- X-Spam_report: (-2.9 / 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, RCVD_IN_DNSWL_LOW=-0.7, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=unavailable 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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1655857843681100001 From: Leonardo Bras Somewhere between v6 and v7 the of the zero-copy-send patchset a crucial part of the flushing mechanism got missing: incrementing zero_copy_queued. Without that, the flushing interface becomes a no-op, and there is no guarantee the buffer is really sent. This can go as bad as causing a corruption in RAM during migration. Fixes: 2bc58ffc2926 ("QIOChannelSocket: Implement io_writev zero copy flag = & io_flush for CONFIG_LINUX") Reported-by: =E5=BE=90=E9=97=AF Signed-off-by: Leonardo Bras Reviewed-by: Daniel P. Berrang=C3=A9 Reviewed-by: Peter Xu Reviewed-by: Juan Quintela Signed-off-by: Juan Quintela --- io/channel-socket.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/io/channel-socket.c b/io/channel-socket.c index dac9e60c20..4fa0402f54 100644 --- a/io/channel-socket.c +++ b/io/channel-socket.c @@ -611,6 +611,11 @@ static ssize_t qio_channel_socket_writev(QIOChannel *i= oc, "Unable to write to socket"); return -1; } + + if (flags & QIO_CHANNEL_WRITE_FLAG_ZERO_COPY) { + sioc->zero_copy_queued++; + } + return ret; } #else /* WIN32 */ --=20 2.35.3 From nobody Wed May 22 00:43:24 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1655857686; cv=none; d=zohomail.com; s=zohoarc; b=DZMkXyE4Y7kI71FDyvrvGUAk+LA+dVljiZ5VGSDGy0OrYPTeXfRNjFpsnOAX1+8D/9zcr1LRXhGsHLNStwX2ENHye5kMFxDz1XTRimvDsMXuXib3dux80X1V8LGOzMEvtZ0Kn4RYtgPFzPUNlvjz2q2zcVPxh9vfUoX2qIyaZvo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1655857686; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=Y4VozatkZ5m6HC8A1HzX0xLKZ+3cEk6gHd73U6ecoBM=; b=G5Qyb+FQFV1ZLP2ug10gJY+ZcLB4VWUOMRUMKfwfud34FSdhYwgw42B2hXi8hYMVPDJBhJU8pfSlezE1tmZHpkkmWacPe9UDJuOI6gGzHWI/CiHCVcCG/mHR69imJc8yoQ9kkO2FWL5K5+k+gDl5WN5P8aWt46aYwD9sizd0rRQ= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1655857686717691.3061186333402; Tue, 21 Jun 2022 17:28:06 -0700 (PDT) Received: from localhost ([::1]:54594 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1o3oE1-0005Nf-EH for importer@patchew.org; Tue, 21 Jun 2022 20:28:05 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:56122) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1o3oC3-0002Jy-V8 for qemu-devel@nongnu.org; Tue, 21 Jun 2022 20:26:04 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:53138) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1o3oC1-00065K-UM for qemu-devel@nongnu.org; Tue, 21 Jun 2022 20:26:03 -0400 Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-641-LgXxue_CM96LkfDyL-2b8g-1; Tue, 21 Jun 2022 20:25:59 -0400 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.rdu2.redhat.com [10.11.54.7]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 85D1D1C08969; Wed, 22 Jun 2022 00:25:59 +0000 (UTC) Received: from secure.mitica (unknown [10.39.192.22]) by smtp.corp.redhat.com (Postfix) with ESMTP id 5DF27141510D; Wed, 22 Jun 2022 00:25:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1655857561; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Y4VozatkZ5m6HC8A1HzX0xLKZ+3cEk6gHd73U6ecoBM=; b=EqP6PsX+Wk/Hk7O+NCDI2BgV5NVwde7tVGr+/h9j0liDoc+oH3lUBfNkWhFnsQazw2TzyR kfZ98IF87mhG2UvYvRHx0UMNNid/db8pSPNy+wJ58SJtpKPq1untafP8gA8NfHQXzhg9AL QxECRB6pNSU/oWmrCv0VBQ7GCgLKlP0= X-MC-Unique: LgXxue_CM96LkfDyL-2b8g-1 From: Juan Quintela To: qemu-devel@nongnu.org Cc: Hailiang Zhang , Eric Blake , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , Fam Zheng , "Dr. David Alan Gilbert" , Juan Quintela , qemu-block@nongnu.org, Stefan Hajnoczi , Markus Armbruster , Leonardo Bras , Peter Xu Subject: [PULL 04/25] migration: Change zero_copy_send from migration parameter to migration capability Date: Wed, 22 Jun 2022 02:25:26 +0200 Message-Id: <20220622002547.64784-5-quintela@redhat.com> In-Reply-To: <20220622002547.64784-1-quintela@redhat.com> References: <20220622002547.64784-1-quintela@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 2.85 on 10.11.54.7 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=quintela@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -28 X-Spam_score: -2.9 X-Spam_bar: -- X-Spam_report: (-2.9 / 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, RCVD_IN_DNSWL_LOW=-0.7, 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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1655857688006100001 Content-Type: text/plain; charset="utf-8" From: Leonardo Bras When originally implemented, zero_copy_send was designed as a Migration paramenter. But taking into account how is that supposed to work, and how the difference between a capability and a parameter, it only makes sense that zero-copy-send would work better as a capability. Taking into account how recently the change got merged, it was decided that it's still time to make it right, and convert zero_copy_send into a Migration capability. Signed-off-by: Leonardo Bras Reviewed-by: Juan Quintela Acked-by: Markus Armbruster Acked-by: Peter Xu Signed-off-by: Juan Quintela --- qapi/migration.json | 33 ++++++++------------------- migration/migration.c | 52 ++++++++++++++++--------------------------- monitor/hmp-cmds.c | 6 ----- 3 files changed, 28 insertions(+), 63 deletions(-) diff --git a/qapi/migration.json b/qapi/migration.json index 6130cd9fae..baf8d734de 100644 --- a/qapi/migration.json +++ b/qapi/migration.json @@ -461,6 +461,13 @@ # procedure starts. The VM RAM is saved with running= VM. # (since 6.0) # +# @zero-copy-send: Controls behavior on sending memory pages on migration. +# When true, enables a zero-copy mechanism for sending +# memory pages, if host supports it. +# Requires that QEMU be permitted to use locked memory +# for guest RAM pages. +# (since 7.1) +# # Features: # @unstable: Members @x-colo and @x-ignore-shared are experimental. # @@ -474,7 +481,8 @@ 'block', 'return-path', 'pause-before-switchover', 'multifd', 'dirty-bitmaps', 'postcopy-blocktime', 'late-block-activate', { 'name': 'x-ignore-shared', 'features': [ 'unstable' ] }, - 'validate-uuid', 'background-snapshot'] } + 'validate-uuid', 'background-snapshot', + { 'name': 'zero-copy-send', 'if' : 'CONFIG_LINUX'}] } =20 ## # @MigrationCapabilityStatus: @@ -738,12 +746,6 @@ # will consume more CPU. # Defaults to 1. (Since 5.0) # -# @zero-copy-send: Controls behavior on sending memory pages on migration. -# When true, enables a zero-copy mechanism for sending -# memory pages, if host supports it. -# Requires that QEMU be permitted to use locked memory -# for guest RAM pages. -# Defaults to false. (Since 7.1) # # @block-bitmap-mapping: Maps block nodes and bitmaps on them to # aliases for the purpose of dirty bitmap migration= . Such @@ -784,7 +786,6 @@ 'xbzrle-cache-size', 'max-postcopy-bandwidth', 'max-cpu-throttle', 'multifd-compression', 'multifd-zlib-level' ,'multifd-zstd-level', - { 'name': 'zero-copy-send', 'if' : 'CONFIG_LINUX'}, 'block-bitmap-mapping' ] } =20 ## @@ -911,13 +912,6 @@ # will consume more CPU. # Defaults to 1. (Since 5.0) # -# @zero-copy-send: Controls behavior on sending memory pages on migration. -# When true, enables a zero-copy mechanism for sending -# memory pages, if host supports it. -# Requires that QEMU be permitted to use locked memory -# for guest RAM pages. -# Defaults to false. (Since 7.1) -# # @block-bitmap-mapping: Maps block nodes and bitmaps on them to # aliases for the purpose of dirty bitmap migration= . Such # aliases may for example be the corresponding name= s on the @@ -972,7 +966,6 @@ '*multifd-compression': 'MultiFDCompression', '*multifd-zlib-level': 'uint8', '*multifd-zstd-level': 'uint8', - '*zero-copy-send': { 'type': 'bool', 'if': 'CONFIG_LINUX' }, '*block-bitmap-mapping': [ 'BitmapMigrationNodeAlias' ] } } =20 ## @@ -1119,13 +1112,6 @@ # will consume more CPU. # Defaults to 1. (Since 5.0) # -# @zero-copy-send: Controls behavior on sending memory pages on migration. -# When true, enables a zero-copy mechanism for sending -# memory pages, if host supports it. -# Requires that QEMU be permitted to use locked memory -# for guest RAM pages. -# Defaults to false. (Since 7.1) -# # @block-bitmap-mapping: Maps block nodes and bitmaps on them to # aliases for the purpose of dirty bitmap migration= . Such # aliases may for example be the corresponding name= s on the @@ -1178,7 +1164,6 @@ '*multifd-compression': 'MultiFDCompression', '*multifd-zlib-level': 'uint8', '*multifd-zstd-level': 'uint8', - '*zero-copy-send': { 'type': 'bool', 'if': 'CONFIG_LINUX' }, '*block-bitmap-mapping': [ 'BitmapMigrationNodeAlias' ] } } =20 ## diff --git a/migration/migration.c b/migration/migration.c index 31739b2af9..cc253d66e3 100644 --- a/migration/migration.c +++ b/migration/migration.c @@ -163,7 +163,8 @@ INITIALIZE_MIGRATE_CAPS_SET(check_caps_background_snaps= hot, MIGRATION_CAPABILITY_COMPRESS, MIGRATION_CAPABILITY_XBZRLE, MIGRATION_CAPABILITY_X_COLO, - MIGRATION_CAPABILITY_VALIDATE_UUID); + MIGRATION_CAPABILITY_VALIDATE_UUID, + MIGRATION_CAPABILITY_ZERO_COPY_SEND); =20 /* When we add fault tolerance, we could have several migrations at once. For now we don't need to add @@ -910,10 +911,6 @@ MigrationParameters *qmp_query_migrate_parameters(Erro= r **errp) params->multifd_zlib_level =3D s->parameters.multifd_zlib_level; params->has_multifd_zstd_level =3D true; params->multifd_zstd_level =3D s->parameters.multifd_zstd_level; -#ifdef CONFIG_LINUX - params->has_zero_copy_send =3D true; - params->zero_copy_send =3D s->parameters.zero_copy_send; -#endif params->has_xbzrle_cache_size =3D true; params->xbzrle_cache_size =3D s->parameters.xbzrle_cache_size; params->has_max_postcopy_bandwidth =3D true; @@ -1275,6 +1272,18 @@ static bool migrate_caps_check(bool *cap_list, } } =20 +#ifdef CONFIG_LINUX + if (cap_list[MIGRATION_CAPABILITY_ZERO_COPY_SEND] && + (!cap_list[MIGRATION_CAPABILITY_MULTIFD] || + migrate_use_compression() || + migrate_use_tls())) { + error_setg(errp, + "Zero copy only available for non-compressed non-TLS mu= ltifd migration"); + return false; + } +#endif + + /* incoming side only */ if (runstate_check(RUN_STATE_INMIGRATE) && !migrate_multi_channels_is_allowed() && @@ -1497,16 +1506,6 @@ static bool migrate_params_check(MigrationParameters= *params, Error **errp) error_prepend(errp, "Invalid mapping given for block-bitmap-mappin= g: "); return false; } -#ifdef CONFIG_LINUX - if (params->zero_copy_send && - (!migrate_use_multifd() || - params->multifd_compression !=3D MULTIFD_COMPRESSION_NONE || - (params->tls_creds && *params->tls_creds))) { - error_setg(errp, - "Zero copy only available for non-compressed non-TLS mu= ltifd migration"); - return false; - } -#endif return true; } =20 @@ -1580,11 +1579,6 @@ static void migrate_params_test_apply(MigrateSetPara= meters *params, if (params->has_multifd_compression) { dest->multifd_compression =3D params->multifd_compression; } -#ifdef CONFIG_LINUX - if (params->has_zero_copy_send) { - dest->zero_copy_send =3D params->zero_copy_send; - } -#endif if (params->has_xbzrle_cache_size) { dest->xbzrle_cache_size =3D params->xbzrle_cache_size; } @@ -1697,11 +1691,6 @@ static void migrate_params_apply(MigrateSetParameter= s *params, Error **errp) if (params->has_multifd_compression) { s->parameters.multifd_compression =3D params->multifd_compression; } -#ifdef CONFIG_LINUX - if (params->has_zero_copy_send) { - s->parameters.zero_copy_send =3D params->zero_copy_send; - } -#endif if (params->has_xbzrle_cache_size) { s->parameters.xbzrle_cache_size =3D params->xbzrle_cache_size; xbzrle_cache_resize(params->xbzrle_cache_size, errp); @@ -2593,7 +2582,7 @@ bool migrate_use_zero_copy_send(void) =20 s =3D migrate_get_current(); =20 - return s->parameters.zero_copy_send; + return s->enabled_capabilities[MIGRATION_CAPABILITY_ZERO_COPY_SEND]; } #endif =20 @@ -4249,10 +4238,6 @@ static Property migration_properties[] =3D { DEFINE_PROP_UINT8("multifd-zstd-level", MigrationState, parameters.multifd_zstd_level, DEFAULT_MIGRATE_MULTIFD_ZSTD_LEVEL), -#ifdef CONFIG_LINUX - DEFINE_PROP_BOOL("zero_copy_send", MigrationState, - parameters.zero_copy_send, false), -#endif DEFINE_PROP_SIZE("xbzrle-cache-size", MigrationState, parameters.xbzrle_cache_size, DEFAULT_MIGRATE_XBZRLE_CACHE_SIZE), @@ -4290,6 +4275,10 @@ static Property migration_properties[] =3D { DEFINE_PROP_MIG_CAP("x-multifd", MIGRATION_CAPABILITY_MULTIFD), DEFINE_PROP_MIG_CAP("x-background-snapshot", MIGRATION_CAPABILITY_BACKGROUND_SNAPSHOT), +#ifdef CONFIG_LINUX + DEFINE_PROP_MIG_CAP("x-zero-copy-send", + MIGRATION_CAPABILITY_ZERO_COPY_SEND), +#endif =20 DEFINE_PROP_END_OF_LIST(), }; @@ -4350,9 +4339,6 @@ static void migration_instance_init(Object *obj) params->has_multifd_compression =3D true; params->has_multifd_zlib_level =3D true; params->has_multifd_zstd_level =3D true; -#ifdef CONFIG_LINUX - params->has_zero_copy_send =3D true; -#endif params->has_xbzrle_cache_size =3D true; params->has_max_postcopy_bandwidth =3D true; params->has_max_cpu_throttle =3D true; diff --git a/monitor/hmp-cmds.c b/monitor/hmp-cmds.c index 47a27326ee..ca98df0495 100644 --- a/monitor/hmp-cmds.c +++ b/monitor/hmp-cmds.c @@ -1311,12 +1311,6 @@ void hmp_migrate_set_parameter(Monitor *mon, const Q= Dict *qdict) p->has_multifd_zstd_level =3D true; visit_type_uint8(v, param, &p->multifd_zstd_level, &err); break; -#ifdef CONFIG_LINUX - case MIGRATION_PARAMETER_ZERO_COPY_SEND: - p->has_zero_copy_send =3D true; - visit_type_bool(v, param, &p->zero_copy_send, &err); - break; -#endif case MIGRATION_PARAMETER_XBZRLE_CACHE_SIZE: p->has_xbzrle_cache_size =3D true; if (!visit_type_size(v, param, &cache_size, &err)) { --=20 2.35.3 From nobody Wed May 22 00:43:24 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1655858186; cv=none; d=zohomail.com; s=zohoarc; b=liHgGYe7/3RLeIP3Br22dlxuEZkGzTH2+Qpch01xmub8Z/7/P7/8MV+ItQp+n+SkktLX8TeqHqAYMYH+NoZ55+bgqOHRMfoSgCx/bYI1J75+a1FyhuXlTrJi73jpJlbqLTFs8LvIGExR6kQiFCtrajXc2MbXgVgGqvGIgdZkZTE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1655858186; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=0cx4sP/7Zlh7hMX6GOEUJ7/O/30tJjigwNwAiVHnCHI=; b=NwcV0NPwrWIrha3ULDS207E1P0wTjuGc6zgiAEiVHICXnnxb/lITWi3rhisMiS5UOHYre4hYs/88EFBM/lnGKK5i9/sTE8kuyINRx4UMplbzrzuxhuusaZ7EUIgEy4cwF488vmc1esAqkJO8jCGS1gaoe7LLUnyNcpWeHJoUiF4= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1655858186225559.6028812846407; Tue, 21 Jun 2022 17:36:26 -0700 (PDT) Received: from localhost ([::1]:43644 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1o3oM4-000066-Rt for importer@patchew.org; Tue, 21 Jun 2022 20:36:24 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:56192) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1o3oCE-0002qk-M4 for qemu-devel@nongnu.org; Tue, 21 Jun 2022 20:26:14 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:45322) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1o3oC5-000668-PO for qemu-devel@nongnu.org; Tue, 21 Jun 2022 20:26:14 -0400 Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-638-6ypAaGX5OUSFQh7u8bIL1Q-1; Tue, 21 Jun 2022 20:26:02 -0400 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.rdu2.redhat.com [10.11.54.7]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id A7FDF185A7B2; Wed, 22 Jun 2022 00:26:01 +0000 (UTC) Received: from secure.mitica (unknown [10.39.192.22]) by smtp.corp.redhat.com (Postfix) with ESMTP id CE702141510D; Wed, 22 Jun 2022 00:25:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1655857565; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=0cx4sP/7Zlh7hMX6GOEUJ7/O/30tJjigwNwAiVHnCHI=; b=BtdGrQcufdzaU0iVBAxP+IAewpEVoPyO2WrPO6aj0B2OIHc5RgQY/XK7W1BCE3iVuRXCXq tUZFYbAnALun1MTLUtn8iazWZ2OYSJDfiKxkbk/lFINTBF1N/IfIl1g4VMng76dj7Ka5bB 4iuJ+dbLd6qLRrEcafpBsUTBB3hAbhw= X-MC-Unique: 6ypAaGX5OUSFQh7u8bIL1Q-1 From: Juan Quintela To: qemu-devel@nongnu.org Cc: Hailiang Zhang , Eric Blake , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , Fam Zheng , "Dr. David Alan Gilbert" , Juan Quintela , qemu-block@nongnu.org, Stefan Hajnoczi , Markus Armbruster Subject: [PULL 05/25] io: add a QIOChannelNull equivalent to /dev/null Date: Wed, 22 Jun 2022 02:25:27 +0200 Message-Id: <20220622002547.64784-6-quintela@redhat.com> In-Reply-To: <20220622002547.64784-1-quintela@redhat.com> References: <20220622002547.64784-1-quintela@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 2.85 on 10.11.54.7 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=quintela@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -28 X-Spam_score: -2.9 X-Spam_bar: -- X-Spam_report: (-2.9 / 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, RCVD_IN_DNSWL_LOW=-0.7, 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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1655858188720100001 From: Daniel P. Berrang=C3=A9 This is for code which needs a portable equivalent to a QIOChannelFile connected to /dev/null. Signed-off-by: Daniel P. Berrang=C3=A9 Reviewed-by: Juan Quintela Signed-off-by: Juan Quintela --- include/io/channel-null.h | 55 +++++++ io/channel-null.c | 237 ++++++++++++++++++++++++++++++ tests/unit/test-io-channel-null.c | 95 ++++++++++++ io/meson.build | 1 + io/trace-events | 3 + tests/unit/meson.build | 1 + 6 files changed, 392 insertions(+) create mode 100644 include/io/channel-null.h create mode 100644 io/channel-null.c create mode 100644 tests/unit/test-io-channel-null.c diff --git a/include/io/channel-null.h b/include/io/channel-null.h new file mode 100644 index 0000000000..f6d54e63cf --- /dev/null +++ b/include/io/channel-null.h @@ -0,0 +1,55 @@ +/* + * QEMU I/O channels null driver + * + * Copyright (c) 2022 Red Hat, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, see . + * + */ + +#ifndef QIO_CHANNEL_FILE_H +#define QIO_CHANNEL_FILE_H + +#include "io/channel.h" +#include "qom/object.h" + +#define TYPE_QIO_CHANNEL_NULL "qio-channel-null" +OBJECT_DECLARE_SIMPLE_TYPE(QIOChannelNull, QIO_CHANNEL_NULL) + + +/** + * QIOChannelNull: + * + * The QIOChannelNull object provides a channel implementation + * that discards all writes and returns EOF for all reads. + */ + +struct QIOChannelNull { + QIOChannel parent; + bool closed; +}; + + +/** + * qio_channel_null_new: + * + * Create a new IO channel object that discards all writes + * and returns EOF for all reads. + * + * Returns: the new channel object + */ +QIOChannelNull * +qio_channel_null_new(void); + +#endif /* QIO_CHANNEL_NULL_H */ diff --git a/io/channel-null.c b/io/channel-null.c new file mode 100644 index 0000000000..75e3781507 --- /dev/null +++ b/io/channel-null.c @@ -0,0 +1,237 @@ +/* + * QEMU I/O channels null driver + * + * Copyright (c) 2022 Red Hat, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, see . + * + */ + +#include "qemu/osdep.h" +#include "io/channel-null.h" +#include "io/channel-watch.h" +#include "qapi/error.h" +#include "trace.h" +#include "qemu/iov.h" + +typedef struct QIOChannelNullSource QIOChannelNullSource; +struct QIOChannelNullSource { + GSource parent; + QIOChannel *ioc; + GIOCondition condition; +}; + + +QIOChannelNull * +qio_channel_null_new(void) +{ + QIOChannelNull *ioc; + + ioc =3D QIO_CHANNEL_NULL(object_new(TYPE_QIO_CHANNEL_NULL)); + + trace_qio_channel_null_new(ioc); + + return ioc; +} + + +static void +qio_channel_null_init(Object *obj) +{ + QIOChannelNull *ioc =3D QIO_CHANNEL_NULL(obj); + ioc->closed =3D false; +} + + +static ssize_t +qio_channel_null_readv(QIOChannel *ioc, + const struct iovec *iov, + size_t niov, + int **fds G_GNUC_UNUSED, + size_t *nfds G_GNUC_UNUSED, + Error **errp) +{ + QIOChannelNull *nioc =3D QIO_CHANNEL_NULL(ioc); + + if (nioc->closed) { + error_setg_errno(errp, EINVAL, + "Channel is closed"); + return -1; + } + + return 0; +} + + +static ssize_t +qio_channel_null_writev(QIOChannel *ioc, + const struct iovec *iov, + size_t niov, + int *fds G_GNUC_UNUSED, + size_t nfds G_GNUC_UNUSED, + int flags G_GNUC_UNUSED, + Error **errp) +{ + QIOChannelNull *nioc =3D QIO_CHANNEL_NULL(ioc); + + if (nioc->closed) { + error_setg_errno(errp, EINVAL, + "Channel is closed"); + return -1; + } + + return iov_size(iov, niov); +} + + +static int +qio_channel_null_set_blocking(QIOChannel *ioc G_GNUC_UNUSED, + bool enabled G_GNUC_UNUSED, + Error **errp G_GNUC_UNUSED) +{ + return 0; +} + + +static off_t +qio_channel_null_seek(QIOChannel *ioc G_GNUC_UNUSED, + off_t offset G_GNUC_UNUSED, + int whence G_GNUC_UNUSED, + Error **errp G_GNUC_UNUSED) +{ + return 0; +} + + +static int +qio_channel_null_close(QIOChannel *ioc, + Error **errp G_GNUC_UNUSED) +{ + QIOChannelNull *nioc =3D QIO_CHANNEL_NULL(ioc); + + nioc->closed =3D true; + return 0; +} + + +static void +qio_channel_null_set_aio_fd_handler(QIOChannel *ioc G_GNUC_UNUSED, + AioContext *ctx G_GNUC_UNUSED, + IOHandler *io_read G_GNUC_UNUSED, + IOHandler *io_write G_GNUC_UNUSED, + void *opaque G_GNUC_UNUSED) +{ +} + + +static gboolean +qio_channel_null_source_prepare(GSource *source G_GNUC_UNUSED, + gint *timeout) +{ + *timeout =3D -1; + + return TRUE; +} + + +static gboolean +qio_channel_null_source_check(GSource *source G_GNUC_UNUSED) +{ + return TRUE; +} + + +static gboolean +qio_channel_null_source_dispatch(GSource *source, + GSourceFunc callback, + gpointer user_data) +{ + QIOChannelFunc func =3D (QIOChannelFunc)callback; + QIOChannelNullSource *ssource =3D (QIOChannelNullSource *)source; + + return (*func)(ssource->ioc, + ssource->condition, + user_data); +} + + +static void +qio_channel_null_source_finalize(GSource *source) +{ + QIOChannelNullSource *ssource =3D (QIOChannelNullSource *)source; + + object_unref(OBJECT(ssource->ioc)); +} + + +GSourceFuncs qio_channel_null_source_funcs =3D { + qio_channel_null_source_prepare, + qio_channel_null_source_check, + qio_channel_null_source_dispatch, + qio_channel_null_source_finalize +}; + + +static GSource * +qio_channel_null_create_watch(QIOChannel *ioc, + GIOCondition condition) +{ + GSource *source; + QIOChannelNullSource *ssource; + + source =3D g_source_new(&qio_channel_null_source_funcs, + sizeof(QIOChannelNullSource)); + ssource =3D (QIOChannelNullSource *)source; + + ssource->ioc =3D ioc; + object_ref(OBJECT(ioc)); + + ssource->condition =3D condition; + + return source; +} + + +static void +qio_channel_null_class_init(ObjectClass *klass, + void *class_data G_GNUC_UNUSED) +{ + QIOChannelClass *ioc_klass =3D QIO_CHANNEL_CLASS(klass); + + ioc_klass->io_writev =3D qio_channel_null_writev; + ioc_klass->io_readv =3D qio_channel_null_readv; + ioc_klass->io_set_blocking =3D qio_channel_null_set_blocking; + ioc_klass->io_seek =3D qio_channel_null_seek; + ioc_klass->io_close =3D qio_channel_null_close; + ioc_klass->io_create_watch =3D qio_channel_null_create_watch; + ioc_klass->io_set_aio_fd_handler =3D qio_channel_null_set_aio_fd_handl= er; +} + + +static const TypeInfo qio_channel_null_info =3D { + .parent =3D TYPE_QIO_CHANNEL, + .name =3D TYPE_QIO_CHANNEL_NULL, + .instance_size =3D sizeof(QIOChannelNull), + .instance_init =3D qio_channel_null_init, + .class_init =3D qio_channel_null_class_init, +}; + + +static void +qio_channel_null_register_types(void) +{ + type_register_static(&qio_channel_null_info); +} + +type_init(qio_channel_null_register_types); diff --git a/tests/unit/test-io-channel-null.c b/tests/unit/test-io-channel= -null.c new file mode 100644 index 0000000000..b3aab17ccc --- /dev/null +++ b/tests/unit/test-io-channel-null.c @@ -0,0 +1,95 @@ +/* + * QEMU I/O channel null test + * + * Copyright (c) 2022 Red Hat, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, see . + * + */ + +#include "qemu/osdep.h" +#include "io/channel-null.h" +#include "qapi/error.h" + +static gboolean test_io_channel_watch(QIOChannel *ioc, + GIOCondition condition, + gpointer opaque) +{ + GIOCondition *gotcond =3D opaque; + *gotcond =3D condition; + return G_SOURCE_REMOVE; +} + +static void test_io_channel_null_io(void) +{ + g_autoptr(QIOChannelNull) null =3D qio_channel_null_new(); + char buf[1024]; + GIOCondition gotcond =3D 0; + Error *local_err =3D NULL; + + g_assert(qio_channel_write(QIO_CHANNEL(null), + "Hello World", 11, + &error_abort) =3D=3D 11); + + g_assert(qio_channel_read(QIO_CHANNEL(null), + buf, sizeof(buf), + &error_abort) =3D=3D 0); + + qio_channel_add_watch(QIO_CHANNEL(null), + G_IO_IN, + test_io_channel_watch, + &gotcond, + NULL); + + g_main_context_iteration(NULL, false); + + g_assert(gotcond =3D=3D G_IO_IN); + + qio_channel_add_watch(QIO_CHANNEL(null), + G_IO_IN | G_IO_OUT, + test_io_channel_watch, + &gotcond, + NULL); + + g_main_context_iteration(NULL, false); + + g_assert(gotcond =3D=3D (G_IO_IN | G_IO_OUT)); + + qio_channel_close(QIO_CHANNEL(null), &error_abort); + + g_assert(qio_channel_write(QIO_CHANNEL(null), + "Hello World", 11, + &local_err) =3D=3D -1); + g_assert_nonnull(local_err); + + g_clear_pointer(&local_err, error_free); + + g_assert(qio_channel_read(QIO_CHANNEL(null), + buf, sizeof(buf), + &local_err) =3D=3D -1); + g_assert_nonnull(local_err); + + g_clear_pointer(&local_err, error_free); +} + +int main(int argc, char **argv) +{ + module_call_init(MODULE_INIT_QOM); + + g_test_init(&argc, &argv, NULL); + + g_test_add_func("/io/channel/null/io", test_io_channel_null_io); + + return g_test_run(); +} diff --git a/io/meson.build b/io/meson.build index bbcd3c53a4..283b9b2bdb 100644 --- a/io/meson.build +++ b/io/meson.build @@ -3,6 +3,7 @@ io_ss.add(files( 'channel-buffer.c', 'channel-command.c', 'channel-file.c', + 'channel-null.c', 'channel-socket.c', 'channel-tls.c', 'channel-util.c', diff --git a/io/trace-events b/io/trace-events index c5e814eb44..3cc5cf1efd 100644 --- a/io/trace-events +++ b/io/trace-events @@ -10,6 +10,9 @@ qio_task_thread_result(void *task) "Task thread result ta= sk=3D%p" qio_task_thread_source_attach(void *task, void *source) "Task thread sourc= e attach task=3D%p source=3D%p" qio_task_thread_source_cancel(void *task, void *source) "Task thread sourc= e cancel task=3D%p source=3D%p" =20 +# channel-null.c +qio_channel_null_new(void *ioc) "Null new ioc=3D%p" + # channel-socket.c qio_channel_socket_new(void *ioc) "Socket new ioc=3D%p" qio_channel_socket_new_fd(void *ioc, int fd) "Socket new ioc=3D%p fd=3D%d" diff --git a/tests/unit/meson.build b/tests/unit/meson.build index 287b367ec3..b497a41378 100644 --- a/tests/unit/meson.build +++ b/tests/unit/meson.build @@ -88,6 +88,7 @@ if have_block 'test-io-channel-file': ['io-channel-helpers.c', io], 'test-io-channel-command': ['io-channel-helpers.c', io], 'test-io-channel-buffer': ['io-channel-helpers.c', io], + 'test-io-channel-null': [io], 'test-crypto-ivgen': [io], 'test-crypto-afsplit': [io], 'test-crypto-block': [io], --=20 2.35.3 From nobody Wed May 22 00:43:24 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1655858201; cv=none; d=zohomail.com; s=zohoarc; b=BEGYyK1ACPAI1h6HILJ6XvCGYVpi04wAbxEZplbqBS4h/oDUazj/5p9YmxWYlm7Uq2o2sTyDNKL6ci0tYotLO94ZcEezNrfXcc/DmVGgHSb9DCf2yZNDAUiC2ZViNVz3hv5fLG0hPbnzMo6fEMHqzn64BxOTAiD4NDJxuaSGOdE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1655858201; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=NWmVpRmMqZxslS2wDEvplRHj16T+Uv3aYbCe3PRbN4I=; b=Fei0eTmNaRhlG9AMZos60rSdl2MbU6MzIUM8l7Up0Idvu1bEw+PNSLmmsA0waCEwr+kWW5vd1jFDOfXlzgKx3T3mow7OwM4zeN2xfEn8ODnjvWTAt4ZndUn2zG5e4VEgxuR5JgBIpYtfFnSAYI2+u7dlmzPg5PlwmufxEWIXh5c= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1655858201146700.623418364171; Tue, 21 Jun 2022 17:36:41 -0700 (PDT) Received: from localhost ([::1]:44612 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1o3oMJ-0000qF-Si for importer@patchew.org; Tue, 21 Jun 2022 20:36:40 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:56246) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1o3oCG-0002vd-3P for qemu-devel@nongnu.org; Tue, 21 Jun 2022 20:26:16 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:44129) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1o3oC6-00066L-Dg for qemu-devel@nongnu.org; Tue, 21 Jun 2022 20:26:15 -0400 Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-665-xVWC-l3BN9OTTxYA2tjiNw-1; Tue, 21 Jun 2022 20:26:04 -0400 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.rdu2.redhat.com [10.11.54.7]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id A78713C0CD46; Wed, 22 Jun 2022 00:26:03 +0000 (UTC) Received: from secure.mitica (unknown [10.39.192.22]) by smtp.corp.redhat.com (Postfix) with ESMTP id F0BF8141510D; Wed, 22 Jun 2022 00:26:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1655857565; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=NWmVpRmMqZxslS2wDEvplRHj16T+Uv3aYbCe3PRbN4I=; b=DCrGnP/1raMc1sS0EhPGQFlBH0XLqxhBz0mKCKyGXXjRjyF0bdM+sBdua8NMGVohUMjmQd Ppy1ICPqFT018WBkVWDjf7xgk5Ys8WPkdHJ8xMTq4FIi47EXuog+wUNG8WTs9f2tyAgDTl 5fwHPynPrLmqRvD4m00kLJgPnWiwy3Y= X-MC-Unique: xVWC-l3BN9OTTxYA2tjiNw-1 From: Juan Quintela To: qemu-devel@nongnu.org Cc: Hailiang Zhang , Eric Blake , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , Fam Zheng , "Dr. David Alan Gilbert" , Juan Quintela , qemu-block@nongnu.org, Stefan Hajnoczi , Markus Armbruster Subject: [PULL 06/25] migration: switch to use QIOChannelNull for dummy channel Date: Wed, 22 Jun 2022 02:25:28 +0200 Message-Id: <20220622002547.64784-7-quintela@redhat.com> In-Reply-To: <20220622002547.64784-1-quintela@redhat.com> References: <20220622002547.64784-1-quintela@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 2.85 on 10.11.54.7 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=quintela@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -28 X-Spam_score: -2.9 X-Spam_bar: -- X-Spam_report: (-2.9 / 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, RCVD_IN_DNSWL_LOW=-0.7, 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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1655858202610100001 From: Daniel P. Berrang=C3=A9 This removes one further custom impl of QEMUFile, in favour of a QIOChannel based impl. Reviewed-by: Eric Blake Signed-off-by: Daniel P. Berrang=C3=A9 Reviewed-by: Juan Quintela Signed-off-by: Juan Quintela --- migration/ram.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/migration/ram.c b/migration/ram.c index 5f5e37f64d..89082716d6 100644 --- a/migration/ram.c +++ b/migration/ram.c @@ -32,11 +32,13 @@ #include "qemu/bitmap.h" #include "qemu/madvise.h" #include "qemu/main-loop.h" +#include "io/channel-null.h" #include "xbzrle.h" #include "ram.h" #include "migration.h" #include "migration/register.h" #include "migration/misc.h" +#include "migration/qemu-file-channel.h" #include "qemu-file.h" #include "postcopy-ram.h" #include "page_cache.h" @@ -457,8 +459,6 @@ static QemuThread *compress_threads; */ static QemuMutex comp_done_lock; static QemuCond comp_done_cond; -/* The empty QEMUFileOps will be used by file in CompressParam */ -static const QEMUFileOps empty_ops =3D { }; =20 static QEMUFile *decomp_file; static DecompressParam *decomp_param; @@ -569,7 +569,8 @@ static int compress_threads_save_setup(void) /* comp_param[i].file is just used as a dummy buffer to save data, * set its ops to empty. */ - comp_param[i].file =3D qemu_fopen_ops(NULL, &empty_ops, false); + comp_param[i].file =3D qemu_fopen_channel_output( + QIO_CHANNEL(qio_channel_null_new())); comp_param[i].done =3D true; comp_param[i].quit =3D false; qemu_mutex_init(&comp_param[i].mutex); --=20 2.35.3 From nobody Wed May 22 00:43:24 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1655857882; cv=none; d=zohomail.com; s=zohoarc; b=JWxaaBVdahlbdQwchkeLyOmEuw60pL4cHas0CRONgOpxYfwhKul1s7m0KcxXVeseYkpjOw/cd0XdBI9uWD+RClZEfWF+uoB9rvwOcse2AxFvAmYPLlrabYFYvchxfpmFKVorDR6NeDIZAxNShYN21Kyl91H4JeWUVDndYrA1ZG4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1655857882; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=g+uMnRaLeQKuWtyD+nFNekjbp1dKQlHO4G3vZ/fbLuw=; b=acSL/LLsI0UAG/15qskw3dqLRLY92TQvslMzlpU6GBNYr5H1r0s5pUOJ5Do7bpDuOBrl6X1FwazeMEGYG7rFB/G4CycJtXHhmTtGkr2KZtKZ2+jRotJ/m57ORgmf5b4XTfdpT52cbd3E5YErIIxqU0kBatuKcVUa4tAi/PPqkko= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1655857882501761.8837037675871; Tue, 21 Jun 2022 17:31:22 -0700 (PDT) Received: from localhost ([::1]:35870 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1o3oHB-0003Ga-DM for importer@patchew.org; Tue, 21 Jun 2022 20:31:21 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:56254) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1o3oCG-0002wG-Eu for qemu-devel@nongnu.org; Tue, 21 Jun 2022 20:26:17 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:32677) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1o3oCB-00066c-9t for qemu-devel@nongnu.org; Tue, 21 Jun 2022 20:26:16 -0400 Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-98-u_RX8FZKN1qZg1ncv0mLwA-1; Tue, 21 Jun 2022 20:26:06 -0400 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.rdu2.redhat.com [10.11.54.7]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id A83C785A582; Wed, 22 Jun 2022 00:26:05 +0000 (UTC) Received: from secure.mitica (unknown [10.39.192.22]) by smtp.corp.redhat.com (Postfix) with ESMTP id F0AA21410F3B; Wed, 22 Jun 2022 00:26:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1655857570; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=g+uMnRaLeQKuWtyD+nFNekjbp1dKQlHO4G3vZ/fbLuw=; b=BCOJTNnmSmIVtlzfStVG0IP8xaC7KdtRBN+/WHoVuTwwPtPFOBX/xjE8zhEgc81Vuesud6 Y9HpJWFyv/K1GqP21gl0i0BKgh5J4cwV65z4CizicUflMFjBc4L3gtBILNVdf07gCYRyoY xd9xQgYsObaFUcbaI/GoS99M0eLArcA= X-MC-Unique: u_RX8FZKN1qZg1ncv0mLwA-1 From: Juan Quintela To: qemu-devel@nongnu.org Cc: Hailiang Zhang , Eric Blake , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , Fam Zheng , "Dr. David Alan Gilbert" , Juan Quintela , qemu-block@nongnu.org, Stefan Hajnoczi , Markus Armbruster Subject: [PULL 07/25] migration: remove unreachble RDMA code in save_hook impl Date: Wed, 22 Jun 2022 02:25:29 +0200 Message-Id: <20220622002547.64784-8-quintela@redhat.com> In-Reply-To: <20220622002547.64784-1-quintela@redhat.com> References: <20220622002547.64784-1-quintela@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 2.85 on 10.11.54.7 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=quintela@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -28 X-Spam_score: -2.9 X-Spam_bar: -- X-Spam_report: (-2.9 / 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, RCVD_IN_DNSWL_LOW=-0.7, 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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1655857883045100004 From: Daniel P. Berrang=C3=A9 The QEMUFile 'save_hook' callback has a 'size_t size' parameter. The RDMA impl of this has logic that takes different actions depending on whether the value is zero or non-zero. It has commented out logic that would have taken further actions if the value was negative. The only place where the 'save_hook' callback is invoked is the ram_control_save_page() method, which passes 'size' through from its caller. The only caller of this method is in turn control_save_page(). This method unconditionally passes the 'TARGET_PAGE_SIZE' constant for the 'size' parameter. IOW, the only scenario for 'size' that can execute in the qemu_rdma_save_page method is 'size > 0'. The remaining code has been unreachable since RDMA support was first introduced 9 years ago. Reviewed-by: Eric Blake Reviewed-by: Dr. David Alan Gilbert Signed-off-by: Daniel P. Berrang=C3=A9 Reviewed-by: Juan Quintela Signed-off-by: Juan Quintela --- migration/rdma.c | 120 +++++++++-------------------------------------- 1 file changed, 21 insertions(+), 99 deletions(-) diff --git a/migration/rdma.c b/migration/rdma.c index 8504152f39..c5fa4a408a 100644 --- a/migration/rdma.c +++ b/migration/rdma.c @@ -1462,34 +1462,6 @@ static uint64_t qemu_rdma_make_wrid(uint64_t wr_id, = uint64_t index, return result; } =20 -/* - * Set bit for unregistration in the next iteration. - * We cannot transmit right here, but will unpin later. - */ -static void qemu_rdma_signal_unregister(RDMAContext *rdma, uint64_t index, - uint64_t chunk, uint64_t wr_id) -{ - if (rdma->unregistrations[rdma->unregister_next] !=3D 0) { - error_report("rdma migration: queue is full"); - } else { - RDMALocalBlock *block =3D &(rdma->local_ram_blocks.block[index]); - - if (!test_and_set_bit(chunk, block->unregister_bitmap)) { - trace_qemu_rdma_signal_unregister_append(chunk, - rdma->unregister_next= ); - - rdma->unregistrations[rdma->unregister_next++] =3D - qemu_rdma_make_wrid(wr_id, index, chunk); - - if (rdma->unregister_next =3D=3D RDMA_SIGNALED_SEND_MAX) { - rdma->unregister_next =3D 0; - } - } else { - trace_qemu_rdma_signal_unregister_already(chunk); - } - } -} - /* * Consult the connection manager to see a work request * (of any kind) has completed. @@ -3237,23 +3209,7 @@ qio_channel_rdma_shutdown(QIOChannel *ioc, * Offset is an offset to be added to block_offset and used * to also lookup the corresponding RAMBlock. * - * @size > 0 : - * Initiate an transfer this size. - * - * @size =3D=3D 0 : - * A 'hint' or 'advice' that means that we wish to speculatively - * and asynchronously unregister this memory. In this case, there i= s no - * guarantee that the unregister will actually happen, for example, - * if the memory is being actively transmitted. Additionally, the m= emory - * may be re-registered at any future time if a write within the sa= me - * chunk was requested again, even if you attempted to unregister it - * here. - * - * @size < 0 : TODO, not yet supported - * Unregister the memory NOW. This means that the caller does not - * expect there to be any future RDMA transfers and we just want to= clean - * things up. This is used in case the upper layer owns the memory = and - * cannot wait for qemu_fclose() to occur. + * @size : Number of bytes to transfer * * @bytes_sent : User-specificed pointer to indicate how many bytes were * sent. Usually, this will not be more than a few bytes = of @@ -3282,61 +3238,27 @@ static size_t qemu_rdma_save_page(QEMUFile *f, void= *opaque, =20 qemu_fflush(f); =20 - if (size > 0) { - /* - * Add this page to the current 'chunk'. If the chunk - * is full, or the page doesn't belong to the current chunk, - * an actual RDMA write will occur and a new chunk will be formed. - */ - ret =3D qemu_rdma_write(f, rdma, block_offset, offset, size); - if (ret < 0) { - error_report("rdma migration: write error! %d", ret); - goto err; - } + /* + * Add this page to the current 'chunk'. If the chunk + * is full, or the page doesn't belong to the current chunk, + * an actual RDMA write will occur and a new chunk will be formed. + */ + ret =3D qemu_rdma_write(f, rdma, block_offset, offset, size); + if (ret < 0) { + error_report("rdma migration: write error! %d", ret); + goto err; + } =20 - /* - * We always return 1 bytes because the RDMA - * protocol is completely asynchronous. We do not yet know - * whether an identified chunk is zero or not because we're - * waiting for other pages to potentially be merged with - * the current chunk. So, we have to call qemu_update_position() - * later on when the actual write occurs. - */ - if (bytes_sent) { - *bytes_sent =3D 1; - } - } else { - uint64_t index, chunk; - - /* TODO: Change QEMUFileOps prototype to be signed: size_t =3D> lo= ng - if (size < 0) { - ret =3D qemu_rdma_drain_cq(f, rdma); - if (ret < 0) { - fprintf(stderr, "rdma: failed to synchronously drain" - " completion queue before unregistration.\= n"); - goto err; - } - } - */ - - ret =3D qemu_rdma_search_ram_block(rdma, block_offset, - offset, size, &index, &chunk); - - if (ret) { - error_report("ram block search failed"); - goto err; - } - - qemu_rdma_signal_unregister(rdma, index, chunk, 0); - - /* - * TODO: Synchronous, guaranteed unregistration (should not occur = during - * fast-path). Otherwise, unregisters will process on the next cal= l to - * qemu_rdma_drain_cq() - if (size < 0) { - qemu_rdma_unregister_waiting(rdma); - } - */ + /* + * We always return 1 bytes because the RDMA + * protocol is completely asynchronous. We do not yet know + * whether an identified chunk is zero or not because we're + * waiting for other pages to potentially be merged with + * the current chunk. So, we have to call qemu_update_position() + * later on when the actual write occurs. + */ + if (bytes_sent) { + *bytes_sent =3D 1; } =20 /* --=20 2.35.3 From nobody Wed May 22 00:43:24 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1655858440; cv=none; d=zohomail.com; s=zohoarc; b=K1OMrkbx436oakqMeu+8rboeMK/uZzM+eoSOlXzNxzpsR83T+2pFIJ77vI8ldY4RxZr8zFUHI7QEfbzRFp45DfNUfnBA0QOsTrWCWB/TDf1rtexC9n8fMILEoUXPRsGvA72/5QmZysdjlwvPR593db+5djKdPMQkE8+jDNtAl7o= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1655858440; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=czs2z7mw1opsiuh2ICHWW14lwUYXZu/iBz7oLEWD5fw=; b=UdWyaSW2QZHJfc8aPaSrnW/YC54PaQTvDJk6hr7V2qu9VcGL+NenPpPW9wFAmBAGU4+Cp2GT7KICq7zti/OM9kmt2rB4bmziePpnSeWvHc4tQ9Js5nnEYvt/t3eXJFecOH/SpxPE5RxLUdlw/IHW1j3UZmurdUBMjqqkCVQOGDQ= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 16558584409661015.9211294667168; Tue, 21 Jun 2022 17:40:40 -0700 (PDT) Received: from localhost ([::1]:53072 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1o3oQB-0006Wb-EO for importer@patchew.org; Tue, 21 Jun 2022 20:40:39 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:56300) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1o3oCI-0002xs-AR for qemu-devel@nongnu.org; Tue, 21 Jun 2022 20:26:18 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:45468) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1o3oCB-00066i-Oz for qemu-devel@nongnu.org; Tue, 21 Jun 2022 20:26:16 -0400 Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-668-aHrVB70sPtKWiZs8jFTa5A-1; Tue, 21 Jun 2022 20:26:08 -0400 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.rdu2.redhat.com [10.11.54.7]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id C0BDB3804507; Wed, 22 Jun 2022 00:26:07 +0000 (UTC) Received: from secure.mitica (unknown [10.39.192.22]) by smtp.corp.redhat.com (Postfix) with ESMTP id 0036F141510D; Wed, 22 Jun 2022 00:26:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1655857571; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=czs2z7mw1opsiuh2ICHWW14lwUYXZu/iBz7oLEWD5fw=; b=SwvBwBGEGv/yOQrZzoKy4dqVBKAms+iJaYxic0R47U/mqCdZ0A4acSDxrihWIuffsK6z+3 iP8/WQgff2ZwCj0+8AtrXrMo7SeazkkNPI48UHh10odunyKVTB9HcadzhSECTp2PXlfLRM vf+U0vf0sjuUyev8lG0DrykVcAtNpNo= X-MC-Unique: aHrVB70sPtKWiZs8jFTa5A-1 From: Juan Quintela To: qemu-devel@nongnu.org Cc: Hailiang Zhang , Eric Blake , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , Fam Zheng , "Dr. David Alan Gilbert" , Juan Quintela , qemu-block@nongnu.org, Stefan Hajnoczi , Markus Armbruster Subject: [PULL 08/25] migration: rename rate limiting fields in QEMUFile Date: Wed, 22 Jun 2022 02:25:30 +0200 Message-Id: <20220622002547.64784-9-quintela@redhat.com> In-Reply-To: <20220622002547.64784-1-quintela@redhat.com> References: <20220622002547.64784-1-quintela@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 2.85 on 10.11.54.7 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=quintela@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -28 X-Spam_score: -2.9 X-Spam_bar: -- X-Spam_report: (-2.9 / 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, RCVD_IN_DNSWL_LOW=-0.7, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=unavailable 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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1655858442278100001 From: Daniel P. Berrang=C3=A9 This renames the following QEMUFile fields * bytes_xfer -> rate_limit_used * xfer_limit -> rate_limit_max The intent is to make it clear that 'bytes_xfer' is specifically related to rate limiting of data and applies to data queued, which need not have been transferred on the wire yet if a flush hasn't taken place. Reviewed-by: Dr. David Alan Gilbert Signed-off-by: Daniel P. Berrang=C3=A9 Reviewed-by: Juan Quintela Signed-off-by: Juan Quintela --- migration/qemu-file.c | 30 +++++++++++++++++++----------- 1 file changed, 19 insertions(+), 11 deletions(-) diff --git a/migration/qemu-file.c b/migration/qemu-file.c index 1479cddad9..03f0b13a55 100644 --- a/migration/qemu-file.c +++ b/migration/qemu-file.c @@ -39,8 +39,16 @@ struct QEMUFile { const QEMUFileHooks *hooks; void *opaque; =20 - int64_t bytes_xfer; - int64_t xfer_limit; + /* + * Maximum amount of data in bytes to transfer during one + * rate limiting time window + */ + int64_t rate_limit_max; + /* + * Total amount of data in bytes queued for transfer + * during this rate limiting time window + */ + int64_t rate_limit_used; =20 int64_t pos; /* start of buffer when writing, end of buffer when reading */ @@ -304,7 +312,7 @@ size_t ram_control_save_page(QEMUFile *f, ram_addr_t bl= ock_offset, int ret =3D f->hooks->save_page(f, f->opaque, block_offset, offset, size, bytes_sent); if (ret !=3D RAM_SAVE_CONTROL_NOT_SUPP) { - f->bytes_xfer +=3D size; + f->rate_limit_used +=3D size; } =20 if (ret !=3D RAM_SAVE_CONTROL_DELAYED && @@ -457,7 +465,7 @@ void qemu_put_buffer_async(QEMUFile *f, const uint8_t *= buf, size_t size, return; } =20 - f->bytes_xfer +=3D size; + f->rate_limit_used +=3D size; add_to_iovec(f, buf, size, may_free); } =20 @@ -475,7 +483,7 @@ void qemu_put_buffer(QEMUFile *f, const uint8_t *buf, s= ize_t size) l =3D size; } memcpy(f->buf + f->buf_index, buf, l); - f->bytes_xfer +=3D l; + f->rate_limit_used +=3D l; add_buf_to_iovec(f, l); if (qemu_file_get_error(f)) { break; @@ -492,7 +500,7 @@ void qemu_put_byte(QEMUFile *f, int v) } =20 f->buf[f->buf_index] =3D v; - f->bytes_xfer++; + f->rate_limit_used++; add_buf_to_iovec(f, 1); } =20 @@ -674,7 +682,7 @@ int qemu_file_rate_limit(QEMUFile *f) if (qemu_file_get_error(f)) { return 1; } - if (f->xfer_limit > 0 && f->bytes_xfer > f->xfer_limit) { + if (f->rate_limit_max > 0 && f->rate_limit_used > f->rate_limit_max) { return 1; } return 0; @@ -682,22 +690,22 @@ int qemu_file_rate_limit(QEMUFile *f) =20 int64_t qemu_file_get_rate_limit(QEMUFile *f) { - return f->xfer_limit; + return f->rate_limit_max; } =20 void qemu_file_set_rate_limit(QEMUFile *f, int64_t limit) { - f->xfer_limit =3D limit; + f->rate_limit_max =3D limit; } =20 void qemu_file_reset_rate_limit(QEMUFile *f) { - f->bytes_xfer =3D 0; + f->rate_limit_used =3D 0; } =20 void qemu_file_update_transfer(QEMUFile *f, int64_t len) { - f->bytes_xfer +=3D len; + f->rate_limit_used +=3D len; } =20 void qemu_put_be16(QEMUFile *f, unsigned int v) --=20 2.35.3 From nobody Wed May 22 00:43:24 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1655857920; cv=none; d=zohomail.com; s=zohoarc; b=iMt+5iiWtbpzkwoQbxgfZnuRAZ+m+wLvI1LQ7SnbU1c180Wo8zZzQx4beVsmiplJT96MqovThSHWrdUKAX944SLoNi+Ir/MGAt3q7DwUctN5pK6Ox+F7T1c2E70Rqo2a9jsFHr3fOK5NZ9pSMR317EH/S+VJIpJRNyKaf/KSSLg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1655857920; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=WM2cPEJ1DhIuqYDYVpYdjNnleTZpBvnBIkLZYrWreZ8=; b=lPGyaGwwtcBgYfl4wmjhD9x48RcAfFlJObneqgCIuSA0sTcf1OiDIpAwYlEq17IxcDQzWW7N7lySbmDwRQNRWXVGgHov0QzglyIeJ0Ktx62KAewgmyrY25Q5BoOTWLs7sNwjAnX8BirszMrlkKQg7RYJ1BZSlvzKEDKpnPoqDk8= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1655857920141295.4415226612084; Tue, 21 Jun 2022 17:32:00 -0700 (PDT) Received: from localhost ([::1]:37196 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1o3oHn-00048G-5h for importer@patchew.org; Tue, 21 Jun 2022 20:31:59 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:56302) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1o3oCI-0002xt-A0 for qemu-devel@nongnu.org; Tue, 21 Jun 2022 20:26:18 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:52106) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1o3oCD-000679-To for qemu-devel@nongnu.org; Tue, 21 Jun 2022 20:26:17 -0400 Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-161-XpCaU5AbMEmpu-Meqt7lwQ-1; Tue, 21 Jun 2022 20:26:10 -0400 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.rdu2.redhat.com [10.11.54.7]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id C3B01101E165; Wed, 22 Jun 2022 00:26:09 +0000 (UTC) Received: from secure.mitica (unknown [10.39.192.22]) by smtp.corp.redhat.com (Postfix) with ESMTP id 18975141510D; Wed, 22 Jun 2022 00:26:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1655857573; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=WM2cPEJ1DhIuqYDYVpYdjNnleTZpBvnBIkLZYrWreZ8=; b=T2HARKaG9lvRp3cTr8gpa6CJ6zNqYhr0b66mGtLn2Agx1NtUIDvWuBwcsfphWhgqt5fcs5 RiOD5zEBPcayEt/he3le22EjYa3o02/QzCQxQPWJCJJUyZ6msBNRcoBfE+4coJpe8SsW+m /qvh066QoM8E/g14qUu39OyX/oLkXdk= X-MC-Unique: XpCaU5AbMEmpu-Meqt7lwQ-1 From: Juan Quintela To: qemu-devel@nongnu.org Cc: Hailiang Zhang , Eric Blake , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , Fam Zheng , "Dr. David Alan Gilbert" , Juan Quintela , qemu-block@nongnu.org, Stefan Hajnoczi , Markus Armbruster Subject: [PULL 09/25] migration: rename 'pos' field in QEMUFile to 'bytes_processed' Date: Wed, 22 Jun 2022 02:25:31 +0200 Message-Id: <20220622002547.64784-10-quintela@redhat.com> In-Reply-To: <20220622002547.64784-1-quintela@redhat.com> References: <20220622002547.64784-1-quintela@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 2.85 on 10.11.54.7 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=quintela@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -28 X-Spam_score: -2.9 X-Spam_bar: -- X-Spam_report: (-2.9 / 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, RCVD_IN_DNSWL_LOW=-0.7, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=unavailable 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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1655857921236100001 From: Daniel P. Berrang=C3=A9 The field name 'pos' gives the misleading impression that the QEMUFile objects are seekable. This is not the case, as in general we just have an opaque stream. The users of this method are only interested in the total bytes processed. This switches to a new name that reflects the intended usage. Every QIOChannel backed impl of QEMUFile is currently ignoring the 'pos' field. The only QEMUFile impl using 'pos' as an offset for I/O is the block device vmstate. A later patch is introducing a QIOChannel impl for the vmstate, and to handle this it is tracking a file offset itself internally to the QIOChannel impl. So when we later eliminate the QEMUFileOps callbacks later, the 'pos' field will no longer be used from any I/O read/write methods. Reviewed-by: Dr. David Alan Gilbert Signed-off-by: Daniel P. Berrang=C3=A9 Reviewed-by: Juan Quintela Signed-off-by: Juan Quintela --- migration/qemu-file.c | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/migration/qemu-file.c b/migration/qemu-file.c index 03f0b13a55..b21da4c5bf 100644 --- a/migration/qemu-file.c +++ b/migration/qemu-file.c @@ -50,8 +50,9 @@ struct QEMUFile { */ int64_t rate_limit_used; =20 - int64_t pos; /* start of buffer when writing, end of buffer - when reading */ + /* The sum of bytes transferred on the wire */ + int64_t total_transferred; + int buf_index; int buf_size; /* 0 when writing */ uint8_t buf[IO_BUF_SIZE]; @@ -241,14 +242,14 @@ void qemu_fflush(QEMUFile *f) } if (f->iovcnt > 0) { expect =3D iov_size(f->iov, f->iovcnt); - ret =3D f->ops->writev_buffer(f->opaque, f->iov, f->iovcnt, f->pos, + ret =3D f->ops->writev_buffer(f->opaque, f->iov, f->iovcnt, f->tot= al_transferred, &local_error); =20 qemu_iovec_release_ram(f); } =20 if (ret >=3D 0) { - f->pos +=3D ret; + f->total_transferred +=3D ret; } /* We expect the QEMUFile write impl to send the full * data set we requested, so sanity check that. @@ -357,11 +358,11 @@ static ssize_t qemu_fill_buffer(QEMUFile *f) return 0; } =20 - len =3D f->ops->get_buffer(f->opaque, f->buf + pending, f->pos, + len =3D f->ops->get_buffer(f->opaque, f->buf + pending, f->total_trans= ferred, IO_BUF_SIZE - pending, &local_error); if (len > 0) { f->buf_size +=3D len; - f->pos +=3D len; + f->total_transferred +=3D len; } else if (len =3D=3D 0) { qemu_file_set_error_obj(f, -EIO, local_error); } else if (len !=3D -EAGAIN) { @@ -375,7 +376,7 @@ static ssize_t qemu_fill_buffer(QEMUFile *f) =20 void qemu_update_position(QEMUFile *f, size_t size) { - f->pos +=3D size; + f->total_transferred +=3D size; } =20 /** Closes the file @@ -658,7 +659,7 @@ int qemu_get_byte(QEMUFile *f) =20 int64_t qemu_ftell_fast(QEMUFile *f) { - int64_t ret =3D f->pos; + int64_t ret =3D f->total_transferred; int i; =20 for (i =3D 0; i < f->iovcnt; i++) { @@ -671,7 +672,7 @@ int64_t qemu_ftell_fast(QEMUFile *f) int64_t qemu_ftell(QEMUFile *f) { qemu_fflush(f); - return f->pos; + return f->total_transferred; } =20 int qemu_file_rate_limit(QEMUFile *f) --=20 2.35.3 From nobody Wed May 22 00:43:24 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1655858221; cv=none; d=zohomail.com; s=zohoarc; b=k7lh5PQu5R93QI3fC77g3/nINqPnc+J2SaDm+t0ocr3YuscmeBXOdtBdbZ97+KfazUcbb3rQ2uFMLI5rQ4UK0EqUMM/EkvQrsGDLJPf4rFjtaTVJzWwGdvfH442TKqHhy86lhqkL2TKlZZfi0j+2RApk5Pf8naTKcRv6oW8khyA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1655858221; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=Xmd1ImPDx092hOYqoxlvuLfz6j3en1eFIou/U1Z29kI=; b=M0VZtPcoo7c/3rDOfZnm+WkTiLjzwQoCUPLHNF147b098Bw+WIdfh+oAQ0kHIDMppjQO9zxSd2GMmgb8xBW+rKpXZBIS2eXsv0ZchcybDowl08tB6BfPIWKLJkEU6bUufk3dmAFvW5tlYM0DaAJV/SSliULtbfsKZMh6KtBHVlQ= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1655858221328759.4512309543067; Tue, 21 Jun 2022 17:37:01 -0700 (PDT) Received: from localhost ([::1]:45938 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1o3oMd-0001iT-C5 for importer@patchew.org; Tue, 21 Jun 2022 20:36:59 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:56296) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1o3oCI-0002xe-A6 for qemu-devel@nongnu.org; Tue, 21 Jun 2022 20:26:18 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:41940) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1o3oCD-00067C-W1 for qemu-devel@nongnu.org; Tue, 21 Jun 2022 20:26:17 -0400 Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-17-bsiLcCt6NS2PmJkviKbIig-1; Tue, 21 Jun 2022 20:26:12 -0400 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.rdu2.redhat.com [10.11.54.7]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id C7E8F101E165; Wed, 22 Jun 2022 00:26:11 +0000 (UTC) Received: from secure.mitica (unknown [10.39.192.22]) by smtp.corp.redhat.com (Postfix) with ESMTP id 1BB3F141510D; Wed, 22 Jun 2022 00:26:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1655857573; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Xmd1ImPDx092hOYqoxlvuLfz6j3en1eFIou/U1Z29kI=; b=O0Qi0De0MY1XRqs4OJXWOUZvGe/U678dbHT6FiGA29wFc3XA964V6HyirB73sHN97a2ui8 UD4yO2YfMCEXlxdxV+Nx2KDngAh61z4T3j9LA/u71BZjpCye6p0H08eQ1u97D7UEJqmGsO 0bqc+QkTMtLIoogshQ3NmZK91VvJJww= X-MC-Unique: bsiLcCt6NS2PmJkviKbIig-1 From: Juan Quintela To: qemu-devel@nongnu.org Cc: Hailiang Zhang , Eric Blake , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , Fam Zheng , "Dr. David Alan Gilbert" , Juan Quintela , qemu-block@nongnu.org, Stefan Hajnoczi , Markus Armbruster Subject: [PULL 10/25] migration: rename qemu_ftell to qemu_file_total_transferred Date: Wed, 22 Jun 2022 02:25:32 +0200 Message-Id: <20220622002547.64784-11-quintela@redhat.com> In-Reply-To: <20220622002547.64784-1-quintela@redhat.com> References: <20220622002547.64784-1-quintela@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 2.85 on 10.11.54.7 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=quintela@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -28 X-Spam_score: -2.9 X-Spam_bar: -- X-Spam_report: (-2.9 / 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, RCVD_IN_DNSWL_LOW=-0.7, 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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1655858222502100001 From: Daniel P. Berrang=C3=A9 The name 'ftell' gives the misleading impression that the QEMUFile objects are seekable. This is not the case, as in general we just have an opaque stream. The users of this method are only interested in the total bytes processed. This switches to a new name that reflects the intended usage. Reviewed-by: Dr. David Alan Gilbert Signed-off-by: Daniel P. Berrang=C3=A9 Reviewed-by: Juan Quintela Signed-off-by: Juan Quintela --- migration/qemu-file.h | 33 +++++++++++++++++++++++++++++++-- migration/block.c | 10 +++++----- migration/migration.c | 3 ++- migration/qemu-file.c | 4 ++-- migration/savevm.c | 6 +++--- migration/vmstate.c | 4 ++-- 6 files changed, 45 insertions(+), 15 deletions(-) diff --git a/migration/qemu-file.h b/migration/qemu-file.h index 3f36d4dc8c..05f6aef903 100644 --- a/migration/qemu-file.h +++ b/migration/qemu-file.h @@ -124,8 +124,37 @@ QEMUFile *qemu_fopen_ops(void *opaque, const QEMUFileO= ps *ops, bool has_ioc); void qemu_file_set_hooks(QEMUFile *f, const QEMUFileHooks *hooks); int qemu_get_fd(QEMUFile *f); int qemu_fclose(QEMUFile *f); -int64_t qemu_ftell(QEMUFile *f); -int64_t qemu_ftell_fast(QEMUFile *f); + +/* + * qemu_file_total_transferred: + * + * Report the total number of bytes transferred with + * this file. + * + * For writable files, any pending buffers will be + * flushed, so the reported value will be equal to + * the number of bytes transferred on the wire. + * + * For readable files, the reported value will be + * equal to the number of bytes transferred on the + * wire. + * + * Returns: the total bytes transferred + */ +int64_t qemu_file_total_transferred(QEMUFile *f); + +/* + * qemu_file_total_transferred_fast: + * + * As qemu_file_total_transferred except for writable + * files, where no flush is performed and the reported + * amount will include the size of any queued buffers, + * on top of the amount actually transferred. + * + * Returns: the total bytes transferred and queued + */ +int64_t qemu_file_total_transferred_fast(QEMUFile *f); + /* * put_buffer without copying the buffer. * The buffer should be available till it is sent asynchronously. diff --git a/migration/block.c b/migration/block.c index 077a413325..823453c977 100644 --- a/migration/block.c +++ b/migration/block.c @@ -756,8 +756,8 @@ static int block_save_setup(QEMUFile *f, void *opaque) static int block_save_iterate(QEMUFile *f, void *opaque) { int ret; - int64_t last_ftell =3D qemu_ftell(f); - int64_t delta_ftell; + int64_t last_bytes =3D qemu_file_total_transferred(f); + int64_t delta_bytes; =20 trace_migration_block_save("iterate", block_mig_state.submitted, block_mig_state.transferred); @@ -809,10 +809,10 @@ static int block_save_iterate(QEMUFile *f, void *opaq= ue) } =20 qemu_put_be64(f, BLK_MIG_FLAG_EOS); - delta_ftell =3D qemu_ftell(f) - last_ftell; - if (delta_ftell > 0) { + delta_bytes =3D qemu_file_total_transferred(f) - last_bytes; + if (delta_bytes > 0) { return 1; - } else if (delta_ftell < 0) { + } else if (delta_bytes < 0) { return -1; } else { return 0; diff --git a/migration/migration.c b/migration/migration.c index cc253d66e3..e07d9359c6 100644 --- a/migration/migration.c +++ b/migration/migration.c @@ -3533,7 +3533,8 @@ static MigThrError migration_detect_error(MigrationSt= ate *s) /* How many bytes have we transferred since the beginning of the migration= */ static uint64_t migration_total_bytes(MigrationState *s) { - return qemu_ftell(s->to_dst_file) + ram_counters.multifd_bytes; + return qemu_file_total_transferred(s->to_dst_file) + + ram_counters.multifd_bytes; } =20 static void migration_calculate_complete(MigrationState *s) diff --git a/migration/qemu-file.c b/migration/qemu-file.c index b21da4c5bf..664ac77067 100644 --- a/migration/qemu-file.c +++ b/migration/qemu-file.c @@ -657,7 +657,7 @@ int qemu_get_byte(QEMUFile *f) return result; } =20 -int64_t qemu_ftell_fast(QEMUFile *f) +int64_t qemu_file_total_transferred_fast(QEMUFile *f) { int64_t ret =3D f->total_transferred; int i; @@ -669,7 +669,7 @@ int64_t qemu_ftell_fast(QEMUFile *f) return ret; } =20 -int64_t qemu_ftell(QEMUFile *f) +int64_t qemu_file_total_transferred(QEMUFile *f) { qemu_fflush(f); return f->total_transferred; diff --git a/migration/savevm.c b/migration/savevm.c index d9076897b8..75d05f1a84 100644 --- a/migration/savevm.c +++ b/migration/savevm.c @@ -916,9 +916,9 @@ static void vmstate_save_old_style(QEMUFile *f, SaveSta= teEntry *se, { int64_t old_offset, size; =20 - old_offset =3D qemu_ftell_fast(f); + old_offset =3D qemu_file_total_transferred_fast(f); se->ops->save_state(f, se->opaque); - size =3D qemu_ftell_fast(f) - old_offset; + size =3D qemu_file_total_transferred_fast(f) - old_offset; =20 if (vmdesc) { json_writer_int64(vmdesc, "size", size); @@ -2887,7 +2887,7 @@ bool save_snapshot(const char *name, bool overwrite, = const char *vmstate, goto the_end; } ret =3D qemu_savevm_state(f, errp); - vm_state_size =3D qemu_ftell(f); + vm_state_size =3D qemu_file_total_transferred(f); ret2 =3D qemu_fclose(f); if (ret < 0) { goto the_end; diff --git a/migration/vmstate.c b/migration/vmstate.c index 36ae8b9e19..b0551e82c6 100644 --- a/migration/vmstate.c +++ b/migration/vmstate.c @@ -360,7 +360,7 @@ int vmstate_save_state_v(QEMUFile *f, const VMStateDesc= ription *vmsd, void *curr_elem =3D first_elem + size * i; =20 vmsd_desc_field_start(vmsd, vmdesc_loop, field, i, n_elems= ); - old_offset =3D qemu_ftell_fast(f); + old_offset =3D qemu_file_total_transferred_fast(f); if (field->flags & VMS_ARRAY_OF_POINTER) { assert(curr_elem); curr_elem =3D *(void **)curr_elem; @@ -390,7 +390,7 @@ int vmstate_save_state_v(QEMUFile *f, const VMStateDesc= ription *vmsd, return ret; } =20 - written_bytes =3D qemu_ftell_fast(f) - old_offset; + written_bytes =3D qemu_file_total_transferred_fast(f) - ol= d_offset; vmsd_desc_field_end(vmsd, vmdesc_loop, field, written_byte= s, i); =20 /* Compressed arrays only care about the first element */ --=20 2.35.3 From nobody Wed May 22 00:43:24 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1655858639; cv=none; d=zohomail.com; s=zohoarc; b=fbtwUMa79dgovBNgaW9+SCu5mkbUSkHaxquR4tYfvVSHhEVzln+uEGFgE2RZ9tjKoaaCUvkBqS47pNJQxxGI+WEtfScRtKbpYoYfMhgQQ9N81UexOCTujPNaHnRXL+p78nwmpEziNcAib4iGO66jpllq/oA/8CG8ciS2Jn4HxFI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1655858639; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=CPBWZfErhAM4slp3Mz2qGpDeLQlgqtlF8ezmEOPOA/g=; b=TzmVIO4LeBemi+SOlcrwTnOdNKD+p9u33sIzidvomp2Ni5zBzC/LnvTmMOs5AiNW2oGlrdnm2KeENgVg7AQgiAPwa/kO4gQ7dsEdfV17Pjuzu4/jQGNv5WGVIzyV06NdWP6XPrDkaw1BS2B01PEufTeVGYvhhfCx5legkYHrOAs= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1655858639719882.5770496185648; Tue, 21 Jun 2022 17:43:59 -0700 (PDT) Received: from localhost ([::1]:34134 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1o3oTO-0004We-FM for importer@patchew.org; Tue, 21 Jun 2022 20:43:58 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:56332) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1o3oCJ-000307-Vo for qemu-devel@nongnu.org; Tue, 21 Jun 2022 20:26:21 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:38217) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1o3oCH-000681-Um for qemu-devel@nongnu.org; Tue, 21 Jun 2022 20:26:19 -0400 Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-88-ZHKqQtM3MMyIYtB2BMVvGA-1; Tue, 21 Jun 2022 20:26:14 -0400 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.rdu2.redhat.com [10.11.54.7]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id C99251C08969; Wed, 22 Jun 2022 00:26:13 +0000 (UTC) Received: from secure.mitica (unknown [10.39.192.22]) by smtp.corp.redhat.com (Postfix) with ESMTP id 1FC60141510D; Wed, 22 Jun 2022 00:26:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1655857577; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=CPBWZfErhAM4slp3Mz2qGpDeLQlgqtlF8ezmEOPOA/g=; b=CTBUJE4j8UjJen4U24JOYYN4eNQt1Kk8C9F86kdtI2cXXYpHO/GrK5JAy6EpuXFnDQFkGy XInuZQBEMg7Dq4whVZf3ayJeWN7TmH4ixGb/1HHnnrZxX0yOS4PTMJtAd/Sfm0SahjA5RN x5WsqzUFzqTbqjjUNd5L98Jlsy0hg3c= X-MC-Unique: ZHKqQtM3MMyIYtB2BMVvGA-1 From: Juan Quintela To: qemu-devel@nongnu.org Cc: Hailiang Zhang , Eric Blake , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , Fam Zheng , "Dr. David Alan Gilbert" , Juan Quintela , qemu-block@nongnu.org, Stefan Hajnoczi , Markus Armbruster Subject: [PULL 11/25] migration: rename qemu_update_position to qemu_file_credit_transfer Date: Wed, 22 Jun 2022 02:25:33 +0200 Message-Id: <20220622002547.64784-12-quintela@redhat.com> In-Reply-To: <20220622002547.64784-1-quintela@redhat.com> References: <20220622002547.64784-1-quintela@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 2.85 on 10.11.54.7 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=quintela@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -28 X-Spam_score: -2.9 X-Spam_bar: -- X-Spam_report: (-2.9 / 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, RCVD_IN_DNSWL_LOW=-0.7, 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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1655858641341100001 From: Daniel P. Berrang=C3=A9 The qemu_update_position method name gives the misleading impression that it is changing the current file offset. Most of the files are just streams, however, so there's no concept of a file offset in the general case. What this method is actually used for is to report on the number of bytes that have been transferred out of band from the main I/O methods. This new name better reflects this purpose. Reviewed-by: Dr. David Alan Gilbert Signed-off-by: Daniel P. Berrang=C3=A9 Reviewed-by: Juan Quintela Signed-off-by: Juan Quintela --- migration/qemu-file.h | 9 ++++++++- migration/qemu-file.c | 4 ++-- migration/ram.c | 2 +- 3 files changed, 11 insertions(+), 4 deletions(-) diff --git a/migration/qemu-file.h b/migration/qemu-file.h index 05f6aef903..d96f5f7118 100644 --- a/migration/qemu-file.h +++ b/migration/qemu-file.h @@ -179,7 +179,14 @@ int qemu_put_qemu_file(QEMUFile *f_des, QEMUFile *f_sr= c); */ int qemu_peek_byte(QEMUFile *f, int offset); void qemu_file_skip(QEMUFile *f, int size); -void qemu_update_position(QEMUFile *f, size_t size); +/* + * qemu_file_credit_transfer: + * + * Report on a number of bytes that have been transferred + * out of band from the main file object I/O methods. This + * accounting information tracks the total migration traffic. + */ +void qemu_file_credit_transfer(QEMUFile *f, size_t size); void qemu_file_reset_rate_limit(QEMUFile *f); void qemu_file_update_transfer(QEMUFile *f, int64_t len); void qemu_file_set_rate_limit(QEMUFile *f, int64_t new_rate); diff --git a/migration/qemu-file.c b/migration/qemu-file.c index 664ac77067..9a7f715e17 100644 --- a/migration/qemu-file.c +++ b/migration/qemu-file.c @@ -319,7 +319,7 @@ size_t ram_control_save_page(QEMUFile *f, ram_addr_t bl= ock_offset, if (ret !=3D RAM_SAVE_CONTROL_DELAYED && ret !=3D RAM_SAVE_CONTROL_NOT_SUPP) { if (bytes_sent && *bytes_sent > 0) { - qemu_update_position(f, *bytes_sent); + qemu_file_credit_transfer(f, *bytes_sent); } else if (ret < 0) { qemu_file_set_error(f, ret); } @@ -374,7 +374,7 @@ static ssize_t qemu_fill_buffer(QEMUFile *f) return len; } =20 -void qemu_update_position(QEMUFile *f, size_t size) +void qemu_file_credit_transfer(QEMUFile *f, size_t size) { f->total_transferred +=3D size; } diff --git a/migration/ram.c b/migration/ram.c index 89082716d6..bf321e1e72 100644 --- a/migration/ram.c +++ b/migration/ram.c @@ -2301,7 +2301,7 @@ void acct_update_position(QEMUFile *f, size_t size, b= ool zero) } else { ram_counters.normal +=3D pages; ram_transferred_add(size); - qemu_update_position(f, size); + qemu_file_credit_transfer(f, size); } } =20 --=20 2.35.3 From nobody Wed May 22 00:43:24 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1655857882; cv=none; d=zohomail.com; s=zohoarc; b=h4H7M6XRR4wYBjvW8TXYB1rFX++GaB3s6uOdvXI1bx45dvvBrzSXACTOz15ioEz6Be7HiDr0GdlrzIKH9T5EDY6fWXUeQ4RdGy6MzpAnZeH3p8ZYL7A2zN+SCNFyLenck437wpn36dTfxXABGDECLVSg3f92WPUcZ8ji6IdjqdU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1655857882; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=3Yela9Z8gSIGprzsYS4UVl2P7Jxw7vqXYvS1aoRyS3o=; b=mIOgfv+jBYxY4ZtAgVC0xTdrgU3oCNI1h4fobx7KYetqtlKhJumwxpxfJdcesMeLkxw4lnuQuYJHwSdivNj/v2Kcs9So+1sRIMfYBt2Csf3TGaYy9cdWLqWkNijQBqTeENpynlv6B3C+vPQv8LTn8FQQgf8FKu3AdVUJftw9tO0= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1655857882591425.03398178193675; Tue, 21 Jun 2022 17:31:22 -0700 (PDT) Received: from localhost ([::1]:35910 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1o3oHB-0003I9-0N for importer@patchew.org; Tue, 21 Jun 2022 20:31:21 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:56374) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1o3oCM-00031T-Tl for qemu-devel@nongnu.org; Tue, 21 Jun 2022 20:26:23 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:54808) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1o3oCK-000690-Q5 for qemu-devel@nongnu.org; Tue, 21 Jun 2022 20:26:22 -0400 Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-536-A9SW7PZhOwu6s6_oW25zRQ-1; Tue, 21 Jun 2022 20:26:16 -0400 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.rdu2.redhat.com [10.11.54.7]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id CC8A8801756; Wed, 22 Jun 2022 00:26:15 +0000 (UTC) Received: from secure.mitica (unknown [10.39.192.22]) by smtp.corp.redhat.com (Postfix) with ESMTP id 2182C141510D; Wed, 22 Jun 2022 00:26:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1655857580; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=3Yela9Z8gSIGprzsYS4UVl2P7Jxw7vqXYvS1aoRyS3o=; b=WzyLp6Zjb8CboR6+bXinhaSm4BEjJGgG4zjpOSg6/0QPYJI0WVazIDyxdzKJxpobGKrOAm BHGUbOJBD7Ug7PVArDEUrfvGng6w05MhZESyUEHLOyQV+Quk7f3jvSiZrhJGifDrS9nX3K SmTcz3zMKCIghJQQ1+HcD7Emfqgy68c= X-MC-Unique: A9SW7PZhOwu6s6_oW25zRQ-1 From: Juan Quintela To: qemu-devel@nongnu.org Cc: Hailiang Zhang , Eric Blake , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , Fam Zheng , "Dr. David Alan Gilbert" , Juan Quintela , qemu-block@nongnu.org, Stefan Hajnoczi , Markus Armbruster Subject: [PULL 12/25] migration: rename qemu_file_update_transfer to qemu_file_acct_rate_limit Date: Wed, 22 Jun 2022 02:25:34 +0200 Message-Id: <20220622002547.64784-13-quintela@redhat.com> In-Reply-To: <20220622002547.64784-1-quintela@redhat.com> References: <20220622002547.64784-1-quintela@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 2.85 on 10.11.54.7 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=quintela@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -28 X-Spam_score: -2.9 X-Spam_bar: -- X-Spam_report: (-2.9 / 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, RCVD_IN_DNSWL_LOW=-0.7, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=unavailable 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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1655857883018100002 From: Daniel P. Berrang=C3=A9 The qemu_file_update_transfer name doesn't give a clear guide on what its purpose is, and how it differs from the qemu_file_credit_transfer method. The latter is specifically for accumulating for total migration traffic, while the former is specifically for accounting in thue rate limit calculations. The new name give better guidance on its usage. Signed-off-by: Daniel P. Berrang=C3=A9 Reviewed-by: Dr. David Alan Gilbert Reviewed-by: Juan Quintela Signed-off-by: Juan Quintela --- migration/qemu-file.h | 9 ++++++++- migration/multifd.c | 4 ++-- migration/qemu-file.c | 2 +- 3 files changed, 11 insertions(+), 4 deletions(-) diff --git a/migration/qemu-file.h b/migration/qemu-file.h index d96f5f7118..901f2cf697 100644 --- a/migration/qemu-file.h +++ b/migration/qemu-file.h @@ -188,7 +188,14 @@ void qemu_file_skip(QEMUFile *f, int size); */ void qemu_file_credit_transfer(QEMUFile *f, size_t size); void qemu_file_reset_rate_limit(QEMUFile *f); -void qemu_file_update_transfer(QEMUFile *f, int64_t len); +/* + * qemu_file_acct_rate_limit: + * + * Report on a number of bytes the have been transferred + * out of band from the main file object I/O methods, and + * need to be applied to the rate limiting calcuations + */ +void qemu_file_acct_rate_limit(QEMUFile *f, int64_t len); void qemu_file_set_rate_limit(QEMUFile *f, int64_t new_rate); int64_t qemu_file_get_rate_limit(QEMUFile *f); int qemu_file_get_error_obj(QEMUFile *f, Error **errp); diff --git a/migration/multifd.c b/migration/multifd.c index 9282ab6aa4..684c014c86 100644 --- a/migration/multifd.c +++ b/migration/multifd.c @@ -435,7 +435,7 @@ static int multifd_send_pages(QEMUFile *f) p->pages =3D pages; transferred =3D ((uint64_t) pages->num) * qemu_target_page_size() + p->packet_len; - qemu_file_update_transfer(f, transferred); + qemu_file_acct_rate_limit(f, transferred); ram_counters.multifd_bytes +=3D transferred; ram_counters.transferred +=3D transferred; qemu_mutex_unlock(&p->mutex); @@ -610,7 +610,7 @@ int multifd_send_sync_main(QEMUFile *f) p->packet_num =3D multifd_send_state->packet_num++; p->flags |=3D MULTIFD_FLAG_SYNC; p->pending_job++; - qemu_file_update_transfer(f, p->packet_len); + qemu_file_acct_rate_limit(f, p->packet_len); ram_counters.multifd_bytes +=3D p->packet_len; ram_counters.transferred +=3D p->packet_len; qemu_mutex_unlock(&p->mutex); diff --git a/migration/qemu-file.c b/migration/qemu-file.c index 9a7f715e17..6bbdb60d4d 100644 --- a/migration/qemu-file.c +++ b/migration/qemu-file.c @@ -704,7 +704,7 @@ void qemu_file_reset_rate_limit(QEMUFile *f) f->rate_limit_used =3D 0; } =20 -void qemu_file_update_transfer(QEMUFile *f, int64_t len) +void qemu_file_acct_rate_limit(QEMUFile *f, int64_t len) { f->rate_limit_used +=3D len; } --=20 2.35.3 From nobody Wed May 22 00:43:24 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1655858506; cv=none; d=zohomail.com; s=zohoarc; b=WsTgJQJHJd+7TSu8NLjhtUSxp9L3SPcv7b0iG+QY4hXfQYiQppquYFjwAfx2X5+lsdTbwvIMF/+A3DIhkhiVOmvCLD7hZCeiLTxYZVnOft0KVcV4xlIMs9Psu8Knx9WQHuEuepwAjyrqZmGEtEB+P5ZE4nxobyJBfscuHFaER5Q= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1655858506; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=6c+dMDDPv7z7cjQmQbGLQPZzKht4lWVbGTHMdcVmxeg=; b=YRcEhqmZ+SBteNgW6LfFhRUaX7Z17UIYLtkfbD5w1EL5SMY5/EPZoTdWdTjRmeBx93MLiiRoe+bsgs7qcBNk8fC/goYDkJUdn7wMuEUvhO+SAob+gXzZFJo47xL7dmCK5z4zaLFpfObB33+aUxdXbCmOnM+afaXNE3YMe92RhSY= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1655858506478711.8054551032001; Tue, 21 Jun 2022 17:41:46 -0700 (PDT) Received: from localhost ([::1]:55434 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1o3oRF-0008C7-DX for importer@patchew.org; Tue, 21 Jun 2022 20:41:45 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:56396) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1o3oCO-00032q-JK for qemu-devel@nongnu.org; Tue, 21 Jun 2022 20:26:25 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:30393) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1o3oCM-00069L-Ly for qemu-devel@nongnu.org; Tue, 21 Jun 2022 20:26:24 -0400 Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-582-Navmp3F8NLubyYDQUnD6SQ-1; Tue, 21 Jun 2022 20:26:18 -0400 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.rdu2.redhat.com [10.11.54.7]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id D326C185A7B2; Wed, 22 Jun 2022 00:26:17 +0000 (UTC) Received: from secure.mitica (unknown [10.39.192.22]) by smtp.corp.redhat.com (Postfix) with ESMTP id 24873141510D; Wed, 22 Jun 2022 00:26:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1655857581; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=6c+dMDDPv7z7cjQmQbGLQPZzKht4lWVbGTHMdcVmxeg=; b=KExKdrv3LGeuasZhDEm/3dmUr9gi/JuZAEmKvQTu9pMjvCE8tnAJrRxq+05N/whO5Mmsv5 /jvvRkuaxCdk+yHM4KUSMdxAPcbeKj2w6UNxJfZY7I1bYREWhEnMdaSlpplOtxJIYgQd5z 5eoO1Nl8dlrappsGEdnHe8ko8F5h7Yw= X-MC-Unique: Navmp3F8NLubyYDQUnD6SQ-1 From: Juan Quintela To: qemu-devel@nongnu.org Cc: Hailiang Zhang , Eric Blake , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , Fam Zheng , "Dr. David Alan Gilbert" , Juan Quintela , qemu-block@nongnu.org, Stefan Hajnoczi , Markus Armbruster Subject: [PULL 13/25] migration: introduce a QIOChannel impl for BlockDriverState VMState Date: Wed, 22 Jun 2022 02:25:35 +0200 Message-Id: <20220622002547.64784-14-quintela@redhat.com> In-Reply-To: <20220622002547.64784-1-quintela@redhat.com> References: <20220622002547.64784-1-quintela@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 2.85 on 10.11.54.7 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=quintela@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -28 X-Spam_score: -2.9 X-Spam_bar: -- X-Spam_report: (-2.9 / 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, RCVD_IN_DNSWL_LOW=-0.7, 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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1655858508541100001 From: Daniel P. Berrang=C3=A9 Introduce a QIOChannelBlock class that exposes the BlockDriverState VMState region for I/O. This is kept in the migration/ directory rather than io/, to avoid a mutual dependancy between block/ <-> io/ directories. Also the VMState should only be used by the migration code. Signed-off-by: Daniel P. Berrang=C3=A9 Reviewed-by: Juan Quintela Signed-off-by: Juan Quintela --- migration/channel-block.h | 59 ++++++++++++ migration/channel-block.c | 195 ++++++++++++++++++++++++++++++++++++++ migration/meson.build | 1 + 3 files changed, 255 insertions(+) create mode 100644 migration/channel-block.h create mode 100644 migration/channel-block.c diff --git a/migration/channel-block.h b/migration/channel-block.h new file mode 100644 index 0000000000..31673824e6 --- /dev/null +++ b/migration/channel-block.h @@ -0,0 +1,59 @@ +/* + * QEMU I/O channels block driver + * + * Copyright (c) 2022 Red Hat, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, see . + * + */ + +#ifndef QIO_CHANNEL_BLOCK_H +#define QIO_CHANNEL_BLOCK_H + +#include "io/channel.h" +#include "qom/object.h" + +#define TYPE_QIO_CHANNEL_BLOCK "qio-channel-block" +OBJECT_DECLARE_SIMPLE_TYPE(QIOChannelBlock, QIO_CHANNEL_BLOCK) + + +/** + * QIOChannelBlock: + * + * The QIOChannelBlock object provides a channel implementation + * that is able to perform I/O on the BlockDriverState objects + * to the VMState region. + */ + +struct QIOChannelBlock { + QIOChannel parent; + BlockDriverState *bs; + off_t offset; +}; + + +/** + * qio_channel_block_new: + * @bs: the block driver state + * + * Create a new IO channel object that can perform + * I/O on a BlockDriverState object to the VMState + * region + * + * Returns: the new channel object + */ +QIOChannelBlock * +qio_channel_block_new(BlockDriverState *bs); + +#endif /* QIO_CHANNEL_BLOCK_H */ diff --git a/migration/channel-block.c b/migration/channel-block.c new file mode 100644 index 0000000000..ad52342c10 --- /dev/null +++ b/migration/channel-block.c @@ -0,0 +1,195 @@ +/* + * QEMU I/O channels block driver + * + * Copyright (c) 2022 Red Hat, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, see . + * + */ + +#include "qemu/osdep.h" +#include "migration/channel-block.h" +#include "qapi/error.h" +#include "block/block.h" +#include "trace.h" + +QIOChannelBlock * +qio_channel_block_new(BlockDriverState *bs) +{ + QIOChannelBlock *ioc; + + ioc =3D QIO_CHANNEL_BLOCK(object_new(TYPE_QIO_CHANNEL_BLOCK)); + + bdrv_ref(bs); + ioc->bs =3D bs; + + return ioc; +} + + +static void +qio_channel_block_finalize(Object *obj) +{ + QIOChannelBlock *ioc =3D QIO_CHANNEL_BLOCK(obj); + + g_clear_pointer(&ioc->bs, bdrv_unref); +} + + +static ssize_t +qio_channel_block_readv(QIOChannel *ioc, + const struct iovec *iov, + size_t niov, + int **fds, + size_t *nfds, + Error **errp) +{ + QIOChannelBlock *bioc =3D QIO_CHANNEL_BLOCK(ioc); + QEMUIOVector qiov; + int ret; + + qemu_iovec_init_external(&qiov, (struct iovec *)iov, niov); + ret =3D bdrv_readv_vmstate(bioc->bs, &qiov, bioc->offset); + if (ret < 0) { + return ret; + } + + bioc->offset +=3D qiov.size; + return qiov.size; +} + + +static ssize_t +qio_channel_block_writev(QIOChannel *ioc, + const struct iovec *iov, + size_t niov, + int *fds, + size_t nfds, + int flags, + Error **errp) +{ + QIOChannelBlock *bioc =3D QIO_CHANNEL_BLOCK(ioc); + QEMUIOVector qiov; + int ret; + + qemu_iovec_init_external(&qiov, (struct iovec *)iov, niov); + ret =3D bdrv_writev_vmstate(bioc->bs, &qiov, bioc->offset); + if (ret < 0) { + return ret; + } + + bioc->offset +=3D qiov.size; + return qiov.size; +} + + +static int +qio_channel_block_set_blocking(QIOChannel *ioc, + bool enabled, + Error **errp) +{ + if (!enabled) { + error_setg(errp, "Non-blocking mode not supported for block device= s"); + return -1; + } + return 0; +} + + +static off_t +qio_channel_block_seek(QIOChannel *ioc, + off_t offset, + int whence, + Error **errp) +{ + QIOChannelBlock *bioc =3D QIO_CHANNEL_BLOCK(ioc); + + switch (whence) { + case SEEK_SET: + bioc->offset =3D offset; + break; + case SEEK_CUR: + bioc->offset +=3D whence; + break; + case SEEK_END: + error_setg(errp, "Size of VMstate region is unknown"); + return (off_t)-1; + default: + g_assert_not_reached(); + } + + return bioc->offset; +} + + +static int +qio_channel_block_close(QIOChannel *ioc, + Error **errp) +{ + QIOChannelBlock *bioc =3D QIO_CHANNEL_BLOCK(ioc); + int rv; + + if ((rv =3D bdrv_flush(bioc->bs)) < 0) { + error_setg_errno(errp, -rv, + "Unable to flush VMState"); + return -1; + } + + g_clear_pointer(&bioc->bs, bdrv_unref); + bioc->offset =3D 0; + + return 0; +} + + +static void +qio_channel_block_set_aio_fd_handler(QIOChannel *ioc, + AioContext *ctx, + IOHandler *io_read, + IOHandler *io_write, + void *opaque) +{ + /* XXX anything we can do here ? */ +} + + +static void +qio_channel_block_class_init(ObjectClass *klass, + void *class_data G_GNUC_UNUSED) +{ + QIOChannelClass *ioc_klass =3D QIO_CHANNEL_CLASS(klass); + + ioc_klass->io_writev =3D qio_channel_block_writev; + ioc_klass->io_readv =3D qio_channel_block_readv; + ioc_klass->io_set_blocking =3D qio_channel_block_set_blocking; + ioc_klass->io_seek =3D qio_channel_block_seek; + ioc_klass->io_close =3D qio_channel_block_close; + ioc_klass->io_set_aio_fd_handler =3D qio_channel_block_set_aio_fd_hand= ler; +} + +static const TypeInfo qio_channel_block_info =3D { + .parent =3D TYPE_QIO_CHANNEL, + .name =3D TYPE_QIO_CHANNEL_BLOCK, + .instance_size =3D sizeof(QIOChannelBlock), + .instance_finalize =3D qio_channel_block_finalize, + .class_init =3D qio_channel_block_class_init, +}; + +static void +qio_channel_block_register_types(void) +{ + type_register_static(&qio_channel_block_info); +} + +type_init(qio_channel_block_register_types); diff --git a/migration/meson.build b/migration/meson.build index 6880b61b10..8d309f5849 100644 --- a/migration/meson.build +++ b/migration/meson.build @@ -13,6 +13,7 @@ softmmu_ss.add(migration_files) softmmu_ss.add(files( 'block-dirty-bitmap.c', 'channel.c', + 'channel-block.c', 'colo-failover.c', 'colo.c', 'exec.c', --=20 2.35.3 From nobody Wed May 22 00:43:24 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1655858207; cv=none; d=zohomail.com; s=zohoarc; b=WOjzkK/wZbTj4E+z+hTynq+5txAClkDLnPN/NaMZyrhTcveT8Sv5bm3FtVvix4qy8hBj1F84iAgTiPcGVJdbqS2TLBsarMdjk/jdOJlkiJmAugZlAjTyz6matlphQEB1Fc7ofwNFMibQHwf1CPG3pUkeWPuTVA9gLP0HZb4We+c= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1655858207; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=rkgkihmuWH55uB1nDy9MReJ58rxDzTLx3dpDLFY96WI=; b=eWAp+OYrMrgdgqOqKt/CVDXuE3A4zXm5wIfHe2GUe7ao6ctIdrktYqHN+vSRiMbLms+2sx0CbmKSHRnLQbYPZfVdTXxVVgsXuBfksyiQCsFy/4vp/IKaeO6oqsY/QPqfoy5eCYkY0fymeJ3zCiPeyOZU9bZv1GqnGx/h5LUWBQw= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1655858207080392.78529972768877; Tue, 21 Jun 2022 17:36:47 -0700 (PDT) Received: from localhost ([::1]:44910 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1o3oMP-00013p-Gs for importer@patchew.org; Tue, 21 Jun 2022 20:36:45 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:56418) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1o3oCP-00033n-SC for qemu-devel@nongnu.org; Tue, 21 Jun 2022 20:26:25 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:43795) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1o3oCM-00069S-MD for qemu-devel@nongnu.org; Tue, 21 Jun 2022 20:26:25 -0400 Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-449-uAf_EWHAO5iPn_k2PfOZ9A-1; Tue, 21 Jun 2022 20:26:20 -0400 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.rdu2.redhat.com [10.11.54.7]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id D3BAB80029D; Wed, 22 Jun 2022 00:26:19 +0000 (UTC) Received: from secure.mitica (unknown [10.39.192.22]) by smtp.corp.redhat.com (Postfix) with ESMTP id 2A6DC141510D; Wed, 22 Jun 2022 00:26:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1655857581; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=rkgkihmuWH55uB1nDy9MReJ58rxDzTLx3dpDLFY96WI=; b=LiXeJEOmf0/gYb9OxYXC9WPyBs1Ppi67T6yg9HZ1V76whdm+N9tcWwujFvkWdbsf7wGSbV pEkVJPXwCYYgsdR1JtfDFeOLzW5gN8h1ZkpX5c30004DGAwqXqr0gLTfHXfhu43qdJTbG6 hTSx6GU7hXQlptrFTOmZAw2onKOiAuE= X-MC-Unique: uAf_EWHAO5iPn_k2PfOZ9A-1 From: Juan Quintela To: qemu-devel@nongnu.org Cc: Hailiang Zhang , Eric Blake , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , Fam Zheng , "Dr. David Alan Gilbert" , Juan Quintela , qemu-block@nongnu.org, Stefan Hajnoczi , Markus Armbruster Subject: [PULL 14/25] migration: convert savevm to use QIOChannelBlock for VMState Date: Wed, 22 Jun 2022 02:25:36 +0200 Message-Id: <20220622002547.64784-15-quintela@redhat.com> In-Reply-To: <20220622002547.64784-1-quintela@redhat.com> References: <20220622002547.64784-1-quintela@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 2.85 on 10.11.54.7 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=quintela@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -28 X-Spam_score: -2.9 X-Spam_bar: -- X-Spam_report: (-2.9 / 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, RCVD_IN_DNSWL_LOW=-0.7, 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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1655858208426100001 From: Daniel P. Berrang=C3=A9 With this change, all QEMUFile usage is backed by QIOChannel at last. Reviewed-by: Dr. David Alan Gilbert Signed-off-by: Daniel P. Berrang=C3=A9 Reviewed-by: Juan Quintela Signed-off-by: Juan Quintela --- migration/savevm.c | 42 ++++-------------------------------------- 1 file changed, 4 insertions(+), 38 deletions(-) diff --git a/migration/savevm.c b/migration/savevm.c index 75d05f1a84..24a50376dc 100644 --- a/migration/savevm.c +++ b/migration/savevm.c @@ -35,6 +35,7 @@ #include "migration/misc.h" #include "migration/register.h" #include "migration/global_state.h" +#include "migration/channel-block.h" #include "ram.h" #include "qemu-file-channel.h" #include "qemu-file.h" @@ -130,48 +131,13 @@ static struct mig_cmd_args { /***********************************************************/ /* savevm/loadvm support */ =20 -static ssize_t block_writev_buffer(void *opaque, struct iovec *iov, int io= vcnt, - int64_t pos, Error **errp) -{ - int ret; - QEMUIOVector qiov; - - qemu_iovec_init_external(&qiov, iov, iovcnt); - ret =3D bdrv_writev_vmstate(opaque, &qiov, pos); - if (ret < 0) { - return ret; - } - - return qiov.size; -} - -static ssize_t block_get_buffer(void *opaque, uint8_t *buf, int64_t pos, - size_t size, Error **errp) -{ - return bdrv_load_vmstate(opaque, buf, pos, size); -} - -static int bdrv_fclose(void *opaque, Error **errp) -{ - return bdrv_flush(opaque); -} - -static const QEMUFileOps bdrv_read_ops =3D { - .get_buffer =3D block_get_buffer, - .close =3D bdrv_fclose -}; - -static const QEMUFileOps bdrv_write_ops =3D { - .writev_buffer =3D block_writev_buffer, - .close =3D bdrv_fclose -}; - static QEMUFile *qemu_fopen_bdrv(BlockDriverState *bs, int is_writable) { if (is_writable) { - return qemu_fopen_ops(bs, &bdrv_write_ops, false); + return qemu_fopen_channel_output(QIO_CHANNEL(qio_channel_block_new= (bs))); + } else { + return qemu_fopen_channel_input(QIO_CHANNEL(qio_channel_block_new(= bs))); } - return qemu_fopen_ops(bs, &bdrv_read_ops, false); } =20 =20 --=20 2.35.3 From nobody Wed May 22 00:43:24 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1655858445; cv=none; d=zohomail.com; s=zohoarc; b=kVh0WoSYwHfVO1IbQz9M0lP2VJiq2iMzeqs8YgIWn0DeLDdOa0RDMjGsdDNJqqK73ZLAJx3rhRuDG3c1WJnfmTuq6PwBZ2TamskwUUzIr4m3r/1nQFM+7IpvR3P8zULkjrXz2w+FuUMf/N3SzSM3FjLl40K+I0Ydq3eOKn46CnE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1655858445; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=QW//rlgUCCdF00Frd0kamO6u/jnl8cfY+kUOf9BSCTI=; b=kNPa5WjbP+5IaGU0V4O3QNl9v2zdusznVIVU5oj5t25qsMNTYodKtLT5ZOkh7VqwStgrYbaoFCPtwMU3loOW/eCRMXCBdsth90zKqiQkhREqE8VPARwyAAufG1upiI5iTcb0R0PORTGCjZZ/doF+cxCI+HMOBIdZe79qvXx2yVQ= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1655858445845254.29039110674012; Tue, 21 Jun 2022 17:40:45 -0700 (PDT) Received: from localhost ([::1]:53394 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1o3oQG-0006k6-N1 for importer@patchew.org; Tue, 21 Jun 2022 20:40:44 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:56458) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1o3oCS-0003Bi-Ti for qemu-devel@nongnu.org; Tue, 21 Jun 2022 20:26:28 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:41952) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1o3oCR-00069y-1P for qemu-devel@nongnu.org; Tue, 21 Jun 2022 20:26:28 -0400 Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-255-L8bC2G8yNgWPGSSbKha2QA-1; Tue, 21 Jun 2022 20:26:22 -0400 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.rdu2.redhat.com [10.11.54.7]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id D78AC101E165; Wed, 22 Jun 2022 00:26:21 +0000 (UTC) Received: from secure.mitica (unknown [10.39.192.22]) by smtp.corp.redhat.com (Postfix) with ESMTP id 2BE47141510D; Wed, 22 Jun 2022 00:26:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1655857585; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=QW//rlgUCCdF00Frd0kamO6u/jnl8cfY+kUOf9BSCTI=; b=XX1oSHh7dzFwmJD33mEywFuF5O/As6dQFYwU30uAog8cTiJPF1egMUkakpNsUSKNVb9JOr QeyvK8SFuaG7U34Ys+Hzu8xxc43r+QncKZKe+00gCqFKR71j/NxDxx3/61Kx8/5GjSYU06 lwx1cTXNgghB3lWTPnS3Wd7gMnGuDvQ= X-MC-Unique: L8bC2G8yNgWPGSSbKha2QA-1 From: Juan Quintela To: qemu-devel@nongnu.org Cc: Hailiang Zhang , Eric Blake , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , Fam Zheng , "Dr. David Alan Gilbert" , Juan Quintela , qemu-block@nongnu.org, Stefan Hajnoczi , Markus Armbruster Subject: [PULL 15/25] migration: stop passing 'opaque' parameter to QEMUFile hooks Date: Wed, 22 Jun 2022 02:25:37 +0200 Message-Id: <20220622002547.64784-16-quintela@redhat.com> In-Reply-To: <20220622002547.64784-1-quintela@redhat.com> References: <20220622002547.64784-1-quintela@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 2.85 on 10.11.54.7 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=quintela@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -28 X-Spam_score: -2.9 X-Spam_bar: -- X-Spam_report: (-2.9 / 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, RCVD_IN_DNSWL_LOW=-0.7, 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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1655858446218100001 From: Daniel P. Berrang=C3=A9 The only user of the hooks is RDMA which provides a QIOChannel backed impl of QEMUFile. It can thus use the qemu_file_get_ioc() method. Reviewed-by: Dr. David Alan Gilbert Signed-off-by: Daniel P. Berrang=C3=A9 Reviewed-by: Juan Quintela Signed-off-by: Juan Quintela --- migration/qemu-file.h | 14 ++++++-------- migration/qemu-file.c | 8 ++++---- migration/rdma.c | 19 ++++++++++--------- 3 files changed, 20 insertions(+), 21 deletions(-) diff --git a/migration/qemu-file.h b/migration/qemu-file.h index 901f2cf697..277f1d5a62 100644 --- a/migration/qemu-file.h +++ b/migration/qemu-file.h @@ -65,11 +65,9 @@ typedef ssize_t (QEMUFileWritevBufferFunc)(void *opaque,= struct iovec *iov, /* * This function provides hooks around different * stages of RAM migration. - * 'opaque' is the backend specific data in QEMUFile * 'data' is call specific data associated with the 'flags' value */ -typedef int (QEMURamHookFunc)(QEMUFile *f, void *opaque, uint64_t flags, - void *data); +typedef int (QEMURamHookFunc)(QEMUFile *f, uint64_t flags, void *data); =20 /* * Constants used by ram_control_* hooks @@ -84,11 +82,11 @@ typedef int (QEMURamHookFunc)(QEMUFile *f, void *opaque= , uint64_t flags, * This function allows override of where the RAM page * is saved (such as RDMA, for example.) */ -typedef size_t (QEMURamSaveFunc)(QEMUFile *f, void *opaque, - ram_addr_t block_offset, - ram_addr_t offset, - size_t size, - uint64_t *bytes_sent); +typedef size_t (QEMURamSaveFunc)(QEMUFile *f, + ram_addr_t block_offset, + ram_addr_t offset, + size_t size, + uint64_t *bytes_sent); =20 /* * Return a QEMUFile for comms in the opposite direction diff --git a/migration/qemu-file.c b/migration/qemu-file.c index 6bbdb60d4d..006880abd3 100644 --- a/migration/qemu-file.c +++ b/migration/qemu-file.c @@ -266,7 +266,7 @@ void ram_control_before_iterate(QEMUFile *f, uint64_t f= lags) int ret =3D 0; =20 if (f->hooks && f->hooks->before_ram_iterate) { - ret =3D f->hooks->before_ram_iterate(f, f->opaque, flags, NULL); + ret =3D f->hooks->before_ram_iterate(f, flags, NULL); if (ret < 0) { qemu_file_set_error(f, ret); } @@ -278,7 +278,7 @@ void ram_control_after_iterate(QEMUFile *f, uint64_t fl= ags) int ret =3D 0; =20 if (f->hooks && f->hooks->after_ram_iterate) { - ret =3D f->hooks->after_ram_iterate(f, f->opaque, flags, NULL); + ret =3D f->hooks->after_ram_iterate(f, flags, NULL); if (ret < 0) { qemu_file_set_error(f, ret); } @@ -290,7 +290,7 @@ void ram_control_load_hook(QEMUFile *f, uint64_t flags,= void *data) int ret =3D -EINVAL; =20 if (f->hooks && f->hooks->hook_ram_load) { - ret =3D f->hooks->hook_ram_load(f, f->opaque, flags, data); + ret =3D f->hooks->hook_ram_load(f, flags, data); if (ret < 0) { qemu_file_set_error(f, ret); } @@ -310,7 +310,7 @@ size_t ram_control_save_page(QEMUFile *f, ram_addr_t bl= ock_offset, uint64_t *bytes_sent) { if (f->hooks && f->hooks->save_page) { - int ret =3D f->hooks->save_page(f, f->opaque, block_offset, + int ret =3D f->hooks->save_page(f, block_offset, offset, size, bytes_sent); if (ret !=3D RAM_SAVE_CONTROL_NOT_SUPP) { f->rate_limit_used +=3D size; diff --git a/migration/rdma.c b/migration/rdma.c index c5fa4a408a..26a0cbbf40 100644 --- a/migration/rdma.c +++ b/migration/rdma.c @@ -3215,11 +3215,11 @@ qio_channel_rdma_shutdown(QIOChannel *ioc, * sent. Usually, this will not be more than a few bytes = of * the protocol because most transfers are sent asynchron= ously. */ -static size_t qemu_rdma_save_page(QEMUFile *f, void *opaque, +static size_t qemu_rdma_save_page(QEMUFile *f, ram_addr_t block_offset, ram_addr_t offs= et, size_t size, uint64_t *bytes_sent) { - QIOChannelRDMA *rioc =3D QIO_CHANNEL_RDMA(opaque); + QIOChannelRDMA *rioc =3D QIO_CHANNEL_RDMA(qemu_file_get_ioc(f)); RDMAContext *rdma; int ret; =20 @@ -3831,14 +3831,15 @@ rdma_block_notification_handle(QIOChannelRDMA *rioc= , const char *name) return 0; } =20 -static int rdma_load_hook(QEMUFile *f, void *opaque, uint64_t flags, void = *data) +static int rdma_load_hook(QEMUFile *f, uint64_t flags, void *data) { + QIOChannelRDMA *rioc =3D QIO_CHANNEL_RDMA(qemu_file_get_ioc(f)); switch (flags) { case RAM_CONTROL_BLOCK_REG: - return rdma_block_notification_handle(opaque, data); + return rdma_block_notification_handle(rioc, data); =20 case RAM_CONTROL_HOOK: - return qemu_rdma_registration_handle(f, opaque); + return qemu_rdma_registration_handle(f, rioc); =20 default: /* Shouldn't be called with any other values */ @@ -3846,10 +3847,10 @@ static int rdma_load_hook(QEMUFile *f, void *opaque= , uint64_t flags, void *data) } } =20 -static int qemu_rdma_registration_start(QEMUFile *f, void *opaque, +static int qemu_rdma_registration_start(QEMUFile *f, uint64_t flags, void *data) { - QIOChannelRDMA *rioc =3D QIO_CHANNEL_RDMA(opaque); + QIOChannelRDMA *rioc =3D QIO_CHANNEL_RDMA(qemu_file_get_ioc(f)); RDMAContext *rdma; =20 RCU_READ_LOCK_GUARD(); @@ -3875,10 +3876,10 @@ static int qemu_rdma_registration_start(QEMUFile *f= , void *opaque, * Inform dest that dynamic registrations are done for now. * First, flush writes, if any. */ -static int qemu_rdma_registration_stop(QEMUFile *f, void *opaque, +static int qemu_rdma_registration_stop(QEMUFile *f, uint64_t flags, void *data) { - QIOChannelRDMA *rioc =3D QIO_CHANNEL_RDMA(opaque); + QIOChannelRDMA *rioc =3D QIO_CHANNEL_RDMA(qemu_file_get_ioc(f)); RDMAContext *rdma; RDMAControlHeader head =3D { .len =3D 0, .repeat =3D 1 }; int ret =3D 0; --=20 2.35.3 From nobody Wed May 22 00:43:24 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1655858630; cv=none; d=zohomail.com; s=zohoarc; b=e9DG8i22U7in1cm7N2tw0IQM06aEVYOO7IOYvdf3qaOJDloOLDCwi97I/qyq7xqv91CjCF/nPqpmm6KeMnEc1BaLTBg+einC296s+RSH7AFnGO+HJBTpGzvbGC5EqJySw1JLq4w5ZbuBg5Tlw5fB/WECoLSJiIJaaNqLZPRckuQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1655858630; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=GfmlXgTjOrkbsp/ws8H1eCb+jr6Et8+r8An9XNDNW/w=; b=XdR9MOHOSB3bOUA4c0FjQrEUYWlKzphDakWmufvwXiuxWSDeCvPQXb3tFFD44+EilbAtBQje7LiKhJdBKIXKf9p9Gh1nLMQxggDCvf1G2SbAgfLzwXLKN8NOan0wqsZ5HXH7+CCzUhN42sU58ubLl3PW3uTHoaXvjG29UMEYm8M= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1655858630061429.29204327959087; Tue, 21 Jun 2022 17:43:50 -0700 (PDT) Received: from localhost ([::1]:33512 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1o3oTF-00046Z-1q for importer@patchew.org; Tue, 21 Jun 2022 20:43:49 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:56492) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1o3oCU-0003Hw-D1 for qemu-devel@nongnu.org; Tue, 21 Jun 2022 20:26:30 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:45427) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1o3oCR-0006AA-1W for qemu-devel@nongnu.org; Tue, 21 Jun 2022 20:26:30 -0400 Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-385-W0pWxV_VNW2m5_Ys1vVhOg-1; Tue, 21 Jun 2022 20:26:24 -0400 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.rdu2.redhat.com [10.11.54.7]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id DA76380029D; Wed, 22 Jun 2022 00:26:23 +0000 (UTC) Received: from secure.mitica (unknown [10.39.192.22]) by smtp.corp.redhat.com (Postfix) with ESMTP id 2CDFF141510D; Wed, 22 Jun 2022 00:26:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1655857585; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=GfmlXgTjOrkbsp/ws8H1eCb+jr6Et8+r8An9XNDNW/w=; b=BeTDEO/NmzZ1uOtkAFzjyCwAqaMuIDdWcw+VpQTc2q3UGSyzwoR3oMcewpakVOQVpoip62 WmUoD3zK+AfKXodkof72zrk1zVcM/FVcNOC/EWfnKDe9FSqgc3CyZLI9R7a/30e61h6MOn mKtgiCGpOKe+C0+PP9qJBdAVqw0Ph48= X-MC-Unique: W0pWxV_VNW2m5_Ys1vVhOg-1 From: Juan Quintela To: qemu-devel@nongnu.org Cc: Hailiang Zhang , Eric Blake , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , Fam Zheng , "Dr. David Alan Gilbert" , Juan Quintela , qemu-block@nongnu.org, Stefan Hajnoczi , Markus Armbruster Subject: [PULL 16/25] migration: hardcode assumption that QEMUFile is backed with QIOChannel Date: Wed, 22 Jun 2022 02:25:38 +0200 Message-Id: <20220622002547.64784-17-quintela@redhat.com> In-Reply-To: <20220622002547.64784-1-quintela@redhat.com> References: <20220622002547.64784-1-quintela@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 2.85 on 10.11.54.7 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=quintela@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -28 X-Spam_score: -2.9 X-Spam_bar: -- X-Spam_report: (-2.9 / 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, RCVD_IN_DNSWL_LOW=-0.7, 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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1655858631154100001 From: Daniel P. Berrang=C3=A9 The only callers of qemu_fopen_ops pass 'true' for the 'has_ioc' parameter, so hardcode this assumption in QEMUFile, by passing in the QIOChannel object as a non-opaque parameter. Reviewed-by: Dr. David Alan Gilbert Signed-off-by: Daniel P. Berrang=C3=A9 Reviewed-by: Juan Quintela Signed-off-by: Juan Quintela --- migration/qemu-file.h | 2 +- migration/qemu-file-channel.c | 4 ++-- migration/qemu-file.c | 35 +++++++++++++++++------------------ 3 files changed, 20 insertions(+), 21 deletions(-) diff --git a/migration/qemu-file.h b/migration/qemu-file.h index 277f1d5a62..3a1ecc0e34 100644 --- a/migration/qemu-file.h +++ b/migration/qemu-file.h @@ -118,7 +118,7 @@ typedef struct QEMUFileHooks { QEMURamSaveFunc *save_page; } QEMUFileHooks; =20 -QEMUFile *qemu_fopen_ops(void *opaque, const QEMUFileOps *ops, bool has_io= c); +QEMUFile *qemu_fopen_ops(QIOChannel *ioc, const QEMUFileOps *ops); void qemu_file_set_hooks(QEMUFile *f, const QEMUFileHooks *hooks); int qemu_get_fd(QEMUFile *f); int qemu_fclose(QEMUFile *f); diff --git a/migration/qemu-file-channel.c b/migration/qemu-file-channel.c index bb5a5752df..ce8eced417 100644 --- a/migration/qemu-file-channel.c +++ b/migration/qemu-file-channel.c @@ -184,11 +184,11 @@ static const QEMUFileOps channel_output_ops =3D { QEMUFile *qemu_fopen_channel_input(QIOChannel *ioc) { object_ref(OBJECT(ioc)); - return qemu_fopen_ops(ioc, &channel_input_ops, true); + return qemu_fopen_ops(ioc, &channel_input_ops); } =20 QEMUFile *qemu_fopen_channel_output(QIOChannel *ioc) { object_ref(OBJECT(ioc)); - return qemu_fopen_ops(ioc, &channel_output_ops, true); + return qemu_fopen_ops(ioc, &channel_output_ops); } diff --git a/migration/qemu-file.c b/migration/qemu-file.c index 006880abd3..ce48d7a5d8 100644 --- a/migration/qemu-file.c +++ b/migration/qemu-file.c @@ -37,7 +37,7 @@ struct QEMUFile { const QEMUFileOps *ops; const QEMUFileHooks *hooks; - void *opaque; + QIOChannel *ioc; =20 /* * Maximum amount of data in bytes to transfer during one @@ -65,8 +65,6 @@ struct QEMUFile { Error *last_error_obj; /* has the file has been shutdown */ bool shutdown; - /* Whether opaque points to a QIOChannel */ - bool has_ioc; }; =20 /* @@ -81,7 +79,7 @@ int qemu_file_shutdown(QEMUFile *f) if (!f->ops->shut_down) { return -ENOSYS; } - ret =3D f->ops->shut_down(f->opaque, true, true, NULL); + ret =3D f->ops->shut_down(f->ioc, true, true, NULL); =20 if (!f->last_error) { qemu_file_set_error(f, -EIO); @@ -98,7 +96,7 @@ QEMUFile *qemu_file_get_return_path(QEMUFile *f) if (!f->ops->get_return_path) { return NULL; } - return f->ops->get_return_path(f->opaque); + return f->ops->get_return_path(f->ioc); } =20 bool qemu_file_mode_is_not_valid(const char *mode) @@ -113,15 +111,15 @@ bool qemu_file_mode_is_not_valid(const char *mode) return false; } =20 -QEMUFile *qemu_fopen_ops(void *opaque, const QEMUFileOps *ops, bool has_io= c) +QEMUFile *qemu_fopen_ops(QIOChannel *ioc, const QEMUFileOps *ops) { QEMUFile *f; =20 f =3D g_new0(QEMUFile, 1); =20 - f->opaque =3D opaque; + f->ioc =3D ioc; f->ops =3D ops; - f->has_ioc =3D has_ioc; + return f; } =20 @@ -242,7 +240,7 @@ void qemu_fflush(QEMUFile *f) } if (f->iovcnt > 0) { expect =3D iov_size(f->iov, f->iovcnt); - ret =3D f->ops->writev_buffer(f->opaque, f->iov, f->iovcnt, f->tot= al_transferred, + ret =3D f->ops->writev_buffer(f->ioc, f->iov, f->iovcnt, f->total_= transferred, &local_error); =20 qemu_iovec_release_ram(f); @@ -358,7 +356,7 @@ static ssize_t qemu_fill_buffer(QEMUFile *f) return 0; } =20 - len =3D f->ops->get_buffer(f->opaque, f->buf + pending, f->total_trans= ferred, + len =3D f->ops->get_buffer(f->ioc, f->buf + pending, f->total_transfer= red, IO_BUF_SIZE - pending, &local_error); if (len > 0) { f->buf_size +=3D len; @@ -394,7 +392,7 @@ int qemu_fclose(QEMUFile *f) ret =3D qemu_file_get_error(f); =20 if (f->ops->close) { - int ret2 =3D f->ops->close(f->opaque, NULL); + int ret2 =3D f->ops->close(f->ioc, NULL); if (ret >=3D 0) { ret =3D ret2; } @@ -861,18 +859,19 @@ void qemu_put_counted_string(QEMUFile *f, const char = *str) void qemu_file_set_blocking(QEMUFile *f, bool block) { if (f->ops->set_blocking) { - f->ops->set_blocking(f->opaque, block, NULL); + f->ops->set_blocking(f->ioc, block, NULL); } } =20 /* - * Return the ioc object if it's a migration channel. Note: it can return= NULL - * for callers passing in a non-migration qemufile. E.g. see qemu_fopen_b= drv() - * and its usage in e.g. load_snapshot(). So we need to check against NULL - * before using it. If without the check, migration_incoming_state_destro= y() - * could fail for load_snapshot(). + * qemu_file_get_ioc: + * + * Get the ioc object for the file, without incrementing + * the reference count. + * + * Returns: the ioc object */ QIOChannel *qemu_file_get_ioc(QEMUFile *file) { - return file->has_ioc ? QIO_CHANNEL(file->opaque) : NULL; + return file->ioc; } --=20 2.35.3 From nobody Wed May 22 00:43:24 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1655859125; cv=none; d=zohomail.com; s=zohoarc; b=Y934nKAA88uVob3J31oictdoyIu8LzyfYUa9mXQpawWSOOhmJACHS78EXUzXPNZqd3iYxXlLCXilHTDMKysqa9bJfaMGljUj+7ywGG92/J877Q6TuHtTM/b0BHA0Xc0JJt/uqxRcCnhIWllsVCbdzEiBXU99R02OYIvpT6TNe+U= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1655859125; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=lvEhFBNMgrTBeJs6+tHpDvdLbybo6LjkAAuRPKsRYMs=; b=Q4EnnkcXpW0WLihNIKTBQcfCd7/sMhqC/ODR1gqCtmTlCK0FrzAT4xLcPVoAS+6sIiLhYBHkHyPhviEZA/+nEBF6uVwJGnLeY0hpY0SWlh8Hi5ymStBi3XMv1aXp5a2HLfjqoH/aJtMzJSwhav7JKYOqQ8NK1Cp+j7xTyaSODf0= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1655859125778396.86585909971507; Tue, 21 Jun 2022 17:52:05 -0700 (PDT) Received: from localhost ([::1]:48098 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1o3obE-000632-3G for importer@patchew.org; Tue, 21 Jun 2022 20:52:04 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:56574) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1o3oCY-0003ZY-P3 for qemu-devel@nongnu.org; Tue, 21 Jun 2022 20:26:34 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:41614) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1o3oCW-0006B8-Hn for qemu-devel@nongnu.org; Tue, 21 Jun 2022 20:26:34 -0400 Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-511-V-apk1C4P7iqXBmuZ46ljg-1; Tue, 21 Jun 2022 20:26:26 -0400 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.rdu2.redhat.com [10.11.54.7]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id DB7F52999B42; Wed, 22 Jun 2022 00:26:25 +0000 (UTC) Received: from secure.mitica (unknown [10.39.192.22]) by smtp.corp.redhat.com (Postfix) with ESMTP id 32564141510D; Wed, 22 Jun 2022 00:26:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1655857592; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=lvEhFBNMgrTBeJs6+tHpDvdLbybo6LjkAAuRPKsRYMs=; b=i9K38E6/aRz+oGB5SFLVkpR2Qzt574wsFL8p61MDo3X4ti/deUctyJr3Jrv9Q8RKlNGyKv Mj0JyJ+3dSMfuPr9bVlIBS4D240ir/1ouKQ1DkGNlg1OGC4eYtWHmyo+OBGGvqhVe+ARSf wKpxfdlIvaezxfGLTvLuOS/owgiJOXc= X-MC-Unique: V-apk1C4P7iqXBmuZ46ljg-1 From: Juan Quintela To: qemu-devel@nongnu.org Cc: Hailiang Zhang , Eric Blake , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , Fam Zheng , "Dr. David Alan Gilbert" , Juan Quintela , qemu-block@nongnu.org, Stefan Hajnoczi , Markus Armbruster Subject: [PULL 17/25] migration: introduce new constructors for QEMUFile Date: Wed, 22 Jun 2022 02:25:39 +0200 Message-Id: <20220622002547.64784-18-quintela@redhat.com> In-Reply-To: <20220622002547.64784-1-quintela@redhat.com> References: <20220622002547.64784-1-quintela@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 2.85 on 10.11.54.7 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=quintela@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -28 X-Spam_score: -2.9 X-Spam_bar: -- X-Spam_report: (-2.9 / 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, RCVD_IN_DNSWL_LOW=-0.7, 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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1655859127489100001 From: Daniel P. Berrang=C3=A9 Prepare for the elimination of QEMUFileOps by introducing a pair of new constructors. This lets us distinguish between an input and output file object explicitly rather than via the existance of specific callbacks. Reviewed-by: Dr. David Alan Gilbert Signed-off-by: Daniel P. Berrang=C3=A9 Reviewed-by: Juan Quintela Signed-off-by: Juan Quintela --- migration/qemu-file.h | 3 ++- migration/qemu-file-channel.c | 4 ++-- migration/qemu-file.c | 18 ++++++++++++++++-- 3 files changed, 20 insertions(+), 5 deletions(-) diff --git a/migration/qemu-file.h b/migration/qemu-file.h index 3a1ecc0e34..3c93a27978 100644 --- a/migration/qemu-file.h +++ b/migration/qemu-file.h @@ -118,7 +118,8 @@ typedef struct QEMUFileHooks { QEMURamSaveFunc *save_page; } QEMUFileHooks; =20 -QEMUFile *qemu_fopen_ops(QIOChannel *ioc, const QEMUFileOps *ops); +QEMUFile *qemu_file_new_input(QIOChannel *ioc, const QEMUFileOps *ops); +QEMUFile *qemu_file_new_output(QIOChannel *ioc, const QEMUFileOps *ops); void qemu_file_set_hooks(QEMUFile *f, const QEMUFileHooks *hooks); int qemu_get_fd(QEMUFile *f); int qemu_fclose(QEMUFile *f); diff --git a/migration/qemu-file-channel.c b/migration/qemu-file-channel.c index ce8eced417..5cb8ac93c0 100644 --- a/migration/qemu-file-channel.c +++ b/migration/qemu-file-channel.c @@ -184,11 +184,11 @@ static const QEMUFileOps channel_output_ops =3D { QEMUFile *qemu_fopen_channel_input(QIOChannel *ioc) { object_ref(OBJECT(ioc)); - return qemu_fopen_ops(ioc, &channel_input_ops); + return qemu_file_new_input(ioc, &channel_input_ops); } =20 QEMUFile *qemu_fopen_channel_output(QIOChannel *ioc) { object_ref(OBJECT(ioc)); - return qemu_fopen_ops(ioc, &channel_output_ops); + return qemu_file_new_output(ioc, &channel_output_ops); } diff --git a/migration/qemu-file.c b/migration/qemu-file.c index ce48d7a5d8..c181686e41 100644 --- a/migration/qemu-file.c +++ b/migration/qemu-file.c @@ -38,6 +38,7 @@ struct QEMUFile { const QEMUFileOps *ops; const QEMUFileHooks *hooks; QIOChannel *ioc; + bool is_writable; =20 /* * Maximum amount of data in bytes to transfer during one @@ -111,7 +112,9 @@ bool qemu_file_mode_is_not_valid(const char *mode) return false; } =20 -QEMUFile *qemu_fopen_ops(QIOChannel *ioc, const QEMUFileOps *ops) +static QEMUFile *qemu_file_new_impl(QIOChannel *ioc, + const QEMUFileOps *ops, + bool is_writable) { QEMUFile *f; =20 @@ -119,10 +122,21 @@ QEMUFile *qemu_fopen_ops(QIOChannel *ioc, const QEMUF= ileOps *ops) =20 f->ioc =3D ioc; f->ops =3D ops; + f->is_writable =3D is_writable; =20 return f; } =20 +QEMUFile *qemu_file_new_output(QIOChannel *ioc, const QEMUFileOps *ops) +{ + return qemu_file_new_impl(ioc, ops, true); +} + +QEMUFile *qemu_file_new_input(QIOChannel *ioc, const QEMUFileOps *ops) +{ + return qemu_file_new_impl(ioc, ops, false); +} + =20 void qemu_file_set_hooks(QEMUFile *f, const QEMUFileHooks *hooks) { @@ -181,7 +195,7 @@ void qemu_file_set_error(QEMUFile *f, int ret) =20 bool qemu_file_is_writable(QEMUFile *f) { - return f->ops->writev_buffer; + return f->is_writable; } =20 static void qemu_iovec_release_ram(QEMUFile *f) --=20 2.35.3 From nobody Wed May 22 00:43:24 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1655858699; cv=none; d=zohomail.com; s=zohoarc; b=C+xCMFyIfI3XX2YbCWLQBu2qmh7JlqWIDmLVcUCr8fpPB2bpAd1A9zPwKMIf25LPzJZ6uwH2H3qw7h1COMpxwt/pMFwSzsWAcgbUTSLGJ+4irZC3OFqDkHDPXD+huRsjRCmPgAG40zzCFqijSeZsr0heOmWWLYpOMfvdlGy2mtg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1655858699; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=YMXj7/UV6N+OaeFIHmBxdoVMbN+yl9eFzWbxfrjkqfg=; b=UAqPZxex819Q8GA/oaEXnsKmcrVSHvVbEG4IRLMOhfKM2hiorCm91lTJ9cp/ynHH3ptMUWJeAYospfhV+BEAAijF/lgxfMmbnydv4P8edpSUWJLu95a0kcOgRwNSHVtw4EgbdcLLjEAC5oFUgpo1iOpVnUmjZbDVxHvyJ8pFSr0= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1655858699701196.83534578801311; Tue, 21 Jun 2022 17:44:59 -0700 (PDT) Received: from localhost ([::1]:36252 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1o3oUM-00061J-5D for importer@patchew.org; Tue, 21 Jun 2022 20:44:58 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:56538) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1o3oCX-0003Tt-EC for qemu-devel@nongnu.org; Tue, 21 Jun 2022 20:26:33 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:24384) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1o3oCW-0006B1-2P for qemu-devel@nongnu.org; Tue, 21 Jun 2022 20:26:33 -0400 Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-166-dojNh-yeMvOl3njM9l2SMA-1; Tue, 21 Jun 2022 20:26:28 -0400 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.rdu2.redhat.com [10.11.54.7]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id DC81C1C0896B; Wed, 22 Jun 2022 00:26:27 +0000 (UTC) Received: from secure.mitica (unknown [10.39.192.22]) by smtp.corp.redhat.com (Postfix) with ESMTP id 32D1D141510D; Wed, 22 Jun 2022 00:26:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1655857591; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=YMXj7/UV6N+OaeFIHmBxdoVMbN+yl9eFzWbxfrjkqfg=; b=T1+dCRWEZm2oltWj3A/8t+vBME+8C2Tu74XBeMljLQUlpCR5PZnpjvOR3mRkKSoQvtxUJN vz/SB4aNpVplyQpxT7pfpILjAD7Cwpv10vl7ejK2NIZDO1t85mEUomSPjGl0FbseO5sShJ lp2k7uYpUOy621v13xs0vqMZxwGW9W0= X-MC-Unique: dojNh-yeMvOl3njM9l2SMA-1 From: Juan Quintela To: qemu-devel@nongnu.org Cc: Hailiang Zhang , Eric Blake , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , Fam Zheng , "Dr. David Alan Gilbert" , Juan Quintela , qemu-block@nongnu.org, Stefan Hajnoczi , Markus Armbruster Subject: [PULL 18/25] migration: remove unused QEMUFileGetFD typedef / qemu_get_fd method Date: Wed, 22 Jun 2022 02:25:40 +0200 Message-Id: <20220622002547.64784-19-quintela@redhat.com> In-Reply-To: <20220622002547.64784-1-quintela@redhat.com> References: <20220622002547.64784-1-quintela@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 2.85 on 10.11.54.7 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=quintela@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -28 X-Spam_score: -2.9 X-Spam_bar: -- X-Spam_report: (-2.9 / 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, RCVD_IN_DNSWL_LOW=-0.7, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=unavailable 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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1655858701496100001 From: Daniel P. Berrang=C3=A9 Reviewed-by: Dr. David Alan Gilbert Signed-off-by: Daniel P. Berrang=C3=A9 Reviewed-by: Juan Quintela Signed-off-by: Juan Quintela --- migration/qemu-file.h | 5 ----- 1 file changed, 5 deletions(-) diff --git a/migration/qemu-file.h b/migration/qemu-file.h index 3c93a27978..fe1b2d1c00 100644 --- a/migration/qemu-file.h +++ b/migration/qemu-file.h @@ -46,10 +46,6 @@ typedef ssize_t (QEMUFileGetBufferFunc)(void *opaque, ui= nt8_t *buf, */ typedef int (QEMUFileCloseFunc)(void *opaque, Error **errp); =20 -/* Called to return the OS file descriptor associated to the QEMUFile. - */ -typedef int (QEMUFileGetFD)(void *opaque); - /* Called to change the blocking mode of the file */ typedef int (QEMUFileSetBlocking)(void *opaque, bool enabled, Error **errp= ); @@ -121,7 +117,6 @@ typedef struct QEMUFileHooks { QEMUFile *qemu_file_new_input(QIOChannel *ioc, const QEMUFileOps *ops); QEMUFile *qemu_file_new_output(QIOChannel *ioc, const QEMUFileOps *ops); void qemu_file_set_hooks(QEMUFile *f, const QEMUFileHooks *hooks); -int qemu_get_fd(QEMUFile *f); int qemu_fclose(QEMUFile *f); =20 /* --=20 2.35.3 From nobody Wed May 22 00:43:24 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1655858950; cv=none; d=zohomail.com; s=zohoarc; b=Q2RBfOsFhTGwXELCN86Lh6JQhI3WgPvTi2XXuBG9uBjYCeOS9i7iPgoR+rVxWOjzIVw8gMMVZAEaQQb4FXgEqkx7lUGhhA37PkYQHRWCLhS0meBfsiDR98XhVuscMB2zs3Df2JFAKwevpy3yG6W91WUWrivGRZ15tmGx1eGOv+8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1655858950; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=NNTbXlKmcZJr13PKqD2ut3OQ/QDn1CrT/BzHhpq1Di4=; b=WBW6OVRpSyBIAmAPRE4HUdsquFTpcYN96AUMQJWYYizwohne8kk0Q9xj0mIiTplpJfg4jJl/QO/MnrEH+jarUQ9eMt9Ft+ICeURbzp7TqM84P4jPNCuF3mkqJ5/2iO06tmnQ2tckE57ElwA49ybVdrCxRPw0YDVeAj+IU0rwh3I= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1655858950086166.46426193242326; Tue, 21 Jun 2022 17:49:10 -0700 (PDT) Received: from localhost ([::1]:42626 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1o3oYO-00027E-SV for importer@patchew.org; Tue, 21 Jun 2022 20:49:08 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:56540) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1o3oCX-0003U4-Ej for qemu-devel@nongnu.org; Tue, 21 Jun 2022 20:26:33 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:44985) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1o3oCV-0006Ax-RU for qemu-devel@nongnu.org; Tue, 21 Jun 2022 20:26:33 -0400 Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-312-t2cwzfetP9eX5m2lIxocRw-1; Tue, 21 Jun 2022 20:26:30 -0400 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.rdu2.redhat.com [10.11.54.7]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id DAB061C08969; Wed, 22 Jun 2022 00:26:29 +0000 (UTC) Received: from secure.mitica (unknown [10.39.192.22]) by smtp.corp.redhat.com (Postfix) with ESMTP id 317BC141510E; Wed, 22 Jun 2022 00:26:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1655857591; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=NNTbXlKmcZJr13PKqD2ut3OQ/QDn1CrT/BzHhpq1Di4=; b=DaLMDDUbDYMVk4pTg98GEC5U2jgaAUi49CdP6Tc9QgZo7fzIsct6gWKoij1jlliJvX47ii gZa2PrmP3klZbLQNPDUyyD2R2wvMOzb9I/TFh8owGctfl0xxtHrv6PPYQNQa3Zy6FpygGi qehbdjpRvi2Ppmnm4CHIF6Sy5lRyycM= X-MC-Unique: t2cwzfetP9eX5m2lIxocRw-1 From: Juan Quintela To: qemu-devel@nongnu.org Cc: Hailiang Zhang , Eric Blake , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , Fam Zheng , "Dr. David Alan Gilbert" , Juan Quintela , qemu-block@nongnu.org, Stefan Hajnoczi , Markus Armbruster Subject: [PULL 19/25] migration: remove the QEMUFileOps 'shut_down' callback Date: Wed, 22 Jun 2022 02:25:41 +0200 Message-Id: <20220622002547.64784-20-quintela@redhat.com> In-Reply-To: <20220622002547.64784-1-quintela@redhat.com> References: <20220622002547.64784-1-quintela@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 2.85 on 10.11.54.7 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=quintela@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -28 X-Spam_score: -2.9 X-Spam_bar: -- X-Spam_report: (-2.9 / 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, RCVD_IN_DNSWL_LOW=-0.7, 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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1655858950722100001 From: Daniel P. Berrang=C3=A9 This directly implements the shutdown logic using QIOChannel APIs. Reviewed-by: Dr. David Alan Gilbert Signed-off-by: Daniel P. Berrang=C3=A9 Reviewed-by: Juan Quintela Signed-off-by: Juan Quintela --- migration/qemu-file.h | 10 ---------- migration/qemu-file-channel.c | 27 --------------------------- migration/qemu-file.c | 13 ++++++++++--- 3 files changed, 10 insertions(+), 40 deletions(-) diff --git a/migration/qemu-file.h b/migration/qemu-file.h index fe1b2d1c00..9fa92c1998 100644 --- a/migration/qemu-file.h +++ b/migration/qemu-file.h @@ -89,22 +89,12 @@ typedef size_t (QEMURamSaveFunc)(QEMUFile *f, */ typedef QEMUFile *(QEMURetPathFunc)(void *opaque); =20 -/* - * Stop any read or write (depending on flags) on the underlying - * transport on the QEMUFile. - * Existing blocking reads/writes must be woken - * Returns 0 on success, -err on error - */ -typedef int (QEMUFileShutdownFunc)(void *opaque, bool rd, bool wr, - Error **errp); - typedef struct QEMUFileOps { QEMUFileGetBufferFunc *get_buffer; QEMUFileCloseFunc *close; QEMUFileSetBlocking *set_blocking; QEMUFileWritevBufferFunc *writev_buffer; QEMURetPathFunc *get_return_path; - QEMUFileShutdownFunc *shut_down; } QEMUFileOps; =20 typedef struct QEMUFileHooks { diff --git a/migration/qemu-file-channel.c b/migration/qemu-file-channel.c index 5cb8ac93c0..80f05dc371 100644 --- a/migration/qemu-file-channel.c +++ b/migration/qemu-file-channel.c @@ -112,31 +112,6 @@ static int channel_close(void *opaque, Error **errp) } =20 =20 -static int channel_shutdown(void *opaque, - bool rd, - bool wr, - Error **errp) -{ - QIOChannel *ioc =3D QIO_CHANNEL(opaque); - - if (qio_channel_has_feature(ioc, - QIO_CHANNEL_FEATURE_SHUTDOWN)) { - QIOChannelShutdown mode; - if (rd && wr) { - mode =3D QIO_CHANNEL_SHUTDOWN_BOTH; - } else if (rd) { - mode =3D QIO_CHANNEL_SHUTDOWN_READ; - } else { - mode =3D QIO_CHANNEL_SHUTDOWN_WRITE; - } - if (qio_channel_shutdown(ioc, mode, errp) < 0) { - return -EIO; - } - } - return 0; -} - - static int channel_set_blocking(void *opaque, bool enabled, Error **errp) @@ -166,7 +141,6 @@ static QEMUFile *channel_get_output_return_path(void *o= paque) static const QEMUFileOps channel_input_ops =3D { .get_buffer =3D channel_get_buffer, .close =3D channel_close, - .shut_down =3D channel_shutdown, .set_blocking =3D channel_set_blocking, .get_return_path =3D channel_get_input_return_path, }; @@ -175,7 +149,6 @@ static const QEMUFileOps channel_input_ops =3D { static const QEMUFileOps channel_output_ops =3D { .writev_buffer =3D channel_writev_buffer, .close =3D channel_close, - .shut_down =3D channel_shutdown, .set_blocking =3D channel_set_blocking, .get_return_path =3D channel_get_output_return_path, }; diff --git a/migration/qemu-file.c b/migration/qemu-file.c index c181686e41..6e79de1404 100644 --- a/migration/qemu-file.c +++ b/migration/qemu-file.c @@ -71,16 +71,23 @@ struct QEMUFile { /* * Stop a file from being read/written - not all backing files can do this * typically only sockets can. + * + * TODO: convert to propagate Error objects instead of squashing + * to a fixed errno value */ int qemu_file_shutdown(QEMUFile *f) { - int ret; + int ret =3D 0; =20 f->shutdown =3D true; - if (!f->ops->shut_down) { + if (!qio_channel_has_feature(f->ioc, + QIO_CHANNEL_FEATURE_SHUTDOWN)) { return -ENOSYS; } - ret =3D f->ops->shut_down(f->ioc, true, true, NULL); + + if (qio_channel_shutdown(f->ioc, QIO_CHANNEL_SHUTDOWN_BOTH, NULL) < 0)= { + ret =3D -EIO; + } =20 if (!f->last_error) { qemu_file_set_error(f, -EIO); --=20 2.35.3 From nobody Wed May 22 00:43:24 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1655859245; cv=none; d=zohomail.com; s=zohoarc; b=lcL3/AlLfQrQUq+jc5wVHCryB2Zc9n7F/+UTVGx/AKUo9tkTqWg8DtpFSPTk1xe5rmGzj2/9kH+NPT5/iFZwJJBQ+dFA4STZ/bvuHZmmk04oMPxCq/0O3dHHEvE+IjqTSvmqeqQVsoDsMvmRvc2SOTHjGGKn04V8oE+h0zA07tM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1655859245; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=RR2+LhBF7f5sdVTfye/zoJnZYvoHrBoL7asL5IJKR48=; b=iJEgfSwPZmdDBK7uNSOKMIaJv6/YtM9nYQwP/0Q4i0mtnURyHfb+mxeO6mgPgpuRasQgYFfti8wgZM+t1M+REr+JAKbkxtZXNwxbdM7OJJHMu5FiQwIW+7UFhqb/smGjMtN3o2fh3eEx7af6fiYGF0SWztJOcM7mvRwNVJ8ReuU= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1655859245037350.21446484138016; Tue, 21 Jun 2022 17:54:05 -0700 (PDT) Received: from localhost ([::1]:52768 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1o3od9-0000kS-UC for importer@patchew.org; Tue, 21 Jun 2022 20:54:03 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:56646) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1o3oCd-0003r7-VO for qemu-devel@nongnu.org; Tue, 21 Jun 2022 20:26:39 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:40524) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1o3oCc-0006CM-CE for qemu-devel@nongnu.org; Tue, 21 Jun 2022 20:26:39 -0400 Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-371-HiWphlH9M_W6iqSgKJv-Ig-1; Tue, 21 Jun 2022 20:26:32 -0400 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.rdu2.redhat.com [10.11.54.7]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id DC54D3804510; Wed, 22 Jun 2022 00:26:31 +0000 (UTC) Received: from secure.mitica (unknown [10.39.192.22]) by smtp.corp.redhat.com (Postfix) with ESMTP id 3201C141510D; Wed, 22 Jun 2022 00:26:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1655857597; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=RR2+LhBF7f5sdVTfye/zoJnZYvoHrBoL7asL5IJKR48=; b=JD+01z4NWdNIZWY09vUZW9QIvf2760/tnTcTa9cU3d9f5X5gtbxJRwfTHtI/3QWRKxDoIB 0ZB7bgdZcqrywX36DYythUU0YIkikcIhIilgTSyvfMa5t3JVl+W7eM7jhZCoVlTpvx8pmI MVImLmdCjcr5JP52V8A+kntyp7PSg4M= X-MC-Unique: HiWphlH9M_W6iqSgKJv-Ig-1 From: Juan Quintela To: qemu-devel@nongnu.org Cc: Hailiang Zhang , Eric Blake , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , Fam Zheng , "Dr. David Alan Gilbert" , Juan Quintela , qemu-block@nongnu.org, Stefan Hajnoczi , Markus Armbruster Subject: [PULL 20/25] migration: remove the QEMUFileOps 'set_blocking' callback Date: Wed, 22 Jun 2022 02:25:42 +0200 Message-Id: <20220622002547.64784-21-quintela@redhat.com> In-Reply-To: <20220622002547.64784-1-quintela@redhat.com> References: <20220622002547.64784-1-quintela@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 2.85 on 10.11.54.7 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=quintela@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -28 X-Spam_score: -2.9 X-Spam_bar: -- X-Spam_report: (-2.9 / 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, RCVD_IN_DNSWL_LOW=-0.7, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=unavailable 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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1655859246616100001 From: Daniel P. Berrang=C3=A9 This directly implements the set_blocking logic using QIOChannel APIs. Reviewed-by: Dr. David Alan Gilbert Signed-off-by: Daniel P. Berrang=C3=A9 Reviewed-by: Juan Quintela Signed-off-by: Juan Quintela --- migration/qemu-file.h | 5 ----- migration/qemu-file-channel.c | 14 -------------- migration/qemu-file.c | 4 +--- 3 files changed, 1 insertion(+), 22 deletions(-) diff --git a/migration/qemu-file.h b/migration/qemu-file.h index 9fa92c1998..7793e765f2 100644 --- a/migration/qemu-file.h +++ b/migration/qemu-file.h @@ -46,10 +46,6 @@ typedef ssize_t (QEMUFileGetBufferFunc)(void *opaque, ui= nt8_t *buf, */ typedef int (QEMUFileCloseFunc)(void *opaque, Error **errp); =20 -/* Called to change the blocking mode of the file - */ -typedef int (QEMUFileSetBlocking)(void *opaque, bool enabled, Error **errp= ); - /* * This function writes an iovec to file. The handler must write all * of the data or return a negative errno value. @@ -92,7 +88,6 @@ typedef QEMUFile *(QEMURetPathFunc)(void *opaque); typedef struct QEMUFileOps { QEMUFileGetBufferFunc *get_buffer; QEMUFileCloseFunc *close; - QEMUFileSetBlocking *set_blocking; QEMUFileWritevBufferFunc *writev_buffer; QEMURetPathFunc *get_return_path; } QEMUFileOps; diff --git a/migration/qemu-file-channel.c b/migration/qemu-file-channel.c index 80f05dc371..0350d367ec 100644 --- a/migration/qemu-file-channel.c +++ b/migration/qemu-file-channel.c @@ -112,18 +112,6 @@ static int channel_close(void *opaque, Error **errp) } =20 =20 -static int channel_set_blocking(void *opaque, - bool enabled, - Error **errp) -{ - QIOChannel *ioc =3D QIO_CHANNEL(opaque); - - if (qio_channel_set_blocking(ioc, enabled, errp) < 0) { - return -1; - } - return 0; -} - static QEMUFile *channel_get_input_return_path(void *opaque) { QIOChannel *ioc =3D QIO_CHANNEL(opaque); @@ -141,7 +129,6 @@ static QEMUFile *channel_get_output_return_path(void *o= paque) static const QEMUFileOps channel_input_ops =3D { .get_buffer =3D channel_get_buffer, .close =3D channel_close, - .set_blocking =3D channel_set_blocking, .get_return_path =3D channel_get_input_return_path, }; =20 @@ -149,7 +136,6 @@ static const QEMUFileOps channel_input_ops =3D { static const QEMUFileOps channel_output_ops =3D { .writev_buffer =3D channel_writev_buffer, .close =3D channel_close, - .set_blocking =3D channel_set_blocking, .get_return_path =3D channel_get_output_return_path, }; =20 diff --git a/migration/qemu-file.c b/migration/qemu-file.c index 6e79de1404..efbc0a5515 100644 --- a/migration/qemu-file.c +++ b/migration/qemu-file.c @@ -879,9 +879,7 @@ void qemu_put_counted_string(QEMUFile *f, const char *s= tr) */ void qemu_file_set_blocking(QEMUFile *f, bool block) { - if (f->ops->set_blocking) { - f->ops->set_blocking(f->ioc, block, NULL); - } + qio_channel_set_blocking(f->ioc, block, NULL); } =20 /* --=20 2.35.3 From nobody Wed May 22 00:43:24 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1655858889; cv=none; d=zohomail.com; s=zohoarc; b=m2tn1tRpgR0nmHpH4s0KTE8m5809PSjzKG+A7Esio6Ieho63zfHWoFtbaVvFpIsSZPLu8XMeNwr34H4LCzO3t78cqnq+32Sv+RwNX2eESLWyRUslcHaxeUgshi3lSbnU0u9bSHjBURMlLaucbaNnpHP9iGBTyfh0dI1t3RnyeMg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1655858889; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=q4loIAEnvKo9xONcIrW2rexLR/C5GP3Xpxrj+ksLtqg=; b=Q0RElUHf2srjG+tkzf2/W4GY8q2/luujCVC+t1ph7q2rDEtocHyDZsHPdYgbqtmT58oR5EBTLiFk6OiciGYHIXybXk9lTtmtEJ3ksYvgDuvHDprjyN6BR9iMMe69C4VVtHqT2VDV8IQ3R169vOCvuRF8DIuC/LGM0idQfhDfLAA= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 165585888901931.96637350965375; Tue, 21 Jun 2022 17:48:09 -0700 (PDT) Received: from localhost ([::1]:41280 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1o3oXP-0001Af-Oe for importer@patchew.org; Tue, 21 Jun 2022 20:48:07 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:56648) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1o3oCe-0003sT-8k for qemu-devel@nongnu.org; Tue, 21 Jun 2022 20:26:40 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:56755) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1o3oCc-0006CS-Kp for qemu-devel@nongnu.org; Tue, 21 Jun 2022 20:26:40 -0400 Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-386-S5MYx2cKPAW_u6drhciMwA-1; Tue, 21 Jun 2022 20:26:34 -0400 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.rdu2.redhat.com [10.11.54.7]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 8FD2585A581; Wed, 22 Jun 2022 00:26:34 +0000 (UTC) Received: from secure.mitica (unknown [10.39.192.22]) by smtp.corp.redhat.com (Postfix) with ESMTP id 33FDD141510D; Wed, 22 Jun 2022 00:26:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1655857598; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=q4loIAEnvKo9xONcIrW2rexLR/C5GP3Xpxrj+ksLtqg=; b=Yt7Usy30E+NKkxA/K2rC/NwKFWkstzzKDtfWcCxiPHHRnChV+q29ZyB0aoPZn8uJ1BuaoH p9Awkl0aG3QXjvM9pYT5E13Pr1gHcnVKp3lkr9xI23r/b5H4TmHTeDr4ZP8V4iBPDMYpte 7jlAAz85IUhV1lcdyKAOKzo4sQ7Chmg= X-MC-Unique: S5MYx2cKPAW_u6drhciMwA-1 From: Juan Quintela To: qemu-devel@nongnu.org Cc: Hailiang Zhang , Eric Blake , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , Fam Zheng , "Dr. David Alan Gilbert" , Juan Quintela , qemu-block@nongnu.org, Stefan Hajnoczi , Markus Armbruster Subject: [PULL 21/25] migration: remove the QEMUFileOps 'close' callback Date: Wed, 22 Jun 2022 02:25:43 +0200 Message-Id: <20220622002547.64784-22-quintela@redhat.com> In-Reply-To: <20220622002547.64784-1-quintela@redhat.com> References: <20220622002547.64784-1-quintela@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 2.85 on 10.11.54.7 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=quintela@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -28 X-Spam_score: -2.9 X-Spam_bar: -- X-Spam_report: (-2.9 / 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, RCVD_IN_DNSWL_LOW=-0.7, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=unavailable 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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1655858890445100001 From: Daniel P. Berrang=C3=A9 This directly implements the close logic using QIOChannel APIs. Reviewed-by: Dr. David Alan Gilbert Signed-off-by: Daniel P. Berrang=C3=A9 Reviewed-by: Juan Quintela Signed-off-by: Juan Quintela --- migration/qemu-file.h | 10 ---------- migration/qemu-file-channel.c | 12 ------------ migration/qemu-file.c | 12 ++++++------ 3 files changed, 6 insertions(+), 28 deletions(-) diff --git a/migration/qemu-file.h b/migration/qemu-file.h index 7793e765f2..4a3beedb5b 100644 --- a/migration/qemu-file.h +++ b/migration/qemu-file.h @@ -37,15 +37,6 @@ typedef ssize_t (QEMUFileGetBufferFunc)(void *opaque, ui= nt8_t *buf, int64_t pos, size_t size, Error **errp); =20 -/* Close a file - * - * Return negative error number on error, 0 or positive value on success. - * - * The meaning of return value on success depends on the specific back-end= being - * used. - */ -typedef int (QEMUFileCloseFunc)(void *opaque, Error **errp); - /* * This function writes an iovec to file. The handler must write all * of the data or return a negative errno value. @@ -87,7 +78,6 @@ typedef QEMUFile *(QEMURetPathFunc)(void *opaque); =20 typedef struct QEMUFileOps { QEMUFileGetBufferFunc *get_buffer; - QEMUFileCloseFunc *close; QEMUFileWritevBufferFunc *writev_buffer; QEMURetPathFunc *get_return_path; } QEMUFileOps; diff --git a/migration/qemu-file-channel.c b/migration/qemu-file-channel.c index 0350d367ec..8ff58e81f9 100644 --- a/migration/qemu-file-channel.c +++ b/migration/qemu-file-channel.c @@ -102,16 +102,6 @@ static ssize_t channel_get_buffer(void *opaque, } =20 =20 -static int channel_close(void *opaque, Error **errp) -{ - int ret; - QIOChannel *ioc =3D QIO_CHANNEL(opaque); - ret =3D qio_channel_close(ioc, errp); - object_unref(OBJECT(ioc)); - return ret; -} - - static QEMUFile *channel_get_input_return_path(void *opaque) { QIOChannel *ioc =3D QIO_CHANNEL(opaque); @@ -128,14 +118,12 @@ static QEMUFile *channel_get_output_return_path(void = *opaque) =20 static const QEMUFileOps channel_input_ops =3D { .get_buffer =3D channel_get_buffer, - .close =3D channel_close, .get_return_path =3D channel_get_input_return_path, }; =20 =20 static const QEMUFileOps channel_output_ops =3D { .writev_buffer =3D channel_writev_buffer, - .close =3D channel_close, .get_return_path =3D channel_get_output_return_path, }; =20 diff --git a/migration/qemu-file.c b/migration/qemu-file.c index efbc0a5515..5eb8cf0e28 100644 --- a/migration/qemu-file.c +++ b/migration/qemu-file.c @@ -408,16 +408,16 @@ void qemu_file_credit_transfer(QEMUFile *f, size_t si= ze) */ int qemu_fclose(QEMUFile *f) { - int ret; + int ret, ret2; qemu_fflush(f); ret =3D qemu_file_get_error(f); =20 - if (f->ops->close) { - int ret2 =3D f->ops->close(f->ioc, NULL); - if (ret >=3D 0) { - ret =3D ret2; - } + ret2 =3D qio_channel_close(f->ioc, NULL); + if (ret >=3D 0) { + ret =3D ret2; } + g_clear_pointer(&f->ioc, object_unref); + /* If any error was spotted before closing, we should report it * instead of the close() return value. */ --=20 2.35.3 From nobody Wed May 22 00:43:24 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1655859107; cv=none; d=zohomail.com; s=zohoarc; b=X51W627Wc3C+gVsWGeosMAzRz+pVsiLaWQXJilzvRxL2khNZrrl+4PDB4BIpZgd/28fV3GhWUNvI8HbNqvPh1/6CIXEPQFFrsb16ph+snhDNNnh5d5VJTv0RYYkrIRHzMpBeXEJeLI/hlDbwKwjCgCfmlvaj6iO48675HMLhoZI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1655859107; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=t8PJiIg3yp+yPrfSi/cfAxVxF12WLxTELw+Ll5yAc5Y=; b=VBj/O4DfUISaxdzy+FVjmJDndII40E2xh54N8rafOzC5ZKLaAIspRsuALdCjSl5lXTPApqLdWSzWu1sjzIt2Pa+IPSxBHJgwPVJKwSi9HDYoGaHIRuKWQa0iZZZYRsgwJGhZ6g2nGCD26jqyTY9O+Y8TtQpNC14XDq5ThbEe9Uw= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 16558591070521015.0562492879493; Tue, 21 Jun 2022 17:51:47 -0700 (PDT) Received: from localhost ([::1]:47256 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1o3oav-0005TG-Ih for importer@patchew.org; Tue, 21 Jun 2022 20:51:45 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:56672) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1o3oCf-0003w0-F1 for qemu-devel@nongnu.org; Tue, 21 Jun 2022 20:26:42 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:59246) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1o3oCc-0006CW-OF for qemu-devel@nongnu.org; Tue, 21 Jun 2022 20:26:41 -0400 Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-643-bDhPiobINcqxiKyjlnHwWQ-1; Tue, 21 Jun 2022 20:26:36 -0400 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.rdu2.redhat.com [10.11.54.7]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 8E44E811E75; Wed, 22 Jun 2022 00:26:36 +0000 (UTC) Received: from secure.mitica (unknown [10.39.192.22]) by smtp.corp.redhat.com (Postfix) with ESMTP id D8F78141510D; Wed, 22 Jun 2022 00:26:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1655857598; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=t8PJiIg3yp+yPrfSi/cfAxVxF12WLxTELw+Ll5yAc5Y=; b=Thm2wmRRcPpDVVuPxoO5d8a2xm/W+fLG62fcjsnci21nflAseZQFmRx5wXELa9PmfFDZog EE5rjM95MhkQvL+QuMLWleuKsnf3SJE4UoT2Fo+Kkd6V46/EQusNeJD5E8MVSHbxdq6x3N DAXVgAihFQQzvygXE0wSSLDvihZDr2U= X-MC-Unique: bDhPiobINcqxiKyjlnHwWQ-1 From: Juan Quintela To: qemu-devel@nongnu.org Cc: Hailiang Zhang , Eric Blake , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , Fam Zheng , "Dr. David Alan Gilbert" , Juan Quintela , qemu-block@nongnu.org, Stefan Hajnoczi , Markus Armbruster Subject: [PULL 22/25] migration: remove the QEMUFileOps 'get_buffer' callback Date: Wed, 22 Jun 2022 02:25:44 +0200 Message-Id: <20220622002547.64784-23-quintela@redhat.com> In-Reply-To: <20220622002547.64784-1-quintela@redhat.com> References: <20220622002547.64784-1-quintela@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 2.85 on 10.11.54.7 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=quintela@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -28 X-Spam_score: -2.9 X-Spam_bar: -- X-Spam_report: (-2.9 / 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, RCVD_IN_DNSWL_LOW=-0.7, 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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1655859107369100001 From: Daniel P. Berrang=C3=A9 This directly implements the get_buffer logic using QIOChannel APIs. Reviewed-by: Dr. David Alan Gilbert Signed-off-by: Daniel P. Berrang=C3=A9 Reviewed-by: Juan Quintela Signed-off-by: Juan Quintela --- migration/qemu-file.h | 9 --------- migration/qemu-file-channel.c | 29 ----------------------------- migration/qemu-file.c | 18 ++++++++++++++++-- 3 files changed, 16 insertions(+), 40 deletions(-) diff --git a/migration/qemu-file.h b/migration/qemu-file.h index 4a3beedb5b..f7ed568894 100644 --- a/migration/qemu-file.h +++ b/migration/qemu-file.h @@ -29,14 +29,6 @@ #include "exec/cpu-common.h" #include "io/channel.h" =20 -/* Read a chunk of data from a file at the given position. The pos argume= nt - * can be ignored if the file is only be used for streaming. The number of - * bytes actually read should be returned. - */ -typedef ssize_t (QEMUFileGetBufferFunc)(void *opaque, uint8_t *buf, - int64_t pos, size_t size, - Error **errp); - /* * This function writes an iovec to file. The handler must write all * of the data or return a negative errno value. @@ -77,7 +69,6 @@ typedef size_t (QEMURamSaveFunc)(QEMUFile *f, typedef QEMUFile *(QEMURetPathFunc)(void *opaque); =20 typedef struct QEMUFileOps { - QEMUFileGetBufferFunc *get_buffer; QEMUFileWritevBufferFunc *writev_buffer; QEMURetPathFunc *get_return_path; } QEMUFileOps; diff --git a/migration/qemu-file-channel.c b/migration/qemu-file-channel.c index 8ff58e81f9..7b32831752 100644 --- a/migration/qemu-file-channel.c +++ b/migration/qemu-file-channel.c @@ -74,34 +74,6 @@ static ssize_t channel_writev_buffer(void *opaque, } =20 =20 -static ssize_t channel_get_buffer(void *opaque, - uint8_t *buf, - int64_t pos, - size_t size, - Error **errp) -{ - QIOChannel *ioc =3D QIO_CHANNEL(opaque); - ssize_t ret; - - do { - ret =3D qio_channel_read(ioc, (char *)buf, size, errp); - if (ret < 0) { - if (ret =3D=3D QIO_CHANNEL_ERR_BLOCK) { - if (qemu_in_coroutine()) { - qio_channel_yield(ioc, G_IO_IN); - } else { - qio_channel_wait(ioc, G_IO_IN); - } - } else { - return -EIO; - } - } - } while (ret =3D=3D QIO_CHANNEL_ERR_BLOCK); - - return ret; -} - - static QEMUFile *channel_get_input_return_path(void *opaque) { QIOChannel *ioc =3D QIO_CHANNEL(opaque); @@ -117,7 +89,6 @@ static QEMUFile *channel_get_output_return_path(void *op= aque) } =20 static const QEMUFileOps channel_input_ops =3D { - .get_buffer =3D channel_get_buffer, .get_return_path =3D channel_get_input_return_path, }; =20 diff --git a/migration/qemu-file.c b/migration/qemu-file.c index 5eb8cf0e28..df438724cd 100644 --- a/migration/qemu-file.c +++ b/migration/qemu-file.c @@ -377,8 +377,22 @@ static ssize_t qemu_fill_buffer(QEMUFile *f) return 0; } =20 - len =3D f->ops->get_buffer(f->ioc, f->buf + pending, f->total_transfer= red, - IO_BUF_SIZE - pending, &local_error); + do { + len =3D qio_channel_read(f->ioc, + (char *)f->buf + pending, + IO_BUF_SIZE - pending, + &local_error); + if (len =3D=3D QIO_CHANNEL_ERR_BLOCK) { + if (qemu_in_coroutine()) { + qio_channel_yield(f->ioc, G_IO_IN); + } else { + qio_channel_wait(f->ioc, G_IO_IN); + } + } else if (len < 0) { + len =3D EIO; + } + } while (len =3D=3D QIO_CHANNEL_ERR_BLOCK); + if (len > 0) { f->buf_size +=3D len; f->total_transferred +=3D len; --=20 2.35.3 From nobody Wed May 22 00:43:24 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1655859001; cv=none; d=zohomail.com; s=zohoarc; b=Xo8U30QTJa74SYbpCdOwt1bhSlwIr7PtVreoU/zoySVOVJb50//m6hnwcnn3HrLswBpfx9Zeqgcz265VSxshIMmPuzfjmvy7WVz2XqL3cEFdSnPhreCEsJFgZafT0Q8u4Phqn/7QyarsaIYAI+ZoB+bk1uv/WPDeFv9jyWLNH/I= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1655859001; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=6js0qAaHxmu3dXcYfctx/iwpn1Ev8c7g31iO7EcPnCI=; b=mEBLnAN9U5JHhdaljrtU7tyB9hKAZxVIT83MDHb3OUGbNQ1IHNEPj5/19ALxV6pj6/T4H28ekJZlGnp0zqOBEzlxslUJX+pNq7Mqiics0hV6H8v3/zvgH1mvCaD5qFxZPZzUp72kJfQ9aOpvuMTBHoSXMZ7Xjem9gaRILoANWIc= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1655859001962690.1907494193111; Tue, 21 Jun 2022 17:50:01 -0700 (PDT) Received: from localhost ([::1]:43326 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1o3oZE-0002af-UA for importer@patchew.org; Tue, 21 Jun 2022 20:50:01 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:56714) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1o3oCi-0003zb-LW for qemu-devel@nongnu.org; Tue, 21 Jun 2022 20:26:44 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:28111) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1o3oCg-0006D9-R7 for qemu-devel@nongnu.org; Tue, 21 Jun 2022 20:26:44 -0400 Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-611-0QDHq750MxCzUTjdY8Bl7g-1; Tue, 21 Jun 2022 20:26:38 -0400 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.rdu2.redhat.com [10.11.54.7]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 90A6B1C08962; Wed, 22 Jun 2022 00:26:38 +0000 (UTC) Received: from secure.mitica (unknown [10.39.192.22]) by smtp.corp.redhat.com (Postfix) with ESMTP id DA078141510D; Wed, 22 Jun 2022 00:26:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1655857602; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=6js0qAaHxmu3dXcYfctx/iwpn1Ev8c7g31iO7EcPnCI=; b=YHZyyQ9wWeRca4x3dc74Hb5U7GVpr711d7qWnTaH3lK9yOlwtYmyNSCr9QC1UNOEZ6AJVs 9K2lCz+r28HJSEhQrYPE5TGd7+XG/DUYX9+XaCsaBAx303+GhBv+2zDXBRzx2UgS7ccQVk 0Kl9ir/EPjWC+sEA/hKbQUAKXKfqyzs= X-MC-Unique: 0QDHq750MxCzUTjdY8Bl7g-1 From: Juan Quintela To: qemu-devel@nongnu.org Cc: Hailiang Zhang , Eric Blake , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , Fam Zheng , "Dr. David Alan Gilbert" , Juan Quintela , qemu-block@nongnu.org, Stefan Hajnoczi , Markus Armbruster Subject: [PULL 23/25] migration: remove the QEMUFileOps 'writev_buffer' callback Date: Wed, 22 Jun 2022 02:25:45 +0200 Message-Id: <20220622002547.64784-24-quintela@redhat.com> In-Reply-To: <20220622002547.64784-1-quintela@redhat.com> References: <20220622002547.64784-1-quintela@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 2.85 on 10.11.54.7 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=quintela@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -28 X-Spam_score: -2.9 X-Spam_bar: -- X-Spam_report: (-2.9 / 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, RCVD_IN_DNSWL_LOW=-0.7, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=unavailable 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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1655859002872100001 From: Daniel P. Berrang=C3=A9 This directly implements the writev_buffer logic using QIOChannel APIs. Reviewed-by: Dr. David Alan Gilbert Signed-off-by: Daniel P. Berrang=C3=A9 Reviewed-by: Juan Quintela Signed-off-by: Juan Quintela --- migration/qemu-file.h | 9 -------- migration/qemu-file-channel.c | 43 ----------------------------------- migration/qemu-file.c | 24 +++++++------------ 3 files changed, 8 insertions(+), 68 deletions(-) diff --git a/migration/qemu-file.h b/migration/qemu-file.h index f7ed568894..de3f066014 100644 --- a/migration/qemu-file.h +++ b/migration/qemu-file.h @@ -29,14 +29,6 @@ #include "exec/cpu-common.h" #include "io/channel.h" =20 -/* - * This function writes an iovec to file. The handler must write all - * of the data or return a negative errno value. - */ -typedef ssize_t (QEMUFileWritevBufferFunc)(void *opaque, struct iovec *iov, - int iovcnt, int64_t pos, - Error **errp); - /* * This function provides hooks around different * stages of RAM migration. @@ -69,7 +61,6 @@ typedef size_t (QEMURamSaveFunc)(QEMUFile *f, typedef QEMUFile *(QEMURetPathFunc)(void *opaque); =20 typedef struct QEMUFileOps { - QEMUFileWritevBufferFunc *writev_buffer; QEMURetPathFunc *get_return_path; } QEMUFileOps; =20 diff --git a/migration/qemu-file-channel.c b/migration/qemu-file-channel.c index 7b32831752..2e139f7bcd 100644 --- a/migration/qemu-file-channel.c +++ b/migration/qemu-file-channel.c @@ -32,48 +32,6 @@ #include "yank_functions.h" =20 =20 -static ssize_t channel_writev_buffer(void *opaque, - struct iovec *iov, - int iovcnt, - int64_t pos, - Error **errp) -{ - QIOChannel *ioc =3D QIO_CHANNEL(opaque); - ssize_t done =3D 0; - struct iovec *local_iov =3D g_new(struct iovec, iovcnt); - struct iovec *local_iov_head =3D local_iov; - unsigned int nlocal_iov =3D iovcnt; - - nlocal_iov =3D iov_copy(local_iov, nlocal_iov, - iov, iovcnt, - 0, iov_size(iov, iovcnt)); - - while (nlocal_iov > 0) { - ssize_t len; - len =3D qio_channel_writev(ioc, local_iov, nlocal_iov, errp); - if (len =3D=3D QIO_CHANNEL_ERR_BLOCK) { - if (qemu_in_coroutine()) { - qio_channel_yield(ioc, G_IO_OUT); - } else { - qio_channel_wait(ioc, G_IO_OUT); - } - continue; - } - if (len < 0) { - done =3D -EIO; - goto cleanup; - } - - iov_discard_front(&local_iov, &nlocal_iov, len); - done +=3D len; - } - - cleanup: - g_free(local_iov_head); - return done; -} - - static QEMUFile *channel_get_input_return_path(void *opaque) { QIOChannel *ioc =3D QIO_CHANNEL(opaque); @@ -94,7 +52,6 @@ static const QEMUFileOps channel_input_ops =3D { =20 =20 static const QEMUFileOps channel_output_ops =3D { - .writev_buffer =3D channel_writev_buffer, .get_return_path =3D channel_get_output_return_path, }; =20 diff --git a/migration/qemu-file.c b/migration/qemu-file.c index df438724cd..b787dabff7 100644 --- a/migration/qemu-file.c +++ b/migration/qemu-file.c @@ -248,10 +248,6 @@ static void qemu_iovec_release_ram(QEMUFile *f) */ void qemu_fflush(QEMUFile *f) { - ssize_t ret =3D 0; - ssize_t expect =3D 0; - Error *local_error =3D NULL; - if (!qemu_file_is_writable(f)) { return; } @@ -260,22 +256,18 @@ void qemu_fflush(QEMUFile *f) return; } if (f->iovcnt > 0) { - expect =3D iov_size(f->iov, f->iovcnt); - ret =3D f->ops->writev_buffer(f->ioc, f->iov, f->iovcnt, f->total_= transferred, - &local_error); + Error *local_error =3D NULL; + if (qio_channel_writev_all(f->ioc, + f->iov, f->iovcnt, + &local_error) < 0) { + qemu_file_set_error_obj(f, -EIO, local_error); + } else { + f->total_transferred +=3D iov_size(f->iov, f->iovcnt); + } =20 qemu_iovec_release_ram(f); } =20 - if (ret >=3D 0) { - f->total_transferred +=3D ret; - } - /* We expect the QEMUFile write impl to send the full - * data set we requested, so sanity check that. - */ - if (ret !=3D expect) { - qemu_file_set_error_obj(f, ret < 0 ? ret : -EIO, local_error); - } f->buf_index =3D 0; f->iovcnt =3D 0; } --=20 2.35.3 From nobody Wed May 22 00:43:24 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1655859215; cv=none; d=zohomail.com; s=zohoarc; b=Q5I/egQ+EDgB6KiPi6rkriTi7cKv2rFPxv2mlMhFbY2lm4Zt8SO3fu9xFg0FUGHOllReicyXIP3KMNbeqH0eDSIOQtoyS4V69Ov3k+MLQkXQqLagKpznoUDS2dPWhNJFEg+/7yEEPXyPMfrZY+OP57trVCN0r4VLm4HzzsVbdjs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1655859215; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=jN/86Sgr+GZX0ygMWQglO1d9rCVXd5+43foFBUPa6fs=; b=Vxj1X5eUTrgL1IOD6z4jXmIUW84NRRv0Ca1JaPqG9dxPWX7BY1it33/irk/VQYB01mXq3Ur3QtLB8/9pOyu0tMl/LkytdkO8t6YLCfANN06rlvpQAn6BoCzt03tJMRPu6CBEvdiUIXWXNLU5SVzV2ManoxczUrkBNn7I1VdJ4CY= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1655859215840915.3009551440684; Tue, 21 Jun 2022 17:53:35 -0700 (PDT) Received: from localhost ([::1]:51462 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1o3ocg-0008Jq-0P for importer@patchew.org; Tue, 21 Jun 2022 20:53:34 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:56732) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1o3oCm-00045G-5f for qemu-devel@nongnu.org; Tue, 21 Jun 2022 20:26:48 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:25065) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1o3oCj-0006DR-5a for qemu-devel@nongnu.org; Tue, 21 Jun 2022 20:26:46 -0400 Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-523-Wd7cc6O9NgCGoyCSWNMECg-1; Tue, 21 Jun 2022 20:26:42 -0400 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.rdu2.redhat.com [10.11.54.7]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 927DC1C08962; Wed, 22 Jun 2022 00:26:40 +0000 (UTC) Received: from secure.mitica (unknown [10.39.192.22]) by smtp.corp.redhat.com (Postfix) with ESMTP id DC5BE141510D; Wed, 22 Jun 2022 00:26:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1655857603; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=jN/86Sgr+GZX0ygMWQglO1d9rCVXd5+43foFBUPa6fs=; b=KfivJIC2SbcIPvpG7Gi30Pw8MEeZQOtG0L9VlF12p2PNn8/Z8WdO/JALNcGNt51h55x/QV lHdFNwsBXryHkwnzi8EblNdCdwVczYt7nWEmelx8qEvpI2fFZZJKLYJtfsTM/onIHZw++q 5YH/vOgHytFcFNm2ZGbjyZurNw6sVQQ= X-MC-Unique: Wd7cc6O9NgCGoyCSWNMECg-1 From: Juan Quintela To: qemu-devel@nongnu.org Cc: Hailiang Zhang , Eric Blake , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , Fam Zheng , "Dr. David Alan Gilbert" , Juan Quintela , qemu-block@nongnu.org, Stefan Hajnoczi , Markus Armbruster Subject: [PULL 24/25] migration: remove the QEMUFileOps 'get_return_path' callback Date: Wed, 22 Jun 2022 02:25:46 +0200 Message-Id: <20220622002547.64784-25-quintela@redhat.com> In-Reply-To: <20220622002547.64784-1-quintela@redhat.com> References: <20220622002547.64784-1-quintela@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 2.85 on 10.11.54.7 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=quintela@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -28 X-Spam_score: -2.9 X-Spam_bar: -- X-Spam_report: (-2.9 / 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, RCVD_IN_DNSWL_LOW=-0.7, 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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1655859216595100001 From: Daniel P. Berrang=C3=A9 This directly implements the get_return_path logic using QIOChannel APIs. Reviewed-by: Dr. David Alan Gilbert Signed-off-by: Daniel P. Berrang=C3=A9 Reviewed-by: Juan Quintela Signed-off-by: Juan Quintela --- migration/qemu-file.h | 6 ------ migration/qemu-file-channel.c | 16 ---------------- migration/qemu-file.c | 22 ++++++++++------------ 3 files changed, 10 insertions(+), 34 deletions(-) diff --git a/migration/qemu-file.h b/migration/qemu-file.h index de3f066014..fe8f9766d1 100644 --- a/migration/qemu-file.h +++ b/migration/qemu-file.h @@ -55,13 +55,7 @@ typedef size_t (QEMURamSaveFunc)(QEMUFile *f, size_t size, uint64_t *bytes_sent); =20 -/* - * Return a QEMUFile for comms in the opposite direction - */ -typedef QEMUFile *(QEMURetPathFunc)(void *opaque); - typedef struct QEMUFileOps { - QEMURetPathFunc *get_return_path; } QEMUFileOps; =20 typedef struct QEMUFileHooks { diff --git a/migration/qemu-file-channel.c b/migration/qemu-file-channel.c index 2e139f7bcd..51717c1137 100644 --- a/migration/qemu-file-channel.c +++ b/migration/qemu-file-channel.c @@ -32,27 +32,11 @@ #include "yank_functions.h" =20 =20 -static QEMUFile *channel_get_input_return_path(void *opaque) -{ - QIOChannel *ioc =3D QIO_CHANNEL(opaque); - - return qemu_fopen_channel_output(ioc); -} - -static QEMUFile *channel_get_output_return_path(void *opaque) -{ - QIOChannel *ioc =3D QIO_CHANNEL(opaque); - - return qemu_fopen_channel_input(ioc); -} - static const QEMUFileOps channel_input_ops =3D { - .get_return_path =3D channel_get_input_return_path, }; =20 =20 static const QEMUFileOps channel_output_ops =3D { - .get_return_path =3D channel_get_output_return_path, }; =20 =20 diff --git a/migration/qemu-file.c b/migration/qemu-file.c index b787dabff7..cea9a0de7d 100644 --- a/migration/qemu-file.c +++ b/migration/qemu-file.c @@ -95,18 +95,6 @@ int qemu_file_shutdown(QEMUFile *f) return ret; } =20 -/* - * Result: QEMUFile* for a 'return path' for comms in the opposite directi= on - * NULL if not available - */ -QEMUFile *qemu_file_get_return_path(QEMUFile *f) -{ - if (!f->ops->get_return_path) { - return NULL; - } - return f->ops->get_return_path(f->ioc); -} - bool qemu_file_mode_is_not_valid(const char *mode) { if (mode =3D=3D NULL || @@ -134,6 +122,16 @@ static QEMUFile *qemu_file_new_impl(QIOChannel *ioc, return f; } =20 +/* + * Result: QEMUFile* for a 'return path' for comms in the opposite directi= on + * NULL if not available + */ +QEMUFile *qemu_file_get_return_path(QEMUFile *f) +{ + object_ref(f->ioc); + return qemu_file_new_impl(f->ioc, f->ops, !f->is_writable); +} + QEMUFile *qemu_file_new_output(QIOChannel *ioc, const QEMUFileOps *ops) { return qemu_file_new_impl(ioc, ops, true); --=20 2.35.3 From nobody Wed May 22 00:43:24 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1655859412; cv=none; d=zohomail.com; s=zohoarc; b=RxWR2TzMk/8Kh7boYR4psT9DKQGrq9Mg5+thRymg1mnIGH8ber9ZuciZ6IpaiECajMFxBdcKqmHBCC0uaEv5BEALKprch2785Ij1oCXI2XtZ5HL8Yr8UwnHRhK13STtAkZJGEr0Ewi4DitudrX15IyTIfxYvJ8dYoYGb3yhLnFM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1655859412; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=c9pnYF28Ia3mYFtH/EZLUVD9A6oRUhaSNku4YZJ6x1g=; b=mHxPI+hH4v4sTKgFWI3st25HCo3gA56SHe+OpAWrt3RILW9N4PV66eJ7smNtmkOYXBmV3P+cmmF4ZSc9K+G/EpujvCovsMjG1dAZ2XJWkQakMmV1ypuhs8umvXQoVIqNLauErXujphgkLSp6Zeqvfva4FnA18S1XJFL0K/Rrask= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1655859412405680.9442301607756; Tue, 21 Jun 2022 17:56:52 -0700 (PDT) Received: from localhost ([::1]:56558 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1o3ofr-0003LK-9I for importer@patchew.org; Tue, 21 Jun 2022 20:56:51 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:56834) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1o3oCt-0004Bm-Kq for qemu-devel@nongnu.org; Tue, 21 Jun 2022 20:26:56 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:55786) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1o3oCn-0006G5-Ti for qemu-devel@nongnu.org; Tue, 21 Jun 2022 20:26:53 -0400 Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-617-IJfRjYaDOgS_obsei9In7w-1; Tue, 21 Jun 2022 20:26:46 -0400 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.rdu2.redhat.com [10.11.54.7]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id B81CA811E76; Wed, 22 Jun 2022 00:26:42 +0000 (UTC) Received: from secure.mitica (unknown [10.39.192.22]) by smtp.corp.redhat.com (Postfix) with ESMTP id DFA6D141510D; Wed, 22 Jun 2022 00:26:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1655857609; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=c9pnYF28Ia3mYFtH/EZLUVD9A6oRUhaSNku4YZJ6x1g=; b=CbZXm77K/TqhOTUNdDRm5O5a4T6Cook0Jp2U6toPIdgb1BAEnFELe+gt41BDgI5hMK80DN jnPQtEQDV3ddBpcergrAkJ76LXS3ISPmzNFsZPX9TgjRV7GtAyM68LXKImubeE8JI/p1aD XKih/yU8ZDKVXyvaRHE9r3SqtzAiWC4= X-MC-Unique: IJfRjYaDOgS_obsei9In7w-1 From: Juan Quintela To: qemu-devel@nongnu.org Cc: Hailiang Zhang , Eric Blake , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , Fam Zheng , "Dr. David Alan Gilbert" , Juan Quintela , qemu-block@nongnu.org, Stefan Hajnoczi , Markus Armbruster Subject: [PULL 25/25] migration: remove the QEMUFileOps abstraction Date: Wed, 22 Jun 2022 02:25:47 +0200 Message-Id: <20220622002547.64784-26-quintela@redhat.com> In-Reply-To: <20220622002547.64784-1-quintela@redhat.com> References: <20220622002547.64784-1-quintela@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 2.85 on 10.11.54.7 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=quintela@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -28 X-Spam_score: -2.9 X-Spam_bar: -- X-Spam_report: (-2.9 / 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, RCVD_IN_DNSWL_LOW=-0.7, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=unavailable 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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1655859413289100001 From: Daniel P. Berrang=C3=A9 Now that all QEMUFile callbacks are removed, the entire concept can be deleted. Reviewed-by: Dr. David Alan Gilbert Signed-off-by: Daniel P. Berrang=C3=A9 Reviewed-by: Juan Quintela Signed-off-by: Juan Quintela --- migration/qemu-file-channel.h | 32 --------------------- migration/qemu-file.h | 7 ++--- migration/channel.c | 4 +-- migration/colo.c | 5 ++-- migration/migration.c | 7 ++--- migration/qemu-file-channel.c | 53 ----------------------------------- migration/qemu-file.c | 20 ++++++------- migration/ram.c | 3 +- migration/rdma.c | 5 ++-- migration/savevm.c | 11 ++++---- tests/unit/test-vmstate.c | 5 ++-- migration/meson.build | 1 - 12 files changed, 27 insertions(+), 126 deletions(-) delete mode 100644 migration/qemu-file-channel.h delete mode 100644 migration/qemu-file-channel.c diff --git a/migration/qemu-file-channel.h b/migration/qemu-file-channel.h deleted file mode 100644 index 0028a09eb6..0000000000 --- a/migration/qemu-file-channel.h +++ /dev/null @@ -1,32 +0,0 @@ -/* - * QEMUFile backend for QIOChannel objects - * - * Copyright (c) 2015-2016 Red Hat, Inc - * - * Permission is hereby granted, free of charge, to any person obtaining a= copy - * of this software and associated documentation files (the "Software"), t= o deal - * in the Software without restriction, including without limitation the r= ights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or se= ll - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included= in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS= OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OT= HER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING= FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS = IN - * THE SOFTWARE. - */ - -#ifndef QEMU_FILE_CHANNEL_H -#define QEMU_FILE_CHANNEL_H - -#include "io/channel.h" - -QEMUFile *qemu_fopen_channel_input(QIOChannel *ioc); -QEMUFile *qemu_fopen_channel_output(QIOChannel *ioc); -#endif diff --git a/migration/qemu-file.h b/migration/qemu-file.h index fe8f9766d1..96e72d8bd8 100644 --- a/migration/qemu-file.h +++ b/migration/qemu-file.h @@ -55,9 +55,6 @@ typedef size_t (QEMURamSaveFunc)(QEMUFile *f, size_t size, uint64_t *bytes_sent); =20 -typedef struct QEMUFileOps { -} QEMUFileOps; - typedef struct QEMUFileHooks { QEMURamHookFunc *before_ram_iterate; QEMURamHookFunc *after_ram_iterate; @@ -65,8 +62,8 @@ typedef struct QEMUFileHooks { QEMURamSaveFunc *save_page; } QEMUFileHooks; =20 -QEMUFile *qemu_file_new_input(QIOChannel *ioc, const QEMUFileOps *ops); -QEMUFile *qemu_file_new_output(QIOChannel *ioc, const QEMUFileOps *ops); +QEMUFile *qemu_file_new_input(QIOChannel *ioc); +QEMUFile *qemu_file_new_output(QIOChannel *ioc); void qemu_file_set_hooks(QEMUFile *f, const QEMUFileHooks *hooks); int qemu_fclose(QEMUFile *f); =20 diff --git a/migration/channel.c b/migration/channel.c index a162d00fea..90087d8986 100644 --- a/migration/channel.c +++ b/migration/channel.c @@ -14,7 +14,7 @@ #include "channel.h" #include "tls.h" #include "migration.h" -#include "qemu-file-channel.h" +#include "qemu-file.h" #include "trace.h" #include "qapi/error.h" #include "io/channel-tls.h" @@ -85,7 +85,7 @@ void migration_channel_connect(MigrationState *s, return; } } else { - QEMUFile *f =3D qemu_fopen_channel_output(ioc); + QEMUFile *f =3D qemu_file_new_output(ioc); =20 migration_ioc_register_yank(ioc); =20 diff --git a/migration/colo.c b/migration/colo.c index 5f7071b3cd..2b71722fd6 100644 --- a/migration/colo.c +++ b/migration/colo.c @@ -14,7 +14,6 @@ #include "sysemu/sysemu.h" #include "qapi/error.h" #include "qapi/qapi-commands-migration.h" -#include "qemu-file-channel.h" #include "migration.h" #include "qemu-file.h" #include "savevm.h" @@ -559,7 +558,7 @@ static void colo_process_checkpoint(MigrationState *s) goto out; } bioc =3D qio_channel_buffer_new(COLO_BUFFER_BASE_SIZE); - fb =3D qemu_fopen_channel_output(QIO_CHANNEL(bioc)); + fb =3D qemu_file_new_output(QIO_CHANNEL(bioc)); object_unref(OBJECT(bioc)); =20 qemu_mutex_lock_iothread(); @@ -873,7 +872,7 @@ void *colo_process_incoming_thread(void *opaque) colo_incoming_start_dirty_log(); =20 bioc =3D qio_channel_buffer_new(COLO_BUFFER_BASE_SIZE); - fb =3D qemu_fopen_channel_input(QIO_CHANNEL(bioc)); + fb =3D qemu_file_new_input(QIO_CHANNEL(bioc)); object_unref(OBJECT(bioc)); =20 qemu_mutex_lock_iothread(); diff --git a/migration/migration.c b/migration/migration.c index e07d9359c6..4aa8e0446b 100644 --- a/migration/migration.c +++ b/migration/migration.c @@ -30,7 +30,6 @@ #include "migration/misc.h" #include "migration.h" #include "savevm.h" -#include "qemu-file-channel.h" #include "qemu-file.h" #include "migration/vmstate.h" #include "block/block.h" @@ -723,7 +722,7 @@ void migration_ioc_process_incoming(QIOChannel *ioc, Er= ror **errp) =20 if (!mis->from_src_file) { /* The first connection (multifd may have multiple) */ - QEMUFile *f =3D qemu_fopen_channel_input(ioc); + QEMUFile *f =3D qemu_file_new_input(ioc); =20 if (!migration_incoming_setup(f, errp)) { return; @@ -3070,7 +3069,7 @@ static int postcopy_start(MigrationState *ms) */ bioc =3D qio_channel_buffer_new(4096); qio_channel_set_name(QIO_CHANNEL(bioc), "migration-postcopy-buffer"); - fb =3D qemu_fopen_channel_output(QIO_CHANNEL(bioc)); + fb =3D qemu_file_new_output(QIO_CHANNEL(bioc)); object_unref(OBJECT(bioc)); =20 /* @@ -3960,7 +3959,7 @@ static void *bg_migration_thread(void *opaque) */ s->bioc =3D qio_channel_buffer_new(512 * 1024); qio_channel_set_name(QIO_CHANNEL(s->bioc), "vmstate-buffer"); - fb =3D qemu_fopen_channel_output(QIO_CHANNEL(s->bioc)); + fb =3D qemu_file_new_output(QIO_CHANNEL(s->bioc)); object_unref(OBJECT(s->bioc)); =20 update_iteration_initial_status(s); diff --git a/migration/qemu-file-channel.c b/migration/qemu-file-channel.c deleted file mode 100644 index 51717c1137..0000000000 --- a/migration/qemu-file-channel.c +++ /dev/null @@ -1,53 +0,0 @@ -/* - * QEMUFile backend for QIOChannel objects - * - * Copyright (c) 2015-2016 Red Hat, Inc - * - * Permission is hereby granted, free of charge, to any person obtaining a= copy - * of this software and associated documentation files (the "Software"), t= o deal - * in the Software without restriction, including without limitation the r= ights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or se= ll - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included= in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS= OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OT= HER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING= FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS = IN - * THE SOFTWARE. - */ - -#include "qemu/osdep.h" -#include "qemu-file-channel.h" -#include "qemu-file.h" -#include "io/channel-socket.h" -#include "io/channel-tls.h" -#include "qemu/iov.h" -#include "qemu/yank.h" -#include "yank_functions.h" - - -static const QEMUFileOps channel_input_ops =3D { -}; - - -static const QEMUFileOps channel_output_ops =3D { -}; - - -QEMUFile *qemu_fopen_channel_input(QIOChannel *ioc) -{ - object_ref(OBJECT(ioc)); - return qemu_file_new_input(ioc, &channel_input_ops); -} - -QEMUFile *qemu_fopen_channel_output(QIOChannel *ioc) -{ - object_ref(OBJECT(ioc)); - return qemu_file_new_output(ioc, &channel_output_ops); -} diff --git a/migration/qemu-file.c b/migration/qemu-file.c index cea9a0de7d..3a380a6072 100644 --- a/migration/qemu-file.c +++ b/migration/qemu-file.c @@ -35,7 +35,6 @@ #define MAX_IOV_SIZE MIN_CONST(IOV_MAX, 64) =20 struct QEMUFile { - const QEMUFileOps *ops; const QEMUFileHooks *hooks; QIOChannel *ioc; bool is_writable; @@ -107,16 +106,14 @@ bool qemu_file_mode_is_not_valid(const char *mode) return false; } =20 -static QEMUFile *qemu_file_new_impl(QIOChannel *ioc, - const QEMUFileOps *ops, - bool is_writable) +static QEMUFile *qemu_file_new_impl(QIOChannel *ioc, bool is_writable) { QEMUFile *f; =20 f =3D g_new0(QEMUFile, 1); =20 + object_ref(ioc); f->ioc =3D ioc; - f->ops =3D ops; f->is_writable =3D is_writable; =20 return f; @@ -128,21 +125,19 @@ static QEMUFile *qemu_file_new_impl(QIOChannel *ioc, */ QEMUFile *qemu_file_get_return_path(QEMUFile *f) { - object_ref(f->ioc); - return qemu_file_new_impl(f->ioc, f->ops, !f->is_writable); + return qemu_file_new_impl(f->ioc, !f->is_writable); } =20 -QEMUFile *qemu_file_new_output(QIOChannel *ioc, const QEMUFileOps *ops) +QEMUFile *qemu_file_new_output(QIOChannel *ioc) { - return qemu_file_new_impl(ioc, ops, true); + return qemu_file_new_impl(ioc, true); } =20 -QEMUFile *qemu_file_new_input(QIOChannel *ioc, const QEMUFileOps *ops) +QEMUFile *qemu_file_new_input(QIOChannel *ioc) { - return qemu_file_new_impl(ioc, ops, false); + return qemu_file_new_impl(ioc, false); } =20 - void qemu_file_set_hooks(QEMUFile *f, const QEMUFileHooks *hooks) { f->hooks =3D hooks; @@ -238,6 +233,7 @@ static void qemu_iovec_release_ram(QEMUFile *f) memset(f->may_free, 0, sizeof(f->may_free)); } =20 + /** * Flushes QEMUFile buffer * diff --git a/migration/ram.c b/migration/ram.c index bf321e1e72..01f9cc1d72 100644 --- a/migration/ram.c +++ b/migration/ram.c @@ -38,7 +38,6 @@ #include "migration.h" #include "migration/register.h" #include "migration/misc.h" -#include "migration/qemu-file-channel.h" #include "qemu-file.h" #include "postcopy-ram.h" #include "page_cache.h" @@ -569,7 +568,7 @@ static int compress_threads_save_setup(void) /* comp_param[i].file is just used as a dummy buffer to save data, * set its ops to empty. */ - comp_param[i].file =3D qemu_fopen_channel_output( + comp_param[i].file =3D qemu_file_new_output( QIO_CHANNEL(qio_channel_null_new())); comp_param[i].done =3D true; comp_param[i].quit =3D false; diff --git a/migration/rdma.c b/migration/rdma.c index 26a0cbbf40..94a55dd95b 100644 --- a/migration/rdma.c +++ b/migration/rdma.c @@ -21,7 +21,6 @@ #include "migration.h" #include "qemu-file.h" #include "ram.h" -#include "qemu-file-channel.h" #include "qemu/error-report.h" #include "qemu/main-loop.h" #include "qemu/module.h" @@ -4052,12 +4051,12 @@ static QEMUFile *qemu_fopen_rdma(RDMAContext *rdma,= const char *mode) rioc =3D QIO_CHANNEL_RDMA(object_new(TYPE_QIO_CHANNEL_RDMA)); =20 if (mode[0] =3D=3D 'w') { - rioc->file =3D qemu_fopen_channel_output(QIO_CHANNEL(rioc)); + rioc->file =3D qemu_file_new_output(QIO_CHANNEL(rioc)); rioc->rdmaout =3D rdma; rioc->rdmain =3D rdma->return_path; qemu_file_set_hooks(rioc->file, &rdma_write_hooks); } else { - rioc->file =3D qemu_fopen_channel_input(QIO_CHANNEL(rioc)); + rioc->file =3D qemu_file_new_input(QIO_CHANNEL(rioc)); rioc->rdmain =3D rdma; rioc->rdmaout =3D rdma->return_path; qemu_file_set_hooks(rioc->file, &rdma_read_hooks); diff --git a/migration/savevm.c b/migration/savevm.c index 24a50376dc..e8a1b96fcd 100644 --- a/migration/savevm.c +++ b/migration/savevm.c @@ -37,7 +37,6 @@ #include "migration/global_state.h" #include "migration/channel-block.h" #include "ram.h" -#include "qemu-file-channel.h" #include "qemu-file.h" #include "savevm.h" #include "postcopy-ram.h" @@ -134,9 +133,9 @@ static struct mig_cmd_args { static QEMUFile *qemu_fopen_bdrv(BlockDriverState *bs, int is_writable) { if (is_writable) { - return qemu_fopen_channel_output(QIO_CHANNEL(qio_channel_block_new= (bs))); + return qemu_file_new_output(QIO_CHANNEL(qio_channel_block_new(bs))= ); } else { - return qemu_fopen_channel_input(QIO_CHANNEL(qio_channel_block_new(= bs))); + return qemu_file_new_input(QIO_CHANNEL(qio_channel_block_new(bs))); } } =20 @@ -2159,7 +2158,7 @@ static int loadvm_handle_cmd_packaged(MigrationIncomi= ngState *mis) bioc->usage +=3D length; trace_loadvm_handle_cmd_packaged_received(ret); =20 - QEMUFile *packf =3D qemu_fopen_channel_input(QIO_CHANNEL(bioc)); + QEMUFile *packf =3D qemu_file_new_input(QIO_CHANNEL(bioc)); =20 ret =3D qemu_loadvm_state_main(packf, mis); trace_loadvm_handle_cmd_packaged_main(ret); @@ -2917,7 +2916,7 @@ void qmp_xen_save_devices_state(const char *filename,= bool has_live, bool live, goto the_end; } qio_channel_set_name(QIO_CHANNEL(ioc), "migration-xen-save-state"); - f =3D qemu_fopen_channel_output(QIO_CHANNEL(ioc)); + f =3D qemu_file_new_output(QIO_CHANNEL(ioc)); object_unref(OBJECT(ioc)); ret =3D qemu_save_device_state(f); if (ret < 0 || qemu_fclose(f) < 0) { @@ -2964,7 +2963,7 @@ void qmp_xen_load_devices_state(const char *filename,= Error **errp) return; } qio_channel_set_name(QIO_CHANNEL(ioc), "migration-xen-load-state"); - f =3D qemu_fopen_channel_input(QIO_CHANNEL(ioc)); + f =3D qemu_file_new_input(QIO_CHANNEL(ioc)); object_unref(OBJECT(ioc)); =20 ret =3D qemu_loadvm_state(f); diff --git a/tests/unit/test-vmstate.c b/tests/unit/test-vmstate.c index 6a417bb102..72077b5780 100644 --- a/tests/unit/test-vmstate.c +++ b/tests/unit/test-vmstate.c @@ -28,7 +28,6 @@ #include "migration/vmstate.h" #include "migration/qemu-file-types.h" #include "../migration/qemu-file.h" -#include "../migration/qemu-file-channel.h" #include "../migration/savevm.h" #include "qemu/coroutine.h" #include "qemu/module.h" @@ -52,9 +51,9 @@ static QEMUFile *open_test_file(bool write) } ioc =3D QIO_CHANNEL(qio_channel_file_new_fd(fd)); if (write) { - f =3D qemu_fopen_channel_output(ioc); + f =3D qemu_file_new_output(ioc); } else { - f =3D qemu_fopen_channel_input(ioc); + f =3D qemu_file_new_input(ioc); } object_unref(OBJECT(ioc)); return f; diff --git a/migration/meson.build b/migration/meson.build index 8d309f5849..690487cf1a 100644 --- a/migration/meson.build +++ b/migration/meson.build @@ -4,7 +4,6 @@ migration_files =3D files( 'xbzrle.c', 'vmstate-types.c', 'vmstate.c', - 'qemu-file-channel.c', 'qemu-file.c', 'yank_functions.c', ) --=20 2.35.3