From nobody Thu Jul 10 04:28:35 2025 Delivered-To: importer2@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+importer2=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1653391217; cv=none; d=zohomail.com; s=zohoarc; b=N/NdLGrZa43FmuTilBWNOiGzIVIFYKEx/AOx5o74pJG53V4xo/PRndRSZqsrAgyj5gjErHl/5/G7HIkGJ5u7dcSacfYF8B1VD8FVsjem1Xr1aeHCVcyTC6GaeIDQhuHEzTwgaLbPgb0mEmmi+uE2RbUAMqC1ijjImPHIFJn7X9A= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1653391217; 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=pQkwVbjlo79rr6iCqEDki1fx3gNO8Cq1x0LHRao3bMk=; b=KMXPZjsD1kW9Z1rNX20bGNKsxXrkp+p+fz2hBUcuPwij5r+FC0eYN1fa4qJOxVXQikvLM2l2dhkbgl6YnkUEJstWyI/37pEPT93IZ3F9KRXYX9XbviTloKEO05tRJ4RIHV/1oF+VLWmvxBGLvchoZb6CyQWTXIvvfdggV88bWlc= 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+importer2=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 1653391217625446.70297880294277; Tue, 24 May 2022 04:20:17 -0700 (PDT) Received: from localhost ([::1]:48906 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ntSaF-0000mH-6r for importer2@patchew.org; Tue, 24 May 2022 07:20:15 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:32774) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ntSJc-0005t8-4r for qemu-devel@nongnu.org; Tue, 24 May 2022 07:03:04 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:29816) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ntSJZ-0003QF-2H for qemu-devel@nongnu.org; Tue, 24 May 2022 07:03:03 -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-225-zXynFlqDNZW_dP05y4x_Ug-1; Tue, 24 May 2022 07:02:58 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 7AA4E100BAB1; Tue, 24 May 2022 11:02:58 +0000 (UTC) Received: from localhost.localdomain.com (unknown [10.33.36.159]) by smtp.corp.redhat.com (Postfix) with ESMTP id 2CEE11121315; Tue, 24 May 2022 11:02:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1653390180; 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=pQkwVbjlo79rr6iCqEDki1fx3gNO8Cq1x0LHRao3bMk=; b=QhYmM7g6bKhFGNAARxa5+DMNxcUJs45f9kSSM/ammF0IfaGfAiEivEOgvm9f2OpsJ4elh1 l0RfJlX9Ow6t3uA2eWvy3Bhzb7r77v7mllrNnZ4DW8gcD1EByFOTysBhoD0wAqVLOSf4QA DEXmlf5XIEEq/jlnZS4i/9g3y/gV9UQ= X-MC-Unique: zXynFlqDNZW_dP05y4x_Ug-1 From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= To: qemu-devel@nongnu.org Cc: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , "Dr. David Alan Gilbert" , qemu-block@nongnu.org, Stefan Hajnoczi , Hailiang Zhang , Juan Quintela , Fam Zheng Subject: [PATCH 12/20] migration: introduce new constructors for QEMUFile Date: Tue, 24 May 2022 12:02:27 +0100 Message-Id: <20220524110235.145079-13-berrange@redhat.com> In-Reply-To: <20220524110235.145079-1-berrange@redhat.com> References: <20220524110235.145079-1-berrange@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 2.78 on 10.11.54.3 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+importer2=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=berrange@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+importer2=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1653391219006100001 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. Signed-off-by: Daniel P. Berrang=C3=A9 Reviewed-by: Dr. David Alan Gilbert --- migration/qemu-file-channel.c | 4 ++-- migration/qemu-file.c | 18 ++++++++++++++++-- migration/qemu-file.h | 3 ++- 3 files changed, 20 insertions(+), 5 deletions(-) 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 ea1e8da0cb..5548e1abf3 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) diff --git a/migration/qemu-file.h b/migration/qemu-file.h index 0458b1d3b6..07c86bfea3 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); --=20 2.36.1