From nobody Sat Sep 26 20:50:16 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=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1789085857; cv=none; d=zohomail.com; s=zohoarc; b=CoOWt5LoaeyAqwk1NvAJvsomCx/JwvkAeGkSArz70u46g4owaSCyzla6mvN9wiDM9JKUtujAPU72+VYpqOgu0p1PWvzcCGBeAGnBdirBFeInhTuFHVIitw4dcbNW+/en9vnOfG970odvkyv2qINwX/YHaiwgbiGUst7z5DNFhIc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1789085857; h=Content-Type: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=cY4K5hEbqA2jAPtmBdYZErh868yrTmlvKXQA8mwMwzI=; b=H54bwE0aEsFmpgnGNiaAAZpJrp5YG4BGYq89A3E+HbK3DqvCCqrG2a+FQc16cNkcgQyI9DZz/dwjTNsCjCgaOe5ZE/Or4Dq+R0lfeXetN0vKE4vgAooDnFKtt49RTBZ3p7XkJGS2g2pPfEk3JmXdgX4PPUSSdzaNn17sPhMZIcU= 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 lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1789085857029566.4336119442172; Thu, 10 Sep 2026 17:17:37 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1x4oug-0001md-1s; Thu, 10 Sep 2026 20:14:50 -0400 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 1x4lVp-0006Pr-Aw for qemu-devel@nongnu.org; Thu, 10 Sep 2026 16:37:03 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1x4lVf-0004hk-SL for qemu-devel@nongnu.org; Thu, 10 Sep 2026 16:36:45 -0400 Received: from mail-ua1-f71.google.com (mail-ua1-f71.google.com [209.85.222.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-599-zd5N0HjWNc6UdUOzGBhO0g-1; Thu, 10 Sep 2026 16:11:32 -0400 Received: by mail-ua1-f71.google.com with SMTP id a1e0cc1a2514c-97e98448895so90019241.0 for ; Thu, 10 Sep 2026 13:11:31 -0700 (PDT) Received: from redhat.com (IGLD-80-230-79-236.inter.net.il. [80.230.79.236]) by smtp.gmail.com with ESMTPSA id ada2fe7eead31-7927cbdf17fsm741239137.3.2026.09.10.13.11.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Sep 2026 13:11:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1789072563; 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=cY4K5hEbqA2jAPtmBdYZErh868yrTmlvKXQA8mwMwzI=; b=h0yINGtAtaSk4OiKy7QXXbK6RXSkVEUtKuEsgmofVcKlBQ4TrPzABSc+eqPYgnAVhp3RbR zi1V1R0ndEKh7YXXsGxYUEqzw8h/ufbXhhTsh+mOGHu5KctgJLmT6X5O7PdaXVJZs0sqsk 59RPGHemJuGAT4S/POvj+nEvukQofbE= X-MC-Unique: zd5N0HjWNc6UdUOzGBhO0g-1 X-Mimecast-MFC-AGG-ID: zd5N0HjWNc6UdUOzGBhO0g_1789071091 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=google; t=1789071091; x=1789675891; 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=cY4K5hEbqA2jAPtmBdYZErh868yrTmlvKXQA8mwMwzI=; b=X4YDPJwRzYGmKhWFtXGp/3RY/Ob99MF00y9DDMIO/i1CtJH5D/rMAeMu87rkCShb97 VJTtfdw2SQrQbgatuex64wiVK7DANaHs+lC4m7DKaZCo7lOHbK6gBON6Qb3FCWSh1M82 z+31FDV11Z9qkEwhA5jpmiSUfpy9kQQMLyTnlsC0bHOfwSd9up8UkyNZhW98GRnWmVHC g2kXVsBEaCr4nn7ky9sx0NYie6hrsDViVzXOMbFnhAhfK0keLJn/4AHk6wmTZW2WeSQx D6saosKEpwGEw2xjmlqe0faSojFqhTLZxRabaEb4kBSkGC650LPn0rFQRtxDAZIVGGPl eCRQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1789071091; x=1789675891; 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=cY4K5hEbqA2jAPtmBdYZErh868yrTmlvKXQA8mwMwzI=; b=spkrRfiIBzZypPyLWu2eVedh7VuoVcwhn2FX1CN+0g9NLxKlHabc72PuSO/D989W0o AQGBlCYO4PuitnmHYL8rS96dn+RvF5eZEL4PreC8jDFT733/KryeoZUmFUXg/RCDnJa6 FG58pC9uGCwuH4zwChzpbTsV/BsJ5M2jCopUrIMzLvtoGAbHSvzxoG2eAVLLc6FgBjNN QkdnPtgJKmcbie2oLX60xyx1NSfSG0oQXAe4VhGk+BTJTmUq623QyWMncADU7VZNB75/ KYMF8MKjnT8d7ds7AVcChQJgzcW8Wz7RrPaZSXFeJ0OxcTVRRQU2P/Ur3qQrE26WzyJ7 ls9w== X-Gm-Message-State: AFuF++kUhXZt1B/BEKu52T1KmAg4Ht7dk+taWao7aXrP0bGvmprnvxWk ih9fKoCqWTP8S8k8xdsUIKNj+jF99sQrModANA7oKgiXE45dpwapmTmXyi0tSaKwf2XKFGXMZ2f l+PTfEBW9WxHRtHXFwW8++Yo28pDaepenA+XEJCkoNEVwvHjEk7s4Y17KPApo1Uqy8NCRb40lsl EYvNiuT4b6SimT61SeecwvWhm6AIM0R75S7Q== X-Gm-Gg: AYBFou0Qs+PRKzbmxSj8t8LMy8xrkymDATQLGog/6j+h6Vjng0KRs3hdB/4vKYwWt/T 1+/IyfhWysjx6ciL3Cbc5nxCxBSXlCvZs5eG+xp1AJz+hHUzuHoFRkJim37pEyzkZXETXp2guR7 nND6kdSNXVFelM8lcDoTdXDqZyFS9iHbn17RJqrQwX+cXyc9g9LF8prl74QINK5e16iMHEZ82V1 nYOWXnZyG6kp/bMuf2qKw5FXzn2/C9IROYicefL3diQ2w13CsOEKuM1DFoQtj5++HT3o/9D3THH 1dRJJoLGdpNVXLuvD8053iHhJbMkXPg7rQ038Yv4jhY1cjdT6BGEl+D/F2Jqz0jm+oGMAY1sgIL 0cKCQIss9w+A3fyDkcTEwL14= X-Received: by 2002:a05:6102:61c5:10b0:78a:8a0:7126 with SMTP id ada2fe7eead31-792a93b099fmr1543301137.10.1789071090554; Thu, 10 Sep 2026 13:11:30 -0700 (PDT) X-Received: by 2002:a05:6102:61c5:10b0:78a:8a0:7126 with SMTP id ada2fe7eead31-792a93b099fmr1542650137.10.1789071085157; Thu, 10 Sep 2026 13:11:25 -0700 (PDT) Date: Thu, 10 Sep 2026 16:11:21 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Stefan Hajnoczi , Kevin Wolf , Hanna Reitz , Laurent Vivier , Amit Shah , =?utf-8?Q?Marc-Andr=C3=A9?= Lureau , Paolo Bonzini , Fam Zheng , qemu-block@nongnu.org Subject: [PULL 01/90] virtio: fix exit(1) on DMA mapping failure during migration restore Message-ID: <5ec2a0b21fe5b8e1419a94a753636088d6b0409b.1789071042.git.mst@redhat.com> References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-Mailer: git-send-email 2.51.2.2891.g4157995a80.dirty X-Mutt-Fcc: =sent 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=170.10.129.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com 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, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=0.001, SPF_HELO_PASS=-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-Zoho-Virus-Status: 1 X-Zoho-AV-Stamp: zmail-av-0.2.13.1.5.4/289.74.40 X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1789085858382158500 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" When QEMU restores pending virtio requests from a migration stream, it calls qemu_get_virtqueue_element(), which calls virtqueue_map() and virtqueue_map_iovec() to re-map the saved DMA fragment addresses into the destination address space. If the addresses in the migration stream are corrupted, and as a result dma_memory_map() returns NULL or a shorter-than-expected length, virtqueue_map_iovec() calls exit(1), terminating the destination QEMU process instead of failing the migration cleanly. Convert virtqueue_map_iovec() and virtqueue_map() from void to bool. On failure, virtqueue_map_iovec() unmaps any entries it has already mapped and returns false; virtqueue_map() similarly cleans up the in_sg entries if out_sg mapping fails. qemu_get_virtqueue_element() now checks the return value, frees the element and returns NULL on failure, allowing the migration restore path to propagate a clean error. The callers in virtio-blk, virtio-serial-bus and virtio-scsi that invoke qemu_get_virtqueue_element() during load are updated to check for NULL and return an error code. Fixes: 3b3b062821 ("virtio: slim down allocation of VirtQueueElements") Resolves: https://gitlab.com/qemu-project/qemu/-/work_items/3888 Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- include/hw/virtio/virtio.h | 2 +- hw/block/virtio-blk.c | 4 +++ hw/char/virtio-serial-bus.c | 4 +++ hw/scsi/virtio-scsi.c | 4 +++ hw/virtio/virtio.c | 49 +++++++++++++++++++++++++++---------- 5 files changed, 49 insertions(+), 14 deletions(-) diff --git a/include/hw/virtio/virtio.h b/include/hw/virtio/virtio.h index c99cb19d88..27c5fe3a6b 100644 --- a/include/hw/virtio/virtio.h +++ b/include/hw/virtio/virtio.h @@ -320,7 +320,7 @@ bool virtqueue_rewind(VirtQueue *vq, unsigned int num); void virtqueue_fill(VirtQueue *vq, const VirtQueueElement *elem, unsigned int len, unsigned int idx); =20 -void virtqueue_map(VirtIODevice *vdev, VirtQueueElement *elem); +bool virtqueue_map(VirtIODevice *vdev, VirtQueueElement *elem); void *virtqueue_pop(VirtQueue *vq, size_t sz); unsigned int virtqueue_drop_all(VirtQueue *vq); void *qemu_get_virtqueue_element(VirtIODevice *vdev, QEMUFile *f, size_t s= z); diff --git a/hw/block/virtio-blk.c b/hw/block/virtio-blk.c index 6b92066aff..cb6a276a82 100644 --- a/hw/block/virtio-blk.c +++ b/hw/block/virtio-blk.c @@ -1384,6 +1384,10 @@ static int virtio_blk_load_device(VirtIODevice *vdev= , QEMUFile *f, } =20 req =3D qemu_get_virtqueue_element(vdev, f, sizeof(VirtIOBlockReq)= ); + if (!req) { + error_report("Failed to restore virtio-blk request"); + return -EINVAL; + } virtio_blk_init_request(s, virtio_get_queue(vdev, vq_idx), req); =20 WITH_QEMU_LOCK_GUARD(&s->rq_lock) { diff --git a/hw/char/virtio-serial-bus.c b/hw/char/virtio-serial-bus.c index 83a033ce85..81db0bdc91 100644 --- a/hw/char/virtio-serial-bus.c +++ b/hw/char/virtio-serial-bus.c @@ -764,6 +764,10 @@ static int fetch_active_ports_list(QEMUFile *f, =20 port->elem =3D qemu_get_virtqueue_element(vdev, f, sizeof(VirtQueueElemen= t)); + if (!port->elem) { + error_report("Failed to restore virtio-serial element"); + return -EINVAL; + } =20 /* * Port was throttled on source machine. Let's diff --git a/hw/scsi/virtio-scsi.c b/hw/scsi/virtio-scsi.c index bf64d1231a..132f833226 100644 --- a/hw/scsi/virtio-scsi.c +++ b/hw/scsi/virtio-scsi.c @@ -274,6 +274,10 @@ static void *virtio_scsi_load_request(QEMUFile *f, SCS= IRequest *sreq) assert(n < vs->conf.num_queues); req =3D qemu_get_virtqueue_element(vdev, f, sizeof(VirtIOSCSIReq) + vs->cdb_size); + if (!req) { + error_report("Failed to restore virtio-scsi request"); + return NULL; + } virtio_scsi_init_req(s, vs->cmd_vqs[n], req); =20 if (virtio_scsi_parse_req(req, sizeof(VirtIOSCSICmdReq) + vs->cdb_size, diff --git a/hw/virtio/virtio.c b/hw/virtio/virtio.c index daa5607338..34f1df260b 100644 --- a/hw/virtio/virtio.c +++ b/hw/virtio/virtio.c @@ -1680,36 +1680,56 @@ static void virtqueue_undo_map_desc(AddressSpace *a= s, } } =20 -static void virtqueue_map_iovec(VirtIODevice *vdev, struct iovec *sg, +static bool virtqueue_map_iovec(VirtIODevice *vdev, struct iovec *sg, hwaddr *addr, unsigned int num_sg, bool is_write) { unsigned int i; hwaddr len; + DMADirection dir =3D is_write ? DMA_DIRECTION_FROM_DEVICE : + DMA_DIRECTION_TO_DEVICE; =20 for (i =3D 0; i < num_sg; i++) { len =3D sg[i].iov_len; - sg[i].iov_base =3D dma_memory_map(vdev->dma_as, - addr[i], &len, is_write ? - DMA_DIRECTION_FROM_DEVICE : - DMA_DIRECTION_TO_DEVICE, - MEMTXATTRS_UNSPECIFIED); + sg[i].iov_base =3D dma_memory_map(vdev->dma_as, addr[i], &len, + dir, MEMTXATTRS_UNSPECIFIED); if (!sg[i].iov_base) { error_report("virtio: error trying to map MMIO memory"); - exit(1); + goto err_undo_map; } if (len !=3D sg[i].iov_len) { error_report("virtio: unexpected memory split"); - exit(1); + dma_memory_unmap(vdev->dma_as, sg[i].iov_base, len, dir, 0); + goto err_undo_map; } } + return true; + +err_undo_map: + while (i-- > 0) { + dma_memory_unmap(vdev->dma_as, sg[i].iov_base, sg[i].iov_len, + dir, 0); + } + return false; } =20 -void virtqueue_map(VirtIODevice *vdev, VirtQueueElement *elem) +bool virtqueue_map(VirtIODevice *vdev, VirtQueueElement *elem) { - virtqueue_map_iovec(vdev, elem->in_sg, elem->in_addr, elem->in_num, tr= ue); - virtqueue_map_iovec(vdev, elem->out_sg, elem->out_addr, elem->out_num, - fa= lse); + if (!virtqueue_map_iovec(vdev, elem->in_sg, elem->in_addr, + elem->in_num, true)) { + return false; + } + if (!virtqueue_map_iovec(vdev, elem->out_sg, elem->out_addr, + elem->out_num, false)) { + unsigned int i; + for (i =3D 0; i < elem->in_num; i++) { + dma_memory_unmap(vdev->dma_as, elem->in_sg[i].iov_base, + elem->in_sg[i].iov_len, + DMA_DIRECTION_FROM_DEVICE, 0); + } + return false; + } + return true; } =20 static void *virtqueue_alloc_element(size_t sz, unsigned out_num, unsigned= in_num) @@ -2206,7 +2226,10 @@ void *qemu_get_virtqueue_element(VirtIODevice *vdev,= QEMUFile *f, size_t sz) qemu_get_be32s(f, &elem->ndescs); } =20 - virtqueue_map(vdev, elem); + if (!virtqueue_map(vdev, elem)) { + g_free(elem); + return NULL; + } return elem; } =20 --=20 MST From nobody Sat Sep 26 20:50:16 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=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1789084985; cv=none; d=zohomail.com; s=zohoarc; b=CMZL6gTN27YClc+Bxkim2wxbtHvep7TQ2E+lZ25GebI2UkdyG0NG75EZVfwfaIxPnqS3VZhhIKGhgHWfOLLrbh3v0oIocl2UNbVYpHkikf0FIMfLyv3L2KHDwA5YzWk2dsb/GyvAFAsuz/yVcPYh3URgeeGiMYi3pkgZZxfYkL4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1789084985; h=Content-Type: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=P/dt9G1EklZEpM1Y9s4cFZiMEKzuwD4r1pjdVZY4uXc=; b=jXnm/5Wq9m792E9z+PLNlYJ73H9CwaNQOsE87kCFim0RwHQAy03NmHl/CuxxEwuLVpTNK/vfhdYqsjGchIFGqw6XnAAjR6GexiFqxGnDSwQtBzpLHNacQiqE/fMKYr77X4x3zx0EHAOCZ1CrHgyzIqIPvDmB1VDnBnlnFIzRAYc= 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 lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1789084985765432.8446812406577; Thu, 10 Sep 2026 17:03:05 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1x4oeQ-0005gO-TA; Thu, 10 Sep 2026 19:58:12 -0400 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 1x4lX0-0006dY-RZ for qemu-devel@nongnu.org; Thu, 10 Sep 2026 16:38:15 -0400 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 1x4lWh-0004Rp-Od for qemu-devel@nongnu.org; Thu, 10 Sep 2026 16:37:55 -0400 Received: from mail-lf1-f70.google.com (mail-lf1-f70.google.com [209.85.167.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-572-UEXuqf0fNRKEs0cwut_nHA-1; Thu, 10 Sep 2026 16:11:30 -0400 Received: by mail-lf1-f70.google.com with SMTP id 2adb3069b0e04-5b667b38b04so303881e87.2 for ; Thu, 10 Sep 2026 13:11:29 -0700 (PDT) Received: from redhat.com (IGLD-80-230-79-236.inter.net.il. [80.230.79.236]) by smtp.gmail.com with ESMTPSA id 2adb3069b0e04-5b8a03a76a6sm115004e87.9.2026.09.10.13.11.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Sep 2026 13:11:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1789072503; 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=P/dt9G1EklZEpM1Y9s4cFZiMEKzuwD4r1pjdVZY4uXc=; b=D7O9GGQGMWUmnABpNt1Thng0A71krWYM7y5Lxf/o4cxbIn/2iEq0fjGR41S8hudZvA7J51 6XtDTPrtc3tLxD39i9Nz/eszziLN46qVaNLUxQGJAgiiItG5/V+HKQyZFEwiqqjpuEOTAW mY7kO6eONbHH+DLubjVrhhGdlaOdaOk= X-MC-Unique: UEXuqf0fNRKEs0cwut_nHA-1 X-Mimecast-MFC-AGG-ID: UEXuqf0fNRKEs0cwut_nHA_1789071089 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=google; t=1789071089; x=1789675889; 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=P/dt9G1EklZEpM1Y9s4cFZiMEKzuwD4r1pjdVZY4uXc=; b=VfoR9VIoTcVahXoA/YVfZXHipLMgEZHwVfp2irdfKS0ff+wcsVnxPUAxAR5iHX7FOV UKTYQQX5W1CdWnxhc0lAreAuVGtLsU2ASCOVpc+CFR9EPySmOH9TQidK/uv+vFCv+W/u Jhc0OwOcEeCsuCftxP52inO5ZR6Atm8llz8cmxepYIPQSOZu1gFYvB6FKWglzGMdefwz GSwQAHISFAhoHRX1YW2c3Ccfmks9jqX3h15dAkloVJku0iwxRA+6fyNmvsVWvC8oURRq H8kDRhtNU8mKMtfddZYxCLaRdDh+GfY+hNA7JBSF+XDzQUqq0MXJS8QzE8fhP3sCD751 Z9gA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1789071089; x=1789675889; 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=P/dt9G1EklZEpM1Y9s4cFZiMEKzuwD4r1pjdVZY4uXc=; b=DQo6sSQSgNnZLVHMn3zR+yMsBCYAqvDR2/3/P4riL+GZ4FPs7DKZBO8gchuCu0VFRR pf/wnZ79g+xt4qmDAwv10ZJlotlV5bpq96QJU0LRTyAEsr6w2BPCEUL/VcgCzYaMv4ZC LwF9KGpbRFgrIaaHGo5srHmxLEDsKVCZpzEVe27a7Dkn3MwSfJ0LCwtyu8U8P35768Eh HtzsLNbS1sIS6CM/UarGEq3A7cgD9cC+rUfYJWb6uYl7nuvfCv8H8v83x/i39ab/4iEz 3Fgwp26iV7qWEs0NmJroNgtibCpy5XKKYRS31wcgj/C1R28Ja4kfKXKhz/67JZN5FXns 2QGA== X-Gm-Message-State: AFuF++kgcOV5PnGh2elrLbXn0R0aIB/ixsj91DxOmTKflPeILHx5qqP2 E7hEkOJtX5SnSNmrV8p/NvVcElfN/SqSdx9+7EmIWdxYx+Ta/0Hf+WPOhsgGI3Dfx5TZ/3zlC7J fwWa3zQ66T7kcmR3m9nsOrR4H3bIDYDRMwmaiz/ABnRS64JMrzC+qn84BjL13dUSesW0Xb46Fpz v3jJ1OHqSjI7W8LshSOxHwm9CrsDBg2frLgQ== X-Gm-Gg: AYBFou13T6Ew7Q1ng/NnaNuZ+IBsPhELPZZP53VBlCbaGu8Mq7EEQzTk4hF0fnCtQdT E/tV94e1xHqDrpAqIz+GtemZiB5+ZK9eHFUGvrecNLwRhkAg738/J65K8RTfd+HchZ80qBmtC1z ASzFBb9YFTyaHNKfTbX2oyRBWOYoGMH4Q1Gw4BXhqLfiSesHBAn+NDlRhMiMYvNJqua9G/tpD/l wzfg6Mt2HNpdECpzyJzss3GhOKQCszonK2SwAIId6DhHOLR1CvHE3c2Mam5JXDTKabbFdJ/6fJm mOSVQNSYpcjKAb3p0AXV4mZbm7jdfByZ6iHR8RBVX9j1+FWUYxH5o6w5XgfriWTCgNW0MLQPPBj o4tijR04OAwtNub2FJjxH+x4= X-Received: by 2002:a05:6512:1296:b0:5b6:183c:5ca2 with SMTP id 2adb3069b0e04-5b8a032db71mr187416e87.64.1789071088633; Thu, 10 Sep 2026 13:11:28 -0700 (PDT) X-Received: by 2002:a05:6512:1296:b0:5b6:183c:5ca2 with SMTP id 2adb3069b0e04-5b8a032db71mr187405e87.64.1789071088087; Thu, 10 Sep 2026 13:11:28 -0700 (PDT) Date: Thu, 10 Sep 2026 16:11:25 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , "Dr. David Alan Gilbert" Subject: [PULL 02/90] virtio: fix config_len DoS in migration restore path Message-ID: <2b35ded9c235145cfb31a8553b29e6faf65899fb.1789071042.git.mst@redhat.com> References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-Mailer: git-send-email 2.51.2.2891.g4157995a80.dirty X-Mutt-Fcc: =sent 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=170.10.133.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com 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, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_PASS=-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-Zoho-Virus-Status: 1 X-Zoho-AV-Stamp: zmail-av-0.2.13.1.5.4/289.74.40 X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1789084986966158500 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" virtio_load() reads config_len from the migration stream into a local int32_t variable and then, if the incoming length exceeds the device's own config size, skips the surplus one byte at a time in a loop. Two defects in this loop allow a malicious or truncated migration stream to cause a prolonged CPU spin on the destination QEMU. First, the local variable is int32_t while vdev->config_len is size_t. The C standard converts the signed operand to the unsigned type for the comparison, so any value with the high bit set becomes a very large size_t that exceeds the device config length. The loop then counts the signed counter down through all negative values and back around, effectively running for up to 2^32 iterations. Second, once the file stream reaches EOF, qemu_get_byte() returns 0 without advancing the read position. Without a check for file errors, the loop spins until the counter reaches the device config length. An attacker who sends a large config_len and then closes the stream can hold the destination QEMU busy for attacker-controlled time. Change the local config_len to uint32_t so that the comparison with size_t is unsigned and values with the high bit set are treated as large-but-finite skip counts. In addition, check qemu_file_get_error() after each byte read and return failure immediately when the stream signals EOF or an I/O error. Fixes: 2f5732e964 ("Allow mismatched virtio config-len") Cc: Dr. David Alan Gilbert Resolves: https://gitlab.com/qemu-project/qemu/-/work_items/3891 Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- hw/virtio/virtio.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/hw/virtio/virtio.c b/hw/virtio/virtio.c index 34f1df260b..848fe8539e 100644 --- a/hw/virtio/virtio.c +++ b/hw/virtio/virtio.c @@ -3584,6 +3584,9 @@ virtio_load(VirtIODevice *vdev, QEMUFile *f, int vers= ion_id) return -1; } qemu_get_byte(f); + if (qemu_file_get_error(f)) { + return -1; + } config_len--; } =20 --=20 MST From nobody Sat Sep 26 20:50:16 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=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1789086387; cv=none; d=zohomail.com; s=zohoarc; b=IrNjVVepkDXx/gj/a+BitJgKS+pJfiAM0LT0T5meyYBVfHrf9IhN3ie33UPzRsh5+cnGEOSiRX6djb0YlM3JUjJ6hL6F3iMTZqTBoJer+NxHU+u8XneGsDtvpUSwZ77ZQ5YhNHargPmGXTYvMVh73hT0ndhlxiwdWOh8dnWnV/w= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1789086387; h=Content-Type: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=cztzzK3RRsXNvSO1Mj0DbxdXP/qmCz45hPp6THADzZ0=; b=XT/wQNI46XAOK8Vm1C5mgU9qvX9D/WseEAJG0rRZuer5igo9RPlewijkZq9SREXZnpubtRHuTQaZR5lY5kDw21GOVBbhumnJFs7IBLSHAQFvi9S7uTCVPuBWeLzFo5+9Tc571mLXmG17QzheZirVitNFCCzHRb15q6o/YUS2mQ8= 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 lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1789086387457219.1327349765645; Thu, 10 Sep 2026 17:26:27 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1x4ot5-0001RF-OA; Thu, 10 Sep 2026 20:13:09 -0400 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 1x4lXR-0006iB-M6 for qemu-devel@nongnu.org; Thu, 10 Sep 2026 16:38:36 -0400 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 1x4lXB-0004Ro-9C for qemu-devel@nongnu.org; Thu, 10 Sep 2026 16:38:21 -0400 Received: from mail-wr1-f72.google.com (mail-wr1-f72.google.com [209.85.221.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-613-DHfwrLzROryMdYv6gMcRrQ-1; Thu, 10 Sep 2026 16:11:32 -0400 Received: by mail-wr1-f72.google.com with SMTP id ffacd0b85a97d-48439eea716so54490f8f.2 for ; Thu, 10 Sep 2026 13:11:31 -0700 (PDT) Received: from redhat.com (IGLD-80-230-79-236.inter.net.il. [80.230.79.236]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-486eb360409sm707483f8f.36.2026.09.10.13.11.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Sep 2026 13:11:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1789072503; 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=cztzzK3RRsXNvSO1Mj0DbxdXP/qmCz45hPp6THADzZ0=; b=KX0rCiOavBbqErHmWmDq27Y79O/fF6s9opmyIhk5m27KinZRH53cyK/gJHFmR2Y++Sbh8Q s1EwecqTF35f5zzL5vylLJaaEsvAIGwdDa7zFG8Dpa+kq2xvYdI5DWgohh1wWjhT74o+Fd c9pFt/13zxn34feyQO/4eZwbAXS6wQU= X-MC-Unique: DHfwrLzROryMdYv6gMcRrQ-1 X-Mimecast-MFC-AGG-ID: DHfwrLzROryMdYv6gMcRrQ_1789071091 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=google; t=1789071091; x=1789675891; 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=cztzzK3RRsXNvSO1Mj0DbxdXP/qmCz45hPp6THADzZ0=; b=obM2euD31cDujhvkapkycCxbQBDlmf3E6uhatnKkncCBiQ3UnPmClAx95HOKriOQmX bRfUKbhU1OV1HOqlbtR5n0eCJE4yEX12dNaB7pW+niYjEOYCJWAieTSvV9ZKLg2QBhN6 ja0FhRT6F3N+qwNhaqN/sXmhWinbZGmGp6jQh/1SOmpYESdcJyTIunrmRhNiuzSgQwSS a70tWXKY3r00DCoAkejos+zY+wg2Z698FB9K/14wIve/DfSFivx4XqQAcjNBFz8q7wka JmA0tcyLKfgMBK9+czrBEbuteTH43im9DEXgNI8zJI1FMFuk/bOLiELdDSN55PEWNkz0 iMjw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1789071091; x=1789675891; 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=cztzzK3RRsXNvSO1Mj0DbxdXP/qmCz45hPp6THADzZ0=; b=Jgjr2+oazSP1b3KsqNCzOKky1bC1hVj86TRFE7VK2+2Ep//pLl09joBz4KzmMujunf pxxvLHbS3T2Zr/cz23j7m/0AM3XiAygpCZPxjcAVqEd9Su1WViACM1x94d2AOiiA4KOP feF0s+jgtrn4MV2MwfNWsMxdNkWPgl5Rj9QGgyWwWN8kHhpKt76yskhpES8oLU4biKJy Au7yooImCoLUuis99AAygKo8ZWE4RLxTi6Aj8WzT+LMZEXUOhAENP9Zw+6XRhktQCRJM aN6VpWEqxyzhZ4CdEV7kFEkVtOmBAEvdnXQNZM273BtL5HCvSlApS3f4qyBXqIkFHsx4 oi3w== X-Gm-Message-State: AFuF++miJhOEbPZtryuPH7WjZtNDarP/zekZ26N+DFGFi20l/TKUyh88 ctoXGSv6CP9fIokgmSemnXeS25lot+b/5APOK6YbWC04SerrT6SDMTXrWL0HPw4VH/ONFBOwuae vKCWGxdrjGm1DtkvHxw4yMRQtHuL/h6mgpjbjwUOXzhTfnmbdS4gVB7Z3eByjNIbs8+p+rhCFDu zQLSPXPEnvHzZKOmFyxlMYEMRXlcXuc9GS6Q== X-Gm-Gg: AYBFou00+9EGYzgVn4dKXyT455vp2e0+H9VigST87FCP6GltYCv5GwvkQANpoimumNo BkPUpNIx4IgTVrBAR0kfRwTfmCYAUxfhO9J11BVYbnUUbA6Kzb6g4unyIEPxkbwWodXsYpv1kmX YZR9zwbGmX5sQv1tJLgNgUqW1YgVbzyzJW3SpY7nC6PO/WZL9LtUoU1T+A+7P90UiSyAWyW0bt0 MKIRMLfZATd2A2chlKznoCB8Gg4U8jz4y9ZlWaorSrpQgG97UZDtqvBghFLVXk5jNCZo8qChOjK MlH9y/fDHhVojN+azaF5fUFhyftYAadwQgWpHIsnha1a6cpJeZGXiYpTjq7/tdx/56em1XBS5PP PIGC0+9L5fKnRHckscAQWwA0= X-Received: by 2002:a05:6000:2005:b0:485:8fb5:20e2 with SMTP id ffacd0b85a97d-486eafd5fe0mr723645f8f.12.1789071090764; Thu, 10 Sep 2026 13:11:30 -0700 (PDT) X-Received: by 2002:a05:6000:2005:b0:485:8fb5:20e2 with SMTP id ffacd0b85a97d-486eafd5fe0mr723592f8f.12.1789071090173; Thu, 10 Sep 2026 13:11:30 -0700 (PDT) Date: Thu, 10 Sep 2026 16:11:28 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Kangjie Xu Subject: [PULL 03/90] virtio-pci: reject Q_ENABLE write on already-enabled queue Message-ID: <62976e8a2ea7fcc8c635754739fbaf2c499dc754.1789071042.git.mst@redhat.com> References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-Mailer: git-send-email 2.51.2.2891.g4157995a80.dirty X-Mutt-Fcc: =sent 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=170.10.133.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com 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, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_PASS=-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-Zoho-Virus-Status: 1 X-Zoho-AV-Stamp: zmail-av-0.2.13.1.5.4/289.74.40 X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1789086388289158500 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" When the guest writes 1 to the VIRTIO_PCI_COMMON_Q_ENABLE field of a queue that is already enabled, QEMU re-applies the ring geometry stored in the PCI proxy shadow registers by calling virtio_queue_set_num() and virtio_queue_set_rings(). Those functions update the vring descriptor, available, and used addresses and the region cache, but they do not touch the host-side progress fields - last_avail_idx, shadow_avail_idx, used_idx, inuse, and the packed-ring wrap counters - which are only zeroed by __virtio_queue_reset(). Because the progress indices are stale while the ring layout is new, the host can treat the new ring as though there are up to 65535 pending descriptors already waiting, causing virtqueue_pop() to iterate far beyond what the guest actually posted. On virtio-iommu this translates into a stream of ATTACH/DETACH/MAP/UNMAP commands, driving the QEMU process toward OOM from guest-controlled BAR writes. The virtio specification requires the driver to complete a full queue reset cycle before re-enabling a queue. Fix this by checking the proxy's per-queue enabled flag before processing the write. If the queue is already enabled, log the violation as a guest error and ignore the write. Fixes: d1060e3dc5 ("virtio-pci: support queue enable") Cc: Kangjie Xu Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- hw/virtio/virtio-pci.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/hw/virtio/virtio-pci.c b/hw/virtio/virtio-pci.c index 6f5db5fc42..c73f1f546c 100644 --- a/hw/virtio/virtio-pci.c +++ b/hw/virtio/virtio-pci.c @@ -1692,6 +1692,13 @@ static void virtio_pci_common_write(void *opaque, hw= addr addr, break; case VIRTIO_PCI_COMMON_Q_ENABLE: if (val =3D=3D 1) { + if (proxy->vqs[vdev->queue_sel].enabled) { + qemu_log_mask(LOG_GUEST_ERROR, + "%s: queue %d already enabled - " + "reset queue before re-enabling\n", + __func__, vdev->queue_sel); + break; + } virtio_queue_set_num(vdev, vdev->queue_sel, proxy->vqs[vdev->queue_sel].num); virtio_queue_set_rings(vdev, vdev->queue_sel, --=20 MST From nobody Sat Sep 26 20:50:16 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=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1789084446; cv=none; d=zohomail.com; s=zohoarc; b=Zbc2u87jDzWfwUwWVvtbCjiFjlP9wUF1JC4OqixE7fQv2gY6T9VtnnCsUXIrBOLhP2KboJkrLvh5bTXBRYGSDzNSEUrQlqUEPyfF8Q2r0xa0m6irRKSCc+VpaOX1k+02D7+Wfj5U6lamLyLxzxpgTQM8YyIk0i5pF1utZYA5gQA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1789084446; h=Content-Type: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=duT8sfy/1vmAKnbU6GKLoZk3/IV53fEkN7T7OylyeSg=; b=aNzrTmYzHfzsAxICe+laItq/YGG9/VHrhGhh6Mkhm6b/JtxP+T9v+OpsK+VJg8rrvLr/wrb83xQlE6FdYu2DX8gGqMN7iFZ+ntecLo6TL9WMajH0wdMAfHvv6+YSpsYhu5JmtlHyb+mVBeE/bsnwkzsE8hD7+w0CzBKQO9Bhdrk= 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 lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1789084446332628.5082399368947; Thu, 10 Sep 2026 16:54:06 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1x4o3M-0003MZ-5Z; Thu, 10 Sep 2026 19:19:43 -0400 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 1x4lVh-0006PK-Rt for qemu-devel@nongnu.org; Thu, 10 Sep 2026 16:36:48 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1x4lVV-0004V9-2I for qemu-devel@nongnu.org; Thu, 10 Sep 2026 16:36:35 -0400 Received: from mail-wr1-f69.google.com (mail-wr1-f69.google.com [209.85.221.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-122-BHsiNiuwN5SANcj84uYzxw-1; Thu, 10 Sep 2026 16:11:35 -0400 Received: by mail-wr1-f69.google.com with SMTP id ffacd0b85a97d-485f6788029so99764f8f.1 for ; Thu, 10 Sep 2026 13:11:34 -0700 (PDT) Received: from redhat.com (IGLD-80-230-79-236.inter.net.il. [80.230.79.236]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-486eb32e7f5sm839873f8f.9.2026.09.10.13.11.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Sep 2026 13:11:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1789072509; 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=duT8sfy/1vmAKnbU6GKLoZk3/IV53fEkN7T7OylyeSg=; b=S1qSnFHW5/Z5n3cj34nTdqqxbLo2Lhyqd0nEniGoXl4zVQV/cl/RVrBi3p/r+gSlb3yRYD ZZq1GnV71DnV0gTBVJxGSQ4/4GWK/j6i9/jzlYlLtZl83E6h8BNer9Km/jKj8u8UMf4KMC PmjSB1DJ9n5GmeqeEx7Tkl0LOfZ66vU= X-MC-Unique: BHsiNiuwN5SANcj84uYzxw-1 X-Mimecast-MFC-AGG-ID: BHsiNiuwN5SANcj84uYzxw_1789071094 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=google; t=1789071094; x=1789675894; 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=duT8sfy/1vmAKnbU6GKLoZk3/IV53fEkN7T7OylyeSg=; b=QOSFWrES8I3JCObd9bhSm4Ll4YvdlzQLEPv1VIYfwD0Hj91jy2yrsRyiOTU0Md1RAR cHAIiwZkpjXUmeSa2euEaanTXhT7xl4yNgcOqD+JtLN8LHQCjHvS1BqVsSsMZDxYca0j JJjIlSa8blWBLTAmXl8JRFEpdkZ49ELWGQcOHrF3NscADXcfcLDWGrcWCYxN888Q2iqm bonKc2Eu1wEYsyZdgShUQqzkN2uPmZkEPUK85UxZcVTeTtu0pmIsPla6hUbj1+wX5Euc ZB6ckbTwUnUuApNCnjfyVfbLuCIFBv7lhPv2IxfjuKqrUEbE4hqBIOHl6Cj3NTxgIT6F rCqw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1789071094; x=1789675894; 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=duT8sfy/1vmAKnbU6GKLoZk3/IV53fEkN7T7OylyeSg=; b=pT/jM1dJr/eaGeuZ4b+eQSM/Ew+F4dIsm9pTwUeKMXl6u8lWY/WL9oCpBtt6YSpUVO jZLMqWeRfvx9pm0VW6Er2Ylb6UKjeFCeXyhIxAc25FLsbi7R+ezAZDNxBneOny9KYNoa ZxHO8CqAmjpD2+MxW4jYbv9AhEnDJ8eOf3Vb/DTdaw9Ie1hQShVV/9K/7XiJ8l4zcmIe 8ikl7NPBQEuJm77l063W5hHaYKYU4oz7BD6a+Oq3UJQU31IqF71oBKF6TZ6daujFKZvm UNA09GZOUsv9TCCmqSo7PNsTZP+py+JWjKfH7s5GOnTI16rouBlBOXJimnE7AaRLyIiG HWLg== X-Gm-Message-State: AFuF++lQ6RnM1BfcsGuWn/7mPQicpywY61quAyr+LJu2Bm31wSGDJsR2 qNb38vs1mRgeMuZNtLbC3IlUZ8ZXgnuYs+7V3r70dBylc4u8sg8a7JCh8FrQqgHypY/N2+rUOjN QjMDqu92IN/pT4iBIb8SPIA9rbhyYmpAG4AZf+nFVEo1mOpvlal6+1rE9F6CP++x/viQHmUOWI0 Ub3Yji2FDYAWlewQq/JAVy1rn5cpAcmgGCsg== X-Gm-Gg: AYBFou1qljtzsTMWvqDBsQv21S8OGHfuXTitcj2XemLNkoDBu5vE7lV/S0TgA6wzRvt rrtGMFQRE4LFGLKPUkZE7PnVUIFAEwmcfu7ljHZehFwVBhJli00rMx+Dit93/cucgplDgyV6v6+ p2j7WhlxKIOCumbhYR345i7h1a8xkfbDVkugh8CxMX9x0aWvjPJt2rVrMDiYmupXKLCYeuHDebi vhRMpnxkrGqgMooPjHFnFKGHMD+SmumVMrm9NhcWIajNjIFDQj+LKgtbY8T/MOTrs92OLftHvTu pFtMeScJ+UStNEvoCymJyJ/yNcOKFfiDqMO0ITHI1G6LVclf7Hi4aNm9GliQuVE0LX9nzNq1Nh5 +8V/3affRjn8xt7cD/dYHrCo= X-Received: by 2002:a05:6000:4541:b0:47f:9254:d453 with SMTP id ffacd0b85a97d-486eb2db733mr1044069f8f.8.1789071093723; Thu, 10 Sep 2026 13:11:33 -0700 (PDT) X-Received: by 2002:a05:6000:4541:b0:47f:9254:d453 with SMTP id ffacd0b85a97d-486eb2db733mr1044003f8f.8.1789071093177; Thu, 10 Sep 2026 13:11:33 -0700 (PDT) Date: Thu, 10 Sep 2026 16:11:30 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Junjie Cao , qemu-stable@nongnu.org, Jonathan Cameron , linux-cxl@vger.kernel.org Subject: [PULL 04/90] hw/cxl: Fix guest-triggerable QEMU exit on reserved interleave ways Message-ID: <713e7e85a2b43e9d4e58d91643aef230d2c30b07.1789071042.git.mst@redhat.com> References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-Mailer: git-send-email 2.51.2.2891.g4157995a80.dirty X-Mutt-Fcc: =sent 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=170.10.129.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com 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, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=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-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-Zoho-Virus-Status: 1 X-Zoho-AV-Stamp: zmail-av-0.2.13.1.5.4/289.74.40 X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1789084448453158500 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Junjie Cao A buggy or malicious guest can program a committed HDM decoder with a reserved Interleave Ways encoding (e.g. 0x5-0x7, 0xb-0xf). Two call sites pass &error_fatal to cxl_interleave_ways_dec(), which calls exit(1) on the reserved encoding before the subsequent decoded_iw =3D=3D 0 guards can run: - cxl-host.c update_non_interleaved(): called at commit time from hdm_decoder_commit() via cfmws_update_non_interleaved(), so a guest writing COMMIT with a reserved IW terminates QEMU immediately. This is the primary trigger on the current tree. - cxl_type3.c cxl_type3_dpa(): called on memory access while iterating past committed decoders to accumulate dpa_base. Once the commit-time exit is removed, the decoder stays committed with the reserved encoding, so a later guest access outside that decoder's range would otherwise hit this second &error_fatal; both are fixed here. Pass NULL instead of &error_fatal at both sites so that the reserved encoding returns zero and the existing guards handle it gracefully. This can be reproduced by writing the HDM Decoder 0 Control register with a reserved IW encoding and the COMMIT bit set (e.g. IW=3D0x5, COMMIT=3D1). Cc: qemu-stable@nongnu.org Fixes: 680935c9a6ff ("hw/cxl: Add a performant (and correct) path for the n= on interleaved cases") Fixes: 48461825af1b ("hw/mem/cxl_type3: Fix potential divide by zero report= ed by coverity") Signed-off-by: Junjie Cao Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin Message-ID: <20260618104316.557306-1-junjie.cao@intel.com> --- hw/cxl/cxl-host.c | 2 +- hw/mem/cxl_type3.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/hw/cxl/cxl-host.c b/hw/cxl/cxl-host.c index eba13c9e7c..369a985f9b 100644 --- a/hw/cxl/cxl-host.c +++ b/hw/cxl/cxl-host.c @@ -442,7 +442,7 @@ static int update_non_interleaved(Object *obj, void *op= aque) } } =20 - interleave_ways_dec =3D cxl_interleave_ways_dec(iw, &error_fatal); + interleave_ways_dec =3D cxl_interleave_ways_dec(iw, NULL); if (interleave_ways_dec =3D=3D 0) { return 0; } diff --git a/hw/mem/cxl_type3.c b/hw/mem/cxl_type3.c index 28f41fa623..6f44770db6 100644 --- a/hw/mem/cxl_type3.c +++ b/hw/mem/cxl_type3.c @@ -1200,7 +1200,7 @@ static bool cxl_type3_dpa(CXLType3Dev *ct3d, hwaddr h= ost_addr, uint64_t *dpa) } if (((uint64_t)host_addr < decoder_base) || (hpa_offset >=3D decoder_size)) { - int decoded_iw =3D cxl_interleave_ways_dec(iw, &error_fatal); + int decoded_iw =3D cxl_interleave_ways_dec(iw, NULL); =20 if (decoded_iw =3D=3D 0) { return false; --=20 MST From nobody Sat Sep 26 20:50:16 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=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1789082163; cv=none; d=zohomail.com; s=zohoarc; b=O42foAFI4pdBq3c7P7oAsrm3bn+pHKOt4D+ih8gi4euibTGZ1kiDaVUseCWVj0+ycSZ82KqY0pV6ri9l4fIaEIUStPUkTrE/7xDQW4pUgri9+sqeessPWt83QtrqWqZ2T6QoIXSTkMomDfqTAKPNEPSPYaK4TKfi+OssXZfHoWQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1789082163; h=Content-Type: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=6kSbe3EQQwukUniN5j1YO+Sdv0dG67Pln7DjT7x+CNQ=; b=ctNAvpy5DxplPUbXV9A7hEwnGprhjU034mzQxLvEwCmjDYPULhYBW7A/94aicTs8MINxMAVqMlQTzNGLVW9dTjDLYTI64w7TwfvRh9PHtTvUunr71poCUXyGnP6xY65SVaDOPxrCpCOLdqw5hQPNuNyhr5/PgHsLzzmbbBcBITY= 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 lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1789082163771945.9885700965434; Thu, 10 Sep 2026 16:16:03 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1x4nxi-0001MJ-N5; Thu, 10 Sep 2026 19:14:18 -0400 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 1x4lj1-0001Qy-V2 for qemu-devel@nongnu.org; Thu, 10 Sep 2026 16:50:41 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1x4liq-0006NS-34 for qemu-devel@nongnu.org; Thu, 10 Sep 2026 16:50:20 -0400 Received: from mail-wr1-f71.google.com (mail-wr1-f71.google.com [209.85.221.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-342-aP7WvBgFM1qYbFA-9iT1yg-1; Thu, 10 Sep 2026 16:11:37 -0400 Received: by mail-wr1-f71.google.com with SMTP id ffacd0b85a97d-486e8fb7d75so35323f8f.0 for ; Thu, 10 Sep 2026 13:11:36 -0700 (PDT) Received: from redhat.com (IGLD-80-230-79-236.inter.net.il. [80.230.79.236]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-486eb32e7d4sm904984f8f.8.2026.09.10.13.11.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Sep 2026 13:11:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1789073414; 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=6kSbe3EQQwukUniN5j1YO+Sdv0dG67Pln7DjT7x+CNQ=; b=IBCPaEw0D1E17zKr4JIMsK5J84F51LkS3yEeEFlGuVytI0uVuizFg9JU3saADzLCHM0Y5y 9iJQqoFb2gQauQkpN1PjzC/67wv7/uRR4pl2KQRit0l0kt4EkSLpTAFSkQOG2M+EGHPZYD rWmrnvQbxd4DuWvoFJMGxigRNjk/Dwo= X-MC-Unique: aP7WvBgFM1qYbFA-9iT1yg-1 X-Mimecast-MFC-AGG-ID: aP7WvBgFM1qYbFA-9iT1yg_1789071096 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=google; t=1789071096; x=1789675896; 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=6kSbe3EQQwukUniN5j1YO+Sdv0dG67Pln7DjT7x+CNQ=; b=IGkzX0nxQLJfSUKzVtjOf8tIl9B1B7Rw2il3uyZNrrNICFuYg/vsM4AZOT0p8OZ59F ufARGPrkLAZe+qJtpzlLX2RDR4RbplJdxpTr5FjqGvv605z/gSgA87LPmyIqc+yMXfZL JAWAwxmhOK2+DfASI1rbQNVhxjWklZkeTnM3SxuuYySZgU5vdIaEL2hNE7gnAvsFb8rM hg6dxWKTXJkJr7n6hQi/dK+Gg5OkxxLNIkXqA2sAIUwbj1aR5vDBj2ZC/EnMZkjhYE2M pelH3tqQUuFr737LKZa/8KEk9ebkf+A9QZclXbqYwqR86xBotugau8E8LlGme8SiTw2E PhkA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1789071096; x=1789675896; 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=6kSbe3EQQwukUniN5j1YO+Sdv0dG67Pln7DjT7x+CNQ=; b=ZgRTKWrGWX4dAbOJZ1D3TgQSooPojkRx3cotcu3wjB2DDLO78Sv/M28cyl4MfdDKRa 7TUtTTueTIFeXFELp8/UHP9TYv3nK70MtQphi7mDPURbATJSh8DUH9GmjLRrb4PmN31w MJ07DzBlGqsT0RfdHS/ZXUKgs6OFC0inIDunUGgadq+CTB1r7KDWWxwOrZ2yjTD4kYi5 Kq4ccPgUFKOrlKmRpzm2qhW5gJoeplYTUGATpTj7mWHm7jhV/s1frX/wX5zN1rg7U4X1 6nRbJwSx5W0OmlwOMlZtNUnkYZ7JLLaoRBwNe2zdyXsbbO81yOcp8LXBlUn/enRdPdwh k4Xg== X-Gm-Message-State: AFuF++mQeAURM57N3lOr3Gzj0KZcn/yjwdtd+EwxSIEeuF/QBn+UA/Wf ni/CMUt3iFvuCNknnH+wuFRQiM908bKkp0eNe6mtV030i7FQ2FHQaRhk2epJkT3xR0blxTTUJYs VUmu0CvdfN8McJWAmPdFBM8JlmnP8CpnBmFmymvx95y4qAwVkTKnh5MbClxkcdm/Omm3dpzCZoI N6/mmkU42Ur3Ehwj2Cvo8fUKVygwVEU7WCGw== X-Gm-Gg: AYBFou0n6As3MLfCItLS5NxgD4pdYrBoq9CVGws/oqlr3BkqkQgNxWIAPm+LUlDEfwX eh6g8ca3a8YGYId7OVqlkm9ZFLx+Z5erWwMkxXZmtFY48ZkLGKS78NL1w8/Ua4mkpoZU0EwOb0q WP+rxFKvqf4zUhfA1leGCuQFqRQfVR72h5awWciNkvA34BE0PdGYOLCNr2TfyyhjuO+pZ8SdclS R5+RUCiA/zqjX1SNY44oIoCLPIbWWE59ue/W4n6vFWnpaYVpGoeTYTs2M6nFYk0VcmYoMoXsdtn B8yfUO1GYgAsp9lM5yqy+QuwU3Ya/qazwDUxlzTi5/c/usH9vQ+4/E6DoNpf/6kX0+BNCjTfZHS nQKQZFhJd8Fb9GP9+Gs2STaQ= X-Received: by 2002:a5d:630b:0:b0:484:3311:3176 with SMTP id ffacd0b85a97d-486eb2feb3cmr485934f8f.23.1789071095824; Thu, 10 Sep 2026 13:11:35 -0700 (PDT) X-Received: by 2002:a5d:630b:0:b0:484:3311:3176 with SMTP id ffacd0b85a97d-486eb2feb3cmr485903f8f.23.1789071095246; Thu, 10 Sep 2026 13:11:35 -0700 (PDT) Date: Thu, 10 Sep 2026 16:11:33 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Andrey Drobyshev , Stefano Garzarella Subject: [PULL 05/90] vhost-vsock: block CPR migration modes Message-ID: <506207fc2f814c2b4aa72d44977d10f4b4ea1285.1789071042.git.mst@redhat.com> References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-Mailer: git-send-email 2.51.2.2891.g4157995a80.dirty X-Mutt-Fcc: =sent 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=170.10.129.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com 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, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=0.001, SPF_HELO_PASS=-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-Zoho-Virus-Status: 1 X-Zoho-AV-Stamp: zmail-av-0.2.13.1.5.4/289.74.40 X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1789082166144158500 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Andrey Drobyshev CPR migration with a vhost-vsock device currently crashes the target QEMU. The device ownership is not handed over, so while the source QEMU still holds the guest CID hashed in the kernel, the target's freshly opened vhost-vsock device fails to set the same CID in realize(): qemu-system-x86_64: -device vhost-vsock-pci,id=3Dvsock0,guest-cid=3D3: vhost-vsock: unable to set guest cid: Address already in use Add an unconditional migration blocker for the CPR modes, so that such a migration fails early and gracefully instead. The following patches implement the actual vhost-vsock CPR support, and the blocker is lifted once it's fully working. Signed-off-by: Andrey Drobyshev Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin Message-ID: <20260820113955.509478-2-andrey.drobyshev@virtuozzo.com> --- include/hw/virtio/vhost-vsock.h | 1 + hw/virtio/vhost-vsock.c | 27 +++++++++++++++++++++++---- 2 files changed, 24 insertions(+), 4 deletions(-) diff --git a/include/hw/virtio/vhost-vsock.h b/include/hw/virtio/vhost-vsoc= k.h index 84f4e727c7..a964d57e1b 100644 --- a/include/hw/virtio/vhost-vsock.h +++ b/include/hw/virtio/vhost-vsock.h @@ -29,6 +29,7 @@ struct VHostVSock { /*< private >*/ VHostVSockCommon parent; VHostVSockConf conf; + Error *migration_blocker; /* CPR migration is not supported */ =20 /*< public >*/ }; diff --git a/hw/virtio/vhost-vsock.c b/hw/virtio/vhost-vsock.c index da244eb165..503d248a61 100644 --- a/hw/virtio/vhost-vsock.c +++ b/hw/virtio/vhost-vsock.c @@ -20,6 +20,8 @@ #include "hw/core/qdev-properties.h" #include "hw/virtio/vhost-vsock.h" #include "monitor/monitor.h" +#include "migration/blocker.h" +#include "migration/misc.h" =20 static void vhost_vsock_get_config(VirtIODevice *vdev, uint8_t *config) { @@ -140,25 +142,38 @@ static void vhost_vsock_device_realize(DeviceState *d= ev, Error **errp) return; } =20 + /* + * CPR migration of a vhost-vsock device is not supported yet: the + * device ownership is not handed over, so the target fails to set + * up its device. Fail the migration early and gracefully instead. + */ + error_setg(&vsock->migration_blocker, + "vhost-vsock: CPR migration is not supported"); + if (migrate_add_blocker_modes(&vsock->migration_blocker, + BIT(MIG_MODE_CPR_TRANSFER) | + BIT(MIG_MODE_CPR_EXEC), errp) < 0) { + return; + } + if (vsock->conf.vhostfd) { vhostfd =3D monitor_fd_param(monitor_cur(), vsock->conf.vhostfd, e= rrp); if (vhostfd =3D=3D -1) { error_prepend(errp, "vhost-vsock: unable to parse vhostfd: "); - return; + goto err_blocker; } =20 if (!qemu_set_blocking(vhostfd, false, errp)) { - return; + goto err_blocker; } } else { vhostfd =3D open("/dev/vhost-vsock", O_RDWR); if (vhostfd < 0) { error_setg_file_open(errp, errno, "/dev/vhost-vsock"); - return; + goto err_blocker; } =20 if (!qemu_set_blocking(vhostfd, false, errp)) { - return; + goto err_blocker; } } =20 @@ -187,16 +202,20 @@ err_vhost_dev: vhost_dev_cleanup(&vvc->vhost_dev); err_virtio: vhost_vsock_common_unrealize(vdev); +err_blocker: + migrate_del_blocker(&vsock->migration_blocker); } =20 static void vhost_vsock_device_unrealize(DeviceState *dev) { VHostVSockCommon *vvc =3D VHOST_VSOCK_COMMON(dev); VirtIODevice *vdev =3D VIRTIO_DEVICE(dev); + VHostVSock *vsock =3D VHOST_VSOCK(dev); =20 /* This will stop vhost backend if appropriate. */ vhost_vsock_set_status(vdev, 0); =20 + migrate_del_blocker(&vsock->migration_blocker); vhost_dev_cleanup(&vvc->vhost_dev); vhost_vsock_common_unrealize(vdev); } --=20 MST From nobody Sat Sep 26 20:50:16 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=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1789085226; cv=none; d=zohomail.com; s=zohoarc; b=AMNgko4uXHvyI5oEk5GLpPQtLIUiqL7wpK7ds6y5llVCdHQx9x0M/SuAOdddLMzTly2/EGi6o3QV6lZZWOnAhFGn9xGY9Ucj74tfBJ/eCYLjmStAWUASsBrX/x/oJObaWNTozCyt4tfuS0OB1d5RD6Ypo8uqJTQVLRnPfliChXg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1789085226; h=Content-Type: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=8nca6ab6j9DpnVime3jEZyKCaQ7UUnAbl2LkixdkLlA=; b=QxdHuS03L3OqmomQ/iX242nJbhOiTeohKM9Wp8A3EB/mSU9MIqyuOtKXdFJ7anko9XZImA7oJ1OPNUpSUd0kQUzeGx+4l0oDM4Ll6uMgxEIvwvbYZ1DfDvjgCFAsmnwdw8g7WkMCkc9TvIHWnkMGV2jDxISM/5D3vsqPSqyVgxI= 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 lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1789085226914677.5701155448212; Thu, 10 Sep 2026 17:07:06 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1x4oko-0007Vs-13; Thu, 10 Sep 2026 20:04:47 -0400 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 1x4lTV-0005rE-24 for qemu-devel@nongnu.org; Thu, 10 Sep 2026 16:34:35 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1x4lTJ-0002Yr-Hf for qemu-devel@nongnu.org; Thu, 10 Sep 2026 16:34:20 -0400 Received: from mail-wr1-f71.google.com (mail-wr1-f71.google.com [209.85.221.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-110-f74Zrb17OJmiu_No0YgU7g-1; Thu, 10 Sep 2026 16:11:40 -0400 Received: by mail-wr1-f71.google.com with SMTP id ffacd0b85a97d-48437090e74so60116f8f.2 for ; Thu, 10 Sep 2026 13:11:40 -0700 (PDT) Received: from redhat.com (IGLD-80-230-79-236.inter.net.il. [80.230.79.236]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-486eb32d5f1sm904567f8f.12.2026.09.10.13.11.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Sep 2026 13:11:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1789072269; 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=8nca6ab6j9DpnVime3jEZyKCaQ7UUnAbl2LkixdkLlA=; b=HvB0saZyf4KvXb3zRJ6SsYZWWxcsex1Z0ffp5DZzq1GvyPel9Mysn8dgfVY6glrmDQLgcV kxI6gJJUrrDVYmMRYUgnd0k5D6+rutBzYi/tSXZ1zTrA5+cS7HIaR8zPUuh4bC8fKSh/Vt NKDjAQffC+T0fLilJLe2lh7lHfOBA9o= X-MC-Unique: f74Zrb17OJmiu_No0YgU7g-1 X-Mimecast-MFC-AGG-ID: f74Zrb17OJmiu_No0YgU7g_1789071099 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=google; t=1789071099; x=1789675899; 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=8nca6ab6j9DpnVime3jEZyKCaQ7UUnAbl2LkixdkLlA=; b=Vo33G8S8xnE5731NGwWikEHf4PyN+wgwGc01xUiYr8Fga9eManNVY9h7rGsZ5HfPaG uqbx6rEO9odGbJK6EzPaJ5C45O3COnb2+XZl+51Vx6YZRAU1nXYf6OG5UIxIlqG+mY+o EvTaz+r058NHd8dTh0ZW5ZlKhQuP2UlokZv1OiNIhgZftR8GQ9iJVt/ii+lNpVPjDbVo rH8SOWd+B+HFx3+Jnnwc17s/P16tVyWuqUmDjMZDBnwwIeRN3gmkQUfNtdigSVIFciC2 RAS+uFn5Mu1ELAFKaHmJDv9cIaFw0i42JzXL2kGgianrIW0E6cm1Zskbs+CaeUKJol0w FzxQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1789071099; x=1789675899; 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=8nca6ab6j9DpnVime3jEZyKCaQ7UUnAbl2LkixdkLlA=; b=AalO5QJzrZ+D8wCs1WYTFT2N5LEnDGVZnDEdY8eMosFOE3I1E2uF/NgpLByanb+gOn sNR0Ca89Ao/JplW9Vpt3nGFSLqDXvGHB/PB08q1C3Opv9fht6YdoN01xU6VAh9l8u+Lb ChInIXa8aKO0jbkrGVOm4zBRlgpuxPdtdzW/mxv23+hRISckvJC8utzwhKveqjd9qigs NCAddV4mLR33CbUjEg6+DvZoGYvlfRKPUhZ6amyMqGwofI0+qi2Ku20oj9xOKP9oOeIj sFN0SP22zeANRIJH+HdTwH7P0MI6/Sy83wq7kRE8WZe3UIQu5PYm766xhXZ3KxPbprNb sSsQ== X-Gm-Message-State: AFuF++ljhmu7XBWWLhTS5RytDevbdkar1LnJMgeuJF2EtE3yfzFgntYZ /PBi9YjymyMdjSQCCKAe+Fp5rqhvyJ5VmLouyUh3I8rulE51wVVm1yUl9yRFCmsgSh/NJPT/+Kf tZR+GKEaU7g56bZjaJmD9fkk1C/in1sH5Z3o5KjQbOHDVZUkXMG4vqpYlbRaCgZF6Dgj13ohXQA qpLBM7SLof52thX99FLyb9mpWyUIfUL1Thgg== X-Gm-Gg: AYBFou2+Mqp1kynj5jJoXqVooNZQSZwTIMeE+4BiQodnfb61L0kLK45XoyAfF84MtYj +v0YP3OgKq9aU4AVApuOmjTGM7JG6raOWilA6nIzSekzIeFIIxrpCJWH/Ig469j4PZkW5EHS85F Gabh6kDvHY4oYrVn6ZzqlaIs4dk+RsFkB1E349+N5xWgq6YCaggVJzMM1nNa8OYCaB+DfQ+LU+Q LE4rIdovOwtIQbNfo4/b877tH1rmxf3IqkCSc7caNAwjN/dKxzJFSoHD5i1ZnzkXAlIAuMYZC4m w0VYqcrlF7nB+gcjU88LBhkrGSDz3623ZJjUPU5mzfp7gAqz4fKtimZfhq1TOas2Ik67RukeXb0 bb5dmNf41B3udVJXVDnCib7Y= X-Received: by 2002:a5d:64cc:0:b0:485:7cb9:4ec4 with SMTP id ffacd0b85a97d-486eb2ec226mr897160f8f.5.1789071099053; Thu, 10 Sep 2026 13:11:39 -0700 (PDT) X-Received: by 2002:a5d:64cc:0:b0:485:7cb9:4ec4 with SMTP id ffacd0b85a97d-486eb2ec226mr897098f8f.5.1789071098378; Thu, 10 Sep 2026 13:11:38 -0700 (PDT) Date: Thu, 10 Sep 2026 16:11:35 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Andrey Drobyshev , Mark Kanda , Steve Sistare , Ben Chaney , "Maciej S. Szmigiero" , Stefano Garzarella Subject: [PULL 06/90] vhost: add vhost_reset_owner op Message-ID: References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-Mailer: git-send-email 2.51.2.2891.g4157995a80.dirty X-Mutt-Fcc: =sent 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=170.10.129.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com 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, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=0.001, SPF_HELO_PASS=-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-Zoho-Virus-Status: 1 X-Zoho-AV-Stamp: zmail-av-0.2.13.1.5.4/289.74.40 X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1789085228132158500 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Andrey Drobyshev Add a VhostOps callback issuing VHOST_RESET_OWNER, wired up for the kernel backend. The CPR (checkpoint-restore) path uses it to release device ownership on the source so the destination can reclaim it later with VHOST_SET_OWNER. Originally-by: Mark Kanda Originally-by: Steve Sistare Originally-by: Ben Chaney Signed-off-by: Andrey Drobyshev Reviewed-by: Michael S. Tsirkin Acked-by: Maciej S. Szmigiero # for CPR Signed-off-by: Michael S. Tsirkin Message-ID: <20260820113955.509478-3-andrey.drobyshev@virtuozzo.com> --- include/hw/virtio/vhost-backend.h | 1 + hw/virtio/vhost-kernel.c | 6 ++++++ 2 files changed, 7 insertions(+) diff --git a/include/hw/virtio/vhost-backend.h b/include/hw/virtio/vhost-ba= ckend.h index d878d7b733..6c949e6a38 100644 --- a/include/hw/virtio/vhost-backend.h +++ b/include/hw/virtio/vhost-backend.h @@ -204,6 +204,7 @@ typedef struct VhostOps { vhost_get_features_op vhost_get_features; vhost_set_backend_cap_op vhost_set_backend_cap; vhost_set_owner_op vhost_set_owner; + vhost_set_owner_op vhost_reset_owner; vhost_reset_device_op vhost_reset_device; vhost_get_vq_index_op vhost_get_vq_index; vhost_set_vring_enable_op vhost_set_vring_enable; diff --git a/hw/virtio/vhost-kernel.c b/hw/virtio/vhost-kernel.c index 3390b48c6f..55d316b88e 100644 --- a/hw/virtio/vhost-kernel.c +++ b/hw/virtio/vhost-kernel.c @@ -261,6 +261,11 @@ static int vhost_kernel_set_owner(struct vhost_dev *de= v) return vhost_kernel_call(dev, VHOST_SET_OWNER, NULL); } =20 +static int vhost_kernel_reset_owner(struct vhost_dev *dev) +{ + return vhost_kernel_call(dev, VHOST_RESET_OWNER, NULL); +} + static int vhost_kernel_get_vq_index(struct vhost_dev *dev, int idx) { assert(idx >=3D dev->vq_index && idx < dev->vq_index + dev->nvqs); @@ -385,6 +390,7 @@ const VhostOps kernel_ops =3D { .vhost_get_features_ex =3D vhost_kernel_get_features, .vhost_set_backend_cap =3D vhost_kernel_set_backend_cap, .vhost_set_owner =3D vhost_kernel_set_owner, + .vhost_reset_owner =3D vhost_kernel_reset_owner, .vhost_get_vq_index =3D vhost_kernel_get_vq_index, .vhost_vsock_set_guest_cid =3D vhost_kernel_vsock_set_guest_cid, .vhost_vsock_set_running =3D vhost_kernel_vsock_set_running, --=20 MST From nobody Sat Sep 26 20:50:16 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=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1789086345; cv=none; d=zohomail.com; s=zohoarc; b=G2S8op9gas7vjSCZeGDTbgVPBNEqmeaWWC/NkCw8d40l8T9T9hoRXRdfwW2PjdcFJrR6k9YY7oO+/Xpf3H/WCMfpotRVBdpXppTpf/KAqmDMMfBIcKt1OpcRX8lnrdywNytJWOdZLyFtdldipUzptHqHBHB3JS/LlrilXC5wY8o= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1789086345; h=Content-Type: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=YJvWkUnb4lzQW4cMMtlq1toGA8UHfGJGyMh5sRRga0g=; b=WFjJ0kk90Z4F6QV4V54npFCqww/xbfYAvdovimVIRzrlO75ZwJt3Blwc23wu/zKP211oaAg1YclP+KuQmqboORWXJDi9UGBPWsAD/PKGRxQLFm0rCylwSYeQJU0g1N4wyPcS1GPNnAzoNGE9gW3rJXljec/KNNhgN1DEWpCSmtE= 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 lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1789086345848571.2509263331523; Thu, 10 Sep 2026 17:25:45 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1x4owe-0002Xt-M7; Thu, 10 Sep 2026 20:16:57 -0400 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 1x4ljL-0001bP-RZ for qemu-devel@nongnu.org; Thu, 10 Sep 2026 16:51:05 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1x4liz-0006Nt-D5 for qemu-devel@nongnu.org; Thu, 10 Sep 2026 16:50:31 -0400 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-115-HORBhjSrN1Ob8gv5N1uWIA-1; Thu, 10 Sep 2026 16:11:42 -0400 Received: by mail-wm1-f70.google.com with SMTP id 5b1f17b1804b1-49d2951089fso1540855e9.2 for ; Thu, 10 Sep 2026 13:11:42 -0700 (PDT) Received: from redhat.com (IGLD-80-230-79-236.inter.net.il. [80.230.79.236]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-49d26c2985dsm162559465e9.6.2026.09.10.13.11.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Sep 2026 13:11:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1789073418; 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=YJvWkUnb4lzQW4cMMtlq1toGA8UHfGJGyMh5sRRga0g=; b=br9+eI4RkW+9CLer6Z7cRtkDp2/4NkLAh0hB/6WNf+l9OGBfJnkY+ECWeRPWIHRmLT+eWs vli6uViDVNqEOcO8DZc0LWrKnGUqrtiWuEJdHhRq1TzAon+3pxtiqf1Zy1aHnsKjKFUDf8 XFxLfaCtC6q2wdM4SfFWgweb+ovX/lo= X-MC-Unique: HORBhjSrN1Ob8gv5N1uWIA-1 X-Mimecast-MFC-AGG-ID: HORBhjSrN1Ob8gv5N1uWIA_1789071101 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=google; t=1789071101; x=1789675901; 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=YJvWkUnb4lzQW4cMMtlq1toGA8UHfGJGyMh5sRRga0g=; b=sLAc4pRwhlOOkauIbEHcruimtkVejRcVZumYJa5brS0xS2dhMgus6tUQCergItlvFC ytSrJSVRcSG0chIN+A2Vm2nSK3kDdEkrAVqe1FfckNiozdgAnXeN+90EuL7V3b+LBehk 7/a4GoDaJpUOtRMPLiy61afZjC4SMJdfl9AdoBUwlny8VOuDWA4uxs+9f6BwSVBRp8Lp pYFzZrKyi79w9+ZkvE2ULx2ZXZe3gqH6113LAmiduhAYNdh8XZftDmPAr5VP2roih61B eLwdTl9RlOLtCajplLeb+biLIPtj6v7w08Tm0E5OUJ+R+/nJBdJyhtjH6m+NWkzmKO1h 7LJg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1789071101; x=1789675901; 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=YJvWkUnb4lzQW4cMMtlq1toGA8UHfGJGyMh5sRRga0g=; b=AaD7AT7Qn76nBzgxmPjku/KHyTItpo8uRNNHQhExw65GM97du0o3EAOHG9i0CJpmTb RmDsoG3VK4FvZ50u52cOIuQBimV+SeSwASZdlLSC6BfHbdAsl86uEj12vX/JIvAWSALT cKZIg0gHaJiZPjBQB18ukHm96FhvhTei9uqyZGeIhvhy8DzfseI3JT6aLxYBfAh7O2bc R5NFPgSXwJugMFjZQnufHu1aYcrAP2CtdX2mg1wuGKUER9EZ+34XoNuk6iDiUN0SbYWb F0V+9ZpAc97aQWinCY0sWxstZ1+rvZj1+QHFLN1ohW5rk4EekNiQa0Ubi+Nj1PmzzZmq b0mw== X-Gm-Message-State: AFuF++nQfotso/3NEYqfbmOoMjKHjVLoMvP18oThan8N18wzPrdM/t9+ 6foNUS1YR8Kvw05UTL7X/8S9MDpyvk0Md6MojAHx55ruIyNBuXiWXON0umav2yJOxGTRhA9tZ8V 3xt4erOJGYBVGmupgB/2HO0EANdhar7hHOZHB5kHYt0WBG3Pce3U9Sq7lE7XXTsDQA+z/A5ERaP 9LlTrIt6faR+oL9ZEJJPheBD0pwBphyupYAg== X-Gm-Gg: AYBFou0UqgiDeBJ11gglcJkspThlSoMPYfsmlQZUzolI7weZ69UuwwJf/PDTgawCf88 j1DiUx8D2NVZcxOOKviwpHdboNyJ5fzjS6aK5KBb3CuDTIs+ZJY6AZaUHg4DODp6O5gyRvFVgug Q2r+JQuGiNxbQgB0ESOsbStGV34Imr9VB0l0tjSRP4E4MPw7RE5CdvV4Hm6YhSVkqL2kMJhgYCN YqWHJ5RboCv4BX5CC9kgerI9Dmsxggqo1DtssN4LTCOvrcuJ/mFu4pNjSc3WGm2My3YbI35ARqD CSCnAtvDl6dOOowJ9SewQ2Tjf82f8nM3HY/Q+AzepAT1YexYmMHxiTN2cSe5gr/L9DNbdYaZXRl bu2agG61v70OD7JRZv7KGYoc= X-Received: by 2002:a05:600c:3104:b0:499:621a:2ec2 with SMTP id 5b1f17b1804b1-49e6188899fmr8133935e9.3.1789071101023; Thu, 10 Sep 2026 13:11:41 -0700 (PDT) X-Received: by 2002:a05:600c:3104:b0:499:621a:2ec2 with SMTP id 5b1f17b1804b1-49e6188899fmr8133655e9.3.1789071100400; Thu, 10 Sep 2026 13:11:40 -0700 (PDT) Date: Thu, 10 Sep 2026 16:11:38 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Andrey Drobyshev , Stefano Garzarella Subject: [PULL 07/90] vhost-vsock: don't reset connections during CPR Message-ID: References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-Mailer: git-send-email 2.51.2.2891.g4157995a80.dirty X-Mutt-Fcc: =sent 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=170.10.129.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com 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, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=0.001, SPF_HELO_PASS=-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-Zoho-Virus-Status: 1 X-Zoho-AV-Stamp: zmail-av-0.2.13.1.5.4/289.74.40 X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1789086348310158500 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Andrey Drobyshev Migration target with a vhost-vsock device in the .post_load() hook issues VIRTIO_VSOCK_EVENT_TRANSPORT_RESET event to the guest. This results into the guest tearing down all its vsock connections. That reset exists because after a normal migration the cid may change. However it's not true for CPR-style migration. In this case cid remains the same, and we want the connections to persist. Thus, let's customize the .post_load() hook to skip the common transport reset part in this case. Signed-off-by: Andrey Drobyshev Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin Message-ID: <20260820113955.509478-4-andrey.drobyshev@virtuozzo.com> --- hw/virtio/vhost-vsock.c | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/hw/virtio/vhost-vsock.c b/hw/virtio/vhost-vsock.c index 503d248a61..c582ac9fcc 100644 --- a/hw/virtio/vhost-vsock.c +++ b/hw/virtio/vhost-vsock.c @@ -20,6 +20,7 @@ #include "hw/core/qdev-properties.h" #include "hw/virtio/vhost-vsock.h" #include "monitor/monitor.h" +#include "migration/cpr.h" #include "migration/blocker.h" #include "migration/misc.h" =20 @@ -110,6 +111,20 @@ static uint64_t vhost_vsock_get_features(VirtIODevice = *vdev, return vhost_vsock_common_get_features(vdev, requested_features, errp); } =20 +static int vhost_vsock_post_load(void *opaque, int version_id) +{ + /* + * Only reset vsock connections for non-CPR migration. For CPR the + * guest cid is unchanged, and the cid-change reset would otherwise + * tear the vsock connections down. + */ + if (!cpr_is_incoming()) { + return vhost_vsock_common_post_load(opaque, version_id); + } + + return 0; +} + static const VMStateDescription vmstate_virtio_vhost_vsock =3D { .name =3D "virtio-vhost_vsock", .minimum_version_id =3D VHOST_VSOCK_SAVEVM_VERSION, @@ -119,7 +134,7 @@ static const VMStateDescription vmstate_virtio_vhost_vs= ock =3D { VMSTATE_END_OF_LIST() }, .pre_save =3D vhost_vsock_common_pre_save, - .post_load =3D vhost_vsock_common_post_load, + .post_load =3D vhost_vsock_post_load, }; =20 static void vhost_vsock_device_realize(DeviceState *dev, Error **errp) --=20 MST From nobody Sat Sep 26 20:50:16 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=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1789084682; cv=none; d=zohomail.com; s=zohoarc; b=YPA4xaImdMtpRGy7TZpsdUoVQxwPS8LuYOYgExP1N9jh+FrD/sjgzxtMs/zlgqs8xKn9kLk+HN0wX8gHZpuqRQuuX+X4BR1r7LKiEEFKJ8fqRm1r+5eNELp1syhsIecmiXSXsyqPq/K3eHr3ZJb4l8p+sg2+RiHJyNlx3kKZ/bY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1789084682; h=Content-Type: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=kbCiydol7NCeGRxJ9uKdT9EoWt9Zlq2cgE3irIl6fTc=; b=Ga057a8c96l/FSgTNvPTftPemMmjsymAB1DwCoSnoVogP/elD8ZCpUUVmR4gUYrZV2z2yAjPxhnv7K4S/QId0aTZ/g6R0T9Vc6DzgyQNbAWZwCkudOzorFAMS3vR2GXMPdEj4UFBSF89zNs4BAaeiQsHwfDXQNB/b8BgEERSquE= 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 lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1789084682830204.99617601690647; Thu, 10 Sep 2026 16:58:02 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1x4oWY-0003Tt-B3; Thu, 10 Sep 2026 19:49:59 -0400 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 1x4lU1-0005wx-4N for qemu-devel@nongnu.org; Thu, 10 Sep 2026 16:35:05 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1x4lTg-0002Xc-Ok for qemu-devel@nongnu.org; Thu, 10 Sep 2026 16:34:40 -0400 Received: from mail-wr1-f70.google.com (mail-wr1-f70.google.com [209.85.221.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-98-h4kDUhucOJuC9fr5p3a59A-1; Thu, 10 Sep 2026 16:11:45 -0400 Received: by mail-wr1-f70.google.com with SMTP id ffacd0b85a97d-486e9338393so71210f8f.0 for ; Thu, 10 Sep 2026 13:11:45 -0700 (PDT) Received: from redhat.com (IGLD-80-230-79-236.inter.net.il. [80.230.79.236]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-486eb36e4a6sm792448f8f.37.2026.09.10.13.11.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Sep 2026 13:11:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1789072266; 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=kbCiydol7NCeGRxJ9uKdT9EoWt9Zlq2cgE3irIl6fTc=; b=KEyP1gGR8pMMkim5ufttuuGtBK6hdjB5p349lj2ZtWo4yKMYVHpD1uHYsLzc6C0LLJh7NK ezo/pisMPaWpOeKgMn3+NR2iF6Dsc0iaZKkGgEkw8LzSnB7F9Vzts/r1NUyq8ANAnQK70B KksUu/yS38ORKvC3KxtoCec5XJHUp4s= X-MC-Unique: h4kDUhucOJuC9fr5p3a59A-1 X-Mimecast-MFC-AGG-ID: h4kDUhucOJuC9fr5p3a59A_1789071104 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=google; t=1789071104; x=1789675904; 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=kbCiydol7NCeGRxJ9uKdT9EoWt9Zlq2cgE3irIl6fTc=; b=QOzfpYUH4/7xyl7cM6sTuYyATBwuNj7DIszSpYCAeEh+nPwTlaD+yDUiYWKusmDy88 F832PXCBNeEM4wyxVXL6pVa3dNCmgwfL/4BednPvfl5Ypc572ojA2XiBmz5d+Wxoq+w8 NQOXFSCLdSmDWyoD0FujrtxPsa7Xn27vv76bj1OGKI0q+W3dJVcxVqia+PmxvnKKhD8c A9uytypb+tRP550PuDrUyeF2t0brIjQdiEnCgr/ObtjtkREBUw4fkFn9+dPAFkNSVgg1 oMzqKo6tcyQ5k2LO4TgqH/LMSx6NMOAreD/eF7MDdatmPw4Y2JFOMK1QdQ+qRnA4btIo WSWA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1789071104; x=1789675904; 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=kbCiydol7NCeGRxJ9uKdT9EoWt9Zlq2cgE3irIl6fTc=; b=RxI5hH09ATVJMTU6xljw1G/kV2/wXFeuy+W09PLvEeqiLbx972aER829MmIQlkedTP /FFjvPl76Gu1VmuOWCVeSHr4jwF0LD82LA06jo3qcnfgoJo6OrewPwW05kW02PwP5uEl vUCU8eHUlP0eEOliIsAnRhZIwjfGXN4vP7ZIOf+M4dddUilGdpejeYMmMVonoCYKOo/3 2gE/omGQM0b0dG45fc5jGWOnYHW9hDH7tukmHzm7yaEpLpSEcNBOJICYpUy9ofANyVjk RdlBUeUlNd1lXO2LrRHyLlR5R3iCaEvzVdNECjrQJ0KMZTz0fdZ9PA7RGI5bCkuEypRt 4DBQ== X-Gm-Message-State: AFuF++nR2qCsp7b8J59OjKMzsNQ4EFd570EHlImQIH+vVLuiZ3w5q6XV bOeKbPBX/u83mXwOTBJUTqBi9tuXhHlhQIxTccqrhYpwZZAMO0wDEVJEHIbbc/6+4O3CeKl87hr U7RSUYKfO00lAbOGmQjfKvB9Hsav5Bag2aloCy3CfXq3nnu7m3SfF/criI2Ra6+McmPz9FkP/OY yWuhRxUf98UkssM7e/a9ia6YTX/YVUqqXPZw== X-Gm-Gg: AYBFou13GaQm9cQ120+DeKvrK0QcpV4DhdMuzPTb5/H0BHu/b0gRILesA27MpD0gwEo biBhSYwY9kaNQAYg/tNhsE9RJpZ4QkhmkuMI46aEDU7ko5eo0saXQlUCey9g+oRvpZyvND7HEGz Hj81RxcKNumIPL9c+moV1O8RfSxGYElt1jd4EHvmscL4fJqvDVb+d9hWQHhPqBM9glgqquveJeY wO0EGhRMEPyhFc31O7h3G3aKS25Z5Wf4N0g4iWqcwWxMN5P0eUfpsxijeYV47cx1fzOmdjmaOKN AM/5i3v6WfTMOuGjFi0+ot/hjzf6/txGnk3LBNGYMHTPcKkoyMWd+xXZyiKniO6fK79DJZ4l6Mg I9cZ1CErl9juVnAJyriktJ7U= X-Received: by 2002:a05:6000:240a:b0:485:ac96:724b with SMTP id ffacd0b85a97d-486eb2d9756mr789558f8f.7.1789071103964; Thu, 10 Sep 2026 13:11:43 -0700 (PDT) X-Received: by 2002:a05:6000:240a:b0:485:ac96:724b with SMTP id ffacd0b85a97d-486eb2d9756mr789503f8f.7.1789071103155; Thu, 10 Sep 2026 13:11:43 -0700 (PDT) Date: Thu, 10 Sep 2026 16:11:40 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Andrey Drobyshev , Stefano Garzarella Subject: [PULL 08/90] vhost-vsock: fix FD leak in realize() Message-ID: References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-Mailer: git-send-email 2.51.2.2891.g4157995a80.dirty X-Mutt-Fcc: =sent 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=170.10.129.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com 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, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=0.001, SPF_HELO_PASS=-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-Zoho-Virus-Status: 1 X-Zoho-AV-Stamp: zmail-av-0.2.13.1.5.4/289.74.40 X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1789084685669158500 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Andrey Drobyshev In vhost_vsock_device_realize(), after unsuccessful call to qemu_set_blocking(vhostfd, false), vhostfd gets leaked. Let's close it explicitly in this case. CPR-saved FDs don't get automatically closed, thus it is safe both for vhostfd obtained from cpr_find_fd() and from open(/dev/vhost-vsock). Signed-off-by: Andrey Drobyshev Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin Message-ID: <20260820113955.509478-5-andrey.drobyshev@virtuozzo.com> --- hw/virtio/vhost-vsock.c | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/hw/virtio/vhost-vsock.c b/hw/virtio/vhost-vsock.c index c582ac9fcc..3ec20d8760 100644 --- a/hw/virtio/vhost-vsock.c +++ b/hw/virtio/vhost-vsock.c @@ -176,20 +176,17 @@ static void vhost_vsock_device_realize(DeviceState *d= ev, Error **errp) error_prepend(errp, "vhost-vsock: unable to parse vhostfd: "); goto err_blocker; } - - if (!qemu_set_blocking(vhostfd, false, errp)) { - goto err_blocker; - } } else { vhostfd =3D open("/dev/vhost-vsock", O_RDWR); if (vhostfd < 0) { error_setg_file_open(errp, errno, "/dev/vhost-vsock"); goto err_blocker; } + } =20 - if (!qemu_set_blocking(vhostfd, false, errp)) { - goto err_blocker; - } + if (!qemu_set_blocking(vhostfd, false, errp)) { + close(vhostfd); + goto err_blocker; } =20 vhost_vsock_common_realize(vdev); --=20 MST From nobody Sat Sep 26 20:50:16 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=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1789077934; cv=none; d=zohomail.com; s=zohoarc; b=Ns0zI2CoM8UFN0Azci522nsdJd8M7J6lsDeq3l61cw+335w1ZtAPrew+4fGMgW6trz1hStXrhSXtYx9s1fY6YSof76+yIorI+gkGgLarFBi37DYtvWMYUTodtsYhrnJfF0Epld91jZdRwHfdAtVzLig4meuSk16AqnvMfy6d0ig= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1789077934; h=Content-Type: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=vKr9lNpyACzOKzz7rZq+Sx8L/PCb2spJh1GK0S9epoU=; b=W88kz5kg6vPGpe0ECn3c4vS5J8lwSM5FG2Fep+EJVNLiWY6FJfbplGeNKq6mVyLqPdWQrI3LnNaFk1UzA6vtxhORsxgkBydkMOV49yihVt+m+sYLTkAETasf03SLHMUfUnwJs6hEiFPEzxnophhDpBp6JBQEeH/5ugjWCVCMpOg= 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 lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1789077934496792.6854001551411; Thu, 10 Sep 2026 15:05:34 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1x4mhh-00068V-AS; Thu, 10 Sep 2026 17:53:21 -0400 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 1x4lRn-000535-3p for qemu-devel@nongnu.org; Thu, 10 Sep 2026 16:33:03 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1x4lRQ-0002Xe-RL for qemu-devel@nongnu.org; Thu, 10 Sep 2026 16:32:25 -0400 Received: from mail-wr1-f71.google.com (mail-wr1-f71.google.com [209.85.221.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-271-bA7hPFbkOHS_4pkjjQDYHQ-1; Thu, 10 Sep 2026 16:11:47 -0400 Received: by mail-wr1-f71.google.com with SMTP id ffacd0b85a97d-482f763db88so46668f8f.2 for ; Thu, 10 Sep 2026 13:11:46 -0700 (PDT) Received: from redhat.com (IGLD-80-230-79-236.inter.net.il. [80.230.79.236]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-486eb35c071sm746452f8f.33.2026.09.10.13.11.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Sep 2026 13:11:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1789072266; 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=vKr9lNpyACzOKzz7rZq+Sx8L/PCb2spJh1GK0S9epoU=; b=HF/3bRdW2IvbUCmkiiVoryNqfUiMdKAX3ptG8ABVrU70m+JxqMbWvM1rLCjdQdoGRmV2bV Y0dryBjDDljrLMbn36RuGLcBed8ncSOkAkO5n0zBoU9jiZ2aNFo6KMOBGwfuoimNhGZAhg rG1vKgw717Np1jaZtnlYc8yYY1PezuA= X-MC-Unique: bA7hPFbkOHS_4pkjjQDYHQ-1 X-Mimecast-MFC-AGG-ID: bA7hPFbkOHS_4pkjjQDYHQ_1789071106 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=google; t=1789071106; x=1789675906; 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=vKr9lNpyACzOKzz7rZq+Sx8L/PCb2spJh1GK0S9epoU=; b=J2VfsMArrVvz10/fGbk2c+eck9CxNLpyRm6DF9Pa26k0UqaBl9VnjUau7bOnoemscN uYu1Ii5l0S4czuSL9ISyiIeWmtKxpWmbFSWZ0Q+fXZFqtP8hTZ9jBNqd1pACoreR/kcZ V7O3iErB2dhfveLrLAi69H8uV9qwYAnM8WvbBaRS0YLzR0xQRUrXl52fkDH73ryuK6VV o7TIj3qzZXZblP8IDgTuaxMCRg88bIVEbtwhFiQw6TXdrzNYvnTYZGVWzh8ElAzLahGx sdbWdFE3sR0QW3mhP49O+3zeigHANDB8dablx/4LUYDpgeEYeX6Sa2DZNuRlZA9bk3VZ xctQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1789071106; x=1789675906; 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=vKr9lNpyACzOKzz7rZq+Sx8L/PCb2spJh1GK0S9epoU=; b=YN/l8cAetOSm2xj2hhaudbbNEtJhQGMLCUyCfDzs2ivTTDye/qvj7rTvTYj9bDW+A/ y6sYHFp3ClUVzJGFR62rcltKPVFv4rBWm5+N9GtQHBohsyHKFSpd108mBwICJxAuiygu E4yheYwUqV4RNm+D5L5Id7NmlO76/G8KbUAYoVki5FEgiBcry/yoXfWASJ5ghcFefA+j uVsJfUD1wM4cmliZ8Wg8jPoxUrU4+/pie5ilpView9CM84Y5qg0qMFz3R0ADVeA6QMFe PzQvCLuHBcL3E5oXPgbbjIU96mPOBzqAyq6UAhBk6197UVYmjtK9yxmO92sCpJ5J2kiV Bniw== X-Gm-Message-State: AFuF++np4DuYP7hPR26X/pjKW30G/AgaMGWUA8zxGe6GgV3EhT/lNKZS 1QOXjP9LBYZ1/Q8vrEkaUDlUZC3fIFMcHPFwC1veUsSSGQhCRM7F+3Q47aynmjWzai9nmyEaWii rs7+DNTUS/XelV6cXfISnGn/Filqts56ifj+0uP2Wm9/zdFXoqKE1BsVdma98Ds/pCiUXQZe+y/ 5C8kfK1uq+1pClQj02pE+PJWB8u2N5lW+Wsw== X-Gm-Gg: AYBFou3NpV0Uw5wxjz5Phu6F2smXV8W53CR34Ya83QipFA4lfMhHIG8HsM15mgrUr/Q TfavSQ1BZWqGj6B1GskvynbJ0wyvXgKRHI9KcAY7NLGS875VmwgO++J2BGf3Nf8bShlZ/A07nt0 S9HddpyKIl/6TuAcyILkYTjKSEGjBsoCwGNE44A74AFsgj7uQaaETEC8xS0LrerbgczN2SKiKLV maokb7EcUSUMrX7r8RLML/PYPISIfkMS4q61xBkIHQZFc0PJWPPn23VvU9p+aT1JMrZFm7oID19 yGqt4WEPGXA4W25SEt9agF33jN8Eu2vpNabPGqj/FIwz75c2+JpZiwUHUCOm3uPLrEnPEWK09F6 f+l+1J9a2DlF7mJzlqlHHvHc= X-Received: by 2002:a05:6000:2501:b0:486:e5f7:89ca with SMTP id ffacd0b85a97d-486eb1d99c5mr729416f8f.8.1789071105758; Thu, 10 Sep 2026 13:11:45 -0700 (PDT) X-Received: by 2002:a05:6000:2501:b0:486:e5f7:89ca with SMTP id ffacd0b85a97d-486eb1d99c5mr729375f8f.8.1789071105219; Thu, 10 Sep 2026 13:11:45 -0700 (PDT) Date: Thu, 10 Sep 2026 16:11:43 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Andrey Drobyshev , Stefano Garzarella Subject: [PULL 09/90] vhost-vsock: preserve vhost FD during CPR Message-ID: References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-Mailer: git-send-email 2.51.2.2891.g4157995a80.dirty X-Mutt-Fcc: =sent 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=170.10.129.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com 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, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=0.001, SPF_HELO_PASS=-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-Zoho-Virus-Status: 1 X-Zoho-AV-Stamp: zmail-av-0.2.13.1.5.4/289.74.40 X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1789077936172158500 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Andrey Drobyshev During CPR (checkpoint-restore) migration the guest keeps running on the same host, so instead of reopening /dev/vhost-vsock on the destination, we should reuse the FD from the source. The FD is saved in the CPR namespace (hash table) with cpr_save_fd() and then reclaimed on the target via cpr_find_fd(). Since the key in CPR hash table is device ID, CPR needs a unique ID. Thus we only preserve the FD with cpr_{save,find} if this ID is present. In a following patch, when we lift the CPR migration blocker, we're going to condition it on the presence of ID. vhost_dev_init() (and thus VHOST_SET_OWNER) still runs in realize() here. Deferring the ownership handoff to pre_save/post_load is done in a following patch. Until then CPR remains blocked, so the restore path added here is not reachable yet. Signed-off-by: Andrey Drobyshev Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin Message-ID: <20260820113955.509478-6-andrey.drobyshev@virtuozzo.com> --- hw/virtio/vhost-vsock.c | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/hw/virtio/vhost-vsock.c b/hw/virtio/vhost-vsock.c index 3ec20d8760..cec2c31f0c 100644 --- a/hw/virtio/vhost-vsock.c +++ b/hw/virtio/vhost-vsock.c @@ -143,6 +143,7 @@ static void vhost_vsock_device_realize(DeviceState *dev= , Error **errp) VHostVSockCommon *vvc =3D VHOST_VSOCK_COMMON(dev); VirtIODevice *vdev =3D VIRTIO_DEVICE(dev); VHostVSock *vsock =3D VHOST_VSOCK(dev); + DeviceState *proxy =3D qdev_get_parent_bus(DEVICE(vsock))->parent; int vhostfd; int ret; =20 @@ -170,7 +171,19 @@ static void vhost_vsock_device_realize(DeviceState *de= v, Error **errp) return; } =20 - if (vsock->conf.vhostfd) { + if (cpr_is_incoming()) { + /* Reuse the fd handed over from the source QEMU. */ + if (!proxy->id) { + error_setg(errp, "vhost-vsock: device ID is required for " + "CPR migration"); + goto err_blocker; + } + vhostfd =3D cpr_find_fd(proxy->id, 0); + if (vhostfd < 0) { + error_setg(errp, "vhost-vsock: could not find restored vhost F= D"); + goto err_blocker; + } + } else if (vsock->conf.vhostfd) { vhostfd =3D monitor_fd_param(monitor_cur(), vsock->conf.vhostfd, e= rrp); if (vhostfd =3D=3D -1) { error_prepend(errp, "vhost-vsock: unable to parse vhostfd: "); @@ -207,6 +220,11 @@ static void vhost_vsock_device_realize(DeviceState *de= v, Error **errp) goto err_vhost_dev; } =20 + /* Register the fd for a future CPR after a fully successful realize */ + if (proxy->id) { + cpr_save_fd(proxy->id, 0, vhostfd); + } + return; =20 err_vhost_dev: @@ -223,10 +241,14 @@ static void vhost_vsock_device_unrealize(DeviceState = *dev) VHostVSockCommon *vvc =3D VHOST_VSOCK_COMMON(dev); VirtIODevice *vdev =3D VIRTIO_DEVICE(dev); VHostVSock *vsock =3D VHOST_VSOCK(dev); + DeviceState *proxy =3D qdev_get_parent_bus(dev)->parent; =20 /* This will stop vhost backend if appropriate. */ vhost_vsock_set_status(vdev, 0); =20 + if (proxy->id) { + cpr_delete_fd(proxy->id, 0); + } migrate_del_blocker(&vsock->migration_blocker); vhost_dev_cleanup(&vvc->vhost_dev); vhost_vsock_common_unrealize(vdev); --=20 MST From nobody Sat Sep 26 20:50:16 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=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1789079527; cv=none; d=zohomail.com; s=zohoarc; b=fe68mzq50neA1bDzX/Iph53+MxdQv1Sfb75rFOoB9nRSGMuKOGCbjjrpL8gRz691FlQeuq27L736HTR+7mYS2vYHPMcJ/S/MV8BSFk0gHzIoEKMyooaZDpRXM9VbtD0zfJZzOHxybYQ8W36HHwS/qbY5ZBd9EQ7Awez80onVAgI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1789079527; h=Content-Type: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=ZQDk4aDnIuGue9PuQFrUh0Z8Opb928Cl0XfZUcAFxaI=; b=CN/xZWFa1qhjMxtHfwWBZWvJz4SDF4lJDQ7dEGqOD5JoANOtWGveSMKsrPE4Jy2cvw9vYYxm3UEKKL7hrU3cFh0FF5Detlfo3wXEJXau5XZxXT8lHGuwmHFXyi+RhpvRTj7c2j9OzwnzGJBEAk1sFQcza7lUuBpA0ARKFiq70eg= 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 lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1789079527584258.78433036840727; Thu, 10 Sep 2026 15:32:07 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1x4n80-0004GI-H3; Thu, 10 Sep 2026 18:20:30 -0400 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 1x4lJj-0002N5-7F for qemu-devel@nongnu.org; Thu, 10 Sep 2026 16:24:39 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1x4lJQ-0000IP-66 for qemu-devel@nongnu.org; Thu, 10 Sep 2026 16:24:07 -0400 Received: from mail-wm1-f71.google.com (mail-wm1-f71.google.com [209.85.128.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-530-qHPP63j6Njeem71c1sQ4gw-1; Thu, 10 Sep 2026 16:11:49 -0400 Received: by mail-wm1-f71.google.com with SMTP id 5b1f17b1804b1-4994aebe932so2209915e9.3 for ; Thu, 10 Sep 2026 13:11:48 -0700 (PDT) Received: from redhat.com (IGLD-80-230-79-236.inter.net.il. [80.230.79.236]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-486eb33ea4fsm743680f8f.21.2026.09.10.13.11.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Sep 2026 13:11:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1789071721; 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=ZQDk4aDnIuGue9PuQFrUh0Z8Opb928Cl0XfZUcAFxaI=; b=a7wKiQAu/hmf3akun/HqhVQdSMf2tA9QAT4s7rje/VOaKGL7/pIdzW5bMES7lIOGsN2Jwv xC7alzvfTykLna6T97UHblUVRSIT19Z51kYcviLmmR+iporIqTO5aKoF/nBvqZp06cYrDx HYgaumPprd0Cq84R3ZjJ9lI/JrRGog4= X-MC-Unique: qHPP63j6Njeem71c1sQ4gw-1 X-Mimecast-MFC-AGG-ID: qHPP63j6Njeem71c1sQ4gw_1789071108 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=google; t=1789071108; x=1789675908; 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=ZQDk4aDnIuGue9PuQFrUh0Z8Opb928Cl0XfZUcAFxaI=; b=fziojBq4bnfIdq7uw4tT5EdjIv+yT+mtARiV+BDJWi4umV6GLep9ENEaNOIIoItbmS 3fZmCvMLsy7sI5wcoVkmqVZCIsw5QtOlEAY9giu7FkX4KJZ0ZLi4/dmpScLX2uAVReMe BO0E4vseVhZj7D8qbUrTQgo5NrSFMgsrW898hgY/BJ8j6KvZTDTw5s9vD6aWZ3IT1pxx 7xMPq4SK3Pah7Dvms7+3twI2ZFWRKFvTqlhEYry3r4/oGRrYR+FrK/E4pCbe2GIPOR84 XWel0ZosEB0ojJQhpHpJJJ49PT4DjQacjMMkbNUvS012wKkq+lFBpzvDpJr0QyR7R+rC cZPA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1789071108; x=1789675908; 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=ZQDk4aDnIuGue9PuQFrUh0Z8Opb928Cl0XfZUcAFxaI=; b=p0IO9klXsh3VJHN3XHD2yoS1oo8+923Of8fPH76WOVyPNnOT6m9y6/QIz5ZMLwxPQF G9zV3g5WVbHQo4H81gnt3xr22Nu0mHqtya5fMsYM9M2pPibkrs8JnUXyuf70LVSDEkMu gIZnH25+UHHbXv1+7Mpvh1VLxWqv6zErcMyxkEDvfG6PqwypwwVKkMtmLEA0blo5QSJG XJUj/mikZAyzcYacW6oDzEs80n12CwQ6GQewndXxqyLsJvjneBQmtoFWjMZdqEkgptF2 fbGpzaHyZEneMba2W0Pc/ZFLRZf3fIUg4FmT0DxFtXc/or/3LMMQmYIjKIczUTBlx9BL e1EQ== X-Gm-Message-State: AFuF++kgOUIxh/ix3Lxj5+tPTnExRoYwpHtDJagOnx1u4OM07ipkFmHY pRzCAFUPgeTiaI+0irlTV2FveI13DwIGXVLkNm5sosTKziCMW29YAngUrlvUcSXQnNQmHLBSevc OJ1BWwdrx8frs8iamnI2ejmOmJsgVqX8oo5WyM0WvHtinvBifLwBF9/N84Ewan0bX8/s23iHKpP lbFtXOEo4Xvccgbj5zBKo588LpcNz2SKpkBg== X-Gm-Gg: AYBFou3mRu444lItw0YWbN6vekIAQdcRP8K5XhsLqJtIfQoNfvl1KIKR7aIPoek3bas iOUDaUQQ2VFBJCvx+GWM4lzaopEpXXFyBRO0GC6Z9CgJp1W0YlJ/c3t57letJgTZPFegtYZf6uc kQbKXQDl+fBJHvXW+cGLosSCJ3eXZagjIQdukgo2PzyO9eeh9/TWUrtNXMzyoP1qZvv66muvA2B gk/0yymGbrEpHiHo3emy/2N6a8+s49YocNF5xncTETtsZ2yZnOEYJmH30f+of4fesy/9S31XUEX 8Ac1KBayUAK77h0CHYe1flY3LobPkpKucxp7AP01JxZmholXXanUezcTJZCTSRG03Y6HE7vTW02 NtEHbGf1QxeZsRuCNjN35pNk= X-Received: by 2002:a05:600c:1d08:b0:49d:2450:68ac with SMTP id 5b1f17b1804b1-49e619b57admr14913625e9.5.1789071107815; Thu, 10 Sep 2026 13:11:47 -0700 (PDT) X-Received: by 2002:a05:600c:1d08:b0:49d:2450:68ac with SMTP id 5b1f17b1804b1-49e619b57admr14912795e9.5.1789071107265; Thu, 10 Sep 2026 13:11:47 -0700 (PDT) Date: Thu, 10 Sep 2026 16:11:45 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Andrey Drobyshev , Stefano Garzarella Subject: [PULL 10/90] vhost: factor out vhost_dev_init_backend() Message-ID: <7bb122158b931f22b40f7e9bd3e44a63744661d5.1789071042.git.mst@redhat.com> References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-Mailer: git-send-email 2.51.2.2891.g4157995a80.dirty X-Mutt-Fcc: =sent 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=170.10.129.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com 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, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=0.001, SPF_HELO_PASS=-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-Zoho-Virus-Status: 1 X-Zoho-AV-Stamp: zmail-av-0.2.13.1.5.4/289.74.40 X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1789079530074158500 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Andrey Drobyshev Split the first part of vhost_dev_init(): selecting the backend, calling its .vhost_init() and reading the supported features - into a new vhost_dev_init_backend() helper, and call it from vhost_dev_init(). This is in preparation for CPR restore of vhost-vsock, which needs to learn the backend's features at realize time to negotiate them when loading the incoming virtio state, but also must defer taking ownership of the device to post_load. vhost_dev_init_backend() does exactly the pre-ownership part. As a result VHOST_SET_OWNER now follows the feature query rather than precedes it. This should be safe, as no backend requires ownership before VHOST_GET_FEATURES - the kernel and vdpa backends do not check ownership for it, and vhost-user already does query features from its .vhost_init() before set_owner(). Signed-off-by: Andrey Drobyshev Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin Message-ID: <20260820113955.509478-7-andrey.drobyshev@virtuozzo.com> --- include/hw/virtio/vhost.h | 22 ++++++++++++++++++++++ hw/virtio/vhost.c | 33 +++++++++++++++++++++++---------- 2 files changed, 45 insertions(+), 10 deletions(-) diff --git a/include/hw/virtio/vhost.h b/include/hw/virtio/vhost.h index 684bafcaad..9b98d34dd0 100644 --- a/include/hw/virtio/vhost.h +++ b/include/hw/virtio/vhost.h @@ -156,6 +156,28 @@ int vhost_dev_init(struct vhost_dev *hdev, void *opaqu= e, VhostBackendType backend_type, uint32_t busyloop_timeout, Error **errp); =20 +/** + * vhost_dev_init_backend() - set up the backend and query its features + * @hdev: the common vhost_dev structure + * @opaque: opaque ptr passed to backend (vhost/vhost-user/vdpa) + * @backend_type: type of backend + * @errp: error handle + * + * Select the backend, initialise the backend instance and read its suppor= ted + * features into @hdev, without issuing VHOST_SET_OWNER, setting up the + * virtqueues or registering the memory listener. This is the part of + * vhost_dev_init() that precedes taking ownership; it can be used on its = own + * so feature negotiation can happen before ownership is acquired (e.g. by= CPR + * restore). + * + * On failure the backend may be left partially initialised; the caller mu= st + * still call vhost_dev_cleanup() to release it. + * + * Return: 0 on success, non-zero on error while setting errp. + */ +int vhost_dev_init_backend(struct vhost_dev *hdev, void *opaque, + VhostBackendType backend_type, Error **errp); + /** * vhost_dev_cleanup() - tear down and cleanup vhost interface * @hdev: the common vhost_dev structure diff --git a/hw/virtio/vhost.c b/hw/virtio/vhost.c index 371dca17dd..f9b54c46f9 100644 --- a/hw/virtio/vhost.c +++ b/hw/virtio/vhost.c @@ -1668,6 +1668,28 @@ static int vhost_dev_init_features(struct vhost_dev = *hdev) return r; } =20 +int vhost_dev_init_backend(struct vhost_dev *hdev, void *opaque, + VhostBackendType backend_type, Error **errp) +{ + int r; + + r =3D vhost_set_backend_type(hdev, backend_type); + assert(r >=3D 0); + + r =3D hdev->vhost_ops->vhost_init(hdev, opaque, errp); + if (r < 0) { + return r; + } + + r =3D vhost_dev_init_features(hdev); + if (r < 0) { + error_setg_errno(errp, -r, "vhost_init_features failed"); + return r; + } + + return 0; +} + int vhost_dev_init(struct vhost_dev *hdev, void *opaque, VhostBackendType backend_type, uint32_t busyloop_timeou= t, Error **errp) @@ -1680,10 +1702,7 @@ int vhost_dev_init(struct vhost_dev *hdev, void *opa= que, hdev->vdev =3D NULL; hdev->migration_blocker =3D NULL; =20 - r =3D vhost_set_backend_type(hdev, backend_type); - assert(r >=3D 0); - - r =3D hdev->vhost_ops->vhost_init(hdev, opaque, errp); + r =3D vhost_dev_init_backend(hdev, opaque, backend_type, errp); if (r < 0) { goto fail; } @@ -1694,12 +1713,6 @@ int vhost_dev_init(struct vhost_dev *hdev, void *opa= que, goto fail; } =20 - r =3D vhost_dev_init_features(hdev); - if (r < 0) { - error_setg_errno(errp, -r, "vhost_init_features failed"); - goto fail; - } - limit =3D hdev->vhost_ops->vhost_memslots_limit(hdev); if (limit < MEMORY_DEVICES_SAFE_MAX_MEMSLOTS && memory_devices_memslot_auto_decision_active()) { --=20 MST From nobody Sat Sep 26 20:50:16 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=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1789081813; cv=none; d=zohomail.com; s=zohoarc; b=Mpt3Pozp9X+Or2xJRzDozsoUUKk0akgD0PXugyLiqwUOI5e7ymyDaGyT/tFV+jgYkWZe02o06d/bGpumR49rXNGq/sACWUQQDFMkOE0klY9EFLYikHuz1OwXZlFt6s7cYDZGm36Nb2dUx1HfrG0ADP5aYDmMYO3iH9QQA8enxbw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1789081813; h=Content-Type: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=5tTG7r4ospJl2zFiWFXBEc0cVcn4tmkTXMIavMez6uQ=; b=a9ZecTtd0Ibbq7pazYkRIZnSAg+6zyS6AEUiYqrc2Qs/97fE2glo8n+RfwDEORKp+x5f3Bqj4QRJaGaf032f947zjxqetm4W5A8rx+V55Ic/FJMLqM6XsKcxysoGgT6GmMNdSFEh5Pw19/vu2fpgGGYQOck7/l89bOfWJtPGKMw= 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 lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1789081813030951.8939715731797; Thu, 10 Sep 2026 16:10:13 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1x4ngN-0004l4-Gw; Thu, 10 Sep 2026 18:56:08 -0400 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 1x4lSX-0005Ze-AN for qemu-devel@nongnu.org; Thu, 10 Sep 2026 16:33:40 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1x4lSQ-0002Yq-9T for qemu-devel@nongnu.org; Thu, 10 Sep 2026 16:33:20 -0400 Received: from mail-wr1-f72.google.com (mail-wr1-f72.google.com [209.85.221.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-662-1gmGK18gMD2cMA8rBIYn0w-1; Thu, 10 Sep 2026 16:11:51 -0400 Received: by mail-wr1-f72.google.com with SMTP id ffacd0b85a97d-482e2541c30so114998f8f.1 for ; Thu, 10 Sep 2026 13:11:50 -0700 (PDT) Received: from redhat.com (IGLD-80-230-79-236.inter.net.il. [80.230.79.236]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-486eb32e7f5sm841004f8f.9.2026.09.10.13.11.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Sep 2026 13:11:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1789072269; 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=5tTG7r4ospJl2zFiWFXBEc0cVcn4tmkTXMIavMez6uQ=; b=dqHlFrdJyRuf3K8roxj9vtWZowj7F81EVXowIn46fO7sOqPj8CXt1+cFUmwNLaDJ+VDSHB y7w7CyXfv6qcXRGs+JIrepTEekpIM0veg1RD+oCSKSvnM4GL27PVe6RbDtRfscEAE1m8ea 69biDL+zbpUwe1AWmtCpErgDwa3hoz8= X-MC-Unique: 1gmGK18gMD2cMA8rBIYn0w-1 X-Mimecast-MFC-AGG-ID: 1gmGK18gMD2cMA8rBIYn0w_1789071110 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=google; t=1789071110; x=1789675910; 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=5tTG7r4ospJl2zFiWFXBEc0cVcn4tmkTXMIavMez6uQ=; b=KKennPOHpC+m78/sn5UihnwzHDfEk5t2cMssd9K+R1HTbGCMrkHyOB/X95GppP5O59 DN1lWGc5QhZShTEZF+aO1etDU8BXmZ+qG8fnocMcY9QI3Y8SgMqT+PJCtloJsyvQynLO VelTEDhY4f7nH0fsYpVoKPMzJdrThJEUzVet9AdDiOX5vn5pQGrpsj9j2x3fCq3NT3Qp 5ZDj7eDx8P/8WIVTgr3R0/9KoDP2+I9xzUNVEdxaWPecDj82J8b/3FFMU07wLoAGGEXJ 5xnZu2PZoyAnc9xU/M4ETWLXPRPmdLy7Ok7Hy5wNkGDmjrJneC6RfR0czOSUxJIaJiT0 RwVQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1789071110; x=1789675910; 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=5tTG7r4ospJl2zFiWFXBEc0cVcn4tmkTXMIavMez6uQ=; b=fIJo5x7yfFFLfGYicxDc/dAVxC3UaT3RoD0zm4GDdEHQWI2w6fO0PZEvUsDfmLPWup tEy4bhRJN+S3dB1XYRUFEKJUVXzMZAiS+fArtwL+6rk4LDTbP0l96LVmBn1NV8lctHAV tPuFmyhuZCSfTPiNdzB+fxsMJ3ndXJiuB11q+DAV01m+qbXZ5Od0kRh6bN4tJ8bhaC3v M1Bb14G8YB4gqJCCMWtqcq+tecbL4fvpfPvBxQXTJ85O1uuthIN5Bw7Jw0noAGvhWDp4 /Hn8MhuCDCXykKWBrZHUj67LwXea4mAJY5a+byrkriTHIkcvMRerIHWOd38GXdkbI0RQ nnGg== X-Gm-Message-State: AFuF++nh0Pud9DXjYgPWO4UJf46Ri9RyDtLsYlY/krBZ/Vo1gaSCZW+s ztUiu3zKCEaE67MsfTu5HR9AJGrHHrh2QopnmAZbVtqVnd7jBAo9LI8JFXlmZV7kc2jTmxIHxb8 qD03wBeYiluxboRo2r7fP8OTMAt68FzGM22/byjsf7BgwDLeIqPuH+SKws5iHFB5dLjoYP+80ao iPz7Av+xMv4NZb45OeEgRO2AtXIEwMIZ2Iww== X-Gm-Gg: AYBFou3If2ST3/+5XtTlBWzViskjEfV4CUtNncoMLGbiX4VYzOi174mYcpvZcrOPjnz W5MWjZZPlAKrCJjLcqvQLjWcaMjQRNOvgjg4PN8+7FQKbMApZxHEtRVXQVnjr/h9saJ7t5oPiOA 1WKhmXSZmVnJNNBvl+9b3q6+UHHMSp3qFtXqQ435y3C/KQEtbikxgNcNiUFKbVSp4Hv6IhlX/Oo Is0AXI5tGZyvNekamGRQH0RX694PcNUbjC8Hgkeh41MDrCUbY25YExyY2NlOt9P0DNbb7a/w2o3 2E94s5FMmHmbMtWYiqFHYksH4TaZvIhJmrFkS2+2eVR64Eywn4gJFij+Ecnfro8P6MpqBmR3b6B T32TwNcZvo6C4gCdzXoexEHI= X-Received: by 2002:a05:6000:4701:b0:485:8a07:3f0b with SMTP id ffacd0b85a97d-486d7309df9mr7516698f8f.0.1789071109884; Thu, 10 Sep 2026 13:11:49 -0700 (PDT) X-Received: by 2002:a05:6000:4701:b0:485:8a07:3f0b with SMTP id ffacd0b85a97d-486d7309df9mr7516665f8f.0.1789071109341; Thu, 10 Sep 2026 13:11:49 -0700 (PDT) Date: Thu, 10 Sep 2026 16:11:47 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Andrey Drobyshev , Stefano Garzarella Subject: [PULL 11/90] vhost: make vhost_dev_cleanup() safe on a partially initialized device Message-ID: <1d6177870c442be537ceaee55c832d3c4eee3464.1789071042.git.mst@redhat.com> References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-Mailer: git-send-email 2.51.2.2891.g4157995a80.dirty X-Mutt-Fcc: =sent 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=170.10.129.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com 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, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=0.001, SPF_HELO_PASS=-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-Zoho-Virus-Status: 1 X-Zoho-AV-Stamp: zmail-av-0.2.13.1.5.4/289.74.40 X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1789081814838158500 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Andrey Drobyshev A device which only went through vhost_dev_init_backend() has its VQs not yet initialized, so vq->dev is NULL and vhost_virtqueue_cleanup() would crash dereferencing it. Check vq->dev before use, so that vhost_dev_cleanup() can be called to release a device whose full vhost_dev_init() never ran or failed along the way. Signed-off-by: Andrey Drobyshev Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin Message-ID: <20260820113955.509478-8-andrey.drobyshev@virtuozzo.com> --- hw/virtio/vhost.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hw/virtio/vhost.c b/hw/virtio/vhost.c index f9b54c46f9..2bb9a23fee 100644 --- a/hw/virtio/vhost.c +++ b/hw/virtio/vhost.c @@ -1648,7 +1648,7 @@ fail_call: static void vhost_virtqueue_cleanup(struct vhost_virtqueue *vq) { event_notifier_cleanup(&vq->masked_notifier); - if (vq->dev->vhost_ops->vhost_set_vring_err) { + if (vq->dev && vq->dev->vhost_ops->vhost_set_vring_err) { event_notifier_set_handler(&vq->error_notifier, NULL); event_notifier_cleanup(&vq->error_notifier); } --=20 MST From nobody Sat Sep 26 20:50:16 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=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1789083235; cv=none; d=zohomail.com; s=zohoarc; b=ck/fVXO3PIOZw5C+4hTHtONXLA1TD6k6MtBcEtjTBCGDcJwpJtC2jYtGW7Dq8DBK+yVNNU2UDp7/yhVxgakVnjCGTOLTL2HCYx64obZq/9f+VxBnbGkQP/n3IWiOteMquxBAdPMUernhxCxO+qwvqcRpjVWnTUC1WP3zL7FWLOE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1789083235; h=Content-Type: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=DXlvSlMUeFS1LC0HetGaOS9EPv1rV9NRjwcngeZp5O0=; b=PaQ2OweipAgQdWkCWx2pH2iO41lW1CbHc1645s8ZQEMV/tqLV/yaz4fZuXIe+PyBSaC6A/3MA6M38d+wB7ryjSluRVS2JGQQpUfv9VSBwmqyMSMZNR12HMN+t0d5RA59//Dq8+96Ga6tZ5vgmX3HuOhkrWDtf9IuuhiAIJabaks= 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 lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1789083235225903.2034184556944; Thu, 10 Sep 2026 16:33:55 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1x4nw7-000198-Da; Thu, 10 Sep 2026 19:12:14 -0400 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 1x4lTR-0005q8-BQ for qemu-devel@nongnu.org; Thu, 10 Sep 2026 16:34:30 -0400 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 1x4lT2-0002bw-IK for qemu-devel@nongnu.org; Thu, 10 Sep 2026 16:34:07 -0400 Received: from mail-wr1-f70.google.com (mail-wr1-f70.google.com [209.85.221.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-364-RJQ_XtX7NrerKCOauaaPjQ-1; Thu, 10 Sep 2026 16:11:53 -0400 Received: by mail-wr1-f70.google.com with SMTP id ffacd0b85a97d-4843e59c32dso62850f8f.3 for ; Thu, 10 Sep 2026 13:11:53 -0700 (PDT) Received: from redhat.com (IGLD-80-230-79-236.inter.net.il. [80.230.79.236]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-486eaccaa1asm1180268f8f.0.2026.09.10.13.11.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Sep 2026 13:11:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1789072275; 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=DXlvSlMUeFS1LC0HetGaOS9EPv1rV9NRjwcngeZp5O0=; b=amMTJllUuOSh0p1za69NeMHCewX6688lqwGZITknNLTQMK55YIBIcOSHVSBv/Fub9pltJT nKqv0k9DqJMkSwbW3xlsoueonz5ZgQ5cFTRvkm9MV9COV2PQYOWSOV26Ga/A//iYVGcOhO RHgwEuBimKUBtRm8Q13J+koZrSHWAUo= X-MC-Unique: RJQ_XtX7NrerKCOauaaPjQ-1 X-Mimecast-MFC-AGG-ID: RJQ_XtX7NrerKCOauaaPjQ_1789071112 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=google; t=1789071112; x=1789675912; 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=DXlvSlMUeFS1LC0HetGaOS9EPv1rV9NRjwcngeZp5O0=; b=m7Xqr6SeNt180gwGGZDjQmVrJonO6kzuuXBXcZlmR8v/rUU/6pvW1due+HRYhbSK/d jsFxBC+lFvGtpEXe/FgqPxQJm2Oz3K+PzYy/ewbOBONtYblWbbBHN2g0y5KL6MJfa1Zk HNZKdnIMV8j9jyOf011TPbVv4AyGuslVr98zvqRh4AQpFGhNiO2cZsJqzccpalfRQMSA Vqpr0MuCf5qnJ+ct+pViEo6lHNs7ZzQpiGate/Yy9Mjh8HljyC+g/y3yyblq4U/g+TE6 H9w1jThxrilG+uNYeF8RWbTAi8XkCOwH4tbUbCPsZqYDxh2JEg3ktjEdbsQrfFudn2Mj 0Rdw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1789071112; x=1789675912; 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=DXlvSlMUeFS1LC0HetGaOS9EPv1rV9NRjwcngeZp5O0=; b=KHBVea9F4m7PLo7O3h0D0ivXDQCr8f8XN2w/VGJpyhCp+e8YFincVAg9lfJhG6bKVj Nw/RL+I5cRaZ6iGIetBf2RJO6qkEXwQ9XQBAthPWn1q+jc7N12DnUceoZTF9TEu5/e6s 7atVXDeyqDET6Oty6JmI/gzyKI1XGv5H4/fS6Ijj1vG3E8X58nPM5kFgkVjRphENRAON B5G7TSCH/W251NwoX3MLLq11x2JZS2C39DY7xl0sUtqHkT/Xm9ySxux+u/nfinEcEgKh hH3ecqRmyEQSJyPignr3Dd/Hj/JCAQ/WYCZuFXKM8IwkhAQrUtP6I0CkDdGanaBs2995 M5Vg== X-Gm-Message-State: AFuF++mCdgCTaenBJdCnYZ/TN9V6filOKMmg1q+Gz6kqixqL0kKMgvRV 86fCDkhDjNv61hM1V5LbtknrCFOowqs3Zfo6yx81HXp/L8Xv5TSkehuqJVK2WfJzFHbWEDV/bsq GqHt4BtICbdqHjN7W/+0mksEI6Gav7TewS6MoMxJHJiZq7Zv9mQN3GQVc71A/f90vRU/A6voz9i YFbgsycoXWczefYx3yd9ju3y0w+j5M1tg/Aw== X-Gm-Gg: AYBFou1AzgbRqroGpCOWB4117xbzJzR9GV/HJrHUfkYfKIVANsJWikIXwoPnpuqc5lK Kisg1nSuUmbesvCk708XmQlXSfv4yEJHgiHGJhBs3DqBKBtgrjSeYogoww9sz5btBc1VaR6QtnK cW4Xm0fK6DFE/dS+vHvv7WSXg/GyC6YNAztaWzgrqU4g+mWSmG4wmZpqeMsN9CYYBuv9v4Ku6u1 LrMybch2HylTX4KaSQzcZYJGJVMwfzuV1SOJ8UFUJwMhym3PysWrDar+WIe1eGFtNGH5opsx4/a 28q33DILpoPLPpzho+igCmFoddaglgcRh4ikBED7Qziaf6UnAeyH0FmUmYzz3oE43ezynoswKPl nw5es4HSm6ikRbI5Nf/tiHyA= X-Received: by 2002:a05:6000:2f86:b0:486:e73e:abe5 with SMTP id ffacd0b85a97d-486eb2e269amr867033f8f.10.1789071112101; Thu, 10 Sep 2026 13:11:52 -0700 (PDT) X-Received: by 2002:a05:6000:2f86:b0:486:e73e:abe5 with SMTP id ffacd0b85a97d-486eb2e269amr866983f8f.10.1789071111535; Thu, 10 Sep 2026 13:11:51 -0700 (PDT) Date: Thu, 10 Sep 2026 16:11:49 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Andrey Drobyshev , "Maciej S. Szmigiero" , Stefano Garzarella Subject: [PULL 12/90] vhost: add vhost_dev_set_owner() / vhost_dev_reset_owner() helpers Message-ID: <8a6790e5438a7e9e67125acfb8c441ae1b721b13.1789071042.git.mst@redhat.com> References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-Mailer: git-send-email 2.51.2.2891.g4157995a80.dirty X-Mutt-Fcc: =sent 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=170.10.133.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com 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, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_PASS=-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-Zoho-Virus-Status: 1 X-Zoho-AV-Stamp: zmail-av-0.2.13.1.5.4/289.74.40 X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1789083236522158500 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Andrey Drobyshev Wrap the set_owner/reset_owner backend ops in dev-level helpers, matching other vhost_dev_* wrappers, so device code can take or release ownership without reaching into vhost_ops directly. vhost_dev_init() now uses vhost_dev_set_owner(). Both return -ENOSYS if the backend has no such op. No functional change. These are used by the following vhost-vsock patch to hand a device between owners during CPR. Signed-off-by: Andrey Drobyshev Reviewed-by: Michael S. Tsirkin Acked-by: Maciej S. Szmigiero # for CPR Signed-off-by: Michael S. Tsirkin Message-ID: <20260820113955.509478-9-andrey.drobyshev@virtuozzo.com> --- include/hw/virtio/vhost.h | 13 +++++++++++++ hw/virtio/vhost.c | 20 +++++++++++++++++++- 2 files changed, 32 insertions(+), 1 deletion(-) diff --git a/include/hw/virtio/vhost.h b/include/hw/virtio/vhost.h index 9b98d34dd0..44e65968d9 100644 --- a/include/hw/virtio/vhost.h +++ b/include/hw/virtio/vhost.h @@ -178,6 +178,19 @@ int vhost_dev_init(struct vhost_dev *hdev, void *opaqu= e, int vhost_dev_init_backend(struct vhost_dev *hdev, void *opaque, VhostBackendType backend_type, Error **errp); =20 +/** + * vhost_dev_set_owner() / vhost_dev_reset_owner() - take / release owners= hip + * @hdev: the common vhost_dev structure + * + * Take (VHOST_SET_OWNER) or release (VHOST_RESET_OWNER) ownership of a + * device that has already been set up. Used to hand a device over during + * CPR. Returns -ENOSYS if the backend has no such op. + * + * Return: 0 on success, negative errno on failure. + */ +int vhost_dev_set_owner(struct vhost_dev *hdev); +int vhost_dev_reset_owner(struct vhost_dev *hdev); + /** * vhost_dev_cleanup() - tear down and cleanup vhost interface * @hdev: the common vhost_dev structure diff --git a/hw/virtio/vhost.c b/hw/virtio/vhost.c index 2bb9a23fee..ea17bf0108 100644 --- a/hw/virtio/vhost.c +++ b/hw/virtio/vhost.c @@ -1690,6 +1690,24 @@ int vhost_dev_init_backend(struct vhost_dev *hdev, v= oid *opaque, return 0; } =20 +int vhost_dev_set_owner(struct vhost_dev *hdev) +{ + assert(hdev->vhost_ops); + if (!hdev->vhost_ops->vhost_set_owner) { + return -ENOSYS; + } + return hdev->vhost_ops->vhost_set_owner(hdev); +} + +int vhost_dev_reset_owner(struct vhost_dev *hdev) +{ + assert(hdev->vhost_ops); + if (!hdev->vhost_ops->vhost_reset_owner) { + return -ENOSYS; + } + return hdev->vhost_ops->vhost_reset_owner(hdev); +} + int vhost_dev_init(struct vhost_dev *hdev, void *opaque, VhostBackendType backend_type, uint32_t busyloop_timeou= t, Error **errp) @@ -1707,7 +1725,7 @@ int vhost_dev_init(struct vhost_dev *hdev, void *opaq= ue, goto fail; } =20 - r =3D hdev->vhost_ops->vhost_set_owner(hdev); + r =3D vhost_dev_set_owner(hdev); if (r < 0) { error_setg_errno(errp, -r, "vhost_set_owner failed"); goto fail; --=20 MST From nobody Sat Sep 26 20:50:16 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=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1789078388; cv=none; d=zohomail.com; s=zohoarc; b=UsK6uLpAPEtovLgOfoHhtt6jUrw4enwjn2dgZv2n3PpWl0zqeh0tIBQezgAdrkcxx4Ra+OaF+lmv0gbJY5BZlNllt7NWiAL+E/9qZN0YEDSNRxOc5UoWuIAXmBW6gwH6nfPcSn2S9egZ8fLGlLnpvhKWFhqYue4Lq9AvuR1UMGw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1789078388; h=Content-Type: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=wZrDckEuRqXcdJQtcRSJZ7IayS+V6IuygbIlsWDcXKU=; b=RKn36iWqVFBbFYV277a1Kvg5GJU0hgeggNmtfw1enG9+CLkNI9mt5km0R5F4D3yPlVaJIkg/FjbAWxeenLrRyL1zRWa5ElXPrNAyUAtWEtkS2/BxtsvslK20x8o6TnibXGM8QpUX+zkfkuYQy0nS7bwSrmEp7XgMhPmiF6kwaQs= 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 lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1789078388122901.8200540912226; Thu, 10 Sep 2026 15:13:08 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1x4moi-00081d-2C; Thu, 10 Sep 2026 18:01:18 -0400 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 1x4lWk-0006al-1t for qemu-devel@nongnu.org; Thu, 10 Sep 2026 16:38:07 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1x4lWQ-0004he-97 for qemu-devel@nongnu.org; Thu, 10 Sep 2026 16:37:31 -0400 Received: from mail-wm1-f69.google.com (mail-wm1-f69.google.com [209.85.128.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-204-lF8ZaUVZPk68mUIj_gV0HQ-1; Thu, 10 Sep 2026 16:11:55 -0400 Received: by mail-wm1-f69.google.com with SMTP id 5b1f17b1804b1-49d28ac5735so2319675e9.0 for ; Thu, 10 Sep 2026 13:11:55 -0700 (PDT) Received: from redhat.com (IGLD-80-230-79-236.inter.net.il. [80.230.79.236]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-486eaccaa1asm1180583f8f.0.2026.09.10.13.11.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Sep 2026 13:11:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1789072563; 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=wZrDckEuRqXcdJQtcRSJZ7IayS+V6IuygbIlsWDcXKU=; b=WDa3FiQFxTA5tlYUA/gKsmQYqQ7jzp1URPjiX6zqKcYjA6JOzSBuRnwSm9yUbg/QPabCUI c4bW0pD2YlkMTXBWJDbempuhy5GfaBR2IIeKtkJOitWPTuGm9mu/yTIU1TYNBCbCWANNlR Bo21tiKf/PU6WFRFWYyr+34m39jnm6A= X-MC-Unique: lF8ZaUVZPk68mUIj_gV0HQ-1 X-Mimecast-MFC-AGG-ID: lF8ZaUVZPk68mUIj_gV0HQ_1789071114 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=google; t=1789071114; x=1789675914; 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=wZrDckEuRqXcdJQtcRSJZ7IayS+V6IuygbIlsWDcXKU=; b=EateLUatgA7aO1trNMQmEnfNpdL5mjBWg2f+NpExbWyooko7bBdpAkUDp/OXeLHtYt csOoENjlP++pGHkpUN7/8FXX6fUUc7qYHI8dIy7DJJPO1jsA4d+iRV31zMeOcnFqy+6E n+iLfxreNa4LxWW1U2LXRyqPgSRo91G6cXhi9PhE++0UV7e0M0rwmMpuQGkiuLMymXVm bfzfeQl+XwfmFkOHKYVQToIezoTYMpGbyPo84eZmPjHYzbVFvc4ybzmsY7bLFh+cGVYf ig4b2qmuw0oMlL/kzHMiKamhTjKrT/0Gl4QDa6sryWLF17tyoxqrAgvltxbEKAGNcDCW rd6A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1789071114; x=1789675914; 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=wZrDckEuRqXcdJQtcRSJZ7IayS+V6IuygbIlsWDcXKU=; b=b1v+Vw9XTT+iCe5R2ItyOa+Rims5jf6s7MOcC7rMbKyKPggCTtUqyQ91wtszzTf1O5 UWifpxh9PlJkqL8PZW37y3KMw4lQ8wLntJNoyAA9YSbaArW1ZCZGFb2fEFRc0a3J8J9v z3lJNRk6wbOz1Y0fqlqqxYiFxpr1ZF/JNKXmn9vSCRyo+fr+0wohiyUioY1to5I3Jbg/ oHFnTI6qI7iUzuwfArW/ADBXMThiv0DaQpzJtOFhc9yDPSIIa5NY+sJfz8vGlRHG9/ZK A1GoX5xaeCHsN2XpPYA47D6oNVvUOSlLeLEfVA7HkiwCFrhFNOmtiBMmhC1dBpzm2G+Y xL1A== X-Gm-Message-State: AFuF++nMY8j6R2A58B8iKAHx7ELQwN5DqpO+Gs7rlqxs6/qsSOQdDp+V rR+qPqpZHBAk+Az9XfcZoymyWjYBGFec/kIEcXr5Z/0efbyboLq25BV6cBHcWiRT1fl5VFs2uTR Aao+mkjqHngWp54Vv/TbHcwuszuJfSDt2VD2GKMR1eS6evnjRuG62Ixl05lhcgaEs7G74Trb9b1 82Oz4wnGH6PpTdS8UMIXrwd5dVtU8lbyxPBQ== X-Gm-Gg: AYBFou2NmjPP9r/PG8i1Tf1KyAw8CJeo88oEuCwpSrmApiO3N1+Z03IOi/OyCVfHGe/ n7vi+AaClPpVktgqjYtsN+BfK9oxFgATzg6ZuEyMmRDG1Gt/JX5hJJgCxdWazZLABov5C961/ZO 6GrsKn3lOnaYr4LVkCYjQWf+2sdkEbiiVYSkzlqoF3AxuPaasPsWEZToh6/QOgo6+mI9iAuuyrI 588TBgCYzxL7ndRtBM1V1TW78KcKSNHicmDYxZ8OCXtHfYzB98XV/BG5GgMX4l5Gesp+J6DmWrX AkVhAKe3+X3yisYat4kruqm2Fj2LkUU7izVKpEWKIbgZEwbeETPcVk73rLfAsQkkwN3EC9GQlUE FgQFj69MR+Oi4xs33YyUZsV8= X-Received: by 2002:a05:600c:3b27:b0:49d:10d6:fd55 with SMTP id 5b1f17b1804b1-49e619805dbmr7481885e9.1.1789071114105; Thu, 10 Sep 2026 13:11:54 -0700 (PDT) X-Received: by 2002:a05:600c:3b27:b0:49d:10d6:fd55 with SMTP id 5b1f17b1804b1-49e619805dbmr7481445e9.1.1789071113520; Thu, 10 Sep 2026 13:11:53 -0700 (PDT) Date: Thu, 10 Sep 2026 16:11:51 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Andrey Drobyshev , Stefano Garzarella Subject: [PULL 13/90] vhost: add vhost_dev_is_initialized() helper Message-ID: <66d0d51d79266778f2ac0cf8801fc18ad1aa9e32.1789071042.git.mst@redhat.com> References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-Mailer: git-send-email 2.51.2.2891.g4157995a80.dirty X-Mutt-Fcc: =sent 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=170.10.129.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com 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, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=0.001, SPF_HELO_PASS=-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-Zoho-Virus-Status: 1 X-Zoho-AV-Stamp: zmail-av-0.2.13.1.5.4/289.74.40 X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1789078390752158500 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Andrey Drobyshev The upcoming CPR support for vhost-vsock defers the full vhost_dev_init() to .post_load(). On an incoming CPR .realize() only sets up the backend, so we need a way to tell a fully initialized vhost device from a partially initialized one. Add an explicit 'bool initialized' field, set once vhost_dev_init() succeeds, and cleared only in vhost_dev_cleanup() (by memset(0)). Also add a public vhost_dev_is_initialized() helper. Suggested-by: Stefano Garzarella Signed-off-by: Andrey Drobyshev Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin Message-ID: <20260820113955.509478-10-andrey.drobyshev@virtuozzo.com> --- include/hw/virtio/vhost.h | 14 ++++++++++++++ hw/virtio/vhost.c | 2 ++ 2 files changed, 16 insertions(+) diff --git a/include/hw/virtio/vhost.h b/include/hw/virtio/vhost.h index 44e65968d9..7c4f032996 100644 --- a/include/hw/virtio/vhost.h +++ b/include/hw/virtio/vhost.h @@ -109,6 +109,8 @@ struct vhost_dev { uint64_t backend_cap; /* @started: is the vhost device started? */ bool started; + /* @initialized: has the full vhost_dev_init() completed? */ + bool initialized; bool log_enabled; uint64_t log_size; Error *migration_blocker; @@ -236,6 +238,18 @@ static inline bool vhost_dev_is_started(struct vhost_d= ev *hdev) return hdev->started; } =20 +/** + * vhost_dev_is_initialized() - report init status of vhost device + * @hdev: common vhost_dev structure + * + * Return true if the full vhost_dev_init() has completed successfully + * (and vhost_dev_cleanup() has not run since). + */ +static inline bool vhost_dev_is_initialized(struct vhost_dev *hdev) +{ + return hdev->initialized; +} + static inline int vhost_dev_set_vring_enable(struct vhost_dev *hdev, int e= nable) { if (!hdev->vhost_ops->vhost_set_vring_enable) { diff --git a/hw/virtio/vhost.c b/hw/virtio/vhost.c index ea17bf0108..a81cd94f90 100644 --- a/hw/virtio/vhost.c +++ b/hw/virtio/vhost.c @@ -1821,6 +1821,8 @@ int vhost_dev_init(struct vhost_dev *hdev, void *opaq= ue, goto fail; } =20 + hdev->initialized =3D true; + trace_vhost_dev_init_out(hdev); =20 return 0; --=20 MST From nobody Sat Sep 26 20:50:16 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=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1789084101; cv=none; d=zohomail.com; s=zohoarc; b=Ty0qb6ZwYNi5hLlCznDJMRpxzvMoVPm152Q7kUP4zCEbB4SDeks892QhPspjpJ/nHA40l4tYyOwBEI8WP5nYpbJ5LaCW5g+2mGBRf/coDsWFVbDaOpgTORgV4L+rK8A7MBW6kNwggeV3fBloUJnaO2b80gx2LcuQOevqJy3FNgU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1789084101; h=Content-Type: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=RD4dlmLlkNeM/6QiFlWXI6gFoCY42PMOKXH1p326AOs=; b=HDDoscKvtZOZEITit/QCxcalm02/MRVMdn4/ugjnnpK/6JF7rHDx6ZGmQ914E8FS3JeFwz9xG/4WW7KFfD5igT+PCfWZ6rC1B63iWJ+ajoVwW4LWXoQJvvJ/D+oGrW5POTVlH6dEFKw6e7LbqYJm6eFYQA813j+sGFpMCHgE1oo= 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 lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1789084101223852.3086364785096; Thu, 10 Sep 2026 16:48:21 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1x4oSU-0002E2-OU; Thu, 10 Sep 2026 19:45:51 -0400 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 1x4lS8-0005Is-6Z for qemu-devel@nongnu.org; Thu, 10 Sep 2026 16:33:10 -0400 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 1x4lRl-0002Xk-7d for qemu-devel@nongnu.org; Thu, 10 Sep 2026 16:32:44 -0400 Received: from mail-wm1-f71.google.com (mail-wm1-f71.google.com [209.85.128.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-424-SZRbGP6hPyWJ4zDZfok0mA-1; Thu, 10 Sep 2026 16:11:57 -0400 Received: by mail-wm1-f71.google.com with SMTP id 5b1f17b1804b1-49cced8309bso1983435e9.3 for ; Thu, 10 Sep 2026 13:11:57 -0700 (PDT) Received: from redhat.com (IGLD-80-230-79-236.inter.net.il. [80.230.79.236]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-49e62225628sm1025855e9.3.2026.09.10.13.11.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Sep 2026 13:11:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1789072266; 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=RD4dlmLlkNeM/6QiFlWXI6gFoCY42PMOKXH1p326AOs=; b=ddTVKjS9ObPxLoaGvzljAH0acTLJy1N2B5bDRT0ckU4KOx9WMXc3IyPEFfI/Ey0iT8ktZl zXkmC2MO9bcQ3LEcewp7kDmKxJNgOgKxG9tYKXXo4Vr+lsSrFcIkgf3eXOjSwL988K1zqK vz2W7feLAe51gKspbnVjFajAsnhhkxA= X-MC-Unique: SZRbGP6hPyWJ4zDZfok0mA-1 X-Mimecast-MFC-AGG-ID: SZRbGP6hPyWJ4zDZfok0mA_1789071117 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=google; t=1789071117; x=1789675917; 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=RD4dlmLlkNeM/6QiFlWXI6gFoCY42PMOKXH1p326AOs=; b=nsFx08Nbb4Dnq3590yrabTedAeyzShx/GzK84IcSg7TDeTYS/2g2th13mslXjX9s2p kaR9ny8XgUmbm5ht0RPvUEov2aFQCkUcy14r0M3Chieoz0VfxHcb6TD7PKiZRzFkJo7c FVo2DvqlD0PMx3W0ZkT3a/W/PVDKpN64VwuYRxAitZfGlm4GLtb9EMlaUAf1+akpi3xF WAA1z24u8suy55q8CKAWqkY3GDdKbdy1y3ZZD0DXbbCgQwHEtOBfaQTSPodACsT4SKqa G0NgsJftc5HZjKz5sRggJMRefTsKSI406Li+Su1vIvbsO4LWK5H75kFq1VckYTKLLq6j UHbA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1789071117; x=1789675917; 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=RD4dlmLlkNeM/6QiFlWXI6gFoCY42PMOKXH1p326AOs=; b=sMM1ttDLn5ODvjj2caN4UpPn4HP2CHuhpoxsBimoNpoIhr92lV2PWaY5AOG4Qdrtt9 BIvRhPRYojVK0zeZ4sHj3V2ZSIkkHvMdcBWM9KzuUFfvTDAKqlpaUQzGtwR72u0Jz10t LQEbpAqWZWkGlwd7rvZHT2Fp9siNr3qkbV+JrjH/pFaSsJBvwZSGaIZbkyo+ueZVCoXt mHxYAftvOXQUSF5oxn068FnBfFasnmzpCUFJ+R3LDhLLxvW7Fvd022xjt6v72+Mo2k2Q rYTtoRidDs8BKK9yHj146daDCuhMAX3tYgaVipLoEo0bM6w+ljZsDjVEwClJYVnFLk6f ihXw== X-Gm-Message-State: AFuF++kPAw+ZTtoAsKP8t32H7Y9wOJ9VidRFHrNc2UTWiCLql4L78An1 Hv+Whdglqg79i73yEPuA0TNsLEvxy8z2Df+YsEHxgc4UBNLssVxRvXyEkhBR251DaFFHV40FMf6 WGXInTaIcR8TRXri4zGOFai92Nic2jc+ZeBIqAGm1WURbkd/wWWMKQajq8+vpOvBlhCLFoArsz6 g1oYvuDwuThciyQCtP63ZbpNfOxBiV6zKiNw== X-Gm-Gg: AYBFou3G9gBghM0HY2taiDOhO/kH3mBcQBHflnvEpvupBTT+9NWWqMkZFdX4xPy5ceE V1RDVrSIe7mCZIDzP6cIORetbaC1X//tZOGah0NBk8yPI9FFCgajwMY941cI7vMH+3gqOzaA9gM /Mv9tg+UEyJFJW3lxLbkg55unBUii8a6Vgj8yI2jUNuSQm5iKCNEjtCoTDSk+gA3WehvoOtAWfl L0GtLvYN33GTKOw30XqNoUWKN66nf+2tz6wZpIpOMFhVc1zon+/t4McnhXJGD6jt32Cb6af8Cic 3Mu4lyeaqu7ydpVZ3ITGda4KvvWwwy4Pejpu0fhzHtBLnwQB8qbX73xkwP30oNkLbMhjaE2j9Dq LlZDwwB8TnUn2WZgztl/TsLA= X-Received: by 2002:a05:600c:1d08:b0:49c:fc6e:8cb4 with SMTP id 5b1f17b1804b1-49e619c4d64mr8159755e9.24.1789071116431; Thu, 10 Sep 2026 13:11:56 -0700 (PDT) X-Received: by 2002:a05:600c:1d08:b0:49c:fc6e:8cb4 with SMTP id 5b1f17b1804b1-49e619c4d64mr8159335e9.24.1789071115833; Thu, 10 Sep 2026 13:11:55 -0700 (PDT) Date: Thu, 10 Sep 2026 16:11:53 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Andrey Drobyshev , Dongli Zhang , Stefano Garzarella Subject: [PULL 14/90] vhost-vsock: hand off device ownership across CPR Message-ID: References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-Mailer: git-send-email 2.51.2.2891.g4157995a80.dirty X-Mutt-Fcc: =sent 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=170.10.133.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com 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, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_PASS=-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-Zoho-Virus-Status: 1 X-Zoho-AV-Stamp: zmail-av-0.2.13.1.5.4/289.74.40 X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1789084103169158500 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Andrey Drobyshev The previous patches reuse the source vhost FD on the destination, however both source and target still call vhost_dev_init() (VHOST_SET_OWNER) in realize(). For cpr-transfer the destination realizes while the source still owns the shared FD, so its SET_OWNER would fail - ownership has to be handed over explicitly. Do this through the device's CPR vmstate hooks. Namely, release device ownership in pre_save, reclaim in post_load, re-acquire on failure: - .pre_save() releases ownership on the source (VHOST_RESET_OWNER) once the VM is stopped, for the FD-preserving CPR modes (cpr-transfer and cpr-exec). - .realize(), for an incoming CPR, only sets up the virtio device and queries the backend features by calling vhost_dev_init_backend(). It doesn't take device ownership and doesn't touch the VQs which still-running source might use. The full init is deferred to .post_load(). - .post_load() reclaims it on the destination: the full vhost_dev_init() (VHOST_SET_OWNER) on the preserved FD, plus sets the guest cid, before the device is started at vm_start. - A MIG_EVENT_FAILED notifier re-acquires ownership if the migration fails after pre_save released it and the source VM is resumed. - .set_status() refuses to start a device whose handoff hasn't completed: not fully initialized yet, or left ownerless after a failed CPR. With the handoff in place, lift the CPR blocker: only ID-less devices, which can't preserve their FDs, remain blocked. Suggested-by: Dongli Zhang Signed-off-by: Andrey Drobyshev Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin Message-ID: <20260820113955.509478-11-andrey.drobyshev@virtuozzo.com> --- include/hw/virtio/vhost-vsock.h | 5 +- hw/virtio/vhost-vsock.c | 165 ++++++++++++++++++++++++++++---- 2 files changed, 152 insertions(+), 18 deletions(-) diff --git a/include/hw/virtio/vhost-vsock.h b/include/hw/virtio/vhost-vsoc= k.h index a964d57e1b..6d0cff4fb9 100644 --- a/include/hw/virtio/vhost-vsock.h +++ b/include/hw/virtio/vhost-vsock.h @@ -15,6 +15,7 @@ #define QEMU_VHOST_VSOCK_H =20 #include "hw/virtio/vhost-vsock-common.h" +#include "qemu/notify.h" #include "qom/object.h" =20 #define TYPE_VHOST_VSOCK "vhost-vsock-device" @@ -29,7 +30,9 @@ struct VHostVSock { /*< private >*/ VHostVSockCommon parent; VHostVSockConf conf; - Error *migration_blocker; /* CPR migration is not supported */ + Error *migration_blocker; /* set when the device has no ID */ + bool owner_reset; /* CPR released ownership; needs re-acquir= e */ + NotifierWithReturn cpr_notifier; /* re-acquires ownership if CPR fai= ls */ =20 /*< public >*/ }; diff --git a/hw/virtio/vhost-vsock.c b/hw/virtio/vhost-vsock.c index cec2c31f0c..e25e535090 100644 --- a/hw/virtio/vhost-vsock.c +++ b/hw/virtio/vhost-vsock.c @@ -73,9 +73,23 @@ static int vhost_vsock_set_running(VirtIODevice *vdev, i= nt start) static int vhost_vsock_set_status(VirtIODevice *vdev, uint8_t status) { VHostVSockCommon *vvc =3D VHOST_VSOCK_COMMON(vdev); + VHostVSock *vsock =3D VHOST_VSOCK(vdev); bool should_start =3D virtio_device_should_start(vdev, status); + bool initialized =3D vhost_dev_is_initialized(&vvc->vhost_dev); int ret; =20 + /* + * During CPR, on target the full vhost_dev_init() is deferred to + * post_load. On source the device is left without an owner if a + * failed CPR couldn't re-acquire it. Refuse to start in both cases + * rather than issue vhost ioctls on a half-initialised or ownerless + * device. + */ + if (should_start && (!initialized || vsock->owner_reset)) { + error_report("vhost-vsock: refusing to start, device init incomple= te"); + return 0; + } + if (vhost_dev_is_started(&vvc->vhost_dev) =3D=3D should_start) { return 0; } @@ -111,8 +125,67 @@ static uint64_t vhost_vsock_get_features(VirtIODevice = *vdev, return vhost_vsock_common_get_features(vdev, requested_features, errp); } =20 +/* + * Re-acquire device ownership if a CPR migration that released it (in + * vhost_vsock_pre_save()) failed and the source VM is about to resume. + * This runs before vm_start(), so the device is owned again before it is + * restarted. + */ +static int vhost_vsock_cpr_notifier(NotifierWithReturn *notifier, + MigrationEvent *e, Error **errp) +{ + VHostVSock *vsock =3D container_of(notifier, VHostVSock, cpr_notifier); + VHostVSockCommon *vvc =3D VHOST_VSOCK_COMMON(vsock); + int ret; + + if (e->type =3D=3D MIG_EVENT_FAILED && vsock->owner_reset) { + ret =3D vhost_dev_set_owner(&vvc->vhost_dev); + if (ret < 0) { + error_report("vhost-vsock: failed to re-acquire owner: %d", re= t); + } else { + vsock->owner_reset =3D false; + } + } + + return 0; +} + +static int vhost_vsock_pre_save(void *opaque) +{ + VHostVSockCommon *vvc =3D VHOST_VSOCK_COMMON(opaque); + VHostVSock *vsock =3D VHOST_VSOCK(opaque); + int ret; + + ret =3D vhost_vsock_common_pre_save(opaque); + if (ret) { + return ret; + } + + /* + * Release the device ownership now for CPR migration. The device is + * already stopped at pre_save, and destination reclaims it by calling + * VHOST_SET_OWNER in post_load. + */ + if (cpr_incoming_needed(NULL)) { + ret =3D vhost_dev_reset_owner(&vvc->vhost_dev); + if (ret < 0) { + error_report("vhost-vsock: vhost_reset_owner failed: %d", ret); + return ret; + } + vsock->owner_reset =3D true; + } + + return 0; +} + static int vhost_vsock_post_load(void *opaque, int version_id) { + VHostVSockCommon *vvc =3D VHOST_VSOCK_COMMON(opaque); + VirtIODevice *vdev =3D VIRTIO_DEVICE(opaque); + DeviceState *proxy =3D qdev_get_parent_bus(DEVICE(vdev))->parent; + Error *local_err =3D NULL; + int vhostfd, ret; + /* * Only reset vsock connections for non-CPR migration. For CPR the * guest cid is unchanged, and the cid-change reset would otherwise @@ -122,6 +195,32 @@ static int vhost_vsock_post_load(void *opaque, int ver= sion_id) return vhost_vsock_common_post_load(opaque, version_id); } =20 + /* + * CPR restore case. The source released device ownership in its + * pre_save. Complete the handoff here, before the device is started + * at vm_start. Init vhost device on preserved FD, issue + * VHOST_SET_OWNER on it, and restore the guest cid. + */ + vhostfd =3D cpr_find_fd(proxy->id, 0); + if (vhostfd < 0) { + error_report("vhost-vsock: could not find restored vhost FD"); + return -1; + } + + ret =3D vhost_dev_init(&vvc->vhost_dev, (void *)(uintptr_t)vhostfd, + VHOST_BACKEND_TYPE_KERNEL, 0, &local_err); + if (ret < 0) { + error_report_err(local_err); + return ret; + } + + ret =3D vhost_vsock_set_guest_cid(vdev); + if (ret < 0) { + error_report("vhost-vsock: unable to set guest cid: %d", ret); + vhost_dev_cleanup(&vvc->vhost_dev); + return ret; + } + return 0; } =20 @@ -133,7 +232,7 @@ static const VMStateDescription vmstate_virtio_vhost_vs= ock =3D { VMSTATE_VIRTIO_DEVICE, VMSTATE_END_OF_LIST() }, - .pre_save =3D vhost_vsock_common_pre_save, + .pre_save =3D vhost_vsock_pre_save, .post_load =3D vhost_vsock_post_load, }; =20 @@ -144,6 +243,7 @@ static void vhost_vsock_device_realize(DeviceState *dev= , Error **errp) VirtIODevice *vdev =3D VIRTIO_DEVICE(dev); VHostVSock *vsock =3D VHOST_VSOCK(dev); DeviceState *proxy =3D qdev_get_parent_bus(DEVICE(vsock))->parent; + bool cpr_incoming =3D cpr_is_incoming(); int vhostfd; int ret; =20 @@ -159,19 +259,30 @@ static void vhost_vsock_device_realize(DeviceState *d= ev, Error **errp) } =20 /* - * CPR migration of a vhost-vsock device is not supported yet: the - * device ownership is not handed over, so the target fails to set - * up its device. Fail the migration early and gracefully instead. + * With the ownership handoff in place CPR migration is now supported. + * Having a unique ID is mandatory for FD preservation during it, thus + * we only keep the migration blocker for the ID-less case. */ - error_setg(&vsock->migration_blocker, - "vhost-vsock: CPR migration is not supported"); - if (migrate_add_blocker_modes(&vsock->migration_blocker, - BIT(MIG_MODE_CPR_TRANSFER) | - BIT(MIG_MODE_CPR_EXEC), errp) < 0) { - return; + if (!proxy->id) { + error_setg(&vsock->migration_blocker, + "vhost-vsock: device ID is required for CPR migration"); + if (migrate_add_blocker_modes(&vsock->migration_blocker, + BIT(MIG_MODE_CPR_TRANSFER) | + BIT(MIG_MODE_CPR_EXEC), errp) < 0) { + return; + } } =20 - if (cpr_is_incoming()) { + /* + * Re-acquire ownership if a CPR migration releases it (in pre_save) b= ut + * then fails. + */ + migration_add_notifier_modes(&vsock->cpr_notifier, + vhost_vsock_cpr_notifier, + BIT(MIG_MODE_CPR_TRANSFER) | + BIT(MIG_MODE_CPR_EXEC)); + + if (cpr_incoming) { /* Reuse the fd handed over from the source QEMU. */ if (!proxy->id) { error_setg(errp, "vhost-vsock: device ID is required for " @@ -204,14 +315,32 @@ static void vhost_vsock_device_realize(DeviceState *d= ev, Error **errp) =20 vhost_vsock_common_realize(vdev); =20 - ret =3D vhost_dev_init(&vvc->vhost_dev, (void *)(uintptr_t)vhostfd, - VHOST_BACKEND_TYPE_KERNEL, 0, errp); - if (ret < 0) { + if (!cpr_incoming) { + ret =3D vhost_dev_init(&vvc->vhost_dev, (void *)(uintptr_t)vhostfd, + VHOST_BACKEND_TYPE_KERNEL, 0, errp); + if (ret < 0) { + /* + * vhostfd is closed by vhost_dev_cleanup, which is called + * by vhost_dev_init on initialization error. + */ + goto err_virtio; + } + } else { /* - * vhostfd is closed by vhost_dev_cleanup, which is called - * by vhost_dev_init on initialization error. + * CPR restore case: only learn the backend feature set now, but + * defer taking ownership or touching VQs (the still-running source + * might be using them). The full vhost_dev_init()/VHOST_SET_OWNER + * is done later in post_load. */ - goto err_virtio; + ret =3D vhost_dev_init_backend(&vvc->vhost_dev, + (void *)(uintptr_t)vhostfd, + VHOST_BACKEND_TYPE_KERNEL, errp); + if (ret < 0) { + /* vhost_dev_init_backend() does not close the fd on error */ + goto err_vhost_dev; + } + + return; } =20 ret =3D vhost_vsock_set_guest_cid(vdev); @@ -233,6 +362,7 @@ err_vhost_dev: err_virtio: vhost_vsock_common_unrealize(vdev); err_blocker: + migration_remove_notifier(&vsock->cpr_notifier); migrate_del_blocker(&vsock->migration_blocker); } =20 @@ -249,6 +379,7 @@ static void vhost_vsock_device_unrealize(DeviceState *d= ev) if (proxy->id) { cpr_delete_fd(proxy->id, 0); } + migration_remove_notifier(&vsock->cpr_notifier); migrate_del_blocker(&vsock->migration_blocker); vhost_dev_cleanup(&vvc->vhost_dev); vhost_vsock_common_unrealize(vdev); --=20 MST From nobody Sat Sep 26 20:50:16 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=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1789083217; cv=none; d=zohomail.com; s=zohoarc; b=iyZBsyqdghd1tNdKHxuWRKuGN3BhOoR4JltBEQxaMjqqo4BSm3FDhWArtOQNM+A4ZdB7aEEhjPfhmzV8tMuxxU4F0QqHCXGJozVJZ7+UTfK9l38dPjab7vbEDyxjep8jr60ToEfrPs/RtZJHteQqO91ZqJPE/KmFTzaQGUBlssg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1789083217; h=Content-Type: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=cK0jKLb9Y25sWTW+STMCp41/svnDlrpZe9udpBmpYJc=; b=n4BS7XHre3bEKXpJNXP6iNsWSdNbxkYf88cV6pCE+iinQckn825q86ie0FSEveBrUOwD5G5D5tjfIyAIYy4KU0SJzk8sy+rWl3tu1LIMrBVYFYaKMEGDzqIuoinihl5qYu5AlGr9ZMdd6HIDcCWq1nftsIHF/It1lc1O8qosmoo= 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 lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1789083217222860.0384934340883; Thu, 10 Sep 2026 16:33:37 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1x4npP-0007Ly-FI; Thu, 10 Sep 2026 19:05:31 -0400 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 1x4lRn-000534-3n for qemu-devel@nongnu.org; Thu, 10 Sep 2026 16:33:03 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1x4lRQ-0002Yu-RM for qemu-devel@nongnu.org; Thu, 10 Sep 2026 16:32:25 -0400 Received: from mail-wr1-f72.google.com (mail-wr1-f72.google.com [209.85.221.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-65-WaxveBleNaOGDKve5pPHEQ-1; Thu, 10 Sep 2026 16:12:00 -0400 Received: by mail-wr1-f72.google.com with SMTP id ffacd0b85a97d-47d81cf0c4cso67936f8f.2 for ; Thu, 10 Sep 2026 13:11:59 -0700 (PDT) Received: from redhat.com (IGLD-80-230-79-236.inter.net.il. [80.230.79.236]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-486eb33fc02sm731796f8f.16.2026.09.10.13.11.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Sep 2026 13:11:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1789072269; 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=cK0jKLb9Y25sWTW+STMCp41/svnDlrpZe9udpBmpYJc=; b=VMGVn6OfVBPoBH2pLwzFBu8MDFWlN4swwmA1spStIBse5j0Xr15W92j09jOsLIIVGJQslL lxuHX3JQltqUjtr6/NENZHEe2PHNq0FBuCGHa1+9XLiRSuTZExyR1WeLzdeyUaNUsdzPjN +IxAeHo/2JWoZCgwsaEmP5TEva7kRxU= X-MC-Unique: WaxveBleNaOGDKve5pPHEQ-1 X-Mimecast-MFC-AGG-ID: WaxveBleNaOGDKve5pPHEQ_1789071119 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=google; t=1789071119; x=1789675919; 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=cK0jKLb9Y25sWTW+STMCp41/svnDlrpZe9udpBmpYJc=; b=BGNoGcX+JJusVyUBOkS7qOFwgaPOXm1VIWUGJJcOBlNFwC6wlPXNxQl+2y+HxZ2yd+ NabjnwQqUnW8wQPp1Lv23577WQkZbAEwKR7KfdgMB4u4EzDldng0XtVJcUkSJrAQtg9W bMKCOcQ84jtQMxlyeOCcPglOlGztUaxd7bOQBaLN+SWpBl/f8VH7Z3K2RyLygPxlo96O D/ibOrAVG9E9scjIT+FuxL9oIbwRwj8XOdWeY+pnQTTTJzBre8cWO8ct4PX5KFTq4I15 euOFB3OBspH2a3n6zirqchr7ClPsqROVIk7X9S/ueDltsSUyISI1dUnzQxskmv23e+65 n37g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1789071119; x=1789675919; 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=cK0jKLb9Y25sWTW+STMCp41/svnDlrpZe9udpBmpYJc=; b=c06KOeY1P+qlv2p6vH2KUleO7vOiLiFj+KI12IBNUzZ0iou8zICkcPe5PpdIjpNGYy 9kUqbgejCSUtBW2ayT6JyyrTGgE9UW+7YqPA2mlksp2oIs0B5LJn27gicXE28TlcnbuC YQvMozEutKfn2ZuLHflLVz95zM/cZRgpXtlgo5OG2PqgoNZC6wqaIzF2UFFcKRTdKi1C enHuy99ePiKM2ZfWk4l7rMtwpAtVPGkfFCth/t9XPoFDTOK5U6119lH3HsT/8rJBsMme 0SK9NVaxC6QbdER1AKBmpAGu1XrbrkLIfNwRWrZU2uA8ac3CjhICdeKaTi/HtpEio6aT UEvQ== X-Gm-Message-State: AFuF++nhh0hF9W35cTHahh/VxJHmlx13SCwD8lT3mbTCdwPJu//qeyrv gLIbjFQEZf+QjbBKLVQvERM5Bh7m8SKj7ZO7CEenC/1uPJMGNpedZv6XDgiqf0oKK1JvzUi7LTB WNjIpJshFPh/QgcqOHX7zF5nDGpLILRBSKxWbYsUTr2ifSjIxcAzZ0sh1d4D44RKz8g+lOBd/BW ft2XCP/zj9ddUafopI6p3Sc+bCni/bd3WtvQ== X-Gm-Gg: AYBFou0uBIg9dJWFHRxL1BOoK73JXxltVKXVx0fKa4aGXeHnDv0UccArwybQrLOmZec XPusC+1YXDjc+Fj7fQnjL/P/MvhacfLAJikkFyeAycjZyWZTpRjsBzQAMU4KrA0YoUUIUTiGNR2 s1MhGClLuI6OOPZhxjpILrLnNpUFLiKzpqMN3WcNV6ADA+j+gchxiEBIYQu5Do6HXSeKVIcPTmG KTfTK1knNYv43z1Qnj4SvIsh9CwfwhpA++JzNTxgJvhlrmGqUaTKe/7kQlHv1cTRpOFOVirGUg/ hwVk1geWCl8dAQKxcF2RWjrXHxuKXPIju9YCMGV3gxVAIzuuHdP1y3TMx/wHhn2etq2gf/tABmr 9jGZRAZTCVqfdoqxH61nCUlU= X-Received: by 2002:a05:6000:454f:b0:485:acfd:4fa2 with SMTP id ffacd0b85a97d-486eb35833cmr716690f8f.28.1789071118647; Thu, 10 Sep 2026 13:11:58 -0700 (PDT) X-Received: by 2002:a05:6000:454f:b0:485:acfd:4fa2 with SMTP id ffacd0b85a97d-486eb35833cmr716646f8f.28.1789071118138; Thu, 10 Sep 2026 13:11:58 -0700 (PDT) Date: Thu, 10 Sep 2026 16:11:56 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Albert Esteve , Dorinda Bassey , Cornelia Huck , Paolo Bonzini Subject: [PULL 15/90] linux-headers: add VIRTIO_ID_MEDIA Message-ID: References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-Mailer: git-send-email 2.51.2.2891.g4157995a80.dirty X-Mutt-Fcc: =sent 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=170.10.129.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com 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, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=0.001, SPF_HELO_PASS=-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-Zoho-Virus-Status: 1 X-Zoho-AV-Stamp: zmail-av-0.2.13.1.5.4/289.74.40 X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1789083218299158500 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Albert Esteve The ID was added in Linux commit 2187be212179 ("virtio: Add ID for virtio media") and is included in v7.3-rc1. Signed-off-by: Albert Esteve Reviewed-by: Michael S. Tsirkin Tested-by: Dorinda Bassey Signed-off-by: Michael S. Tsirkin Message-ID: <20260901-virtio-media-v2-1-bd3cc9347ab9@redhat.com> --- include/standard-headers/linux/virtio_ids.h | 1 + 1 file changed, 1 insertion(+) diff --git a/include/standard-headers/linux/virtio_ids.h b/include/standard= -headers/linux/virtio_ids.h index 6c12db16fa..f9056af0c6 100644 --- a/include/standard-headers/linux/virtio_ids.h +++ b/include/standard-headers/linux/virtio_ids.h @@ -69,6 +69,7 @@ #define VIRTIO_ID_BT 40 /* virtio bluetooth */ #define VIRTIO_ID_GPIO 41 /* virtio gpio */ #define VIRTIO_ID_SPI 45 /* virtio spi */ +#define VIRTIO_ID_MEDIA 48 /* virtio media */ =20 /* * Virtio Transitional IDs --=20 MST From nobody Sat Sep 26 20:50:16 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=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1789081853; cv=none; d=zohomail.com; s=zohoarc; b=Oz+o+VRSTcfiKWXmEberZwkphPR6hDs6BXebznkOw6N9tImkho+4u7wmeSRj+b8H+pyWbjoJsN01mvRnDOC+hNoiJFFlsOHu1LvfJi2FGkq+uuGs9lk8S1ypQ52lvP2djHnEKZbezfCFHbfV372XISaC4hJKWKplbMq3UipqRaM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1789081853; h=Content-Type: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=7Pkx3kxAuiL1nB7bUYs1e0dAYEeoWG4XC8UPSEM/wlk=; b=hBlj6B2sIkBISCfNByIGnBN8NU9qHw7fAaJ2btH3/luUMhyevz7hDlGMGVVq75jLohLq0UXrQlC1D1W6UwOOfVFqrLnziABZUO6K8xIzWffTPqh34ibP1U51NXu1qzZ5QZ8NYGHl0zJpS5dwcAr0J7xVDu0ur2fMiuszvtzA2Xs= 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 lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1789081853048536.5883412201647; Thu, 10 Sep 2026 16:10:53 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1x4nrE-0007tT-5o; Thu, 10 Sep 2026 19:07:13 -0400 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 1x4lRr-0005BW-AK for qemu-devel@nongnu.org; Thu, 10 Sep 2026 16:33:03 -0400 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 1x4lRV-0002c5-LC for qemu-devel@nongnu.org; Thu, 10 Sep 2026 16:32:30 -0400 Received: from mail-wm1-f72.google.com (mail-wm1-f72.google.com [209.85.128.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-507-MY-9gvxmObyjAfyxyP0-vw-1; Thu, 10 Sep 2026 16:12:03 -0400 Received: by mail-wm1-f72.google.com with SMTP id 5b1f17b1804b1-490a767c7dcso1401685e9.2 for ; Thu, 10 Sep 2026 13:12:02 -0700 (PDT) Received: from redhat.com (IGLD-80-230-79-236.inter.net.il. [80.230.79.236]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-49d26c2985dsm162602505e9.6.2026.09.10.13.11.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Sep 2026 13:12:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1789072275; 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=7Pkx3kxAuiL1nB7bUYs1e0dAYEeoWG4XC8UPSEM/wlk=; b=QDO2ahh8kUpzxwE7YDAyH4p5g29y6V5oEyeBcFlJgv5+pfI9BABsxAicNpWkzN1MPnN+k+ UhB3If/0hqUF+skjJHYwyFBnax9HwskKEYLUMWgSV/tSUqBTUR3DT3PkBGJ4+vIqE8ajO1 HduIvuAzrozKWLMH9ruypQZdwkeoou0= X-MC-Unique: MY-9gvxmObyjAfyxyP0-vw-1 X-Mimecast-MFC-AGG-ID: MY-9gvxmObyjAfyxyP0-vw_1789071121 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=google; t=1789071121; x=1789675921; 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=7Pkx3kxAuiL1nB7bUYs1e0dAYEeoWG4XC8UPSEM/wlk=; b=n/2ksFCj99VHlIkxghIfXv5R6K4oombAafVU/7nNqOt+brQq/HE6BTQNuYD4aMGmI5 X8ClKGKmETXByXTmV7hwer/LE7xiiMsQ0q09/uDaDbr1L1AL5vaigyqZVkqaOr/Ldqzg mUGHPYPEVTg9ATJFDCrLR34zuU0dWoWoUat3VZz56kZtPJApa4Befd3B9m0nq9V55TGc m4UDiaAPK0NaxzMdVhU+33x68j5EnQELGKxeuR0yQTg+Fuxwepna4tFSkndpFz8shwmv reSRbuRhCAtvUkUai4IVaXfkKtyEefeUsNXrxjIt5hFn+Q1oOjaPKRTMoZXSHQlMx4aD iv/Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1789071121; x=1789675921; 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=7Pkx3kxAuiL1nB7bUYs1e0dAYEeoWG4XC8UPSEM/wlk=; b=JjW1YcJwQVErHzv1quJllvMfoyEjKSBDrMMsKJ3bBc9kvDk4d2vYBX0Be4AOeSJH13 HAS0jYta11K9FiMflegwirjLsZ1D2KmQpQ1T+4mezhN3zJEqupDCzi2uC3GWtNaJM2XV YNOQ3vOi6S3go86XpPPmK5aIPJaNmamK/jpeYKViEQVKVO+t+oXOveZ6YBEmbGr8PeJl 0M1X0XZu1KPQCFpDlz6dvul1ha/gP/J5JoDuu0f1BzDYuPElhlviCOWhF5j5SGKtXkKg Rq7jF2Fc+ff37Z4LyCC/Xyg6ZVOwk3zqOgxgCNApZ4HGIEe9020JVYe8ljJwQaUTsBIV n7Sw== X-Gm-Message-State: AFuF++ksr074DqsJaFC81SG014pfh3vrUlsxdILqrazVKVpfGd7oiVEd 3+SeAh/AUdRAAD/mx/xT/sPJV8qKjIgVLA96TDB47zoeu2F61pofDQecHoqK7gAqHydW/HUOGjR csnyddK79tOmnYsIX/vCq2pft0ZwD5+GSU6UAJ/m/Xq0w7/YoqV2aW7LhoYyIEQll+Z3aK7nM0F OzhjzVgLsdj5IAwaNhlT3hkCP+loiwx1E29w== X-Gm-Gg: AYBFou3kjMLUyjlCj8wSz2qoczmxqlsy1frG2TViz5vie6zzyDQ03Lg0J7W1FFtUf47 S7l/KBQttw5fJcKpT4rnt3W9/Y9zaNWlfPZ5qKXXEn9hRDAO6MdMW01aCVn3ktz++Mc6WVKm6By VWYCDstSiq+XO2f0yIxwwxd70uHrSbK5tKIJy+LI5f8qyCxx6/4pB1gtMuBhsU+g0mhOWnXw6u2 NfHYdPvPElbycA6cKBUcS6XvTnpbH4GoaQc9/rpO1LibD/A9sAGkMa8RH/c03SWYTUiHRHJ/gdJ qrQavuYpAzDoeWtRVL2Y1DtJ92G/Z26qBzLCTHWJ99OWZ93HspGFdIuYUPdWQZX4x/KiQ+3cNJS 8plnNaWVQTQd8vzUT5n4/uS0= X-Received: by 2002:a05:600c:a016:b0:49c:ffe3:2b3f with SMTP id 5b1f17b1804b1-49e619a0458mr8567945e9.3.1789071121137; Thu, 10 Sep 2026 13:12:01 -0700 (PDT) X-Received: by 2002:a05:600c:a016:b0:49c:ffe3:2b3f with SMTP id 5b1f17b1804b1-49e619a0458mr8567415e9.3.1789071120501; Thu, 10 Sep 2026 13:12:00 -0700 (PDT) Date: Thu, 10 Sep 2026 16:11:58 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Albert Esteve , Dorinda Bassey , Paolo Bonzini , Stefano Garzarella , =?utf-8?Q?Marc-Andr=C3=A9?= Lureau Subject: [PULL 16/90] hw/display: add vhost-user-media device Message-ID: References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-Mailer: git-send-email 2.51.2.2891.g4157995a80.dirty X-Mutt-Fcc: =sent 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=170.10.133.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com 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, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_PASS=-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-Zoho-Virus-Status: 1 X-Zoho-AV-Stamp: zmail-av-0.2.13.1.5.4/289.74.40 X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1789081854864158500 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Albert Esteve Add the QEMU side of the vhost-user-media device, which connects to a virtio-media vhost-user backend daemon implementing the V4L2 API over the virtio-media protocol. The virtio-media device is specified in the VirtIO specification v1.4, section 5.22: https://docs.oasis-open.org/virtio/virtio/v1.4/cs01/virtio-v1.4-cs01.ht= ml Tested with the rust-vmm vhost-device-media backend [1]: cargo run -- -s /path/to/media.sock -d /dev/video0 --backend v4l2-proxy Example invocation: qemu-system-x86_64 \ -chardev socket,path=3D/path/to/media.sock,id=3Dmedia \ -device vhost-user-media-pci,chardev=3Dmedia,id=3Dmedia [1] https://github.com/rust-vmm/vhost-device/tree/main/vhost-device-media Tested-by: Dorinda Bassey Signed-off-by: Albert Esteve Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin Message-ID: <20260901-virtio-media-v2-2-bd3cc9347ab9@redhat.com> --- MAINTAINERS | 6 + include/hw/virtio/vhost-user-media.h | 46 ++++ hw/display/vhost-user-media-pci.c | 80 ++++++ hw/display/vhost-user-media.c | 348 +++++++++++++++++++++++++++ hw/virtio/virtio.c | 3 +- hw/display/Kconfig | 5 + hw/display/meson.build | 3 + 7 files changed, 490 insertions(+), 1 deletion(-) create mode 100644 include/hw/virtio/vhost-user-media.h create mode 100644 hw/display/vhost-user-media-pci.c create mode 100644 hw/display/vhost-user-media.c diff --git a/MAINTAINERS b/MAINTAINERS index 7183babd6a..ec313c3259 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -2690,6 +2690,12 @@ S: Supported F: include/hw/virtio/vhost-user-rtc.h F: hw/virtio/vhost-user-rtc* =20 +vhost-user-media +M: Albert Esteve +S: Supported +F: hw/display/vhost-user-media* +F: include/hw/virtio/vhost-user-media.h + virtio-crypto M: Gonglei S: Supported diff --git a/include/hw/virtio/vhost-user-media.h b/include/hw/virtio/vhost= -user-media.h new file mode 100644 index 0000000000..d040c70f63 --- /dev/null +++ b/include/hw/virtio/vhost-user-media.h @@ -0,0 +1,46 @@ +/* + * vhost-user-media virtio device + * + * Copyright Red Hat, Inc. 2026 + * + * Authors: + * Albert Esteve + * + * SPDX-License-Identifier: GPL-2.0-or-later + */ + +#ifndef QEMU_VHOST_USER_MEDIA_H +#define QEMU_VHOST_USER_MEDIA_H + +#include "hw/virtio/virtio.h" +#include "hw/virtio/vhost.h" +#include "hw/virtio/vhost-user.h" +#include "qom/object.h" + +#define TYPE_VHOST_USER_MEDIA "vhost-user-media-device" +OBJECT_DECLARE_SIMPLE_TYPE(VHostUserMEDIA, VHOST_USER_MEDIA) + +/* virtio-media config layout, spec 5.22.4 */ +struct virtio_media_config { + uint32_t device_caps; + uint32_t device_type; + uint8_t card[32]; +} QEMU_PACKED; + +typedef struct { + CharFrontend chardev; +} VHostUserMEDIAConf; + +struct VHostUserMEDIA { + /*< private >*/ + VirtIODevice parent; + VHostUserMEDIAConf conf; + struct vhost_dev vhost_dev; + VhostUserState vhost_user; + VirtQueue *command_vq; + VirtQueue *event_vq; + bool connected; + /*< public >*/ +}; + +#endif /* QEMU_VHOST_USER_MEDIA_H */ diff --git a/hw/display/vhost-user-media-pci.c b/hw/display/vhost-user-medi= a-pci.c new file mode 100644 index 0000000000..3e09fcfdd0 --- /dev/null +++ b/hw/display/vhost-user-media-pci.c @@ -0,0 +1,80 @@ +/* + * Vhost-user MEDIA virtio device PCI glue + * + * Copyright Red Hat, Inc. 2026 + * Authors: Albert Esteve + * + * SPDX-License-Identifier: GPL-2.0-or-later + */ + +#include "qemu/osdep.h" +#include "qapi/error.h" +#include "hw/core/qdev-properties.h" +#include "hw/virtio/vhost-user-media.h" +#include "hw/virtio/virtio-pci.h" + +#define TYPE_VHOST_USER_MEDIA_PCI "vhost-user-media-pci-base" +OBJECT_DECLARE_SIMPLE_TYPE(VHostUserMEDIAPCI, VHOST_USER_MEDIA_PCI) + +struct VHostUserMEDIAPCI { + VirtIOPCIProxy parent_obj; + VHostUserMEDIA vdev; +}; + +static const Property vumedia_pci_properties[] =3D { + DEFINE_PROP_BIT("ioeventfd", VirtIOPCIProxy, flags, + VIRTIO_PCI_FLAG_USE_IOEVENTFD_BIT, true), + DEFINE_PROP_UINT32("vectors", VirtIOPCIProxy, nvectors, + DEV_NVECTORS_UNSPECIFIED), +}; + +static void vumedia_pci_realize(VirtIOPCIProxy *vpci_dev, Error **errp) +{ + VHostUserMEDIAPCI *dev =3D VHOST_USER_MEDIA_PCI(vpci_dev); + DeviceState *dev_state =3D DEVICE(&dev->vdev); + + if (vpci_dev->nvectors =3D=3D DEV_NVECTORS_UNSPECIFIED) { + vpci_dev->nvectors =3D 1; + } + + if (!qdev_realize(dev_state, BUS(&vpci_dev->bus), errp)) { + return; + } +} + +static void vumedia_pci_class_init(ObjectClass *klass, const void *data) +{ + DeviceClass *dc =3D DEVICE_CLASS(klass); + VirtioPCIClass *k =3D VIRTIO_PCI_CLASS(klass); + PCIDeviceClass *pcidev_k =3D PCI_DEVICE_CLASS(klass); + k->realize =3D vumedia_pci_realize; + set_bit(DEVICE_CATEGORY_MISC, dc->categories); + device_class_set_props(dc, vumedia_pci_properties); + pcidev_k->vendor_id =3D PCI_VENDOR_ID_REDHAT_QUMRANET; + pcidev_k->device_id =3D 0; /* Set by virtio-pci based on virtio id */ + pcidev_k->revision =3D 0x00; + pcidev_k->class_id =3D PCI_CLASS_MULTIMEDIA_VIDEO; +} + +static void vumedia_pci_instance_init(Object *obj) +{ + VHostUserMEDIAPCI *dev =3D VHOST_USER_MEDIA_PCI(obj); + + virtio_instance_init_common(obj, &dev->vdev, sizeof(dev->vdev), + TYPE_VHOST_USER_MEDIA); +} + +static const VirtioPCIDeviceTypeInfo vumedia_pci_info =3D { + .base_name =3D TYPE_VHOST_USER_MEDIA_PCI, + .non_transitional_name =3D "vhost-user-media-pci", + .instance_size =3D sizeof(VHostUserMEDIAPCI), + .instance_init =3D vumedia_pci_instance_init, + .class_init =3D vumedia_pci_class_init, +}; + +static void vumedia_pci_register(void) +{ + virtio_pci_types_register(&vumedia_pci_info); +} + +type_init(vumedia_pci_register); diff --git a/hw/display/vhost-user-media.c b/hw/display/vhost-user-media.c new file mode 100644 index 0000000000..14edc7c668 --- /dev/null +++ b/hw/display/vhost-user-media.c @@ -0,0 +1,348 @@ +/* + * Vhost-user Media device + * + * Copyright Red Hat, Inc. 2026 + * + * This is the boilerplate for instantiating a vhost-user device + * implementing a virtio-media device. + * + * Authors: + * Albert Esteve + * + * SPDX-License-Identifier: GPL-2.0-or-later + */ + +#include "qemu/osdep.h" +#include "qapi/error.h" +#include "qemu/error-report.h" +#include "hw/core/qdev-properties-system.h" +#include "standard-headers/linux/virtio_ids.h" +#include "hw/virtio/virtio-bus.h" +#include "hw/virtio/vhost-user-media.h" + +static const int feature_bits[] =3D { + VIRTIO_F_VERSION_1, + VIRTIO_F_NOTIFY_ON_EMPTY, + VIRTIO_RING_F_INDIRECT_DESC, + VIRTIO_RING_F_EVENT_IDX, + VIRTIO_F_RING_RESET, + VHOST_INVALID_FEATURE_BIT +}; + +static void +vu_media_get_config(VirtIODevice *vdev, uint8_t *config_data) +{ + VHostUserMEDIA *media =3D VHOST_USER_MEDIA(vdev); + Error *local_err =3D NULL; + int ret; + + memset(config_data, 0, sizeof(struct virtio_media_config)); + + ret =3D vhost_dev_get_config(&media->vhost_dev, + config_data, sizeof(struct virtio_media_con= fig), + &local_err); + if (ret) { + error_report_err(local_err); + return; + } +} + +static void vu_media_start(VirtIODevice *vdev) +{ + VHostUserMEDIA *media =3D VHOST_USER_MEDIA(vdev); + BusState *qbus =3D BUS(qdev_get_parent_bus(DEVICE(vdev))); + VirtioBusClass *k =3D VIRTIO_BUS_GET_CLASS(qbus); + int ret; + int i; + + if (!k->set_guest_notifiers) { + error_report("binding does not support guest notifiers"); + return; + } + + ret =3D vhost_dev_enable_notifiers(&media->vhost_dev, vdev); + if (ret < 0) { + error_report("Error enabling host notifiers: %d", -ret); + return; + } + + ret =3D k->set_guest_notifiers(qbus->parent, media->vhost_dev.nvqs, tr= ue); + if (ret < 0) { + error_report("Error binding guest notifier: %d", -ret); + goto err_host_notifiers; + } + + media->vhost_dev.acked_features =3D vdev->guest_features; + + media->vhost_dev.vq_index_end =3D media->vhost_dev.nvqs; + ret =3D vhost_dev_start(&media->vhost_dev, vdev, true); + if (ret < 0) { + error_report("Error starting vhost-user-media: %d", -ret); + goto err_guest_notifiers; + } + + /* + * guest_notifier_mask/pending not used yet, so just unmask + * everything here. virtio-pci will do the right thing by + * enabling/disabling irqfd. + */ + for (i =3D 0; i < media->vhost_dev.nvqs; i++) { + vhost_virtqueue_mask(&media->vhost_dev, vdev, i, false); + } + + return; + +err_guest_notifiers: + k->set_guest_notifiers(qbus->parent, media->vhost_dev.nvqs, false); +err_host_notifiers: + vhost_dev_disable_notifiers(&media->vhost_dev, vdev); +} + +static void vu_media_stop(VirtIODevice *vdev) +{ + VHostUserMEDIA *media =3D VHOST_USER_MEDIA(vdev); + BusState *qbus =3D BUS(qdev_get_parent_bus(DEVICE(vdev))); + VirtioBusClass *k =3D VIRTIO_BUS_GET_CLASS(qbus); + int ret; + + if (!k->set_guest_notifiers) { + return; + } + + vhost_dev_stop(&media->vhost_dev, vdev, true); + + ret =3D k->set_guest_notifiers(qbus->parent, media->vhost_dev.nvqs, fa= lse); + if (ret < 0) { + error_report("vhost guest notifier cleanup failed: %d", ret); + return; + } + + vhost_dev_disable_notifiers(&media->vhost_dev, vdev); +} + +static int vu_media_set_status(VirtIODevice *vdev, uint8_t status) +{ + VHostUserMEDIA *media =3D VHOST_USER_MEDIA(vdev); + bool should_start =3D virtio_device_should_start(vdev, status); + + if (vhost_dev_is_started(&media->vhost_dev) =3D=3D should_start) { + return 0; + } + + if (should_start) { + vu_media_start(vdev); + } else { + vu_media_stop(vdev); + } + return 0; +} + +static uint64_t vu_media_get_features(VirtIODevice *vdev, + uint64_t requested_features, + Error **errp) +{ + VHostUserMEDIA *media =3D VHOST_USER_MEDIA(vdev); + + return vhost_get_features(&media->vhost_dev, feature_bits, + requested_features); +} + +static void vu_media_handle_output(VirtIODevice *vdev, VirtQueue *vq) +{ + /* + * Not normally called; it's the daemon that handles the queue; + * however virtio's cleanup path can call this. + */ +} + +static void vu_media_guest_notifier_mask(VirtIODevice *vdev, int idx, + bool mask) +{ + VHostUserMEDIA *media =3D VHOST_USER_MEDIA(vdev); + + if (idx =3D=3D VIRTIO_CONFIG_IRQ_IDX) { + return; + } + + vhost_virtqueue_mask(&media->vhost_dev, vdev, idx, mask); +} + +static bool vu_media_guest_notifier_pending(VirtIODevice *vdev, int idx) +{ + VHostUserMEDIA *media =3D VHOST_USER_MEDIA(vdev); + + if (idx =3D=3D VIRTIO_CONFIG_IRQ_IDX) { + return false; + } + + return vhost_virtqueue_pending(&media->vhost_dev, idx); +} + +static int vu_media_handle_config_change(struct vhost_dev *dev) +{ + virtio_notify_config(dev->vdev); + return 0; +} + +static const VhostDevConfigOps media_ops =3D { + .vhost_dev_config_notifier =3D vu_media_handle_config_change, +}; + +static int vu_media_connect(DeviceState *dev) +{ + VirtIODevice *vdev =3D VIRTIO_DEVICE(dev); + VHostUserMEDIA *media =3D VHOST_USER_MEDIA(vdev); + + if (media->connected) { + return 0; + } + media->connected =3D true; + + /* restore vhost state */ + if (virtio_device_started(vdev, vdev->status)) { + vu_media_start(vdev); + } + + return 0; +} + +static void vu_media_disconnect(DeviceState *dev) +{ + VirtIODevice *vdev =3D VIRTIO_DEVICE(dev); + VHostUserMEDIA *media =3D VHOST_USER_MEDIA(vdev); + + if (!media->connected) { + return; + } + media->connected =3D false; + + if (vhost_dev_is_started(&media->vhost_dev)) { + vu_media_stop(vdev); + } +} + +static void vu_media_event(void *opaque, QEMUChrEvent event) +{ + DeviceState *dev =3D opaque; + VirtIODevice *vdev =3D VIRTIO_DEVICE(dev); + VHostUserMEDIA *media =3D VHOST_USER_MEDIA(vdev); + + switch (event) { + case CHR_EVENT_OPENED: + if (vu_media_connect(dev) < 0) { + qemu_chr_fe_disconnect(&media->conf.chardev); + return; + } + break; + case CHR_EVENT_CLOSED: + vu_media_disconnect(dev); + break; + case CHR_EVENT_BREAK: + case CHR_EVENT_MUX_IN: + case CHR_EVENT_MUX_OUT: + /* Ignore */ + break; + } +} + +static void do_vhost_user_cleanup(VirtIODevice *vdev, VHostUserMEDIA *medi= a, + struct vhost_virtqueue *vhost_vqs) +{ + virtio_delete_queue(media->command_vq); + virtio_delete_queue(media->event_vq); + g_free(vhost_vqs); + virtio_cleanup(vdev); + vhost_user_cleanup(&media->vhost_user); +} + +static void vu_media_device_realize(DeviceState *dev, Error **errp) +{ + VirtIODevice *vdev =3D VIRTIO_DEVICE(dev); + VHostUserMEDIA *media =3D VHOST_USER_MEDIA(dev); + struct vhost_virtqueue *vhost_vqs; + int ret; + + if (!media->conf.chardev.chr) { + error_setg(errp, "vhost-user-media: chardev is mandatory"); + return; + } + + if (!vhost_user_init(&media->vhost_user, &media->conf.chardev, errp)) { + return; + } + + virtio_init(vdev, VIRTIO_ID_MEDIA, sizeof(struct virtio_media_config)); + + media->command_vq =3D virtio_add_queue(vdev, 128, vu_media_handle_outp= ut); + media->event_vq =3D virtio_add_queue(vdev, 128, vu_media_handle_output= ); + media->vhost_dev.nvqs =3D 2; + media->vhost_dev.vqs =3D g_new0(struct vhost_virtqueue, + media->vhost_dev.nvqs); + vhost_vqs =3D media->vhost_dev.vqs; + + vhost_dev_set_config_notifier(&media->vhost_dev, &media_ops); + media->vhost_user.supports_config =3D true; + + ret =3D vhost_dev_init(&media->vhost_dev, &media->vhost_user, + VHOST_BACKEND_TYPE_USER, 0, errp); + if (ret < 0) { + do_vhost_user_cleanup(vdev, media, vhost_vqs); + return; + } + + qemu_chr_fe_set_handlers(&media->conf.chardev, NULL, + NULL, vu_media_event, + NULL, (void *)dev, NULL, true); +} + +static void vu_media_device_unrealize(DeviceState *dev) +{ + VirtIODevice *vdev =3D VIRTIO_DEVICE(dev); + VHostUserMEDIA *media =3D VHOST_USER_MEDIA(dev); + struct vhost_virtqueue *vhost_vqs =3D media->vhost_dev.vqs; + + /* This will stop vhost backend if appropriate. */ + vu_media_set_status(vdev, 0); + vhost_dev_cleanup(&media->vhost_dev); + do_vhost_user_cleanup(vdev, media, vhost_vqs); +} + +static const VMStateDescription vu_media_vmstate =3D { + .name =3D "vhost-user-media", + .unmigratable =3D 1, +}; + +static const Property vu_media_properties[] =3D { + DEFINE_PROP_CHR("chardev", VHostUserMEDIA, conf.chardev), +}; + +static void vu_media_class_init(ObjectClass *klass, const void *data) +{ + DeviceClass *dc =3D DEVICE_CLASS(klass); + VirtioDeviceClass *vdc =3D VIRTIO_DEVICE_CLASS(klass); + + device_class_set_props(dc, vu_media_properties); + dc->vmsd =3D &vu_media_vmstate; + set_bit(DEVICE_CATEGORY_MISC, dc->categories); + vdc->realize =3D vu_media_device_realize; + vdc->unrealize =3D vu_media_device_unrealize; + vdc->get_features =3D vu_media_get_features; + vdc->get_config =3D vu_media_get_config; + vdc->set_status =3D vu_media_set_status; + vdc->guest_notifier_mask =3D vu_media_guest_notifier_mask; + vdc->guest_notifier_pending =3D vu_media_guest_notifier_pending; +} + +static const TypeInfo vu_media_info =3D { + .name =3D TYPE_VHOST_USER_MEDIA, + .parent =3D TYPE_VIRTIO_DEVICE, + .instance_size =3D sizeof(VHostUserMEDIA), + .class_init =3D vu_media_class_init, +}; + +static void vu_media_register_types(void) +{ + type_register_static(&vu_media_info); +} + +type_init(vu_media_register_types) diff --git a/hw/virtio/virtio.c b/hw/virtio/virtio.c index 848fe8539e..0b2fbbed3f 100644 --- a/hw/virtio/virtio.c +++ b/hw/virtio/virtio.c @@ -198,7 +198,8 @@ const char *virtio_device_names[] =3D { [VIRTIO_ID_AUDIO_POLICY] =3D "virtio-audio-pol", [VIRTIO_ID_BT] =3D "virtio-bluetooth", [VIRTIO_ID_GPIO] =3D "virtio-gpio", - [VIRTIO_ID_SPI] =3D "virtio-spi" + [VIRTIO_ID_SPI] =3D "virtio-spi", + [VIRTIO_ID_MEDIA] =3D "virtio-media", }; =20 static const char *virtio_id_to_name(uint16_t device_id) diff --git a/hw/display/Kconfig b/hw/display/Kconfig index b3593fe981..060274b1e6 100644 --- a/hw/display/Kconfig +++ b/hw/display/Kconfig @@ -120,6 +120,11 @@ config VHOST_USER_VGA default y depends on VIRTIO_VGA && VHOST_USER_GPU =20 +config VHOST_USER_MEDIA + bool + default y + depends on VIRTIO && VHOST_USER + config DPCD bool select AUX diff --git a/hw/display/meson.build b/hw/display/meson.build index ffecedbf70..d8b4e121fe 100644 --- a/hw/display/meson.build +++ b/hw/display/meson.build @@ -37,6 +37,9 @@ system_ss.add(when: 'CONFIG_NEXTCUBE', if_true: files('ne= xt-fb.c')) system_ss.add(when: 'CONFIG_VGA', if_true: files('vga.c')) system_ss.add(when: 'CONFIG_VIRTIO', if_true: files('virtio-dmabuf.c')) system_ss.add(when: 'CONFIG_DM163', if_true: files('dm163.c')) +system_ss.add(when: 'CONFIG_VHOST_USER_MEDIA', if_true: files('vhost-user-= media.c')) +system_ss.add(when: ['CONFIG_VHOST_USER_MEDIA', 'CONFIG_VIRTIO_PCI'], + if_true: files('vhost-user-media-pci.c')) =20 stub_ss.add([files('acpi-vga-stub.c'), pixman]) if (config_all_devices.has_key('CONFIG_VGA_CIRRUS') or --=20 MST From nobody Sat Sep 26 20:50:16 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=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1789081648; cv=none; d=zohomail.com; s=zohoarc; b=NoqYSTKCOWZuuqqGSwp6e6XYosstfzcJzLIa9kO7xiLVuNx/d1M9eRl6scWoS5/wclnCQb+082MWDaN/eVCnGZ1jDBV1SeAqq8g7qmEhebdU3WFqiLew4M1RL9b5jr1T4w6vEsm3il3FRE7zxl4LpPw+4psnZ4bWfTjSENElqPM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1789081648; h=Content-Type: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=HW5dHu/luwrYtl1kcOiBVGsiXZR8UnfoA5Cn0Bb40EU=; b=gJwCPVf+OHiSrF/ON1uF0aDnXFswtyE+PY++Y2ZeCaXJ/cgbxzX71ly/8h87AirzARbF9i3g8OjzRJklUmg5NaUwImLVogFhXARFecnvhF33h97IwiwczGDJKZR6A3vnatsBLhJoj2Vw3twtk66qWfH7mTXE2wrhwTubqKyemrc= 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 lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1789081648987576.7604899421209; Thu, 10 Sep 2026 16:07:28 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1x4niQ-0005Ua-EB; Thu, 10 Sep 2026 18:58:34 -0400 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 1x4lW7-0006T9-Kz for qemu-devel@nongnu.org; Thu, 10 Sep 2026 16:37:23 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1x4lVn-0004ha-2D for qemu-devel@nongnu.org; Thu, 10 Sep 2026 16:36:54 -0400 Received: from mail-wr1-f70.google.com (mail-wr1-f70.google.com [209.85.221.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-441-hvobuiZnO82XStHAEjacaQ-1; Thu, 10 Sep 2026 16:12:05 -0400 Received: by mail-wr1-f70.google.com with SMTP id ffacd0b85a97d-48436a5fb42so52191f8f.1 for ; Thu, 10 Sep 2026 13:12:04 -0700 (PDT) Received: from redhat.com (IGLD-80-230-79-236.inter.net.il. [80.230.79.236]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-49d26c2985dsm162607925e9.6.2026.09.10.13.12.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Sep 2026 13:12:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1789072563; 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=HW5dHu/luwrYtl1kcOiBVGsiXZR8UnfoA5Cn0Bb40EU=; b=F+LnR/bQsKlx3L01kXI5utCG1oMmTOq72kJ4BqZ2L6bW7Z/XzJoDDK/9P4wqPkiMnzT9xL K4Xkgv6mvJGz2mff1vw9V8KCoEe5Sw5KyDsULQrX0xNbryYObBMhUjkJubM8sCFPP+uQFQ ukkaTkvWh/xD56qEEsh6gsrVFmDnXr8= X-MC-Unique: hvobuiZnO82XStHAEjacaQ-1 X-Mimecast-MFC-AGG-ID: hvobuiZnO82XStHAEjacaQ_1789071124 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=google; t=1789071124; x=1789675924; 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=HW5dHu/luwrYtl1kcOiBVGsiXZR8UnfoA5Cn0Bb40EU=; b=kh+2jypM8FI4Skx0Bm9m0tf0/ViVOZI+E+rwnxHSwNUU6i+N9yYsvft+ALdRGpNmEY s8hpZmRLlc+y0OR05q3sF8ki6Q+xNRjxx/uDM1aNIswws4W2ePKl9G2bLRa9QO419fkF bT4dppfhY4aqOWlj5nyhdy9xtd4XgwerWPlhGtuM1FH2YZlhntzu4f3LH3FcnJyyNZDb nRr9oYiE4QLSLRUAdVDl5kWlx0lRKxTLXXSeYGegOjud7GmdYazozpBBid5P6RmlhZzi IsKGhtqFFq61oDg8HUawQr/XJf8Vdee6gUYRI52So1hHOtBXp2ZkpbUU4jEtXNO9csmL PruA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1789071124; x=1789675924; 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=HW5dHu/luwrYtl1kcOiBVGsiXZR8UnfoA5Cn0Bb40EU=; b=Vr70Mg/EfGCeR7vpjgecTyLOTGhvrMHLPbe7yfSLEjvmKqepFnsOnJ5kOAy7dqggQ5 qEMIRKRug4SawcYW32T0iasEmh7Pv1dcmmRqmcHw1Iju4/ySFcEWZAhQGgCSWBjKslMj dM0kWOLqGpHZGbdfiTwKXmKt9UGxcGIVNZ9WPfXS3bNHMdrYh4omC5x0GFI4cWnmdnPI T8TMdhNJBkpBR9tWs2Y11lx/TRbglitg2Gm5IM+Wko4kg9Aoi++0nORyhpTbT3zljlZB 9TsW797uBtUSlMQA8y4rTKeSYT2jS+cCPEwXEnEVdNuZxZRZY1JSo6L+ep5gyDx30ve1 VJPw== X-Gm-Message-State: AFuF++mRz8Aep8/yOsfDagG4GNK7SH6iXf80/c1lwoHAl36FNrmGIfR0 AU/IYSH2Xl3HVGzyUkhEwN2m3xpFkM2bL6jGsiv2pi/a+nNJikUTNgxF2Pc16+z/q2w4aRNWMOv qVmt/BzjwE3NbreUZuHQDaNHnwMM1vq/xRbGGohkk6E4+z61ZZmxS5N9ev2e+62Xy/D8z1jzeFG W5+GswgpC64ZfEXxpfZGD1AmxlgOyLY7OaLA== X-Gm-Gg: AYBFou1Jqv9p+E05xtRjKDNE0o2PUvYcaz/7dNFrjU6qioE0lJA8emHYwke56thKsRm YzCi+9NhppIms8nl5H0JyPDmdRSws3LzsYFWcCqmdjJh9CyztUp96BSoABL9rXgtDFM5ecM7gYM pYhkqR8coLgKH3Uibup0GFKniC46a+WroJtGP3vg9G/AkuZzKolc1s8MhylcvST72aIbNRubh/4 xLvaNPsGnagLmzWYSjioavfXMgR9gJ1uVAYY6oScGyCDpcu/ttuuld1zzUBkzjCotpINVFTgSMI 4F2s/+d1RZtWq5MNnbVeeIWB6LmjPq46GYRmc0TKQUswQBu72wYcdUWbaJ0wTFS4YWLW209bmaP PwtJYTgY/CqT+n7lUz9zZrR4= X-Received: by 2002:a05:600c:4f88:b0:49b:2796:be30 with SMTP id 5b1f17b1804b1-49e6198cf7emr7106875e9.11.1789071123769; Thu, 10 Sep 2026 13:12:03 -0700 (PDT) X-Received: by 2002:a05:600c:4f88:b0:49b:2796:be30 with SMTP id 5b1f17b1804b1-49e6198cf7emr7106575e9.11.1789071123181; Thu, 10 Sep 2026 13:12:03 -0700 (PDT) Date: Thu, 10 Sep 2026 16:12:00 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Albert Esteve , Dorinda Bassey , =?utf-8?Q?Marc-Andr=C3=A9?= Lureau , Stefano Garzarella Subject: [PULL 17/90] hw/display/vhost-user-media: add shared memory region BAR Message-ID: <076c2922436da03ef55e767d4c5ba677c4c7739f.1789071042.git.mst@redhat.com> References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-Mailer: git-send-email 2.51.2.2891.g4157995a80.dirty X-Mutt-Fcc: =sent 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=170.10.129.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com 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, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=0.001, SPF_HELO_PASS=-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-Zoho-Virus-Status: 1 X-Zoho-AV-Stamp: zmail-av-0.2.13.1.5.4/289.74.40 X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1789081651818158500 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Albert Esteve Expose virtio-media shared memory region 0 (spec 5.22.6.1.6) as a prefetchable 64-bit PCI BAR (BAR 2) with a VirtIO shm capability. The size is obtained through GET_SHMEM_CONFIG and requires at least one shared region. The guest maps host-provisioned MMAP buffers into this window; QEMU creates a container region on realize, not a full-sized RAM allocation. modern-pio-notify is rejected because it claims BAR 2. vhost-user still needs shareable guest RAM, e.g.: -object memory-backend-memfd,id=3Dmem,size=3D4G,share=3Don \ -numa node,memdev=3Dmem Tested-by: Dorinda Bassey Signed-off-by: Albert Esteve Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin Message-ID: <20260901-virtio-media-v2-3-bd3cc9347ab9@redhat.com> --- hw/display/vhost-user-media-pci.c | 35 ++++++++++++++++++++++++++ hw/display/vhost-user-media.c | 42 ++++++++++++++++++++++++++++++- 2 files changed, 76 insertions(+), 1 deletion(-) diff --git a/hw/display/vhost-user-media-pci.c b/hw/display/vhost-user-medi= a-pci.c index 3e09fcfdd0..7681f7505d 100644 --- a/hw/display/vhost-user-media-pci.c +++ b/hw/display/vhost-user-media-pci.c @@ -13,12 +13,18 @@ #include "hw/virtio/vhost-user-media.h" #include "hw/virtio/virtio-pci.h" =20 +/* BAR 2 is used for the shared memory region exposed to the guest */ +#define VIRTIO_MEDIA_PCI_SHM_BAR 2 + +#define VIRTIO_MEDIA_PCI_SHMCAP_ID_SHM 0 + #define TYPE_VHOST_USER_MEDIA_PCI "vhost-user-media-pci-base" OBJECT_DECLARE_SIMPLE_TYPE(VHostUserMEDIAPCI, VHOST_USER_MEDIA_PCI) =20 struct VHostUserMEDIAPCI { VirtIOPCIProxy parent_obj; VHostUserMEDIA vdev; + MemoryRegion shmbar; }; =20 static const Property vumedia_pci_properties[] =3D { @@ -32,14 +38,43 @@ static void vumedia_pci_realize(VirtIOPCIProxy *vpci_de= v, Error **errp) { VHostUserMEDIAPCI *dev =3D VHOST_USER_MEDIA_PCI(vpci_dev); DeviceState *dev_state =3D DEVICE(&dev->vdev); + VirtIODevice *vdev =3D VIRTIO_DEVICE(dev_state); + VirtioSharedMemory *shmem; + uint64_t shm_size; =20 if (vpci_dev->nvectors =3D=3D DEV_NVECTORS_UNSPECIFIED) { vpci_dev->nvectors =3D 1; } =20 + if (vpci_dev->flags & VIRTIO_PCI_FLAG_MODERN_PIO_NOTIFY) { + error_setg(errp, "modern-pio-notify is not supported due to PCI BA= R " + "layout limitations"); + return; + } + if (!qdev_realize(dev_state, BUS(&vpci_dev->bus), errp)) { return; } + + shmem =3D virtio_find_shmem_region(vdev, VIRTIO_MEDIA_PCI_SHMCAP_ID_SH= M); + if (!shmem) { + error_setg(errp, "vhost-user-media: missing shared memory region"); + return; + } + shm_size =3D memory_region_size(&shmem->mr); + + memory_region_init(&dev->shmbar, OBJECT(vpci_dev), + "vhost-media-pci-shmbar", shm_size); + memory_region_add_subregion(&dev->shmbar, 0, &shmem->mr); + virtio_pci_add_shm_cap(vpci_dev, VIRTIO_MEDIA_PCI_SHM_BAR, 0, + shm_size, VIRTIO_MEDIA_PCI_SHMCAP_ID_SHM); + + /* After 'realized' so the memory region exists */ + pci_register_bar(&vpci_dev->pci_dev, VIRTIO_MEDIA_PCI_SHM_BAR, + PCI_BASE_ADDRESS_SPACE_MEMORY | + PCI_BASE_ADDRESS_MEM_PREFETCH | + PCI_BASE_ADDRESS_MEM_TYPE_64, + &dev->shmbar); } =20 static void vumedia_pci_class_init(ObjectClass *klass, const void *data) diff --git a/hw/display/vhost-user-media.c b/hw/display/vhost-user-media.c index 14edc7c668..eaf99dc6a2 100644 --- a/hw/display/vhost-user-media.c +++ b/hw/display/vhost-user-media.c @@ -19,6 +19,7 @@ #include "standard-headers/linux/virtio_ids.h" #include "hw/virtio/virtio-bus.h" #include "hw/virtio/vhost-user-media.h" +#include "migration/blocker.h" =20 static const int feature_bits[] =3D { VIRTIO_F_VERSION_1, @@ -259,8 +260,9 @@ static void vu_media_device_realize(DeviceState *dev, E= rror **errp) { VirtIODevice *vdev =3D VIRTIO_DEVICE(dev); VHostUserMEDIA *media =3D VHOST_USER_MEDIA(dev); + uint64_t memory_sizes[VIRTIO_MAX_SHMEM_REGIONS]; struct vhost_virtqueue *vhost_vqs; - int ret; + int ret, nregions; =20 if (!media->conf.chardev.chr) { error_setg(errp, "vhost-user-media: chardev is mandatory"); @@ -290,9 +292,47 @@ static void vu_media_device_realize(DeviceState *dev, = Error **errp) return; } =20 + ret =3D media->vhost_dev.vhost_ops->vhost_get_shmem_config(&media->vho= st_dev, + &nregions, + memory_sizes, + errp); + if (ret < 0) { + goto q_fail; + } + + if (!nregions || !memory_sizes[0]) { + error_setg(errp, "vhost-user-media: backend did not provide " + "shared memory region 0"); + goto q_fail; + } + + if (memory_sizes[0] % qemu_real_host_page_size() !=3D 0) { + error_setg(errp, "shared memory region 0 size must be a multiple " + "of the host page size"); + goto q_fail; + } + + if (media->vhost_dev.migration_blocker =3D=3D NULL) { + error_setg(&media->vhost_dev.migration_blocker, + "Migration disabled: devices with VIRTIO Shared Memory " + "Regions do not support migration yet."); + ret =3D migrate_add_blocker_normal(&media->vhost_dev.migration_blo= cker, + errp); + if (ret < 0) { + goto q_fail; + } + } + + virtio_new_shmem_region(vdev, 0, memory_sizes[0]); + qemu_chr_fe_set_handlers(&media->conf.chardev, NULL, NULL, vu_media_event, NULL, (void *)dev, NULL, true); + return; + +q_fail: + vhost_dev_cleanup(&media->vhost_dev); + do_vhost_user_cleanup(vdev, media, vhost_vqs); } =20 static void vu_media_device_unrealize(DeviceState *dev) --=20 MST From nobody Sat Sep 26 20:50:16 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=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1789082110; cv=none; d=zohomail.com; s=zohoarc; b=c15QhLQrYct2q0jt6vTGMlttyQZJGz/LNVoqKagmR81a7GpRHdv6p+ivXs4u5wZmOcDscra1wuqZfZJeCoy9NqSJH/CNh8zpc4BBcVzNcE0FvHN6eAqx05xiPDGZXWR+kTt+ZAYssxX6i42YI1LE9XBxABvd6arOJG+XeesEFCE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1789082110; h=Content-Type: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=UIh1PwEycfZASKTI05iblD1tmogo/rlgL3ovx7Py+Kg=; b=icgBSOod4hBpGGEX8kdx1NC95/lZxkJ50BXP7gF2Fl1y6dfs2AtD971F12Ib/nDCBpc9PxG6V77BsBD4GbOyvkFDHvjPoVPf7Vm+mcKpiCZ3n6Dd2K5xGNmeb0CNEzrKGXbKqS4+H0x/SLHeXjsszkUWF+Ba5F4uDdMjhxL9HYg= 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 lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1789082110132412.9270700828191; Thu, 10 Sep 2026 16:15:10 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1x4ngN-0004l3-Gd; Thu, 10 Sep 2026 18:56:07 -0400 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 1x4lMD-00037d-CA for qemu-devel@nongnu.org; Thu, 10 Sep 2026 16:27:26 -0400 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 1x4lM2-0000SX-Bf for qemu-devel@nongnu.org; Thu, 10 Sep 2026 16:26:50 -0400 Received: from mail-wr1-f71.google.com (mail-wr1-f71.google.com [209.85.221.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-599-2U1ANRveO4-xnfPjwOsFbA-1; Thu, 10 Sep 2026 16:12:08 -0400 Received: by mail-wr1-f71.google.com with SMTP id ffacd0b85a97d-485866e0066so41758f8f.2 for ; Thu, 10 Sep 2026 13:12:08 -0700 (PDT) Received: from redhat.com (IGLD-80-230-79-236.inter.net.il. [80.230.79.236]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-49e62217965sm1078175e9.2.2026.09.10.13.12.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Sep 2026 13:12:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1789071782; 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=UIh1PwEycfZASKTI05iblD1tmogo/rlgL3ovx7Py+Kg=; b=QB1JfPVbj6xkusTXi94NBzLh6ONztUZcFOPWgJYKN4uYUITlgdqMJ7Ic41q6M+qKsFwRkJ 04fMu4Ifs6iJwVlVHr2Z3oRjFXaKksG45/3k2MMt9stdxkAp+8pays18s5CfzNcYMEKbRB ij7itHdT63t4c63HKFIpGl40SZqPra4= X-MC-Unique: 2U1ANRveO4-xnfPjwOsFbA-1 X-Mimecast-MFC-AGG-ID: 2U1ANRveO4-xnfPjwOsFbA_1789071128 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=google; t=1789071127; x=1789675927; 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=UIh1PwEycfZASKTI05iblD1tmogo/rlgL3ovx7Py+Kg=; b=sB7WJBAHm95m5T3A71gOTjFojMwDXEHYailmOnJfcZbVtBIyZ0Cfe+eRnRKopNo7rs x2/9J4dBdf2KtgldBZMfzQVayvX2wi3F37ZSACnr7rKIOl/xxmhtud//ZEVoQBqM5j7n vbZkjxfdTX6wHh4WEVGsGTKK57v+7tHqSQsWYOLFYmFv/z7QX7GdIIanh0g6rt5mnSKq zCU1ygQ6ocwC2EpSEkPrKM4QFDt+WnzcNHRGVH6dE/C89v0w5n27cd6nQTmpVWOReJh+ 6RGUqAjMUkcxd/CNwgoU1Fc6L4lRZDgm3w/tOaLGsVWbSNKEmfcglkFbOSaKBhV4Llqh I+Rg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1789071127; x=1789675927; 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=UIh1PwEycfZASKTI05iblD1tmogo/rlgL3ovx7Py+Kg=; b=O/Q45B++RXGppvs3Mbb88cJxVTaij2WXevK/owpvelD7VlaATMHD6Ndh3I9taJJgJI X+WnKS38lP7OV3JdHZNVQHtyfMk0pg6ixIgla4yjPS0ydJktmk6fwwBf60YGT3YmteLu 4AIxrlvqDJOr0by4JNIO/f++ka1sU4I2KeZS76aqS6lR3CkuMOxN6l1sDw6aj1l+X7uT bMO+yce4w4YhGpoaicVPm8Ahh/WL7Uy0cUArLpVLKMZPbnWf6bEjAZOrLyh/FdDpHFHC 5rWIq70nCiVX/eF73a9nOnSB5qKj2sh7DDcdq/MvQi73WBNZ1eMx+rmF33mS/0otK4Vi 8Mog== X-Gm-Message-State: AFuF++lPD+4eRRRYOYWABPjI24hUF2RSZldbqL4iK6qlhBsn/B7BiMPJ td+2FPVs14FnylNVZzaKvvliNciA1CoI7MORkizss1ZH0Qqa0CU9OmljoSwTIgJTswjlmNw+Xd/ XkLLHtbXYLWWqtrnaFUJvUHNI0p6Wc/1DRTeaUFDyXOd9k5OL8aaG3ucyXOYlcS54mIkij83fiw JeltFPJqV40C0i7qyJrrqrckc7QRMatRYG8g== X-Gm-Gg: AYBFou3XKqX5t+pENzeHgJ21OeUZZng8Y7yo7kjtiliE2/125+zt88TJmMKsPYvh2vt URDWl21yOLMvn+CBUq9GZfgXD9Kr74VOIJwJmZ5rFJTLZiUk9caShC3Zn7ce3yTQdHwYrrxkk9O bpEnzz0L5UpkwQujpPT3yxoONAaWa+iG5/xqqUoAMRHSMK95IEfEyvrGji0DbSbF2jit5rXbTwy ne0FSx6o/kuSaUVY+WbhsGWWrHulKntaHiqDZGtIDa1s4qXLq9UvX9RImtwYV2G6Zgq1jrOyDxY nfnUwqPqzLhREYOSPD9p9Ez8P6UDijly4jI7hVFATDRLnG1lNXhir8hvMDhNkP1m/QMyl4TU1wk wZj72EUkOJNrO0p0pdfykPCc= X-Received: by 2002:a05:600c:540e:b0:49c:e1b5:b2bf with SMTP id 5b1f17b1804b1-49e61645616mr8756885e9.0.1789071127477; Thu, 10 Sep 2026 13:12:07 -0700 (PDT) X-Received: by 2002:a05:600c:540e:b0:49c:e1b5:b2bf with SMTP id 5b1f17b1804b1-49e61645616mr8756405e9.0.1789071126559; Thu, 10 Sep 2026 13:12:06 -0700 (PDT) Date: Thu, 10 Sep 2026 16:12:03 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Jia Jia Subject: [PULL 18/90] virtio: reduce code duplication for split ring Message-ID: <47c8210827a7ba1b85c3779c252b0260312dab0d.1789071042.git.mst@redhat.com> References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-Mailer: git-send-email 2.51.2.2891.g4157995a80.dirty X-Mutt-Fcc: =sent 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=170.10.133.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com 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, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_PASS=-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-Zoho-Virus-Status: 1 X-Zoho-AV-Stamp: zmail-av-0.2.13.1.5.4/289.74.40 X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1789082112114158500 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Jia Jia virtio_queue_empty_rcu duplicates virtqueue_num_heads for no good reason, let's not do it. As a nice side effect, we gain better handling for misbehaving guests. The virtio_device_disabled() check in virtio_queue_empty_rcu is redundant because virtqueue_split_pop() is only called through virtqueue_pop(), which already performs the check. Signed-off-by: Jia Jia Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin Message-ID: <20260726012857.1580646-1-physicalmtea@gmail.com> --- hw/virtio/virtio.c | 30 ++++++------------------------ 1 file changed, 6 insertions(+), 24 deletions(-) diff --git a/hw/virtio/virtio.c b/hw/virtio/virtio.c index 0b2fbbed3f..c9f9e5b511 100644 --- a/hw/virtio/virtio.c +++ b/hw/virtio/virtio.c @@ -717,26 +717,6 @@ static inline bool is_desc_avail(uint16_t flags, bool = wrap_counter) return (avail !=3D used) && (avail =3D=3D wrap_counter); } =20 -/* Fetch avail_idx from VQ memory only when we really need to know if - * guest has added some buffers. - * Called within rcu_read_lock(). */ -static int virtio_queue_empty_rcu(VirtQueue *vq) -{ - if (virtio_device_disabled(vq->vdev)) { - return 1; - } - - if (unlikely(!vq->vring.avail)) { - return 1; - } - - if (vq->shadow_avail_idx !=3D vq->last_avail_idx) { - return 0; - } - - return vring_avail_idx(vq) =3D=3D vq->last_avail_idx; -} - static int virtio_queue_split_empty(VirtQueue *vq) { bool empty; @@ -1773,12 +1753,14 @@ static void *virtqueue_split_pop(VirtQueue *vq, siz= e_t sz) address_space_cache_init_empty(&indirect_desc_cache); =20 RCU_READ_LOCK_GUARD(); - if (virtio_queue_empty_rcu(vq)) { + if (unlikely(!vq->vring.avail)) { + goto done; + } + + rc =3D virtqueue_num_heads(vq, vq->last_avail_idx); + if (rc <=3D 0) { goto done; } - /* Needed after virtio_queue_empty(), see comment in - * virtqueue_num_heads(). */ - smp_rmb(); =20 /* When we start there are none of either input nor output. */ out_num =3D in_num =3D elem_entries =3D 0; --=20 MST From nobody Sat Sep 26 20:50:16 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=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1789085842; cv=none; d=zohomail.com; s=zohoarc; b=TfHFVtIuRYR7AfRsvsjnjS1MQAcVxDb2AIMFbcbJnn1PgOfjrnFxtBU3kSPbvOew2iDwk5bSeAElxqgpRVVBRLRmQkNtANUi1dcXixLmiyMGngMmiK0WYqsXMW+ts2vp9i3Pq1o/9QaXd7Gu9as4qpns/6dTHh1n9Asjgy+tmwQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1789085842; h=Content-Type: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=hrTN7OVSCNm9vbc/NCEC/WvGaVnoOJUhrqiC5Yh7fcA=; b=VhC50ykZ7dHGnj2xC9zHPX/Rl8LwX9aWU31Unrf7tLxPMno0JvM05g6MA9wDWgX2X3LAUEYDFrmI8LilqvPN6NLQzzjmSA/tzzeNoeQcDU2pSBQwcDX2IQmuPJ1GDS1uZ8Iy/2yypqlzCjoXoTU9DtGFpiJeTeq1SQFNuFRgNIY= 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 lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1789085842096197.54729309259346; Thu, 10 Sep 2026 17:17:22 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1x4ouj-0001mc-C7; Thu, 10 Sep 2026 20:14:50 -0400 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 1x4ljr-0001gI-Pl for qemu-devel@nongnu.org; Thu, 10 Sep 2026 16:51:40 -0400 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 1x4ljf-0006Qy-4H for qemu-devel@nongnu.org; Thu, 10 Sep 2026 16:51:11 -0400 Received: from mail-wr1-f69.google.com (mail-wr1-f69.google.com [209.85.221.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-606-iy4EpvhXMjyVYc2al5Y48w-1; Thu, 10 Sep 2026 16:12:10 -0400 Received: by mail-wr1-f69.google.com with SMTP id ffacd0b85a97d-48597bbd963so91978f8f.2 for ; Thu, 10 Sep 2026 13:12:10 -0700 (PDT) Received: from redhat.com (IGLD-80-230-79-236.inter.net.il. [80.230.79.236]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-486eb32e7f5sm842549f8f.9.2026.09.10.13.12.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Sep 2026 13:12:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1789073463; 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=hrTN7OVSCNm9vbc/NCEC/WvGaVnoOJUhrqiC5Yh7fcA=; b=QaDSaHdhRzUuLtDy0yuq67Q12pY+w8vwyopXybTCqLGwdeTQODKMvrhyKYLvaAaq9MQ3OI kWJ28gX0/6Gi/3E5Fk9bTZQRudvBJiii/tMY+gTG9B0++37dTOjmuyInrMNopjZDWIsUhQ Cb5ZB9cMbfvcSlU64rm2O6az/Cj6gYI= X-MC-Unique: iy4EpvhXMjyVYc2al5Y48w-1 X-Mimecast-MFC-AGG-ID: iy4EpvhXMjyVYc2al5Y48w_1789071130 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=google; t=1789071129; x=1789675929; 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=hrTN7OVSCNm9vbc/NCEC/WvGaVnoOJUhrqiC5Yh7fcA=; b=O5Fk62u0X84WbDL03XFxRStj/8VJs7pEGDum5lPF+ySOHKL+zPCE2CnmRuOsYGJzIH E5MEaq6X658bGJQehc2NcGwDWuhBAbSALGbLGO7VSynG4bgV0PYLC5OI9Fb3pQ+TfAEa wMQlp+v1g70LO1y3iQ7oLLrVT/IMhzk8HClt7pUf0iKE3x6WcMahT8dIROn1fGJXgFmo 9lznMZnT4XjrexcrNAmgPmLdRlLVumLoz84X7Ug7XG40GOwU+dhvxGb9OLMOm3i0ajpJ Olx2LqawimiKy2kYjK2DZTpZKmzC7UpQuYfNE4pc/ElYrCH6n8XTbeicNv1VDWCz9A1j 9z9Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1789071129; x=1789675929; 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=hrTN7OVSCNm9vbc/NCEC/WvGaVnoOJUhrqiC5Yh7fcA=; b=X0mn4K2hs6C/vsLy+FqBn+fVt4CXYYbQeJTWo9FozMXQQsG15LpikAO7Vr04RiyTT5 33xagD/PgvtfLwF9ft3xqBCI95NJ3ju79XVv35YrpeBzd6M9CzdykHND8+6BezsgIy0l V4yRlD2FQWrLC7Kpxnq/PIwD22IqH1ag+aNEMdrt4aMb9W0/mjAuG82aPnMS3tWlXM3X n2tbTifTCC8FfmerLFwYarh2LsT6n/OHMLzFMd7qAYR0kJON15Z9yMLNZ3UEuEHkNwme DdUv0JcO6RoSiY3EGQNAWbBNTjYNNzq1I1LK4LamLG69Upi5RoljYo2x877P19Pyjbdc yBCA== X-Gm-Message-State: AFuF++lP4W2Ner1tClM3b5wfGtTYGwTuZchAbd29EHBsw1A6Ef1QfrDn RqWHWz0V/21uOIeGq/QuqY5Jum1If2DFJ2J329HsCP37sUZjBzdnOLeRGqqBMavfxpi2B97S6wq V0joZi9PB4rHh0ghVk0uSaUo0vblAsLNeifeHGFzPm5I7mfQSUE92vqNPA1TDzTiS9sXrejKaSD VBFJa5/4MAhY/4Rl92gRwVZAdpAwUKTccxiA== X-Gm-Gg: AYBFou2BJL49iBegvonaGu8FLetADjJl8teB8/LQge648jhlgcfcr2Fjhe664B7Qdam 1vmtKIcpwlarfS3mVxc6PkXVzPoh/sHxWyOpx09IWojWuuFjK51An8/NnKbQPodwTy2WZVCNhME LtuyK8dYN1cdsAKHMFDQzM019Ghv1kTemJUl6hpJJN7+PT/Ms/OH2GWTCwJZD8RfT4wvtzboihL BLukr7mu0zQztlCNZ4Wv2NwetADDa3VOP790lQshXTFnB28ZCBMzdj/fxGDvwXI+Mcxfla1R562 cCto8JfV/0lWU98jDfnVctTPir58aUPnwvhMXRW8bnOJXbOPiBo7igW0OcdPc+t182Pt/ENDztW EXvejeg8HqEmFvZ7hqJMOb7I= X-Received: by 2002:a05:6000:240b:b0:482:ea08:8c8a with SMTP id ffacd0b85a97d-486eb33c4f5mr972951f8f.20.1789071129508; Thu, 10 Sep 2026 13:12:09 -0700 (PDT) X-Received: by 2002:a05:6000:240b:b0:482:ea08:8c8a with SMTP id ffacd0b85a97d-486eb33c4f5mr972872f8f.20.1789071128909; Thu, 10 Sep 2026 13:12:08 -0700 (PDT) Date: Thu, 10 Sep 2026 16:12:06 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Vladimir Sementsov-Ogievskiy , Ben Chaney , Markus Armbruster , Jason Wang Subject: [PULL 19/90] net/tap: rework tap_parse_script Message-ID: <5a3751757db840eefeef8d0e061281edd31445de.1789071042.git.mst@redhat.com> References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-Mailer: git-send-email 2.51.2.2891.g4157995a80.dirty X-Mutt-Fcc: =sent 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=170.10.133.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com 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, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_PASS=-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-Zoho-Virus-Status: 1 X-Zoho-AV-Stamp: zmail-av-0.2.13.1.5.4/289.74.40 X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1789085844696158500 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Vladimir Sementsov-Ogievskiy Factor out tap_is_explicit_no_script() helper, to simplify further changes. Avoid extra copying by simpler code flow: first check for NULL / empty / "no" cases, then get default or do copying respectively. Signed-off-by: Vladimir Sementsov-Ogievskiy Reviewed-by: Ben Chaney Reviewed-by: Markus Armbruster Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin Message-ID: <20260819180201.1970193-2-vsementsov@yandex-team.ru> --- net/tap.c | 30 +++++++++++++++++++++++------- 1 file changed, 23 insertions(+), 7 deletions(-) diff --git a/net/tap.c b/net/tap.c index 57ffb09885..2076f5b780 100644 --- a/net/tap.c +++ b/net/tap.c @@ -92,19 +92,35 @@ static void launch_script(const char *setup_script, con= st char *ifname, static void tap_send(void *opaque); static void tap_writable(void *opaque); =20 -static char *tap_parse_script(const char *script_arg, const char *default_= path) +static bool tap_is_explicit_no_script(const char *script_arg_value) { - g_autofree char *res =3D g_strdup(script_arg); - - if (!res) { - res =3D get_relocated_path(default_path); + if (!script_arg_value) { + return false; } =20 - if (res[0] =3D=3D '\0' || strcmp(res, "no") =3D=3D 0) { + if (script_arg_value[0] =3D=3D '\0') { + return true; + } + + if (strcmp(script_arg_value, "no") =3D=3D 0) { + return true; + } + + return false; +} + +static char *tap_parse_script(const char *script_arg_value, + const char *default_path) +{ + if (tap_is_explicit_no_script(script_arg_value)) { return NULL; } =20 - return g_steal_pointer(&res); + if (!script_arg_value) { + return get_relocated_path(default_path); + } + + return g_strdup(script_arg_value); } =20 static void tap_update_fd_handler(TAPState *s) --=20 MST From nobody Sat Sep 26 20:50:17 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=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1789079239; cv=none; d=zohomail.com; s=zohoarc; b=HpFJ0ns7V//GHO17iUxWBpCPBAvEYdWm3KCGJsAPGKNvEZy6NhIcyeKtqoDeyLSQcfJY1EV0Yt4H2MG2GD1lViQ0iZcBUEh+cGBJ4shheY2cMC5qfjML8RYBM045eIORiRGQgCP7qy1uYu9mIe7id41Hrl5bSDwWWSnFWSpqQTQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1789079239; h=Content-Type: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=gBSHhMDPj1wNd+THvAUfp3LvU17AmLFoV6OMcA35G6I=; b=km1FFwLqpe1nzqdNYz05FZE6kUHmqBzHqqWT98g9hWrI4UhyaAD39sDvCY7HmFL4fUruxFNbYAagwXRXRHKxMeuJLix73FHprs5p4LjZSvBcAWB/pJ5vWtVlfK3FxwIEhA4Xvpe49tFFbVnaZIlBVoQFDcnH1KQ0A0LI8a8fHwg= 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 lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1789079239598703.2426970018888; Thu, 10 Sep 2026 15:27:19 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1x4nC2-00050A-0M; Thu, 10 Sep 2026 18:24:55 -0400 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 1x4lKg-0002gb-68 for qemu-devel@nongnu.org; Thu, 10 Sep 2026 16:25:34 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1x4lKS-0000S2-F9 for qemu-devel@nongnu.org; Thu, 10 Sep 2026 16:25:13 -0400 Received: from mail-wr1-f72.google.com (mail-wr1-f72.google.com [209.85.221.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-508-8oppo6ZEON-CUcA3h1GPpw-1; Thu, 10 Sep 2026 16:12:13 -0400 Received: by mail-wr1-f72.google.com with SMTP id ffacd0b85a97d-484337a63bbso55247f8f.3 for ; Thu, 10 Sep 2026 13:12:13 -0700 (PDT) Received: from redhat.com (IGLD-80-230-79-236.inter.net.il. [80.230.79.236]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-486eb36e4a6sm796159f8f.37.2026.09.10.13.12.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Sep 2026 13:12:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1789071781; 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=gBSHhMDPj1wNd+THvAUfp3LvU17AmLFoV6OMcA35G6I=; b=XC3EVB6q3fwHDOG43AvzZ4zj9iYOLYmyuLWfU04pQ1YoEql/NhShngPQ1YV3oFpBAVtyLz Yd1II5Sdm9rEHcSRNliXF0rPlFq9Yc1Fo8tVnCPNExUsTTH7Q5Unjsr/s0WwxhBRqVaF5m UICIKUSsIw72MolU3X10VM0CDVfFuwQ= X-MC-Unique: 8oppo6ZEON-CUcA3h1GPpw-1 X-Mimecast-MFC-AGG-ID: 8oppo6ZEON-CUcA3h1GPpw_1789071132 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=google; t=1789071132; x=1789675932; 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=gBSHhMDPj1wNd+THvAUfp3LvU17AmLFoV6OMcA35G6I=; b=Oj5tFq0Fu4D85/a49cOy926xfiVHapp5mbEaoLI+iv7S/KW2Fth4CTUqqfrzLnu8mz xiojhWpVucbiRzsViZ6KX3fm9J1pHrYI+VPl8GkBk8/Ti0w8YzxA6IVRoFUV69vaJEA7 NjMyZhQGUIFWSKmwGcWf2lEzwflwaYAcykDS8kN0Z5TlADfxBr0mRlsCp4hDEf1oVY+B Wg5AX12xrlCsXO4BjyHpIrkYzE0K1XTP3sqJylvAgSr4kmoxd7cZ1VREGDM9ZvkWQCQ1 NWce26a1xV+ML0YIlJbZ+ZLE3p+It2kFJHuN9y/0ZXJY+lJWgc6GVxHEh8Kk4z8DqiWh 4ExQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1789071132; x=1789675932; 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=gBSHhMDPj1wNd+THvAUfp3LvU17AmLFoV6OMcA35G6I=; b=Rgn6LqLM5AnlrYZ84vlB7aHVb0CkQJAFwauKbwslpi1goXSA/6H8DOSwf+OP8QBxGV IW6HZOQnv13FXLSGCWm1RJbeusQQ+Gt9ULIRKVMlDNSkfskfO69IvZr1Zi5xShyKTyIw PK6naQacju4A95kcv5XqyqBmDm5uemJdj5BXTLq74mZG6RITwUqWeb9PkLq4BVaU0LPT WQ/sdyZ5LGh1oSea/StHquCGXK4vT5y/XsDy7DIig9aX5YMYG3OWXzBUlhTJSnKVkWE5 t+y8AbHDUYuuUkt8BlQa5mCRngCbkwaxF7Jb1Z689X9iGQrYcf77tXMgiQ415jKFWJ4d gYdw== X-Gm-Message-State: AFuF++kMmqHzQLXCs7kUSnaFuETIPDVsKUQJDTDto5A3djIdqK2TaSxA uOvbA2zI7Ta2aF5eTjjFVgfSHRmnbZIJZI4YKCUz4huIMk7LPtZpK5h1T0Hy4TLcLc33tTOMw8T ZQ4cjhly/MIsaYvENEx+5BuIEh9t7vrkVNV4cxeLZYbIxOxECSFXScsuKO6AKp6CB2jBDZbftuq g+4ArY1EpicSI2sS6yLXjqmR1Flfg86Fkjzw== X-Gm-Gg: AYBFou2iqFKzWv/n2Yx2Tkg5g7ncwtw4Jq7DD2KPFdmRhpVwpBIhbyNXtxxs2XjW+wn jiXRZOe/eJU8RQ6POOpI1aLivGtLMJBjiqg+2/niJXQBbQ82wswpI0sS/07OeTUXQeFZ+EaQxyh /rtIJomb/0opiSCxOm1Fl76r+Mx0CS9oyH3KLLptIIL3o7oylRr6rNLaPPJOAVQqehFaUG+Jyb3 JdcglGqnUZ7QhlGMYE+vAuRCcgI+jnugI2Ct5Y/m9cAQ1uZbu2lkPaqDy56EufIE7vNNCL0aUOz FQViuP1BOzUc1Fm2hEXYWTzIpFChtF1wnRXx3Az4k3mne5gkgPqjP2E5wI1nTnSnvNbBvYkJvC2 b/IVIJxAzs5GZXs/QV2t2To0= X-Received: by 2002:a05:6000:4601:b0:485:8a46:b3ce with SMTP id ffacd0b85a97d-486eb3465e8mr572767f8f.54.1789071131862; Thu, 10 Sep 2026 13:12:11 -0700 (PDT) X-Received: by 2002:a05:6000:4601:b0:485:8a46:b3ce with SMTP id ffacd0b85a97d-486eb3465e8mr572719f8f.54.1789071131296; Thu, 10 Sep 2026 13:12:11 -0700 (PDT) Date: Thu, 10 Sep 2026 16:12:09 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Vladimir Sementsov-Ogievskiy , Markus Armbruster , Ben Chaney , Jason Wang , Eric Blake Subject: [PULL 20/90] net/tap: improve script/downscript options documentation Message-ID: <925f3dce8892f55d5760a7bba263be12f5c9460a.1789071042.git.mst@redhat.com> References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-Mailer: git-send-email 2.51.2.2891.g4157995a80.dirty X-Mutt-Fcc: =sent 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=170.10.129.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com 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, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=0.001, SPF_HELO_PASS=-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-Zoho-Virus-Status: 1 X-Zoho-AV-Stamp: zmail-av-0.2.13.1.5.4/289.74.40 X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1789079243243158500 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Vladimir Sementsov-Ogievskiy Properly document defaults and special values of "" and "no". Signed-off-by: Vladimir Sementsov-Ogievskiy Reviewed-by: Markus Armbruster Reviewed-by: Ben Chaney Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin Message-ID: <20260819180201.1970193-3-vsementsov@yandex-team.ru> --- qapi/net.json | 10 ++++++++-- qemu-options.hx | 9 +++++---- 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/qapi/net.json b/qapi/net.json index 85c78710fe..ab8ed9c086 100644 --- a/qapi/net.json +++ b/qapi/net.json @@ -399,9 +399,15 @@ # @fds: multiple file descriptors of already opened multiqueue capable # tap # -# @script: script to initialize the interface +# @script: script to initialize the interface. An empty string or +# "no" disables script execution. Defaults to +# ``/qemu-ifup``, where ```` is the +# system configuration directory at build time (typically /etc). # -# @downscript: script to shut down the interface +# @downscript: script to shut down the interface. An empty string or +# "no" disables script execution. Defaults to +# ``/qemu-ifdown``, where ```` is the +# system configuration directory at build time (typically /etc). # # @br: bridge name (since 2.8) # diff --git a/qemu-options.hx b/qemu-options.hx index 6c1713ed61..16ef7d5455 100644 --- a/qemu-options.hx +++ b/qemu-options.hx @@ -3022,7 +3022,7 @@ DEF("netdev", HAS_ARG, QEMU_OPTION_netdev, " use network scripts 'file' (default=3D" DEFAULT_NETWO= RK_SCRIPT ")\n" " to configure it and 'dfile' (default=3D" DEFAULT_NETW= ORK_DOWN_SCRIPT ")\n" " to deconfigure it\n" - " use '[down]script=3Dno' to disable script execution\n" + " use '[down]script=3Dno' or '[down]script=3D' to disab= le script execution\n" " use network helper 'helper' (default=3D" DEFAULT_BRID= GE_HELPER ") to\n" " configure it\n" " use 'fd=3Dh' to connect to an already opened TAP inte= rface\n" @@ -3558,9 +3558,10 @@ SRST Use the network script file to configure it and the network script dfile to deconfigure it. If name is not provided, the OS automatically provides one. The default network configure script is - ``/etc/qemu-ifup`` and the default network deconfigure script is - ``/etc/qemu-ifdown``. Use ``script=3Dno`` or ``downscript=3Dno`` to - disable script execution. + ``/qemu-ifup`` and the default network deconfigure script = is + ``/qemu-ifdown``, where ```` is the system + configuration directory at build time (typically ``/etc``). + Use ``[down]script=3Dno`` or ``[down]script=3D`` to disable script exe= cution. =20 If running QEMU as an unprivileged user, use the network helper to configure the TAP interface and attach it to the bridge. --=20 MST From nobody Sat Sep 26 20:50:17 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass(p=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1789071162; cv=none; d=zohomail.com; s=zohoarc; b=T+v37QxyCzbW62LLHPXZCFh/7G+wsduAXEgp63s61L8QVefj6crh7tXs2HdsL4B/n5N6m+humkADKPnfGjr0NyoqxIIKzvrG1vvE3zuWchsvuALC37tJ+R/Uk8OlMK5M4z4FFKKMx6xCRcBFzpT0Y6Jc4YYQTyDuFiQyBTSj62Y= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1789071162; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=g9mLgS0ybrUUaTMFusFVuyMEvSQGJ2PNYaEiCYholds=; b=Ifxog5HkSd4UZYFVyKADaOonQNfzz3B/m9zIxBvANOVQyadhryA/9iQXrQp1n8uy85jtNJDltj5Ooz/3v2L2KOimfzOjuex6wj9AU3y9hozjopg/rkLhmid9t3kVmHwEQkYR0wCgjXU9f1wKrphEaPbLRbjmH4gRp7WcbzGQEXM= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 17890711626921021.081072894829; Thu, 10 Sep 2026 13:12:42 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.1415320.1644768 (Exim 4.92) (envelope-from ) id 1x4l8B-0004eY-MJ; Thu, 10 Sep 2026 20:12:23 +0000 Received: by outflank-mailman (output) from mailman id 1415320.1644768; Thu, 10 Sep 2026 20:12:23 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1x4l8B-0004eR-JZ; Thu, 10 Sep 2026 20:12:23 +0000 Received: by outflank-mailman (input) for mailman id 1415320; Thu, 10 Sep 2026 20:12:22 +0000 Received: from mx.expurgate.net ([195.190.135.10]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1x4l89-0004eL-Ny for xen-devel@lists.xenproject.org; Thu, 10 Sep 2026 20:12:21 +0000 Received: from mx.expurgate.net (helo=localhost) by mx.expurgate.net with esmtp id 1x4l88-00GmME-Uq for xen-devel@lists.xenproject.org; Thu, 10 Sep 2026 22:12:20 +0200 Received: from [10.42.69.5] (helo=localhost) by localhost with ESMTP (eXpurgate MTA 0.9.1) (envelope-from ) id 6aa30f0b-bab6-0a2a0a5309dd-0a2a4505b7b2-18 for ; Thu, 10 Sep 2026 22:12:20 +0200 Received: from [170.10.133.124] (helo=us-smtp-delivery-124.mimecast.com) by tlsNG-c201ff.mxtls.expurgate.net with ESMTPS (eXpurgate 4.57.1) (envelope-from ) id 6aa30f22-4cb1-0a2a45050019-aa0a857c8189-3 for ; Thu, 10 Sep 2026 22:12:19 +0200 Received: from mail-wm1-f69.google.com (mail-wm1-f69.google.com [209.85.128.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-90-lDK37aFsOmSoGhOGRUYthg-1; Thu, 10 Sep 2026 16:12:17 -0400 Received: by mail-wm1-f69.google.com with SMTP id 5b1f17b1804b1-495474a5fbcso2069515e9.1 for ; Thu, 10 Sep 2026 13:12:17 -0700 (PDT) Received: from redhat.com (IGLD-80-230-79-236.inter.net.il. [80.230.79.236]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-49e62121747sm1798195e9.2.2026.09.10.13.12.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Sep 2026 13:12:14 -0700 (PDT) X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" Authentication-Results: eu.smtp.expurgate.cloud; dkim=pass header.s=mimecast20190719 header.d=redhat.com header.i="@redhat.com" header.h="From:Subject:Date:Message-ID:To:Cc:MIME-Version:Content-Type:Content-Transfer-Encoding:In-Reply-To:References" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1789071138; 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=g9mLgS0ybrUUaTMFusFVuyMEvSQGJ2PNYaEiCYholds=; b=i653n/VOhca+FLMIKoLwfxg51OwIncc7/bzU6xsrjt+nYsZGMC0fSUDqUHnWq0hVbBe5H5 0Zgc9vEbYxIka9B1oQtiLCXWrCILG26DDc9POhh+9aRKpZwKHE42azm/fCBLCDEbrl4teT 4v42u+R3jcPXsYCNwI0T3jTjkpZfyak= X-MC-Unique: lDK37aFsOmSoGhOGRUYthg-1 X-Mimecast-MFC-AGG-ID: lDK37aFsOmSoGhOGRUYthg_1789071136 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1789071136; x=1789675936; h=in-reply-to:content-transfer-encoding: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=g9mLgS0ybrUUaTMFusFVuyMEvSQGJ2PNYaEiCYholds=; b=EgTwWcFhwcLrfwbcsHli876Tp8IRGXfUGLQlESnY+dJBvYwCxgI6QjXNgKB9lkHfh8 kA0eK8MNXTPo+avql/aVDSDhpf+czSlOPOhAdYD56cTu2YBgnqwt2m5fx4USe4KM+BC5 BP7beVYmYMnlZpXnAtsouYqYc261cmNtibkHAtHDUT8S0Q5PIRwVnLC3y4CCMBrky8bx p18q7gWgEw/exTXa6ML7cDKfdtiFwu76e6zrbCpbasE90PogW4QOjJqfUtH06osBriSy Ydv7kSWV43xnCVbQjmwj76589bpHCR0Fa1DqE0rxGQDNGcgq/2/bDDuDbcAug92yt8ll 86xA== X-Forwarded-Encrypted: i=1; AKwUvByN5lvjTjikgnQdU73YG7cQAqppbML8AZUu6/X3aIYg0NaG3NYAMuA8T/3nGUdOJr+362srs0MS8ic=@lists.xenproject.org X-Gm-Message-State: AFuF++lk8GAK3gU4YUEbSYXhcgZ4vfkbI/USovL03Ccuv95GZHXrwacl 5RfQQCRhSQX8thLIOZ/AoH3Uw2e4d7P54YbwhwtlB4E/JnTuH08viJW3xt+r0afIV/WEHrNnHhs uDAqsqW3ZPYRPwqch2uNd22LZ87ewha+jY1Y5AlI8qaY3VXRdthGq7MkyPIG524XxGtV3 X-Gm-Gg: AYBFou3bajYhATSk8Kp9x5LdzV3wegP5iNUun6NU44+CeU8p6qz6h+8AJQh8hYzOB9w ohm45eZwHfmdPwnazRPrzKcGBy4SoDg1lrkQlAZhp5THkLTQNM1aS4fzKBKc+xnMK6vM/uJl4tb 4D5UWE/uDOyHpWL/PH4OLSv79cpzA12r+vzxqh1LNYN7OkjDJcQrUls88SgdZoJH5OomXRAqMV9 oeToQmheVD1Qe45sL6Dg3ayVASuBhlhdNePuUDlExyfOBVhNdnKkS70TSHM8FkLr+mqbtHiMZfN ZUgNEnu+ZR9/zO2bcPcC6McBJSdZYV1TGF1r16L7uxfR+CG0G9QBGYEL2y8NZNSdLpGS90VG52s dypsHlsLbadbwULPsDBgy4DA= X-Received: by 2002:a05:600d:8498:10b0:49d:1842:f001 with SMTP id 5b1f17b1804b1-49e6198f7bamr5892335e9.14.1789071135745; Thu, 10 Sep 2026 13:12:15 -0700 (PDT) X-Received: by 2002:a05:600d:8498:10b0:49d:1842:f001 with SMTP id 5b1f17b1804b1-49e6198f7bamr5891645e9.14.1789071134907; Thu, 10 Sep 2026 13:12:14 -0700 (PDT) Date: Thu, 10 Sep 2026 16:12:11 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Vladimir Sementsov-Ogievskiy , Ben Chaney , Markus Armbruster , Pierrick Bouvier , Sergio Lopez , Paolo Bonzini , Zhao Liu , Stefano Stabellini , Anthony PERARD , "Edgar E. Iglesias" , Bernhard Beschow , Conor Dooley , Sebastian Huber , Alistair Francis , Palmer Dabbelt , Jason Wang , Eric Blake , devel@lists.libvirt.org, xen-devel@lists.xenproject.org, qemu-ppc@nongnu.org, qemu-riscv@nongnu.org Subject: [PULL 21/90] net/tap: deprecate "no" as special value for script/downscript Message-ID: References: MIME-Version: 1.0 In-Reply-To: X-Mailer: git-send-email 2.51.2.2891.g4157995a80.dirty X-Mutt-Fcc: =sent X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: aw8ScHP_1bRBB_6QEQJQpPbPZoRVirTD24WSLuz3FB4_1789071136 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" Content-Disposition: inline Content-Transfer-Encoding: quoted-printable X-purgate-ID: tlsNG-c201ff/1789071140-71CA82A1-E5941498/0/0 X-purgate-type: clean X-purgate-size: 12712 X-Zoho-Virus-Status: 1 X-Zoho-AV-Stamp: zmail-av-0.2.13.1.5.4/289.52.80 X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1789071165463158500 From: Vladimir Sementsov-Ogievskiy The interface is ambiguous, as "no" is valid file name. So, using "no" as a special value to disable script is deprecated. Use an empty string ("script=3D" / "downscript=3D") instead. In a future version, "no" will be treated as a plain file name, just like any other non-empty value. Document the deprecation in docs/about/deprecated.rst, qapi/net.json, and qemu-options.hx. Update other docs to use empty string instead of "no". Add a warning. Signed-off-by: Vladimir Sementsov-Ogievskiy Reviewed-by: Ben Chaney Reviewed-by: Markus Armbruster Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin Message-ID: <20260819180201.1970193-4-vsementsov@yandex-team.ru> --- docs/about/deprecated.rst | 18 ++++++++++++++++++ docs/system/i386/microvm.rst | 4 ++-- docs/system/i386/xenpvh.rst | 2 +- docs/system/ppc/ppce500.rst | 4 ++-- docs/system/riscv/microchip-icicle-kit.rst | 2 +- docs/system/riscv/sifive_u.rst | 2 +- qapi/net.json | 14 ++++++++++---- net/tap.c | 17 +++++++++++------ qemu-options.hx | 8 ++++++-- 9 files changed, 52 insertions(+), 19 deletions(-) diff --git a/docs/about/deprecated.rst b/docs/about/deprecated.rst index 98c32991c9..61e775373d 100644 --- a/docs/about/deprecated.rst +++ b/docs/about/deprecated.rst @@ -71,6 +71,15 @@ flexible enough. The monitor objects have been converted= to QOM, so ``-mon mode=3Dcontrol`` is replaced by ``-object monitor-qmp``. The short convenience options are not deprecated, only ``-mon``. =20 +``script=3Dno`` and ``downscript=3Dno`` for ``-netdev tap`` (since 11.2) +''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' + +The special value ``"no"`` for the ``script`` and ``downscript`` +parameters of ``-netdev tap`` disables script execution. This special +treatment of ``"no"`` is deprecated. Use an empty string (``script=3D`` +or ``downscript=3D``) to disable script execution instead. In a future +version, ``"no"`` will be treated as a plain file name. + QEMU Machine Protocol (QMP) commands ------------------------------------ =20 @@ -164,6 +173,15 @@ Use ``job-finalize`` instead. =20 Use ``query-accelerators`` instead. =20 +``"no"`` as value of ``script``/``downscript`` for tap in ``netdev_add`` (= since 11.2) +''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''= ''''''''''' + +The special value ``"no"`` for the ``script`` and ``downscript`` +parameters of ``netdev_add`` with ``type=3Dtap`` disables script +execution. This special treatment of ``"no"`` is deprecated. Use an +empty string instead. In a future version, ``"no"`` will be treated as +a plain file name. + Human Machine Protocol (HMP) commands ------------------------------------- =20 diff --git a/docs/system/i386/microvm.rst b/docs/system/i386/microvm.rst index 1675e37d3e..077ea15751 100644 --- a/docs/system/i386/microvm.rst +++ b/docs/system/i386/microvm.rst @@ -79,7 +79,7 @@ legacy ``ISA serial`` device as console:: -serial stdio \ -drive id=3Dtest,file=3Dtest.img,format=3Draw,if=3Dnone \ -device virtio-blk-device,drive=3Dtest \ - -netdev tap,id=3Dtap0,script=3Dno,downscript=3Dno \ + -netdev tap,id=3Dtap0,script=3D,downscript=3D \ -device virtio-net-device,netdev=3Dtap0 =20 While the example above works, you might be interested in reducing the @@ -103,7 +103,7 @@ disabled:: -device virtconsole,chardev=3Dvirtiocon0 \ -drive id=3Dtest,file=3Dtest.img,format=3Draw,if=3Dnone \ -device virtio-blk-device,drive=3Dtest \ - -netdev tap,id=3Dtap0,script=3Dno,downscript=3Dno \ + -netdev tap,id=3Dtap0,script=3D,downscript=3D \ -device virtio-net-device,netdev=3Dtap0 =20 =20 diff --git a/docs/system/i386/xenpvh.rst b/docs/system/i386/xenpvh.rst index 904778e3f5..862f38830b 100644 --- a/docs/system/i386/xenpvh.rst +++ b/docs/system/i386/xenpvh.rst @@ -42,7 +42,7 @@ case you need to construct one manually: -vnc none \ -display none \ -device virtio-net-pci,id=3Dnic0,netdev=3Dnet0,mac=3D00:16:3e:5c:81:= 78 \ - -netdev type=3Dtap,id=3Dnet0,ifname=3Dvif3.0-emu,br=3Dxenbr0,script= =3Dno,downscript=3Dno \ + -netdev type=3Dtap,id=3Dnet0,ifname=3Dvif3.0-emu,br=3Dxenbr0,script= =3D,downscript=3D \ -smp 4,maxcpus=3D4 \ -nographic \ -machine xenpvh,ram-low-base=3D0,ram-low-size=3D2147483648,ram-high-= base=3D4294967296,ram-high-size=3D2147483648,pci-ecam-base=3D824633720832,p= ci-ecam-size=3D268435456,pci-mmio-base=3D4026531840,pci-mmio-size=3D3355443= 2,pci-mmio-high-base=3D824902156288,pci-mmio-high-size=3D68719476736 \ diff --git a/docs/system/ppc/ppce500.rst b/docs/system/ppc/ppce500.rst index c9fe0915dc..ec5aaf14fd 100644 --- a/docs/system/ppc/ppce500.rst +++ b/docs/system/ppc/ppce500.rst @@ -158,14 +158,14 @@ interface at PCI address 0.1.0, but we can switch tha= t to an e1000 NIC by: $ qemu-system-ppc64 -M ppce500 -smp 4 -m 2G \ -display none -serial stdio \ -bios u-boot \ - -nic tap,ifname=3Dtap0,script=3Dno,downscript=3Dno,m= odel=3De1000 + -nic tap,ifname=3Dtap0,script=3D,downscript=3D,model= =3De1000 =20 The QEMU ``ppce500`` machine can also dynamically instantiate an eTSEC dev= ice if =E2=80=9C-device eTSEC=E2=80=9D is given to QEMU: =20 .. code-block:: bash =20 - -netdev tap,ifname=3Dtap0,script=3Dno,downscript=3Dno,id=3Dnet0 -device = eTSEC,netdev=3Dnet0 + -netdev tap,ifname=3Dtap0,script=3D,downscript=3D,id=3Dnet0 -device eTSE= C,netdev=3Dnet0 =20 Root file system on flash drive ------------------------------- diff --git a/docs/system/riscv/microchip-icicle-kit.rst b/docs/system/riscv= /microchip-icicle-kit.rst index 9809e94b84..7fdb96601a 100644 --- a/docs/system/riscv/microchip-icicle-kit.rst +++ b/docs/system/riscv/microchip-icicle-kit.rst @@ -84,7 +84,7 @@ Then we can boot the machine by: $ qemu-system-riscv64 -M microchip-icicle-kit -smp 5 -m 2G \ -sd path/to/sdcard.img \ -nic user,model=3Dcadence_gem \ - -nic tap,ifname=3Dtap,model=3Dcadence_gem,script=3Dno \ + -nic tap,ifname=3Dtap,model=3Dcadence_gem,script=3D \ -display none -serial stdio \ -kernel path/to/u-boot/build/dir/u-boot.bin \ -dtb path/to/u-boot/build/dir/u-boot.dtb diff --git a/docs/system/riscv/sifive_u.rst b/docs/system/riscv/sifive_u.rst index 8f55ae8e31..0e4dcf3e70 100644 --- a/docs/system/riscv/sifive_u.rst +++ b/docs/system/riscv/sifive_u.rst @@ -199,7 +199,7 @@ To boot the VxWorks kernel in QEMU with the ``sifive_u`= ` machine, use: =20 $ qemu-system-riscv64 -M sifive_u -smp 5 -m 2G \ -display none -serial stdio \ - -nic tap,ifname=3Dtap0,script=3Dno,downscript=3Dno \ + -nic tap,ifname=3Dtap0,script=3D,downscript=3D \ -kernel /path/to/vxWorks \ -append "gem(0,0)host:vxWorks h=3D192.168.200.1 e=3D192.168.200.2:ff= ffff00 u=3Dtarget pw=3DvxTarget f=3D0x01" =20 diff --git a/qapi/net.json b/qapi/net.json index ab8ed9c086..dccf95bbbc 100644 --- a/qapi/net.json +++ b/qapi/net.json @@ -399,15 +399,21 @@ # @fds: multiple file descriptors of already opened multiqueue capable # tap # -# @script: script to initialize the interface. An empty string or -# "no" disables script execution. Defaults to +# @script: script to initialize the interface. An empty string +# disables script execution. Defaults to # ``/qemu-ifup``, where ```` is the # system configuration directory at build time (typically /etc). +# Using "no" to disable script execution is deprecated (since +# 11.2); use an empty string instead. In a future version, "no" +# will be treated as a plain file name. # -# @downscript: script to shut down the interface. An empty string or -# "no" disables script execution. Defaults to +# @downscript: script to shut down the interface. An empty string +# disables script execution. Defaults to # ``/qemu-ifdown``, where ```` is the # system configuration directory at build time (typically /etc). +# Using "no" to disable script execution is deprecated (since +# 11.2); use an empty string instead. In a future version, "no" +# will be treated as a plain file name. # # @br: bridge name (since 2.8) # diff --git a/net/tap.c b/net/tap.c index 2076f5b780..f4051e8d4b 100644 --- a/net/tap.c +++ b/net/tap.c @@ -92,7 +92,8 @@ static void launch_script(const char *setup_script, const= char *ifname, static void tap_send(void *opaque); static void tap_writable(void *opaque); =20 -static bool tap_is_explicit_no_script(const char *script_arg_value) +static bool tap_is_explicit_no_script(const char *script_arg_name, + const char *script_arg_value) { if (!script_arg_value) { return false; @@ -103,16 +104,19 @@ static bool tap_is_explicit_no_script(const char *scr= ipt_arg_value) } =20 if (strcmp(script_arg_value, "no") =3D=3D 0) { + warn_report("'%s=3Dno' is deprecated; use '%s=3D' instead", + script_arg_name, script_arg_name); return true; } =20 return false; } =20 -static char *tap_parse_script(const char *script_arg_value, +static char *tap_parse_script(const char *script_arg_name, + const char *script_arg_value, const char *default_path) { - if (tap_is_explicit_no_script(script_arg_value)) { + if (tap_is_explicit_no_script(script_arg_name, script_arg_value)) { return NULL; } =20 @@ -741,7 +745,7 @@ static bool net_init_tap_one(const NetdevTapOptions *ta= p, NetClientState *peer, qemu_set_info_str(&s->nc, "helper=3D%s", tap->helper); } else { qemu_set_info_str(&s->nc, "ifname=3D%s,script=3D%s,downscript=3D%s= ", ifname, - script ?: "no", downscript ?: "no"); + script ?: "", downscript ?: ""); =20 if (downscript) { snprintf(s->down_script, sizeof(s->down_script), "%s", downscr= ipt); @@ -947,9 +951,10 @@ int net_init_tap(const Netdev *netdev, const char *nam= e, } } else { g_autofree char *script =3D - tap_parse_script(tap->script, DEFAULT_NETWORK_SCRIPT); + tap_parse_script("script", tap->script, DEFAULT_NETWORK_SCRIPT= ); g_autofree char *downscript =3D - tap_parse_script(tap->downscript, DEFAULT_NETWORK_DOWN_SCRIPT); + tap_parse_script("downscript", tap->downscript, + DEFAULT_NETWORK_DOWN_SCRIPT); =20 if (tap->ifname) { pstrcpy(ifname, sizeof ifname, tap->ifname); diff --git a/qemu-options.hx b/qemu-options.hx index 16ef7d5455..2f6863180b 100644 --- a/qemu-options.hx +++ b/qemu-options.hx @@ -3022,7 +3022,8 @@ DEF("netdev", HAS_ARG, QEMU_OPTION_netdev, " use network scripts 'file' (default=3D" DEFAULT_NETWO= RK_SCRIPT ")\n" " to configure it and 'dfile' (default=3D" DEFAULT_NETW= ORK_DOWN_SCRIPT ")\n" " to deconfigure it\n" - " use '[down]script=3Dno' or '[down]script=3D' to disab= le script execution\n" + " use '[down]script=3D' to disable script execution\n" + " ('[down]script=3Dno' is deprecated and will be treate= d as a file name in future)\n" " use network helper 'helper' (default=3D" DEFAULT_BRID= GE_HELPER ") to\n" " configure it\n" " use 'fd=3Dh' to connect to an already opened TAP inte= rface\n" @@ -3561,7 +3562,10 @@ SRST ``/qemu-ifup`` and the default network deconfigure script = is ``/qemu-ifdown``, where ```` is the system configuration directory at build time (typically ``/etc``). - Use ``[down]script=3Dno`` or ``[down]script=3D`` to disable script exe= cution. + Use ``[down]script=3D`` to disable script execution. + Using ``[down]script=3Dno`` is deprecated; it disables script + execution now, but in a future version it will be treated as a + plain file name. =20 If running QEMU as an unprivileged user, use the network helper to configure the TAP interface and attach it to the bridge. --=20 MST From nobody Sat Sep 26 20:50:17 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=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1789084451; cv=none; d=zohomail.com; s=zohoarc; b=g9ONHekp2MJbuodYJL2rcsOKDOQ+rYV3+dEVRkJa0Rd2eMasRPVAuShGUBrDuHQgCJ6KJx3TegCA2JlKB2LsrVSGudxxP0GvBzdULLS4N1USMgIAq4GMGKaq5i167n2XXSelDzncFzxDEpMQYBDL51eZZeRJC2Epu5i/unpZNfA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1789084451; h=Content-Type: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=pzQMAUIV8a8b91Vm/oUOdfGDZskrETDwBh/Nv2MWtB8=; b=Gy1+ShfWo9O5wySHq5gfpPP+aAvV+KUvufjWwZLYRq1RI0Z+YeZbrxSD4iulJcYZPpehd/vou9RtIRrhvfPoVHKui3MVIn5AjFS2BYbWtO7sU66C3Sc106DHtONkg/96KGLazpfg2BcJj5PsBHCytRYT6Ytiv9WVV1KVlc6Lmzc= 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 lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 178908445139331.91937820738724; Thu, 10 Sep 2026 16:54:11 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1x4o5A-00043y-SC; Thu, 10 Sep 2026 19:21:35 -0400 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 1x4lW3-0006SV-2y for qemu-devel@nongnu.org; Thu, 10 Sep 2026 16:37:09 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1x4lVh-0004hg-Fs for qemu-devel@nongnu.org; Thu, 10 Sep 2026 16:36:49 -0400 Received: from mail-wr1-f72.google.com (mail-wr1-f72.google.com [209.85.221.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-80-8-MuRIUwOuKcG3ZLw_3mbQ-1; Thu, 10 Sep 2026 16:12:19 -0400 Received: by mail-wr1-f72.google.com with SMTP id ffacd0b85a97d-486e9338393so71576f8f.0 for ; Thu, 10 Sep 2026 13:12:18 -0700 (PDT) Received: from redhat.com (IGLD-80-230-79-236.inter.net.il. [80.230.79.236]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-486eb32e7f5sm843320f8f.9.2026.09.10.13.12.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Sep 2026 13:12:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1789072563; 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=pzQMAUIV8a8b91Vm/oUOdfGDZskrETDwBh/Nv2MWtB8=; b=U/e4hcTTkpym+2k5X/3fRId2p40noSu3WKiTC0BU9G+WbpfLD/DMnBllHqtS2K8SR+6eZr wg6jMLDyOsbXsKLNcsmV6vECRQ/D92/sqg733hrSUHkrd8J8MjWJ/sXsa/Wmyzbja40+oE 9VSKLusPyCLQn6Rvvormd2xO3HGuCTY= X-MC-Unique: 8-MuRIUwOuKcG3ZLw_3mbQ-1 X-Mimecast-MFC-AGG-ID: 8-MuRIUwOuKcG3ZLw_3mbQ_1789071138 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=google; t=1789071138; x=1789675938; 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=pzQMAUIV8a8b91Vm/oUOdfGDZskrETDwBh/Nv2MWtB8=; b=Cq90e/vtKNZ97AnecRxqGClTWWH0lUrP1Aeg4y8cVmNE4iLdoZxVFZhpqK2jNil7Il WpIsrd5eMBGdaGBtaVD6CEs4XaAzyrnnj+AVRQbljODbaoW0SNKjqxYAWSNlrVDvOLNg 1Zs38NWEksU3rOiCAxa2X8wn3YQQzUIpiRzd3wIvdvQiiQA17dRTfaTJIqhRTDYjyr4W LuUjFRuEspBHj8sAv4iV8U/E8qmIOHZictquclGnY5ajjBe8nrqQfBPahp74ZEQ1mfDt EcioIPMXnab3rhoyTWV8yHc+cDoEAi9AY1qbTuEUZCH8X6hYjnamGkzQq4hsTBiaBhEE asNQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1789071138; x=1789675938; 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=pzQMAUIV8a8b91Vm/oUOdfGDZskrETDwBh/Nv2MWtB8=; b=HFtKnHqDt/76rXroSbudf7dQa/G4caQSH2JryGQMyy6UK5+s0MEOaz6M5DBRmp/ayY NlAq+4ycuVb5Sb2GflhlwB1xZEzfwl8ihGGKPCVZFrndyxxHUqCx9C2xvNk4I77qMcVg BCWYwQQPox3va14LT1+krnwqmmVnzSnIguaYHkltVyLC6pnH4jWfMjG0xj+32HiltUV+ IoZ4DcXE5uRrtc7cGBNx2q6yCm2k9ftftKrQusYclLEudnxkhcXQPJkM3vFave2gXdE1 NZpsEB1degPZoS6IE9jW+BGk6PJujwH7qg1oEZspV8b4jHRSdXYoLfSYoDH4oE2D5Maa fNHQ== X-Gm-Message-State: AFuF++lkXskuB/c9t+L9JgSt0u3Y3wGgEqJFdWZlfHfyTy90XLxZfBR/ qCEx+cdthiwuuT1KyFqa68k5NoI64lcpoRn5h/XvkEWLWN8EN1pVNk3NnkQ+ORGEluIetLGW1I0 Q3jrqM/+ue2H6OshtP8SjQcxHR3nGzsfZgjuHlfN06Ze/7sN7L5LB49O2nyvPEoRt+eeAMrVPPm MEidaM2hNl0jBscMrzgDf7HiIgs+ZAzpubmA== X-Gm-Gg: AYBFou1LwLsxrjrqFTzgR3FQ27LgQyOdH1P/jyXnM6qUIkJQ0fOCOuGhfQgk87eS6eK /TcHaj5BfsORkf+G0DgFqwF9vyqIBlvWg9com+If8ADjES2mNCLuXIQv7DSNmECYj7n5fnpjxRb psrtlD/k1VE2kxWKhP3YkPTRrpTEUJPCtxyUK2if3toOVtVP0InQgqCJHGazyRSey42ePJT6ETx s75hMsO/z++1b0IPu17aRo2XuGuFHRvRaNVPBLmwmMTToaOsCd74nwWCETc9YZQmg8I7656stan ImKIbMwG29SSfEGfNurM3IJTIFz/OQ4eMEx9aMaPpqZh6KAhwhZRsHGoWrf4vphB2Jpwkhwq98B eQ6AYS/+HQvrOEaiUSkeXWTo= X-Received: by 2002:a05:6000:1cc9:b0:485:8a46:b3c6 with SMTP id ffacd0b85a97d-486eb3395e0mr480895f8f.46.1789071137755; Thu, 10 Sep 2026 13:12:17 -0700 (PDT) X-Received: by 2002:a05:6000:1cc9:b0:485:8a46:b3c6 with SMTP id ffacd0b85a97d-486eb3395e0mr480857f8f.46.1789071137168; Thu, 10 Sep 2026 13:12:17 -0700 (PDT) Date: Thu, 10 Sep 2026 16:12:15 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Vladimir Sementsov-Ogievskiy , Ben Chaney , Jason Wang Subject: [PULL 22/90] net/tap: move vhost-net open() calls to tap_parse_vhost_fds() Message-ID: References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-Mailer: git-send-email 2.51.2.2891.g4157995a80.dirty X-Mutt-Fcc: =sent 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=170.10.129.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com 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, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=0.001, SPF_HELO_PASS=-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-Zoho-Virus-Status: 1 X-Zoho-AV-Stamp: zmail-av-0.2.13.1.5.4/289.74.40 X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1789084452888158500 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Vladimir Sementsov-Ogievskiy 1. Simplify code path: get vhostfds for all cases in one function. 2. Prepare for further tap-fd-migraton feature, when we'll need to postpone vhost initialization up to post-load stage. Signed-off-by: Vladimir Sementsov-Ogievskiy Reviewed-by: Ben Chaney Reviewed-by: Michael S. Tsirkin Based-on: <20260318113144.15697-1-vsementsov@yandex-team.ru> Signed-off-by: Michael S. Tsirkin Message-ID: <20260819180201.1970193-5-vsementsov@yandex-team.ru> --- net/tap.c | 39 ++++++++++++++++++++++----------------- 1 file changed, 22 insertions(+), 17 deletions(-) diff --git a/net/tap.c b/net/tap.c index f4051e8d4b..bec2cd48fd 100644 --- a/net/tap.c +++ b/net/tap.c @@ -756,8 +756,7 @@ static bool net_init_tap_one(const NetdevTapOptions *ta= p, NetClientState *peer, } } =20 - if (tap->has_vhost ? tap->vhost : - (vhostfd !=3D -1) || (tap->has_vhostforce && tap->vhostforce)) { + if (vhostfd !=3D -1) { VhostNetOptions options; =20 options.backend_type =3D VHOST_BACKEND_TYPE_KERNEL; @@ -767,17 +766,6 @@ static bool net_init_tap_one(const NetdevTapOptions *t= ap, NetClientState *peer, } else { options.busyloop_timeout =3D 0; } - - if (vhostfd =3D=3D -1) { - vhostfd =3D open("/dev/vhost-net", O_RDWR); - if (vhostfd < 0) { - error_setg_file_open(errp, errno, "/dev/vhost-net"); - goto failed; - } - if (!qemu_set_blocking(vhostfd, false, errp)) { - goto failed; - } - } options.opaque =3D (void *)(uintptr_t)vhostfd; options.nvqs =3D 2; options.feature_bits =3D kernel_feature_bits; @@ -863,14 +851,31 @@ static int tap_parse_fds_and_queues(const NetdevTapOp= tions *tap, int **fds, static bool tap_parse_vhost_fds(const NetdevTapOptions *tap, int **vhost_f= ds, int queues, Error **errp) { - if (!(tap->vhostfd || tap->vhostfds)) { + bool need_vhost =3D tap->has_vhost ? tap->vhost : + ((tap->vhostfd || tap->vhostfds) || + (tap->has_vhostforce && tap->vhostforce)); + + if (!need_vhost) { *vhost_fds =3D NULL; return true; } =20 - if (net_parse_fds(tap->vhostfd ?: tap->vhostfds, - vhost_fds, queues, errp) < 0) { - return false; + if (tap->vhostfd || tap->vhostfds) { + if (net_parse_fds(tap->vhostfd ?: tap->vhostfds, + vhost_fds, queues, errp) < 0) { + return false; + } + } else { + *vhost_fds =3D g_new(int, queues); + for (int i =3D 0; i < queues; i++) { + int vhostfd =3D open("/dev/vhost-net", O_RDWR); + if (vhostfd < 0) { + error_setg_file_open(errp, errno, "/dev/vhost-net"); + net_free_fds(*vhost_fds, i); + return false; + } + (*vhost_fds)[i] =3D vhostfd; + } } =20 if (!unblock_fds(*vhost_fds, queues, errp)) { --=20 MST From nobody Sat Sep 26 20:50:17 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=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1789074456; cv=none; d=zohomail.com; s=zohoarc; b=SvgVkiKyFzDyl99YB3l0Vq9WRJHyeGoLB6ctbyANBOHjwtQauPsB9ppVXpp1zBFDcjUa6NUKfOB273gm2AdOYSAvwxfUEXJAKYUHK7c5dL0eKuNmrMnfWUN0x1K23Ea4/L9CXzisUBgzFXn1D8ZsPzht3yd+XHYQVwyItehoEYU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1789074456; h=Content-Type: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=hZQoGnwsXrICqagpiwSzGmzqnz5JLACVM0aRzU+Os8Y=; b=DUne73vAU2+c4abe4QKITZaRN4ppJZ8uqqiTOXWvBm3z3x3HfMRAN61vhfEf1cMywC4MFn+mEKoyAyB2KXgCZ3s/wxPsXzwgq1tFdfFpQjMn8wq7wxacHSk/sMdaf94vMTagG86zW8Lsyw3ozTZ62Tkt2niSGfoZGhCnx1/2PAA= 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 lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1789074456828417.68796534567537; Thu, 10 Sep 2026 14:07:36 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1x4lwz-0004ie-5M; Thu, 10 Sep 2026 17:05:08 -0400 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 1x4lFY-0000YX-2X for qemu-devel@nongnu.org; Thu, 10 Sep 2026 16:20:03 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1x4lFN-0007J2-Hh for qemu-devel@nongnu.org; Thu, 10 Sep 2026 16:19:56 -0400 Received: from mail-wr1-f69.google.com (mail-wr1-f69.google.com [209.85.221.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-557-uLCNIWTwP3i7H-OUr3ZmcQ-1; Thu, 10 Sep 2026 16:12:22 -0400 Received: by mail-wr1-f69.google.com with SMTP id ffacd0b85a97d-484362cb000so118971f8f.0 for ; Thu, 10 Sep 2026 13:12:22 -0700 (PDT) Received: from redhat.com (IGLD-80-230-79-236.inter.net.il. [80.230.79.236]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-486eb32d3c7sm753668f8f.10.2026.09.10.13.12.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Sep 2026 13:12:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1789071447; 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=hZQoGnwsXrICqagpiwSzGmzqnz5JLACVM0aRzU+Os8Y=; b=JnUYXMiuTTRToQMS6Lc7Uy8SMfDpUikNyvZqGFSNxbzwpuGAry6QBcxTU4Rdr6N/czOosG T/RqHVZ1WUqmF3NAVeL0Pl4VEvWQ6BjEym+jE7ccIjJDZT/TrAG5uSpnHStCHF9a0E3MXh 3VfA1sAMYpbR7ZotSKkJMTRdu1DVeLw= X-MC-Unique: uLCNIWTwP3i7H-OUr3ZmcQ-1 X-Mimecast-MFC-AGG-ID: uLCNIWTwP3i7H-OUr3ZmcQ_1789071141 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=google; t=1789071141; x=1789675941; 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=hZQoGnwsXrICqagpiwSzGmzqnz5JLACVM0aRzU+Os8Y=; b=gWy5ml5Odz1nGvLURfrJzVpZaaWpqaLMs+l5xNVPvpMHf0mW9ZA2S87vywsqu083ui NYiY5pzm2qJglv1C0cZeuNshpRFPS9DRJGU0fMC48sMWonqb34SC79SbdHiOiUShdwKC 0mutoNezYiO4vOFBb97pntU/W7q5oE5gTw5NuRVwX6CuqZ/gzq1g8Df3G/7QAJlXHccG FTkHlyyRNxHZXEg0cidJpq9BZfSpOGwrYuq6pJDZ5vIwFnlece907pKzS8qkdRbKQtdb n8FuKoIGWJdH2Ts31m6oO3aMqZy57LQP431NAs5ffQXq736czdBbofsgOXOC2OrIJoJe J0NA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1789071141; x=1789675941; 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=hZQoGnwsXrICqagpiwSzGmzqnz5JLACVM0aRzU+Os8Y=; b=ZQ8SxlgNXUKNo7x7pc4DdhMCf2XhgcGyZAm4AxU7/CsDCckeuWAT0vtH+lahUaI+18 npQesGMsINq99KBrR4tPuvCp//0k3wO2uCnHvlHSIrER7HVgYKpWuEbkbo0s2Xu/Ijrr 4FpU8xN+FisObryYSNWsLMgI1GuepPFvuMuLZXBOgDBukbfQjtLYITnORY173bGeRc5i ASwRH3lhPPRVQkZVO+n8FRFW+6L8u48hDY80zgW3iPxunaZzz+wDuBzZjyeiAxfVYpVs NvjpvcJfZ7IzMQaS97vas125vrDrwbRmVuCXLaKpm+ltt4/ZK3TRZlEYiGWtCSx91rC/ QMhg== X-Gm-Message-State: AFuF++nsJfwAMfBFcXnZhxEak9asQHvIf0LmcFvO8fjgkftfnbaPbLX+ ssQqkLVKip+5dWLGJzfaw/i4StyPhW4fpPK+DZ3RKFi8yKEZZ/EDD6KZaYimtYYAotkXl5e6Btf pTwScOLhu6uPdBD8eiS4bfzeD5XuqTxuUue4NwL5ceu0Yn7vl2LtDg3Vvr6JAznhPbIhQsfX6sR 9KZZOgEmfW57KlpF2RFHbIXiiPPOXmZgE3FQ== X-Gm-Gg: AYBFou0IDLw0gDh4kAN/y21TJk7s2b+01KKJTM4bHkMkj8Q2EROB4VrbjTlT6EaTtEH vNsxhmg4sbbAet68wQyKJCxagtWejsoi5VGDgoDJBouVs9/sz9P3UIzfH643u+7yJkIZ7OycoMW 1Iui3DybEInQkYfoLwWBaATA8rdA7LP9eb4dWRfZ9GUM/F/LRR0fTg/fMT1xNviAupX4us8uGZ+ oY0DqIbPSCuUbFiVv++63ZwVvV2GAHRVmlZpn1WqhV8Pb79AI3x+44SMxMV+r+JExXt842HBTPw A+2PXxEewp9Jhl4ZMlEy9u8Gc9q8hiV5hDX++aTXVHwJMpAJx/jYPoN/+/e1qp+3Mn5ip61f11l pFXRxJlAlrmZ+2BQT3gdm/xY= X-Received: by 2002:a05:6000:2082:b0:484:482d:dce4 with SMTP id ffacd0b85a97d-486e91e4c97mr1443183f8f.0.1789071141436; Thu, 10 Sep 2026 13:12:21 -0700 (PDT) X-Received: by 2002:a05:6000:2082:b0:484:482d:dce4 with SMTP id ffacd0b85a97d-486e91e4c97mr1443142f8f.0.1789071140901; Thu, 10 Sep 2026 13:12:20 -0700 (PDT) Date: Thu, 10 Sep 2026 16:12:17 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Vladimir Sementsov-Ogievskiy , Ben Chaney , Jason Wang Subject: [PULL 23/90] net/tap: move vhost initialization to tap_setup_vhost() Message-ID: References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-Mailer: git-send-email 2.51.2.2891.g4157995a80.dirty X-Mutt-Fcc: =sent 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=170.10.129.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com 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, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=0.001, SPF_HELO_PASS=-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-Zoho-Virus-Status: 1 X-Zoho-AV-Stamp: zmail-av-0.2.13.1.5.4/289.52.80 X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1789074457958158500 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Vladimir Sementsov-Ogievskiy Make a new helper function in a way it can be reused later for TAP fd-migration feature: we'll need to initialize vhost in a later point when we doesn't have access to QAPI parameters. Signed-off-by: Vladimir Sementsov-Ogievskiy Reviewed-by: Ben Chaney Reviewed-by: Michael S. Tsirkin Based-on: <20260318113144.15697-1-vsementsov@yandex-team.ru> Based-on: <20260218202829.1322088-1-vsementsov@yandex-team.ru> Signed-off-by: Michael S. Tsirkin Message-ID: <20260819180201.1970193-6-vsementsov@yandex-team.ru> --- net/tap.c | 62 ++++++++++++++++++++++++++++++++++--------------------- 1 file changed, 38 insertions(+), 24 deletions(-) diff --git a/net/tap.c b/net/tap.c index bec2cd48fd..f2b571dd11 100644 --- a/net/tap.c +++ b/net/tap.c @@ -71,6 +71,8 @@ static const int kernel_feature_bits[] =3D { typedef struct TAPState { NetClientState nc; int fd; + int vhostfd; + uint32_t vhost_busyloop_timeout; char down_script[1024]; char down_script_arg[128]; uint8_t buf[NET_BUFSIZE]; @@ -722,6 +724,38 @@ static int net_tap_init(const NetdevTapOptions *tap, i= nt *vnet_hdr, return fd; } =20 +static bool tap_setup_vhost(TAPState *s, Error **errp) +{ + VhostNetOptions options; + + if (s->vhostfd =3D=3D -1) { + return true; + } + + options.backend_type =3D VHOST_BACKEND_TYPE_KERNEL; + options.net_backend =3D &s->nc; + options.busyloop_timeout =3D s->vhost_busyloop_timeout; + options.opaque =3D (void *)(uintptr_t)s->vhostfd; + options.nvqs =3D 2; + options.feature_bits =3D kernel_feature_bits; + options.get_acked_features =3D NULL; + options.save_acked_features =3D NULL; + options.max_tx_queue_size =3D 0; + options.is_vhost_user =3D false; + + s->vhost_net =3D vhost_net_init(&options); + if (!s->vhost_net) { + error_setg(errp, + "vhost-net requested but could not be initialized"); + return false; + } + + /* vhostfd ownership is passed to s->vhost_net */ + s->vhostfd =3D -1; + + return true; +} + static bool net_init_tap_one(const NetdevTapOptions *tap, NetClientState *= peer, const char *name, const char *ifname, const char *script, @@ -756,30 +790,10 @@ static bool net_init_tap_one(const NetdevTapOptions *= tap, NetClientState *peer, } } =20 - if (vhostfd !=3D -1) { - VhostNetOptions options; - - options.backend_type =3D VHOST_BACKEND_TYPE_KERNEL; - options.net_backend =3D &s->nc; - if (tap->has_poll_us) { - options.busyloop_timeout =3D tap->poll_us; - } else { - options.busyloop_timeout =3D 0; - } - options.opaque =3D (void *)(uintptr_t)vhostfd; - options.nvqs =3D 2; - options.feature_bits =3D kernel_feature_bits; - options.get_acked_features =3D NULL; - options.save_acked_features =3D NULL; - options.max_tx_queue_size =3D 0; - options.is_vhost_user =3D false; - - s->vhost_net =3D vhost_net_init(&options); - if (!s->vhost_net) { - error_setg(errp, - "vhost-net requested but could not be initialized"); - goto failed; - } + s->vhostfd =3D vhostfd; + s->vhost_busyloop_timeout =3D tap->has_poll_us ? tap->poll_us : 0; + if (!tap_setup_vhost(s, errp)) { + return false; } =20 return true; --=20 MST From nobody Sat Sep 26 20:50:17 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=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1789077564; cv=none; d=zohomail.com; s=zohoarc; b=ZthAjlnR/o64id0JAqL2Bld9sABveSXqW8j8Zk1UWK7yI18Ad7+8qbst4E7iaDOYfg0fAYBW0D84bhRs4MW+KRDMae5ezKtmziR+0SNAjeFUyohXf9Zn78uNTX56EYTve1mNRwjNv28itra5kvf0gmoMUztemA+sMgsZtVrdbMg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1789077564; h=Content-Type: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=AWRhi/FGrwhxDDpXDBZ1js0/6fDRqICz+xroCDFuHEc=; b=deS+BaN8YovpcgfIUIRJ6+TKrFLD+wO4+wcXqwWqosULqwYxFkEA3ucW+RuQwGHPuzGa13DgBYAoV4npHgARBiZZoXQCbxqCAOaT4DPHQjjK2lsTRs26YHuNCRfKfjLDr3HbocP+X9ruSPpPMsyJ+NgdzTN6yETk/slPsmYusUc= 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 lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1789077564527718.1461342634113; Thu, 10 Sep 2026 14:59:24 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1x4mkb-0006ql-CY; Thu, 10 Sep 2026 17:56:31 -0400 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 1x4lWk-0006an-6G for qemu-devel@nongnu.org; Thu, 10 Sep 2026 16:38:07 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1x4lWK-0004ke-Dy for qemu-devel@nongnu.org; Thu, 10 Sep 2026 16:37:28 -0400 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-466-Btvl-lMWNLWdtv8-R6KV9A-1; Thu, 10 Sep 2026 16:12:25 -0400 Received: by mail-wm1-f70.google.com with SMTP id 5b1f17b1804b1-49d156c917cso8576845e9.1 for ; Thu, 10 Sep 2026 13:12:24 -0700 (PDT) Received: from redhat.com (IGLD-80-230-79-236.inter.net.il. [80.230.79.236]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-49e61a7a686sm6596295e9.1.2026.09.10.13.12.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Sep 2026 13:12:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1789072566; 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=AWRhi/FGrwhxDDpXDBZ1js0/6fDRqICz+xroCDFuHEc=; b=eUpVdw0kh0Nm3/JlX8wbypTNm1FB+zKWuipg20vp8YwN6SMx2UkaGwZP9CZasCRl4hGlQv 6JkFc/2sIGPw5ae5n/B3CLOpidtmrh1OnhjWn4R+FalSQJGly6/jiyZfkMmzItUF1tn/G5 jpQsfBZPiDJVLK6LIS+X8PlgkLhKp48= X-MC-Unique: Btvl-lMWNLWdtv8-R6KV9A-1 X-Mimecast-MFC-AGG-ID: Btvl-lMWNLWdtv8-R6KV9A_1789071144 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=google; t=1789071144; x=1789675944; 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=AWRhi/FGrwhxDDpXDBZ1js0/6fDRqICz+xroCDFuHEc=; b=gpFgtkQD6bORZCg1Rbk/LwRFkVl9rd4WvpOgqwUgKK6YR7HN2cXfJPS9aOc7/RUATH ngXFWDWQ8FcTqyi9wcStx99bBEpOv/Vh2ApydI9gcy061vpTp2Lujo4Yr2VjsBmLcxOz CNyRaKhSY6B5kWbAkeF5DD1XZO7us1VuIRi5IbmgwZYxe64rJ/PNo266/K2shKgTpuqM voW9QUeGyvQKJtg3ndWWmmMlJVceChJ8Qqj1aB5oZdDlXs/TdTV9YLfZKV4mMrzwVUWR qsx38ZckYx80PgTwnLWeIhN5IEpfaIPLA3at7Hr8m7Q3POl26INz2p6An03lbrxxIfa7 cKOA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1789071144; x=1789675944; 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=AWRhi/FGrwhxDDpXDBZ1js0/6fDRqICz+xroCDFuHEc=; b=amM5bQCL2ss0C11GCebCY7Pl7phrxYJbksU5oeonUqw9UFcuTIbJD2UyrPA1F5cjS4 30DI831vgKPFx9tPMwiGc/pMsUOklb3ohp/KGnBnnHRu8Og2EOwGBoUFHjGpXoElU5js hs9H4kiVIQdQAjuSUHJTVuqD1H6Tzjf39RLhVjf85gdS5ke8xqmFkxBxnNXx1Zwh4UON hrfq/rd9CCA3i9Wy3TNUMxgRT7l/xlo6lDNHFDO0oMiTC8lzkRqFc0KaZ8Wsnk47Mrkv nRkFZ4BVQua+P1ThwEyQnZX1KzJBWeWgv7IuycIBiwQ5TTYjpeQJ/KAC9E441IvzQsR/ /TmQ== X-Gm-Message-State: AFuF++leCr3h0x4d/W/sry8Ii00lp+yzj9CjEjlZBtGSm1upB7P7X43N drkZwV3Aj5raGxcdioq1pd7y6D2eDBYi9Ql6HpfCr+jmpzJDymJUfDz9UBgskKAmNZ7sRU72Wtx SsZ4GatN3bq5jHbBD9+Qp8Xel4YJQN6kXcdvRv6+ekY473tgn8bbmk2jX7VaS9VtcawRqgnVV2E nCggz/RzXr6Z3VsCt59T3HMwwydHY8AMEsWg== X-Gm-Gg: AYBFou3r5LRD0QVGgccldqV9tucNIKAwEilaO9Mm5oxioRA22JaZVhkOIyZ0Q0eOvoO ItvFpUqGeb3SDBLuUkquKFquCn9LnN5R1D/g8PfuFBrsNbDgRPcHdv47+PeD3wCwY+5i9cdexRO d8N8fY9hBog80NVkRIJpGNpUZMkg9YkbGJWuFGgGif5hwJelu64Mxb8M4CRwvg3w3QSqmJSiRZA Mlc7MPEhJQtGfp3ar9HqLB4iyJNYydXHycdXcZN6cXpnfL3Rvn42dhkSc/a4pyQ83eGY32kcSzq VtFVy/CXnIqD/upuFpEzLWG7CVE/0bSzCCZ4TAGSybGk6cyVf3fSX0LcaLSycyNowuIYg0zblkN YmvUYsdASlpfZAUUDxwUOiGQ= X-Received: by 2002:a05:600c:3115:b0:49d:1e79:35d6 with SMTP id 5b1f17b1804b1-49e61094b9bmr12279795e9.14.1789071143756; Thu, 10 Sep 2026 13:12:23 -0700 (PDT) X-Received: by 2002:a05:600c:3115:b0:49d:1e79:35d6 with SMTP id 5b1f17b1804b1-49e61094b9bmr12279205e9.14.1789071143140; Thu, 10 Sep 2026 13:12:23 -0700 (PDT) Date: Thu, 10 Sep 2026 16:12:21 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Vladimir Sementsov-Ogievskiy , Ben Chaney , Jason Wang Subject: [PULL 24/90] net/tap: use container_of instead of DO_UPCAST Message-ID: <2aaacce0a03705d7f69c47cc02cb9ae859b1ebef.1789071042.git.mst@redhat.com> References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-Mailer: git-send-email 2.51.2.2891.g4157995a80.dirty X-Mutt-Fcc: =sent 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=170.10.129.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com 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, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=0.001, SPF_HELO_PASS=-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-Zoho-Virus-Status: 1 X-Zoho-AV-Stamp: zmail-av-0.2.13.1.5.4/289.74.40 X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1789077566012158500 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Vladimir Sementsov-Ogievskiy We are going to QOMify tap backend, which includes deriving TAPState from Object. So "NetClientState nc" will not be a first member. Let's parepare for this change, and use container_of(), which will work regardless position of "nc" field. Signed-off-by: Vladimir Sementsov-Ogievskiy Reviewed-by: Ben Chaney Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin Message-ID: <20260819180201.1970193-7-vsementsov@yandex-team.ru> --- net/tap.c | 36 ++++++++++++++++++------------------ 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/net/tap.c b/net/tap.c index f2b571dd11..bfed74717e 100644 --- a/net/tap.c +++ b/net/tap.c @@ -175,7 +175,7 @@ static ssize_t tap_write_packet(TAPState *s, const stru= ct iovec *iov, int iovcnt static ssize_t tap_receive_iov(NetClientState *nc, const struct iovec *iov, int iovcnt) { - TAPState *s =3D DO_UPCAST(TAPState, nc, nc); + TAPState *s =3D container_of(nc, TAPState, nc); const struct iovec *iovp =3D iov; g_autofree struct iovec *iov_copy =3D NULL; struct virtio_net_hdr hdr =3D { }; @@ -211,7 +211,7 @@ ssize_t tap_read_packet(int tapfd, uint8_t *buf, int ma= xlen) =20 static void tap_send_completed(NetClientState *nc, ssize_t len) { - TAPState *s =3D DO_UPCAST(TAPState, nc, nc); + TAPState *s =3D container_of(nc, TAPState, nc); tap_read_poll(s, true); } =20 @@ -271,7 +271,7 @@ static void tap_send(void *opaque) =20 static bool tap_has_ufo(NetClientState *nc) { - TAPState *s =3D DO_UPCAST(TAPState, nc, nc); + TAPState *s =3D container_of(nc, TAPState, nc); =20 assert(nc->info->type =3D=3D NET_CLIENT_DRIVER_TAP); =20 @@ -280,7 +280,7 @@ static bool tap_has_ufo(NetClientState *nc) =20 static bool tap_has_uso(NetClientState *nc) { - TAPState *s =3D DO_UPCAST(TAPState, nc, nc); + TAPState *s =3D container_of(nc, TAPState, nc); =20 assert(nc->info->type =3D=3D NET_CLIENT_DRIVER_TAP); =20 @@ -289,7 +289,7 @@ static bool tap_has_uso(NetClientState *nc) =20 static bool tap_has_tunnel(NetClientState *nc) { - TAPState *s =3D DO_UPCAST(TAPState, nc, nc); + TAPState *s =3D container_of(nc, TAPState, nc); =20 assert(nc->info->type =3D=3D NET_CLIENT_DRIVER_TAP); return s->has_tunnel; @@ -297,7 +297,7 @@ static bool tap_has_tunnel(NetClientState *nc) =20 static bool tap_has_vnet_hdr(NetClientState *nc) { - TAPState *s =3D DO_UPCAST(TAPState, nc, nc); + TAPState *s =3D container_of(nc, TAPState, nc); =20 assert(nc->info->type =3D=3D NET_CLIENT_DRIVER_TAP); =20 @@ -311,7 +311,7 @@ static bool tap_has_vnet_hdr_len(NetClientState *nc, in= t len) =20 static void tap_set_vnet_hdr_len(NetClientState *nc, int len) { - TAPState *s =3D DO_UPCAST(TAPState, nc, nc); + TAPState *s =3D container_of(nc, TAPState, nc); =20 assert(nc->info->type =3D=3D NET_CLIENT_DRIVER_TAP); =20 @@ -322,21 +322,21 @@ static void tap_set_vnet_hdr_len(NetClientState *nc, = int len) =20 static int tap_set_vnet_le(NetClientState *nc, bool is_le) { - TAPState *s =3D DO_UPCAST(TAPState, nc, nc); + TAPState *s =3D container_of(nc, TAPState, nc); =20 return tap_fd_set_vnet_le(s->fd, is_le); } =20 static int tap_set_vnet_be(NetClientState *nc, bool is_be) { - TAPState *s =3D DO_UPCAST(TAPState, nc, nc); + TAPState *s =3D container_of(nc, TAPState, nc); =20 return tap_fd_set_vnet_be(s->fd, is_be); } =20 static void tap_set_offload(NetClientState *nc, const NetOffloads *ol) { - TAPState *s =3D DO_UPCAST(TAPState, nc, nc); + TAPState *s =3D container_of(nc, TAPState, nc); if (s->fd < 0) { return; } @@ -357,7 +357,7 @@ static void tap_exit_notify(Notifier *notifier, void *d= ata) =20 static void tap_cleanup(NetClientState *nc) { - TAPState *s =3D DO_UPCAST(TAPState, nc, nc); + TAPState *s =3D container_of(nc, TAPState, nc); =20 if (s->vhost_net) { vhost_net_cleanup(s->vhost_net); @@ -381,14 +381,14 @@ static void tap_cleanup(NetClientState *nc) =20 static void tap_poll(NetClientState *nc, bool enable) { - TAPState *s =3D DO_UPCAST(TAPState, nc, nc); + TAPState *s =3D container_of(nc, TAPState, nc); tap_read_poll(s, enable); tap_write_poll(s, enable); } =20 static bool tap_set_steering_ebpf(NetClientState *nc, int prog_fd) { - TAPState *s =3D DO_UPCAST(TAPState, nc, nc); + TAPState *s =3D container_of(nc, TAPState, nc); assert(nc->info->type =3D=3D NET_CLIENT_DRIVER_TAP); =20 return tap_fd_set_steering_ebpf(s->fd, prog_fd) =3D=3D 0; @@ -396,7 +396,7 @@ static bool tap_set_steering_ebpf(NetClientState *nc, i= nt prog_fd) =20 int tap_get_fd(NetClientState *nc) { - TAPState *s =3D DO_UPCAST(TAPState, nc, nc); + TAPState *s =3D container_of(nc, TAPState, nc); assert(nc->info->type =3D=3D NET_CLIENT_DRIVER_TAP); return s->fd; } @@ -408,7 +408,7 @@ int tap_get_fd(NetClientState *nc) */ static VHostNetState *tap_get_vhost_net(NetClientState *nc) { - TAPState *s =3D DO_UPCAST(TAPState, nc, nc); + TAPState *s =3D container_of(nc, TAPState, nc); assert(nc->info->type =3D=3D NET_CLIENT_DRIVER_TAP); return s->vhost_net; } @@ -447,7 +447,7 @@ static TAPState *net_tap_fd_init(NetClientState *peer, =20 nc =3D qemu_new_net_client(&net_tap_info, peer, model, name); =20 - s =3D DO_UPCAST(TAPState, nc, nc); + s =3D container_of(nc, TAPState, nc); =20 s->fd =3D fd; s->host_vnet_hdr_len =3D vnet_hdr ? sizeof(struct virtio_net_hdr) : 0; @@ -1016,7 +1016,7 @@ fail: =20 int tap_enable(NetClientState *nc) { - TAPState *s =3D DO_UPCAST(TAPState, nc, nc); + TAPState *s =3D container_of(nc, TAPState, nc); int ret; =20 if (s->enabled) { @@ -1033,7 +1033,7 @@ int tap_enable(NetClientState *nc) =20 int tap_disable(NetClientState *nc) { - TAPState *s =3D DO_UPCAST(TAPState, nc, nc); + TAPState *s =3D container_of(nc, TAPState, nc); int ret; =20 if (s->enabled =3D=3D 0) { --=20 MST From nobody Sat Sep 26 20:50:17 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=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1789081482; cv=none; d=zohomail.com; s=zohoarc; b=QPZfIwAJNiTqbWGO1mf56fxZHqBEJ72+alNENpUBzaVR2/GzzpYSkL27RM1RRH0ecgZKPX63Oj+VRBYUh0oI1nRBFhN+VsaQ2gsWSuMTbPtoOsE/WMKQmUke9cIGglJf7W5pSq9l+IW6J1tND/B0mK9x4j2/9jpP7Ekckl0+Cb0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1789081482; h=Content-Type: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=ym7KMRqUcvU4ABujQuwWyzRgxAgmuy8bm1077mgBw+A=; b=FPsIJs6KESSpmYivJ2ZDpoGdRgQsmI2zR7+NL5aA9RQfTCnzr51zrpnMjYXE1QeXx2jb0eQyMoHE2HSOGFVO1fr10O42PSVkkuVy9CtPmGg9x/36e9YC+N0ts5drct24zvGEe/HmxuI0FGcvQCOy1hboxnUx7JHjsSi3fDqj4T0= 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 lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1789081482736142.8229274617422; Thu, 10 Sep 2026 16:04:42 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1x4nlQ-00066j-JB; Thu, 10 Sep 2026 19:01:30 -0400 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 1x4lNl-0003Yh-QO for qemu-devel@nongnu.org; Thu, 10 Sep 2026 16:28:50 -0400 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 1x4lNV-0001Dh-80 for qemu-devel@nongnu.org; Thu, 10 Sep 2026 16:28:19 -0400 Received: from mail-wm1-f72.google.com (mail-wm1-f72.google.com [209.85.128.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-240-Z10Ojd1dMamFWMXCzzBk4Q-1; Thu, 10 Sep 2026 16:12:27 -0400 Received: by mail-wm1-f72.google.com with SMTP id 5b1f17b1804b1-4994cf6cdb9so1564895e9.3 for ; Thu, 10 Sep 2026 13:12:27 -0700 (PDT) Received: from redhat.com (IGLD-80-230-79-236.inter.net.il. [80.230.79.236]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-49e60adaee4sm25603115e9.14.2026.09.10.13.12.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Sep 2026 13:12:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1789072026; 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=ym7KMRqUcvU4ABujQuwWyzRgxAgmuy8bm1077mgBw+A=; b=e41rFEO0t3us9d5PtfthU567tyAWteQ20aGNAocdm0MjtCQwmZX/H8qztTkbXmRQDp9ZOc v7ZplMnjfvQnr4X6SPQe58ztNM6nrbzT1eiIkIX6Yfce82+puhzT0NxA+dugRLOP99EXF2 BEbSOGurFOUhdXfmKGnjS19dfFBpwFw= X-MC-Unique: Z10Ojd1dMamFWMXCzzBk4Q-1 X-Mimecast-MFC-AGG-ID: Z10Ojd1dMamFWMXCzzBk4Q_1789071147 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=google; t=1789071146; x=1789675946; 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=ym7KMRqUcvU4ABujQuwWyzRgxAgmuy8bm1077mgBw+A=; b=QoOg8u6REyAqXLTIZ2xNOa3MSRLF+sU2pX87aGGG4tW+S7Zd8b6CKOC+HNILt9Pgdg 8rr6RRkQUNJFaiD5NU08QFyznExjCcN3+uNknKCF93dqpmYzPPtUgQtkcOBegpvkhedf zQcG0+vSFd5wCIKHfz6IuW14NdgOePu9stWX5lAqECbXqdbKU+F2NZQm626fjphI7KcY 1KpKWoGUaNeW0qO//1p9TT+gvav+2sluDF5icxToxkCzuZFxryj5GZX6SyJr3ujtfNQd 2H9OMDy0BKdaN7Z7ckWAHPstajmKV3xPcXfCpqeTCnjqQcjV4zfI3g/xWFuKMryFqJ38 VfeQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1789071146; x=1789675946; 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=ym7KMRqUcvU4ABujQuwWyzRgxAgmuy8bm1077mgBw+A=; b=VUJwQnllp6ZEqLYDW0ftibxyMNGNpOhTj0IwB2OBHay3q+Y2yFpKEJehYMPzjWEffw sW2JDPEgzs4KYfNT84xkOvLCAMY9UaxonYs4Bbu/lJJFoKWpweaKgv7csXrvydqb7o5/ rXNHrZeS7JkxQjNIpPqcxzHtJa/dRcEHm1TsTtV1RaxPBWT5LcHAsp1f74GPHfaGd5LC 6w/wXHSi0HB4+FMKkOe+BnfPTV2i+ZqRsoU8sA6N7cwkj3jMXT34TF8XURFRsSutnwC6 +bmENjIYwDsRh+/MxzkI9BvVBeXqLm3GYFvSTxqvFBPCrAKsNYJKX6qSuY6AAsqCT8Wr /L0A== X-Gm-Message-State: AFuF++npcbqubV61g9OVd84sNX9iINU7QiJuubfxzxKvPTxRvUXiOq3a ITt+ZqNU1XlcjjBXZZiHzf/uacMEfadM2HMGLtLfUy/SvhQV9Nf4RkFlCjDB72z8zDpc0bKUk/3 +k+FYdyWJkkjXxKT1y3ToEwXINGOWlV+dIIrQQ863ZrKa/p18Rj+kTpzOkpbPZ93V35xIeDb3Ne 1ojXuaROvmX6s4pS+QyGr1jvRm9L3B8Hy0cQ== X-Gm-Gg: AYBFou2X5zdSjcocu1m+g3JaukdfRgCETg4Yp4PvtWjZQPOtrN7BKnwldc+FNS6BFQT xCmezQXRALGgVLIM1g9iQlAX+kFEVg2oQ3zl9oZnhikHLSUdNmjSCA8sKvp5m0JgGPx6f8anxYt EoGxp402DlFW2Ic2sernoVD3QTPBLYSOOVjBUF3i1VNhEdAv9D+hdnJci1Qk1p2UwXpOoFmDyOz sUpA3JdsF371rKYePEz4Gknl+bkRadB55wBQNa15DUfFdqLAYATd245EmBJVooAg8YVoU6CRuj9 nqEkYmaXs3HtsDTnLs0FfW6cndljno7TIVwzE3ihrFxQAWGDGyR2/P/iDjKOBUqux2NJmpWN2Ro YyaRTQoZ3YXyLzW8pn2aJMSw= X-Received: by 2002:a05:600d:8444:10b0:49c:d818:8764 with SMTP id 5b1f17b1804b1-49e61988253mr5830015e9.11.1789071146444; Thu, 10 Sep 2026 13:12:26 -0700 (PDT) X-Received: by 2002:a05:600d:8444:10b0:49c:d818:8764 with SMTP id 5b1f17b1804b1-49e61988253mr5829735e9.11.1789071145975; Thu, 10 Sep 2026 13:12:25 -0700 (PDT) Date: Thu, 10 Sep 2026 16:12:23 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Vladimir Sementsov-Ogievskiy , Ben Chaney , Jason Wang Subject: [PULL 25/90] net/tap: QOMify tap backend Message-ID: <3559b6073c917e55bbd8fffe8df42ead10c19cf9.1789071042.git.mst@redhat.com> References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-Mailer: git-send-email 2.51.2.2891.g4157995a80.dirty X-Mutt-Fcc: =sent 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=170.10.133.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com 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, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_PASS=-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-Zoho-Virus-Status: 1 X-Zoho-AV-Stamp: zmail-av-0.2.13.1.5.4/289.74.40 X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1789081485010158500 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Vladimir Sementsov-Ogievskiy We prepare for being able to migrate TAP backend. We'll need a user change-able property for it, which can be set from machine type. So, let's QOMify it first. Signed-off-by: Vladimir Sementsov-Ogievskiy Reviewed-by: Ben Chaney Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin Message-ID: <20260819180201.1970193-8-vsementsov@yandex-team.ru> --- include/net/net.h | 7 +++++++ include/net/tap.h | 2 ++ net/net.c | 14 +++++++------- net/tap.c | 48 +++++++++++++++++++++++++++++++++++++++-------- 4 files changed, 56 insertions(+), 15 deletions(-) diff --git a/include/net/net.h b/include/net/net.h index 626b997948..ea07760b56 100644 --- a/include/net/net.h +++ b/include/net/net.h @@ -161,6 +161,13 @@ char *qemu_mac_strdup_printf(const uint8_t *macaddr); NetClientState *qemu_find_netdev(const char *id); int qemu_find_net_clients_except(const char *id, NetClientState **ncs, NetClientDriver type, int max); +void qemu_net_client_setup(NetClientState *nc, + NetClientInfo *info, + NetClientState *peer, + const char *model, + const char *name, + NetClientDestructor *destructor, + bool is_datapath); NetClientState *qemu_new_net_client(NetClientInfo *info, NetClientState *peer, const char *model, diff --git a/include/net/tap.h b/include/net/tap.h index 6f34f13eae..268570571f 100644 --- a/include/net/tap.h +++ b/include/net/tap.h @@ -28,6 +28,8 @@ =20 #include "standard-headers/linux/virtio_net.h" =20 +#define TYPE_TAP_NETDEV "tap-netdev" + int tap_enable(NetClientState *nc); int tap_disable(NetClientState *nc); =20 diff --git a/net/net.c b/net/net.c index 1161183e18..d7fa637ce5 100644 --- a/net/net.c +++ b/net/net.c @@ -261,13 +261,13 @@ static ssize_t qemu_deliver_packet_iov(NetClientState= *sender, int iovcnt, void *opaque); =20 -static void qemu_net_client_setup(NetClientState *nc, - NetClientInfo *info, - NetClientState *peer, - const char *model, - const char *name, - NetClientDestructor *destructor, - bool is_datapath) +void qemu_net_client_setup(NetClientState *nc, + NetClientInfo *info, + NetClientState *peer, + const char *model, + const char *name, + NetClientDestructor *destructor, + bool is_datapath) { nc->info =3D info; nc->model =3D g_strdup(model); diff --git a/net/tap.c b/net/tap.c index bfed74717e..7392344200 100644 --- a/net/tap.c +++ b/net/tap.c @@ -43,6 +43,7 @@ #include "qemu/main-loop.h" #include "qemu/sockets.h" #include "hw/virtio/vhost.h" +#include "qom/object.h" =20 #include "net/tap.h" #include "net/util.h" @@ -68,7 +69,11 @@ static const int kernel_feature_bits[] =3D { VHOST_INVALID_FEATURE_BIT }; =20 -typedef struct TAPState { +OBJECT_DECLARE_SIMPLE_TYPE(TAPState, TAP_NETDEV) + +struct TAPState { + Object parent_obj; + NetClientState nc; int fd; int vhostfd; @@ -86,7 +91,7 @@ typedef struct TAPState { VHostNetState *vhost_net; unsigned host_vnet_hdr_len; Notifier exit; -} TAPState; +}; =20 static void launch_script(const char *setup_script, const char *ifname, int fd, Error **errp); @@ -413,6 +418,19 @@ static VHostNetState *tap_get_vhost_net(NetClientState= *nc) return s->vhost_net; } =20 + +static const TypeInfo tap_netdev_info =3D { + .name =3D TYPE_TAP_NETDEV, + .parent =3D TYPE_OBJECT, + .instance_size =3D sizeof(TAPState), +}; + +static void tap_net_client_destructor(NetClientState *nc) +{ + TAPState *s =3D container_of(nc, TAPState, nc); + object_unref(OBJECT(s)); +} + /* fd support */ =20 static NetClientInfo net_tap_info =3D { @@ -435,6 +453,18 @@ static NetClientInfo net_tap_info =3D { .get_vhost_net =3D tap_get_vhost_net, }; =20 +static TAPState *new_tap(NetClientState *peer, + const char *model, + const char *name) +{ + TAPState *s =3D TAP_NETDEV(object_new(TYPE_TAP_NETDEV)); + + qemu_net_client_setup(&s->nc, &net_tap_info, peer, model, name, + tap_net_client_destructor, true); + + return s; +} + static TAPState *net_tap_fd_init(NetClientState *peer, const char *model, const char *name, @@ -442,12 +472,7 @@ static TAPState *net_tap_fd_init(NetClientState *peer, int vnet_hdr) { NetOffloads ol =3D {}; - NetClientState *nc; - TAPState *s; - - nc =3D qemu_new_net_client(&net_tap_info, peer, model, name); - - s =3D container_of(nc, TAPState, nc); + TAPState *s =3D new_tap(peer, model, name); =20 s->fd =3D fd; s->host_vnet_hdr_len =3D vnet_hdr ? sizeof(struct virtio_net_hdr) : 0; @@ -1048,3 +1073,10 @@ int tap_disable(NetClientState *nc) return ret; } } + +static void tap_register_types(void) +{ + type_register_static(&tap_netdev_info); +} + +type_init(tap_register_types) --=20 MST From nobody Sat Sep 26 20:50:17 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=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1789076443; cv=none; d=zohomail.com; s=zohoarc; b=LL6KC4qhctNZrrh63ihgwQmH8Kh1Qqv+ZnELyVHDJv0gtrfjU1wWB+SvxbLbZymDMLpnCmrEWchQMalSX0hMVVTlZY7dHF8tDb3A2uIXNd0ViN9XxKUtbPvmHR2XaGfiyrU8P7WsszonwtBNHIeKYJuDLoU+LaTJkHd8fmD0/xE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1789076443; h=Content-Type: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=RmU1ZVuK0eWJ8g7D4bDyVxoI5VfvIMF1jU9CZuz+FqI=; b=nqND9PcydF5jjRGMuBe761wP9Qa5O4h4F5cYIB29O0X6YarBhmKAbJ0JXx76lDevuSCFxG8WJ3A631qPXSnLbmovfSF5mq9R6KHC2BglevPPV3+PGROC2IFI40B4xxFdwI7I9brEyfN4u2XMcAdwjBIU1RCP9OUaHhvSFhSovSU= 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 lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1789076443561837.2456159446795; Thu, 10 Sep 2026 14:40:43 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1x4mKP-0001CH-ST; Thu, 10 Sep 2026 17:29:28 -0400 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 1x4lK2-0002QM-L1 for qemu-devel@nongnu.org; Thu, 10 Sep 2026 16:24:50 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1x4lJp-0000TF-OH for qemu-devel@nongnu.org; Thu, 10 Sep 2026 16:24:34 -0400 Received: from mail-wm1-f69.google.com (mail-wm1-f69.google.com [209.85.128.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-519-pNwfoZnEPnS0VcfjxdLsMA-1; Thu, 10 Sep 2026 16:12:30 -0400 Received: by mail-wm1-f69.google.com with SMTP id 5b1f17b1804b1-49cf5bd2f12so2190855e9.1 for ; Thu, 10 Sep 2026 13:12:30 -0700 (PDT) Received: from redhat.com (IGLD-80-230-79-236.inter.net.il. [80.230.79.236]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-49d26c494basm87343805e9.12.2026.09.10.13.12.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Sep 2026 13:12:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1789071783; 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=RmU1ZVuK0eWJ8g7D4bDyVxoI5VfvIMF1jU9CZuz+FqI=; b=Hjq1RdKZ0eA+LrdCMDEEf6/DIqabDWRaiXSvrWEjG+hwxjSkh6IX8dNkC7ApRQrVfjv95m mN4vPiiXfo40xQrMIjxo2kQi0pTxbOsR4QHtjfGX2ItZefY3nTZzFgNeBh81iB6GGTkChn 4fm6iKUPcU54fMRw+/M/wxuj62Waiag= X-MC-Unique: pNwfoZnEPnS0VcfjxdLsMA-1 X-Mimecast-MFC-AGG-ID: pNwfoZnEPnS0VcfjxdLsMA_1789071149 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=google; t=1789071149; x=1789675949; 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=RmU1ZVuK0eWJ8g7D4bDyVxoI5VfvIMF1jU9CZuz+FqI=; b=S30Ft62Y8fsesBugWok85KY8OHvlNV2KPegyaV2S49Yxt70F9YejYLxBwqLHxgn0Zn abkrj0ISqzo1d+15dzSnFAmc9/lCia00t7uFmqj0490HArdIrYw02ik+xPu6XvqW2KH8 fknAiN1Qmmrb9NEGeigl3X6ojweZekIOSBxWLBY5Bf5eMwoaWe/wo6PMyGCVAztCYJVU cFdRQRl0IALP4yE9kcfYsCBFd/g5tGjHn5d85ta48R9U/xJ//5yIpgum2IMTjcAcdzIh EWi7cDgMfIeC9A01juIuB//wral05tg2AocNgmHgrJ74vLgQcQjoPBvd1oaS8+J8YslB DTOw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1789071149; x=1789675949; 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=RmU1ZVuK0eWJ8g7D4bDyVxoI5VfvIMF1jU9CZuz+FqI=; b=JSBbTiIBElcTruTYBlfFJRadnePlYYYw+Z6XFWi3rLIRdgjMawBlVwbp+MPOQD1o1z rLi2Cc/a+x1TOAYEWnDQ069dRqRxGKInAr+9uZAfOy8mXPBW4YdFdhn5UUrHk6WOvYzB P7kohIj/HOu0yf4PJ1ijBxuJ7XNpqu6uNfQZMYiEkdUvjM/rCvJrjbbq/8vvNkh/j/qH wVeLdoU0VvN4IwW2smiGoXYAGYc5cgruEO6PIO6cPWpEGDpsSf5fBXtYc/vbrifSblcT 9L5QSILEsLMqkYeXe3cazLo/Q9HyYcMCWtgycuKP55w31WC3hnFEzdBDEdsncRJZ9MFT WvmA== X-Gm-Message-State: AFuF++lyxfHvAcIpsyi3ujmfX5X2wI0xC+J4hpc0RQ+TXLcR4/p9nbZQ GP8yqx4z3v1MXuNDs4Jqwpmrvd32U1ymI1azaT5cin+V0Tr82WcMtg+bQ4PnM4JComV1bHUcoYX MjtPO2ghRIyTSJP69wHBGnsXdfCSw5pyuaYgX9aRNI5j5o01VuPMWVRqMgZxRRQDm4Rbh89S2c1 h9uiP2vo//wd8f0xAUgpxEws8NsA4zjKWWiQ== X-Gm-Gg: AYBFou3NsQCFwhaDxh2DLOE1l9f9kQmaGcYXzgH3y7dpszkUiyIdrg3o8peDUv3rAqS PV8+Yyg/ct5kTRhjp3ByP+NlfaP1T+9LXDdKOzRbMhqx/IOXV9N704HWJkV7GhePFn+UpNYifnD 8Q/BM62GsEkiel4VeUMIXRB+l6CCH6B/76TbeW+XYCWQkOv1MkRsjZeTZs36uyweNTD/lpxxAmg SRNyxME4vew6rdpsiYows66vliIrJrWAgpH8COk3FHJpzwTvJxy9lv4Mtg0zrSBd944kxNhqXVr QHVZXeqeDLJvbeoQVSy6qW18j7iCo/CS6qhbEY2jpFPBM2y5WJwhPNe1TiL8Rmi8fcqcQ08g7h6 7EAyYvS2JSidcfG0f5UWsjG0= X-Received: by 2002:a05:600c:b96:b0:49c:dada:30b7 with SMTP id 5b1f17b1804b1-49e618898eamr7003625e9.2.1789071148924; Thu, 10 Sep 2026 13:12:28 -0700 (PDT) X-Received: by 2002:a05:600c:b96:b0:49c:dada:30b7 with SMTP id 5b1f17b1804b1-49e618898eamr7003165e9.2.1789071148362; Thu, 10 Sep 2026 13:12:28 -0700 (PDT) Date: Thu, 10 Sep 2026 16:12:26 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Vladimir Sementsov-Ogievskiy , Ben Chaney , Jason Wang Subject: [PULL 26/90] net/tap: add TYPE_VMSTATE_IF interface Message-ID: References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-Mailer: git-send-email 2.51.2.2891.g4157995a80.dirty X-Mutt-Fcc: =sent 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=170.10.129.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com 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, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=0.001, SPF_HELO_PASS=-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-Zoho-Virus-Status: 1 X-Zoho-AV-Stamp: zmail-av-0.2.13.1.5.4/289.52.80 X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1789076446020158500 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Vladimir Sementsov-Ogievskiy We'll need it to implement TAP backend live migration. Signed-off-by: Vladimir Sementsov-Ogievskiy Reviewed-by: Ben Chaney Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin Message-ID: <20260819180201.1970193-9-vsementsov@yandex-team.ru> --- net/tap.c | 43 ++++++++++++++++++++++++++++++++++--------- 1 file changed, 34 insertions(+), 9 deletions(-) diff --git a/net/tap.c b/net/tap.c index 7392344200..dd0d134875 100644 --- a/net/tap.c +++ b/net/tap.c @@ -43,7 +43,6 @@ #include "qemu/main-loop.h" #include "qemu/sockets.h" #include "hw/virtio/vhost.h" -#include "qom/object.h" =20 #include "net/tap.h" #include "net/util.h" @@ -91,6 +90,8 @@ struct TAPState { VHostNetState *vhost_net; unsigned host_vnet_hdr_len; Notifier exit; + + int queue_index; }; =20 static void launch_script(const char *setup_script, const char *ifname, @@ -419,10 +420,29 @@ static VHostNetState *tap_get_vhost_net(NetClientStat= e *nc) } =20 =20 +static char *tap_vmstate_if_get_id(VMStateIf *obj) +{ + TAPState *s =3D TAP_NETDEV(obj); + char *res =3D g_strdup_printf("%s/%d", s->nc.name, s->queue_index); + return res; +} + +static void tap_class_init(ObjectClass *klass, const void *data) +{ + VMStateIfClass *vc =3D VMSTATE_IF_CLASS(klass); + + vc->get_id =3D tap_vmstate_if_get_id; +} + static const TypeInfo tap_netdev_info =3D { .name =3D TYPE_TAP_NETDEV, .parent =3D TYPE_OBJECT, .instance_size =3D sizeof(TAPState), + .class_init =3D tap_class_init, + .interfaces =3D (const InterfaceInfo[]) { + { TYPE_VMSTATE_IF }, + { } + }, }; =20 static void tap_net_client_destructor(NetClientState *nc) @@ -455,13 +475,16 @@ static NetClientInfo net_tap_info =3D { =20 static TAPState *new_tap(NetClientState *peer, const char *model, - const char *name) + const char *name, + int queue_index) { TAPState *s =3D TAP_NETDEV(object_new(TYPE_TAP_NETDEV)); =20 qemu_net_client_setup(&s->nc, &net_tap_info, peer, model, name, tap_net_client_destructor, true); =20 + s->queue_index =3D queue_index; + return s; } =20 @@ -469,10 +492,11 @@ static TAPState *net_tap_fd_init(NetClientState *peer, const char *model, const char *name, int fd, - int vnet_hdr) + int vnet_hdr, + int queue_index) { NetOffloads ol =3D {}; - TAPState *s =3D new_tap(peer, model, name); + TAPState *s =3D new_tap(peer, model, name, queue_index); =20 s->fd =3D fd; s->host_vnet_hdr_len =3D vnet_hdr ? sizeof(struct virtio_net_hdr) : 0; @@ -709,7 +733,7 @@ int net_init_bridge(const Netdev *netdev, const char *n= ame, close(fd); return -1; } - s =3D net_tap_fd_init(peer, "bridge", name, fd, vnet_hdr); + s =3D net_tap_fd_init(peer, "bridge", name, fd, vnet_hdr, 0); =20 qemu_set_info_str(&s->nc, "helper=3D%s,br=3D%s", helper, br); =20 @@ -785,10 +809,11 @@ static bool net_init_tap_one(const NetdevTapOptions *= tap, NetClientState *peer, const char *name, const char *ifname, const char *script, const char *downscript, int vhostfd, - int vnet_hdr, int fd, Error **errp) + int vnet_hdr, int fd, int queue_index, + Error **errp) { TAPState *s =3D net_tap_fd_init(peer, tap->helper ? "bridge" : "tap", - name, fd, vnet_hdr); + name, fd, vnet_hdr, queue_index); bool sndbuf_required =3D tap->has_sndbuf; int sndbuf =3D (tap->has_sndbuf && tap->sndbuf) ? MIN(tap->sndbuf, INT_MAX) : INT= _MAX; @@ -989,7 +1014,7 @@ int net_init_tap(const Netdev *netdev, const char *nam= e, if (!net_init_tap_one(tap, peer, name, ifname, NULL, NULL, vhost_fds ? vhost_fds[i] : -1, - vnet_hdr, fds[i], errp)) { + vnet_hdr, fds[i], i, errp)) { goto fail; } } @@ -1024,7 +1049,7 @@ int net_init_tap(const Netdev *netdev, const char *na= me, i >=3D 1 ? NULL : script, i >=3D 1 ? NULL : downscript, vhost_fds ? vhost_fds[i] : -1, - vnet_hdr, fd, errp)) { + vnet_hdr, fd, i, errp)) { goto fail; } } --=20 MST From nobody Sat Sep 26 20:50:17 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=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1789082573; cv=none; d=zohomail.com; s=zohoarc; b=booBTJmiq9fb3ziBgfH3vgi38aNIkLLwbEPzbHOVL0UiHNKG6UKvqzgpgapoDIES/Ee1H2r7ONomnHyQhQaSD6VROLl7b1gzAtyGH2NJQotsbPkfc0cinBAOIPTZoKxDQ3uTYZ43Ub6Ikmr/wqh4+m1mVkcf9LSgmZ8LgQWiRYE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1789082573; h=Content-Type: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=dveBwypMxxlS0tHYi3KN/e1QMBIv6aayFrNW2TY0wNY=; b=fo5Z9nDE1LUWEF7M5QT1IFMzDYyRhImPuaIzCOasO95iIVPSph87fPInhON0a5JuKxLyvZciGP94bSDmkR52snw3CiLm2sNjkxtbSQnLca89bgp05RQZbmK1jNuA4npNsNHGLY2ACfX9zSYRsSOX+UrzBH1d9qVXuqzsMvrKceE= 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 lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 178908257330693.0868024636469; Thu, 10 Sep 2026 16:22:53 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1x4nnj-0006il-G3; Thu, 10 Sep 2026 19:03:46 -0400 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 1x4lWk-0006ak-1e for qemu-devel@nongnu.org; Thu, 10 Sep 2026 16:38:07 -0400 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 1x4lWQ-0004kc-8l for qemu-devel@nongnu.org; Thu, 10 Sep 2026 16:37:32 -0400 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-163-vrBAOIujM82xawktE87_Ig-1; Thu, 10 Sep 2026 16:12:33 -0400 Received: by mail-wm1-f70.google.com with SMTP id 5b1f17b1804b1-49b7c1dcc82so1273655e9.0 for ; Thu, 10 Sep 2026 13:12:32 -0700 (PDT) Received: from redhat.com (IGLD-80-230-79-236.inter.net.il. [80.230.79.236]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-49e60aba026sm19917895e9.3.2026.09.10.13.12.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Sep 2026 13:12:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1789072566; 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=dveBwypMxxlS0tHYi3KN/e1QMBIv6aayFrNW2TY0wNY=; b=ijft60zSJC4pExnrT6RDirM/EU/r2HDPTrFcu5g12V13hT8HOcSxFFzuHwHdbmohuEjjTM wX9mYZsQzTR/lKdc88e63zerIFX7LeO1FQjr3eZIVXkwgYXUAJ/x7dTeUzNfFj/44QqOkN 6Wj06raM+0t5KS5I9DxsctCw0GEkIAo= X-MC-Unique: vrBAOIujM82xawktE87_Ig-1 X-Mimecast-MFC-AGG-ID: vrBAOIujM82xawktE87_Ig_1789071152 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=google; t=1789071152; x=1789675952; 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=dveBwypMxxlS0tHYi3KN/e1QMBIv6aayFrNW2TY0wNY=; b=SqwI09eFfnW50KEk/oTqrXw5mFYmDB95jE3X1INp2PGCLHt6OoBOk3huNlOxx7RGc7 jhXBg7W5SFcmgSXcYucliS9hjQP10JRaNjui8Hw27WADW1FX3kPD2QBdUBG1LlvZiWEi PUWC2WlOV0A0+Y3ccwSmBDIAI31SP+ugLlWI8FtKIcAt6YaoAWm3b9tsf8xRL3cYd5Gl 20CQpv9CBUpdxAQNG2sguyXToajQs+7qjFdDHwk8NSPBfa6JSVFKOuDW7jxzFYpREpA7 iXUIb+3ezgHF2AZBahNI+lOtOvn0IbJzkK0CGOmk+ll+bBmTB+aSwq2DcEECZE8MTP6m Sdtg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1789071152; x=1789675952; 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=dveBwypMxxlS0tHYi3KN/e1QMBIv6aayFrNW2TY0wNY=; b=grKHyyZyHy7Jup9EBjFz4PGmA9idS+zpEt06LficJGwur4wwFmd+maoIh+4CVIQtsz RImAEO4YzbUm5xJ8tq5wEbLkWR4dYE2ZFZNkf5iSQMW2gRzALznytfVDFykdaOQ+ckZz AdZWNOBwvqmbWPq0txelAcJMXXy3Ne7kigLlJ9OAPjKzHMzjz5p14VTJ/4dZE2uTetIB mUndz5aRXTUrVYNXPUsvb2JSBmWRY/UllCoaBiuWwUsrSNpERlJNL67i/JB/yZJjlj33 Yldl5rOSya5nRYWHRMXBaJXeFgttBLfzPe6KBWs/D2SA67uN+Nz9w8Yt64M/HxVYsJEC 71CQ== X-Gm-Message-State: AFuF++nMORGFJpwa9BCD08Yz4YmS9ow50O2wlqB77qY6dql4+va42kcm LwUwbewjEUbyqFHGRo5z5Qxm4h2LVv6gauZVu8I4CBIqemygDBHp3DiTmr7zwf6JopQSU+V3t37 2s/hJJaGTzhdUdLSTBaXZxKFctCeVnZXJHo+9nz5WjrHyRLcGWOY59Y9DVDIhJRIDALlNK1k9HR 0oF+2QGYWpGeU1UK2VE1C8GJnaOHBHn7v3wA== X-Gm-Gg: AYBFou2Kxm9yWX4CefkmakdU1ZE37k5FDwqjh2xV7BcJBVv+CgQ+1DS/zzjLmu0YLeh aR4ZvAVrWjO1rqJ/uejGt9XVHHclu/Kzi4p4O3zt7e4eadf3JSWRZ49qrfCf8Pmfp73HwYYyuLl GwaEX03CDnThxpwFkkJy575Cr7y0Nej88yqV9d+5ABUGiEa7XZwUlx0xALIiaRWJRASIXDWMSzK V9M5w6AddL+T54UiHAYSUDWWXmPQ4QdpcTGNYikA3D/ajaNq7XvPkdqnAjKI54/2GTGVSUzdQOV Lgymy0yMX0daOoSWPOY9XVMGXTrCZHdiVs59LogxqBRckTWUKu7CsTEQoWBo4KCggzBoUbvFZet Z1GZdpdBNxYM/azvqouFIpd0= X-Received: by 2002:a05:600c:34c2:b0:49c:fc6e:a3dc with SMTP id 5b1f17b1804b1-49e619d87ecmr7677795e9.27.1789071151695; Thu, 10 Sep 2026 13:12:31 -0700 (PDT) X-Received: by 2002:a05:600c:34c2:b0:49c:fc6e:a3dc with SMTP id 5b1f17b1804b1-49e619d87ecmr7677485e9.27.1789071151238; Thu, 10 Sep 2026 13:12:31 -0700 (PDT) Date: Thu, 10 Sep 2026 16:12:28 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Vladimir Sementsov-Ogievskiy , Markus Armbruster , Peter Xu , Fabiano Rosas , Eric Blake Subject: [PULL 27/90] qapi: add local migration parameter Message-ID: References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-Mailer: git-send-email 2.51.2.2891.g4157995a80.dirty X-Mutt-Fcc: =sent 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=170.10.133.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com 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, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_PASS=-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-Zoho-Virus-Status: 1 X-Zoho-AV-Stamp: zmail-av-0.2.13.1.5.4/289.74.40 X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1789082576279158500 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Vladimir Sementsov-Ogievskiy We are going to implement local-migration feature: some devices will be able to transfer open file descriptors through migration stream (which must UNIX domain socket for that purpose). This allows to transfer the whole backend state without reconnecting and restarting the backend service. For example, virtio-net will migrate its attached TAP netdev, together with its connected file descriptors. In this commit we introduce a migration parameter, which enables the feature for devices that support it (none at the moment). We can't simply auto-detect local migration by checking whether the migration channel is a UNIX domain socket: the UNIX socket may be only the first part of the transfer channel to a remote target. Hence an explicit parameter is needed. Moreover, "local" migration parameter may be useful in cpr-exec mode, when FDs are passed through exec instead of UNIX socket. Signed-off-by: Vladimir Sementsov-Ogievskiy Acked-by: Markus Armbruster Reviewed-by: Peter Xu Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin Message-ID: <20260819180201.1970193-10-vsementsov@yandex-team.ru> --- qapi/migration.json | 21 +++++++++++++++++---- include/migration/misc.h | 2 ++ migration/options.c | 18 +++++++++++++++++- 3 files changed, 36 insertions(+), 5 deletions(-) diff --git a/qapi/migration.json b/qapi/migration.json index b1eaf7b054..f7628b55e9 100644 --- a/qapi/migration.json +++ b/qapi/migration.json @@ -830,7 +830,8 @@ 'zero-page-detection', 'direct-io', { 'name': 'x-rdma-chunk-size', 'features': [ 'unstable' ] }, - 'cpr-exec-command'] } + 'cpr-exec-command', + 'local'] } =20 ## # @migrate-set-parameters: @@ -1012,10 +1013,20 @@ # Must be set to the same value on both source and destination # before migration starts. (Since 11.1) # +# @local: Permit the use of optimizations for local migration. This +# must only be set when either both the source and destination +# QEMU processes are directly connected with a UNIX domain socket +# as the migration channel (to enable use of file descriptor +# passing) or cpr-exec migration mode is enabled (this way file +# descriptors are inherited by new process). Individual device +# backends may need additional configuration flags set to enable +# local migration optimizations. This will be documented against +# the device backends where it applies. (Since 11.2) +# # Features: # -# @unstable: Members @x-checkpoint-delay, @x-rdma-chunk-size, and -# @x-vcpu-dirty-limit-period are experimental. +# @unstable: Members @local, @x-checkpoint-delay, @x-rdma-chunk-size, +# and @x-vcpu-dirty-limit-period are experimental. # # Since: 2.4 ## @@ -1053,7 +1064,9 @@ '*direct-io': 'bool', '*x-rdma-chunk-size': { 'type': 'uint64', 'features': [ 'unstable' ] }, - '*cpr-exec-command': [ 'str' ]} } + '*cpr-exec-command': [ 'str' ], + '*local': { 'type': 'bool', + 'features': [ 'unstable' ] } } } =20 ## # @query-migrate-parameters: diff --git a/include/migration/misc.h b/include/migration/misc.h index 2b2fbb59a4..019717f4cd 100644 --- a/include/migration/misc.h +++ b/include/migration/misc.h @@ -161,4 +161,6 @@ bool multifd_join_device_state_save_threads(void); =20 void migration_request_switchover_ack_legacy(const char *requester); =20 +bool migrate_local(void); + #endif diff --git a/migration/options.c b/migration/options.c index d2575edb6c..05b026f4bf 100644 --- a/migration/options.c +++ b/migration/options.c @@ -14,6 +14,7 @@ #include "qemu/osdep.h" #include "qemu/error-report.h" #include "qemu/units.h" +#include "qapi/util.h" #include "exec/target_page.h" #include "qapi/clone-visitor.h" #include "qapi/error.h" @@ -25,6 +26,7 @@ #include "migration/colo.h" #include "migration/cpr.h" #include "migration/misc.h" +#include "migration/options.h" #include "migration.h" #include "migration-stats.h" #include "qemu-file.h" @@ -350,6 +352,12 @@ bool migrate_mapped_ram(void) return s->capabilities[MIGRATION_CAPABILITY_MAPPED_RAM]; } =20 +bool migrate_local(void) +{ + MigrationState *s =3D migrate_get_current(); + return s->parameters.local; +} + bool migrate_ignore_shared(void) { MigrationState *s =3D migrate_get_current(); @@ -1101,7 +1109,7 @@ static void migrate_mark_all_params_present(Migration= Parameters *p) &p->has_announce_step, &p->has_block_bitmap_mapping, &p->has_x_vcpu_dirty_limit_period, &p->has_vcpu_dirty_limit, &p->has_mode, &p->has_zero_page_detection, &p->has_direct_io, - &p->has_x_rdma_chunk_size, &p->has_cpr_exec_command, + &p->has_x_rdma_chunk_size, &p->has_cpr_exec_command, &p->has_local, }; =20 len =3D ARRAY_SIZE(has_fields); @@ -1449,6 +1457,10 @@ static void migrate_params_test_apply(MigrationParam= eters *params, qapi_free_strList(dest->cpr_exec_command); dest->cpr_exec_command =3D QAPI_CLONE(strList, params->cpr_exec_co= mmand); } + + if (params->has_local) { + dest->local =3D params->local; + } } =20 static void migrate_params_apply(MigrationParameters *params) @@ -1581,6 +1593,10 @@ static void migrate_params_apply(MigrationParameters= *params) s->parameters.cpr_exec_command =3D QAPI_CLONE(strList, params->cpr_exec_command); } + + if (params->has_local) { + s->parameters.local =3D params->local; + } } =20 void qmp_migrate_set_parameters(MigrationParameters *params, Error **errp) --=20 MST From nobody Sat Sep 26 20:50:17 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=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1789077236; cv=none; d=zohomail.com; s=zohoarc; b=dJiY+s24JDwZsODBEQSzarygOq11yhH4zeb21XvgHLXPg1hFCtUieD6w8J96pvGGsItJeO4EZUc5HnlzMYoBjboXmxC/m+sE9ZTeHRIsEeD6grR2N6gZegtKXAzD/lKMST/yvsZP42Q33nTbXU2uqelAlVop0V4SvSceJ6MXrvk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1789077236; h=Content-Type: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=qnAlDO2QjRLH3bD583YkEJaCzSVpdg74aK2h0Y1Pq7U=; b=bitg+N6mKSXfp1GnR2Pt97aoyyhQcIgoy6enw/NYPE6rn6GHqF6mF5+/E5H77q6V+GH+HqFJ8LvW3lZtmCJg3x0JTVzpT4C3x5kDxVmYjUAmZYQNsPFqmN13Fm7gk/9jViPr2MxE0YCDPfKh0jR5NQGxtoQnscg9wHVOxi0wZ34= 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 lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1789077236179704.0226221467734; Thu, 10 Sep 2026 14:53:56 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1x4mev-0005HX-Dl; Thu, 10 Sep 2026 17:50:25 -0400 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 1x4lWg-0006Zl-JL for qemu-devel@nongnu.org; Thu, 10 Sep 2026 16:37:55 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1x4lWK-0004kf-Dz for qemu-devel@nongnu.org; Thu, 10 Sep 2026 16:37:28 -0400 Received: from mail-wm1-f69.google.com (mail-wm1-f69.google.com [209.85.128.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-596-PygtLgpcODS8YaFvv21ZYw-1; Thu, 10 Sep 2026 16:12:35 -0400 Received: by mail-wm1-f69.google.com with SMTP id 5b1f17b1804b1-49cf5bd2f12so2191925e9.1 for ; Thu, 10 Sep 2026 13:12:35 -0700 (PDT) Received: from redhat.com (IGLD-80-230-79-236.inter.net.il. [80.230.79.236]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-486eb32d3c7sm754511f8f.10.2026.09.10.13.12.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Sep 2026 13:12:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1789072566; 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=qnAlDO2QjRLH3bD583YkEJaCzSVpdg74aK2h0Y1Pq7U=; b=EaA8PtF+9QKF23MDdBat5qmYJ3QLGhWP8nCeL5/N9OpNDwQgHvl9CELvh3lQR5Oz9YANqp KEPQHEyWPSU4pYIek2o5VM3L7w28F7GQ0Pi3nas6IIZKBDTwM4QsvmjGHGoa+ZazabbWj9 9j0FhVZkGyCaIkDJj69yA/4bznu0O9g= X-MC-Unique: PygtLgpcODS8YaFvv21ZYw-1 X-Mimecast-MFC-AGG-ID: PygtLgpcODS8YaFvv21ZYw_1789071155 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=google; t=1789071155; x=1789675955; 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=qnAlDO2QjRLH3bD583YkEJaCzSVpdg74aK2h0Y1Pq7U=; b=BkfNXQE4m0a3R68mP9RlHNdkxFiDW9bNFoWzJkBH3OrjHNgyEH2WfsxlcuZWDvQPP2 FwLce1kSCW6q1LMLeZQOc+tQlWTR5C6as+qBlESwnBdqW7eP9cq0HQ7X2SXIDybLYC4u F4DsskvSc/b1YMnZGMeeRMMs1A2woHPuSGYrw0OXYDZgjx0i8fdNMwJYCVGsjImiKvY7 nDXBbH/7qRiQKEr0wt1pNWwk/tL/s7EumII2cEqbqsyECRg5ZNKN8Uc8xze6YU7bqCFA qqg0BsjT9+vAsmn3KpvZ8800AxHqVdt8sQRbes0NrkQipe7oLb92AtZX8VMbmehSesxo DgRA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1789071155; x=1789675955; 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=qnAlDO2QjRLH3bD583YkEJaCzSVpdg74aK2h0Y1Pq7U=; b=JjydlKVzfIl4PWy2v+jke8KvPDagyn6deXMR4c12URFeOorNYcs7X1tm2OOfByNg3F 22FFVKmhgLEJRsKZMULkJHXreeC+HLzCBD3ZlCQ4IWzgqinPCj622o6WRTpct09HvAWr u2MXLRCsa21+cCQ7o2rrMOhKFMvwhKfptrjAKKdoOwE+RX8ML7gpTfgHhn5N+xlkSSAt kKjOvhUk+KTnnLpb93IXQS1WhVbP7In5oLGaBKfVnVRoEEXbajocgeGUBblUhK1dCGfi 6Le7otjsEAUBryKbt32kmAzkQmieNrgajH7Dlgg7irEfALRqcgEdgl1ZR7l7KBEbRLxH Nx9g== X-Gm-Message-State: AFuF++kwhp2kvj7L42qLZcrFvpv65q9no/o7dlW2rnAN0nnkmT+kj6lF 3v9U45NJ5MprPrse9soJ9gMIpAgpTOM0kP0AfY167FpD1ZfT0SJs3BIM4y1gT45Nq33FRCWuQO2 5lk2nPaF1UE9qP2o1BHgGO5SaxbgxvQ6b+PE/7kXSWYWbZ1TJNSEf8gofJDGmLGNeS9JGI7lOWr s8AvkK8RzkH+Ydr+nSfI+XwFHmXncrnWahfA== X-Gm-Gg: AYBFou0RBTvKN5qZNLep3K7Nggub1mXM+W0Ze1bDMwRQBOkwGiVxHvbHqlxixOOeR67 HQ5u1V8X0nY9CxPjBw2rLzRfnJA+nbKZdUYmnMD9t02gFjU/1WQNIf7Axdu4fdwob1xtVk3Sx48 hVEp42lMb8KzqZu4JXCu2LJavyN4n4X/3/4h/K+tZNEVZ8L6Sey24yFBQXK/iSbJGzJL697wo++ ahTSZ31bzKfZKQvmJi5oZSkILtqy9/uikeG53zsXHGH9I8zZqCcBHsPLUg3gNcfo7ULewXnTphc BUhZUfOIHx2YTB53VvAMR/XuSVR5p65/7HH8qr1uC454hjP2tyscT/swkVD/D4zaBYxtPpPf9QN lw22YEIzZl+JzBtYX58Q8Dsw= X-Received: by 2002:a05:600c:c491:b0:49d:827:e5b6 with SMTP id 5b1f17b1804b1-49e619bb949mr8885745e9.20.1789071154587; Thu, 10 Sep 2026 13:12:34 -0700 (PDT) X-Received: by 2002:a05:600c:c491:b0:49d:827:e5b6 with SMTP id 5b1f17b1804b1-49e619bb949mr8885115e9.20.1789071154030; Thu, 10 Sep 2026 13:12:34 -0700 (PDT) Date: Thu, 10 Sep 2026 16:12:31 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Vladimir Sementsov-Ogievskiy , Peter Xu , Fabiano Rosas Subject: [PULL 28/90] migration/fd: fix fd leak when fd is not valid for migration Message-ID: <7630e775908de3f4e9969234d0ca74360a00f872.1789071042.git.mst@redhat.com> References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-Mailer: git-send-email 2.51.2.2891.g4157995a80.dirty X-Mutt-Fcc: =sent 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=170.10.129.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com 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, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=0.001, SPF_HELO_PASS=-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-Zoho-Virus-Status: 1 X-Zoho-AV-Stamp: zmail-av-0.2.13.1.5.4/289.74.40 X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1789077239117158500 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Vladimir Sementsov-Ogievskiy Both fd_connect_outgoing() and fd_connect_incoming() own the file descriptor after resolving it from the monitor, but forget to close it when migration_fd_valid() check fails. Signed-off-by: Vladimir Sementsov-Ogievskiy Reviewed-by: Peter Xu Fixes: f1fcc1c101 ("migration: Remove fd: support on files") Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin Message-ID: <20260819180201.1970193-11-vsementsov@yandex-team.ru> --- migration/fd.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/migration/fd.c b/migration/fd.c index f05f95992f..02b39b150e 100644 --- a/migration/fd.c +++ b/migration/fd.c @@ -62,6 +62,7 @@ QIOChannel *fd_connect_outgoing(MigrationState *s, const = char *fdname, if (!migration_fd_valid(fd)) { error_setg(errp, "fd: migration to a file is not supported." " Use file: instead."); + close(fd); goto out; } =20 @@ -97,6 +98,7 @@ void fd_connect_incoming(const char *fdname, Error **errp) if (!migration_fd_valid(fd)) { error_setg(errp, "fd: migration to a file is not supported." " Use file: instead."); + close(fd); return; } =20 --=20 MST From nobody Sat Sep 26 20:50:17 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=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1789076808; cv=none; d=zohomail.com; s=zohoarc; b=FRm5d7ZSTN+1+vvwndXcC52Fc+loiCzqlmVFOwUxIdPEEhaNj0sLBnT2KLG48DcMzrB8n27LvNUKj100ivP9aacJi8A1lHbwl3RBWtDCT2jyGqPPML3yjJuQkUpaGR1lDp25+5rxh323SBoALo9mv+cwiHdBn5j3lArBmNxqn8g= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1789076808; h=Content-Type: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=beU7FjgyA0BsZQfNfNmJBUW0kDGthpqeSLUuh7lD0jw=; b=S29F/RxYJGX4oAL8QqSsxx7zvhqYDoZT247lg2KloxeZXWmnuLYyI4owhcp/+XzejmHHzsvftJa80xlEJCCSqdOK6g6uBmJo60+IgeThrNJ2Dn6CmrBVNoi+97c0DyVfhJABslGhpeOfdwzsLIfUcFStDn1/dW2hhu/WhBwFZzg= 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 lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1789076808298957.4086235085516; Thu, 10 Sep 2026 14:46:48 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1x4mZa-000421-JZ; Thu, 10 Sep 2026 17:44:56 -0400 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 1x4lLK-0002tK-Uy for qemu-devel@nongnu.org; Thu, 10 Sep 2026 16:26:24 -0400 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 1x4lLC-0000bR-DB for qemu-devel@nongnu.org; Thu, 10 Sep 2026 16:25:54 -0400 Received: from mail-wm1-f71.google.com (mail-wm1-f71.google.com [209.85.128.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-3-xlzQ-l6NO5as3QDCYvy9LA-1; Thu, 10 Sep 2026 16:12:40 -0400 Received: by mail-wm1-f71.google.com with SMTP id 5b1f17b1804b1-495529a93f9so1654275e9.3 for ; Thu, 10 Sep 2026 13:12:40 -0700 (PDT) Received: from redhat.com (IGLD-80-230-79-236.inter.net.il. [80.230.79.236]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-49e60abab54sm18710765e9.5.2026.09.10.13.12.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Sep 2026 13:12:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1789071841; 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=beU7FjgyA0BsZQfNfNmJBUW0kDGthpqeSLUuh7lD0jw=; b=LZgkFQCSAiNYqTNZaGZVR9FfsQ6bTfa6unY65DTJS9rvpREVwh6fuc3HQMxZAnqzPzMgLp 8W1US8CHICH7gFNZBe3KWV7m2SQsZGDZYOgcIHUPvmN9R1jQibzB6crkVTztAigEIuZNUc 8AfbNu0WkneKfY6ng9uTIO16Ty9u1kY= X-MC-Unique: xlzQ-l6NO5as3QDCYvy9LA-1 X-Mimecast-MFC-AGG-ID: xlzQ-l6NO5as3QDCYvy9LA_1789071159 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=google; t=1789071159; x=1789675959; 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=beU7FjgyA0BsZQfNfNmJBUW0kDGthpqeSLUuh7lD0jw=; b=Q7EcygWAzG7zAc6+yWoeSyyd01u9ayunTBboNj1mI7JO87YTiTgzmYchgh5dOxR+eW ufFh0ZNCxJDqbYgWXjCbc8rmhTvYuyjv/Z0pqxwk90Wu/dM7csCIfZGI8dz0P2atj7/i Rir1vdS5erzSxf1wOvo+Vhyjm/icPosW6Zk0x/RIBPGszjzzkEVPNyYH+vojagQUcCac KdbYqO8fCt8yAkSEZtypA8d/dcqZQgMrZo5FnIlgjgPd0z24ob2THHoKW086PTjObj59 cMOL8iJk5I1Icj7lThgnMX11w66okXmPsBua+0qU1CfYRmFoQHAWh7mH3aQ1oi49Pxfx GlGw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1789071159; x=1789675959; 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=beU7FjgyA0BsZQfNfNmJBUW0kDGthpqeSLUuh7lD0jw=; b=AHgVsszplaNWewfZw7XotTJ9bvknxG3LnMh1wn+qf8vJ1Oz6G1mavWOmycUSLQzezG dMmoDrrihtXJhP26A2z8Gbx+C4ag6fBMq8OM/nPSv1CHB3sKuzRV2bY1XQYu6lRTIMnn YI5xiSXquWyXlLpQHZb8vMT0hpgvBX8MK6BKvKM4z4z/coKsdNuaTz9wJsCfHfJ01qw0 cfChE5GrgGgaSkuoQuzu5U4tsXrcOc7bu03e1VjNwKH+YGlbdRsPC1EWDKEYL0qIHoH3 ecZrQsfyFN3eYJf5ImEKFuJmGZNT6ZW4Y8qyZ41MejKFm3T6DPgvRSaqWgCfumrKGgsR WLrw== X-Gm-Message-State: AFuF++l2r++ho+Ak8zbbQPjakz/woo0qOqsUQAA//sNj7BBlC5z313EI Z1W2DkmiPnlO2xtZS4TysbrXILzskEnmH8eAi5gVVuxDsCyY7O1kgjOjMVCmZn7d0MH6PaEez3O aRTeX/IcAWH6ly6zDeB/xTCjE12uv+kxsna2U1Gl6ZKEX2RIkqhjezfihs1IXzCUgIwKaGj8PrK 7NGZ5IQhJLMWRvGvQY/uNA2phEM0frrSLCMA== X-Gm-Gg: AYBFou2yeerQ+CVmcTxPxammlcySlupNN+i4mylQlGosNeocdXGyzPP1sFr+upcr07h j5Fyw7rFIo+FfrJ8ytTTo1DPxr1h8bjJ9wWr1XBbwpxxDDCB/vmW1TkrHeaQFJcnROc4AkxgNnQ CsZ14fifCDRkN3HBvhTJE3Yz7pCnEppmInDmsI6fcMXC6NIYh5gLLeDEPtq3WN7cszakM3C/8I1 1OAZDzbRa4pAArd1IQO2xzIFDhCJOghGJWWj7RWDWspygBe3KJlQTCvWZMTRpWNQ+rpFmL4kpoS Sjb1sFDw1W0X8zq6TPHjUQpbdJUYFU3EVbIg8qjjdS4oxBQI7kiwYUSDoCS9I9oEMgMWZbVOVdW 10MfOXlnWqLuQZpDonNGwdss= X-Received: by 2002:a05:600c:8a1b:20b0:49d:17d8:abec with SMTP id 5b1f17b1804b1-49e619c1912mr5591815e9.21.1789071159353; Thu, 10 Sep 2026 13:12:39 -0700 (PDT) X-Received: by 2002:a05:600c:8a1b:20b0:49d:17d8:abec with SMTP id 5b1f17b1804b1-49e619c1912mr5591515e9.21.1789071158796; Thu, 10 Sep 2026 13:12:38 -0700 (PDT) Date: Thu, 10 Sep 2026 16:12:34 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Vladimir Sementsov-Ogievskiy , Peter Xu , Fabiano Rosas Subject: [PULL 29/90] migration/fd: add errp parameter to migration_fd_valid() Message-ID: <023a51dfc227a6d59eb99ab972726d4137505abd.1789071042.git.mst@redhat.com> References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-Mailer: git-send-email 2.51.2.2891.g4157995a80.dirty X-Mutt-Fcc: =sent 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=170.10.133.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com 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, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_PASS=-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-Zoho-Virus-Status: 1 X-Zoho-AV-Stamp: zmail-av-0.2.13.1.5.4/289.74.40 X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1789076812680158500 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Vladimir Sementsov-Ogievskiy Let migration_fd_valid() report the error itself, instead of duplicating the error message in both callers. This also prepares for adding one more check (with a different error message) to the function. Signed-off-by: Vladimir Sementsov-Ogievskiy Reviewed-by: Peter Xu Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin Message-ID: <20260819180201.1970193-12-vsementsov@yandex-team.ru> --- migration/fd.c | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/migration/fd.c b/migration/fd.c index 02b39b150e..78a27caca2 100644 --- a/migration/fd.c +++ b/migration/fd.c @@ -37,16 +37,14 @@ static bool fd_is_pipe(int fd) return S_ISFIFO(statbuf.st_mode); } =20 -static bool migration_fd_valid(int fd) +static bool migration_fd_valid(int fd, Error **errp) { - if (fd_is_socket(fd)) { - return true; - } - - if (fd_is_pipe(fd)) { + if (fd_is_socket(fd) || fd_is_pipe(fd)) { return true; } =20 + error_setg(errp, "fd: migration to a file is not supported." + " Use file: instead."); return false; } =20 @@ -59,9 +57,7 @@ QIOChannel *fd_connect_outgoing(MigrationState *s, const = char *fdname, goto out; } =20 - if (!migration_fd_valid(fd)) { - error_setg(errp, "fd: migration to a file is not supported." - " Use file: instead."); + if (!migration_fd_valid(fd, errp)) { close(fd); goto out; } @@ -95,9 +91,7 @@ void fd_connect_incoming(const char *fdname, Error **errp) return; } =20 - if (!migration_fd_valid(fd)) { - error_setg(errp, "fd: migration to a file is not supported." - " Use file: instead."); + if (!migration_fd_valid(fd, errp)) { close(fd); return; } --=20 MST From nobody Sat Sep 26 20:50:17 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=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1789078891; cv=none; d=zohomail.com; s=zohoarc; b=K/kJ5DXD4XqKN44tQr0wQRFSPQZKrXbyBvvf9UK5rYxN9nm2Y7w45Nczw+DNpDwvfhpsV0d96DYOiM2zOJEFxCfgt6CL6cPpxMTDe8c/swanWbOehpe081rOeBsbpTtVti5P94Lro/TN9o1ZCQGqqKsxkRk7xuzCPC4m0+Wccc4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1789078891; h=Content-Type: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=f254NehgLbY8bvUcUnlxHVuzEfFRxr1y8JaeM6VB6uw=; b=HLzbmLThNmYj2LwxgZ3j0EvOATkVG+2g1K7/tG0OKH8clmZNk2h8FIhxbe/D9unxnAvd5JxaY5Oip31UhdSyHWpJ9+mmlPUt6T0qNt1JnBF5coNNR/ai17BGQaBiMIXb7BMP5LS5iM2CFbj6mnYnhixy6ZIdJgx0iUr6svscOHo= 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 lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTP id 1789078891250830.690987328859; Thu, 10 Sep 2026 15:21:31 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1x4n57-0003Sr-PW; Thu, 10 Sep 2026 18:17:34 -0400 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 1x4lWk-0006am-3x for qemu-devel@nongnu.org; Thu, 10 Sep 2026 16:38:07 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1x4lWQ-0004kk-1I for qemu-devel@nongnu.org; Thu, 10 Sep 2026 16:37:29 -0400 Received: from mail-wm1-f71.google.com (mail-wm1-f71.google.com [209.85.128.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-101-jZp30QDMMTSHE0lQG60yrw-1; Thu, 10 Sep 2026 16:12:45 -0400 Received: by mail-wm1-f71.google.com with SMTP id 5b1f17b1804b1-499913d1a79so1355315e9.0 for ; Thu, 10 Sep 2026 13:12:45 -0700 (PDT) Received: from redhat.com (IGLD-80-230-79-236.inter.net.il. [80.230.79.236]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-49e61a803c5sm5170365e9.1.2026.09.10.13.12.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Sep 2026 13:12:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1789072566; 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=f254NehgLbY8bvUcUnlxHVuzEfFRxr1y8JaeM6VB6uw=; b=X/HtS/AQyyzJwtVRAtRTcvfrDIjIvGYtuKrmKIz4JfheJ1IldBRBhTVWRklUvprI677j6R C9QFtLNllfyRMkcKOcQWrkNP4/HCRZXAg99XiriuQ9AQ79uCiE7/KQqwFslXoRlbJhcATB 10LFAuYWZSEqVYNSJQyNooZYsPHOijo= X-MC-Unique: jZp30QDMMTSHE0lQG60yrw-1 X-Mimecast-MFC-AGG-ID: jZp30QDMMTSHE0lQG60yrw_1789071164 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=google; t=1789071164; x=1789675964; 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=f254NehgLbY8bvUcUnlxHVuzEfFRxr1y8JaeM6VB6uw=; b=Dkkx06a70myCN1odLpX5mlyDmel2m0nmOqJqsLyvcNs/NHZcSXJ9GM9VLrSxGA5E/k KmlOo4kpVeZlziEYp4+bw9ed9rRN/il9qKX4y+Phpi31DA1Ct04usDhGcB2R1RL7AzEu w1dg5SrvYy8hu7Lapg2yNn8qUHfKJEyrzUz97/BtWd+MgYzut57Q5GlnPcm+2JOM7Nn+ /sSjAAmjWfceCU+LrgShtqJL3bRwdw5e70A2RoChSKSNaiSKw0G8QMQBCXe8n0iw+5Gs p+CbRBB8qRgWOIIOuwQVuazZ5yliDJFc6tOTRzmePcaG+Lq3d+YJh1HbC0hZx+Kbkbwz SB6g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1789071164; x=1789675964; 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=f254NehgLbY8bvUcUnlxHVuzEfFRxr1y8JaeM6VB6uw=; b=VKz01MU4koeRixndeeA08su6MiBJKRQ6vI+/U/G6PLXch6gwem6LGjRS/suZSjgzoV wz58+z+ysOTcKhHSNwnFrn1f2lnyRclFv3yEOkZ7kK6r96Xz36Lb1Z83MW7i/id7oArO foAjplso+GOoKJ9rpht5bEReAhmtxciGZ6V8EC/HkCphAfkT7eKguio1z8VXnhD1nM1J J868a4t38wLTbDXN55YgY8G2lqqp5wj/ZxBmR/3X0ifFWklR47Ov2GkKACKUinAohEjn N8Q659NDqsmUDnJwzL2KxHdZf74xOcOtvVIyy63gqusbM7V3dNrUZjGsPafYEqaFb/+F KSNA== X-Gm-Message-State: AFuF++lSTYlC3PQbwAPWzTdzL4pPW+/SORehJPE89963Uuajj+mMpNH2 /JyRboyv1Tm/+E23IvGMNC9qY9ODMfWMHmNY5Wg8/eBFSDlSEjMW/pRJCpdSImAU6qYuPn8BnNw Pnu7fegvGevQ9sm8fbExh/V1k7zgGLYPZcnQQTdZW8hHS1kmnE1a96+Xswi26DD+Dg4LPwBHVl9 yx+SWgmEgUkSy6VQYmAwyZngaBNqyEvFwNag== X-Gm-Gg: AYBFou2y6iJq3KU7M936RwBQ5bABeMNThoZDQH9cWAucinWRtbiFTKqleYMOqm1B1fk AcKdnqd2qQtvbvvQmsuxI2aGpAmd2h/STcrh+78g1W7PSOYp/tMV/Bx48US9uFv/OOmfOfsWTSZ PXj+gOilRJRAwwl+PZgyV4h/lTmrJBFH/o+gsfWomGFszQT8XxZJs7AdapJp0dSVQ06AP0vsm8c ysQyZO/mZQUAKM94WT4J4biNNxQ8hP7ZBt89Q3m8vAbUkz9wy7LgDYK9sbRTCG5XoMMIeylQpsY 7KGBxQmHJiLh7uJckG9cCZXLpXmHaN2k9NI5mn6pm+ySGUnsE2Dz8lFwZfm99dx/Xeq1rYy1glx XbvjIX2JFB3TJKoUEKnjgqPc= X-Received: by 2002:a05:600c:6289:b0:49b:9105:cdaf with SMTP id 5b1f17b1804b1-49e619a0973mr11354635e9.8.1789071164002; Thu, 10 Sep 2026 13:12:44 -0700 (PDT) X-Received: by 2002:a05:600c:6289:b0:49b:9105:cdaf with SMTP id 5b1f17b1804b1-49e619a0973mr11353955e9.8.1789071163419; Thu, 10 Sep 2026 13:12:43 -0700 (PDT) Date: Thu, 10 Sep 2026 16:12:39 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Vladimir Sementsov-Ogievskiy , Peter Xu , Fabiano Rosas Subject: [PULL 30/90] migration: check that transfer is UNIX socket when "local" set Message-ID: References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-Mailer: git-send-email 2.51.2.2891.g4157995a80.dirty X-Mutt-Fcc: =sent 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=170.10.129.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com 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, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=0.001, SPF_HELO_PASS=-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-Zoho-Virus-Status: 1 X-Zoho-AV-Stamp: zmail-av-0.2.13.1.5.4/289.74.40 X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1789078893092158500 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Vladimir Sementsov-Ogievskiy As documented, for "local", the migration channel must be direct UNIX socket connection from source to target (except for CPR_EXEC mode). We can't check for it being "direct", but let's at least check that we deal with UNIX socket. Signed-off-by: Vladimir Sementsov-Ogievskiy Reviewed-by: Peter Xu Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin Message-ID: <20260819180201.1970193-13-vsementsov@yandex-team.ru> --- migration/fd.c | 14 ++++++++++++++ migration/migration.c | 13 +++++++++++++ 2 files changed, 27 insertions(+) diff --git a/migration/fd.c b/migration/fd.c index 78a27caca2..4a891e814a 100644 --- a/migration/fd.c +++ b/migration/fd.c @@ -39,6 +39,20 @@ static bool fd_is_pipe(int fd) =20 static bool migration_fd_valid(int fd, Error **errp) { + if (migrate_local() && migrate_mode() !=3D MIG_MODE_CPR_EXEC) { + struct sockaddr_storage ss; + socklen_t sslen =3D sizeof(ss); + + if (getsockname(fd, (struct sockaddr *)&ss, &sslen) < 0 || + ss.ss_family !=3D AF_UNIX) { + error_setg(errp, + "local migration requires a UNIX domain socket chan= nel"); + return false; + } + + return true; + } + if (fd_is_socket(fd) || fd_is_pipe(fd)) { return true; } diff --git a/migration/migration.c b/migration/migration.c index b413d28622..d8418e4582 100644 --- a/migration/migration.c +++ b/migration/migration.c @@ -260,6 +260,19 @@ migration_capabilities_and_transport_compatible(Migrat= ionAddress *addr, errp); } =20 + if (migrate_local() && migrate_mode() !=3D MIG_MODE_CPR_EXEC && + (addr->transport !=3D MIGRATION_ADDRESS_TYPE_SOCKET || + (addr->u.socket.type !=3D SOCKET_ADDRESS_TYPE_UNIX && + addr->u.socket.type !=3D SOCKET_ADDRESS_TYPE_FD))) { + /* + * For SOCKET_ADDRESS_TYPE_FD we do check the fd itself later + * in migration_fd_valid(). + */ + error_setg(errp, + "local migration requires a UNIX domain socket channel"= ); + return false; + } + return true; } =20 --=20 MST From nobody Sat Sep 26 20:50:17 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=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1789085076; cv=none; d=zohomail.com; s=zohoarc; b=Yot/XXoaZY2eAZOKFSGFt7jYQhBpyZKhgSVG8KYQQLv7g8ha5w5ZIfsloMIZW+2HyBsGqM2f9nQPN+wfbwN7OWLXNYWXAcR5FM0PI1L3LJK6Wju6FqHa6wWzsqDlpvIG8Pp2v1VngKw82hGyxhwabM7Av7CnRxJio3z9dI+ac54= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1789085076; h=Content-Type: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=ZhK7m7LfrlPcMC5A9kLcc4Id8ZYHnzxhU78CaEvxc74=; b=SL70S15i5TGCf34tRWCJOBCfI7CfuSb37EGaSBH3Evlvwf3aiOWWGPvgQglzK5Yyd2IyU88jcKdpqwIQodj8d/JpdlXkQw6qmvJwLvIfhql0IjmYeE2fJM81zkPvKoR/Zvya1AxIvK6YZxTsfSM2PR6ADhi10IDOiI982KPCLag= 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 lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 17890850761311022.3936899494183; Thu, 10 Sep 2026 17:04:36 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1x4oiu-0006uE-F7; Thu, 10 Sep 2026 20:02:42 -0400 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 1x4lXR-0006iC-N6 for qemu-devel@nongnu.org; Thu, 10 Sep 2026 16:38:36 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1x4lXB-0004ki-9R for qemu-devel@nongnu.org; Thu, 10 Sep 2026 16:38:23 -0400 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-371-JCdXtTEgO1WFMMYOrzn3Dw-1; Thu, 10 Sep 2026 16:12:48 -0400 Received: by mail-wm1-f70.google.com with SMTP id 5b1f17b1804b1-4955e865174so799585e9.3 for ; Thu, 10 Sep 2026 13:12:48 -0700 (PDT) Received: from redhat.com (IGLD-80-230-79-236.inter.net.il. [80.230.79.236]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-486eb359f38sm689277f8f.30.2026.09.10.13.12.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Sep 2026 13:12:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1789072566; 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=ZhK7m7LfrlPcMC5A9kLcc4Id8ZYHnzxhU78CaEvxc74=; b=cy8tgEjQU9kmsOxpV0MJxPq1Du+cJ7umIHkK0t/4HRiJ6LPqqDr913HLz4fEsZjcg1jRI/ Lkni9r9YecpUKUbRezV18WcMAf2W+2xiTy1KLTR2F9oG5wPgVP5zZCmiMGL9H5sw11SO9m qA/Lx9wYWi04MSi5RqLH0AmI+N65kq0= X-MC-Unique: JCdXtTEgO1WFMMYOrzn3Dw-1 X-Mimecast-MFC-AGG-ID: JCdXtTEgO1WFMMYOrzn3Dw_1789071167 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=google; t=1789071167; x=1789675967; 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=ZhK7m7LfrlPcMC5A9kLcc4Id8ZYHnzxhU78CaEvxc74=; b=SclS1a93sL3P2xG79mhp4gSE5QdHcD+8FhLo7lUm2aR0RmTzbClMtiWEUt0W7QoTuo NpfAu/98l6xsTfYyfuARPW+NRm/GzzyBzEYJQ9OPIAqUSl57EMq4YcI71gxKmQMS5EPo JUMU1fKKHx+dX4UcfbQAQtaqip7FUwrW3bAt/34Pv+Dq3liHT2UCamL74fX7BoE3qVFw zsu43auP6SymRPjkoRwbWJUqrf4XIDtaV6XA6cemU4fvX6tyAmsmg8c8wo72CvMJwAwA BGrCK4W+73VpKVA8grZ2aiSqcLmo16k9EWts9ZT5sDo4i0aVvm+eFeRX0puaLqjuY+PI z+LQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1789071167; x=1789675967; 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=ZhK7m7LfrlPcMC5A9kLcc4Id8ZYHnzxhU78CaEvxc74=; b=Y8bZggdhqbYRaJx1NI9Gkkkv5Jov8gPCr8VnBo2IQHZO1hj2LL7+3qH8f/axl9wCvv VFRPsFbj1UlvqkSRPvIMu4i8+EO2ZB2ALa88S3PxFZ9NUwNjvfdD+kNjsWma9SufDIvO /nF3zxZ8bKYOaoZVGGkWAoatkKHOG27kgUx1dNycHT4byWO3kWdoHnRM8fZFIBtp7kvS exSMEG7csoZovSLeNjAHOx0FL+2n8lBe9EE+qH6wk4kckYI6Hs1R6MdblB1dIScvf383 dx/Kd1b8/zP3O3SxPgZaQwjuZwdB2d0ZLrpzYlXkScDuK1Yy+Tv5cDdEcyGM6FiQ+Sx2 2cxw== X-Gm-Message-State: AFuF++nrOuk14XNSF7rIESGlfkkfk8LOYhAtaH0jIsC0PI/u1e7YL+Mb Rx7TJBcrQDP+pHOI08IDDSvz+YPo08ND7GOls2UCG//1HVbjXP3xxzfQmQUBKZjA69EM+w9S1Hp aYoJt7Zyr7ATjAnaPuRL06uPXCG0Xbrcy+EVDq7ODnuxj/eba7uJ7hO1TuaqEnTg1J7wi7WSpUW wJ8K40pCy0L3le9swPWlF0A1JwBDOhBEy1Sg== X-Gm-Gg: AYBFou0Cq6EKQVEWvDFZvGude/uIMzFzVXXHNJc7znkPvFDjgcAPlcHQsER/nTTxff4 PSQOHuwlyzKHJJ0QJFL5A8Vwdn91A6/aK3Lu5N72i+TMJAJ/Mdvu5bSzf2Suwhtr9A7b3DMKuL4 KEHPtixGL3kQPfSUF7s///wEYcnGS16nij+2B7cT73F12IWAm2maxSryaV8efbGkKjj61FHpsiO dxLw7leUKZbEZVLhPEjRnZ0ibdOuPRs3TiuT0P5m+Llv0bSZLeZmXc06VdZ+/W06uTDCxt5sBsE V4WhWQ9+cuVSAcn1r9UQxQOdmwYAVXqeUFJ4hG/K7iOw8Ej50jB0da2yqZv7+xABAkAjHYRRfW5 1x7dhaItCLR2/e6KrnCcGrkY= X-Received: by 2002:a05:600c:3b1f:b0:49c:cee2:1697 with SMTP id 5b1f17b1804b1-49e619e0f85mr7002995e9.16.1789071167430; Thu, 10 Sep 2026 13:12:47 -0700 (PDT) X-Received: by 2002:a05:600c:3b1f:b0:49c:cee2:1697 with SMTP id 5b1f17b1804b1-49e619e0f85mr7002525e9.16.1789071166939; Thu, 10 Sep 2026 13:12:46 -0700 (PDT) Date: Thu, 10 Sep 2026 16:12:43 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Vladimir Sementsov-Ogievskiy , Ben Chaney , Jason Wang , Peter Xu , Fabiano Rosas Subject: [PULL 31/90] virtio-net: support local migration of backend Message-ID: <9d1c9893233c0fd5da2b238441042b047e36fce0.1789071042.git.mst@redhat.com> References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-Mailer: git-send-email 2.51.2.2891.g4157995a80.dirty X-Mutt-Fcc: =sent 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=170.10.129.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com 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, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=0.001, SPF_HELO_PASS=-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-Zoho-Virus-Status: 1 X-Zoho-AV-Stamp: zmail-av-0.2.13.1.5.4/289.74.40 X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1789085079795158500 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Vladimir Sementsov-Ogievskiy Next commit will introduce live-migration (with fd-passing) for TAP net backend. So, now we prepare virtio-net for it Add virtio-net option local-migration, which is true by default, but false for older machine types, which doesn't support the feature. We introduce interface for live-migrating backends: 1. ->is_wait_incoming() handler, so that virtio-net knows, that backend is not fully intialized, as it waits for incoming migration stream. 2. MIG_PRI_BACKEND priority: backends should migrate with higher priority than virtio-net, so that we can do final preparations here in post-load handlers and be sure, that backends are already prepared. Signed-off-by: Vladimir Sementsov-Ogievskiy Reviewed-by: Ben Chaney Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin Message-ID: <20260819180201.1970193-14-vsementsov@yandex-team.ru> --- include/hw/virtio/virtio-net.h | 1 + include/migration/vmstate.h | 2 + include/net/net.h | 2 + hw/net/virtio-net.c | 89 +++++++++++++++++++++++++++++++++- 4 files changed, 93 insertions(+), 1 deletion(-) diff --git a/include/hw/virtio/virtio-net.h b/include/hw/virtio/virtio-net.h index 371e376428..8c967760c2 100644 --- a/include/hw/virtio/virtio-net.h +++ b/include/hw/virtio/virtio-net.h @@ -230,6 +230,7 @@ struct VirtIONet { struct EBPFRSSContext ebpf_rss; uint32_t nr_ebpf_rss_fds; char **ebpf_rss_fds; + bool peers_wait_incoming; }; =20 size_t virtio_net_handle_ctrl_iov(VirtIODevice *vdev, diff --git a/include/migration/vmstate.h b/include/migration/vmstate.h index e72c3fae9a..7d2b786382 100644 --- a/include/migration/vmstate.h +++ b/include/migration/vmstate.h @@ -169,6 +169,8 @@ typedef enum { =20 MIG_PRI_LOW, /* Must happen after default */ MIG_PRI_DEFAULT, + MIG_PRI_BACKEND, /* Must happen before emulated devices, */ + /* e.g. virtio-net */ MIG_PRI_IOMMU, /* Must happen before PCI devices */ MIG_PRI_PCI_BUS, /* Must happen before IOMMU */ MIG_PRI_VIRTIO_MEM, /* Must happen before IOMMU */ diff --git a/include/net/net.h b/include/net/net.h index ea07760b56..fdf6a2ddd4 100644 --- a/include/net/net.h +++ b/include/net/net.h @@ -82,6 +82,7 @@ typedef void (SocketReadStateFinalize)(SocketReadState *r= s); typedef void (NetAnnounce)(NetClientState *); typedef bool (SetSteeringEBPF)(NetClientState *, int); typedef bool (NetCheckPeerType)(NetClientState *, ObjectClass *, Error **); +typedef bool (IsWaitIncoming)(NetClientState *); typedef struct vhost_net *(GetVHostNet)(NetClientState *nc); =20 typedef struct NetClientInfo { @@ -110,6 +111,7 @@ typedef struct NetClientInfo { NetAnnounce *announce; SetSteeringEBPF *set_steering_ebpf; NetCheckPeerType *check_peer_type; + IsWaitIncoming *is_wait_incoming; GetVHostNet *get_vhost_net; } NetClientInfo; =20 diff --git a/hw/net/virtio-net.c b/hw/net/virtio-net.c index 814b99a43d..274fbcb0d6 100644 --- a/hw/net/virtio-net.c +++ b/hw/net/virtio-net.c @@ -40,6 +40,7 @@ #include "migration/misc.h" #include "standard-headers/linux/ethtool.h" #include "system/system.h" +#include "system/runstate.h" #include "system/replay.h" #include "trace.h" #include "monitor/qdev.h" @@ -3079,7 +3080,17 @@ static void virtio_net_set_multiqueue(VirtIONet *n, = int multiqueue) n->multiqueue =3D multiqueue; virtio_net_change_num_queues(n, max * 2 + 1); =20 - virtio_net_set_queue_pairs(n); + /* + * virtio_net_set_multiqueue() called from set_features(0) on early + * reset, when peer may wait for incoming (and is not initialized + * yet). + * Don't worry about it: virtio_net_set_queue_pairs() will be called + * later from virtio_net_post_load_device(), and anyway will be + * no-op for local incoming migration with live backend passing. + */ + if (!n->peers_wait_incoming) { + virtio_net_set_queue_pairs(n); + } } =20 static int virtio_net_pre_load_queues(VirtIODevice *vdev, uint32_t n) @@ -3108,6 +3119,17 @@ static void virtio_net_get_features(VirtIODevice *vd= ev, uint64_t *features, =20 virtio_add_feature_ex(features, VIRTIO_NET_F_MAC); =20 + if (n->peers_wait_incoming) { + /* + * Excessive feature set is OK for early initialization when + * we wait for local incoming migration: actual guest-negotiated + * features will come with migration stream anyway. And we are sure + * that we support same host-features as source, because the backe= nd + * is the same (the same TAP device, for example). + */ + return; + } + if (!peer_has_vnet_hdr(n)) { virtio_clear_feature_ex(features, VIRTIO_NET_F_CSUM); virtio_clear_feature_ex(features, VIRTIO_NET_F_HOST_TSO4); @@ -3204,6 +3226,7 @@ static int virtio_net_post_load_device(void *opaque, = int version_id) VirtIODevice *vdev =3D VIRTIO_DEVICE(n); int i, link_down; bool has_tunnel_hdr =3D virtio_has_tunnel_hdr(vdev->guest_features_ex); + Error *local_err =3D NULL; =20 trace_virtio_net_post_load_device(); virtio_net_set_mrg_rx_bufs(n, n->mergeable_rx_bufs, @@ -3261,6 +3284,20 @@ static int virtio_net_post_load_device(void *opaque,= int version_id) } =20 virtio_net_commit_rss_config(n); + + /* + * If live-migration is enabled for some backend, than backend + * has already been migrated at higher priority (MIG_PRI_BACKEND) + * and virtio_net_vnet_post_load() has already called + * peer_test_vnet_hdr(). Recompute host_features so that virtio-net + * reflects the capabilities of the restored backend. + */ + virtio_net_get_features(vdev, &vdev->host_features, &local_err); + if (local_err) { + error_report_err(local_err); + return -EINVAL; + } + return 0; } =20 @@ -3411,6 +3448,14 @@ static int virtio_net_vnet_post_load(void *opaque, i= nt version_id) { struct VirtIONetMigTmp *tmp =3D opaque; =20 + /* + * If live-migration is enabled for some backend, than backend + * has already been migrated at higher priority (MIG_PRI_BACKEND), + * so n->has_vnet_hdr can be refreshed from the live backend right + * here. + */ + peer_test_vnet_hdr(tmp->parent); + if (tmp->has_vnet_hdr && !peer_has_vnet_hdr(tmp->parent)) { error_report("virtio-net: saved image requires vnet_hdr=3Don"); return -EINVAL; @@ -3890,6 +3935,42 @@ static bool failover_hide_primary_device(DeviceListe= ner *listener, return qatomic_read(&n->failover_primary_hidden); } =20 +static bool virtio_net_check_peers_wait_incoming(VirtIONet *n, bool *waiti= ng, + Error **errp) +{ + bool has_waiting =3D false; + bool has_not_waiting =3D false; + + for (int i =3D 0; i < n->max_queue_pairs; i++) { + NetClientState *peer =3D n->nic->ncs[i].peer; + if (!peer) { + continue; + } + + if (peer->info->is_wait_incoming && + peer->info->is_wait_incoming(peer)) { + has_waiting =3D true; + } else { + has_not_waiting =3D true; + } + + if (has_waiting && has_not_waiting) { + error_setg(errp, "Mixed peer states: some peers wait for incom= ing " + "migration while others don't"); + return false; + } + } + + if (has_waiting && !runstate_check(RUN_STATE_INMIGRATE)) { + error_setg(errp, "Peers wait for incoming, but it's not an incomin= g " + "migration."); + return false; + } + + *waiting =3D has_waiting; + return true; +} + static void virtio_net_device_realize(DeviceState *dev, Error **errp) { VirtIODevice *vdev =3D VIRTIO_DEVICE(dev); @@ -4027,6 +4108,12 @@ static void virtio_net_device_realize(DeviceState *d= ev, Error **errp) n->nic->ncs[i].do_not_pad =3D true; } =20 + if (!virtio_net_check_peers_wait_incoming(n, &n->peers_wait_incoming, + errp)) { + virtio_cleanup(vdev); + return; + } + peer_test_vnet_hdr(n); if (peer_has_vnet_hdr(n)) { n->host_hdr_len =3D sizeof(struct virtio_net_hdr); --=20 MST From nobody Sat Sep 26 20:50:17 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=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1789081916; cv=none; d=zohomail.com; s=zohoarc; b=J7eBSw1dnXGqpCmIR2lCgMyBxUmpVUvZwZ4pGMIh5GdTTRiFku4CnWwLZ6cQLF0nBExpiFhM82qdPrhmv89k3hJC8XP8WQX+JHIsTIEsWMsWjORb5ghzhZhZJ5B9L0fE6v80jjMoNZsAt3VEdYBiidvVSSO0Yfzhj/uWAfmGr90= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1789081916; h=Content-Type: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=e6oAhYiiIn3xpeHIgSvH0lgBJsq4uFVnZ7OcjCH2hOg=; b=mXWNM+6C90lf0PGg9vCvjmKcSVSADYaYh6vkyLchKhTucGWvsto5OenCZYLZ4eMW2ADv2LKWi1IQn948hYEl6xRB7xa+R/qagPkIAk3aGk26a8JVD6bCju51N+UTJxFFQr/V9IOGgJGUQ2k+BRm7MvGKK7Kk2WLc9zbLFw69Tr8= 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 lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1789081916686775.1344608208298; Thu, 10 Sep 2026 16:11:56 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1x4ntl-00009A-WD; Thu, 10 Sep 2026 19:09:49 -0400 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 1x4lTR-0005qF-GJ for qemu-devel@nongnu.org; Thu, 10 Sep 2026 16:34:30 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1x4lT4-0003BI-OX for qemu-devel@nongnu.org; Thu, 10 Sep 2026 16:34:08 -0400 Received: from mail-wm1-f71.google.com (mail-wm1-f71.google.com [209.85.128.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-541-4MBw1wCnOPW5En48PaM3Pg-1; Thu, 10 Sep 2026 16:13:01 -0400 Received: by mail-wm1-f71.google.com with SMTP id 5b1f17b1804b1-49b8c651ac0so2919035e9.2 for ; Thu, 10 Sep 2026 13:12:58 -0700 (PDT) Received: from redhat.com (IGLD-80-230-79-236.inter.net.il. [80.230.79.236]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-49d26c1bc5fsm95244475e9.3.2026.09.10.13.12.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Sep 2026 13:12:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1789072383; 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=e6oAhYiiIn3xpeHIgSvH0lgBJsq4uFVnZ7OcjCH2hOg=; b=A9JpJBBfATQsYi/UAM2pk7l82hjy6OIwiK8wl/y7N+HYXjjmKsdMFlJghNuxfTT7P9D9Aa ek6YUIWHgNEr5YXQ+BAiXpiPjPXycDfEvD5aDmrZ5tC9JDk0f5T5Rw8Ovk9J5osXWdx/JR JxT4z30vi5F/aZw/xg3w6yGwnJCpDeo= X-MC-Unique: 4MBw1wCnOPW5En48PaM3Pg-1 X-Mimecast-MFC-AGG-ID: 4MBw1wCnOPW5En48PaM3Pg_1789071173 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=google; t=1789071170; x=1789675970; 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=e6oAhYiiIn3xpeHIgSvH0lgBJsq4uFVnZ7OcjCH2hOg=; b=NEQMoBJCxjwObK7vqluwdy/S9QK3h40MJshXyBvWmjYN3Utbm6QHvMaL1wijBeSP2+ Jfqy6NMzd9O+oEB2DqJ/vNp6E4BM+miroR6fypABIw5VaGKC8L+x//PM2pZVmB6Hs+G3 NqnmzrnOpx+CgqK8yTlGEYo8R1cFdS3f5mSezQDTFtApetyPhUKhwsoeQu/NHi+AL+/k Y2P/1HRKFF75+amXSkUnJELdMrGnwQPMZHEyOwE7AZzBhIrLty0yUsa+yFnpc4uipAUL Bdmkb9Pp8TNCPVWVG6uE7Mwbu5uc0ypYHCfM6ZvE1Sh9Y1BL+DUU+83npOZ84/9+lXyF 5+Yg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1789071170; x=1789675970; 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=e6oAhYiiIn3xpeHIgSvH0lgBJsq4uFVnZ7OcjCH2hOg=; b=sSHK+DffVDUo4TmDaqzL/zOS8z8d4Zj/BuPSH+zzSZbMp9js4CwDECvCw/o74xEgA4 Cff5ecKjhWhMRIpqu7v1j6zckOtetc6TwPB9kn8I1FX3bG1+rUtzAKiFVnkdE/jOuqO8 vaSCyoeNYkbtXz++PZgJnN4fZk0+evnmbbTvaq1fgem/80VmqISqV5QkGCEW9yzltNfq Ozss+9BmzZzZG6aoyHfuWSb7aHP4lBbh32YtEaXKtvLeQkaUDi4SLO1pooEFQc2Z6TSF qR2fv3u36CdM8NROIcZghUWYR5j5RWKzOD0Gc0u1IGCBIka8sl4w5Yaumzk6PicL2BvN W+FA== X-Gm-Message-State: AFuF++mP633yHAaOhAjJDJxJGYYhYnwNoavNazmbmkjafxKvYDctr36h kPYbUlT8kEsMzGTis/KVEaSih3w+0mweFOjRj+IJy/ZsUXqLk5KkQK7jo8dlKHlOEh1MN9pvtwR JVgTICJ29zQiGVjR+e8IfaV88XIecw7eBERBQbZPjcdJWcGbRopeozdOU3wOCMnBaJV4O9qWziu HVgUJwOZeZs1jkTEKvPis1SrUdrSstqGz70g== X-Gm-Gg: AYBFou2Ppo7NGQ7Iu9nb+CFeJFc31wibThqxnXtyNm29S2l0XDjfHgXmNPjaHRJim++ ZLnWTARFPoj43Vh7QLhTHph+cY89l5Ss0nnjqhDkC3FQNBx2IVW2yPvhiLuOTAieH/CSd+epYEn BMeMIQY2Wp9XX5DK23U5BiDnJ5oqSe4m8ffqjBPYh8kVw2A6I6FeacWZpCrDPVYIPGdnpCNxErg Pmv2aHE2AWN1avHAAf8KpSdOnRuWiAJyfTPQJj7LfMWFCOGKfb3lHxiz7w6OKkGhmyF8b6kRvYI 4RRCg5DpD4t6bm31qdGwSfmUdY3b7YNjKuo0RaBAzv0OPjUtqbY87FRwfV/C/qxl+oXTKpr8Gk4 et3/uS63YeWPt1Vck9oIeJCU= X-Received: by 2002:a05:600c:3115:b0:495:4d88:e630 with SMTP id 5b1f17b1804b1-49e61989e79mr7907555e9.10.1789071169713; Thu, 10 Sep 2026 13:12:49 -0700 (PDT) X-Received: by 2002:a05:600c:3115:b0:495:4d88:e630 with SMTP id 5b1f17b1804b1-49e61989e79mr7907245e9.10.1789071169172; Thu, 10 Sep 2026 13:12:49 -0700 (PDT) Date: Thu, 10 Sep 2026 16:12:47 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Vladimir Sementsov-Ogievskiy , Jason Wang Subject: [PULL 32/90] net/tap: disable read polling for stopped VM Message-ID: <1b08604011ee67bfb180503acfe0c70df8c8099f.1789071042.git.mst@redhat.com> References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-Mailer: git-send-email 2.51.2.2891.g4157995a80.dirty X-Mutt-Fcc: =sent 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=170.10.129.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com 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, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=0.001, SPF_HELO_PASS=-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-Zoho-Virus-Status: 1 X-Zoho-AV-Stamp: zmail-av-0.2.13.1.5.4/289.74.40 X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1789081919502158500 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Vladimir Sementsov-Ogievskiy Polling when VM is stopped doesn't make real sense, as stopped VM can't handle incoming traffic anyway. And it's critical for introduction of local TAP migration feature in the next commit: the TAP device will be transferred to the target (open fd will be passed through migration channel), and if we continue polling on source, we may get a package, which we'll never handle on source (already stopped), it will be lost. Better is save this package for target VM to handle. Signed-off-by: Vladimir Sementsov-Ogievskiy Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin Message-ID: <20260819180201.1970193-15-vsementsov@yandex-team.ru> --- net/tap.c | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/net/tap.c b/net/tap.c index dd0d134875..51d028d956 100644 --- a/net/tap.c +++ b/net/tap.c @@ -36,6 +36,7 @@ #include "net/net.h" #include "clients.h" #include "monitor/monitor.h" +#include "system/runstate.h" #include "system/system.h" #include "qapi/error.h" #include "qemu/cutils.h" @@ -92,6 +93,8 @@ struct TAPState { Notifier exit; =20 int queue_index; + bool enable_poll_on_resume; + VMChangeStateEntry *vmstate; }; =20 static void launch_script(const char *setup_script, const char *ifname, @@ -145,10 +148,31 @@ static void tap_update_fd_handler(TAPState *s) =20 static void tap_read_poll(TAPState *s, bool enable) { + if (enable && runstate_check(RUN_STATE_FINISH_MIGRATE)) { + s->enable_poll_on_resume =3D true; + return; + } s->read_poll =3D enable; tap_update_fd_handler(s); } =20 +static void tap_vm_state_change(void *opaque, bool running, RunState state) +{ + TAPState *s =3D opaque; + + if (running) { + if (s->enable_poll_on_resume) { + tap_read_poll(s, true); + s->enable_poll_on_resume =3D false; + } + } else if (state =3D=3D RUN_STATE_FINISH_MIGRATE) { + if (s->read_poll) { + s->enable_poll_on_resume =3D true; + tap_read_poll(s, false); + } + } +} + static void tap_write_poll(TAPState *s, bool enable) { s->write_poll =3D enable; @@ -379,6 +403,11 @@ static void tap_cleanup(NetClientState *nc) s->exit.notify =3D NULL; } =20 + if (s->vmstate) { + qemu_del_vm_change_state_handler(s->vmstate); + s->vmstate =3D NULL; + } + tap_read_poll(s, false); tap_write_poll(s, false); close(s->fd); @@ -818,6 +847,9 @@ static bool net_init_tap_one(const NetdevTapOptions *ta= p, NetClientState *peer, int sndbuf =3D (tap->has_sndbuf && tap->sndbuf) ? MIN(tap->sndbuf, INT_MAX) : INT= _MAX; =20 + s->enable_poll_on_resume =3D false; + s->vmstate =3D qemu_add_vm_change_state_handler(tap_vm_state_change, s= ); + if (!tap_set_sndbuf(fd, sndbuf, sndbuf_required ? errp : NULL) && sndbuf_required) { goto failed; --=20 MST From nobody Sat Sep 26 20:50:17 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=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1789076973; cv=none; d=zohomail.com; s=zohoarc; b=Z6APabY8Hg2gigL8vz8HUbZFDAW/009CpbOgmmMyzmqiHSjNS+YQYW1fzMHrf/usrW+WYhS95998aIhR6O4o8fnKTyoJ1Ca3DIbdQs8GOE20Smb0JxO7e+4Po39WmGD7H0/Kl4jKrSeg3LYEG9/zwzyEZ+fJiSQ5uMBet1OMei4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1789076973; h=Content-Type: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=U+LQxEq+xa1ZMmsDwLunNgJiMF+B5iHrSKttb1+MsNY=; b=W+QiMS/Gt+HSZK2v/2J60OTBhszmZj34v8r4grDjQH4LJa6lAu5LkgadiE+bztRoCowr5PwbEHvpDadLryzRbqs7K1KLAHKksjhca8eHqHnTQ/oJnBRnbynauHjQSnXgufR0FeDG3megwMbJsD7EzeIy2GvR6dzyttk7+1YJCug= 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 lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 178907697344949.635187830414225; Thu, 10 Sep 2026 14:49:33 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1x4mcj-0004or-Cy; Thu, 10 Sep 2026 17:48:23 -0400 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 1x4lLe-00032d-0e for qemu-devel@nongnu.org; Thu, 10 Sep 2026 16:26:34 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1x4lLQ-0000T5-5B for qemu-devel@nongnu.org; Thu, 10 Sep 2026 16:26:11 -0400 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-344-16T8oqJAM1Cmpxh2LBsRBA-1; Thu, 10 Sep 2026 16:12:53 -0400 Received: by mail-wm1-f70.google.com with SMTP id 5b1f17b1804b1-495569acf8dso874695e9.1 for ; Thu, 10 Sep 2026 13:12:53 -0700 (PDT) Received: from redhat.com (IGLD-80-230-79-236.inter.net.il. [80.230.79.236]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-49e60a8a89esm18273605e9.1.2026.09.10.13.12.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Sep 2026 13:12:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1789071783; 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=U+LQxEq+xa1ZMmsDwLunNgJiMF+B5iHrSKttb1+MsNY=; b=RORjQLr6tHAHN+EMReNDzSZV02U2HCsCNVs4nL9i/ZyBQgOSNdHuy3NEKWzjjvbjsMH8fk iYniKYvUBY47vG4q8I1e6Y59BHUYkGHiJRTqep7bH6snqCIEUj1Qs+x4HDqxbnPxcScgUX 2yPMy7SJpRFyDhoayvOzmZS3G3Fj2/M= X-MC-Unique: 16T8oqJAM1Cmpxh2LBsRBA-1 X-Mimecast-MFC-AGG-ID: 16T8oqJAM1Cmpxh2LBsRBA_1789071172 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=google; t=1789071172; x=1789675972; 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=U+LQxEq+xa1ZMmsDwLunNgJiMF+B5iHrSKttb1+MsNY=; b=YtCDvmTIX0BqDxNwYJvldmSYAhQdchtm2Un7iyDZ8iLv4Nc6MFk2f9vD7XyiR1iJnY xrIshsIjQ6VOErgKFFbtFlVIlVYB5EZemuTYTw045onmYX49HPc46XG1DDmLKUrQ+Lj8 TNJvvXob9kSfL2WmRo0CpoZ9iC0CjjV1IsjqYJsFDh0qKzQlUfR1bWjyRHujNtG+0+MG 7llMCRxxh2E0us5bmb4HSOS4WV0gtiZoi93ERHHzOtDYanO4a1IkgENu6tXWQjXFUoQs JE/PFUxtSq8v3RjKjE4IdM3QwG+ny8P4Cdjf4UUgxoTKV6Qchh67EoYzL4pa4VCKWWYR RE7Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1789071172; x=1789675972; 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=U+LQxEq+xa1ZMmsDwLunNgJiMF+B5iHrSKttb1+MsNY=; b=DMXFLW7us7RXRccBSC0imQVKtnUHVOiI2JtN0wnxuAbsQIgcUZWcawIRWzuY2C4NpI NOOVeKxQlzwSWTy4Vx4aNvId52nH1bekqJfuVD5/dF0u11wkJxdM5lVXtd07+fmYiMvd cXtbkCa8UBC6Dn8r4ndMBvYzes24zC/3EO5YMUibOVhpiWOkOc6N90w6iKcIodb7vHRV MhXPagiyXNsm8YSj/NiJN0iRzVdtHBHbSW+MApGDUkqMlyZR2nlXCa5dJJvgSPz9247g MBaKy9cOb2ZmzyfnEaYdebTC/d0jexbjHQ0w9JNz3reCnEJpmun+alATj35aAvzSIAs3 tC7g== X-Gm-Message-State: AFuF++m1AwF+ypcaRMnq5h8/mFJd0M9ErhBa9ncykbEFeKXGH0b8gi5r kLZlGkEOjrvewtJmhxENdmsYfkqyUMT+rZiOQto+KQ7kaV+dkWVPpmfOgqYJ8pt9ZOUIKsCr7QZ 0cR3NpLPQtGYqfuBiN7uzEpHQAbOFEgl83fHmS2Ea1uy5SlNhszu3wHr7HAaIe60IPgf/W/V83h +hrOgBQ88oRrl84oJ3fI2IX9AnUBM9n3Sd+g== X-Gm-Gg: AYBFou2N4vdB/HOzl41zrgFZJP4ksmwK0e4PUKEHTCc36H+GCp0jjZH5c/rrUg8xw1b 9cPIemCw7dxvo7C8ehZtUgrVO6CHYHV+xJdxHTEEljm4K7LmTfePFV+yQoxtPi/YjDbPuK/CQJh IfkutlTt5WpS+t6/oDOYfvX9lIVb7fPwzvRXnoQWwPIQd3WIhj3ZI4NqTJ1asygm7ENvKiK8fMj 1s79Q8zN2NQnTxkZjA8xOe3JVgOy2vmtGB3WmnbYHMAJRS2tg48HpXi6pg0vHR3EVCXv7GM0KfW 0YetfymkYJHrm2qfQ7qed9GaIDVQUmt9+VhDfdExUY0z1qdKwN9fU6K05RYs9x6vP8VrjB63bXH daErueq6S9P4HNQTG9MWtS5c= X-Received: by 2002:a05:600c:4e0c:b0:49c:ed94:cdd8 with SMTP id 5b1f17b1804b1-49e6198734emr20904895e9.6.1789071172082; Thu, 10 Sep 2026 13:12:52 -0700 (PDT) X-Received: by 2002:a05:600c:4e0c:b0:49c:ed94:cdd8 with SMTP id 5b1f17b1804b1-49e6198734emr20903925e9.6.1789071171540; Thu, 10 Sep 2026 13:12:51 -0700 (PDT) Date: Thu, 10 Sep 2026 16:12:49 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Vladimir Sementsov-Ogievskiy , Ben Chaney , Markus Armbruster , Jason Wang , Eric Blake Subject: [PULL 33/90] net/tap: support local migration with virtio-net Message-ID: <332b7ea34541d246b556964a04f1d9767f2f3556.1789071042.git.mst@redhat.com> References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-Mailer: git-send-email 2.51.2.2891.g4157995a80.dirty X-Mutt-Fcc: =sent 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=170.10.129.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com 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, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=0.001, SPF_HELO_PASS=-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-Zoho-Virus-Status: 1 X-Zoho-AV-Stamp: zmail-av-0.2.13.1.5.4/289.74.40 X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1789076975003158501 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Vladimir Sementsov-Ogievskiy Support transferring of TAP state (including open fd). Add new property "x-permit-local-migration", which defines whether local migration is actually permitted for this TAP device. Note that local-migration is enabled by global "local" migration parameter, but individual devices may have additional options to enable/disable it per device. The tricky thing is that we need to know whether to call open/connect in TAP initialization code, i.e. we need to know the value of migration parameter "local" when creating the TAP device. For incoming migration, we can know only for TAP devices created with QMP after setting the migration parameter with QMP. So the full picture is: On source, to start outgoing "local" migration you need: - migration parameter "local" set to true - "x-permit-local-migration" TAP option set to true If at least one of these options is not set, TAP backend doesn't participate in migration. On target, things are more difficult: Same, you need both "local" and "x-permit-local-migration" be set. And same, if one of them is not set, TAP backend is initialized as usual, and doesn't accept any incoming state. Additionally, if you are going to set "local", it must be set before creating the TAP device. If TAP device created with "local" unset, it initializes as usual. If you enable "local" after it and start incoming migration, it will fail in .pre_load handler of TAP backend. Moreover, there are interface restrictions: if you create TAP device when QEMU is in INCOMING state, and both "local" and "x-permit-local-migration" set, most of TAP options are not allowed, and script/downscript are required to be explicitly disabled. Signed-off-by: Vladimir Sementsov-Ogievskiy Reviewed-by: Ben Chaney Acked-by: Markus Armbruster Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin Message-ID: <20260819180201.1970193-16-vsementsov@yandex-team.ru> --- qapi/net.json | 29 ++++++++- net/tap.c | 167 ++++++++++++++++++++++++++++++++++++++++++++++++-- 2 files changed, 189 insertions(+), 7 deletions(-) diff --git a/qapi/net.json b/qapi/net.json index dccf95bbbc..64c0ef1f6d 100644 --- a/qapi/net.json +++ b/qapi/net.json @@ -437,6 +437,31 @@ # @poll-us: maximum number of microseconds that could be spent on busy # polling for tap (since 2.7) # +# @x-permit-local-migration: permit local migration for this TAP +# backend. When set, local migration is enabled/disabled by +# migration parameter @local for this TAP backend. When unset, +# migration parameter @local is ignored for this TAP backend. +# +# To be able to do incoming local migration of a TAP backend, +# migration parameter @local must be set _before_ creating the +# TAP backend. Otherwise, TAP backend is initialized as usual, +# opening/creating TAP devices in kernel. In this case further +# local incoming migration (with migration parameter @local set +# after creating TAP backend with @x-permit-local-migration +# parameter set) will simply fail. +# +# Moreover, when QEMU is in incoming migration state, migration +# parameter @local is set and @x-permit-local-migration is set, +# the following options are not supported and must not be set: +# @fd, @fds, @helper, @br, @ifname, @sndbuf, @vnet_hdr. +# Additionally, @script and @downscript must be explicitly +# disabled then. +# (default: false, since 11.2) +# +# Features: +# +# @unstable: Member @x-permit-local-migration is experimental. +# # Since: 1.2 ## { 'struct': 'NetdevTapOptions', @@ -455,7 +480,9 @@ '*vhostfds': 'str', '*vhostforce': 'bool', '*queues': 'uint32', - '*poll-us': 'uint32'} } + '*poll-us': 'uint32', + '*x-permit-local-migration': { + 'type': 'bool', 'features' : [ 'unstable'] } } } =20 ## # @NetdevSocketOptions: diff --git a/net/tap.c b/net/tap.c index 51d028d956..d71e3dd117 100644 --- a/net/tap.c +++ b/net/tap.c @@ -38,12 +38,17 @@ #include "monitor/monitor.h" #include "system/runstate.h" #include "system/system.h" +#include "migration/misc.h" #include "qapi/error.h" #include "qemu/cutils.h" #include "qemu/error-report.h" #include "qemu/main-loop.h" #include "qemu/sockets.h" #include "hw/virtio/vhost.h" +#include "hw/core/vmstate-if.h" +#include "migration/vmstate.h" +#include "qom/object.h" +#include "qom/compat-properties.h" =20 #include "net/tap.h" #include "net/util.h" @@ -71,6 +76,8 @@ static const int kernel_feature_bits[] =3D { =20 OBJECT_DECLARE_SIMPLE_TYPE(TAPState, TAP_NETDEV) =20 +static const VMStateDescription vmstate_tap; + struct TAPState { Object parent_obj; =20 @@ -95,6 +102,7 @@ struct TAPState { int queue_index; bool enable_poll_on_resume; VMChangeStateEntry *vmstate; + bool permit_local_migration; }; =20 static void launch_script(const char *setup_script, const char *ifname, @@ -412,6 +420,8 @@ static void tap_cleanup(NetClientState *nc) tap_write_poll(s, false); close(s->fd); s->fd =3D -1; + + vmstate_unregister(VMSTATE_IF(s), &vmstate_tap, s); } =20 static void tap_poll(NetClientState *nc, bool enable) @@ -448,6 +458,78 @@ static VHostNetState *tap_get_vhost_net(NetClientState= *nc) return s->vhost_net; } =20 +static bool tap_is_wait_incoming(NetClientState *nc) +{ + TAPState *s =3D container_of(nc, TAPState, nc); + assert(nc->info->type =3D=3D NET_CLIENT_DRIVER_TAP); + return s->fd =3D=3D -1; +} + +static bool tap_pre_load(void *opaque, Error **errp) +{ + ERRP_GUARD(); + TAPState *s =3D opaque; + + if (s->fd !=3D -1) { + error_setg(errp, + "TAP is already initialized and cannot receive " + "incoming fd"); + error_append_hint(errp, + "Migration parameter 'local' must be set" + " before creating the TAP device."); + return false; + } + + return true; +} + +static bool tap_setup_vhost(TAPState *s, Error **errp); + +static bool tap_post_load(void *opaque, int version_id, Error **errp) +{ + ERRP_GUARD(); + TAPState *s =3D opaque; + + tap_read_poll(s, true); + + if (s->fd < 0) { + error_setg(errp, "FD was not loaded during incoming migration"); + return false; + } + + if (!tap_setup_vhost(s, errp)) { + error_prepend(errp, + "Failed to setup vhost during TAP post-load: "); + return false; + } + + return true; +} + +static bool tap_needed(void *opaque) +{ + TAPState *s =3D opaque; + + return s->permit_local_migration && migrate_local(); +} + +static const VMStateDescription vmstate_tap =3D { + .name =3D "net-tap", + .priority =3D MIG_PRI_BACKEND, + .pre_load_errp =3D tap_pre_load, + .post_load_errp =3D tap_post_load, + .needed =3D tap_needed, + .fields =3D (const VMStateField[]) { + VMSTATE_FD(fd, TAPState), + VMSTATE_BOOL(using_vnet_hdr, TAPState), + VMSTATE_BOOL(has_ufo, TAPState), + VMSTATE_BOOL(has_uso, TAPState), + VMSTATE_BOOL(has_tunnel, TAPState), + VMSTATE_BOOL(enabled, TAPState), + VMSTATE_UINT32(host_vnet_hdr_len, TAPState), + VMSTATE_END_OF_LIST() + } +}; =20 static char *tap_vmstate_if_get_id(VMStateIf *obj) { @@ -456,17 +538,42 @@ static char *tap_vmstate_if_get_id(VMStateIf *obj) return res; } =20 +static bool tap_get_permit_local_migration_prop(Object *obj, Error **errp) +{ + TAPState *s =3D TAP_NETDEV(obj); + return s->permit_local_migration; +} + +static void tap_set_permit_local_migration_prop(Object *obj, bool value, + Error **errp) +{ + TAPState *s =3D TAP_NETDEV(obj); + s->permit_local_migration =3D value; +} + +static void tap_instance_init(Object *obj) +{ + TAPState *s =3D TAP_NETDEV(obj); + s->permit_local_migration =3D false; +} + static void tap_class_init(ObjectClass *klass, const void *data) { VMStateIfClass *vc =3D VMSTATE_IF_CLASS(klass); =20 vc->get_id =3D tap_vmstate_if_get_id; + + object_class_property_add_bool(klass, "x-permit-local-migration", + tap_get_permit_local_migration_prop, + tap_set_permit_local_migration_prop); } =20 static const TypeInfo tap_netdev_info =3D { .name =3D TYPE_TAP_NETDEV, .parent =3D TYPE_OBJECT, .instance_size =3D sizeof(TAPState), + .instance_init =3D tap_instance_init, + .instance_post_init =3D object_apply_compat_props, .class_init =3D tap_class_init, .interfaces =3D (const InterfaceInfo[]) { { TYPE_VMSTATE_IF }, @@ -499,13 +606,16 @@ static NetClientInfo net_tap_info =3D { .set_vnet_le =3D tap_set_vnet_le, .set_vnet_be =3D tap_set_vnet_be, .set_steering_ebpf =3D tap_set_steering_ebpf, + .is_wait_incoming =3D tap_is_wait_incoming, .get_vhost_net =3D tap_get_vhost_net, }; =20 static TAPState *new_tap(NetClientState *peer, const char *model, const char *name, - int queue_index) + int queue_index, + bool has_permit_local_migration, + bool permit_local_migration) { TAPState *s =3D TAP_NETDEV(object_new(TYPE_TAP_NETDEV)); =20 @@ -514,6 +624,12 @@ static TAPState *new_tap(NetClientState *peer, =20 s->queue_index =3D queue_index; =20 + if (has_permit_local_migration) { + s->permit_local_migration =3D permit_local_migration; + } + + vmstate_register(VMSTATE_IF(s), VMSTATE_INSTANCE_ID_ANY, &vmstate_tap,= s); + return s; } =20 @@ -522,10 +638,14 @@ static TAPState *net_tap_fd_init(NetClientState *peer, const char *name, int fd, int vnet_hdr, - int queue_index) + int queue_index, + bool has_permit_local_migration, + bool permit_local_migration) { NetOffloads ol =3D {}; - TAPState *s =3D new_tap(peer, model, name, queue_index); + TAPState *s =3D new_tap(peer, model, name, queue_index, + has_permit_local_migration, + permit_local_migration); =20 s->fd =3D fd; s->host_vnet_hdr_len =3D vnet_hdr ? sizeof(struct virtio_net_hdr) : 0; @@ -762,7 +882,7 @@ int net_init_bridge(const Netdev *netdev, const char *n= ame, close(fd); return -1; } - s =3D net_tap_fd_init(peer, "bridge", name, fd, vnet_hdr, 0); + s =3D net_tap_fd_init(peer, "bridge", name, fd, vnet_hdr, 0, true, fal= se); =20 qemu_set_info_str(&s->nc, "helper=3D%s,br=3D%s", helper, br); =20 @@ -842,7 +962,9 @@ static bool net_init_tap_one(const NetdevTapOptions *ta= p, NetClientState *peer, Error **errp) { TAPState *s =3D net_tap_fd_init(peer, tap->helper ? "bridge" : "tap", - name, fd, vnet_hdr, queue_index); + name, fd, vnet_hdr, queue_index, + tap->has_x_permit_local_migration, + tap->x_permit_local_migration); bool sndbuf_required =3D tap->has_sndbuf; int sndbuf =3D (tap->has_sndbuf && tap->sndbuf) ? MIN(tap->sndbuf, INT_MAX) : INT= _MAX; @@ -990,6 +1112,7 @@ int net_init_tap(const Netdev *netdev, const char *nam= e, /* for the no-fd, no-helper case */ char ifname[128]; int *fds =3D NULL, *vhost_fds =3D NULL; + bool incoming_fds; =20 assert(netdev->type =3D=3D NET_CLIENT_DRIVER_TAP); tap =3D &netdev->u.tap; @@ -1012,6 +1135,23 @@ int net_init_tap(const Netdev *netdev, const char *n= ame, return -1; } =20 + incoming_fds =3D tap->x_permit_local_migration && migrate_local() && + runstate_check(RUN_STATE_INMIGRATE); + + if (incoming_fds && + (tap->fd || tap->fds || tap->helper || tap->br || tap->ifname || + tap->has_sndbuf || tap->has_vnet_hdr || + !tap_is_explicit_no_script("script", tap->script) || + !tap_is_explicit_no_script("downscript", tap->downscript))) { + error_setg(errp, "Local incoming migration of TAP device (-incomin= g, " + "migration parameter @local is set, " + "TAP parameter @x-permit-local-migration is set) " + "is incompatible with " + "fd=3D, fds=3D, helper=3D, br=3D, ifname=3D, sndbuf=3D = and vnet_hdr=3D, " + "and requires explicit empty script=3D and downscript= =3D"); + return -1; + } + queues =3D tap_parse_fds_and_queues(tap, &fds, errp); if (queues < 0) { return -1; @@ -1030,7 +1170,22 @@ int net_init_tap(const Netdev *netdev, const char *n= ame, goto fail; } =20 - if (fds) { + if (incoming_fds) { + for (i =3D 0; i < queues; i++) { + TAPState *s =3D new_tap(peer, "tap", name, i, + tap->has_x_permit_local_migration, + tap->x_permit_local_migration); + qemu_set_info_str(&s->nc, "incoming"); + + s->fd =3D -1; + if (vhost_fds) { + s->vhostfd =3D vhost_fds[i]; + s->vhost_busyloop_timeout =3D tap->has_poll_us ? tap->poll= _us : 0; + } else { + s->vhostfd =3D -1; + } + } + } else if (fds) { for (i =3D 0; i < queues; i++) { if (i =3D=3D 0) { vnet_hdr =3D tap_probe_vnet_hdr(fds[i], errp); --=20 MST From nobody Sat Sep 26 20:50:17 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=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1789074760; cv=none; d=zohomail.com; s=zohoarc; b=RRBD2O8+5kHYVmEaFas+T2C/l8PP7Q4o+NqAFys6PGS8hkG2ytQzRmV80Zcm5O8CQcw4+nIGXAf29UEfY170grlWmVXfkti/cNxPDqgY+YRav/t05J9JJoGSrfE2tIzIF321EV4jk2EqAmdkdHYP8dkJihXvogAXug18C8D9FN0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1789074760; h=Content-Type: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=5biUd1hrE7MZBRCxmWFH37KE+WRWPVMF0xAnNQXGG3o=; b=V4q8OW5I4pxpCeU1UBB4YAFgNKt2Z9iFvFfjjzRFTEpIBhfE5bxW2sTYwrFATQSmQRwOARFaoGMgC58VhvFou3IapQlYIvzG5UYU52tyRBQQUpUM5ZA5LBF/3h0s9ESfO35bgiVy7O4Y4PgmY+W18dqmJm6PBH7Al6KkD66M6e0= 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 lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1789074760560138.19604111233014; Thu, 10 Sep 2026 14:12:40 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1x4m0B-00055g-VB; Thu, 10 Sep 2026 17:08:34 -0400 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 1x4lIQ-0001bI-GE for qemu-devel@nongnu.org; Thu, 10 Sep 2026 16:23:10 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1x4lI7-0007ky-KL for qemu-devel@nongnu.org; Thu, 10 Sep 2026 16:22:45 -0400 Received: from mail-wr1-f72.google.com (mail-wr1-f72.google.com [209.85.221.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-372-cc2KBvj0Oea_MY5evLVGRQ-1; Thu, 10 Sep 2026 16:12:56 -0400 Received: by mail-wr1-f72.google.com with SMTP id ffacd0b85a97d-4839f9edb08so60290f8f.0 for ; Thu, 10 Sep 2026 13:12:56 -0700 (PDT) Received: from redhat.com (IGLD-80-230-79-236.inter.net.il. [80.230.79.236]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-486eb32e7f5sm846666f8f.9.2026.09.10.13.12.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Sep 2026 13:12:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1789071543; 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=5biUd1hrE7MZBRCxmWFH37KE+WRWPVMF0xAnNQXGG3o=; b=FtfIRWYaQNGwpODiZ919rCpHDk9EDx/Ux8eos8azELvHOcMKaeYzj0yZF29qDXGvsqvAFc Qyx45oSn1vnKqEDdm+8OJfD5c2YuztoAEQsuHAPO4Gfxy2N78HME+BdljAOEZSztt5Ckd8 YsNPzikdk101SZTN1Lm5VdW9/hLmyaA= X-MC-Unique: cc2KBvj0Oea_MY5evLVGRQ-1 X-Mimecast-MFC-AGG-ID: cc2KBvj0Oea_MY5evLVGRQ_1789071175 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=google; t=1789071175; x=1789675975; 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=5biUd1hrE7MZBRCxmWFH37KE+WRWPVMF0xAnNQXGG3o=; b=sF28ZwDIBZssnztTWfu0G8JVd9pbtgDQbd3EMhXiUwfWHwzOHsi0HbJthaQnbcNBM+ Ndp0jRNOKQRflEczae7O6I+3+bvaVo8cyQHIBG5AAA5+v/1K6sloAQtjSLl3w4/Z6sGx RhTSK6SlLtB2y5/mJap9icvb+TFDruY6XmQVHc0FtXux0Vhsy3qk/vVK8loTRcWismiJ 6zHLbwnZJeV0BzuYM8IgW0fXYwzxNB+Uz8Qy7sOa+/rtJ+CvJ/ydK8R1tIz8NnA9sIfj LcY7CM50IH312Vz9W0aKtnFhR/d/43Kx32IxeYH26YlJTZ/6m405WrfRf0koR0JZAnvO qe+w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1789071175; x=1789675975; 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=5biUd1hrE7MZBRCxmWFH37KE+WRWPVMF0xAnNQXGG3o=; b=E0VTb0eNOEVbVrx+NXtOutcV4CdiOufYdHZx3mIpBzhlFE5377WycPBrHRIgXECrMM l63vpETPwg9jfDWvqz9Pu2O8h2spfEi/jRkGjpc9ZSsw6cXgR+xrQrBMkQwFppemMh8f 6rZ3XYXz+4fOJOUfOIKokFNBf0FGyJKDA0xRN7D8iSZAYR3C1ePEEJbFU4E2fIcRrCTI QMlm4f8ilPauS6j8ymKVhAIZkeOvx8MI0/OlpXJZo6eAjPx7nG5fjoSxbNb3G3G9EqPr JC5Rd+WSjvXvK1JVSySYLLSZwOSK5HDYwpKHRRlvrm3eflfvKEwb0ls1OPxJZMWpNzXW jLKw== X-Gm-Message-State: AFuF++nukOtkdEaTcUR6nkJ+XzmLL7uWge/uRLDwr00CrfUaUn+/oDVP EI0uAfhtsuMwiSk0BNCSTqJID9Xm+BeL+1ZMRdYVX4l8A9Q+8IMgn9jRRTEj6cUWICty/ICDH9C hFQkQRegGCDFN5RSlrDgkkiz03xjdiDd2hF85ffgPMiDU60aWm1guNHXBZjj+IjmrlQbydGPzFP jKi0Ifl0MllYTaLJkOU3VNGViibXI1ngCafg== X-Gm-Gg: AYBFou2aHexyuswFrxgXWSKXdrpt8ZtRZXAkPbqUoDYdEnbuEfHwXtw+xCTkEuK+8mx YjKv4N+TxKwntZaGjknfUNXzxgDwjUFo9JKY7/NAiLTCQsCPwwVENRqNasdxqEvyV09+15ddjzn JVeIay5q2vu68//bbJbNeUSEEwV8l3s2g+nEJOWlH4LAzJGBrKb52axZeiwI44CbI07aTHykDF/ 3BopjXEZUdxHF2zzV1GicvWXUp4UU/3yBUa8VeMP1wOZotDemuQ2yk68K8C8Gsmjck7QYjlUzFE 7iVwiI1mp0JVZuCdQXha4iTYhEWRGPuTAVpdYP8AeZYu1o3omq69CfgCVthXT/XUADLOPkzGuLu N3zAsIAM6wyq/6gQiAvBw7us= X-Received: by 2002:a05:6000:4552:b0:485:8c17:976d with SMTP id ffacd0b85a97d-486eb316b13mr371940f8f.47.1789071174698; Thu, 10 Sep 2026 13:12:54 -0700 (PDT) X-Received: by 2002:a05:6000:4552:b0:485:8c17:976d with SMTP id ffacd0b85a97d-486eb316b13mr371900f8f.47.1789071174206; Thu, 10 Sep 2026 13:12:54 -0700 (PDT) Date: Thu, 10 Sep 2026 16:12:51 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Vladimir Sementsov-Ogievskiy , Ben Chaney , Paolo Bonzini , Zhao Liu , Peter Xu , Fabiano Rosas Subject: [PULL 34/90] tests/functional: add test_tap_migration Message-ID: References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-Mailer: git-send-email 2.51.2.2891.g4157995a80.dirty X-Mutt-Fcc: =sent 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=170.10.129.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com 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, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=0.001, SPF_HELO_PASS=-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-Zoho-Virus-Status: 1 X-Zoho-AV-Stamp: zmail-av-0.2.13.1.5.4/289.52.80 X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1789074764439158500 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Vladimir Sementsov-Ogievskiy Add test for a new local-migration migration of virtio-net/tap, with fd passing through UNIX socket. Signed-off-by: Vladimir Sementsov-Ogievskiy Reviewed-by: Ben Chaney Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin Message-ID: <20260819180201.1970193-17-vsementsov@yandex-team.ru> --- tests/functional/x86_64/meson.build | 1 + tests/functional/x86_64/test_tap_migration.py | 461 ++++++++++++++++++ 2 files changed, 462 insertions(+) create mode 100755 tests/functional/x86_64/test_tap_migration.py diff --git a/tests/functional/x86_64/meson.build b/tests/functional/x86_64/= meson.build index 0353b2af8e..6254149239 100644 --- a/tests/functional/x86_64/meson.build +++ b/tests/functional/x86_64/meson.build @@ -51,4 +51,5 @@ tests_x86_64_system_thorough =3D [ 'virtio_balloon', 'virtio_gpu', 'rebuild_vmfd', + 'tap_migration', ] diff --git a/tests/functional/x86_64/test_tap_migration.py b/tests/function= al/x86_64/test_tap_migration.py new file mode 100755 index 0000000000..1e0d602518 --- /dev/null +++ b/tests/functional/x86_64/test_tap_migration.py @@ -0,0 +1,461 @@ +#!/usr/bin/env python3 +# +# Functional test that tests TAP local migration +# with fd passing +# +# Copyright (c) Yandex Technologies LLC, 2026 +# +# SPDX-License-Identifier: GPL-2.0-or-later + +import os +import time +import subprocess +from subprocess import run +import signal +import ctypes +import ctypes.util +import unittest +from contextlib import contextmanager, ExitStack +from typing import Tuple + +from qemu_test import ( + LinuxKernelTest, + Asset, + exec_command_and_wait_for_pattern, +) +from qemu_test.decorators import skipWithoutSudo + + +GUEST_IP =3D "192.168.100.2" +GUEST_IP_MASK =3D f"{GUEST_IP}/24" +GUEST_MAC =3D "d6:0d:75:f8:0f:b7" +HOST_IP =3D "192.168.100.1" +HOST_IP_MASK =3D f"{HOST_IP}/24" +TAP_ID =3D "tap0" +TAP_ID2 =3D "tap1" +TAP_MAC =3D "e6:1d:44:b5:03:5d" +NETNS =3D f"qemu_test_ns_{os.getpid()}" + + +def ip(args, check=3DTrue) -> None: + """Run ip command with sudo""" + run(["sudo", "ip"] + args, check=3Dcheck) + + +@contextmanager +def switch_netns(netns_name): + libc =3D ctypes.CDLL(ctypes.util.find_library("c")) + netns_path =3D f"/var/run/netns/{netns_name}" + + def switch_to_fd(fd, check: bool =3D False): + """Switch to netns by file descriptor""" + SYS_setns =3D 308 + CLONE_NEWNET =3D 0x40000000 + ret =3D libc.syscall(SYS_setns, fd, CLONE_NEWNET) + if check and ret !=3D 0: + raise RuntimeError("syscall SETNS failed") + + with ExitStack() as stack: + original_netns_fd =3D os.open("/proc/self/ns/net", os.O_RDONLY) + stack.callback(os.close, original_netns_fd) + + ip(["netns", "add", netns_name]) + stack.callback(ip, ["netns", "del", netns_name], check=3DFalse) + + new_netns_fd =3D os.open(netns_path, os.O_RDONLY) + stack.callback(os.close, new_netns_fd) + + switch_to_fd(new_netns_fd) + stack.callback(switch_to_fd, original_netns_fd, check=3DFalse) + + yield + + +def del_tap(tap_name: str =3D TAP_ID) -> None: + ip(["tuntap", "del", tap_name, "mode", "tap", "multi_queue"], check=3D= False) + + +def init_tap(tap_name: str =3D TAP_ID, with_ip: bool =3D True) -> None: + ip(["tuntap", "add", "dev", tap_name, "mode", "tap", "multi_queue"]) + if with_ip: + ip(["link", "set", "dev", tap_name, "address", TAP_MAC]) + ip(["addr", "add", HOST_IP_MASK, "dev", tap_name]) + ip(["link", "set", tap_name, "up"]) + + +def switch_network_to_tap2() -> None: + ip(["link", "set", TAP_ID2, "down"]) + ip(["link", "set", TAP_ID, "down"]) + ip(["addr", "delete", HOST_IP_MASK, "dev", TAP_ID]) + ip(["link", "set", "dev", TAP_ID2, "address", TAP_MAC]) + ip(["addr", "add", HOST_IP_MASK, "dev", TAP_ID2]) + ip(["link", "set", TAP_ID2, "up"]) + + +def parse_ping_line(line: str) -> float: + # suspect lines like + # [1748524876.590509] 64 bytes from 94.245.155.3 \ + # (94.245.155.3): icmp_seq=3D1 ttl=3D250 time=3D101 ms + spl =3D line.split() + return float(spl[0][1:-1]) + + +def parse_ping_output(out) -> Tuple[bool, float, float]: + lines =3D [x for x in out.split("\n") if x.startswith("[")] + + try: + first_no_ans =3D next( + (ind for ind in range(len(lines)) if lines[ind][20:26] =3D=3D = "no ans") + ) + except StopIteration: + return False, parse_ping_line(lines[0]), parse_ping_line(lines[-1]) + + last_no_ans =3D next( + ind + for ind in range(len(lines) - 1, -1, -1) + if lines[ind][20:26] =3D=3D "no ans" + ) + + return ( + True, + parse_ping_line(lines[first_no_ans]), + parse_ping_line(lines[last_no_ans]), + ) + + +def wait_migration_finish(source_vm, target_vm): + migr_events =3D ( + ("MIGRATION", {"data": {"status": "completed"}}), + ("MIGRATION", {"data": {"status": "failed"}}), + ) + + source_e =3D source_vm.events_wait(migr_events)["data"] + target_e =3D target_vm.events_wait(migr_events)["data"] + + source_s =3D source_vm.cmd("query-status")["status"] + target_s =3D target_vm.cmd("query-status")["status"] + + assert ( + source_e["status"] =3D=3D "completed" + and target_e["status"] =3D=3D "completed" + and source_s =3D=3D "postmigrate" + and target_s =3D=3D "paused" + ), f"""Migration failed: + SRC status: {source_s} + SRC event: {source_e} + TGT status: {target_s} + TGT event:{target_e}""" + + +@skipWithoutSudo() +class TAPFdMigration(LinuxKernelTest): + + ASSET_KERNEL =3D Asset( + ( + "https://archives.fedoraproject.org/pub/archive/fedora/linux/r= eleases" + "/31/Server/x86_64/os/images/pxeboot/vmlinuz" + ), + "d4738d03dbbe083ca610d0821d0a8f1488bebbdccef54ce33e3adb35fda00129", + ) + + ASSET_INITRD =3D Asset( + ( + "https://archives.fedoraproject.org/pub/archive/fedora/linux/r= eleases" + "/31/Server/x86_64/os/images/pxeboot/initrd.img" + ), + "277cd6c7adf77c7e63d73bbb2cded8ef9e2d3a2f100000e92ff1f8396513cd8b", + ) + + ASSET_ALPINE_ISO =3D Asset( + ( + "https://dl-cdn.alpinelinux.org/" + "alpine/v3.22/releases/x86_64/alpine-standard-3.22.1-x86_64.is= o" + ), + "96d1b44ea1b8a5a884f193526d92edb4676054e9fa903ad2f016441a0fe13089", + ) + + @classmethod + def setUpClass(cls): + super().setUpClass() + + try: + cls.netns_context =3D switch_netns(NETNS) + cls.netns_context.__enter__() + except (OSError, subprocess.CalledProcessError) as e: + raise unittest.SkipTest(f"can't switch network namespace: {e}") + + @classmethod + def tearDownClass(cls): + if hasattr(cls, "netns_context"): + cls.netns_context.__exit__(None, None, None) + super().tearDownClass() + + def setUp(self): + super().setUp() + + self.require_accelerator("kvm") + self.set_machine("q35") + + self.setup_shared_memory() + + init_tap() + + self.outer_ping_proc =3D None + self.shm_path =3D None + + def tearDown(self): + with ExitStack() as stack: + stack.callback(super().tearDown) + + if self.shm_path: + stack.callback(lambda p: (os.unlink(p) if os.path.exists(p) + else None), + self.shm_path) + self.shm_path =3D None + + stack.callback(del_tap, TAP_ID2) + stack.callback(del_tap, TAP_ID) + + if self.outer_ping_proc: + self.stop_outer_ping() + + def start_outer_ping(self) -> None: + assert self.outer_ping_proc is None + self.outer_ping_log =3D self.scratch_file("ping.log") + with open(self.outer_ping_log, "w") as f: + self.outer_ping_proc =3D subprocess.Popen( + ["ping", "-i", "0", "-O", "-D", GUEST_IP], + text=3DTrue, + stdout=3Df, + ) + + def stop_outer_ping(self) -> str: + assert self.outer_ping_proc + self.outer_ping_proc.send_signal(signal.SIGINT) + + self.outer_ping_proc.communicate(timeout=3D5) + self.outer_ping_proc =3D None + + with open(self.outer_ping_log) as f: + return f.read() + + def stop_ping_and_check(self, stop_time, resume_time): + ping_res =3D self.stop_outer_ping() + + discon, a, b =3D parse_ping_output(ping_res) + + if not discon: + text =3D ( + f"STOP: {stop_time}, RESUME: {resume_time}," f"PING: {a} -= {b}" + ) + if a > stop_time or b < resume_time: + self.fail(f"PING failed: {text}") + self.log.info(f"PING: no packets lost: {text}") + return + + text =3D ( + f"STOP: {stop_time}, RESUME: {resume_time}," + f"PING: disconnect: {a} - {b}" + ) + self.log.info(text) + eps =3D 0.05 + if a < stop_time - eps or b > resume_time + eps: + self.fail(text) + + def one_ping_from_guest(self, vm) -> None: + exec_command_and_wait_for_pattern( + self, + f"ping -c 1 -W 1 {HOST_IP}", + "1 packets transmitted, 1 packets received", + "1 packets transmitted, 0 packets received", + vm=3Dvm, + ) + self.wait_for_console_pattern("# ", vm=3Dvm) + + def one_ping_from_host(self) -> None: + run( + ["ping", "-c", "1", "-W", "1", GUEST_IP], + stdout=3Dsubprocess.DEVNULL, + check=3DTrue, + ) + + def setup_shared_memory(self): + self.shm_path =3D f"/dev/shm/qemu_test_{os.getpid()}" + + try: + with open(self.shm_path, "wb") as f: + f.write(b"\0" * (1024 * 1024 * 1024)) # 1GB + except Exception as e: + self.fail(f"Failed to create shared memory file: {e}") + + def prepare_vm( + self, shm_path, vhost, incoming=3DFalse, vm=3DNone, local=3DTrue + ): + if not vm: + vm =3D self.vm + + vm.set_console() + vm.add_args("-accel", "kvm") + vm.add_args("-device", "pcie-pci-bridge,id=3Dpci.1,bus=3Dpcie.0") + vm.add_args("-m", "1G") + vm.add_args("-net", "none") + + vm.add_args( + "-object", + f"memory-backend-file,id=3Dram0,size=3D1G,mem-path=3D{shm_path= },share=3Don", + ) + vm.add_args("-machine", "memory-backend=3Dram0") + + vm.add_args( + "-drive", + f"file=3D{self.ASSET_ALPINE_ISO.fetch()},media=3Dcdrom,format= =3Draw", + ) + + vm.add_args("-S") + + if incoming: + vm.add_args("-incoming", "defer") + + def add_virtio_net( + self, vm, vhost: bool, tap_name: str, local: bool, incoming: bool + ): + netdev_params =3D { + "id": "netdev.1", + "vhost": vhost, + "type": "tap", + "queues": 4, + "script": "no", + "downscript": "no", + "x-permit-local-migration": local, + } + + if not (local and incoming): + netdev_params["vnet_hdr"] =3D True + netdev_params["ifname"] =3D tap_name + + vm.cmd("netdev_add", netdev_params) + + vm.cmd( + "device_add", + driver=3D"virtio-net-pci", + romfile=3D"", + id=3D"vnet.1", + netdev=3D"netdev.1", + mq=3DTrue, + vectors=3D18, + bus=3D"pci.1", + mac=3DGUEST_MAC, + disable_legacy=3D"off", + ) + + def set_migration_capabilities(self, vm, local): + vm.cmd( + "migrate-set-capabilities", + { + "capabilities": [ + {"capability": "events", "state": True}, + {"capability": "x-ignore-shared", "state": True}, + ] + }, + ) + vm.cmd("migrate-set-parameters", {"local": local}) + + def setup_guest_network(self) -> None: + exec_command_and_wait_for_pattern(self, "ip addr", "# ") + exec_command_and_wait_for_pattern( + self, + f"ip addr add {GUEST_IP_MASK} dev eth0 && " + "ip link set eth0 up && echo OK", + "OK", + ) + self.wait_for_console_pattern("# ") + + def migrate(self, vm, mig_sock): + vm.cmd("migrate", uri=3Df"unix:{mig_sock}") + def do_test_tap_fd_migration(self, vhost, local=3DTrue): + socket_dir =3D self.socket_dir() + mig_sock =3D os.path.join(socket_dir.name, "mig.sock") + + # Setup second TAP if needed + if not local: + del_tap(TAP_ID2) + init_tap(TAP_ID2, with_ip=3DFalse) + + self.prepare_vm(self.shm_path, vhost, local=3Dlocal) + self.vm.launch() + self.set_migration_capabilities(self.vm, local=3Dlocal) + self.add_virtio_net(self.vm, vhost, TAP_ID, local, incoming=3DFals= e) + + self.vm.cmd("cont") + self.wait_for_console_pattern("login:") + exec_command_and_wait_for_pattern(self, "root", "# ") + + self.setup_guest_network() + + self.one_ping_from_guest(self.vm) + self.one_ping_from_host() + self.start_outer_ping() + + # Get some successful pings before migration + time.sleep(0.5) + + target_vm =3D self.get_vm(name=3D"target") + self.prepare_vm( + self.shm_path, + vhost, + incoming=3DTrue, + vm=3Dtarget_vm, + local=3Dlocal, + ) + + target_vm.launch() + if not local: + tap_name =3D TAP_ID2 + else: + tap_name =3D TAP_ID + self.set_migration_capabilities(target_vm, local=3Dlocal) + self.add_virtio_net(target_vm, vhost, tap_name, local, incoming=3D= True) + + target_vm.cmd("migrate-incoming", {"uri": f"unix:{mig_sock}"}) + + self.log.info("Starting migration") + freeze_start =3D time.time() + self.migrate(self.vm, mig_sock) + + self.log.info("Waiting for migration completion") + wait_migration_finish(self.vm, target_vm) + + # Switch network to tap1 if not using local-migration + if not local: + switch_network_to_tap2() + + target_vm.cmd("cont") + freeze_end =3D time.time() + + self.vm.shutdown() + + self.log.info("Verifying PING on target VM after migration") + self.one_ping_from_guest(target_vm) + self.one_ping_from_host() + + # And a bit more pings after source shutdown + time.sleep(0.3) + self.stop_ping_and_check(freeze_start, freeze_end) + + target_vm.shutdown() + + def test_tap_fd_migration(self): + self.do_test_tap_fd_migration(False) + + def test_tap_fd_migration_vhost(self): + self.do_test_tap_fd_migration(True) + + def test_tap_new_tap_migration(self): + self.do_test_tap_fd_migration(False, local=3DFalse) + + def test_tap_new_tap_migration_vhost(self): + self.do_test_tap_fd_migration(True, local=3DFalse) + + +if __name__ =3D=3D "__main__": + LinuxKernelTest.main() --=20 MST From nobody Sat Sep 26 20:50:17 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=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1789086541; cv=none; d=zohomail.com; s=zohoarc; b=MMD3C5iFv0D86e7bfLeUrB9gaJUnwbhISxPZnMW9haGN4p7xREfU1To/X4yG0iWNag0d+VgCMrCSvk2k0rjYn6BFAUjV99wZNQ4JRrzfM7pDpFIcLLrqW9PXKrtpClG4lp2s9Atol7zMULTT3tYRNZik6L9qIkIshtNK7lOph/c= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1789086541; h=Content-Type: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=4QZ/6VEOC+lNsRJAeXv7eh5vh8Fz3+qeKO3RjOtexo4=; b=DH4MXErCBbcQIt/1SBQnK4RIlGzQ2SEjMfkXwVfj6OWDYAOBZOsz/9qLJGK2vz0TFYRo2GV+j0HYNfqZMVFrDOrs2obvKQigr8/4nBC3YV36ITybBThEhoCb1a+4/XanzYZODdBHA9oDSdAwm5znyfNiw01eiodgA9wkG078vWk= 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 lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1789086541699603.4332441004151; Thu, 10 Sep 2026 17:29:01 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1x4ot5-0001RI-OL; Thu, 10 Sep 2026 20:13:09 -0400 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 1x4ljt-0001gR-Mf for qemu-devel@nongnu.org; Thu, 10 Sep 2026 16:51:40 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1x4ljn-0006RD-P8 for qemu-devel@nongnu.org; Thu, 10 Sep 2026 16:51:21 -0400 Received: from mail-wr1-f69.google.com (mail-wr1-f69.google.com [209.85.221.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-530-K_7fcvUQNrCoVx0nOmM74w-1; Thu, 10 Sep 2026 16:12:58 -0400 Received: by mail-wr1-f69.google.com with SMTP id ffacd0b85a97d-48437090e74so60883f8f.2 for ; Thu, 10 Sep 2026 13:12:58 -0700 (PDT) Received: from redhat.com (IGLD-80-230-79-236.inter.net.il. [80.230.79.236]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-486eb357288sm789158f8f.29.2026.09.10.13.12.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Sep 2026 13:12:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1789073471; 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=4QZ/6VEOC+lNsRJAeXv7eh5vh8Fz3+qeKO3RjOtexo4=; b=cz7YQzQh/AKYEUrhTwxeRllVeWt9vqUc+AbdiZ1UxqUSUET1lX8LW+/xzPLvnUzxpopBhf 5oCQXrczyQ87fmi+E+kM7GN/qHgpILlTXHn2sp8GjEMTSOHUE5GXx+MsLLNPBAe8bD9z22 Bh/9BW73OaoNC3oC3Adm5gPHzuck2Ps= X-MC-Unique: K_7fcvUQNrCoVx0nOmM74w-1 X-Mimecast-MFC-AGG-ID: K_7fcvUQNrCoVx0nOmM74w_1789071177 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=google; t=1789071177; x=1789675977; darn=nongnu.org; h=in-reply-to:content-transfer-encoding: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=4QZ/6VEOC+lNsRJAeXv7eh5vh8Fz3+qeKO3RjOtexo4=; b=mgX2vOFuYcnc/O1I29dUYTSx8fO317lq1+dQ9ReijE+omc/v02TKSNTWIDSRhlfebh iNypOFyBz4NTpXSYhKlD6Ca4UnZ/T2EW4/jDiQ1kPtJxCt3ARSLB84HEDYjYU7rxE5kD fsp+xbB1o2iTAQ7Ok2Q9z8m7bucm7u0HqqZBjUxrRLUfNdYspAiWg/FedLHcId2bIHaI Mt423EvKVhQSzzj9IEL2HwtzUESpYvgOkpxlQtzsAGxFzRDmzcpCisU8eQ+JhL36pq5X 1rq6bqAz/SoCWR+m5TDsKQHsvOw62SeN4ngO1jxr8NOXxUV35GnGBAnX6xjJiqlNW09Y X3Jg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1789071177; x=1789675977; h=in-reply-to:content-transfer-encoding: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=4QZ/6VEOC+lNsRJAeXv7eh5vh8Fz3+qeKO3RjOtexo4=; b=Bp9CBD+NVumF7IL64TLqVS+oLJoFCtn0nabRWltXSxFfrdWza/Q5S99HqWSkP+VdqX BSBikrjo6U2wF37O9I2bZRFrkXoNDDv30YbE61EZfll+oCkLyos6JfavmBii3aidPydx P2m/Is+DnIvvvjtMK1aI/zS1Es+YlmhWKPEchph8joFqInB8pj3nyLCvLNGDFtU3Qkzs Ay1yAR+BdkbiQrdSe8uNRqPAE4j+gA5BPKVsusvauF3mnNgU3bqpYZG35k8V9FZryca9 1mWgZgVEvxABeL52VL+3v0K+IlrPmmo4bEs4rh/NCCzTMRCPF1XZtcR15yA2D4L4PJ/G m9nA== X-Gm-Message-State: AFuF++lQNttzu23Rmoi+uSqpYvDZKbGxaZ0Ylr1wzI/vocoPPRMas9Ig 8rvl5rX3Ew8oOyw8PwFAAVZ3Rw00Q0C+wr8/DUeZfbaeuSRn8svWiKftYEOiVmM5l1kpFfdzH6W kdhhtJIVyFhUFcA+VbBv2hfAlcEPl8IWBkfQWUC0/9E6J5V9Z6eXM7AhN2/QOSPtJ09qvnNLZCI LnLQ40M88eyaGMJNWlbDjvV+yjUHQJ1q5HDw== X-Gm-Gg: AYBFou0eLGfpBPMTyZofFq+vifjiPBHgBZJKi87azWO87s+4QMduEL77SMIfuYnJIs8 VLh8kyLRmpYOSJXbfOYcXFa5B6BuiqflDQQQJiKkPXPBhDsR3TYJxC0orHwIoJXNe4Rx0B8vaNb 8KO/VPe506mj4E9eMAOdp8dxc+w/9d5UZY40faHfFTLBiYQGTfH2nou/nZEb22NCXq0bOIWUloy 5hEXqAuAsVW/Am0p+AQSslXenrfQD5QcS/TGYnRLWuDaM4NcKHzON2IPZO4YEwJ6R6QpKA9cT+2 VPMyMmmehKcvYjD6rIQYOl3fIeVBTotzRFgBi4QiLuAUybSEw0rS8hnFTbW5HrUvDCcOx7g9gWl 9vkqtt0IA8gKCn8yp2bt8pPE= X-Received: by 2002:a5d:5f4f:0:b0:484:4769:18a4 with SMTP id ffacd0b85a97d-486eb2fa4fcmr675569f8f.14.1789071176874; Thu, 10 Sep 2026 13:12:56 -0700 (PDT) X-Received: by 2002:a5d:5f4f:0:b0:484:4769:18a4 with SMTP id ffacd0b85a97d-486eb2fa4fcmr675523f8f.14.1789071176310; Thu, 10 Sep 2026 13:12:56 -0700 (PDT) Date: Thu, 10 Sep 2026 16:12:54 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , =?utf-8?Q?Marc-Andr=C3=A9?= Lureau , admin@fluentlogic.org, Stefano Garzarella Subject: [PULL 35/90] vhost-user-gpu: validate command buffer size in submit_3d Message-ID: <67f10fb88d3c75da3ba7fa5a37f7d6bcfcf3ce9e.1789071042.git.mst@redhat.com> References: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Disposition: inline Content-Transfer-Encoding: quoted-printable In-Reply-To: X-Mailer: git-send-email 2.51.2.2891.g4157995a80.dirty X-Mutt-Fcc: =sent 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=170.10.129.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com 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, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=0.001, SPF_HELO_PASS=-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-Zoho-Virus-Status: 1 X-Zoho-AV-Stamp: zmail-av-0.2.13.1.5.4/289.74.40 X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1789086543043158500 From: Marc-Andr=C3=A9 Lureau virgl_cmd_submit_3d() passes the guest-controlled cs.size directly to g_malloc() without any bounds check. A malicious guest can set this field to an arbitrarily large value (up to 4GB), causing an OOM abort that crashes the vhost-user-gpu daemon. Validate cs.size against the actual descriptor payload size before allocating, rejecting values that exceed what the virtqueue entry can carry. Fixes: d52c454aadc ("contrib: add vhost-user-gpu") Resolves: https://gitlab.com/qemu-project/qemu/-/work_items/3776 Reported-by: admin@fluentlogic.org Signed-off-by: Marc-Andr=C3=A9 Lureau Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin Message-ID: <20260713125431.107278-1-marcandre.lureau@redhat.com> --- contrib/vhost-user-gpu/virgl.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/contrib/vhost-user-gpu/virgl.c b/contrib/vhost-user-gpu/virgl.c index 20bae57d0f..c95c4afc5c 100644 --- a/contrib/vhost-user-gpu/virgl.c +++ b/contrib/vhost-user-gpu/virgl.c @@ -197,20 +197,24 @@ virgl_cmd_submit_3d(VuGpu *g, struct virtio_gpu_ctrl_command *cmd) { struct virtio_gpu_cmd_submit cs; + size_t iov_len; void *buf; size_t s; =20 VUGPU_FILL_CMD(cs); =20 - if (cs.size > VIRTIO_GPU_MAX_CMD_SUBMIT_SIZE) { - g_critical("%s: command buffer too large (%u)", - __func__, cs.size); + iov_len =3D iov_size(cmd->elem.out_sg, cmd->elem.out_num); + if (cs.size =3D=3D 0 || iov_len < sizeof(cs) || + cs.size > iov_len - sizeof(cs) || + cs.size > VIRTIO_GPU_MAX_CMD_SUBMIT_SIZE) { + g_critical("%s: size out of range (%u/%zu)", + __func__, cs.size, iov_len); cmd->error =3D VIRTIO_GPU_RESP_ERR_INVALID_PARAMETER; return; } =20 buf =3D g_try_malloc(cs.size); - if (!buf && cs.size) { + if (!buf) { cmd->error =3D VIRTIO_GPU_RESP_ERR_OUT_OF_MEMORY; return; } --=20 MST From nobody Sat Sep 26 20:50:17 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=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1789074832; cv=none; d=zohomail.com; s=zohoarc; b=g6HjvcpBiX9Cd8QOff+FTPGLr3owh0ne7Lrap6s7YPar2/TG6dNP/AQNfKFhphio3+rL8To9f5RGXjxpbcsblVX2mGiTBcZio7r5tGOIiZs0rZwwHTf+f+QgGDf2zhQ0RYuyQfMqSgxXGzPSK2ZKitNeSUfOYvUAnF/45NnLBiI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1789074832; h=Content-Type: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=HlDAI3aXlBUqmLElEAtno+7cNgJBmTJIFkfsvSTRx+s=; b=kccK3gBXJyQW1JbCdDNJFSKtjXnYi1TPyl9xHs3IGHcoErCWLMaseFrA2833fLuFrfJVpPyhC8vBaR/3uRqHzWuGhVMV4Gn8wPJqlCr7AhyhmwnpJidXvf942RhqhMveBpfv6Gk2WAE/vOTU6NTdjC8QNWQZ80gI8XlM3o37wWE= 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 lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1789074832161752.610625919059; Thu, 10 Sep 2026 14:13:52 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1x4m1c-0005PY-6U; Thu, 10 Sep 2026 17:10:16 -0400 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 1x4lIA-0001Yr-5E for qemu-devel@nongnu.org; Thu, 10 Sep 2026 16:22:58 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1x4lHk-0007la-E5 for qemu-devel@nongnu.org; Thu, 10 Sep 2026 16:22:27 -0400 Received: from mail-wm1-f71.google.com (mail-wm1-f71.google.com [209.85.128.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-681-Lv1bhQHoOZGd-T4FPlWkwA-1; Thu, 10 Sep 2026 16:13:01 -0400 Received: by mail-wm1-f71.google.com with SMTP id 5b1f17b1804b1-4994aebe932so2224265e9.3 for ; Thu, 10 Sep 2026 13:13:00 -0700 (PDT) Received: from redhat.com (IGLD-80-230-79-236.inter.net.il. [80.230.79.236]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-49e62232cb7sm1135575e9.4.2026.09.10.13.12.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Sep 2026 13:12:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1789071546; 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=HlDAI3aXlBUqmLElEAtno+7cNgJBmTJIFkfsvSTRx+s=; b=bQ9HCr+78d73SVFaeJ5WaH8S936Q3OQXpm9ORlJ8nqvq+bIjBagxq6r7pqfNRVKTgS4xig I4iVPx9hkoJc3bO/Db12+K+3Ta+VN3zm1nu6+SLTUh4+cpCm/lezpBg0lJ9c3m7fIzSKrx d9RY1OXngUDaSGFGJmOb9rdp0CC4p4M= X-MC-Unique: Lv1bhQHoOZGd-T4FPlWkwA-1 X-Mimecast-MFC-AGG-ID: Lv1bhQHoOZGd-T4FPlWkwA_1789071180 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=google; t=1789071180; x=1789675980; 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=HlDAI3aXlBUqmLElEAtno+7cNgJBmTJIFkfsvSTRx+s=; b=NetmzmEUwvwizLNzf/CjhAUGxxXZr3IaggOFKBiL77WdKZfgcHXBBOAs0maJN+S3+Z zu8KozzwhTIFpt1rwzVI0ixIQU4wDc04VjL4Rxh7O9wpBlxu7yAexlqz+tvkwlyFQerO TiI4ympvnTKsgqZDFdx/+dEc/vpoTx6qfJ8LpAycM1D8q56UvMHR8vT3ZaxE+2hnfsfh R0KyFxk20BiBujOOUkNr1UlG0FG4RqBiE7GZ3Ta+V4ID94qn5UBzMotGQd2CvIt+f/vH 9di0c4S2dJ4pFI4Qkk1XZ7eu+S7PzJQp8u2DbLSJ0ABIaf8LrF/ILejDc5swoAVjGttq ofcQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1789071180; x=1789675980; 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=HlDAI3aXlBUqmLElEAtno+7cNgJBmTJIFkfsvSTRx+s=; b=YOBmj0QEw9dy+t27IVAYahM+mvlblfEqzTst6izu9mu4w4a4HaYf8tqGJ3WQz5Dqn+ G1+kd/kIYuSLUCZEjc2m2/PBkRs5bUdi1kpLb/wWX6k6NnREBM5eiyZMsCvOwq0YHi3M f85LtK/cok9DVLcO/oJfgOXbuQEVSd8h2AMrBpgJ3cOh+XHCO/XcwV8bgTHrcx5Nw2DQ lncowznv3aQV/rp75l0qYe3Q1+jXpbpNpBW6MvPmFP4xZl/2zXAR2TrDVg0NXIGnJw4t faWJi672wxQB7DLRz+9aYXLFh5024/0Hw8KmvqGMsF5W7lfpk8qCt7PLJO7sC9gsa2aQ IvWg== X-Gm-Message-State: AFuF++kk8OC1julmHKF6q/49eE5PoZADvsH/521X387C5uCv1t5eSBsi mf5hPQ+rSWCMvr839a9gXA+UcAyxFR7Ocov85zgtvJqimmVIxWaBTywMK3DCVVMyPl/Bl5SRF/I NUPhN/xVngzF40wU+6u+xOxFe0kVwbdkADpD/gfogx32kEdAXh06u8ozYmyBjea3rFMt52iCej9 nDlu01Ql2aR0XhP8TEdwflM8/nhWcCM9DfwA== X-Gm-Gg: AYBFou3zYz1HHp2mvZJ0zy2bpGr/DXYQChxBK9CxR9DLjTRbiOBuM2MiGgFblWxolkN 5f1RU6V9at/OgcCsRAnh3JphSTirTmRwiCDphN0PuatLHsADEbE3T0UGfwbndqnW+Tn/AfKXZfd NEaYA01yHYtjP/tClH++JWQ4CYLD103kTle1fD9xNWUD2HkWweUIbCpPiaF+EBv2OwUDBmwQ2G9 IW+Pg3nUN969tXZsUgQMAOUfWgmF8IOAtbCwgmijIw6p2dk3PGa/VooQnk3JJx1DhhQAJgOKISY A1Pe4V28H+6xTVM+96aVMRcKFP1pHCh5pehH0PEcrQP4qGlsDtEfsTmAp0Xj94ZC8RhYiYj9GvS BPoy/GyQ04tcIDv9H0PXuyFk= X-Received: by 2002:a05:600c:3115:b0:49c:f89b:f82 with SMTP id 5b1f17b1804b1-49e619f687dmr14055395e9.12.1789071179750; Thu, 10 Sep 2026 13:12:59 -0700 (PDT) X-Received: by 2002:a05:600c:3115:b0:49c:f89b:f82 with SMTP id 5b1f17b1804b1-49e619f687dmr14054375e9.12.1789071179143; Thu, 10 Sep 2026 13:12:59 -0700 (PDT) Date: Thu, 10 Sep 2026 16:12:56 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Dorinda Bassey , Albert Esteve , Stefano Garzarella Subject: [PULL 36/90] vhost: Fix SHMEM_MAP transaction ordering and resulting deadlock Message-ID: <741ace9011d65ed8a34eb9f941f6355515ffe74b.1789071042.git.mst@redhat.com> References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-Mailer: git-send-email 2.51.2.2891.g4157995a80.dirty X-Mutt-Fcc: =sent 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=170.10.129.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com 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, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=0.001, SPF_HELO_PASS=-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-Zoho-Virus-Status: 1 X-Zoho-AV-Stamp: zmail-av-0.2.13.1.5.4/289.52.80 X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1789074834051158500 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Dorinda Bassey Commit the memory region transaction before sending the SHMEM_MAP reply so the KVM memory slot exists before the guest can access the mapped region. This moves the commit to while the backend is still blocked waiting for the reply, which can trigger ADD_MEM_REG back to the backend and deadlock. Filter shmem mapping regions out of vhost_section() by checking the MR owner type to prevent this. The explicit transaction begin/commit wrapping is dropped since virtio_add_shmem_map() already commits via memory_region_add_subregion(). The unmap handler keeps the original ordering: reply before delete, so the backend is unblocked before the transaction commit. Fixes: b52e1896e764 ("vhost-user: Add VirtIO Shared Memory map request") Suggested-by: Albert Esteve Reviewed-by: Albert Esteve Tested-by: Albert Esteve Signed-off-by: Dorinda Bassey Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin Message-ID: <20260717134920.265128-2-dbassey@redhat.com> --- hw/virtio/vhost-user.c | 20 ++------------------ hw/virtio/vhost.c | 10 ++++++++++ 2 files changed, 12 insertions(+), 18 deletions(-) diff --git a/hw/virtio/vhost-user.c b/hw/virtio/vhost-user.c index 2881cec72d..fac02a1ffc 100644 --- a/hw/virtio/vhost-user.c +++ b/hw/virtio/vhost-user.c @@ -1980,8 +1980,6 @@ vhost_user_backend_handle_shmem_map(struct vhost_dev = *dev, } } =20 - memory_region_transaction_begin(); - /* Create VirtioSharedMemoryMapping object */ VirtioSharedMemoryMapping *mapping =3D virtio_shared_memory_mapping_ne= w( vu_mmap->shmid, fd, vu_mmap->fd_offset, vu_mmap->shm_offset, @@ -1989,7 +1987,7 @@ vhost_user_backend_handle_shmem_map(struct vhost_dev = *dev, =20 if (!mapping) { ret =3D -EFAULT; - goto send_reply_commit; + goto send_reply; } =20 /* Add the mapping to the shared memory region */ @@ -1997,23 +1995,9 @@ vhost_user_backend_handle_shmem_map(struct vhost_dev= *dev, error_report("Failed to add shared memory mapping"); object_unref(OBJECT(mapping)); ret =3D -EFAULT; - goto send_reply_commit; + goto send_reply; } =20 -send_reply_commit: - /* Send reply and commit after transaction started */ - if (hdr->flags & VHOST_USER_NEED_REPLY_MASK) { - payload->u64 =3D !!ret; - hdr->size =3D sizeof(payload->u64); - if (!vhost_user_send_resp(ioc, hdr, payload, &local_err)) { - error_report_err(local_err); - memory_region_transaction_commit(); - return -EFAULT; - } - } - memory_region_transaction_commit(); - return 0; - send_reply: if (hdr->flags & VHOST_USER_NEED_REPLY_MASK) { payload->u64 =3D !!ret; diff --git a/hw/virtio/vhost.c b/hw/virtio/vhost.c index a81cd94f90..838b1da739 100644 --- a/hw/virtio/vhost.c +++ b/hw/virtio/vhost.c @@ -636,6 +636,16 @@ static bool vhost_section(struct vhost_dev *dev, Memor= yRegionSection *section) { MemoryRegion *mr =3D section->mr; =20 + /* + * Skip shmem mapping regions, they are managed via SHMEM_MAP/UNMAP. + * Including them triggers ADD_MEM_REG during the SHMEM_MAP transaction + * commit, deadlocking the backend. + */ + if (object_dynamic_cast(memory_region_owner(mr), + TYPE_VIRTIO_SHARED_MEMORY_MAPPING)) { + return false; + } + if (memory_region_is_ram(mr) && !memory_region_is_rom(mr)) { uint8_t dirty_mask =3D memory_region_get_dirty_log_mask(mr); uint8_t handled_dirty; --=20 MST From nobody Sat Sep 26 20:50:17 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=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1789084229; cv=none; d=zohomail.com; s=zohoarc; b=BDqtpEuJ3YigXA169zXAnxfrLzW/OJsUlbG9yDgqJeeG3skSar38teyawy8svlGC2z1RJ7V5q41CP2Fbrzz+Kf9R+WL12q1sL4/VIk2NpTggdpRBRnWnIueX48S98/ucoeNlJAhAKgpCMMmu2nhnk/bvDG9ksiqrkkK1Y1VByV4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1789084229; h=Content-Type: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=SgB+S9u3GSAcq8/Uuupwqbwj/4AB+NAz4BxPvnZlGUs=; b=TwUAZQqJwBLmXMzFJbtWriLUc19Mw/XIbeucJgIJrLISG+4ib/JxZqkODljsaBjPyL0rKTK6dnVoDFqsGf413/gaafwytmFsRxUOpUKO2F8o/X7JndidYOZeHteAVicHYNkVdCz9KMkKru3Z52+Z7cm0VqL04iCICUyt61BvdxA= 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 lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1789084229652983.037880170782; Thu, 10 Sep 2026 16:50:29 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1x4oUc-0002t6-4M; Thu, 10 Sep 2026 19:48:04 -0400 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 1x4lTj-0005uF-7G for qemu-devel@nongnu.org; Thu, 10 Sep 2026 16:35:00 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1x4lTR-0003BG-6e for qemu-devel@nongnu.org; Thu, 10 Sep 2026 16:34:29 -0400 Received: from mail-wr1-f72.google.com (mail-wr1-f72.google.com [209.85.221.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-121-Pd7bbjUNNFKgWGgudRia1A-1; Thu, 10 Sep 2026 16:13:03 -0400 Received: by mail-wr1-f72.google.com with SMTP id ffacd0b85a97d-482f763db88so47200f8f.2 for ; Thu, 10 Sep 2026 13:13:03 -0700 (PDT) Received: from redhat.com (IGLD-80-230-79-236.inter.net.il. [80.230.79.236]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-486eb33ee5csm805192f8f.20.2026.09.10.13.13.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Sep 2026 13:13:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1789072383; 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=SgB+S9u3GSAcq8/Uuupwqbwj/4AB+NAz4BxPvnZlGUs=; b=epF8NG8hzj0WKDkMmAUlq5SzA2QDx8W3pI+XFKlXzOuOghQJZb1uzpvizoyQiq38j3DJKf P3aOeK33fLcmowftEVnD7+dlYL9HtO2XaNv2uCTG3tps1FAXjoMwbUv8jn4LYlMzaA9Qzt 8sL7V2srVmOfFcPYRs12RYivtWPjnbM= X-MC-Unique: Pd7bbjUNNFKgWGgudRia1A-1 X-Mimecast-MFC-AGG-ID: Pd7bbjUNNFKgWGgudRia1A_1789071182 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=google; t=1789071182; x=1789675982; 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=SgB+S9u3GSAcq8/Uuupwqbwj/4AB+NAz4BxPvnZlGUs=; b=dfaqVToegu2f9z5DT1dtsJcK7NzzeDoQEIhws0R9u5RLZI2O/08q20JRdo0RoIfHZh zTMuwZcRFd+kddpAqTnj0wLOXHTct8RmI+NwO5SEKrgGIW8yVmsX3HY2I8mFv2q9RxYC EJC6IDiI4R33Xi5Yj7exyUlSPSHqrY8gAxII9hq+ClPfSWB0ctNrSXaGowd8O5F3drEP upGK/v5TYKunVWWo+kLsS6djkb0T99/A4MhMkymuIog7xVCt+zomccIWoSA+Ao6EPn0o +giAHfDuPkfl7mI9V2o9CTmwQu/bToDIqrp2t6RxeX61E6/DFZGqgLnLxb/ENKpBkezW KVKw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1789071182; x=1789675982; 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=SgB+S9u3GSAcq8/Uuupwqbwj/4AB+NAz4BxPvnZlGUs=; b=i/aoZZ+roGVqZtyOm5JdrAg46JNfW7LX9qYg1oUbjzLS+QHIQ/sgDhK0uCceYGq90k VXB3YPP3TKyjZ7lw55JrqQSZQe821INETYw2PoMHrnPYoARtGtKPTBUz3AFvDiMH9M1d uIQiyw4CX8evTllqGfzhuvcYozfKGeUl9feN0oPtb2JFaQ5TFYuymkVRSymvKi6GBegx b/L+8rtQh/8UH4tvAO4drvmEAtzIz8WNRfmCXhobhGkkshkGXbgPg/Wzj9y/nvWVc4bE lw7/9r77KRm5Dfq5JSZMOCy2kfcVBK6K50OfKmD+f55p2t6ru5m+sne5zu6gXotZc8FN Bp/w== X-Gm-Message-State: AFuF++l3MhP47B/9+JCsYicx0ybxcRr+g4pV15F7zMCt4v1IQSTrnnh3 RPAh4sUmDjw7hyipIG2jFrWYTNu3+UTaRdL4u/zEYixWX/P2uBoCn0iuUIUW9ZEKqTHCTOkHK9M vLh54TK3lidjR/+5uiNFpEaOhFYyzyUqkI48G2nOlNr2Fczt7dtzjlaX+Pi0cvSacnnfGP8u+RM HIB3/aGPs2WYLeBMvoQMdALT8zEEJ7Ag9hxQ== X-Gm-Gg: AYBFou0P0+5/gpZ9FPqFaa4NPD6CqlzS8bpvHngrCtpByBkd85XQXjMQ8EgQ1LtM5c+ 0Epk2R+YsxiLpZ+x93MopuLHgvwUEq9YCVZKMbU1lghOHumDOXfQDGVcU6+YqqXCIul0FS6eyDn ikXvM0j+AK+WvAbNqZrLRkr4FEipvImRsT39tVsJzUOgeq5+Yljbctz0Sz+KKgzS606KKzv2yNT MB9hpNx0Va8t+0M4YVryIQyKyYDoNYTbT2fJxM3v6ycspnaTcfRj6dwzHpXWHP6MtaqCpmAYGnt HWx2mDKhAC2PtpwNPEGOnk7EulSM1sdrb1VdSl9GZ6aJl8iLwMZbmMe8/ujHp0dw8PnzlCNYUrR wqP4BmtxbmWts9RvPy/H8W4A= X-Received: by 2002:a05:6000:384:b0:482:e124:836f with SMTP id ffacd0b85a97d-486eb1d99afmr639097f8f.3.1789071182054; Thu, 10 Sep 2026 13:13:02 -0700 (PDT) X-Received: by 2002:a05:6000:384:b0:482:e124:836f with SMTP id ffacd0b85a97d-486eb1d99afmr639058f8f.3.1789071181564; Thu, 10 Sep 2026 13:13:01 -0700 (PDT) Date: Thu, 10 Sep 2026 16:12:59 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Matej Hrica , Albert Esteve , Dorinda Bassey , =?utf-8?Q?Marc-Andr=C3=A9?= Lureau , Stefano Garzarella Subject: [PULL 37/90] vhost-user-gpu: Add shared memory region support Message-ID: References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-Mailer: git-send-email 2.51.2.2891.g4157995a80.dirty X-Mutt-Fcc: =sent 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=170.10.129.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com 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, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=0.001, SPF_HELO_PASS=-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-Zoho-Virus-Status: 1 X-Zoho-AV-Stamp: zmail-av-0.2.13.1.5.4/289.74.40 X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1789084233647158500 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Matej Hrica Add a 'hostmem' property to the vhost-user-gpu which enables the shared memory in the parent object. Register a container MR in the shmem_list for SHMEM_MAP/UNMAP operations. A container MR is used so that SHMEM_MAP FD-backed subregions each get their own KVM memory slot with the correct backing fd. Suggested-by: Albert Esteve Reviewed-by: Albert Esteve Signed-off-by: Matej Hrica Signed-off-by: Dorinda Bassey Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin Message-ID: <20260717134920.265128-3-dbassey@redhat.com> --- hw/display/vhost-user-gpu.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/hw/display/vhost-user-gpu.c b/hw/display/vhost-user-gpu.c index cd684d6363..80ab6b773e 100644 --- a/hw/display/vhost-user-gpu.c +++ b/hw/display/vhost-user-gpu.c @@ -687,6 +687,16 @@ vhost_user_gpu_device_realize(DeviceState *qdev, Error= **errp) } =20 g->vhost_gpu_fd =3D -1; + + /* + * If shared memory is enabled, register the hostmem region for + * SHMEM_MAP/UNMAP operations. + */ + if (virtio_gpu_hostmem_enabled(g->parent_obj.conf)) { + VirtioSharedMemory *shmem =3D virtio_new_shmem_region( + vdev, VIRTIO_GPU_SHM_ID_HOST_VISIBLE, g->parent_obj.conf.hostm= em); + memory_region_add_subregion(&g->parent_obj.hostmem, 0, &shmem->mr); + } } =20 static struct vhost_dev *vhost_user_gpu_get_vhost(VirtIODevice *vdev) @@ -697,6 +707,7 @@ static struct vhost_dev *vhost_user_gpu_get_vhost(VirtI= ODevice *vdev) =20 static const Property vhost_user_gpu_properties[] =3D { VIRTIO_GPU_BASE_PROPERTIES(VhostUserGPU, parent_obj.conf), + DEFINE_PROP_SIZE("hostmem", VhostUserGPU, parent_obj.conf.hostmem, 0), }; =20 static void --=20 MST From nobody Sat Sep 26 20:50:17 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=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1789079832; cv=none; d=zohomail.com; s=zohoarc; b=EX3YiLnsPgg0QsT3W/I5wsJW0npzlqHdthiieIyG2o8Quecz3HAU02QyPnJA8qnu6N5dV6cAIRLLxp+naIpgGu4CGVh4BO1PVJdGRNGRxhCm6yfOQc9RCZkPsmITbSkp5B1+N1MITtRwGm8JIlYuAVUlHPpr8BfzqQ71p6NgrrY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1789079832; h=Content-Type: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=QDA3XcyEbs9mnsHi7voqYp+3OWZBRTr16GtYX9av+z8=; b=BRGjAXAFdFrOj+rxRacVkYUPfI+/5VYIiWYoqZqEX1cFlWkyPhctEajdIkMO3Y6QSJLlKLXJpcMiWKG1BPEishX0dBkwjDNjBteVC6nE/CP89uH/yXr0PxBdYPg3LasBwZTwHlDB7UinvXJx1236iwgbGCKUXmii9FKmEJlqDZI= 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 lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1789079832843421.6412617928157; Thu, 10 Sep 2026 15:37:12 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1x4nNT-0008KF-34; Thu, 10 Sep 2026 18:36:36 -0400 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 1x4lPl-0004M3-94 for qemu-devel@nongnu.org; Thu, 10 Sep 2026 16:30:55 -0400 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 1x4lPQ-0001Ss-1N for qemu-devel@nongnu.org; Thu, 10 Sep 2026 16:30:23 -0400 Received: from mail-wm1-f69.google.com (mail-wm1-f69.google.com [209.85.128.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-331-wnu9MhCzMgW8G9Y3W-wwVQ-1; Thu, 10 Sep 2026 16:13:06 -0400 Received: by mail-wm1-f69.google.com with SMTP id 5b1f17b1804b1-49cd55ee2f7so1861305e9.0 for ; Thu, 10 Sep 2026 13:13:05 -0700 (PDT) Received: from redhat.com (IGLD-80-230-79-236.inter.net.il. [80.230.79.236]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-49d26be3e0asm100907585e9.1.2026.09.10.13.13.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Sep 2026 13:13:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1789072095; 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=QDA3XcyEbs9mnsHi7voqYp+3OWZBRTr16GtYX9av+z8=; b=eIfhW9+GLRVqsO8sVb/zzP/6pyqHJTTAiONlAg3XxFCRz30n8TRvKVpIReUP2R3BRLKwAw y21vtvROSm1G1cyojIKvwrMQvZdkgnbmIyQ1jy6Dn/IBTpop+/nY/OxZuminTzYAv9VcUH Q6MXwSGbhim0t6uvMLqxobRvzCzSHlA= X-MC-Unique: wnu9MhCzMgW8G9Y3W-wwVQ-1 X-Mimecast-MFC-AGG-ID: wnu9MhCzMgW8G9Y3W-wwVQ_1789071185 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=google; t=1789071185; x=1789675985; 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=QDA3XcyEbs9mnsHi7voqYp+3OWZBRTr16GtYX9av+z8=; b=nQno72uTLf9v6QuljDmHApTH7NhW0sco2idFTUlkc1aRxxoTb6ifPRQUfvL0tM2GUl Beqav+mun/+2xh/h664hYbfUEV6dbuQneVe4RjJTk/wfmjRs2SnY4V/noZ1RW4jmboo/ F1tQqPXm4lJdfjHT3+mBMM2DqNyfHBhjdaB7nfiJABuvnn/KXb/Dnz5z0duhf7vhu5jO KBre6aYdy6bBB43SiXJ8YUlJFGjsvL8nmjGTmPPHH1aRM0bBYT4ADpnGwOyZbKwQcb9g Fm4OJ7O4+g4YPfdudMclEGBK/d4AvPIxb38VTP9jk7o87AR6o3fa6my+6TICTTByj8w0 2a9Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1789071185; x=1789675985; 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=QDA3XcyEbs9mnsHi7voqYp+3OWZBRTr16GtYX9av+z8=; b=FXDODqwhJWUMxXJRJlyOCGw5JZfOGQpWMFjXNuWxnoy7S2ap1OetVrpWx9cPrYYJJZ 4llqykzWTGVADwIX6efEn22JbuibGwIz8RE7woMIsY5OMmiITf7xyspcJoMrHUZFep5P 6/RBo+Mra46wfBYefo90uFcwo1DOnRpjbkDzNd9ludf4iaHcM++10DxTMJxTcKTETsQO RFB3nzeTjnz+BJEyJjFODloNLUMpGfOGVooLb2XegspTeBcjZMgTa034hBPNTFTKdKTZ bb8I6QH92ruxETlH+Dkn10Bo+yppJzTXaOjTPiPzxGOMqn0Gz7la1qzMtwTCpERz6nhi p5EA== X-Gm-Message-State: AFuF++lqF6W0wBeZaATqZnli8cTJ89asBiYWXNpd2Z1KPl0jQv6GAkku PvFz0jC5DPk+RTY+YdxfPTkLnJ2qHj+X+QtMSUM1WdWQFuVDYfumx7vHfCV/ieXMOFSCT3p+AZp jJdtZD7NFDTqyt3cXnlZLpM22KF8E2S9QUn3CQijW2WkTGFZbsRIAN5mS+kIQbiccEHuq+as2WT rLyYl57DOhHAyo6rg0mZ7GnoHA1TzdCsde8w== X-Gm-Gg: AYBFou25WTH6EsQWecymsdUJdJKI0d/Em4hHerw99IAv2nloKW3TpIh7BYa+M1PxLFU gH1CEPs7KgC/f00oX9rs2beWHBUBRH/Q8+ZDFH3cr8OD+zUrvipvvGZpOmf8vTzel0cBNlmT1ey kdx2k70MrD0pv7xrXOBJkkMEoO1ntT2AWSjBb+xicX/3GAFkNrxdeqPXPizr7h8+gHb5Kn8xIfP kgUI1cR4uaP68cQBSp3j35dDmbSJKjzqX/qy/77ti3k0AH+rxlIO7UZB5nMZXSyH8oWHctCO+n3 RDaCOsksn5ny9qCriCxsznaWk2t3bo61uKaPe8E+f7WH42phzGA3Wv7LfccVRl74B/pGVE9i5Fc P7cwwi8lWG7uOLLiphCPmXs8= X-Received: by 2002:a05:600c:3acb:b0:49c:fa21:1c8c with SMTP id 5b1f17b1804b1-49e619e0e6amr6770965e9.33.1789071184697; Thu, 10 Sep 2026 13:13:04 -0700 (PDT) X-Received: by 2002:a05:600c:3acb:b0:49c:fa21:1c8c with SMTP id 5b1f17b1804b1-49e619e0e6amr6770635e9.33.1789071184201; Thu, 10 Sep 2026 13:13:04 -0700 (PDT) Date: Thu, 10 Sep 2026 16:13:01 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Matej Hrica , Manos Pitsidianakis , Dorinda Bassey , Stefano Garzarella , =?utf-8?Q?Marc-Andr=C3=A9?= Lureau Subject: [PULL 38/90] vhost-user-gpu: Forward RESOURCE_BLOB and CONTEXT_INIT flags Message-ID: <327c91ef1d0c82421da6ac4cdcef097b77b046e7.1789071043.git.mst@redhat.com> References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-Mailer: git-send-email 2.51.2.2891.g4157995a80.dirty X-Mutt-Fcc: =sent 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=170.10.133.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com 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, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_PASS=-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-Zoho-Virus-Status: 1 X-Zoho-AV-Stamp: zmail-av-0.2.13.1.5.4/289.74.40 X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1789079835309158500 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Matej Hrica Forward VIRTIO_GPU_F_RESOURCE_BLOB and VIRTIO_GPU_F_CONTEXT_INIT received from a vhost backend to expose it to the guest. Use vhost_dev_has_feature() to query the backend features, matching the existing pattern for RESOURCE_UUID. This allows the guest to negotiate blob resource support and context initialization when the backend (e.g., vhost-device-gpu with Venus) advertises these capabilities. Reviewed-by: Manos Pitsidianakis Signed-off-by: Matej Hrica Signed-off-by: Dorinda Bassey Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin Message-ID: <20260717134920.265128-4-dbassey@redhat.com> --- hw/display/vhost-user-gpu.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/hw/display/vhost-user-gpu.c b/hw/display/vhost-user-gpu.c index 80ab6b773e..a5b4df2c46 100644 --- a/hw/display/vhost-user-gpu.c +++ b/hw/display/vhost-user-gpu.c @@ -681,6 +681,12 @@ vhost_user_gpu_device_realize(DeviceState *qdev, Error= **errp) if (vhost_dev_has_feature(&g->vhost->dev, VIRTIO_GPU_F_RESOURCE_UUID))= { g->parent_obj.conf.flags |=3D 1 << VIRTIO_GPU_FLAG_RESOURCE_UUID_E= NABLED; } + if (vhost_dev_has_feature(&g->vhost->dev, VIRTIO_GPU_F_RESOURCE_BLOB))= { + g->parent_obj.conf.flags |=3D 1 << VIRTIO_GPU_FLAG_BLOB_ENABLED; + } + if (vhost_dev_has_feature(&g->vhost->dev, VIRTIO_GPU_F_CONTEXT_INIT)) { + g->parent_obj.conf.flags |=3D 1 << VIRTIO_GPU_FLAG_CONTEXT_INIT_EN= ABLED; + } =20 if (!virtio_gpu_base_device_realize(qdev, NULL, NULL, errp)) { return; --=20 MST From nobody Sat Sep 26 20:50:17 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=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1789086642; cv=none; d=zohomail.com; s=zohoarc; b=alDWGoJZVD6h2Wxv/V1+6h3KNgySssbBL7QoP+wiB/XANtiWl9qsgqI43ECwrdDvnRtO3feeS6Cm1VklTfzqAsABoXdR56j5Ild9/o8qLxF8ldfaja92rSLMA8Ppj9x1vdt35lMV1ldFKa3RNgmByK/A8hPsV6GE6L0biIT2faU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1789086642; h=Content-Type: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=GnRjJ65SGrC9am8hi9r7ANKDtkiUG6pnQWAw9MHk3fY=; b=G46g4BYjo+ifKvS3AeAq/ZAaVTpQS3AO/4HHFt/mmfwiWRFgMFHa/7GFnd7W+C3pNpwEUk6YSgDeblhBL6Xwsbrq8+jqIe4r/yGrXdN5693cQPQvWfPgBSZ45TIieuDxZy7z0geydrBJl2G60Za9YhYVZj5U4J6pUc5Ap9eOSRk= 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 lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 178908664211098.11408951669614; Thu, 10 Sep 2026 17:30:42 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1x4owk-0002XR-A9; Thu, 10 Sep 2026 20:16:58 -0400 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 1x4lkz-0001lX-JL for qemu-devel@nongnu.org; Thu, 10 Sep 2026 16:52:40 -0400 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 1x4lkp-0006TD-Ps for qemu-devel@nongnu.org; Thu, 10 Sep 2026 16:52:26 -0400 Received: from mail-wr1-f69.google.com (mail-wr1-f69.google.com [209.85.221.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-65-q8bAevDUOVebB6VvTWsclg-1; Thu, 10 Sep 2026 16:13:08 -0400 Received: by mail-wr1-f69.google.com with SMTP id ffacd0b85a97d-484362cb000so119506f8f.0 for ; Thu, 10 Sep 2026 13:13:08 -0700 (PDT) Received: from redhat.com (IGLD-80-230-79-236.inter.net.il. [80.230.79.236]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-486eb32e7f5sm847945f8f.9.2026.09.10.13.13.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Sep 2026 13:13:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1789073521; 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=GnRjJ65SGrC9am8hi9r7ANKDtkiUG6pnQWAw9MHk3fY=; b=PG40q3MQ8ViwKV7hADhs1anyGOVwl7JfQtzST5uyn8xDnWPWBh2L1pl9edfkIrr484bHb8 qFMS6L5nAk46uyNSJmOvguKjvxCrThGBTM2gUitaW5KKLmufID11pgs9PT4ms0ag8T61Y/ X44n+5jk6lPSshtHNrLsHJKf1HYjwoE= X-MC-Unique: q8bAevDUOVebB6VvTWsclg-1 X-Mimecast-MFC-AGG-ID: q8bAevDUOVebB6VvTWsclg_1789071187 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=google; t=1789071187; x=1789675987; 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=GnRjJ65SGrC9am8hi9r7ANKDtkiUG6pnQWAw9MHk3fY=; b=Uux0OJb0f+qKoIIDfC6U142jCsY9Z/1ZobTHo8IF9RN1GS2le3o4244Sp0nCsyWYLc CLyRXgHd5uRmykP2uk42lDv9k7xR/XvaBOp6vVUNTdPeaiTdMP74oWBS1NqiPdSRwFW6 W+UJn2wC0WRx+oIoIwxRGHIC2LoM3U9j17gUgqI4RQSq1go0eu4M8gCq66CHQLF9KchE VI1zo1UKO9NzvGl5m2DdB/CXCy5O6ja9P204pMOMXVVMgSYCVkhHJszqntIcTXToc+pG bG+Bf3nBjhZU309NL85rU4y3RuHLUHdSjQ1b57K2chSnXkb851rReOOqU4IRGHnRwuz+ 5Kfg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1789071187; x=1789675987; 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=GnRjJ65SGrC9am8hi9r7ANKDtkiUG6pnQWAw9MHk3fY=; b=q+PbHK9Qpa4sEY/uQ/+vjsgPFyVPF/T7LW7FOe2p6egeLRx6wbypL4vEi++Ckohxnw uqVT0bJZVafs+W6rcCOJnrALQ0u7W3/FiMRd5gmqoqyqWWeoOSCSkHNWGRsX45jeyFBh IQL1sLEdfiSksDzXoIIoIMUtIgv+PUs/n9NLmwzh7SxFzPIGHoiVCBigPHK5DrNq4yb0 gkPTcRE+ishX/YSTdAkGwJBiAxBCumAo0t+L9qpdXxiTU+36WlWD8YfJvadiAhsLsNnq 3FEJJupjfwuvbfsqRJ7U30KcviFbQdSk0DFdBkt8cOqmSeM72aR7+EPQWXW7muGRtiqR TVQQ== X-Gm-Message-State: AFuF++ncULBNeyp6QDn9xmeZuHJYeUhbQLlYbPIBVq5V5tZWnqOAFLMQ bUJDnUSl7ziDMuYo0ECvh2WE3DrHrACaPjvo+X2q/FlaUIpznYVqQbnsSA0TIJyj+vXrAk6HzRH DLhI3dN4n1QgDRVQP9+B+xUWNKiPwmxlIvckokKD5WkYkPI0KvuNsK7gxDwHBjEi6X5V5TrMSmY e9dBw0FpEKVAOQ8UyAwhHm3fpd1ItXNn8Bag== X-Gm-Gg: AYBFou2yZQHQTh7DaN3qRXv16FlMLPKISPdR/7mptJO7om266fx6DRAgPWe9lwyjKrx iaJ/fhLwB15DiBRYtXb2YnjXf4jWABi4F5ckyohc41k4K8rfjzE+6GoUacXAdvnmdc7VIm+ES3+ ZeH6eBeUFNNQ8U+f6qpS8qyo6k4yWIi6rTViPRAqbc9oGoMqPh+frxoxfNCxlkbmbOytFAm7/4+ 1ANmmkvfJFNTWUqKXLnLpf7sqGWjC925PTh6LAV+2FfrK5++gVuComd3vX/7OMSaNVP4fEngwNo IEsrt9CrNl0nehWeKJ6H+qpMwaHsEmH6aVHr83Izv7Ok44FuLCAglo65DfYCd75kahCbghiUUTP gOW75rgleU4N2G9/skEPOriI= X-Received: by 2002:a05:6000:178b:b0:485:8413:5272 with SMTP id ffacd0b85a97d-486e0f8e741mr8013175f8f.26.1789071187004; Thu, 10 Sep 2026 13:13:07 -0700 (PDT) X-Received: by 2002:a05:6000:178b:b0:485:8413:5272 with SMTP id ffacd0b85a97d-486e0f8e741mr8013110f8f.26.1789071186445; Thu, 10 Sep 2026 13:13:06 -0700 (PDT) Date: Thu, 10 Sep 2026 16:13:04 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Davidlohr Bueso , Igor Mammedov , Ani Sinha Subject: [PULL 39/90] tests/bios-tables-test: Exclude CEDT.cxl for the CFMW restriction change Message-ID: <1bd49555d4287049d06ee0e319ffdf2be41fd6f3.1789071043.git.mst@redhat.com> References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-Mailer: git-send-email 2.51.2.2891.g4157995a80.dirty X-Mutt-Fcc: =sent 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=170.10.133.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com 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, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_PASS=-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-Zoho-Virus-Status: 1 X-Zoho-AV-Stamp: zmail-av-0.2.13.1.5.4/289.74.40 X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1789086643817158500 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Davidlohr Bueso The next patch changes the default CXL Fixed Memory Window restrictions, dropping Back-Invalidate. Add CEDT.cxl to the allowed-diff list so the comparison passes until the expected blob is regenerated. Signed-off-by: Davidlohr Bueso Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin Message-ID: <20260720233242.901544-2-dave@stgolabs.net> --- tests/qtest/bios-tables-test-allowed-diff.h | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/qtest/bios-tables-test-allowed-diff.h b/tests/qtest/bios= -tables-test-allowed-diff.h index dfb8523c8b..b4646b5b31 100644 --- a/tests/qtest/bios-tables-test-allowed-diff.h +++ b/tests/qtest/bios-tables-test-allowed-diff.h @@ -1 +1,2 @@ /* List of comma-separated changed AML files to ignore */ +"tests/data/acpi/x86/q35/CEDT.cxl", --=20 MST From nobody Sat Sep 26 20:50:17 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=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1789084767; cv=none; d=zohomail.com; s=zohoarc; b=ZMxfaujeGdbfnxByC9FBz/HDPAaDiI8hKApwTS8hemwco4qFGRfBC7KwcCd/UAWxfg8/7llfHdVzJT/v06iez6752KI6DBc2ip+6cO3lb8G6ckgj9IXJb4QBr2SOVg47hbQ97odbJI3PTou4qxKpbmm/uKVbusdJPuDyxUpArW8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1789084767; h=Content-Type: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=YYj6Zo8VlXl2zP5B4qr6Yw7Ml5uWH4dbodIZUAM6V0A=; b=LYdoYQnV76kYfb+JWuDLmQhdnkm6um6prICOndwZm0h/yP00GFLQ3mGhG6hm2FUZzj4cOg8AZ8i2hP1Q/LZ/+jgMnzVBTiqweOFxSKgl/JgmgN+LLVgMcjMBlyj6gB1A9Vp/SSExrNmYcTv8YIOPlOS5u5y/nadTN7fw/vxbM2E= 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 lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1789084767467268.91428852620015; Thu, 10 Sep 2026 16:59:27 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1x4oay-0004tZ-9C; Thu, 10 Sep 2026 19:54:27 -0400 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 1x4lWl-0006ax-G5 for qemu-devel@nongnu.org; Thu, 10 Sep 2026 16:38:15 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1x4lWR-0004mn-RS for qemu-devel@nongnu.org; Thu, 10 Sep 2026 16:37:34 -0400 Received: from mail-wr1-f69.google.com (mail-wr1-f69.google.com [209.85.221.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-457-9PpT0C_fMbGwFBa_aix4fg-1; Thu, 10 Sep 2026 16:13:10 -0400 Received: by mail-wr1-f69.google.com with SMTP id ffacd0b85a97d-47d81cf0c4cso68667f8f.2 for ; Thu, 10 Sep 2026 13:13:10 -0700 (PDT) Received: from redhat.com (IGLD-80-230-79-236.inter.net.il. [80.230.79.236]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-486eb350686sm758979f8f.27.2026.09.10.13.13.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Sep 2026 13:13:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1789072581; 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=YYj6Zo8VlXl2zP5B4qr6Yw7Ml5uWH4dbodIZUAM6V0A=; b=Mg4ZDaYoRKfBeqdm21MpmmfPowQO2nXPK38qJryFDByCLxa8Gw97X4J2SOvKBM9KnYDJZ/ dLQaqUl4zXUsSoXxsSq2CcQNbAc3NZw+IfYpzerG79MqW+whyTBH8slTSyv7Sls5ug/TQy 5GSBkmUiU+49Oft0r08JVmE0A+c+mwY= X-MC-Unique: 9PpT0C_fMbGwFBa_aix4fg-1 X-Mimecast-MFC-AGG-ID: 9PpT0C_fMbGwFBa_aix4fg_1789071189 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=google; t=1789071189; x=1789675989; 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=YYj6Zo8VlXl2zP5B4qr6Yw7Ml5uWH4dbodIZUAM6V0A=; b=ZNkf8VBBzkMEiUQ9vW0pCmB8Ws3XcYx4LkcC8kBsDp+g0jFeXUWW995qZkYw5ggtT/ OHJvHTu5aRIr5EYWHMW3hWPvzYBuHmPtB2iJyhaqWZB+29L3BuNAAQ0uYPvtTx9xFwLW lCn80i+xi80CFabvAQZlvHZs2h3rVzQsDJRvw00Q3laitFwGlZ6QqqLlTma0il9dNGgo 3K/kX8lfS9P0lLVo97xANJFYbdHCY3IA4VXTNtkC15FDejBemuaSfNukBt7KijKfztMn gqAeNxIKVCqItm1MgrdhtgkkKi2P4jks3w9u9WV9sNXV61HQSc1toRZrF6L9wFxXNgeS f0Cw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1789071189; x=1789675989; 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=YYj6Zo8VlXl2zP5B4qr6Yw7Ml5uWH4dbodIZUAM6V0A=; b=diqODQi5OvghKXtnEjG4Uz9/xmekJc1RtIxYQaa8E7w3MfDuVejR95R1yQ5SP6Xk9a /Efy0GfsGTKykzAY0Puyb4VMH3mwPu5KfW6bIoNLCSZ8oUQiSWNyamVIZ/TCw8eo8HmU klnOBCMZL7yrCZvpUcche9QA3N/CWulTF2vc/vR+IQtge2kMnSn0GLJFTe3uzoZvG0XY NMnfvSD1dEsQ5VeUHqAfa/8vMp+Okkgg4PWMoOQPGNlF9ocRvPCqC0wOxUjL7l2QBp2F w4PRZAyTbpNxqM1VcAez0BxsMYKe+IstwyFR0bzlF11RzvDzaDqFOn9fq8LV2HJ5PEaQ Bpiw== X-Gm-Message-State: AFuF++mWS6WFZlQ4KYCsq+BRHqEj+ou0Qh61oXeN4AtEEwlM3iAsjLks qJog2xUe1WsKNDB4GqyqkjE+Di9hOIJ7n5YKQMdzTsddT5vi8cW+HsG9T2+urSQmGrfuIhsMQJA tgZMxRZLm+HWS2GgjDfCQmn4favJQfk5P+aYGFu1Mg934KulRH34GeS/swhajqDVi9OfbItR/q5 9r5bHGbzjol3jOhh/dHaOk0VS3DlOhtaV2Nw== X-Gm-Gg: AYBFou003GYzCEcMi9lR3jTd6F8+8zMqML1Jb/Jlm67yA+DSHbb/4eoy81xbvb7tRoc Dt7iguQE5kZx+Ts+aEneI7gRfKAc9qP4X71HK+nAjTDJV/pu4Eib10XQQtQxoWV0ESLsy7R4qBO ZT6Gw/PouS/gsg8KYGgfG2jaBBeTmRJuQonC5ZqTi0A6aA00EpH9PYtn3RRsJpDd0pRMQBfp8uw T3uEVXaXPVjDqkMtoff8ShSAoKzsfzZFn05NPEWb3yL2kLUZK5T7XO+unhQnIT+iwzQM2doYmU9 hkxR88ppATQqzWrwtv6iE0ZHaQ022+Ql0ke2fgOJy0aeHbToYS7FDSA82wIXe07D5PgVl0Ygm8W PbWQHSu5153zIkTw2Z0S2leg= X-Received: by 2002:a5d:4483:0:b0:482:dac8:cd0d with SMTP id ffacd0b85a97d-486eb33ec05mr1074724f8f.21.1789071189221; Thu, 10 Sep 2026 13:13:09 -0700 (PDT) X-Received: by 2002:a5d:4483:0:b0:482:dac8:cd0d with SMTP id ffacd0b85a97d-486eb33ec05mr1074669f8f.21.1789071188697; Thu, 10 Sep 2026 13:13:08 -0700 (PDT) Date: Thu, 10 Sep 2026 16:13:06 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Davidlohr Bueso , Igor Mammedov , Ani Sinha Subject: [PULL 40/90] hw/cxl: Drop Back-Invalidate from default CFMW window restrictions Message-ID: References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-Mailer: git-send-email 2.51.2.2891.g4157995a80.dirty X-Mutt-Fcc: =sent 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=170.10.129.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com 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, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=0.001, SPF_HELO_PASS=-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-Zoho-Virus-Status: 1 X-Zoho-AV-Stamp: zmail-av-0.2.13.1.5.4/289.74.40 X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1789084769801158500 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Davidlohr Bueso The default CXL Fixed Memory Window restrictions advertised host-only coherent together with Back-Invalidate. A window advertising both simultaneously is undefined behavior per CXL r4.0 9.18.1.3. Drop Back-Invalidate from the default, leaving device-coherent + host-only + volatile + persistent. Signed-off-by: Davidlohr Bueso Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin Message-ID: <20260720233242.901544-3-dave@stgolabs.net> --- hw/acpi/cxl.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hw/acpi/cxl.c b/hw/acpi/cxl.c index f92f7fa3d5..75edb2c0a6 100644 --- a/hw/acpi/cxl.c +++ b/hw/acpi/cxl.c @@ -172,7 +172,7 @@ static void cedt_build_cfmws(CXLFixedWindow *fw, Aml *c= edt) build_append_int_noprefix(table_data, fw->enc_int_gran, 4); =20 /* Window Restrictions */ - build_append_int_noprefix(table_data, 0x2f, 2); + build_append_int_noprefix(table_data, 0x0f, 2); =20 /* QTG ID */ build_append_int_noprefix(table_data, 0, 2); --=20 MST From nobody Sat Sep 26 20:50:17 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=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1789073198; cv=none; d=zohomail.com; s=zohoarc; b=Tn9T6ynhw1mY0mpRjqLWnVqykmxqneUG6HsppnbBL8xN09HdCdDlpcbEv72T24HD+lAMP5HN7GZsyipY4ws8vw8z60Q6Crmo8LomfYJw5UFkwNXWl/dl9ghPtHeqFUc1VqbGT9nj2Zx4Z59NleV/vqAL4Ago09MKYr14IWwEQig= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1789073198; h=Content-Type: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=mkq+2WPt2mey0qAVGmB0E6fFgehzww9kQ8e4JC/K6q4=; b=A3roOk3Bd4G1vJX9Q94MmFVl30y5pAk6DP7zeKiYYGyZ9yBcTEwXDu8rXIIj7tMzQ5Vpvy1f/aDe33bO0R8qRDJeeDzYk1+CdOYVin/fN1P9CgRXW0CmSjlhrO7U7lpxS/2nqifCqavbwQWjPZlehprBj04/EJE1sRAerz/+vT8= 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 lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1789073198566877.9871681468546; Thu, 10 Sep 2026 13:46:38 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1x4leS-0008Ij-Sy; Thu, 10 Sep 2026 16:46:09 -0400 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 1x4lGW-00016T-QG for qemu-devel@nongnu.org; Thu, 10 Sep 2026 16:21:13 -0400 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 1x4lG9-0007uy-4P for qemu-devel@nongnu.org; Thu, 10 Sep 2026 16:20:45 -0400 Received: from mail-wm1-f69.google.com (mail-wm1-f69.google.com [209.85.128.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-378-yl0y02OMOJ6-cV-pyfbLYQ-1; Thu, 10 Sep 2026 16:13:12 -0400 Received: by mail-wm1-f69.google.com with SMTP id 5b1f17b1804b1-49991beee7aso1734105e9.2 for ; Thu, 10 Sep 2026 13:13:12 -0700 (PDT) Received: from redhat.com (IGLD-80-230-79-236.inter.net.il. [80.230.79.236]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-49d26be3e35sm94063665e9.2.2026.09.10.13.13.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Sep 2026 13:13:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1789071558; 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=mkq+2WPt2mey0qAVGmB0E6fFgehzww9kQ8e4JC/K6q4=; b=D9OGcfJkqhmtZw49eCTDV01NmzCdqdkd5HHYNijLBSa2S5BMvygZpjOLi7+3IV3vc29cl3 eHbixVkPeqwy2aItoZIid0lrWeg0T2/RWRCR5FgCPy5ls6W55LVAIIcspRZjf93b/4sU1j MkvfjBj+ZXwVE3yh7x2HeiXkW/mf25Q= X-MC-Unique: yl0y02OMOJ6-cV-pyfbLYQ-1 X-Mimecast-MFC-AGG-ID: yl0y02OMOJ6-cV-pyfbLYQ_1789071192 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=google; t=1789071191; x=1789675991; 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=mkq+2WPt2mey0qAVGmB0E6fFgehzww9kQ8e4JC/K6q4=; b=OQG6JbxmYUkHuMmNAsYrN6WIHo3okb/wu86fYon0ty9IGGAb4Cv06pQqo2aoGlbntA S1KuDzP6IflC0ioPcyG+oH9NQANoVJMj1Bt6h2YSS8qxUy+Ix2AMbeIyu2uzWElwdsNP qBcHt0gATWbLdSdoE+8kzjupmlYb8gRG6c3z6x22t49+ohX+NT1zyO1FiKiwdoEUfMfO 0gmLOVaof/bT/zh7afZEpCPBy+2/Hh1Q3BwyHohsmsBgaCP3Ms43QJLlAeV/zeAG6H8E aEpDJMqHnUKMwEqpADzD5dkT9eDBIMzphqnFZRDVax0ukZPXcRtMxAWmXw+rMMse+kd9 KSJQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1789071191; x=1789675991; 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=mkq+2WPt2mey0qAVGmB0E6fFgehzww9kQ8e4JC/K6q4=; b=NAHCw5cRkEaYGaG9iT9+VA+M8APKXLiRYxlkvUUSQKWMj1/GlMJLks3vQPRgxJRYcf bmw7l64MIwImPLdnQlvaO/vm6eAkf0BqmWmJRyVE9/RyovfGAR+x+vbdGvIb/Ue5j7IU 4uJosDjCZgcRGIBRGJ7+9YGFAWqDlFIQHUrbrfk0UttlmT+af4S9Jc7LWIDwGVM1Nigi hZ33Vl0CS8AyE443t0TApBxXYv3sxRs3YT/WDtpJfAYmRx6eNTgqPjglHl2GVRexGv3Z is7f5VvAfaGnQRumRpJTbvnsg6WO/pZTJi7WNynb77xfkgZgQ9dzhFHI7qrl6QpDni3H wAqg== X-Gm-Message-State: AFuF++lgvQCOryrCeQymmkz7q3FdykmbNvWBFaNVEPtkLffc7KOripH7 5dpdG7DyKZlIuylgC8ziPFppPLvHdb6ytla8wBCNNEzE/kvJN6Rhz1aoHMePk/vIOLEIiN10njt ovrIsvMbZPmPvEV5QCTwvsXTxCAinZCAXN92kD/Fqf2uR1borjHjXsxWTNYBfEtjor6mzW+KTSf eIyBMBlju4lZDLbwWyLPWx0OFbEFn0h8Obwg== X-Gm-Gg: AYBFou11ZkCQS0eSwpdQakoXQJ133EY6jr4C5PbAlbU9PcF2esv0r7TVZibZvbuVyMW JmILeoDk811jJ6+csiz5qzozmVrlZXtGhkXmuGLHmwBrXpT9y7TQSBlpAQ8R8mUaNW4+e+T5UTF fENjZMza2it7VzwouDjoxkAUMlXe59lthsSpVARebvuwRVMcvynuc32kusg5PcgESWsNLBgysIe NTK9mdfcQ7tvti51X2adlVSZXkjSpHH27gKY1p/EDqs9X7f6gQ0RNxtcZo2HsOIN5TH79y+QJtn 2eQ4ZapRC/qiu0wjiEGq3NiUuw6h7xamg9dYSmI4RnGPiT528OEauMNI9KcWuRpTKB5SPh3GziV TuejbCY72HEV+8tB4ZmQh5Ag= X-Received: by 2002:a05:600c:3b11:b0:49c:f617:7cf with SMTP id 5b1f17b1804b1-49e61645c2fmr13901405e9.0.1789071191363; Thu, 10 Sep 2026 13:13:11 -0700 (PDT) X-Received: by 2002:a05:600c:3b11:b0:49c:f617:7cf with SMTP id 5b1f17b1804b1-49e61645c2fmr13900805e9.0.1789071190809; Thu, 10 Sep 2026 13:13:10 -0700 (PDT) Date: Thu, 10 Sep 2026 16:13:08 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Davidlohr Bueso , Igor Mammedov , Ani Sinha Subject: [PULL 41/90] tests/acpi/cxl: Update CEDT.cxl for the default CFMW restrictions Message-ID: <2591d8008c932c507f076b635d4071c58e723f5d.1789071043.git.mst@redhat.com> References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-Mailer: git-send-email 2.51.2.2891.g4157995a80.dirty X-Mutt-Fcc: =sent 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=170.10.133.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com 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, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_PASS=-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-Zoho-Virus-Status: 1 X-Zoho-AV-Stamp: zmail-av-0.2.13.1.5.4/289.52.80 X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1789073200582158500 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Davidlohr Bueso With the default CXL Fixed Memory Window restrictions changed to drop Back-Invalidate (keeping device-coherent and host-only), update the expected CEDT to advertise 0x0f instead of 0x2f. [064h 0100 001h] Subtable Type : 01 [CXL Fixed Memory Window = Structure] [065h 0101 001h] Reserved : 00 [066h 0102 002h] Length : 0028 [068h 0104 004h] Reserved : 00000000 [06Ch 0108 008h] Window base address : 0000000110000000 [074h 0116 008h] Window size : 0000000100000000 [07Ch 0124 001h] Interleave Members : 00 [07Dh 0125 001h] Interleave Arithmetic : 00 [07Eh 0126 002h] Reserved : 0000 [080h 0128 004h] Granularity : 00000005 [084h 0132 002h] Restrictions : 000F [086h 0134 002h] QtgId : 0000 [088h 0136 004h] First Target : 0000000C Signed-off-by: Davidlohr Bueso Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin Message-ID: <20260720233242.901544-4-dave@stgolabs.net> --- tests/qtest/bios-tables-test-allowed-diff.h | 1 - tests/data/acpi/x86/q35/CEDT.cxl | Bin 184 -> 184 bytes 2 files changed, 1 deletion(-) diff --git a/tests/qtest/bios-tables-test-allowed-diff.h b/tests/qtest/bios= -tables-test-allowed-diff.h index b4646b5b31..dfb8523c8b 100644 --- a/tests/qtest/bios-tables-test-allowed-diff.h +++ b/tests/qtest/bios-tables-test-allowed-diff.h @@ -1,2 +1 @@ /* List of comma-separated changed AML files to ignore */ -"tests/data/acpi/x86/q35/CEDT.cxl", diff --git a/tests/data/acpi/x86/q35/CEDT.cxl b/tests/data/acpi/x86/q35/CED= T.cxl index c35f3882eee67aa5613af427234d1ccd196aa249..ff8203af070241bd23dd0eb8a51= 460692bb7d229 100644 GIT binary patch delta 36 scmdnNxPy_)+0`Xv2Ll5G (p=quarantine dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1789073571811439.05054513249274; Thu, 10 Sep 2026 13:52:51 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1x4ljw-0001cV-Lf; Thu, 10 Sep 2026 16:51:41 -0400 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 1x4lGn-0001AP-JE for qemu-devel@nongnu.org; Thu, 10 Sep 2026 16:21:30 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1x4lGH-000842-LR for qemu-devel@nongnu.org; Thu, 10 Sep 2026 16:20:58 -0400 Received: from mail-wr1-f72.google.com (mail-wr1-f72.google.com [209.85.221.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-257-4ucjWdRfOUGObBTlRlQq5g-1; Thu, 10 Sep 2026 16:13:15 -0400 Received: by mail-wr1-f72.google.com with SMTP id ffacd0b85a97d-485afdd5079so100703f8f.1 for ; Thu, 10 Sep 2026 13:13:15 -0700 (PDT) Received: from redhat.com (IGLD-80-230-79-236.inter.net.il. [80.230.79.236]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-486eb33ea60sm779458f8f.17.2026.09.10.13.13.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Sep 2026 13:13:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1789071601; 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=bX21n48672hBN8Zfk6zuZxrqxEgRNXLThdAmJPdhE1E=; b=ea0I7HgLrDLUM5tOPd1lY196LYYZ/h6o6ASyIrhTZgkX95Mp2adm/9wWtf4WEC/dJmDrnc J6s8r5StIKwi2oAUx9ibxw07rowMdU1uhyS4wIVu7HVR3QKF1S4YXtkXG6NxMfdufL0WTr jo7MbCgzg/N2TK2UmurQ1msREaip72g= X-MC-Unique: 4ucjWdRfOUGObBTlRlQq5g-1 X-Mimecast-MFC-AGG-ID: 4ucjWdRfOUGObBTlRlQq5g_1789071194 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=google; t=1789071194; x=1789675994; 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=bX21n48672hBN8Zfk6zuZxrqxEgRNXLThdAmJPdhE1E=; b=pfGQ5+h22DgOpecAL1j5KYRoo85mgZ2KTUtbJwvawSA2rdDs3iPRkBDJVBB+gAYOvS hvCNIJ7Jrw76RamDnD37M0HnhJBSUTjpcIzZ2EQFM+yxZWcX1IAPJcJsRAcdM0cRjQqq Yyt9fDwq+T4iz0wDwMw2/xG7dDhM0dRUQDZdJgMrTK2g9JUxcNpbs/Gzt0emgS1ENN+n oMBK58AjS+ouHShV0K8GSvfUnknCNeYcnljT88/j5TsTiLI3e5JEwAN6I0cnFIlGvH0C TemMkpgKN0ivh2Zpa8ZdIg004eo+9mLSXCwl+F3m9GrRkmM0ltAxYKFqsyQIsolj0lFG LIgg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1789071194; x=1789675994; 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=bX21n48672hBN8Zfk6zuZxrqxEgRNXLThdAmJPdhE1E=; b=nzxoV5u5pcSj6zEF0YKuR5zn5VczZqGdcLnnfcKTOmxcE102b6CeoE4jIh6nfYfoME 5/s70oFRo7PDCHFOW9XPtgyBpTFlC3OP+Gk2ItvVOBSeqDSdTY8XdLELz40jfpL4vqQt FEMm4UaNlPBcI5/TvhYtUhncSPU9O35zeKVLre5NQZD4nDRaLLNJ414wGr2ugBVJi1kx hb7WR/yUq5iX0AzP3HzLmzmqEe/XKwKuAJSDCL3qN2Ag/hqPZG+LpU/mvoMyTtbIUECD sIkpDdkT+37YE9p8jEUTSm6vBwRIesigtqxcAzD14bMWJloMYNLvuPndXHQaJfHGtn86 bsfg== X-Gm-Message-State: AFuF++nLL2rJJyqyohRULHYnN2GV1oDsZcXtdm7j1IKrSZyyeTE1Z56s k88g70H5a1qW3otHC6bzbkeO3FyG3VJNDeI9gNgffL8PlxretrEstEofoQ5BE9lBSwDCpxDPvu2 jhuP+CvDZIvP8fKkvfAt3WaeznHf144qxi0WZazO3KoL5tWXHcFawHNqVzesn6VnpxZCWlTXLJL iFkwth4tgXqg6r+L0pyVmLtOHJgYRbfXJ3Yw== X-Gm-Gg: AYBFou3T8HNdkEkYFE16pp6grJqEPa5cBxrJIxvdbCuU91ho2bM8XR+tRQSDelAXiQb oQzg47slT6Y4Vu3Qxove6lxTlndTvOOqL0Nl0w8OEjmNVJnCFv+TahRjJF8/hhxFY0E30xA34oe g1+UXheoufrYSA8fWUQqwbfSpq3xxsUOVczvJYkvx9yGlRkRO0HtAGtt61RCRPucyF63x/m6AnA oUzmGZIiXeKDE+6Pf41gSHGIirlr9sxQeaDjI53gWtPU1V3cIF8tomkh/K6spekUbC878UOEeIz l8HC1kdrwi100blNtqFGfAXpKjT1lNvgLA9p3rSB7CRTRKTXA82nd23FIAkQ91pnoFlXXoAEtab QoAsBmpXQQLqeLioh929hnQ8= X-Received: by 2002:adf:f30b:0:b0:485:8c16:a33d with SMTP id ffacd0b85a97d-486eb34a466mr436148f8f.50.1789071194154; Thu, 10 Sep 2026 13:13:14 -0700 (PDT) X-Received: by 2002:adf:f30b:0:b0:485:8c16:a33d with SMTP id ffacd0b85a97d-486eb34a466mr436106f8f.50.1789071193517; Thu, 10 Sep 2026 13:13:13 -0700 (PDT) Date: Thu, 10 Sep 2026 16:13:10 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Davidlohr Bueso , Pierrick Bouvier , Igor Mammedov , Ani Sinha , Jonathan Cameron , Junjie Cao , Eric Blake , Markus Armbruster , Philippe =?utf-8?Q?Mathieu-Daud=C3=A9?= , Zhao Liu , linux-cxl@vger.kernel.org Subject: [PULL 42/90] hw/cxl: Add configurable CXL Fixed Memory Window restriction flags Message-ID: <1eace36d009bae786bb89399055b55de932b2ac8.1789071043.git.mst@redhat.com> References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-Mailer: git-send-email 2.51.2.2891.g4157995a80.dirty X-Mutt-Fcc: =sent 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=170.10.129.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com 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, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=0.001, SPF_HELO_PASS=-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-Zoho-Virus-Status: 1 X-Zoho-AV-Stamp: zmail-av-0.2.13.1.5.4/289.52.80 X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1789073579086158500 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Davidlohr Bueso Expose the CFMWS "Window Restrictions" (CXL r4.0 9.18.1.3) as named per-window machine properties -- device-coherent, host-only, volatile, persistent, fixed-config and back-invalidate -- so the advertised restrictions can be configured per window rather than left at the default. No changes in default options. HDM-D and HDM-H are advertised by default; disabling one (device-coherent=3Doff or host-only=3Doff) narrows the window= to the other. back-invalidate implies device-coherent (HDM-DB) and suppresses the host-only default. host-only coherent combined with back-invalidate is rejected as undefined behavior per the spec. Signed-off-by: Davidlohr Bueso Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin Message-ID: <20260720233242.901544-5-dave@stgolabs.net> --- docs/system/devices/cxl.rst | 25 ++++++++++++-------- qapi/machine.json | 28 ++++++++++++++++++++++ include/hw/cxl/cxl.h | 12 ++++++++++ hw/acpi/cxl.c | 2 +- hw/cxl/cxl-host.c | 46 +++++++++++++++++++++++++++++++++++++ 5 files changed, 102 insertions(+), 11 deletions(-) diff --git a/docs/system/devices/cxl.rst b/docs/system/devices/cxl.rst index 9d0771cdfd..6bee339cea 100644 --- a/docs/system/devices/cxl.rst +++ b/docs/system/devices/cxl.rst @@ -384,8 +384,13 @@ An example of 4 devices below a switch suitable for 1,= 2 or 4 way interleave:: -device cxl-type3,bus=3Dswport3,persistent-memdev=3Dcxl-mem3,lsa=3Dcxl-l= sa3,id=3Dcxl-pmem3,sn=3D0x4 \ -M cxl-fmw.0.targets.0=3Dcxl.1,cxl-fmw.0.size=3D4G,cxl-fmw.0.interleave-= granularity=3D4k =20 -An example of 4 type3 devices with volatile memory below a switch. Two of = the devices -use HDM-DB for coherence, which requires operating in Flit mode:: +An example of a mixed configuration across two host bridges, each with its +own CXL window. Below cxl.1, two type3 volatile devices behind a switch use +HDM-DB for coherence, which requires operating in Flit mode and a window +that permits the device-coherent Back-Invalidate model. Below cxl.2, two +plain host-only devices are directly attached and use the default window. +Because a window targets a host bridge, giving each coherency model its own +bridge keeps the window-to-device mapping explicit:: =20 qemu-system-x86_64 -M q35,cxl=3Don -m 4G,maxmem=3D8G,slots=3D8 -smp 4 \ ... @@ -395,17 +400,17 @@ use HDM-DB for coherence, which requires operating in= Flit mode:: -object memory-backend-ram,id=3Dcxl-mem3,share=3Don,size=3D256M \ -device pxb-cxl,bus_nr=3D12,bus=3Dpcie.0,id=3Dcxl.1 \ -device cxl-rp,port=3D0,bus=3Dcxl.1,id=3Droot_port0,chassis=3D0,slot=3D0= \ - -device cxl-rp,port=3D1,bus=3Dcxl.1,id=3Droot_port1,chassis=3D0,slot=3D1= \ -device cxl-upstream,bus=3Droot_port0,id=3Dus0,x-256b-flit=3Don \ -device cxl-downstream,port=3D0,bus=3Dus0,id=3Dswport0,chassis=3D0,slot= =3D4 \ - -device cxl-type3,bus=3Dswport0,volatile-memdev=3Dcxl-mem0,id=3Dcxl-mem0= ,sn=3D0x1,x-256b-flit=3Don,hdm-db=3Don \ + -device cxl-type3,bus=3Dswport0,volatile-memdev=3Dcxl-mem0,id=3Dcxl-vmem= 0,sn=3D0x1,x-256b-flit=3Don,hdm-db=3Don \ -device cxl-downstream,port=3D1,bus=3Dus0,id=3Dswport1,chassis=3D0,slot= =3D5 \ - -device cxl-type3,bus=3Dswport1,volatile-memdev=3Dcxl-mem1,id=3Dcxl-mem1= ,sn=3D0x2,x-256b-flit=3Don,hdm-db=3Don \ - -device cxl-downstream,port=3D2,bus=3Dus0,id=3Dswport2,chassis=3D0,slot= =3D6 \ - -device cxl-type3,bus=3Dswport2,volatile-memdev=3Dcxl-mem2,id=3Dcxl-mem2= ,sn=3D0x3 \ - -device cxl-downstream,port=3D3,bus=3Dus0,id=3Dswport3,chassis=3D0,slot= =3D7 \ - -device cxl-type3,bus=3Dswport3,volatile-memdev=3Dcxl-mem3,id=3Dcxl-mem3= ,sn=3D0x4 \ - -M cxl-fmw.0.targets.0=3Dcxl.1,cxl-fmw.0.size=3D4G,cxl-fmw.0.interleave-= granularity=3D4k + -device cxl-type3,bus=3Dswport1,volatile-memdev=3Dcxl-mem1,id=3Dcxl-vmem= 1,sn=3D0x2,x-256b-flit=3Don,hdm-db=3Don \ + -device pxb-cxl,bus_nr=3D222,bus=3Dpcie.0,id=3Dcxl.2 \ + -device cxl-rp,port=3D0,bus=3Dcxl.2,id=3Droot_port1,chassis=3D0,slot=3D6= \ + -device cxl-type3,bus=3Droot_port1,volatile-memdev=3Dcxl-mem2,id=3Dcxl-v= mem2,sn=3D0x3 \ + -device cxl-rp,port=3D1,bus=3Dcxl.2,id=3Droot_port2,chassis=3D0,slot=3D7= \ + -device cxl-type3,bus=3Droot_port2,volatile-memdev=3Dcxl-mem3,id=3Dcxl-v= mem3,sn=3D0x4 \ + -M cxl-fmw.0.targets.0=3Dcxl.1,cxl-fmw.0.size=3D4G,cxl-fmw.0.interleave-= granularity=3D4k,cxl-fmw.0.back-invalidate=3Don,cxl-fmw.1.targets.0=3Dcxl.2= ,cxl-fmw.1.size=3D4G,cxl-fmw.1.interleave-granularity=3D4k =20 A simple arm/virt example featuring a single direct connected CXL Type 3 Volatile Memory device:: diff --git a/qapi/machine.json b/qapi/machine.json index 2d63c1bac3..de6460f091 100644 --- a/qapi/machine.json +++ b/qapi/machine.json @@ -552,15 +552,43 @@ # accesses will go to a given interleave target. Accepted values # [256, 512, 1k, 2k, 4k, 8k, 16k] # +# @device-coherent: Window permits device-coherent (minimally HDM-D) +# accesses. (since 11.1) +# +# @host-only: Window permits host-only coherent (HDM-H) accesses. +# (since 11.1) +# +# @volatile: Window permits volatile memory. (since 11.1) +# +# @persistent: Window permits persistent memory. (since 11.1) +# +# @fixed-config: Window has a fixed device configuration. Advertised +# in the CEDT only; not otherwise emulated. (since 11.1) +# +# @back-invalidate: Window permits Back-Invalidate (HDM-DB). Implies +# @device-coherent. (since 11.1) +# # @targets: Target root bridge IDs from -device ...,id=3D for each # root bridge. # +# Coherency defaults to both device-coherent and host-only; disabling +# one (host-only=3Doff or device-coherent=3Doff) narrows to the other. +# @back-invalidate implies device-coherent and is not host-only. +# @volatile and @persistent default on. host-only coherent combined +# with @back-invalidate is rejected as undefined behavior. +# # Since: 7.1 ## { 'struct': 'CXLFixedMemoryWindowOptions', 'data': { 'size': 'size', '*interleave-granularity': 'size', + '*device-coherent': 'bool', + '*host-only': 'bool', + '*volatile': 'bool', + '*persistent': 'bool', + '*fixed-config': 'bool', + '*back-invalidate': 'bool', 'targets': ['str'] }} =20 ## diff --git a/include/hw/cxl/cxl.h b/include/hw/cxl/cxl.h index d8cd8359d2..7cf3dc622c 100644 --- a/include/hw/cxl/cxl.h +++ b/include/hw/cxl/cxl.h @@ -27,6 +27,17 @@ =20 typedef struct PXBCXLDev PXBCXLDev; =20 +/* + * CEDT CFMWS "Window Restrictions" bits (CXL r4.0 9.18.1.3), advertising + * which capabilities the host bridges below this window support. + */ +#define CXL_FMW_DEVICE_COHERENT (1 << 0) /* HDM-D */ +#define CXL_FMW_HOST_ONLY (1 << 1) /* HDM-H */ +#define CXL_FMW_VOLATILE (1 << 2) +#define CXL_FMW_PERSISTENT (1 << 3) +#define CXL_FMW_FIXED_CONFIG (1 << 4) +#define CXL_FMW_BI (1 << 5) /* HDM-DB, Back-Invalidate */ + typedef struct CXLFixedWindow { SysBusDevice parent_obj; int index; @@ -36,6 +47,7 @@ typedef struct CXLFixedWindow { uint8_t num_targets; uint8_t enc_int_ways; uint8_t enc_int_gran; + uint16_t restrictions; /* Todo: XOR based interleaving */ MemoryRegion mr; hwaddr base; diff --git a/hw/acpi/cxl.c b/hw/acpi/cxl.c index 75edb2c0a6..77c1db6561 100644 --- a/hw/acpi/cxl.c +++ b/hw/acpi/cxl.c @@ -172,7 +172,7 @@ static void cedt_build_cfmws(CXLFixedWindow *fw, Aml *c= edt) build_append_int_noprefix(table_data, fw->enc_int_gran, 4); =20 /* Window Restrictions */ - build_append_int_noprefix(table_data, 0x0f, 2); + build_append_int_noprefix(table_data, fw->restrictions, 2); =20 /* QTG ID */ build_append_int_noprefix(table_data, 0, 2); diff --git a/hw/cxl/cxl-host.c b/hw/cxl/cxl-host.c index 369a985f9b..e279ce5fe3 100644 --- a/hw/cxl/cxl-host.c +++ b/hw/cxl/cxl-host.c @@ -61,6 +61,52 @@ static void cxl_fixed_memory_window_config(CXLFixedMemor= yWindowOptions *object, fw->enc_int_gran =3D 0; } =20 + /* + * HDM-D and HDM-H are advertised by default; disabling one + * (host-only=3Doff or device-coherent=3Doff) narrows the window to the + * other. + */ + if (!object->has_device_coherent || object->device_coherent) { + fw->restrictions |=3D CXL_FMW_DEVICE_COHERENT; + } + if (object->has_host_only ? object->host_only : !object->back_invalida= te) { + fw->restrictions |=3D CXL_FMW_HOST_ONLY; + } + if (object->back_invalidate) { + fw->restrictions |=3D CXL_FMW_DEVICE_COHERENT | CXL_FMW_BI; + } + + if (!(fw->restrictions & (CXL_FMW_DEVICE_COHERENT | CXL_FMW_HOST_ONLY)= )) { + error_setg(errp, "CFMW coherency model required"); + return; + } + + if (object->fixed_config) { + fw->restrictions |=3D CXL_FMW_FIXED_CONFIG; /* no-op */ + } + + /* Volatile and persistent are permitted unless explicitly disabled. */ + if (!object->has_q_volatile || object->q_volatile) { + fw->restrictions |=3D CXL_FMW_VOLATILE; + } + if (!object->has_persistent || object->persistent) { + fw->restrictions |=3D CXL_FMW_PERSISTENT; + } + if (!(fw->restrictions & (CXL_FMW_VOLATILE | CXL_FMW_PERSISTENT))) { + error_setg(errp, "CFMW volatile and/or persistent memory required"= ); + return; + } + + /* + * Reject the undefined and conflicting coherency combinations, + * per CXL r4.0 9.18.1.3. + */ + if ((fw->restrictions & CXL_FMW_HOST_ONLY) && + (fw->restrictions & CXL_FMW_BI)) { + error_setg(errp, "CFMW host-only coherency + BI is undefined behav= ior"); + return; + } + fw->targets =3D g_malloc0_n(fw->num_targets, sizeof(*fw->targets)); for (i =3D 0, target =3D object->targets; target; i++, target =3D targ= et->next) { /* This link cannot be resolved yet, so stash the name for now */ --=20 MST From nobody Sat Sep 26 20:50:17 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=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1789080189; cv=none; d=zohomail.com; s=zohoarc; b=P7OaFn72hpdbyo+4vDGVhJ3cJAD86cYBwHHwlZdqV+MI8o1BkSEahhIZVixzq5IS7jU+hXxjLRyDBqSWXYznb2kFcFmz5P42WLgZ6LmUYeaKQBFA1baTzI4/xwyPuggDWuGQg6gvmFCKqdqJ1x8pBOFK4LQuRHE25hPpwACUUs0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1789080189; h=Content-Type: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=SMrXl840QxHcg/H4ML9GgiuvmC8Z3gLSM3n2uW6G38c=; b=brpW44rwljobZFAtuAV1rUM6sHfyvnZsKVdY9MBJqCbBzdIxweuV5sQxTvl4CIsWgBrWdjgBPA2cQNGbs6pOXI4TjYKaPfG0BhEK2gf6x1ST5y0hwy/rxgXV9wT6Ps7T/wUr50xSvD+xlPdVbFaa2CVtSTvuT4342V3UmZT5HiY= 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 lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1789080189485976.4436146019018; Thu, 10 Sep 2026 15:43:09 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1x4nSG-00019I-GO; Thu, 10 Sep 2026 18:41:29 -0400 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 1x4lJw-0002Pn-EL for qemu-devel@nongnu.org; Thu, 10 Sep 2026 16:24:50 -0400 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 1x4lJp-0000Hv-4m for qemu-devel@nongnu.org; Thu, 10 Sep 2026 16:24:27 -0400 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-394-AWIQKZL3OG-X4-lmGDCpBQ-1; Thu, 10 Sep 2026 16:13:17 -0400 Received: by mail-wm1-f70.google.com with SMTP id 5b1f17b1804b1-4994aebe932so2226675e9.3 for ; Thu, 10 Sep 2026 13:13:17 -0700 (PDT) Received: from redhat.com (IGLD-80-230-79-236.inter.net.il. [80.230.79.236]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-49d26c1bfc1sm116298845e9.4.2026.09.10.13.13.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Sep 2026 13:13:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1789071721; 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=SMrXl840QxHcg/H4ML9GgiuvmC8Z3gLSM3n2uW6G38c=; b=MfMPp1sNwv/GJHV0YyeWinoxDUEwlSyQR72je086FcxvkpqXSt+fU7Z4PTjV6lLAZKt8XV GQ7oOiDCUIYDoS2AmX/XcvmxLSyDaAEzDG6QBKVPGJziCcugV/Fe+v1TC6tCzaJ3Hrz8FW QPk3GSbqw29xG1LS7Wfm6dd23q7DP9g= X-MC-Unique: AWIQKZL3OG-X4-lmGDCpBQ-1 X-Mimecast-MFC-AGG-ID: AWIQKZL3OG-X4-lmGDCpBQ_1789071196 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=google; t=1789071196; x=1789675996; 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=SMrXl840QxHcg/H4ML9GgiuvmC8Z3gLSM3n2uW6G38c=; b=flO3U+IgURz9QcC8ZYyiGrH2sPyVhDJjfX9sUAJ7WPjlS1+stBBq69yW4QGzr3/5SK WJ6Y6LPH6ZQSZRyRcewWePDp5tlALFrKTfLAqCJbWvP0i3YgW2fakv9A13o351WsfiO0 nhU+JM+r2XMTR6NHd2m4hjKlAm1VTAS2ZBpDd0fmGmLLjCZPmKZ7XRb5vr3wv9xYKSqv CK+gflR0Fs9W75ixEX/iMy8BdlnpA644pA9UBOX6MHu/A+hqeMpkPkjBHq3gg855Jhy0 HZU0GEfWxuNdOAHGSv0JxzHsq+5wE2Hf88hY4E9Tg4aqdvdg2Xuc7w8Bc7CM8KQjlISR V7/A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1789071196; x=1789675996; 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=SMrXl840QxHcg/H4ML9GgiuvmC8Z3gLSM3n2uW6G38c=; b=CGFIeOfn6n8VIcMryRwTwDmnl2pPsJL/FGYikp7BkNhhXJMYbfDU+vANCwmPVjTxfY 2m/dEHnULG7LeZ2d1PfhxxDi1Wl857mqTuqA4Hhg7v520rxYivQ9T4n9uE0p1xaHX+OP 4d06gC6GoS6F+5ZJwZNag7268q3RNsQFJZSoS4XybPJoEGxxgDWPjpdCzC3DPYoRknVf xg8fn3SOEGJ06zVygvGSf3XhYD4GSrH2fYaEtx5U+XhONJSn8iq2JlJpS+LaML6qSZMg hHz02mOevFWzRngkbu6gN3Y9WiQG7dDHU2DlkjtUp4Grh7py8LCsl6jGc0+fPFOK4BqT 5A2w== X-Gm-Message-State: AFuF++mEiCoNiJ0lYikGtR4BUnYXDOh5wABXc3R0xf1ehhezZr2NURXC 9Lq2k2/MdRK9XGQffxwNhdyXn3Htd387KAY+jcpUnKSt4zTZza78i2AYvSwkOJcLiiu2S484ZOV 3tF3C4EPJwFpHRFmNcribB2bVJOgXUsEFa097ouHB8WXIFNDUU0l1i9+nuEmMiyVA7ki0KL7B3T MssEQU8V1cr0cJCkqKdC6ed1gpUrwfJStXEQ== X-Gm-Gg: AYBFou1A89QZn4n0aAQ6uEUafBJV64Jy6yVBIDxZDxV7Maw3c4CQ12pXWFG3jLsZ6Z7 O6phfGSvcdu9CRLVYxvDYYJ/SS4qAN9B4jMMNoBKHzwmW+DFqYq3cE5DswnAYAF15MAUz2F00Hr /vCTWVJxfgXJ/xzJ1yFra6OXLvImQmsLi02BUi5JSuJY9CIRH3AV9P51RHsnuAg8igyNtIHEDeH M+wm3PAFeN+oIf1zShh7OU5b7XrUQVY0f/RgrLMs7Thvxv6cE1FZGDMUEBKtyhUImGBnVUzAUgk 5Jp8Xj5sANGhK5t7/WTT0hzUEHTxOj6FZ3tiMYy+AfKYfX0epRKEtWI1cxYY6QQO48QhIpESj6p BY09lKr2KcWLCIHK9VkmWHbc= X-Received: by 2002:a05:600c:b99:b0:499:a277:e8b5 with SMTP id 5b1f17b1804b1-49e619a1c6amr16232825e9.3.1789071196324; Thu, 10 Sep 2026 13:13:16 -0700 (PDT) X-Received: by 2002:a05:600c:b99:b0:499:a277:e8b5 with SMTP id 5b1f17b1804b1-49e619a1c6amr16232135e9.3.1789071195767; Thu, 10 Sep 2026 13:13:15 -0700 (PDT) Date: Thu, 10 Sep 2026 16:13:13 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Davidlohr Bueso , Fabiano Rosas , Laurent Vivier , Paolo Bonzini Subject: [PULL 43/90] tests/qtest/cxl: Add CXL Fixed Memory Window restriction flag tests Message-ID: <8bcc440ac210269c7439b97604efe38dad9f94a8.1789071043.git.mst@redhat.com> References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-Mailer: git-send-email 2.51.2.2891.g4157995a80.dirty X-Mutt-Fcc: =sent 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=170.10.133.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com 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, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_PASS=-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-Zoho-Virus-Status: 1 X-Zoho-AV-Stamp: zmail-av-0.2.13.1.5.4/289.74.40 X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1789080193011158500 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Davidlohr Bueso Add a /pci/cxl/cfmw group exercising the configurable CFMWS Window Restrictions. Signed-off-by: Davidlohr Bueso Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin Message-ID: <20260720233242.901544-6-dave@stgolabs.net> --- tests/qtest/cxl-test.c | 95 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 95 insertions(+) diff --git a/tests/qtest/cxl-test.c b/tests/qtest/cxl-test.c index 8fb7e58d4f..49d820cde1 100644 --- a/tests/qtest/cxl-test.c +++ b/tests/qtest/cxl-test.c @@ -81,6 +81,13 @@ "-object memory-backend-file,id=3Dlsa3,mem-path=3D%s,size=3D256M " \ "-device cxl-type3,bus=3Drp3,persistent-memdev=3Dcxl-mem3,lsa=3Dlsa3,i= d=3Dpmem3 " =20 +/* Single pxb + volatile type3 + one window; base for the CFMW tests. */ +#define QEMU_CFMW \ + "-machine q35,cxl=3Don " \ + "-device pxb-cxl,id=3Dcxl.0,bus=3Dpcie.0,bus_nr=3D52 " \ + QEMU_RP QEMU_T3D_VMEM \ + "-M cxl-fmw.0.targets.0=3Dcxl.0,cxl-fmw.0.size=3D4G" + static void cxl_basic_hb(void) { qtest_start("-machine q35,cxl=3Don"); @@ -117,6 +124,81 @@ static void cxl_2root_port(void) qtest_end(); } =20 +/* + * CFMWS "Window Restrictions" (CXL r4.0 9.18.1.3) are configurable per + * window; check that valid restriction sets are accepted. + */ +static void cxl_cfmw_default(void) +{ + /* No coherency flag advertises both HDM-D and HDM-H. */ + qtest_start(QEMU_CFMW); + qtest_end(); +} + +static void cxl_cfmw_host_only_off(void) +{ + /* Disabling host-only leaves device-coherent (HDM-D). */ + qtest_start(QEMU_CFMW ",cxl-fmw.0.host-only=3Doff"); + qtest_end(); +} + +static void cxl_cfmw_device_coherent_off(void) +{ + /* Disabling device-coherent leaves host-only (HDM-H). */ + qtest_start(QEMU_CFMW ",cxl-fmw.0.device-coherent=3Doff"); + qtest_end(); +} + +static void cxl_cfmw_back_invalidate(void) +{ + /* Back-Invalidate implies device-coherent (HDM-DB). */ + qtest_start(QEMU_CFMW ",cxl-fmw.0.back-invalidate=3Don"); + qtest_end(); +} + +static void cxl_cfmw_fixed_config(void) +{ + qtest_start(QEMU_CFMW ",cxl-fmw.0.fixed-config=3Don"); + qtest_end(); +} + +static void cxl_cfmw_device_and_host(void) +{ + /* + * device-coherent and host-only may both be advertised (the spec + * permits multiple bits set); this must be accepted -- a regression + * guard against reinstating a device/host-only mutual exclusion. + */ + qtest_start(QEMU_CFMW + ",cxl-fmw.0.device-coherent=3Don,cxl-fmw.0.host-only=3Don"= ); + qtest_end(); +} + +static void cxl_cfmw_volatile_only(void) +{ + qtest_start(QEMU_CFMW ",cxl-fmw.0.persistent=3Doff"); + qtest_end(); +} + +static void cxl_cfmw_persistent_only(void) +{ + qtest_start(QEMU_CFMW ",cxl-fmw.0.volatile=3Doff"); + qtest_end(); +} + +/* Two windows in one VM: a Back-Invalidate window and a host-only window.= */ +static void cxl_cfmw_two_windows(void) +{ + qtest_start("-machine q35,cxl=3Don " + "-device pxb-cxl,id=3Dcxl.0,bus=3Dpcie.0,bus_nr=3D52 " + "-device pxb-cxl,id=3Dcxl.1,bus=3Dpcie.0,bus_nr=3D53 " + QEMU_RP QEMU_T3D_VMEM + "-M cxl-fmw.0.targets.0=3Dcxl.0,cxl-fmw.0.size=3D4G," + "cxl-fmw.0.back-invalidate=3Don," + "cxl-fmw.1.targets.0=3Dcxl.1,cxl-fmw.1.size=3D4G"); + qtest_end(); +} + #ifdef CONFIG_POSIX static void cxl_t3d_deprecated(void) { @@ -233,6 +315,19 @@ int main(int argc, char **argv) qtest_add_func("/pci/cxl/pxb_x2_with_window", cxl_2pxb_with_window= ); qtest_add_func("/pci/cxl/rp", cxl_root_port); qtest_add_func("/pci/cxl/rp_x2", cxl_2root_port); + qtest_add_func("/pci/cxl/cfmw/default", cxl_cfmw_default); + qtest_add_func("/pci/cxl/cfmw/host_only_off", cxl_cfmw_host_only_o= ff); + qtest_add_func("/pci/cxl/cfmw/device_coherent_off", + cxl_cfmw_device_coherent_off); + qtest_add_func("/pci/cxl/cfmw/back_invalidate", + cxl_cfmw_back_invalidate); + qtest_add_func("/pci/cxl/cfmw/fixed_config", cxl_cfmw_fixed_config= ); + qtest_add_func("/pci/cxl/cfmw/device_and_host", + cxl_cfmw_device_and_host); + qtest_add_func("/pci/cxl/cfmw/volatile_only", cxl_cfmw_volatile_on= ly); + qtest_add_func("/pci/cxl/cfmw/persistent_only", + cxl_cfmw_persistent_only); + qtest_add_func("/pci/cxl/cfmw/two_windows", cxl_cfmw_two_windows); #ifdef CONFIG_POSIX qtest_add_func("/pci/cxl/type3_device", cxl_t3d_deprecated); qtest_add_func("/pci/cxl/type3_device_pmem", cxl_t3d_persistent); --=20 MST From nobody Sat Sep 26 20:50:17 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=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1789079349; cv=none; d=zohomail.com; s=zohoarc; b=moObfGzLS2FHaNDbTH3LfpIbEPOHq5QrUFNvPXyxQVg84V0ShYNI2yZE5UZj3aoWap3hgslhdDv5gBUhbsIHXFveVJG7Cw+L4hA5vnVU0GvD/+lUkl1gU2ve/F+MGUggdBtDVYoUR6NpjI8oBHOhqVdxKzfeSPMCy4aV/cRTq5k= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1789079349; h=Content-Type: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=QEbTpBGXkapN3DVQGc/Z0YGHeJnV/+deXbNBxtlR344=; b=T8Jy5rerYvt4y23vowgrAeAU4Gd1DN4HRixQZqhB2Eqgo96NFwdEMsK74M1PofjF4oKqTdNrmHOm6wwteAB/Y+Q6MrJvPpqHxuuOs8AcqBlqkn96sKLT6oiXtTinOctv3/FtsjbgmVe/h0BHXRKq9bdM17fE7tDolxw2DutgMzI= 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 lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1789079349378266.964593351075; Thu, 10 Sep 2026 15:29:09 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1x4nEv-0005yx-4F; Thu, 10 Sep 2026 18:27:41 -0400 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 1x4lL5-0002sL-Tk for qemu-devel@nongnu.org; Thu, 10 Sep 2026 16:26:06 -0400 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 1x4lKl-0000Hz-7t for qemu-devel@nongnu.org; Thu, 10 Sep 2026 16:25:36 -0400 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-599-Gq03KTE9PLCd0p480LB_IQ-1; Thu, 10 Sep 2026 16:13:19 -0400 Received: by mail-wm1-f70.google.com with SMTP id 5b1f17b1804b1-49b7c1dc61eso981045e9.3 for ; Thu, 10 Sep 2026 13:13:19 -0700 (PDT) Received: from redhat.com (IGLD-80-230-79-236.inter.net.il. [80.230.79.236]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-49e60ac4397sm19145115e9.7.2026.09.10.13.13.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Sep 2026 13:13:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1789071721; 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=QEbTpBGXkapN3DVQGc/Z0YGHeJnV/+deXbNBxtlR344=; b=KX+WKR4RHZRPMN0aGiXmK5YHfdj3HNBvPxnT7gydNB+0F3b09vfwACDU282pXCvcEco9EQ KYrDT94GM+M1ltwhUMAM/DS8L6dWtaKCaeCSrDVV1qnOTkU0ldEgAnN50HM/nuQLO+Mzyl Svkqik7XWZn9NM424CJHHXGu0/fbreQ= X-MC-Unique: Gq03KTE9PLCd0p480LB_IQ-1 X-Mimecast-MFC-AGG-ID: Gq03KTE9PLCd0p480LB_IQ_1789071198 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=google; t=1789071198; x=1789675998; darn=nongnu.org; h=in-reply-to:content-transfer-encoding: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=QEbTpBGXkapN3DVQGc/Z0YGHeJnV/+deXbNBxtlR344=; b=F2Y6wmDBh70pxYT8g3A8+hwo5OrPOFQoOg1p4v8tbo6Nb37ZnNissi2M9GtB3OO7Dp 1G274lqSX9ve6sE4RzE7Q5hrAdPWSxsUGkf3femOHlUafrukiFqlCvI6ShQTGSESkFtW BD7m0eGTanMCGhLpTjazfCgCemJ0UgmCAvDPpmcZ2P0pFjGjE9x8Lr+ARpU5GdFcnHxS oCqg/N38oaQvboxkGBmdTJpCZtVjHGL5s+tukmGPzA+CpVbMmrJlv6DxGZNoI75eJQhT 8Agi5g7JR2MKa/vRAB7x5Bh/vJsxgHmLUd0tNS5S8eSvbQvSSIz4fjuskt8obbOjpYdt xW1w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1789071198; x=1789675998; h=in-reply-to:content-transfer-encoding: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=QEbTpBGXkapN3DVQGc/Z0YGHeJnV/+deXbNBxtlR344=; b=BWhoGE8DPWnexQ4UkygkPDmA22aNthYrx21AOdCgXXmgp+/XzYf/WyMkjPEP7rBsbP AeZAntnGD15618BPh6dktiIxcKLTJU5HhBrETdfZtSW6Cm2V0J6wjCfVRAKD7jJ3Hh6B hiTYAhgNEMQatIYpfHbuJaot2qir3pjpXrcgUaj0sPpHLFlpjvUYHveQViVKBBqvoDCz CiqQYbVzmL3BlqbCUdRJMiEt3ziJQjQ+6DxPBd0/orVNqrPW7BNLfjIurR2FMj2srOze m225Q6Ks26cdODlB2tI0nkck9tJOgU2loACyw9MCCaRwJ9G4ul3NbRbNW+kEda2rXXdq 4i3g== X-Gm-Message-State: AFuF++m8AFYS5HvgCvbo1DRSgSTcEae7JmUSp7anbSm2MNwk+SUO54+X mKlNZ5zGBKDRldwadaIu8w6IQO5Tbhq8vAZd/hwKIbbRgGhc84dFs7AzZdUW5ANlJNeMaoVHANK ODA8n8YCOWO2Fgs7KXyIlgRQ/DZXSi7+KFNOiA/fxLNUahkamyr3ttvKqkGY3WWJyCsK+cY79KX xBw9PF/89xbKFHOJSbflyT1q+NDVxqPwpllQ== X-Gm-Gg: AYBFou0dO4ErjcNAPbvoAVge22E/NHGxd2A+/M9J3V7iwartyAJ/zsUmxRnNAebHzlR EE/aiaBdH6r7YVacESNmCWXxcZJw3uhOF6RgXzSCkWnWTk62FE9L13iQzeSQam4XfBErHQqbzQ5 u7FJSmlmgOHlzdDa3bvWdwd66ncI0GpKktT1FVUyuip6BWlgJXsCc+wdYLBtk4g7avWgtYx/7vA BI2//svMj7VakKyPVPdwDENyLsATYHLLGcoNTkpM/UT9sHDsQMA2ZS8TY3F50UMrfRWcG4xewYM Jr4Y7bjgqKWK2qU+GldPXeuKomckyAblwgSNSzksgnAjwkmCnJQYnViDuksckyJ4NHawf0Y2np7 b+O1ivdXAG7SRiLhgYlptjWA= X-Received: by 2002:a05:600d:4446:20b0:498:952:e276 with SMTP id 5b1f17b1804b1-49e6198bd8dmr5980035e9.8.1789071198458; Thu, 10 Sep 2026 13:13:18 -0700 (PDT) X-Received: by 2002:a05:600d:4446:20b0:498:952:e276 with SMTP id 5b1f17b1804b1-49e6198bd8dmr5979805e9.8.1789071198005; Thu, 10 Sep 2026 13:13:18 -0700 (PDT) Date: Thu, 10 Sep 2026 16:13:15 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Laurent Vivier , qemu-stable@nongnu.org, Philippe =?utf-8?Q?Mathieu-Daud=C3=A9?= , Jason Wang Subject: [PULL 44/90] hw/net/virtio-net: check packet size before VLAN tag access in receive_filter() Message-ID: References: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Disposition: inline Content-Transfer-Encoding: quoted-printable In-Reply-To: X-Mailer: git-send-email 2.51.2.2891.g4157995a80.dirty X-Mutt-Fcc: =sent 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=170.10.133.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com 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, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, 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-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-Zoho-Virus-Status: 1 X-Zoho-AV-Stamp: zmail-av-0.2.13.1.5.4/289.74.40 X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1789079351667158500 From: Laurent Vivier receive_filter() reads ptr[14..15] to extract the VLAN ID without checking the packet is large enough. A short frame with VLAN TPID at bytes 12-13 but no VLAN TCI causes a 2-byte out-of-bounds read. Add size checks before accessing the Ethernet header and the VLAN tag fields. Cc: qemu-stable@nongnu.org Resolves: https://gitlab.com/qemu-project/qemu/-/issues/3788 Fixes: f21c0ed97c97 ("qemu:virtio-net: Add VLAN filtering (Alex Williamson)= ") Signed-off-by: Laurent Vivier Reviewed-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin Message-ID: <20260722115008.1570510-1-lvivier@redhat.com> --- hw/net/virtio-net.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/hw/net/virtio-net.c b/hw/net/virtio-net.c index 274fbcb0d6..f3f375e1b2 100644 --- a/hw/net/virtio-net.c +++ b/hw/net/virtio-net.c @@ -1751,12 +1751,16 @@ static int receive_filter(VirtIONet *n, const uint8= _t *buf, int size) } =20 ptr +=3D n->host_hdr_len; + size -=3D n->host_hdr_len; + + if (size < sizeof(struct eth_header)) { + return 0; + } =20 if (!memcmp(&ptr[12], vlan, sizeof(vlan))) { int vid; =20 - /* Truncated vlan packet */ - if (size < n->host_hdr_len + 16) { + if (size < 16) { return 0; } vid =3D lduw_be_p(ptr + 14) & 0xfff; --=20 MST From nobody Sat Sep 26 20:50:17 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=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1789073328; cv=none; d=zohomail.com; s=zohoarc; b=ZPBL4CTxzInJi0TjUBcSM/LwYWIy+q+ViAvzBCq6ZHpMXQ5NJ2toExsJ9Kzq6o3RSNULgtSbedn+vWTmEORM/n+ipcHYLDs1qw+0AN+3EvXNa63YpvtdJ+gDFKzK5Pgct8HfQ4PaVmYqLdcwM+l2wYfZlQap8ZyaXCeouY3fYOs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1789073328; h=Content-Type: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=YVWgcLlJ6W5VVT8H262UfAJpSjM0Zse4ulGjykHY0SY=; b=G1bGyhUPPCONW2ifBcr5Zau6doHwOaLOYoejKk5ls4fniCYcuBF1T4bW2CaJC2hp/B2MwjCb7jW0Qi2woRFDEZP0FbWl7GI//NIrdJtMXf2HtQd9j5jPtjXFS2QsFit3uZrmfGsKiqbPQ6XOwbLEOzUURwnnCyHR4VrPFLXVTOk= 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 lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1789073328362581.8896127905437; Thu, 10 Sep 2026 13:48:48 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1x4lgi-0000Zm-Fk; Thu, 10 Sep 2026 16:48:14 -0400 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 1x4lG6-0000wp-J7 for qemu-devel@nongnu.org; Thu, 10 Sep 2026 16:20:41 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1x4lFn-00083j-EZ for qemu-devel@nongnu.org; Thu, 10 Sep 2026 16:20:24 -0400 Received: from mail-wr1-f71.google.com (mail-wr1-f71.google.com [209.85.221.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-635-YGlGfXhRNOKFa9Wj1Ii24Q-1; Thu, 10 Sep 2026 16:13:22 -0400 Received: by mail-wr1-f71.google.com with SMTP id ffacd0b85a97d-47d81cf0c4cso68759f8f.2 for ; Thu, 10 Sep 2026 13:13:21 -0700 (PDT) Received: from redhat.com (IGLD-80-230-79-236.inter.net.il. [80.230.79.236]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-49e60946249sm21236135e9.0.2026.09.10.13.13.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Sep 2026 13:13:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1789071601; 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=YVWgcLlJ6W5VVT8H262UfAJpSjM0Zse4ulGjykHY0SY=; b=Z2oSYus1MVK4pulRwhxr9XQryWS7L2IRU2pftw4C0tlg8vJ0V+IGbX0mFj7QKxiwLbLjmW KjLJlUGRnzRBUU26oRSMymmxJvSvzPoLPbtlfe/tehMZ2pif5dUhMzBiqbshBiNDSr0pGZ tp9lNN7tPNZryVez0kqJklfTyuPf7GI= X-MC-Unique: YGlGfXhRNOKFa9Wj1Ii24Q-1 X-Mimecast-MFC-AGG-ID: YGlGfXhRNOKFa9Wj1Ii24Q_1789071201 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=google; t=1789071201; x=1789676001; 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=YVWgcLlJ6W5VVT8H262UfAJpSjM0Zse4ulGjykHY0SY=; b=LJ2Z6W5UCXv/fEJUMoiC0FP7b/89nQwFuhBKgV7leLxA4vWgsZhH6HIP7vCpKwaKi9 uvNTViB9PTuWK6cOjPCR4NTu7urFm+v35/REEhGdN5d/QQw3oLKaQiWbH73F6kpt8ZPT DFa/la7V1I4kBaJ90c4S/knd9SogWTyqJcwwKkI9ktV1pK/Wa/QLp3E27G0D4Dv3NLdH PL34Q1v2n3HJWQWBCQLZ8JVdGtdtj6WnJG2/AW8vQkWHScmV2dz4L3O71mtoRuXwNbr9 xxRRBxSdc/hBM4VdZ8YSN1vOk/X8/qOh1wVmrXNbcxPqMjQqC/3zsjF6Oe7wuhN6Y4zq UUyQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1789071201; x=1789676001; 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=YVWgcLlJ6W5VVT8H262UfAJpSjM0Zse4ulGjykHY0SY=; b=japSN24y02CnwWTQIPAaOeCag3z/0ETcY2Y08e2sFYPfUvnlD5Gi934xdo2wSgq3pq zYttAQAyX0y9C0I9DNUmSFpiLiy8965rC2WA/jSID/m4AjATihmiIqQJ6/GIE7Bxrreh XGnFLUrGdXcqQ+kvstiWzpYkAhsibF2/R3h6gkOdDMHn49hoV0d9jyA7wKs/JE/FhXRp UrOk3r3DKtRz7j2BrfB7uMObQy82YPTrNo6+/XasQ7xnusUz5HxPeE2WJN1haHuEjfni fX/JtITmr+RBkr/nv6HyvlQGZOo7i6I2y4WnswZBbnvCMiYM4x5mHfbyLExTUl6/Ah+A qf2w== X-Gm-Message-State: AFuF++mSN/Taz3XaXYZj6mOo5KhrWiGh2jjUYdk3npAiuZK91BoZM3YN m6q2w0n5JpYnPrK/YxrrcGARg/5w4l5LxC6XG7W4Eow+PXWgu9yzr9/5lijYcdCefnB+b+CqOVW y1maMQ3ZV7lPdq+/Vfcy4UMXyLftSxpnNJS0QHPhw2akvhlREHg41TO9Xj0NwQH8g5eabY0q9Q3 wFV01+YEVxjx3TP5OBkCFJofjaMYHkg6zIsg== X-Gm-Gg: AYBFou2gbR2Y2Klw/yxrGWQGQMI0roq0iuh2sxuSR3+TEAImkXUgxH7//VAHhEIRQxo 4ciqbOEElpA1nZA3sfAP/CdJEdYMa0Mo+uynGj76TtpuUK+Xr91CM7eDCUH0MzAtgeVSASN7GLy 2YQkUCTWkP9nEE+RYgc01iF+LaHp4kogo/5B6dl5a+Ba8PnztWsY/2oEhUnfE+Qq1shaIWbfPVk 6uSMDcHd5ZA+Q/+Mg+pVPjet7yeJmNffEo8/iAE6TnD5o17JLyw/5ENorenQVRv7VUz4LC9cvE6 2Hyt/CvWq8H14khUI3BFtxLDPytiNjQxtTwA9oBs9zMBncKnTS6snh8Lm6USmpSqil/zcmAOtuM dftFwqEqfi6Pt/jGpN/9uyq8= X-Received: by 2002:a05:600c:8518:b0:49c:edfe:d525 with SMTP id 5b1f17b1804b1-49e619acc89mr19429425e9.10.1789071200722; Thu, 10 Sep 2026 13:13:20 -0700 (PDT) X-Received: by 2002:a05:600c:8518:b0:49c:edfe:d525 with SMTP id 5b1f17b1804b1-49e619acc89mr19428465e9.10.1789071200238; Thu, 10 Sep 2026 13:13:20 -0700 (PDT) Date: Thu, 10 Sep 2026 16:13:18 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Hanna Czenczek , Stefan Hajnoczi , Kevin Wolf , qemu-block@nongnu.org Subject: [PULL 45/90] hw/virtio-blk: Account discard operations Message-ID: References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-Mailer: git-send-email 2.51.2.2891.g4157995a80.dirty X-Mutt-Fcc: =sent 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=170.10.129.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com 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, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=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-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-Zoho-Virus-Status: 1 X-Zoho-AV-Stamp: zmail-av-0.2.13.1.5.4/289.52.80 X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1789073331315158500 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Hanna Czenczek The acct_failed argument to virtio_blk_handle_rw_error() tells whether there is accounting for this operation or not. The only operation for which there is none is discarding, which seems to be because at the time of the introducing commit 37b06f8d46f ("virtio-blk: add DISCARD and WRITE_ZEROES features"), BlockAcctType did not yet have a BLOCK_ACCT_UNMAP variant. It does have that now, though, so we may as well track those discard operations with it, and can thus remove the acct_failed parameter. Signed-off-by: Hanna Czenczek Reviewed-by: Michael S. Tsirkin Reviewed-by: Stefan Hajnoczi Signed-off-by: Michael S. Tsirkin Message-ID: <20260724152315.234183-2-hreitz@redhat.com> --- hw/block/virtio-blk.c | 26 +++++++++++--------------- 1 file changed, 11 insertions(+), 15 deletions(-) diff --git a/hw/block/virtio-blk.c b/hw/block/virtio-blk.c index cb6a276a82..4110380392 100644 --- a/hw/block/virtio-blk.c +++ b/hw/block/virtio-blk.c @@ -69,7 +69,7 @@ void virtio_blk_req_complete(VirtIOBlockReq *req, unsigne= d char status) } =20 static int virtio_blk_handle_rw_error(VirtIOBlockReq *req, int error, - bool is_read, bool acct_failed) + bool is_read) { VirtIOBlock *s =3D req->dev; BlockErrorAction action =3D blk_get_error_action(s->blk, is_read, erro= r); @@ -85,9 +85,7 @@ static int virtio_blk_handle_rw_error(VirtIOBlockReq *req= , int error, } } else if (action =3D=3D BLOCK_ERROR_ACTION_REPORT) { virtio_blk_req_complete(req, VIRTIO_BLK_S_IOERR); - if (acct_failed) { - block_acct_failed(blk_get_stats(s->blk), &req->acct); - } + block_acct_failed(blk_get_stats(s->blk), &req->acct); g_free(req); } =20 @@ -124,7 +122,7 @@ static void virtio_blk_rw_complete(void *opaque, int re= t) * the memory until the request is completed (which will * happen on the other side of the migration). */ - if (virtio_blk_handle_rw_error(req, -ret, is_read, true)) { + if (virtio_blk_handle_rw_error(req, -ret, is_read)) { continue; } } @@ -140,7 +138,7 @@ static void virtio_blk_flush_complete(void *opaque, int= ret) VirtIOBlockReq *req =3D opaque; VirtIOBlock *s =3D req->dev; =20 - if (ret && virtio_blk_handle_rw_error(req, -ret, 0, true)) { + if (ret && virtio_blk_handle_rw_error(req, -ret, 0)) { return; } =20 @@ -153,17 +151,13 @@ static void virtio_blk_discard_write_zeroes_complete(= void *opaque, int ret) { VirtIOBlockReq *req =3D opaque; VirtIOBlock *s =3D req->dev; - bool is_write_zeroes =3D (virtio_ldl_p(VIRTIO_DEVICE(s), &req->out.typ= e) & - ~VIRTIO_BLK_T_BARRIER) =3D=3D VIRTIO_BLK_T_WRI= TE_ZEROES; =20 - if (ret && virtio_blk_handle_rw_error(req, -ret, false, is_write_zeroe= s)) { + if (ret && virtio_blk_handle_rw_error(req, -ret, false)) { return; } =20 virtio_blk_req_complete(req, VIRTIO_BLK_S_OK); - if (is_write_zeroes) { - block_acct_done(blk_get_stats(s->blk), &req->acct); - } + block_acct_done(blk_get_stats(s->blk), &req->acct); g_free(req); } =20 @@ -443,6 +437,9 @@ static uint8_t virtio_blk_handle_discard_write_zeroes(V= irtIOBlockReq *req, goto err; } =20 + block_acct_start(blk_get_stats(s->blk), &req->acct, bytes, + BLOCK_ACCT_UNMAP); + blk_aio_pdiscard(s->blk, sector << BDRV_SECTOR_BITS, bytes, virtio_blk_discard_write_zeroes_complete, req); } @@ -450,9 +447,8 @@ static uint8_t virtio_blk_handle_discard_write_zeroes(V= irtIOBlockReq *req, return VIRTIO_BLK_S_OK; =20 err: - if (is_write_zeroes) { - block_acct_invalid(blk_get_stats(s->blk), BLOCK_ACCT_WRITE); - } + block_acct_invalid(blk_get_stats(s->blk), + is_write_zeroes ? BLOCK_ACCT_WRITE : BLOCK_ACCT_UNM= AP); return err_status; } =20 --=20 MST From nobody Sat Sep 26 20:50:17 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=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1789078428; cv=none; d=zohomail.com; s=zohoarc; b=QLtwolfNaq24RpoCHd+zTSI7OBhu/VZE0ZjuVidQ6dNEWEh64myO/4CerN5el6QNSToIWBST2pURIVMKWrplb7I5s/G21rYoeOanEpsE7wacV9+tw92ps9aqW1BhlOuas8TheC0XZ4w8bOnJFeWQgXcV1mnDg6tde5lUf8ncuJo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1789078428; h=Content-Type: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=3G43obeGkrZrvaSbMOJK2K6rTqOeLtl6zfRvJGCm6co=; b=Z/auIj15uw5PMhOtPRgOE/EXl7B0Cc5XISNGvTDlv8hCAeYRThoTK0Ipo0valegyBEkfjrnFGkJSIJ3/PZLbKdaRPBI/VY991w/UWqXm3IkslMnJmLEH3XDYDnTSfxGhgewRDxCIbb057dXhOE3IcdA74b9jR8kdrLCL3GzYGtA= 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 lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1789078428482152.92109953701458; Thu, 10 Sep 2026 15:13:48 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1x4myR-0001Xz-4e; Thu, 10 Sep 2026 18:10:45 -0400 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 1x4lVV-0006Mb-9Z for qemu-devel@nongnu.org; Thu, 10 Sep 2026 16:36:35 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1x4lV7-0003gP-3p for qemu-devel@nongnu.org; Thu, 10 Sep 2026 16:36:09 -0400 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-679-Xe2MbG3DP4SdOe3CfQbR9g-1; Thu, 10 Sep 2026 16:13:24 -0400 Received: by mail-wm1-f70.google.com with SMTP id 5b1f17b1804b1-49cd55ee2f7so1863605e9.0 for ; Thu, 10 Sep 2026 13:13:24 -0700 (PDT) Received: from redhat.com (IGLD-80-230-79-236.inter.net.il. [80.230.79.236]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-49e60ac42b9sm17723175e9.6.2026.09.10.13.13.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Sep 2026 13:13:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1789072441; 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=3G43obeGkrZrvaSbMOJK2K6rTqOeLtl6zfRvJGCm6co=; b=aYZN3ziRwwdZ4a9BnCKhKDPnmQq2N73eYqogDbV5iaWa7DeBfMzRVdezYVk5aw7oqQd9n5 Bc1+f3NJ6HIokZgiY/DsUZbPJBQ39Cvnj0eo4kk+y9/VkzLkYMJ/tM5r361wMDPh/vIL1t red8qOTqo/c6v3knUwGlm2NXdhQHUCI= X-MC-Unique: Xe2MbG3DP4SdOe3CfQbR9g-1 X-Mimecast-MFC-AGG-ID: Xe2MbG3DP4SdOe3CfQbR9g_1789071203 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=google; t=1789071203; x=1789676003; 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=3G43obeGkrZrvaSbMOJK2K6rTqOeLtl6zfRvJGCm6co=; b=eyDeUTJshDojg6g7gl2wpaqtjlqIQaV9EioaZyLM2bEOtyS1LmuhDdxb6A2OQ1945g dgfILB3n8tVhj8kKGxJ068MWHE62yeV+aZHxURSwlVoAbibOAiutlOisZgpj0y7naPGd Rcdg+hALp97pR52oPl6UVSmu+P1YfPZQ/tzzSnnADfUUoOsV0s/y333RCxE4AXLNNW7E JszJzKeutOK3WCZsD2yS/AWfW82lN86mtTxwblzu04xSiEk277MkZeP82MS9e2FJ6o71 Xi5u3ZJusM4qd2TGvbuBa3K3wgQj+btYtXzXgJriyTE6ZKPDMREIzF33o+FyFFn1JVl5 7JZg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1789071203; x=1789676003; 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=3G43obeGkrZrvaSbMOJK2K6rTqOeLtl6zfRvJGCm6co=; b=geXse2fyhY/0m1hWmKCB2Z3pRAnA2A5NoYj3nxGLgmPmTo4dr81s1oZMUK675BCpGn zFM4bx3etkw8enZPjUwrVzVmzpCbNxH8c2pCAx7OFkXTLHJjjEg1nP38ZuWGwgaZRCFn HwgrfsAH9PY4UHLmy/bXZdUCW4vu7tzON4IGCa2EZjEI6n0jYg1ZujmtRbshqzu9jGvt rr41c6yVfZ3FQMPSCMabtGDuloX/Crjx008kC0VZpvLpNLMOZ2SO81TZGsu4kvO5YJsg fGjC0JybU+MloWQ3VGNLW/1L55TVLfYG+0bGlZQB1BdU0sb/iRaFp1LrFUrHql5a0y/l 47eg== X-Gm-Message-State: AFuF++mgGOIicnIilOWh0Y7dVkP8KyTRSbdk/wDzpIIKDmGlsMdk/F4j oEiq9ccPP4vvVhXKob9d4L/xJtHUnYiOvO1JkmotSlkCfWCHABGIZMdCaebqjhc4c1iuNYpBmvU GX1RON5Ib49uKifnuTLLW8JDWQg1TB5FG22vKhXbcFQivWwnd0p4j90p/3KUmMJ0u73m5cKLdyd L2lIpRVnLLDakwlL9eNOnWp7HaCFURwt+GNg== X-Gm-Gg: AYBFou3b1lDWDU8zyOp62sKcdlOCmeJbIbgyWfwTUplToR18Lj/yCy2ScWH5xMq804R 5JC20xYCuU0pycXmOWaYG5JHdgIebsIZpOupqMx8MqUPx9dZ0oi1GThBV+HNMYDbdbFFk5cboDY ZTKnWBqxkaEDtgL5hXjpEQMD5Vbr/y9GD7YTlEVCzAJy/J87Ql+AuncL4E9gep5vgy9cCRw2+h3 IrICm+PjQyR+PGIr6vnzSHV3OOFcroF8xG28HlyCmF3ppRkCfsLFnX8oHFJbWy/IQQYNvH6emh0 ZBJDnzU/drbNNgXvaWvXuS0lGi3w2Q9Qf9y3dmxYlJpmikek0aD7BA5//mgwpD4961709EQTUfs wq5cmkOeuisvcFZ7ukc+0wUs= X-Received: by 2002:a05:600c:860b:b0:49c:fa21:1c87 with SMTP id 5b1f17b1804b1-49e619d1bddmr6851045e9.28.1789071202974; Thu, 10 Sep 2026 13:13:22 -0700 (PDT) X-Received: by 2002:a05:600c:860b:b0:49c:fa21:1c87 with SMTP id 5b1f17b1804b1-49e619d1bddmr6850615e9.28.1789071202421; Thu, 10 Sep 2026 13:13:22 -0700 (PDT) Date: Thu, 10 Sep 2026 16:13:20 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Hanna Czenczek , Stefan Hajnoczi , Kevin Wolf , qemu-block@nongnu.org Subject: [PULL 46/90] hw/virtio-blk: Complete zone-append cookies Message-ID: <562021c4e4ca62f408728d814ce7290ba35b7e12.1789071043.git.mst@redhat.com> References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-Mailer: git-send-email 2.51.2.2891.g4157995a80.dirty X-Mutt-Fcc: =sent 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=170.10.129.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com 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, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=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-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-Zoho-Virus-Status: 1 X-Zoho-AV-Stamp: zmail-av-0.2.13.1.5.4/289.74.40 X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1789078430592158500 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Hanna Czenczek virtio_blk_handle_zone_append() starts accounting via block_acct_start(), but this is actually never completed. Do so. Signed-off-by: Hanna Czenczek Reviewed-by: Michael S. Tsirkin Reviewed-by: Stefan Hajnoczi Signed-off-by: Michael S. Tsirkin Message-ID: <20260724152315.234183-3-hreitz@redhat.com> --- hw/block/virtio-blk.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/hw/block/virtio-blk.c b/hw/block/virtio-blk.c index 4110380392..61c341ce2c 100644 --- a/hw/block/virtio-blk.c +++ b/hw/block/virtio-blk.c @@ -755,7 +755,8 @@ static void virtio_blk_zone_append_complete(void *opaqu= e, int ret) { ZoneCmdData *data =3D opaque; VirtIOBlockReq *req =3D data->req; - VirtIODevice *vdev =3D VIRTIO_DEVICE(req->dev); + VirtIOBlock *s =3D req->dev; + VirtIODevice *vdev =3D VIRTIO_DEVICE(s); int64_t append_sector, n; uint8_t err_status =3D VIRTIO_BLK_S_OK; =20 @@ -778,6 +779,11 @@ static void virtio_blk_zone_append_complete(void *opaq= ue, int ret) =20 out: virtio_blk_req_complete(req, err_status); + if (err_status =3D=3D VIRTIO_BLK_S_OK) { + block_acct_done(blk_get_stats(s->blk), &req->acct); + } else { + block_acct_failed(blk_get_stats(s->blk), &req->acct); + } g_free(req); g_free(data); } --=20 MST From nobody Sat Sep 26 20:50:17 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=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1789076442; cv=none; d=zohomail.com; s=zohoarc; b=i0vO8jLxKJ/9LUgk9AqreCHwDF81RbgaKGUqBsFw/DkINmDTMx4RhNW/6W/MRPuxY8RgI76ostZYC4wDUkBPquaz3NqeoVtSKNioHbmXj1zPtuwME3lKl4VcKgOyG0MgyhcBeZgrSMZdc2H4wxl5lcagQZTEbEE6rpajr7bpX5o= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1789076442; h=Content-Type: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=S24e5KZkbgytsFsTZMikkKLncaEvmAfRYA/x9bDr/iM=; b=fKDeXFv3EkbLjfLp14Jpb3JDXuLFQYHHWB3sa+hriQWsZmNTt/mLrtFXPw/JXpxbOIyFGm4JxN56A5X8+AoTBJfYA4uk11WgAE9TU1w279aTUYwEdFq1uI/M1pWJvyJvUY48KtzXaBq+itf1OW8Njae40Z3IozG7LS9DS//5EpA= 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 lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 178907644272956.876457761840584; Thu, 10 Sep 2026 14:40:42 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1x4mKP-0001Bt-Ln; Thu, 10 Sep 2026 17:29:28 -0400 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 1x4lMK-00038J-Dn for qemu-devel@nongnu.org; Thu, 10 Sep 2026 16:27:29 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1x4lM8-0000We-Ta for qemu-devel@nongnu.org; Thu, 10 Sep 2026 16:26:51 -0400 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-530-LLgk5h9JM_yE2kAvEpv8ww-1; Thu, 10 Sep 2026 16:13:26 -0400 Received: by mail-wm1-f70.google.com with SMTP id 5b1f17b1804b1-4955e865174so802205e9.3 for ; Thu, 10 Sep 2026 13:13:26 -0700 (PDT) Received: from redhat.com (IGLD-80-230-79-236.inter.net.il. [80.230.79.236]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-49d26c2985dsm162781735e9.6.2026.09.10.13.13.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Sep 2026 13:13:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1789071816; 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=S24e5KZkbgytsFsTZMikkKLncaEvmAfRYA/x9bDr/iM=; b=dZEd15AcRuMVcGSNkGQWWK7zXKjUpERtW/68Wne00BuDCBNHNSr0DbPpOuW5GPKYlTv2h+ wwVKHC6+QnaX0arte949k1720ouJ7EjtA23NB4sZqcfFFyUyELfzrRuBBreu1uQiZo4ynL cvVgVVDBxR7zIlJO4HxfMcVs1KJOM14= X-MC-Unique: LLgk5h9JM_yE2kAvEpv8ww-1 X-Mimecast-MFC-AGG-ID: LLgk5h9JM_yE2kAvEpv8ww_1789071205 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=google; t=1789071205; x=1789676005; 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=S24e5KZkbgytsFsTZMikkKLncaEvmAfRYA/x9bDr/iM=; b=fvzNIOERLyuXvASriJw+4VdjdP7Z1QoutvLriYu2GOOrdbHn8rE6gDbVuxovt1VOvp Wxjy9mqOZmKXvFzbh7nm6pcRAbIjU8lrGbAKLuD6ZQSZtuwHBRwtOWY/c/Nhmhu7VbhS 8P4q3RovVIUYQTiGITXE/ie4WV1+4CND1NXMk30zKtV3mSqghtI0GU3q12ca99EaaF82 SQYkUS9zFH4yqJ62QmvPrFFsX3WyBo01ANS4ydv6hfTRuP5J28HnI0ah3m7zqECJ8VIz QDQCyYKsZ0QsJ2AOsdRKRBn2PPn6dRfPUECpuonjW3Ts+XOExjlFTQ8RHotBnr1fxKcX rvSA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1789071205; x=1789676005; 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=S24e5KZkbgytsFsTZMikkKLncaEvmAfRYA/x9bDr/iM=; b=RDHbMY4MRdDfLadsv8rn644krq5urbBHBsw1aZOskR+lgqzXhTRRjEunrT25DNAwWf bxOeh1Jzrffy8OkBWh/nBYN38fu5CCeycSm54e3Tal5aclpbiJqXCqIQ13R4kR3FiSjK KfU5XPxKQTg9WZvpMU/x8naMtCYj/Qz467rDiLQaxf136MZzSh46YL0msm+csaDZhNX5 OlOj//OyxSCOO6vONSGE/hHF/ebiF+9UPKiiSvezidWDjaZ9zLdd11PEo8gLlYG28Aj3 Ag3t5W8hpm8pr7VTTH9UtDx0DnQG6qO2YmCu2mOdHEnw1T8yaqNIjxWR0pX0VTxbdpcv YnwQ== X-Gm-Message-State: AFuF++mdiKqKJYHN+9wAQbDZI79h3GlPXb2roB5KLs/HI4RW6PbMWttR GvGAy/f+p0fTFkt0Onsz3I3iLe0RSC5DwX+Mpv+SuYvPvzMtYBMvvragY66ipMydXAWBX33vfNh WuWoQNKmjHaSx68SvkP+U+bFkkcg8WtEol5/roIfQjdhpRLe2WoAKOHIJnVrD1pcZ9vAamjA4pE guS0ImnLYGoA/MqbFXH4yS5QK7wSK2dDyFYA== X-Gm-Gg: AYBFou23gd3ylDKF9gkKvgtRUIINvhsGAj/yxTPzvDDMyo83NWJLOE3z1gp25eB+Q7D IgIlyh7mr1YT5e8DNWLtFgTpZyQ/Rpk1ymWjkZxS7CsEyAwWDstEXfAJR0tTsivkOAfebQWHePX 0IMlv2JaYvgHRw+2vx3lcaNYFvZICW+OzQXpvYNU8f38G2swjK0w/26mAE36rjaaXJzo3wA242e YECjH/OCj1sQieKH4uCTyPfb3gSGE4ieENzqeZknCzfWDPJ7vCM55QuJtNJxtY3vHLBXzYiOrJ/ aZHpztjzznaOjDLtyu+8cCPQAouOFzgMf0UQRPWMjgd3DHrxQqb33alorYU4NiJez9lXuaOCGyy ADWw+atZ2DC77VWF9u5Nz2Lk= X-Received: by 2002:a05:600c:8712:b0:49c:ee36:10fc with SMTP id 5b1f17b1804b1-49e619acbfemr7651055e9.8.1789071205383; Thu, 10 Sep 2026 13:13:25 -0700 (PDT) X-Received: by 2002:a05:600c:8712:b0:49c:ee36:10fc with SMTP id 5b1f17b1804b1-49e619acbfemr7650595e9.8.1789071204851; Thu, 10 Sep 2026 13:13:24 -0700 (PDT) Date: Thu, 10 Sep 2026 16:13:22 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Hanna Czenczek , Klaus Jensen , Stefan Hajnoczi , Keith Busch , Klaus Jensen , Jesper Devantier , qemu-block@nongnu.org Subject: [PULL 47/90] hw/nvme: Fix block accounting in nvme_copy() Message-ID: <7e18eb15d941e08f4b6f96f876a412269ab25bb3.1789071043.git.mst@redhat.com> References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-Mailer: git-send-email 2.51.2.2891.g4157995a80.dirty X-Mutt-Fcc: =sent 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=170.10.129.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com 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, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=0.001, SPF_HELO_PASS=-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-Zoho-Virus-Status: 1 X-Zoho-AV-Stamp: zmail-av-0.2.13.1.5.4/289.52.80 X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1789076444308158500 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Hanna Czenczek In nvme_copy(), we start accounting for each of the copied ranges, but only end it once (in nvme_copy_done()). We should end it after each read/write operation is done instead, so they are properly accounted for. We should also actually pass the number of bytes we are reading/writing (instead of 0), and probably account for the metadata operations also, as they are block operations we execute. Signed-off-by: Hanna Czenczek Reviewed-by: Klaus Jensen Reviewed-by: Michael S. Tsirkin Reviewed-by: Stefan Hajnoczi Signed-off-by: Michael S. Tsirkin Message-ID: <20260724152315.234183-4-hreitz@redhat.com> --- hw/nvme/ctrl.c | 53 +++++++++++++++++++++++++++++++------------------- 1 file changed, 33 insertions(+), 20 deletions(-) diff --git a/hw/nvme/ctrl.c b/hw/nvme/ctrl.c index c662d968db..c56725947a 100644 --- a/hw/nvme/ctrl.c +++ b/hw/nvme/ctrl.c @@ -2802,8 +2802,6 @@ static const AIOCBInfo nvme_copy_aiocb_info =3D { static void nvme_copy_done(NvmeCopyAIOCB *iocb) { NvmeRequest *req =3D iocb->req; - NvmeNamespace *ns =3D req->ns; - BlockAcctStats *stats =3D blk_get_stats(ns->blkconf.blk); =20 if (iocb->idx !=3D iocb->nr) { req->cqe.result =3D cpu_to_le32(iocb->idx); @@ -2813,14 +2811,6 @@ static void nvme_copy_done(NvmeCopyAIOCB *iocb) g_free(iocb->bounce); g_free(iocb->ranges); =20 - if (iocb->ret < 0) { - block_acct_failed(stats, &iocb->acct.read); - block_acct_failed(stats, &iocb->acct.write); - } else { - block_acct_done(stats, &iocb->acct.read); - block_acct_done(stats, &iocb->acct.write); - } - iocb->common.cb(iocb->common.opaque, iocb->ret); qemu_aio_unref(iocb); } @@ -2951,6 +2941,7 @@ static void nvme_copy_out_completed_cb(void *opaque, = int ret) NvmeCopyAIOCB *iocb =3D opaque; NvmeRequest *req =3D iocb->req; NvmeNamespace *dns =3D req->ns; + BlockAcctStats *stats =3D blk_get_stats(dns->blkconf.blk); uint32_t nlb; =20 nvme_copy_source_range_parse(iocb->ranges, iocb->idx, iocb->format, NU= LL, @@ -2959,10 +2950,12 @@ static void nvme_copy_out_completed_cb(void *opaque= , int ret) if (ret < 0) { iocb->ret =3D ret; req->status =3D NVME_WRITE_FAULT; - goto out; - } else if (iocb->ret < 0) { + } + if (iocb->ret < 0) { + block_acct_failed(stats, &iocb->acct.write); goto out; } + block_acct_done(stats, &iocb->acct.write); =20 if (dns->params.zoned) { nvme_advance_zone_wp(dns, iocb->zone, nlb); @@ -2979,11 +2972,18 @@ static void nvme_copy_out_cb(void *opaque, int ret) NvmeCopyAIOCB *iocb =3D opaque; NvmeRequest *req =3D iocb->req; NvmeNamespace *dns =3D req->ns; + BlockAcctStats *stats =3D blk_get_stats(dns->blkconf.blk); uint32_t nlb; size_t mlen; uint8_t *mbounce; =20 - if (ret < 0 || iocb->ret < 0 || !dns->lbaf.ms) { + if (ret < 0 || iocb->ret < 0) { + block_acct_failed(stats, &iocb->acct.write); + goto out; + } + block_acct_done(stats, &iocb->acct.write); + + if (!dns->lbaf.ms) { goto out; } =20 @@ -2996,6 +2996,7 @@ static void nvme_copy_out_cb(void *opaque, int ret) qemu_iovec_reset(&iocb->iov); qemu_iovec_add(&iocb->iov, mbounce, mlen); =20 + block_acct_start(stats, &iocb->acct.write, mlen, BLOCK_ACCT_WRITE); iocb->aiocb =3D blk_aio_pwritev(dns->blkconf.blk, nvme_moff(dns, iocb-= >slba), &iocb->iov, 0, nvme_copy_out_completed_c= b, iocb); @@ -3012,6 +3013,7 @@ static void nvme_copy_in_completed_cb(void *opaque, i= nt ret) NvmeRequest *req =3D iocb->req; NvmeNamespace *sns =3D iocb->sns; NvmeNamespace *dns =3D req->ns; + BlockAcctStats *sstats =3D blk_get_stats(sns->blkconf.blk); NvmeCopyCmd *copy =3D NULL; uint8_t *mbounce =3D NULL; uint32_t nlb; @@ -3024,10 +3026,12 @@ static void nvme_copy_in_completed_cb(void *opaque,= int ret) if (ret < 0) { iocb->ret =3D ret; req->status =3D NVME_UNRECOVERED_READ; - goto out; - } else if (iocb->ret < 0) { + } + if (iocb->ret < 0) { + block_acct_failed(sstats, &iocb->acct.read); goto out; } + block_acct_done(sstats, &iocb->acct.read); =20 nvme_copy_source_range_parse(iocb->ranges, iocb->idx, iocb->format, &s= lba, &nlb, NULL, &apptag, &appmask, &reftag); @@ -3102,7 +3106,7 @@ static void nvme_copy_in_completed_cb(void *opaque, i= nt ret) qemu_iovec_reset(&iocb->iov); qemu_iovec_add(&iocb->iov, iocb->bounce, len); =20 - block_acct_start(blk_get_stats(dns->blkconf.blk), &iocb->acct.write, 0, + block_acct_start(blk_get_stats(dns->blkconf.blk), &iocb->acct.write, l= en, BLOCK_ACCT_WRITE); =20 iocb->aiocb =3D blk_aio_pwritev(dns->blkconf.blk, nvme_l2b(dns, iocb->= slba), @@ -3121,20 +3125,29 @@ static void nvme_copy_in_cb(void *opaque, int ret) { NvmeCopyAIOCB *iocb =3D opaque; NvmeNamespace *sns =3D iocb->sns; + BlockAcctStats *stats =3D blk_get_stats(sns->blkconf.blk); uint64_t slba; uint32_t nlb; + size_t mlen; =20 - if (ret < 0 || iocb->ret < 0 || !sns->lbaf.ms) { + if (ret < 0 || iocb->ret < 0) { + block_acct_failed(stats, &iocb->acct.read); + goto out; + } + block_acct_done(stats, &iocb->acct.read); + + if (!sns->lbaf.ms) { goto out; } =20 nvme_copy_source_range_parse(iocb->ranges, iocb->idx, iocb->format, &s= lba, &nlb, NULL, NULL, NULL, NULL); =20 + mlen =3D nvme_m2b(sns, nlb); qemu_iovec_reset(&iocb->iov); - qemu_iovec_add(&iocb->iov, iocb->bounce + nvme_l2b(sns, nlb), - nvme_m2b(sns, nlb)); + qemu_iovec_add(&iocb->iov, iocb->bounce + nvme_l2b(sns, nlb), mlen); =20 + block_acct_start(stats, &iocb->acct.read, mlen, BLOCK_ACCT_READ); iocb->aiocb =3D blk_aio_preadv(sns->blkconf.blk, nvme_moff(sns, slba), &iocb->iov, 0, nvme_copy_in_completed_cb, iocb); @@ -3342,7 +3355,7 @@ static void nvme_do_copy(NvmeCopyAIOCB *iocb) assert(len <=3D blen); qemu_iovec_add(&iocb->iov, iocb->bounce, len); =20 - block_acct_start(blk_get_stats(sns->blkconf.blk), &iocb->acct.read, 0, + block_acct_start(blk_get_stats(sns->blkconf.blk), &iocb->acct.read, le= n, BLOCK_ACCT_READ); =20 iocb->aiocb =3D blk_aio_preadv(sns->blkconf.blk, nvme_l2b(sns, slba), --=20 MST From nobody Sat Sep 26 20:50:17 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=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1789078560; cv=none; d=zohomail.com; s=zohoarc; b=h3t0/+MUcfqLU+WmR8S9Z4urgOl0uRwRKzj88Z5SCRwDrFzl/JYa56OYQX1hx+KoGTOQ/0q+YxB8dbGL4iBPo8TjYigSrInFKQ52MmUD/oLFay/UCgQsiBKWa6/2tB+BNgezGR7AHjFf20CbVgCGGf6iy38acRbdHpkDEKUoEb8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1789078560; h=Content-Type: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=JyVf7JBB2VSLc3TqglYtvlBBQTxI0eqQCJH5aubruxE=; b=jAShgKCTMsoYNx/R6GARd5SJoa1gljalb7o5dXun9g6eZX5j62sJCxJnBJiZk3gnaXX67iUUQh4Gr4amDslopawNByUnNdNofDxxqlXFMU0MhlqiV7N+eMa71ckTsz7YmIfSoHzNZaYL2Ij7RGZ9MUCFMaP3ZPqNeXN28ZAFWmQ= 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 lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1789078560418577.8661179790813; Thu, 10 Sep 2026 15:16:00 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1x4n26-00028V-Qn; Thu, 10 Sep 2026 18:14:30 -0400 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 1x4lW3-0006SY-4B for qemu-devel@nongnu.org; Thu, 10 Sep 2026 16:37:09 -0400 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 1x4lVh-0003Bz-FR for qemu-devel@nongnu.org; Thu, 10 Sep 2026 16:36:48 -0400 Received: from mail-wr1-f70.google.com (mail-wr1-f70.google.com [209.85.221.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-633-ODAcGmFOPiq0eEgTBDDsBQ-1; Thu, 10 Sep 2026 16:13:29 -0400 Received: by mail-wr1-f70.google.com with SMTP id ffacd0b85a97d-482e2541c30so116345f8f.1 for ; Thu, 10 Sep 2026 13:13:29 -0700 (PDT) Received: from redhat.com (IGLD-80-230-79-236.inter.net.il. [80.230.79.236]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-486eb35c071sm757260f8f.33.2026.09.10.13.13.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Sep 2026 13:13:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1789072389; 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=JyVf7JBB2VSLc3TqglYtvlBBQTxI0eqQCJH5aubruxE=; b=V3/cK8x1+daAJPIgaoHnn/9rL8TArOqqUTwryr0ZI/1uVowNKHvKVQpMWYpjNNkl5VXGXz viAcm2sWCdZkFiEJhHnMTqZvV3/99KnVubxFFqEQiSmM2si0W3hiWnEFMNujTBzkMv+GDQ C8c5iMmPZZxOClUYyuO2otemxzLDtiU= X-MC-Unique: ODAcGmFOPiq0eEgTBDDsBQ-1 X-Mimecast-MFC-AGG-ID: ODAcGmFOPiq0eEgTBDDsBQ_1789071208 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=google; t=1789071208; x=1789676008; darn=nongnu.org; h=in-reply-to:content-transfer-encoding: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=JyVf7JBB2VSLc3TqglYtvlBBQTxI0eqQCJH5aubruxE=; b=V9kXaWkIgOCWYdxO6NgARwbx9TAV9iF+44MPrVrzhsgK/y6P+XksJgWC3pFkPPD1Q0 l7g2tBRLRzd9+dFkE3duF01wPuywYhEwoKMUSXQF0by1YkV7oLSEszupfIXoRSBvhc1e blaVckKPLXxvD32BhQX9A0sLxzQDJHQ+nff3/FrSz29GRTgpfPDDfuF3Q3Mw8dRTYuzH B6m/soCC/6SU7J7fjfzblSejCv1Q+FWHGIlYGXNGAeIBWGnzsBsElSfvjkO67vlM+7Ns V1gsN/97a7v/NOPIUqqKzu2XKwAdmZwscNPt39zwwiy3p5JVEHj7zSM4dv55gh3AcxYY iT5w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1789071208; x=1789676008; h=in-reply-to:content-transfer-encoding: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=JyVf7JBB2VSLc3TqglYtvlBBQTxI0eqQCJH5aubruxE=; b=Uo6BBPDqTmPsr1AOTTOS8V+cpJINZATdy0D7oI367E+syoXckXaM7zGDcmkooCfUeN Xx+1IIfabwioKPj8TtoT8Unv9Ac3IdTOEOQ1luH+8K9Cfm6h18rbYX43FKWJPPm5wLze 0SeaOCaDlYcDvgpOct9PiMypZKKX/zBfubscVYgEk8atDJ88RfWmFlu5OCmCkHcLWWA0 KeGR6yzXcJvl6Qk4y6fzryAzlzhDTYkfX9f1Y8AEkjLmCmMYsMKUtdaaFU+odOYuwvwB MkaA/3Kfd9C1NeRCMckMjF+NZ66IYJSh6MhmK3V28XfnpxWQ0ZJV01q4A1tHWPPqtRBE JUwg== X-Gm-Message-State: AFuF++mAdO8vESziM14LP2QP5QJACvZcw0Oq5o9DGF9X8LP+0KD3EZuQ +3JOvVwh9mJtdOJiqjAj7YZHeZCM6aKVi07CWYfAVwWLbsYB7CpymUP19tP0Mxh/fF4E2CLUC/m h2pvlhOkY+aBoXkZbhwCBy37U10Uewgln4/YCMb6KJNBZKJiFh8BtBMwPvUK/i4GTsLMOO4v8Vv VSrIbpjt+Sun2vtmETmxwmmQDXsrY9TUhkKw== X-Gm-Gg: AYBFou1WNMTOrUI/XD58XBs1bB37QfyzeqgxcT2ArJteNqL5busnbGLnrj7dc2qRNDo wnNEH2+fiZbMWAwhryPRQxQ2KSvSiPsq5eTlNy9oFn2fEnRB5bc4P3XAAqyOjHsnKOIVtIEGUBQ u9IOU1t4Xf8AuYO/7c2AJQ2SkQUkwc+e22VYamFTzEL5k9mdqhr11C+j3KUDOEnSW3FUvFdeuVr PmuOqk5uOGgnaS1MONM+s6+mdZnG5SuWSd57rRJkBsvhj+uQg9IozJGu/wEYxmSqNGAWoBCsWFz aPKcdJflupIKghEwRmT4Nv+6nstJybpQemyd+4SwipWfPNSivPcOXWY/nrVFFd+sS9CXLneTP7i f5fxj8vY9bkUUrE9bgPxsiTY= X-Received: by 2002:a05:6000:384:b0:484:42d7:50fe with SMTP id ffacd0b85a97d-486e9356aadmr1226758f8f.4.1789071208159; Thu, 10 Sep 2026 13:13:28 -0700 (PDT) X-Received: by 2002:a05:6000:384:b0:484:42d7:50fe with SMTP id ffacd0b85a97d-486e9356aadmr1226717f8f.4.1789071207458; Thu, 10 Sep 2026 13:13:27 -0700 (PDT) Date: Thu, 10 Sep 2026 16:13:25 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Hanna Czenczek , Philippe =?utf-8?Q?Mathieu-Daud=C3=A9?= , Klaus Jensen , Stefan Hajnoczi , Keith Busch , Klaus Jensen , Jesper Devantier , qemu-block@nongnu.org Subject: [PULL 48/90] hw/nvme: Fix block accounting for compare Message-ID: <1a4014a9621f7be9b4231a337924078b66a615e1.1789071043.git.mst@redhat.com> References: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Disposition: inline Content-Transfer-Encoding: quoted-printable In-Reply-To: X-Mailer: git-send-email 2.51.2.2891.g4157995a80.dirty X-Mutt-Fcc: =sent 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=170.10.133.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com 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, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, 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-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-Zoho-Virus-Status: 1 X-Zoho-AV-Stamp: zmail-av-0.2.13.1.5.4/289.74.40 X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1789078562393158500 From: Hanna Czenczek nvme_compare() starts block accounting for the operation, but nvme_compare_data_cb() (and nvme_compare_mdata_cb()) do not always finalize the cookie. Specifically, there are a lot of error paths that do not call block_acct_failed(). Fix this by putting block_acct_done()/block_acct_failed() under the `out` labels of nvme_compare_data_cb() and nvme_compare_mdata_cb(). Signed-off-by: Hanna Czenczek Reviewed-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Klaus Jensen Reviewed-by: Michael S. Tsirkin Reviewed-by: Stefan Hajnoczi Signed-off-by: Michael S. Tsirkin Message-ID: <20260724152315.234183-5-hreitz@redhat.com> --- hw/nvme/ctrl.c | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/hw/nvme/ctrl.c b/hw/nvme/ctrl.c index c56725947a..7478f0b33a 100644 --- a/hw/nvme/ctrl.c +++ b/hw/nvme/ctrl.c @@ -2389,7 +2389,6 @@ static void nvme_compare_mdata_cb(void *opaque, int r= et) trace_pci_nvme_compare_mdata_cb(nvme_cid(req)); =20 if (ret) { - block_acct_failed(stats, acct); req->status =3D NVME_UNRECOVERED_READ; =20 trace_pci_nvme_err_aio(nvme_cid(req), strerror(-ret), req->status); @@ -2444,9 +2443,14 @@ static void nvme_compare_mdata_cb(void *opaque, int = ret) goto out; } =20 - block_acct_done(stats, acct); =20 out: + if (req->status =3D=3D NVME_SUCCESS) { + block_acct_done(stats, acct); + } else { + block_acct_failed(stats, acct); + } + qemu_iovec_destroy(&ctx->data.iov); g_free(ctx->data.bounce); =20 @@ -2474,7 +2478,6 @@ static void nvme_compare_data_cb(void *opaque, int re= t) trace_pci_nvme_compare_data_cb(nvme_cid(req)); =20 if (ret) { - block_acct_failed(stats, acct); req->status =3D NVME_UNRECOVERED_READ; =20 trace_pci_nvme_err_aio(nvme_cid(req), strerror(-ret), req->status); @@ -2513,9 +2516,13 @@ static void nvme_compare_data_cb(void *opaque, int r= et) return; } =20 - block_acct_done(stats, acct); - out: + if (req->status =3D=3D NVME_SUCCESS) { + block_acct_done(stats, acct); + } else { + block_acct_failed(stats, acct); + } + qemu_iovec_destroy(&ctx->data.iov); g_free(ctx->data.bounce); g_free(ctx); --=20 MST From nobody Sat Sep 26 20:50:17 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=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1789078838; cv=none; d=zohomail.com; s=zohoarc; b=A+v+TkfPMAbJi9ev4gWEcur/CizmrKewK0gpAlmLFHo5L676BZKf4Ps1bNlEG3AnfPJ2yzvWdSNNhyH0oWlqxfkC0WGYmoZpmw3gzaeCw9n0ZHtaX9eJ9fmkgTSjfr4UOLnvwf+tvEVEiDXSmON0k5XXHJPB+julcdT4M8Tf2vU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1789078838; h=Content-Type: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=wqIBh6wrg3/cCLBO/xish158SNEF5YQcKd9WgGS4UWY=; b=bR3tpOBSy3yo7eSK4cVixpsQtu5tttag01KoeVAPi7hfN5qUKzR8qPlwspwttqMRrtG4djilMRnUVLSEUuEmG3gp2+A3Kn64vq+Zb0XsxWu1C7RNgQXa4ES7sAklt+0zx9/2EJQgtOwBc5rdtgaGiBHYmxlCRrpQnAUm3eX3Qlg= 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 lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1789078838474462.90215289192747; Thu, 10 Sep 2026 15:20:38 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1x4n7R-00041t-G3; Thu, 10 Sep 2026 18:20:00 -0400 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 1x4lWs-0006bm-KK for qemu-devel@nongnu.org; Thu, 10 Sep 2026 16:38:15 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1x4lWS-0003gO-4R for qemu-devel@nongnu.org; Thu, 10 Sep 2026 16:37:35 -0400 Received: from mail-wm1-f72.google.com (mail-wm1-f72.google.com [209.85.128.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-31-ymP0DvhPPHKdWExvqlcJZQ-1; Thu, 10 Sep 2026 16:13:32 -0400 Received: by mail-wm1-f72.google.com with SMTP id 5b1f17b1804b1-4994cf6cdb9so1573155e9.3 for ; Thu, 10 Sep 2026 13:13:32 -0700 (PDT) Received: from redhat.com (IGLD-80-230-79-236.inter.net.il. [80.230.79.236]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-49e60aba026sm19984575e9.3.2026.09.10.13.13.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Sep 2026 13:13:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1789072441; 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=wqIBh6wrg3/cCLBO/xish158SNEF5YQcKd9WgGS4UWY=; b=aAGF1sKxfPkvbGa6cB0yiD8brKNmhBJI9gDMONFdgoMBvWLA45Ii/hn0Y8aFfc42XA8Sl2 J7TKzNpNtBoRtOGiqNyTQaMi+pXSIPeBQ/3txxm5QGkJt68A0qhQ3Vb1DB6FrKCuIJ/ubK Uh+g/QN1Y4fQ3f45rh/HJY0T+uF8ids= X-MC-Unique: ymP0DvhPPHKdWExvqlcJZQ-1 X-Mimecast-MFC-AGG-ID: ymP0DvhPPHKdWExvqlcJZQ_1789071211 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=google; t=1789071211; x=1789676011; 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=wqIBh6wrg3/cCLBO/xish158SNEF5YQcKd9WgGS4UWY=; b=qFcpfCtTIDGR6htxUlVmUtvdzWtZXXgfNo2X1PD1az+tE0ZRuuGLaUMRBmCjBGFhlC EimLhm1DXsea011Ou2l7aWedBw0BjUHdmeZ68d0kfi8VhHSbXHlngeRNxA12mKdWl0BD 5Dx6MzKTrB6EL0O9TRC50goGt9mryC8fF+KHg59w/zOVzsVV/M38D/zMbdx4HBMJFjTI THGUpBc7L5Duz4F1jz2ufsv+BNcRFPq+iZy7pdJLH81vtOHaL8vb75OjhMTevc49pFRl ur7zDKEjJixwHVbrMmv6Vey/pIrRBvcPugPhJBzKuUM19T2HstQ+fCyE11UBFPN4bIWE 3Otw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1789071211; x=1789676011; 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=wqIBh6wrg3/cCLBO/xish158SNEF5YQcKd9WgGS4UWY=; b=lE3jS9iooeNbMecJBB72k0RIj2j9xSST+Eoe6XgKncJzfKRYZDp2cUfjQ3bf1T61oZ Ggn4H4vDzOF6gVA3k5wgJCEWIXLeKWGvmwiWPsMLxGiIHWZnIQGada3TOzDIBXkLbWmN QFEOw0g3S17mrGKNRwCfNb+iEcWrjX46RWcEatJ4hvXmcHYSz1o8UO0rG2Ng0PQGQQVk +XS4sH/Z3zCEcANUZ/LM4yhv35U+OSUPp8Ai512tdZ4SAv1mY8PAl90chAP5ik9Emw18 OJwK4HisWnLr21QcVb+u54axkImS9LVI5vpjWSHHciQHKlRwBdJ5T3g+y/ySY/8e62Gz BNTw== X-Gm-Message-State: AFuF++l3zlwBczKkwxVutQYgNF4K1gUPx34CqBPwTrLS7s1n/00QsBUm ENXSYPJGDQsWGcn2h9fYy7Wx+Cqrx3uhoi+Jk2OukPPKVHv7GU26p8oFaECQi7s8eyFYAq/I1+e fuY+Xki8wSKbWxUu56trUb80QhiDyT0O2qxh7ojOpRgRF4xb9Eg2ssSy0vYFRTXigOHnpYfnv1n LXVCAukWeS3VRr/2Eek9a/AV2713Q5Yvzp6A== X-Gm-Gg: AYBFou3NO8+gwlt3cLHxWvNicTO8M94C0izGfOU/vzvviTNgpTtSvQlDO1speKTh55Q a36/SaGpD2PL0b8ll2bU5504Kiaiavy07iA216na28W/jIHHbk3HbB7vGd3N4dB4soS3xp+Kp3y 3M+/4dZzI6DVowLEx7DuyF6NUfm80kKCaQ87hk5nU38+OabOQ2DWdN3AnOgg5VUFJBh0Rb3SbnG 4A+fRaiZqlqlVku/X4uD3wXqyGLZgJMy79Y0dywETzzTm1EHdrb/pfiQvjFkXW5xZHi2BpF4m/w mQRq7s8rNXPp2N1nFB681mRVZxPM0L7Agc85C5dgRFvYU8AIMfhB5pWlKuA4Lh4K9IKk8sIl/ee IIiNRd5IpUbFyVQVMSREMUrk= X-Received: by 2002:a05:600d:8649:10b0:49c:e1cd:536 with SMTP id 5b1f17b1804b1-49e61988908mr5905755e9.12.1789071210942; Thu, 10 Sep 2026 13:13:30 -0700 (PDT) X-Received: by 2002:a05:600d:8649:10b0:49c:e1cd:536 with SMTP id 5b1f17b1804b1-49e61988908mr5905485e9.12.1789071210529; Thu, 10 Sep 2026 13:13:30 -0700 (PDT) Date: Thu, 10 Sep 2026 16:13:27 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Hanna Czenczek , Stefan Hajnoczi , John Snow , "Denis V. Lunev" , qemu-block@nongnu.org Subject: [PULL 49/90] hw/ide: Have ide_dma_cb() complete accounting Message-ID: <125d3d551e07dcbbb79cb1b4ff83bd4120f09278.1789071043.git.mst@redhat.com> References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-Mailer: git-send-email 2.51.2.2891.g4157995a80.dirty X-Mutt-Fcc: =sent 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=170.10.129.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com 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, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=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-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-Zoho-Virus-Status: 1 X-Zoho-AV-Stamp: zmail-av-0.2.13.1.5.4/289.74.40 X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1789078840881158500 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Hanna Czenczek ide_sector_start_dma() starts accounting for reading and writing, and ide_dma_cb() is supposed to complete it, but currently does not always: In one case, it just forgets it altogether, in the other, it uses block_acct_invalid(), which should not be used after a cookie has already been created. Signed-off-by: Hanna Czenczek Reviewed-by: Michael S. Tsirkin Reviewed-by: Stefan Hajnoczi Signed-off-by: Michael S. Tsirkin Message-ID: <20260724152315.234183-6-hreitz@redhat.com> --- hw/ide/core.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/hw/ide/core.c b/hw/ide/core.c index ef573798d9..06e6bb6067 100644 --- a/hw/ide/core.c +++ b/hw/ide/core.c @@ -898,6 +898,7 @@ static void ide_dma_cb(void *opaque, int ret) =20 if (ret =3D=3D -EINVAL) { ide_dma_error(s); + block_acct_failed(blk_get_stats(s->blk), &s->acct); return; } =20 @@ -968,7 +969,7 @@ static void ide_dma_cb(void *opaque, int ret) if ((s->dma_cmd =3D=3D IDE_DMA_READ || s->dma_cmd =3D=3D IDE_DMA_WRITE= ) && !ide_sect_range_ok(s, sector_num, n)) { ide_dma_error(s); - block_acct_invalid(blk_get_stats(s->blk), s->acct.type); + block_acct_failed(blk_get_stats(s->blk), &s->acct); return; } =20 --=20 MST From nobody Sat Sep 26 20:50:17 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=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1789082109; cv=none; d=zohomail.com; s=zohoarc; b=ahwyFCtWxq4jTCC7rTzvoEwNwdzP+XlKQJH7IY9I0Mk3ThvFPzWTlCW5/56n5od1JBP2EMIU3ay0ZWGnxQcHjBqK3PJ+440IuqII8gCy8JhqVOiwPlIy8SkevQtorQ1UH0DqS6oHuU5kzvCJ/y/YNu2B49r2NXP/A+EAREsPA/c= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1789082109; h=Content-Type: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=wnxtJwJv6yUaxvWZxIjniMMKZkL70PYqB4D9wt2Y1j8=; b=aHGt8N1RtABxy4QGrUVlAp6Y3AZPLCoDm7sOW9MOHBSW/sjUhl6dvx/QOCQdFlwyuU1PQ1xcuHajv1cHAilI5o8/ATiC8RrWWFchEo2QeKO6ymjOdC/gXASh3ZnUoJqMKUqeWHwihWW2Ml2zoZVvZersdQtntC14zoj5yw6vRnM= 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 lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1789082109985777.3361391474984; Thu, 10 Sep 2026 16:15:09 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1x4nnj-0006ik-Gg; Thu, 10 Sep 2026 19:03:46 -0400 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 1x4lPT-0004IU-7q for qemu-devel@nongnu.org; Thu, 10 Sep 2026 16:30:33 -0400 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 1x4lOM-0001OP-Un for qemu-devel@nongnu.org; Thu, 10 Sep 2026 16:29:16 -0400 Received: from mail-wm1-f71.google.com (mail-wm1-f71.google.com [209.85.128.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-616-pw0JO46NNDGiX9GwiPj1ww-1; Thu, 10 Sep 2026 16:13:34 -0400 Received: by mail-wm1-f71.google.com with SMTP id 5b1f17b1804b1-495474a5fbcso2083445e9.1 for ; Thu, 10 Sep 2026 13:13:34 -0700 (PDT) Received: from redhat.com (IGLD-80-230-79-236.inter.net.il. [80.230.79.236]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-49e60ac4397sm19161225e9.7.2026.09.10.13.13.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Sep 2026 13:13:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1789072084; 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=wnxtJwJv6yUaxvWZxIjniMMKZkL70PYqB4D9wt2Y1j8=; b=OIMNGTwZF63l4ZtaKra18IlwsDGZC58zdth8iAewv2VvMIqm0+ny+atCvrIO8TYK4S6zmT ldR2vR+gnLQbcfUT7glNzMLg2YmEUDWCLDqCyDICigVeG0FgitarpuYtSSNn3u8pa3v5hM h68pcMsl9mCVrvKPfTVbORvRHvZrUPg= X-MC-Unique: pw0JO46NNDGiX9GwiPj1ww-1 X-Mimecast-MFC-AGG-ID: pw0JO46NNDGiX9GwiPj1ww_1789071213 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=google; t=1789071213; x=1789676013; 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=wnxtJwJv6yUaxvWZxIjniMMKZkL70PYqB4D9wt2Y1j8=; b=eaEONQ7+AUtUhH+vgIfJpClq5hvTOfMaM6qO/i/Bza36eMhLzKbfqh/L/B6wmB7LbP xIoQ5MAdzOvuJaD9iu0uz6ez8fAYlagMMo5N/dsuQxVBo1374kSSR8ZRq11GjanE0GNY Jh9xuLC2wfa0wTP5d0qdQ7Pa5+kJNcII+vfuL+NpVQ7BkkjEBvVwTpdoA0oL6XIgocu1 WZgPKgAIl0uD55gTzQFcdxbUb5TAKJcGfO54cIRNEqVCopoAVM/AXDbuX49jDkFhwfgl 2/LQ/IlNaObJ7IG6GNtUYKKEw0nxm/HP/1/DKJaV5SdVq3uudj21EDhW+0+ZC5AIYDcU qsNQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1789071213; x=1789676013; 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=wnxtJwJv6yUaxvWZxIjniMMKZkL70PYqB4D9wt2Y1j8=; b=HA4FQyFVw8ylN/oWYibjcXC86YjrjBpfG9y6KMJIjtZ8Ttm3qeL22hThLBpMm19ac0 RQ7GXZ5j4Wx6nrCp47BM4C+EAPi0zBvCbzMJd/dI00+vPAAoMyjH/pm3mh40T2PraDqp Ei3cWLJXVbRjsac8ut7XqGSuR8sAP95/6dxtwNbrQBGQK4M2xAikrDu9ij0q4qsXYSM/ vjjOT1KANKInnvXQoj5aYSdBVyGus2IxM2g63vRtzrpyv45at05DWUAAxBF8Mjx7yoTB hNecixjhAzl05+OL1LKFS2SPcUEdpo32jGt4394lGy4TdBcFLSqKDxDNUAvV48eXOnwH OmwQ== X-Gm-Message-State: AFuF++k094/U7Kh3VvVzMbEos2JaLlJHuChl4IIYe6DnpP3B6abvXmrl JytgrxrjLJNSi+pR3AfYYT52rctGw6/v0YPjV6YM7RjoWwNNLCs06zkEVTxT624HaV2MI8yJCMl 8DeJ+tZK7CHJFnDF9VVGIPvNoFyHjpbY7D5cmUO4n0bwJoA8TRzOMsUEYqzlzswq5E9IVL//4ge xbye9fTh80BG7s7/EhqapBxBb2k/c2KAnDDQ== X-Gm-Gg: AYBFou1njtzTe32Y7fj93ExedkJoKKymst9vk+x16G3m1sE6JTktWB4yotpQUUzkyuz IW4IlE+qiwZxzrSWMWnBBIupapMG4bxuzZTBf0ycr7yVc3sLIgv8TqEwqkR6LddI5m+rclAQVKm 9jHA+rrbmp+O8zraa7Qtc6rTN1UH3LN7JLEsINLmpr/h0tNmv1OXaPYWQTO3/7Av66283conReC /hLm6dDl9LLRtgr1+Jzefo++bIb6Mn4Op/UPjilTW/Rbv9wVDrIrG1xUihb/PZk7yK1hwe+HDYm w4yhugoRplNwh5vDb1ddGdRX/4Cx25Acgb0YjCFiU2x3+hjmy0NSdNlHlahQJ4+DOPeBfcPGg1M PnK/BukpQwGh7Pmw7mDVEiKQ= X-Received: by 2002:a05:600c:1c16:b0:49d:1a02:4797 with SMTP id 5b1f17b1804b1-49e619bb9bfmr9928855e9.17.1789071213275; Thu, 10 Sep 2026 13:13:33 -0700 (PDT) X-Received: by 2002:a05:600c:1c16:b0:49d:1a02:4797 with SMTP id 5b1f17b1804b1-49e619bb9bfmr9928405e9.17.1789071212794; Thu, 10 Sep 2026 13:13:32 -0700 (PDT) Date: Thu, 10 Sep 2026 16:13:30 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Hanna Czenczek , Stefan Hajnoczi , Paolo Bonzini , Fam Zheng Subject: [PULL 50/90] hw/scsi-disk: Fix accounting for IGNORE, ret > 0 Message-ID: References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-Mailer: git-send-email 2.51.2.2891.g4157995a80.dirty X-Mutt-Fcc: =sent 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=170.10.133.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com 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, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_PASS=-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-Zoho-Virus-Status: 1 X-Zoho-AV-Stamp: zmail-av-0.2.13.1.5.4/289.74.40 X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1789082112142158500 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Hanna Czenczek When encountering SCSI error status (ret > 0), accounting is left to scsi_handle_rw_error(), but the BLOCK_ERROR_ACTION_IGNORE path in turn leaves accounting (block_acct_done()) to the caller, so neither side does it. Fix this by unconditionally calling block_acct_done() in the IGNORE path. Yes, this will often result in it being called twice, but that is a no-op, as block_acct_done() resets the cookie type to BLOCK_ACCT_NONE, and will only do accounting if the type is not BLOCK_ACCT_NONE. (And given that the conditions on who does what accounting are quite confusing in scsi-disk, for me at least, I prefer this unconditional call rather than guard it with a condition that has no obvious reason.) Signed-off-by: Hanna Czenczek Reviewed-by: Michael S. Tsirkin Reviewed-by: Stefan Hajnoczi Signed-off-by: Michael S. Tsirkin Message-ID: <20260724152315.234183-7-hreitz@redhat.com> --- hw/scsi/scsi-disk.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/hw/scsi/scsi-disk.c b/hw/scsi/scsi-disk.c index a42f7d8e77..deb33ac1dd 100644 --- a/hw/scsi/scsi-disk.c +++ b/hw/scsi/scsi-disk.c @@ -318,6 +318,13 @@ static bool scsi_handle_rw_error(SCSIDiskReq *r, int r= et, bool acct_failed) return true; =20 case BLOCK_ERROR_ACTION_IGNORE: + /* + * The caller may have already finalized the accounting cookie + * (e.g. scsi_dma_complete() for ret < 0), but calling + * block_acct_done() afterwards is fine (just a no-op). Just + * make sure all cookies are indeed accounted at some point. + */ + block_acct_done(blk_get_stats(s->qdev.conf.blk), &r->acct); return false; =20 case BLOCK_ERROR_ACTION_STOP: --=20 MST From nobody Sat Sep 26 20:50:17 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=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1789079699; cv=none; d=zohomail.com; s=zohoarc; b=GJ2B2Ve/kdLaACsLDplNSp5kEG6lEE/MuZdyGp4nVOfrU8TbxOywYFbwAs/qfrcxpMwF8+lxwGITA8DpSUD0KM2DtM+t4mJ1BBXVLk42mDXwkLWRq0Ye+C3OloBNQ2DtBFepE5JJfOJN3mefhQPP2Xjoq4D7q1ennw9W8KVrWLA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1789079699; h=Content-Type: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=5re7lxkrkt8+upQzc9fNBwoUOfPVSS5sXD8pGJHek6w=; b=B1JTmqdlC9+EfDz1ypkmZch6W97D51GxhhIHHb+z++T8oYLVWcHVXaaT2TWghsTgFF3L0hqOGcfaBSicrOzFubJJ80+VvEkxWUKXMGRVe3q0jlHFk98RhGoTY6GQTQg/pl3rRsd/wEJo7b5q5RZcszMIYUcp1xggvtJ7Rl1Ibvs= 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 lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1789079699642932.7217926030385; Thu, 10 Sep 2026 15:34:59 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1x4nLP-0007fD-1h; Thu, 10 Sep 2026 18:34:21 -0400 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 1x4lPY-0004Iv-En for qemu-devel@nongnu.org; Thu, 10 Sep 2026 16:30:46 -0400 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 1x4lOM-0001OK-UX for qemu-devel@nongnu.org; Thu, 10 Sep 2026 16:29:15 -0400 Received: from mail-wr1-f72.google.com (mail-wr1-f72.google.com [209.85.221.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-264-pvvcdLKQNhGNFBS7CkuZNQ-1; Thu, 10 Sep 2026 16:13:37 -0400 Received: by mail-wr1-f72.google.com with SMTP id ffacd0b85a97d-47d81cf0c4cso68893f8f.2 for ; Thu, 10 Sep 2026 13:13:37 -0700 (PDT) Received: from redhat.com (IGLD-80-230-79-236.inter.net.il. [80.230.79.236]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-486eb33ee8bsm728004f8f.15.2026.09.10.13.13.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Sep 2026 13:13:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1789072083; 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=5re7lxkrkt8+upQzc9fNBwoUOfPVSS5sXD8pGJHek6w=; b=Y8rwoGUk39utt9HPO4M7aR7Wg/K9rtlfLj51sotnQVJXKZCm5UZt9mDTGtUxFSDTCq3k9g 49R6mlWbqGoLB2q7KPX9gsxZmdiFgnmfyTqNIbUL/kpEOjqKM7KVdHDXmM8T+TyL/lAkD1 QuOVz90gLfiCwOytGZJ6Ty/12ADjwwg= X-MC-Unique: pvvcdLKQNhGNFBS7CkuZNQ-1 X-Mimecast-MFC-AGG-ID: pvvcdLKQNhGNFBS7CkuZNQ_1789071216 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=google; t=1789071216; x=1789676016; darn=nongnu.org; h=in-reply-to:content-transfer-encoding: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=5re7lxkrkt8+upQzc9fNBwoUOfPVSS5sXD8pGJHek6w=; b=XDUK8bYQ1KHbOc8VX6LCJBW6jgYaQJsNB4GWzWQvhmXTI6zj/3EA9+gpCw7PA+5DdN LhGdIw/np/ZBOqkKCNLPi5wmmu1LKWGQTNyTsScHyQyHevu8WEgitGWZAbBxtUApF5/r NVeByPCq36t2KJ8wKSLGM66AVe/plptZFEyVCM5mMSmJG6Mt1+/Pdju4u5afwh3VciPj IMSgdlbUotl/Sf0rAH68QWQak/0laeVhYwuRymnfcb6S73I5RCqz/u0HqS3jD8L0rj13 MuFNaDtc6nionZcB5FN+il0gytqjjZVYQvQI07U4s5wCW6hzRT+83UhfD6KWukmC7dEg ZVsA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1789071216; x=1789676016; h=in-reply-to:content-transfer-encoding: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=5re7lxkrkt8+upQzc9fNBwoUOfPVSS5sXD8pGJHek6w=; b=Ryz8pxdbcuy4iHcvzq5vz3iP6iw3K2f+mY2bykkOfvvSt0DYXL9g+fthlc9J/yTFSn UJCgwh7BRr1F53lj1KyVyqvtXAO/Ktg0lDGWYbgqrjzkGBSo0PBn0WWBG9IILOOUlLsj S6e1+fsSNg42KqzAnZ1kqeDyu8K6l5UliM9vwx69CAAfQJfAe29jdyHBHdDYqYRMCs6v q2zASyYC7Gu8TZ1nNIr8fobzJ1aA5XrXNCBQG13W/MQuGpTupyUsWWW/Dlz3poclKhEj 5fJe3b6ePjJEaTpwd+cT/chHcT+hSsb8T8pVNJbTundUfuj8w9qBorLtEgXit5KfvxSu qW2A== X-Gm-Message-State: AFuF++nQBFYpkYtsFEmlhZL/e0RojyiW2SXReFByFOJmxQIN9LOwozDE CauHCa3HExOuBgEW+iPSq+3dBMr7vJniYFMTpE4VPDEUp1qcIhUYaissPTGZjj1ZpQjV5gc3bWY 911MFw8GiB4TEvHEvx+hbDoyFupo2E/yZyJqv4hWINYRChajegYaHEH7KdJYsDrCaq4gsgolLCf PbG6C4e0xD2q6QSoVXnShSz2FH9l7Ue6uy0g== X-Gm-Gg: AYBFou3O1DhEGcyFtkFLA2p9F/7nfvQIXYtqTRXyHhCgAHfWTQ2nwY7Cs7mVZF9lwg7 MICb/MHLt/7clSgGiAdmzEfPR4Rx68l6xKCdzyV+pmbhzPEDPkdTUd5GxZY0T5DEmB6x1Qm0Kg9 1TwghfU/DEUY6REv/30YMyeXEzLXSeTJJUw22jfJpIsr1NbUdj5GKDMJmAgnOuEJjEVmtf7wMpV L9RI9LOocb6WOzWNucZwStOoEdQ1OKibij2D/oh4JxscNqVVouivLR0lzJEd5qodmwrBOCmwU6Q QGU0NR8fVNvekp7++A+ZiH2Np85P+yXPkEjDTuBC33Zmi2fbtFVdIQn6/SZRqRzWdQWrqBpz3Tv rQJ7lzVOLGyxY9BlpDDlYdjM= X-Received: by 2002:a5d:64ea:0:b0:486:e91d:9f99 with SMTP id ffacd0b85a97d-486eb2e40c3mr1542163f8f.10.1789071216281; Thu, 10 Sep 2026 13:13:36 -0700 (PDT) X-Received: by 2002:a5d:64ea:0:b0:486:e91d:9f99 with SMTP id ffacd0b85a97d-486eb2e40c3mr1542098f8f.10.1789071215667; Thu, 10 Sep 2026 13:13:35 -0700 (PDT) Date: Thu, 10 Sep 2026 16:13:32 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Daniel =?utf-8?B?UC4gQmVycmFuZ8Op?= , Paolo Bonzini , =?utf-8?Q?Marc-Andr=C3=A9?= Lureau , Pierrick Bouvier Subject: [PULL 51/90] meson: disable "maybe uninitilized" errors with -Og Message-ID: <5dbc8c2fd7c824ba6038118acb6b6412ead67194.1789071043.git.mst@redhat.com> References: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Disposition: inline Content-Transfer-Encoding: quoted-printable In-Reply-To: X-Mailer: git-send-email 2.51.2.2891.g4157995a80.dirty X-Mutt-Fcc: =sent 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=170.10.133.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com 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, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_PASS=-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-Zoho-Virus-Status: 1 X-Zoho-AV-Stamp: zmail-av-0.2.13.1.5.4/289.74.40 X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1789079702880158500 GCC's "maybe uninitilized" warnings depend on optimizations for code flow analysis, and produce false positive errors with -Og. Default build gives us coverage with that, so let's just disable with -Og. Reviewed-by: Daniel P. Berrang=C3=A9 Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin Message-ID: --- meson.build | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/meson.build b/meson.build index ec9b05414a..e2da31880b 100644 --- a/meson.build +++ b/meson.build @@ -746,6 +746,10 @@ warn_flags =3D [ '-Wno-typedef-redefinition', ] =20 +if get_option('optimization') =3D=3D 'g' + warn_flags +=3D ['-Wno-error=3Dmaybe-uninitialized'] +endif + if host_os !=3D 'darwin' tsa_has_cleanup =3D cc.compiles(''' struct __attribute__((capability("mutex"))) mutex {}; --=20 MST From nobody Sat Sep 26 20:50:17 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=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1789072990; cv=none; d=zohomail.com; s=zohoarc; b=T3gNhTFrOPp22jWgUuB7SDkgSEudzTSIwdsFuopdeiVvueHd7VJKgUAlsu4RDZJHgJ0OFp9OjncPcMirQ1BAqjODu7utZaeUmv0NXDbiGTcKD7WJrnnz51dOP01CQMhOmg0ai6vDCCrDPD8qN/U1dNl4AZJq8rklAXj88v76ylI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1789072990; h=Content-Type: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=sbPme7j4pWLTyo9RI68qo6cFhFds/zr08zUNXOqMtd4=; b=npfanny9Wgn19CvDQifnqesKJ81VjuUN63nA4wOJq55mfi4r3C2mzozc5wRF2rIUlErMTO3QVJOk99QPGWEAGLiWoXcpMLJCqzYAZrmngPkKqDaY9julFiQNLjQ/dCaMMhLvua5r8KEXeeQo9C6wGHmecxi94bKKRKpJwyd+uco= 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 lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1789072990610964.7572628850552; Thu, 10 Sep 2026 13:43:10 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1x4lbL-0007RS-Eg; Thu, 10 Sep 2026 16:42:38 -0400 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 1x4lFl-0000go-SH for qemu-devel@nongnu.org; Thu, 10 Sep 2026 16:20:27 -0400 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 1x4lFV-00080Z-Es for qemu-devel@nongnu.org; Thu, 10 Sep 2026 16:20:01 -0400 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-496-eKcmbK5TOgqMmV_CaZfQ5w-1; Thu, 10 Sep 2026 16:13:40 -0400 Received: by mail-wm1-f70.google.com with SMTP id 5b1f17b1804b1-49d156c917cso8584045e9.1 for ; Thu, 10 Sep 2026 13:13:40 -0700 (PDT) Received: from redhat.com (IGLD-80-230-79-236.inter.net.il. [80.230.79.236]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-486eb34f1f7sm765644f8f.24.2026.09.10.13.13.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Sep 2026 13:13:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1789071586; 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=sbPme7j4pWLTyo9RI68qo6cFhFds/zr08zUNXOqMtd4=; b=ffuSQsn1RNAfUZZ6Dbj6i2Xg/31Y0ultIyitT02upSdVmYclhvvecPVMhAo3eAvs2m/LrN ghjAi2hsPTPENlMTfXPdy/cqEdh93cdcFdl69r83b7/rQYs+uvzgx5qN5IE8lcbmDR4uKJ xV88j0pARTkhwBMNBzrvZDFeOGr0ctc= X-MC-Unique: eKcmbK5TOgqMmV_CaZfQ5w-1 X-Mimecast-MFC-AGG-ID: eKcmbK5TOgqMmV_CaZfQ5w_1789071219 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=google; t=1789071219; x=1789676019; 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=sbPme7j4pWLTyo9RI68qo6cFhFds/zr08zUNXOqMtd4=; b=AcEZSoW6PJgwNfrIAqa6XWqb3l5kwkZ1ui4QYf8jt8mdwpq2xU5hEoPJbdWaPev7Y3 WIVYtGwk1LLwRjyGvLQBTL97e7ekbW4h6mC9vAIcs4OkNBXs/Xy9kc0RZxpEpc60efwV euQ95Od6+vV3/BVgbDKKzmHBqfdE0aSxObT9m9jJ4p5xJWhoUWeooOMqSYQ2eQUJuZCB ZrN703zEgOVi310eQe6fndlbiokat57iecDNDeu9gp18NotxvaCgxn/OS1CsuNE6EtJR BYkdGFbzpDxvLhCZx9/MIY40JSKDbx6yb5jQ9n0EsW6/qnJtiB/3EcvVCY4yd3ahlKh9 cLPg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1789071219; x=1789676019; 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=sbPme7j4pWLTyo9RI68qo6cFhFds/zr08zUNXOqMtd4=; b=pcEeJdA1fP4EA8riDE/rKeW7cfchIq8v8JELJAkt6l7wEgnHGnmZDK9Z3ngEepM7ha Ys1qYE9fxvqSbB3i8hyYIjmJpMNv5OIPeNfXyvPOLoPH2kzjNgr5iz1yjHUsV+3A3UcB gyhpChPJ6Kb+JrO+VoSfRBipf2qXUBKRBPp5AKXdyXQxmHgDU+j9yhsDUBwEQdMdEmlx Kox9fGGFIH4pyd39FkfEPVRFH7OcPtpaJddb/BGiogFP8etNSxiL3knk/fypTR1IjOBp O4lik2XxA6+qBwnE67CqfTE3QPBU6wa70Mawrp9VdDwzwaB6Fb2JErjPbK/1IijiwFrH yBhQ== X-Gm-Message-State: AFuF++mC9EpLTHKLW6en9Q3JNng+sbj6rdvYc4gCsapQgqJghpr1vukW WbaECnGi+DK3H2sQHfLtr0bHdcQ3zGwSXYBXZgM1bqQKx+nBM01njSJnmYmitoHa7nA3RKAMz5u m7jOa6fgKGD1zLjLHUVi5t5iXGMcJ6EpbCjr+l28GILue8evjBUWwC7i0wpceShcuQHzCrWC3Hh HkOesV07YqzXssKff4FvEfFtSlELNUXmMVKw== X-Gm-Gg: AYBFou1IM1QJe80E4riqIiSyUv898jzYI23k4/Mnm2okkSgIHKUDlLNybWxUvHLMNgY lNVlNYQUlyuUemVpgu3yEA+VqhPGKBTbmCSz4X31d/SZU2CnI0Cl9hXHSa7f7cNmIhlClHD9m7B w65LJhdQq96Dt1EYvL2H6FlHLQqmfuCYtuv7XOa4kjQoyo8wmdscV55BPr3TL+j3xBLk788do23 RyZK7fa1+MQ/ZkB9eF8BLBJUK5O/U3zoI3frR513FrjeZMHCDrlvuTE8RBqImwjDwkq9ghLP8AY kgg8rr2VDNoHz2mAWCOYDy2v259ASEn8dnIBn7wXsjmNRc/MhR8XYcEY8Qw9//RKUiw/KVYUFHO EmoUOjeCEJ1Di21rVYrqMToQ= X-Received: by 2002:a05:600d:8444:20b0:49d:27ee:79c9 with SMTP id 5b1f17b1804b1-49d27ee7af0mr55871665e9.8.1789071219219; Thu, 10 Sep 2026 13:13:39 -0700 (PDT) X-Received: by 2002:a05:600d:8444:20b0:49d:27ee:79c9 with SMTP id 5b1f17b1804b1-49d27ee7af0mr55871305e9.8.1789071218624; Thu, 10 Sep 2026 13:13:38 -0700 (PDT) Date: Thu, 10 Sep 2026 16:13:35 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Laurent Vivier , qemu-stable@nongnu.org, Yuri Benditovich , Sven , Jason Wang Subject: [PULL 52/90] hw/net/virtio-net: strip trailing padding when caching RSC segment Message-ID: References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-Mailer: git-send-email 2.51.2.2891.g4157995a80.dirty X-Mutt-Fcc: =sent 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=170.10.133.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com 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, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_PASS=-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-Zoho-Virus-Status: 1 X-Zoho-AV-Stamp: zmail-av-0.2.13.1.5.4/289.52.80 X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1789072993343158500 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Laurent Vivier When an RSC candidate packet has trailing padding bytes beyond the declared IP payload, virtio_net_rsc_cache_buf() copies the full wire size into the coalescing buffer and sets seg->size to that value. The bounds check in virtio_net_rsc_coalesce_data() uses the IP length field (o_ip_len) which does not include the padding, so the check can pass while the subsequent memmove() overflows the buffer. Fix this by computing the actual IP packet size from the IP header and using it for both the memcpy and seg->size, so that seg->size stays in sync with the IP length field. virtio_net_rsc_sanity_check4/6() guarantees that ip_size <=3D size. Fixes: CVE-2026-66900 Fixes: 2974e916df87 ("virtio-net: support RSC v4/v6 tcp traffic for Windows= HCK") Cc: qemu-stable@nongnu.org Cc: Yuri Benditovich Resolves: https://gitlab.com/qemu-project/qemu/-/issues/3879 Reported-by: Sven Signed-off-by: Laurent Vivier Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin Message-ID: <20260728082311.4179910-1-lvivier@redhat.com> --- hw/net/virtio-net.c | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/hw/net/virtio-net.c b/hw/net/virtio-net.c index f3f375e1b2..23c26aa08c 100644 --- a/hw/net/virtio-net.c +++ b/hw/net/virtio-net.c @@ -2200,13 +2200,31 @@ static void virtio_net_rsc_cache_buf(VirtioNetRscCh= ain *chain, { uint16_t hdr_len; VirtioNetRscSeg *seg; + size_t ip_size; =20 hdr_len =3D chain->n->guest_hdr_len; + + /* + * Strip any trailing padding beyond the IP payload so that seg->size + * stays in sync with the IP length field used by the bounds check in + * virtio_net_rsc_coalesce_data(). virtio_net_rsc_sanity_check4/6() + * guarantees that ip_size <=3D size. + */ + ip_size =3D hdr_len + sizeof(struct eth_header); + if (chain->proto =3D=3D ETH_P_IP) { + struct ip_header *ip =3D (struct ip_header *)(buf + ip_size); + ip_size +=3D htons(ip->ip_len); + } else { + struct ip6_header *ip6 =3D (struct ip6_header *)(buf + ip_size); + ip_size +=3D sizeof(struct ip6_header) + + htons(ip6->ip6_ctlun.ip6_un1.ip6_un1_plen); + } + seg =3D g_new(VirtioNetRscSeg, 1); seg->buf =3D g_malloc(hdr_len + sizeof(struct eth_header) + sizeof(struct ip6_header) + VIRTIO_NET_MAX_TCP_PAYLOAD); - memcpy(seg->buf, buf, size); - seg->size =3D size; + memcpy(seg->buf, buf, ip_size); + seg->size =3D ip_size; seg->packets =3D 1; seg->dup_ack =3D 0; seg->is_coalesced =3D 0; --=20 MST From nobody Sat Sep 26 20:50:17 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=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1789073787; cv=none; d=zohomail.com; s=zohoarc; b=BgDgWCmbQiEsFewmMA0DjL2N7XFqus/WcQz6prYpzes9PDsH2hgJ3/LTtlNxzyVicMYBtnN2g4PQF06DQIQvrdGOWmMISphGN5XXgu5pa8i5yEOv5x2SmB8Lwqg4u08L69ILSC1FshAPhhBT4wP7r6r5rE5Qx3J5QhwGiWf+hlQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1789073787; h=Content-Type: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=6dS2LV10xW58XQBK2n8n0ndzTRRlQmRu7LpDRVGCeMs=; b=gEK0Mg+mMlwMcWQT4Qyf6Z+Oz3gFRbnGHiYQCi4EUjdt9Ra1r3pCnymAv3EDgeJqehse93Vm0Sl8gtY+9vvuhi8DkZxhrEhBiomLXuB4Xkth6SorYp6/bN9f3vgdQnGUnqVldYiV962rm1Xcg44OdKqQF7J2wv1PpLd3kkTutgA= 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 lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1789073787177570.3397246759862; Thu, 10 Sep 2026 13:56:27 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1x4lnh-00027q-CI; Thu, 10 Sep 2026 16:55:36 -0400 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 1x4lGn-0001AO-J9 for qemu-devel@nongnu.org; Thu, 10 Sep 2026 16:21:30 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1x4lGD-00083R-0N for qemu-devel@nongnu.org; Thu, 10 Sep 2026 16:20:58 -0400 Received: from mail-wr1-f69.google.com (mail-wr1-f69.google.com [209.85.221.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-178-nkx2V4-COWqwJlkDkDkk7g-1; Thu, 10 Sep 2026 16:13:43 -0400 Received: by mail-wr1-f69.google.com with SMTP id ffacd0b85a97d-4858f06e142so98480f8f.0 for ; Thu, 10 Sep 2026 13:13:43 -0700 (PDT) Received: from redhat.com (IGLD-80-230-79-236.inter.net.il. [80.230.79.236]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-486eb35f3d9sm679751f8f.35.2026.09.10.13.13.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Sep 2026 13:13:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1789071601; 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=6dS2LV10xW58XQBK2n8n0ndzTRRlQmRu7LpDRVGCeMs=; b=fkab8dWxcPtVNYrj3imFOAK4+G9EjXMmhbEESN9itc4WqduSZeSEwu124IpBI/QqciAYcr 5zzR8GK/GlWjriYmpKw7pXaUGA1dK77CKNVbpoL4mC7lh1WAeTiGB4Qr1gF7id165PKs0t /ZnsyIjNoYY5iCUVVuAVZujv0AicrWI= X-MC-Unique: nkx2V4-COWqwJlkDkDkk7g-1 X-Mimecast-MFC-AGG-ID: nkx2V4-COWqwJlkDkDkk7g_1789071222 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=google; t=1789071222; x=1789676022; 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=6dS2LV10xW58XQBK2n8n0ndzTRRlQmRu7LpDRVGCeMs=; b=mq+Bs6HuLgMB/Te2e4F/rfxF6oZ1x2UIwPXAT6jiXX3iPnFJsWA8odAVRCuLVdnHXa Rue6XFb23FoZqGfF5C3C/wYkaO5pqGYCdJ7L4NBfQPho5XxJdW/ZQYUQ4AbbiFpJcOBt psjqWNKclW040hnUo37v0pil4fpy7ik1G3jdhgA2jTr9jsQKL59qJH5n82AFq0T5inbr fo9sWWdz7wzyQebvItCFuzvIqZdHRn5k9V1H5hjCmKDYf5WrOjyD6kybDnvNIS9KysxW g0fx1gIasWL9L0l3BCJkExOX0Wm7mWZewv6hngxxc2LFclne89a21+urLX4QOGM6U0nf P/jw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1789071222; x=1789676022; 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=6dS2LV10xW58XQBK2n8n0ndzTRRlQmRu7LpDRVGCeMs=; b=pgdHpa3AnigRuF/Vp6nAoyk/576v3o3xTpUOKGpRJqoHdVhZyegjE2k23uAsn1ZffS n14IC+hccRINtrHS/f3jvNT1AfC2gzrNbFpYh55RLKM2rh8D+e2u0kTMGBIgLnd8yeo9 mmLdNacYmo2UUziDPzqueVxtDvSMkiGZ6RH8n7jNwyh1X+bXnCuMTALhc43YcBDYXqnz C1K2j7JJe06qCnrB0qbO2PV8CivulaFdVGoq07L2xsR9mb5/l+0CWIlBGbJ8II0SM3vJ vpaEMim822iTmDMtFUapGkJpGLpLCnW5kMBy0mYv1SQaT54IAttoYtUk8R3kB64mPs3M AOEg== X-Gm-Message-State: AFuF++nhiBnShH8ADnibz8gBds8mTgz+kh7sqQavjhSJd3DVxmbaE/oR FS5cVyDYvRGGxFW2m8Chv/LgVS7ZUedidpDlugCYpJ2oCTsZhaum5PZ8Xv4T4APczNlWG3H8NxF c91JaVO221Ymv47GRIkmeJFfZF4f+mB3fIejg75N2FKAjO6uLN79vL7JxUk0OgN5iOj5bmvJZnq UoVGgRvjhbf68CBaS3gN7b3SG1ByUfXPk+Wg== X-Gm-Gg: AYBFou2XJkY3Zpb0n1SeeHXi1GF3bEmKNrJjXwfsX7OrJrr7y89cav/fhxIzUbsoLfq fgoV4uB3+ROZMfWckuMYe0JJkHyl/rYqy1VYiYfh9cchfujdt63bwiIMa7UGs6t4H83pSLHrtC/ A76qH5kU/6q8bHuk0wKbdgIa0JLCHx9Vk8TgXbREnfjTsipIA+FfGvjIyXk/NXfijzFsgeveG+z HHRcwbz1tTKUODMjn4cVgY0peIhcWAcFsFwRBcuCQ+g4jd+qEGzMrwnI5Rj0JeVWxAvJS+Nyb2f mZgQtAQmwEtaDL+0LZETZxjH56FdxboOJ7dZAObLFQH2ETy938RwZjCavXTN4XGwsnjW1Eluaz0 iZ5In00onPMy+H303sZfJCKE= X-Received: by 2002:adf:f792:0:b0:484:3310:f39b with SMTP id ffacd0b85a97d-486eb31e1a3mr559325f8f.28.1789071222098; Thu, 10 Sep 2026 13:13:42 -0700 (PDT) X-Received: by 2002:adf:f792:0:b0:484:3310:f39b with SMTP id ffacd0b85a97d-486eb31e1a3mr559291f8f.28.1789071221596; Thu, 10 Sep 2026 13:13:41 -0700 (PDT) Date: Thu, 10 Sep 2026 16:13:38 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , GuoHan Zhao , "Gonglei (Arei)" Subject: [PULL 53/90] virtio-crypto: clean up every data queue Message-ID: References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-Mailer: git-send-email 2.51.2.2891.g4157995a80.dirty X-Mutt-Fcc: =sent 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=170.10.129.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com 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, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=0.001, SPF_HELO_PASS=-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-Zoho-Virus-Status: 1 X-Zoho-AV-Stamp: zmail-av-0.2.13.1.5.4/289.52.80 X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1789073790071158500 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: GuoHan Zhao realize() creates max_queues data queues and one BH for each of them. unrealize() decides how many to tear down from multiqueue, but nothing ever sets that field, so it only deletes the first queue and BH. It does not matter how many queues the guest used here. unrealize() must undo all the allocations made by realize(), so loop over max_queues. Fixes: 20cb2ffd5ff3 ("virtio-crypto: using bh to handle dataq's requests") Signed-off-by: GuoHan Zhao Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin Message-ID: <20260728111217.573046-1-zhaoguohan@kylinos.cn> --- hw/virtio/virtio-crypto.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/hw/virtio/virtio-crypto.c b/hw/virtio/virtio-crypto.c index 79e2acb56c..85c7279aae 100644 --- a/hw/virtio/virtio-crypto.c +++ b/hw/virtio/virtio-crypto.c @@ -1114,10 +1114,9 @@ static void virtio_crypto_device_unrealize(DeviceSta= te *dev) VirtIODevice *vdev =3D VIRTIO_DEVICE(dev); VirtIOCrypto *vcrypto =3D VIRTIO_CRYPTO(dev); VirtIOCryptoQueue *q; - int i, max_queues; + int i; =20 - max_queues =3D vcrypto->multiqueue ? vcrypto->max_queues : 1; - for (i =3D 0; i < max_queues; i++) { + for (i =3D 0; i < vcrypto->max_queues; i++) { virtio_delete_queue(vcrypto->vqs[i].dataq); q =3D &vcrypto->vqs[i]; qemu_bh_delete(q->dataq_bh); --=20 MST From nobody Sat Sep 26 20:50:17 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=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1789077996; cv=none; d=zohomail.com; s=zohoarc; b=S23UWwl/bR88GDBDMiou0q/kiQmyWLNp+sqfmNLubYvTnwY0owEn2zdI+SD84di6/r/yRjugHQgmHgiepiMceOWMG8n78dDazhlnv9y3LrShr/IzwuQSlbVS1PLm1xCJF9vwE7jTB0MlJimICYtFndULbSAja/Var9spSZYWbyc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1789077996; h=Content-Type: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=tjmu0XflcFt7hcajhQyvOAGpQgP0KwuZU8Bcnz844UE=; b=WC8JLNRrL2llAanwiflnLiQqKjlrfSkV32JCh5zNOuYaUUWgfwV5XF+QNgG1slzW9JmjnhafvIvdXGIiVRBPa6jXGb3SSVAiFJcDqs+zjXVqhJwxrQ09k9x5MPneQOxGSzpN9b++AmVNo9qQM1VCePpeDteoFH7g3VV2tqdfRg0= 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 lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1789077996343703.9880358337913; Thu, 10 Sep 2026 15:06:36 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1x4mpx-0008BF-Sd; Thu, 10 Sep 2026 18:01:58 -0400 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 1x4lPY-0004Iw-Fr for qemu-devel@nongnu.org; Thu, 10 Sep 2026 16:30:48 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1x4lOM-0001O2-Uj for qemu-devel@nongnu.org; Thu, 10 Sep 2026 16:29:16 -0400 Received: from mail-wm1-f72.google.com (mail-wm1-f72.google.com [209.85.128.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-553-9mIMbsP9O724rS8rkqbAvw-1; Thu, 10 Sep 2026 16:13:46 -0400 Received: by mail-wm1-f72.google.com with SMTP id 5b1f17b1804b1-495689bfcc8so1327625e9.1 for ; Thu, 10 Sep 2026 13:13:46 -0700 (PDT) Received: from redhat.com (IGLD-80-230-79-236.inter.net.il. [80.230.79.236]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-49e60adb075sm18503535e9.13.2026.09.10.13.13.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Sep 2026 13:13:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1789072081; 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=tjmu0XflcFt7hcajhQyvOAGpQgP0KwuZU8Bcnz844UE=; b=UgJAiZ/DHXIpLsUfbyKG14gbhCkmphl7LX2tj2YZF6SLw3mvh5nR17G3OcZ/59/lihZ8Zp J2AJWp/U7wJiCi7/ipOn65YIbICcMNESt4EvRgQ3LTTnEo8K4kN5hxt2Jt2pVRD6f345cJ K4gtFAMRX9wt9s9kwj8uBwrjZnLMtNY= X-MC-Unique: 9mIMbsP9O724rS8rkqbAvw-1 X-Mimecast-MFC-AGG-ID: 9mIMbsP9O724rS8rkqbAvw_1789071226 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=google; t=1789071226; x=1789676026; 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=tjmu0XflcFt7hcajhQyvOAGpQgP0KwuZU8Bcnz844UE=; b=q7hVCZU8PGcPQHvcXCHcf790XZVk34oIJ8ReYOVNeiCJQ6cJx0jadFVvC0jFcNP180 iDB0KbEjs4dVzahUTIu4zpJp9xoSK/4m9gFxlUqVGtSWLtux4MgkByZBSD9m4qN4HYx/ +VDelXs2ftkkxHYR1vcUj1Xb2XJ4bBfBTdGd0YYazuO/7jXnnPqms4R80lIt2SfRt0El lBQpVPTV6WaWEkXCjvs39e/1xs+tf0Y6r1HBtkrZxWTEZbmaqDpbhbdAmaltnRBUvQQC HHqZTbviiRDhTpwsVUgknyrJpSnBUTEBiukbrWNj95V6tJhSm/PBOyzb0LwqwhkoM8aQ 6IWA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1789071226; x=1789676026; 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=tjmu0XflcFt7hcajhQyvOAGpQgP0KwuZU8Bcnz844UE=; b=fX/UOHHoCbPDdWn39pboLqnG1NLcXo0KfPwKYDEiZkFxh/OBUPNKszTh8ygzT8mmtc ta1Mv54UnHDfxfA73bVrlmeSUwu+ceaje3fWHwHWbPGdqkpoXRjqDEag4b8YtfHDuOCF 8+PJ850DywwXYwaBqbAitJqj3mmwb3ziw1F3ydoCsfE31v2w2uZAm1FaSNaVhy8Kwqfd N1C46YQGHbzSQCRRfUf6Y/VKn2ZIXLhl4YgaLQnMUTvsgqaM/TvULkt8WgQIPWF2fBh6 unRQ7dtpUtXHVOHd2nvmoXNG34n193fIVBy05TPUmX3uLINeZ9ZOM4acK2Hb3TvR7ABT KZAw== X-Gm-Message-State: AFuF++lUcw+dy/u2uZfHNIvYgVAKbZKlffT6TYoNRtLa6yv44sJWyLzf 7z/3E3SbMXZ2qHiU4F+Oj3T3emrslyZnAMI4M4MB7QhlDitYfUScgXqGWX6VnXa44iliaAZJkD6 Le6cCUkW1Kn5c6Rru4XWV7IyRQOwfnF3n7brr0yGSd01uOyYnCul+ZaRVc+xMHPCF80LKswRHbp EA8YWZUXobB2Uzkr1hAiC1C0solR2wvRrXHQ== X-Gm-Gg: AYBFou10L621VqnuhRLiilMSQpde7K/eUF09vRESv0sTVhuH19rTm6eb5jKR2FxhbCM X1TwQOskwIzA3HMBY4rlrdiV8kW9JIJz4xfL88cPHXyuZCx4B5xtChnpbZdXcEYQ8E0qeP/Jkjn T5GznxX4WYCG4fG9cFXRdSQRL3k8x4uDVMpCDsW3lNH5F/UcC93OnKbJCnL0ODP02RdGqiitP9p quO9atqigHI0TuseF9t0xH09dn5S8tsAultb8Pqr55rxjFbXm89V5Xr13z7TRtIqxOfCQhK+T1j QS/Q1PHIVyk7E0xRf6aAey3g1za89jnP/EHRTPRri+7paCCcLrDtiLYOWOIye+PaDJNF8yE+k+2 av1aDbrsnBQZhJahGZdag/Kw= X-Received: by 2002:a05:600d:8646:20b0:49d:1fd8:b874 with SMTP id 5b1f17b1804b1-49e619c079cmr5547025e9.19.1789071225624; Thu, 10 Sep 2026 13:13:45 -0700 (PDT) X-Received: by 2002:a05:600d:8646:20b0:49d:1fd8:b874 with SMTP id 5b1f17b1804b1-49e619c079cmr5546615e9.19.1789071225070; Thu, 10 Sep 2026 13:13:45 -0700 (PDT) Date: Thu, 10 Sep 2026 16:13:41 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Jia Jia , Eric Auger Subject: [PULL 54/90] hw/virtio: reject inverted virtio-iommu IOVA ranges Message-ID: <60e4e1fb90c6af67c019b1485b50272dd41b57a5.1789071043.git.mst@redhat.com> References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-Mailer: git-send-email 2.51.2.2891.g4157995a80.dirty X-Mutt-Fcc: =sent 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=170.10.129.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com 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, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=0.001, SPF_HELO_PASS=-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-Zoho-Virus-Status: 1 X-Zoho-AV-Stamp: zmail-av-0.2.13.1.5.4/289.74.40 X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1789077998150158500 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Jia Jia Guest MAP and UNMAP requests can set virt_end below virt_start. Since virt_end is inclusive, this is not a valid interval. MAP nevertheless stores it in domain->mappings, but interval_cmp() assumes low <=3D high. For an inverted key, interval_cmp(key, key) returns -1. A covering UNMAP can therefore find the key but fail to remove it and repeat forever while holding s->mutex. Reject inverted request ranges with VIRTIO_IOMMU_S_INVAL and make the notifier range decomposition skip invalid ranges. Keep the existing notifier-before-remove ordering, but return VIRTIO_IOMMU_S_DEVERR if g_tree_remove() fails. Fixes: fe2cacae2438 ("virtio-iommu: Implement map/unmap") Resolves: https://gitlab.com/qemu-project/qemu/-/work_items/4104 Signed-off-by: Jia Jia Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin Message-ID: <20260729131953.1720567-1-physicalmtea@gmail.com> --- hw/virtio/virtio-iommu.c | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/hw/virtio/virtio-iommu.c b/hw/virtio/virtio-iommu.c index 533bd5073f..208815096f 100644 --- a/hw/virtio/virtio-iommu.c +++ b/hw/virtio/virtio-iommu.c @@ -212,6 +212,10 @@ static void virtio_iommu_notify_map_unmap(IOMMUMemoryR= egion *mr, { uint64_t delta =3D virt_end - virt_start; =20 + if (virt_end < virt_start) { + return; + } + event->entry.iova =3D virt_start; event->entry.addr_mask =3D delta; =20 @@ -807,6 +811,10 @@ static int virtio_iommu_map(VirtIOIOMMU *s, return VIRTIO_IOMMU_S_INVAL; } =20 + if (virt_end < virt_start) { + return VIRTIO_IOMMU_S_INVAL; + } + domain =3D g_tree_lookup(s->domains, GUINT_TO_POINTER(domain_id)); if (!domain) { return VIRTIO_IOMMU_S_NOENT; @@ -857,6 +865,10 @@ static int virtio_iommu_unmap(VirtIOIOMMU *s, =20 trace_virtio_iommu_unmap(domain_id, virt_start, virt_end); =20 + if (virt_end < virt_start) { + return VIRTIO_IOMMU_S_INVAL; + } + domain =3D g_tree_lookup(s->domains, GUINT_TO_POINTER(domain_id)); if (!domain) { return VIRTIO_IOMMU_S_NOENT; @@ -879,7 +891,10 @@ static int virtio_iommu_unmap(VirtIOIOMMU *s, virtio_iommu_notify_unmap(ep->iommu_mr, current_low, current_high); } - g_tree_remove(domain->mappings, iter_key); + if (!g_tree_remove(domain->mappings, iter_key)) { + ret =3D VIRTIO_IOMMU_S_DEVERR; + break; + } trace_virtio_iommu_unmap_done(domain_id, current_low, current_= high); } else { ret =3D VIRTIO_IOMMU_S_RANGE; --=20 MST From nobody Sat Sep 26 20:50:17 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=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1789086004; cv=none; d=zohomail.com; s=zohoarc; b=UGmfcLpHmVvJxYDJqzvgodPENsuP0VMbt8WBxEFVdJWk2pqTSG3kaP70geo+Ig65S8+oQsZIMrcW+SbGrMY5250VjxLBVzlL1mthbGjaFp/aQW177J40FLzPar9YoB2+Q2oDCaE2k+DWy9bblsXvYxhYlVp7gBryphB1ywjnz0o= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1789086004; h=Content-Type: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=DrlxSV2VF2oztmcd8kqn2wrqEBAsS1OzZaHE6hsiVqg=; b=W+6FVcHk1GLpMieSi/Rl7c6OYGkgx7vd2e2UTyBLcyCdQd4bxYFSc7wuz7rmpttZyXzF/DCYnZBiYKB92zR11eZPEmuaSqyQMg2EsNCKIfCRIfOHqUIreGNNo12cDFofpZ3hi5I4gJhM+8yApC68VavfQ4bsGqKLH6h+kEKnxyk= 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 lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1789086004858824.067757660418; Thu, 10 Sep 2026 17:20:04 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1x4oqb-0000UC-AT; Thu, 10 Sep 2026 20:10:58 -0400 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 1x4lUT-0006A0-2r for qemu-devel@nongnu.org; Thu, 10 Sep 2026 16:35:37 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1x4lUB-0003Az-9S for qemu-devel@nongnu.org; Thu, 10 Sep 2026 16:35:13 -0400 Received: from mail-wr1-f71.google.com (mail-wr1-f71.google.com [209.85.221.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-575-rBjKisxsMYmuclzm_a82Vw-1; Thu, 10 Sep 2026 16:13:49 -0400 Received: by mail-wr1-f71.google.com with SMTP id ffacd0b85a97d-48589603501so62830f8f.3 for ; Thu, 10 Sep 2026 13:13:49 -0700 (PDT) Received: from redhat.com (IGLD-80-230-79-236.inter.net.il. [80.230.79.236]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-486eb34fdd2sm722491f8f.28.2026.09.10.13.13.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Sep 2026 13:13:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1789072381; 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=DrlxSV2VF2oztmcd8kqn2wrqEBAsS1OzZaHE6hsiVqg=; b=jJgBrmUNuBIBydAiXj0a0FzjDKA6L3GgWv/OOWghCmv3d54Q5fObeBrG4Yo7OHZv2MG8Jj BQTsQWE9SZ5OU3qVoMejcbwyVLUMQVsBUmj8cnjHHNNnUNdna6hYfwqrDkiO1lBABVosoj qn9CyerGk1wCrusAwzcmuAY2MKONm6c= X-MC-Unique: rBjKisxsMYmuclzm_a82Vw-1 X-Mimecast-MFC-AGG-ID: rBjKisxsMYmuclzm_a82Vw_1789071228 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=google; t=1789071228; x=1789676028; 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=DrlxSV2VF2oztmcd8kqn2wrqEBAsS1OzZaHE6hsiVqg=; b=t4aFPdYx/8YcFO15ODzeYao+8wL+lpBaMnAb83yZrTMAsZaj21cwJomWPGiKp1fzRe kaNAn2G9GX+Q/tHI8UEdVsS49Oqmk6rsFI6Htqa3gl7+/4KW9GrPb3RHLZQz+fZ+RWk/ XEuIZSSFE6r4iQtC/7j4ZCkK8AewuYVGU4nYRXvNbfuNtgz4Fbb6wrcy/lhG58OS9D4P 5NGLpIp8x24NwEOTn9B5Ezxt3o61M4XVgtH5sCx3e/PC0M68GliOVRURDMa7MbNfvk0O bVO+63WxaXsdlRzBZbH9lIGaF/ouczSdquaXL71sTXzh7qqIZHvk7esQdj32C2vuyJe/ 9ovA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1789071228; x=1789676028; 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=DrlxSV2VF2oztmcd8kqn2wrqEBAsS1OzZaHE6hsiVqg=; b=ek2XNw0d+indKWsTJxZnjF3t7oi7gp/59hpKPGo2bWH1Oqu7dmM57DJ2CeI/tXBrbj eFPKychHEGChBOg1q6cTyqmIMYhGSiSY9YvH0pNzgTO28CNTNUxjoVRcvHVhDxAF3C74 LGrCEFXdQLlECQ5o2htQTyIjampIBhq1LZj+lidSEOWW2M9XqSPndaANhxylL+1hHofu 5PsFz2EwN6RwHx0phXh1EsWu3wOB3RvjwC2htQknFJG3ehm7Ypwxgop5yT19buz3iNZI NT2NbrvrNcfZ+WYxjYgAQr/3Sz5VzNVZZHrk7EWYvMM6ulxeVewvAniMFFv3NOB9Ae8G 8ubQ== X-Gm-Message-State: AFuF++klKU2i0uCryhFFBZn5QqkUgdv0ZQAZoKWFmD/VQhMeF6qPAzBQ j0IUJjBSW1CDFKlVYtaTzjWSnRRyVVxgVrsW42FW6xT6lICqNi9CWlxj6O5GdDI7h+MMBS0eid/ m/uTUHLTrnESKuQ7pZOMyNmIXt33CWb1h7gbsiqPtGYL111Mjd27PNWPdrIcFOODmWUBQZ+vPmJ uNRohexWklj9nqsvcEU39ChSumg19LBqwtIQ== X-Gm-Gg: AYBFou0aL3olNDnRjLJOZ4h7aU3tCqy8ZQs+/XHpJxAbrqqMFsSHlrkfWJipCeAVxIy PMhoE/bCALKbBd/zjMvBOR4nG3BNZFIl7SDnsWu2pxccOjtNlPPbMhtzaHounv/Uy3O2JjshoPW i76NsChFartpqs2cn8mU1nhyl2R29MSdM7DinuKXibVXbsAPa2YtoLuiOhjRuotnKzrzPOc2dFM KO33INvK8HnykA+AADLhGNWRzItMcyBU8n1UZxipKUaIn+yVnR/zDwvWecNQK75mn+LcxZiLU4B dszmiN9pUy7VU/oR3V83OMV+EqD1fCt52lLxmcdZ88/S22knKTBLSeoPZixdtWxtKibvMRMpV4o hJaSQxrJbBfQAwlQ3oxhczlg= X-Received: by 2002:a05:6000:430a:b0:482:fb60:2f0 with SMTP id ffacd0b85a97d-486eb2ec2dfmr760630f8f.8.1789071227817; Thu, 10 Sep 2026 13:13:47 -0700 (PDT) X-Received: by 2002:a05:6000:430a:b0:482:fb60:2f0 with SMTP id ffacd0b85a97d-486eb2ec2dfmr760571f8f.8.1789071227260; Thu, 10 Sep 2026 13:13:47 -0700 (PDT) Date: Thu, 10 Sep 2026 16:13:45 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , David Hildenbrand , mhun512 Subject: [PULL 55/90] virtio-balloon: fix free-page BH teardown on unrealize Message-ID: References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-Mailer: git-send-email 2.51.2.2891.g4157995a80.dirty X-Mutt-Fcc: =sent 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=170.10.129.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com 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, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=0.001, SPF_HELO_PASS=-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-Zoho-Virus-Status: 1 X-Zoho-AV-Stamp: zmail-av-0.2.13.1.5.4/289.74.40 X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1789086006963158500 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" When a guest triggers PCIe hot-unplug while the free-page-hint BH is running on an IOThread, the BH will keep accessing vq->used_elems array when running it. Note that qemu_bh_delete merely prevents new BHs from running, it does not wait for already running ones to finish. We need to wait for it to finish - do it like virtio scsi and run a dummy oneshot AIO in the same context, and wait for it. But there's a twist: BH could be blocked in qemu_cond_wait, then AIO won't run. Add a special reporting state FREE_PAGE_HINT_S_UNREALIZE to make BH exit immediately. Cc: David Hildenbrand Fixes: CVE-2026-66899 Resolves: https://gitlab.com/qemu-project/qemu/-/work_items/4079 Reported-by: mhun512 Reviewed-by: David Hildenbrand Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin Message-ID: <0967d574d9ffe469edf5fc16da86237e54a69c34.1785327742.git.mst@re= dhat.com> --- include/hw/virtio/virtio-balloon.h | 1 + hw/virtio/virtio-balloon.c | 19 ++++++++++++++++++- 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/include/hw/virtio/virtio-balloon.h b/include/hw/virtio/virtio-= balloon.h index abbf339718..53bbaa4c9a 100644 --- a/include/hw/virtio/virtio-balloon.h +++ b/include/hw/virtio/virtio-balloon.h @@ -39,6 +39,7 @@ enum virtio_balloon_free_page_hint_status { FREE_PAGE_HINT_S_REQUESTED =3D 1, FREE_PAGE_HINT_S_START =3D 2, FREE_PAGE_HINT_S_DONE =3D 3, + FREE_PAGE_HINT_S_UNREALIZE =3D 4, }; =20 struct VirtIOBalloon { diff --git a/hw/virtio/virtio-balloon.c b/hw/virtio/virtio-balloon.c index 4c5f486ba2..07d519cf6d 100644 --- a/hw/virtio/virtio-balloon.c +++ b/hw/virtio/virtio-balloon.c @@ -35,6 +35,7 @@ #include "system/reset.h" #include "hw/virtio/virtio-bus.h" #include "hw/virtio/virtio-access.h" +#include "qemu/aio-wait.h" =20 #define BALLOON_PAGE_SIZE (1 << VIRTIO_BALLOON_PFN_SHIFT) =20 @@ -519,6 +520,9 @@ static bool get_free_page_hints(VirtIOBalloon *dev) int i; =20 while (dev->block_iothread) { + if (dev->free_page_hint_status =3D=3D FREE_PAGE_HINT_S_UNREALIZE) { + return false; + } qemu_cond_wait(&dev->free_page_cond, &dev->free_page_lock); } =20 @@ -912,6 +916,11 @@ static void virtio_balloon_device_realize(DeviceState = *dev, Error **errp) qemu_register_resettable(OBJECT(dev)); } =20 +static void dummy_bh(void *opaque) +{ + /* Do nothing */ +} + static void virtio_balloon_device_unrealize(DeviceState *dev) { VirtIODevice *vdev =3D VIRTIO_DEVICE(dev); @@ -919,9 +928,17 @@ static void virtio_balloon_device_unrealize(DeviceStat= e *dev) =20 qemu_unregister_resettable(OBJECT(dev)); if (s->free_page_bh) { + AioContext *ctx =3D iothread_get_aio_context(s->iothread); + qemu_bh_delete(s->free_page_bh); + + qemu_mutex_lock(&s->free_page_lock); + s->free_page_hint_status =3D FREE_PAGE_HINT_S_UNREALIZE; + qemu_cond_signal(&s->free_page_cond); + qemu_mutex_unlock(&s->free_page_lock); + aio_wait_bh_oneshot(ctx, dummy_bh, NULL); + object_unref(OBJECT(s->iothread)); - virtio_balloon_free_page_stop(s); precopy_remove_notifier(&s->free_page_hint_notify); } balloon_stats_destroy_timer(s); --=20 MST From nobody Sat Sep 26 20:50:17 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=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1789076932; cv=none; d=zohomail.com; s=zohoarc; b=OCu5Bmvvltf7VSIjAiaaDqcIL43z/pnNefXDj+LDgNFjaSQ89jKuiwaLBQ7xildhdPMPF+przT4y0RQjJRnXb7AWXg+IoSbkjTIEAgcA2x3inlmlmLDrx4Uwt43ltqIksUxolat3/eAqsxVQivdVEPwaNYVJrI0WN1nIMfz5xEk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1789076932; h=Content-Type: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=XBW41WApnawDSx9a8mqXcCXFaaQqc3qyywi8ob8BaOU=; b=DAXChKyc4/uVXlQCDwV/vYEHxbqHUP2qMyQ5wT34DJ1jFG/UYjZtYpfu5jTe8qwSpuSsfARKZdNVNFBx6DnQQFsrzV2Lp9NmRNyAwUcjHwfailVBEl5Ba/55467e12LwC5hxnmHfHqN04eVXlFui01btyf+lMqfNKhNZliJ8AVI= 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 lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1789076932671427.22019979360846; Thu, 10 Sep 2026 14:48:52 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1x4mcj-0004ou-DJ; Thu, 10 Sep 2026 17:48:23 -0400 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 1x4lVh-0006PL-SB for qemu-devel@nongnu.org; Thu, 10 Sep 2026 16:36:50 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1x4lVV-0003BA-2l for qemu-devel@nongnu.org; Thu, 10 Sep 2026 16:36:35 -0400 Received: from mail-wr1-f70.google.com (mail-wr1-f70.google.com [209.85.221.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-180-A_Yw0YZ0NeSDUGVtiwI3xQ-1; Thu, 10 Sep 2026 16:13:51 -0400 Received: by mail-wr1-f70.google.com with SMTP id ffacd0b85a97d-4843e59c32dso64089f8f.3 for ; Thu, 10 Sep 2026 13:13:51 -0700 (PDT) Received: from redhat.com (IGLD-80-230-79-236.inter.net.il. [80.230.79.236]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-486eb33ebe4sm657519f8f.14.2026.09.10.13.13.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Sep 2026 13:13:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1789072383; 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=XBW41WApnawDSx9a8mqXcCXFaaQqc3qyywi8ob8BaOU=; b=HTJFBpsDbuUT+zPqEIfA3wrDVpmTDdJpmbTOrZwp2VFe65iA1+yz84ch/1DnDAqIU80bLu f0YDI9ZYYT8T3My+BHRY0pJ4yOkrCvU5Y4I7GJaUM7x25AiWIEM1GE2JXJqC/O9acGevdx N0tUaBGnAeZ+iBuHcuAWHKZe7qkaqWE= X-MC-Unique: A_Yw0YZ0NeSDUGVtiwI3xQ-1 X-Mimecast-MFC-AGG-ID: A_Yw0YZ0NeSDUGVtiwI3xQ_1789071230 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=google; t=1789071230; x=1789676030; 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=XBW41WApnawDSx9a8mqXcCXFaaQqc3qyywi8ob8BaOU=; b=VwH53Nj7UDhMPr5kx1p1gR9qQPOkgL3sVvkc/B+pqQW5SQ7QAbtdVker1hw49CG098 dHkqe8UqmhQoNY0FMLMJrzQhHCSZd1YRRDFbfxlN/CbyrzsNw09OmeH/zwRv2DcMVpxW lb/wRNw4ZJO8yYUrFAkP+2PYkWejzKbIcH+SIGN7PDvkhdTvP5ppckfJ6NPnyltMJEt6 CTPqxSgHddmKg2G02uuj7BAZPokigOTmOXxGP0exP5pN4ikn06Iy1Bgd5sMXWPOuFIEM AoQ7B1n6xcug0oV7xqfHOjlqu6kshcijcqEsMRtDpyMfHa4yMIjo6nLsjY4/5laqxmWp cqTw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1789071230; x=1789676030; 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=XBW41WApnawDSx9a8mqXcCXFaaQqc3qyywi8ob8BaOU=; b=s8F+LaEQMy5jc/MhZyiQ80XVc9EaHwb/BaZvbRVRzKv20qIlDs80kczxBTK7g3Fm/R mAFYoVr+1TLkEPd3Nn+jV7KQxIJsi0WXu842zvdawObAO0v2XU2d2Y1+ZzQRCfcKUGDe mX2JbUzyG7OxTZVAN9isFaM+wxODuPnE1gLWy2eAc5wMzHijsBJvB1Nc8D3Y4VZVqhdr 4dquExrGjDtAoG5J4eKsGo5Dw7sWLx7o4RAj2HYVUb8a6plLB2ur/YFK1A9hZyarjv3b rx7vdQXt9OMmn0qFdAf7U61qQ7zPtFOTNJy95L8JeX2lyYzPf32CU7zYJDwq/gyyQNah PofQ== X-Gm-Message-State: AFuF++my9D1l9EwGqAmapaOz2CNI7v94PDQ43BEEy2oRfqQbDpm15AO9 kdFPNizcgsclKzNLIC9IFZ7so5Y3zJhEnXitC/L1ToKNxiTxQe0IIj4vIVODDaGw4z0zEy8bTrU UEXyYKHLKnbYK8TRm1/YNApXq9zK7O6VSfQWu/9cEYfGXp1Oi44Ad/LIFSUokEZiLu3hWJupypF rNj90RCnC3Ex0yh1a1Z7ObByCPHaGQYLOFfg== X-Gm-Gg: AYBFou1nzAIYSnnltlHiigkEqaw1SkXOKgtfaDl3Q3bBDQ90E/YrrWT+G0FZu4ZWDNR cgVZCh18OjdyPLC7h83WqSAS3L7dL0OY0eUFxp8f5yCi99wg8KAsCeQFXa6rBgEmzG+yvwPudcw S4BBw6x8aAmsbOHnj1USAh+MNtNxnH1+JcGC5gCWjFvxbB5GjbeFf1QjggUC7rTKUZLojFjeCI9 yvA/xzkpwR89Y/oOvbIo8wkpLPf+3IR9JAnn6mFnOixvHXQfNXEfTUbe8qUuOEif//zN+FWrJt2 nyiy6zTC6L9i7mvVlQGnEjBCRIMEFts89ttZRwv+jv+SsIEmNGjqZfb4urmq0PeDPeZtCrivX/7 UUY50AlBYZHfEv8jUs7+JAsY= X-Received: by 2002:a05:6000:4007:b0:486:ed36:b99 with SMTP id ffacd0b85a97d-486ed360d6bmr192842f8f.55.1789071230221; Thu, 10 Sep 2026 13:13:50 -0700 (PDT) X-Received: by 2002:a05:6000:4007:b0:486:ed36:b99 with SMTP id ffacd0b85a97d-486ed360d6bmr192802f8f.55.1789071229754; Thu, 10 Sep 2026 13:13:49 -0700 (PDT) Date: Thu, 10 Sep 2026 16:13:47 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Alyssa Ross , Manos Pitsidianakis , Stefan Hajnoczi , Stefano Garzarella , Pierrick Bouvier Subject: [PULL 56/90] vhost-user.rst: fix typo Message-ID: <7b37b1670c0d09d100afb73b99c65ea33082909e.1789071043.git.mst@redhat.com> References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-Mailer: git-send-email 2.51.2.2891.g4157995a80.dirty X-Mutt-Fcc: =sent 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=170.10.129.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com 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, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=0.001, SPF_HELO_PASS=-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-Zoho-Virus-Status: 1 X-Zoho-AV-Stamp: zmail-av-0.2.13.1.5.4/289.74.40 X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1789076934709158500 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Alyssa Ross The protocol feature is named SHMEM. SHMEM_MAP is one of the requests. Fixes: 588acb45c2 ("vhost_user.rst: Add SHMEM_MAP/_UNMAP to spec") Signed-off-by: Alyssa Ross Reviewed-by: Manos Pitsidianakis Reviewed-by: Stefan Hajnoczi Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin Message-ID: <20260804121000.444745-3-hi@alyssa.is> --- docs/interop/vhost-user.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/interop/vhost-user.rst b/docs/interop/vhost-user.rst index ae8c7ed995..fbfb9d01c6 100644 --- a/docs/interop/vhost-user.rst +++ b/docs/interop/vhost-user.rst @@ -1158,7 +1158,7 @@ Protocol features #define VHOST_USER_PROTOCOL_F_DEVICE_STATE 19 #define VHOST_USER_PROTOCOL_F_GET_VRING_BASE_INFLIGHT 20 #define VHOST_USER_PROTOCOL_F_GPA_ADDRESSES 21 - #define VHOST_USER_PROTOCOL_F_SHMEM_MAP 22 + #define VHOST_USER_PROTOCOL_F_SHMEM 22 =20 Front-end message types ----------------------- --=20 MST From nobody Sat Sep 26 20:50:17 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=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1789075890; cv=none; d=zohomail.com; s=zohoarc; b=CmQxL48peb7s9T8hm/5xSZi5bDIVuBknZY17C7YKqitiv5i88jJs9eokyPI2tt4xobBGyp5P9GRWM4GDzPJSzxbDB7Vd37Kp9r7GkPnOVCS7ju9OSujuGloKgDoP4VilAiQo/MHcNQ3SZokx8qcutkw6P1e2FD7afVLmXoy95Es= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1789075890; h=Content-Type: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=PDrhF8GFxx7xPnASxg3T8JG+Bhc76LAfLhogtUAUv9Y=; b=KWlNuHA2mLV7a9lHood9bS8O8k/7VSmJKPhebLFuwdqeb2vq+NIYzqIrjtqIqVAI3FAtKfVPAp4IV7ZB+NgiV+srCJ6Q/WL9vhKfe7nA6Ki5ZqLAJ1uB9TGS3E91D/EIEKj+Pmh7whD9a7lRWL6Kk7dQEQeZuJl47AYXURRUEXs= 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 lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1789075890209538.0762773741432; Thu, 10 Sep 2026 14:31:30 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1x4mHS-0000nJ-Is; Thu, 10 Sep 2026 17:26:31 -0400 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 1x4lJU-0002KQ-8L for qemu-devel@nongnu.org; Thu, 10 Sep 2026 16:24:08 -0400 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 1x4lJ7-00085B-35 for qemu-devel@nongnu.org; Thu, 10 Sep 2026 16:23:51 -0400 Received: from mail-wm1-f71.google.com (mail-wm1-f71.google.com [209.85.128.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-605-DwJAN87sMwmrNjtATGOavQ-1; Thu, 10 Sep 2026 16:13:54 -0400 Received: by mail-wm1-f71.google.com with SMTP id 5b1f17b1804b1-49564d4b849so500465e9.3 for ; Thu, 10 Sep 2026 13:13:53 -0700 (PDT) Received: from redhat.com (IGLD-80-230-79-236.inter.net.il. [80.230.79.236]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-49d26be3e0asm100957055e9.1.2026.09.10.13.13.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Sep 2026 13:13:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1789071603; 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=PDrhF8GFxx7xPnASxg3T8JG+Bhc76LAfLhogtUAUv9Y=; b=i0toPnbGEz1FN/EnR4vPWn6YPBr6+WoGk6hMJ92/pdjVY+Jg4plqaEvLXL5aOaY9XztHAO qWpFgZsOJt0IkYbpIZ7MfgDtuwGgHMBkKbYpK16PZTOsv0Y/oH/jNsKW1qLRHuK7+JCRFx fQEq+HvmhQpXl8iZ3NEraA5gjVsVwu8= X-MC-Unique: DwJAN87sMwmrNjtATGOavQ-1 X-Mimecast-MFC-AGG-ID: DwJAN87sMwmrNjtATGOavQ_1789071233 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=google; t=1789071233; x=1789676033; 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=PDrhF8GFxx7xPnASxg3T8JG+Bhc76LAfLhogtUAUv9Y=; b=LgeGEGTd8XjsVuuYK2H5UO+P8sQAZwjk8aNWuvrS2vUMs/WuY5FC0o8IlxsFIAxXj/ +cIydKe1paXvbx8sWmreBmyvXzfxNzPHUgnykH+3VZuJIOLLe7UdWfonLcg2uGNwG82N POlsVoixIsE8O+BK+rqK+qPFvMFXZKnfXZukQf85lY4wNCuZH8vgeavIY7TitQZJ3h5L SqZff7BXZGUi8JaXwGgsXX+JiA1zGRel+ZoY/p5yKrWFUZwrPIsIBLWdykvTXNpPFhpM /L0/NnifTpagrCUw8e1rLnHQ/4wS2oEQKQQbeGq87Xtgm5jB2rAWBgDsc6ezEApXeQ3Y iLTA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1789071233; x=1789676033; 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=PDrhF8GFxx7xPnASxg3T8JG+Bhc76LAfLhogtUAUv9Y=; b=QcSjYhREx9L343DCb4OV/tvSG6pn7u0AjZd44+1XynEc4HYfTxhbw50bvZABr0s4KG GxT+aF/ju6klO9Mz1gfvgy/SIHwDY/I8sfesjE0croxmY8coEgnUqufwO+FuzcqXdeFs DWc3ZYvHTiD1O1Nsb6yv+uz/yzMqzkOBd5mRktlxyBsr6NwLqr4UlTmQKxjaJ9qvs9Bd KJlDBK2D4PktivJow3TX0ZPdUxzjxoljCkv/Akr2ZD9FIFo6lfxBo+vrSX4UcY08tRKv ol7HpyaVmQ6nGCeaTeAP02WIEYkQAC0CC1cSUcRGoW3pKprV5Ze9VCedlbTZp8neBp8D b7JA== X-Gm-Message-State: AFuF++keHG7TXMCfsZ5SDvUm6z6GGXBBazaQkEA0J0uTzF5oMz9LI7w6 CMzLeIyri6XR+EdzrC8JV44ZDFx9pmH3kjx8tEmjtSQVGKE0TgaEFhm9uNUJ1yPRiNuA0MCBOqo s+54Owv9/9PJNkeguWLVxLNOVVu1gEgxK5hnxLkQk18eOZkLzEkNpj83UI+yL3Ytwp0v4QJD8ih bl7OJKffjqp8pS1PvhBgyEfkZ0mzScbF3E5A== X-Gm-Gg: AYBFou2uGkOWzNADrWz6W2rNDU0dkTnYOLy+EY8LmyQMsDP3BZq+ZN/XDkXSmJHFkcA Iro4LKQaKZHZ6vQQxSVdCvU4AdKOSiZ+fpcmL/irSR+L8QPeehT2r0nFtNGcAe6lsMKPAHtIIYn POX5A/XbGknGhjfgC/ZaYa7WLJ4mS+lgzQPZbITjK+g4V2R5QL26ScrR+rzWzCqdRgJhCnvKOdc VhgwRtG6iH+0l5Oms8GWj75Zwet7HdRAksPbXKTsKWCbbTHs9KAY5ZEksmOtAj5DiMa1QHnPRfx vHx19Iev+eAqL+YgbQ8lXQfi65CiEmC5JghIyNqeXinh3UncdeHozFXH9wrHbg2SlcjZXqFqoPG 3PQsGNsGnKmJmjT6MQnSXAO8= X-Received: by 2002:a05:600d:864d:10b0:499:bf8c:cfd1 with SMTP id 5b1f17b1804b1-49e61983764mr5917505e9.2.1789071232651; Thu, 10 Sep 2026 13:13:52 -0700 (PDT) X-Received: by 2002:a05:600d:864d:10b0:499:bf8c:cfd1 with SMTP id 5b1f17b1804b1-49e61983764mr5917075e9.2.1789071231989; Thu, 10 Sep 2026 13:13:51 -0700 (PDT) Date: Thu, 10 Sep 2026 16:13:49 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Feifan Qian , Albert Esteve , Stefano Garzarella Subject: [PULL 57/90] vhost-user: Reject SHMEM_MAP when no KVM memory slot is left Message-ID: <45623631fdf38e6a725bc2487ce22a04f04c40ae.1789071043.git.mst@redhat.com> References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-Mailer: git-send-email 2.51.2.2891.g4157995a80.dirty X-Mutt-Fcc: =sent 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=170.10.133.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com 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, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_PASS=-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-Zoho-Virus-Status: 1 X-Zoho-AV-Stamp: zmail-av-0.2.13.1.5.4/289.52.80 X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1789075893370158500 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Feifan Qian Each SHMEM_MAP request creates a separate RAM MemoryRegion that consumes a KVM memory slot. Once all KVM slots are in use, processing another SHMEM_MAP request would make the KVM memory listener fail while registering the new region. Shared memory mappings are filtered out of the vhost memory table (vhost_section() skips TYPE_VIRTIO_SHARED_MEMORY_MAPPING regions), so they never count against the negotiated vhost-user slot limit; only the KVM slot budget applies. Reject the request with ENOSPC before changing the memory topology when KVM has no free slot left. Also validate each vhost memory table against the slot limit negotiated with the backend before sending regions via SET_MEM_TABLE or ADD_MEM_REG. Fixes: b52e1896e764 ("vhost-user: Add VirtIO Shared Memory map request") Signed-off-by: Feifan Qian Reviewed-by: Albert Esteve Acked-by: Stefano Garzarella Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin Message-ID: --- hw/virtio/vhost-user.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/hw/virtio/vhost-user.c b/hw/virtio/vhost-user.c index fac02a1ffc..f737a05d07 100644 --- a/hw/virtio/vhost-user.c +++ b/hw/virtio/vhost-user.c @@ -1126,6 +1126,13 @@ static int vhost_user_set_mem_table(struct vhost_dev= *dev, dev, VHOST_USER_PROTOCOL_F_CONFIGURE_MEM_SLOTS); int ret; =20 + if (mem->nregions > u->user->memory_slots) { + error_report("vhost-user memory table has %u regions, " + "but the backend supports only %d", + mem->nregions, u->user->memory_slots); + return -ENOSPC; + } + if (do_postcopy) { /* * Postcopy has enough differences that it's best done in it's own @@ -1980,6 +1987,17 @@ vhost_user_backend_handle_shmem_map(struct vhost_dev= *dev, } } =20 + /* + * Each SHMEM mapping becomes a separate RAM MemoryRegion and thus + * consumes a KVM memory slot. Reject the request before changing the + * memory topology if no slot is left. + */ + if (kvm_enabled() && !kvm_get_free_memslots()) { + error_report("No free KVM memory slots for shared memory mapping"); + ret =3D -ENOSPC; + goto send_reply; + } + /* Create VirtioSharedMemoryMapping object */ VirtioSharedMemoryMapping *mapping =3D virtio_shared_memory_mapping_ne= w( vu_mmap->shmid, fd, vu_mmap->fd_offset, vu_mmap->shm_offset, --=20 MST From nobody Sat Sep 26 20:50:17 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=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1789078391; cv=none; d=zohomail.com; s=zohoarc; b=LfNAt9QzOdHyACCRpuDJ2Vqq8O/cQs3wRQ4KAnZSnimdvE5k8pXrL5Aoy3bXM4StLozQCd1GIEV7FIn/e2lCTijDB6dCGE5r5/GcyhKxttr0ZDhkuSaWAdfU4Mm41edUlUofMJTTguCQEoHvNSsw8W2ihy2iBJWIFmVYbzRll0o= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1789078391; h=Content-Type: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=hsEZfCYpQa9toaMH2oc+Rwd2XMpw3IccFW5x9qsdK3I=; b=Gr2aUVsv0tBvHExafv4isLQG/LYgB5xxPlTjD2x9MRBSTE0qzrdR9cF5X5oblavGzJQxIabBi+I6f60ht5fAzz5pjgiWVBdlXu629B7GKjbViSUzdvroe4JiwwAiCykOP6MxyNbTtaeWKCIAt172785RfMFjQWTczHPUQno+oYI= 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 lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1789078391237778.4509261502509; Thu, 10 Sep 2026 15:13:11 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1x4my9-0001PW-5v; Thu, 10 Sep 2026 18:10:23 -0400 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 1x4lVZ-0006ND-If for qemu-devel@nongnu.org; Thu, 10 Sep 2026 16:36:41 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1x4lVC-0003gm-6J for qemu-devel@nongnu.org; Thu, 10 Sep 2026 16:36:21 -0400 Received: from mail-wr1-f71.google.com (mail-wr1-f71.google.com [209.85.221.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-122-x9w56P0JPBu3KpXsAqM09A-1; Thu, 10 Sep 2026 16:13:57 -0400 Received: by mail-wr1-f71.google.com with SMTP id ffacd0b85a97d-48589603501so62907f8f.3 for ; Thu, 10 Sep 2026 13:13:56 -0700 (PDT) Received: from redhat.com (IGLD-80-230-79-236.inter.net.il. [80.230.79.236]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-486eb34f353sm768655f8f.26.2026.09.10.13.13.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Sep 2026 13:13:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1789072442; 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=hsEZfCYpQa9toaMH2oc+Rwd2XMpw3IccFW5x9qsdK3I=; b=bBjFkbtxVo54O/IulXiWRfx+YgZGGN2oG4NY69sQ+L+6/MF6BN9gdTzIpzrol8cViWEqUJ kvD9C07pF6z4tC8oyNe6B/joK8pR7aKTNKZwORjmqSI2Uy8YUiqw531hnEcNSOjZ3R0m4f YTUsnbzhC9uYYtIb6DPyBDnd9oDhdGk= X-MC-Unique: x9w56P0JPBu3KpXsAqM09A-1 X-Mimecast-MFC-AGG-ID: x9w56P0JPBu3KpXsAqM09A_1789071236 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=google; t=1789071236; x=1789676036; 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=hsEZfCYpQa9toaMH2oc+Rwd2XMpw3IccFW5x9qsdK3I=; b=LAPqKFY33ldOq3JelBgdHhv95MZTPu4uhQA3h3p6G8RHsBiWsVKNVeNAiGyfoEDVRh 8PEemk7poeHZ/a/9qmAGOJgJjCn43yk2SXreZNSKc5Tvw9UylDlrcqrf7BV0LQoVLeaP lmlrqMo6Tr2f6LF+KDJmfNEQzLnRrcpwEI5q+2kTE9p0H7y/RF9tgk5wFfN4kB3zytcZ ZrmfzXbPQalLTMBQMLasPrdEtc7gRd1q8C/LuMf+smVZUyigZx2tzsd9YMqjkIRulqgQ iwW0L30u/ORHEWBS5V7XNCulRgQ43JheFp4T4TmPqwB1r8nihZCuCLswMYpkvoB6wzgC M1yw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1789071236; x=1789676036; 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=hsEZfCYpQa9toaMH2oc+Rwd2XMpw3IccFW5x9qsdK3I=; b=HuiLqisZTHX7ZHUgvI1DnVYjmSOict30R3U3e2Q51dIxa4yXLBdf73njmIIyNvcrEx sY67nndYrB+T11Dqri8XMFLhWebMMpAucR/WUE590t0EPwe9h+fmVxyrXLj9b7xikCsw pW4cDiZkN8Dj8GzgRjaDOl3cjAxKTTS/eTF0ubputW4bo/0aEnIJgvNxb/GK7hGzBzXf JSJbfrGJdh2rXAgAd7nXOScu18tq50whCkevQYagjrDs+2i35SLVhJ6KBScFHzq5b0w2 6oh1iZEa9YNTEKCACYbnWoe0xmRddWa0NvVOZF/5/WVgUnzMatwqFA///KdPl1Y9MwuA VqXQ== X-Gm-Message-State: AFuF++k8tKDIQQ7MNAZxpdT9ypvbH7ezxIVfGMdjyMcAyewUwUOnIaO7 qKFzBwLIhVkc8qrr1L5QE2ZCXNiHZtRry6OqATrBNjYLeWqm4+YoDiCkB25WJcuczxMxlV6OBmQ A8sxKCZcKLzJrONiarz8KY8hvdwMIpd5GYgpWDkb9zisJ0NSrNc6tXNxPrOCROab1F0dBCyWFs0 1zqSLJaGkDMbzKC8USH7AV8Nn+HuRxNfcBQQ== X-Gm-Gg: AYBFou2M75cb5lV7SURwrjOyjJaM/u6Bkw7QCwCpMKB9yAsljjga8ecirNYhCMB4NuJ wIi6spq5J2ne5ikNZRSb6CsdsuYp7jNW4xwATOWbPui5n7ORJ5qTjVugDBtDC206qPWeR9nGQiA 2tQATewnxn0HOrncAUVJ/vQfD3T4TROhIWh67PTszctv1F1PGIzv7YqznYgWsYfD6zHf820vb2i P7jVbhGclLKyvQl6jiPOLUGrP+V6rdnED/ch5aKfseegXnl5Utr38uUQ46xNHJ2CeVBSALm3Ut1 oNZSNiezCMJ9N4u0xdbzG2xF0WiZ5vPmNAygVrkqMM7XHdGlQbLr9KpQWq9eV/76o+hgx0hhLRY 3jAkniE6DdEAXb/gdxUyARvY= X-Received: by 2002:a05:6000:4717:b0:485:8c16:a357 with SMTP id ffacd0b85a97d-486eb358c5dmr606786f8f.47.1789071235738; Thu, 10 Sep 2026 13:13:55 -0700 (PDT) X-Received: by 2002:a05:6000:4717:b0:485:8c16:a357 with SMTP id ffacd0b85a97d-486eb358c5dmr606744f8f.47.1789071235238; Thu, 10 Sep 2026 13:13:55 -0700 (PDT) Date: Thu, 10 Sep 2026 16:13:52 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Xiong Weimin , Stefano Garzarella Subject: [PULL 58/90] hw/virtio: Propagate vhost_virtqueue_mask errors Message-ID: <22ffc542a1ab7ad898e3efacc0ce16c68ae85c73.1789071043.git.mst@redhat.com> References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-Mailer: git-send-email 2.51.2.2891.g4157995a80.dirty X-Mutt-Fcc: =sent 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=170.10.129.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com 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, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=0.001, SPF_HELO_PASS=-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-Zoho-Virus-Status: 1 X-Zoho-AV-Stamp: zmail-av-0.2.13.1.5.4/289.74.40 X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1789078394582158500 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Xiong Weimin vhost_virtqueue_mask() currently reports failures from vhost_set_vring_call() but always returns void, so callers cannot react. In particular, vhost_virtqueue_start() has a TODO next to the unmask call when !use_guest_notifier_mask. Make vhost_virtqueue_mask() return the underlying errno, and on failure in vhost_virtqueue_start() jump to the existing fail path which unmaps the vring and propagates the error to the device start caller. Other call sites keep today's behavior by ignoring the return value. Signed-off-by: Xiong Weimin Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin Message-ID: <20260807024359.2157914-1-xiongweimin@kylinos.cn> --- include/hw/virtio/vhost.h | 9 ++++++--- hw/virtio/vhost.c | 10 +++++++--- 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/include/hw/virtio/vhost.h b/include/hw/virtio/vhost.h index 7c4f032996..cd012b99a2 100644 --- a/include/hw/virtio/vhost.h +++ b/include/hw/virtio/vhost.h @@ -359,10 +359,13 @@ void vhost_dev_set_config_notifier(struct vhost_dev *= dev, */ bool vhost_virtqueue_pending(struct vhost_dev *hdev, int n); =20 -/* Mask/unmask events from this vq. +/** + * vhost_virtqueue_mask(): mask/unmask events from this vq. + * + * Returns: 0 on success, a negative errno on failure. */ -void vhost_virtqueue_mask(struct vhost_dev *hdev, VirtIODevice *vdev, int = n, - bool mask); +int vhost_virtqueue_mask(struct vhost_dev *hdev, VirtIODevice *vdev, int n, + bool mask); =20 /** * vhost_get_features_ex() - sanitize the extended features set diff --git a/hw/virtio/vhost.c b/hw/virtio/vhost.c index 838b1da739..6c2612a1dd 100644 --- a/hw/virtio/vhost.c +++ b/hw/virtio/vhost.c @@ -1481,8 +1481,10 @@ int vhost_virtqueue_start(struct vhost_dev *dev, * will do it later. */ if (!vdev->use_guest_notifier_mask) { - /* TODO: check and handle errors. */ - vhost_virtqueue_mask(dev, vdev, idx, false); + r =3D vhost_virtqueue_mask(dev, vdev, idx, false); + if (r < 0) { + goto fail; + } } =20 if (k->query_guest_notifiers && @@ -1962,7 +1964,7 @@ bool vhost_virtqueue_pending(struct vhost_dev *hdev, = int n) } =20 /* Mask/unmask events from this vq. */ -void vhost_virtqueue_mask(struct vhost_dev *hdev, VirtIODevice *vdev, int = n, +int vhost_virtqueue_mask(struct vhost_dev *hdev, VirtIODevice *vdev, int n, bool mask) { struct VirtQueue *vvq =3D virtio_get_queue(vdev, n); @@ -1983,7 +1985,9 @@ void vhost_virtqueue_mask(struct vhost_dev *hdev, Vir= tIODevice *vdev, int n, r =3D hdev->vhost_ops->vhost_set_vring_call(hdev, &file); if (r < 0) { error_report("vhost_set_vring_call failed %d", -r); + return r; } + return 0; } =20 bool vhost_config_pending(struct vhost_dev *hdev) --=20 MST From nobody Sat Sep 26 20:50:17 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=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1789086495; cv=none; d=zohomail.com; s=zohoarc; b=Y1bdA2IeM7Fh+EaoYMyg7bd1kwATeOSmsHB/5uxnmOKPYr/IZw7rwJbF6zJt7Qinhrd5HSzWPv7FO62zyXH4T0Qj3EK7QpzudFBzuJrz3kHtpqpLil75KdFd7pqgvrEVnAYg5EsViEdrQFyQ30ZL4yUkDrbIRxsPxTvXTSPqHK8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1789086495; h=Content-Type: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=+sod/F5ZJD19JAbUugoGre+d4N7kWAhYD4EQjfTMC7Q=; b=kX3nFxMzz3CJZWr/u1FiDgdF20vNVqIr7JW8ucs/Ke4AbWJ8kVPwK2i7XCIPY25JQSLkNq2ovYzHFnv/Jzyb/LwnNE4ikKk/ZXCULdkZqdJQIoKNNNi172N9VbEMGt1TcBWNp9GVa2DTZbVxfo1p8F/RtLKKILoDtxVcej1YXHg= 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 lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 178908649534592.70431659537667; Thu, 10 Sep 2026 17:28:15 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1x4ot5-0001Oe-OA; Thu, 10 Sep 2026 20:13:09 -0400 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 1x4lV9-0006I6-BT for qemu-devel@nongnu.org; Thu, 10 Sep 2026 16:36:20 -0400 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 1x4lUq-0003CQ-K2 for qemu-devel@nongnu.org; Thu, 10 Sep 2026 16:36:02 -0400 Received: from mail-wr1-f72.google.com (mail-wr1-f72.google.com [209.85.221.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-632-r_6EDSupOFSXp1y2BzjkbA-1; Thu, 10 Sep 2026 16:14:00 -0400 Received: by mail-wr1-f72.google.com with SMTP id ffacd0b85a97d-482e05af072so99785f8f.3 for ; Thu, 10 Sep 2026 13:14:00 -0700 (PDT) Received: from redhat.com (IGLD-80-230-79-236.inter.net.il. [80.230.79.236]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-486eb32e6f1sm814687f8f.6.2026.09.10.13.13.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Sep 2026 13:13:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1789072391; 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=+sod/F5ZJD19JAbUugoGre+d4N7kWAhYD4EQjfTMC7Q=; b=W0IciWMsDvS9o/KohcBSa79V3Za4jb1X3TOVwrD+5zaG0Qm4SSDXgCm7ZHIO0MRdXPhaX8 1v5LBid+hSlc8e9bN9UDxJNnZfdZoh/R9GwkSrpMM5J+zmmDFZjebpyCtWFz8b6w0PQsFE sfwZWtohfAxVCp3cf8Vf27XnA7o99b8= X-MC-Unique: r_6EDSupOFSXp1y2BzjkbA-1 X-Mimecast-MFC-AGG-ID: r_6EDSupOFSXp1y2BzjkbA_1789071239 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=google; t=1789071239; x=1789676039; 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=+sod/F5ZJD19JAbUugoGre+d4N7kWAhYD4EQjfTMC7Q=; b=B6c7jCgHhx054dWaxfTINLJRBW/8Ati7ZosJtMgTU0hoJ+dC5oLnw4Oh3USoCwzNtg 2ZeVONyqmtYGkccABqh9P6qpBM7bWcbOdP2R8UfZ+pvjS46DlIRd825zDh91UjwAGOEX ybe8CSxlCa6BbhRm9xC2ieNbIpN8B1OoknEsDXShn6FeZxgRWfOkcDbYDZwuUVkssC3+ qkhRTYcQG9dp0P/5mX1intu1Xb4eN/Bvz1E1G9WcH4JRN/5Xcm8b7BAlSD5/t/QfsPJV 7ZKL4HWp+NJvsUrdlA0FFZYyePG3SKXtlr4CbqTBR2mfYAcmzT0W6+qw9So1UXPZoZcy I10w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1789071239; x=1789676039; 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=+sod/F5ZJD19JAbUugoGre+d4N7kWAhYD4EQjfTMC7Q=; b=daU58p9pcCJUqnDoT9IWOmNBSjd8gFWMicqraOpJshPvgsY4/lWMISscUcTc8YLTyD SOsLz/0hSXpY1irsKOtaOEh8eyXyw3Jity/pLAHwMIFSn4/NYXK2jWmHzdM1uuSNNmm1 rS5FSgdmgrUVwpfssgizZzwJlPfETXS4kKfMQobh/pZx7QxauxTpem1MM5dRfoZumJiz n8HOztquO5pNeJ2vBC0oMi26k4Q7jmToo5jfiLp7qXrzUxMaUQaG6jOGrd+UhpzmPzBJ G81ZRAnYEtgCjPa9JpuVZx8S2j0e4nFV0ItP7Stya6EwhlnhEePH8Fi0PNaVPZWu5dFO +Gdw== X-Gm-Message-State: AFuF++nCF9zWCJYmgE3nlQU8SWT48dZXMzeR2seNuRUrFCUoh2oQo2xY OWzxcjHsBhifyGUl6GznTo+81vMrLKVGFuCTTaWZL005EbIF9iCcPavhzwE7njQuWEXq97bj+oo fMLDcfjgcs0xEQ28l4INpg3yL+O3GKvAscPIgwvc7f2nzB37T9vBSUR75Y1ZjdObZFilB0e4x9h o4WsetYvlPEiDtPInP6HHMR04mXUBJOznJPA== X-Gm-Gg: AYBFou0eiEq9Y0qYqePyIdEYX53EPq42ZSBZQlCghYN/CpCa4cVLVG8EjwdOcL3UFMV rIODkWbi7GM4dETSh/bzCLNlDfCWz1aMGgvhlXedfYD7Zt1dTMAuN8Mtj7EdUvv2mGbFx6OG5Io Uj1y5WhaGsotrOI/TYD2WhEI4PXfi+VdPeoAjlEwzkDJWbS9G4LzpP0cUJOgpTw5tGv8wTt88nA 8PyGoUY6fdk0GHNND2GPSrAEO6U8hmo1SqnevkY+LKW/BRJI+OBHFAKim2dmShYZ5G2+TBezlCL 0n7SoOjudoLeSZM7GCmAhgmMcD5Bt3EX8i9wtkqC16eD7cW7Pb+fOymjAw5bxzXTkaurvJWzmSB ZWohTtyQiI9cYBYz/9jXStb8= X-Received: by 2002:adf:ee86:0:b0:485:b148:aa0b with SMTP id ffacd0b85a97d-486eb300f56mr524341f8f.36.1789071238878; Thu, 10 Sep 2026 13:13:58 -0700 (PDT) X-Received: by 2002:adf:ee86:0:b0:485:b148:aa0b with SMTP id ffacd0b85a97d-486eb300f56mr524312f8f.36.1789071238271; Thu, 10 Sep 2026 13:13:58 -0700 (PDT) Date: Thu, 10 Sep 2026 16:13:55 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Sairaj Kodilkar , Alejandro Jimenez , Paolo Bonzini , Richard Henderson Subject: [PULL 59/90] amd_iommu: Return empty efr for stub call Message-ID: <374b65875652e44c72e0a3b6120338f79eea58b0.1789071043.git.mst@redhat.com> References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-Mailer: git-send-email 2.51.2.2891.g4157995a80.dirty X-Mutt-Fcc: =sent 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=170.10.133.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com 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, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_PASS=-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-Zoho-Virus-Status: 1 X-Zoho-AV-Stamp: zmail-av-0.2.13.1.5.4/289.74.40 X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1789086496749158500 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Sairaj Kodilkar The stub call should not return normal EFR as it is used as place holder when actual AMD IOMMU calls are not available. Hence return 0. Signed-off-by: Sairaj Kodilkar Reviewed-by: Alejandro Jimenez Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin Message-ID: <20260807061250.27739-2-sarunkod@amd.com> --- hw/i386/amd_iommu-stub.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hw/i386/amd_iommu-stub.c b/hw/i386/amd_iommu-stub.c index d62a3732e6..fb36dee903 100644 --- a/hw/i386/amd_iommu-stub.c +++ b/hw/i386/amd_iommu-stub.c @@ -22,5 +22,5 @@ =20 uint64_t amdvi_extended_feature_register(AMDVIState *s) { - return AMDVI_DEFAULT_EXT_FEATURES; + return 0; } --=20 MST From nobody Sat Sep 26 20:50:17 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=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1789086337; cv=none; d=zohomail.com; s=zohoarc; b=BLPOqYcOTNBysCPmuWN2FmkD5cjpbVl4tkMux7oC3SvfuBsTRlCVv90p3kKwrB1bmzmcCDC5YSyn1f7v8aDu/ibgsnrRt9ppzfHUmNv5hEAAKkd3ipM9Xc+1ch2/HeaH+9UiNfLvyvKaX1VapZKaOOCBX/xC/CNChuZZ5lWsAhY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1789086337; h=Content-Type: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=mBiB/jOHXjADUICu4zFhNVY6emnuWrVA0Kv/cK2oUiY=; b=lFjT/8kY3d6vLgtQcBiRyf0D7kCAoymu0hEj8jbWFeeUmAbFyQasMr9Vs3FfNLiYIJRty+0Pe7FioRaqF0FOuRHaHC9qtHZ9Lfxswp/jT1AWt6sBqN/Mo+Hh4WhLmtukT//gRwjvvVsOsdORlmtpVvkx4c9y6VnJ8nGB0K1I7eg= 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 lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1789086337383976.7398773158606; Thu, 10 Sep 2026 17:25:37 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1x4oqu-0000QT-BW; Thu, 10 Sep 2026 20:11:09 -0400 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 1x4lWL-0006Uw-Ka for qemu-devel@nongnu.org; Thu, 10 Sep 2026 16:37:23 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1x4lW9-0003ga-5o for qemu-devel@nongnu.org; Thu, 10 Sep 2026 16:37:15 -0400 Received: from mail-wm1-f71.google.com (mail-wm1-f71.google.com [209.85.128.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-423-CkEdhRMZNACH-fgFurVxnA-1; Thu, 10 Sep 2026 16:14:02 -0400 Received: by mail-wm1-f71.google.com with SMTP id 5b1f17b1804b1-495569acf8dso878525e9.1 for ; Thu, 10 Sep 2026 13:14:02 -0700 (PDT) Received: from redhat.com (IGLD-80-230-79-236.inter.net.il. [80.230.79.236]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-49d26c1bfb5sm104235585e9.5.2026.09.10.13.13.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Sep 2026 13:13:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1789072441; 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=mBiB/jOHXjADUICu4zFhNVY6emnuWrVA0Kv/cK2oUiY=; b=Wk2YTbEemqFfjj/txNXYH4nEb2GhFwJ6lkdF2Z/JRDpAwJyYQB7mqGfSzIbigItv3NlJ1f SBeFTz+kEp9LQfSDrMcPE11c+WsvT06+JATG+JYXbelfK2ja47K2XgkWKc399nizWlRAFo tdkrlGPO41r1IH17/KxgZGseUoR9B7w= X-MC-Unique: CkEdhRMZNACH-fgFurVxnA-1 X-Mimecast-MFC-AGG-ID: CkEdhRMZNACH-fgFurVxnA_1789071242 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=google; t=1789071241; x=1789676041; 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=mBiB/jOHXjADUICu4zFhNVY6emnuWrVA0Kv/cK2oUiY=; b=rdjWUnKB9dzXEHuDOm9oOL/u2tHy6FqzJdIT1LUJRkPS07oN1S5fY918ydvO4c79jC ivgzGTTjKZEOginxMISesIH2fTRDIZh43OyUYYQw+QM64jEoS4F6aGSUJfXp1WP9q7k3 /A+XyBj02wDEvW+UPylVKX9866GEzPQLY1QDP0CYWVvlQ6G8UjCGLluRGZrAfO1gCNFc h7i0mEfGIKEJkWulxfyZmG8xpf7/k8R4ZrWXjXnoaa6UhTZh0O7dhvGjD8d4y61Xmo7v grQhspksQgJuMYKk/YnyAnbM/4cA4gLZo0TmpR9TFRf8TvpD3UyKkDEZPatoJyk70mWE Hthw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1789071241; x=1789676041; 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=mBiB/jOHXjADUICu4zFhNVY6emnuWrVA0Kv/cK2oUiY=; b=M4THvBJOALTwjSk4gYMpJMwMiMP4NlpvEZlpuVenlE+XEDrNFW+3amBHVHhZtHpdwA 6J4a8NsaiToogUJAKjT2lKSY9MSTZ6UID3H8nkE8419z36lPfFuZUts4Is4Yf9G6Jx72 c9Kncmc2oijFabzvX0edO3ZifaRevNiMJM0f/QpwBAqzBL97fcAhfKAxJNCt8hpWTLm6 wyFJ28N3pT4wf1Fyb5FvJ9erZiCkYluktceve/vAb06UVqVxjwuHwt4lA3Rwmut7Tm/6 H48qM22E7fJpkSzNFKyQZ+FKzRt/cUotlCegZyGJ95EIYwo49H56fHBnmSUilUKo8Dly l+4g== X-Gm-Message-State: AFuF++mX9YbTHrHUn6jXLLg84KSebl5+Rl75sh+h29myuQ2qn5DImt8e vVp7ihnxHU8RdkFglPAKEAIoJxThfbcXEoybaf4DjSJ6L13oAy20ypYuct58nDNtwxUsT/4Qu0W 4VHAIDYSE5FOi82txSnSMgj9IpX3bWhZBMDSoS4V038Ccxr9mYLtXAByt1eYZu2ozmmNZXoC8ux iqxDRLo80Tbk92fZI+Xm0MP5eNZyB1AA1pKg== X-Gm-Gg: AYBFou1YFNWcIORSkPjfbiqqsZgaFqQoA6JkUg0dGVCeUh7v2SIumlNS5FguAv+5AsU zgPkYZ2kOu3nnfAO7vK25TPau5TUuhQhMhvxTNonQtKIKIIgESca09B9H9Q26hfdZawSIbX5ma5 nvJyCq7fJ8pj199qWss8WOub1V8WVe6Es0WpjS8bH0qMv3EmYSV7ryzLFTDBlMpo+2l81pb4KMZ JthgcQv5HMzb+/+sbY+Pu8AW2qsBYCMgpatQGevY7LAMOnDmZ1bL904wMGbwILGlFH/h9QdGg+G 2UdZM88q2kLEys0Qt/u9+sTeGFq+0hq0tfHugZLIOdJxYRfIFSageBfB6KsILiKRuEhDywYoO40 ktK6qjswGk57OxudJKBefsIg= X-Received: by 2002:a05:600c:8518:b0:49c:edfe:d525 with SMTP id 5b1f17b1804b1-49e619acc89mr19498725e9.10.1789071241547; Thu, 10 Sep 2026 13:14:01 -0700 (PDT) X-Received: by 2002:a05:600c:8518:b0:49c:edfe:d525 with SMTP id 5b1f17b1804b1-49e619acc89mr19497875e9.10.1789071241044; Thu, 10 Sep 2026 13:14:01 -0700 (PDT) Date: Thu, 10 Sep 2026 16:13:58 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Sairaj Kodilkar , Igor Mammedov , Ani Sinha Subject: [PULL 60/90] tests/acpi: x86: Allow IVRS acpi table changes Message-ID: <5c5d6a0fdf2527a64f5ae5997d9ae59aa6d5f0be.1789071043.git.mst@redhat.com> References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-Mailer: git-send-email 2.51.2.2891.g4157995a80.dirty X-Mutt-Fcc: =sent 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=170.10.129.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com 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, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=0.001, SPF_HELO_PASS=-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-Zoho-Virus-Status: 1 X-Zoho-AV-Stamp: zmail-av-0.2.13.1.5.4/289.74.40 X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1789086340708158500 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Sairaj Kodilkar Signed-off-by: Sairaj Kodilkar Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin Message-ID: <20260807061250.27739-3-sarunkod@amd.com> --- tests/qtest/bios-tables-test-allowed-diff.h | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/qtest/bios-tables-test-allowed-diff.h b/tests/qtest/bios= -tables-test-allowed-diff.h index dfb8523c8b..33e9981655 100644 --- a/tests/qtest/bios-tables-test-allowed-diff.h +++ b/tests/qtest/bios-tables-test-allowed-diff.h @@ -1 +1,2 @@ /* List of comma-separated changed AML files to ignore */ +tests/data/acpi/x86/q35/IVRS.ivrs --=20 MST From nobody Sat Sep 26 20:50:17 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=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1789082290; cv=none; d=zohomail.com; s=zohoarc; b=R0VvaxQMd2fb7wiSIoylZBvgFHRQtRb1/FkGlHJAWMgsfopdR201TSZy2xMxNvKmbYzjS29F78rP5s0pEqonGE7MqtJhbUxpnnpyrJxYrcn7aAigJ8nM/JmxfPGf+iPTON5XLxRxo+R/VpdLJkiCnrdCMvfMmzrkXBFk/lWMQIM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1789082290; h=Content-Type: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=EbHgYTTTglQemO80px4rrB2L4uzTAs06wcqbum2Jp9A=; b=J9wexbgjTZUW2XP8MWpnuQDEXHYJrIhlakxSjR7Vak7xCJNZ25jE6uJyYdT6QicytprEmBGSXbc1qkH7gQJw1m7xDkF7y2oyCG0whun+szq501RKuU4/WqD4o7SdNTdsYPW/qd7/ZbiBIQwnGHLIYlX71T159CI87w3suV47Pxo= 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 lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1789082290253976.837107374905; Thu, 10 Sep 2026 16:18:10 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1x4nQ5-0000Y1-Dz; Thu, 10 Sep 2026 18:39:11 -0400 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 1x4lK0-0002Py-7S for qemu-devel@nongnu.org; Thu, 10 Sep 2026 16:24:50 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1x4lJp-0008FW-Qv for qemu-devel@nongnu.org; Thu, 10 Sep 2026 16:24:33 -0400 Received: from mail-wm1-f71.google.com (mail-wm1-f71.google.com [209.85.128.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-325-r4eOxOBAMCun2FCdGBIgzA-1; Thu, 10 Sep 2026 16:14:05 -0400 Received: by mail-wm1-f71.google.com with SMTP id 5b1f17b1804b1-49cced8309bso2003015e9.3 for ; Thu, 10 Sep 2026 13:14:04 -0700 (PDT) Received: from redhat.com (IGLD-80-230-79-236.inter.net.il. [80.230.79.236]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-49e62121747sm1938275e9.2.2026.09.10.13.14.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Sep 2026 13:14:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1789071666; 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=EbHgYTTTglQemO80px4rrB2L4uzTAs06wcqbum2Jp9A=; b=Dv5W6LdE0SEB4XAKAyyBWvfmyhfLS/NUde4FJm4+xmWRPIqvdLnd9rd0KgEKGqPBZbYzXj i8MWN43Oo0F/E+F/qPM97VAuGybWnNn+IGQngEdiGq8iNa5wjSpovqexsEZNf87pGIxbhJ p96FUZeEsTHTQRbxKbpwrMy/NLmv9g0= X-MC-Unique: r4eOxOBAMCun2FCdGBIgzA-1 X-Mimecast-MFC-AGG-ID: r4eOxOBAMCun2FCdGBIgzA_1789071244 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=google; t=1789071244; x=1789676044; 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=EbHgYTTTglQemO80px4rrB2L4uzTAs06wcqbum2Jp9A=; b=DJlTlvgfLm0hq7Z4cRAfHQGA0Qxin0gn6T7sF8QS/wUteUsdLA+twZcxF8gG/U2tZm AQYt4ncHwi8ZD+68OFuJYjIsiGp4YGndszO+pJKUbKPbm8J4j0oPwQ2uk9eV8FvKbq3H OU5LkTwyn7BOcbjT97N7gEfmPQxLfCEWcUPk63ZYEKjQjNdsQqV5/r9VxGH3M6xIyfGS aczNTHcvz0ZFJlE/91DkwaxDbpVm7Mu29sQsB+sUZ7Hg8VSdl735WEY2qgu9BS/jockM wv6SuunkiUyGCPt6zxjHSDS7Xe6bBstWOqLD61r6l+wQp3brsTS+LeFEgKY3wnUxwM5s bn8g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1789071244; x=1789676044; 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=EbHgYTTTglQemO80px4rrB2L4uzTAs06wcqbum2Jp9A=; b=kxSWL9VNGFUYkwaYetYFn0TKl/6BpHzqGk8aAS857G3NY5TuJ0igwkI6LgVll/KqfE rn2FcnUhR0yR6nPagbQHh2ZHJx1N9bjvOWvzFNOJA47lc0hlsw8GT0z5WngZxW4VICWO XVoDmHwF7Lt3pvNFqizKsUOY7Pya0g6Vq1fcCmrLVep4M9sosiL2dAHRr5SGjh/EGPBe ckolZIPeA5AJ6VUwnOv34J/34ICkZImkGX9aNMjR/98yVsRQ97OxmHJioxmVYn9fwnXv w8oPa9AModj64t5kdvSTmd9WTvqu9zsVAhvTKrAUErK2hvqUy0DqZBnyLMvSKFaVuNMf OiEg== X-Gm-Message-State: AFuF++m5ofKsniJbWPKnxikJYzJkQp+TOUx9cj4Kkaj3i9DshaYzBk5O DafzYxtsmiEBTfLQUhuAP4tMsPk4Ldtowk/zfAWXjk3MehdS+gCotU9eiPwAA24ID65qHvEUYUz 92DslPUQ77EGK7pmGYjwItVRrQ6XhKNl5qqZIc6EWmezHyecC/4M9lm6hf0cYJV4/3niTDgzN46 iU5bQ3CMRjnU8XmmX3st5lboMXozlXOI2c7w== X-Gm-Gg: AYBFou2Ua5kMNF9xziDbMxnmbmFWowVNpZ4s2oMMaY3DFkhDLw//5sxUzERwNNbNBwQ U8fd3LqdiM6WiF4b7Po305opaePUivWJFcD+on26YXoB8hVFGGqo67KT/BJFOJIgrw5cWkCF7qz kOic5qkyr+RTFY3HV3eTG9je2J9P5sd7YldB5ztr3aLTBBxWhyaM4qotUErnA2Z2P6iQ7p7IVSW 7uw6y+1+458howFnOldTzqPiOJ+c9Fu+zkKH81LPbV3YfIE774517IYK+VMfCTa/DUHkMG6uqoD bqM2M53XHQ6zO8g/QyCCIHGhch31usG4KxAUEUo6tD6IblMRTCyG4ENJfQSLAxYFztoe3cAolHM Q74cS1QXEoOwgQHug2OAQVlQ= X-Received: by 2002:a05:600c:8b23:b0:49b:9202:6f80 with SMTP id 5b1f17b1804b1-49e619805b5mr7385395e9.6.1789071243841; Thu, 10 Sep 2026 13:14:03 -0700 (PDT) X-Received: by 2002:a05:600c:8b23:b0:49b:9202:6f80 with SMTP id 5b1f17b1804b1-49e619805b5mr7385165e9.6.1789071243384; Thu, 10 Sep 2026 13:14:03 -0700 (PDT) Date: Thu, 10 Sep 2026 16:14:01 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Sairaj Kodilkar , Alejandro Jimenez , Igor Mammedov , Ani Sinha , Paolo Bonzini , Richard Henderson Subject: [PULL 61/90] amd_iommu: acpi-build: update PA, GVA and VA size macros Message-ID: <5aea68d8f088795d1a65ed0d50731d45e72965a7.1789071043.git.mst@redhat.com> References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-Mailer: git-send-email 2.51.2.2891.g4157995a80.dirty X-Mutt-Fcc: =sent 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=170.10.129.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com 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, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=0.001, SPF_HELO_PASS=-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-Zoho-Virus-Status: 1 X-Zoho-AV-Stamp: zmail-av-0.2.13.1.5.4/289.74.40 X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1789082292802158500 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Sairaj Kodilkar Current implementation supports up to 64 bit IOVA and up to 52 bit PA. Modify related macros so that guest can see right size. Also, use these macros to build the IVINFO field in the IVRS. Signed-off-by: Sairaj Kodilkar Reviewed-by: Alejandro Jimenez Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin Message-ID: <20260807061250.27739-4-sarunkod@amd.com> --- hw/i386/amd_iommu.h | 11 ++++++++--- hw/i386/acpi-build.c | 4 +++- hw/i386/amd_iommu.c | 2 +- 3 files changed, 12 insertions(+), 5 deletions(-) diff --git a/hw/i386/amd_iommu.h b/hw/i386/amd_iommu.h index 687691ec1c..d01f9b41df 100644 --- a/hw/i386/amd_iommu.h +++ b/hw/i386/amd_iommu.h @@ -243,9 +243,14 @@ #define AMDVI_PAGE_SHIFT_4K 12 #define AMDVI_PAGE_MASK_4K GENMASK64(63, 12) =20 -#define AMDVI_MAX_GVA_ADDR (2UL << 5) -#define AMDVI_MAX_PH_ADDR (40UL << 8) -#define AMDVI_MAX_VA_ADDR (48UL << 15) +/* + * IOMMU Capability Offset 10h: Miscellaneous Information Register 0. + * VAsize[21:15], PAsize[14:8], and GVAsize[7:5]. + * These fields use the same layout in the IVRS IVinfo Field. + */ +#define AMDVI_VA_SIZE_64 (64UL << 15) +#define AMDVI_PA_SIZE_52 (52UL << 8) +#define AMDVI_GVA_SIZE_48 (2UL << 5) =20 /* Completion Wait data size */ #define AMDVI_COMPLETION_DATA_SIZE 8 diff --git a/hw/i386/acpi-build.c b/hw/i386/acpi-build.c index 1696821048..05b68d05a8 100644 --- a/hw/i386/acpi-build.c +++ b/hw/i386/acpi-build.c @@ -1858,7 +1858,9 @@ build_amd_iommu(GArray *table_data, BIOSLinker *linke= r, const char *oem_id, */ build_append_int_noprefix(table_data, (1UL << 0) | /* EFRSup */ - (40UL << 8), /* PASize */ + AMDVI_GVA_SIZE_48 | /* GVASize: 010b =3D = 48 bits */ + AMDVI_PA_SIZE_52 | /* PASize: 011_0100b =3D = 52 bits */ + AMDVI_VA_SIZE_64, /* VASize: 100_0000b =3D = 64 bits */ 4); /* reserved */ build_append_int_noprefix(table_data, 0, 8); diff --git a/hw/i386/amd_iommu.c b/hw/i386/amd_iommu.c index 578c27ccbe..56e7815412 100644 --- a/hw/i386/amd_iommu.c +++ b/hw/i386/amd_iommu.c @@ -2595,7 +2595,7 @@ static void amdvi_pci_realize(PCIDevice *pdev, Error = **errp) 0xff000000); pci_set_long(pdev->config + s->capab_offset + AMDVI_CAPAB_MISC, 0); pci_set_long(pdev->config + s->capab_offset + AMDVI_CAPAB_MISC, - AMDVI_MAX_PH_ADDR | AMDVI_MAX_GVA_ADDR | AMDVI_MAX_VA_ADDR); + AMDVI_PA_SIZE_52 | AMDVI_GVA_SIZE_48 | AMDVI_VA_SIZE_64); } =20 static void amdvi_sysbus_reset(DeviceState *dev) --=20 MST From nobody Sat Sep 26 20:50:17 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=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1789079843; cv=none; d=zohomail.com; s=zohoarc; b=fuO8z6GycmBh4vRypEsjOeKnU6gg0ps8ngnW2fXfPU4GNpru1PhrMghSwJ2L7gIgM0X3+/vpGSylO6yQeUXKUMEHN+3NvubAmpFU2TaVqACrJ4Z+/2+E+TQU2tvQA9h4v94FizcQDFPte2QWpHSUbUiNEmxxMt1owHv/mUORAyU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1789079843; h=Content-Type: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=Moug1WmXO2CB2DYm8PmKZYdWRJM7GGO9/h6JXojQGEQ=; b=EDks+GJi0cuPaeScQusHgxTuvz3I5VMlGwS1HmwOUd40oNSs5GywtEL5R/hv8fjlZ3TKJeWlLbca0bdqAPf1av1+De3hUOsfIkYqvJrazlyeCjTSkAOwkPcqtOfCPlhPUMDqWGMHXOLiylRKBtcfyCgirN0juPvIH7/qc3HVRoo= 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 lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 178907984325438.37681124967344; Thu, 10 Sep 2026 15:37:23 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1x4nNr-0008QZ-Nx; Thu, 10 Sep 2026 18:36:50 -0400 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 1x4lJo-0002Nb-TD for qemu-devel@nongnu.org; Thu, 10 Sep 2026 16:24:39 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1x4lJa-00087c-Gb for qemu-devel@nongnu.org; Thu, 10 Sep 2026 16:24:16 -0400 Received: from mail-wr1-f69.google.com (mail-wr1-f69.google.com [209.85.221.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-331-EXgOxq0SOdGzzlIPZ7NwKQ-1; Thu, 10 Sep 2026 16:14:07 -0400 Received: by mail-wr1-f69.google.com with SMTP id ffacd0b85a97d-486e8fb7d75so36218f8f.0 for ; Thu, 10 Sep 2026 13:14:07 -0700 (PDT) Received: from redhat.com (IGLD-80-230-79-236.inter.net.il. [80.230.79.236]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-486eb33ee5csm810113f8f.20.2026.09.10.13.14.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Sep 2026 13:14:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1789071616; 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=Moug1WmXO2CB2DYm8PmKZYdWRJM7GGO9/h6JXojQGEQ=; b=ZYSXDyVCa4ip1RhR1FmirIF/UOYcuLJ5/ohOMkSMzZJYbZcbAdWF/b+R48cmiE/qKxJ/0r +PdTFUinALnox8pl3kv0SRCdf1U2lEpzP9Jtq5MIyIdDoi1bVWHVnzaJQ+nIs/1n8RzkzI 1nbM+M0YWuKf//KX512kc3OX9vMIcMc= X-MC-Unique: EXgOxq0SOdGzzlIPZ7NwKQ-1 X-Mimecast-MFC-AGG-ID: EXgOxq0SOdGzzlIPZ7NwKQ_1789071246 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=google; t=1789071246; x=1789676046; 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=Moug1WmXO2CB2DYm8PmKZYdWRJM7GGO9/h6JXojQGEQ=; b=gPftJCD9b6DnwxsL+uYFAzAf7U0Da2amVolXKIoI/Fyu/2AKbmRFueIpoRi+NaZvIW +D2/qc6TojSgLePMxrf43g+aESJGiBWDhvPYoOl7ljPyPM3aabIedYDk/FS7O8MvhI5S ch9/Em5pyYeq/kWm6q1sjC4Pv/tqF85tq2wk6E/vM11vFHm9edrWPy8yiYbIzUndcy0s NCzg5OP44zYfHK/qBNSCwtFekxjRuacPosT09Z3o+Lqmc4i/8EzWB2p2EYPDuBzAZP9g aPDaasQi/wWIeRaBhmv09IwV3FaH1NGbSgAbAkVwUKValtMTkkV/FotWWTEtYS0K/ab6 q77w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1789071246; x=1789676046; 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=Moug1WmXO2CB2DYm8PmKZYdWRJM7GGO9/h6JXojQGEQ=; b=gmbzsj0AQkR1x066vcBFPseIyytEvDqlUhL25poeY7aZlxvgdyb/iZjuJNRzQuxouD NGg1Ph53QBznKgpIlVfHQgi0HN6bxABVcNcXwrA7UTbuCCwa0LeOa9+j4x8w6RELVkyd 5mt71IPP1wnsiDUCHeIdN4C0mT7HeV+drdLBa8tb8+5LVJQfG43IToopBIaDgshJ2ER9 HYGa7xguiPjdvmB2bUeMq/6zDZTXrLcuvm4/5pVMp++v4A3xYwOJQ6tiQWvnWBFS9WTx rl23v1QIR49GZ+MAqZzzo8MfkGaphlvWhnToy6kEQmbafA8UAJ+Iy7TIste4YWhoDBl3 AFPg== X-Gm-Message-State: AFuF++nPz0ouQNvKw5HfvZuiKdkt5rgB0didKRibLWRO8QMlaMNFFgS+ KmlHwx6IwQfpfII0Hh6mBM8X5bg466cFWexkiugTYAzxJcn662sy8PLQP8IUTEIOBjtVUjOQ8Av aPbauqadUNO3L+LEBbPWtwtsljatez0pB0I9ma2slMTDn9flrsC78LHVLpwk95tZhY6VsNpCdtw xWCmYX1hqXACcYm7ono/0l46+FARbYsyVXOg== X-Gm-Gg: AYBFou10t00wOMTUOiukIgQV1Myex4iNy1HISdrGyULWXOid3uOll92J07aJ7SdthRT oaHz8qqHbprcr06NlVpj2V6hn2m17biPYdoMwLDxubd/cnfx1f4PzPIXOHeptPfqveHPaAKMZSA dVQ7FhxHNN+aB2IxRu9pXNWoeqT49nr4QsP0W/3imEt80meZ9L3XpEB8BbPQm1sOkMTENM4H7bl uP+7DNwh2pEHo68u2vBZEltS+GOpufe4tyBG7+klqu2F84O2EREjoM3yQAUIS+uaOy5hy8SjXWn 5VkxN+EFrhUWElFVHV8iREAEx5vL8TaE4hfmuHhRHzGwSzo9VIor78eZHPo4yB83t4PilA++Rj5 CNUOHcihGSAfDVRp4Egzrdmg= X-Received: by 2002:a05:6000:2006:b0:485:847f:fd89 with SMTP id ffacd0b85a97d-486eb2e2588mr668046f8f.9.1789071246350; Thu, 10 Sep 2026 13:14:06 -0700 (PDT) X-Received: by 2002:a05:6000:2006:b0:485:847f:fd89 with SMTP id ffacd0b85a97d-486eb2e2588mr667996f8f.9.1789071245753; Thu, 10 Sep 2026 13:14:05 -0700 (PDT) Date: Thu, 10 Sep 2026 16:14:03 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Sairaj Kodilkar , Alejandro Jimenez , Igor Mammedov , Ani Sinha , Paolo Bonzini , Richard Henderson Subject: [PULL 62/90] acpi_build: Use IOMMU pci device to build IOMMU DeviceID Message-ID: <30b49a4782d7bff2abfbf9982a30255aa40c3376.1789071043.git.mst@redhat.com> References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-Mailer: git-send-email 2.51.2.2891.g4157995a80.dirty X-Mutt-Fcc: =sent 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=170.10.129.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com 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, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=0.001, SPF_HELO_PASS=-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-Zoho-Virus-Status: 1 X-Zoho-AV-Stamp: zmail-av-0.2.13.1.5.4/289.74.40 X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1789079845348158500 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Sairaj Kodilkar Currently, build_amd_iommu() uses "addr" property to build the DeviceID for IOMMU device and advertise it through IVRS. But this property does not enco= de IOMMU bus number, only the device and function number. This creates an incorrect DeviceID when the IOMMU is attached to a bus other than the default one with bus number 0. Signed-off-by: Sairaj Kodilkar Reviewed-by: Alejandro Jimenez Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin Message-ID: <20260807061250.27739-5-sarunkod@amd.com> --- hw/i386/acpi-build.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/hw/i386/acpi-build.c b/hw/i386/acpi-build.c index 05b68d05a8..a28bb2ec63 100644 --- a/hw/i386/acpi-build.c +++ b/hw/i386/acpi-build.c @@ -1851,6 +1851,7 @@ build_amd_iommu(GArray *table_data, BIOSLinker *linke= r, const char *oem_id, AcpiTable table =3D { .sig =3D "IVRS", .rev =3D 1, .oem_id =3D oem_id, .oem_table_id =3D oem_table_id }; uint64_t feature_report; + uint16_t iommu_devid =3D pci_get_bdf(&s->pci->dev); =20 acpi_table_begin(&table, table_data); /* IVinfo - IO virtualization information common to all @@ -1913,9 +1914,7 @@ build_amd_iommu(GArray *table_data, BIOSLinker *linke= r, const char *oem_id, /* IVHD length */ build_append_int_noprefix(table_data, ivhd_blob->len + 24, 2); /* DeviceID */ - build_append_int_noprefix(table_data, - object_property_get_int(OBJECT(s->pci), "add= r", - &error_abort), 2); + build_append_int_noprefix(table_data, iommu_devid, 2); /* Capability offset */ build_append_int_noprefix(table_data, s->pci->capab_offset, 2); /* IOMMU base address */ @@ -1947,10 +1946,9 @@ build_amd_iommu(GArray *table_data, BIOSLinker *link= er, const char *oem_id, =20 /* IVHD length */ build_append_int_noprefix(table_data, ivhd_blob->len + 40, 2); + /* DeviceID */ - build_append_int_noprefix(table_data, - object_property_get_int(OBJECT(s->pci), "add= r", - &error_abort), 2); + build_append_int_noprefix(table_data, iommu_devid, 2); /* Capability offset */ build_append_int_noprefix(table_data, s->pci->capab_offset, 2); /* IOMMU base address */ --=20 MST From nobody Sat Sep 26 20:50:17 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=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1789073620; cv=none; d=zohomail.com; s=zohoarc; b=AeEskv1PrXaPJdSkr9Eh8IZIGQ3JNt85EuJxUC/nHIIqm1DfQb+ikCEDQPphGWBtyHEZU7hRvGRtgsyd+xLQbJG9ZS8xRwZEiKY0ZDJt1qbiitJnJyBtSd6kHNGTp9U+iS44/Ah/8JISrkWaljCtuSjT87bJRGEnVM8P7b8fh3U= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1789073620; h=Content-Type: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=PWQxLCtaF9Z/qhP7GNgCPFbg0LbmSSJO7NpN+DpDut8=; b=CwsqsmLvcXY62997D/MPxZLZ1vVrq+O2YUDbeBx0Onwv8O25pmRfE8lgRFJPPMn+eCpHXDrvF3Es8a80e/hNsJpVJ0HVVpB3uz+HJFM+Zwrwbuuxv6Fycwuj3MLKfj9JgpxhgPDbQjVsMAMjo7T3vBH3YGzGZMLLE2lD+21f3AQ= 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 lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1789073620077173.55687197265797; Thu, 10 Sep 2026 13:53:40 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1x4llA-0001hm-U2; Thu, 10 Sep 2026 16:52:56 -0400 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 1x4lIe-0001rk-GF for qemu-devel@nongnu.org; Thu, 10 Sep 2026 16:23:23 -0400 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 1x4lII-000890-MV for qemu-devel@nongnu.org; Thu, 10 Sep 2026 16:22:59 -0400 Received: from mail-wm1-f71.google.com (mail-wm1-f71.google.com [209.85.128.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-77-Bq5qd6onN1-ZRavNgSo8tQ-1; Thu, 10 Sep 2026 16:14:10 -0400 Received: by mail-wm1-f71.google.com with SMTP id 5b1f17b1804b1-495689bfcc8so1329365e9.1 for ; Thu, 10 Sep 2026 13:14:09 -0700 (PDT) Received: from redhat.com (IGLD-80-230-79-236.inter.net.il. [80.230.79.236]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-49db038401fsm74660505e9.13.2026.09.10.13.14.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Sep 2026 13:14:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1789071621; 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=PWQxLCtaF9Z/qhP7GNgCPFbg0LbmSSJO7NpN+DpDut8=; b=GwjCDscONKMc5aKs4UQsDi7Kpv5axuoybTRBwmtoKYXckMto2T/Ykx7I8OAWgoWI2G+UX4 gHHha2OT133FydC/18jsHdjUrow2hxBFeUnL6VLfzhPYXZmJlLKNZOEhBq9YbYtdXLPKID j0iLNkClvvkuDq9+GrWH/ftV2ozyG8g= X-MC-Unique: Bq5qd6onN1-ZRavNgSo8tQ-1 X-Mimecast-MFC-AGG-ID: Bq5qd6onN1-ZRavNgSo8tQ_1789071249 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=google; t=1789071249; x=1789676049; 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=PWQxLCtaF9Z/qhP7GNgCPFbg0LbmSSJO7NpN+DpDut8=; b=exvgHzp9GM8gGXEsbzkzlf+u+KTIPMaLXSuD/qP7Re4vkIQoFPCg5/y0zpTFktuWjc v/ujrWGjsfxLdHK1s0E55W45sojQ4C+LjUU0ecvXCzpJwbx3S0rKhR+66Q3sYcP+Cyc5 cXiySu6lG3V14NgWH5GfiBaG+9FG51i/W600ldcfXEdlnspEyL1mHnCNoejVA9+YLvax CInIkXzQHsTu9SmqrNEEgtQb/vuTqA/a9juLjQqQSVM8C+WLKRsha1ehr+4c/a9fjPAT doVbJInSFr04Mu8uOBxjgAnw1P81nUKPB6GuK61zQdpwMZkBt7+JtUBsnLpi+vBiUoUn Bfow== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1789071249; x=1789676049; 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=PWQxLCtaF9Z/qhP7GNgCPFbg0LbmSSJO7NpN+DpDut8=; b=fpEAPw1U+mHM9Bdcc06pOIpKDM5e5h3VBE9GSeshjaYUYMZL9N7kAcIP1vSC+aCHap tEszG+GFQeqDmeNNmBS3mQHRPXk32uCJsKBHzytIjDK3iX9XBfEoF4w4cHBahYkh+0bu 6Hkp2fDo/fKc+qmPT/+YfgSJkc+5jPatBr4fU5GxllEhbup1nrcmqKwOH3/ytZLmw/TF oVYSouZeL/7aMQ1WKZA7xWWkHXhnFh5eUtLMcmufHv5HxrgYum1pLomJUBNcf0nd8Ayq 98KnAShtBAUTW3/aX8zHFpio2Q5nAdYfCDkzV0+mxvvf06emB01NZa1nMXhCleUpb+iy MbSQ== X-Gm-Message-State: AFuF++k48SG55SHxR5D3Qfcch3o5kpTrvt+l5V32ZFguyI+SHmMHOPAf 1pvCkLXwcXCaBY2aqV/xn+IT6d0iW134ZNoilpJ7E5eC+MAbBCtmUxLAdnCwybz46LFuyiLZJ9s VrVtg8CwKGD5tQqJTdQ/6CY/NDYxJ7+AZHvCyNUNtKdpJEJL9Io67I92PNGDzExhVvg94cSjo/X bXmVQD3YuwXGKi4/sTFY+6H3Wr3ksvmcnkoA== X-Gm-Gg: AYBFou3OtIgnv4tq1pYf1PTQKdHWtrbQ+cca95poXfJidbx4DtOoYQUalSjxYzwVKH3 9tqJPxLDlwV6rsG9A+0nGZVhRJoEkd5iqWi8dsg43RTs39X1YOyhiLsHuufpWEhClMpGVbTkyhn U0xHq7Mn4IqScKaro/ue42u1k3zhA60BLLgLw5ZZJQhFIKwwmuqaIp4NyGzXZMIZ0kds1H6Gi+k l/d/cdrdq9KxtrP9Z5XeoJsygLbtJUtO1uJg8fcuFSmydWU79TeB5CGa39+4v2b/NrMYQyncAnE V3hT/42X8lxgrPN9uqj5SlZfgoCsnHbZyJJxILRmBDfhPDKv9Gu3qvVCXZSv9JT6S1sMV6f8+A/ 9pz63ekNHOe1BI4V8yco8v/g= X-Received: by 2002:a05:600c:4e8e:b0:49c:fa21:e744 with SMTP id 5b1f17b1804b1-49e619ce914mr8604755e9.26.1789071248629; Thu, 10 Sep 2026 13:14:08 -0700 (PDT) X-Received: by 2002:a05:600c:4e8e:b0:49c:fa21:e744 with SMTP id 5b1f17b1804b1-49e619ce914mr8604185e9.26.1789071248204; Thu, 10 Sep 2026 13:14:08 -0700 (PDT) Date: Thu, 10 Sep 2026 16:14:05 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Sairaj Kodilkar , Igor Mammedov , Ani Sinha , Paolo Bonzini , Richard Henderson , Alejandro Jimenez Subject: [PULL 63/90] acpi_build: Build IVRS feature report using extended feature register Message-ID: References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-Mailer: git-send-email 2.51.2.2891.g4157995a80.dirty X-Mutt-Fcc: =sent 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=170.10.133.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com 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, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_PASS=-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-Zoho-Virus-Status: 1 X-Zoho-AV-Stamp: zmail-av-0.2.13.1.5.4/289.52.80 X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1789073622732158500 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Sairaj Kodilkar Currently IVRS feature report values are hardcoded, this is difficult to maintain as any updates to extended feature must be synced. Along with it, current feature report does not have GATS and HATS set. Hence use the extended feature registers to build the IVRS feature report. Signed-off-by: Sairaj Kodilkar Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin Message-ID: <20260807061250.27739-6-sarunkod@amd.com> --- hw/i386/amd_iommu.h | 11 ++++++++++ hw/i386/acpi-build.c | 48 +++++++++++++++++++++++++++++++++----------- 2 files changed, 47 insertions(+), 12 deletions(-) diff --git a/hw/i386/amd_iommu.h b/hw/i386/amd_iommu.h index d01f9b41df..319db18618 100644 --- a/hw/i386/amd_iommu.h +++ b/hw/i386/amd_iommu.h @@ -174,7 +174,11 @@ #define AMDVI_DTE_QUAD3_RESERVED (GENMASK64(14, 0) | GENMASK64(53, = 48)) =20 /* AMDVI paging mode */ +#define AMDVI_GATS_MODE_SHIFT (12) +#define AMDVI_GATS_MODE_MASK (3ULL << 12) #define AMDVI_GATS_MODE (2ULL << 12) +#define AMDVI_HATS_MODE_SHIFT (10) +#define AMDVI_HATS_MODE_MASK (3ULL << 10) #define AMDVI_HATS_MODE (2ULL << 10) #define AMDVI_HATS_MODE_RESERVED (3ULL << 10) =20 @@ -296,6 +300,13 @@ #define AMDVI_DEV_LINT0_PASS_MASK (1ULL << 62) #define AMDVI_DEV_LINT1_PASS_MASK (1ULL << 63) =20 +#define AMDVI_IVHD_FEATURE_REPORT_HATS_SHIFT (30) +#define AMDVI_IVHD_FEATURE_REPORT_GATS_SHIFT (28) +#define AMDVI_IVHD_FEATURE_REPORT_GA_SUP_SHIFT (6) +#define AMDVI_IVHD_FEATURE_REPORT_IA_SUP_SHIFT (5) +#define AMDVI_IVHD_FEATURE_REPORT_GT_SUP_SHIFT (2) +#define AMDVI_IVHD_FEATURE_REPORT_XT_SUP_SHIFT (0) + #define TYPE_AMD_IOMMU_DEVICE "amd-iommu" OBJECT_DECLARE_SIMPLE_TYPE(AMDVIState, AMD_IOMMU_DEVICE) =20 diff --git a/hw/i386/acpi-build.c b/hw/i386/acpi-build.c index a28bb2ec63..7bf3858b63 100644 --- a/hw/i386/acpi-build.c +++ b/hw/i386/acpi-build.c @@ -1842,6 +1842,37 @@ ivrs_host_bridges(Object *obj, void *opaque) return 0; } =20 +/* + * IVHD type 0x10 reports features using Feature Reporting field, which has + * different format than extended feature register (EFR) in the IOMMU MMIO + * space. + * + * Convert the EFR format to feature reporting format. + */ +static uint32_t +get_amd_ivhd_feature_report(uint64_t extended_feature) +{ + uint32_t feature_report; + uint64_t hats_mode =3D (extended_feature & AMDVI_HATS_MODE_MASK) >> + AMDVI_HATS_MODE_SHIFT; + uint64_t gats_mode =3D (extended_feature & AMDVI_GATS_MODE_MASK) >> + AMDVI_GATS_MODE_SHIFT; + uint32_t is_ia =3D !!(extended_feature & AMDVI_FEATURE_IA); + uint32_t is_ga =3D !!(extended_feature & AMDVI_FEATURE_GA); + uint32_t is_gt =3D !!(extended_feature & AMDVI_FEATURE_GT); + uint32_t is_xt =3D !!(extended_feature & AMDVI_FEATURE_XT); + + feature_report =3D + hats_mode << AMDVI_IVHD_FEATURE_REPORT_HATS_SHIFT | /* HATS[31:30= ] */ + gats_mode << AMDVI_IVHD_FEATURE_REPORT_GATS_SHIFT | /* GATS[29:28= ] */ + is_ia << AMDVI_IVHD_FEATURE_REPORT_IA_SUP_SHIFT | /* IASup[5] = */ + is_ga << AMDVI_IVHD_FEATURE_REPORT_GA_SUP_SHIFT | /* GASup[6] = */ + is_gt << AMDVI_IVHD_FEATURE_REPORT_GT_SUP_SHIFT | /* GTSup[2] = */ + is_xt << AMDVI_IVHD_FEATURE_REPORT_XT_SUP_SHIFT; /* XTSup[0] = */ + + return feature_report; +} + static void build_amd_iommu(GArray *table_data, BIOSLinker *linker, const char *oem_id, const char *oem_table_id) @@ -1850,8 +1881,8 @@ build_amd_iommu(GArray *table_data, BIOSLinker *linke= r, const char *oem_id, GArray *ivhd_blob =3D g_array_new(false, true, 1); AcpiTable table =3D { .sig =3D "IVRS", .rev =3D 1, .oem_id =3D oem_id, .oem_table_id =3D oem_table_id }; - uint64_t feature_report; uint16_t iommu_devid =3D pci_get_bdf(&s->pci->dev); + uint64_t extended_feature =3D amdvi_extended_feature_register(s); =20 acpi_table_begin(&table, table_data); /* IVinfo - IO virtualization information common to all @@ -1924,14 +1955,9 @@ build_amd_iommu(GArray *table_data, BIOSLinker *link= er, const char *oem_id, /* IOMMU info */ build_append_int_noprefix(table_data, 0, 2); /* IOMMU Feature Reporting */ - feature_report =3D (48UL << 30) | /* HATS */ - (48UL << 28) | /* GATS */ - (1UL << 2) | /* GTSup */ - (1UL << 6); /* GASup */ - if (s->xtsup) { - feature_report |=3D (1UL << 0); /* XTSup */ - } - build_append_int_noprefix(table_data, feature_report, 4); + build_append_int_noprefix(table_data, + get_amd_ivhd_feature_report(extended_feature= ), + 4); =20 /* IVHD entries as found above */ g_array_append_vals(table_data, ivhd_blob->data, ivhd_blob->len); @@ -1964,9 +1990,7 @@ build_amd_iommu(GArray *table_data, BIOSLinker *linke= r, const char *oem_id, build_append_int_noprefix(table_data, 0, 4); } /* EFR Register Image */ - build_append_int_noprefix(table_data, - amdvi_extended_feature_register(s), - 8); + build_append_int_noprefix(table_data, extended_feature, 8); /* EFR Register Image 2 */ build_append_int_noprefix(table_data, 0, 8); =20 --=20 MST From nobody Sat Sep 26 20:50:17 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=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1789076411; cv=none; d=zohomail.com; s=zohoarc; b=dDE8htkdj4XSo+aIHx7aFcdmxg/xOEfty0OkdxoNs9I97fUf1963FTjmrlIzJaXfGkAaqzTlnumrtdTU9zkxdO7N4dltFIN+1RVlB0DaMQTDfRYufcCHXpEDj3y3xr+Ndd1NBJv4zTmZhbcDNUpZPBTFwamQE6q+QLPwmhQw0Eo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1789076411; h=Content-Type: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=4xO9Jj7yHXJpXhsIddL9LHeTxBWYycN9Rwv/iB+IGEU=; b=fe0285h4xLAA0W6LedA8Upe+/J16DU8iQahlrERMhGVSOOBIqjMZdX5p+g9N2NO1io0EvkTjDSvBdTnH4/tyRAWnv7yx3JZ6XovITHfVfGtuRXkJWMCBkwDnKF3z8+bT716/jOK3fROufoqkFVr+haiesCe3REhfcnpXVD+5kfg= 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 lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1789076411109978.0789545466724; Thu, 10 Sep 2026 14:40:11 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1x4mTX-0001o1-Tr; Thu, 10 Sep 2026 17:38:44 -0400 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 1x4lUB-000604-CI for qemu-devel@nongnu.org; Thu, 10 Sep 2026 16:35:26 -0400 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 1x4lTi-0003jH-VX for qemu-devel@nongnu.org; Thu, 10 Sep 2026 16:34:55 -0400 Received: from mail-wr1-f69.google.com (mail-wr1-f69.google.com [209.85.221.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-687-JM-nPsnmNnOz7WNf_fkoLA-1; Thu, 10 Sep 2026 16:14:13 -0400 Received: by mail-wr1-f69.google.com with SMTP id ffacd0b85a97d-485835753caso82824f8f.3 for ; Thu, 10 Sep 2026 13:14:12 -0700 (PDT) Received: from redhat.com (IGLD-80-230-79-236.inter.net.il. [80.230.79.236]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-486eb35bed0sm737699f8f.32.2026.09.10.13.14.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Sep 2026 13:14:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1789072449; 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=4xO9Jj7yHXJpXhsIddL9LHeTxBWYycN9Rwv/iB+IGEU=; b=ghnB/iJZJLXciHyGrGDJ97lHwO9hNXyZ1+8XecIA3xZmU6AgjYcS8isT1Fj1c8yiroaJdy UztfJ+MayQ52en7/IK8aZeBnU0SCESclkJskhTPGkwQwVoiEHKRbsJmC5gpEpyvIKGRiXC ETzFN/rYOjmcg0k3MhY8E4M5R0laEOo= X-MC-Unique: JM-nPsnmNnOz7WNf_fkoLA-1 X-Mimecast-MFC-AGG-ID: JM-nPsnmNnOz7WNf_fkoLA_1789071252 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=google; t=1789071252; x=1789676052; 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=4xO9Jj7yHXJpXhsIddL9LHeTxBWYycN9Rwv/iB+IGEU=; b=dp1pncu2WhpwP7D7l+4t7zMSxIq3mKmmcIk0ajW9QxLl6uNlJOjKpS8fvVQIk/2ASj b6R0fM6rsi2HmN0NUNWEDUwtgOp1G0WSLHdgATUQN2ObFImR+fAHOUz8x5LVIHCmEi+i WULsWJQd1n9eNH0E1TtNMc3aHtPZw1wnxWkvqehzoDtp3AUFAELpC1l2PnonbLNnX2Yi ZZG2V5ytx96Rvo2WyLAu7rpBRDVbrLVX1zxKw1FalZeweMA1rT4rba440ScH6tVxoQLf 7RJFebz6Nv7LaTUxubyX/XPEvwUt4d2I9qpFjeNDmG+raEg1fW1fUWh2IoauxkWdjt0S kOLg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1789071252; x=1789676052; 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=4xO9Jj7yHXJpXhsIddL9LHeTxBWYycN9Rwv/iB+IGEU=; b=p3OycSEwh0HdbgdMMB1kS58PyJjzNBQ8fD3M1hMbaIitJZ+EUGX3Wlzp5ZRw/k3oj2 KezH/W/mAdoFQn8Uh6hFcX3I8RPNbNAK2OpFNxGbjoX0JF0y/nJXftm9oDuW8iYg47qy aGYu5Xb/R3mD2vOnfxa+4Y0HWloTOYopillR16IBw/prnDg2bXove3HTpZ02m2XUN7zp oL19rLg9qJBIKj/AfHxmJr4ZS2ERLsF7wkLz6d1kfBxzTDLbQaA/cdM/6vVCnbim+EsH feFumqXpG9pyQHNSQaqPIIdUpbLp5jXUliOzPXA933zVI8xX/3rMmgcYUil8oI/QuKzh 7K3Q== X-Gm-Message-State: AFuF++lV5EIJDOuw4SVxwb+s2nzjETirsLWK+A09XxOXMTSCqDgZgPyz 0Ij7azlrm9vi9R1NbHq6Fi8W+6E2pgtUxb4rOG/3TtHdNPXZNvsVGeAyj8NcrGopHD2OC/IJ8Yp eVZpo+YnqlR6rELqGr+Tm+zqpy2OllH9UAgky+MatgeUPxZPL3yqkvvZsxzjmntvEOYww0inCfE xCqHcDcYE6rqMpXC0R81VeP4+ioV20LXhqPg== X-Gm-Gg: AYBFou0ibHHWG36LJvSJOIwhgeyqQ5YLQfWbyuPoCexyjMh1KyHF4trGhwcFN6qJ0QI Pl/jqZIaR/Eq59tQ0vUdBPjHhETjVMW3oV+yVfY5w0FFaCQak1lifyufD8OKNM39k9U0T0wTpNy ThnDuyKKhsLYNkXwe8eEA7TvGgVoLFY6JAEZ7YiY1t/j7fPLPIhD3zC2/JgzXUZOZoWJ0oG2vyB DPvkW0fJABv29fg8y1MlENVO+G71cVzDq8lzGlHhAW/rlCUtVGnyfbYunfj1VPVthkfGB6hja51 PlgTzpa31PHb8n5AI6xbTF5oCJgBMZ2Sri05YV9BwzgodFPBnzz8Ka5SnvXBaTNPPVb26m0dEMY NkfBZQUNp9zU7J3JWwVj0pB8= X-Received: by 2002:a05:6000:46c5:b0:486:e0f0:f2e9 with SMTP id ffacd0b85a97d-486eb2e3d82mr515397f8f.8.1789071251723; Thu, 10 Sep 2026 13:14:11 -0700 (PDT) X-Received: by 2002:a05:6000:46c5:b0:486:e0f0:f2e9 with SMTP id ffacd0b85a97d-486eb2e3d82mr515354f8f.8.1789071251220; Thu, 10 Sep 2026 13:14:11 -0700 (PDT) Date: Thu, 10 Sep 2026 16:14:08 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Sairaj Kodilkar , Igor Mammedov , Ani Sinha , Paolo Bonzini , Richard Henderson , Alejandro Jimenez Subject: [PULL 64/90] amd_iommu: acpi-build: Remove unsupported PPR and HE feature Message-ID: <32adc52ecb7cfca74279c993a22959677bf6f306.1789071043.git.mst@redhat.com> References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-Mailer: git-send-email 2.51.2.2891.g4157995a80.dirty X-Mutt-Fcc: =sent 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=170.10.133.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com 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, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_PASS=-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-Zoho-Virus-Status: 1 X-Zoho-AV-Stamp: zmail-av-0.2.13.1.5.4/289.74.40 X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1789076414208158500 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Sairaj Kodilkar AMD IOMMU does not support ppr and hardware error registers. Hence do not publish these features to guest through extended feature MMIO register and IVHD 10h flags field. Signed-off-by: Sairaj Kodilkar Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin Message-ID: <20260807061250.27739-7-sarunkod@amd.com> --- hw/i386/amd_iommu.h | 5 ++--- hw/i386/acpi-build.c | 3 +-- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/hw/i386/amd_iommu.h b/hw/i386/amd_iommu.h index 319db18618..c5b346cc35 100644 --- a/hw/i386/amd_iommu.h +++ b/hw/i386/amd_iommu.h @@ -227,9 +227,8 @@ =20 /* default extended feature */ #define AMDVI_DEFAULT_EXT_FEATURES \ - (AMDVI_FEATURE_PREFETCH | AMDVI_FEATURE_PPR | \ - AMDVI_FEATURE_IA | AMDVI_FEATURE_GT | AMDVI_FEATURE_HE | \ - AMDVI_GATS_MODE | AMDVI_HATS_MODE | AMDVI_FEATURE_GA) + (AMDVI_FEATURE_PREFETCH | AMDVI_FEATURE_IA | AMDVI_FEATURE_GT | \ + AMDVI_GATS_MODE | AMDVI_HATS_MODE | AMDVI_FEATURE_GA) =20 /* capabilities header */ #define AMDVI_CAPAB_FEATURES (AMDVI_CAPAB_FLAT_EXT | \ diff --git a/hw/i386/acpi-build.c b/hw/i386/acpi-build.c index 7bf3858b63..6d7308b4e4 100644 --- a/hw/i386/acpi-build.c +++ b/hw/i386/acpi-build.c @@ -1938,8 +1938,7 @@ build_amd_iommu(GArray *table_data, BIOSLinker *linke= r, const char *oem_id, build_append_int_noprefix(table_data, (1UL << 0) | /* HtTunEn */ (1UL << 4) | /* iotblSup */ - (1UL << 6) | /* PrefSup */ - (1UL << 7), /* PPRSup */ + (1UL << 6), /* PrefSup */ 1); =20 /* IVHD length */ --=20 MST From nobody Sat Sep 26 20:50:17 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=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1789075247; cv=none; d=zohomail.com; s=zohoarc; b=mAD5yc2PAxZLYeiJfAOM3rxU/WS4DLcMlN0P1q56UZifF+7KIy9zHfi8oIEtFjV2Xdw0pmN7/KmTp6lfxejcI8VX7UESJzu/lnvIneg2hKtA6t/WqrylX4cSOeW2S6VCV67L7bLfQeo5tN0qRFtkueLSGDEV5ohjdEJDQMHfiMc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1789075247; h=Content-Type: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=s25v9MuORRs6iYLVe6PGLtMBi7BEybbRfKrSYsEB5hA=; b=OUJm8jlrWBsUqk0gtmpPMLFKDLAwh5foODYYGJjNTQzogpDKBrm1XM+WKYCAJl85uLVy25jNcIHJ0MBZq/jRT+p2LSh4te5KEqMDB6w9OzgIinwBHX/LloC5oCzcig/6aXp+YnsHIoI8YiFIVHU6Xa20V7Xw+p0A1j+/LaFXYHI= 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 lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 178907524689375.74356376496439; Thu, 10 Sep 2026 14:20:46 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1x4mBd-0006IL-7I; Thu, 10 Sep 2026 17:20:10 -0400 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 1x4lIz-00022t-BJ for qemu-devel@nongnu.org; Thu, 10 Sep 2026 16:23:47 -0400 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 1x4lIe-0008FP-RB for qemu-devel@nongnu.org; Thu, 10 Sep 2026 16:23:19 -0400 Received: from mail-wr1-f70.google.com (mail-wr1-f70.google.com [209.85.221.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-480-Rw0vn4NhP5ecdl8olT9EnA-1; Thu, 10 Sep 2026 16:14:15 -0400 Received: by mail-wr1-f70.google.com with SMTP id ffacd0b85a97d-485f6788029so101970f8f.1 for ; Thu, 10 Sep 2026 13:14:15 -0700 (PDT) Received: from redhat.com (IGLD-80-230-79-236.inter.net.il. [80.230.79.236]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-486eb2ecfc3sm792759f8f.4.2026.09.10.13.14.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Sep 2026 13:14:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1789071666; 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=s25v9MuORRs6iYLVe6PGLtMBi7BEybbRfKrSYsEB5hA=; b=WqPDPB5MJHZ7UQ07uJyt4rUjNKXS3dOVuK2+xaEM0uorkNk2KEK04U+QNeVde1CKuvkErJ thYL3OnahJoOhlHVmpBkdHkPp8cMT3jysVP+0uBqd05vlKUFtHGXO8nf6oI2OhCzJmcV77 CVdvFbBO0nOhab6UbzFR3CzWBJwIu1E= X-MC-Unique: Rw0vn4NhP5ecdl8olT9EnA-1 X-Mimecast-MFC-AGG-ID: Rw0vn4NhP5ecdl8olT9EnA_1789071254 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=google; t=1789071254; x=1789676054; 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=s25v9MuORRs6iYLVe6PGLtMBi7BEybbRfKrSYsEB5hA=; b=a6YNT7DnZl69dZIuELTSv0HRQj4DHefTywWIiVZsEt6BNa3Wj36qeKjmP1fMGWehtX QYuLy8Vzw8qn0D5iRA6C3yeNQS4Sf8iRg0FA7ve3YjjRt+/BKMWzCOu1Pm0PbPVTRFSH zKbOn2107RPGc73ECmqu8zhwvi3ZsZs2fQIhZ0Ti45KlqcokCks5rbS9CTrCoJA+d+Xh 4o4RM51+LXnd+1bZ3fsCDCYhLKHNhRronvoQE6rdrLbJj+6v4lEd6TcBQZ+pnvaRAZ7z 9zY/wa1AIKIySzFx8WWIC6oV/dB60Z0FW+VeqK3USYamIG1S1lOs7SvoTk4BCBxyNqOq +Vnw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1789071254; x=1789676054; 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=s25v9MuORRs6iYLVe6PGLtMBi7BEybbRfKrSYsEB5hA=; b=nm0HfO5QNqWgtiDJeiDaaFMM5gN7KEUMWDtL6wdovtjO4HqoOP00eMn0BOBEff5PDi eax7sO2+j6CvIr80ZwyTF09haRkM3X/P1suC3rKoFrb0cBQlGByrhfNG2Rqin9a8Bfvs PJAgpgnUGDP/NJEqrn+b+2xqsSCjTdk27yNfKz3YrCvqRrpFkSdJhiPpXVYUHLe2wznv ZepYlet2m8VvtRpqv8TC/vt9IyzasxjPPSdlIQeiglDbTmv0rmQKT3Og7DohrVyGlHQR xzWB0YO1Fk8/xVaPJqMVSelJqAQr8yzBmqagdaRLqmrB1Yn8Ec58K5ADOBgbMZccYHm5 9mbw== X-Gm-Message-State: AFuF++lo9UNHSCZiOxUwHRi/JjoaUwYpJk2F/FQDkJ60dVXKx7SEjG+N gJIofj4bXekmfQWbWX1QFLigqh+gcpmj+fmoSJQ0d0OAzjn4Yrqkc6y9fgK6lytdubjHVa2yF0Q Le7QYkqhFwBwbyzhiDZexKWk4O/mVO46xONPoW+5hJV73csbRhNxfh/UD46673D7FLEVNS817Ba M2EDbBsRyPvxDZtCiwYhJL2jSOUkRgoolzNw== X-Gm-Gg: AYBFou22P+kV9yUGjKBUqZsHrk+4h6woAYYCNwLdhS7opDkdDKvLp8or5YquGP3G2VM BTQXsMMXJOiP7mhKeAEzpGKVWRd6L8LrLD0/fThYzttnGUJzrpUq4ac3nQyijlzFDW8jxP+GEJW LcBFd9QeF/Gd+o9j0l/m7y0SZ/UbEfWRDEkO4ujEyhWLTKMpFseHPUiCImXZlvgc7thOuLP4NyI rL3ADcgk6SGJX6R7JU0SY/+1UnJGpegIBLbg3/j//VAYx9oX9ApkPS4/BR7u217hRjVWvbUOPBI oi36w/MbcJHkDIWUBNsOhiZjMAuX+mHBThfbHJ01GdCRnrsFVK2VVWjVl4wqv/bgqeG6fmMn56e /cp7lbPZIj2mNEVP5AlZe1NE= X-Received: by 2002:a05:6000:46d0:b0:485:b096:d2d3 with SMTP id ffacd0b85a97d-486eb2d9f0amr1164665f8f.7.1789071254210; Thu, 10 Sep 2026 13:14:14 -0700 (PDT) X-Received: by 2002:a05:6000:46d0:b0:485:b096:d2d3 with SMTP id ffacd0b85a97d-486eb2d9f0amr1164588f8f.7.1789071253600; Thu, 10 Sep 2026 13:14:13 -0700 (PDT) Date: Thu, 10 Sep 2026 16:14:11 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Sairaj Kodilkar , Igor Mammedov , Ani Sinha Subject: [PULL 65/90] tests/acpi: x86: update golden masters for IVRS Message-ID: <6795e746b2aafca99198d3fa0058f9095c2cb2d4.1789071043.git.mst@redhat.com> References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-Mailer: git-send-email 2.51.2.2891.g4157995a80.dirty X-Mutt-Fcc: =sent 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=170.10.133.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com 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, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_PASS=-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-Zoho-Virus-Status: 1 X-Zoho-AV-Stamp: zmail-av-0.2.13.1.5.4/289.52.80 X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1789075249787158500 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Sairaj Kodilkar Differences between disassembled ASL files for IVRS: /* * Intel ACPI Component Architecture * AML/ASL+ Disassembler version 20200925 (64-bit version) * Copyright (c) 2000 - 2020 Intel Corporation * - * Disassembly of tests/data/acpi/x86/q35/IVRS.ivrs, Mon May 11 11:21:47 2= 026 + * Disassembly of /tmp/aml-NGQ9O3, Mon May 11 11:21:47 2026 * * ACPI Data Table [IVRS] * * Format: [HexOffset DecimalOffset ByteLength] FieldName : FieldValue */ [000h 0000 4] Signature : "IVRS" [I/O Virtualizati= on Reporting Structure] [004h 0004 4] Table Length : 000000B0 [008h 0008 1] Revision : 01 -[009h 0009 1] Checksum : 74 +[009h 0009 1] Checksum : CB [00Ah 0010 6] Oem ID : "BOCHS " [010h 0016 8] Oem Table ID : "BXPC " [018h 0024 4] Oem Revision : 00000001 [01Ch 0028 4] Asl Compiler ID : "BXPC" [020h 0032 4] Asl Compiler Revision : 00000001 -[024h 0036 4] Virtualization Info : 00002801 +[024h 0036 4] Virtualization Info : 00203441 [028h 0040 8] Reserved : 0000000000000000 [030h 0048 1] Subtable Type : 10 [Hardware Definition Blo= ck] -[031h 0049 1] Flags : D1 +[031h 0049 1] Flags : 51 [032h 0050 2] Length : 0038 [034h 0052 2] DeviceId : 0010 [036h 0054 2] Capability Offset : 0040 [038h 0056 8] Base Address : 00000000FED80000 [040h 0064 2] PCI Segment Group : 0000 [042h 0066 2] Virtualization Info : 0000 -[044h 0068 4] Feature Reporting : 00000044 +[044h 0068 4] Feature Reporting : A0000064 [048h 0072 1] Entry Type : 02 [049h 0073 2] Device ID : 0000 [04Bh 0075 1] Data Setting : 00 [04Ch 0076 1] Entry Type : 02 [04Dh 0077 2] Device ID : 0008 [04Fh 0079 1] Data Setting : 00 [050h 0080 1] Entry Type : 02 [051h 0081 2] Device ID : 0010 [053h 0083 1] Data Setting : 00 [054h 0084 1] Entry Type : 02 [055h 0085 2] Device ID : 00F8 [057h 0087 1] Data Setting : 00 @@ -62,33 +62,33 @@ [061h 0097 2] Device ID : 0000 [063h 0099 1] Data Setting : 00 [064h 0100 1] Handle : 00 [065h 0101 2] Source Used Device ID : 00A0 [067h 0103 1] Variety : 01 [068h 0104 1] Subtable Type : 11 [Hardware Definition Blo= ck] [069h 0105 1] Flags : 11 [06Ah 0106 2] Length : 0048 [06Ch 0108 2] DeviceId : 0010 [06Eh 0110 2] Capability Offset : 0040 [070h 0112 8] Base Address : 00000000FED80000 [078h 0120 2] PCI Segment Group : 0000 [07Ah 0122 2] Virtualization Info : 0000 [07Ch 0124 4] Attributes : 00000000 -[080h 0128 8] EFR Image : 00000000000029D3 +[080h 0128 8] EFR Image : 00000000000028D1 [088h 0136 8] Reserved : 0000000000000000 [090h 0144 1] Entry Type : 02 [091h 0145 2] Device ID : 0000 [093h 0147 1] Data Setting : 00 [094h 0148 1] Entry Type : 02 [095h 0149 2] Device ID : 0008 [097h 0151 1] Data Setting : 00 [098h 0152 1] Entry Type : 02 [099h 0153 2] Device ID : 0010 [09Bh 0155 1] Data Setting : 00 [09Ch 0156 1] Entry Type : 02 [09Dh 0157 2] Device ID : 00F8 @@ -98,27 +98,27 @@ [0A1h 0161 2] Device ID : 00FA [0A3h 0163 1] Data Setting : 00 [0A4h 0164 1] Entry Type : 02 [0A5h 0165 2] Device ID : 00FB [0A7h 0167 1] Data Setting : 00 [0A8h 0168 1] Entry Type : 48 [0A9h 0169 2] Device ID : 0000 [0ABh 0171 1] Data Setting : 00 [0ACh 0172 1] Handle : 00 [0ADh 0173 2] Source Used Device ID : 00A0 [0AFh 0175 1] Variety : 01 Signed-off-by: Sairaj Kodilkar Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin Message-ID: <20260807061250.27739-8-sarunkod@amd.com> --- tests/qtest/bios-tables-test-allowed-diff.h | 1 - tests/data/acpi/x86/q35/IVRS.ivrs | Bin 176 -> 176 bytes 2 files changed, 1 deletion(-) diff --git a/tests/qtest/bios-tables-test-allowed-diff.h b/tests/qtest/bios= -tables-test-allowed-diff.h index 33e9981655..dfb8523c8b 100644 --- a/tests/qtest/bios-tables-test-allowed-diff.h +++ b/tests/qtest/bios-tables-test-allowed-diff.h @@ -1,2 +1 @@ /* List of comma-separated changed AML files to ignore */ -tests/data/acpi/x86/q35/IVRS.ivrs diff --git a/tests/data/acpi/x86/q35/IVRS.ivrs b/tests/data/acpi/x86/q35/IV= RS.ivrs index 7f9e91aabc0b7777a7efc9f219587a4f91f0edb1..b3b809c65f026fde0a49a2243a3= 216e7b8c87502 100644 GIT binary patch delta 67 zcmdnMxPg(&Gb|{00|NsC (p=quarantine dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1789073929119316.20030186991085; Thu, 10 Sep 2026 13:58:49 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1x4lph-0002mj-1n; Thu, 10 Sep 2026 16:57:41 -0400 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 1x4lJp-0002Nl-NZ for qemu-devel@nongnu.org; Thu, 10 Sep 2026 16:24:39 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1x4lJc-0008F7-UD for qemu-devel@nongnu.org; Thu, 10 Sep 2026 16:24:22 -0400 Received: from mail-wr1-f71.google.com (mail-wr1-f71.google.com [209.85.221.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-122-ICpaDwDqNzaan2RtauthBQ-1; Thu, 10 Sep 2026 16:14:18 -0400 Received: by mail-wr1-f71.google.com with SMTP id ffacd0b85a97d-482e05af072so99899f8f.3 for ; Thu, 10 Sep 2026 13:14:18 -0700 (PDT) Received: from redhat.com (IGLD-80-230-79-236.inter.net.il. [80.230.79.236]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-486eb32e6f1sm816155f8f.6.2026.09.10.13.14.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Sep 2026 13:14:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1789071663; 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=n9ZmjCxLo+pq7wNUdqZBErRHKHAn5SxcOItc3qcLCnY=; b=g28hXxEVkrWemqki2ydL0W8dH8N8YAwJjFXDnRD0vcxxi4Z7oYhjcp9tUowYOEbIHnHVHn 5x8gb98cIU8/YIBj3s20PbUt82aMctLg9PKzgqvqngGzj9HNNUHXinmMEmCRElzFYmYxoG eWDXKh0uz+0W9o6gjTl330ZV5Jachec= X-MC-Unique: ICpaDwDqNzaan2RtauthBQ-1 X-Mimecast-MFC-AGG-ID: ICpaDwDqNzaan2RtauthBQ_1789071257 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=google; t=1789071257; x=1789676057; 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=n9ZmjCxLo+pq7wNUdqZBErRHKHAn5SxcOItc3qcLCnY=; b=nNb12Ud/YdVbK+ZBsgAh8UODPTE0239Rs0t5yNAt78c6I0PRc053V5gmZsmDBMSAoy YY/kEqYUjaNwAA573KqFnUR8I3iAHMVScwVOmZ5bfOQdFirvowMVJi2FVJ+26Dk6C/hm CK9Ldkaohw6b9oWKqhIY4w2zWQQyYV8N24mGLJrrA9qzBU8r9LZC+CjkSO9ZdwXRFVIK mihn0nkO4XsyETCPU+gwOrvAwI2n6nb5W3tnV+mMgwIEO1/xmb647gwnDIczi+CRfTBS C2nZ9npYh4rXFVNo9yesG9GcLcZxVMLQ5woTD7sIsLlBjVwkvNZCA/9pNvGCPDJP2SWq bRHg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1789071257; x=1789676057; 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=n9ZmjCxLo+pq7wNUdqZBErRHKHAn5SxcOItc3qcLCnY=; b=nrV3vaBLGaSM2lx/nzLVMQfR1iN7cosB2P0icLe0oWEtGh2XZ98PuGJ6x4TLIdvKip z1SIuRSV3ejxe5Gy0itiHEUiMSWDxeHmonlgxzqCj9HXUOZ/hM9fgEmUc9lcbLg2ePny U21rRJOCO8dsn6r8CEg0nsNP84rj/ULpSOuAVM2+fICma78l2C8APOuA/BrzAAr0LtGz 3X2fnyqlJcorMMKRTMxa5xG1HYLP0IfIKuEYP1Qsx3FrVnufGFAIHiy5AJeqqT+1rwzz rELpqiKj/yQ9yRfO8p7WtbLuGv6i/4tIN4lipsitqlSGGmFqhaDuVaU5hdBXyPmTENGr Ipcw== X-Gm-Message-State: AFuF++nTa2tNz6u0VZFlI4Fn7CQoJ6uAnt2/OA0e+kkfmOw9G4xRo7hw HaPnti9YxwyUTNVzMpxNs/P3jaeoGLMYxaxluP3OUI0vrR0WtyxGPFdkyjh6eyWhk+AxyUOvJLF bXReey51WGEE4l4e6rohjeGZ4r1t5CYnlL5X2nu5DXQ0W/VUdgG1kDiIHztgIgdxlwTpk2fkHwH mKDcd4xu97Mv7/dV7Tum9jhGK5PrAvy4QBYA== X-Gm-Gg: AYBFou1bW5CSeD8DfTAD8SVUOjWukksXwoq6/9UfPjfrjQV/0oHa86Wo8wz0uyL795n uwmsD82uBzjPd2zJaetGUprat3r510kwkYeCgbiV8KZ25Ds+kVIibqKDaP7dYhdFpVyuLLFRTPk iUhVfpztWvcs/VBhLpA/7zdEzp99mvITCLjgqkKum1R3L81eUNxywiBGTDBkenTq0Dut8XvSuxj o09rRjZ56CseYFliY8tC5MoU4lI9vHWpgv5HpkljuK6ttXL8oRfaAHcPJKkvWApU3RSaYHQR/7O BNea4ttTKjK+ZemviEmiwOXGafQOi7CY8J1E4hQmTbkdNOmrLpf+udERtUHvrpXYcXwrW0M4Ww5 nh7tzsreU2cQhl7tiCSfmQmQ= X-Received: by 2002:a05:6000:46c4:b0:485:8c17:976b with SMTP id ffacd0b85a97d-486eb3164bdmr336811f8f.45.1789071257145; Thu, 10 Sep 2026 13:14:17 -0700 (PDT) X-Received: by 2002:a05:6000:46c4:b0:485:8c17:976b with SMTP id ffacd0b85a97d-486eb3164bdmr336785f8f.45.1789071256588; Thu, 10 Sep 2026 13:14:16 -0700 (PDT) Date: Thu, 10 Sep 2026 16:14:13 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Bin Guo , Stefano Garzarella Subject: [PULL 66/90] libvhost-user: accept the postcopy client base ack in vu_add_mem_reg() Message-ID: References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-Mailer: git-send-email 2.51.2.2891.g4157995a80.dirty X-Mutt-Fcc: =sent 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=170.10.129.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com 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, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=0.001, SPF_HELO_PASS=-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-Zoho-Virus-Status: 1 X-Zoho-AV-Stamp: zmail-av-0.2.13.1.5.4/289.52.80 X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1789073930695158500 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Bin Guo In postcopy mode QEMU signals that it has collected all the postcopy client bases by sending a VHOST_USER_ADD_MEM_REG message with a u64 payload of 0 and no file descriptor (see vhost_user_add_remove_regions()). vu_add_mem_reg() has a case for that message, but only reaches it after validating the fd count of a regular region, so the ack is rejected first: VHOST_USER_ADD_MEM_REG received 0 fds - only 1 fd should be sent for this message type This kills the backend during memory table setup, making postcopy unusable for any libvhost-user backend that negotiates VHOST_USER_PROTOCOL_F_CONFIGURE_MEM_SLOTS. Recognise the ack before validating the fd count. Fixes: 9f4e63491b ("libvhost-user: Add vu_add_mem_reg input validation") Signed-off-by: Bin Guo Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin Message-ID: <20260813095501.20282-2-guobin@linux.alibaba.com> --- subprojects/libvhost-user/libvhost-user.c | 26 ++++++++++++----------- 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/subprojects/libvhost-user/libvhost-user.c b/subprojects/libvho= st-user/libvhost-user.c index a74d814bb4..248550aae1 100644 --- a/subprojects/libvhost-user/libvhost-user.c +++ b/subprojects/libvhost-user/libvhost-user.c @@ -948,6 +948,20 @@ static bool vu_add_mem_reg(VuDev *dev, VhostUserMsg *vmsg) { VhostUserMemoryRegion m =3D vmsg->payload.memreg.region, *msg_region = =3D &m; =20 + /* + * If we are in postcopy mode and we receive a u64 payload with a 0 va= lue + * we know all the postcopy client bases have been received, and we + * should start generating faults. This message carries no file + * descriptor, so it has to be recognised before the fd count of a real + * region is validated below. + */ + if (dev->postcopy_listening && + vmsg->size =3D=3D sizeof(vmsg->payload.u64) && + vmsg->payload.u64 =3D=3D 0) { + (void)generate_faults(dev); + return false; + } + if (vmsg->fd_num !=3D 1) { vmsg_close_fds(vmsg); vu_panic(dev, "VHOST_USER_ADD_MEM_REG received %d fds - only 1 fd " @@ -971,18 +985,6 @@ vu_add_mem_reg(VuDev *dev, VhostUserMsg *vmsg) { return false; } =20 - /* - * If we are in postcopy mode and we receive a u64 payload with a 0 va= lue - * we know all the postcopy client bases have been received, and we - * should start generating faults. - */ - if (dev->postcopy_listening && - vmsg->size =3D=3D sizeof(vmsg->payload.u64) && - vmsg->payload.u64 =3D=3D 0) { - (void)generate_faults(dev); - return false; - } - _vu_add_mem_reg(dev, msg_region, vmsg->fds[0]); close(vmsg->fds[0]); =20 --=20 MST From nobody Sat Sep 26 20:50:17 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=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1789080430; cv=none; d=zohomail.com; s=zohoarc; b=BbK8czKrfItet3FgVOYjIUgCaCOiZAErDTvMUlclzEuG02j5b9mn9zbiHTBQICDZs6SM+Gl5ceHxXpEjnGhUTsgJcKM94mMAPJEUWuxnFnfjNMZiK4tI81gYqzIbi1ZfPOZk+Nmgvhpv10/8rDVXoQiGU0pmpl/Ume/Hha+OECg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1789080430; h=Content-Type: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=OCozH6Xs5QSeR+YEhmbXShw4rBZnSCVZ1vH0Ur9vXBU=; b=ejL3Z2UFHQr5sazEyCfvE9LFAV8C9R0Wr9vinV4NJM1Z8Dr4hlWximpOGJYpnx+6FiKMi54yzT/B5zSuogCeFGkyvW1d2LGw8BSREdGcJQ0ED9ghUp728DrshkuM9DiTlXU8wNKlNGpM24YQm+pL8lCSALc9UUD6eqNGtv3AvXc= 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 lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 178908043068685.05537259795244; Thu, 10 Sep 2026 15:47:10 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1x4nU9-0001wd-So; Thu, 10 Sep 2026 18:43:23 -0400 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 1x4lKx-0002qO-0e for qemu-devel@nongnu.org; Thu, 10 Sep 2026 16:25:43 -0400 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 1x4lKe-0000Hx-6x for qemu-devel@nongnu.org; Thu, 10 Sep 2026 16:25:20 -0400 Received: from mail-wr1-f72.google.com (mail-wr1-f72.google.com [209.85.221.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-570-nx-jA5J-MiOJdgy6-JIWsA-1; Thu, 10 Sep 2026 16:14:20 -0400 Received: by mail-wr1-f72.google.com with SMTP id ffacd0b85a97d-47d81cf0c4cso69244f8f.2 for ; Thu, 10 Sep 2026 13:14:20 -0700 (PDT) Received: from redhat.com (IGLD-80-230-79-236.inter.net.il. [80.230.79.236]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-486eb35bd1esm767200f8f.31.2026.09.10.13.14.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Sep 2026 13:14:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1789071721; 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=OCozH6Xs5QSeR+YEhmbXShw4rBZnSCVZ1vH0Ur9vXBU=; b=Z5fKU3hoIhW4SFOoy37OlDW3OVGiXcHOXPRDvFtTIa2yjgpTzAXlIOR3A/8u/AFeyxVevI lmKlPjabROnuq6YsCqoCm5ppV2B3eNkTXy9AAiDhVq0vjnA6ot0tjb2Zb0zddv5i5BGEtq TkGY6JqIH6mk2ELgvWZ6icMNNiDKxcM= X-MC-Unique: nx-jA5J-MiOJdgy6-JIWsA-1 X-Mimecast-MFC-AGG-ID: nx-jA5J-MiOJdgy6-JIWsA_1789071260 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=google; t=1789071259; x=1789676059; 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=OCozH6Xs5QSeR+YEhmbXShw4rBZnSCVZ1vH0Ur9vXBU=; b=QN1mSOT86a95xOiBirrQi8BOO2M+SpZEZrq00XgSDg4/f0AN/idQVewRcVlyX0gOaZ Svg3xIw96NXDvg/zq42I713X8kLcUhVnsgrHL3mj+7FeEMi1+EEIgcvW4cA/xwdnMsob x6POr+A8bKDBkybonMa3mGu0FxI8S0dgEHlKzX9qbnyf8W088hnKaLVe/JJNfGqgA9es F17wgiMhMqgXJApJ4hkr+XoXxvO1hKu/sr6zInz/HuVB7ll5QK3DAU9DcSn1egk+K5zV FscxpAwfL+RZVcqp3srRJeqDxOYTxFYO9B95CnGQN2wbhBETE0KXrfVJfK8jVIXhlS8i 93/A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1789071259; x=1789676059; 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=OCozH6Xs5QSeR+YEhmbXShw4rBZnSCVZ1vH0Ur9vXBU=; b=JmepbKmnTySbE8baHs7SbHhjz8frBMtouk8VDgTPiiQVi2wgF4wouoIHaiIJasTS7z 5SAPGgkpJJ/aSEFflSYrPR6JMA0YMQPQfjcD+kRJMiuLbJo6h9yYzjCaJna2+EZGxu4W ZoetXANFVPFy3Z75LJEJZXwVm+pk5OeF09hL3er9mwsQ3twqGs9u9Soll22OkSm7ekSw ovj1DtREN5F+v+1Fi+DE5nC6kUSHfU4MwHnHtNxeKlak+am7jygQB7ZjrUsMkaMkrlgi 7Zgk/HQFKcRu1js2ntQO/TGWxzBzXXd5PVf+JoTQb/IlCZzwArTLjzoOdiGvkFQcYmj4 rwJw== X-Gm-Message-State: AFuF++n7XKcoZzi8WemY31QPPHe6dIAGUfTKr1bB5vihCBDze7AsWjTf kzbR0ysXJXVV2BfR4Ff7UG7kjafzaTj9/HZsyLJdsu496vzaAJp1kKFqewrJG958Z55DFQSfIW9 x7rCTT/5SP815e3TZzHL5QA8CqkRhZMpu/1xQ10gjbnphpn+8yO2HpXBY0nKMhceevQbY+URxPw 12CVUtGOYLL6Snax8oE78LzLU9jM3OjsD7UA== X-Gm-Gg: AYBFou2YPCNECIH7EtqBxvJ62chHhkB7zoh8q51B0zlzUBtubX+lTymB37XEwy6Kqkz zXrJzuAuWL9lOuAq4EViY2EaXLXJ1p63Tpmsg/hO54Qp9L/TYoB0pScjyBwlLSNg9ovfwgbHdrP DFHadG7OpemlTPSGgLpm0yv0SucZQlfhy+3gt64K0JisWuaCWnNK9TEOs5nKgwHPqQab1ECzS31 7FcTgPBkG051ys+tjux+OtNGVZdgDckF9wEGyKzJM63aAzMfnNqJuejlDuA/J84lioQfSIW3UdO R6ZQgPBvmpEezjL5O2q8j1YmaelbNy45tS6q02GnZgSWA42qqTuQlXHMf1kuFqKj5fJTyfNU0R1 hX02Xv92bEn7E1BRsv5cHg2k= X-Received: by 2002:a5d:64cf:0:b0:482:f0ee:1390 with SMTP id ffacd0b85a97d-486eb34107emr1488279f8f.22.1789071259302; Thu, 10 Sep 2026 13:14:19 -0700 (PDT) X-Received: by 2002:a5d:64cf:0:b0:482:f0ee:1390 with SMTP id ffacd0b85a97d-486eb34107emr1488176f8f.22.1789071258673; Thu, 10 Sep 2026 13:14:18 -0700 (PDT) Date: Thu, 10 Sep 2026 16:14:16 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Bin Guo , Stefano Garzarella Subject: [PULL 67/90] libvhost-user: return the backend mapping address for added regions Message-ID: <793d2895ef2f1b4fc971d40cb0cdd6a6f62b4b25.1789071043.git.mst@redhat.com> References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-Mailer: git-send-email 2.51.2.2891.g4157995a80.dirty X-Mutt-Fcc: =sent 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=170.10.133.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com 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, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_PASS=-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-Zoho-Virus-Status: 1 X-Zoho-AV-Stamp: zmail-av-0.2.13.1.5.4/289.74.40 X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1789080432766158500 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Bin Guo In postcopy mode the backend must tell QEMU where it mapped a region, so that QEMU can translate the backend's fault addresses back into a RAMBlock and offset. vu_add_mem_reg() works on a copy of the region and lets _vu_add_mem_reg() fill the mapping address into that copy, but never writes it back into the reply payload. QEMU then stores its own address as the postcopy client base, so fault resolution fails: vhost_user_postcopy_fault_handler: Failed to find region for fault ... The VHOST_USER_SET_MEM_TABLE path is unaffected, it fills the payload directly. Put the updated region back into the payload before replying; a pointer into the payload cannot be used instead, as VhostUserMsg is packed. Fixes: ec94c8e621 ("Support adding individual regions in libvhost-user") Signed-off-by: Bin Guo Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin Message-ID: <20260813095501.20282-3-guobin@linux.alibaba.com> --- subprojects/libvhost-user/libvhost-user.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/subprojects/libvhost-user/libvhost-user.c b/subprojects/libvho= st-user/libvhost-user.c index 248550aae1..2fed792e85 100644 --- a/subprojects/libvhost-user/libvhost-user.c +++ b/subprojects/libvhost-user/libvhost-user.c @@ -989,7 +989,13 @@ vu_add_mem_reg(VuDev *dev, VhostUserMsg *vmsg) { close(vmsg->fds[0]); =20 if (dev->postcopy_listening) { - /* Send the message back to qemu with the addresses filled in. */ + /* + * Send the message back to qemu with the addresses filled in. + * _vu_add_mem_reg() worked on our copy of the region, so it has t= o be + * put back into the message payload. A pointer into the payload + * cannot be handed out instead, VhostUserMsg is packed. + */ + vmsg->payload.memreg.region =3D m; vmsg->fd_num =3D 0; DPRINT("Successfully added new region in postcopy\n"); return true; --=20 MST From nobody Sat Sep 26 20:50:17 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=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1789080873; cv=none; d=zohomail.com; s=zohoarc; b=lU0/oMPsAFDiS09izpphZ3wl/h9z2RlrHbQ3ukfUY+f/UU5EpkiUL+zfb2HXqYmCmr4l0p0R6G4+Zzt8iROzDV1gTCnnjEdT587h1Ya7kcCmNy3bfYjYEtXe4u/RQcJnjLPEgSXb4bAS4YGyrM6WIgAbe3jXhiNt/WGGEstRbk4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1789080873; h=Content-Type: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=BDaUJ5n6w1ultc7lfv5pJdGM89J/WSuiZOQnoJO8Zqs=; b=JZR0uXoP4oj6oFWd4RS0pTf1ZegNHOd/Sw26nqD5iZSpbqK3/BbA4vBqypEUWz3WH5GHD1W0mqgKLLLCJvfr2E++MAN3alDmm5bKezp/ql96Iar9sKrfK9xc40AzdTJ7EUd0DIxNeSk4Vak3ZmiFUQdWFBxCqpUs7wUJ9xksw2I= 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 lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1789080873172625.4338621111724; Thu, 10 Sep 2026 15:54:33 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1x4nXo-00038H-FM; Thu, 10 Sep 2026 18:47:21 -0400 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 1x4lWs-0006bn-Ka for qemu-devel@nongnu.org; Thu, 10 Sep 2026 16:38:15 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1x4lWV-0003hh-Ia for qemu-devel@nongnu.org; Thu, 10 Sep 2026 16:37:43 -0400 Received: from mail-wr1-f72.google.com (mail-wr1-f72.google.com [209.85.221.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-530-XH_fPjXxOJCQtSSWdw66Xg-1; Thu, 10 Sep 2026 16:14:22 -0400 Received: by mail-wr1-f72.google.com with SMTP id ffacd0b85a97d-48436a5fb42so53245f8f.1 for ; Thu, 10 Sep 2026 13:14:22 -0700 (PDT) Received: from redhat.com (IGLD-80-230-79-236.inter.net.il. [80.230.79.236]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-486eb357288sm795566f8f.29.2026.09.10.13.14.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Sep 2026 13:14:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1789072447; 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=BDaUJ5n6w1ultc7lfv5pJdGM89J/WSuiZOQnoJO8Zqs=; b=gxPItCh6G1rzYJuUVKXFn3nWrsdhsbjGgWioIfqUuU2jmezHwOpYyLJ3izh1+XLJNeeNx2 4218Xl04Mdz56UrzBScC35xZx2r3gtOtwOfHfSN3t8Lx+TagG80FOGaJqXrWFX0TeM91QA k3uRT4rliQxFvuwJqC56usEUuV5bRDs= X-MC-Unique: XH_fPjXxOJCQtSSWdw66Xg-1 X-Mimecast-MFC-AGG-ID: XH_fPjXxOJCQtSSWdw66Xg_1789071262 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=google; t=1789071261; x=1789676061; 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=BDaUJ5n6w1ultc7lfv5pJdGM89J/WSuiZOQnoJO8Zqs=; b=nrEQcIorAaV8szaYUbsh2Z2d+6KMW06G0KW8dOr2OeJyS7YsLTqMqmRbYk1uvXL7EL l9K/xOqjo/9X8q3zJf6qW/CrcqKfdMWTVkCyKq4px4iOQWqT3zWPSzRweMTI6Mdg8BHM plgN1ThGVkwI1o4l08adcb9pr1rD4wU/qhtmwGhVLR79y4FYlozObWlN5XqpYefq3kbR 23Y/mdS+cNCsnJpTs34yLJueHqfayKmn0wQPX1lY+VvGgyx6IVK5+YYh7HxCiGCjeuNX 7WQEjqvZPBhAPdOg2d15xpk19PzbLwkpGqb5/i72Do0E6DObXB1Szsbv7nxTsmG9ZzmD Wpng== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1789071261; x=1789676061; 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=BDaUJ5n6w1ultc7lfv5pJdGM89J/WSuiZOQnoJO8Zqs=; b=cNY5A+tWbVsrhmIKhovrUBYkAtlCFpm+W//kF2sLLUMJv9Ueo886ChZ1S1hESGwx+/ SisjngSASwgOW/k8Y7JtAOdOtu72ynRE5llN3fGz4Ql6PYt85dGiBEhXi7Pb9bDf5yUl UAK0Fgzinxe801AsQebrjvyd+fJ468DPToxgCOKXqBzOf+iSp1ZNxcMB8Pej+l/6l6e2 4yslRdd+e2+55Q9VvaL1fnFTTnx3dgF3ajxpchxUvTRGHEuPFjQ5REx/dR1VV9Sl70FT TQPLrDOR/DTMybv4z/EMV28OVLf28lYk4NWBdCSY4LUTfpECojB8CvPXJlT57R7j4eSn xW/A== X-Gm-Message-State: AFuF++l8igubmIrYGE3QAuSxjhe/NGx4/mzGLRWLbeMHAHQtbFyhxUEe FnLwFDjRdRO7yzzB4a/mJKCPFjZVUGAwgz0nf5xT4sGxK1JbWKiayiHW+u4Kp/w8zltKJnMEfag v7FytokmTxNk3/x8NN3ugh2WYCbPHEjAJxq2JB6qFQm8Mnq0VmDNb44fNu+UEVf4R3AxnkrV0b3 vD/PsE/L+oHBUH84Au4v56WEBMC456zxBeVQ== X-Gm-Gg: AYBFou21vj+o0uHwGTsn2DYNRqtLJuEvjASytVtt4UxbYmRyRApG89skZgG7Du4codR bleGNGfiaHEwoF9k71pR9bAxehyxe6OfUuPvA44cyrQuIUUbofwfhZP9tpvn4uE8XNjLlijMF4K L3K3oy5tSkoZ6dLrpAHveBXRh0hHYUMyEzq8VbQ/4pCoc0zYLWJOvr/l4YqVRuuFoA3gv2xiQPU gZidp+2NTROxCFp3kvHbw8H0katkEIxV3j/c4lxjuFiRbv7KdGfkS7zEBhamdCLfDrgkgkK7p+O kXwuLZENvUwfzvIz8ikuuncnvs0DFDl5qD/c9J6iI4bJEhlpnVj4PEnTPFqilgFANdqiC42qdX8 e7b6XnJ8QTCql2Eh/ZD61+yc= X-Received: by 2002:a05:6000:386:b0:486:e396:d054 with SMTP id ffacd0b85a97d-486eb335206mr809769f8f.36.1789071261428; Thu, 10 Sep 2026 13:14:21 -0700 (PDT) X-Received: by 2002:a05:6000:386:b0:486:e396:d054 with SMTP id ffacd0b85a97d-486eb335206mr809714f8f.36.1789071260833; Thu, 10 Sep 2026 13:14:20 -0700 (PDT) Date: Thu, 10 Sep 2026 16:14:18 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Albert Esteve , Cornelia Huck , Paolo Bonzini Subject: [PULL 68/90] linux-headers: Update to Linux v7.3-rc1 Message-ID: <0485e0dff41bec2a9c89b6acbcd5f57f0dd3d84f.1789071043.git.mst@redhat.com> References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-Mailer: git-send-email 2.51.2.2891.g4157995a80.dirty X-Mutt-Fcc: =sent 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=170.10.129.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com 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, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=0.001, SPF_HELO_PASS=-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-Zoho-Virus-Status: 1 X-Zoho-AV-Stamp: zmail-av-0.2.13.1.5.4/289.74.40 X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1789080875748158500 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Albert Esteve VIRTIO_ID_MEDIA was added previously, synchronize the rest of the headers to the same version. Signed-off-by: Albert Esteve Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin Message-ID: <20260821135038.2676679-1-aesteve@redhat.com> --- include/standard-headers/linux/ethtool.h | 6 +++ linux-headers/linux/iommufd.h | 45 ++++++++++++++++++-- linux-headers/linux/userfaultfd.h | 54 ++++++++++++++++++++++-- linux-headers/linux/vduse.h | 28 ++++++++++++ linux-headers/linux/vfio.h | 21 +++++++++ linux-headers/linux/vfio_zdev.h | 2 + 6 files changed, 149 insertions(+), 7 deletions(-) diff --git a/include/standard-headers/linux/ethtool.h b/include/standard-he= aders/linux/ethtool.h index 55f608c3a7..622d634d04 100644 --- a/include/standard-headers/linux/ethtool.h +++ b/include/standard-headers/linux/ethtool.h @@ -2015,7 +2015,13 @@ enum ethtool_link_mode_bit_indices { ETHTOOL_LINK_MODE_100000baseLR4_ER4_Full_BIT =3D 39, ETHTOOL_LINK_MODE_50000baseSR2_Full_BIT =3D 40, ETHTOOL_LINK_MODE_1000baseX_Full_BIT =3D 41, + + /* Despite the "baseCR" in 10000baseCR, this is not an IEEE 802.3 baseCR + * It represents SFF-8431 Appendix-E SFP+ Direct Attach (10G-SFI-DA). + * The name is kept as-is for uAPI backward compatibility. + */ ETHTOOL_LINK_MODE_10000baseCR_Full_BIT =3D 42, + ETHTOOL_LINK_MODE_10000baseSR_Full_BIT =3D 43, ETHTOOL_LINK_MODE_10000baseLR_Full_BIT =3D 44, ETHTOOL_LINK_MODE_10000baseLRM_Full_BIT =3D 45, diff --git a/linux-headers/linux/iommufd.h b/linux-headers/linux/iommufd.h index 10c600d71e..3c61caadbf 100644 --- a/linux-headers/linux/iommufd.h +++ b/linux-headers/linux/iommufd.h @@ -57,6 +57,7 @@ enum { IOMMUFD_CMD_IOAS_CHANGE_PROCESS =3D 0x92, IOMMUFD_CMD_VEVENTQ_ALLOC =3D 0x93, IOMMUFD_CMD_HW_QUEUE_ALLOC =3D 0x94, + IOMMUFD_CMD_IOAS_NOIOMMU_GET_PA =3D 0x95, }; =20 /** @@ -219,6 +220,33 @@ struct iommu_ioas_map { }; #define IOMMU_IOAS_MAP _IO(IOMMUFD_TYPE, IOMMUFD_CMD_IOAS_MAP) =20 +/** + * struct iommu_ioas_noiommu_get_pa - ioctl(IOMMU_IOAS_NOIOMMU_GET_PA) + * @size: sizeof(struct iommu_ioas_noiommu_get_pa) + * @flags: Reserved, must be 0 for now + * @ioas_id: IOAS ID to query IOVA to PA mapping from + * @__reserved: Must be 0 + * @iova: IOVA to query + * @length: On input, non-zero maximum number of bytes to query starting f= rom + * @iova. On output, number of physically contiguous bytes starti= ng + * from @out_phys, capped by the input length. + * @out_phys: Output physical address the IOVA maps to + * + * Query the physical address backing an IOVA range. The beginning of the + * range must be mapped already and length must be non-zero. For noiommu + * devices doing unsafe DMA only. + */ +struct iommu_ioas_noiommu_get_pa { + __u32 size; + __u32 flags; + __u32 ioas_id; + __u32 __reserved; + __aligned_u64 iova; + __aligned_u64 length; + __aligned_u64 out_phys; +}; +#define IOMMU_IOAS_NOIOMMU_GET_PA _IO(IOMMUFD_TYPE, IOMMUFD_CMD_IOAS_NOIOM= MU_GET_PA) + /** * struct iommu_ioas_map_file - ioctl(IOMMU_IOAS_MAP_FILE) * @size: sizeof(struct iommu_ioas_map_file) @@ -574,11 +602,22 @@ struct iommu_hw_info_vtd { __aligned_u64 ecap_reg; }; =20 +/** + * enum iommu_hw_info_arm_smmuv3_flags - Flags for ARM SMMUv3 hw_info + * @IOMMU_HW_INFO_ARM_SMMUV3_ERRATA_REPEAT_TLBI_CFGI: + * If set, user space must issue TLBI/CFGI+SYNC commands twice due to + * hardware erratum T264-SMMU-3. See the description at + * arm_smmu_erratum_repeat_tlbi_cfgi_key. + */ +enum iommu_hw_info_arm_smmuv3_flags { + IOMMU_HW_INFO_ARM_SMMUV3_ERRATA_REPEAT_TLBI_CFGI =3D 1 << 0, +}; + /** * struct iommu_hw_info_arm_smmuv3 - ARM SMMUv3 hardware information * (IOMMU_HW_INFO_TYPE_ARM_SMMUV3) * - * @flags: Must be set to 0 + * @flags: Combination of enum iommu_hw_info_arm_smmuv3_flags * @__reserved: Must be 0 * @idr: Implemented features for ARM SMMU Non-secure programming interface * @iidr: Information about the implementation and implementer of ARM SMMU, @@ -594,7 +633,7 @@ struct iommu_hw_info_vtd { * idr[0]: ST_LEVEL, TERM_MODEL, STALL_MODEL, TTENDIAN , CD2L, ASID16, TTF * idr[1]: SIDSIZE, SSIDSIZE * idr[3]: BBML, RIL - * idr[5]: VAX, GRAN64K, GRAN16K, GRAN4K + * idr[5]: VAX, GRAN64K, GRAN16K, GRAN4K, DS * * - S1P should be assumed to be true if a NESTED HWPT can be created * - VFIO/iommufd only support platforms with COHACC, it should be assumed= to be @@ -602,7 +641,7 @@ struct iommu_hw_info_vtd { * - ATS is a per-device property. If the VMM describes any devices as ATS * capable in ACPI/DT it should set the corresponding idr. * - * This list may expand in future (eg E0PD, AIE, PBHA, D128, DS etc). It is + * This list may expand in future (eg E0PD, AIE, PBHA, D128 etc). It is * important that VMMs do not read bits outside the list to allow for * compatibility with future kernels. Several features in the SMMUv3 * architecture are not currently supported by the kernel for nesting: HTT= U, diff --git a/linux-headers/linux/userfaultfd.h b/linux-headers/linux/userfa= ultfd.h index 4283de22d5..c8e99df952 100644 --- a/linux-headers/linux/userfaultfd.h +++ b/linux-headers/linux/userfaultfd.h @@ -25,7 +25,8 @@ #define UFFD_API ((__u64)0xAA) #define UFFD_API_REGISTER_MODES (UFFDIO_REGISTER_MODE_MISSING | \ UFFDIO_REGISTER_MODE_WP | \ - UFFDIO_REGISTER_MODE_MINOR) + UFFDIO_REGISTER_MODE_MINOR | \ + UFFDIO_REGISTER_MODE_RWP) #define UFFD_API_FEATURES (UFFD_FEATURE_PAGEFAULT_FLAG_WP | \ UFFD_FEATURE_EVENT_FORK | \ UFFD_FEATURE_EVENT_REMAP | \ @@ -42,10 +43,13 @@ UFFD_FEATURE_WP_UNPOPULATED | \ UFFD_FEATURE_POISON | \ UFFD_FEATURE_WP_ASYNC | \ - UFFD_FEATURE_MOVE) + UFFD_FEATURE_MOVE | \ + UFFD_FEATURE_RWP | \ + UFFD_FEATURE_RWP_ASYNC) #define UFFD_API_IOCTLS \ ((__u64)1 << _UFFDIO_REGISTER | \ (__u64)1 << _UFFDIO_UNREGISTER | \ + (__u64)1 << _UFFDIO_SET_MODE | \ (__u64)1 << _UFFDIO_API) #define UFFD_API_RANGE_IOCTLS \ ((__u64)1 << _UFFDIO_WAKE | \ @@ -54,13 +58,15 @@ (__u64)1 << _UFFDIO_MOVE | \ (__u64)1 << _UFFDIO_WRITEPROTECT | \ (__u64)1 << _UFFDIO_CONTINUE | \ - (__u64)1 << _UFFDIO_POISON) + (__u64)1 << _UFFDIO_POISON | \ + (__u64)1 << _UFFDIO_RWPROTECT) #define UFFD_API_RANGE_IOCTLS_BASIC \ ((__u64)1 << _UFFDIO_WAKE | \ (__u64)1 << _UFFDIO_COPY | \ (__u64)1 << _UFFDIO_WRITEPROTECT | \ (__u64)1 << _UFFDIO_CONTINUE | \ - (__u64)1 << _UFFDIO_POISON) + (__u64)1 << _UFFDIO_POISON | \ + (__u64)1 << _UFFDIO_RWPROTECT) =20 /* * Valid ioctl command number range with this API is from 0x00 to @@ -79,6 +85,8 @@ #define _UFFDIO_WRITEPROTECT (0x06) #define _UFFDIO_CONTINUE (0x07) #define _UFFDIO_POISON (0x08) +#define _UFFDIO_RWPROTECT (0x09) +#define _UFFDIO_SET_MODE (0x0A) #define _UFFDIO_API (0x3F) =20 /* userfaultfd ioctl ids */ @@ -103,6 +111,10 @@ struct uffdio_continue) #define UFFDIO_POISON _IOWR(UFFDIO, _UFFDIO_POISON, \ struct uffdio_poison) +#define UFFDIO_RWPROTECT _IOWR(UFFDIO, _UFFDIO_RWPROTECT, \ + struct uffdio_rwprotect) +#define UFFDIO_SET_MODE _IOW(UFFDIO, _UFFDIO_SET_MODE, \ + struct uffdio_set_mode) =20 /* read() structure */ struct uffd_msg { @@ -158,6 +170,7 @@ struct uffd_msg { #define UFFD_PAGEFAULT_FLAG_WRITE (1<<0) /* If this was a write fault */ #define UFFD_PAGEFAULT_FLAG_WP (1<<1) /* If reason is VM_UFFD_WP */ #define UFFD_PAGEFAULT_FLAG_MINOR (1<<2) /* If reason is VM_UFFD_MINOR */ +#define UFFD_PAGEFAULT_FLAG_RWP (1<<3) /* If reason is VM_UFFD_RWP */ =20 struct uffdio_api { /* userland asks for an API number and the features to enable */ @@ -230,6 +243,18 @@ struct uffdio_api { * * UFFD_FEATURE_MOVE indicates that the kernel supports moving an * existing page contents from userspace. + * + * UFFD_FEATURE_RWP indicates that the kernel supports + * UFFDIO_REGISTER_MODE_RWP for read-write protection tracking. + * Pages are made inaccessible via UFFDIO_RWPROTECT and faults + * are delivered when the pages are re-accessed. + * + * UFFD_FEATURE_RWP_ASYNC indicates asynchronous mode for + * UFFDIO_REGISTER_MODE_RWP. When set, faults on read-write + * protected pages are auto-resolved by the kernel (PTE + * permissions restored immediately) without delivering a message + * to the userfaultfd handler. Use PAGEMAP_SCAN with inverted + * PAGE_IS_ACCESSED to find pages that were not re-accessed. */ #define UFFD_FEATURE_PAGEFAULT_FLAG_WP (1<<0) #define UFFD_FEATURE_EVENT_FORK (1<<1) @@ -248,6 +273,8 @@ struct uffdio_api { #define UFFD_FEATURE_POISON (1<<14) #define UFFD_FEATURE_WP_ASYNC (1<<15) #define UFFD_FEATURE_MOVE (1<<16) +#define UFFD_FEATURE_RWP (1<<17) +#define UFFD_FEATURE_RWP_ASYNC (1<<18) __u64 features; =20 __u64 ioctls; @@ -263,6 +290,7 @@ struct uffdio_register { #define UFFDIO_REGISTER_MODE_MISSING ((__u64)1<<0) #define UFFDIO_REGISTER_MODE_WP ((__u64)1<<1) #define UFFDIO_REGISTER_MODE_MINOR ((__u64)1<<2) +#define UFFDIO_REGISTER_MODE_RWP ((__u64)1<<3) __u64 mode; =20 /* @@ -356,6 +384,14 @@ struct uffdio_poison { __s64 updated; }; =20 +struct uffdio_rwprotect { + struct uffdio_range range; + /* !RWP means undo RWP-protection */ +#define UFFDIO_RWPROTECT_MODE_RWP ((__u64)1<<0) +#define UFFDIO_RWPROTECT_MODE_DONTWAKE ((__u64)1<<1) + __u64 mode; +}; + struct uffdio_move { __u64 dst; __u64 src; @@ -374,6 +410,16 @@ struct uffdio_move { __s64 move; }; =20 +struct uffdio_set_mode { + /* + * Toggle async mode for features at runtime. + * Supported: UFFD_FEATURE_RWP_ASYNC. + * Setting a bit in both enable and disable is invalid. + */ + __u64 enable; + __u64 disable; +}; + /* * Flags for the userfaultfd(2) system call itself. */ diff --git a/linux-headers/linux/vduse.h b/linux-headers/linux/vduse.h index e19b3c0f51..bab47129db 100644 --- a/linux-headers/linux/vduse.h +++ b/linux-headers/linux/vduse.h @@ -14,6 +14,12 @@ =20 #define VDUSE_API_VERSION_1 1 =20 +/* The VDUSE instance expects a request for vq ready */ +#define VDUSE_F_QUEUE_READY 0 + +/* The VDUSE instance expects a request for suspend */ +#define VDUSE_F_SUSPEND 1 + /* * Get the version of VDUSE API that kernel supported (VDUSE_API_VERSION). * This is used for future extension. @@ -63,6 +69,12 @@ struct vduse_dev_config { */ #define VDUSE_DESTROY_DEV _IOW(VDUSE_BASE, 0x03, char[VDUSE_NAME_MAX]) =20 +/* Get the VDUSE supported features */ +#define VDUSE_GET_FEATURES _IOR(VDUSE_BASE, 0x04, __u64) + +/* Set the VDUSE features */ +#define VDUSE_SET_FEATURES _IOW(VDUSE_BASE, 0x05, __u64) + /* The ioctls for VDUSE device (/dev/vduse/$NAME) */ =20 /** @@ -325,6 +337,8 @@ enum vduse_req_type { VDUSE_SET_STATUS, VDUSE_UPDATE_IOTLB, VDUSE_SET_VQ_GROUP_ASID, + VDUSE_SET_VQ_READY, + VDUSE_SUSPEND, }; =20 /** @@ -372,6 +386,15 @@ struct vduse_iova_range_v2 { __u32 padding; }; =20 +/** + * struct vduse_vq_ready - Virtqueue ready request message + * @num: Virtqueue number + */ +struct vduse_vq_ready { + __u32 num; + __u32 ready; +}; + /** * struct vduse_dev_request - control request * @type: request type @@ -382,6 +405,7 @@ struct vduse_iova_range_v2 { * @iova: IOVA range for updating * @iova_v2: IOVA range for updating if API_VERSION >=3D 1 * @vq_group_asid: ASID of a virtqueue group + * @vq_ready: Virtqueue ready request * @padding: padding * * Structure used by read(2) on /dev/vduse/$NAME. @@ -399,6 +423,10 @@ struct vduse_dev_request { */ struct vduse_iova_range_v2 iova_v2; struct vduse_vq_group_asid vq_group_asid; + + /* Only if VDUSE_F_QUEUE_READY is negotiated */ + struct vduse_vq_ready vq_ready; + __u32 padding[32]; }; }; diff --git a/linux-headers/linux/vfio.h b/linux-headers/linux/vfio.h index f3282b8e86..c85dcbfe30 100644 --- a/linux-headers/linux/vfio.h +++ b/linux-headers/linux/vfio.h @@ -1534,6 +1534,27 @@ struct vfio_device_feature_dma_buf { */ #define VFIO_DEVICE_FEATURE_MIG_PRECOPY_INFOv2 12 =20 +/** + * VFIO_DEVICE_FEATURE_ZPCI_ERROR feature provides PCI error information to + * userspace for vfio-pci devices on s390. On s390, PCI error recovery + * involves platform firmware and notification to operating systems is done + * by architecture specific mechanism. Exposing this information to + * userspace allows it to take appropriate actions to handle an + * error on the device. + * + * Userspace provides an opaque buffer of fixed length, and the kernel + * fills it with the zpci_ccdf_err data structure. The length of + * zpci_ccdf_err is provided to userspace via the + * VFIO_DEVICE_INFO_CAP_ZPCI_BASE capability. + * + * The ioctl returns -ENOMSG if there are no pending PCI errors. + */ +struct vfio_device_feature_zpci_err { + __aligned_u64 data; +}; + +#define VFIO_DEVICE_FEATURE_ZPCI_ERROR 13 + /* -------- API for Type1 VFIO IOMMU -------- */ =20 /** diff --git a/linux-headers/linux/vfio_zdev.h b/linux-headers/linux/vfio_zde= v.h index 77f2aff1f2..d6c1175c88 100644 --- a/linux-headers/linux/vfio_zdev.h +++ b/linux-headers/linux/vfio_zdev.h @@ -32,6 +32,8 @@ struct vfio_device_info_cap_zpci_base { /* End of version 1 */ __u32 fh; /* PCI function handle */ /* End of version 2 */ + __u32 ccdf_err_length; /* PCI CCDF length */ + /* End of version 3 */ }; =20 /** --=20 MST From nobody Sat Sep 26 20:50:17 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=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1789080974; cv=none; d=zohomail.com; s=zohoarc; b=Y9X1w8UthmDYbUMyD4Sh9dXw1eorZ1g88SQn1w1yUGqumMBrlN3S5E13zp/LfVGaIOvXUmBkknWSbxYlUdfnjOlUmgiLNOCKwbum1GrAPnt3gBrwppjt9GXkuY3lIczEQ4mFSw6FY2vVwCwmTcK1qFIZ7pFV+2sxajRNw6MDDbk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1789080974; h=Content-Type: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=zlpYQy/1MbjiL1NkAZwSro3mr5gaZVYlMNIrEIu3Rs4=; b=CxQTLeBT1+iFv51D/FHX0uhw/ERFYgirwBCDGuNr6opOZgoBXv54itpLz7dUIwC4CQPx+5cgdTZjEfDudxcbZy1F/gynNDW+i3IRTqUXIHuKopEHRL7H4VD9morTphBotgRH0p4E9rnKsTg+l6+n4ZMmomF+Dge++dmR7ROmy4U= 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 lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1789080973995347.8474956607291; Thu, 10 Sep 2026 15:56:13 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1x4nVu-0002Dq-OC; Thu, 10 Sep 2026 18:45:09 -0400 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 1x4lUq-0006E4-Es for qemu-devel@nongnu.org; Thu, 10 Sep 2026 16:35:59 -0400 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 1x4lUW-0003hV-Rf for qemu-devel@nongnu.org; Thu, 10 Sep 2026 16:35:37 -0400 Received: from mail-wm1-f69.google.com (mail-wm1-f69.google.com [209.85.128.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-672-nmrH8T2WMSCzUTrO3V0j2A-1; Thu, 10 Sep 2026 16:14:25 -0400 Received: by mail-wm1-f69.google.com with SMTP id 5b1f17b1804b1-49cf5bd2f12so2211575e9.1 for ; Thu, 10 Sep 2026 13:14:24 -0700 (PDT) Received: from redhat.com (IGLD-80-230-79-236.inter.net.il. [80.230.79.236]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-49db038401fsm74674895e9.13.2026.09.10.13.14.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Sep 2026 13:14:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1789072446; 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=zlpYQy/1MbjiL1NkAZwSro3mr5gaZVYlMNIrEIu3Rs4=; b=RFZFWM2IKt4dkFX/B6kIfF0ym7YD/7NWEH/VE2GLpeOleuvq+HPEHmubRNTnDYUXdyg7TD F2T0WGy7nP78GN1PHJqJ9nVi2+ZFQrmBAQjgDzm1v84OYOVsE9aoEoSOWw4uGWyL1F1VOo NGMIAW9ncP41S2354yrq9CTIl4E4CMY= X-MC-Unique: nmrH8T2WMSCzUTrO3V0j2A-1 X-Mimecast-MFC-AGG-ID: nmrH8T2WMSCzUTrO3V0j2A_1789071264 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=google; t=1789071264; x=1789676064; darn=nongnu.org; h=in-reply-to:content-transfer-encoding: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=zlpYQy/1MbjiL1NkAZwSro3mr5gaZVYlMNIrEIu3Rs4=; b=boPC0RElixK4fuLmychIWaPdtfIe6YnHnlrUGZLBIgYZy5Z0yckoN9PazxI7hq/Gsp f0KSPxVdDoQT4ten7WLkq4EaqP1LLqmOquuKzilvXfOq+I9tg/HeAbduA5vW7FAa5/ot EgLeRtSsUj+2v4PLM1pjJNc5BoWIVcX3NcCK6Tx+AokKkmLOukccQEFa9CmVpknMum2g o6wG3URbVqEfbEQjhH+z+It3y8V7Jy6fnk0mpwq4yQwL7VrdczXFmFnzGglFmRUwF1E0 XANw9ugzbjKVEjNQ1abY4jeEr5A5NeyKlEVKhrw91008ecpY/vxyXQaBCFpC88/pgDVG /CAA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1789071264; x=1789676064; h=in-reply-to:content-transfer-encoding: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=zlpYQy/1MbjiL1NkAZwSro3mr5gaZVYlMNIrEIu3Rs4=; b=poZNGHuiI2CG1DhFi35ISeMmwhhZSSoyxCHK0E186ZEcsPcaHlALhwl/jsAUPU1FVh XxNbFfqtAyfA4jNwkPubOYa4g/6/U022Nfaf1BcgLFoL4XymEZJBO+Z04NvOma57PMK8 seHlAxnTZODzxSDnCq9G8t9spgTJvpBK4/flP+YXxl0CDKlMQKV0Q1Ju+DUC7Sed56vz v94yW0WsNneJNpI8lD1RCANjOlsBf5F4Amp8IDNbOPYy+1uauZKTC5pQ5EROcOjs5s8w xSm9yNeugDmHll8baZm8ovrV3TIEoe6FD0enr0uM9fWHkB2oLJFva5N3hWDIQym7yvhh IMtw== X-Gm-Message-State: AFuF++mrPpkU/vo2fZBklioG5gkopButhysD51OEzRjjZZUB4QAuxMnx uSZ9sIcE4udgOgGM1Sf6BdFYHVo3hv2SErwKXl+wMV7QEyZkiax8mBqEjI1/z4LOzP7beEHTHjE iGJ6C6LPGdlsI9Uq0ell/+gm6sPGkmQ920au8Zzhs/iqXqNziRIL1RTl3CE9aPppq+B+vPaPvVw FNogj0q1TFlbUCP1r77XMfhXfmh4DB+BwyOQ== X-Gm-Gg: AYBFou06ZjQluZZfEHHIlH9DF73U/2P1blRTJ5FD67bUCIQeA6eTO0GCAwpwHIJTfNi CI+yeWKflLqeLHUIqvg60n9Q3e/V1MFoMX1bW11n0Wn2+/9dvh7q5ECwbrZ7tauzO09U8jF6pcH Jmnp78450M+eVCWJ3TtY2/eUzHCoHkzdWLVtGPpwntB073A0M6ffHxh5se/8nEBHzuaTwxasFTj E2z0NZCvrrN1ZHJgO1blmQcWqiiyYpmbtzzeU1ghzp0P9p8ZVzHg5FnlIebE57vdvY59/nhq1En a/Ccgq5hRtPh0O89uD8aG9oLbKiGP0OpyauL1aWBdhi8zTTge7H5hUSSP57soMauGRY+BN88nHI n0T2uHRxPwI8QKDLdkQFwl10= X-Received: by 2002:a05:600c:c4a8:b0:49c:fa21:1c7d with SMTP id 5b1f17b1804b1-49e619d6713mr7109785e9.18.1789071263576; Thu, 10 Sep 2026 13:14:23 -0700 (PDT) X-Received: by 2002:a05:600c:c4a8:b0:49c:fa21:1c7d with SMTP id 5b1f17b1804b1-49e619d6713mr7109375e9.18.1789071263053; Thu, 10 Sep 2026 13:14:23 -0700 (PDT) Date: Thu, 10 Sep 2026 16:14:21 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Stefan Hajnoczi , Paolo Bonzini , Philippe =?utf-8?Q?Mathieu-Daud=C3=A9?= , Fam Zheng Subject: [PULL 69/90] virtio-scsi: set dataplane_started to false upon failure Message-ID: <752fec0995accf1570d54183c680143bc8a3a415.1789071043.git.mst@redhat.com> References: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Disposition: inline Content-Transfer-Encoding: quoted-printable In-Reply-To: X-Mailer: git-send-email 2.51.2.2891.g4157995a80.dirty X-Mutt-Fcc: =sent 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=170.10.133.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com 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, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_PASS=-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-Zoho-Virus-Status: 1 X-Zoho-AV-Stamp: zmail-av-0.2.13.1.5.4/289.74.40 X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1789080976228158500 From: Stefan Hajnoczi Commit e24a47c5b73e ("virtio-scsi: do not use vring in dataplane") set dataplane_started to true when virtio_scsi_dataplane_start() fails. This is likely a typo since dataplane is not functional after failure. The non-ioeventfd fallback is broken because dataplane_started is true after virtio_scsi_dataplane_start() failure. As a result, the following assertion failure occurs when a virtio-scsi device exceeds the open file descriptor ulimit when setting up notifiers (eventfds): $ ulimit -n 104 # exact number can vary based on QEMU version $ qemu-system-x86_64 -M q35,accel=3Dkvm -m 1G -cpu host -smp 14 \ --blockdev file,node-name=3Ddrive0,filename=3Dtest.img,cache.direc= t=3Don,aio=3Dnative \ --blockdev file,node-name=3Ddrive1,filename=3Ddata01.img,cache.dir= ect=3Don,aio=3Dnative \ --device virtio-scsi-pci,id=3Dvirtio-scsi-pci0 \ --device scsi-hd,drive=3Ddrive0,bus=3Dvirtio-scsi-pci0.0 \ --device virtio-scsi-pci,id=3Dvirtio-scsi-pci1 \ --device scsi-hd,drive=3Ddrive1,bus=3Dvirtio-scsi-pci1.0 qemu: virtio-scsi: Failed to set guest notifiers (-24), ensure -accel kvm= is set. qemu: virtio_bus_start_ioeventfd: failed. Fallback to userspace (slower). qemu-system-x86_64: ../hw/scsi/virtio-scsi.c:1017: virtio_scsi_reset: Ass= ertion `!s->dataplane_started' failed. Aborted (core dumped) Cc: Paolo Bonzini Fixes: e24a47c5b73e ("virtio-scsi: do not use vring in dataplane") Buglink: https://redhat.atlassian.net/browse/RHEL-193328 Signed-off-by: Stefan Hajnoczi Reviewed-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin Message-ID: <20260825154854.263819-1-stefanha@redhat.com> --- hw/scsi/virtio-scsi-dataplane.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hw/scsi/virtio-scsi-dataplane.c b/hw/scsi/virtio-scsi-dataplan= e.c index 95f13fb7c2..bcb6e44133 100644 --- a/hw/scsi/virtio-scsi-dataplane.c +++ b/hw/scsi/virtio-scsi-dataplane.c @@ -230,7 +230,7 @@ fail_host_notifiers: fail_guest_notifiers: s->dataplane_fenced =3D true; s->dataplane_starting =3D false; - s->dataplane_started =3D true; + s->dataplane_started =3D false; return -ENOSYS; } =20 --=20 MST From nobody Sat Sep 26 20:50:17 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=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1789080351; cv=none; d=zohomail.com; s=zohoarc; b=fZRtU+Y27hEhufCU/kHsy9EcQFp7QEwslpJUcg34woV2xoizMjPfrBQzFn/DMwz1oBMp1nTOUEb/NA9b1C+cvxN3CBlJ/Pebr3+v5FEZnVpxvIo2qVpbNviFUl6cmcOj8MBz+0oYWlPrTnxKicx4CbB7UejCjLCgfqudbtDaw50= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1789080351; h=Content-Type: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=swaVK7hHvfhctLSwvjj1/ywE8ntA6Euz0DduNvrigAM=; b=ER4IvWZmVJWX3XWTgDdUsnoNSxXjptmwfEYS+aK/KPVPId9rZ3pU6ASY6JglZaSeogEdw56eWH/3ruXE45mi3I5sx0KrkfWZKvBjagAlZHj7S5kyB7m0JjY4oUF4BW8rKenE1ZokBrLaTimVMlDi9OgIkgnI6Ju6lPRzlhIVRD0= 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 lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 178908035166421.022882413606226; Thu, 10 Sep 2026 15:45:51 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1x4nPS-0000X9-Fb; Thu, 10 Sep 2026 18:38:41 -0400 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 1x4lQ1-0004T4-Ps for qemu-devel@nongnu.org; Thu, 10 Sep 2026 16:31:01 -0400 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 1x4lPl-0001tX-0n for qemu-devel@nongnu.org; Thu, 10 Sep 2026 16:30:38 -0400 Received: from mail-wm1-f71.google.com (mail-wm1-f71.google.com [209.85.128.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-16-S1E6HD3INu6fmcFrn08U1w-1; Thu, 10 Sep 2026 16:14:27 -0400 Received: by mail-wm1-f71.google.com with SMTP id 5b1f17b1804b1-49564d4b849so501405e9.3 for ; Thu, 10 Sep 2026 13:14:26 -0700 (PDT) Received: from redhat.com (IGLD-80-230-79-236.inter.net.il. [80.230.79.236]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-49d26d4e3f3sm104182515e9.15.2026.09.10.13.14.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Sep 2026 13:14:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1789072143; 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=swaVK7hHvfhctLSwvjj1/ywE8ntA6Euz0DduNvrigAM=; b=Jq3ntEieeSye+JA8iH5wIMAxqaFULz+lfImFLyEx99ajK+uIqtWaI56DDpY5ZZEAvFrj0N wpslRFSUnfopSAo1OxKqpHv4JAAXEKiGlbbIw+JKk4zEqej14TUMbzfHLndU3HZ34rPKkH UIArdAdfKuc8ctfrytn230rS8sprVm8= X-MC-Unique: S1E6HD3INu6fmcFrn08U1w-1 X-Mimecast-MFC-AGG-ID: S1E6HD3INu6fmcFrn08U1w_1789071266 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=google; t=1789071266; x=1789676066; 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=swaVK7hHvfhctLSwvjj1/ywE8ntA6Euz0DduNvrigAM=; b=fZR1zv1WH48dFQNtsRCEuIXcIGCE2FvwJvpPGiez6JYkltpvjIEl6+W/xvQS4jRkAT Pqr6Lye62LwsyViopaZ5PZoeuAmSWCm3F/vgYcjtOjWHrkEyxm1zkzNYNX1hLjCWAdIB ObIj5HMmraCSjdt8W+uyr3GlvXFzRK24kuY103QLpyRxEoWFKTp/NfcWkM1GNA3cp3aF 7OnzLgfYCfeWrbmOTZ/CG/KbEaUkawl1cDgunOlgS7B8ohkh5N5u1Wna61GHnBBid5s7 FnHBnB1DCmCVBlx9PssC2omrtPvBO7lRSPdicPvtWenIcJ2V5PWiea2lC9tv5imT2fsE tCWg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1789071266; x=1789676066; 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=swaVK7hHvfhctLSwvjj1/ywE8ntA6Euz0DduNvrigAM=; b=MI0tsK+ZlnUmahaoHuYvM9ZL01NArIBwJ+1zbW5X4ePFA9PuFkODIMuThO/sTfPymr 1A5rMGSakedJ7o9LvI44jN4o6NEm7QjxgsDhQatEaHCU9HlZsRXS1xIQXi5tMEK94Loy 5mpOx1I3qa8cj/p09qttu85M07+Jq2IpVvoer4bZ5Lj0YCYVH0nDBekjUAzE8xrRzKbA GY9MiKJ+rJYFKjR24iBwxg6yq0dmn4G4SsRnwB7mdDEvu0N0ZKlEfo+7snioW9EGqd1A gum4TH0Irg1U+ucpDlpNTHy1DkuzZHmrjuo6fsCH+DRdxwZ/46OlWrSM08PmrQfpWIuE IzeQ== X-Gm-Message-State: AFuF++m3vu2sAgVBjd64JNs+HkkIkHqEZAShhRC1EeEEPGYDmZljOwi/ ICjof9AY50wExDIm/6Vy8jTsIbJ/1Fihir8xFAHnTE8pWLgES7MD110HgZUwIURv6Wuz5/CoMBU 76IQ7Dql+GEcPqwUC61DQ7rLPKnd0uI4ZJnpSxYnE5yt0lb7yJM83CUQcpR/Un17PB5qkw/N9K/ 1QsJN+6pwqaKi4+0qhsXHZn2B4C80IAu2/uQ== X-Gm-Gg: AYBFou35N+C7YOrWWcIjTqxF86i7BARxHFoJiCCGcTCj8OTq2/plkLst/m4wJ2JwPAh fAaZAA9iuvM90yecNzCtjMl+HNiEflj1bH/RFooBSsMr4SQPK9qa/MaBnXR35BjwiQWvCFB0/Sb 9ml1tlVd43G+gI8V7cJDnMMtFkDAy13x3Pu2eaeBv3ZKi7ymV0Z40tUbt0+WBsACFTDpHxYs6fB Dbxk/fUKRansE9QYhgwbfIewl2jFth9Dfx5D6+s92S3Wr/VqBGkN3Ik6B+WqVW5K+MqI0ImiGgR YcaLmWNT+6jnApdYrP9bb2QRn4/zIKcR6BHecYagc+xxVb7it8QvzghPZeo0JBLJjZH9yX2K3y8 iSIf4Unm3U4tr4p7LqK/xcEc= X-Received: by 2002:a05:600c:8a1a:10b0:49c:ee22:364c with SMTP id 5b1f17b1804b1-49e6198d0a6mr6071305e9.9.1789071265730; Thu, 10 Sep 2026 13:14:25 -0700 (PDT) X-Received: by 2002:a05:600c:8a1a:10b0:49c:ee22:364c with SMTP id 5b1f17b1804b1-49e6198d0a6mr6070975e9.9.1789071265196; Thu, 10 Sep 2026 13:14:25 -0700 (PDT) Date: Thu, 10 Sep 2026 16:14:23 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Junjie Cao , Jonathan Cameron , linux-cxl@vger.kernel.org Subject: [PULL 70/90] hw/cxl: fix the CDAT DOE overlapping the Flex Bus DVSEC when sn= is set Message-ID: References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-Mailer: git-send-email 2.51.2.2891.g4157995a80.dirty X-Mutt-Fcc: =sent 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=170.10.133.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com 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, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_PASS=-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-Zoho-Virus-Status: 1 X-Zoho-AV-Stamp: zmail-av-0.2.13.1.5.4/289.74.40 X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1789080353482158500 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Junjie Cao ct3_realize() adds the CDAT DOE at a fixed 0x190. Since 8700ee15de the four DVSECs take 0x90 bytes, which from 0x100 ends exactly at 0x190. With sn=3D the Device Serial Number capability pushes the block to 0x10c..0x19c, and the DOE, added later, overwrites the last 12 bytes of the Flex Bus Port DVSEC: Capability2, Control2 and Status2. Nothing catches this -- pcie_add_capability() checks bounds, not overlap, and the chain still walks because the DVSEC's next pointer becomes 0x190, inside its own body. Most cxl-type3 examples in docs/system/devices/cxl.rst set sn=3D. Derive the offset from the DVSEC block instead, as cxl_upstream.c already does. Without sn=3D the layout is unchanged byte for byte; with sn=3D the DOE moves to 0x19c, below the AER capability at 0x200. The type 3 device has no VMStateDescription, so its config space never reaches the migration stream. Fixes: 8700ee15de ("hw/cxl: Standardize all references on CXL r3.1 and mino= r updates") Signed-off-by: Junjie Cao Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin Message-ID: <20260831022302.406740-1-junjie.cao@intel.com> --- hw/mem/cxl_type3.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/hw/mem/cxl_type3.c b/hw/mem/cxl_type3.c index 6f44770db6..a04dc74ecc 100644 --- a/hw/mem/cxl_type3.c +++ b/hw/mem/cxl_type3.c @@ -936,8 +936,8 @@ static void ct3_realize(PCIDevice *pci_dev, Error **err= p) } =20 /* DOE Initialization */ - pcie_doe_init(pci_dev, &ct3d->doe_cdat, 0x190, doe_cdat_prot, true, - CXL_T3_MSIX_PCIE_DOE_TABLE_ACCESS); + pcie_doe_init(pci_dev, &ct3d->doe_cdat, cxl_cstate->dvsec_offset, + doe_cdat_prot, true, CXL_T3_MSIX_PCIE_DOE_TABLE_ACCESS); =20 cxl_cstate->cdat.build_cdat_table =3D ct3_build_cdat_table; cxl_cstate->cdat.free_cdat_table =3D ct3_free_cdat_table; --=20 MST From nobody Sat Sep 26 20:50:17 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=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1789074395; cv=none; d=zohomail.com; s=zohoarc; b=nsVB/P2b0heIihLgeYFNSh9b8iUrIFAeJ0iaO2ROXRgGPYLl64PNE19PdonmFpHFrN/xNNmGuAaxiyv+GpkxNGVAS4Lzhtk0RhjlIjeaVlcjuhSJZAxWjBILDo6V+rvuc6hOF5M1Pw2PieiLD0q0bTCl79qCSACjGOvQ95oN6Co= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1789074395; h=Content-Type: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=13Q36j0M5BaF1k6VkvQm4baQtJfJHEebKt7N8YZcxpU=; b=WaAwOB6w6EUF25GBCKdRzkNI0O4xQE2HMgFHMIKJ4Hl3lo8wYYcH8CTslNhABHlj+L1Fz/IQ5UR42ZEhNbvWvhu7iUfZbGW4p3vHHx5smBLQYLl34gmLx0qlbGRHATLA1Gj5xzz41BJkuxOmfXjf9BuqoOpik9jC1v0BbmKlnKo= 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 lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTP id 1789074395186464.7713321591607; Thu, 10 Sep 2026 14:06:35 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1x4luY-0004Dj-EH; Thu, 10 Sep 2026 17:02:43 -0400 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 1x4lGw-0001Ah-D3 for qemu-devel@nongnu.org; Thu, 10 Sep 2026 16:21:33 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1x4lGM-0007ye-VI for qemu-devel@nongnu.org; Thu, 10 Sep 2026 16:21:06 -0400 Received: from mail-wr1-f72.google.com (mail-wr1-f72.google.com [209.85.221.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-194-EL2qpT6CMAOYAi_Fe-kGLQ-1; Thu, 10 Sep 2026 16:14:29 -0400 Received: by mail-wr1-f72.google.com with SMTP id ffacd0b85a97d-485835753caso82959f8f.3 for ; Thu, 10 Sep 2026 13:14:28 -0700 (PDT) Received: from redhat.com (IGLD-80-230-79-236.inter.net.il. [80.230.79.236]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-486eb33fc02sm744233f8f.16.2026.09.10.13.14.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Sep 2026 13:14:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1789071573; 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=13Q36j0M5BaF1k6VkvQm4baQtJfJHEebKt7N8YZcxpU=; b=HDI169TrA7CEcD5yKi/G1zHmT5fo3oyjZ8spKbDIKvF7S+CC1i4sEIhqruusyXMRs9/Dk/ IysC40dMUVi9SAwWbxXt9CkpuSKZGSKvcRwzWe4gSSLP0HhbGeulmt08SYS8nm9x8029nL aZaP6LxCNBc5JocctdRESyw7GDG6bsw= X-MC-Unique: EL2qpT6CMAOYAi_Fe-kGLQ-1 X-Mimecast-MFC-AGG-ID: EL2qpT6CMAOYAi_Fe-kGLQ_1789071268 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=google; t=1789071268; x=1789676068; 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=13Q36j0M5BaF1k6VkvQm4baQtJfJHEebKt7N8YZcxpU=; b=QJXaQibg4eGKJWZVE24NOPuSLQZLTTo2cmaQNEIHdhtWMabavgtYavAFUpVrNecH2i ewTIxSEZQ+gDiKro2OSOtEEsao3gfZaVNniUCWMC/XXZ5ID8kHQWYsf8ZYoQHgUXgT+i Obn+kkJ4RXtFNKgcmUBGDBhuY65lXHkVhMgbXWFwCUEB0iYVegTpg9NLU82fBlPCYM0z D4CNEFqnyqAXp483LQqWI+SdnPTD0ymKY1rzGvzyBtarevE0qEtX55CYOn5p/ewWceDq DKu4NqVXCOJ2iLhzoXDfyDDGvzH/aueau3pkxMblsP1cEtqk2LLMRRc/FiCacEvxIVCP ojtg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1789071268; x=1789676068; 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=13Q36j0M5BaF1k6VkvQm4baQtJfJHEebKt7N8YZcxpU=; b=AqmaH+hWkHukHZKktmYPR7Jk8YTf7zq3GogOzI861EdrwqG/IOMByJZzDLRESmckwu QnuoIgvaTQql15l0A+KebQWaWqEFKOjTHvGm4ARV8PF9ZGjl/nvurhn0DPxZTOLKZxa4 AMkoQ4OiCPR5b8IlKwBKSxqMD93FnawAArlxWtI7nawn9TkOzoxCM0H0n0wON69yfdWK HOZdiQe/qAQ5Mfrvbos9z8BpoWPhuux/8J4fEsDxocw4oluOIWEbey4xbgPOl7VcKoDa pss55a8LRx3qG5QqKuysHHZczNRQ0Dm8pb6dzubquKsZ+bivvNXVpy46HfkTtNZUXA2R HiiA== X-Gm-Message-State: AFuF++lgRFsw7v7bg02PJkE62qFpqadU3en2hlaHuNYILFIBPr6h3qeb VORPh3ktofyhtdg6C4veBvYsIax5jwyQ1xL8POVvfUMKX5jfIdBoS3R7FNBP1D7UWlZkqYvOgcP JML4J0ke1lDirETKTL3efT8lmyruXw2Om13miLhWumUUn+zl35Jw6HEtYtSmNoTTGegxnCU74vx 790U3DYtjAyeHSMuPGyyoS0daK5XpjolzWrg== X-Gm-Gg: AYBFou2jccmiCDhV+cr8eNNS2BCnfguPe96n6wXsMmvWWGzR+/pSh8ddDGE/UEpCeCs lcJL14qh3lrVdEL93PNewe8LnumyAtYR7LbeGDXUsRouWzDT/xtoi3aODe9E6y6XiOBoRX8x1TC N+hXjVRXfio7ZMweztlpmSJZaXlNCNUPnuAA4xy5riGr3gOp1OMKxn+btYKndYvN//LzEP98VGH YbWntEdfosjyawGunBTcCD1zMaXAeM63DeUXObdo5H3Pg+XgEi6wOKxDTSsJBGHVKU4M04ksdpa /BzL1UG25deE8uM5kEs0LxqW21r/Cf5MwN7REBm5VtwIuXhJKlbNrcFkrDUsQdkbGMxA5jMs9P4 ADFlDdWfekeItBT3evvcYwH4= X-Received: by 2002:a5d:64cf:0:b0:485:8ef9:325f with SMTP id ffacd0b85a97d-486eb3421d6mr677606f8f.42.1789071267853; Thu, 10 Sep 2026 13:14:27 -0700 (PDT) X-Received: by 2002:a5d:64cf:0:b0:485:8ef9:325f with SMTP id ffacd0b85a97d-486eb3421d6mr677571f8f.42.1789071267322; Thu, 10 Sep 2026 13:14:27 -0700 (PDT) Date: Thu, 10 Sep 2026 16:14:25 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Kuan-Wei Chiu Subject: [PULL 71/90] virtio-rtc: Report smeared UTC clock type Message-ID: References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-Mailer: git-send-email 2.51.2.2891.g4157995a80.dirty X-Mutt-Fcc: =sent 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=170.10.129.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com 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, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=0.001, SPF_HELO_PASS=-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-Zoho-Virus-Status: 1 X-Zoho-AV-Stamp: zmail-av-0.2.13.1.5.4/289.52.80 X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1789074397996158500 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Kuan-Wei Chiu The Linux virtio_rtc driver only registers an RTC class device when the clock type is VIRTIO_RTC_CLOCK_UTC_SMEARED to avoid leap second steps on pure UTC clocks. Report VIRTIO_RTC_CLOCK_UTC_SMEARED in clock capabilities so the guest can expose the device as an RTC device. Signed-off-by: Kuan-Wei Chiu Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin Message-ID: <20260831190612.369235-1-visitorckw@gmail.com> --- hw/virtio/virtio-rtc.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/hw/virtio/virtio-rtc.c b/hw/virtio/virtio-rtc.c index 32de9c1650..0dcbe94758 100644 --- a/hw/virtio/virtio-rtc.c +++ b/hw/virtio/virtio-rtc.c @@ -62,7 +62,8 @@ static void virtio_rtc_handle_request(VirtIODevice *vdev,= VirtQueue *vq) resp.head.status =3D VIRTIO_RTC_S_ENODEV; } else { resp.head.status =3D VIRTIO_RTC_S_OK; - resp.type =3D VIRTIO_RTC_CLOCK_UTC; + resp.type =3D VIRTIO_RTC_CLOCK_UTC_SMEARED; + resp.leap_second_smearing =3D VIRTIO_RTC_SMEAR_UNSPECIFIED; } written =3D iov_from_buf(elem->in_sg, elem->in_num, 0, &resp, sizeof(resp)); --=20 MST From nobody Sat Sep 26 20:50:17 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=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1789076516; cv=none; d=zohomail.com; s=zohoarc; b=DkD02ItQGiTTsZxcxR4YFOVq5kK82GbG2c7V0X3uFzqwRgb3J5rJoK8MydUSIBQP0IPAviaBYml8A0q8USGFpnNbe1KzUSBH380LN4GX0muddef16BrrbC9+nXvA7kWCDVXOkTah8Ofx+Jd1Plu2pkdGtG6pbO/LC/1Emc7dKBg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1789076516; h=Content-Type: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=qEQqbP05s+OSlyzjNTsgrx4dobovQAA0LQxrJHMbWCc=; b=FPMo9Bj5Cs2+AVIpzLrDlXWwbpU69DxT4uxlzgONl5lj/lWfxQhFkVlkenaTgPItiWm3q7ex0++9/ljKjXEhwJ6/5e/+jw7Nq6mUvxuf3JRnxrdRzp4xBgSsvuGb71S4SA7t6X2JEDqiSJ7CTfKrJpz8UY3/4hbMBwHra54EBbc= 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 lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1789076516600353.5960044328998; Thu, 10 Sep 2026 14:41:56 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1x4mVo-0002pU-25; Thu, 10 Sep 2026 17:41:23 -0400 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 1x4lKB-0002RI-M1 for qemu-devel@nongnu.org; Thu, 10 Sep 2026 16:24:52 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1x4lJz-0008Ek-Vu for qemu-devel@nongnu.org; Thu, 10 Sep 2026 16:24:42 -0400 Received: from mail-wm1-f72.google.com (mail-wm1-f72.google.com [209.85.128.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-685-x72-GnfyP5GPTHlJztLtGg-1; Thu, 10 Sep 2026 16:14:31 -0400 Received: by mail-wm1-f72.google.com with SMTP id 5b1f17b1804b1-4994aebe932so2236565e9.3 for ; Thu, 10 Sep 2026 13:14:31 -0700 (PDT) Received: from redhat.com (IGLD-80-230-79-236.inter.net.il. [80.230.79.236]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-486eb35bed0sm740246f8f.32.2026.09.10.13.14.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Sep 2026 13:14:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1789071661; 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=qEQqbP05s+OSlyzjNTsgrx4dobovQAA0LQxrJHMbWCc=; b=dCFFFjlPU7moV9julJ40XkIao+mIpHiTn+ENrAT7W2oCnmlRdUo1DiEVMPLIehkk0HwEy5 BbT2CTjWCOPQHfhYZYat7p4JI7hB5Qkrsd+NK5lRcv5WwTz+wIzcRedy0h+EDyTcCrIvzw 2b5dCQAF0FDVf+aNSDEj1iWGmC5+L1k= X-MC-Unique: x72-GnfyP5GPTHlJztLtGg-1 X-Mimecast-MFC-AGG-ID: x72-GnfyP5GPTHlJztLtGg_1789071270 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=google; t=1789071270; x=1789676070; darn=nongnu.org; h=in-reply-to:content-transfer-encoding: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=qEQqbP05s+OSlyzjNTsgrx4dobovQAA0LQxrJHMbWCc=; b=sC6xDDYkaJULit/SusMrX+goF1Z5rhUk5jYPsLIYl98kKKSY3fs6dcr/nZzaTnhVzr 7SWAAlarNCFaq8Jd6R2/JEl4NirzS5qgEx0R1W6DJQ2Ev6strlL3f386etuKZvtIHRjP SiFjnqhgx3F6gCHK1A9c4R+c8/m2HML19kRc9VNcWUiqLFBMmTq6l2mfnsrTefWOccC5 YWPuZmcEvr5iYTyGWAAOqLZsy6CApK/CCmvLGPwbky24jeGshYXfAYTFAoH3lKaHHcbq Atkb68bwdWLGgHbklLGGU5aHuUk4wmEWsjH2lXX6+F7tBqT7KTIMLJ6mohfAqa4zqqUN X13Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1789071270; x=1789676070; h=in-reply-to:content-transfer-encoding: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=qEQqbP05s+OSlyzjNTsgrx4dobovQAA0LQxrJHMbWCc=; b=sqfxpUmplICP8Z41h1PNdQXWQwoQ6nKLVUo85I9suhu+czOzRDwcxH7NHMh6zR2fqP wn3FW08yJug151VpDpNGlBnIniuwg1+lFprrIJ1AvHK3zrLOjL49d60kojXuu6VlKWan GPgS5XhJQo0Aknrh5DDaB8zQfpKLpxIN3zRxg9vXot9MTZmNUEeY/+QxfvU9TK1z0rcF jADaiTMETLa7VayZyOJ/6M/3DqP10to6sO+aJExpCm+liAHkO5CGBiEJt0Lf/5kYBZS7 9iHxnwmRuEVR0HPBm/N/iTB5/Decw/RVuNSfiCTR5DfinGxA2Z/f4dmzd74YT3mY2rOB 8Law== X-Gm-Message-State: AFuF++lqmgosm6QIXC1SOLOMoSX3NoXqfKS1TSuT4AdVsh1IgjycqbzQ E4sezvIhMfKpE9VOEu/xT/mynCGARly8s8KPMGyhgV1N0uFfNKw6VVlKnetGlDIBPErjPOi4ZXX 0K9rMmFPLKmAcZuEXWi6y2b372fHx7PoOs4j/SaZPCOrylEeQ+sP6bvnBMhNp8rJPZxxKsPCuN0 I6R09dXh05jvPaSTqKB/YAz6Ksrf7NyusOsw== X-Gm-Gg: AYBFou0m0NEv8bPv21YvFrmfbM1Ex8Gx2BtISav3twxaNUnbL1JkSfsoJ83AKgSnQ6K gIeyI2g2x/LgaDc13CTfzgRtxjUijcN2i18YIZoedJO8hanLktpqMuWKhw6pr1Vq4O0ExWmngfF tAMtA+++LmHtV/qa+dSEoYWwYJYad+XfGN67Uo9oUQ1x8YqRtxzBrPgQbilqUeg2nH7EalciBRg DDFiUPkz8/9r+2ICZ/h9qhJyxfZxNJWQfdwc/BvrSkr8J7O3cW4QZ5vWoOqjRC/MlbBjq8Mz9Yw 2g1UHSlX9zAfqeDOtZLTdt0oYMzY/6gayfsKtAonAF3JJaeswNtIFPSBxL4ti/hqoalKxSQozur XwZ5tuBZIBLPHl5TFWdcIxKg= X-Received: by 2002:a05:600c:b99:b0:499:a277:e8b5 with SMTP id 5b1f17b1804b1-49e619a1c6amr16333035e9.3.1789071270187; Thu, 10 Sep 2026 13:14:30 -0700 (PDT) X-Received: by 2002:a05:600c:b99:b0:499:a277:e8b5 with SMTP id 5b1f17b1804b1-49e619a1c6amr16332145e9.3.1789071269627; Thu, 10 Sep 2026 13:14:29 -0700 (PDT) Date: Thu, 10 Sep 2026 16:14:27 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , =?utf-8?Q?Cl=C3=A9ment?= MATHIEU--DRIF , Jason Wang , Yi Liu , Paolo Bonzini , Richard Henderson Subject: [PULL 72/90] intel_iommu: Support concurrent page fault handling with PRI Message-ID: <0597be6f01e3c23263233f57e36cb02be55d0556.1789071043.git.mst@redhat.com> References: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Disposition: inline Content-Transfer-Encoding: quoted-printable In-Reply-To: X-Mailer: git-send-email 2.51.2.2891.g4157995a80.dirty X-Mutt-Fcc: =sent 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=170.10.129.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com 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, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=0.001, SPF_HELO_PASS=-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-Zoho-Virus-Status: 1 X-Zoho-AV-Stamp: zmail-av-0.2.13.1.5.4/289.52.80 X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1789076518649158500 From: Cl=C3=A9ment MATHIEU--DRIF PRQ slot allocation must be thread safe to avoid posting multiple commands in the same slot so we take a lock in vtd_pri_request_page. This allows multiple devices to call the page request interface of the same iommu instance. Signed-off-by: Clement Mathieu--Drif Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin Message-ID: <20260903145044.2245609-1-clement.mathieu--drif@bull.com> --- hw/i386/intel_iommu.c | 103 ++++++++++++++++++++++++++---------------- 1 file changed, 63 insertions(+), 40 deletions(-) diff --git a/hw/i386/intel_iommu.c b/hw/i386/intel_iommu.c index 82c3c3b2c3..7c442a86ca 100644 --- a/hw/i386/intel_iommu.c +++ b/hw/i386/intel_iommu.c @@ -3627,15 +3627,26 @@ static void vtd_handle_iectl_write(IntelIOMMUState = *s) =20 static void vtd_handle_prs_write(IntelIOMMUState *s) { - uint32_t prs =3D vtd_get_long_raw(s, DMAR_PRS_REG); + uint32_t prs; + + vtd_iommu_lock(s); + + prs =3D vtd_get_long_raw(s, DMAR_PRS_REG); if (!(prs & VTD_PR_STATUS_PPR) && !(prs & VTD_PR_STATUS_PRO)) { vtd_set_clear_mask_long(s, DMAR_PECTL_REG, VTD_PR_PECTL_IP, 0); } + + vtd_iommu_unlock(s); } =20 static void vtd_handle_pectl_write(IntelIOMMUState *s) { - uint32_t pectl =3D vtd_get_long_raw(s, DMAR_PECTL_REG); + uint32_t pectl; + + vtd_iommu_lock(s); + + pectl =3D vtd_get_long_raw(s, DMAR_PECTL_REG); + if ((pectl & VTD_PR_PECTL_IP) && !(pectl & VTD_PR_PECTL_IM)) { /* * If IP field was 1 when software clears the IM field, @@ -3644,6 +3655,8 @@ static void vtd_handle_pectl_write(IntelIOMMUState *s) vtd_set_clear_mask_long(s, DMAR_PECTL_REG, VTD_PR_PECTL_IP, 0); vtd_generate_interrupt(s, DMAR_PEADDR_REG, DMAR_PEDATA_REG); } + + vtd_iommu_unlock(s); } =20 static uint64_t vtd_mem_read(void *opaque, hwaddr addr, unsigned size) @@ -5377,19 +5390,18 @@ static int vtd_pri_request_page(PCIBus *bus, void *= opaque, int devfn, { IntelIOMMUState *s =3D opaque; VTDAddressSpace *vtd_as; + uint64_t queue_addr_reg; + uint64_t queue_tail_offset_reg; + uint64_t new_queue_tail_offset; + uint64_t queue_head_offset_reg; + hwaddr queue_tail; + uint32_t old_pr_status; + uint16_t sid; + VTDPRDesc desc; + int ret =3D 0; =20 vtd_as =3D vtd_find_add_as(s, bus, devfn, pasid); - - uint64_t queue_addr_reg =3D vtd_get_quad(s, DMAR_PQA_REG); - uint64_t queue_tail_offset_reg =3D vtd_get_quad(s, DMAR_PQT_REG); - uint64_t new_queue_tail_offset =3D ( - (queue_tail_offset_reg + VTD_PQA_ENTRY_SIZ= E) % - (vtd_prq_size(s) * VTD_PQA_ENTRY_SIZE)); - uint64_t queue_head_offset_reg =3D vtd_get_quad(s, DMAR_PQH_REG); - hwaddr queue_tail =3D (queue_addr_reg & VTD_PQA_ADDR) + queue_tail_off= set_reg; - uint32_t old_pr_status =3D vtd_get_long(s, DMAR_PRS_REG); - uint16_t sid =3D PCI_BUILD_BDF(pci_bus_num(vtd_as->bus), vtd_as->devfn= ); - VTDPRDesc desc; + sid =3D PCI_BUILD_BDF(pci_bus_num(vtd_as->bus), vtd_as->devfn); =20 if (!(s->ecap & VTD_ECAP_PRS)) { return -EPERM; @@ -5413,25 +5425,7 @@ static int vtd_pri_request_page(PCIBus *bus, void *o= paque, int devfn, return -EPERM; } =20 - if (old_pr_status & VTD_PR_STATUS_PRO) { - /* - * No action is taken by hardware to report a fault - * or generate an event - */ - return -ENOSPC; - } - - /* Check for overflow */ - if (new_queue_tail_offset =3D=3D queue_head_offset_reg) { - vtd_set_clear_mask_long(s, DMAR_PRS_REG, 0, VTD_PR_STATUS_PRO); - vtd_generate_page_request_event(s, old_pr_status); - return -ENOSPC; - } - - if (vtd_pri_perform_implicit_invalidation(vtd_as, addr)) { - return -EINVAL; - } - + /* Prepare the descriptor */ desc.lo =3D VTD_PRD_TYPE | VTD_PRD_PP(true) | VTD_PRD_RID(sid) | VTD_PRD_PASID(vtd_as->pasid) | VTD_PRD_PMR(priv_req); desc.hi =3D VTD_PRD_RDR(is_read) | VTD_PRD_WRR(is_write) | @@ -5439,26 +5433,55 @@ static int vtd_pri_request_page(PCIBus *bus, void *= opaque, int devfn, =20 desc.lo =3D cpu_to_le64(desc.lo); desc.hi =3D cpu_to_le64(desc.hi); + + if (vtd_pri_perform_implicit_invalidation(vtd_as, addr)) { + return -EINVAL; + } + + vtd_iommu_lock(s); + + queue_addr_reg =3D vtd_get_quad(s, DMAR_PQA_REG); + queue_tail_offset_reg =3D vtd_get_quad(s, DMAR_PQT_REG); + new_queue_tail_offset =3D ((queue_tail_offset_reg + VTD_PQA_ENTRY_SIZE= ) % + (vtd_prq_size(s) * VTD_PQA_ENTRY_SIZE)); + queue_head_offset_reg =3D vtd_get_quad(s, DMAR_PQH_REG); + queue_tail =3D (queue_addr_reg & VTD_PQA_ADDR) + queue_tail_offset_reg; + old_pr_status =3D vtd_get_long(s, DMAR_PRS_REG); + + if (old_pr_status & VTD_PR_STATUS_PRO) { + /* + * No action is taken by hardware to report a fault + * or generate an event + */ + ret =3D -ENOSPC; + goto out; + } + + /* Check for overflow */ + if (new_queue_tail_offset =3D=3D queue_head_offset_reg) { + vtd_set_clear_mask_long(s, DMAR_PRS_REG, 0, VTD_PR_STATUS_PRO); + vtd_generate_page_request_event(s, old_pr_status); + ret =3D -ENOSPC; + goto out; + } + if (dma_memory_write(&address_space_memory, queue_tail, &desc, sizeof(= desc), MEMTXATTRS_UNSPECIFIED)) { error_report_once("IO error, the PQ tail cannot be updated"); - return -EIO; + ret =3D -EIO; + goto out; } =20 /* increment the tail register and set the pending request bit */ vtd_set_quad(s, DMAR_PQT_REG, new_queue_tail_offset); - /* - * read status again so that the kernel does not miss a request. - * in some cases, we can trigger an unecessary interrupt but this stra= tegy - * drastically improves performance as we don't need to take a lock. - */ - old_pr_status =3D vtd_get_long(s, DMAR_PRS_REG); if (!(old_pr_status & VTD_PR_STATUS_PPR)) { vtd_set_clear_mask_long(s, DMAR_PRS_REG, 0, VTD_PR_STATUS_PPR); vtd_generate_page_request_event(s, old_pr_status); } =20 - return 0; +out: + vtd_iommu_unlock(s); + return ret; } =20 static void vtd_init_iotlb_notifier(PCIBus *bus, void *opaque, int devfn, --=20 MST From nobody Sat Sep 26 20:50:17 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=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1789082877; cv=none; d=zohomail.com; s=zohoarc; b=WBazdtweCHsWB84G+cm2sCCqykhXT/q/TM/pjCbQ6OAQFb3ezzSSNbFld95B4vulk0GmLT6TazA4EE+d9WkDKV3a9V4ktAJhlEHlSBJ2J+wM++Ic3gEtbf/APSVn0utty0cJ0BS3OhgVa9NR7Cvz8XLX3KKMp8LrHXttJm21m9g= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1789082877; h=Content-Type: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=mDN0pKO3NI28SBsIJ08S3mFqoBiJB+cbySC7sAon6z4=; b=HdF4l15Ptl8JEG8dRSr9XGhscdeBfoylpaBAcxLx731WQJF18xDwC8UocNnlbpu/0EUUU9Jg7sj+yVJe8A+NfVd/YzLdN4rJ+R7pgERVbQi1jhzdM5+G2qtVyjHGKp+HInCq0w0gzCDTVs9bJPO1aXDg8jaiqtytcxAN2CacBec= 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 lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1789082877832861.5485720676668; Thu, 10 Sep 2026 16:27:57 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1x4nzV-000234-R1; Thu, 10 Sep 2026 19:15:46 -0400 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 1x4lV7-0006Hi-AK for qemu-devel@nongnu.org; Thu, 10 Sep 2026 16:36:17 -0400 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 1x4lUn-0003gS-0B for qemu-devel@nongnu.org; Thu, 10 Sep 2026 16:35:49 -0400 Received: from mail-wm1-f72.google.com (mail-wm1-f72.google.com [209.85.128.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-2-nscHisKWM8KDrpcLSie0gg-1; Thu, 10 Sep 2026 16:14:33 -0400 Received: by mail-wm1-f72.google.com with SMTP id 5b1f17b1804b1-4994aebe932so2236745e9.3 for ; Thu, 10 Sep 2026 13:14:33 -0700 (PDT) Received: from redhat.com (IGLD-80-230-79-236.inter.net.il. [80.230.79.236]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-49e60ae55f8sm19687265e9.15.2026.09.10.13.14.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Sep 2026 13:14:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1789072441; 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=mDN0pKO3NI28SBsIJ08S3mFqoBiJB+cbySC7sAon6z4=; b=SZqlDmeRjdkiu5BgyDjGtC7v04ByjucgLYr8htr9KI83sOO07Ved4cNlFaRhJsxM2JEqXk ASFrTnTdUXTKQ5lz9pW+5HcNxc4hCRaz6n2bEgr/zzs5UWZE3B5df3qU+XuuPnl2yWRQLT MMHYp0evREtN1zRLNohx84visErhCM8= X-MC-Unique: nscHisKWM8KDrpcLSie0gg-1 X-Mimecast-MFC-AGG-ID: nscHisKWM8KDrpcLSie0gg_1789071273 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=google; t=1789071272; x=1789676072; darn=nongnu.org; h=in-reply-to:content-transfer-encoding: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=mDN0pKO3NI28SBsIJ08S3mFqoBiJB+cbySC7sAon6z4=; b=k9gnDePZNrGsoZDgjbFG41OgxvlyBKVwjuXbCQm/bTgN9kz4hi4uAFAogw3xXPMOEX j17oczpc/uNxM8QlbTuAQUI42gTVnzcYRgdgY+g1mThKTeV0ac+aUQN3VhNCcto7rATC +1bzHzNTS2+XVSRrFY7DAUWALAjHT6NbVuslz3C9nTt8q7EtSrenAqrVXII69pSJfgr4 xbR0L8gvCpuwr532nRyErzjoZz7a925GzcbGzIllUke3kcdBcNoxO4upoKqtAMQUknRP rt0CVxS1L/C3GUeoyjD2Eol/q9BTUPCY5cDgFqjcJcgMyqkwjlNQgalAAfG19S/SqJCl g88g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1789071272; x=1789676072; h=in-reply-to:content-transfer-encoding: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=mDN0pKO3NI28SBsIJ08S3mFqoBiJB+cbySC7sAon6z4=; b=oLGGRlIo71PkB1pGfB3KSM4dSpxUV7TO65n9+nlutHn+v3yaZv7I7ROvXF6nYb7pBT Jh3p8jb8TcXBci1iQbIY+RgLSISvZtlPIews0Lpyk5GtSD7L3LeKz7rBke10GSRupFKs 3WyLWpY/QS5hSf1zzxpZPpDnX6mdaOJhPbSqXzlO7nHW5XsXMf/8AkSlCa/kNbcC/vV8 O/FdyvGjyxzL84zxCTkpUvTlin0aBdL8wHWeX2hr17Ay8+C8uSl6UjKhpklXQrcvVYQ9 ntYK3ZImBfArOW0A8YweuK5imnniVkbadu4SWHAHcGsEoO7Bbl1KASvE6p3srGvqhMd7 WLIQ== X-Gm-Message-State: AFuF++lKu7YuW74aOAWESTwECdi6n5xK+EEq3Yy8bySvWUu1sSw9z8XH SmMiMmCyhwKgTavqgWWn2rxD7CjvlprdW2azkWhgY6XQAqtNjCkjCAFA001WhOeNQCtqueay2I6 I8UQulDZ0C70BtLLlbsKnvXSEBVENpdROrZw6fHpt7kAZP3pM4cBeVfdXCC22C3yQkocsOtVSQh odZYRvSb/LM2pztVVmVq6sLu31UjAxcNHVcg== X-Gm-Gg: AYBFou0WbOuCGuxbr71VMJJMq7Sn4ImiXlNlHBmm0haVmBPJ3/43Hs/ta9ObxgyZOVY 0X0kRVqBoshkRX+pS6///kxQvGgCzeO8+E+/c0i2PEqddVF5y99Fwz4rsQCvs/nY7PwZGRgYW39 m5E5+oL7igJPVZkvBcVh9/8Ws/k/DmrgHtBGXUF0SE96QDB/C6Xw0rqnZpRDtg92MXKV6xLnKUv Z7iil4p4CfUVBoojmfyl8s8N79z31hm1D4m3sAlg9TCN8K++YWsxwJ+2WX9vwcey+aAmYocj42l emgq1kc3UGlc/Wh5ICmuUx6d2kK2EFFM+S/Z7ULk3S1sSo3vG9/7C0daTVW6ErRnOYuTBgfdXvu XNhTWqU1xzTwng0Ofq/g1Usg= X-Received: by 2002:a05:600c:8b38:b0:49d:272d:74b4 with SMTP id 5b1f17b1804b1-49e619a1e56mr16639725e9.2.1789071272493; Thu, 10 Sep 2026 13:14:32 -0700 (PDT) X-Received: by 2002:a05:600c:8b38:b0:49d:272d:74b4 with SMTP id 5b1f17b1804b1-49e619a1e56mr16638985e9.2.1789071271984; Thu, 10 Sep 2026 13:14:31 -0700 (PDT) Date: Thu, 10 Sep 2026 16:14:29 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , =?utf-8?Q?Cl=C3=A9ment?= MATHIEU--DRIF , Yi Liu , Jason Wang , Paolo Bonzini , Richard Henderson Subject: [PULL 73/90] intel_iommu: Only set dirty bit when PTE exposes write permission Message-ID: <349aac91a1cafad9688451aa937543cad68f7ac5.1789071043.git.mst@redhat.com> References: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Disposition: inline Content-Transfer-Encoding: quoted-printable In-Reply-To: X-Mailer: git-send-email 2.51.2.2891.g4157995a80.dirty X-Mutt-Fcc: =sent 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=170.10.133.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com 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, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_PASS=-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-Zoho-Virus-Status: 1 X-Zoho-AV-Stamp: zmail-av-0.2.13.1.5.4/289.74.40 X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1789082881844158500 From: Cl=C3=A9ment MATHIEU--DRIF Setting the dirty bit without the write bit in vIOMMU creates a spoofed shadow stack PTE that misleads the guest OS. This results in infinite PRI requests from the device, as no actual write permission is ever granted - the guest OS treats the PTE as a legitimate shadow stack entry and considers the permissions already correct. Fixes: 65c4f0999991 ("intel_iommu: Set accessed and dirty bits during stage= -1 translation") Signed-off-by: Clement Mathieu--Drif Reviewed-by: Yi Liu Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin Message-ID: <20260903150649.2281104-2-clement.mathieu--drif@bull.com> --- hw/i386/intel_iommu.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hw/i386/intel_iommu.c b/hw/i386/intel_iommu.c index 7c442a86ca..eccb16346c 100644 --- a/hw/i386/intel_iommu.c +++ b/hw/i386/intel_iommu.c @@ -2039,7 +2039,7 @@ static int vtd_iova_to_fspte(IntelIOMMUState *s, VTDC= ontextEntry *ce, return -VTD_FR_FS_PAGING_ENTRY_RSVD; } =20 - if (vtd_is_last_pte(fspte, *fspte_level) && is_write) { + if (vtd_is_last_pte(fspte, *fspte_level) && *writes && is_write) { flag_ad |=3D VTD_FS_D; } =20 --=20 MST From nobody Sat Sep 26 20:50:17 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=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1789084441; cv=none; d=zohomail.com; s=zohoarc; b=Kx2eqpWZsmhVsWhzaArMtS4pJIOYCSgO5eaKMD35BSpZZZI3OnXmojvCFk2MaIuznPX7Fmj2Ut7FvAVAN4ISxLYDNOa2HIqjDI+iEh5ON8bFMNOvxl3VeLYJ73bt2CenEcPa6f+zRX/FkeEuRdPAKoGaf42vlI5ZAJHCqH7kxLY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1789084441; h=Content-Type: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=Ztrp18hGYXHuUYyUKf9DJwGmlf0B2MNBYEJ6m3HjUYc=; b=Ijw8jFb1wqOlmu1cw1KKyHOAWc32mDyAb0XaHD81/idk0zm93qHtXGne4YTpQThN/sIsq88c8xDYZsC1BFPqgWDp1xU/dR5CkYl4EKGQ1TRKUbhcNqJWKD1cxoAKZVACcmydalHULMlEyKGljDLoFPxEooKoD6n2tv/jhfkPweM= 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 lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1789084441017576.6023604648242; Thu, 10 Sep 2026 16:54:01 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1x4o1M-0002oz-TT; Thu, 10 Sep 2026 19:17:55 -0400 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 1x4lVJ-0006JO-2M for qemu-devel@nongnu.org; Thu, 10 Sep 2026 16:36:34 -0400 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 1x4lV5-0003jW-2f for qemu-devel@nongnu.org; Thu, 10 Sep 2026 16:36:06 -0400 Received: from mail-wm1-f72.google.com (mail-wm1-f72.google.com [209.85.128.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-156-8LlQ_Tc8N_SORNqVk7769g-1; Thu, 10 Sep 2026 16:14:36 -0400 Received: by mail-wm1-f72.google.com with SMTP id 5b1f17b1804b1-49d2951089fso1566465e9.2 for ; Thu, 10 Sep 2026 13:14:36 -0700 (PDT) Received: from redhat.com (IGLD-80-230-79-236.inter.net.il. [80.230.79.236]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-49e62121747sm1969385e9.2.2026.09.10.13.14.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Sep 2026 13:14:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1789072452; 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=Ztrp18hGYXHuUYyUKf9DJwGmlf0B2MNBYEJ6m3HjUYc=; b=CjhrmFo0Ai2ckOl998ZOMpy+aXrG1zp1moH7RTZ5NaRiimLZmwURj7B8O6OUYSuSOU0P+/ TdPlGY48t7ZA4KtSamZXKuPETRP1RLDVSCCFOmsrNhHfRai+M1D7xvO6pI3Tzhj5sOvVNM aJSuyNx+KxWBgB8NmF6FtcKOWPTmqs8= X-MC-Unique: 8LlQ_Tc8N_SORNqVk7769g-1 X-Mimecast-MFC-AGG-ID: 8LlQ_Tc8N_SORNqVk7769g_1789071275 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=google; t=1789071275; x=1789676075; darn=nongnu.org; h=in-reply-to:content-transfer-encoding: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=Ztrp18hGYXHuUYyUKf9DJwGmlf0B2MNBYEJ6m3HjUYc=; b=IeAsOWhypvBD2ZyyZAWGMYUbyiK+ILaBlg3h2E5jm1ivj8kaiqc/a5u6lYxPPty2ro HOJYbD8vbsZkaTWgneoz6Uex5v4aAc+KgYwsozpP3tM9hDz0LQ79nnz5XTI59DLqm2cv 01qlv63RSXk/mZyA6aVGjUfKrzzdrEFAK1/h650CWTsShuMuoTfzUI4U+r2uwZvAcqK5 g05kTs79mIHkTaB7vZAe+jGZ0uIJ5W7W8hs6Q5V/MxV+JPmw245Af31A2pZGT/1eDApq zqMoZx/H5UEjHKw0i6Z5gQQQ9swx6CoTn5KhawRj2WRPm2TU7MObkpBKesSpk/fzXYWD cDpA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1789071275; x=1789676075; h=in-reply-to:content-transfer-encoding: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=Ztrp18hGYXHuUYyUKf9DJwGmlf0B2MNBYEJ6m3HjUYc=; b=oJ+Uj1MACi4Irv4oD0XSpxHHfTw7bB6pHdLbvodru406wb5VP/sJfclFOSxofzrBY7 iZRwXOgQ4q6UB7vTzUwPsWtHYz/uOSQjtSAppo7E4Pmlv310wOyQAzeuHUWrA1Li8+oK vfiR/jNiGWIjCdf3wA4qU8mCIeeS+0U6W7cED5zuoXz4DcShy09ofUo3CjGxarmqubiu vmK4z4QWYRKIrJbBkR1O9esha/qufKS9J69ICq7vbgy7/oxqitIUWKNCUk4pxjF/QXuc 2Obiwq67nKR5Eog5TF/mit6/Xs644eeEe8uTOgAyw+bGBia0b82mSspaxCbrut0x9AUK D5XQ== X-Gm-Message-State: AFuF++kIJyGXRg9dP4lfE5mLed5gHdi7smM37gJ9tJdiN3befW6my+XO oPYNeuITeMrbJI+oQ00oim+L2FUYlqknBpFtALQAW3R61w7enfslRYcysN2Chr5beDrtqZfAGEa SvV3s8Z/EkBSMfA+eBdj3vCAlgenI53Vjlq8nSfnFeM7IhVf0GSWF/4cGJ+Xp3U/iAcea54YD5K qiyWmSU52ahETishLN31nPj5NevZjNxdzAVA== X-Gm-Gg: AYBFou275BV2za19gMmtsoWvINJdHl4y2vYIraURuRuDQ8oGxiY3LBuY6GSLdbCZIKq NZzdzizwNUdn4L3QEEQ3ERqrmIQzEddPgqY88yn8jFDp3+uEdZSDH5iRTkSumjFeeTCbTP7fVc3 4o+Z0f8bKkNApOTaChyU7c/wCdL6+7d+d5Ea+5iNOWfoyrkp9dMZeQwtI6CdA3rjUgh9QcRoTzI V4tR/KUcHZMxeaZK8RbdwoSBHRYCgG9dyqJK4S/X07l0YhppFOhlq/kU72QvNphVXRqWky15ypr QCgpUNy1YaTHZEjlClBB8sssrmL/v0HPZHbIT7CKtM4wPZLoaK5FjHGGuxD3zk+5aBDVIJib/rd kN+LX+WU7330dlx00gU/Yxi4= X-Received: by 2002:a05:600c:1385:b0:49c:fa21:1c89 with SMTP id 5b1f17b1804b1-49e619d1daamr6300725e9.30.1789071275443; Thu, 10 Sep 2026 13:14:35 -0700 (PDT) X-Received: by 2002:a05:600c:1385:b0:49c:fa21:1c89 with SMTP id 5b1f17b1804b1-49e619d1daamr6300255e9.30.1789071274795; Thu, 10 Sep 2026 13:14:34 -0700 (PDT) Date: Thu, 10 Sep 2026 16:14:32 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , =?utf-8?Q?Cl=C3=A9ment?= MATHIEU--DRIF , Yi Liu , Zhenzhong Duan , Jason Wang , Paolo Bonzini , Richard Henderson Subject: [PULL 74/90] intel_iommu: Always write all the flags passed to vtd_set_flag_in_pte Message-ID: References: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Disposition: inline Content-Transfer-Encoding: quoted-printable In-Reply-To: X-Mailer: git-send-email 2.51.2.2891.g4157995a80.dirty X-Mutt-Fcc: =sent 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=170.10.133.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com 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, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_PASS=-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-Zoho-Virus-Status: 1 X-Zoho-AV-Stamp: zmail-av-0.2.13.1.5.4/289.74.40 X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1789084443288158500 From: Cl=C3=A9ment MATHIEU--DRIF This function was initially designed to write a single flag in a pte. The current implementation expects it to set several flags. Fixes: 65c4f0999991 ("intel_iommu: Set accessed and dirty bits during stage= -1 translation") Signed-off-by: Clement Mathieu--Drif Reviewed-by: Yi Liu Reviewed-by: Zhenzhong Duan Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin Message-ID: <20260903150649.2281104-3-clement.mathieu--drif@bull.com> --- hw/i386/intel_iommu.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/hw/i386/intel_iommu.c b/hw/i386/intel_iommu.c index eccb16346c..91ab549dbf 100644 --- a/hw/i386/intel_iommu.c +++ b/hw/i386/intel_iommu.c @@ -1964,13 +1964,13 @@ static bool vtd_iova_fs_check_canonical(IntelIOMMUS= tate *s, uint64_t iova, } } =20 -static MemTxResult vtd_set_flag_in_pte(dma_addr_t base_addr, uint32_t inde= x, - uint64_t pte, uint64_t flag) +static MemTxResult vtd_set_flags_in_pte(dma_addr_t base_addr, uint32_t ind= ex, + uint64_t pte, uint64_t flags) { - if (pte & flag) { + if ((pte & flags) =3D=3D flags) { return MEMTX_OK; } - pte |=3D flag; + pte |=3D flags; pte =3D cpu_to_le64(pte); return dma_memory_write(&address_space_memory, base_addr + index * sizeof(pte), @@ -2043,7 +2043,7 @@ static int vtd_iova_to_fspte(IntelIOMMUState *s, VTDC= ontextEntry *ce, flag_ad |=3D VTD_FS_D; } =20 - if (vtd_set_flag_in_pte(addr, offset, fspte, flag_ad) !=3D MEMTX_O= K) { + if (vtd_set_flags_in_pte(addr, offset, fspte, flag_ad) !=3D MEMTX_= OK) { return -VTD_FR_FS_BIT_UPDATE_FAILED; } =20 --=20 MST From nobody Sat Sep 26 20:50:17 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=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1789074099; cv=none; d=zohomail.com; s=zohoarc; b=Sla0Jm5tXWXEhuNCaD3HzNXAvLUsgJwRKXiNc5SBzIRH1EQAtH45V66okwaIU8pLOmJB6Iy2ZdctDSQAgIc4YpfxzT4OAFb6g55RHylYnd7TuoY7pTSGrzTj1hhrDgTjCg0C0NZHxps0sBHO9JGxjT6SNf3V+ZzqVd87ZJqC6+A= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1789074099; h=Content-Type: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=2hNz4/jqFz0hJ0OYLcWq6vFd56S2mjD9cbtRudNy4aw=; b=AiJ1xVUsk/adcQoh4tLQlhJhn25CjcqzGWil0Iq/cX7Nnv0290cupAnbE9gEvuOTPkaqTzsWcfKEhdFJ7xD8cQp/X1y2JTfCz/dJ4M5eTg9YKtPAod/mbZ5qdSlrXJQwJQL5g0e0drC0OKKBp7yHq1eCt60ARdzRKyDwbCGwv/k= 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 lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1789074099213743.4522357915425; Thu, 10 Sep 2026 14:01:39 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1x4lsv-0003Zs-Rr; Thu, 10 Sep 2026 17:00:55 -0400 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 1x4lF1-0000Td-8n for qemu-devel@nongnu.org; Thu, 10 Sep 2026 16:19:34 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1x4lEu-00079c-F1 for qemu-devel@nongnu.org; Thu, 10 Sep 2026 16:19:26 -0400 Received: from mail-wm1-f71.google.com (mail-wm1-f71.google.com [209.85.128.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-454-SSBe9grrPPmrL0wtm6cZ5Q-1; Thu, 10 Sep 2026 16:14:39 -0400 Received: by mail-wm1-f71.google.com with SMTP id 5b1f17b1804b1-4994cf6cdb9so1579775e9.3 for ; Thu, 10 Sep 2026 13:14:39 -0700 (PDT) Received: from redhat.com (IGLD-80-230-79-236.inter.net.il. [80.230.79.236]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-49e61a81943sm6043655e9.1.2026.09.10.13.14.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Sep 2026 13:14:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1789071342; 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=2hNz4/jqFz0hJ0OYLcWq6vFd56S2mjD9cbtRudNy4aw=; b=E0Knp96H5ECHfEKEl/DKfMMSnXknYpoiv0hFDiVerIVigvznsiHP76/A+bAgWDMH6EGiza e22YD+XiU6wDKyiNQjfPZcyl2ySEAR2unPOgjmILcOB6IcyVC5EsaSkIUsM5kGc5yBy2pe 2bQX51lyBB8h/CDz6JlBfvg4URc+M/g= X-MC-Unique: SSBe9grrPPmrL0wtm6cZ5Q-1 X-Mimecast-MFC-AGG-ID: SSBe9grrPPmrL0wtm6cZ5Q_1789071278 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=google; t=1789071278; x=1789676078; 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=2hNz4/jqFz0hJ0OYLcWq6vFd56S2mjD9cbtRudNy4aw=; b=r4ZtCwRyk0Jy/wAn+qNowFu4bDq4kHILiigEHEx5PlbvLjXWJU+O6HpD4sp13jQSCm wnv3lxs/j2odot4SlLpCGVSZed9qO794IO49qo2krs2vGq7z81mWyKCXGlEMeN54oRYY A/kASRU+gYnVpByz7t7xqT2JCy2xJNxKsFudWie7QZ1sqO3/MmJ14p7JlCb5qdlcEc78 op6RPyz59xLF94di7Ca1+EbFl66I5AV7//GCJj/t3n45A9YBcW7qZxfXtAdg8OjG+tcf Oc5pyxvGmfcIkW8A3aggO1w3YhNVtK3YqUQbRp1O/wg3w8ACOeLup8Z17B14XOakYDaS jhvg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1789071278; x=1789676078; 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=2hNz4/jqFz0hJ0OYLcWq6vFd56S2mjD9cbtRudNy4aw=; b=cQlfuQxv6EsXnq0VN9BCBJ6HEAih9wLv1BowASGjYzM58TiQk+VJ1Jx7wKmkv2jVeg +ncmykJtDDXJBtbGdWj6QxgafeBoohOzpFDY4kc0swz7j6KbHEs35YrZF/+7025OOwim VLK9hczVorMWrv2pEqOXU+B1b0ActOWHNk753B4ETo9vzjdSodG8dtZrnlhwqsTDSdXZ CM+TZtrySiUshdFrHMmyBOCwd+/FkQHBpku+J1NyYqA+ZL2fV+cERW4Be0jO+BAkP9/0 Cdq6zjzw7xnqvI5eHI4VCc7BxWXlXDt4r0pIpxxw0XpUL2/UIN/jhFG0rMbqXX/kAuNd fVXA== X-Gm-Message-State: AFuF++kyKZoA2gjcYe9h54XzHnAMwgym2ZQk1674jdo8GOc66EJIzj9b jwUrp6Sis3wFO15RV0J8rIGgVfiGvglRgxoeZajzxYrAalNNrBDxNCmX3cv1UqUT3Z5i8BBSD0/ 9QArN3nWuGe1NistAIuiarevHbxYYkKVyZqLM95rPW46JZdp+HxSYagv9CsRpWj4v8r0PgFsR0n bIWDsosc76AVfz3FZ9GyIwooQcu/fKYqO3OQ== X-Gm-Gg: AYBFou0gMAb0BdCxPhP1JaBmdSvzTXoesI6K22hdJw8vzT/58x34WGti6Cbi8PcDyYb 9KOzuG5RbBuC4CPmGrq2SpmSsABAqvWtb+XvMyzkgLvK4XySXHjm07DZKNxlk+1vFgJa997qDAB UoHDSR68Y+tOgfFsOyZ7Roih2HVwHSJtpCoy4Z7QWgF8QX01Z2NLAUZEB6nJTEAreBMINJUInKl bYyO6MRvJr8ODau4mfOUFBCO5DWebS4ua8J8OafHSsdTHYDcVv5YpaC1tQ6Ktx0xVh82rE7rpbW uM+Ab4QBF3CyhZELO663v6ocYgOsjGwInrRggCoUPFjKyNnaI5JQKL21YsXniwY3aLKPR/wJy6l wLsq8vqC8MVaJmCw3m/PczhU= X-Received: by 2002:a05:600c:3ba2:b0:49d:99:1d98 with SMTP id 5b1f17b1804b1-49e619881e3mr10082575e9.9.1789071278066; Thu, 10 Sep 2026 13:14:38 -0700 (PDT) X-Received: by 2002:a05:600c:3ba2:b0:49d:99:1d98 with SMTP id 5b1f17b1804b1-49e619881e3mr10082045e9.9.1789071277549; Thu, 10 Sep 2026 13:14:37 -0700 (PDT) Date: Thu, 10 Sep 2026 16:14:35 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , "Denis V. Lunev" , "Denis V. Lunev" Subject: [PULL 75/90] pci: batch BAR remapping into one memory transaction Message-ID: References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-Mailer: git-send-email 2.51.2.2891.g4157995a80.dirty X-Mutt-Fcc: =sent 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=170.10.129.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com 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, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=0.001, SPF_HELO_PASS=-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-Zoho-Virus-Status: 1 X-Zoho-AV-Stamp: zmail-av-0.2.13.1.5.4/289.52.80 X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1789074102269158500 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: "Denis V. Lunev" pci_update_mappings() deletes and re-adds a subregion for each BAR whose address changed, and both of those commit their own transaction, so one BAR move costs two full flatview rebuilds. Nothing between the delete and the add touches an address space, so the walk can run inside a single transaction. pci_bridge_update_mappings() already does this for the bridge windows. CC: Michael S. Tsirkin Signed-off-by: Denis V. Lunev Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin Message-ID: <20260903184542.2629976-2-den@openvz.org> --- hw/pci/pci.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/hw/pci/pci.c b/hw/pci/pci.c index c15f2b9f08..14c78e3c62 100644 --- a/hw/pci/pci.c +++ b/hw/pci/pci.c @@ -1742,6 +1742,8 @@ static void pci_update_mappings(PCIDevice *d) int i; pcibus_t new_addr; =20 + memory_region_transaction_begin(); + for(i =3D 0; i < PCI_NUM_REGIONS; i++) { r =3D &d->io_regions[i]; =20 @@ -1778,6 +1780,8 @@ static void pci_update_mappings(PCIDevice *d) } =20 pci_update_vga(d); + + memory_region_transaction_commit(); } =20 int pci_irq_disabled(PCIDevice *d) --=20 MST From nobody Sat Sep 26 20:50:17 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=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1789072994; cv=none; d=zohomail.com; s=zohoarc; b=jwNDtI1WiKr1LZVT4Vt8PF9umtWKR9JsTNTj+ekiGbNnat5L8L4b/ywJfauSjA1fFxCcPPaT0FNgWOlQcmSIF/H+pBK0XwCLH4JaM6Bq527OzRkxe/vCGyUz69mjgTD7o9ptfcHTGvfMdGbK61ONvbeeZPSCDnJY7enX9hqizGg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1789072994; h=Content-Type: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=c093DEqy/fkrW/Lhh1nhHFo8QJoMiHWxFZZ8F2Ne0/E=; b=LMt1g25WUZGdqvZrnBDdbWeFQbfTOxBzM88lDk5ZrDv9SGYZUCkSowCt715ym93fwQLnRwkf1/LKqe8qNjxUpO3ucRF/+wZaFmypHMwQ6nN5wiV9h5EjJBi7NaZFohJpJTHHE2olB+Ij2/zv9rtjElJywtg0UaafHdFsGlW7Scg= 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 lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1789072994624381.4805945688021; Thu, 10 Sep 2026 13:43:14 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1x4lbL-0007RR-F4; Thu, 10 Sep 2026 16:42:38 -0400 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 1x4lEl-0000Nh-G6 for qemu-devel@nongnu.org; Thu, 10 Sep 2026 16:19:15 -0400 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 1x4lEU-0007Dv-VV for qemu-devel@nongnu.org; Thu, 10 Sep 2026 16:19:02 -0400 Received: from mail-wr1-f70.google.com (mail-wr1-f70.google.com [209.85.221.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-695-uSB1YJqHM7iiEfc8BB5xZw-1; Thu, 10 Sep 2026 16:15:14 -0400 Received: by mail-wr1-f70.google.com with SMTP id ffacd0b85a97d-4855e47d062so61590f8f.1 for ; Thu, 10 Sep 2026 13:15:14 -0700 (PDT) Received: from redhat.com (IGLD-80-230-79-236.inter.net.il. [80.230.79.236]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-486eb34e74esm793113f8f.25.2026.09.10.13.14.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Sep 2026 13:14:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1789071378; 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=c093DEqy/fkrW/Lhh1nhHFo8QJoMiHWxFZZ8F2Ne0/E=; b=gQlalLo5RoKDirYY8HWG1umvOutKoBgNHbOmlxHGJWR1xNHRJbisQ39kMYc2PEZ+ofI6KN YVR/DHUlAPBcOvdjILrg70AKmiznDnT0JRTQM4SJUvVhg1dxwS+PBMIFmnSjqS8GqZaMGa HwtxzjGlu9iBUAJJsdEigT3mN+WEQF8= X-MC-Unique: uSB1YJqHM7iiEfc8BB5xZw-1 X-Mimecast-MFC-AGG-ID: uSB1YJqHM7iiEfc8BB5xZw_1789071313 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=google; t=1789071313; x=1789676113; 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=c093DEqy/fkrW/Lhh1nhHFo8QJoMiHWxFZZ8F2Ne0/E=; b=ISW4dHJ6f8FkGgqunxev/T7CrcqA2fA8mlEnVED3fbJ/t3MFRODhR1oEb1KhSyfQz1 7Y48Sz+IaBYpgReFOX5BbXl7iaHTeCT9R1XWLt3+Iw1YwkM8ZPdA9UpkJ+cARR5ZWixS Cr1W8tEZb0lKvBhdFBFYM4YoiHGZ+dq4kbvuNySB0zJ0Z+8/BJw2kw+LpFW4sv/ohVY7 tHbQXtVOCMgzIMxraGqx59CMPlpXwylTLDpkCOBeqQ1HsW91CLnG6DrcqckerMc1wbYj XSA55eJJkalrzPtJKRHOAgNeRTBvMbGyhb9oj9Uh9dY7CYUD/R0+9c5pE3ADT94uEPji BTwg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1789071313; x=1789676113; 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=c093DEqy/fkrW/Lhh1nhHFo8QJoMiHWxFZZ8F2Ne0/E=; b=NdTuUjNk6JQeZjIuRB1vJonyM1dxiFO4wEAQ3HlrkJ57v7PeyFfvQ4yrIl0YS/Yr2e LztaqYeLF1WVxqCk7zQBpbPoAwsQwc5UnTSMoXByPNGJ+85MCqaIVfX3UofFuBD1vSOB HQkqec7BJ0WhAASMy42QqHE1d+yAL4AwI5G1IuOvyvUNcnKXW68YgOOhOFy4Y3moyZdY 94swut6wN/xqyY6ijYKARUpwfxxAuv9WUd6nupFGUS3iQuC3K2YbZWB9P0egEdrbUnHM +68j+LE4KT5OU9LWdOKDSVc61I30IVV5Uxi/6Qmtoe9E4j7+6ToLk0vVg6RMLa6WBu9u zHHg== X-Gm-Message-State: AFuF++lzfcjxlghLsSWIkg311+xB/xT21u02sDLq6J1u9zHxFRGY59O0 erg60KBfjP7daXIanrI5/98iXJ8tyBUXqjGog++H/rAyUhWLnrfujibjmVqxTgQgg3B6PD/J+I2 kviRo3dMVfDaFP0CAbmMbBXAVoCwHYCZYqFyXP3mpmwIpy/qOmuL5jxp2blhguKyitYqP6C70Nt 7qF7qoKKHukeenE1tHVQeWl8uQ04UYJfWL/Q== X-Gm-Gg: AYBFou2R0d1JUqjZEZBZkMEPqh3yFSa+vYAvod8PaNiAlMk37T2uwkvW6zHMdERtUfh fQ+lDWTk41yspFuAiJYVvFNT1sh8qEvCcc+T9tLCPRLClORJ+wh0nMPp3Z5BR2eeCvFav5dxsWI 2kzpI5T0HYA6S1rFBBG4lFJfzy1YfbABAcSQzl7YiDlHyhJE475g1Prfp6X03GKO1OpnUIZiVlD rjDcDUa4NF5tFKnYqZ/xPQZg6Tm0sYwSsk1cTYMk4NzH/pAPeEsM2rnjRT0eTrAUVihamIspP2s ZMgfTQyam3f0rnz+JqfxiKtUIKoT1SrjmJpVST6wtMkZy6vmx6MsukxiA5v/4THtqBUnTioQP+m Tc+73b0PQjfJqCoMSf5S90pw= X-Received: by 2002:a05:6000:608:b0:486:414:e3d5 with SMTP id ffacd0b85a97d-486eb2d9912mr779047f8f.8.1789071312933; Thu, 10 Sep 2026 13:15:12 -0700 (PDT) X-Received: by 2002:a05:6000:608:b0:486:414:e3d5 with SMTP id ffacd0b85a97d-486eb2d9912mr779006f8f.8.1789071312345; Thu, 10 Sep 2026 13:15:12 -0700 (PDT) Date: Thu, 10 Sep 2026 16:14:37 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , "Denis V. Lunev" , "Denis V. Lunev" Subject: [PULL 76/90] pci: load a device's config inside one memory transaction Message-ID: References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-Mailer: git-send-email 2.51.2.2891.g4157995a80.dirty X-Mutt-Fcc: =sent 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=170.10.133.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com 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, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_PASS=-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-Zoho-Virus-Status: 1 X-Zoho-AV-Stamp: zmail-av-0.2.13.1.5.4/289.52.80 X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1789072995529158500 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: "Denis V. Lunev" Restoring config space remaps the BARs, updates the bridge windows when the device is a bridge, and toggles the bus master region. Each of those commits a transaction of its own, so one device costs several flatview rebuilds where one would do, and the cost of a rebuild grows with the number of regions in the machine. Nothing between them touches an address space, so the three can share a transaction. The saving scales with the number of PCI devices. CC: Michael S. Tsirkin Signed-off-by: Denis V. Lunev Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin Message-ID: <20260903184542.2629976-3-den@openvz.org> --- hw/pci/pci.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/hw/pci/pci.c b/hw/pci/pci.c index 14c78e3c62..0efb4eb4bb 100644 --- a/hw/pci/pci.c +++ b/hw/pci/pci.c @@ -840,6 +840,8 @@ static int get_pci_config_device(QEMUFile *f, void *pv,= size_t size, } memcpy(s->config, config, size); =20 + memory_region_transaction_begin(); + pci_update_mappings(s); if (IS_PCI_BRIDGE(s)) { pci_bridge_update_mappings(PCI_BRIDGE(s)); @@ -848,6 +850,8 @@ static int get_pci_config_device(QEMUFile *f, void *pv,= size_t size, pci_set_master(s, pci_get_word(s->config + PCI_COMMAND) & PCI_COMMAND_MASTER); =20 + memory_region_transaction_commit(); + g_free(config); return 0; } --=20 MST From nobody Sat Sep 26 20:50:17 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=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1789073159; cv=none; d=zohomail.com; s=zohoarc; b=T6HVbKgvwbH4MEwrNQaPkvUjk3sRji4smYMkNCRwqW9yEZzTP7YAcp5P6WVxMSkCMKhKqABFxzwJVJp9VIaNL1U6RMwoj+V/sVW2HLSY2gPNW0t7IQcfXw5sB6e5lCPpy5NrO2/dmBfq1ScEaDtC0BSoYhjB2NSTPZcfKmfXRAs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1789073159; h=Content-Type: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=ztnEzJr9cLGP85wdavmJjLJZCpMNN2vWplsbH2YazF8=; b=Vqw8nyI6ZwRqUCBYk4AgC7KRNkw0MX+RvstakgBJtLDnKWvsiXzApURCq4iLU6pak/wOZip+OEvi9FmNMO+14XtSGaU+JSyPgVjPMedTr7MWLtVnLvC5AqfdS18z2Gvs89XSvuUXZLoqppss9njWex0poJS5jM82koL63rR2TFY= 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 lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1789073159842409.49708194112316; Thu, 10 Sep 2026 13:45:59 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1x4lds-00083f-UW; Thu, 10 Sep 2026 16:45:21 -0400 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 1x4lFn-0000gy-NS for qemu-devel@nongnu.org; Thu, 10 Sep 2026 16:20:32 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1x4lFX-0007ED-Qg for qemu-devel@nongnu.org; Thu, 10 Sep 2026 16:20:06 -0400 Received: from mail-wr1-f71.google.com (mail-wr1-f71.google.com [209.85.221.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-325-jmgcZ_zRPlWIZS8F6UNYOg-1; Thu, 10 Sep 2026 16:15:21 -0400 Received: by mail-wr1-f71.google.com with SMTP id ffacd0b85a97d-47f4bff865cso79553f8f.0 for ; Thu, 10 Sep 2026 13:15:19 -0700 (PDT) Received: from redhat.com (IGLD-80-230-79-236.inter.net.il. [80.230.79.236]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-486eb36e4a6sm814696f8f.37.2026.09.10.13.15.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Sep 2026 13:15:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1789071387; 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=ztnEzJr9cLGP85wdavmJjLJZCpMNN2vWplsbH2YazF8=; b=NtFry1IOnVVG7VtddtNt4Y0CJv3pEp/sV9+59jMijsMetpTBxjmAKEOf44LDB9Zkduw/eU ZmrGiMLkYSk8QmrRyoYhlokobWO3jCSRuCP5mW3ooqev0M2nIRu/YkknutnFrN/mN9C99t gV2a6lz10m+u/SyF8nSnxHvKu2E3Rjc= X-MC-Unique: jmgcZ_zRPlWIZS8F6UNYOg-1 X-Mimecast-MFC-AGG-ID: jmgcZ_zRPlWIZS8F6UNYOg_1789071318 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=google; t=1789071318; x=1789676118; darn=nongnu.org; h=in-reply-to:content-transfer-encoding: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=ztnEzJr9cLGP85wdavmJjLJZCpMNN2vWplsbH2YazF8=; b=E1s2mSAzgL9tiIpCejdQJWsc5Afk2bOdypw7iHuUvKH+p7VNPU+gzO1JWFgfdF9yXG CmKRMembm1EP2hPtD+UL8FNGN0TIionQKGhVZGsgY46Xrp9cFf4RxyUtH9ZaonajFalX 7nm9aFbESQuT7d3MwBdsmpjS8cZ0o9exiSmeyV9XnuM6AL5nS4a8JfWfDDgHbeyT1m+n FYtmQtOcp9ZnPwreI47FAwqFrJkrJvGoMRA+RYxpJBONYhPxj631860Ifl1D8DGPwrGz 2TgKrBlCOB+uoMkWRecFzEqaWGfgoeNDCrRr/9CajuB0RVqmdJ/0/pRf9GaDuQIn3FkH ocOQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1789071318; x=1789676118; h=in-reply-to:content-transfer-encoding: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=ztnEzJr9cLGP85wdavmJjLJZCpMNN2vWplsbH2YazF8=; b=ClWBy9G0bUKvqeglI5DPWuVGXsRGKiZ33MezT0ZbF/guL9XFlKnFRO8+kpMGJzdA7Z Bx86Zhh3eHgG/Tdh9rtlPOeaDLRuGNDdxfrC/pvXqhgjoZH8qQI6cfLulFANVstkXBsF r62P9mOY+JP73FXp4F1EnwyMYy+deo2NtDYckuaiZgleP+7lgNud2RCv9WnHMEAmCz5Z hcuT1yIPh6T4nzYzaOCsh7jw/fZvQByiUpWwyjZLUU0KmjgzHMcsG2wLPxdCjnK3ZFpn 5xEot2jgSX6wDFr9cr29gTe0DeqFGlOdhEWGkVeBtdasGpWLY87TVfVQg6t3I0IE84Z2 4Mgg== X-Gm-Message-State: AFuF++lM9eNmCIwkVljls5k7KsGxEbN0SWXarbtnvIkJ4dGS490s1SFX q2MSNojl5vpQg92GtulOfU2DhhV/hYdbm/p9iRU9je8h0HQwOgHCqEY6Y/I8vKs6elCW0WvLAyM vyuKXAqurN7WleOdHYApUYwTIpa4uuR1jH/DJIvoAIx46NgV/gyi/qFl8G/vZunMdfdRCJAsNa6 QZfLY+DQco8kCZiZQdlqpC1q/sbG6KXC2wLg== X-Gm-Gg: AYBFou04QViDUZTXdOSzIfU/DUhirxcu4sifJFXVWSXiOS2ZAwdUcEx43BHKr2CfLvY QPcbMoFx+OPPvGBmgqGUWHCZt/1F4ezx91y48hQgmWZ2gJ0JH41/LQKXxq/vHDHAuiNxqg3sCe8 Bs49x+YH6BDd6zpiPHc6Izw3BYDhT46kr2cYiCFq7PiNXFkH7Yxm7UhniqsoB/QjbMHqQdzIKUh RLMbWVbDXe+Nmq4R+z7GY5tnERRv7X7n1UMYhsMRx8UOLTR/QnLRiaJCuLOcd0v5I3UrQRhgT75 XGFK6ms2LlU0CJ0rNW4bw1WZWHwTaL1fzRZ6wyXRxTUjNmagFnRBKwLH5WzbWHTxib5eKzAc4Ct aDF209FBmbiyrizTENHX6kF0= X-Received: by 2002:a5d:5290:0:b0:485:8b5d:96d with SMTP id ffacd0b85a97d-486eb324d34mr1121186f8f.19.1789071317902; Thu, 10 Sep 2026 13:15:17 -0700 (PDT) X-Received: by 2002:a5d:5290:0:b0:485:8b5d:96d with SMTP id ffacd0b85a97d-486eb324d34mr1121122f8f.19.1789071317305; Thu, 10 Sep 2026 13:15:17 -0700 (PDT) Date: Thu, 10 Sep 2026 16:15:12 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Philippe =?utf-8?Q?Mathieu-Daud=C3=A9?= , Igor Mammedov , Ani Sinha Subject: [PULL 77/90] hw/acpi: Make AcpiGedState const in build_ged_aml() Message-ID: References: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Disposition: inline Content-Transfer-Encoding: quoted-printable In-Reply-To: X-Mailer: git-send-email 2.51.2.2891.g4157995a80.dirty X-Mutt-Fcc: =sent 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=170.10.129.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com 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, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=0.001, SPF_HELO_PASS=-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-Zoho-Virus-Status: 1 X-Zoho-AV-Stamp: zmail-av-0.2.13.1.5.4/289.52.80 X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1789073162618158500 From: Philippe Mathieu-Daud=C3=A9 build_ged_aml() do not modify the AcpiGedState structure. Signed-off-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin Message-ID: <20260903230245.65601-2-philmd@oss.qualcomm.com> --- hw/acpi/generic_event_device.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hw/acpi/generic_event_device.c b/hw/acpi/generic_event_device.c index 67c9e9b3e8..5225e32513 100644 --- a/hw/acpi/generic_event_device.c +++ b/hw/acpi/generic_event_device.c @@ -48,7 +48,7 @@ static const uint32_t ged_supported_events[] =3D { void build_ged_aml(Aml *table, const char *name, HotplugHandler *hotplug_d= ev, uint32_t ged_irq, AmlRegionSpace rs, hwaddr ged_base) { - AcpiGedState *s =3D ACPI_GED(hotplug_dev); + const AcpiGedState *s =3D ACPI_GED(hotplug_dev); Aml *crs =3D aml_resource_template(); Aml *evt, *field; Aml *dev =3D aml_device("%s", name); --=20 MST From nobody Sat Sep 26 20:50:17 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=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1789075234; cv=none; d=zohomail.com; s=zohoarc; b=YMN5/dxM7rIka+c1hUFDTNpl9Qq/hnQ5GQxgKCbzGbOv5bUxf20eXdSZJpzuVuRJzw7osQntUHDve4Wkynfg52XAeRxJvq7H4leNbmd2pPTQ22EGNqVBt0vy7PDXV2ajpeYBjel3XU0/GstvY79JMD7MpOodpvUjOwECRvaIM98= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1789075234; h=Content-Type: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=4CnyxDCKVe7u1Oo/VtDfYPCe5Gbe0/d1270GUGGe0eo=; b=StxaWr7y6iTyZYrT8l4YzgjvC/XfPo5o6nu59DPNo9cOyv22oEeFJn3KWE6NlgrF2rn+PuymRcNpsqg7XtecXNsa1LvAqM3AovmesIXi7s8Jeidlj8FalSn4Old3bAWXuebAsRXalVl09hJoQM32Ep+WR4q3mIEUIn2Zre23714= 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 lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1789075234807150.10397966933; Thu, 10 Sep 2026 14:20:34 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1x4m4j-00069B-0b; Thu, 10 Sep 2026 17:13:43 -0400 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 1x4lM2-00036C-JD for qemu-devel@nongnu.org; Thu, 10 Sep 2026 16:26:55 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1x4lLk-0000Rr-HJ for qemu-devel@nongnu.org; Thu, 10 Sep 2026 16:26:28 -0400 Received: from mail-wm1-f69.google.com (mail-wm1-f69.google.com [209.85.128.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-672-9oL67tGePzG99xhpBztNGA-1; Thu, 10 Sep 2026 16:15:22 -0400 Received: by mail-wm1-f69.google.com with SMTP id 5b1f17b1804b1-49cd83ca361so1742305e9.1 for ; Thu, 10 Sep 2026 13:15:22 -0700 (PDT) Received: from redhat.com (IGLD-80-230-79-236.inter.net.il. [80.230.79.236]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-49e62225628sm1168585e9.3.2026.09.10.13.15.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Sep 2026 13:15:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1789071781; 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=4CnyxDCKVe7u1Oo/VtDfYPCe5Gbe0/d1270GUGGe0eo=; b=QtwlouJ4xtFc7kdnB7w7mXfLZeR/Dz9xPvUqphBEDg+wR4Z/CrjEmhj66Vqg+c2QA4V2IW IjR02wdAOqbEazOVHLKZl8sLJWk/5kBJHfDvHRdWA6DRv8K7g0pE/Wf6FeML80u4kNiLYV E/xY7rH1InHQ6gnq0RpBE4TwmKtbGe8= X-MC-Unique: 9oL67tGePzG99xhpBztNGA-1 X-Mimecast-MFC-AGG-ID: 9oL67tGePzG99xhpBztNGA_1789071321 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=google; t=1789071321; x=1789676121; darn=nongnu.org; h=in-reply-to:content-transfer-encoding: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=4CnyxDCKVe7u1Oo/VtDfYPCe5Gbe0/d1270GUGGe0eo=; b=HXq0a4IS+SNkfTZjMmEhxLghb5yXMcEPbI7ZJ5VhWkzgE+/k1e59d51kS9l/+ZtBTt P2VIit81xpziKci8hu6YYPRkQ7esAqHrmJmX+qFm5xCvzyGLSyA0cSCJiqeCJPIyZQlN 2Y36ks44Gho+5EZ4SWCquiSkz66qg88ybipt+oGyyZq71+jSDQP2BedfrqaoGYhZWiY3 NFtjD4nfVQ89+ESzbtO10WUO8qRouuAWlJ2kz1VZu0GebqFg9gp4mdNHeEWuDpQrAhjC RbNsrgYOG3IMxZltkm6Jk64d9yjjSGHGQP8wtpGwsaLPTFtgfUt2RSB7C4xRJ97oq0d9 jY2g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1789071321; x=1789676121; h=in-reply-to:content-transfer-encoding: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=4CnyxDCKVe7u1Oo/VtDfYPCe5Gbe0/d1270GUGGe0eo=; b=qVJ2tOtqPFOW/69HH2mvhmUPJRyTL2PFy7xL3OGeMQ4sqkkgd8xC5WYwPShIqrRfxA gSBV636qreha8TPNyrXgVXrhV9SaZXg7yz0k8PCduWuM+nrSlWE4Bc9FOjb/ONVukP3O PSH5eb27fA2m89H97hlUd/+56yFteFh4EFZTYZiVTPTB3VzrF96o33V0qnO3KvPCO35i zjWZOOehhHXX9qgoSAMU+OnhLzSfvEe9/CDm1Wx55VgbpOcept0y7nOQew6jMvjju66o Qhp0S8lFxyVCTxq/tG2XzbEQTfqsIdzqCVXxsVEs1vPdekSFzSd+nEiWibbLb8SmiWEt Avig== X-Gm-Message-State: AFuF++lq30aRgZZQczWbhsIXTUlSWq0zXnnUjcyPn8k7eChfXQ377P4I Jjf7ug0xuUZ3w8BfAGC1KR0Z1XmBYZXKgtKQ6kh1xor6tb/3qYieLV7eHVwJ1k/98Z96otQ4tNO UIAVewwIGxaYVkRTEUuJabZcqxlEK99AMLI8TK/8soEmw7yvcVrLgH7fl5JcG+u4Av7trBK2Etu G20jUmbOLNhX7BfED17HFSiwYhN+59CfOOWA== X-Gm-Gg: AYBFou1zkLwXQMD0itdU923YBvE1VEwDfy96jdTi1wUHoVT4E3tp1xSTa7a2bCPKLPL rDufp9a7p+LFVTbZKAQMa+FGHsDwcaknMWc/DRaGuP7ZCj8L6gB9jOw2LVvrmU/cgPGwHIJv0um drHpACcLxdxmGyNnWgBwHg6a+d3g1X2lOv5qyfsG1X87VCAEwoNGuRAB++ciz11ZB1YtqrQJvU3 DsFG6cLdSA7bQ3gqyknIriOFQtnlgbCVYZ+g/Hsy/qhaQ9ClbSmBDkd1GQPGZK+rZ0SoB7aGUaz bzGv1231ZgSM39T7ZbC3LkV7uMdYGHNJSvxru37Oe9gAef7a3rjRkXkmLYZjt7I7emo/nYOog1v 4EKu96VV8Jnb9dGr2mp4Is1Q= X-Received: by 2002:a05:600c:3513:b0:49d:28c4:b304 with SMTP id 5b1f17b1804b1-49e619d479emr7365715e9.29.1789071320838; Thu, 10 Sep 2026 13:15:20 -0700 (PDT) X-Received: by 2002:a05:600c:3513:b0:49d:28c4:b304 with SMTP id 5b1f17b1804b1-49e619d479emr7365155e9.29.1789071320262; Thu, 10 Sep 2026 13:15:20 -0700 (PDT) Date: Thu, 10 Sep 2026 16:15:17 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Philippe =?utf-8?Q?Mathieu-Daud=C3=A9?= , David Hildenbrand , Cornelia Huck , Halil Pasic , Eric Farman , Christian Borntraeger , Matthew Rosato , Richard Henderson , Ilya Leoshkevich , Paolo Bonzini , Daniel =?utf-8?B?UC4gQmVycmFuZ8Op?= , qemu-s390x@nongnu.org Subject: [PULL 78/90] hw/hotplug: Mark various HotplugHandlerClass variables as const Message-ID: <3a9648b103b09ee9abbb680f7d07e32f05bd9290.1789071043.git.mst@redhat.com> References: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Disposition: inline Content-Transfer-Encoding: quoted-printable In-Reply-To: X-Mailer: git-send-email 2.51.2.2891.g4157995a80.dirty X-Mutt-Fcc: =sent 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=170.10.129.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com 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, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=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-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-Zoho-Virus-Status: 1 X-Zoho-AV-Stamp: zmail-av-0.2.13.1.5.4/289.52.80 X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1789075236829158500 From: Philippe Mathieu-Daud=C3=A9 The HotplugHandlerClass pointers are only dereferenced, not updated. Signed-off-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin Message-ID: <20260903230245.65601-3-philmd@oss.qualcomm.com> --- include/hw/core/qdev.h | 2 +- hw/core/hotplug.c | 8 ++++---- hw/s390x/virtio-ccw-md.c | 2 +- hw/virtio/virtio-md-pci.c | 2 +- system/qdev-monitor.c | 2 +- 5 files changed, 8 insertions(+), 8 deletions(-) diff --git a/include/hw/core/qdev.h b/include/hw/core/qdev.h index f054a214fc..e4cb027ab3 100644 --- a/include/hw/core/qdev.h +++ b/include/hw/core/qdev.h @@ -1069,7 +1069,7 @@ static inline bool qbus_is_hotpluggable(BusState *bus) bool ret =3D !!plug_handler; =20 if (plug_handler) { - HotplugHandlerClass *hdc; + const HotplugHandlerClass *hdc; =20 hdc =3D HOTPLUG_HANDLER_GET_CLASS(plug_handler); if (hdc->is_hotpluggable_bus) { diff --git a/hw/core/hotplug.c b/hw/core/hotplug.c index 68aabad8ae..00e80a67c8 100644 --- a/hw/core/hotplug.c +++ b/hw/core/hotplug.c @@ -17,7 +17,7 @@ void hotplug_handler_pre_plug(HotplugHandler *plug_handle= r, DeviceState *plugged_dev, Error **errp) { - HotplugHandlerClass *hdc =3D HOTPLUG_HANDLER_GET_CLASS(plug_handler); + const HotplugHandlerClass *hdc =3D HOTPLUG_HANDLER_GET_CLASS(plug_hand= ler); =20 if (hdc->pre_plug) { hdc->pre_plug(plug_handler, plugged_dev, errp); @@ -28,7 +28,7 @@ void hotplug_handler_plug(HotplugHandler *plug_handler, DeviceState *plugged_dev, Error **errp) { - HotplugHandlerClass *hdc =3D HOTPLUG_HANDLER_GET_CLASS(plug_handler); + const HotplugHandlerClass *hdc =3D HOTPLUG_HANDLER_GET_CLASS(plug_hand= ler); =20 if (hdc->plug) { hdc->plug(plug_handler, plugged_dev, errp); @@ -39,7 +39,7 @@ void hotplug_handler_unplug_request(HotplugHandler *plug_= handler, DeviceState *plugged_dev, Error **errp) { - HotplugHandlerClass *hdc =3D HOTPLUG_HANDLER_GET_CLASS(plug_handler); + const HotplugHandlerClass *hdc =3D HOTPLUG_HANDLER_GET_CLASS(plug_hand= ler); =20 if (hdc->unplug_request) { hdc->unplug_request(plug_handler, plugged_dev, errp); @@ -50,7 +50,7 @@ void hotplug_handler_unplug(HotplugHandler *plug_handler, DeviceState *plugged_dev, Error **errp) { - HotplugHandlerClass *hdc =3D HOTPLUG_HANDLER_GET_CLASS(plug_handler); + const HotplugHandlerClass *hdc =3D HOTPLUG_HANDLER_GET_CLASS(plug_hand= ler); =20 if (hdc->unplug) { hdc->unplug(plug_handler, plugged_dev, errp); diff --git a/hw/s390x/virtio-ccw-md.c b/hw/s390x/virtio-ccw-md.c index 0370f58450..0b18b49bc4 100644 --- a/hw/s390x/virtio-ccw-md.c +++ b/hw/s390x/virtio-ccw-md.c @@ -73,7 +73,7 @@ void virtio_ccw_md_unplug_request(VirtIOMDCcw *vmd, Machi= neState *ms, VirtIOMDCcwClass *vmdc =3D VIRTIO_MD_CCW_GET_CLASS(vmd); DeviceState *dev =3D DEVICE(vmd); HotplugHandler *bus_handler =3D qdev_get_bus_hotplug_handler(dev); - HotplugHandlerClass *hdc; + const HotplugHandlerClass *hdc; Error *local_err =3D NULL; =20 if (!vmdc->unplug_request_check) { diff --git a/hw/virtio/virtio-md-pci.c b/hw/virtio/virtio-md-pci.c index 9278b32cf8..aa5b11c0f6 100644 --- a/hw/virtio/virtio-md-pci.c +++ b/hw/virtio/virtio-md-pci.c @@ -72,7 +72,7 @@ void virtio_md_pci_unplug_request(VirtIOMDPCI *vmd, Machi= neState *ms, VirtIOMDPCIClass *vmdc =3D VIRTIO_MD_PCI_GET_CLASS(vmd); DeviceState *dev =3D DEVICE(vmd); HotplugHandler *bus_handler =3D qdev_get_bus_hotplug_handler(dev); - HotplugHandlerClass *hdc; + const HotplugHandlerClass *hdc; Error *local_err =3D NULL; =20 if (!vmdc->unplug_request_check) { diff --git a/system/qdev-monitor.c b/system/qdev-monitor.c index 5c87fda509..0c5502d45b 100644 --- a/system/qdev-monitor.c +++ b/system/qdev-monitor.c @@ -918,7 +918,7 @@ static DeviceState *find_device_state(const char *id, b= ool use_generic_error, void qdev_unplug(DeviceState *dev, Error **errp) { HotplugHandler *hotplug_ctrl; - HotplugHandlerClass *hdc; + const HotplugHandlerClass *hdc; Error *local_err =3D NULL; =20 if (!qdev_hotunplug_allowed(dev, errp)) { --=20 MST From nobody Sat Sep 26 20:50:17 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=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1789080872; cv=none; d=zohomail.com; s=zohoarc; b=cLmDP8OvHmLhJIPimlv/LqnqMmuTNZqn51yeuvZXyhlGrQp0BSIZQMWMzSWQbJko1IY0VsTduBTUvpFACdtGFyCmERr4FHDNOcCph//UpyOUjkPx3HGMZqqEId7DG+jNFLymLI5tAI/vC1Ms5TV1an3tyU5gC4MDtGYg0y56Ews= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1789080872; h=Content-Type: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=0xy/HYzVNQBnkK+frgobWoz0pO/IVcyKqhz4VJS2NJ0=; b=K5B2cTynlQlnvyp1huiGmgKICKejS9SX05RnYz8vW62FhwVTJujA0NygcKnq5bjxiiPuTaA2NYQBjSQjhUh1xQZ44deQIuvP2t1rNQsJMmoTj7het6ZEwesYKRgs2T3o5k1d1b+Nqu+/mIqEKQlBOEe3799Z6fIpD/rgRlgVIt4= 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 lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1789080872796242.7740853405985; Thu, 10 Sep 2026 15:54:32 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1x4nWS-0002aj-HN; Thu, 10 Sep 2026 18:45:44 -0400 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 1x4lLC-0002st-E7 for qemu-devel@nongnu.org; Thu, 10 Sep 2026 16:26:06 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1x4lL0-0008No-St for qemu-devel@nongnu.org; Thu, 10 Sep 2026 16:25:43 -0400 Received: from mail-wm1-f71.google.com (mail-wm1-f71.google.com [209.85.128.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-327-toXL85FKNHacrqzzYtqFew-1; Thu, 10 Sep 2026 16:15:24 -0400 Received: by mail-wm1-f71.google.com with SMTP id 5b1f17b1804b1-49991beee7aso1748705e9.2 for ; Thu, 10 Sep 2026 13:15:24 -0700 (PDT) Received: from redhat.com (IGLD-80-230-79-236.inter.net.il. [80.230.79.236]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-49e61a32803sm8333465e9.0.2026.09.10.13.15.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Sep 2026 13:15:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1789071699; 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=0xy/HYzVNQBnkK+frgobWoz0pO/IVcyKqhz4VJS2NJ0=; b=TeCsFlfHLdWHVABxxRq308SCh5F/Kyxgg/fISAKXOUEyJTdWlFJb8nYeAoUYWJzUyHVcB7 +3CHTnFVLnTsiGR/3+8cb6s8WGnp73O6ogKms/0qcHGPL2FyXKTmz40RiIEMAO33XfBl1C EQs3yfBvW0XQrqH8DylrsvX5QVuoFmo= X-MC-Unique: toXL85FKNHacrqzzYtqFew-1 X-Mimecast-MFC-AGG-ID: toXL85FKNHacrqzzYtqFew_1789071323 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=google; t=1789071323; x=1789676123; darn=nongnu.org; h=in-reply-to:content-transfer-encoding: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=0xy/HYzVNQBnkK+frgobWoz0pO/IVcyKqhz4VJS2NJ0=; b=nHttDi+IN1dJMShL6748HDrwnRk1kIuUmpLglp1wQzPJxDDl8KuUsgO6dVAjiPJFlx vMedhx+u1EDNwJKyoSPwtkPtZUCRNx+9wg0ouXt+fv7jSLczeniCBoRnIE2Yb5e9fww8 acEH7cP6bw+0WQ7xyFd2IuVnUUw8KBK1NXN1ssMSNuuYJth2dsdyoVkF3Hb3biTIZ/fn bbFk3jUkokKDfBHyOVtq1onlqtdGCsvYQo/3MaYyw48Gts02Rrds350lrq6QkxH8EeCU 6Jyn2k/rYpajmaSlDyW+wz78Ut+T3rVdGctvr8pEWLipBP7VdI4TrZuqn9r/1/0MJ+sH Bymw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1789071323; x=1789676123; h=in-reply-to:content-transfer-encoding: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=0xy/HYzVNQBnkK+frgobWoz0pO/IVcyKqhz4VJS2NJ0=; b=eV6WtgsK+F9IUMsXEmp4rWTow47d2QeJEGeUm4jf6pZi4gTKphc5oSDm6N5fQwheY3 kDp2Vs9HxNIRb1YewwlBXLAlRqG3LqqNuRfjGALfOhF0uYXy8lWCl5Uy+5eocNoA9ECB ABsE2LbKyeJhkVJVhSOzgFcssD0H/SGBhhG5JNWyMWYGZaGTcOPLfucMTYZw8zJgfD0s wthZhA5CZ7oHxTxpM9eaN17bL3HOJKO8rGW1ehyKY3xN2SinefgLfqKS0GKWXmqUcqil uoO2nX49sZeRIPMlnk+IQzTIkjDTOvSnW6IQnqGfU+Cz2imVW+c+NP2vbc5YRM9gJoDK jueg== X-Gm-Message-State: AFuF++kdKrP4LutfFL/3Rwi+eCJUYSuTJPODW57mA8wh3Ae5yDn6X7Bk lOc8LrrlemYj8LPAuVHYmWx4lqj5F4N96bk7/+ZuRcRSvBra/7YFaINVbw83oyOvG9mfEXDOCMu GIZLn/ED/t0sjAfiHnVVQAvJd1AVwbZC71i9Bq/m44ROSv7mF3y0dIDx/8Re7mc6PtpNkq2T4JN ANc1+syIUKZN4VIRD1exNFnuAghWktULGnbA== X-Gm-Gg: AYBFou2yxHRVA/Uc3G3San5cwmz/C1kPSLwnHDatj5vFoA9I2MB+a4fZyJ8Trai+wDQ UTiRmNQZdg6/9ksuQAB1L8mI7UYlMbt9jyDe6Fc6gkEt3612/hIR43MuF0bAxtVkN9Lrf+0CZY1 +68LjKXof+6YHdjRKDcQNcfp+nyz33EQiFx946jbh8LaFprGjYo8AuWvKv/Nn2ladk+cVDmMf3t B2rC2pBmB45A+GcYVVLE2Gmm3pD759OjPxC8DDKjn+TFxnV7fpQCCy0qybH8Imo8vNyUfWCVfPL DjiqdHUR/Kpu8hLJ62s2tbyXbVtdAc8m872OypMGITV7dXJcVOzeO/XLaY4XumXsnMcexTBKDw+ NL3F7HwgG6ZmMbqI4AmompII= X-Received: by 2002:a05:600c:4f8e:b0:49d:17d4:aff2 with SMTP id 5b1f17b1804b1-49e619a1c3bmr16401835e9.1.1789071323253; Thu, 10 Sep 2026 13:15:23 -0700 (PDT) X-Received: by 2002:a05:600c:4f8e:b0:49d:17d4:aff2 with SMTP id 5b1f17b1804b1-49e619a1c3bmr16400755e9.1.1789071322578; Thu, 10 Sep 2026 13:15:22 -0700 (PDT) Date: Thu, 10 Sep 2026 16:15:20 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Philippe =?utf-8?Q?Mathieu-Daud=C3=A9?= , Igor Mammedov , Ani Sinha Subject: [PULL 79/90] hw/hotplug: Reduce some HotplugHandler variables scope Message-ID: References: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Disposition: inline Content-Transfer-Encoding: quoted-printable In-Reply-To: X-Mailer: git-send-email 2.51.2.2891.g4157995a80.dirty X-Mutt-Fcc: =sent 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=170.10.129.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com 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, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=0.001, SPF_HELO_PASS=-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-Zoho-Virus-Status: 1 X-Zoho-AV-Stamp: zmail-av-0.2.13.1.5.4/289.74.40 X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1789080874469158500 From: Philippe Mathieu-Daud=C3=A9 Signed-off-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin Message-ID: <20260903230245.65601-4-philmd@oss.qualcomm.com> --- hw/acpi/memory_hotplug.c | 3 ++- hw/acpi/pcihp.c | 3 ++- hw/pci/shpc.c | 3 ++- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/hw/acpi/memory_hotplug.c b/hw/acpi/memory_hotplug.c index 1ddfdd17b7..f482c835a1 100644 --- a/hw/acpi/memory_hotplug.c +++ b/hw/acpi/memory_hotplug.c @@ -119,7 +119,6 @@ static void acpi_memory_hotplug_write(void *opaque, hwa= ddr addr, uint64_t data, MemStatus *mdev; ACPIOSTInfo *info; DeviceState *dev =3D NULL; - HotplugHandler *hotplug_ctrl =3D NULL; Error *local_err =3D NULL; =20 if (!mem_st->dev_count) { @@ -167,6 +166,8 @@ static void acpi_memory_hotplug_write(void *opaque, hwa= ddr addr, uint64_t data, mdev->is_removing =3D false; trace_mhp_acpi_clear_remove_evt(mem_st->selector); } else if (data & 8) { + HotplugHandler *hotplug_ctrl; + if (!mdev->is_enabled) { trace_mhp_acpi_ejecting_invalid_slot(mem_st->selector); break; diff --git a/hw/acpi/pcihp.c b/hw/acpi/pcihp.c index b26ddf0a26..336ebe1a13 100644 --- a/hw/acpi/pcihp.c +++ b/hw/acpi/pcihp.c @@ -173,7 +173,6 @@ static bool acpi_pcihp_pc_no_hotplug(AcpiPciHpState *s,= PCIDevice *dev) =20 static void acpi_pcihp_eject_slot(AcpiPciHpState *s, unsigned bsel, unsign= ed slots) { - HotplugHandler *hotplug_ctrl; BusChild *kid, *next; int slot =3D ctz32(slots); PCIBus *bus =3D acpi_pcihp_find_hotplug_bus(s, bsel); @@ -210,6 +209,8 @@ static void acpi_pcihp_eject_slot(AcpiPciHpState *s, un= signed bsel, unsigned slo */ qdev->pending_deleted_event =3D false; } else { + HotplugHandler *hotplug_ctrl; + hotplug_ctrl =3D qdev_get_hotplug_handler(qdev); hotplug_handler_unplug(hotplug_ctrl, qdev, &error_abor= t); object_unparent(OBJECT(qdev)); diff --git a/hw/pci/shpc.c b/hw/pci/shpc.c index 938602866d..1198e1ab8c 100644 --- a/hw/pci/shpc.c +++ b/hw/pci/shpc.c @@ -271,7 +271,6 @@ static void shpc_invalid_command(SHPCDevice *shpc) =20 static void shpc_free_devices_in_slot(SHPCDevice *shpc, int slot) { - HotplugHandler *hotplug_ctrl; int devfn; int pci_slot =3D SHPC_IDX_TO_PCI(slot); for (devfn =3D PCI_DEVFN(pci_slot, 0); @@ -279,6 +278,8 @@ static void shpc_free_devices_in_slot(SHPCDevice *shpc,= int slot) ++devfn) { PCIDevice *affected_dev =3D shpc->sec_bus->devices[devfn]; if (affected_dev) { + HotplugHandler *hotplug_ctrl; + hotplug_ctrl =3D qdev_get_hotplug_handler(DEVICE(affected_dev)= ); hotplug_handler_unplug(hotplug_ctrl, DEVICE(affected_dev), &error_abort); --=20 MST From nobody Sat Sep 26 20:50:17 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass(p=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1789071367; cv=none; d=zohomail.com; s=zohoarc; b=nmhAMeJGMmQznxMXnJqt+rOdLvxGuHsIKd+FiRiXE8HTGWzEl80QnPCBLeqJiHvIENvVIFtW8Q4DddCeqzu+d4MdpY7t0w66zG9ammgCex2G8XvUpjdYxVrqIqMDq9wIDzdQHiRz4srJBWpjTCDPwla6I3G9etziIyuB+Aezdyw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1789071367; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=wP5nj9MfiPsEKxjmqX6H5CG7YIoHYGFHlaBEBpbtyXc=; b=deISmr3Kl/R+t6NlnGQQO3V3xqhyTo7TDlfN6skmi36qVYuDWodPGqzeLTF2rewiMwLq/WSlTGfo0Xn0ScoYqZKxt/EMu1TvLCkpzCxtTBcHoXniBmYGtNXOMKJPxPUHCLo56++tt9MagFt65ABQGenLGfRkvR5XCMgBE5Za+Ms= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1789071367153591.4523952111839; Thu, 10 Sep 2026 13:16:07 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.1415329.1644777 (Exim 4.92) (envelope-from ) id 1x4lBN-0005EL-8H; Thu, 10 Sep 2026 20:15:41 +0000 Received: by outflank-mailman (output) from mailman id 1415329.1644777; Thu, 10 Sep 2026 20:15:41 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1x4lBN-0005EE-4q; Thu, 10 Sep 2026 20:15:41 +0000 Received: by outflank-mailman (input) for mailman id 1415329; Thu, 10 Sep 2026 20:15:39 +0000 Received: from mx.expurgate.net ([195.190.135.10]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1x4lBL-0005E7-2u for xen-devel@lists.xenproject.org; Thu, 10 Sep 2026 20:15:39 +0000 Received: from mx.expurgate.net (helo=localhost) by mx.expurgate.net with esmtp id 1x4lBK-0077Pl-FH for xen-devel@lists.xenproject.org; Thu, 10 Sep 2026 22:15:38 +0200 Received: from [10.42.69.9] (helo=localhost) by localhost with ESMTP (eXpurgate MTA 0.9.1) (envelope-from ) id 6aa30fc2-bab6-0a2a0a5309dd-0a2a4509d31e-14 for ; Thu, 10 Sep 2026 22:15:38 +0200 Received: from [170.10.133.124] (helo=us-smtp-delivery-124.mimecast.com) by tlsNG-bad1c0.mxtls.expurgate.net with ESMTPS (eXpurgate 4.57.1) (envelope-from ) id 6aa30fe8-be1a-0a2a45090019-aa0a857cbf0f-3 for ; Thu, 10 Sep 2026 22:15:37 +0200 Received: from mail-wr1-f72.google.com (mail-wr1-f72.google.com [209.85.221.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-66-MbfP3QVtP0mvqdAWzkTH3g-1; Thu, 10 Sep 2026 16:15:33 -0400 Received: by mail-wr1-f72.google.com with SMTP id ffacd0b85a97d-48437090e74so62084f8f.2 for ; Thu, 10 Sep 2026 13:15:33 -0700 (PDT) Received: from redhat.com (IGLD-80-230-79-236.inter.net.il. [80.230.79.236]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-49e62217965sm1215825e9.2.2026.09.10.13.15.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Sep 2026 13:15:28 -0700 (PDT) X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" Authentication-Results: eu.smtp.expurgate.cloud; dkim=pass header.s=mimecast20190719 header.d=redhat.com header.i="@redhat.com" header.h="From:Subject:Date:Message-ID:To:Cc:MIME-Version:Content-Type:Content-Transfer-Encoding:In-Reply-To:References" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1789071336; 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=wP5nj9MfiPsEKxjmqX6H5CG7YIoHYGFHlaBEBpbtyXc=; b=Zaaw0cJjGWeRGig9OMn4rVdgmPgzfXruLb7ueS6AsdRNDMJZOAkRJwFmCJAZdyEesw6oYf NIy8shGeoqzPaBHDA4ZZhipsHYXt849p+M94/G3gLM8+qbsOj3qXs8K0JmdXzA3C1D4gnX KfxabPDqkhP/IcORolueGV4LxbFeT3I= X-MC-Unique: MbfP3QVtP0mvqdAWzkTH3g-1 X-Mimecast-MFC-AGG-ID: MbfP3QVtP0mvqdAWzkTH3g_1789071332 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1789071332; x=1789676132; h=in-reply-to:content-transfer-encoding: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=wP5nj9MfiPsEKxjmqX6H5CG7YIoHYGFHlaBEBpbtyXc=; b=Ki/55c8tCZgvUBSDeVTldmU8G0zlleftvoRCmlgCIVEqc/aK56tTZSlayjgv/ZOZ+n GaFkdbrrR3D0dsY7NiG3nqsmIPntoxxrUy4/odSZGmtMJEzioXM2ZhavFSCfpSGZCaF/ buNMiQ0UZnqJ13qcfI1KQSxN0N5KE//eBCTx8O9uoGazg6Buarw9rf5yHOqOLcYg4uf4 OlaaeYB3J+2n1Pou+gBpFMyi2haO1qpAtZQ5ES8j2XoJoawxaTGBgKWWg0pwcKlzcmQJ YHle8h8tYNQ083OC0Bc1dHHLHBIBNZbsBNZeWHYhiTXdBYt3MannFWvTyTRCVFVsm1Wa fmHg== X-Forwarded-Encrypted: i=1; AKwUvBxiIdOHpx6+nwygV1IWdGyQnKHdSa9Ms5ZMI00uwueBGfh9Pa8i1sBIfSFkRMA5so9OlBCTBNYXENc=@lists.xenproject.org X-Gm-Message-State: AFuF++llCBnwhl15pAckx+edNAIxC1xEfc5sS0WfNylGMuMk/we4eHkp LyJD/bbcHr3fhAU+ST+B/J4Ut5Mb7Era7xBqTYQmOW4LhSCZo9jEap5Q6+ytuwPFXjDa51aTehS 0u2UmAvWRyOgWw8GvUgTNs9ABq+Z0yp6l4jInewnn1Hi/VYRA3zQG+UH+gmHfBpARSPVW X-Gm-Gg: AYBFou0tmy7DtErVbykDwqPNsA8H8c6kP6+4IcSgrCsr6mYR+R1zrXE7EP3/IbvmhyU 3BsROmTgU1BcBZEwOUbBYKcVdfj2/H/iAg0mXaHoqXRE1KSzan4qn7kE5qgmG4TYlpQRDb5iPhi 76jnpFmfcX6Bl8t1tei8gs30nq5wqm98YnbmqXE/O0RX4B3chDkV0LanH/QirVc4BftKq1XPMgi Q2JfD+lxJoHBF1Az79jW282W7YR6nBmyES4dBTORwZhzkeRlTv1UiV73wvJzGT5IcgcSWgl0o90 7RhfrWLXODV4rU+y7D3bhJ6x0OLiRAkTS+Flg1qFRrvaFHjcswWf2AxsEbwfck4CPy2EkUrp93J X7/J/vQL/MdtKyAT01SoioM4= X-Received: by 2002:a05:600d:444c:20b0:49b:96a0:5c00 with SMTP id 5b1f17b1804b1-49e6198d09bmr6064815e9.13.1789071330796; Thu, 10 Sep 2026 13:15:30 -0700 (PDT) X-Received: by 2002:a05:600d:444c:20b0:49b:96a0:5c00 with SMTP id 5b1f17b1804b1-49e6198d09bmr6064085e9.13.1789071329779; Thu, 10 Sep 2026 13:15:29 -0700 (PDT) Date: Thu, 10 Sep 2026 16:15:22 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Philippe =?utf-8?Q?Mathieu-Daud=C3=A9?= , Igor Mammedov , Ani Sinha , Aurelien Jarno , Laurent Vivier , Amit Shah , =?utf-8?Q?Marc-Andr=C3=A9?= Lureau , Paolo Bonzini , Daniel =?utf-8?B?UC4gQmVycmFuZ8Op?= , Sergio Lopez , Richard Henderson , Song Gao <17746591750@163.com>, Bibo Mao , Xianglai Li , Jiaxun Yang , Jason Wang , Keith Busch , Klaus Jensen , Jesper Devantier , Bernhard Beschow , Nicholas Piggin , Harsh Prateek Bora , Amit Machhiwal , Elena Ufimtseva , Jagannathan Raman , Palmer Dabbelt , Alistair Francis , Weiwei Li , Daniel Henrique Barboza , Liu Zhiwei , Chao Liu , Halil Pasic , Christian Borntraeger , Eric Farman , Farhan Ali , Matthew Rosato , Cornelia Huck , Ilya Leoshkevich , David Hildenbrand , Fam Zheng , Dmitry Fleytman , Stefano Stabellini , Anthony PERARD , "Edgar E. Iglesias" , Zhao Liu , FangSheng Huang , qemu-arm@nongnu.org, qemu-block@nongnu.org, qemu-ppc@nongnu.org, qemu-riscv@nongnu.org, qemu-s390x@nongnu.org, xen-devel@lists.xenproject.org Subject: [PULL 80/90] hw/hotplug: Constify HotplugHandler Message-ID: <621ba41b05516e9d08e9593ce8689b7ec569491f.1789071043.git.mst@redhat.com> References: MIME-Version: 1.0 In-Reply-To: X-Mailer: git-send-email 2.51.2.2891.g4157995a80.dirty X-Mutt-Fcc: =sent X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: moTAKNc71FWIURw2-uFr09J51WruIIY30HAp5KFFTfU_1789071332 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" Content-Disposition: inline Content-Transfer-Encoding: quoted-printable X-purgate-ID: tlsNG-bad1c0/1789071338-BF4D3394-79467E9F/0/0 X-purgate-type: clean X-purgate-size: 99091 X-Zoho-Virus-Status: 1 X-Zoho-AV-Stamp: zmail-av-0.2.13.1.5.4/289.52.80 X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1789071368625158500 From: Philippe Mathieu-Daud=C3=A9 HotplugHandler value returned from qdev_get_hotplug_handler() points to the handler of and object implementing the TYPE_HOTPLUG_HANDLER interface. That handler mostly points to read-only section which shouldn't not be updated. Better protect it with the const qualifier. Mechanical change using 'sed' then manually adapted coding style. Signed-off-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin Message-ID: <20260903230245.65601-5-philmd@oss.qualcomm.com> --- hw/s390x/ccw-device.h | 2 +- include/hw/acpi/cpu.h | 4 +-- include/hw/acpi/cpu_hotplug.h | 2 +- include/hw/acpi/generic_event_device.h | 3 +- include/hw/acpi/ich9.h | 10 +++--- include/hw/acpi/memory_hotplug.h | 4 +-- include/hw/acpi/pcihp.h | 8 ++--- include/hw/core/boards.h | 4 +-- include/hw/core/hotplug.h | 13 +++---- include/hw/core/qdev.h | 12 +++---- include/hw/i386/microvm.h | 4 +-- include/hw/i386/x86.h | 10 +++--- include/hw/mem/nvdimm.h | 2 +- include/hw/pci/pci_bridge.h | 6 ++-- include/hw/pci/pcie.h | 8 ++--- include/hw/pci/shpc.h | 6 ++-- include/hw/ppc/spapr_nvdimm.h | 2 +- hw/acpi/acpi-cpu-hotplug-stub.c | 4 +-- hw/acpi/acpi-mem-hotplug-stub.c | 4 +-- hw/acpi/acpi-nvdimm-stub.c | 2 +- hw/acpi/acpi-pci-hotplug-stub.c | 8 ++--- hw/acpi/cpu.c | 6 ++-- hw/acpi/generic_event_device.c | 11 +++--- hw/acpi/ich9.c | 10 +++--- hw/acpi/memory_hotplug.c | 6 ++-- hw/acpi/nvdimm.c | 2 +- hw/acpi/pcihp.c | 10 +++--- hw/acpi/piix4.c | 12 +++---- hw/arm/virt.c | 23 ++++++------ hw/char/virtio-serial-bus.c | 2 +- hw/core/hotplug.c | 8 ++--- hw/core/qdev-hotplug.c | 10 +++--- hw/core/qdev.c | 2 +- hw/i386/microvm.c | 12 +++---- hw/i386/pc.c | 28 +++++++-------- hw/i386/x86-common.c | 8 ++--- hw/intc/loongarch_dintc.c | 8 ++--- hw/intc/loongarch_extioi_common.c | 4 +-- hw/intc/loongarch_ipi.c | 4 +-- hw/loongarch/virt.c | 44 +++++++++++------------ hw/net/virtio-net.c | 4 +-- hw/nvme/ctrl.c | 8 ++--- hw/pci-bridge/pci_bridge_dev.c | 6 ++-- hw/pci/pcie.c | 10 +++--- hw/pci/pcie_port.c | 2 +- hw/pci/shpc.c | 10 +++--- hw/ppc/e500plat.c | 4 +-- hw/ppc/spapr.c | 48 +++++++++++++------------- hw/ppc/spapr_nvdimm.c | 2 +- hw/ppc/spapr_pci.c | 12 +++---- hw/remote/machine.c | 2 +- hw/riscv/virt.c | 6 ++-- hw/s390x/css-bridge.c | 2 +- hw/s390x/s390-pci-bus.c | 12 +++---- hw/s390x/s390-virtio-ccw.c | 16 ++++----- hw/s390x/virtio-ccw-md.c | 8 ++--- hw/s390x/virtio-ccw.c | 2 +- hw/scsi/virtio-scsi.c | 6 ++-- hw/scsi/vmw_pvscsi.c | 4 +-- hw/virtio/virtio-md-pci.c | 8 ++--- hw/xen/xen-bus.c | 2 +- stubs/hotplug-stubs.c | 6 ++-- system/qdev-monitor.c | 2 +- 63 files changed, 257 insertions(+), 253 deletions(-) diff --git a/hw/s390x/ccw-device.h b/hw/s390x/ccw-device.h index 15f64cfb63..c303f1de42 100644 --- a/hw/s390x/ccw-device.h +++ b/hw/s390x/ccw-device.h @@ -37,7 +37,7 @@ extern const VMStateDescription vmstate_ccw_dev; =20 struct CCWDeviceClass { DeviceClass parent_class; - void (*unplug)(HotplugHandler *, DeviceState *, Error **); + void (*unplug)(const HotplugHandler *, DeviceState *, Error **); bool (*realize)(CcwDevice *, Error **); void (*refill_ids)(CcwDevice *); }; diff --git a/include/hw/acpi/cpu.h b/include/hw/acpi/cpu.h index 04c821d2b9..3664ac7a52 100644 --- a/include/hw/acpi/cpu.h +++ b/include/hw/acpi/cpu.h @@ -39,10 +39,10 @@ typedef struct CPUHotplugState { AcpiCpuStatus *devs; } CPUHotplugState; =20 -void acpi_cpu_plug_cb(HotplugHandler *hotplug_dev, +void acpi_cpu_plug_cb(const HotplugHandler *hotplug_dev, CPUHotplugState *cpu_st, DeviceState *dev, Error **e= rrp); =20 -void acpi_cpu_unplug_request_cb(HotplugHandler *hotplug_dev, +void acpi_cpu_unplug_request_cb(const HotplugHandler *hotplug_dev, CPUHotplugState *cpu_st, DeviceState *dev, Error **errp); =20 diff --git a/include/hw/acpi/cpu_hotplug.h b/include/hw/acpi/cpu_hotplug.h index 5b670b04eb..bac40ccfa0 100644 --- a/include/hw/acpi/cpu_hotplug.h +++ b/include/hw/acpi/cpu_hotplug.h @@ -25,7 +25,7 @@ typedef struct AcpiCpuHotplug { uint8_t sts[ACPI_GPE_PROC_LEN]; } AcpiCpuHotplug; =20 -void legacy_acpi_cpu_plug_cb(HotplugHandler *hotplug_dev, +void legacy_acpi_cpu_plug_cb(const HotplugHandler *hotplug_dev, AcpiCpuHotplug *g, DeviceState *dev, Error **= errp); =20 void legacy_acpi_cpu_hotplug_init(MemoryRegion *parent, Object *owner, diff --git a/include/hw/acpi/generic_event_device.h b/include/hw/acpi/gener= ic_event_device.h index 7cbfb5fe7d..42a8033a23 100644 --- a/include/hw/acpi/generic_event_device.h +++ b/include/hw/acpi/generic_event_device.h @@ -136,7 +136,8 @@ typedef struct AcpiGedClass { ResettablePhases parent_phases; } AcpiGedClass; =20 -void build_ged_aml(Aml *table, const char* name, HotplugHandler *hotplug_d= ev, +void build_ged_aml(Aml *table, const char *name, + const HotplugHandler *hotplug_dev, uint32_t ged_irq, AmlRegionSpace rs, hwaddr ged_base); void acpi_dsdt_add_power_button(Aml *scope); =20 diff --git a/include/hw/acpi/ich9.h b/include/hw/acpi/ich9.h index 6d14544751..6956b2b9c9 100644 --- a/include/hw/acpi/ich9.h +++ b/include/hw/acpi/ich9.h @@ -85,15 +85,15 @@ void ich9_pm_reset_properties(ICH9LPCPMRegs *pm); =20 void ich9_pm_add_class_properties(ObjectClass *oc, ptrdiff_t pm_offset); =20 -void ich9_pm_device_pre_plug_cb(HotplugHandler *hotplug_dev, DeviceState *= dev, +void ich9_pm_device_pre_plug_cb(const HotplugHandler *hotplug_dev, DeviceS= tate *dev, Error **errp); -void ich9_pm_device_plug_cb(HotplugHandler *hotplug_dev, DeviceState *dev, +void ich9_pm_device_plug_cb(const HotplugHandler *hotplug_dev, DeviceState= *dev, Error **errp); -void ich9_pm_device_unplug_request_cb(HotplugHandler *hotplug_dev, +void ich9_pm_device_unplug_request_cb(const HotplugHandler *hotplug_dev, DeviceState *dev, Error **errp); -void ich9_pm_device_unplug_cb(HotplugHandler *hotplug_dev, DeviceState *de= v, +void ich9_pm_device_unplug_cb(const HotplugHandler *hotplug_dev, DeviceSta= te *dev, Error **errp); -bool ich9_pm_is_hotpluggable_bus(HotplugHandler *hotplug_dev, BusState *bu= s); +bool ich9_pm_is_hotpluggable_bus(const HotplugHandler *hotplug_dev, BusSta= te *bus); =20 void ich9_pm_ospm_status(AcpiDeviceIf *adev, ACPIOSTInfoList ***list); #endif /* HW_ACPI_ICH9_H */ diff --git a/include/hw/acpi/memory_hotplug.h b/include/hw/acpi/memory_hotp= lug.h index eb7f460afe..6e4f82bcf9 100644 --- a/include/hw/acpi/memory_hotplug.h +++ b/include/hw/acpi/memory_hotplug.h @@ -36,9 +36,9 @@ typedef struct MemHotplugState { void acpi_memory_hotplug_init(MemoryRegion *as, Object *owner, MemHotplugState *state, hwaddr io_base); =20 -void acpi_memory_plug_cb(HotplugHandler *hotplug_dev, MemHotplugState *mem= _st, +void acpi_memory_plug_cb(const HotplugHandler *hotplug_dev, MemHotplugStat= e *mem_st, DeviceState *dev, Error **errp); -void acpi_memory_unplug_request_cb(HotplugHandler *hotplug_dev, +void acpi_memory_unplug_request_cb(const HotplugHandler *hotplug_dev, MemHotplugState *mem_st, DeviceState *dev, Error **errp); void acpi_memory_unplug_cb(MemHotplugState *mem_st, diff --git a/include/hw/acpi/pcihp.h b/include/hw/acpi/pcihp.h index efce5fd2e1..21c0b72355 100644 --- a/include/hw/acpi/pcihp.h +++ b/include/hw/acpi/pcihp.h @@ -66,13 +66,13 @@ void acpi_pcihp_init(Object *owner, AcpiPciHpState *, MemoryRegion *io, uint16_t io_base); =20 bool acpi_pcihp_is_hotpluggable_bus(AcpiPciHpState *s, BusState *bus); -void acpi_pcihp_device_pre_plug_cb(HotplugHandler *hotplug_dev, +void acpi_pcihp_device_pre_plug_cb(const HotplugHandler *hotplug_dev, DeviceState *dev, Error **errp); -void acpi_pcihp_device_plug_cb(HotplugHandler *hotplug_dev, AcpiPciHpState= *s, +void acpi_pcihp_device_plug_cb(const HotplugHandler *hotplug_dev, AcpiPciH= pState *s, DeviceState *dev, Error **errp); -void acpi_pcihp_device_unplug_cb(HotplugHandler *hotplug_dev, AcpiPciHpSta= te *s, +void acpi_pcihp_device_unplug_cb(const HotplugHandler *hotplug_dev, AcpiPc= iHpState *s, DeviceState *dev, Error **errp); -void acpi_pcihp_device_unplug_request_cb(HotplugHandler *hotplug_dev, +void acpi_pcihp_device_unplug_request_cb(const HotplugHandler *hotplug_dev, AcpiPciHpState *s, DeviceState *d= ev, Error **errp); =20 diff --git a/include/hw/core/boards.h b/include/hw/core/boards.h index a436d48c8e..dba465efc2 100644 --- a/include/hw/core/boards.h +++ b/include/hw/core/boards.h @@ -322,8 +322,8 @@ struct MachineClass { SMPCompatProps smp_props; const char *default_ram_id; =20 - HotplugHandler *(*get_hotplug_handler)(MachineState *machine, - DeviceState *dev); + const HotplugHandler *(*get_hotplug_handler)(MachineState *machine, + DeviceState *dev); bool (*hotplug_allowed)(MachineState *state, DeviceState *dev, Error **errp); CpuInstanceProperties (*cpu_index_to_instance_props)(MachineState *mac= hine, diff --git a/include/hw/core/hotplug.h b/include/hw/core/hotplug.h index a9840ed485..0c69be60ee 100644 --- a/include/hw/core/hotplug.h +++ b/include/hw/core/hotplug.h @@ -30,7 +30,7 @@ typedef struct HotplugHandler HotplugHandler; * @plugged_dev: a device that has been (un)plugged * @errp: returns an error if this function fails */ -typedef void (*hotplug_fn)(HotplugHandler *plug_handler, +typedef void (*hotplug_fn)(const HotplugHandler *plug_handler, DeviceState *plugged_dev, Error **errp); =20 /** @@ -59,7 +59,8 @@ struct HotplugHandlerClass { hotplug_fn plug; hotplug_fn unplug_request; hotplug_fn unplug; - bool (*is_hotpluggable_bus)(HotplugHandler *plug_handler, BusState *bu= s); + bool (*is_hotpluggable_bus)(const HotplugHandler *plug_handler, + BusState *bus); }; =20 /** @@ -67,7 +68,7 @@ struct HotplugHandlerClass { * * Call #HotplugHandlerClass.plug callback of @plug_handler. */ -void hotplug_handler_plug(HotplugHandler *plug_handler, +void hotplug_handler_plug(const HotplugHandler *plug_handler, DeviceState *plugged_dev, Error **errp); =20 @@ -76,7 +77,7 @@ void hotplug_handler_plug(HotplugHandler *plug_handler, * * Call #HotplugHandlerClass.pre_plug callback of @plug_handler. */ -void hotplug_handler_pre_plug(HotplugHandler *plug_handler, +void hotplug_handler_pre_plug(const HotplugHandler *plug_handler, DeviceState *plugged_dev, Error **errp); =20 @@ -85,7 +86,7 @@ void hotplug_handler_pre_plug(HotplugHandler *plug_handle= r, * * Calls #HotplugHandlerClass.unplug_request callback of @plug_handler. */ -void hotplug_handler_unplug_request(HotplugHandler *plug_handler, +void hotplug_handler_unplug_request(const HotplugHandler *plug_handler, DeviceState *plugged_dev, Error **errp); /** @@ -93,7 +94,7 @@ void hotplug_handler_unplug_request(HotplugHandler *plug_= handler, * * Calls #HotplugHandlerClass.unplug callback of @plug_handler. */ -void hotplug_handler_unplug(HotplugHandler *plug_handler, +void hotplug_handler_unplug(const HotplugHandler *plug_handler, DeviceState *plugged_dev, Error **errp); #endif diff --git a/include/hw/core/qdev.h b/include/hw/core/qdev.h index e4cb027ab3..1f6bf3fc1a 100644 --- a/include/hw/core/qdev.h +++ b/include/hw/core/qdev.h @@ -386,7 +386,7 @@ struct BusState { /* public: */ DeviceState *parent; char *name; - HotplugHandler *hotplug_handler; + const HotplugHandler *hotplug_handler; int max_index; bool realized; bool full; @@ -514,8 +514,8 @@ bool qdev_realize_and_unref(DeviceState *dev, BusState = *bus, Error **errp); void qdev_unrealize(DeviceState *dev); void qdev_set_legacy_instance_id(DeviceState *dev, int alias_id, int required_for_version); -HotplugHandler *qdev_get_bus_hotplug_handler(DeviceState *dev); -HotplugHandler *qdev_get_machine_hotplug_handler(DeviceState *dev); +const HotplugHandler *qdev_get_bus_hotplug_handler(DeviceState *dev); +const HotplugHandler *qdev_get_machine_hotplug_handler(DeviceState *dev); bool qdev_hotplug_allowed(DeviceState *dev, BusState *bus, Error **errp); bool qdev_hotunplug_allowed(DeviceState *dev, Error **errp); =20 @@ -529,10 +529,10 @@ bool qdev_hotunplug_allowed(DeviceState *dev, Error *= *errp); * Return: pointer to object that implements TYPE_HOTPLUG_HANDLER interface * or NULL if there aren't any. */ -HotplugHandler *qdev_get_hotplug_handler(DeviceState *dev); +const HotplugHandler *qdev_get_hotplug_handler(DeviceState *dev); void qdev_unplug(DeviceState *dev, Error **errp); int qdev_sync_config(DeviceState *dev, Error **errp); -void qdev_simple_device_unplug_cb(HotplugHandler *hotplug_dev, +void qdev_simple_device_unplug_cb(const HotplugHandler *hotplug_dev, DeviceState *dev, Error **errp); void qdev_machine_creation_done(void); bool qdev_machine_modified(void); @@ -1065,7 +1065,7 @@ void qbus_set_bus_hotplug_handler(BusState *bus); =20 static inline bool qbus_is_hotpluggable(BusState *bus) { - HotplugHandler *plug_handler =3D bus->hotplug_handler; + const HotplugHandler *plug_handler =3D bus->hotplug_handler; bool ret =3D !!plug_handler; =20 if (plug_handler) { diff --git a/include/hw/i386/microvm.h b/include/hw/i386/microvm.h index 184b7a8c09..5d5eacd1c6 100644 --- a/include/hw/i386/microvm.h +++ b/include/hw/i386/microvm.h @@ -76,8 +76,8 @@ =20 struct MicrovmMachineClass { X86MachineClass parent; - HotplugHandler *(*orig_hotplug_handler)(MachineState *machine, - DeviceState *dev); + const HotplugHandler *(*orig_hotplug_handler)(MachineState *machine, + DeviceState *dev); void (*x86_load_linux)(X86MachineState *x86ms, FWCfgState *fw_cfg, int acpi_data_size); }; diff --git a/include/hw/i386/x86.h b/include/hw/i386/x86.h index 71fe6b5e12..abb073ca47 100644 --- a/include/hw/i386/x86.h +++ b/include/hw/i386/x86.h @@ -46,7 +46,7 @@ struct X86MachineState { qemu_irq *gsi; DeviceState *ioapic2; GMappedFile *initrd_mapped_file; - HotplugHandler *acpi_dev; + const HotplugHandler *acpi_dev; =20 /* * Map the whole BIOS just underneath the 4 GiB address boundary. Only= used @@ -112,13 +112,13 @@ uint32_t x86_cpu_apic_id_from_index(X86MachineState *= x86ms, =20 void x86_cpus_init(X86MachineState *pcms, int default_cpu_version); void x86_rtc_set_cpus_count(ISADevice *rtc, uint16_t cpus_count); -void x86_cpu_pre_plug(HotplugHandler *hotplug_dev, +void x86_cpu_pre_plug(const HotplugHandler *hotplug_dev, DeviceState *dev, Error **errp); -void x86_cpu_plug(HotplugHandler *hotplug_dev, +void x86_cpu_plug(const HotplugHandler *hotplug_dev, DeviceState *dev, Error **errp); -void x86_cpu_unplug_request_cb(HotplugHandler *hotplug_dev, +void x86_cpu_unplug_request_cb(const HotplugHandler *hotplug_dev, DeviceState *dev, Error **errp); -void x86_cpu_unplug_cb(HotplugHandler *hotplug_dev, +void x86_cpu_unplug_cb(const HotplugHandler *hotplug_dev, DeviceState *dev, Error **errp); =20 void x86_isa_bios_init(MemoryRegion *isa_bios, MemoryRegion *isa_memory, diff --git a/include/hw/mem/nvdimm.h b/include/hw/mem/nvdimm.h index d3b763453a..169a943e3c 100644 --- a/include/hw/mem/nvdimm.h +++ b/include/hw/mem/nvdimm.h @@ -157,5 +157,5 @@ void nvdimm_build_acpi(GArray *table_offsets, GArray *t= able_data, uint32_t ram_slots, const char *oem_id, const char *oem_table_id); void nvdimm_plug(NVDIMMState *state); -void nvdimm_acpi_plug_cb(HotplugHandler *hotplug_dev, DeviceState *dev); +void nvdimm_acpi_plug_cb(const HotplugHandler *hotplug_dev, DeviceState *d= ev); #endif diff --git a/include/hw/pci/pci_bridge.h b/include/hw/pci/pci_bridge.h index b61360b900..f114f0a651 100644 --- a/include/hw/pci/pci_bridge.h +++ b/include/hw/pci/pci_bridge.h @@ -141,11 +141,11 @@ void pci_bridge_reset(DeviceState *qdev); void pci_bridge_initfn(PCIDevice *pci_dev, const char *typename); void pci_bridge_exitfn(PCIDevice *pci_dev); =20 -void pci_bridge_dev_plug_cb(HotplugHandler *hotplug_dev, DeviceState *dev, +void pci_bridge_dev_plug_cb(const HotplugHandler *hotplug_dev, DeviceState= *dev, Error **errp); -void pci_bridge_dev_unplug_cb(HotplugHandler *hotplug_dev, DeviceState *de= v, +void pci_bridge_dev_unplug_cb(const HotplugHandler *hotplug_dev, DeviceSta= te *dev, Error **errp); -void pci_bridge_dev_unplug_request_cb(HotplugHandler *hotplug_dev, +void pci_bridge_dev_unplug_request_cb(const HotplugHandler *hotplug_dev, DeviceState *dev, Error **errp); =20 /* diff --git a/include/hw/pci/pcie.h b/include/hw/pci/pcie.h index 71ba94874b..ec25e7a7de 100644 --- a/include/hw/pci/pcie.h +++ b/include/hw/pci/pcie.h @@ -146,13 +146,13 @@ void pcie_ats_init(PCIDevice *dev, uint16_t offset, b= ool aligned); void pcie_cap_fill_link_ep_usp(PCIDevice *dev, PCIExpLinkWidth width, PCIExpLinkSpeed speed, bool flitmode); =20 -void pcie_cap_slot_pre_plug_cb(HotplugHandler *hotplug_dev, DeviceState *d= ev, +void pcie_cap_slot_pre_plug_cb(const HotplugHandler *hotplug_dev, DeviceSt= ate *dev, Error **errp); -void pcie_cap_slot_plug_cb(HotplugHandler *hotplug_dev, DeviceState *dev, +void pcie_cap_slot_plug_cb(const HotplugHandler *hotplug_dev, DeviceState = *dev, Error **errp); -void pcie_cap_slot_unplug_cb(HotplugHandler *hotplug_dev, DeviceState *dev, +void pcie_cap_slot_unplug_cb(const HotplugHandler *hotplug_dev, DeviceStat= e *dev, Error **errp); -void pcie_cap_slot_unplug_request_cb(HotplugHandler *hotplug_dev, +void pcie_cap_slot_unplug_request_cb(const HotplugHandler *hotplug_dev, DeviceState *dev, Error **errp); =20 void pcie_pasid_common_init(PCIDevice *dev, uint16_t offset, diff --git a/include/hw/pci/shpc.h b/include/hw/pci/shpc.h index fce5bdd3bc..67becb5c56 100644 --- a/include/hw/pci/shpc.h +++ b/include/hw/pci/shpc.h @@ -45,11 +45,11 @@ void shpc_free(PCIDevice *dev); void shpc_cap_write_config(PCIDevice *d, uint32_t addr, uint32_t val, int = len); =20 =20 -void shpc_device_plug_cb(HotplugHandler *hotplug_dev, DeviceState *dev, +void shpc_device_plug_cb(const HotplugHandler *hotplug_dev, DeviceState *d= ev, Error **errp); -void shpc_device_unplug_cb(HotplugHandler *hotplug_dev, DeviceState *dev, +void shpc_device_unplug_cb(const HotplugHandler *hotplug_dev, DeviceState = *dev, Error **errp); -void shpc_device_unplug_request_cb(HotplugHandler *hotplug_dev, +void shpc_device_unplug_request_cb(const HotplugHandler *hotplug_dev, DeviceState *dev, Error **errp); =20 extern const VMStateInfo shpc_vmstate_info; diff --git a/include/hw/ppc/spapr_nvdimm.h b/include/hw/ppc/spapr_nvdimm.h index e9436cb6ef..386da92042 100644 --- a/include/hw/ppc/spapr_nvdimm.h +++ b/include/hw/ppc/spapr_nvdimm.h @@ -18,7 +18,7 @@ typedef struct SpaprMachineState SpaprMachineState; int spapr_pmem_dt_populate(SpaprDrc *drc, SpaprMachineState *spapr, void *fdt, int *fdt_start_offset, Error **errp); void spapr_dt_persistent_memory(SpaprMachineState *spapr, void *fdt); -bool spapr_nvdimm_validate(HotplugHandler *hotplug_dev, NVDIMMDevice *nvdi= mm, +bool spapr_nvdimm_validate(const HotplugHandler *hotplug_dev, NVDIMMDevice= *nvdimm, uint64_t size, Error **errp); void spapr_add_nvdimm(DeviceState *dev, uint64_t slot); void spapr_nvdimm_finish_flushes(void); diff --git a/hw/acpi/acpi-cpu-hotplug-stub.c b/hw/acpi/acpi-cpu-hotplug-stu= b.c index 72c5f05f5c..2e05d7100b 100644 --- a/hw/acpi/acpi-cpu-hotplug-stub.c +++ b/hw/acpi/acpi-cpu-hotplug-stub.c @@ -14,7 +14,7 @@ void acpi_cpu_ospm_status(CPUHotplugState *cpu_st, ACPIOS= TInfoList ***list) { } =20 -void acpi_cpu_plug_cb(HotplugHandler *hotplug_dev, +void acpi_cpu_plug_cb(const HotplugHandler *hotplug_dev, CPUHotplugState *cpu_st, DeviceState *dev, Error **e= rrp) { } @@ -24,7 +24,7 @@ void acpi_cpu_unplug_cb(CPUHotplugState *cpu_st, { } =20 -void acpi_cpu_unplug_request_cb(HotplugHandler *hotplug_dev, +void acpi_cpu_unplug_request_cb(const HotplugHandler *hotplug_dev, CPUHotplugState *cpu_st, DeviceState *dev, Error **errp) { diff --git a/hw/acpi/acpi-mem-hotplug-stub.c b/hw/acpi/acpi-mem-hotplug-stu= b.c index 7ad0fdcdf2..c218813fd1 100644 --- a/hw/acpi/acpi-mem-hotplug-stub.c +++ b/hw/acpi/acpi-mem-hotplug-stub.c @@ -13,7 +13,7 @@ void acpi_memory_ospm_status(MemHotplugState *mem_st, ACP= IOSTInfoList ***list) { } =20 -void acpi_memory_plug_cb(HotplugHandler *hotplug_dev, MemHotplugState *mem= _st, +void acpi_memory_plug_cb(const HotplugHandler *hotplug_dev, MemHotplugStat= e *mem_st, DeviceState *dev, Error **errp) { } @@ -23,7 +23,7 @@ void acpi_memory_unplug_cb(MemHotplugState *mem_st, { } =20 -void acpi_memory_unplug_request_cb(HotplugHandler *hotplug_dev, +void acpi_memory_unplug_request_cb(const HotplugHandler *hotplug_dev, MemHotplugState *mem_st, DeviceState *dev, Error **errp) { diff --git a/hw/acpi/acpi-nvdimm-stub.c b/hw/acpi/acpi-nvdimm-stub.c index 22ba17f511..0120bacaac 100644 --- a/hw/acpi/acpi-nvdimm-stub.c +++ b/hw/acpi/acpi-nvdimm-stub.c @@ -2,6 +2,6 @@ #include "hw/mem/nvdimm.h" #include "hw/core/hotplug.h" =20 -void nvdimm_acpi_plug_cb(HotplugHandler *hotplug_dev, DeviceState *dev) +void nvdimm_acpi_plug_cb(const HotplugHandler *hotplug_dev, DeviceState *d= ev) { } diff --git a/hw/acpi/acpi-pci-hotplug-stub.c b/hw/acpi/acpi-pci-hotplug-stu= b.c index d58ea726a8..20625c7ed7 100644 --- a/hw/acpi/acpi-pci-hotplug-stub.c +++ b/hw/acpi/acpi-pci-hotplug-stub.c @@ -9,22 +9,22 @@ void acpi_pcihp_init(Object *owner, AcpiPciHpState *s, { } =20 -void acpi_pcihp_device_plug_cb(HotplugHandler *hotplug_dev, AcpiPciHpState= *s, +void acpi_pcihp_device_plug_cb(const HotplugHandler *hotplug_dev, AcpiPciH= pState *s, DeviceState *dev, Error **errp) { } =20 -void acpi_pcihp_device_pre_plug_cb(HotplugHandler *hotplug_dev, +void acpi_pcihp_device_pre_plug_cb(const HotplugHandler *hotplug_dev, DeviceState *dev, Error **errp) { } =20 -void acpi_pcihp_device_unplug_cb(HotplugHandler *hotplug_dev, AcpiPciHpSta= te *s, +void acpi_pcihp_device_unplug_cb(const HotplugHandler *hotplug_dev, AcpiPc= iHpState *s, DeviceState *dev, Error **errp) { } =20 -void acpi_pcihp_device_unplug_request_cb(HotplugHandler *hotplug_dev, +void acpi_pcihp_device_unplug_request_cb(const HotplugHandler *hotplug_dev, AcpiPciHpState *s, DeviceState *d= ev, Error **errp) { diff --git a/hw/acpi/cpu.c b/hw/acpi/cpu.c index d63ca83c1b..ef97ed779a 100644 --- a/hw/acpi/cpu.c +++ b/hw/acpi/cpu.c @@ -132,7 +132,7 @@ static void cpu_hotplug_wr(void *opaque, hwaddr addr, u= int64_t data, trace_cpuhp_acpi_clear_remove_evt(cpu_st->selector); } else if (data & 8) { DeviceState *dev =3D NULL; - HotplugHandler *hotplug_ctrl =3D NULL; + const HotplugHandler *hotplug_ctrl; =20 if (!cdev->cpu || cdev->cpu =3D=3D first_cpu) { trace_cpuhp_acpi_ejecting_invalid_cpu(cpu_st->selector); @@ -247,7 +247,7 @@ static AcpiCpuStatus *get_cpu_status(CPUHotplugState *c= pu_st, DeviceState *dev) return NULL; } =20 -void acpi_cpu_plug_cb(HotplugHandler *hotplug_dev, +void acpi_cpu_plug_cb(const HotplugHandler *hotplug_dev, CPUHotplugState *cpu_st, DeviceState *dev, Error **e= rrp) { AcpiCpuStatus *cdev; @@ -264,7 +264,7 @@ void acpi_cpu_plug_cb(HotplugHandler *hotplug_dev, } } =20 -void acpi_cpu_unplug_request_cb(HotplugHandler *hotplug_dev, +void acpi_cpu_unplug_request_cb(const HotplugHandler *hotplug_dev, CPUHotplugState *cpu_st, DeviceState *dev, Error **errp) { diff --git a/hw/acpi/generic_event_device.c b/hw/acpi/generic_event_device.c index 5225e32513..65a5d1612f 100644 --- a/hw/acpi/generic_event_device.c +++ b/hw/acpi/generic_event_device.c @@ -45,7 +45,8 @@ static const uint32_t ged_supported_events[] =3D { * affected by the interrupt. This way, we can support up to 32 events * with a unique interrupt. */ -void build_ged_aml(Aml *table, const char *name, HotplugHandler *hotplug_d= ev, +void build_ged_aml(Aml *table, const char *name, + const HotplugHandler *hotplug_dev, uint32_t ged_irq, AmlRegionSpace rs, hwaddr ged_base) { const AcpiGedState *s =3D ACPI_GED(hotplug_dev); @@ -250,7 +251,7 @@ static const MemoryRegionOps ged_regs_ops =3D { }, }; =20 -static void acpi_ged_device_pre_plug_cb(HotplugHandler *hotplug_dev, +static void acpi_ged_device_pre_plug_cb(const HotplugHandler *hotplug_dev, DeviceState *dev, Error **errp) { if (object_dynamic_cast(OBJECT(dev), TYPE_PCI_DEVICE)) { @@ -258,7 +259,7 @@ static void acpi_ged_device_pre_plug_cb(HotplugHandler = *hotplug_dev, } } =20 -static void acpi_ged_device_plug_cb(HotplugHandler *hotplug_dev, +static void acpi_ged_device_plug_cb(const HotplugHandler *hotplug_dev, DeviceState *dev, Error **errp) { AcpiGedState *s =3D ACPI_GED(hotplug_dev); @@ -279,7 +280,7 @@ static void acpi_ged_device_plug_cb(HotplugHandler *hot= plug_dev, } } =20 -static void acpi_ged_unplug_request_cb(HotplugHandler *hotplug_dev, +static void acpi_ged_unplug_request_cb(const HotplugHandler *hotplug_dev, DeviceState *dev, Error **errp) { AcpiGedState *s =3D ACPI_GED(hotplug_dev); @@ -298,7 +299,7 @@ static void acpi_ged_unplug_request_cb(HotplugHandler *= hotplug_dev, } } =20 -static void acpi_ged_unplug_cb(HotplugHandler *hotplug_dev, +static void acpi_ged_unplug_cb(const HotplugHandler *hotplug_dev, DeviceState *dev, Error **errp) { AcpiGedState *s =3D ACPI_GED(hotplug_dev); diff --git a/hw/acpi/ich9.c b/hw/acpi/ich9.c index 8082eae428..6d421b990c 100644 --- a/hw/acpi/ich9.c +++ b/hw/acpi/ich9.c @@ -410,7 +410,7 @@ void ich9_pm_add_class_properties(ObjectClass *oc, ptrd= iff_t pm_offset) =20 #undef PM_REG_FIELD =20 -void ich9_pm_device_pre_plug_cb(HotplugHandler *hotplug_dev, DeviceState *= dev, +void ich9_pm_device_pre_plug_cb(const HotplugHandler *hotplug_dev, DeviceS= tate *dev, Error **errp) { ICH9LPCState *lpc =3D ICH9_LPC_DEVICE(hotplug_dev); @@ -432,7 +432,7 @@ void ich9_pm_device_pre_plug_cb(HotplugHandler *hotplug= _dev, DeviceState *dev, } } =20 -void ich9_pm_device_plug_cb(HotplugHandler *hotplug_dev, DeviceState *dev, +void ich9_pm_device_plug_cb(const HotplugHandler *hotplug_dev, DeviceState= *dev, Error **errp) { ICH9LPCState *lpc =3D ICH9_LPC_DEVICE(hotplug_dev); @@ -455,7 +455,7 @@ void ich9_pm_device_plug_cb(HotplugHandler *hotplug_dev= , DeviceState *dev, } } =20 -void ich9_pm_device_unplug_request_cb(HotplugHandler *hotplug_dev, +void ich9_pm_device_unplug_request_cb(const HotplugHandler *hotplug_dev, DeviceState *dev, Error **errp) { ICH9LPCState *lpc =3D ICH9_LPC_DEVICE(hotplug_dev); @@ -489,7 +489,7 @@ void ich9_pm_device_unplug_request_cb(HotplugHandler *h= otplug_dev, } } =20 -void ich9_pm_device_unplug_cb(HotplugHandler *hotplug_dev, DeviceState *de= v, +void ich9_pm_device_unplug_cb(const HotplugHandler *hotplug_dev, DeviceSta= te *dev, Error **errp) { ICH9LPCState *lpc =3D ICH9_LPC_DEVICE(hotplug_dev); @@ -507,7 +507,7 @@ void ich9_pm_device_unplug_cb(HotplugHandler *hotplug_d= ev, DeviceState *dev, } } =20 -bool ich9_pm_is_hotpluggable_bus(HotplugHandler *hotplug_dev, BusState *bu= s) +bool ich9_pm_is_hotpluggable_bus(const HotplugHandler *hotplug_dev, BusSta= te *bus) { ICH9LPCState *lpc =3D ICH9_LPC_DEVICE(hotplug_dev); return acpi_pcihp_is_hotpluggable_bus(&lpc->pm.acpi_pci_hotplug, bus); diff --git a/hw/acpi/memory_hotplug.c b/hw/acpi/memory_hotplug.c index f482c835a1..b5b6d6ada6 100644 --- a/hw/acpi/memory_hotplug.c +++ b/hw/acpi/memory_hotplug.c @@ -166,7 +166,7 @@ static void acpi_memory_hotplug_write(void *opaque, hwa= ddr addr, uint64_t data, mdev->is_removing =3D false; trace_mhp_acpi_clear_remove_evt(mem_st->selector); } else if (data & 8) { - HotplugHandler *hotplug_ctrl; + const HotplugHandler *hotplug_ctrl; =20 if (!mdev->is_enabled) { trace_mhp_acpi_ejecting_invalid_slot(mem_st->selector); @@ -254,7 +254,7 @@ acpi_memory_slot_status(MemHotplugState *mem_st, return &mem_st->devs[slot]; } =20 -void acpi_memory_plug_cb(HotplugHandler *hotplug_dev, MemHotplugState *mem= _st, +void acpi_memory_plug_cb(const HotplugHandler *hotplug_dev, MemHotplugStat= e *mem_st, DeviceState *dev, Error **errp) { MemStatus *mdev; @@ -277,7 +277,7 @@ void acpi_memory_plug_cb(HotplugHandler *hotplug_dev, M= emHotplugState *mem_st, } } =20 -void acpi_memory_unplug_request_cb(HotplugHandler *hotplug_dev, +void acpi_memory_unplug_request_cb(const HotplugHandler *hotplug_dev, MemHotplugState *mem_st, DeviceState *dev, Error **errp) { diff --git a/hw/acpi/nvdimm.c b/hw/acpi/nvdimm.c index 703e854951..5a7ff1ede8 100644 --- a/hw/acpi/nvdimm.c +++ b/hw/acpi/nvdimm.c @@ -887,7 +887,7 @@ static const MemoryRegionOps nvdimm_dsm_ops =3D { }, }; =20 -void nvdimm_acpi_plug_cb(HotplugHandler *hotplug_dev, DeviceState *dev) +void nvdimm_acpi_plug_cb(const HotplugHandler *hotplug_dev, DeviceState *d= ev) { if (dev->hotplugged) { acpi_send_event(DEVICE(hotplug_dev), ACPI_NVDIMM_HOTPLUG_STATUS); diff --git a/hw/acpi/pcihp.c b/hw/acpi/pcihp.c index 336ebe1a13..b69379a18b 100644 --- a/hw/acpi/pcihp.c +++ b/hw/acpi/pcihp.c @@ -209,7 +209,7 @@ static void acpi_pcihp_eject_slot(AcpiPciHpState *s, un= signed bsel, unsigned slo */ qdev->pending_deleted_event =3D false; } else { - HotplugHandler *hotplug_ctrl; + const HotplugHandler *hotplug_ctrl; =20 hotplug_ctrl =3D qdev_get_hotplug_handler(qdev); hotplug_handler_unplug(hotplug_ctrl, qdev, &error_abor= t); @@ -261,7 +261,7 @@ void acpi_pcihp_reset(AcpiPciHpState *s) acpi_pcihp_update(s); } =20 -void acpi_pcihp_device_pre_plug_cb(HotplugHandler *hotplug_dev, +void acpi_pcihp_device_pre_plug_cb(const HotplugHandler *hotplug_dev, DeviceState *dev, Error **errp) { PCIDevice *pdev =3D PCI_DEVICE(dev); @@ -275,7 +275,7 @@ void acpi_pcihp_device_pre_plug_cb(HotplugHandler *hotp= lug_dev, } } =20 -void acpi_pcihp_device_plug_cb(HotplugHandler *hotplug_dev, AcpiPciHpState= *s, +void acpi_pcihp_device_plug_cb(const HotplugHandler *hotplug_dev, AcpiPciH= pState *s, DeviceState *dev, Error **errp) { PCIDevice *pdev =3D PCI_DEVICE(dev); @@ -317,7 +317,7 @@ void acpi_pcihp_device_plug_cb(HotplugHandler *hotplug_= dev, AcpiPciHpState *s, acpi_send_event(DEVICE(hotplug_dev), ACPI_PCI_HOTPLUG_STATUS); } =20 -void acpi_pcihp_device_unplug_cb(HotplugHandler *hotplug_dev, AcpiPciHpSta= te *s, +void acpi_pcihp_device_unplug_cb(const HotplugHandler *hotplug_dev, AcpiPc= iHpState *s, DeviceState *dev, Error **errp) { PCIDevice *pdev =3D PCI_DEVICE(dev); @@ -328,7 +328,7 @@ void acpi_pcihp_device_unplug_cb(HotplugHandler *hotplu= g_dev, AcpiPciHpState *s, qdev_unrealize(dev); } =20 -void acpi_pcihp_device_unplug_request_cb(HotplugHandler *hotplug_dev, +void acpi_pcihp_device_unplug_request_cb(const HotplugHandler *hotplug_dev, AcpiPciHpState *s, DeviceState *d= ev, Error **errp) { diff --git a/hw/acpi/piix4.c b/hw/acpi/piix4.c index 52bd61667f..a7d5356340 100644 --- a/hw/acpi/piix4.c +++ b/hw/acpi/piix4.c @@ -303,8 +303,8 @@ static void piix4_pm_powerdown_req(Notifier *n, void *o= paque) acpi_pm1_evt_power_down(&s->ar); } =20 -static void piix4_device_pre_plug_cb(HotplugHandler *hotplug_dev, - DeviceState *dev, Error **errp) +static void piix4_device_pre_plug_cb(const HotplugHandler *hotplug_dev, + DeviceState *dev, Error **errp) { PIIX4PMState *s =3D PIIX4_PM(hotplug_dev); =20 @@ -323,7 +323,7 @@ static void piix4_device_pre_plug_cb(HotplugHandler *ho= tplug_dev, } } =20 -static void piix4_device_plug_cb(HotplugHandler *hotplug_dev, +static void piix4_device_plug_cb(const HotplugHandler *hotplug_dev, DeviceState *dev, Error **errp) { PIIX4PMState *s =3D PIIX4_PM(hotplug_dev); @@ -344,7 +344,7 @@ static void piix4_device_plug_cb(HotplugHandler *hotplu= g_dev, } } =20 -static void piix4_device_unplug_request_cb(HotplugHandler *hotplug_dev, +static void piix4_device_unplug_request_cb(const HotplugHandler *hotplug_d= ev, DeviceState *dev, Error **errp) { PIIX4PMState *s =3D PIIX4_PM(hotplug_dev); @@ -364,7 +364,7 @@ static void piix4_device_unplug_request_cb(HotplugHandl= er *hotplug_dev, } } =20 -static void piix4_device_unplug_cb(HotplugHandler *hotplug_dev, +static void piix4_device_unplug_cb(const HotplugHandler *hotplug_dev, DeviceState *dev, Error **errp) { PIIX4PMState *s =3D PIIX4_PM(hotplug_dev); @@ -383,7 +383,7 @@ static void piix4_device_unplug_cb(HotplugHandler *hotp= lug_dev, } } =20 -static bool piix4_is_hotpluggable_bus(HotplugHandler *hotplug_dev, +static bool piix4_is_hotpluggable_bus(const HotplugHandler *hotplug_dev, BusState *bus) { PIIX4PMState *s =3D PIIX4_PM(hotplug_dev); diff --git a/hw/arm/virt.c b/hw/arm/virt.c index 0871a35e11..3eecf094bc 100644 --- a/hw/arm/virt.c +++ b/hw/arm/virt.c @@ -3753,7 +3753,7 @@ static const CPUArchIdList *virt_possible_cpu_arch_id= s(MachineState *ms) return ms->possible_cpus; } =20 -static void virt_memory_pre_plug(HotplugHandler *hotplug_dev, DeviceState = *dev, +static void virt_memory_pre_plug(const HotplugHandler *hotplug_dev, Device= State *dev, Error **errp) { VirtMachineState *vms =3D VIRT_MACHINE(hotplug_dev); @@ -3779,7 +3779,7 @@ static void virt_memory_pre_plug(HotplugHandler *hotp= lug_dev, DeviceState *dev, pc_dimm_pre_plug(PC_DIMM(dev), MACHINE(hotplug_dev), errp); } =20 -static void virt_memory_plug(HotplugHandler *hotplug_dev, +static void virt_memory_plug(const HotplugHandler *hotplug_dev, DeviceState *dev, Error **errp) { VirtMachineState *vms =3D VIRT_MACHINE(hotplug_dev); @@ -3798,7 +3798,7 @@ static void virt_memory_plug(HotplugHandler *hotplug_= dev, } } =20 -static void virt_machine_device_pre_plug_cb(HotplugHandler *hotplug_dev, +static void virt_machine_device_pre_plug_cb(const HotplugHandler *hotplug_= dev, DeviceState *dev, Error **errp) { VirtMachineState *vms =3D VIRT_MACHINE(hotplug_dev); @@ -3896,7 +3896,7 @@ static void virt_machine_device_pre_plug_cb(HotplugHa= ndler *hotplug_dev, } } =20 -static void virt_machine_device_plug_cb(HotplugHandler *hotplug_dev, +static void virt_machine_device_plug_cb(const HotplugHandler *hotplug_dev, DeviceState *dev, Error **errp) { VirtMachineState *vms =3D VIRT_MACHINE(hotplug_dev); @@ -3957,7 +3957,7 @@ static void virt_machine_device_plug_cb(HotplugHandle= r *hotplug_dev, } } =20 -static void virt_dimm_unplug_request(HotplugHandler *hotplug_dev, +static void virt_dimm_unplug_request(const HotplugHandler *hotplug_dev, DeviceState *dev, Error **errp) { VirtMachineState *vms =3D VIRT_MACHINE(hotplug_dev); @@ -3977,7 +3977,7 @@ static void virt_dimm_unplug_request(HotplugHandler *= hotplug_dev, errp); } =20 -static void virt_dimm_unplug(HotplugHandler *hotplug_dev, +static void virt_dimm_unplug(const HotplugHandler *hotplug_dev, DeviceState *dev, Error **errp) { VirtMachineState *vms =3D VIRT_MACHINE(hotplug_dev); @@ -3995,8 +3995,9 @@ out: error_propagate(errp, local_err); } =20 -static void virt_machine_device_unplug_request_cb(HotplugHandler *hotplug_= dev, - DeviceState *dev, Error **errp) +static void +virt_machine_device_unplug_request_cb(const HotplugHandler *hotplug_dev, + DeviceState *dev, Error **errp) { if (object_dynamic_cast(OBJECT(dev), TYPE_PC_DIMM)) { virt_dimm_unplug_request(hotplug_dev, dev, errp); @@ -4009,7 +4010,7 @@ static void virt_machine_device_unplug_request_cb(Hot= plugHandler *hotplug_dev, } } =20 -static void virt_machine_device_unplug_cb(HotplugHandler *hotplug_dev, +static void virt_machine_device_unplug_cb(const HotplugHandler *hotplug_de= v, DeviceState *dev, Error **errp) { if (object_dynamic_cast(OBJECT(dev), TYPE_PC_DIMM)) { @@ -4022,8 +4023,8 @@ static void virt_machine_device_unplug_cb(HotplugHand= ler *hotplug_dev, } } =20 -static HotplugHandler *virt_machine_get_hotplug_handler(MachineState *mach= ine, - DeviceState *dev) +static const HotplugHandler * +virt_machine_get_hotplug_handler(MachineState *machine, DeviceState *dev) { MachineClass *mc =3D MACHINE_GET_CLASS(machine); =20 diff --git a/hw/char/virtio-serial-bus.c b/hw/char/virtio-serial-bus.c index 81db0bdc91..c36e18a4cf 100644 --- a/hw/char/virtio-serial-bus.c +++ b/hw/char/virtio-serial-bus.c @@ -979,7 +979,7 @@ static void virtser_port_device_realize(DeviceState *de= v, Error **errp) port->elem =3D NULL; } =20 -static void virtser_port_device_plug(HotplugHandler *hotplug_dev, +static void virtser_port_device_plug(const HotplugHandler *hotplug_dev, DeviceState *dev, Error **errp) { VirtIOSerialPort *port =3D VIRTIO_SERIAL_PORT(dev); diff --git a/hw/core/hotplug.c b/hw/core/hotplug.c index 00e80a67c8..3aca068840 100644 --- a/hw/core/hotplug.c +++ b/hw/core/hotplug.c @@ -13,7 +13,7 @@ #include "hw/core/hotplug.h" #include "qemu/module.h" =20 -void hotplug_handler_pre_plug(HotplugHandler *plug_handler, +void hotplug_handler_pre_plug(const HotplugHandler *plug_handler, DeviceState *plugged_dev, Error **errp) { @@ -24,7 +24,7 @@ void hotplug_handler_pre_plug(HotplugHandler *plug_handle= r, } } =20 -void hotplug_handler_plug(HotplugHandler *plug_handler, +void hotplug_handler_plug(const HotplugHandler *plug_handler, DeviceState *plugged_dev, Error **errp) { @@ -35,7 +35,7 @@ void hotplug_handler_plug(HotplugHandler *plug_handler, } } =20 -void hotplug_handler_unplug_request(HotplugHandler *plug_handler, +void hotplug_handler_unplug_request(const HotplugHandler *plug_handler, DeviceState *plugged_dev, Error **errp) { @@ -46,7 +46,7 @@ void hotplug_handler_unplug_request(HotplugHandler *plug_= handler, } } =20 -void hotplug_handler_unplug(HotplugHandler *plug_handler, +void hotplug_handler_unplug(const HotplugHandler *plug_handler, DeviceState *plugged_dev, Error **errp) { diff --git a/hw/core/qdev-hotplug.c b/hw/core/qdev-hotplug.c index 1d547e0dbd..d7fa8a5ed2 100644 --- a/hw/core/qdev-hotplug.c +++ b/hw/core/qdev-hotplug.c @@ -14,7 +14,7 @@ #include "hw/core/boards.h" #include "qapi/error.h" =20 -HotplugHandler *qdev_get_machine_hotplug_handler(DeviceState *dev) +const HotplugHandler *qdev_get_machine_hotplug_handler(DeviceState *dev) { MachineState *machine; MachineClass *mc; @@ -90,7 +90,7 @@ bool qdev_hotunplug_allowed(DeviceState *dev, Error **err= p) qdev_hotplug_unplug_allowed_common(dev, dev->parent_bus, errp); } =20 -HotplugHandler *qdev_get_bus_hotplug_handler(DeviceState *dev) +const HotplugHandler *qdev_get_bus_hotplug_handler(DeviceState *dev) { if (dev->parent_bus) { return dev->parent_bus->hotplug_handler; @@ -98,9 +98,9 @@ HotplugHandler *qdev_get_bus_hotplug_handler(DeviceState = *dev) return NULL; } =20 -HotplugHandler *qdev_get_hotplug_handler(DeviceState *dev) +const HotplugHandler *qdev_get_hotplug_handler(DeviceState *dev) { - HotplugHandler *hotplug_ctrl =3D qdev_get_machine_hotplug_handler(dev); + const HotplugHandler *hotplug_ctrl =3D qdev_get_machine_hotplug_handle= r(dev); =20 if (hotplug_ctrl =3D=3D NULL && dev->parent_bus) { hotplug_ctrl =3D qdev_get_bus_hotplug_handler(dev); @@ -109,7 +109,7 @@ HotplugHandler *qdev_get_hotplug_handler(DeviceState *d= ev) } =20 /* can be used as ->unplug() callback for the simple cases */ -void qdev_simple_device_unplug_cb(HotplugHandler *hotplug_dev, +void qdev_simple_device_unplug_cb(const HotplugHandler *hotplug_dev, DeviceState *dev, Error **errp) { qdev_unrealize(dev); diff --git a/hw/core/qdev.c b/hw/core/qdev.c index 0b0f2f47fa..c6540bec56 100644 --- a/hw/core/qdev.c +++ b/hw/core/qdev.c @@ -501,7 +501,7 @@ static void device_set_realized(Object *obj, bool value= , Error **errp) { DeviceState *dev =3D DEVICE(obj); DeviceClass *dc =3D DEVICE_GET_CLASS(dev); - HotplugHandler *hotplug_ctrl; + const HotplugHandler *hotplug_ctrl; BusState *bus; NamedClockList *ncl; Error *local_err =3D NULL; diff --git a/hw/i386/microvm.c b/hw/i386/microvm.c index e7adab7d2e..a49de33749 100644 --- a/hw/i386/microvm.c +++ b/hw/i386/microvm.c @@ -416,7 +416,7 @@ static void microvm_fix_kernel_cmdline(MachineState *ma= chine) g_free(cmdline); } =20 -static void microvm_device_pre_plug_cb(HotplugHandler *hotplug_dev, +static void microvm_device_pre_plug_cb(const HotplugHandler *hotplug_dev, DeviceState *dev, Error **errp) { X86CPU *cpu =3D X86_CPU(dev); @@ -425,26 +425,26 @@ static void microvm_device_pre_plug_cb(HotplugHandler= *hotplug_dev, x86_cpu_pre_plug(hotplug_dev, dev, errp); } =20 -static void microvm_device_plug_cb(HotplugHandler *hotplug_dev, +static void microvm_device_plug_cb(const HotplugHandler *hotplug_dev, DeviceState *dev, Error **errp) { x86_cpu_plug(hotplug_dev, dev, errp); } =20 -static void microvm_device_unplug_request_cb(HotplugHandler *hotplug_dev, +static void microvm_device_unplug_request_cb(const HotplugHandler *hotplug= _dev, DeviceState *dev, Error **err= p) { error_setg(errp, "unplug not supported by microvm"); } =20 -static void microvm_device_unplug_cb(HotplugHandler *hotplug_dev, +static void microvm_device_unplug_cb(const HotplugHandler *hotplug_dev, DeviceState *dev, Error **errp) { error_setg(errp, "unplug not supported by microvm"); } =20 -static HotplugHandler *microvm_get_hotplug_handler(MachineState *machine, - DeviceState *dev) +static const HotplugHandler *microvm_get_hotplug_handler(MachineState *mac= hine, + DeviceState *dev) { if (object_dynamic_cast(OBJECT(dev), TYPE_CPU)) { return HOTPLUG_HANDLER(machine); diff --git a/hw/i386/pc.c b/hw/i386/pc.c index e9e4fc262b..9006e7c29e 100644 --- a/hw/i386/pc.c +++ b/hw/i386/pc.c @@ -1181,7 +1181,7 @@ void pc_i8259_create(ISABus *isa_bus, qemu_irq *i8259= _irqs) g_free(i8259); } =20 -static void pc_memory_pre_plug(HotplugHandler *hotplug_dev, DeviceState *d= ev, +static void pc_memory_pre_plug(const HotplugHandler *hotplug_dev, DeviceSt= ate *dev, Error **errp) { const X86MachineState *x86ms =3D X86_MACHINE(hotplug_dev); @@ -1214,7 +1214,7 @@ static void pc_memory_pre_plug(HotplugHandler *hotplu= g_dev, DeviceState *dev, pc_dimm_pre_plug(PC_DIMM(dev), MACHINE(hotplug_dev), errp); } =20 -static void pc_memory_plug(HotplugHandler *hotplug_dev, +static void pc_memory_plug(const HotplugHandler *hotplug_dev, DeviceState *dev, Error **errp) { PCMachineState *pcms =3D PC_MACHINE(hotplug_dev); @@ -1231,7 +1231,7 @@ static void pc_memory_plug(HotplugHandler *hotplug_de= v, hotplug_handler_plug(x86ms->acpi_dev, dev, &error_abort); } =20 -static void pc_memory_unplug_request(HotplugHandler *hotplug_dev, +static void pc_memory_unplug_request(const HotplugHandler *hotplug_dev, DeviceState *dev, Error **errp) { X86MachineState *x86ms =3D X86_MACHINE(hotplug_dev); @@ -1256,7 +1256,7 @@ static void pc_memory_unplug_request(HotplugHandler *= hotplug_dev, errp); } =20 -static void pc_memory_unplug(HotplugHandler *hotplug_dev, +static void pc_memory_unplug(const HotplugHandler *hotplug_dev, DeviceState *dev, Error **errp) { PCMachineState *pcms =3D PC_MACHINE(hotplug_dev); @@ -1274,7 +1274,7 @@ static void pc_memory_unplug(HotplugHandler *hotplug_= dev, error_propagate(errp, local_err); } =20 -static void pc_hv_balloon_pre_plug(HotplugHandler *hotplug_dev, +static void pc_hv_balloon_pre_plug(const HotplugHandler *hotplug_dev, DeviceState *dev, Error **errp) { /* The vmbus handler has no hotplug handler; we should never end up he= re. */ @@ -1282,13 +1282,13 @@ static void pc_hv_balloon_pre_plug(HotplugHandler *= hotplug_dev, memory_device_pre_plug(MEMORY_DEVICE(dev), MACHINE(hotplug_dev), errp); } =20 -static void pc_hv_balloon_plug(HotplugHandler *hotplug_dev, +static void pc_hv_balloon_plug(const HotplugHandler *hotplug_dev, DeviceState *dev, Error **errp) { memory_device_plug(MEMORY_DEVICE(dev), MACHINE(hotplug_dev)); } =20 -static void pc_sp_mem_pre_plug(HotplugHandler *hotplug_dev, +static void pc_sp_mem_pre_plug(const HotplugHandler *hotplug_dev, DeviceState *dev, Error **errp) { MachineState *ms =3D MACHINE(hotplug_dev); @@ -1304,7 +1304,7 @@ static void pc_sp_mem_pre_plug(HotplugHandler *hotplu= g_dev, memory_device_pre_plug(MEMORY_DEVICE(dev), ms, errp); } =20 -static void pc_sp_mem_plug(HotplugHandler *hotplug_dev, +static void pc_sp_mem_plug(const HotplugHandler *hotplug_dev, DeviceState *dev, Error **errp) { SpMemDevice *spm =3D SP_MEM(dev); @@ -1318,7 +1318,7 @@ static void pc_sp_mem_plug(HotplugHandler *hotplug_de= v, e820_add_entry(addr, size, E820_SOFT_RESERVED); } =20 -static void pc_machine_device_pre_plug_cb(HotplugHandler *hotplug_dev, +static void pc_machine_device_pre_plug_cb(const HotplugHandler *hotplug_de= v, DeviceState *dev, Error **errp) { if (object_dynamic_cast(OBJECT(dev), TYPE_PC_DIMM)) { @@ -1356,7 +1356,7 @@ static void pc_machine_device_pre_plug_cb(HotplugHand= ler *hotplug_dev, } } =20 -static void pc_machine_device_plug_cb(HotplugHandler *hotplug_dev, +static void pc_machine_device_plug_cb(const HotplugHandler *hotplug_dev, DeviceState *dev, Error **errp) { if (object_dynamic_cast(OBJECT(dev), TYPE_PC_DIMM)) { @@ -1372,7 +1372,7 @@ static void pc_machine_device_plug_cb(HotplugHandler = *hotplug_dev, } } =20 -static void pc_machine_device_unplug_request_cb(HotplugHandler *hotplug_de= v, +static void pc_machine_device_unplug_request_cb(const HotplugHandler *hotp= lug_dev, DeviceState *dev, Error **= errp) { if (object_dynamic_cast(OBJECT(dev), TYPE_PC_DIMM)) { @@ -1388,7 +1388,7 @@ static void pc_machine_device_unplug_request_cb(Hotpl= ugHandler *hotplug_dev, } } =20 -static void pc_machine_device_unplug_cb(HotplugHandler *hotplug_dev, +static void pc_machine_device_unplug_cb(const HotplugHandler *hotplug_dev, DeviceState *dev, Error **errp) { if (object_dynamic_cast(OBJECT(dev), TYPE_PC_DIMM)) { @@ -1403,8 +1403,8 @@ static void pc_machine_device_unplug_cb(HotplugHandle= r *hotplug_dev, } } =20 -static HotplugHandler *pc_get_hotplug_handler(MachineState *machine, - DeviceState *dev) +static const HotplugHandler *pc_get_hotplug_handler(MachineState *machine, + DeviceState *dev) { if (object_dynamic_cast(OBJECT(dev), TYPE_PC_DIMM) || object_dynamic_cast(OBJECT(dev), TYPE_SP_MEM) || diff --git a/hw/i386/x86-common.c b/hw/i386/x86-common.c index 8f9419e7d3..ae58352760 100644 --- a/hw/i386/x86-common.c +++ b/hw/i386/x86-common.c @@ -158,7 +158,7 @@ static CPUArchId *x86_find_cpu_slot(MachineState *ms, u= int32_t id, int *idx) return found_cpu; } =20 -void x86_cpu_plug(HotplugHandler *hotplug_dev, +void x86_cpu_plug(const HotplugHandler *hotplug_dev, DeviceState *dev, Error **errp) { CPUArchId *found_cpu; @@ -199,7 +199,7 @@ out: error_propagate(errp, local_err); } =20 -void x86_cpu_unplug_request_cb(HotplugHandler *hotplug_dev, +void x86_cpu_unplug_request_cb(const HotplugHandler *hotplug_dev, DeviceState *dev, Error **errp) { int idx =3D -1; @@ -222,7 +222,7 @@ void x86_cpu_unplug_request_cb(HotplugHandler *hotplug_= dev, errp); } =20 -void x86_cpu_unplug_cb(HotplugHandler *hotplug_dev, +void x86_cpu_unplug_cb(const HotplugHandler *hotplug_dev, DeviceState *dev, Error **errp) { CPUArchId *found_cpu; @@ -248,7 +248,7 @@ void x86_cpu_unplug_cb(HotplugHandler *hotplug_dev, error_propagate(errp, local_err); } =20 -void x86_cpu_pre_plug(HotplugHandler *hotplug_dev, +void x86_cpu_pre_plug(const HotplugHandler *hotplug_dev, DeviceState *dev, Error **errp) { int idx; diff --git a/hw/intc/loongarch_dintc.c b/hw/intc/loongarch_dintc.c index c01f1fe07e..1bedfbce43 100644 --- a/hw/intc/loongarch_dintc.c +++ b/hw/intc/loongarch_dintc.c @@ -168,8 +168,8 @@ static DINTCCore *loongarch_dintc_get_cpu(LoongArchDINT= CState *s, return loongarch_dintc_cpu_by_arch_id(s, arch_id); } =20 -static void loongarch_dintc_cpu_plug(HotplugHandler *hotplug_dev, - DeviceState *dev, Error **errp) +static void loongarch_dintc_cpu_plug(const HotplugHandler *hotplug_dev, + DeviceState *dev, Error **errp) { LoongArchDINTCState *s =3D LOONGARCH_DINTC(hotplug_dev); Object *obj =3D OBJECT(dev); @@ -194,8 +194,8 @@ static void loongarch_dintc_cpu_plug(HotplugHandler *ho= tplug_dev, return; } =20 -static void loongarch_dintc_cpu_unplug(HotplugHandler *hotplug_dev, - DeviceState *dev, Error **errp) +static void loongarch_dintc_cpu_unplug(const HotplugHandler *hotplug_dev, + DeviceState *dev, Error **errp) { LoongArchDINTCState *s =3D LOONGARCH_DINTC(hotplug_dev); Object *obj =3D OBJECT(dev); diff --git a/hw/intc/loongarch_extioi_common.c b/hw/intc/loongarch_extioi_c= ommon.c index 5cb0d396c6..22cbb7a097 100644 --- a/hw/intc/loongarch_extioi_common.c +++ b/hw/intc/loongarch_extioi_common.c @@ -28,7 +28,7 @@ static ExtIOICore *loongarch_extioi_get_cpu(LoongArchExtI= OICommonState *s, return NULL; } =20 -static void loongarch_extioi_cpu_plug(HotplugHandler *hotplug_dev, +static void loongarch_extioi_cpu_plug(const HotplugHandler *hotplug_dev, DeviceState *dev, Error **errp) { LoongArchExtIOICommonState *s =3D LOONGARCH_EXTIOI_COMMON(hotplug_dev); @@ -60,7 +60,7 @@ static void loongarch_extioi_cpu_plug(HotplugHandler *hot= plug_dev, } } =20 -static void loongarch_extioi_cpu_unplug(HotplugHandler *hotplug_dev, +static void loongarch_extioi_cpu_unplug(const HotplugHandler *hotplug_dev, DeviceState *dev, Error **errp) { LoongArchExtIOICommonState *s =3D LOONGARCH_EXTIOI_COMMON(hotplug_dev); diff --git a/hw/intc/loongarch_ipi.c b/hw/intc/loongarch_ipi.c index 28d816e3f5..c8f775a93e 100644 --- a/hw/intc/loongarch_ipi.c +++ b/hw/intc/loongarch_ipi.c @@ -129,7 +129,7 @@ static void loongarch_ipi_reset_hold(Object *obj, Reset= Type type) } } =20 -static void loongarch_ipi_cpu_plug(HotplugHandler *hotplug_dev, +static void loongarch_ipi_cpu_plug(const HotplugHandler *hotplug_dev, DeviceState *dev, Error **errp) { LoongsonIPICommonState *lics =3D LOONGSON_IPI_COMMON(hotplug_dev); @@ -155,7 +155,7 @@ static void loongarch_ipi_cpu_plug(HotplugHandler *hotp= lug_dev, qdev_connect_gpio_out(DEVICE(lics), index, qdev_get_gpio_in(dev, IRQ_I= PI)); } =20 -static void loongarch_ipi_cpu_unplug(HotplugHandler *hotplug_dev, +static void loongarch_ipi_cpu_unplug(const HotplugHandler *hotplug_dev, DeviceState *dev, Error **errp) { LoongsonIPICommonState *lics =3D LOONGSON_IPI_COMMON(hotplug_dev); diff --git a/hw/loongarch/virt.c b/hw/loongarch/virt.c index 9cc79929a8..9c5371af9d 100644 --- a/hw/loongarch/virt.c +++ b/hw/loongarch/virt.c @@ -1167,7 +1167,7 @@ static CPUArchId *virt_find_empty_cpu_slot(MachineSta= te *ms) return NULL; } =20 -static void virt_cpu_pre_plug(HotplugHandler *hotplug_dev, +static void virt_cpu_pre_plug(const HotplugHandler *hotplug_dev, DeviceState *dev, Error **errp) { LoongArchVirtMachineState *lvms =3D LOONGARCH_VIRT_MACHINE(hotplug_dev= ); @@ -1229,7 +1229,7 @@ static void virt_cpu_pre_plug(HotplugHandler *hotplug= _dev, numa_cpu_pre_plug(cpu_slot, dev, errp); } =20 -static void virt_cpu_unplug_request(HotplugHandler *hotplug_dev, +static void virt_cpu_unplug_request(const HotplugHandler *hotplug_dev, DeviceState *dev, Error **errp) { LoongArchVirtMachineState *lvms =3D LOONGARCH_VIRT_MACHINE(hotplug_dev= ); @@ -1246,7 +1246,7 @@ static void virt_cpu_unplug_request(HotplugHandler *h= otplug_dev, hotplug_handler_unplug_request(HOTPLUG_HANDLER(lvms->acpi_ged), dev, e= rrp); } =20 -static void virt_cpu_unplug(HotplugHandler *hotplug_dev, +static void virt_cpu_unplug(const HotplugHandler *hotplug_dev, DeviceState *dev, Error **errp) { CPUArchId *cpu_slot; @@ -1268,7 +1268,7 @@ static void virt_cpu_unplug(HotplugHandler *hotplug_d= ev, cpu_slot->cpu =3D NULL; } =20 -static void virt_cpu_plug(HotplugHandler *hotplug_dev, +static void virt_cpu_plug(const HotplugHandler *hotplug_dev, DeviceState *dev, Error **errp) { CPUArchId *cpu_slot; @@ -1304,14 +1304,14 @@ static bool memhp_type_supported(DeviceState *dev) !object_dynamic_cast(OBJECT(dev), TYPE_NVDIMM); } =20 -static void virt_mem_pre_plug(HotplugHandler *hotplug_dev, DeviceState *de= v, - Error **errp) +static void virt_mem_pre_plug(const HotplugHandler *hotplug_dev, + DeviceState *dev, Error **errp) { pc_dimm_pre_plug(PC_DIMM(dev), MACHINE(hotplug_dev), errp); } =20 -static void virt_device_pre_plug(HotplugHandler *hotplug_dev, - DeviceState *dev, Error **errp) +static void virt_device_pre_plug(const HotplugHandler *hotplug_dev, + DeviceState *dev, Error **errp) { if (memhp_type_supported(dev)) { virt_mem_pre_plug(hotplug_dev, dev, errp); @@ -1320,8 +1320,8 @@ static void virt_device_pre_plug(HotplugHandler *hotp= lug_dev, } } =20 -static void virt_mem_unplug_request(HotplugHandler *hotplug_dev, - DeviceState *dev, Error **errp) +static void virt_mem_unplug_request(const HotplugHandler *hotplug_dev, + DeviceState *dev, Error **errp) { LoongArchVirtMachineState *lvms =3D LOONGARCH_VIRT_MACHINE(hotplug_dev= ); =20 @@ -1330,8 +1330,8 @@ static void virt_mem_unplug_request(HotplugHandler *h= otplug_dev, errp); } =20 -static void virt_device_unplug_request(HotplugHandler *hotplug_dev, - DeviceState *dev, Error **errp) +static void virt_device_unplug_request(const HotplugHandler *hotplug_dev, + DeviceState *dev, Error **errp) { if (memhp_type_supported(dev)) { virt_mem_unplug_request(hotplug_dev, dev, errp); @@ -1340,8 +1340,8 @@ static void virt_device_unplug_request(HotplugHandler= *hotplug_dev, } } =20 -static void virt_mem_unplug(HotplugHandler *hotplug_dev, - DeviceState *dev, Error **errp) +static void virt_mem_unplug(const HotplugHandler *hotplug_dev, + DeviceState *dev, Error **errp) { LoongArchVirtMachineState *lvms =3D LOONGARCH_VIRT_MACHINE(hotplug_dev= ); =20 @@ -1350,8 +1350,8 @@ static void virt_mem_unplug(HotplugHandler *hotplug_d= ev, qdev_unrealize(dev); } =20 -static void virt_device_unplug(HotplugHandler *hotplug_dev, - DeviceState *dev, Error **errp) +static void virt_device_unplug(const HotplugHandler *hotplug_dev, + DeviceState *dev, Error **errp) { if (memhp_type_supported(dev)) { virt_mem_unplug(hotplug_dev, dev, errp); @@ -1360,8 +1360,8 @@ static void virt_device_unplug(HotplugHandler *hotplu= g_dev, } } =20 -static void virt_mem_plug(HotplugHandler *hotplug_dev, - DeviceState *dev, Error **errp) +static void virt_mem_plug(const HotplugHandler *hotplug_dev, + DeviceState *dev, Error **errp) { LoongArchVirtMachineState *lvms =3D LOONGARCH_VIRT_MACHINE(hotplug_dev= ); =20 @@ -1370,8 +1370,8 @@ static void virt_mem_plug(HotplugHandler *hotplug_dev, dev, &error_abort); } =20 -static void virt_device_plug_cb(HotplugHandler *hotplug_dev, - DeviceState *dev, Error **errp) +static void virt_device_plug_cb(const HotplugHandler *hotplug_dev, + DeviceState *dev, Error **errp) { LoongArchVirtMachineState *lvms =3D LOONGARCH_VIRT_MACHINE(hotplug_dev= ); MachineClass *mc =3D MACHINE_GET_CLASS(lvms); @@ -1389,8 +1389,8 @@ static void virt_device_plug_cb(HotplugHandler *hotpl= ug_dev, } } =20 -static HotplugHandler *virt_get_hotplug_handler(MachineState *machine, - DeviceState *dev) +static const HotplugHandler *virt_get_hotplug_handler(MachineState *machin= e, + DeviceState *dev) { MachineClass *mc =3D MACHINE_GET_CLASS(machine); =20 diff --git a/hw/net/virtio-net.c b/hw/net/virtio-net.c index 23c26aa08c..986ceff514 100644 --- a/hw/net/virtio-net.c +++ b/hw/net/virtio-net.c @@ -3816,7 +3816,7 @@ void virtio_net_set_netclient_name(VirtIONet *n, cons= t char *name, =20 static bool failover_unplug_primary(VirtIONet *n, DeviceState *dev) { - HotplugHandler *hotplug_ctrl; + const HotplugHandler *hotplug_ctrl; PCIDevice *pci_dev; Error *err =3D NULL; =20 @@ -3839,7 +3839,7 @@ static bool failover_replug_primary(VirtIONet *n, Dev= iceState *dev, Error **errp) { Error *err =3D NULL; - HotplugHandler *hotplug_ctrl; + const HotplugHandler *hotplug_ctrl; PCIDevice *pdev =3D PCI_DEVICE(dev); BusState *primary_bus; =20 diff --git a/hw/nvme/ctrl.c b/hw/nvme/ctrl.c index 7478f0b33a..c641226e27 100644 --- a/hw/nvme/ctrl.c +++ b/hw/nvme/ctrl.c @@ -10615,8 +10615,8 @@ static const TypeInfo nvme_info =3D { }, }; =20 -static void nvme_ns_hot_plug(HotplugHandler *hotplug_dev, DeviceState *dev, - Error **errp) +static void nvme_ns_hot_plug(const HotplugHandler *hotplug_dev, + DeviceState *dev, Error **errp) { NvmeNamespace *ns =3D NVME_NS(dev); NvmeSubsystem *subsys =3D ns->subsys; @@ -10647,8 +10647,8 @@ static void nvme_ns_hot_plug(HotplugHandler *hotplu= g_dev, DeviceState *dev, } } =20 -static void nvme_ns_hot_unplug(HotplugHandler *hotplug_dev, DeviceState *d= ev, - Error **errp) +static void nvme_ns_hot_unplug(const HotplugHandler *hotplug_dev, + DeviceState *dev, Error **errp) { NvmeNamespace *ns =3D NVME_NS(dev); NvmeSubsystem *subsys =3D ns->subsys; diff --git a/hw/pci-bridge/pci_bridge_dev.c b/hw/pci-bridge/pci_bridge_dev.c index 0c1383562d..bc53bcb69d 100644 --- a/hw/pci-bridge/pci_bridge_dev.c +++ b/hw/pci-bridge/pci_bridge_dev.c @@ -205,7 +205,7 @@ static const VMStateDescription pci_bridge_dev_vmstate = =3D { } }; =20 -void pci_bridge_dev_plug_cb(HotplugHandler *hotplug_dev, DeviceState *dev, +void pci_bridge_dev_plug_cb(const HotplugHandler *hotplug_dev, DeviceState= *dev, Error **errp) { PCIDevice *pci_hotplug_dev =3D PCI_DEVICE(hotplug_dev); @@ -218,7 +218,7 @@ void pci_bridge_dev_plug_cb(HotplugHandler *hotplug_dev= , DeviceState *dev, shpc_device_plug_cb(hotplug_dev, dev, errp); } =20 -void pci_bridge_dev_unplug_cb(HotplugHandler *hotplug_dev, DeviceState *de= v, +void pci_bridge_dev_unplug_cb(const HotplugHandler *hotplug_dev, DeviceSta= te *dev, Error **errp) { PCIDevice *pci_hotplug_dev =3D PCI_DEVICE(hotplug_dev); @@ -227,7 +227,7 @@ void pci_bridge_dev_unplug_cb(HotplugHandler *hotplug_d= ev, DeviceState *dev, shpc_device_unplug_cb(hotplug_dev, dev, errp); } =20 -void pci_bridge_dev_unplug_request_cb(HotplugHandler *hotplug_dev, +void pci_bridge_dev_unplug_request_cb(const HotplugHandler *hotplug_dev, DeviceState *dev, Error **errp) { PCIDevice *pci_hotplug_dev =3D PCI_DEVICE(hotplug_dev); diff --git a/hw/pci/pcie.c b/hw/pci/pcie.c index 4622c75e48..42bcb9206d 100644 --- a/hw/pci/pcie.c +++ b/hw/pci/pcie.c @@ -508,7 +508,7 @@ static void pcie_cap_slot_plug_common(PCIDevice *hotplu= g_dev, DeviceState *dev, } } =20 -void pcie_cap_slot_pre_plug_cb(HotplugHandler *hotplug_dev, DeviceState *d= ev, +void pcie_cap_slot_pre_plug_cb(const HotplugHandler *hotplug_dev, DeviceSt= ate *dev, Error **errp) { PCIDevice *hotplug_pdev =3D PCI_DEVICE(hotplug_dev); @@ -525,7 +525,7 @@ void pcie_cap_slot_pre_plug_cb(HotplugHandler *hotplug_= dev, DeviceState *dev, pcie_cap_slot_plug_common(PCI_DEVICE(hotplug_dev), dev, errp); } =20 -void pcie_cap_slot_plug_cb(HotplugHandler *hotplug_dev, DeviceState *dev, +void pcie_cap_slot_plug_cb(const HotplugHandler *hotplug_dev, DeviceState = *dev, Error **errp) { PCIDevice *hotplug_pdev =3D PCI_DEVICE(hotplug_dev); @@ -571,7 +571,7 @@ void pcie_cap_slot_plug_cb(HotplugHandler *hotplug_dev,= DeviceState *dev, } } =20 -void pcie_cap_slot_unplug_cb(HotplugHandler *hotplug_dev, DeviceState *dev, +void pcie_cap_slot_unplug_cb(const HotplugHandler *hotplug_dev, DeviceStat= e *dev, Error **errp) { qdev_unrealize(dev); @@ -579,7 +579,7 @@ void pcie_cap_slot_unplug_cb(HotplugHandler *hotplug_de= v, DeviceState *dev, =20 static void pcie_unplug_device(PCIBus *bus, PCIDevice *dev, void *opaque) { - HotplugHandler *hotplug_ctrl =3D qdev_get_hotplug_handler(DEVICE(dev)); + const HotplugHandler *hotplug_ctrl =3D qdev_get_hotplug_handler(DEVICE= (dev)); =20 if (dev->partially_hotplugged) { dev->qdev.pending_deleted_event =3D false; @@ -608,7 +608,7 @@ static void pcie_cap_slot_do_unplug(PCIDevice *dev) PCI_EXP_SLTSTA_PDC); } =20 -void pcie_cap_slot_unplug_request_cb(HotplugHandler *hotplug_dev, +void pcie_cap_slot_unplug_request_cb(const HotplugHandler *hotplug_dev, DeviceState *dev, Error **errp) { Error *local_err =3D NULL; diff --git a/hw/pci/pcie_port.c b/hw/pci/pcie_port.c index dbb6032160..57fcc9079a 100644 --- a/hw/pci/pcie_port.c +++ b/hw/pci/pcie_port.c @@ -188,7 +188,7 @@ int pcie_count_ds_ports(PCIBus *bus) return dsp_count; } =20 -static bool pcie_slot_is_hotpluggable_bus(HotplugHandler *plug_handler, +static bool pcie_slot_is_hotpluggable_bus(const HotplugHandler *plug_handl= er, BusState *bus) { PCIESlot *s =3D PCIE_SLOT(bus->parent); diff --git a/hw/pci/shpc.c b/hw/pci/shpc.c index 1198e1ab8c..3f24ca84f5 100644 --- a/hw/pci/shpc.c +++ b/hw/pci/shpc.c @@ -278,7 +278,7 @@ static void shpc_free_devices_in_slot(SHPCDevice *shpc,= int slot) ++devfn) { PCIDevice *affected_dev =3D shpc->sec_bus->devices[devfn]; if (affected_dev) { - HotplugHandler *hotplug_ctrl; + const HotplugHandler *hotplug_ctrl; =20 hotplug_ctrl =3D qdev_get_hotplug_handler(DEVICE(affected_dev)= ); hotplug_handler_unplug(hotplug_ctrl, DEVICE(affected_dev), @@ -561,8 +561,8 @@ static bool shpc_device_get_slot(PCIDevice *affected_de= v, int *slot, return true; } =20 -void shpc_device_plug_cb(HotplugHandler *hotplug_dev, DeviceState *dev, - Error **errp) +void shpc_device_plug_cb(const HotplugHandler *hotplug_dev, + DeviceState *dev, Error **errp) { PCIDevice *pci_hotplug_dev =3D PCI_DEVICE(hotplug_dev); SHPCDevice *shpc =3D pci_hotplug_dev->shpc; @@ -601,13 +601,13 @@ void shpc_device_plug_cb(HotplugHandler *hotplug_dev,= DeviceState *dev, shpc_interrupt_update(pci_hotplug_dev); } =20 -void shpc_device_unplug_cb(HotplugHandler *hotplug_dev, DeviceState *dev, +void shpc_device_unplug_cb(const HotplugHandler *hotplug_dev, DeviceState = *dev, Error **errp) { qdev_unrealize(dev); } =20 -void shpc_device_unplug_request_cb(HotplugHandler *hotplug_dev, +void shpc_device_unplug_request_cb(const HotplugHandler *hotplug_dev, DeviceState *dev, Error **errp) { PCIDevice *pci_hotplug_dev =3D PCI_DEVICE(hotplug_dev); diff --git a/hw/ppc/e500plat.c b/hw/ppc/e500plat.c index 85cec810d9..4bc1426dc8 100644 --- a/hw/ppc/e500plat.c +++ b/hw/ppc/e500plat.c @@ -42,7 +42,7 @@ static void e500plat_init(MachineState *machine) ppce500_init(machine); } =20 -static void e500plat_machine_device_plug_cb(HotplugHandler *hotplug_dev, +static void e500plat_machine_device_plug_cb(const HotplugHandler *hotplug_= dev, DeviceState *dev, Error **errp) { PPCE500MachineState *pms =3D PPCE500_MACHINE(hotplug_dev); @@ -53,7 +53,7 @@ static void e500plat_machine_device_plug_cb(HotplugHandle= r *hotplug_dev, } } =20 -static +static const HotplugHandler *e500plat_machine_get_hotpug_handler(MachineState *machine, DeviceState *dev) { diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c index 20e024907b..6d99464486 100644 --- a/hw/ppc/spapr.c +++ b/hw/ppc/spapr.c @@ -3616,7 +3616,7 @@ static void spapr_add_lmbs(DeviceState *dev, uint64_t= addr_start, uint64_t size, } } =20 -static void spapr_memory_plug(HotplugHandler *hotplug_dev, DeviceState *de= v) +static void spapr_memory_plug(const HotplugHandler *hotplug_dev, DeviceSta= te *dev) { SpaprMachineState *ms =3D SPAPR_MACHINE(hotplug_dev); PCDIMMDevice *dimm =3D PC_DIMM(dev); @@ -3642,7 +3642,7 @@ static void spapr_memory_plug(HotplugHandler *hotplug= _dev, DeviceState *dev) } } =20 -static void spapr_memory_pre_plug(HotplugHandler *hotplug_dev, DeviceState= *dev, +static void spapr_memory_pre_plug(const HotplugHandler *hotplug_dev, Devic= eState *dev, Error **errp) { SpaprMachineState *spapr =3D SPAPR_MACHINE(hotplug_dev); @@ -3807,7 +3807,7 @@ void spapr_memory_unplug_rollback(SpaprMachineState *= spapr, DeviceState *dev) /* Callback to be called during DRC release. */ void spapr_lmb_release(DeviceState *dev) { - HotplugHandler *hotplug_ctrl =3D qdev_get_hotplug_handler(dev); + const HotplugHandler *hotplug_ctrl =3D qdev_get_hotplug_handler(dev); SpaprMachineState *spapr =3D SPAPR_MACHINE(hotplug_ctrl); SpaprDimmState *ds =3D spapr_pending_dimm_unplugs_find(spapr, PC_DIMM(= dev)); =20 @@ -3832,7 +3832,7 @@ void spapr_lmb_release(DeviceState *dev) object_unparent(OBJECT(dev)); } =20 -static void spapr_memory_unplug(HotplugHandler *hotplug_dev, DeviceState *= dev) +static void spapr_memory_unplug(const HotplugHandler *hotplug_dev, DeviceS= tate *dev) { SpaprMachineState *spapr =3D SPAPR_MACHINE(hotplug_dev); SpaprDimmState *ds =3D spapr_pending_dimm_unplugs_find(spapr, PC_DIMM(= dev)); @@ -3845,7 +3845,7 @@ static void spapr_memory_unplug(HotplugHandler *hotpl= ug_dev, DeviceState *dev) spapr_pending_dimm_unplugs_remove(spapr, ds); } =20 -static void spapr_memory_unplug_request(HotplugHandler *hotplug_dev, +static void spapr_memory_unplug_request(const HotplugHandler *hotplug_dev, DeviceState *dev, Error **errp) { SpaprMachineState *spapr =3D SPAPR_MACHINE(hotplug_dev); @@ -3899,14 +3899,14 @@ static void spapr_memory_unplug_request(HotplugHand= ler *hotplug_dev, /* Callback to be called during DRC release. */ void spapr_core_release(DeviceState *dev) { - HotplugHandler *hotplug_ctrl =3D qdev_get_hotplug_handler(dev); + const HotplugHandler *hotplug_ctrl =3D qdev_get_hotplug_handler(dev); =20 /* Call the unplug handler chain. This can never fail. */ hotplug_handler_unplug(hotplug_ctrl, dev, &error_abort); object_unparent(OBJECT(dev)); } =20 -static void spapr_core_unplug(HotplugHandler *hotplug_dev, DeviceState *de= v) +static void spapr_core_unplug(const HotplugHandler *hotplug_dev, DeviceSta= te *dev) { MachineState *ms =3D MACHINE(hotplug_dev); CPUCore *cc =3D CPU_CORE(dev); @@ -3918,7 +3918,7 @@ static void spapr_core_unplug(HotplugHandler *hotplug= _dev, DeviceState *dev) } =20 static -void spapr_core_unplug_request(HotplugHandler *hotplug_dev, DeviceState *d= ev, +void spapr_core_unplug_request(const HotplugHandler *hotplug_dev, DeviceSt= ate *dev, Error **errp) { SpaprMachineState *spapr =3D SPAPR_MACHINE(OBJECT(hotplug_dev)); @@ -3988,7 +3988,7 @@ int spapr_core_dt_populate(SpaprDrc *drc, SpaprMachin= eState *spapr, return 0; } =20 -static void spapr_core_plug(HotplugHandler *hotplug_dev, DeviceState *dev) +static void spapr_core_plug(const HotplugHandler *hotplug_dev, DeviceState= *dev) { SpaprMachineState *spapr =3D SPAPR_MACHINE(OBJECT(hotplug_dev)); MachineClass *mc =3D MACHINE_GET_CLASS(spapr); @@ -4043,7 +4043,7 @@ static void spapr_core_plug(HotplugHandler *hotplug_d= ev, DeviceState *dev) =20 } =20 -static void spapr_core_pre_plug(HotplugHandler *hotplug_dev, DeviceState *= dev, +static void spapr_core_pre_plug(const HotplugHandler *hotplug_dev, DeviceS= tate *dev, Error **errp) { MachineState *machine =3D MACHINE(OBJECT(hotplug_dev)); @@ -4169,7 +4169,7 @@ static bool spapr_phb_placement(SpaprMachineState *sp= apr, uint32_t index, return true; } =20 -static bool spapr_phb_pre_plug(HotplugHandler *hotplug_dev, DeviceState *d= ev, +static bool spapr_phb_pre_plug(const HotplugHandler *hotplug_dev, DeviceSt= ate *dev, Error **errp) { SpaprMachineState *spapr =3D SPAPR_MACHINE(OBJECT(hotplug_dev)); @@ -4198,7 +4198,7 @@ static bool spapr_phb_pre_plug(HotplugHandler *hotplu= g_dev, DeviceState *dev, windows_supported, sphb->dma_liobn, errp); } =20 -static void spapr_phb_plug(HotplugHandler *hotplug_dev, DeviceState *dev) +static void spapr_phb_plug(const HotplugHandler *hotplug_dev, DeviceState = *dev) { SpaprPhbState *sphb =3D SPAPR_PCI_HOST_BRIDGE(dev); SpaprDrc *drc; @@ -4220,18 +4220,18 @@ static void spapr_phb_plug(HotplugHandler *hotplug_= dev, DeviceState *dev) =20 void spapr_phb_release(DeviceState *dev) { - HotplugHandler *hotplug_ctrl =3D qdev_get_hotplug_handler(dev); + const HotplugHandler *hotplug_ctrl =3D qdev_get_hotplug_handler(dev); =20 hotplug_handler_unplug(hotplug_ctrl, dev, &error_abort); object_unparent(OBJECT(dev)); } =20 -static void spapr_phb_unplug(HotplugHandler *hotplug_dev, DeviceState *dev) +static void spapr_phb_unplug(const HotplugHandler *hotplug_dev, DeviceStat= e *dev) { qdev_unrealize(dev); } =20 -static void spapr_phb_unplug_request(HotplugHandler *hotplug_dev, +static void spapr_phb_unplug_request(const HotplugHandler *hotplug_dev, DeviceState *dev, Error **errp) { SpaprPhbState *sphb =3D SPAPR_PCI_HOST_BRIDGE(dev); @@ -4251,7 +4251,7 @@ static void spapr_phb_unplug_request(HotplugHandler *= hotplug_dev, } =20 static -bool spapr_tpm_proxy_pre_plug(HotplugHandler *hotplug_dev, DeviceState *de= v, +bool spapr_tpm_proxy_pre_plug(const HotplugHandler *hotplug_dev, DeviceSta= te *dev, Error **errp) { SpaprMachineState *spapr =3D SPAPR_MACHINE(OBJECT(hotplug_dev)); @@ -4264,7 +4264,7 @@ bool spapr_tpm_proxy_pre_plug(HotplugHandler *hotplug= _dev, DeviceState *dev, return true; } =20 -static void spapr_tpm_proxy_plug(HotplugHandler *hotplug_dev, DeviceState = *dev) +static void spapr_tpm_proxy_plug(const HotplugHandler *hotplug_dev, Device= State *dev) { SpaprMachineState *spapr =3D SPAPR_MACHINE(OBJECT(hotplug_dev)); SpaprTpmProxy *tpm_proxy =3D SPAPR_TPM_PROXY(dev); @@ -4275,7 +4275,7 @@ static void spapr_tpm_proxy_plug(HotplugHandler *hotp= lug_dev, DeviceState *dev) spapr->tpm_proxy =3D tpm_proxy; } =20 -static void spapr_tpm_proxy_unplug(HotplugHandler *hotplug_dev, DeviceStat= e *dev) +static void spapr_tpm_proxy_unplug(const HotplugHandler *hotplug_dev, Devi= ceState *dev) { SpaprMachineState *spapr =3D SPAPR_MACHINE(OBJECT(hotplug_dev)); =20 @@ -4284,7 +4284,7 @@ static void spapr_tpm_proxy_unplug(HotplugHandler *ho= tplug_dev, DeviceState *dev spapr->tpm_proxy =3D NULL; } =20 -static void spapr_machine_device_plug(HotplugHandler *hotplug_dev, +static void spapr_machine_device_plug(const HotplugHandler *hotplug_dev, DeviceState *dev, Error **errp) { if (object_dynamic_cast(OBJECT(dev), TYPE_PC_DIMM)) { @@ -4298,7 +4298,7 @@ static void spapr_machine_device_plug(HotplugHandler = *hotplug_dev, } } =20 -static void spapr_machine_device_unplug(HotplugHandler *hotplug_dev, +static void spapr_machine_device_unplug(const HotplugHandler *hotplug_dev, DeviceState *dev, Error **errp) { if (object_dynamic_cast(OBJECT(dev), TYPE_PC_DIMM)) { @@ -4324,7 +4324,7 @@ bool spapr_memory_hot_unplug_supported(SpaprMachineSt= ate *spapr) spapr_ovec_empty(spapr->ov5_cas); } =20 -static void spapr_machine_device_unplug_request(HotplugHandler *hotplug_de= v, +static void spapr_machine_device_unplug_request(const HotplugHandler *hotp= lug_dev, DeviceState *dev, Error **= errp) { SpaprMachineState *sms =3D SPAPR_MACHINE(OBJECT(hotplug_dev)); @@ -4349,7 +4349,7 @@ static void spapr_machine_device_unplug_request(Hotpl= ugHandler *hotplug_dev, } } =20 -static void spapr_machine_device_pre_plug(HotplugHandler *hotplug_dev, +static void spapr_machine_device_pre_plug(const HotplugHandler *hotplug_de= v, DeviceState *dev, Error **errp) { if (object_dynamic_cast(OBJECT(dev), TYPE_PC_DIMM)) { @@ -4363,8 +4363,8 @@ static void spapr_machine_device_pre_plug(HotplugHand= ler *hotplug_dev, } } =20 -static HotplugHandler *spapr_get_hotplug_handler(MachineState *machine, - DeviceState *dev) +static const HotplugHandler *spapr_get_hotplug_handler(MachineState *machi= ne, + DeviceState *dev) { if (object_dynamic_cast(OBJECT(dev), TYPE_PC_DIMM) || object_dynamic_cast(OBJECT(dev), TYPE_SPAPR_CPU_CORE) || diff --git a/hw/ppc/spapr_nvdimm.c b/hw/ppc/spapr_nvdimm.c index 6647428391..542ed79497 100644 --- a/hw/ppc/spapr_nvdimm.c +++ b/hw/ppc/spapr_nvdimm.c @@ -64,7 +64,7 @@ struct SPAPRNVDIMMClass { void (*unrealize)(NVDIMMDevice *dimm, Error **errp); }; =20 -bool spapr_nvdimm_validate(HotplugHandler *hotplug_dev, NVDIMMDevice *nvdi= mm, +bool spapr_nvdimm_validate(const HotplugHandler *hotplug_dev, NVDIMMDevice= *nvdimm, uint64_t size, Error **errp) { const MachineClass *mc =3D MACHINE_GET_CLASS(hotplug_dev); diff --git a/hw/ppc/spapr_pci.c b/hw/ppc/spapr_pci.c index c1d4b7806e..f7fc544d35 100644 --- a/hw/ppc/spapr_pci.c +++ b/hw/ppc/spapr_pci.c @@ -1445,7 +1445,7 @@ static int spapr_dt_pci_device(SpaprPhbState *sphb, P= CIDevice *dev, /* Callback to be called during DRC release. */ void spapr_phb_remove_pci_device_cb(DeviceState *dev) { - HotplugHandler *hotplug_ctrl =3D qdev_get_hotplug_handler(dev); + const HotplugHandler *hotplug_ctrl =3D qdev_get_hotplug_handler(dev); =20 hotplug_handler_unplug(hotplug_ctrl, dev, &error_abort); object_unparent(OBJECT(dev)); @@ -1454,7 +1454,7 @@ void spapr_phb_remove_pci_device_cb(DeviceState *dev) int spapr_pci_dt_populate(SpaprDrc *drc, SpaprMachineState *spapr, void *fdt, int *fdt_start_offset, Error **errp) { - HotplugHandler *plug_handler =3D qdev_get_hotplug_handler(drc->dev); + const HotplugHandler *plug_handler =3D qdev_get_hotplug_handler(drc->d= ev); SpaprPhbState *sphb =3D SPAPR_PCI_HOST_BRIDGE(plug_handler); PCIDevice *pdev =3D PCI_DEVICE(drc->dev); =20 @@ -1521,7 +1521,7 @@ static bool bridge_has_valid_chassis_nr(Object *bridg= e, Error **errp) return true; } =20 -static void spapr_pci_pre_plug(HotplugHandler *plug_handler, +static void spapr_pci_pre_plug(const HotplugHandler *plug_handler, DeviceState *plugged_dev, Error **errp) { SpaprPhbState *phb =3D SPAPR_PCI_HOST_BRIDGE(DEVICE(plug_handler)); @@ -1556,7 +1556,7 @@ static void spapr_pci_pre_plug(HotplugHandler *plug_h= andler, } } =20 -static void spapr_pci_plug(HotplugHandler *plug_handler, +static void spapr_pci_plug(const HotplugHandler *plug_handler, DeviceState *plugged_dev, Error **errp) { SpaprPhbState *phb =3D SPAPR_PCI_HOST_BRIDGE(DEVICE(plug_handler)); @@ -1614,7 +1614,7 @@ static void spapr_pci_bridge_unplug(SpaprPhbState *ph= b, remove_drcs(phb, bus); } =20 -static void spapr_pci_unplug(HotplugHandler *plug_handler, +static void spapr_pci_unplug(const HotplugHandler *plug_handler, DeviceState *plugged_dev, Error **errp) { SpaprPhbState *phb =3D SPAPR_PCI_HOST_BRIDGE(DEVICE(plug_handler)); @@ -1639,7 +1639,7 @@ static void spapr_pci_unplug(HotplugHandler *plug_han= dler, qdev_unrealize(plugged_dev); } =20 -static void spapr_pci_unplug_request(HotplugHandler *plug_handler, +static void spapr_pci_unplug_request(const HotplugHandler *plug_handler, DeviceState *plugged_dev, Error **err= p) { SpaprPhbState *phb =3D SPAPR_PCI_HOST_BRIDGE(DEVICE(plug_handler)); diff --git a/hw/remote/machine.c b/hw/remote/machine.c index ced782f6a9..f79f5a0565 100644 --- a/hw/remote/machine.c +++ b/hw/remote/machine.c @@ -111,7 +111,7 @@ static void remote_machine_instance_init(Object *obj) s->auto_shutdown =3D true; } =20 -static void remote_machine_dev_unplug_cb(HotplugHandler *hotplug_dev, +static void remote_machine_dev_unplug_cb(const HotplugHandler *hotplug_dev, DeviceState *dev, Error **errp) { qdev_unrealize(dev); diff --git a/hw/riscv/virt.c b/hw/riscv/virt.c index f3a1cc5ba3..d4b501802f 100644 --- a/hw/riscv/virt.c +++ b/hw/riscv/virt.c @@ -1088,8 +1088,8 @@ static void virt_set_acpi(Object *obj, Visitor *v, co= nst char *name, visit_type_OnOffAuto(v, name, &s->acpi, errp); } =20 -static HotplugHandler *virt_machine_get_hotplug_handler(MachineState *mach= ine, - DeviceState *dev) +static const HotplugHandler * +virt_machine_get_hotplug_handler(MachineState *machine, DeviceState *dev) { MachineClass *mc =3D MACHINE_GET_CLASS(machine); RISCVVirtState *s =3D RISCV_VIRT_MACHINE(machine); @@ -1104,7 +1104,7 @@ static HotplugHandler *virt_machine_get_hotplug_handl= er(MachineState *machine, return NULL; } =20 -static void virt_machine_device_plug_cb(HotplugHandler *hotplug_dev, +static void virt_machine_device_plug_cb(const HotplugHandler *hotplug_dev, DeviceState *dev, Error **errp) { RISCVVirtState *s =3D RISCV_VIRT_MACHINE(hotplug_dev); diff --git a/hw/s390x/css-bridge.c b/hw/s390x/css-bridge.c index 440fefb7d0..e7cd9ac7b6 100644 --- a/hw/s390x/css-bridge.c +++ b/hw/s390x/css-bridge.c @@ -26,7 +26,7 @@ * (including sending a channel report to the guest) and remove the * device from the virtual css bus. */ -static void ccw_device_unplug(HotplugHandler *hotplug_dev, +static void ccw_device_unplug(const HotplugHandler *hotplug_dev, DeviceState *dev, Error **errp) { CcwDevice *ccw_dev =3D CCW_DEVICE(dev); diff --git a/hw/s390x/s390-pci-bus.c b/hw/s390x/s390-pci-bus.c index eff980fdfe..2eb4e8cec4 100644 --- a/hw/s390x/s390-pci-bus.c +++ b/hw/s390x/s390-pci-bus.c @@ -158,7 +158,7 @@ static void s390_pci_shutdown_notifier(Notifier *n, voi= d *opaque) =20 static void s390_pci_perform_unplug(S390PCIBusDevice *pbdev) { - HotplugHandler *hotplug_ctrl; + const HotplugHandler *hotplug_ctrl; =20 if (pbdev->pft =3D=3D ZPCI_PFT_ISM) { notifier_remove(&pbdev->shutdown_notifier); @@ -1005,8 +1005,8 @@ static bool s390_pci_alloc_idx(S390pciState *s, S390P= CIBusDevice *pbdev) return true; } =20 -static void s390_pcihost_pre_plug(HotplugHandler *hotplug_dev, DeviceState= *dev, - Error **errp) +static void s390_pcihost_pre_plug(const HotplugHandler *hotplug_dev, + DeviceState *dev, Error **errp) { S390pciState *s =3D S390_PCI_HOST_BRIDGE(hotplug_dev); =20 @@ -1079,7 +1079,7 @@ static int s390_pci_interp_plug(S390pciState *s, S390= PCIBusDevice *pbdev) return 0; } =20 -static void s390_pcihost_plug(HotplugHandler *hotplug_dev, DeviceState *de= v, +static void s390_pcihost_plug(const HotplugHandler *hotplug_dev, DeviceSta= te *dev, Error **errp) { S390pciState *s =3D S390_PCI_HOST_BRIDGE(hotplug_dev); @@ -1216,7 +1216,7 @@ static void s390_pcihost_plug(HotplugHandler *hotplug= _dev, DeviceState *dev, } } =20 -static void s390_pcihost_unplug(HotplugHandler *hotplug_dev, DeviceState *= dev, +static void s390_pcihost_unplug(const HotplugHandler *hotplug_dev, DeviceS= tate *dev, Error **errp) { S390pciState *s =3D S390_PCI_HOST_BRIDGE(hotplug_dev); @@ -1255,7 +1255,7 @@ static void s390_pcihost_unplug(HotplugHandler *hotpl= ug_dev, DeviceState *dev, } } =20 -static void s390_pcihost_unplug_request(HotplugHandler *hotplug_dev, +static void s390_pcihost_unplug_request(const HotplugHandler *hotplug_dev, DeviceState *dev, Error **errp) { diff --git a/hw/s390x/s390-virtio-ccw.c b/hw/s390x/s390-virtio-ccw.c index 17266779a6..7fb78d8fa1 100644 --- a/hw/s390x/s390-virtio-ccw.c +++ b/hw/s390x/s390-virtio-ccw.c @@ -343,8 +343,8 @@ static void ccw_init(MachineState *machine) =20 } =20 -static void s390_cpu_plug(HotplugHandler *hotplug_dev, - DeviceState *dev, Error **errp) +static void s390_cpu_plug(const HotplugHandler *hotplug_dev, + DeviceState *dev, Error **errp) { ERRP_GUARD(); MachineState *ms =3D MACHINE(hotplug_dev); @@ -608,7 +608,7 @@ out_lock: bql_lock(); } =20 -static void s390_machine_device_pre_plug(HotplugHandler *hotplug_dev, +static void s390_machine_device_pre_plug(const HotplugHandler *hotplug_dev, DeviceState *dev, Error **errp) { if (object_dynamic_cast(OBJECT(dev), TYPE_VIRTIO_MD_CCW)) { @@ -618,7 +618,7 @@ static void s390_machine_device_pre_plug(HotplugHandler= *hotplug_dev, } } =20 -static void s390_machine_device_plug(HotplugHandler *hotplug_dev, +static void s390_machine_device_plug(const HotplugHandler *hotplug_dev, DeviceState *dev, Error **errp) { S390CcwMachineState *s390ms =3D S390_CCW_MACHINE(hotplug_dev); @@ -648,7 +648,7 @@ static void s390_machine_device_plug(HotplugHandler *ho= tplug_dev, } } =20 -static void s390_machine_device_unplug_request(HotplugHandler *hotplug_dev, +static void s390_machine_device_unplug_request(const HotplugHandler *hotpl= ug_dev, DeviceState *dev, Error **e= rrp) { if (object_dynamic_cast(OBJECT(dev), TYPE_CPU)) { @@ -662,7 +662,7 @@ static void s390_machine_device_unplug_request(HotplugH= andler *hotplug_dev, } } =20 -static void s390_machine_device_unplug(HotplugHandler *hotplug_dev, +static void s390_machine_device_unplug(const HotplugHandler *hotplug_dev, DeviceState *dev, Error **errp) { if (object_dynamic_cast(OBJECT(dev), TYPE_VIRTIO_MD_CCW)) { @@ -715,8 +715,8 @@ static const CPUArchIdList *s390_possible_cpu_arch_ids(= MachineState *ms) return ms->possible_cpus; } =20 -static HotplugHandler *s390_get_hotplug_handler(MachineState *machine, - DeviceState *dev) +static const HotplugHandler *s390_get_hotplug_handler(MachineState *machin= e, + DeviceState *dev) { if (object_dynamic_cast(OBJECT(dev), TYPE_CPU) || object_dynamic_cast(OBJECT(dev), TYPE_VIRTIO_MD_CCW) || diff --git a/hw/s390x/virtio-ccw-md.c b/hw/s390x/virtio-ccw-md.c index 0b18b49bc4..70dbea819a 100644 --- a/hw/s390x/virtio-ccw-md.c +++ b/hw/s390x/virtio-ccw-md.c @@ -19,7 +19,7 @@ void virtio_ccw_md_pre_plug(VirtIOMDCcw *vmd, MachineState *ms, Error **er= rp) { DeviceState *dev =3D DEVICE(vmd); - HotplugHandler *bus_handler =3D qdev_get_bus_hotplug_handler(dev); + const HotplugHandler *bus_handler =3D qdev_get_bus_hotplug_handler(dev= ); MemoryDeviceState *md =3D MEMORY_DEVICE(vmd); Error *local_err =3D NULL; =20 @@ -48,7 +48,7 @@ void virtio_ccw_md_pre_plug(VirtIOMDCcw *vmd, MachineStat= e *ms, Error **errp) void virtio_ccw_md_plug(VirtIOMDCcw *vmd, MachineState *ms, Error **errp) { DeviceState *dev =3D DEVICE(vmd); - HotplugHandler *bus_handler =3D qdev_get_bus_hotplug_handler(dev); + const HotplugHandler *bus_handler =3D qdev_get_bus_hotplug_handler(dev= ); MemoryDeviceState *md =3D MEMORY_DEVICE(vmd); Error *local_err =3D NULL; =20 @@ -72,7 +72,7 @@ void virtio_ccw_md_unplug_request(VirtIOMDCcw *vmd, Machi= neState *ms, { VirtIOMDCcwClass *vmdc =3D VIRTIO_MD_CCW_GET_CLASS(vmd); DeviceState *dev =3D DEVICE(vmd); - HotplugHandler *bus_handler =3D qdev_get_bus_hotplug_handler(dev); + const HotplugHandler *bus_handler =3D qdev_get_bus_hotplug_handler(dev= ); const HotplugHandlerClass *hdc; Error *local_err =3D NULL; =20 @@ -112,7 +112,7 @@ void virtio_ccw_md_unplug_request(VirtIOMDCcw *vmd, Mac= hineState *ms, void virtio_ccw_md_unplug(VirtIOMDCcw *vmd, MachineState *ms, Error **errp) { DeviceState *dev =3D DEVICE(vmd); - HotplugHandler *bus_handler =3D qdev_get_bus_hotplug_handler(dev); + const HotplugHandler *bus_handler =3D qdev_get_bus_hotplug_handler(dev= ); MemoryDeviceState *md =3D MEMORY_DEVICE(vmd); Error *local_err =3D NULL; =20 diff --git a/hw/s390x/virtio-ccw.c b/hw/s390x/virtio-ccw.c index d82874ed27..30fb2c0681 100644 --- a/hw/s390x/virtio-ccw.c +++ b/hw/s390x/virtio-ccw.c @@ -1235,7 +1235,7 @@ static void virtio_ccw_busdev_unrealize(DeviceState *= dev) virtio_ccw_device_unrealize(_dev); } =20 -static void virtio_ccw_busdev_unplug(HotplugHandler *hotplug_dev, +static void virtio_ccw_busdev_unplug(const HotplugHandler *hotplug_dev, DeviceState *dev, Error **errp) { VirtioCcwDevice *_dev =3D to_virtio_ccw_dev_fast(dev); diff --git a/hw/scsi/virtio-scsi.c b/hw/scsi/virtio-scsi.c index 132f833226..d7e2662aa7 100644 --- a/hw/scsi/virtio-scsi.c +++ b/hw/scsi/virtio-scsi.c @@ -1144,14 +1144,14 @@ static void virtio_scsi_change(SCSIBus *bus, SCSIDe= vice *dev, SCSISense sense) } } =20 -static void virtio_scsi_pre_hotplug(HotplugHandler *hotplug_dev, +static void virtio_scsi_pre_hotplug(const HotplugHandler *hotplug_dev, DeviceState *dev, Error **errp) { SCSIDevice *sd =3D SCSI_DEVICE(dev); sd->hba_supports_iothread =3D true; } =20 -static void virtio_scsi_hotplug(HotplugHandler *hotplug_dev, DeviceState *= dev, +static void virtio_scsi_hotplug(const HotplugHandler *hotplug_dev, DeviceS= tate *dev, Error **errp) { VirtIODevice *vdev =3D VIRTIO_DEVICE(hotplug_dev); @@ -1183,7 +1183,7 @@ static void virtio_scsi_hotplug(HotplugHandler *hotpl= ug_dev, DeviceState *dev, } } =20 -static void virtio_scsi_hotunplug(HotplugHandler *hotplug_dev, DeviceState= *dev, +static void virtio_scsi_hotunplug(const HotplugHandler *hotplug_dev, Devic= eState *dev, Error **errp) { VirtIODevice *vdev =3D VIRTIO_DEVICE(hotplug_dev); diff --git a/hw/scsi/vmw_pvscsi.c b/hw/scsi/vmw_pvscsi.c index 05f93171cd..77c9b843b4 100644 --- a/hw/scsi/vmw_pvscsi.c +++ b/hw/scsi/vmw_pvscsi.c @@ -612,7 +612,7 @@ pvscsi_send_msg(PVSCSIState *s, SCSIDevice *dev, uint32= _t msg_type) } =20 static void -pvscsi_hotplug(HotplugHandler *hotplug_dev, DeviceState *dev, Error **errp) +pvscsi_hotplug(const HotplugHandler *hotplug_dev, DeviceState *dev, Error = **errp) { PVSCSIState *s =3D PVSCSI(hotplug_dev); =20 @@ -620,7 +620,7 @@ pvscsi_hotplug(HotplugHandler *hotplug_dev, DeviceState= *dev, Error **errp) } =20 static void -pvscsi_hot_unplug(HotplugHandler *hotplug_dev, DeviceState *dev, Error **e= rrp) +pvscsi_hot_unplug(const HotplugHandler *hotplug_dev, DeviceState *dev, Err= or **errp) { PVSCSIState *s =3D PVSCSI(hotplug_dev); =20 diff --git a/hw/virtio/virtio-md-pci.c b/hw/virtio/virtio-md-pci.c index aa5b11c0f6..97ea0ec7b3 100644 --- a/hw/virtio/virtio-md-pci.c +++ b/hw/virtio/virtio-md-pci.c @@ -19,7 +19,7 @@ void virtio_md_pci_pre_plug(VirtIOMDPCI *vmd, MachineState *ms, Error **er= rp) { DeviceState *dev =3D DEVICE(vmd); - HotplugHandler *bus_handler =3D qdev_get_bus_hotplug_handler(dev); + const HotplugHandler *bus_handler =3D qdev_get_bus_hotplug_handler(dev= ); MemoryDeviceState *md =3D MEMORY_DEVICE(vmd); Error *local_err =3D NULL; =20 @@ -47,7 +47,7 @@ void virtio_md_pci_pre_plug(VirtIOMDPCI *vmd, MachineStat= e *ms, Error **errp) void virtio_md_pci_plug(VirtIOMDPCI *vmd, MachineState *ms, Error **errp) { DeviceState *dev =3D DEVICE(vmd); - HotplugHandler *bus_handler =3D qdev_get_bus_hotplug_handler(dev); + const HotplugHandler *bus_handler =3D qdev_get_bus_hotplug_handler(dev= ); MemoryDeviceState *md =3D MEMORY_DEVICE(vmd); Error *local_err =3D NULL; =20 @@ -71,7 +71,7 @@ void virtio_md_pci_unplug_request(VirtIOMDPCI *vmd, Machi= neState *ms, { VirtIOMDPCIClass *vmdc =3D VIRTIO_MD_PCI_GET_CLASS(vmd); DeviceState *dev =3D DEVICE(vmd); - HotplugHandler *bus_handler =3D qdev_get_bus_hotplug_handler(dev); + const HotplugHandler *bus_handler =3D qdev_get_bus_hotplug_handler(dev= ); const HotplugHandlerClass *hdc; Error *local_err =3D NULL; =20 @@ -110,7 +110,7 @@ void virtio_md_pci_unplug_request(VirtIOMDPCI *vmd, Mac= hineState *ms, void virtio_md_pci_unplug(VirtIOMDPCI *vmd, MachineState *ms, Error **errp) { DeviceState *dev =3D DEVICE(vmd); - HotplugHandler *bus_handler =3D qdev_get_bus_hotplug_handler(dev); + const HotplugHandler *bus_handler =3D qdev_get_bus_hotplug_handler(dev= ); MemoryDeviceState *md =3D MEMORY_DEVICE(vmd); Error *local_err =3D NULL; =20 diff --git a/hw/xen/xen-bus.c b/hw/xen/xen-bus.c index 1762816bf4..8def3bb68b 100644 --- a/hw/xen/xen-bus.c +++ b/hw/xen/xen-bus.c @@ -374,7 +374,7 @@ fail: g_free(key); } =20 -static void xen_bus_unplug_request(HotplugHandler *hotplug, +static void xen_bus_unplug_request(const HotplugHandler *hotplug, DeviceState *dev, Error **errp) { diff --git a/stubs/hotplug-stubs.c b/stubs/hotplug-stubs.c index 0f592ee139..32b4af7997 100644 --- a/stubs/hotplug-stubs.c +++ b/stubs/hotplug-stubs.c @@ -14,19 +14,19 @@ #include "qemu/osdep.h" #include "hw/core/qdev.h" =20 -HotplugHandler *qdev_get_hotplug_handler(DeviceState *dev) +const HotplugHandler *qdev_get_hotplug_handler(DeviceState *dev) { return NULL; } =20 -void hotplug_handler_pre_plug(HotplugHandler *plug_handler, +void hotplug_handler_pre_plug(const HotplugHandler *plug_handler, DeviceState *plugged_dev, Error **errp) { g_assert_not_reached(); } =20 -void hotplug_handler_plug(HotplugHandler *plug_handler, +void hotplug_handler_plug(const HotplugHandler *plug_handler, DeviceState *plugged_dev, Error **errp) { diff --git a/system/qdev-monitor.c b/system/qdev-monitor.c index 0c5502d45b..a62ad23ecf 100644 --- a/system/qdev-monitor.c +++ b/system/qdev-monitor.c @@ -917,7 +917,7 @@ static DeviceState *find_device_state(const char *id, b= ool use_generic_error, =20 void qdev_unplug(DeviceState *dev, Error **errp) { - HotplugHandler *hotplug_ctrl; + const HotplugHandler *hotplug_ctrl; const HotplugHandlerClass *hdc; Error *local_err =3D NULL; =20 --=20 MST From nobody Sat Sep 26 20:50:17 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=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1789083374; cv=none; d=zohomail.com; s=zohoarc; b=BUnvAB6FyAl+5TpdbWeoIiK6LVN6fcATklf1jMFloBW81BcXNnVjjKQq4XeRjdySzS1yiD1dGGbVTtn4mlVZr6taV8orcNM2RdZlgAhOfD5m6UKIau9ZIkXbNwnrBg5VWXf6r71VHGOLX7HXp18Y1Zx9FAmSGaXQmZ2PiljfAxA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1789083374; h=Content-Type: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=KaGnA6790D1crogtaW20lAmdvIS1bCL1ahQfy0qBOJg=; b=a7Qd/VyMQd6RmlgFUuYu8FiDOkEyxyMXeDQdjYhzV3QNl+KupPSH1JbvcMHX2hjgegVPUZ637kowVbaz20hRKu3Ui6N80zGZSZU+wvRADQW8vZKdQ50t1MOIc5ZzvAuvmqZI3rELgb0pboJiKw84/mC2pCkPWZUawgglRXrVXoY= 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 lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1789083374616326.547786635395; Thu, 10 Sep 2026 16:36:14 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1x4nlR-000631-KT; Thu, 10 Sep 2026 19:01:34 -0400 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 1x4lWk-0006ao-63 for qemu-devel@nongnu.org; Thu, 10 Sep 2026 16:38:07 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1x4lWQ-0004hb-1I for qemu-devel@nongnu.org; Thu, 10 Sep 2026 16:37:30 -0400 Received: from mail-wm1-f71.google.com (mail-wm1-f71.google.com [209.85.128.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-689-yAeET3HaMHSeuLFfDAoRaw-1; Thu, 10 Sep 2026 16:15:33 -0400 Received: by mail-wm1-f71.google.com with SMTP id 5b1f17b1804b1-495529a93f9so1673145e9.3 for ; Thu, 10 Sep 2026 13:15:33 -0700 (PDT) Received: from redhat.com (IGLD-80-230-79-236.inter.net.il. [80.230.79.236]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-486eb3602eesm685482f8f.34.2026.09.10.13.15.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Sep 2026 13:15:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1789072563; 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=KaGnA6790D1crogtaW20lAmdvIS1bCL1ahQfy0qBOJg=; b=DTMPOq6ad+rhXmgAOEMMdKokquHKUVokUjkLP+0mGUPSAwe/Kn9vZOnchK9FrFtzTQtGkQ 7i/ciWYo3xBEpCC9BT7H6q5f4mEAbfdklgev679OIyKk1kqVNZlvyF7DesVKtLlzAPwBZs BjE6p6n+3t4KZpDFEGVFBE8khYdW/aQ= X-MC-Unique: yAeET3HaMHSeuLFfDAoRaw-1 X-Mimecast-MFC-AGG-ID: yAeET3HaMHSeuLFfDAoRaw_1789071333 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=google; t=1789071332; x=1789676132; 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=KaGnA6790D1crogtaW20lAmdvIS1bCL1ahQfy0qBOJg=; b=k9tgZJ7+ufwarb3mlvWoOgTK1IyZrw2oB1qYk1LKyqfJMbWBSfvYe+jdR4ROEKsi64 wkXDRI7ZOx6bJQ8N9peEsge+xN4hZB73CiiBNyWbdoakX7VA1Qre5SE/Os/7RC6Nenie bhy4dDiltG5zmuLm4FHVRIodMChcb1Kv5A8HsiZCGtlVTYcUGqRdgGycR6Y2N93tkLPT xjDRKqqYxvsgr32rm2dcsHIww21lYtBTkwOzwNgmt6M9lSdiRp0df4/8H8f45y60+wm1 if8lhE+o5ygjhenNd5MFZvtvTFzOvGIkC3db2yJBVno+NKsmy76QHNJHJso+OOqyGXSI a91w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1789071332; x=1789676132; 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=KaGnA6790D1crogtaW20lAmdvIS1bCL1ahQfy0qBOJg=; b=sC9AU/66hOiL1KqvWr8bpcV/YLWP2oe0PG1/iHygLeFHEuOlLIpWh41MsOSxea0mCj EGSbGVsYF4T9mr9OnI3gLveSbJ9adWL0hKE2DWjxSUA/7gqrXJC5IWEeXXP1alQ7TKY7 Td0gf8aFYbhGW1PQQWHVVk58YbjCKORerjq2+ct1BEXGiXqDq3YjiwQFpG54km8g/pK0 eAZeiP24WGrE92ZlUDoaTEImaJZr7h06mtKWxwuqwwNJ+KBvlfQ2TZXz9ar7wN4o7hqX Y/sXj2rzz/vx/LJ5USviqWUGoFH8ADrm4xfXSUhlqF2qb9kDKNa1q0uJNserBabH9ueq H2mg== X-Gm-Message-State: AFuF++lNTO6dqLHEJB8ALALDe3JXIRqh3yIeafBKksLoKHo2Pf2lKGY1 69g07Rnvl7gQ1fhqMOK7YVGBmnoHpIW3Ud2iwwqvzRMNCk4rNOrbPGMxPymo6B9o8RzA3Cubwfx 3lRtUaA4XdfsDceqRhQFqPpHdBpodrnS8McseWgYEe3OeWfmXtB1U+2WHuYkfEBTh9Q0lDcEPtn FNdgJuq5JHj9kEfhchCQHUvcxzcZZ0UfQmDw== X-Gm-Gg: AYBFou2BriTFf0mDZW//UOSOTBNXcGPymmvRiUOxrs4Zht30yqNuLScQb8JauT5ZP0+ 57nWb1yu20l4eItdGEhnNYrxczaMW8zwHIltoKwtDLWNXC8obL6WLIygim88IDmqriBEiTNtLm7 2lIPDZX21ZbUAReDmW8SFrSV+dnz0G1iy4A6+O5oBxyC48b9m8dRMePl7Qz6oz2rwL9l5+PAvGv Wp8vS3lQolv8ZfvEQqAXcI5akU9RWQbAOa0kpMW57Z98bBJvAtgAAxSwEQRG4oiROetM1qoehQ7 rGr1WmAmmRm6XPyJ+YKYxW4P2hQ2z5h4LXHu+tur0/A+v9kRQf6AneuhutYnYenVY7s0WIMcXLg MuUOj3yBUJdeJFllyaa2T+VM= X-Received: by 2002:a05:600c:c48f:b0:49c:cee2:a508 with SMTP id 5b1f17b1804b1-49e619c18edmr8760225e9.16.1789071332448; Thu, 10 Sep 2026 13:15:32 -0700 (PDT) X-Received: by 2002:a05:600c:c48f:b0:49c:cee2:a508 with SMTP id 5b1f17b1804b1-49e619c18edmr8759605e9.16.1789071331953; Thu, 10 Sep 2026 13:15:31 -0700 (PDT) Date: Thu, 10 Sep 2026 16:15:29 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Weimin Xiong , Jason Wang Subject: [PULL 81/90] net/tap-solaris: Fix resource leaks on error paths Message-ID: <63436f0c382d7e514711c6853d6bbac469097a9f.1789071043.git.mst@redhat.com> References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-Mailer: git-send-email 2.51.2.2891.g4157995a80.dirty X-Mutt-Fcc: =sent 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=170.10.129.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com 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, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=0.001, SPF_HELO_PASS=-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-Zoho-Virus-Status: 1 X-Zoho-AV-Stamp: zmail-av-0.2.13.1.5.4/289.74.40 X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1789083377012158500 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Signed-off-by: Weimin Xiong Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- net/tap-solaris.c | 69 ++++++++++++++++++++++++++++++++--------------- 1 file changed, 48 insertions(+), 21 deletions(-) diff --git a/net/tap-solaris.c b/net/tap-solaris.c index 8704b1084b..2c6c7af15e 100644 --- a/net/tap-solaris.c +++ b/net/tap-solaris.c @@ -60,8 +60,6 @@ ssize_t tap_read_packet(int tapfd, uint8_t *buf, int maxl= en) */ static int tap_alloc(char *dev, size_t dev_size, Error **errp) { - /* FIXME leaks like a sieve on error paths */ - /* FIXME suspicious: many errors are reported, then ignored */ int tap_fd, if_fd, ppa =3D -1; static int ip_fd =3D 0; char *ptr; @@ -102,45 +100,61 @@ static int tap_alloc(char *dev, size_t dev_size, Erro= r **errp) strioc_ppa.ic_timout =3D 0; strioc_ppa.ic_len =3D sizeof(ppa); strioc_ppa.ic_dp =3D (char *)&ppa; - if ((ppa =3D ioctl (tap_fd, I_STR, &strioc_ppa)) < 0) + if ((ppa =3D ioctl (tap_fd, I_STR, &strioc_ppa)) < 0) { error_report("Can't assign new interface"); + goto fail_tap_fd; + } =20 if_fd =3D RETRY_ON_EINTR(open("/dev/tap", O_RDWR, 0)); if (if_fd < 0) { error_setg_file_open(errp, errno, "/dev/tap"); - return -1; + goto fail_tap_fd; } if(ioctl(if_fd, I_PUSH, "ip") < 0){ error_setg(errp, "Can't push IP module"); - return -1; + goto fail_if_fd; } =20 - if (ioctl(if_fd, SIOCGLIFFLAGS, &ifr) < 0) + if (ioctl(if_fd, SIOCGLIFFLAGS, &ifr) < 0) { error_report("Can't get flags"); + goto fail_if_fd; + } =20 - snprintf (actual_name, 32, "tap%d", ppa); + snprintf(actual_name, 32, "tap%d", ppa); pstrcpy(ifr.lifr_name, sizeof(ifr.lifr_name), actual_name); =20 ifr.lifr_ppa =3D ppa; - /* Assign ppa according to the unit number returned by tun device */ - - if (ioctl (if_fd, SIOCSLIFNAME, &ifr) < 0) + if (ioctl(if_fd, SIOCSLIFNAME, &ifr) < 0) { error_report("Can't set PPA %d", ppa); - if (ioctl(if_fd, SIOCGLIFFLAGS, &ifr) <0) + goto fail_if_fd; + } + + if (ioctl(if_fd, SIOCGLIFFLAGS, &ifr) < 0) { error_report("Can't get flags"); + goto fail_if_fd; + } + /* Push arp module to if_fd */ - if (ioctl (if_fd, I_PUSH, "arp") < 0) + if (ioctl(if_fd, I_PUSH, "arp") < 0) { error_report("Can't push ARP module (2)"); + goto fail_if_fd; + } =20 /* Push arp module to ip_fd */ - if (ioctl (ip_fd, I_POP, NULL) < 0) + if (ioctl(ip_fd, I_POP, NULL) < 0) { error_report("I_POP failed"); - if (ioctl (ip_fd, I_PUSH, "arp") < 0) + goto fail_if_fd; + } + if (ioctl(ip_fd, I_PUSH, "arp") < 0) { error_report("Can't push ARP module (3)"); + goto fail_if_fd; + } /* Open arp_fd */ arp_fd =3D RETRY_ON_EINTR(open("/dev/tap", O_RDWR, 0)); - if (arp_fd < 0) + if (arp_fd < 0) { error_report("Can't open %s", "/dev/tap"); + goto fail_if_fd; + } =20 /* Set ifname to arp */ strioc_if.ic_cmd =3D SIOCSLIFNAME; @@ -149,32 +163,45 @@ static int tap_alloc(char *dev, size_t dev_size, Erro= r **errp) strioc_if.ic_dp =3D (char *)𝔦 if (ioctl(arp_fd, I_STR, &strioc_if) < 0){ error_report("Can't set ifname to arp"); + goto fail_arp_fd; } =20 if((ip_muxid =3D ioctl(ip_fd, I_LINK, if_fd)) < 0){ error_setg(errp, "Can't link TAP device to IP"); - return -1; + goto fail_arp_fd; } =20 - if ((arp_muxid =3D ioctl (ip_fd, link_type, arp_fd)) < 0) + if ((arp_muxid =3D ioctl(ip_fd, link_type, arp_fd)) < 0) { error_report("Can't link TAP device to ARP"); + goto fail_ip_muxid; + } =20 - close (if_fd); + close(if_fd); =20 memset(&ifr, 0x0, sizeof(ifr)); pstrcpy(ifr.lifr_name, sizeof(ifr.lifr_name), actual_name); ifr.lifr_ip_muxid =3D ip_muxid; ifr.lifr_arp_muxid =3D arp_muxid; =20 - if (ioctl (ip_fd, SIOCSLIFMUXID, &ifr) < 0) + if (ioctl(ip_fd, SIOCSLIFMUXID, &ifr) < 0) { - ioctl (ip_fd, I_PUNLINK , arp_muxid); - ioctl (ip_fd, I_PUNLINK, ip_muxid); + ioctl(ip_fd, I_PUNLINK, arp_muxid); + ioctl(ip_fd, I_PUNLINK, ip_muxid); error_report("Can't set multiplexor id"); } =20 snprintf(dev, dev_size, "tap%d", ppa); return tap_fd; + +fail_ip_muxid: + ioctl(ip_fd, I_PUNLINK, ip_muxid); +fail_arp_fd: + close(arp_fd); +fail_if_fd: + close(if_fd); +fail_tap_fd: + close(tap_fd); + return -1; } =20 int tap_open(char *ifname, int ifname_size, int *vnet_hdr, --=20 MST From nobody Sat Sep 26 20:50:17 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=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1789077267; cv=none; d=zohomail.com; s=zohoarc; b=AepRupXiYTwqcgOwK2TJWA0O5VPlUybrj1Ec6dV+4GwQWNNU131DVB/WqJV23xkzmLch7bdQdVh46RnuWbUSGBPbqhGqZ3t9sWlMB5xYgU+ehislEbhIR0ehx7NjBvVh4r5NsotSEf3/sSxx84qvXjSjTafLTs/PkxA8cuZKlx0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1789077267; h=Content-Type: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=hzJidFmu3cCZ/gNI5oejlvZ2j1X9hxYd2KmntrLLK2Q=; b=aq2/QLOeexhVR/n+K0UDObmr87w338nyrQp/cfBSFZhCg/ft7PKjm/tWpTzxllKmRssdIRE/mPZljFsw8FMI99gbS1DYB4OHm2KC8phPbBEEbUbgh2mu94b0x8KIdP977uN/F7F/ZnODQykGRtV6ZD7dimc+K+xil1hMJJLs/ng= 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 lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1789077267143541.9786142366629; Thu, 10 Sep 2026 14:54:27 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1x4mel-0005Fd-66; Thu, 10 Sep 2026 17:50:22 -0400 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 1x4lM2-00036B-JI for qemu-devel@nongnu.org; Thu, 10 Sep 2026 16:26:55 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1x4lLl-0000SG-LF for qemu-devel@nongnu.org; Thu, 10 Sep 2026 16:26:29 -0400 Received: from mail-wm1-f71.google.com (mail-wm1-f71.google.com [209.85.128.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-558-1kID34PRPESxyiRWuhoV7w-1; Thu, 10 Sep 2026 16:15:36 -0400 Received: by mail-wm1-f71.google.com with SMTP id 5b1f17b1804b1-49991beee7aso1750805e9.2 for ; Thu, 10 Sep 2026 13:15:36 -0700 (PDT) Received: from redhat.com (IGLD-80-230-79-236.inter.net.il. [80.230.79.236]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-486eb35f3d9sm687758f8f.35.2026.09.10.13.15.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Sep 2026 13:15:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1789071781; 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=hzJidFmu3cCZ/gNI5oejlvZ2j1X9hxYd2KmntrLLK2Q=; b=Xm6JJe8jZACKZildy3sfVvlAL/ANL3nu7YkoVHZkU0lHXKeyVVOWtg0EtGZUDAmi/etr8F VheapQ2RzOgiWPabZw6dyRlRSrUoQL6GKI+G1qcxyk3uCVOg2We31igsn2cykeD0Po94h/ JFUykhdcxrTWomQTDjx+BzXi88RGz4E= X-MC-Unique: 1kID34PRPESxyiRWuhoV7w-1 X-Mimecast-MFC-AGG-ID: 1kID34PRPESxyiRWuhoV7w_1789071335 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=google; t=1789071335; x=1789676135; 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=hzJidFmu3cCZ/gNI5oejlvZ2j1X9hxYd2KmntrLLK2Q=; b=oRWE6o4Bpw70KIvVcA2DSimBJz6gYOeaT1musq707vIoK/KCPjcn01mD9vs3/2OlFo tbkCUSv3jcBvblyMFKAapjy7UvK92rV5TglQy6JfMk4XjrpDjlSnlgLa29rjv1bRY1hG OIyw1r4839EhqcP+jdG6ntcNPqvzPMHe31MFwoX/8dFsC5apw9HLnfeuMWYeEMRBbk1d ZIVCQidJCKbhwzXNUzfGp1KghVEfI9E8d8EpBFiTFcIgK6gPKeedYVdolEypGFP8VYW9 2pfdrcw0Z9TQFIBYZXMQPbO63gDzdKaIxprwiOM4ZLkoolQnvV0vjyFukl1vkHZu8es0 FIEw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1789071335; x=1789676135; 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=hzJidFmu3cCZ/gNI5oejlvZ2j1X9hxYd2KmntrLLK2Q=; b=YQfA91ITSXs4Bol6il6hRSOuDD0EQLCVfjq7/zsLBBus6Szru1aK9hxnwjwodPI3I5 Evfr9hAMyh+yxfLbiXqd7iB51Q9QHZJmNFeqzppspBaxcfhFPI6Ch3L27jp8EsgZMSzq +jG+cl0EnQ5u4CX3vS8jeJlZJnc1Q6I0soVos1MwH7zze/Ab2P6i8Rt2JYhmPdPZ64b1 g21rDllQUzvLVy48cPeXhzpZ4yl3v9DrNjJvOZIROEqaFE6n8qcFU7V1pO06RM7bfngi q+rvOKFAKxV20WGH6Voqe8in3kp7sdG0i4hge7S78PSS/iByK2xLy8wcSYsnrzBa+O08 Zbrg== X-Gm-Message-State: AFuF++k7WWGbJB8BTNnIv7c0seBXjmxEvaCUgdS5QmYEDmqYWC/QMKR+ T6j7AEopfCTTfcj9LwQIPlwb3UXc98fXvfMZDwKV8sDpJWB8mqY8n4deKlfjCHK3TufEShXz81r d1tH75Twga9lG0FsHf21/7RdbF5vZYcZXzFTfH63LhdVgQqRPl851HD/n1UXVGQgy7ge7oUBS7n n8gblIs2Gti5lM1HR9Z/8zvuDlChhthHhhBQ== X-Gm-Gg: AYBFou10YgX/fTO5WFdpQU4fwbjRhHEyHhFOAc8Q9lKT00pk3RokHpO7nTDYKCkZF2Y v3yhjJUvW7maRMcur01h7ZYYLnL8VfXVjeWpJc0w6z/o85lmrP910EX4WUrw5AkPX9BBHyL6cyW M7mCPq68TpVuO32PRRccb7BDs18WKz+FswLnsR/KCKFHxlo/c4G+CWzaF7CN/DL2/VKMORs1Bwb jRwWmuk/GJ4pBGXLE+axMdZary1cavkJ3L95bOPSE1EnV6oP1xN8T/OsA59qyTO5vsRUWNRXgLg v12Hm1dCxRPifPwmAY1ANH3UOXQ8nvswiGrwAZkKHb6woyl2G1y7UD9U0n5hXpmdY298yLcZnPm D+Auy/E8S1aFynwtfeVcuC4U= X-Received: by 2002:a05:600c:19c8:b0:499:b65e:49c9 with SMTP id 5b1f17b1804b1-49e619f3ae1mr12235575e9.10.1789071334908; Thu, 10 Sep 2026 13:15:34 -0700 (PDT) X-Received: by 2002:a05:600c:19c8:b0:499:b65e:49c9 with SMTP id 5b1f17b1804b1-49e619f3ae1mr12234815e9.10.1789071334417; Thu, 10 Sep 2026 13:15:34 -0700 (PDT) Date: Thu, 10 Sep 2026 16:15:32 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Jason Wang , Yuri Benditovich Subject: [PULL 82/90] virtio-net: validate IHL in virtio_net_rsc_extract_unit4 before use Message-ID: <58a9bdd9c75642568bcf364114b3bc704b6fbc99.1789071043.git.mst@redhat.com> References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-Mailer: git-send-email 2.51.2.2891.g4157995a80.dirty X-Mutt-Fcc: =sent 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=170.10.129.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com 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, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=0.001, SPF_HELO_PASS=-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-Zoho-Virus-Status: 1 X-Zoho-AV-Stamp: zmail-av-0.2.13.1.5.4/289.74.40 X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1789077268045158500 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" virtio_net_rsc_extract_unit4() uses the IPv4 IHL nibble from the wire to compute the TCP header offset, but the caller's length check only guarantees space for a minimum 20-byte IP header. A crafted IHL of 15 causes a read 32 bytes past a 66-byte buffer when the frame was parked in net/queue.c's exact-size allocation. virtio_net_rsc_sanity_check4() rejects IHL !=3D 5 on the next line, but runs after the OOB read already happened. Validate IHL before using it as an offset. Since virtio_net_rsc_sanity_check4() only accepts IHL =3D=3D 5 anyway, reject anything else early and let the caller fall through to the bypass path. Fixes: 2974e916df ("virtio-net: support RSC v4/v6 tcp traffic for Windows H= CK") Cc: Jason Wang Cc: Yuri Benditovich Resolves: https://gitlab.com/qemu-project/qemu/-/work_items/4166 Signed-off-by: Michael S. Tsirkin --- hw/net/virtio-net.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/hw/net/virtio-net.c b/hw/net/virtio-net.c index 986ceff514..19f453fb7d 100644 --- a/hw/net/virtio-net.c +++ b/hw/net/virtio-net.c @@ -2104,6 +2104,14 @@ static void virtio_net_rsc_extract_unit4(VirtioNetRs= cChain *chain, unit->ip =3D (void *)ip; ip_hdrlen =3D (ip->ip_ver_len & 0xF) << 2; unit->ip_plen =3D &ip->ip_len; + + if (ip_hdrlen !=3D sizeof(struct ip_header)) { + unit->tcp =3D NULL; + unit->tcp_hdrlen =3D 0; + unit->payload =3D 0; + return; + } + unit->tcp =3D (struct tcp_header *)(((uint8_t *)unit->ip) + ip_hdrlen); unit->tcp_hdrlen =3D (htons(unit->tcp->th_offset_flags) & 0xF000) >> 1= 0; unit->payload =3D read_unit_ip_len(unit) - ip_hdrlen - unit->tcp_hdrle= n; --=20 MST From nobody Sat Sep 26 20:50:17 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=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1789078623; cv=none; d=zohomail.com; s=zohoarc; b=NX5TJDvaSUbfH7+NElc4KHu7h5FSJBUlub1AePAxs3u3HfUa5DtIwK6L0E6Eym14grFq7qXMqW7gyJL3SD8o0NXMPQXMgGZUGMUUZFtm0DtyD/D7rW3KVx6NMF/Db9kOZJCOxUyFtUCwm8ZT0uG4FwY+M5rCrqVzmsMi5Z9WBSM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1789078623; h=Content-Type: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=bUsqkqSEg6ABsPYNlxkrlq9VUldheG28GlxZUj5JBUE=; b=UOUg69l7aLo8CE4rMqxJnLmG75vzkeHwSfmCrjyS89dNTjqv6OrBh3ceds2qioxrGJZMLmnCLnoEfUcwHcFuhb3ohU0zoW+Ny6v07Cav7fc8oJfIhnatpFZD7U83dFtCetqB6rTzdUjLdCM7NqlOhwn9fyCxFqxLOqZlD17dlMg= 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 lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1789078623786354.5264754162489; Thu, 10 Sep 2026 15:17:03 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1x4n3R-0002ba-Oj; Thu, 10 Sep 2026 18:15:57 -0400 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 1x4lW7-0006T8-KC for qemu-devel@nongnu.org; Thu, 10 Sep 2026 16:37:23 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1x4lVn-0004Qa-2E for qemu-devel@nongnu.org; Thu, 10 Sep 2026 16:36:53 -0400 Received: from mail-wr1-f71.google.com (mail-wr1-f71.google.com [209.85.221.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-390-izVNm3pFPtSsp940VrXz4A-1; Thu, 10 Sep 2026 16:15:40 -0400 Received: by mail-wr1-f71.google.com with SMTP id ffacd0b85a97d-482e8e1ac69so683724f8f.0 for ; Thu, 10 Sep 2026 13:15:38 -0700 (PDT) Received: from redhat.com (IGLD-80-230-79-236.inter.net.il. [80.230.79.236]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-486eb33fc02sm749669f8f.16.2026.09.10.13.15.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Sep 2026 13:15:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1789072503; 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=bUsqkqSEg6ABsPYNlxkrlq9VUldheG28GlxZUj5JBUE=; b=HkBNZTWsTv0yxo2/tX+ija3kpqXKIRLU1J1dGpNPR3NKrPUh5//KdcvitndvLclyI57dRg nwHmMCBVmc6V0Jorw4OLpa2HJ1hTUqFsyTURtIVdH+UKnibbUpXZvzTfS3scTaUtef9RFR sfu70QGYzJRkX/c21TJ44sJ0/IfJb+I= X-MC-Unique: izVNm3pFPtSsp940VrXz4A-1 X-Mimecast-MFC-AGG-ID: izVNm3pFPtSsp940VrXz4A_1789071338 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=google; t=1789071337; x=1789676137; darn=nongnu.org; h=in-reply-to:content-transfer-encoding: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=bUsqkqSEg6ABsPYNlxkrlq9VUldheG28GlxZUj5JBUE=; b=msGXNZOxGRInMU4T0buyu5dwW+l4eIErtii0edoAhA597tptX8+goKr6zhrEVSl4pr ziZ++M3Zjv1Dh2SVj8oG7EsFXnkaMeXOOouiPmdDBgp4aMnPwV7b7FxtWVTOAX2JvYty J43upgKBvPQsdOa8jhTVJ5tLHAAMRdDV5gfx5n/iZcfq/IGuJVoke3e63PgYwGngt+tH Xnd9MC29T8S2c/+zGPker8tPN5LSAMIDD06UaP88NAdvAdjvPJweGRIe2XpF9hc6yfP7 1OEg/AjGa8tW+X0SCaguKsMyNnh2GC2IOn6vnejD6E+5PnIU691KAdqT34NlYFMfiNI5 u3pg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1789071337; x=1789676137; h=in-reply-to:content-transfer-encoding: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=bUsqkqSEg6ABsPYNlxkrlq9VUldheG28GlxZUj5JBUE=; b=Z6gu62zukPav4e0HGTXZycWIXulnDl6JMhnYPzNIT/arZEOlKkBwTEPbcsHc4u2xoL 2H8uf3jgiT5q+AdUDhlcU/nnAzVOH9+EF1uM1BTJJdVtYlxTif/WRRnNBsqFwgpKnvaM p9Y4dKLnW+UCIW0DOzWIThR20BYqElJX2pWNw6QvUA4lFK5IOvQ++7X4Qr6lyekhQ54Z L76HeBG/+ISOwl5F/d0wkVR0nIsXMTYeYqp8pBL2hliO21xDt65hZwLegYkErbAUDaIq 0mp63QwgqYU5GPV3XQVEJlDQYQdxoGudiZC/UaMmcXQt/aT4QVuPqaGRA9JWJ7GHT9tg 0ZLg== X-Gm-Message-State: AFuF++l9YZGerFYXkKeELenCX1FfvyUINPa5t3ZsJhS8i1hbku58Utm+ Ny7WMNnr9VD6n80xFUvof8/PAZkL1SrBMGtRm5XtyROu6OxZ8AMEK9BPAOTNFzckAGQXrZS/oT3 WyA9kkn1324/ODaXSS9JO36ojh4anExJ7+dV0yg/VAUmDirN0kTJJ7jUuq6qUb0LpFzSSsfkqrm MfS/TuSslurD5LUYbQqeu2U+44dPBkrtMReA== X-Gm-Gg: AYBFou3ceRZWEiDb3O3I6LxO4bw1rUAnBINe5Hmyh1v2i/bFz/ypvOWnYfBU5581dG7 T1+HZPRGq1TxG5+HhocMYkcX/nnIr2TI3c1yVYlTwvXiqc3IZ0Vgr9s1R/p71uxJCSAdBv+mCvB AP1VEWWQaPcEt8dAi6VdGAnUz1WJbvHIURn5bqeaXf6YmaX0OBlm0gyMTw9UR5NnXbc1ncIM9Ep KJ5MQBqmmvk9wJKZplcKHdrL2QJm85IZuHUSgdfZ7piZ3hy8hM4HdYvhnhsNR2ze+5fldXlmmfz SO/HsKlrtV+zYdz9f80HFFqbkH5dKtMok4c/3GYReTxqqUJf2IQ0dGEvsUUGBOSOw769FAqeA4N xHJPmE9d5VLBnxdmr2LPkQoQ= X-Received: by 2002:a05:600c:4114:b0:49e:5765:1426 with SMTP id 5b1f17b1804b1-49e57651482mr36061405e9.3.1789071337546; Thu, 10 Sep 2026 13:15:37 -0700 (PDT) X-Received: by 2002:a05:600c:4114:b0:49e:5765:1426 with SMTP id 5b1f17b1804b1-49e57651482mr36060885e9.3.1789071337025; Thu, 10 Sep 2026 13:15:37 -0700 (PDT) Date: Thu, 10 Sep 2026 16:15:34 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , =?utf-8?Q?Cl=C3=A9ment?= MATHIEU--DRIF , Zhenzhong Duan , Jason Wang , Yi Liu , Paolo Bonzini , Richard Henderson Subject: [PULL 83/90] intel_iommu: Expose SMPWC when SVM is enabled Message-ID: References: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Disposition: inline Content-Transfer-Encoding: quoted-printable In-Reply-To: X-Mailer: git-send-email 2.51.2.2891.g4157995a80.dirty X-Mutt-Fcc: =sent 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=170.10.129.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com 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, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=0.001, SPF_HELO_PASS=-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-Zoho-Virus-Status: 1 X-Zoho-AV-Stamp: zmail-av-0.2.13.1.5.4/289.74.40 X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1789078626000158500 From: Cl=C3=A9ment MATHIEU--DRIF SVM in Linux requires SMPWC. This is free in the current implementation as it is already in line with the expected behaviour. Link: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/co= mmit/?id=3D780dfed68862 Fixes: 952e1a6e90eb ("intel_iommu: Add a CLI option to enable SVM") Signed-off-by: Clement Mathieu--Drif Reviewed-by: Zhenzhong Duan Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin Message-ID: <20260808153626.873965-1-clement.mathieu--drif@bull.com> --- hw/i386/intel_iommu_internal.h | 1 + hw/i386/intel_iommu.c | 3 ++- hw/i386/intel_iommu_accel.c | 6 ++++++ 3 files changed, 9 insertions(+), 1 deletion(-) diff --git a/hw/i386/intel_iommu_internal.h b/hw/i386/intel_iommu_internal.h index 924e91cb8a..df7a0efa6e 100644 --- a/hw/i386/intel_iommu_internal.h +++ b/hw/i386/intel_iommu_internal.h @@ -202,6 +202,7 @@ #define VTD_ECAP_SMTS (1ULL << 43) #define VTD_ECAP_SSTS (1ULL << 46) #define VTD_ECAP_FSTS (1ULL << 47) +#define VTD_ECAP_SMPWCS (1ULL << 48) =20 /* CAP_REG */ /* (offset >> 4) << 24 */ diff --git a/hw/i386/intel_iommu.c b/hw/i386/intel_iommu.c index 91ab549dbf..350d2b7753 100644 --- a/hw/i386/intel_iommu.c +++ b/hw/i386/intel_iommu.c @@ -5121,7 +5121,8 @@ static void vtd_init(IntelIOMMUState *s) } =20 if (s->svm) { - s->ecap |=3D VTD_ECAP_PRS | VTD_ECAP_PDS | VTD_ECAP_NWFS; + s->ecap |=3D VTD_ECAP_PRS | VTD_ECAP_PDS | VTD_ECAP_NWFS | + VTD_ECAP_SMPWCS; } =20 vtd_reset_caches(s); diff --git a/hw/i386/intel_iommu_accel.c b/hw/i386/intel_iommu_accel.c index c03435f8a2..c3677775e9 100644 --- a/hw/i386/intel_iommu_accel.c +++ b/hw/i386/intel_iommu_accel.c @@ -37,6 +37,12 @@ bool vtd_check_hiod_accel(IntelIOMMUState *s, VTDHostIOM= MUDevice *vtd_hiod, return false; } =20 + if ((s->ecap & VTD_ECAP_SMPWCS) && !(vtd->ecap_reg & VTD_ECAP_SMPWCS))= { + error_setg(errp, + "Scalable-mode coherent walk is unsupported by host IOM= MU"); + return false; + } + if (s->fs1gp && !(vtd->cap_reg & VTD_CAP_FS1GP)) { error_setg(errp, "First stage 1GB large page is unsupported by host IOMM= U"); --=20 MST From nobody Sat Sep 26 20:50:17 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=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1789083186; cv=none; d=zohomail.com; s=zohoarc; b=Q0UOb18Kp/eWqjSY1fMQ1XvsjXUW+x2kXy8Cf9azl2XkZgL8rM635yoKqt88W750uun7NYSLehD4AM/4+jQcjz5/FbjfzdXFltPtQEMvaBfTKQ8MyZafBTA8rzgbqUvjYrDOIm2il3CON5ez3g/eFbSML1r0vs7A3TtGJUMfTzk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1789083186; h=Content-Type: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=VqjojGjFi5nUGCc20Drm+8VeWMIFynXWAu4/zax0fR0=; b=ToBjnb0N9kdwJnYrvjMjpgtlh2YyGt504SU9V3YenH+Ske6bw55n03mVBRVJV8WbLspieHPAwLdC90EYGRi4dc0yWE1sDpHy0n72AQMEPumzC5wdO0X3xa/IioSjvQvQ031+3NRk8DbYzmqUbVm1Zpcboc/B5fRhDSLcZHiQiwQ= 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 lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1789083186758402.11565913403; Thu, 10 Sep 2026 16:33:06 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1x4o02-0002Jr-B8; Thu, 10 Sep 2026 19:16:17 -0400 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 1x4lj3-0001RE-W1 for qemu-devel@nongnu.org; Thu, 10 Sep 2026 16:50:41 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1x4liq-0006Mn-2t for qemu-devel@nongnu.org; Thu, 10 Sep 2026 16:50:21 -0400 Received: from mail-wr1-f72.google.com (mail-wr1-f72.google.com [209.85.221.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-42-vKMcYgSoPDqigSpRej5hDA-1; Thu, 10 Sep 2026 16:15:42 -0400 Received: by mail-wr1-f72.google.com with SMTP id ffacd0b85a97d-48597bbd963so94476f8f.2 for ; Thu, 10 Sep 2026 13:15:42 -0700 (PDT) Received: from redhat.com (IGLD-80-230-79-236.inter.net.il. [80.230.79.236]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-486eb32e6f1sm821976f8f.6.2026.09.10.13.15.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Sep 2026 13:15:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1789073409; 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=VqjojGjFi5nUGCc20Drm+8VeWMIFynXWAu4/zax0fR0=; b=B+m3FwUkbqUbBNwkgi1MYnb9uMUEd0Uso72wvrQeCU7kWe4KNxMBrAeOfWqJC84KVCKLWz sibjJOBBvUwp8AkqOqrGTIexeeVj5ipaTWy73crGsP397EqRNmKd1nXRwPNOQPn50+LsJF 2CUO7tC5yN0qS9i6glaw8Qd1rFGYzOc= X-MC-Unique: vKMcYgSoPDqigSpRej5hDA-1 X-Mimecast-MFC-AGG-ID: vKMcYgSoPDqigSpRej5hDA_1789071341 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=google; t=1789071341; x=1789676141; 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=VqjojGjFi5nUGCc20Drm+8VeWMIFynXWAu4/zax0fR0=; b=lt33hhDKJiXTL6K8b/LpVUU1ybxtZYQJ7VkpV+yTtok5IYbpVit9iVShT41yGx4U31 5h5zJwIV893MnwcTN+Tl1SHe1QKdXXfg7tVphlJDay+fu00q5qjTFC087r8iDOc0PZsX fkFBIACh6HnxxRZvF7L/90prf3atJNB3s0mJGbgLBaomM9Onr5UeBXRQHLQ5wZcpAWWZ 3Rlt/t4ELWlvMakntzhJ4WNGZFj4cI5AVjG8fphEitdikDwd7lgasTeHXZMeYg5F/GaB SQpiDq9TMFtx+GYPzHWod7XwFiEMCrGi5NDfRmXWisoqTC9t7RN4Wd35cxlpibp8ajH/ VucA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1789071341; x=1789676141; 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=VqjojGjFi5nUGCc20Drm+8VeWMIFynXWAu4/zax0fR0=; b=qf14pwxWqNpIYNloNDeeQ9gDhq/4hIXDpJEF8wE0Wam/LDlC8bj49vOtuF6tdXep2I Ym2RLqgSj4xsXeAwjtCtNvzF8UKvDHaQ6RM4WUB/74HrQYCTvzp8DrEb8EdbeIyy8Wrg /cXKkSjpDN2j0djxG6bVMuHQzWkZ8AdaJ1qBmuaSBJ9tms8Yjo+sn06eAlYReiw5GP++ G1+num6dsAVWubz7LIdNwoQIfKeDEGGWgIEthXwk9MbIrzT1sb6DxQ+FzFS40cJbyljB qH6Z7hthH5wDF8Hr/NS+OLBwZ5C9Xp1gTFaJ2SW1ac+hvOa9JcV8/uQzGcGjzkvUSYcu 2dNw== X-Gm-Message-State: AFuF++kXsG4RsiSBfzhcXDp4s6uECLHXo+1TBJRjuWKPByVEZxi/sr4U 2LZvhxSmBMtdIt40IzTf/ntN/VxW/jcknvddHTu0tsHg3uph7bO4SEjMPmSjNYCPyOP6VpCN0/q ug6v8SuAsZSLuoPxPflXd53VMCL5v2D14nLZdsUwwi1hT+zmybpqhQ9eoIEHbinA5Fa0H47y8H2 Mriyr3HrTQrenx2HQAjFQz25yPjMcDt8X29A== X-Gm-Gg: AYBFou1JqrS/9cmPWEcymFgTY+kuVb1IMj57RKxpmBHTQMFQVPn+uSdqaTdzd5bckpe YOuKB6AZbwWKN7kjCukSozfEtffpb5j4ntCHzBJrWqmTvismGIDV7rJwtFSyx+GNugLnT2+MvjP Sx53Gu/SKxv418eVtDKQvWsHzxAsHoIVe4HXvIusFdGM5iw6bCZNQvjqUfyZ0jSTBqhA42Ps0pc Gk/2y30bBEyAuHk6eC0S4X3GQp0JyfgzfhQvAruJzspqiWwcaqCWe6cBV3wkPtQLhiS50tK9ils EW7Xb+xzys6D8trmvOm8eNH959wnzrSl50jFSVdpVTMP/L+tNSbGKkYYwPIFKoPGdY+vyn3zAAp A3MgUfyIfvXG7lSBLs2iCLd8= X-Received: by 2002:adf:ec86:0:b0:47f:7129:6e2d with SMTP id ffacd0b85a97d-486eb325de3mr1103478f8f.17.1789071341089; Thu, 10 Sep 2026 13:15:41 -0700 (PDT) X-Received: by 2002:adf:ec86:0:b0:47f:7129:6e2d with SMTP id ffacd0b85a97d-486eb325de3mr1103352f8f.17.1789071340413; Thu, 10 Sep 2026 13:15:40 -0700 (PDT) Date: Thu, 10 Sep 2026 16:15:37 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Alexandr Moshkov , "Gonglei (Arei)" , zhenwei pi , Stefano Garzarella , Raphael Norwitz , Kevin Wolf , Hanna Reitz , =?utf-8?Q?Marc-Andr=C3=A9?= Lureau , Albert Esteve , Jason Wang , Paolo Bonzini , Fam Zheng , Alex =?utf-8?Q?Benn=C3=A9e?= , Stefan Hajnoczi , Milan Zamazal , qemu-block@nongnu.org, virtio-fs@lists.linux.dev Subject: [PULL 84/90] vhost-user: add skip_drain param to do_vhost_virtqueue_stop Message-ID: References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-Mailer: git-send-email 2.51.2.2891.g4157995a80.dirty X-Mutt-Fcc: =sent 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=170.10.129.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com 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, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=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-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-Zoho-Virus-Status: 1 X-Zoho-AV-Stamp: zmail-av-0.2.13.1.5.4/289.74.40 X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1789083189734158500 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Alexandr Moshkov Currently do_vhost_virtqueue_stop always sends GET_VRING_BASE to the back-end, which requires the back-end to drain all in-flight I/O before stopping the vring. Add a skip_drain parameter to do_vhost_virtqueue_stop and propagate it up through vhost_virtqueue_stop, vhost_dev_stop and their callers. The parameter will be used in a follow-up commit to send a new protocol message that instructs the back-end to suspend in-flight I/O immediately instead of draining it. Signed-off-by: Alexandr Moshkov Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin Message-ID: <20260803072853.2920007-2-dtalexundeer@yandex-team.ru> --- include/hw/virtio/vhost.h | 7 +++++-- backends/cryptodev-vhost.c | 2 +- backends/vhost-user.c | 2 +- hw/block/vhost-user-blk.c | 2 +- hw/display/vhost-user-media.c | 2 +- hw/net/vhost_net.c | 9 +++++---- hw/scsi/vhost-scsi-common.c | 2 +- hw/virtio/vdpa-dev.c | 2 +- hw/virtio/vhost-user-base.c | 2 +- hw/virtio/vhost-user-fs.c | 2 +- hw/virtio/vhost-user-scmi.c | 2 +- hw/virtio/vhost-vsock-common.c | 2 +- hw/virtio/vhost.c | 28 +++++++++++++++++++--------- 13 files changed, 39 insertions(+), 25 deletions(-) diff --git a/include/hw/virtio/vhost.h b/include/hw/virtio/vhost.h index cd012b99a2..cd6e200538 100644 --- a/include/hw/virtio/vhost.h +++ b/include/hw/virtio/vhost.h @@ -277,6 +277,7 @@ int vhost_dev_start(struct vhost_dev *hdev, VirtIODevic= e *vdev, bool vrings); * @hdev: common vhost_dev structure * @vdev: the VirtIODevice structure * @vrings: true to have vrings disabled in this call + * @skip_drain: true to notice back-end to skip draining all in-flight req= uests * * Stop the vhost device. After the device is stopped the notifiers * can be disabled (@vhost_dev_disable_notifiers) and the device can @@ -284,7 +285,8 @@ int vhost_dev_start(struct vhost_dev *hdev, VirtIODevic= e *vdev, bool vrings); * * Return: 0 on success, !=3D 0 on error when stopping dev. */ -int vhost_dev_stop(struct vhost_dev *hdev, VirtIODevice *vdev, bool vrings= ); +int vhost_dev_stop(struct vhost_dev *hdev, VirtIODevice *vdev, bool vrings, + bool skip_drain); =20 /** * vhost_dev_force_stop() - force stop the vhost device @@ -445,7 +447,8 @@ int vhost_device_iotlb_miss(struct vhost_dev *dev, uint= 64_t iova, int write); int vhost_virtqueue_start(struct vhost_dev *dev, struct VirtIODevice *vdev, struct vhost_virtqueue *vq, unsigned idx); int vhost_virtqueue_stop(struct vhost_dev *dev, struct VirtIODevice *vdev, - struct vhost_virtqueue *vq, unsigned idx); + struct vhost_virtqueue *vq, unsigned idx, + bool skip_drain); =20 void vhost_dev_reset_inflight(struct vhost_inflight *inflight); void vhost_dev_free_inflight(struct vhost_inflight *inflight); diff --git a/backends/cryptodev-vhost.c b/backends/cryptodev-vhost.c index c6069f4e5b..f1ca6bcd4e 100644 --- a/backends/cryptodev-vhost.c +++ b/backends/cryptodev-vhost.c @@ -109,7 +109,7 @@ static void cryptodev_vhost_stop_one(CryptoDevBackendVhost *crypto, VirtIODevice *dev) { - vhost_dev_stop(&crypto->dev, dev, false); + vhost_dev_stop(&crypto->dev, dev, false, false); vhost_dev_disable_notifiers(&crypto->dev, dev); } =20 diff --git a/backends/vhost-user.c b/backends/vhost-user.c index 46dadb7480..de6b1ba267 100644 --- a/backends/vhost-user.c +++ b/backends/vhost-user.c @@ -108,7 +108,7 @@ vhost_user_backend_stop(VhostUserBackend *b) return 0; } =20 - ret =3D vhost_dev_stop(&b->dev, b->vdev, true); + ret =3D vhost_dev_stop(&b->dev, b->vdev, true, false); =20 if (k->set_guest_notifiers && (err =3D k->set_guest_notifiers(qbus->parent, b->dev.nvqs, false))= < 0) { diff --git a/hw/block/vhost-user-blk.c b/hw/block/vhost-user-blk.c index 2e5b3ae1b1..c3e3c37f8c 100644 --- a/hw/block/vhost-user-blk.c +++ b/hw/block/vhost-user-blk.c @@ -238,7 +238,7 @@ static int vhost_user_blk_stop(VirtIODevice *vdev) qemu_force_shutdown_requested(); =20 ret =3D force_stop ? vhost_dev_force_stop(&s->dev, vdev, true) : - vhost_dev_stop(&s->dev, vdev, true); + vhost_dev_stop(&s->dev, vdev, true, false); =20 err =3D k->set_guest_notifiers(qbus->parent, s->dev.nvqs, false); if (err < 0) { diff --git a/hw/display/vhost-user-media.c b/hw/display/vhost-user-media.c index eaf99dc6a2..851af8ddc2 100644 --- a/hw/display/vhost-user-media.c +++ b/hw/display/vhost-user-media.c @@ -110,7 +110,7 @@ static void vu_media_stop(VirtIODevice *vdev) return; } =20 - vhost_dev_stop(&media->vhost_dev, vdev, true); + vhost_dev_stop(&media->vhost_dev, vdev, true, false); =20 ret =3D k->set_guest_notifiers(qbus->parent, media->vhost_dev.nvqs, fa= lse); if (ret < 0) { diff --git a/hw/net/vhost_net.c b/hw/net/vhost_net.c index 323d117735..6e05c995f1 100644 --- a/hw/net/vhost_net.c +++ b/hw/net/vhost_net.c @@ -384,7 +384,7 @@ fail: if (net->nc->info->poll) { net->nc->info->poll(net->nc, true); } - vhost_dev_stop(&net->dev, dev, false); + vhost_dev_stop(&net->dev, dev, false, false); fail_start: return r; } @@ -403,7 +403,7 @@ static void vhost_net_stop_one(struct vhost_net *net, if (net->nc->info->poll) { net->nc->info->poll(net->nc, true); } - vhost_dev_stop(&net->dev, dev, false); + vhost_dev_stop(&net->dev, dev, false, false); if (net->nc->info->stop) { net->nc->info->stop(net->nc); } @@ -636,7 +636,8 @@ void vhost_net_virtqueue_reset(VirtIODevice *vdev, NetC= lientState *nc, vhost_virtqueue_stop(&net->dev, vdev, net->dev.vqs + idx, - net->dev.vq_index + idx); + net->dev.vq_index + idx, + false); } =20 int vhost_net_virtqueue_restart(VirtIODevice *vdev, NetClientState *nc, @@ -686,7 +687,7 @@ err_start: assert(ret >=3D 0); } =20 - vhost_dev_stop(&net->dev, vdev, false); + vhost_dev_stop(&net->dev, vdev, false, false); =20 return r; } diff --git a/hw/scsi/vhost-scsi-common.c b/hw/scsi/vhost-scsi-common.c index e19800a0bc..e546a6dc75 100644 --- a/hw/scsi/vhost-scsi-common.c +++ b/hw/scsi/vhost-scsi-common.c @@ -108,7 +108,7 @@ int vhost_scsi_common_stop(VHostSCSICommon *vsc) VirtioBusClass *k =3D VIRTIO_BUS_GET_CLASS(qbus); int ret =3D 0; =20 - ret =3D vhost_dev_stop(&vsc->dev, vdev, true); + ret =3D vhost_dev_stop(&vsc->dev, vdev, true, false); =20 if (k->set_guest_notifiers) { int r =3D k->set_guest_notifiers(qbus->parent, vsc->dev.nvqs, fals= e); diff --git a/hw/virtio/vdpa-dev.c b/hw/virtio/vdpa-dev.c index 6dc684ab09..7e5cc040e9 100644 --- a/hw/virtio/vdpa-dev.c +++ b/hw/virtio/vdpa-dev.c @@ -301,7 +301,7 @@ static void vhost_vdpa_device_stop(VirtIODevice *vdev) return; } =20 - vhost_dev_stop(&s->dev, vdev, false); + vhost_dev_stop(&s->dev, vdev, false, false); =20 ret =3D k->set_guest_notifiers(qbus->parent, s->dev.nvqs, false); if (ret < 0) { diff --git a/hw/virtio/vhost-user-base.c b/hw/virtio/vhost-user-base.c index 478ec68f09..1a377016e7 100644 --- a/hw/virtio/vhost-user-base.c +++ b/hw/virtio/vhost-user-base.c @@ -78,7 +78,7 @@ static int vub_stop(VirtIODevice *vdev) return 0; } =20 - ret =3D vhost_dev_stop(&vub->vhost_dev, vdev, true); + ret =3D vhost_dev_stop(&vub->vhost_dev, vdev, true, false); =20 err =3D k->set_guest_notifiers(qbus->parent, vub->vhost_dev.nvqs, fals= e); if (err < 0) { diff --git a/hw/virtio/vhost-user-fs.c b/hw/virtio/vhost-user-fs.c index 209993918a..0d8842817a 100644 --- a/hw/virtio/vhost-user-fs.c +++ b/hw/virtio/vhost-user-fs.c @@ -111,7 +111,7 @@ static int vuf_stop(VirtIODevice *vdev) return 0; } =20 - ret =3D vhost_dev_stop(&fs->vhost_dev, vdev, true); + ret =3D vhost_dev_stop(&fs->vhost_dev, vdev, true, false); =20 err =3D k->set_guest_notifiers(qbus->parent, fs->vhost_dev.nvqs, false= ); if (err < 0) { diff --git a/hw/virtio/vhost-user-scmi.c b/hw/virtio/vhost-user-scmi.c index 02dc088ea9..c4692bd6aa 100644 --- a/hw/virtio/vhost-user-scmi.c +++ b/hw/virtio/vhost-user-scmi.c @@ -101,7 +101,7 @@ static int vu_scmi_stop(VirtIODevice *vdev) return 0; } =20 - ret =3D vhost_dev_stop(vhost_dev, vdev, true); + ret =3D vhost_dev_stop(vhost_dev, vdev, true, false); =20 err =3D k->set_guest_notifiers(qbus->parent, vhost_dev->nvqs, false); if (err < 0) { diff --git a/hw/virtio/vhost-vsock-common.c b/hw/virtio/vhost-vsock-common.c index b79f4c9ce6..4ef037627b 100644 --- a/hw/virtio/vhost-vsock-common.c +++ b/hw/virtio/vhost-vsock-common.c @@ -106,7 +106,7 @@ int vhost_vsock_common_stop(VirtIODevice *vdev) return 0; } =20 - ret =3D vhost_dev_stop(&vvc->vhost_dev, vdev, true); + ret =3D vhost_dev_stop(&vvc->vhost_dev, vdev, true, false); =20 err =3D k->set_guest_notifiers(qbus->parent, vvc->vhost_dev.nvqs, fals= e); if (err < 0) { diff --git a/hw/virtio/vhost.c b/hw/virtio/vhost.c index 6c2612a1dd..17b36366dc 100644 --- a/hw/virtio/vhost.c +++ b/hw/virtio/vhost.c @@ -23,6 +23,7 @@ #include "qemu/log.h" #include "standard-headers/linux/vhost_types.h" #include "hw/virtio/virtio-bus.h" +#include "hw/virtio/vhost-user.h" #include "hw/mem/memory-device.h" #include "migration/blocker.h" #include "migration/qemu-file-types.h" @@ -1509,8 +1510,13 @@ fail: static int do_vhost_virtqueue_stop(struct vhost_dev *dev, struct VirtIODevice *vdev, struct vhost_virtqueue *vq, - unsigned idx, bool force) + unsigned idx, bool force, + bool skip_drain) { + if (skip_drain) { + assert(vhost_user_has_protocol_feature(dev, + VHOST_USER_PROTOCOL_F_GET_VRING_BASE_INFLIGHT)); + } int vhost_vq_index =3D dev->vhost_ops->vhost_get_vq_index(dev, idx); struct vhost_vring_state state =3D { .index =3D vhost_vq_index, @@ -1560,9 +1566,10 @@ static int do_vhost_virtqueue_stop(struct vhost_dev = *dev, int vhost_virtqueue_stop(struct vhost_dev *dev, struct VirtIODevice *vdev, struct vhost_virtqueue *vq, - unsigned idx) + unsigned idx, + bool skip_drain) { - return do_vhost_virtqueue_stop(dev, vdev, vq, idx, false); + return do_vhost_virtqueue_stop(dev, vdev, vq, idx, false, skip_drain); } =20 static int vhost_virtqueue_set_busyloop_timeout(struct vhost_dev *dev, @@ -2350,7 +2357,8 @@ fail_vq: vhost_virtqueue_stop(hdev, vdev, hdev->vqs + i, - hdev->vq_index + i); + hdev->vq_index + i, + false); } =20 fail_mem: @@ -2365,7 +2373,7 @@ fail_features: =20 /* Host notifiers must be enabled at this point. */ static int do_vhost_dev_stop(struct vhost_dev *hdev, VirtIODevice *vdev, - bool vrings, bool force) + bool vrings, bool force, bool skip_drain) { int i; int rc =3D 0; @@ -2392,7 +2400,8 @@ static int do_vhost_dev_stop(struct vhost_dev *hdev, = VirtIODevice *vdev, vdev, hdev->vqs + i, hdev->vq_index + i, - force); + force, + skip_drain); } if (hdev->vhost_ops->vhost_reset_status) { hdev->vhost_ops->vhost_reset_status(hdev); @@ -2414,15 +2423,16 @@ static int do_vhost_dev_stop(struct vhost_dev *hdev= , VirtIODevice *vdev, return rc; } =20 -int vhost_dev_stop(struct vhost_dev *hdev, VirtIODevice *vdev, bool vrings) +int vhost_dev_stop(struct vhost_dev *hdev, VirtIODevice *vdev, bool vrings, + bool skip_drain) { - return do_vhost_dev_stop(hdev, vdev, vrings, false); + return do_vhost_dev_stop(hdev, vdev, vrings, false, skip_drain); } =20 int vhost_dev_force_stop(struct vhost_dev *hdev, VirtIODevice *vdev, bool vrings) { - return do_vhost_dev_stop(hdev, vdev, vrings, true); + return do_vhost_dev_stop(hdev, vdev, vrings, true, false); } =20 int vhost_net_set_backend(struct vhost_dev *hdev, --=20 MST From nobody Sat Sep 26 20:50:17 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=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1789085459; cv=none; d=zohomail.com; s=zohoarc; b=DJB3Ae9WTn4iW4BlSYJJNWd9UmUfUJ37qa5aF1b4MMlLJVUESPcYhh8BCn39EH4uYKSd/Qx4RPZA/5EBfH2PpaU/eu7NGuXVBL/PzLOi0ncUjJzaG7eJUQHabYk4l9dUPz0Frgz51B9cyZMMjlxvOXwhifR+nhX0pYlCHjThubc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1789085459; h=Content-Type: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=PrmVKhf1ZqItkbl69E27fCItqDxIsRZDaNMDTiAOj/M=; b=cJ1kOtE3PN4d7iCiNF4dnsGbLXpHXyZc4vA0ybEY2hO5Uoaxv+TH6s624IXjgeXjc6Y0ofydL2OGY5mtsHEw2dZ77UOiiybTCBjHGTbvtuMHJz1WeLL9jVpuiAFPsdW8xDwyYV70bX/vjeBueWpqiDMdPgSQp9/zK3rhc7qdVg8= 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 lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTP id 1789085459854916.0587922309039; Thu, 10 Sep 2026 17:10:59 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1x4oo6-0008IG-R8; Thu, 10 Sep 2026 20:08:08 -0400 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 1x4lVZ-0006NE-Ke for qemu-devel@nongnu.org; Thu, 10 Sep 2026 16:36:41 -0400 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 1x4lVC-0004Rs-67 for qemu-devel@nongnu.org; Thu, 10 Sep 2026 16:36:21 -0400 Received: from mail-wm1-f72.google.com (mail-wm1-f72.google.com [209.85.128.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-647-WjMrQXXdMj2miHKtZTaFpg-1; Thu, 10 Sep 2026 16:15:45 -0400 Received: by mail-wm1-f72.google.com with SMTP id 5b1f17b1804b1-49545071724so2496465e9.0 for ; Thu, 10 Sep 2026 13:15:44 -0700 (PDT) Received: from redhat.com (IGLD-80-230-79-236.inter.net.il. [80.230.79.236]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-49d26be3e0asm101087005e9.1.2026.09.10.13.15.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Sep 2026 13:15:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1789072503; 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=PrmVKhf1ZqItkbl69E27fCItqDxIsRZDaNMDTiAOj/M=; b=Bi6nX/gn/LiRofArsrcIxYrH8c6DS2vaHoDRiitK7ThZCVs+ExDutd8MCxCbvPpnTRZZkS OVKilDpV2yuQNYyUUY7gwf+RDJtKkjACrYif2qo3aghv1C7YqLAKLSZ8UIm+KCrYHDhIqw IEPc6iLFzodlxa2tHuKCLkhAsva/cNo= X-MC-Unique: WjMrQXXdMj2miHKtZTaFpg-1 X-Mimecast-MFC-AGG-ID: WjMrQXXdMj2miHKtZTaFpg_1789071344 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=google; t=1789071344; x=1789676144; 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=PrmVKhf1ZqItkbl69E27fCItqDxIsRZDaNMDTiAOj/M=; b=WLWIhqSuGb/6/4NLvjCH0cX82J4qiDQhxZ3d08n9ZHD9/d2SlpCqAuQcvX8L3ss43E 9bxllUc8hlFhqPdxlttMdGkDm3x/rXKnXTf1avMowEgKZI/elwBzChkLD0Z9/tJ30NrA KvamgDOUJOWH8fvXI3ik49NuQWjsUJJNhF+fI71OWuEjHUPfmIk/K7FEg/3/XJdTR8yE Dyhyou1u2QPNOs1pyf7ue03cmhJEwxnosxgbDhAzznxoBbHAA+kS6GZnhHAGlwkE8FIy SZNrWsd4U8cNNcon+qkKsCroo9YsaNkP1VuDd3eFXekoVotDyrR3TrSo36tJcqZ5ION1 ShYw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1789071344; x=1789676144; 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=PrmVKhf1ZqItkbl69E27fCItqDxIsRZDaNMDTiAOj/M=; b=ffujs1qW9d3gXhe2xxxxfjgJ7rERqfNZQH2AWASpUxWgXD8EIpegxPWQ8RV8aJOdV9 tBjpIQE5/qv2cxeRAdTkplir/dL2mTkAZuKWROBOKoB/pof5zuWy6+OMMoOdt/vXO0ge Pd5eaANbv1Vkt2m1BMVl+hSSntcKm+uPzUqu10Mn+lQDs7g61GSwfoU0rKt+g57fdrh2 hfdd5gICwxi2xIUjVObEHSwjny3HWUUQVG+RgzD25733srNxy1p6F93ioZaejJPM5x+M d/msVH+Ag9zv2Dn5XANz8nH8rJw1+Jjb3KLs5gIxRTh72Z3PXRGgUeE93NhUGqlWaT1h l2jA== X-Gm-Message-State: AFuF++lsxaGchsov6oNb3AZFVNUEom6kD53q1tbuXranTir5NysnRDe1 Yz/N17KDEZGOd5wiDFc+wmNckl9//JuslPNRpDZJ41zvEwizDCi9RrOjldPzayG3L5K40yFPda4 BI16D+KPwub5XAB8BRHyrTVzz9YBWAV1doKsRXt5vGN5wHbRS7e+BzHlV9pb5ARltLcy0pfEPem 442xHvO3rJyPIdmCMPTeqUgEJYZ4476Mh2dg== X-Gm-Gg: AYBFou3Wyt6dg6yYto1OKbmjDiwlhVsOIs8wgwsEH2rMmHnJXlTUTIpgFOsMzOoIeMp EzRedaX4eIJereEvFCeIuiC0oGcqQDnsQ0vGFK3KQA+0+0ahh63UH03r9OFd9nRW4JudLmUyqx0 2Xhgi1D/pIxcXuBieWdfw8TqKpIVlPVX/e+e0g9kT46dPKtAYFkCmcLUPnCSZ8InGisyfZ8CCc3 Vu/CmKPm/TDQDA1Z1pWR/kGMvXGjvWhhclES8NhP5iLuGgdoymZwAxy3MouNQ31fIziEm/ZeenA YLCmgyTvhAo+0tv0S9dByLKnyMjhwXTKBRQBn8gI6uuEqassDD91xbx8/8wT67BnD3YAG34iXY0 wrhyM7RzgXdAE5P3N+sF1xdg= X-Received: by 2002:a05:600c:4fc8:b0:49c:cedc:3c36 with SMTP id 5b1f17b1804b1-49e619bd0femr8042605e9.16.1789071343294; Thu, 10 Sep 2026 13:15:43 -0700 (PDT) X-Received: by 2002:a05:600c:4fc8:b0:49c:cedc:3c36 with SMTP id 5b1f17b1804b1-49e619bd0femr8042115e9.16.1789071342731; Thu, 10 Sep 2026 13:15:42 -0700 (PDT) Date: Thu, 10 Sep 2026 16:15:40 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Alexandr Moshkov , Stefano Garzarella , Pierrick Bouvier Subject: [PULL 85/90] vhost-user: add GET_VRING_BASE_SKIP_DRAIN message Message-ID: <6a9a8d689a6f1681dfba47ffeb05a3691d4c4037.1789071043.git.mst@redhat.com> References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-Mailer: git-send-email 2.51.2.2891.g4157995a80.dirty X-Mutt-Fcc: =sent 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=170.10.133.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com 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, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_PASS=-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-Zoho-Virus-Status: 1 X-Zoho-AV-Stamp: zmail-av-0.2.13.1.5.4/289.74.40 X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1789085461229158500 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Alexandr Moshkov VHOST_USER_PROTOCOL_F_GET_VRING_BASE_INFLIGHT was introduced to allow the back-end to suspend in-flight I/O during GET_VRING_BASE instead of draining it, enabling live migration of in-flight requests. However, this behaviour is tied to the protocol feature itself - once negotiated, there is no way for the front-end to tell the back-end to fall back to the normal drain behaviour on a per-stop basis. Introduce a separate message VHOST_USER_GET_VRING_BASE_SKIP_DRAIN (id=3D45) guarded by a new protocol feature VHOST_USER_PROTOCOL_F_GET_VRING_BASE_SKIP_DRAIN. The message is identical to GET_VRING_BASE except that the back-end must immediately suspe= nd all in-flight I/O and record it in the inflight region. This way the front-end has explicit per-call control: send GET_VRING_BASE for normal dra= in, send GET_VRING_BASE_SKIP_DRAIN when immediate suspend is needed. The new feature requires both VHOST_USER_PROTOCOL_F_GET_VRING_BASE_INFLIGHT and VHOST_USER_PROTOCOL_F_INFLIGHT_SHMFD to be negotiated. Signed-off-by: Alexandr Moshkov Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin Message-ID: <20260803072853.2920007-3-dtalexundeer@yandex-team.ru> --- docs/interop/vhost-user.rst | 42 ++++++++++++++++++++--------- include/hw/virtio/vhost-backend.h | 1 + include/hw/virtio/vhost-user.h | 1 + hw/virtio/vhost-user.c | 44 +++++++++++++++++++++++++++---- hw/virtio/vhost.c | 2 +- 5 files changed, 72 insertions(+), 18 deletions(-) diff --git a/docs/interop/vhost-user.rst b/docs/interop/vhost-user.rst index fbfb9d01c6..c1e02ff7e9 100644 --- a/docs/interop/vhost-user.rst +++ b/docs/interop/vhost-user.rst @@ -457,6 +457,7 @@ replies, except for the following requests: * ``VHOST_USER_GET_FEATURES`` * ``VHOST_USER_GET_PROTOCOL_FEATURES`` * ``VHOST_USER_GET_VRING_BASE`` +* ``VHOST_USER_GET_VRING_BASE_SKIP_DRAIN`` * ``VHOST_USER_SET_LOG_BASE`` (if ``VHOST_USER_PROTOCOL_F_LOG_SHMFD``) * ``VHOST_USER_GET_INFLIGHT_FD`` (if ``VHOST_USER_PROTOCOL_F_INFLIGHT_SHMF= D``) =20 @@ -533,7 +534,7 @@ Rings have two independent states: started/stopped, and= enabled/disabled. Each ring is initialized in a stopped and disabled state. Rings are start= ed with ``VHOST_USER_SET_VRING_KICK`` (or ``VHOST_USER_VRING_KICK`` if ``VHOST_USER_PROTOCOL_F_INBAND_NOTIFICATIONS`` is negotiated) and stopped = with -``VHOST_USER_GET_VRING_BASE``. A stopped ring enters the started state ag= ain +``VHOST_USER_GET_VRING_BASE`` or ``VHOST_USER_GET_VRING_BASE_SKIP_DRAIN``.= A stopped ring enters the started state again with ``VHOST_USER_SET_VRING_KICK`` (or ``VHOST_USER_VRING_KICK`` if ``VHOST_USER_PROTOCOL_F_INBAND_NOTIFICATIONS`` is negotiated) and the back= -end resumes processing requests. @@ -1159,6 +1160,7 @@ Protocol features #define VHOST_USER_PROTOCOL_F_GET_VRING_BASE_INFLIGHT 20 #define VHOST_USER_PROTOCOL_F_GPA_ADDRESSES 21 #define VHOST_USER_PROTOCOL_F_SHMEM 22 + #define VHOST_USER_PROTOCOL_F_GET_VRING_BASE_SKIP_DRAIN 23 =20 Front-end message types ----------------------- @@ -1355,17 +1357,11 @@ Front-end message types set to 0. =20 By default, the back-end must complete all inflight I/O requests for the - specified vring before stopping it. - - If the ``VHOST_USER_PROTOCOL_F_GET_VRING_BASE_INFLIGHT`` protocol - feature has been negotiated, the back-end may suspend in-flight I/O - requests and record them as described in :ref:`Inflight I/O tracking - ` instead of completing them before stopping the v= ring. - How to suspend an in-flight request depends on the implementation of the= back-end - but it typically can be done by aborting or cancelling the underlying I/O - request. The ``VHOST_USER_PROTOCOL_F_GET_VRING_BASE_INFLIGHT`` - protocol feature must only be negotiated if - ``VHOST_USER_PROTOCOL_F_INFLIGHT_SHMFD`` is also negotiated. + specified vring before stopping it. If the + ``VHOST_USER_PROTOCOL_F_GET_VRING_BASE_SKIP_DRAIN`` protocol feature has + been negotiated, the front-end may instead use + ``VHOST_USER_GET_VRING_BASE_SKIP_DRAIN`` to request the back-end to + suspend in-flight I/O immediately. =20 ``VHOST_USER_SET_VRING_KICK`` :id: 12 @@ -1868,6 +1864,28 @@ Front-end message types =20 * The size may be 0 if the region is unused. =20 +``VHOST_USER_GET_VRING_BASE_SKIP_DRAIN`` + :id: 45 + :equivalent ioctl: N/A + :request payload: vring state description + :reply payload: vring descriptor index/indices + + This message requires the ``VHOST_USER_PROTOCOL_F_GET_VRING_BASE_SKIP_DR= AIN`` + protocol feature to be negotiated. + + Identical to ``VHOST_USER_GET_VRING_BASE`` except that the back-end + must not wait for inflight I/O requests to complete before stopping + the vring. Instead, the back-end must immediately suspend all + in-flight I/O requests and record them as described in + :ref:`Inflight I/O tracking `. How to suspend + an in-flight request depends on the implementation of the back-end, + but it typically can be done by aborting or cancelling the underlying + I/O request. + + The ``VHOST_USER_PROTOCOL_F_GET_VRING_BASE_SKIP_DRAIN`` protocol feature + must only be negotiated if both ``VHOST_USER_PROTOCOL_F_GET_VRING_BASE_I= NFLIGHT`` + and ``VHOST_USER_PROTOCOL_F_INFLIGHT_SHMFD`` are also negotiated. + Back-end message types ---------------------- =20 diff --git a/include/hw/virtio/vhost-backend.h b/include/hw/virtio/vhost-ba= ckend.h index 6c949e6a38..2333fddacd 100644 --- a/include/hw/virtio/vhost-backend.h +++ b/include/hw/virtio/vhost-backend.h @@ -190,6 +190,7 @@ typedef struct VhostOps { vhost_set_vring_num_op vhost_set_vring_num; vhost_set_vring_base_op vhost_set_vring_base; vhost_get_vring_base_op vhost_get_vring_base; + vhost_get_vring_base_op vhost_get_vring_base_skip_drain; vhost_set_vring_kick_op vhost_set_vring_kick; vhost_set_vring_call_op vhost_set_vring_call; vhost_set_vring_err_op vhost_set_vring_err; diff --git a/include/hw/virtio/vhost-user.h b/include/hw/virtio/vhost-user.h index 06c360af18..47c13f8677 100644 --- a/include/hw/virtio/vhost-user.h +++ b/include/hw/virtio/vhost-user.h @@ -36,6 +36,7 @@ enum VhostUserProtocolFeature { VHOST_USER_PROTOCOL_F_GET_VRING_BASE_INFLIGHT =3D 20, VHOST_USER_PROTOCOL_F_GPA_ADDRESSES =3D 21, VHOST_USER_PROTOCOL_F_SHMEM =3D 22, + VHOST_USER_PROTOCOL_F_GET_VRING_BASE_SKIP_DRAIN =3D 23, VHOST_USER_PROTOCOL_F_MAX }; =20 diff --git a/hw/virtio/vhost-user.c b/hw/virtio/vhost-user.c index f737a05d07..faf9c8aedd 100644 --- a/hw/virtio/vhost-user.c +++ b/hw/virtio/vhost-user.c @@ -101,6 +101,7 @@ typedef enum VhostUserRequest { VHOST_USER_SET_DEVICE_STATE_FD =3D 42, VHOST_USER_CHECK_DEVICE_STATE =3D 43, VHOST_USER_GET_SHMEM_CONFIG =3D 44, + VHOST_USER_GET_VRING_BASE_SKIP_DRAIN =3D 45, VHOST_USER_MAX } VhostUserRequest; =20 @@ -167,6 +168,7 @@ static const char *vhost_req_name(VhostUserRequest req) VHOST_USER_CASE(GET_SHARED_OBJECT) VHOST_USER_CASE(SET_DEVICE_STATE_FD) VHOST_USER_CASE(CHECK_DEVICE_STATE) + VHOST_USER_CASE(GET_VRING_BASE_SKIP_DRAIN) default: return ""; } @@ -1409,12 +1411,18 @@ static VhostUserHostNotifier *fetch_notifier(VhostU= serState *u, return g_ptr_array_index(u->notifiers, idx); } =20 -static int vhost_user_get_vring_base(struct vhost_dev *dev, - struct vhost_vring_state *ring) +static int get_vring_base(struct vhost_dev *dev, + struct vhost_vring_state *ring, + bool skip_drain) { int ret; + int request =3D VHOST_USER_GET_VRING_BASE; + if (skip_drain) { + request =3D VHOST_USER_GET_VRING_BASE_SKIP_DRAIN; + } + VhostUserMsg msg =3D { - .hdr.request =3D VHOST_USER_GET_VRING_BASE, + .hdr.request =3D request, .hdr.flags =3D VHOST_USER_VERSION, .payload.state =3D *ring, .hdr.size =3D sizeof(msg.payload.state), @@ -1434,9 +1442,9 @@ static int vhost_user_get_vring_base(struct vhost_dev= *dev, return ret; } =20 - if (msg.hdr.request !=3D VHOST_USER_GET_VRING_BASE) { + if (msg.hdr.request !=3D request) { error_report("Received unexpected msg type. Expected %d received %= d", - VHOST_USER_GET_VRING_BASE, msg.hdr.request); + request, msg.hdr.request); return -EPROTO; } =20 @@ -1450,6 +1458,25 @@ static int vhost_user_get_vring_base(struct vhost_de= v *dev, return 0; } =20 +static int vhost_user_get_vring_base(struct vhost_dev *dev, + struct vhost_vring_state *ring) +{ + return get_vring_base(dev, ring, false); +} + +static int vhost_user_get_vring_base_skip_drain(struct vhost_dev *dev, + struct vhost_vring_state *ring) +{ + bool skip_drain_supported =3D vhost_user_has_protocol_feature(dev, + VHOST_USER_PROTOCOL_F_GET_VRING_BASE_SKIP_D= RAIN); + + if (!skip_drain_supported) { + return 0; + } + + return get_vring_base(dev, ring, true); +} + static int vhost_set_vring_file(struct vhost_dev *dev, VhostUserRequest request, struct vhost_vring_file *file) @@ -2578,6 +2605,12 @@ static int vhost_user_backend_init(struct vhost_dev = *dev, void *opaque, VHOST_USER_PROTOCOL_F_GET_VRING_BASE_INFLIG= HT); } =20 + if (!virtio_has_feature(protocol_features, + VHOST_USER_PROTOCOL_F_GET_VRING_BASE_INFLIGHT= )) { + protocol_features &=3D ~(1ULL << + VHOST_USER_PROTOCOL_F_GET_VRING_BASE_SKIP_DRA= IN); + } + /* final set of protocol features */ u->protocol_features =3D protocol_features; err =3D vhost_user_set_protocol_features(dev, u->protocol_features= ); @@ -3436,6 +3469,7 @@ const VhostOps user_ops =3D { .vhost_set_vring_num =3D vhost_user_set_vring_num, .vhost_set_vring_base =3D vhost_user_set_vring_base, .vhost_get_vring_base =3D vhost_user_get_vring_base, + .vhost_get_vring_base_skip_drain =3D vhost_user_get_vring_base_ski= p_drain, .vhost_set_vring_kick =3D vhost_user_set_vring_kick, .vhost_set_vring_call =3D vhost_user_set_vring_call, .vhost_set_vring_err =3D vhost_user_set_vring_err, diff --git a/hw/virtio/vhost.c b/hw/virtio/vhost.c index 17b36366dc..27c78ffabf 100644 --- a/hw/virtio/vhost.c +++ b/hw/virtio/vhost.c @@ -1515,7 +1515,7 @@ static int do_vhost_virtqueue_stop(struct vhost_dev *= dev, { if (skip_drain) { assert(vhost_user_has_protocol_feature(dev, - VHOST_USER_PROTOCOL_F_GET_VRING_BASE_INFLIGHT)); + VHOST_USER_PROTOCOL_F_GET_VRING_BASE_SKIP_DRAIN)); } int vhost_vq_index =3D dev->vhost_ops->vhost_get_vq_index(dev, idx); struct vhost_vring_state state =3D { --=20 MST From nobody Sat Sep 26 20:50:17 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=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1789080307; cv=none; d=zohomail.com; s=zohoarc; b=nVEXhtHyeCyx9aJMKphHfSYFeKrdG8HCdjYoDXxsbERYgzHV81vgqlGw+PVFuKO5lTrCP1++gVIQOLfbsQhQ749PF+KrwKByNPp42H8ADE+bwfE4QyLVZ/gi9f8OH+d2KDabY15d9T8BPUnhZj2jXNZNr3t18r34z8Kyofniv1U= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1789080307; h=Content-Type: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=QfzBMW08YXqJdiZb7Qe3vTI1hQNhNiXNaPJ5pmcJCyY=; b=VrPFra9qHxB1eu8fFfLUm1n8SWRcT0ExD1j7JZ/YoEujGaAPJGODuVOT3OCCoqm/twveWAWZtVCLHVtXCc9YkyOAwTWKFbUUwRL2c3EhLlrM4fiavCl/GPkq8czUREETmnNwz+fFMqQ3W5TyD4Z44WQrbgM1MLGfPITFqDM9r7g= 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 lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1789080307721604.6927707594233; Thu, 10 Sep 2026 15:45:07 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1x4nRZ-0000xc-55; Thu, 10 Sep 2026 18:40:48 -0400 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 1x4lS8-0005It-6S for qemu-devel@nongnu.org; Thu, 10 Sep 2026 16:33:10 -0400 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 1x4lRl-0002Z2-7Y for qemu-devel@nongnu.org; Thu, 10 Sep 2026 16:32:44 -0400 Received: from mail-wm1-f69.google.com (mail-wm1-f69.google.com [209.85.128.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-516-ILrrqYEsMiWZXPA8OJzhLw-1; Thu, 10 Sep 2026 16:15:47 -0400 Received: by mail-wm1-f69.google.com with SMTP id 5b1f17b1804b1-4994aebe932so2245745e9.3 for ; Thu, 10 Sep 2026 13:15:47 -0700 (PDT) Received: from redhat.com (IGLD-80-230-79-236.inter.net.il. [80.230.79.236]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-49e62230e72sm871435e9.4.2026.09.10.13.15.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Sep 2026 13:15:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1789072269; 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=QfzBMW08YXqJdiZb7Qe3vTI1hQNhNiXNaPJ5pmcJCyY=; b=BZ6Xol4EpO05k48wA+7ZnICwjnFJiONLx6LDgn6xXg9jG4VTA+9nAF99D2FoIGiQ/AjtkO auVWDkwf3Ag/hXBXoHpQJYynptiLExZVp8wrQiuoG/FVQnfBJz+TWYna969vsDweVVn3M9 NYEklIAJpPOHb99R1F4iSQthXDtZsNw= X-MC-Unique: ILrrqYEsMiWZXPA8OJzhLw-1 X-Mimecast-MFC-AGG-ID: ILrrqYEsMiWZXPA8OJzhLw_1789071347 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=google; t=1789071346; x=1789676146; 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=QfzBMW08YXqJdiZb7Qe3vTI1hQNhNiXNaPJ5pmcJCyY=; b=XGTkpMy0hW3P5tfm2uz5INLVc6C8MCk/6/IByNVeHYvrvvF6R0tMyCk6APZuZucwoM QrolNmxd+xfsgfSYZB2hyZsV09Cr71JQA40hGhMcL7RWt2PPX6OSFtbQbMtn/DMhZapk n4ejgOkr0GKQnhvpwoZ/TSs97Z1LnIBC6dXXQP9ifHXIOmRUkNeeLzr+DBjIFhQ7ZObK L9wCqWLtO81F4mxeX1Zht4m44Xt+WGr/t9t78NJp6BzpDqizei35NhSfAV+AeRc4CLn3 8epKl+menRKAbX/Tq60HXuazhSPM3SBmC/IpjYmAdXVUL4w4UzJtZ/2tvCWyKIdr0CpR Ep4A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1789071346; x=1789676146; 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=QfzBMW08YXqJdiZb7Qe3vTI1hQNhNiXNaPJ5pmcJCyY=; b=omfEVgCgodj1tQx3fMs4fbjMyUXdcPKeLjrzp/EyZe58LNoUbZtdB08oWnEzbXfBQ/ 3/WGEHousQ8EZ26PgsKhNe2IAlJ1CE1zL6M6q55NHMntcL8FqiXUPuf1+qru9uqJ/7YC c9oSnD/zMTfBIxoDqc1ZBaHK43svHO36bk0FLwyUJjGIp9jYbKbmVcaw2ccLapbzjM9G zJkCRxIBlWQkl0MRq6KF4wm3742t+5HEUqzWwkB0B4NaNPAhFV56/wnVdloJbypwqs6q PK2tmRVky0tdPecaSvbGlleb8+AufimqAYt5q+836BHnh/XJsnkJcnxffoiof0xGV1qq nS7A== X-Gm-Message-State: AFuF++l3tvL+iB6ai62S5e7VCGWN8MqEpF18BaUjJeT3G36pzGi+aYId bJ6dgAoR45Mx+wLw0TE5WtuXxGkxqzwdo0Bn9+uam4OFkdWe6YTC1Qj/IxUr6/c2C2aso5bw0p9 QTBPHR2RU/MXSQ8eGaXY+N58wrsjsTa6rndmfAJ8mD1uv3iEbwDAuOJa9tzc6ES/IGoi6Riz+KN y1lOBHYXarAQg/wk64eHGTE24w+X9xPp5WjQ== X-Gm-Gg: AYBFou3QIQ3e3oztuwhGp1KWjo5cl1rtfAkc/ItMqo83YAzHh+HgnPWFq7V1T5EVdh8 vQF+YiJ1D6siCThNsrpLToWeLvRDiE57cepmCLqdu6P/q4A2JZNAez/V0rATZwTGdL7fAM+JcYe fL4pWJsSlYz/zi4EmYIyQzggtrGYWn6qj6VckYii9J5Lq8a+8xSojXysc799YOQ0Q0e/a0C2ElH soELTNNPzk9d+BNy1st/zHtnIyS4xaZEBM+jvP+/+Yn5tWO4W4XN+HxSSL/GSFV6AUfoTlMoINq fbPYDVRiXt4wYqG96viOimUItRGm6FRv3HAcdBlfn7p37qhT9aJiuV5JgVrMOJ5A4QgKV/UJMZE eO2pH35RjoM6wUNRP/eMhQts= X-Received: by 2002:a05:600c:3b90:b0:49c:d52e:d0ea with SMTP id 5b1f17b1804b1-49e619b397emr13912845e9.4.1789071346499; Thu, 10 Sep 2026 13:15:46 -0700 (PDT) X-Received: by 2002:a05:600c:3b90:b0:49c:d52e:d0ea with SMTP id 5b1f17b1804b1-49e619b397emr13911915e9.4.1789071345908; Thu, 10 Sep 2026 13:15:45 -0700 (PDT) Date: Thu, 10 Sep 2026 16:15:42 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Alexandr Moshkov , Stefano Garzarella Subject: [PULL 86/90] vhost-user: use skip_drain with GET_VRING_BASE_SKIP_DRAIN message Message-ID: <7dd0f53d0b10c19ec83adf369801cc1104b1b56f.1789071043.git.mst@redhat.com> References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-Mailer: git-send-email 2.51.2.2891.g4157995a80.dirty X-Mutt-Fcc: =sent 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=170.10.133.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com 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, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_PASS=-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-Zoho-Virus-Status: 1 X-Zoho-AV-Stamp: zmail-av-0.2.13.1.5.4/289.74.40 X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1789080309604158500 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Alexandr Moshkov Wire up the skip_drain parameter introduced in the previous commit to the new GET_VRING_BASE_SKIP_DRAIN message. When skip_drain is set, send GET_VRING_BASE_SKIP_DRAIN instead of GET_VRING_BASE, instructing the back-end to suspend in-flight I/O immediately. Signed-off-by: Alexandr Moshkov Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin Message-ID: <20260803072853.2920007-4-dtalexundeer@yandex-team.ru> --- hw/virtio/vhost.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/hw/virtio/vhost.c b/hw/virtio/vhost.c index 27c78ffabf..68827dc731 100644 --- a/hw/virtio/vhost.c +++ b/hw/virtio/vhost.c @@ -1531,7 +1531,11 @@ static int do_vhost_virtqueue_stop(struct vhost_dev = *dev, } =20 if (!force) { - r =3D dev->vhost_ops->vhost_get_vring_base(dev, &state); + if (!skip_drain) { + r =3D dev->vhost_ops->vhost_get_vring_base(dev, &state); + } else { + r =3D dev->vhost_ops->vhost_get_vring_base_skip_drain(dev, &st= ate); + } if (r < 0) { VHOST_OPS_DEBUG(r, "vhost VQ %u ring restore failed: %d", idx,= r); } --=20 MST From nobody Sat Sep 26 20:50:17 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=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1789085351; cv=none; d=zohomail.com; s=zohoarc; b=awmIre+GKysnD8IXeRefjmWQWEV/Dg2zSpo6CWSYfNqX4g/nIAFmN6UfAVFyb//Cj3Zp7PR/GchRhIVVNxr0azd4kPgct4N2RTenQwIqs3A2uB/ixBuVsnHN6duRcgqF+EIiX2iKHzLVfr/KhnCmz9UWA3Lxu1hBHXhmAoQc6lU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1789085351; h=Content-Type: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=zoVg9FbJe5Igrwha4XGcOTDxhYoC4yK3OmKWb/Idxgg=; b=UdpPEXV0j3zpCQDvjRbyFBFi9I9NWq9GPsMU60pr+kyFgv9FAi23GD+KT89zDd8FcxxqaqaXCd1nFnyZVbxBlpoW2KnOFf3aMuzin5PNuHFzImlodpxvSPQ7jEw9nNtUVu1ckBPZ5+TkBkgFVpWMmEmNfcuINwGkDJeus7NRKCc= 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 lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1789085351392783.8715699511793; Thu, 10 Sep 2026 17:09:11 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1x4ooE-0008NL-IE; Thu, 10 Sep 2026 20:08:18 -0400 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 1x4lSK-0005VF-2l for qemu-devel@nongnu.org; Thu, 10 Sep 2026 16:33:34 -0400 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 1x4lS9-0002Z5-Hz for qemu-devel@nongnu.org; Thu, 10 Sep 2026 16:33:06 -0400 Received: from mail-wm1-f69.google.com (mail-wm1-f69.google.com [209.85.128.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-150-hb40dHQDNMGga25vpvvo1A-1; Thu, 10 Sep 2026 16:15:50 -0400 Received: by mail-wm1-f69.google.com with SMTP id 5b1f17b1804b1-490a767b782so1594955e9.2 for ; Thu, 10 Sep 2026 13:15:50 -0700 (PDT) Received: from redhat.com (IGLD-80-230-79-236.inter.net.il. [80.230.79.236]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-49e60946249sm21378645e9.0.2026.09.10.13.15.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Sep 2026 13:15:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1789072269; 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=zoVg9FbJe5Igrwha4XGcOTDxhYoC4yK3OmKWb/Idxgg=; b=S/b3QfwzZTSSub4ENHinRNZ40ez10r+iuRXWw9SAFsmh2p+x9nVihqmwuQefMMpFfO7lwh ZQ9816P8aoeyrfE4r+52aHuDEicuWQ2chcnkuyTffm/iSQynpr8Cw3IgXjPoOtKslEHXrB UmlF7q9ZO/AnBYHoLNXhQJHgBk4F6cE= X-MC-Unique: hb40dHQDNMGga25vpvvo1A-1 X-Mimecast-MFC-AGG-ID: hb40dHQDNMGga25vpvvo1A_1789071350 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=google; t=1789071350; x=1789676150; 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=zoVg9FbJe5Igrwha4XGcOTDxhYoC4yK3OmKWb/Idxgg=; b=c/8Z1D8YPcd2HnO5gC8iki0ItQN9gaDbV3ughoSsRWufMYin4GU0JTjyBs7C/s4k4u FY2VWTXH0iUXpcCi3D2GIxVVelUZTuZuGuv68TrvcfnBmpqgT0zbjhY1yZsEzUkOr/Tf LT+Ig3y6ZbygTnBKxVrZ5iwaKCwwLugu5KBIddEXWzlLtIiLiXKWOVAu4yUFBgomOtjK rtrKeuECbzeGpJEXuz6LjWs9AhiD+8umozZsBNqVxj7+/XdZf/zquIePx1uY4MLTGAom 5oZKi0o0LY4yEK5enpGitadOJrtOdvoVTxhO32rHtpHL6DKibDV47aP7Tn1yWR2d2CjQ atfQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1789071350; x=1789676150; 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=zoVg9FbJe5Igrwha4XGcOTDxhYoC4yK3OmKWb/Idxgg=; b=SoDD3inl4deFNaSYL3KSkJNcIAgPHbRvZozp9ANcnrLfqxU+g1GvKUZt8nMIeltoOd 83M0umz8GjnXvOAANRmhBkdVXhX7DsGKd2qdmRTP8h6EZFvsMxukXzq6RlPRB5dyNNPL +4ZJLG04BFoRYi11igq0I53pYL6OWIvBf/E2jeyc+3FaImyLtEEySeCnrwC3boLw4sW4 McxnQa1flJJ/sS6xANpSONvpJMh6OwkIww8IzxIewfIw7ulFYRV9fquNQ2iRbiCutvLK GIW09HI+HzO2Q7+Wo/YrXTk0V4G33YFIUnKYo1xZ1fYwHs27Iw9jWQW1zpz72/d+9vxi yu9Q== X-Gm-Message-State: AFuF++nJyDY82TjdKKJ/jvE8Y9W/hLlrrf+UL6JuxZk8NtYIQjdMOJFb YhEXUS5cW6CnitX+i8fV7goDwt1ZWCHcsRNfpyq24SXehIg+ZvQKsELsFJ1l16g6DR/aN/Bk+ZN W1TCP4shM96YaKzA80qowxvKc+ny4gWu1LzqYbZb3ZgckhwkUZFc/rnL5kWCjxl887nvb+Zjy+V IEbQweCh3F0uN0fBd5y96SPeHY4uC8wc5pDw== X-Gm-Gg: AYBFou02bn4tghxVUSTA3wSzRoAriveTweeP40nIKEd+Bhn66y54HymNjUoa2K1G76L 2JOifDv1sLPM6xHupy/synvLnFchfLKQacZWWCBCwK8uEF+ss2vJwfoodqgYPtjs3lSXL2h4t9s 7guVVVpnt3TZ2/ivZEWeSS4q0guzs7gYWY68CUYDG2e3tVpuOq2DQdGGoIIDwDyHx1OwcaNu1Iu b3ZTrvc6dGWv01DkHmZ8Q+7WMJmeArGd1Q9MSzzTyysLF/ns8vAEPlg7yI1milwdfUpJnxNZOn1 Sf1XV769+iV6IclvNNCzNfCUJ01vhNGl8RZp6odifHSsFvxc9PVNdFO1ikxw5MkBRnNs1DkT8qG XrznmtZhzQBdok7WzBuOKW24= X-Received: by 2002:a05:600c:8b41:b0:49d:15b9:2a2a with SMTP id 5b1f17b1804b1-49e6198c0e6mr10037635e9.10.1789071349607; Thu, 10 Sep 2026 13:15:49 -0700 (PDT) X-Received: by 2002:a05:600c:8b41:b0:49d:15b9:2a2a with SMTP id 5b1f17b1804b1-49e6198c0e6mr10036995e9.10.1789071349179; Thu, 10 Sep 2026 13:15:49 -0700 (PDT) Date: Thu, 10 Sep 2026 16:15:46 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Alexandr Moshkov , Stefano Garzarella , Raphael Norwitz , Kevin Wolf , Hanna Reitz , qemu-block@nongnu.org Subject: [PULL 87/90] vhost-user-blk: make inflight-migration prop mutable on running vm Message-ID: <82511c320b6b03c91d578a033a9c1cd59b6b85a8.1789071043.git.mst@redhat.com> References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-Mailer: git-send-email 2.51.2.2891.g4157995a80.dirty X-Mutt-Fcc: =sent 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=170.10.133.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com 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, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_PASS=-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-Zoho-Virus-Status: 1 X-Zoho-AV-Stamp: zmail-av-0.2.13.1.5.4/289.74.40 X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1789085352678158500 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Alexandr Moshkov The inflight-migration property currently can only be set before the device is realized. This makes it impossible to disable inflight migration at runtime without restarting the VM. Make the property mutable, but only while the VM is running. Blocking changes when the VM is not running ensures that the value at stop time reliably reflects the intent set on a live VM, which allows vhost_user_blk_stop() to use skip_drain unconditionally based on the property value without inspecting migration runstate. Signed-off-by: Alexandr Moshkov Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin Message-ID: <20260803072853.2920007-5-dtalexundeer@yandex-team.ru> --- hw/block/vhost-user-blk.c | 28 ++++++++++++++++++++++++++-- 1 file changed, 26 insertions(+), 2 deletions(-) diff --git a/hw/block/vhost-user-blk.c b/hw/block/vhost-user-blk.c index c3e3c37f8c..501de30796 100644 --- a/hw/block/vhost-user-blk.c +++ b/hw/block/vhost-user-blk.c @@ -629,6 +629,8 @@ static const VMStateDescription vmstate_vhost_user_blk = =3D { } }; =20 +static PropertyInfo vhost_user_blk_inflight_migration_prop; + static const Property vhost_user_blk_properties[] =3D { DEFINE_PROP_CHR("chardev", VHostUserBlk, chardev), DEFINE_PROP_UINT16("num-queues", VHostUserBlk, num_queues, @@ -644,8 +646,9 @@ static const Property vhost_user_blk_properties[] =3D { VIRTIO_BLK_F_WRITE_ZEROES, true), DEFINE_PROP_BOOL("skip-get-vring-base-on-force-shutdown", VHostUserBlk, skip_get_vring_base_on_force_shutdown, false), - DEFINE_PROP_BOOL("inflight-migration", VHostUserBlk, - inflight_migration, false), + DEFINE_PROP("inflight-migration", VHostUserBlk, inflight_migration, + vhost_user_blk_inflight_migration_prop, bool, + .set_default =3D true, .defval.u =3D false), }; =20 static void vhost_user_blk_class_init(ObjectClass *klass, const void *data) @@ -675,8 +678,29 @@ static const TypeInfo vhost_user_blk_info =3D { .class_init =3D vhost_user_blk_class_init, }; =20 +static void vhost_user_blk_set_inflight_migration(Object *obj, Visitor *v, + const char *name, + void *opaque, Error **er= rp) +{ + DeviceState *dev =3D DEVICE(obj); + + if (dev->realized && !runstate_is_running()) { + error_setg(errp, "Property '%s' cannot be changed " + "while VM is not running", name); + return; + } + + qdev_prop_bool.set(obj, v, name, opaque, errp); +} + + static void virtio_register_types(void) { + vhost_user_blk_inflight_migration_prop =3D qdev_prop_bool; + vhost_user_blk_inflight_migration_prop.realized_set_allowed =3D true; + vhost_user_blk_inflight_migration_prop.set =3D + vhost_user_blk_set_inflight_migration; + type_register_static(&vhost_user_blk_info); } =20 --=20 MST From nobody Sat Sep 26 20:50:17 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=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1789084724; cv=none; d=zohomail.com; s=zohoarc; b=GzbSNIp+E1pnYXGTvNqzXXWO1MnyBbp/TFjqrKLNxFmLeX34pC8vVVUW/ZkMMV2R2MUB7I+8JPbBanDMltgCX2qq2NzElRg/5wnQUDrkkfzY3NubCr54th3ea9eHxy0TZHIDIUdKt0TUGOv7NzJJexOTPvaBHgKO+vAJyUneadU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1789084724; h=Content-Type: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=nSx6T21s1gGNGKoeJ/fw1fyWuRbnS5MwK7Kbb47ZVSQ=; b=ZGOys7a5MV/gn1qfPqokD1+SCOqMG/i5sWWWPjweocpTZmY1XnUIdDA+VK3N3b4Vs6hjzWV2odsNZ6kfgAK5of5+YNTTw/SmdztZvCgSbFY96Gau9QL08AOdzo0B2NZl/j0iB2hW4bDz8XKnFF9YoRVMBcpWplbeAYPSatDu7Kg= 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 lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1789084724197122.04887489761302; Thu, 10 Sep 2026 16:58:44 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1x4oYK-0004G1-Eh; Thu, 10 Sep 2026 19:51:51 -0400 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 1x4lW9-0006Tc-Fj for qemu-devel@nongnu.org; Thu, 10 Sep 2026 16:37:23 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1x4lVh-0004V7-Fe for qemu-devel@nongnu.org; Thu, 10 Sep 2026 16:36:51 -0400 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-104-DC_zVZ0CN2KvdyDmAygHZQ-1; Thu, 10 Sep 2026 16:15:53 -0400 Received: by mail-wm1-f70.google.com with SMTP id 5b1f17b1804b1-495474a5fbcso2101675e9.1 for ; Thu, 10 Sep 2026 13:15:53 -0700 (PDT) Received: from redhat.com (IGLD-80-230-79-236.inter.net.il. [80.230.79.236]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-486eb33ea4fsm762243f8f.21.2026.09.10.13.15.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Sep 2026 13:15:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1789072509; 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=nSx6T21s1gGNGKoeJ/fw1fyWuRbnS5MwK7Kbb47ZVSQ=; b=bUH4vWp3hmYOpxi9LCcWIx72C6aqm7Ry+B/6a0v+KMdEQp66grcX+GoOmECGcKf6cxelcF vnU2qm4rSNBvt6dIO+iPMrt41T3WFaIEg9+n0c4Mrg1fg4hZouaDh6uNeZT0OwM3bWu6GW GCt2N4rwUf0Dmr9/pt0SwOYcVIKSzYc= X-MC-Unique: DC_zVZ0CN2KvdyDmAygHZQ-1 X-Mimecast-MFC-AGG-ID: DC_zVZ0CN2KvdyDmAygHZQ_1789071352 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=google; t=1789071352; x=1789676152; 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=nSx6T21s1gGNGKoeJ/fw1fyWuRbnS5MwK7Kbb47ZVSQ=; b=jM3cH3fB6bbva81/8eC+lXYnQY6S82BSLHJCqJFVNYMEyl2chWbA/gWJBrgdWsYJQo uoha+F8eGwak7yc4HP3ITHAdpNMkrcs8OjVbCRpfzYCzI3BWP2zhwB2+ot05mwnslyUp p3ByiJugauI4cYxpDkobhp0Bc1DFEVDhMAiw1rHK5n/HnG63zy47ASvxUPtg+a3oUiI5 /nIble2h0bI/sltdFxtMzoxHdW6w+l7LFkHIkBfvoENmjdCJl1P9YgeG5GIEkXj+NpcT 6Wdd72pjPen7ofbu4XeBX9uuuL/CktVbkYNqOTW2vMFYu7GgEhcqZpahFudFcjvLNLSy 3yyA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1789071352; x=1789676152; 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=nSx6T21s1gGNGKoeJ/fw1fyWuRbnS5MwK7Kbb47ZVSQ=; b=oVtCsysQL5d5M8hxCC3hOQaLgSDQ5pKA2LOI4zcsc5znI4hQkiTo5PhrawUQrmmb+8 tvSEjkyRg2f6g5FmjxP3YXZtlAARsQsRaBKVJZmAv+DlRtcH9H/2xdD8vxlDsfKf6/1n RIYQmqG+mvOhK9ev05HB08WzBFhxf7q3scwyFTlYpqQaJ5LAsISTRrr2Sgkchhm78nDG jeZo+kpP/CDJjTPYoK7EvIvU28hRT6Gg/MBT3JhKGrXECP+IOxwfzLSlxj4lgc41xi5E AkWvjs+9PigkagtPwJF44gSOxuRV8mtX30DxK7kw5Ga/wbp3EY+KsH1O9XN+sFPmbimR ClUg== X-Gm-Message-State: AFuF++nYp1VGPQ3XXjcu/PsguFENz4VxIRFPiKilhjmaQ51sBRChdq1j iVpbtP95ucoEaykhKFH69iyuGxbwM0wVVMT7ZSKLyma930buWs2+vwIYU1g824wLs61l0SkpUK/ w3amw8irH+aDtSU2lDIhcjxCVazsKEb60CW4C/xM85Jn1lnsdB2lxZOCOM+fzUjJxwjZ/+hLDgH XHRkEf2uWocsuOHtU9eFAf/8TQL5Ey/zRAXw== X-Gm-Gg: AYBFou0mPJCxugRvRrS8odFX6BW3lP+j9HvfzTqPmV4w+oSnKlZwcZIYZAW08gfQCMf ftnaoTrIp4cQHAWHsGgvMaq8NWpFbEZxpZntYFW9sCpeP9wWwGP2iRcPn0HXNtFM29bA9fcSdRu cnqAkIwrApJYEwE7xtuK4XusWZcJDzP2hr+NFc2WQNy2DqRQ++P9OpLvM+q+YHNtS8KA0vOVayr RLamkVUb32uUKxkS6LVAmIA4EqaVlOhvXfvT0duEfPKbErjo158TAFva4psIbjfY8ifYoP3++4K kdzfXMqH9DLIbukRZQ2y3+jjrdvLrtHgXd1V49kcjIwHMibl2RNQL0ESzAK3WxtdLxBmDPVfeBf jao/Mb7AS/g0uvhtSRYx8vOA= X-Received: by 2002:a05:600c:548b:b0:49c:f2f4:eddd with SMTP id 5b1f17b1804b1-49e619bb9b2mr7028855e9.16.1789071352223; Thu, 10 Sep 2026 13:15:52 -0700 (PDT) X-Received: by 2002:a05:600c:548b:b0:49c:f2f4:eddd with SMTP id 5b1f17b1804b1-49e619bb9b2mr7028395e9.16.1789071351635; Thu, 10 Sep 2026 13:15:51 -0700 (PDT) Date: Thu, 10 Sep 2026 16:15:49 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Alexandr Moshkov , Vladimir Sementsov-Ogievskiy , Raphael Norwitz , Stefano Garzarella , Kevin Wolf , Hanna Reitz , qemu-block@nongnu.org Subject: [PULL 88/90] vhost-user-blk: move inflight_needed higher Message-ID: References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-Mailer: git-send-email 2.51.2.2891.g4157995a80.dirty X-Mutt-Fcc: =sent 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=170.10.129.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com 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, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=0.001, SPF_HELO_PASS=-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-Zoho-Virus-Status: 1 X-Zoho-AV-Stamp: zmail-av-0.2.13.1.5.4/289.74.40 X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1789084725538158500 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Alexandr Moshkov Move vhost_user_blk_inflight_needed() earlier in the file so it can be called from vhost_user_blk_stop(), which is defined before the VMState section. No functional change. Reviewed-by: Vladimir Sementsov-Ogievskiy Signed-off-by: Alexandr Moshkov Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin Message-ID: <20260803072853.2920007-6-dtalexundeer@yandex-team.ru> --- hw/block/vhost-user-blk.c | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/hw/block/vhost-user-blk.c b/hw/block/vhost-user-blk.c index 501de30796..3eaaa19719 100644 --- a/hw/block/vhost-user-blk.c +++ b/hw/block/vhost-user-blk.c @@ -137,6 +137,17 @@ const VhostDevConfigOps blk_ops =3D { .vhost_dev_config_notifier =3D vhost_user_blk_handle_config_change, }; =20 +static bool vhost_user_blk_inflight_needed(void *opaque) +{ + struct VHostUserBlk *s =3D opaque; + + bool inflight_migration =3D virtio_has_feature(s->dev.protocol_feature= s, + VHOST_USER_PROTOCOL_F_GET_VRING_BASE_INFLIG= HT); + + return inflight_migration; +} + + static int vhost_user_blk_start(VirtIODevice *vdev, Error **errp) { VHostUserBlk *s =3D VHOST_USER_BLK(vdev); @@ -597,14 +608,6 @@ static struct vhost_dev *vhost_user_blk_get_vhost(Virt= IODevice *vdev) return &s->dev; } =20 -static bool vhost_user_blk_inflight_needed(void *opaque) -{ - struct VHostUserBlk *s =3D opaque; - - return vhost_user_has_protocol_feature( - &s->dev, VHOST_USER_PROTOCOL_F_GET_VRING_BASE_INFLIGHT); -} - static const VMStateDescription vmstate_vhost_user_blk_inflight =3D { .name =3D "vhost-user-blk/inflight", .version_id =3D 1, --=20 MST From nobody Sat Sep 26 20:50:17 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=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1789082488; cv=none; d=zohomail.com; s=zohoarc; b=b/JtXKsHV0RIhK4UbT2Ofnp2isP8Jl0NneXd7wkL5jcGcg0JP0LuM6pqATB8BQiIfNwxBNr7e8/UmKi2gy51QatbmBOx9cYEOWIxPtKqdr3jOQ1DROtZ23lk5adMEAg8EYPUt99S+O4YESn2Zz5yEWVz5+ZxM7jzRqWYlJ/07Uk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1789082488; h=Content-Type: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=UDN3cLo5Foi5JRgDpkjb/YszGiugJ49+7UhR/BkZU+s=; b=Y9MInFkhvXjEQ2fbkCIZjFLEX0Wk7nygjwpoy0eZPvdYF1RxqvM/fIC6W5vdpHoREKjvS6FBHraUhAICCfSu+htkko9loSnmrE0ltJNNXH6FKTJMM7jbi0Q20ppBEIazHeJ9RCkp82dQp+e+x/eUTxyU2yB8E0O2b0wsqSdr67g= 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 lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1789082488278243.71116908551483; Thu, 10 Sep 2026 16:21:28 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1x4o1z-0002vG-Jp; Thu, 10 Sep 2026 19:18:31 -0400 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 1x4ljr-0001gH-PZ for qemu-devel@nongnu.org; Thu, 10 Sep 2026 16:51:40 -0400 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 1x4ljd-0006Qj-Ab for qemu-devel@nongnu.org; Thu, 10 Sep 2026 16:51:08 -0400 Received: from mail-wm1-f72.google.com (mail-wm1-f72.google.com [209.85.128.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-440-jm-2IrCTP-6nxo4TkFr-sQ-1; Thu, 10 Sep 2026 16:15:56 -0400 Received: by mail-wm1-f72.google.com with SMTP id 5b1f17b1804b1-49ccb223bceso1395205e9.0 for ; Thu, 10 Sep 2026 13:15:56 -0700 (PDT) Received: from redhat.com (IGLD-80-230-79-236.inter.net.il. [80.230.79.236]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-486eb360409sm727741f8f.36.2026.09.10.13.15.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Sep 2026 13:15:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1789073462; 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=UDN3cLo5Foi5JRgDpkjb/YszGiugJ49+7UhR/BkZU+s=; b=BM5PFcHDt6fWBHFYUiVvN/oVdUweCzrET+0c8eAi+HFzxErC6wlw329KdFbd4QTx8m1bX+ Mfwg9yA+g+ipIXm/rZ/98ATJquxcA6mFTXfSNVw36fz3gVPfls26ctGpWsnm1bswEkWQu8 kDr+sVlCn0lSD5fNur/ebXSE30nDmoo= X-MC-Unique: jm-2IrCTP-6nxo4TkFr-sQ-1 X-Mimecast-MFC-AGG-ID: jm-2IrCTP-6nxo4TkFr-sQ_1789071355 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=google; t=1789071355; x=1789676155; 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=UDN3cLo5Foi5JRgDpkjb/YszGiugJ49+7UhR/BkZU+s=; b=Ko0ElNpJyd9VCx19xFx9vtcYbG43+ZhcVOL4cVAkOLk9kFQ5tQQqvuCKnBS58vKAOU 5E/75ph0Up5uzk1PL1bQNb+yi4naypnIbjdudoFtH+BfsIhuyj0p5IhBtrTWYmWCG09x v27i4m2NB/J72/Fb7zoDSBYEWsuaqqu0+1e49z2LN4gGfNkY+nf0xCBY8luPAji/pU2O qOjlnUeC2sWLX7xFErlaBeXI38rZZ0+QMhp68NtKURElJ1YgwhzFM4gf7gswcQ3KFcaO ANwtShYITSodO84Yi0pFZZsS3dc/a7oijxTzUBb4zTaaLIYK/Ijqc/ywK6UrdvLJVvyg x1tw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1789071355; x=1789676155; 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=UDN3cLo5Foi5JRgDpkjb/YszGiugJ49+7UhR/BkZU+s=; b=Ng0RzHBjLl2dYBlnzaPyo9ZqlrxHbIFzdjw6o0lk/XVB+IF+Qae0wzM4IhLPuN56I/ +RPbCI/ePQcRYR4waJUVlNcknnfbVrXTW4//FbZmSCmn1YiClXtAEKyAuB2P/MpRlZGM ycvumelqtVLoc+t4kmqW+s3YqMdP3+IB+V5S/Fi6ccBZsEJwn4Ti6su1ulioDMW9qf+i jUNI6JOs7QWS07dyfTRCugg5tGHntw0t3fv70l52HMGK3CJoWs+ldCc01gnjlmfWKDtw 7kEwl/Lg328N+OfvAQfFRdN7ZLnHhq2uEsZuCFZoQ/+3IU3EwZ6xXnlF/O5TyZ22WidP ndjQ== X-Gm-Message-State: AFuF++l0lK0H02ccu+/Her9VYndV7vw5aBy8YsxnhwNueS8WEWKvaCJB ZdShdDYOZuiFCFS3xw6xrRrS3pvDVs4ZNKE+0CSCpQaS7RN6KcMmhE2Ab2XG3n9ufVVVHijn1Z/ rR6xvyIX4jd7+NXAHgRkzjfUhIRUrBmGCtu2MhIKkoK/rrKvEhsGEXx+gg+Hljw6Y/KYlUqw2sn ETfXmDk8WwFrEnhLO7A4n1sPIb+cDj2p3ClA== X-Gm-Gg: AYBFou3QxEf/Ebu84EclCGpMujpd4SLLb+5aNAwwPW9YglFe45NHuk8vn++0zHDKt1q NGj8dX0z61ek/IxHSjTCbo1VKHT3slKyb5XLoACRr09bd5m7S+rNtc6KPl2BFehLk8/B9WwE1fK EbsWSzz4lrfZav8ECr/NiFOhaqxqSMBxzv/JzpkK6JMr+h8+vmbNqjlaNfQ+HcmrDtq0BAOKlS6 Kd2kxNqZ/R9OZg1ZcGhT2xB29bl01HJW/0/DJlfNMQVprXZsPp6dowSCw56ESN3gpIDzSVAHxMC kTF9FiPl8KXAXD5v3H2w+D0Oa1qYwej5HxAlrZZL8I3p8ipEGxjzzT8sxnicZxheEoJn+UY9Kmw 7MgoGcPFWkvWTWq10Vn0hjRY= X-Received: by 2002:a05:600d:650c:20b0:49d:1d38:b5f6 with SMTP id 5b1f17b1804b1-49d26d7c52amr65751135e9.5.1789071355017; Thu, 10 Sep 2026 13:15:55 -0700 (PDT) X-Received: by 2002:a05:600d:650c:20b0:49d:1d38:b5f6 with SMTP id 5b1f17b1804b1-49d26d7c52amr65750555e9.5.1789071354278; Thu, 10 Sep 2026 13:15:54 -0700 (PDT) Date: Thu, 10 Sep 2026 16:15:51 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Alexandr Moshkov , Stefano Garzarella , Raphael Norwitz , Kevin Wolf , Hanna Reitz , qemu-block@nongnu.org Subject: [PULL 89/90] vhost-user-blk: use GET_VRING_BASE_SKIP_DRAIN when inflight-migration is on Message-ID: References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-Mailer: git-send-email 2.51.2.2891.g4157995a80.dirty X-Mutt-Fcc: =sent 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=170.10.133.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com 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, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, 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-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-Zoho-Virus-Status: 1 X-Zoho-AV-Stamp: zmail-av-0.2.13.1.5.4/289.74.40 X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1789082489986158500 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Alexandr Moshkov Currently during live migration vhost-user-blk sends GET_VRING_BASE to stop vrings, which causes the back-end to drain all in-flight I/O before returning. This blocks the migration source until all I/O completes, adding significant downtime proportional to the I/O load. When inflight-migration is enabled, send GET_VRING_BASE_SKIP_DRAIN instead. This instructs the back-end to immediately suspend in-flight I/O and record it in the shared inflight region, which is then migrated to the destination host along with the rest of the device state. Since inflight-migration can only be toggled while the VM is running, i2ts value at stop time reliably reflects the intent set on a live VM. There is no need to check migration runstate to decide whether to skip draining. Using GET_VRING_BASE_SKIP_DRAIN on a regular VM stop is safe - the back-end records any in-flight requests in the shared inflight region, and they will be resubmitted when the VM starts again via SET_INFLIGHT_FD. If the back-end does not support VHOST_USER_PROTOCOL_F_GET_VRING_BASE_SKIP_DRAIN, migration is aborted with an error in pre_save rather than hitting an assert at runtime. Signed-off-by: Alexandr Moshkov Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin Message-ID: <20260803072853.2920007-7-dtalexundeer@yandex-team.ru> --- include/hw/virtio/vhost-user.h | 1 - hw/block/vhost-user-blk.c | 29 +++++++++++++++++++++++------ hw/virtio/vhost-user.c | 3 +-- 3 files changed, 24 insertions(+), 9 deletions(-) diff --git a/include/hw/virtio/vhost-user.h b/include/hw/virtio/vhost-user.h index 47c13f8677..78b4fba27f 100644 --- a/include/hw/virtio/vhost-user.h +++ b/include/hw/virtio/vhost-user.h @@ -73,7 +73,6 @@ typedef struct VhostUserState { GPtrArray *notifiers; int memory_slots; bool supports_config; - bool supports_inflight_migration; } VhostUserState; =20 /** diff --git a/hw/block/vhost-user-blk.c b/hw/block/vhost-user-blk.c index 3eaaa19719..3dade143c9 100644 --- a/hw/block/vhost-user-blk.c +++ b/hw/block/vhost-user-blk.c @@ -141,10 +141,7 @@ static bool vhost_user_blk_inflight_needed(void *opaqu= e) { struct VHostUserBlk *s =3D opaque; =20 - bool inflight_migration =3D virtio_has_feature(s->dev.protocol_feature= s, - VHOST_USER_PROTOCOL_F_GET_VRING_BASE_INFLIG= HT); - - return inflight_migration; + return s->inflight_migration; } =20 =20 @@ -245,11 +242,13 @@ static int vhost_user_blk_stop(VirtIODevice *vdev) return 0; } =20 + bool skip_drain =3D vhost_user_blk_inflight_needed(s); + force_stop =3D s->skip_get_vring_base_on_force_shutdown && qemu_force_shutdown_requested(); =20 ret =3D force_stop ? vhost_dev_force_stop(&s->dev, vdev, true) : - vhost_dev_stop(&s->dev, vdev, true, false); + vhost_dev_stop(&s->dev, vdev, true, skip_drain); =20 err =3D k->set_guest_notifiers(qbus->parent, s->dev.nvqs, false); if (err < 0) { @@ -381,7 +380,6 @@ static int vhost_user_blk_connect(DeviceState *dev, Err= or **errp) vhost_dev_set_config_notifier(&s->dev, &blk_ops); =20 s->vhost_user.supports_config =3D true; - s->vhost_user.supports_inflight_migration =3D s->inflight_migration; ret =3D vhost_dev_init(&s->dev, &s->vhost_user, VHOST_BACKEND_TYPE_USE= R, 0, errp); if (ret < 0) { @@ -608,10 +606,29 @@ static struct vhost_dev *vhost_user_blk_get_vhost(Vir= tIODevice *vdev) return &s->dev; } =20 +static bool vhost_user_blk_pre_save(void *opaque, Error **errp) +{ + VHostUserBlk *s =3D VHOST_USER_BLK(opaque); + + bool inflight_migration_enabled =3D vhost_user_has_protocol_feature(&s= ->dev, + VHOST_USER_PROTOCOL_F_GET_VRING_BASE_SKIP_D= RAIN); + + if (vhost_user_blk_inflight_needed(s) && !inflight_migration_enabled) { + error_setg(errp, "can't migrate vhost-user-blk device: " + "backend doesn't support " + "VHOST_USER_PROTOCOL_F_GET_VRING_BASE_SKIP_DRAIN " + "protocol feature"); + return false; + } + + return true; +} + static const VMStateDescription vmstate_vhost_user_blk_inflight =3D { .name =3D "vhost-user-blk/inflight", .version_id =3D 1, .needed =3D vhost_user_blk_inflight_needed, + .pre_save_errp =3D vhost_user_blk_pre_save, .fields =3D (const VMStateField[]) { VMSTATE_VHOST_INFLIGHT_REGION(inflight, VHostUserBlk), VMSTATE_END_OF_LIST() diff --git a/hw/virtio/vhost-user.c b/hw/virtio/vhost-user.c index faf9c8aedd..047058833b 100644 --- a/hw/virtio/vhost-user.c +++ b/hw/virtio/vhost-user.c @@ -2598,8 +2598,7 @@ static int vhost_user_backend_init(struct vhost_dev *= dev, void *opaque, } } =20 - if (!u->user->supports_inflight_migration || - !virtio_has_feature(protocol_features, + if (!virtio_has_feature(protocol_features, VHOST_USER_PROTOCOL_F_INFLIGHT_SHMFD)) { protocol_features &=3D ~(1ULL << VHOST_USER_PROTOCOL_F_GET_VRING_BASE_INFLIG= HT); --=20 MST From nobody Sat Sep 26 20:50:17 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=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1789080349; cv=none; d=zohomail.com; s=zohoarc; b=CiqcoXACqXvyv6zorrqDu5nAVZYGLllKjIekYwX6N1GPyYTrc2Qah5VpebLgOLF7Y/HWUowl4LLrjV1+9DhBwZMJOu2uxuVaJa67Rf6az5uXmo4uiR8U5RUOJoIhTElhwC9yLh7Y81j9N2jR+pFL77AqZxLP/YLiJ3nb/VcFmbw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1789080349; h=Content-Type: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=oztlL0t0JZ8ezWj98qmIsDqrr8kTq2UUhazLUKK+7WQ=; b=alaoEdk1nsBt2gbhccGap3XVbKmg1TVGjOCMtmzDwWPK8kHhdCAvRuZsNiAMSKfNDeDYqE1PouTbQrIRaS9ShfVGZE6GMRgfuN5mAOYOkGvKUE4uBaFOk+ECnExLOJ9Qo7xJuVpPcc2EWZSYQK0zsdQSN8stwyheZ+7iHkG2aDQ= 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 lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1789080349217372.2528696332661; Thu, 10 Sep 2026 15:45:49 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1x4nTX-0001jl-Jd; Thu, 10 Sep 2026 18:42:41 -0400 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 1x4lUF-00060T-60 for qemu-devel@nongnu.org; Thu, 10 Sep 2026 16:35:34 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1x4lTo-0002ZF-8M for qemu-devel@nongnu.org; Thu, 10 Sep 2026 16:34:57 -0400 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-219-a1KOShLLNgu81QFiGPJdlA-1; Thu, 10 Sep 2026 16:15:59 -0400 Received: by mail-wm1-f70.google.com with SMTP id 5b1f17b1804b1-49cf5bd2f12so2224155e9.1 for ; Thu, 10 Sep 2026 13:15:59 -0700 (PDT) Received: from redhat.com (IGLD-80-230-79-236.inter.net.il. [80.230.79.236]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-49d26be3e35sm94211115e9.2.2026.09.10.13.15.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Sep 2026 13:15:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1789072269; 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=oztlL0t0JZ8ezWj98qmIsDqrr8kTq2UUhazLUKK+7WQ=; b=KP2lGWBtTx0yYLrLSWDwJbirMOBIoW+h+wGaTMKVLUH4+HmVYtS03HDQWVl+hJfLAZZPX7 kbKsphB5Ks2GwDhcdrN+Gh145pQMUZwRMimx88eUm7JNdpkHILitXZkxL9Fw5rN9n+j2qA mPrpvC0KzNm8yFm+6ePCtptss5b5b2k= X-MC-Unique: a1KOShLLNgu81QFiGPJdlA-1 X-Mimecast-MFC-AGG-ID: a1KOShLLNgu81QFiGPJdlA_1789071358 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=google; t=1789071358; x=1789676158; 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=oztlL0t0JZ8ezWj98qmIsDqrr8kTq2UUhazLUKK+7WQ=; b=TMiYvFcbrprFVM1Hr4XG3aTfn9It0rUUPmcKlAF85HvW4ouxDoxYaBEVzJItj6WtLt rkXQYTBj/Py1LttN6qYmt3bRZEN+9v2oXOMKV3ScfM/qtEdR5yHmnpaUzKv0uguzdTs9 jMtq/xwqUySA1hBXsIT9Xs0IjrwP34XzmGkmcJ96Qc4ZfaUIeg9yE6TTgo3Smb1/5Egb F5Ai9f0a/sQfbq/lZouB9AziD6IV8LTJwLPoZr1fvTZUvK8lBN+ou69CJsJNhFY1pfFC NsJnX6gkVP63i/FmTsf9axZNkY0vkO9d2I65AVTEr7m9+P/Buj04nwIqiIY8C9iA4y7W L3fw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1789071358; x=1789676158; 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=oztlL0t0JZ8ezWj98qmIsDqrr8kTq2UUhazLUKK+7WQ=; b=RYNzvQmCUbBk7tp/EPce9bDtM2Qjq/t92BnPpBVweqTgQeXykVaDfJY/BdkN0fH2jD lcBFfDUfKuu6WbiCAvpflNOjqJF4fjlUFbNe0Uyk+MwjuobDYO86fMFexFReLaawDxig LcX03GkVV+tV9lXQzYtX/gZDe7tf1ABOwvrZfBmCYb+fi2fn7UtAc6dS74n9QufdxElr bPvD1ptsrgQ/swMPujJvNJpv4tquSY98OdB0wJQuuTz7pc0Q82qY95T4y0uKTiw9xYWd V1s57ybba0fApq3I5tU+LNbbO7GVHC9HUmIbm/8aYs+Qfnpt9whcK78xJcPsbrifx0CL HvLA== X-Gm-Message-State: AFuF++kYZWZZM4RV6kz8i+ZuiAOI7i1Hw7qr/VIT2NTNE/gXwdFin74R tMrssNJjGCRJ4knKb2qoFCJOTTc2O/VVvSQjs3d7exRMTcDAvRW7YB8/h+5lg9gmJ7t3/YrKL76 jfy4wgX1U+l1aNBcDKE9qT7QVUDCVaoUoPmjUi5p2fZQoXVtjfLH7bEpCfR8uTP8aiOAOLWhKZP DPv+O4bLwxhr4OSuO5B0IeDtGEWfiAI6lf7g== X-Gm-Gg: AYBFou3EMkeZJdTtFD35+g70rvfC8g4y5litqIGpSP2Zyta3B1jZ8TteMQEzoGGa0DQ jlOiHnwpKTThOUMZ3LjZyphW7ELZtDc8vz2rUV749e3asVn4sGAhHLQJDnbN+t1AhZltRmU0crW wXlzWVlq17azc/VatboDWg2lAeAHd820f4pHtTYHKbhOG+NfdiMbYt2jEAMfVMXKjIx/xmvyvXC ftIDWMGY9Tlo7A8c/P8qmBHuoIUVFERNSDrW8Rt92ZywZnchB79JAPsWh862a5yQ6ONEE+MfpTP cfuZIHvJmvU239UcVr3WbrkVIXLIHiTzrgPWF78WsCGrdqhURkCdcIEfAwMLxOFNYrPHx8QzQ1h y4MNbcVCq1xzFIraJVshtG7M= X-Received: by 2002:a05:600c:630a:b0:49c:edfa:15a with SMTP id 5b1f17b1804b1-49e61992b6amr8282705e9.13.1789071358009; Thu, 10 Sep 2026 13:15:58 -0700 (PDT) X-Received: by 2002:a05:600c:630a:b0:49c:edfa:15a with SMTP id 5b1f17b1804b1-49e61992b6amr8282085e9.13.1789071357442; Thu, 10 Sep 2026 13:15:57 -0700 (PDT) Date: Thu, 10 Sep 2026 16:15:54 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Junjie Cao , Philippe =?utf-8?Q?Mathieu-Daud=C3=A9?= , Markus Armbruster , Pierrick Bouvier , Thomas Huth Subject: [PULL 90/90] MAINTAINERS: add Junjie Cao as CXL reviewer Message-ID: <99c75c61d61251d98e0b93dd199edbb10a990205.1789071043.git.mst@redhat.com> References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-Mailer: git-send-email 2.51.2.2891.g4157995a80.dirty X-Mutt-Fcc: =sent 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=170.10.129.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com 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, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=0.001, SPF_HELO_PASS=-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-Zoho-Virus-Status: 1 X-Zoho-AV-Stamp: zmail-av-0.2.13.1.5.4/289.74.40 X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1789080351590158500 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Junjie Cao I have been reviewing, testing and contributing to hw/cxl for the past few months, and would like to be Cc'd on incoming CXL changes to help with review. Suggested-by: Michael S. Tsirkin Signed-off-by: Junjie Cao Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin Message-ID: <20260908042310.493882-1-junjie.cao@intel.com> --- MAINTAINERS | 1 + 1 file changed, 1 insertion(+) diff --git a/MAINTAINERS b/MAINTAINERS index ec313c3259..d5eac4b42d 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -3334,6 +3334,7 @@ F: docs/devel/migration/CPR.rst =20 Compute Express Link M: Jonathan Cameron +R: Junjie Cao L: linux-cxl@vger.kernel.org S: Supported F: hw/cxl/ --=20 MST