From nobody Mon Feb 9 19:07:36 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=quarantine dis=none) header.from=suse.com ARC-Seal: i=1; a=rsa-sha256; t=1665409065; cv=none; d=zohomail.com; s=zohoarc; b=HGNh/WfxC6j/koNeDFfhAZizUS0eVlGpQ53r2/xaICaikpm5TMh3orT9ofsUkIzhrtuc5B5tDIpvDUSAYaW5JqJHXQOzElBSe7pu9JZsesEGE/r5ZoRT91r8rVAAplgWUatcen5gu8P0vb6H54ceyCoGoUnEAIfmZ1LowQyqjlY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1665409065; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=kPCQLiTt+xycLpMdzoecrm8X5xdA5JatxxJh/K6EFXQ=; b=Ft/zeRWiACRwrhMsakC2LZtt5fL8yDFvG5MynconYm7NsvMW7mmeOQ/p9Hb/jqVh+Pkgcrh2NPYDl42QlUrj8A3n99NFhPV73C/54duDaWGWkmhp42T04qycOqMMuxCvqyqZpiiAxhoT1MpQEPItFtdGF2drGnpdwr5yxL7pTvc= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1665409065487160.38983728709775; Mon, 10 Oct 2022 06:37:45 -0700 (PDT) Received: from localhost ([::1]:44764 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ohsyW-00044i-FS for importer@patchew.org; Mon, 10 Oct 2022 09:37:44 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:40938) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ohsvG-0000zv-Fc for qemu-devel@nongnu.org; Mon, 10 Oct 2022 09:34:23 -0400 Received: from smtp-out2.suse.de ([195.135.220.29]:48750) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ohsvC-0005KU-Em for qemu-devel@nongnu.org; Mon, 10 Oct 2022 09:34:21 -0400 Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id 508661F8F2; Mon, 10 Oct 2022 13:34:17 +0000 (UTC) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id C180C13479; Mon, 10 Oct 2022 13:34:16 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id MF1zLFgfRGNsAwAAMHmgww (envelope-from ); Mon, 10 Oct 2022 13:34:16 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1665408857; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=kPCQLiTt+xycLpMdzoecrm8X5xdA5JatxxJh/K6EFXQ=; b=nbp8qs7V3CumbEVUcOBVCtHWoewLDq3+XiTsTXFiFWXOl733FNc1bGtafxUyzhz8Zgo5Yy GmvOZTx2yxJccB6oxXDBzowN5Y01s5EixuZOsL8fqBMte+oIGgYc0LLfL5tl79en4ri1TA e2IUyG0pY460uWeF4PwYAIlSLPPaBQI= From: Nikolay Borisov To: dgilbert@redhat.com, berrange@redhat.com Cc: qemu-devel@nongnu.org, jfehlig@suse.com, Claudio.Fontana@suse.com, dfaggioli@suse.com, Nikolay Borisov Subject: [PATCH v2 07/11] migration: add qemu_get_buffer_at Date: Mon, 10 Oct 2022 16:34:04 +0300 Message-Id: <20221010133408.3214433-8-nborisov@suse.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221010133408.3214433-1-nborisov@suse.com> References: <20221010133408.3214433-1-nborisov@suse.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=195.135.220.29; envelope-from=nborisov@suse.com; helo=smtp-out2.suse.de X-Spam_score_int: -43 X-Spam_score: -4.4 X-Spam_bar: ---- X-Spam_report: (-4.4 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @suse.com) X-ZM-MESSAGEID: 1665409066210100002 Content-Type: text/plain; charset="utf-8" Restoring a 'fixed-ram' enabled migration stream would require reading from specific offsets in the file so add a helper to QEMUFile that uses the newly introduced qio_channel_file_preadv. Signed-off-by: Nikolay Borisov --- migration/qemu-file.c | 23 +++++++++++++++++++++++ migration/qemu-file.h | 1 + 2 files changed, 24 insertions(+) diff --git a/migration/qemu-file.c b/migration/qemu-file.c index 07ba1125e83f..73fffbdb9b7e 100644 --- a/migration/qemu-file.c +++ b/migration/qemu-file.c @@ -564,6 +564,29 @@ void qemu_put_buffer_at(QEMUFile *f, const uint8_t *bu= f, size_t buflen, off_t po return; } =20 + +size_t qemu_get_buffer_at(QEMUFile *f, const uint8_t *buf, size_t buflen, = off_t pos) +{ + Error *err =3D NULL; + struct iovec iov =3D { .iov_base =3D (char *)buf, .iov_len =3D buflen = }; + ssize_t ret; + + if (f->last_error) { + return 0; + } + + ret =3D qio_channel_file_preadv(f->ioc, &iov, 1, pos, &err); + if (ret =3D=3D -1) { + goto error; + } + + return (size_t)ret; + + error: + qemu_file_set_error_obj(f, -EIO, err); + return 0; +} + void qemu_set_offset(QEMUFile *f, off_t off, int whence) { Error *err =3D NULL; diff --git a/migration/qemu-file.h b/migration/qemu-file.h index 33cfc07b81d1..ab10c3ad7e42 100644 --- a/migration/qemu-file.h +++ b/migration/qemu-file.h @@ -151,6 +151,7 @@ void qemu_file_set_blocking(QEMUFile *f, bool block); void qemu_set_offset(QEMUFile *f, off_t off, int whence); off_t qemu_get_offset(QEMUFile *f); void qemu_put_buffer_at(QEMUFile *f, const uint8_t *buf, size_t buflen, of= f_t pos); +size_t qemu_get_buffer_at(QEMUFile *f, const uint8_t *buf, size_t buflen, = off_t pos); =20 void ram_control_before_iterate(QEMUFile *f, uint64_t flags); void ram_control_after_iterate(QEMUFile *f, uint64_t flags); --=20 2.34.1