From nobody Sun Dec 6 20:48:02 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 ARC-Seal: i=1; a=rsa-sha256; t=1796303570; cv=none; d=zohomail.com; s=zohoarc; b=NeD8XCTKZxvyApj+OKHxEiqdh1BU7Rd63sR6m1Uy6nvGzxrLGaDN6/u+FNog9FrDNtG6OgB4rLR6kEVi5ruCb2R+33Ew/AOEf/TEnEV1Br83OXvUeMhiy60YZVYIMDWJ3qq/Icx27Zz4f2NQXGcCOIufI/eoIE5lcfvHP5+dJd4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1796303570; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=GheuYtT4rheNUV4tl9tugW5ADIlUlGhH6CtNVGmfGn0=; b=bCEkevqtp9oOBtv/+4ZQHSQLv9/QkCJOljy7urRu2ONXmKybdfXChtHKrOLeO+Ss2N3KzJ8rbEaMi9gJlzE8vpyQS0k7alFboLKPknCdAXvF9urO8FkTmhyn79yBElN/kL+wDqRi4/DaiQqBolYgB/5Ao5942NgETsMcmLFmlNI= 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 Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 17963035666531001.6217638425126; Thu, 3 Dec 2026 05:12:46 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xZ6bP-00061Q-Ny; Thu, 03 Dec 2026 08:12:00 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xZ6bM-000618-B3; Thu, 03 Dec 2026 08:11:56 -0500 Received: from isrv.corpit.ru ([212.248.84.144]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xZ6bI-0005GA-1z; Thu, 03 Dec 2026 08:11:55 -0500 Received: from tsrv.corpit.ru (tsrv.tls.msk.ru [192.168.177.2]) by isrv.corpit.ru (Postfix) with ESMTP id 811301EC608; Thu, 03 Dec 2026 16:11:39 +0300 (MSK) Received: from gandalf.tls.msk.ru (mjt.wg.tls.msk.ru [192.168.177.130]) by tsrv.corpit.ru (Postfix) with ESMTP id 7ACA146EE11; Thu, 03 Dec 2026 16:11:39 +0300 (MSK) Received: by gandalf.tls.msk.ru (Postfix, from userid 1000) id 6FD47D373A; Thu, 03 Dec 2026 16:11:39 +0300 (MSK) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=tls.msk.ru; s=202602; t=1796303499; bh=SOmICmMH/+bypACyVLn+x1nwQWEQoiN01CjgZjMoUhc=; h=From:To:Cc:Subject:Date; b=KUdTCVBE9lGZD6xr1JEz32BYuYdcRdZzC2eBZgPYKZWDcdKZIREmqT+dWLke8Zm+d 7MwDoWV8T2qrLhw9Ct44AwUsXjYZeCXUlPlde7WTvEyI2/MWrkfIFTz3uKVeTUyECO eMppGstKwrQUfNoP0A9TTSlK16gxeKPdZ0TihoWxSS9+ej8tcCurr3AboGgjk6CiLu 8I3DoLHMbf7YiK+gPnM5heBFAicgIHcKP/eHE4p+PrevTdbxeF6F27DRupKGlAA7TG dKdNIBTU9UIVszd6k0IwjoM3XYFshEg1lQ5nH0dYSfPmjNfesdXxWS2RAXMFJhLoan KvqjboK+idz8g== From: Michael Tokarev To: qemu-devel@nongnu.org Cc: qemu-stable@nongnu.org, "Michael S . Tsirkin" , Peter Maydell , =?UTF-8?q?Daniel=20P=20=2E=20Berrang=C3=A9?= , Michael Tokarev Subject: [RFC PATCH] virtio: compensate for incoming migration of virtio queues from broken stable series Date: Thu, 3 Dec 2026 16:11:37 +0300 Message-ID: <20261203131137.3127943-1-mjt@tls.msk.ru> X-Mailer: git-send-email 2.47.3 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=lists1p.gnu.org; Received-SPF: pass client-ip=212.248.84.144; envelope-from=mjt@tls.msk.ru; helo=isrv.corpit.ru X-Spam_score_int: -19 X-Spam_score: -2.0 X-Spam_bar: -- X-Spam_report: (-2.0 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-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 Precedence: list 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 @tls.msk.ru) X-ZM-MESSAGEID: 1796303587472158500 Content-Type: text/plain; charset="utf-8" Commit fbb87b0d358a "virtio-mmio: fix QUEUE_NUM_MAX" (v11.1.0) increased queue sizes for virtio-mmio device for older machine types to 1024. This commit were back-ported to older stable series (v10.0.13 and v11.0.5) incorrectly, increasing queue sizes not just for virtio-mmio but for all virtio devices. The result is that for non-mmio virtio devices with queues, migration from these broken versions to curren fails, since the destination expects smaller queue than 1024. Instead of making queue size tied to type of device and machine version, we can reallocate the queue at the load time to match the source. This way, there's no need to have fbb87b0d358a to compensate for the original bug either, as the queues will be adjusted on load. Resolves: https://gitlab.com/qemu-project/qemu/-/work_items/5042 Cc: qemu-stable@nongnu.org Signed-off-by: Michael Tokarev --- Compile-tested only, I haven't actually tried to perform migration. Also, this is my first change in this part of the code, so it might be completely out of sanity. hw/virtio/virtio.c | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/hw/virtio/virtio.c b/hw/virtio/virtio.c index c9f9e5b5116..d2583637cf0 100644 --- a/hw/virtio/virtio.c +++ b/hw/virtio/virtio.c @@ -3590,10 +3590,23 @@ virtio_load(VirtIODevice *vdev, QEMUFile *f, int ve= rsion_id) for (i =3D 0; i < num; i++) { vdev->vq[i].vring.num =3D qemu_get_be32(f); if (vdev->vq[i].vring.num > vdev->vq[i].vring.num_default) { - error_report("VQ %d vring.num %u exceeds allocated max %u", - i, vdev->vq[i].vring.num, - vdev->vq[i].vring.num_default); - return -1; + /* + * Some older stable releases (10.0.13+, 11.0.5+) always alloc= ated + * queue of size 1024 for all virtio devices, due to incorrect + * back-port of v11.1.0-rc1-50-ga5cff318f06c "virtio-mmio: fix + * QUEUE_NUM_MAX". Compensate for this by reallocating queue on + * load, but only for initially non-empty destination queues a= nd + * only for queue of source size 1024 as used by these version= s. + */ + if (!vdev->vq[i].vring.num_default || vdev->vq[i].vring.num != =3D 1024) { + error_report("VQ %d vring.num %u exceeds allocated max %u", + i, vdev->vq[i].vring.num, + vdev->vq[i].vring.num_default); + return -1; + } + g_free(vdev->vq[i].used_elems); + vdev->vq[i].used_elems =3D g_new0(VirtQueueElement, vdev->vq[i= ].vring.num); + vdev->vq[i].vring.num_default =3D vdev->vq[i].vring.num; } if (k->has_variable_vring_alignment) { vdev->vq[i].vring.align =3D qemu_get_be32(f); --=20 2.47.3