From nobody Mon Feb 9 14:19:40 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=none dis=none) header.from=yandex-team.ru ARC-Seal: i=1; a=rsa-sha256; t=1768373302; cv=none; d=zohomail.com; s=zohoarc; b=knjOkot+yTpZA5ctJhTzjwVMvutVg16apHrW9cZXy4QChqhBhZm0ky7eng6E6Ck8U/VzZew9XpMmJ17Ox/Wdp9MRGvXcKnRFYqs+E9cMiuca6hrHqtCVOvD0Rn6FmjFp4/R0bNB2LITp/txGcl8OXYV6jOpgDStk9kzT2HnlT8Q= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1768373302; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=A8aHx7NDG7I0eOLZpPn11ukQ0g9iIT0KmhKkmcwKQQA=; b=n4dO1l0WdoJNGlr4zgmf2kOMT0qI2c4agT/MhiMZMbTA9BCGIuy/uG+UOWv+RT0NK4jBxiRBu9Ej2tJh8AjZ1f03F1JNNi9MPqBCzvi3AH0x3df7U58FI8b4JPhgzBp71d6BQKbDM438A4+GpPFP2mGYTDNEKrOc3xfbY85a7jM= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1768373302089468.3189123298564; Tue, 13 Jan 2026 22:48:22 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vfufD-0001sJ-NX; Wed, 14 Jan 2026 01:47:33 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vfuf2-0001pm-Uf for qemu-devel@nongnu.org; Wed, 14 Jan 2026 01:47:21 -0500 Received: from forwardcorp1d.mail.yandex.net ([178.154.239.200]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vfuf0-0004A0-Q4 for qemu-devel@nongnu.org; Wed, 14 Jan 2026 01:47:20 -0500 Received: from mail-nwsmtp-smtp-corp-main-56.klg.yp-c.yandex.net (mail-nwsmtp-smtp-corp-main-56.klg.yp-c.yandex.net [IPv6:2a02:6b8:c42:65a0:0:640:e1de:0]) by forwardcorp1d.mail.yandex.net (Yandex) with ESMTPS id 7FD2C807B9; Wed, 14 Jan 2026 09:47:14 +0300 (MSK) Received: from vsementsov-lin.. (unknown [2a02:6bf:8080:c88::1:7]) by mail-nwsmtp-smtp-corp-main-56.klg.yp-c.yandex.net (smtpcorp/Yandex) with ESMTPSA id ClNQD90AqW20-3AvZsROj; Wed, 14 Jan 2026 09:47:14 +0300 Precedence: bulk X-Yandex-Fwd: 1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yandex-team.ru; s=default; t=1768373234; bh=A8aHx7NDG7I0eOLZpPn11ukQ0g9iIT0KmhKkmcwKQQA=; h=Message-ID:Date:In-Reply-To:Cc:Subject:References:To:From; b=nWOJWikNpKQQ0UqfdnWhaDDn0NLiJgcDD2r9vRt0yMjsBmDjsaOYyCqhU8Y1jP2er fUtl7lYX15v3SPyedtsgW7DmdBK06mFPqOfINRjXw+HB/W0ejIAkcd4Gi5blxMOiFy yAYgKmBg+1NRj6vB0QepyF6uiTwOCj8Ukxt/7zSc= Authentication-Results: mail-nwsmtp-smtp-corp-main-56.klg.yp-c.yandex.net; dkim=pass header.i=@yandex-team.ru From: Vladimir Sementsov-Ogievskiy To: peterx@redhat.com Cc: farosas@suse.de, qemu-devel@nongnu.org, dtalexundeer@yandex-team.ru, vsementsov@yandex-team.ru, yc-core@yandex-team.ru, d-tatianin@yandex-team.ru Subject: [PATCH 1/5] vmstate-types: get_fd(): handle qemu_file_get_fd() failure Date: Wed, 14 Jan 2026 09:47:06 +0300 Message-ID: <20260114064710.176268-2-vsementsov@yandex-team.ru> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20260114064710.176268-1-vsementsov@yandex-team.ru> References: <20260114064710.176268-1-vsementsov@yandex-team.ru> 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 (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=178.154.239.200; envelope-from=vsementsov@yandex-team.ru; helo=forwardcorp1d.mail.yandex.net X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 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_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, 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 List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @yandex-team.ru) X-ZM-MESSAGEID: 1768373304186158500 Content-Type: text/plain; charset="utf-8" qemu_file_get_fd() may fail, and return -1 in this case. We don't support passing "invalid" file descriptors (like -1), so we should not interpret error here like invalid descriptor. Signed-off-by: Vladimir Sementsov-Ogievskiy Reviewed-by: Fabiano Rosas --- migration/vmstate-types.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/migration/vmstate-types.c b/migration/vmstate-types.c index 4b01dc19c2..e34bf4486e 100644 --- a/migration/vmstate-types.c +++ b/migration/vmstate-types.c @@ -321,12 +321,21 @@ const VMStateInfo vmstate_info_uint64 =3D { static int get_fd(QEMUFile *f, void *pv, size_t size, const VMStateField *field) { + int fd; int32_t *v =3D pv; + if (migrate_mode() =3D=3D MIG_MODE_CPR_EXEC) { qemu_get_sbe32s(f, v); return 0; } - *v =3D qemu_file_get_fd(f); + + fd =3D qemu_file_get_fd(f); + if (fd < 0) { + return -1; + } + + *v =3D fd; + return 0; } =20 --=20 2.48.1 From nobody Mon Feb 9 14:19:40 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=none dis=none) header.from=yandex-team.ru ARC-Seal: i=1; a=rsa-sha256; t=1768373293; cv=none; d=zohomail.com; s=zohoarc; b=aJW3iUqeXgI575+YSFLmlGhNPWyMB9LMbI347NJ0UlGrLJe/O+Df3bSIOX9EASIz9VPlDYnu6TD9cc/t67JwrIufIVVlbrqCaoq5TV1Yml1xpCf1HLdPbaPziDszwcIeONl4rwNmXBmy7JxkgqRQaJBIvrXTP2mxg0AbfnCqjyI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1768373293; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=Tif36W+c4IEEnHeR+8q+hVk+mR4A73d1GMBH7oqV3UA=; b=GEo/0kAtq/7W9Lp61WBkRWY7oh4xFfGwKGN0iqLtMPM8SsqbctTvMC4MQ9ze3+K9JwG57GXA8K8uZgjxP4/CMXoK+FTgJmhEsF5ngleDOXaYMmc4Qp70Vynmn3ESwKXuRFBtoWf19wRbNDN2mfAjclGccmMMEpJhKxGbWX8Nksc= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1768373292760666.5733573437498; Tue, 13 Jan 2026 22:48:12 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vfufJ-0001uM-AM; Wed, 14 Jan 2026 01:47:39 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vfuf2-0001pl-UK for qemu-devel@nongnu.org; Wed, 14 Jan 2026 01:47:21 -0500 Received: from forwardcorp1d.mail.yandex.net ([2a02:6b8:c41:1300:1:45:d181:df01]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vfuf0-0004A8-HB for qemu-devel@nongnu.org; Wed, 14 Jan 2026 01:47:20 -0500 Received: from mail-nwsmtp-smtp-corp-main-56.klg.yp-c.yandex.net (mail-nwsmtp-smtp-corp-main-56.klg.yp-c.yandex.net [IPv6:2a02:6b8:c42:65a0:0:640:e1de:0]) by forwardcorp1d.mail.yandex.net (Yandex) with ESMTPS id 1412D8074D; Wed, 14 Jan 2026 09:47:15 +0300 (MSK) Received: from vsementsov-lin.. (unknown [2a02:6bf:8080:c88::1:7]) by mail-nwsmtp-smtp-corp-main-56.klg.yp-c.yandex.net (smtpcorp/Yandex) with ESMTPSA id ClNQD90AqW20-0Zw04bIg; Wed, 14 Jan 2026 09:47:14 +0300 Precedence: bulk X-Yandex-Fwd: 1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yandex-team.ru; s=default; t=1768373234; bh=Tif36W+c4IEEnHeR+8q+hVk+mR4A73d1GMBH7oqV3UA=; h=Message-ID:Date:In-Reply-To:Cc:Subject:References:To:From; b=WFnsEhpPlPwxCywp/aMYs4q7alunzPm2kKCS/UZ/JFObwlq7CxpBFx598db3F3UBR 9YTfuG7F5Ga1s/ZHgh6ASrPhQJgwSMVgstY6dnMhvT0IdCtTyso2bYGKvj6sPm7AN0 9H7i4KArs3h+3n5csw9pofYX9hac9Qqrk2ec84A0= Authentication-Results: mail-nwsmtp-smtp-corp-main-56.klg.yp-c.yandex.net; dkim=pass header.i=@yandex-team.ru From: Vladimir Sementsov-Ogievskiy To: peterx@redhat.com Cc: farosas@suse.de, qemu-devel@nongnu.org, dtalexundeer@yandex-team.ru, vsementsov@yandex-team.ru, yc-core@yandex-team.ru, d-tatianin@yandex-team.ru Subject: [PATCH 2/5] qemu-file: qemu_file_get_fd(): fail if no expected fd come Date: Wed, 14 Jan 2026 09:47:07 +0300 Message-ID: <20260114064710.176268-3-vsementsov@yandex-team.ru> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20260114064710.176268-1-vsementsov@yandex-team.ru> References: <20260114064710.176268-1-vsementsov@yandex-team.ru> 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 (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=2a02:6b8:c41:1300:1:45:d181:df01; envelope-from=vsementsov@yandex-team.ru; helo=forwardcorp1d.mail.yandex.net X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 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, 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 List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @yandex-team.ru) X-ZM-MESSAGEID: 1768373297295158500 Content-Type: text/plain; charset="utf-8" In _put() we don't actually allow send a service byte without fd. So on _get() it's unexpected. Let's be strict. Signed-off-by: Vladimir Sementsov-Ogievskiy Reviewed-by: Fabiano Rosas --- migration/qemu-file.c | 26 ++++++++++++++++---------- 1 file changed, 16 insertions(+), 10 deletions(-) diff --git a/migration/qemu-file.c b/migration/qemu-file.c index 4b5a409a80..02f30c1c21 100644 --- a/migration/qemu-file.c +++ b/migration/qemu-file.c @@ -389,28 +389,34 @@ int qemu_file_get_fd(QEMUFile *f) { int fd =3D -1; FdEntry *fde; + Error *err =3D NULL; =20 if (!f->can_pass_fd) { - Error *err =3D NULL; error_setg(&err, "%s does not support fd passing", f->ioc->name); - error_report_err(error_copy(err)); - qemu_file_set_error_obj(f, -EIO, err); - goto out; + goto fail; } =20 /* Force the dummy byte and its fd passenger to appear. */ qemu_peek_byte(f, 0); =20 fde =3D QTAILQ_FIRST(&f->fds); - if (fde) { - qemu_get_byte(f); /* Drop the dummy byte */ - fd =3D fde->fd; - QTAILQ_REMOVE(&f->fds, fde, entry); - g_free(fde); + if (!fde) { + error_setg(&err, "%s no FD come with service byte", f->ioc->name); + goto fail; } -out: + + qemu_get_byte(f); /* Drop the dummy byte */ + fd =3D fde->fd; + QTAILQ_REMOVE(&f->fds, fde, entry); + g_free(fde); + trace_qemu_file_get_fd(f->ioc->name, fd); return fd; + +fail: + error_report_err(error_copy(err)); + qemu_file_set_error_obj(f, -EIO, err); + return -1; } =20 /** Closes the file --=20 2.48.1 From nobody Mon Feb 9 14:19:40 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=none dis=none) header.from=yandex-team.ru ARC-Seal: i=1; a=rsa-sha256; t=1768373293; cv=none; d=zohomail.com; s=zohoarc; b=SwvJByKFWNZl6bz4jdV5zki4oDMv7gTdbmrwORyBY8iPetyeamiLJr2EW9u09FDUHpDm9BihL2JWNKeNSzcK+k3zu+6rxqtt3c+lBZY2Yj4bYl1xAOwDnDPNIzFIbgTljcRAwPhoH2pPaS1yGpIvb2U8dF2gbgGFoTyUhw5Ha7s= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1768373293; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=3sUPaLvUHaNGhgC/evAlZ4jxilj/5xxcTbEvzEggJbA=; b=SRnuDvJLshTp5YE3NnKHUk2+LCAdJfyaKyzwBLbn+Myph11b9CwfHlO64ZJm9lCVxEfl1Y1xlXTbgqDWY3wCY3s+ko4KR+HFr90nQeO+SYd3zH8nWov/FovJXpQSOLhu91PXgVAkIhWLxz6zO9J86syUWpfaHaKxOYQnx7Lz0LE= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1768373292874319.35438450238803; Tue, 13 Jan 2026 22:48:12 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vfufJ-0001ss-6G; Wed, 14 Jan 2026 01:47:37 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vfuf2-0001pk-Vi for qemu-devel@nongnu.org; Wed, 14 Jan 2026 01:47:21 -0500 Received: from forwardcorp1d.mail.yandex.net ([178.154.239.200]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vfuf0-0004AE-Ok for qemu-devel@nongnu.org; Wed, 14 Jan 2026 01:47:20 -0500 Received: from mail-nwsmtp-smtp-corp-main-56.klg.yp-c.yandex.net (mail-nwsmtp-smtp-corp-main-56.klg.yp-c.yandex.net [IPv6:2a02:6b8:c42:65a0:0:640:e1de:0]) by forwardcorp1d.mail.yandex.net (Yandex) with ESMTPS id 84AFB807C8; Wed, 14 Jan 2026 09:47:15 +0300 (MSK) Received: from vsementsov-lin.. (unknown [2a02:6bf:8080:c88::1:7]) by mail-nwsmtp-smtp-corp-main-56.klg.yp-c.yandex.net (smtpcorp/Yandex) with ESMTPSA id ClNQD90AqW20-jVbEz059; Wed, 14 Jan 2026 09:47:15 +0300 Precedence: bulk X-Yandex-Fwd: 1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yandex-team.ru; s=default; t=1768373235; bh=3sUPaLvUHaNGhgC/evAlZ4jxilj/5xxcTbEvzEggJbA=; h=Message-ID:Date:In-Reply-To:Cc:Subject:References:To:From; b=dJkUZJIr7qic5XfHOlM+o/SWSe+AhEJAA83aDwhzwLzOgrDqixBVZsns8xs5h3qMh kmvF427yE8EASO9KwIQ1yjL56Drbt7H4JvKDkaLPdR/xjUePmOqX56RJCgoUZk8PEK JlYXKqslW+pfDRqK76o80opp5K3TQDg2Rf5jX53c= Authentication-Results: mail-nwsmtp-smtp-corp-main-56.klg.yp-c.yandex.net; dkim=pass header.i=@yandex-team.ru From: Vladimir Sementsov-Ogievskiy To: peterx@redhat.com Cc: farosas@suse.de, qemu-devel@nongnu.org, dtalexundeer@yandex-team.ru, vsementsov@yandex-team.ru, yc-core@yandex-team.ru, d-tatianin@yandex-team.ru Subject: [PATCH 3/5] qemu-file: qemu_file_get_fd(): get byte in one shot Date: Wed, 14 Jan 2026 09:47:08 +0300 Message-ID: <20260114064710.176268-4-vsementsov@yandex-team.ru> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20260114064710.176268-1-vsementsov@yandex-team.ru> References: <20260114064710.176268-1-vsementsov@yandex-team.ru> 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 (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=178.154.239.200; envelope-from=vsementsov@yandex-team.ru; helo=forwardcorp1d.mail.yandex.net X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 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_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, 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 List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @yandex-team.ru) X-ZM-MESSAGEID: 1768373297351158500 Content-Type: text/plain; charset="utf-8" No reason to split into peek + get. Signed-off-by: Vladimir Sementsov-Ogievskiy Reviewed-by: Fabiano Rosas --- migration/qemu-file.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/migration/qemu-file.c b/migration/qemu-file.c index 02f30c1c21..3a9a0a49d4 100644 --- a/migration/qemu-file.c +++ b/migration/qemu-file.c @@ -396,8 +396,7 @@ int qemu_file_get_fd(QEMUFile *f) goto fail; } =20 - /* Force the dummy byte and its fd passenger to appear. */ - qemu_peek_byte(f, 0); + qemu_get_byte(f); =20 fde =3D QTAILQ_FIRST(&f->fds); if (!fde) { @@ -405,7 +404,6 @@ int qemu_file_get_fd(QEMUFile *f) goto fail; } =20 - qemu_get_byte(f); /* Drop the dummy byte */ fd =3D fde->fd; QTAILQ_REMOVE(&f->fds, fde, entry); g_free(fde); --=20 2.48.1 From nobody Mon Feb 9 14:19:40 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=none dis=none) header.from=yandex-team.ru ARC-Seal: i=1; a=rsa-sha256; t=1768373293; cv=none; d=zohomail.com; s=zohoarc; b=F2SqvNx+GciFptLY2GmC0GRRhfSGBLBe4qkQxrvt/SedPm46sUo6aPzoqSr/S+YRRvog+yzqLM4hsg6mQtwOPriHAAewN6IWsSn4/cS0Cri4g3oI4FRtrvj20uJWCzuYm8Nmi8IolGV+FPTJmSYgBiQbz/+SkxYklJJSaMc+Ae0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1768373293; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=jsy4reI1TzanCtXBfxJ4/w5QjWMW6WCD9Mr70g2ZVgo=; b=gLEEH5lommoLAd3YoEdBeZ5ZX1R1ST30sh3inKUtIGkOAtin+3EyrXWVAE5GIuntfUNNNTbhYQuOz5pYErPTVC6UmulAVmTs7BqC5236YJQY6c4My4H+KDkBLnPlgA+gnADZ2NhWUHEiVac9Guh/nUamgi1k173PsM1FdliAQko= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1768373293105329.7428384574654; Tue, 13 Jan 2026 22:48:13 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vfufO-0001w3-Q0; Wed, 14 Jan 2026 01:47:44 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vfuf4-0001pz-6E for qemu-devel@nongnu.org; Wed, 14 Jan 2026 01:47:22 -0500 Received: from forwardcorp1d.mail.yandex.net ([178.154.239.200]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vfuf1-0004AJ-5S for qemu-devel@nongnu.org; Wed, 14 Jan 2026 01:47:21 -0500 Received: from mail-nwsmtp-smtp-corp-main-56.klg.yp-c.yandex.net (mail-nwsmtp-smtp-corp-main-56.klg.yp-c.yandex.net [IPv6:2a02:6b8:c42:65a0:0:640:e1de:0]) by forwardcorp1d.mail.yandex.net (Yandex) with ESMTPS id 04A0380676; Wed, 14 Jan 2026 09:47:16 +0300 (MSK) Received: from vsementsov-lin.. (unknown [2a02:6bf:8080:c88::1:7]) by mail-nwsmtp-smtp-corp-main-56.klg.yp-c.yandex.net (smtpcorp/Yandex) with ESMTPSA id ClNQD90AqW20-W6iwykCf; Wed, 14 Jan 2026 09:47:15 +0300 Precedence: bulk X-Yandex-Fwd: 1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yandex-team.ru; s=default; t=1768373235; bh=jsy4reI1TzanCtXBfxJ4/w5QjWMW6WCD9Mr70g2ZVgo=; h=Message-ID:Date:In-Reply-To:Cc:Subject:References:To:From; b=G7hg0wfSlTvbz//H4usF7syB7F1fRjSqDkyUa+0hdcR0JQzGNDBwHN6oHIVUko0jS MPJAh25vv69Kx9LOiyNUawq2C7rXKvLPB/DPM9PpSQhpWP4jt9g7Jw4uBz/4OtG4Et iuIOXE77DLsYC1DJqha1RCOBPiZ0pVtWD3nOZS+A= Authentication-Results: mail-nwsmtp-smtp-corp-main-56.klg.yp-c.yandex.net; dkim=pass header.i=@yandex-team.ru From: Vladimir Sementsov-Ogievskiy To: peterx@redhat.com Cc: farosas@suse.de, qemu-devel@nongnu.org, dtalexundeer@yandex-team.ru, vsementsov@yandex-team.ru, yc-core@yandex-team.ru, d-tatianin@yandex-team.ru Subject: [PATCH 4/5] qemu-file: qemu_file_get_fd(): check service byte itself Date: Wed, 14 Jan 2026 09:47:09 +0300 Message-ID: <20260114064710.176268-5-vsementsov@yandex-team.ru> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20260114064710.176268-1-vsementsov@yandex-team.ru> References: <20260114064710.176268-1-vsementsov@yandex-team.ru> 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 (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=178.154.239.200; envelope-from=vsementsov@yandex-team.ru; helo=forwardcorp1d.mail.yandex.net X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 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_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, 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 List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @yandex-team.ru) X-ZM-MESSAGEID: 1768373297287158500 Content-Type: text/plain; charset="utf-8" We can check it, so, why not. Signed-off-by: Vladimir Sementsov-Ogievskiy Reviewed-by: Fabiano Rosas --- migration/qemu-file.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/migration/qemu-file.c b/migration/qemu-file.c index 3a9a0a49d4..da701d40e4 100644 --- a/migration/qemu-file.c +++ b/migration/qemu-file.c @@ -390,13 +390,19 @@ int qemu_file_get_fd(QEMUFile *f) int fd =3D -1; FdEntry *fde; Error *err =3D NULL; + int service_byte; =20 if (!f->can_pass_fd) { error_setg(&err, "%s does not support fd passing", f->ioc->name); goto fail; } =20 - qemu_get_byte(f); + service_byte =3D qemu_get_byte(f); + if (service_byte !=3D ' ') { + error_setg(&err, "%s unexpected service byte: %d(%c)", f->ioc->nam= e, + service_byte, service_byte); + goto fail; + } =20 fde =3D QTAILQ_FIRST(&f->fds); if (!fde) { --=20 2.48.1 From nobody Mon Feb 9 14:19:40 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=none dis=none) header.from=yandex-team.ru ARC-Seal: i=1; a=rsa-sha256; t=1768373318; cv=none; d=zohomail.com; s=zohoarc; b=GG2+8Dw+I/4Er+RXmopbRnK3Pb305WABu/tBP8+2hZR8N0JbVSO+pKTuCs2U9eIk16Q9uCSVCLF1q/4hufBZzfWPSmx276dcNCM5jr4waiv62f+A95NzkEZdBeamqK9rT4aoBG4b490Kjftpcp6/S4OTqFyRShQyCF0xpHU/0vo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1768373318; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=MN2tkwk+2wULskhErRy+Xg3Kjfi5sWUTJLiHbLKQQjE=; b=V9X+NY1mg2cx+jKF8BvDpOIF+uPsroAQOBLL5rpt0sKBoxcRiKzDeFU2YljpFdNe1fpc0RUFc1wVkWVCslamdDvgC1bCwJrTvwKYyzvtn5uNOTAj0aeLsDCi2qXtJomRKPXA/V29xNZO0DmaBYtIuncwNTT4uAVFb7dHo2QC4sg= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1768373318124420.346223430862; Tue, 13 Jan 2026 22:48:38 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vfufL-0001vy-Dp; Wed, 14 Jan 2026 01:47:39 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vfuf3-0001ps-6r for qemu-devel@nongnu.org; Wed, 14 Jan 2026 01:47:21 -0500 Received: from forwardcorp1d.mail.yandex.net ([178.154.239.200]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vfuf1-0004AO-2s for qemu-devel@nongnu.org; Wed, 14 Jan 2026 01:47:20 -0500 Received: from mail-nwsmtp-smtp-corp-main-56.klg.yp-c.yandex.net (mail-nwsmtp-smtp-corp-main-56.klg.yp-c.yandex.net [IPv6:2a02:6b8:c42:65a0:0:640:e1de:0]) by forwardcorp1d.mail.yandex.net (Yandex) with ESMTPS id 8E46C807BC; Wed, 14 Jan 2026 09:47:16 +0300 (MSK) Received: from vsementsov-lin.. (unknown [2a02:6bf:8080:c88::1:7]) by mail-nwsmtp-smtp-corp-main-56.klg.yp-c.yandex.net (smtpcorp/Yandex) with ESMTPSA id ClNQD90AqW20-Awhmfl3Y; Wed, 14 Jan 2026 09:47:16 +0300 Precedence: bulk X-Yandex-Fwd: 1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yandex-team.ru; s=default; t=1768373236; bh=MN2tkwk+2wULskhErRy+Xg3Kjfi5sWUTJLiHbLKQQjE=; h=Message-ID:Date:In-Reply-To:Cc:Subject:References:To:From; b=xHKj5APoodrDy58rHi4uuVndh+Rx1Tu06IJrq6I+Oq5fVpM4dYudg5vgYOXGU9bsA l8tydnX6ISsvX+FVLLy4uDvzb3JR+YSaLhncXk1XW//7TrtfMW9hKRR2poBhgjw+5i B53KXx6PkrIFYw+rkh19Ag2MAjNCKkC9Ss0WLdRQ= Authentication-Results: mail-nwsmtp-smtp-corp-main-56.klg.yp-c.yandex.net; dkim=pass header.i=@yandex-team.ru From: Vladimir Sementsov-Ogievskiy To: peterx@redhat.com Cc: farosas@suse.de, qemu-devel@nongnu.org, dtalexundeer@yandex-team.ru, vsementsov@yandex-team.ru, yc-core@yandex-team.ru, d-tatianin@yandex-team.ru Subject: [PATCH 5/5] qemu-file: qemu_file_get_fd(): improve interface Date: Wed, 14 Jan 2026 09:47:10 +0300 Message-ID: <20260114064710.176268-6-vsementsov@yandex-team.ru> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20260114064710.176268-1-vsementsov@yandex-team.ru> References: <20260114064710.176268-1-vsementsov@yandex-team.ru> 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 (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=178.154.239.200; envelope-from=vsementsov@yandex-team.ru; helo=forwardcorp1d.mail.yandex.net X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 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_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, 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 List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @yandex-team.ru) X-ZM-MESSAGEID: 1768373329485158500 Content-Type: text/plain; charset="utf-8" Make it symmetrical with qemu_file_put_fd() and simplify callers. Signed-off-by: Vladimir Sementsov-Ogievskiy Reviewed-by: Fabiano Rosas --- migration/qemu-file.c | 9 ++++----- migration/qemu-file.h | 2 +- migration/vmstate-types.c | 10 +--------- 3 files changed, 6 insertions(+), 15 deletions(-) diff --git a/migration/qemu-file.c b/migration/qemu-file.c index da701d40e4..f8394cbbb5 100644 --- a/migration/qemu-file.c +++ b/migration/qemu-file.c @@ -385,9 +385,8 @@ int qemu_file_put_fd(QEMUFile *f, int fd) return ret; } =20 -int qemu_file_get_fd(QEMUFile *f) +int qemu_file_get_fd(QEMUFile *f, int *fd) { - int fd =3D -1; FdEntry *fde; Error *err =3D NULL; int service_byte; @@ -410,12 +409,12 @@ int qemu_file_get_fd(QEMUFile *f) goto fail; } =20 - fd =3D fde->fd; + *fd =3D fde->fd; QTAILQ_REMOVE(&f->fds, fde, entry); g_free(fde); =20 - trace_qemu_file_get_fd(f->ioc->name, fd); - return fd; + trace_qemu_file_get_fd(f->ioc->name, *fd); + return 0; =20 fail: error_report_err(error_copy(err)); diff --git a/migration/qemu-file.h b/migration/qemu-file.h index c13c967167..a8e9bb2ccb 100644 --- a/migration/qemu-file.h +++ b/migration/qemu-file.h @@ -82,6 +82,6 @@ size_t qemu_get_buffer_at(QEMUFile *f, const uint8_t *buf= , size_t buflen, =20 QIOChannel *qemu_file_get_ioc(QEMUFile *file); int qemu_file_put_fd(QEMUFile *f, int fd); -int qemu_file_get_fd(QEMUFile *f); +int qemu_file_get_fd(QEMUFile *f, int *fd); =20 #endif diff --git a/migration/vmstate-types.c b/migration/vmstate-types.c index e34bf4486e..89cb211472 100644 --- a/migration/vmstate-types.c +++ b/migration/vmstate-types.c @@ -321,7 +321,6 @@ const VMStateInfo vmstate_info_uint64 =3D { static int get_fd(QEMUFile *f, void *pv, size_t size, const VMStateField *field) { - int fd; int32_t *v =3D pv; =20 if (migrate_mode() =3D=3D MIG_MODE_CPR_EXEC) { @@ -329,14 +328,7 @@ static int get_fd(QEMUFile *f, void *pv, size_t size, return 0; } =20 - fd =3D qemu_file_get_fd(f); - if (fd < 0) { - return -1; - } - - *v =3D fd; - - return 0; + return qemu_file_get_fd(f, v); } =20 static int put_fd(QEMUFile *f, void *pv, size_t size, --=20 2.48.1