Patch Detail
get:
Show a patch.
patch:
Update a patch.
put:
Update a patch.
GET /api/patches/2195830/?format=api
{ "id": 2195830, "url": "http://patchwork.ozlabs.org/api/patches/2195830/?format=api", "web_url": "http://patchwork.ozlabs.org/project/qemu-devel/patch/20260212062522.99565-22-anisinha@redhat.com/", "project": { "id": 14, "url": "http://patchwork.ozlabs.org/api/projects/14/?format=api", "name": "QEMU Development", "link_name": "qemu-devel", "list_id": "qemu-devel.nongnu.org", "list_email": "qemu-devel@nongnu.org", "web_url": "", "scm_url": "", "webscm_url": "", "list_archive_url": "", "list_archive_url_format": "", "commit_url_format": "" }, "msgid": "<20260212062522.99565-22-anisinha@redhat.com>", "list_archive_url": null, "date": "2026-02-12T06:25:05", "name": "[v4,21/31] hw/vfio: generate new file fd for pseudo device and rebind existing descriptors", "commit_ref": null, "pull_url": null, "state": "new", "archived": false, "hash": "11f47d0009abf8490eb24556fdfdf32c2b23d306", "submitter": { "id": 86030, "url": "http://patchwork.ozlabs.org/api/people/86030/?format=api", "name": "Ani Sinha", "email": "anisinha@redhat.com" }, "delegate": null, "mbox": "http://patchwork.ozlabs.org/project/qemu-devel/patch/20260212062522.99565-22-anisinha@redhat.com/mbox/", "series": [ { "id": 491935, "url": "http://patchwork.ozlabs.org/api/series/491935/?format=api", "web_url": "http://patchwork.ozlabs.org/project/qemu-devel/list/?series=491935", "date": "2026-02-12T06:24:45", "name": "Introduce support for confidential guest reset (x86)", "version": 4, "mbox": "http://patchwork.ozlabs.org/series/491935/mbox/" } ], "comments": "http://patchwork.ozlabs.org/api/patches/2195830/comments/", "check": "pending", "checks": "http://patchwork.ozlabs.org/api/patches/2195830/checks/", "tags": {}, "related": [], "headers": { "Return-Path": "<qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org>", "X-Original-To": "incoming@patchwork.ozlabs.org", "Delivered-To": "patchwork-incoming@legolas.ozlabs.org", "Authentication-Results": [ "legolas.ozlabs.org;\n\tdkim=pass (1024-bit key;\n unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256\n header.s=mimecast20190719 header.b=gelOIoP8;\n\tdkim=pass (2048-bit key;\n unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256\n header.s=google header.b=orzKNXAY;\n\tdkim-atps=neutral", "legolas.ozlabs.org;\n spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org\n (client-ip=209.51.188.17; helo=lists.gnu.org;\n envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org;\n receiver=patchwork.ozlabs.org)" ], "Received": [ "from lists.gnu.org (lists.gnu.org [209.51.188.17])\n\t(using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits))\n\t(No client certificate requested)\n\tby legolas.ozlabs.org (Postfix) with ESMTPS id 4fBQMW3k7vz1xvb\n\tfor <incoming@patchwork.ozlabs.org>; Thu, 12 Feb 2026 17:27:35 +1100 (AEDT)", "from localhost ([::1] helo=lists1p.gnu.org)\n\tby lists.gnu.org with esmtp (Exim 4.90_1)\n\t(envelope-from <qemu-devel-bounces@nongnu.org>)\n\tid 1vqQAi-0000SF-77; Thu, 12 Feb 2026 01:27:31 -0500", "from eggs.gnu.org ([2001:470:142:3::10])\n by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)\n (Exim 4.90_1) (envelope-from <anisinha@redhat.com>)\n id 1vqQA2-0008JO-4M\n for qemu-devel@nongnu.org; Thu, 12 Feb 2026 01:26:47 -0500", "from us-smtp-delivery-124.mimecast.com ([170.10.133.124])\n by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)\n (Exim 4.90_1) (envelope-from <anisinha@redhat.com>)\n id 1vqQA0-0005JO-ER\n for qemu-devel@nongnu.org; Thu, 12 Feb 2026 01:26:45 -0500", "from mail-pj1-f72.google.com (mail-pj1-f72.google.com\n [209.85.216.72]) by relay.mimecast.com with ESMTP with STARTTLS\n (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id\n us-mta-422-eEG7hRiHNUGn7dTw7hTO5Q-1; Thu, 12 Feb 2026 01:26:42 -0500", "by mail-pj1-f72.google.com with SMTP id\n 98e67ed59e1d1-354490889b6so13899830a91.3\n for <qemu-devel@nongnu.org>; Wed, 11 Feb 2026 22:26:42 -0800 (PST)", "from rhel9-box.lan ([122.164.27.113])\n by smtp.googlemail.com with ESMTPSA id\n 98e67ed59e1d1-3567e7d95d8sm4894122a91.2.2026.02.11.22.26.38\n (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n Wed, 11 Feb 2026 22:26:40 -0800 (PST)" ], "DKIM-Signature": [ "v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com;\n s=mimecast20190719; t=1770877603;\n h=from:from:reply-to:subject:subject:date:date:message-id:message-id:\n to:to:cc:cc:mime-version:mime-version:\n content-transfer-encoding:content-transfer-encoding:\n in-reply-to:in-reply-to:references:references;\n bh=XewWSAUDjfVoUcn+2YSpUOr5sv9iz8ihTRQjovE/jgc=;\n b=gelOIoP8s4CvnBnGv2sredYWWzwxi9uL26b1pQ3o8px/PgTLrlHdhdRGP6R9yXXiUqzuRC\n GFAju9D2/vX8hTNCiaMc+h9DmhD5INNPtk6qWCD6GWX8QBn2NIZ0iEBopkPr6GI/PUcelc\n PCXZNFRyJqMf7qT3ncef3WrqtNjrZ/w=", "v=1; a=rsa-sha256; c=relaxed/relaxed;\n d=redhat.com; s=google; t=1770877601; x=1771482401; darn=nongnu.org;\n h=content-transfer-encoding:mime-version:references:in-reply-to\n :message-id:date:subject:cc:to:from:from:to:cc:subject:date\n :message-id:reply-to;\n bh=XewWSAUDjfVoUcn+2YSpUOr5sv9iz8ihTRQjovE/jgc=;\n b=orzKNXAYx4sEkN7nWhfFcjnf+z+OdAeRvMHGf/PbKr8jyET+FoMyaRDLRuqpSgnCp+\n t8vC1TPqgDaIOkkI0EPZZ7C+VEbE5WqptVFLasmGYeu9FRx+/ukwx91/VtrEruwzKHLz\n O5Jfr4PUevGfuN9NBhhpf90MjT8QQdenDMAhyF+c8crcDMp9NoJ60BPX+acf4EVV9GsL\n Ox1WouuQ3u0Yr8U2RzLgUaEQ+U5Qvf8yLd9btjS2f/ylK7BXkuTranQzimu44UwRXvJC\n omnktd+iXRKlH/YOrHLkyKo02aZBUwJPDeo7U7XFyFLjxU+N08Z8pRWrKopo2QClSbjj\n Lwyw==" ], "X-MC-Unique": "eEG7hRiHNUGn7dTw7hTO5Q-1", "X-Mimecast-MFC-AGG-ID": "eEG7hRiHNUGn7dTw7hTO5Q_1770877601", "X-Google-DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed;\n d=1e100.net; s=20230601; t=1770877601; x=1771482401;\n h=content-transfer-encoding:mime-version:references:in-reply-to\n :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from\n :to:cc:subject:date:message-id:reply-to;\n bh=XewWSAUDjfVoUcn+2YSpUOr5sv9iz8ihTRQjovE/jgc=;\n b=gPcLsQ3UzCvaG3UZlUk1RuAULF4QJcOj1ELLHCbDLOUaWGVU9VcFvRWGqk155i37s4\n HWtgePOrzCzTxe3f47ngrzzsl3dJjumZE9e9qhzS4fx0ltmuvcm3VHA8TsrFO2XW6hR+\n kKV/xqv+jG58Zrd+dveVOnNluDqSYZ2deQQHcW4nFqrghyiS4Y/w3A/x7oRGCP1sd/QY\n jSU2unOQSTpUKZ2ORKMkq3XlopB7K5HkfAVSUNTfA+gPzKjBh592AVOs4m/NHwssfFdZ\n hX/uYILIpELwu25Q47VDQkfUQpEgtCbdJ8VZSGFo1r1LeyYD4OaK0Bbrevk8KosHATNQ\n qZ5w==", "X-Forwarded-Encrypted": "i=1;\n AJvYcCXYpfhK2Wsz/qFVh9S6xSoyMa/xrtKJmKRn7X4SE3a9EtLNaH3kowoU6QCAx/bt48BxjOdbo+gZK8lV@nongnu.org", "X-Gm-Message-State": "AOJu0YydVt6DvtzP4EAIAvk8iaRYFBQPxfq/69nLauUIxYfB4a5uYf92\n DZUsaQj3Jr8UPIpI0QsXAmRejkH9XO9h5DNR2nfOZehvuU+zGK4RE4kZkVCO7skyl2vuDJM3UH4\n 2Rh+BOfI7SN0FGe5yYKIUD4b03KsxZksOFM/4zqJFmmse1o4w8rQfEnAB", "X-Gm-Gg": "AZuq6aKufV9MXJmnAGoVBDksInsFzLryKrqh3tURBPhR3NN2zPOaKqBKElR3NAxDKB4\n Rmo5B9Rm6Am0y3Va6ALB5cmFd1tcPXW4O7B7ys6MGifHmI5mk+SIZfU2rUnVM5P3x4ExspE3y7u\n e4HoTd/20MJ5BBrWmtjYprsEjCZHuB7Xpim6J7RKtPBoisqZbtmr558cHR+DWyAObotGJdc0sYl\n SgHtMMaTkrLFDTrhKE3MOh9+fJirk87f1iWyrGO8wbI7eJxBkQxVx+EoxQbJSvzc83Ru/Kyno2x\n YB4h0QfB7I4clObeLUWyswcp+7SsEKvTyTxWS4BGynezchr1qNWf48Nr9DBGglCqpNmUsUVPFNa\n +udiUOrwuXeDXM862UnIKmTek/mwNs8uCHN/BHUViKdvm91tHi+gZoFI=", "X-Received": [ "by 2002:a17:90b:33cc:b0:340:776d:f4ca with SMTP id\n 98e67ed59e1d1-3568f403e39mr1685792a91.26.1770877600994;\n Wed, 11 Feb 2026 22:26:40 -0800 (PST)", "by 2002:a17:90b:33cc:b0:340:776d:f4ca with SMTP id\n 98e67ed59e1d1-3568f403e39mr1685780a91.26.1770877600641;\n Wed, 11 Feb 2026 22:26:40 -0800 (PST)" ], "From": "Ani Sinha <anisinha@redhat.com>", "To": "Alex Williamson <alex@shazbot.org>,\n =?utf-8?q?C=C3=A9dric_Le_Goater?= <clg@redhat.com>", "Cc": "kraxel@redhat.com, Ani Sinha <anisinha@redhat.com>, qemu-devel@nongnu.org", "Subject": "[PATCH v4 21/31] hw/vfio: generate new file fd for pseudo device and\n rebind existing descriptors", "Date": "Thu, 12 Feb 2026 11:55:05 +0530", "Message-ID": "<20260212062522.99565-22-anisinha@redhat.com>", "X-Mailer": "git-send-email 2.42.0", "In-Reply-To": "<20260212062522.99565-1-anisinha@redhat.com>", "References": "<20260212062522.99565-1-anisinha@redhat.com>", "MIME-Version": "1.0", "Content-Transfer-Encoding": "8bit", "Received-SPF": "pass client-ip=170.10.133.124;\n envelope-from=anisinha@redhat.com;\n 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,\n DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1,\n RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=0.001,\n RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001,\n 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 <qemu-devel.nongnu.org>", "List-Unsubscribe": "<https://lists.nongnu.org/mailman/options/qemu-devel>,\n <mailto:qemu-devel-request@nongnu.org?subject=unsubscribe>", "List-Archive": "<https://lists.nongnu.org/archive/html/qemu-devel>", "List-Post": "<mailto:qemu-devel@nongnu.org>", "List-Help": "<mailto:qemu-devel-request@nongnu.org?subject=help>", "List-Subscribe": "<https://lists.nongnu.org/mailman/listinfo/qemu-devel>,\n <mailto:qemu-devel-request@nongnu.org?subject=subscribe>", "Errors-To": "qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org", "Sender": "qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org" }, "content": "Normally the vfio pseudo device file descriptor lives for the life of the VM.\nHowever, when the kvm VM file descriptor changes, a new file descriptor\nfor the pseudo device needs to be generated against the new kvm VM descriptor.\nOther existing vfio descriptors needs to be reattached to the new pseudo device\ndescriptor. This change performs the above steps.\n\nThis chnage is untested.\n\nSigned-off-by: Ani Sinha <anisinha@redhat.com>\n---\n hw/vfio/helpers.c | 94 +++++++++++++++++++++++++++++++++++++++++++++++\n 1 file changed, 94 insertions(+)", "diff": "diff --git a/hw/vfio/helpers.c b/hw/vfio/helpers.c\nindex f68f8165d0..2ff189a53b 100644\n--- a/hw/vfio/helpers.c\n+++ b/hw/vfio/helpers.c\n@@ -116,6 +116,91 @@ bool vfio_get_info_dma_avail(struct vfio_iommu_type1_info *info,\n * we'll re-use it should another vfio device be attached before then.\n */\n int vfio_kvm_device_fd = -1;\n+\n+/*\n+ * Confidential virtual machines:\n+ * During reset of confidential vms, the kvm vm file descriptor changes.\n+ * In that case, the old vfio kvm file descriptor is\n+ * closed and a new descriptor is created agaist the new kvm vm file\n+ * descriptor.\n+ */\n+\n+typedef struct KVMVfioFileFd {\n+ int fd;\n+ QLIST_ENTRY(KVMVfioFileFd) node;\n+} KVMVfioFileFd;\n+\n+static QLIST_HEAD(, KVMVfioFileFd) kvm_vfio_file_fds =\n+ QLIST_HEAD_INITIALIZER(kvm_vfio_file_fds);\n+\n+static void insert_fd_to_list(int fd)\n+{\n+ KVMVfioFileFd *file_fd;\n+ file_fd = g_malloc0(sizeof(*file_fd));\n+ file_fd->fd = fd;\n+ QLIST_INSERT_HEAD(&kvm_vfio_file_fds, file_fd, node);\n+ return;\n+}\n+\n+static void remove_fd_from_list(int fd)\n+{\n+ KVMVfioFileFd *file_fd, *next;\n+\n+ QLIST_FOREACH_SAFE(file_fd, &kvm_vfio_file_fds, node, next) {\n+ if (file_fd->fd == fd) {\n+ QLIST_REMOVE(file_fd, node);\n+ g_free(file_fd);\n+ break;\n+ }\n+ }\n+ return;\n+}\n+\n+static int kvm_vfio_filefd_rebind(NotifierWithReturn *notifier, void *data,\n+ Error **errp)\n+{\n+ KVMVfioFileFd *file_fd;\n+ int ret = 0;\n+ struct kvm_device_attr attr = {\n+ .group = KVM_DEV_VFIO_FILE,\n+ .attr = KVM_DEV_VFIO_FILE_ADD,\n+ };\n+ struct kvm_create_device cd = {\n+ .type = KVM_DEV_TYPE_VFIO,\n+ };\n+\n+ /* we are not interested in pre vmfd change notification */\n+ if (((VmfdChangeNotifier *)data)->pre) {\n+ return 0;\n+ }\n+\n+ if (kvm_vm_ioctl(kvm_state, KVM_CREATE_DEVICE, &cd)) {\n+ error_setg_errno(errp, errno, \"Failed to create KVM VFIO device\");\n+ return -errno;\n+ }\n+\n+ if (vfio_kvm_device_fd != -1) {\n+ close(vfio_kvm_device_fd);\n+ }\n+\n+ vfio_kvm_device_fd = cd.fd;\n+\n+ QLIST_FOREACH(file_fd, &kvm_vfio_file_fds, node) {\n+ attr.addr = (uint64_t)(unsigned long)&file_fd->fd;\n+ if (ioctl(vfio_kvm_device_fd, KVM_SET_DEVICE_ATTR, &attr)) {\n+ error_setg_errno(errp, errno,\n+ \"Failed to add fd %d to KVM VFIO device\",\n+ file_fd->fd);\n+ ret = -errno;\n+ }\n+ }\n+ return ret;\n+}\n+\n+static struct NotifierWithReturn kvm_vfio_vmfd_change_notifier = {\n+ .notify = kvm_vfio_filefd_rebind,\n+};\n+\n #endif\n \n void vfio_kvm_device_close(void)\n@@ -153,6 +238,11 @@ int vfio_kvm_device_add_fd(int fd, Error **errp)\n }\n \n vfio_kvm_device_fd = cd.fd;\n+ /*\n+ * If the vm file descriptor changes, add a notifier so that we can\n+ * re-create the vfio_kvm_device_fd.\n+ */\n+ kvm_vmfd_add_change_notifier(&kvm_vfio_vmfd_change_notifier);\n }\n \n if (ioctl(vfio_kvm_device_fd, KVM_SET_DEVICE_ATTR, &attr)) {\n@@ -160,6 +250,8 @@ int vfio_kvm_device_add_fd(int fd, Error **errp)\n fd);\n return -errno;\n }\n+\n+ insert_fd_to_list(fd);\n #endif\n return 0;\n }\n@@ -183,6 +275,8 @@ int vfio_kvm_device_del_fd(int fd, Error **errp)\n \"Failed to remove fd %d from KVM VFIO device\", fd);\n return -errno;\n }\n+\n+ remove_fd_from_list(fd);\n #endif\n return 0;\n }\n", "prefixes": [ "v4", "21/31" ] }