From nobody Sat Apr 27 17:49:52 2024 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=1653391937; cv=none; d=zohomail.com; s=zohoarc; b=HOcKN+Wj4g4xhH+CKTeAsQUDhKbMs110tMhSJN+j9NWMhGAKaws6ZLNrSQ2/bjsYbfCZKfVRvbYAY37X/uqZHEoq5q4bqrjOvVnBBfKDyJm1fdOxePPvcfq8Nyx1IdfMdyBOUUPRIYJTnCgcQUHtjh/hLam1sha4vWJIpssgB1Y= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1653391937; 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=lHWanSgEAJA33yftuz7AD3yN/J/1e7GRvZrzLXojMV8=; b=XXa1/1FSwcB3vDNP+LkZQCd5soQiKvoXkA+D1xmDaQHv0CslmCQ/NpWBOy6SfUgkgF7cEdpTNc71bvePyvCMvoqfGpLM2ROqWcQqj99wsxD+4EBHK40/1HzCVwMAW9qs5cP693Ui4FXQ9aibVyeny4kk5jfOsdd0v3AzRgSZ7WA= 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 1653391937315608.7857875278605; Tue, 24 May 2022 04:32:17 -0700 (PDT) Received: from localhost ([::1]:33542 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ntSls-0001hF-52 for importer2@patchew.org; Tue, 24 May 2022 07:32:16 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:60754) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ntSJS-0005mB-Rt for qemu-devel@nongnu.org; Tue, 24 May 2022 07:02:57 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:36332) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ntSJL-0003Mr-JT for qemu-devel@nongnu.org; Tue, 24 May 2022 07:02:54 -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-327-8t0ynufBMkS_Rx3IkM-zig-1; Tue, 24 May 2022 07:02:40 -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 3D02C3C1E322; Tue, 24 May 2022 11:02:40 +0000 (UTC) Received: from localhost.localdomain.com (unknown [10.33.36.159]) by smtp.corp.redhat.com (Postfix) with ESMTP id BFD0B1121315; Tue, 24 May 2022 11:02:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1653390163; 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=lHWanSgEAJA33yftuz7AD3yN/J/1e7GRvZrzLXojMV8=; b=XGj02lh6UUfguIT+pSXs4MncTAZVYRJxb8QG6GfgPPNxZab/jHK7PHrujWGBB9Q/C0ShmD Fyi+Op44pekBNGGI4gX94284KHPjHgEfga6PV6IlPfiXBGAoIYvFbfO7IElqFS1nIrDDMQ 2ccIt4bZq23EBstQtFczsVyZFig/y50= X-MC-Unique: 8t0ynufBMkS_Rx3IkM-zig-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 01/20] io: add a QIOChannelNull equivalent to /dev/null Date: Tue, 24 May 2022 12:02:16 +0100 Message-Id: <20220524110235.145079-2-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: 1653391938731100001 This is for code which needs a portable equivalent to a QIOChannelFile connected to /dev/null. Signed-off-by: Daniel P. Berrang=C3=A9 --- include/io/channel-null.h | 55 +++++++ io/channel-null.c | 237 ++++++++++++++++++++++++++++++ io/meson.build | 1 + io/trace-events | 3 + tests/unit/meson.build | 1 + tests/unit/test-io-channel-null.c | 95 ++++++++++++ 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..d7c950e494 --- /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 zero bytes 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 zero bytes 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/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 264f2bc0c8..6074ce51aa 100644 --- a/tests/unit/meson.build +++ b/tests/unit/meson.build @@ -86,6 +86,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], 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(); +} --=20 2.36.1 From nobody Sat Apr 27 17:49:52 2024 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=1653391584; cv=none; d=zohomail.com; s=zohoarc; b=ROG+PAoQhtrF+hPQE5vvWs2jqZ6VlpSPx2pDND3/9xk2LnSVfmma25s6JAGaHsh9w1GWNHevDbHqFqdaq9y+jD3LjxkthW1ycObccIE6sd2WbuFR15+2907QUIeouXIxmHlRVF54JtxZJwCSSa336dXNEjluCt7i1Vzh7vTeldU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1653391584; 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=t92MZvuFr2lO0iUw/Ivw7ms1vtMxSzOcJvYJhDe6WPQ=; b=E0BPNHJ+iOwDdBDMBpajhNJbiGEUCWxy2F4UgY70NISBTvl7yFd3YEQSwI0KSq5tEw6gXzWdrFUfE4tVPGH4YRyA6YANjLNgW+FdByxdXnipjcjhbeMvxaTpDIMhmtMKs+ioUmHBTehLuR8nDPALtQLsmMkCMUdackIGhU7/ySQ= 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 1653391584118554.9065521408035; Tue, 24 May 2022 04:26:24 -0700 (PDT) Received: from localhost ([::1]:55864 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ntSgB-0005n2-38 for importer2@patchew.org; Tue, 24 May 2022 07:26:23 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:60726) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ntSJR-0005lv-9C for qemu-devel@nongnu.org; Tue, 24 May 2022 07:02:55 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:46262) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ntSJL-0003Mw-Ji for qemu-devel@nongnu.org; Tue, 24 May 2022 07:02:52 -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-128-6XfevyJAPqiqR3vtat6e_g-1; Tue, 24 May 2022 07:02:42 -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 85B25858EED; Tue, 24 May 2022 11:02:42 +0000 (UTC) Received: from localhost.localdomain.com (unknown [10.33.36.159]) by smtp.corp.redhat.com (Postfix) with ESMTP id 7FFBE1121315; Tue, 24 May 2022 11:02:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1653390164; 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=t92MZvuFr2lO0iUw/Ivw7ms1vtMxSzOcJvYJhDe6WPQ=; b=QnIv6oJggB7LnCeWu9YwjeOpGjcgkO/w3pA/vNbOPMh/xlhA+nfPJnLXRjJSPgT2x8h0mL VvAFlT8RZoBI7/Gh2Jm25NFw63ENlpscYQ4atyGmVSeW2rpOZzRqsy30qzmSFOLGeq+aGF oHwI0XqhsogqF9pHn7DcnwR65XeRTXM= X-MC-Unique: 6XfevyJAPqiqR3vtat6e_g-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 02/20] migration: switch to use QIOChannelNull for dummy channel Date: Tue, 24 May 2022 12:02:17 +0100 Message-Id: <20220524110235.145079-3-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.133.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=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+importer2=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1653391585908100001 This removes one further custom impl of QEMUFile, in favour of a QIOChannel based impl. Signed-off-by: Daniel P. Berrang=C3=A9 Reviewed-by: Eric Blake --- 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.36.1 From nobody Sat Apr 27 17:49:52 2024 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=1653390760; cv=none; d=zohomail.com; s=zohoarc; b=W3KuMJHia9SVYJrC2EKDzKxmx2YITdVARJRZuG4rg7XIpL3gehzjKh1hoapxDnU052bUjubGLawfKdMaoUzV30/xETU1sLc3b4gI5cTn/LhfX7+pC+FPo4e1j3R8yVxiLKNHXYPLyBGek/ZXnccQc9MprsAs8xuvkfEhb4NNPvo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1653390760; 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=/vTIKeW8XrgwF9pMNPBG3wnVd2MZ26Y8J8CG+dWGEUE=; b=Hg36DAMS5zt3wksrwbAsWkPBbWxaBm8bIbYzKoAKZNzuqovpOvDexArIRSoAuEIA5xJGMsDUjA32E/F9jmbXIl8nG4c4mg5o5ss66eIJSeO0YMI6gN4K7H0+C6B5R37v9bwurldbXP+QpIpTN18rZlvua/+gN1r2Q5vPUJtodfI= 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 1653390760930290.80552996316203; Tue, 24 May 2022 04:12:40 -0700 (PDT) Received: from localhost ([::1]:39878 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ntSSt-0002bI-Kt for importer2@patchew.org; Tue, 24 May 2022 07:12:39 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:60888) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ntSJZ-0005oW-Fc for qemu-devel@nongnu.org; Tue, 24 May 2022 07:03:01 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:48296) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ntSJT-0003Nm-23 for qemu-devel@nongnu.org; Tue, 24 May 2022 07:02: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-639-odpFE8nlP1SH1vWkJQQ6jw-1; Tue, 24 May 2022 07:02:48 -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 4BF8C802A5B; Tue, 24 May 2022 11:02:44 +0000 (UTC) Received: from localhost.localdomain.com (unknown [10.33.36.159]) by smtp.corp.redhat.com (Postfix) with ESMTP id E348D1121315; Tue, 24 May 2022 11:02:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1653390169; 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=/vTIKeW8XrgwF9pMNPBG3wnVd2MZ26Y8J8CG+dWGEUE=; b=gmf8YIi6cPEX0Ku3YYcGOGbCdRxy9//AiC70ygp93Loj+HNbtil36JBLna0HlzB9mZ7CuP ODeui5C3rmre01asVAZt3NrUyODNf5IcNYYVARWrB/Nz7FUVws6aHiZcMwI/fd3n/40L2O 5rKIic/LyPPBTj4h08VGA6rlX3Q/XAI= X-MC-Unique: odpFE8nlP1SH1vWkJQQ6jw-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 03/20] migration: remove unreachble RDMA code in save_hook impl Date: Tue, 24 May 2022 12:02:18 +0100 Message-Id: <20220524110235.145079-4-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: 1653390762147100001 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. Signed-off-by: Daniel P. Berrang=C3=A9 Reviewed-by: Dr. David Alan Gilbert Reviewed-by: Eric Blake --- migration/rdma.c | 120 +++++++++-------------------------------------- 1 file changed, 21 insertions(+), 99 deletions(-) diff --git a/migration/rdma.c b/migration/rdma.c index 672d1958a9..6e7756bee7 100644 --- a/migration/rdma.c +++ b/migration/rdma.c @@ -1486,34 +1486,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. @@ -3278,23 +3250,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 @@ -3323,61 +3279,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; - } - - /* - * 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); + /* + * 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 - /* - * 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.36.1 From nobody Sat Apr 27 17:49:52 2024 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=1653392841; cv=none; d=zohomail.com; s=zohoarc; b=brwFJ4Q8Mjt+I8OfD1etktK9tfosCK8U/HLpiR2Tu5yGPz5/89o/oj2SjsQskbs6G8T3Tjr1y58L2gxYOyBQQjEL1sBSZrHjiWsWBiUfB88d2OaORB+1hMWeUPWnITbpD6qaFlKk15Y0LQYyprATKbDG//CASgt70UbSEq68Dwk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1653392841; 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=omqVQcD2wd6yHjOZp8jLK64Uo39yJDgaOhIBAv9DTFo=; b=m+0he2z3d7Qg1lKkS+IZDQgRxruoDXDWZTDp/ZWJhW92JC3JKn4BwtG/Pn2eQB+/oWr7kTqcez27SLEbAdP92xVtHaqzFgtVxBuBGMizPjQ53+oVc9XMaXIw9mRvaOfznjKQZVUxP6kG9Rqyo3HdJ4+mo5VJ/+WtxaLGJVMZGNs= 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 1653392841659371.8543570127016; Tue, 24 May 2022 04:47:21 -0700 (PDT) Received: from localhost ([::1]:45078 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ntT0P-000251-KM for importer2@patchew.org; Tue, 24 May 2022 07:47:18 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:60870) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ntSJZ-0005nn-B8 for qemu-devel@nongnu.org; Tue, 24 May 2022 07:03:01 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:28299) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ntSJP-0003Ne-CK for qemu-devel@nongnu.org; Tue, 24 May 2022 07:02:58 -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-625-QCR2t9h8Mc-NhBSBWFDnTA-1; Tue, 24 May 2022 07:02:46 -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 BBD70100FBC3; Tue, 24 May 2022 11:02:45 +0000 (UTC) Received: from localhost.localdomain.com (unknown [10.33.36.159]) by smtp.corp.redhat.com (Postfix) with ESMTP id 84AD21121315; Tue, 24 May 2022 11:02:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1653390169; 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=omqVQcD2wd6yHjOZp8jLK64Uo39yJDgaOhIBAv9DTFo=; b=K8x1UoPe5BfOHLHAawmxV9+g4zgqK5GzhbU7ugnkt7J8IV5cT9zGG7qBIrOVlzDPSXoRdc bY4Eq/oxW+xqJVPSO5BRv0yZSo72c3+kDVu49py6AV8BkHc+T8k/gxzTYzT1UeyHhV0M5M nr7FT4dk7Z3Eu2THkRxbczKvXNDmzUU= X-MC-Unique: QCR2t9h8Mc-NhBSBWFDnTA-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 04/20] migration: rename rate limiting fields in QEMUFile Date: Tue, 24 May 2022 12:02:19 +0100 Message-Id: <20220524110235.145079-5-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=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+importer2=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1653392843053100001 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. Signed-off-by: Daniel P. Berrang=C3=A9 Reviewed-by: Dr. David Alan Gilbert --- 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.36.1 From nobody Sat Apr 27 17:49:52 2024 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=1653392019; cv=none; d=zohomail.com; s=zohoarc; b=JkrktOYTTYa4b7yOj4hTfOuS4qf8C//7aXmHSlD1aXsXpUMsRIb0HDVGiSPlLiS5mfSjO2JBobxLMHN4YYv0awI8Sm3UOv+mPU3cgvLpeQpY9K9wjo1D5BiB98vibCPLuSw5iqK8NhAIzAFauRPYXEZcceMYryuggpl6C5Kp4Qc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1653392019; 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=RXEWyGS/rz1gatyWIzQy/8Z/ugpqfdru8mXrKQt1Zr0=; b=oJnpFrg3F3l+gF2LWYq0AkAx+qxwb5K2Et6BSMDECdgoOFiNm0mo9RqMNI4YXVRC6UUubd3p0SHc6dPSwdrTFiyb+fhKOQu7isZtxNTdtMzMU4EJ9oVvYt+wAbOOSoiPX/WNmxOxYDD8MHVDYYx7XJFuq+5HEw5YNTNZdoxrKf8= 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 1653392019357714.241207151496; Tue, 24 May 2022 04:33:39 -0700 (PDT) Received: from localhost ([::1]:36190 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ntSnA-0003z7-W3 for importer2@patchew.org; Tue, 24 May 2022 07:33:37 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:60800) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ntSJV-0005mG-2a for qemu-devel@nongnu.org; Tue, 24 May 2022 07:02:57 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:43430) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ntSJP-0003Nb-7N for qemu-devel@nongnu.org; Tue, 24 May 2022 07:02:56 -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-115-skjQYr1wNo-onKL-17Qrjw-1; Tue, 24 May 2022 07:02:47 -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 8BBFB3C025B0; Tue, 24 May 2022 11:02:47 +0000 (UTC) Received: from localhost.localdomain.com (unknown [10.33.36.159]) by smtp.corp.redhat.com (Postfix) with ESMTP id 27C8C1121315; Tue, 24 May 2022 11:02:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1653390169; 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=RXEWyGS/rz1gatyWIzQy/8Z/ugpqfdru8mXrKQt1Zr0=; b=RTgoYdHSkD4Zg17FgJqEX3vIYojUj1I2JAMfAONjwutVZOIz7XfRe3Hme2hJaRGqcOJ2Jb vPy+OEHD4AJ7F8ra0CnUoK7mqMGVNySyziIwgjSKYObdVJtDitRp5JBeQ80h/39HeAUCXI QPXEwnHoU4jmfHAYrfqKgP4B+uJKIZk= X-MC-Unique: skjQYr1wNo-onKL-17Qrjw-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 05/20] migration: rename 'pos' field in QEMUFile to 'bytes_processed' Date: Tue, 24 May 2022 12:02:20 +0100 Message-Id: <20220524110235.145079-6-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=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+importer2=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1653392021285100001 This makes the field name align with the newly introduced method names in the previous commit. Signed-off-by: Daniel P. Berrang=C3=A9 Reviewed-by: Dr. David Alan Gilbert --- 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.36.1 From nobody Sat Apr 27 17:49:52 2024 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=1653391443; cv=none; d=zohomail.com; s=zohoarc; b=bs7/oYqkbhT2pg2efY64PbQx/iBSMj/EcTpnivSb4vBKBMDHiuFjpjM5k4oBQaT7dlSwmnMktk0Ca3ZZixS5r8o7EFYX2lPJ69IIDwHd8bRS6xY/c1Ckwek8Dty/1pnGIEiKryHPoBBCfpSmonoefPqzV07GbM3i0pJ9dcsXCVk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1653391443; 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=7vOYCuiFOHwKEcxHDxUfpctKHL9UqUSBew1/Mv+uIlM=; b=IjolC0AdzzS28AOIyzAkl13uKuHAVl4JR9IAFz0rYW5Ow/oUDByM4E51XJ1cpGpaSs4rcyZrAOXno6P0RgKYbrfCjtsEYEfM7R1uj71wTQAKbHFwC03OB3Zp0r6NJc+VzbEc/Q4tSoRnebQD0Ja+BvIJQG9bnc4pXOkxpf1S+BQ= 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 1653391443590397.80309296872304; Tue, 24 May 2022 04:24:03 -0700 (PDT) Received: from localhost ([::1]:53268 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ntSdu-0003xy-En for importer2@patchew.org; Tue, 24 May 2022 07:24:02 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:60734) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ntSJR-0005lx-KS for qemu-devel@nongnu.org; Tue, 24 May 2022 07:02:57 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:55155) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ntSJP-0003Nt-C8 for qemu-devel@nongnu.org; Tue, 24 May 2022 07:02: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-192-JWh46h7tMeetnjnxg-q8pQ-1; Tue, 24 May 2022 07:02:49 -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 23B17101A54E; Tue, 24 May 2022 11:02:49 +0000 (UTC) Received: from localhost.localdomain.com (unknown [10.33.36.159]) by smtp.corp.redhat.com (Postfix) with ESMTP id C5446112131B; Tue, 24 May 2022 11:02:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1653390170; 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=7vOYCuiFOHwKEcxHDxUfpctKHL9UqUSBew1/Mv+uIlM=; b=RQDbpf6Dx7WpFitq6VfOtSEZ7LzvRJvOJ11ZKupoUd3EN1BvAQF+P0wehdY0wLkByxLgVT QLJJxqBwj1exiKSVpx+/8T393gMSEh8xTmWOwCvjih1x00Kf9SiAN7km4poaxZySG9HYNA VRo80Uqsdvy/fd/5cHkVtq4aPCoofok= X-MC-Unique: JWh46h7tMeetnjnxg-q8pQ-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 06/20] migration: rename qemu_ftell to qemu_file_total_transferred Date: Tue, 24 May 2022 12:02:21 +0100 Message-Id: <20220524110235.145079-7-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.133.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: 1653391445197100001 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. Signed-off-by: Daniel P. Berrang=C3=A9 Reviewed-by: Dr. David Alan Gilbert --- migration/block.c | 10 +++++----- migration/migration.c | 2 +- migration/qemu-file.c | 4 ++-- migration/qemu-file.h | 40 ++++++++++++++++++++++++++++++++++++++-- migration/savevm.c | 6 +++--- migration/vmstate.c | 4 ++-- 6 files changed, 51 insertions(+), 15 deletions(-) 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 31739b2af9..ab1e9610ef 100644 --- a/migration/migration.c +++ b/migration/migration.c @@ -3544,7 +3544,7 @@ 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.mult= ifd_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/qemu-file.h b/migration/qemu-file.h index 3f36d4dc8c..febc961aa9 100644 --- a/migration/qemu-file.h +++ b/migration/qemu-file.h @@ -124,8 +124,44 @@ 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=20 + * 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: + * + * Report the total number of bytes transferred with=20 + * this file. + * + * For writable files, no pending buffers will be + * flushed, but the reported value will include the + * size of any queued buffers, on top of the amount + * actually transferred. + * + * For readable files, the reported value will be + * equal to the number of bytes transferred on the + * wire. + * + * 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/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.36.1 From nobody Sat Apr 27 17:49:52 2024 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=1653392635; cv=none; d=zohomail.com; s=zohoarc; b=fmcaYLiyE2H1auE0UUGMLHsn5QhfWfhutbjwnljofM5FlySsSaFgo3kDazSS+aN6lZmeSK3GW01S750CdP/Z5k5KfBDG8xj8hEo3ANlwCU8wwms7f7e+lids/lfTzBCdxw5y42uyEkBCBgrS7jFXV4VqPpJxv8uihtMXGH63RTc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1653392635; 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=qGlbz4JQtuwlpJepdxpwXrbrRevMxa81DsGXR3VsqtE=; b=P/MU7RzwAem4f59soLR2fp/A7nitMdXbgouujrxgTLlU8t8PR1Q2uDUUPNDeXHdIwUgtZ3odo3/DBI43iFW8vw4c2aakXfazaKt0mZ/fhJb2rN9WEDf/6Np2KfhFx2TuVGI4PjZd8bTrivgWMOYw5EImFwdVdFTYIoecmIpKBd0= 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 165339263540866.84807936266873; Tue, 24 May 2022 04:43:55 -0700 (PDT) Received: from localhost ([::1]:43106 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ntSx8-0000Wt-4E for importer2@patchew.org; Tue, 24 May 2022 07:43:54 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:60886) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ntSJZ-0005oR-Fr for qemu-devel@nongnu.org; Tue, 24 May 2022 07:03:01 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:28052) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ntSJR-0003OK-58 for qemu-devel@nongnu.org; Tue, 24 May 2022 07:03:00 -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-79-huqXIpBYMhCi8z4PlyVEew-1; Tue, 24 May 2022 07:02:51 -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 A3ABD3817A6B; Tue, 24 May 2022 11:02:50 +0000 (UTC) Received: from localhost.localdomain.com (unknown [10.33.36.159]) by smtp.corp.redhat.com (Postfix) with ESMTP id 65DCC1121315; Tue, 24 May 2022 11:02:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1653390172; 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=qGlbz4JQtuwlpJepdxpwXrbrRevMxa81DsGXR3VsqtE=; b=O2Q6puhcZAV8BylyQH0eAGnmKD/LStvq+K9vjSfKoDE2E2Mj6iisqzxH178W9EXNSyMKC8 gBxQEUaOShxbodjk2AMp4UKnTeVNIbnWjSoVImMMSI6E3qxMRintuSrlTQBx2R8zQNAJu6 XVE9ob8qwbtsfH/o+AnmwbLs5IZZJh4= X-MC-Unique: huqXIpBYMhCi8z4PlyVEew-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 07/20] migration: rename qemu_update_position to qemu_file_credit_transfer Date: Tue, 24 May 2022 12:02:22 +0100 Message-Id: <20220524110235.145079-8-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=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+importer2=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1653392637180100001 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. Signed-off-by: Daniel P. Berrang=C3=A9 Reviewed-by: Dr. David Alan Gilbert --- migration/qemu-file.c | 4 ++-- migration/qemu-file.h | 8 +++++++- migration/ram.c | 2 +- 3 files changed, 10 insertions(+), 4 deletions(-) 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/qemu-file.h b/migration/qemu-file.h index febc961aa9..81f6fd7db8 100644 --- a/migration/qemu-file.h +++ b/migration/qemu-file.h @@ -186,7 +186,13 @@ 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. + */ +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/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.36.1 From nobody Sat Apr 27 17:49:53 2024 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=1653393842; cv=none; d=zohomail.com; s=zohoarc; b=gPzxppKeTs328hByodepJukrx+E4+BvhmgKkyFXcKTituFgzzvuD+h/lxAmU2f71IqydVovCxmUsGmjVnjmfzsNRrQt+JgPEqdPqzshxDjSSw/FleZOUluqqc5J5UlqYLZU4Gl8Qx90Kpo7Vo/PH2mS00714w7beme1WhklvuYo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1653393842; 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=Bii81+5cPbNcQvLi1k3r8ya1PODnQU2o6ZLg47dNnZQ=; b=ZEgUH/8XKW59tNBx61xAa/rCC8x6E1Al5S0DORM5HcVmobliXQuyoUST2kyEP/stqfhvHGtZKPgywjDEldrX5lp75SFts6yiixPCKl7OX42ygtuzhCfvXuIPcPVSnHt+ZwuMmYEhypnQvztG/eQTiRq46vCCI4EJR1N+4f+cDWo= 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 1653393842064770.0712063317775; Tue, 24 May 2022 05:04:02 -0700 (PDT) Received: from localhost ([::1]:41484 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ntTGZ-000329-Sz for importer2@patchew.org; Tue, 24 May 2022 08:03:59 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:60900) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ntSJZ-0005pG-Or for qemu-devel@nongnu.org; Tue, 24 May 2022 07:03:01 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:59472) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ntSJU-0003P0-Pi for qemu-devel@nongnu.org; Tue, 24 May 2022 07:03:01 -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-373-XfriovRAM9-MhR63wjdQYw-1; Tue, 24 May 2022 07:02:52 -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 20499100BAB9; Tue, 24 May 2022 11:02:52 +0000 (UTC) Received: from localhost.localdomain.com (unknown [10.33.36.159]) by smtp.corp.redhat.com (Postfix) with ESMTP id DB1081121315; Tue, 24 May 2022 11:02:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1653390175; 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=Bii81+5cPbNcQvLi1k3r8ya1PODnQU2o6ZLg47dNnZQ=; b=LzOXhK3h5eb2QcWxtjK2X15w+DJNVsrZ5gHdugKTnj1ml6ia5vRA2yw4VJtD+Xxlpn514E iq3gnukLSYHg80FjvaDZNhjN4ox7NOFoYCrcq+5tGFdYb+AbVkTBOaJ7al3sXGYuY4Jnta h3Yc4QKZb3S71denMM2XQjLDhnJu7rI= X-MC-Unique: XfriovRAM9-MhR63wjdQYw-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 08/20] migration: introduce a QIOChannel impl for BlockDriverState VMState Date: Tue, 24 May 2022 12:02:23 +0100 Message-Id: <20220524110235.145079-9-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: 1653393842925100001 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. Reviewed-by: Daniel P. Berrang=C3=A9 --- migration/channel-block.c | 195 ++++++++++++++++++++++++++++++++++++++ migration/channel-block.h | 59 ++++++++++++ migration/meson.build | 1 + 3 files changed, 255 insertions(+) create mode 100644 migration/channel-block.c create mode 100644 migration/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/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/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.36.1 From nobody Sat Apr 27 17:49:53 2024 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=1653394189; cv=none; d=zohomail.com; s=zohoarc; b=gJl/qw7r9/HAFt9Kz9w6hxlUFN4zo9pT6QnJi/oiawFhGAC0ghfxOODGq4d0supJzjTUkj0qL4WISO9v38ur3fi/8CgfzSyLqFbjWzbnMOS7xiNgvYjf7QM3ePhGB9HkND3rNXoZff1hRysMKYY1Ob4CDtjro78iHcbYae8Ipd4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1653394189; 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=18lr8k1U3AS15tafgaE2eOiXNUZcqHdVMha4FAPcroQ=; b=JbyKTlVLv8vWhOXcV21JTjjWET8R4kOvNbRAZIzo3daJDdd6FDILnc8ZOzxqh9AHrE1HdWZ5rxkzFQtprJj2ZCoasm1IxDlaQiWRstMAtW/TKFtsoifm4w3Zv7eF7cDPrZJqhky/+Set7H0UhOLZNA+OEML1aB13JjDsN/3jF/g= 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 1653394189691996.6445758349504; Tue, 24 May 2022 05:09:49 -0700 (PDT) Received: from localhost ([::1]:50332 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ntTMC-00019D-9m for importer2@patchew.org; Tue, 24 May 2022 08:09:48 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:60948) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ntSJa-0005rX-Uk for qemu-devel@nongnu.org; Tue, 24 May 2022 07:03:02 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:40055) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ntSJZ-0003PO-07 for qemu-devel@nongnu.org; Tue, 24 May 2022 07:03:02 -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-258-AjwzSFKIM4yCgVl77sdcpQ-1; Tue, 24 May 2022 07:02:54 -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 AF905100BAA1; Tue, 24 May 2022 11:02:53 +0000 (UTC) Received: from localhost.localdomain.com (unknown [10.33.36.159]) by smtp.corp.redhat.com (Postfix) with ESMTP id 69EC41121315; Tue, 24 May 2022 11:02:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1653390177; 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=18lr8k1U3AS15tafgaE2eOiXNUZcqHdVMha4FAPcroQ=; b=cnLbb01Xb4iwd7eRKPPyYsyw9zJ8WeR9PAUve/D2+W8f7+DrZULKD2DD2bNDXLtTpRI1pK 31D4alPE3UNSmvvZKDympxUV9Wiab0B83xqEb7gHa7LqEpSy0TLMkCYhkZTxH6tdXnGCAL GqPUgw+aufUYfV8FtvXes5EKpPM43T8= X-MC-Unique: AjwzSFKIM4yCgVl77sdcpQ-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 09/20] migration: convert savevm to use QIOChannelBlock for VMState Date: Tue, 24 May 2022 12:02:24 +0100 Message-Id: <20220524110235.145079-10-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.133.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=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+importer2=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1653394190355100001 With this change, all QEMUFile usage is backed by QIOChannel at last. Signed-off-by: Daniel P. Berrang=C3=A9 Reviewed-by: Dr. David Alan Gilbert --- 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.36.1 From nobody Sat Apr 27 17:49:53 2024 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=1653393189; cv=none; d=zohomail.com; s=zohoarc; b=oB4l00NyitBx/mPmpeHlAtAcnKq2HlVezJEMMHkRYw2t0ufSWx9SazYOYpVpm38Cn5MUmf5WbcQwxYcufhpSlLjbsW3wRvDzxIGxbToKntCzV+Wltga4zPNt5E3uFOIUfvvwluvsBpYHl9JDqTPLS8oCiNtn6UYsK0fh5qRNfJI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1653393189; 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=LzVwG9whfM4CdqnCPgmNO9T08ml925li2XDejrrQMSo=; b=huhgbbh/ej2mV7h5EKV/V/aWRFrebiTNTz4zQpuml6OD7z0VYeqp0OcIB/RztFkTQ3WA6+QR7l0rDvyRFUZ2o9WSQ/gWyCSHjJWWMuaZ6+XCdNEbCqLbeJYGpNAlSsbM886v8Tx32QDu/mNAURTHHkex7dcsumulOYydRivOsfE= 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 1653393189865173.51819222772372; Tue, 24 May 2022 04:53:09 -0700 (PDT) Received: from localhost ([::1]:52462 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ntT64-0007jb-SI for importer2@patchew.org; Tue, 24 May 2022 07:53:08 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:60960) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ntSJb-0005rr-5B for qemu-devel@nongnu.org; Tue, 24 May 2022 07:03:03 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:43747) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ntSJZ-0003Q7-0g for qemu-devel@nongnu.org; Tue, 24 May 2022 07:03:02 -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-453-3QB071SRNiKE63dFspb2gA-1; Tue, 24 May 2022 07:02:55 -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 71EE3858EED; Tue, 24 May 2022 11:02:55 +0000 (UTC) Received: from localhost.localdomain.com (unknown [10.33.36.159]) by smtp.corp.redhat.com (Postfix) with ESMTP id 065141121315; Tue, 24 May 2022 11:02:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1653390179; 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=LzVwG9whfM4CdqnCPgmNO9T08ml925li2XDejrrQMSo=; b=GFyFWG3ysAgbO1Hw4514ELf9PQ+arbzda4fRD1TKPCeVHiZ047b++VkKa7+vte/0OKxisj +V+EQBrVO+uMveDJBDjkRs0w1WTX/ONja6rFj4Ddhcw+WPziIV45rPY0a0ZCSVcYQmAz5R xTioaNhn4NkRJWSksCADSI1pzoBsOn8= X-MC-Unique: 3QB071SRNiKE63dFspb2gA-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 10/20] migration: stop passing 'opaque' parameter to QEMUFile hooks Date: Tue, 24 May 2022 12:02:25 +0100 Message-Id: <20220524110235.145079-11-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: 1653393191325100001 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. Signed-off-by: Daniel P. Berrang=C3=A9 Reviewed-by: Dr. David Alan Gilbert --- migration/qemu-file.c | 8 ++++---- migration/qemu-file.h | 14 ++++++-------- migration/rdma.c | 19 ++++++++++--------- 3 files changed, 20 insertions(+), 21 deletions(-) diff --git a/migration/qemu-file.c b/migration/qemu-file.c index 9a7f715e17..6badc8b0ec 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/qemu-file.h b/migration/qemu-file.h index 81f6fd7db8..6310071f90 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/rdma.c b/migration/rdma.c index 6e7756bee7..83265513d9 100644 --- a/migration/rdma.c +++ b/migration/rdma.c @@ -3256,11 +3256,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 @@ -3872,14 +3872,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 */ @@ -3887,10 +3888,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(); @@ -3916,10 +3917,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.36.1 From nobody Sat Apr 27 17:49:53 2024 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=1653393320; cv=none; d=zohomail.com; s=zohoarc; b=C3ZdgW98ss/1WsIC0BdvVtGpKSCfOhdAcA1J21fiuxDlo81moqnQ2hjc75TPxsIeIRrHwN8LK5dMq2w4Rv2klPD7ay//PIhaM3pjwwSk/+thEQP5U0CBixIFfh6OdGfqi2eClffxnY75pY6Tfw02DAimNDWj0j8CfG6dmwD8gXQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1653393320; 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=jdx67keC66P+vSbuOgYtmolesP7R4jEOHd8z2UsDAfQ=; b=mFWwXW/vWdVQqmJd3LkvsR5rJ3Xm7D3JD9NMNoWzAxB5DFE0JU23JjfTD0ndVg1KAyhCHUXKaaQTJgpCfVmqqhFs/jzVgF4wwD8S46mOiBlHaYvu5dZlnyjYDlbeL/HTvkPtUqn9MJ1T9E+czzWwyYudhATTxvY79aV8jaAIQ2Q= 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 1653393320814967.7902793119272; Tue, 24 May 2022 04:55:20 -0700 (PDT) Received: from localhost ([::1]:55698 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ntT8B-0001iD-QC for importer2@patchew.org; Tue, 24 May 2022 07:55:19 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:32780) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ntSJc-0005tb-FI 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]:42391) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ntSJZ-0003QK-6e for qemu-devel@nongnu.org; Tue, 24 May 2022 07:03:04 -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-111-BVCf9McIOCWdZ_vHsIJDhQ-1; Tue, 24 May 2022 07:02:57 -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 E36C1811E81; Tue, 24 May 2022 11:02:56 +0000 (UTC) Received: from localhost.localdomain.com (unknown [10.33.36.159]) by smtp.corp.redhat.com (Postfix) with ESMTP id AD3971121315; Tue, 24 May 2022 11:02:55 +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=jdx67keC66P+vSbuOgYtmolesP7R4jEOHd8z2UsDAfQ=; b=ZUoErybOwqq5LyLeX65h7qaYcWjtwhc0ErQ2XxzEu1vw2Uemk8Xf/1Ydy+ONwI9+bttqcO 4pS+T/TIHeAYvdqtjuxTuvWHBA7531JuMZPabgZTCav2krD/G0cH5QMaHpvPt0a8wx8UTC 1hbtfGEqaPNco9sJ7HzWtRW6uFTtByA= X-MC-Unique: BVCf9McIOCWdZ_vHsIJDhQ-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 11/20] migration: hardcode assumption that QEMUFile is backed with QIOChannel Date: Tue, 24 May 2022 12:02:26 +0100 Message-Id: <20220524110235.145079-12-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=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+importer2=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1653393321919100001 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. Signed-off-by: Daniel P. Berrang=C3=A9 Reviewed-by: Dr. David Alan Gilbert --- migration/qemu-file-channel.c | 4 ++-- migration/qemu-file.c | 35 +++++++++++++++++------------------ migration/qemu-file.h | 2 +- 3 files changed, 20 insertions(+), 21 deletions(-) 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 6badc8b0ec..ea1e8da0cb 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; } diff --git a/migration/qemu-file.h b/migration/qemu-file.h index 6310071f90..0458b1d3b6 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); --=20 2.36.1 From nobody Sat Apr 27 17:49:53 2024 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 From nobody Sat Apr 27 17:49:53 2024 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=1653393542; cv=none; d=zohomail.com; s=zohoarc; b=YXvjqP1I2E5RqnIiKCH9oLTaZn/aw6zJyqiQUEfh6TLrjSzt8mCy1jug6/S861+EBFuRMhOEsoLB0HoL8rfpMbX10qcQDBZKwND9dGKjrtmfBTa3FnG80NZAlKYzZGWQXrV1L0t+scA1wlONJX/x+3u7IpfRz/2YyoY+Pl+5Ugw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1653393542; 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=jIKNFTGymh1d22iY8iKq2EuGD62AfJ8Zj9oEcR5nHDg=; b=SutJzIOl3zrm4C7BzPYuxMEu0uXpKyqUHEo6n64JRSDlMyC5nRrQWpwjGuQU7qy/qXhDeGb7panu1PemydC6QfPMOtpKlSzpZg6v0Zs8yPq3bu8eXXhMvH6svnKuYvSLY3iP0OXfQWhK7WBPlVYSv8s69fx7C25EAnT8mOUBfIE= 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 1653393542116854.1266031748846; Tue, 24 May 2022 04:59:02 -0700 (PDT) Received: from localhost ([::1]:36226 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ntTBk-0007pP-Ra for importer2@patchew.org; Tue, 24 May 2022 07:59:00 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:32796) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ntSJc-0005uL-OP 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]:56113) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ntSJa-0003RQ-Fe for qemu-devel@nongnu.org; Tue, 24 May 2022 07:03:04 -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-377-jl8gOyqIPSCTPYOcB-Trug-1; Tue, 24 May 2022 07:03:00 -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 2ABE8811E83; Tue, 24 May 2022 11:03:00 +0000 (UTC) Received: from localhost.localdomain.com (unknown [10.33.36.159]) by smtp.corp.redhat.com (Postfix) with ESMTP id B8AD71121315; Tue, 24 May 2022 11:02:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1653390181; 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=jIKNFTGymh1d22iY8iKq2EuGD62AfJ8Zj9oEcR5nHDg=; b=IYP0HfNGJLT2o3aXZuFdfcdwnMyoLjU3Zlen9745bNvhUfJRnL0qbuAMSzpK+tubsszInB 2EOPJqCERiWnpdSKUt11nPpMbqWU70V6p95xMmqHkbE6pv29itzDTmEXSPmMiiMQaHf6gl Dq7frsPO+l6wYr7Mlb5PPlC1LJbzcLE= X-MC-Unique: jl8gOyqIPSCTPYOcB-Trug-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 13/20] migration: remove unused QEMUFileGetFD typedef Date: Tue, 24 May 2022 12:02:28 +0100 Message-Id: <20220524110235.145079-14-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: 1653393542660100001 Signed-off-by: Daniel P. Berrang=C3=A9 Reviewed-by: Dr. David Alan Gilbert --- migration/qemu-file.h | 4 ---- 1 file changed, 4 deletions(-) diff --git a/migration/qemu-file.h b/migration/qemu-file.h index 07c86bfea3..674c2c409b 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= ); --=20 2.36.1 From nobody Sat Apr 27 17:49:53 2024 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=1653394092; cv=none; d=zohomail.com; s=zohoarc; b=Tj81/SmK6qJupvpUkT+OssWPJ1dzV2QWvzx245ikdR6LRCXaN5EGgXxfSoTEdhRkz8ZgJEFpdbxaD3bbSiK65nSTVGAN7wU7HyK/NHJZ135L7jq5PT3LuEozuSNbYaM0WqUhPWhxODfPe0h9Dng1b2t/2sTirLCNHCpmHMaiFw8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1653394092; 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=CiNBBsgxDLGuk5khrklC9vRDEZqzZ7a8YzaLxiAbIFQ=; b=V4jMve2zqSyJGKUnVsTXOsvezeO6CXWodgf3ZsQrAnSi7ALuXB8FmMrhD1EuqY5NoEg2WIF5nIABJe7s/J6x2eDrczoahor/vSv+Zjt831B3NQTLos5RdOwCGZv6zuNDuXjXqYG4iKnDpUYci7TV0aRVCYCWEF5gWFR+QOxrhBo= 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 1653394092818327.2467397909742; Tue, 24 May 2022 05:08:12 -0700 (PDT) Received: from localhost ([::1]:45628 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ntTKd-00069b-Ng for importer2@patchew.org; Tue, 24 May 2022 08:08:11 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:32876) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ntSJh-00060o-CQ for qemu-devel@nongnu.org; Tue, 24 May 2022 07:03:09 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:27377) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ntSJe-0003Sv-G9 for qemu-devel@nongnu.org; Tue, 24 May 2022 07:03:08 -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-503-GTnU_fOYPbGrbFa0bCm2Tw-1; Tue, 24 May 2022 07:03:02 -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 25A1A802A5B; Tue, 24 May 2022 11:03:02 +0000 (UTC) Received: from localhost.localdomain.com (unknown [10.33.36.159]) by smtp.corp.redhat.com (Postfix) with ESMTP id 65483112131B; Tue, 24 May 2022 11:03:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1653390185; 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=CiNBBsgxDLGuk5khrklC9vRDEZqzZ7a8YzaLxiAbIFQ=; b=TbfG2kPZla0EWa8L3XwhE11bx1bqqjwRstoVKthB6et30G0ZJ6bTsos3cAhao8ETW5cmz9 hALV0HnvXE9FUGtoDm5vaTf1ZjLzLlbca343sm+uBTO6iN6m52RnKYdEr2R31gv8R2KFGW DgZ7/oHH7wvwe7MrW9L8KEr4sOkv6ro= X-MC-Unique: GTnU_fOYPbGrbFa0bCm2Tw-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 14/20] migration: remove the QEMUFileOps 'shut_down' callback Date: Tue, 24 May 2022 12:02:29 +0100 Message-Id: <20220524110235.145079-15-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: 1653394093621100001 This directly implements the shutdown logic using QIOChannel APIs. Signed-off-by: Daniel P. Berrang=C3=A9 Reviewed-by: Dr. David Alan Gilbert --- migration/qemu-file-channel.c | 27 --------------------------- migration/qemu-file.c | 10 +++++++--- migration/qemu-file.h | 10 ---------- 3 files changed, 7 insertions(+), 40 deletions(-) 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 5548e1abf3..fd9f060c02 100644 --- a/migration/qemu-file.c +++ b/migration/qemu-file.c @@ -74,13 +74,17 @@ struct QEMUFile { */ 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); diff --git a/migration/qemu-file.h b/migration/qemu-file.h index 674c2c409b..2049dfe7e4 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 { --=20 2.36.1 From nobody Sat Apr 27 17:49:53 2024 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=1653391910; cv=none; d=zohomail.com; s=zohoarc; b=J/xksM3kwne4T4dl6lZA4LhvxpRwt5xPhaq4K/1EGOs46hfP/qxU3sDUNxXKQDGxFfNVebR8htsGUFyp1j4nOiD6LjPpj54RL9wEt0+7f8RhygHn0tdluBLg1yyr1dFve+bZSSeciQkwWSPklTGzpaK7qXMv5U/+lvsFtChca2M= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1653391910; 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=FCzbZ9JO0ZTfTKQ7PVbfXKGQbUSX37A1lLmOIivYSeI=; b=YHhobXWgdQFzNNlkvEXVKGZ8OpU0CPzQitPpP7tV5CR0ffdGyZhXmQ60yicuVvs6yIGQEPObmsNTW9a0ztGoCbNkGy4PQz5ksxhsWQvToVEMBOdsZo22mmLzSdlu2dmagSj72HZHd0rurzv+5uEoZLPMQTv29GDOUBYIfaG7y5I= 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 1653391910883355.4651356751581; Tue, 24 May 2022 04:31:50 -0700 (PDT) Received: from localhost ([::1]:33016 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ntSlR-0001Ki-An for importer2@patchew.org; Tue, 24 May 2022 07:31:49 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:32916) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ntSJj-00064z-7x for qemu-devel@nongnu.org; Tue, 24 May 2022 07:03:11 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:42373) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ntSJg-0003VG-Vd for qemu-devel@nongnu.org; Tue, 24 May 2022 07:03:10 -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-475-1dycHfyEPiK7c7XlNx2IJA-1; Tue, 24 May 2022 07:03:04 -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 A519B858EFF; Tue, 24 May 2022 11:03:03 +0000 (UTC) Received: from localhost.localdomain.com (unknown [10.33.36.159]) by smtp.corp.redhat.com (Postfix) with ESMTP id 5FE071121315; Tue, 24 May 2022 11:03:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1653390188; 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=FCzbZ9JO0ZTfTKQ7PVbfXKGQbUSX37A1lLmOIivYSeI=; b=enCy9AbhI3tUEKeS7O6IJQqFz2E9xsoljEeY3j5gz5b78Q2O0JOAqtBG1hX5AHoLtkDvlA kbLV2zooztVr3nHSAT4A8zTGoScdDdQINzVziG+k/l1T/gYUTnwCUH1tOGBS5oo60VqT0G nPGbYGCrB7TEbDz+Ds6M4TX1fZslBvU= X-MC-Unique: 1dycHfyEPiK7c7XlNx2IJA-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 15/20] migration: remove the QEMUFileOps 'set_blocking' callback Date: Tue, 24 May 2022 12:02:30 +0100 Message-Id: <20220524110235.145079-16-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: 1653391912477100001 This directly implements the set_blocking logic using QIOChannel APIs. Signed-off-by: Daniel P. Berrang=C3=A9 Reviewed-by: Dr. David Alan Gilbert --- migration/qemu-file-channel.c | 14 -------------- migration/qemu-file.c | 4 +--- migration/qemu-file.h | 5 ----- 3 files changed, 1 insertion(+), 22 deletions(-) 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 fd9f060c02..171b9f85bf 100644 --- a/migration/qemu-file.c +++ b/migration/qemu-file.c @@ -876,9 +876,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 /* diff --git a/migration/qemu-file.h b/migration/qemu-file.h index 2049dfe7e4..6db4bb9fdb 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; --=20 2.36.1 From nobody Sat Apr 27 17:49:53 2024 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=1653394413; cv=none; d=zohomail.com; s=zohoarc; b=A2kYIl0sqUXuhtH3d3Wu4HPFysqbdKYx24+5eBtegL3Mg/r384O0Ig7OttcnZV9uPntqaJAfpoXfeZonMejM6lhhEOsO69uD1lFMDwAlvo1IVpreViSrQC6GCHXL6gpAs85loFAgd+ekv7PUCKmzMipPdr7NB9s0vWvpEJGZ5ik= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1653394413; 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=DuoS4lAc9nEl2/Uu9IBjdWqa4ATF2VoAuiAH2VLQaIU=; b=cx452QkcmkAToUsXychjjIaUIMMzZA/RadT+CVydoNfVVm85m2MlAi25owEg/2sZeTlipxiK0vU+XqRUh33xUHW8NAgpZWW/K7CZwssmDO6yQEOfmgWtoxXfTm6hTa3bLz2K0DlRXE5DVwDxEOOe2uVjgh8ttFt319sSZp4k2OA= 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 1653394413565762.1828979918209; Tue, 24 May 2022 05:13:33 -0700 (PDT) Received: from localhost ([::1]:60246 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ntTPn-0007vY-VZ for importer2@patchew.org; Tue, 24 May 2022 08:13:32 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:32958) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ntSJp-00066t-7Z for qemu-devel@nongnu.org; Tue, 24 May 2022 07:03:21 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:34738) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ntSJh-0003X9-I6 for qemu-devel@nongnu.org; Tue, 24 May 2022 07:03:12 -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-246-sEJuZ6ZpPkCacYo5_Yb2Ew-1; Tue, 24 May 2022 07:03:05 -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 53D84801228; Tue, 24 May 2022 11:03:05 +0000 (UTC) Received: from localhost.localdomain.com (unknown [10.33.36.159]) by smtp.corp.redhat.com (Postfix) with ESMTP id E8FEE1121315; Tue, 24 May 2022 11:03:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1653390188; 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=DuoS4lAc9nEl2/Uu9IBjdWqa4ATF2VoAuiAH2VLQaIU=; b=DMdmlPm7Xi0kijzf67ZG9j2nw4Egs9MIK4cGFGF73srbm1zpEqlcpceszYFdEdty/EkYN1 6BnxJJoiRAt90Ewzbj6M7ZP5wwH21NQiU2DvHMlit169Htl39OHkB6/J9IVqbG43AdR4Ja obdKZf7nnS+idA1HIj1Zb8SHyLJZfxM= X-MC-Unique: sEJuZ6ZpPkCacYo5_Yb2Ew-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 16/20] migration: remove the QEMUFileOps 'close' callback Date: Tue, 24 May 2022 12:02:31 +0100 Message-Id: <20220524110235.145079-17-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.133.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=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+importer2=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1653394414970100001 This directly implements the close logic using QIOChannel APIs. Signed-off-by: Daniel P. Berrang=C3=A9 Reviewed-by: Dr. David Alan Gilbert --- migration/qemu-file-channel.c | 12 ------------ migration/qemu-file.c | 12 ++++++------ migration/qemu-file.h | 10 ---------- 3 files changed, 6 insertions(+), 28 deletions(-) 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 171b9f85bf..a855ce33dc 100644 --- a/migration/qemu-file.c +++ b/migration/qemu-file.c @@ -405,16 +405,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. */ diff --git a/migration/qemu-file.h b/migration/qemu-file.h index 6db4bb9fdb..7ec105bf96 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; --=20 2.36.1 From nobody Sat Apr 27 17:49:53 2024 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=1653392498; cv=none; d=zohomail.com; s=zohoarc; b=RNzGcwWaCAkWtNBqkfSPlFzwnQem+STllavfMc4YXgRvSrsPIcVu8lvWMVlb8qnFQJO58p2k8Ithp2DmsxpnynWwRfer2xTgRPe/hc/XcRDgtm9A84gqM173362HgB3zENkQ/KzR90w6XzbcgBwilC95Bilpxp7Y2htSKfwAG18= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1653392498; 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=RbbA8BocURo/qAoAek6v07EPRR57Pp5v+vIEMEShyTM=; b=Zsx4DpVUaanvDYfZm25kCMMMkNNprhMm4e1C3n3wA+eRHrnW/MnCilzHVFpkO2Ek42gb/XjC+JZC6RszclPPx/4UMdmjE4w9OFbbuQ5iX/gY88rMVAuJU5jvdUcB4zxMlTQthQT9riQaBzIACFP1tF3N+Q/SqzOrub+4eNy0oaI= 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 1653392498144734.0726157015264; Tue, 24 May 2022 04:41:38 -0700 (PDT) Received: from localhost ([::1]:41630 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ntSuu-0007m0-G8 for importer2@patchew.org; Tue, 24 May 2022 07:41:36 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:33074) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ntSKn-00069L-4E for qemu-devel@nongnu.org; Tue, 24 May 2022 07:04:35 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:35171) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ntSJl-0003aM-2O for qemu-devel@nongnu.org; Tue, 24 May 2022 07:03:22 -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-597-TFcTaLUBNLmp4FiDLwatcg-1; Tue, 24 May 2022 07:03:07 -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 4F4E03817A6B; Tue, 24 May 2022 11:03:07 +0000 (UTC) Received: from localhost.localdomain.com (unknown [10.33.36.159]) by smtp.corp.redhat.com (Postfix) with ESMTP id 8F5351121315; Tue, 24 May 2022 11:03:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1653390191; 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=RbbA8BocURo/qAoAek6v07EPRR57Pp5v+vIEMEShyTM=; b=QLqzvSUe3YTh4ls8L2+wzewHnxcJ80K/DmSTi4fQhvgEFRhrd7PmXadbtHDKwfGDebfJKb ja5S3AzgayBy5vvSXCGAy0jA6DoP58IaDpWE/S50tvAvAXzvSs8MKjk+h7TSZHSDcwxQji ads+AMKMGUbKD3vp2C+8I8HOoGH1GHI= X-MC-Unique: TFcTaLUBNLmp4FiDLwatcg-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 17/20] migration: remove the QEMUFileOps 'get_buffer' callback Date: Tue, 24 May 2022 12:02:32 +0100 Message-Id: <20220524110235.145079-18-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=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+importer2=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1653392500440100001 This directly implements the get_buffer logic using QIOChannel APIs. Signed-off-by: Daniel P. Berrang=C3=A9 Reviewed-by: Dr. David Alan Gilbert --- migration/qemu-file-channel.c | 29 ----------------------------- migration/qemu-file.c | 18 ++++++++++++++++-- migration/qemu-file.h | 9 --------- 3 files changed, 16 insertions(+), 40 deletions(-) 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 a855ce33dc..e024b43851 100644 --- a/migration/qemu-file.c +++ b/migration/qemu-file.c @@ -374,8 +374,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; diff --git a/migration/qemu-file.h b/migration/qemu-file.h index 7ec105bf96..cd49184c00 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; --=20 2.36.1 From nobody Sat Apr 27 17:49:53 2024 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=1653394663; cv=none; d=zohomail.com; s=zohoarc; b=Vi6W/dCEServBTfXBi37GQ4MV6nTBcfg3TNcNr/EihdQfEJOBBbjZahUWpjd6oxPw2TNJCHWokcegslPU1g8IyR7er/AWZZ+hk9zniFNSzb9zLBdlXsaxrRVcO+WaJ7v+3wSt8cl2ZIMmlmbtUU0pT7vhUiEhLtuoVcYbF/F8Bk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1653394663; 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=1gCEgo643U7nNGZuHl0CqKWHYLefV5XUxcsKPYVvsPU=; b=Ig6pk3OsGyRMBBNPJO732fjmNDv1ZXsovVzi9tj66s4XJJSo/OfL0aUBaMsy0uCZt8idsVdSSMhY873kvq7ydwv9FerXBlMmQFmREEM3CQ7Ymg5RIdytEFVNzPbRBsN+RbcCWe/aeAexGZlqKSpfHTi45bqm2mJgR+1PcP54t84= 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 1653394663569323.119512962317; Tue, 24 May 2022 05:17:43 -0700 (PDT) Received: from localhost ([::1]:41372 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ntTTp-00069V-UT for importer2@patchew.org; Tue, 24 May 2022 08:17:41 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:33076) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ntSKn-00069M-54 for qemu-devel@nongnu.org; Tue, 24 May 2022 07:04:35 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:22704) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ntSJp-0003ae-0W for qemu-devel@nongnu.org; Tue, 24 May 2022 07:03:26 -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-584-M8YBBzqzN1WhhBd8pC7RAA-1; Tue, 24 May 2022 07:03:09 -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 10D3D811E75; Tue, 24 May 2022 11:03:09 +0000 (UTC) Received: from localhost.localdomain.com (unknown [10.33.36.159]) by smtp.corp.redhat.com (Postfix) with ESMTP id 8EEE11121315; Tue, 24 May 2022 11:03:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1653390192; 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=1gCEgo643U7nNGZuHl0CqKWHYLefV5XUxcsKPYVvsPU=; b=iyHEzsUFAg/74GRlsfmHVxifFoSlhe4MYoXVKz06mOFjPTuV8kTBS1naQiZkjn4Pw8ip5w XX7cCukGxmEqTrKHpi6tXOIc7o97F1XbSzPs0VZDkwRhRLQZ4qzHx5MhcVbUvyDdZR8dz8 Z6Adi0K8WN9ZUvMxCegEJ7N8ZrWrT1g= X-MC-Unique: M8YBBzqzN1WhhBd8pC7RAA-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 18/20] migration: remove the QEMUFileOps 'writev_buffer' callback Date: Tue, 24 May 2022 12:02:33 +0100 Message-Id: <20220524110235.145079-19-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.133.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: 1653394665031100001 This directly implements the writev_buffer logic using QIOChannel APIs. Signed-off-by: Daniel P. Berrang=C3=A9 Reviewed-by: Dr. David Alan Gilbert --- migration/qemu-file-channel.c | 43 ----------------------------------- migration/qemu-file.c | 24 +++++++------------ migration/qemu-file.h | 9 -------- 3 files changed, 8 insertions(+), 68 deletions(-) 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 e024b43851..72a6f58af5 100644 --- a/migration/qemu-file.c +++ b/migration/qemu-file.c @@ -245,10 +245,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; } @@ -257,22 +253,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; } diff --git a/migration/qemu-file.h b/migration/qemu-file.h index cd49184c00..542c637934 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 --=20 2.36.1 From nobody Sat Apr 27 17:49:53 2024 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=1653393157; cv=none; d=zohomail.com; s=zohoarc; b=EoX71mMtwACgEQhvoyQsefMg4nFadr4cdCSfrjpId0BgX8mgabWmKlmbGYR0m+p7pPml1iO0jkGi0361Pm2Ck4dePxNd3i7B0mx+hOxR1CtyiPPGwHwqC4g9EQcpAvz2PIgY5PgrSLpR6W4p03ax5Emu4GrM9gVPi/72wCxL27Q= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1653393157; 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=NAVSYPk4vrJH8E6jm6Z5xwmYGQH1/cDJ/WTrPGvpn9I=; b=f2jGx2JD49MqFDkB+cA6T778Dc7fIHdTaDS6uF2gadc13UhWdKwxUaZceQdIe8R+wlQBuFpkRlsmsNId9689fBmD00eg0amnac1T9JqoOmGumVc8BD6vpHpJat8ALqRjLclP4SPiTIGuMTjq7jI9GTCzDC1DSLQ9t6amco9gHZU= 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 1653393157897893.0458324873284; Tue, 24 May 2022 04:52:37 -0700 (PDT) Received: from localhost ([::1]:51794 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ntT5Y-00078h-3Z for importer2@patchew.org; Tue, 24 May 2022 07:52:36 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:33174) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ntSKy-0006Ap-Or for qemu-devel@nongnu.org; Tue, 24 May 2022 07:04:45 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:45466) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ntSJt-0003aZ-NU for qemu-devel@nongnu.org; Tue, 24 May 2022 07:04:14 -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-184-z4t7eKnCNwan_mKqarHstQ-1; Tue, 24 May 2022 07:03:11 -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 AC8823C1E321; Tue, 24 May 2022 11:03:10 +0000 (UTC) Received: from localhost.localdomain.com (unknown [10.33.36.159]) by smtp.corp.redhat.com (Postfix) with ESMTP id 4B2971121315; Tue, 24 May 2022 11:03:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1653390192; 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=NAVSYPk4vrJH8E6jm6Z5xwmYGQH1/cDJ/WTrPGvpn9I=; b=cpVy0cAHDgVDoU9PVQc9mLVy0pwsBFlyDWa0KZSwJNNgNoqU010q4Pq4QYoRhedhqy9tnN Rzwvj5psCUqg6LjnBE357vzDzIFhtb6pBAZyHriCoq36WEyGTwv1LKB9N0wB4PXmDSkpcb aZ2tyLk3WAaZhDRFcW72MH+yX/fJsIM= X-MC-Unique: z4t7eKnCNwan_mKqarHstQ-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 19/20] migration: remove the QEMUFileOps 'get_return_path' callback Date: Tue, 24 May 2022 12:02:34 +0100 Message-Id: <20220524110235.145079-20-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.133.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=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+importer2=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1653393159201100001 This directly implements the get_return_path logic using QIOChannel APIs. Signed-off-by: Daniel P. Berrang=C3=A9 Reviewed-by: Dr. David Alan Gilbert --- migration/qemu-file-channel.c | 16 ---------------- migration/qemu-file.c | 22 ++++++++++------------ migration/qemu-file.h | 6 ------ 3 files changed, 10 insertions(+), 34 deletions(-) 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 72a6f58af5..dfee808924 100644 --- a/migration/qemu-file.c +++ b/migration/qemu-file.c @@ -92,18 +92,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 || @@ -131,6 +119,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); diff --git a/migration/qemu-file.h b/migration/qemu-file.h index 542c637934..5370e4e5ec 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 { --=20 2.36.1 From nobody Sat Apr 27 17:49:53 2024 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=1653393513; cv=none; d=zohomail.com; s=zohoarc; b=mQzJpKrVlCoQP5zVAQV8zVvec15GnowMlCR/+uOOhzrEn4/qkUHxySqIQMnVIFd9sv8OaMqm1HA5/7fgn9bkFLwlIjhOiuoQRDz9ODz/PzP3bxlJpQeD5/uzbP7KcQu9CQA4+c4XVtSSXInPSnaEJmrZi262oeyad3bIrbq9CGI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1653393513; 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=LPRH62li/3kGAyq1cMAlfJ7iu0H/2KZdv0D/rjF+LRc=; b=Z3/50Xyh7T0nnrRtubEZQoYlqp/qyGYXPjjLrlUPoFT7/e4qB3TYbfOrTGAs5SQCCmLfdpcoq5RjVKaUz8dkvn+ZAYeaBBsAhkkyDv6R85EPDKIwSD4DIDi/kjyTwAtJU8AEGP5Z1l5SVD9LcGXun1G70NFEZ1u/z674nxkO1Ws= 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 1653393513261142.23374109215342; Tue, 24 May 2022 04:58:33 -0700 (PDT) Received: from localhost ([::1]:34706 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ntTBI-0006nA-5F for importer2@patchew.org; Tue, 24 May 2022 07:58:32 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:33202) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ntSLG-0006Az-LY for qemu-devel@nongnu.org; Tue, 24 May 2022 07:04:46 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:23917) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ntSKm-0003c6-GK for qemu-devel@nongnu.org; Tue, 24 May 2022 07:04:23 -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-330-qJY2p4uuPWSewvXiZB3MXw-1; Tue, 24 May 2022 07:03:12 -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 64ADC80159B; Tue, 24 May 2022 11:03:12 +0000 (UTC) Received: from localhost.localdomain.com (unknown [10.33.36.159]) by smtp.corp.redhat.com (Postfix) with ESMTP id E8952112131E; Tue, 24 May 2022 11:03:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1653390196; 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=LPRH62li/3kGAyq1cMAlfJ7iu0H/2KZdv0D/rjF+LRc=; b=ck3s4ZenePq1Qg7dbID7eCpMuHrmn3ZTmPHqM1JP4MkOw5mqaUwrU/gqSg1gqShyJTpxq4 wiYxFAQYXbEnw+CZAx4JGH5dUOfv8goAcC451GeAgI0PY5QXQCXVJox3qiK6t7yUtXQqz0 QJitC0+jXHiI7GeASc314S37JtgO6Dk= X-MC-Unique: qJY2p4uuPWSewvXiZB3MXw-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 20/20] migration: remove the QEMUFileOps abstraction Date: Tue, 24 May 2022 12:02:35 +0100 Message-Id: <20220524110235.145079-21-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.133.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=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+importer2=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1653393513979100003 Now that all QEMUFile callbacks are removed, the entire concept can be deleted. Signed-off-by: Daniel P. Berrang=C3=A9 Reviewed-by: Dr. David Alan Gilbert --- migration/channel.c | 4 +-- migration/colo.c | 5 ++-- migration/meson.build | 1 - migration/migration.c | 7 ++--- migration/qemu-file-channel.c | 53 ----------------------------------- migration/qemu-file-channel.h | 32 --------------------- migration/qemu-file.c | 20 ++++++------- migration/qemu-file.h | 8 ++---- migration/ram.c | 3 +- migration/rdma.c | 5 ++-- migration/savevm.c | 11 ++++---- tests/unit/test-vmstate.c | 5 ++-- 12 files changed, 27 insertions(+), 127 deletions(-) delete mode 100644 migration/qemu-file-channel.c delete mode 100644 migration/qemu-file-channel.h 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/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', ) diff --git a/migration/migration.c b/migration/migration.c index ab1e9610ef..8a30ef17d9 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" @@ -722,7 +721,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; @@ -3081,7 +3080,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 /* @@ -3970,7 +3969,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-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.c b/migration/qemu-file.c index dfee808924..81688b7a23 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; @@ -104,16 +103,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; @@ -125,21 +122,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; @@ -235,6 +230,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/qemu-file.h b/migration/qemu-file.h index 5370e4e5ec..12e625f96a 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,10 +62,9 @@ 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_get_fd(QEMUFile *f); int qemu_fclose(QEMUFile *f); =20 /* 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 83265513d9..49e6dba323 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" @@ -4093,12 +4092,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; --=20 2.36.1