From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 990EF606A681 for ; Thu, 3 Dec 2026 14:04:24 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=h1ZWpgL0; dkim=pass (2048-bit key) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=google header.b=WKmyoz1J Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xZ7PO-0007DI-P7; Thu, 03 Dec 2026 09:03:44 -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 1xZ7OW-0007AI-FD for qemu-devel@nongnu.org; Thu, 03 Dec 2026 09:02:50 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xZ7OS-0000E1-MX for qemu-devel@nongnu.org; Thu, 03 Dec 2026 09:02:42 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1796306558; 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: in-reply-to:in-reply-to:references:references; bh=As72ysqZedgbr0E68tYNzsCNkC2ZTDg+4n2G44wx+Lg=; b=h1ZWpgL0/Ygd5gqpXxomwoPYLa78nNujWcSQw6ULqZcms8L72bb803tHwVIpoReuNYNySZ bIgqepH7K8BhRh+Nn1W3Vxq1renPW3ZSCgSsCz+vTwwSsxtLewC4/sNZH3vmiJ7Jn8gD28 0a9k9Fqwb/MRy9S7AxvnAeD9k5cAgxM= Received: from mail-wm1-f70.google.com (mail-wm1-f70.google.com [209.85.128.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-48-uliIsh_JNFi_rTaaQyTclQ-1; Thu, 3 Dec 2026 14:02:35 +0000 X-MC-Unique: uliIsh_JNFi_rTaaQyTclQ-1 X-Mimecast-MFC-AGG-ID: uliIsh_JNFi_rTaaQyTclQ_1796306554 Received: by mail-wm1-f70.google.com with SMTP id 5b1f17b1804b1-49953abe51fso102111135e9.1 for ; Thu, 03 Dec 2026 06:02:34 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=google; t=1796306553; x=1796911353; darn=nongnu.org; h=in-reply-to:content-disposition:content-type:mime-version :references:message-id:subject:cc:to:from:date:from:to:cc:subject :date:message-id:reply-to:content-type; bh=As72ysqZedgbr0E68tYNzsCNkC2ZTDg+4n2G44wx+Lg=; b=WKmyoz1J6Y1ZDKV8pdI3m15atTKdpuYUHGrZ4B1U10NpcnKY4YZ9coRsVmo1thAs+f /PHlNxRWtyVMhJpgaaI9x16DmyISBljOnQbdD6NO9ybYQlqlDiAgaoOcTSAftImLb6cX QZYHw86k6FVszrf7ASEQt/ZFDl9or0Yufsko4+qlKs0QwV3IHaTfhdYLnRylBcx4CoI9 5eqJkmgnRVtCuWHarZYzPkxHmLeQOOgXegz/8NBdw3B/yPNaba6Nf7P4P62gYHq4XGto Ci3pfnkVpgz9blOBxAJGj0WCXyjye7zvu3jpHx1Q4gDAdh8D3Vj0imcggSFCEISX7pME YhQg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1796306554; x=1796911354; h=in-reply-to:content-disposition:content-type:mime-version :references:message-id:subject:cc:to:from:date:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=As72ysqZedgbr0E68tYNzsCNkC2ZTDg+4n2G44wx+Lg=; b=bgD5UWBC8l5d2/jWehP3gr60/0K3RdcCh+0ah6lVqSFxa7rVcxrmpIfZj+QndR+JgL bg2Og6zFGB4wmo/JS1EIRG0Kg1Xa9MvWqtkjIBanbm2hxpfwq5uq7LQYodTcYjBunXub X1pmTAUDjJgRo5S6NI3AP9y65COX26J4EI0HtosytziZ6SP5BGqpCNByfaGl0UZddSWX JUYyBPp9tJ8Ve/O3/KriFT+UhW2nVixRgUNEWGapBPvU91IK4c9IWLc3wAPMDIc2PUIi bQC3J6gWv3TElv9DvAxsBLsbWBBk7YKFlRlH0Te62E5gVcZRRYLOIPBbMg72GMQruyWv I1qA== X-Gm-Message-State: APuU4Z9bFTer8hgKbBNaUFwb4F6+UyYwggY4iLrJsDeH6DtrqRlkW/2F 4fxghxdHHyWDrhrWcuDwqnPNvKYW9hZ9unyrv21O+SXfhjw0epwN6+efDi1uK8cqVN/BvmMiBOl blgintMILHvIe+0zdhZH0CU9v70CRCG4FB2TXJ77wYcebva6bT9SS7dHr X-Gm-Gg: AZFdTZeh/jUkC6bMjkzaB+MFL1dF9ni9OoTkaJHAAnB9xEWcO2XbCW7lSDr+AL1Um/R HfAkACvtaPOSYbulugkeHWY4R2adRNnRTfuwdukwi7kTneS1ozAdd2I/Hl+wpfgzfNIILxO2dz6 RD9GF0AtWgXczffWv7KDC253QmvLfLzoDSQbAIReKqcpQDnzdA3Y4uwZuPULyAM3bczkii7nSgt 0jnOAuy/ZJTKxjx0mdyXZgWg7at8CIaf8J5CinOUeZifbeBm+52yWSyFubtSb66Y0kCuE7msBRM ++0Qq+w7ZBjLrriw3a4QfDMAnNvvl4U11pFiLmVcN2P6LfXAG+rc3q1973lOeJ31ialfyUDjGJg hZ2Z5ct/9jdbZvgXbxhIiuvezrqT+175H7X+l8Oj/JA== X-Received: by 2002:a05:600c:4ec9:b0:4bb:6a5a:782d with SMTP id 5b1f17b1804b1-4bb88925fcdmr864564115e9.17.1796306553462; Thu, 03 Dec 2026 06:02:33 -0800 (PST) X-Received: by 2002:a05:600c:4ec9:b0:4bb:6a5a:782d with SMTP id 5b1f17b1804b1-4bb88925fcdmr864563615e9.17.1796306552827; Thu, 03 Dec 2026 06:02:32 -0800 (PST) Received: from redhat.com ([2a0d:6fc0:153a:4c00:6468:7acf:febf:a046]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-4ab6a680355sm70461533f8f.27.2026.12.03.06.02.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 03 Dec 2026 06:02:32 -0800 (PST) Date: Thu, 3 Dec 2026 09:02:27 -0500 From: "Michael S. Tsirkin" To: Michael Tokarev Cc: qemu-devel@nongnu.org, qemu-stable@nongnu.org, Peter Maydell , Daniel P =?iso-8859-1?Q?=2E_Berrang=E9?= Subject: Re: [RFC PATCH] virtio: compensate for incoming migration of virtio queues from broken stable series Message-ID: <20261203085900-mutt-send-email-mst@kernel.org> References: <20261203131137.3127943-1-mjt@tls.msk.ru> X-Archived-By: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20261203131137.3127943-1-mjt@tls.msk.ru> Received-SPF: pass client-ip=170.10.133.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -29 X-Spam_score: -3.0 X-Spam_bar: --- X-Spam_report: (-3.0 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.24, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 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: qemu development List-Archive: List-Post: List-Help: List-Subscribe: , Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org X-Spam-Status: No, score=-20.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI, MENTIONS_GIT_HOSTING,SPF_HELO_PASS,SPF_PASS autolearn=ham autolearn_force=no version=4.0.1 X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-26) on aws-us-west-2-korg-listserv-alma10-1 On Thu, Dec 03, 2026 at 04:11:37PM +0300, Michael Tokarev wrote: > 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 Fun times. And then people will complain that incoming migration can cause dos by drinking up unlimited memory. If we really have to, let's put this behind a machine compat flag that will just trigger for the broken machines. > --- > > 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 version_id) > for (i = 0; i < num; i++) { > vdev->vq[i].vring.num = 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 allocated > + * 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 and > + * only for queue of source size 1024 as used by these versions. > + */ > + if (!vdev->vq[i].vring.num_default || vdev->vq[i].vring.num != 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 = g_new0(VirtQueueElement, vdev->vq[i].vring.num); > + vdev->vq[i].vring.num_default = vdev->vq[i].vring.num; > } > if (k->has_variable_vring_alignment) { > vdev->vq[i].vring.align = qemu_get_be32(f); > -- > 2.47.3