From nobody Sun Feb 8 14:36:51 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.libvirt.org designates 8.43.85.245 as permitted sender) client-ip=8.43.85.245; envelope-from=devel-bounces@lists.libvirt.org; helo=lists.libvirt.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of lists.libvirt.org designates 8.43.85.245 as permitted sender) smtp.mailfrom=devel-bounces@lists.libvirt.org; dmarc=fail(p=none dis=none) header.from=gmail.com Return-Path: Received: from lists.libvirt.org (lists.libvirt.org [8.43.85.245]) by mx.zohomail.com with SMTPS id 1728670448441980.1925568322955; Fri, 11 Oct 2024 11:14:08 -0700 (PDT) Received: by lists.libvirt.org (Postfix, from userid 996) id 45EF417D6; Fri, 11 Oct 2024 14:14:07 -0400 (EDT) Received: from lists.libvirt.org (localhost [IPv6:::1]) by lists.libvirt.org (Postfix) with ESMTP id 441C1179C; Fri, 11 Oct 2024 14:13:21 -0400 (EDT) Received: by lists.libvirt.org (Postfix, from userid 996) id 6D4A013A8; Fri, 11 Oct 2024 14:13:16 -0400 (EDT) Received: from mail-oa1-f53.google.com (mail-oa1-f53.google.com [209.85.160.53]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by lists.libvirt.org (Postfix) with ESMTPS id B312F148E for ; Fri, 11 Oct 2024 14:13:15 -0400 (EDT) Received: by mail-oa1-f53.google.com with SMTP id 586e51a60fabf-287b8444ff3so963875fac.1 for ; Fri, 11 Oct 2024 11:13:15 -0700 (PDT) Received: from home.. ([2603:8081:c640:1::1003]) by smtp.gmail.com with ESMTPSA id 586e51a60fabf-2885844a8b7sm1047097fac.58.2024.10.11.11.13.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 11 Oct 2024 11:13:13 -0700 (PDT) X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on lists.libvirt.org X-Spam-Level: X-Spam-Status: No, score=-0.5 required=5.0 tests=DKIM_ADSP_CUSTOM_MED, DKIM_INVALID,DKIM_SIGNED,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,RCVD_IN_VALIDITY_RPBL_BLOCKED, RCVD_IN_VALIDITY_SAFE_BLOCKED,SPF_HELO_NONE autolearn=unavailable autolearn_force=no version=3.4.4 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1728670394; x=1729275194; darn=lists.libvirt.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=NlLopCpjk2vdsEKGOx0kNYZMZne0cxOpaDSsCLU5G30=; b=jldmlukLlIkuTDscBouOH3HZS904dEXPLEFLBHFNnbKJOM0sk/Cdty01fFEmfWIFb+ BEMfYhJtTx82lFayzKxnVvvGg8JV+c1XzgIyBUVR/qI9a+BCzy7mS6Ts2e7vpZ8OIJNn ztAxOeHoYulZ/vkRywVHh4RQkiHV45efK5lZ9umnh9yrYx5D0TVXa18LkjRgOVswuYig ph5v/blAx7SMjWWW5SR92p6zCdzAnPTJKapQDMToX9+gDnawMjjseeAwYghE2Vq6fk0l KN99olKrH5nkqc/pdsX4yuVKPr/yQPpfZtvUZl2ohoOnWtyWvEJMbqKId8Xo3tMYI2jT p/vw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1728670394; x=1729275194; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=NlLopCpjk2vdsEKGOx0kNYZMZne0cxOpaDSsCLU5G30=; b=BfBy5RmQ4nUANpEFVLEdlsn2WhqLtUgLC5LbPeR1sWan/OcT32N182Womyk+EXSAyU BmouGAfiqf8gD8opVi/+/7MLuuuEvysqbsf/zxz0qqe9Fh9241rI8lTQE8tWWZ8fZFtF jNxQt9ZogLj/+FjCU9+8T7OACkMrfB2wTxx3qSRhu2+9fUIw5LdyuaeD+krft5H8lV/S zp/As8mas0IdgKh3Jd1M0nTWvCLqdWTDCty+ZwMibeu/aI6p6OIRwnGn8JkHcRm2ZH2I /J5aAZ4AZKFUDr6ejbYkkOJe48zlHFueLRNzNgDD9IyJhUy+syhtpfkVqde7MnPKMXTy qmeA== X-Gm-Message-State: AOJu0YyFKL6AIO7UOFwOl0sGmDiIcRj3jN7Q18o6jqTVJvAlON4aweHw MdPh7H/nGTovTrgeX7g21pkq0ltL0VoDUdv7JQG+2xuQfp+s6GHjVuweQw== X-Google-Smtp-Source: AGHT+IF1ZHinfES4dN8mBDhWzzTPwm5v9xj8jcJhZvjAOjtlpF/M1uUw4ODKe+pp9CZNt3/Osrw/mQ== X-Received: by 2002:a05:6870:798:b0:287:ce7:7c4a with SMTP id 586e51a60fabf-2886e00f920mr3252083fac.38.1728670394577; Fri, 11 Oct 2024 11:13:14 -0700 (PDT) From: Praveen K Paladugu X-Google-Original-From: Praveen K Paladugu To: devel@lists.libvirt.org Subject: [PATCH 01/10] hypervisor: move HostdevNeedsVFIO to hypervisor Date: Fri, 11 Oct 2024 13:13:02 -0500 Message-ID: <20241011181311.6813-2-prapal@linux.microsoft.com> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20241011181311.6813-1-prapal@linux.microsoft.com> References: <20241011181311.6813-1-prapal@linux.microsoft.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Message-ID-Hash: SWWRWG6WAMPQIDQSZCCOT4LDAEVYLGOY X-Message-ID-Hash: SWWRWG6WAMPQIDQSZCCOT4LDAEVYLGOY X-MailFrom: praveenkpaladugu@gmail.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-config-1; header-match-config-2; header-match-config-3; header-match-devel.lists.libvirt.org-0; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; suspicious-header CC: liuwe@microsoft.com X-Mailman-Version: 3.2.2 Precedence: list List-Id: Development discussions about the libvirt library & tools Archived-At: List-Archive: List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1728670449666116600 Content-Type: text/plain; charset="utf-8" Move HostdevNeedsVFIO method to hypervisor to be reused between qemu and ch drivers. Signed-off-by: Praveen K Paladugu Reviewed-by: Michal Privoznik --- src/hypervisor/virhostdev.c | 7 +++++++ src/hypervisor/virhostdev.h | 3 +++ src/libvirt_private.syms | 1 + src/qemu/qemu_cgroup.c | 5 +++-- src/qemu/qemu_hostdev.c | 8 -------- src/qemu/qemu_hostdev.h | 2 -- src/qemu/qemu_namespace.c | 2 +- 7 files changed, 15 insertions(+), 13 deletions(-) diff --git a/src/hypervisor/virhostdev.c b/src/hypervisor/virhostdev.c index 185ec2ca50..4b06e74894 100644 --- a/src/hypervisor/virhostdev.c +++ b/src/hypervisor/virhostdev.c @@ -2512,3 +2512,10 @@ virHostdevUpdateActiveNVMeDevices(virHostdevManager = *hostdev_mgr, } goto cleanup; } + +bool +virHostdevNeedsVFIO(const virDomainHostdevDef *hostdev) +{ + return virHostdevIsPCIDevice(hostdev) || + virHostdevIsMdevDevice(hostdev); +} diff --git a/src/hypervisor/virhostdev.h b/src/hypervisor/virhostdev.h index 22ec3068db..b9e6108816 100644 --- a/src/hypervisor/virhostdev.h +++ b/src/hypervisor/virhostdev.h @@ -232,3 +232,6 @@ virHostdevUpdateActiveNVMeDevices(virHostdevManager *ho= stdev_mgr, const char *dom_name, virDomainDiskDef **disks, size_t ndisks); + +bool +virHostdevNeedsVFIO(const virDomainHostdevDef *hostdev); diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index e09fb98596..cca071f866 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -1670,6 +1670,7 @@ virCloseCallbacksDomainRunForConn; # hypervisor/virhostdev.h virHostdevFindUSBDevice; virHostdevManagerGetDefault; +virHostdevNeedsVFIO; virHostdevPCINodeDeviceDetach; virHostdevPCINodeDeviceReAttach; virHostdevPCINodeDeviceReset; diff --git a/src/qemu/qemu_cgroup.c b/src/qemu/qemu_cgroup.c index 23b7e6b4e8..be4b9a38ff 100644 --- a/src/qemu/qemu_cgroup.c +++ b/src/qemu/qemu_cgroup.c @@ -32,6 +32,7 @@ #include "virfile.h" #include "virdevmapper.h" #include "virglibutil.h" +#include "virhostdev.h" =20 #define VIR_FROM_THIS VIR_FROM_QEMU =20 @@ -481,7 +482,7 @@ qemuSetupHostdevCgroup(virDomainObj *vm, return -1; } =20 - if (qemuHostdevNeedsVFIO(dev) && + if (virHostdevNeedsVFIO(dev) && qemuCgroupAllowDevicePath(vm, QEMU_DEV_VFIO, VIR_CGROUP_DEVICE_RW, false) < 0) { return -1; @@ -530,7 +531,7 @@ qemuTeardownHostdevCgroup(virDomainObj *vm, return -1; } =20 - if (qemuHostdevNeedsVFIO(dev) && + if (virHostdevNeedsVFIO(dev) && !qemuDomainNeedsVFIO(vm->def) && qemuCgroupDenyDevicePath(vm, QEMU_DEV_VFIO, VIR_CGROUP_DEVICE_RWM, false) < 0) { diff --git a/src/qemu/qemu_hostdev.c b/src/qemu/qemu_hostdev.c index 15b543dbff..f25ccaf1a4 100644 --- a/src/qemu/qemu_hostdev.c +++ b/src/qemu/qemu_hostdev.c @@ -130,14 +130,6 @@ qemuHostdevUpdateActiveDomainDevices(virQEMUDriver *dr= iver, } =20 =20 -bool -qemuHostdevNeedsVFIO(const virDomainHostdevDef *hostdev) -{ - return virHostdevIsPCIDevice(hostdev) || - virHostdevIsMdevDevice(hostdev); -} - - bool qemuHostdevHostSupportsPassthroughVFIO(void) { diff --git a/src/qemu/qemu_hostdev.h b/src/qemu/qemu_hostdev.h index 3e9adc57a9..bbf7bb11e7 100644 --- a/src/qemu/qemu_hostdev.h +++ b/src/qemu/qemu_hostdev.h @@ -23,8 +23,6 @@ =20 #include "qemu_conf.h" =20 -bool qemuHostdevNeedsVFIO(const virDomainHostdevDef *hostdev); - bool qemuHostdevHostSupportsPassthroughVFIO(void); =20 int qemuHostdevUpdateActiveNVMeDisks(virQEMUDriver *driver, diff --git a/src/qemu/qemu_namespace.c b/src/qemu/qemu_namespace.c index bbe3d5a1f7..5c92b5547e 100644 --- a/src/qemu/qemu_namespace.c +++ b/src/qemu/qemu_namespace.c @@ -339,7 +339,7 @@ qemuDomainSetupHostdev(virDomainObj *vm, if (path) *paths =3D g_slist_prepend(*paths, g_steal_pointer(&path)); =20 - if (qemuHostdevNeedsVFIO(hostdev) && + if (virHostdevNeedsVFIO(hostdev) && (!hotplug || !qemuDomainNeedsVFIO(vm->def))) *paths =3D g_slist_prepend(*paths, g_strdup(QEMU_DEV_VFIO)); =20 --=20 2.44.0 From nobody Sun Feb 8 14:36:51 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.libvirt.org designates 8.43.85.245 as permitted sender) client-ip=8.43.85.245; envelope-from=devel-bounces@lists.libvirt.org; helo=lists.libvirt.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of lists.libvirt.org designates 8.43.85.245 as permitted sender) smtp.mailfrom=devel-bounces@lists.libvirt.org; dmarc=fail(p=none dis=none) header.from=gmail.com Return-Path: Received: from lists.libvirt.org (lists.libvirt.org [8.43.85.245]) by mx.zohomail.com with SMTPS id 172867047566625.69138491461888; Fri, 11 Oct 2024 11:14:35 -0700 (PDT) Received: by lists.libvirt.org (Postfix, from userid 996) id 824E6170A; Fri, 11 Oct 2024 14:14:34 -0400 (EDT) Received: from lists.libvirt.org (localhost [IPv6:::1]) by lists.libvirt.org (Postfix) with ESMTP id 544C614D1; Fri, 11 Oct 2024 14:13:23 -0400 (EDT) Received: by lists.libvirt.org (Postfix, from userid 996) id F2788148E; Fri, 11 Oct 2024 14:13:17 -0400 (EDT) Received: from mail-oa1-f54.google.com (mail-oa1-f54.google.com [209.85.160.54]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by lists.libvirt.org (Postfix) with ESMTPS id CB0A613A8 for ; Fri, 11 Oct 2024 14:13:16 -0400 (EDT) Received: by mail-oa1-f54.google.com with SMTP id 586e51a60fabf-2884e6ed0daso916922fac.0 for ; Fri, 11 Oct 2024 11:13:16 -0700 (PDT) Received: from home.. ([2603:8081:c640:1::1003]) by smtp.gmail.com with ESMTPSA id 586e51a60fabf-2885844a8b7sm1047097fac.58.2024.10.11.11.13.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 11 Oct 2024 11:13:14 -0700 (PDT) X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on lists.libvirt.org X-Spam-Level: X-Spam-Status: No, score=-0.5 required=5.0 tests=DKIM_ADSP_CUSTOM_MED, DKIM_INVALID,DKIM_SIGNED,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,RCVD_IN_VALIDITY_RPBL_BLOCKED, RCVD_IN_VALIDITY_SAFE_BLOCKED,SPF_HELO_NONE autolearn=unavailable autolearn_force=no version=3.4.4 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1728670396; x=1729275196; darn=lists.libvirt.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=bHqerm6Gxonp0bEsVDiuoAOc86rFZNBWYYU34U4DERk=; b=i0VNgR0uYjuDH0d9aZ+FFz/zOGL6tY1vExg7wSt46QSJm1GkzHCe724DuvvhPW8zXu q9tgo7cZr4MhXaFpJWHcx4mqnXQD3jal0KtI2lQpF5gkDiQ6Qal9/DErw2m5fyun7m4q G9t3W3g7SY2i4vuE5ozDkul6sgPVp2pXetkWjoOYL/lRHnDbeeBwqdeBEZj2S7CTxc6g oaNB9fYMwOH8IACDR9SshYpKNtymF7vWt+n3ewGyl5zz6GzEBoNpy0baL33RGx97ruH6 Q/LICSyBjSckJBkOZOyZo8HmwHaHK683GD1xPmTF/1dYdqtQ9RjqDr2fEe2cpb75iNtF mtdQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1728670396; x=1729275196; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=bHqerm6Gxonp0bEsVDiuoAOc86rFZNBWYYU34U4DERk=; b=RMNKPmTTiq6c5OsOzhEFDU6MjhE+wQ00MhZflSxT6SHpexxKI4HxDlVkGDBBKiXjvQ A9cpxkMK/u2rCTg4LvVQWFNLLq5MN2vKxq10YWuOw0F9mvbbH1CuSZPx1Nvsu4R803uE bpdeG6rl+suKlYFxniEPI8XH7Tyqjtty4RH5FtQDF+7scF2IrDpS2ldUEUMZxglsCBxM Q2YjovnsyN+nX+xABZVdbS9SuOm8hVLqmoUg7TujVcEw83HtWUD7U2KA1YQH++lg76XB K7FnY0yosGxQ4HBbhAlwFIa7XLV6zO8xvZvrrcOkHtwM8wT5RGfdun/jgVWO+ouegwee tVqw== X-Gm-Message-State: AOJu0YycH52uuoxOCsJYldXvGZ7KX79zPYi+dLt3xN15mNTzSccQc8J0 NTWJ9DEgmwyKIJdTZGw8KYolMrfxDmYPKuwR1ysX6SmPpPaLJ8/s/M8aKw== X-Google-Smtp-Source: AGHT+IFZlh+AkSQyPAyLrCaTAhDvoPpIRwf3thAkFHr1ZdAQskaXnlmLnkbvc4UtEVz5Jw1zbVFg0w== X-Received: by 2002:a05:6871:89e:b0:277:fe14:e68c with SMTP id 586e51a60fabf-2886df8f1d2mr2117636fac.33.1728670395633; Fri, 11 Oct 2024 11:13:15 -0700 (PDT) From: Praveen K Paladugu X-Google-Original-From: Praveen K Paladugu To: devel@lists.libvirt.org Subject: [PATCH 02/10] hypervisor: move HostdevHostSupportsPassthroughVFIO Date: Fri, 11 Oct 2024 13:13:03 -0500 Message-ID: <20241011181311.6813-3-prapal@linux.microsoft.com> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20241011181311.6813-1-prapal@linux.microsoft.com> References: <20241011181311.6813-1-prapal@linux.microsoft.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Message-ID-Hash: YD3OHJQ62WLIA47WWJEJZ54J7SYPFY2G X-Message-ID-Hash: YD3OHJQ62WLIA47WWJEJZ54J7SYPFY2G X-MailFrom: praveenkpaladugu@gmail.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-config-1; header-match-config-2; header-match-config-3; header-match-devel.lists.libvirt.org-0; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; suspicious-header CC: liuwe@microsoft.com X-Mailman-Version: 3.2.2 Precedence: list List-Id: Development discussions about the libvirt library & tools Archived-At: List-Archive: List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1728670477728116600 Content-Type: text/plain; charset="utf-8" Move HostdevHostSupportsPassthroughVFIO method to hypervisor to be shared between qemu and ch drivers. Signed-off-by: Praveen K Paladugu Reviewed-by: Michal Privoznik --- src/hypervisor/virhostdev.c | 16 ++++++++++++++++ src/hypervisor/virhostdev.h | 2 ++ src/libvirt_private.syms | 1 + src/qemu/qemu_capabilities.c | 2 +- src/qemu/qemu_domain.c | 2 +- src/qemu/qemu_driver.c | 2 +- src/qemu/qemu_hostdev.c | 15 --------------- src/qemu/qemu_hostdev.h | 2 -- tests/domaincapstest.c | 2 +- 9 files changed, 23 insertions(+), 21 deletions(-) diff --git a/src/hypervisor/virhostdev.c b/src/hypervisor/virhostdev.c index 4b06e74894..220578f0c0 100644 --- a/src/hypervisor/virhostdev.c +++ b/src/hypervisor/virhostdev.c @@ -29,12 +29,14 @@ #include "virhostdev.h" #include "viralloc.h" #include "virerror.h" +#include "virfile.h" #include "virlog.h" #include "virutil.h" #include "virnetdev.h" #include "configmake.h" =20 #define VIR_FROM_THIS VIR_FROM_NONE +#define VIR_DEV_VFIO "/dev/vfio/vfio" =20 VIR_LOG_INIT("util.hostdev"); =20 @@ -2519,3 +2521,17 @@ virHostdevNeedsVFIO(const virDomainHostdevDef *hostd= ev) return virHostdevIsPCIDevice(hostdev) || virHostdevIsMdevDevice(hostdev); } + +bool +virHostdevHostSupportsPassthroughVFIO(void) +{ + /* condition 1 - host has IOMMU */ + if (!virHostHasIOMMU()) + return false; + + /* condition 2 - /dev/vfio/vfio exists */ + if (!virFileExists(VIR_DEV_VFIO)) + return false; + + return true; +} diff --git a/src/hypervisor/virhostdev.h b/src/hypervisor/virhostdev.h index b9e6108816..b7f8473560 100644 --- a/src/hypervisor/virhostdev.h +++ b/src/hypervisor/virhostdev.h @@ -235,3 +235,5 @@ virHostdevUpdateActiveNVMeDevices(virHostdevManager *ho= stdev_mgr, =20 bool virHostdevNeedsVFIO(const virDomainHostdevDef *hostdev); + +bool virHostdevHostSupportsPassthroughVFIO(void); diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index cca071f866..39988cf0f4 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -1669,6 +1669,7 @@ virCloseCallbacksDomainRunForConn; =20 # hypervisor/virhostdev.h virHostdevFindUSBDevice; +virHostdevHostSupportsPassthroughVFIO; virHostdevManagerGetDefault; virHostdevNeedsVFIO; virHostdevPCINodeDeviceDetach; diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c index ac135aa301..e2f97c3d9a 100644 --- a/src/qemu/qemu_capabilities.c +++ b/src/qemu/qemu_capabilities.c @@ -6378,7 +6378,7 @@ static void virQEMUCapsFillDomainDeviceHostdevCaps(virQEMUCaps *qemuCaps, virDomainCapsDeviceHostdev *hostdev) { - bool supportsPassthroughVFIO =3D qemuHostdevHostSupportsPassthroughVFI= O(); + bool supportsPassthroughVFIO =3D virHostdevHostSupportsPassthroughVFIO= (); =20 hostdev->supported =3D VIR_TRISTATE_BOOL_YES; hostdev->mode.report =3D true; diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index fda4439b0b..065a37445e 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -11698,7 +11698,7 @@ static int qemuDomainPrepareHostdevPCI(virDomainHostdevDef *hostdev, virQEMUCaps *qemuCaps) { - bool supportsPassthroughVFIO =3D qemuHostdevHostSupportsPassthroughVFI= O(); + bool supportsPassthroughVFIO =3D virHostdevHostSupportsPassthroughVFIO= (); virDeviceHostdevPCIDriverName *driverName =3D &hostdev->source.subsys.= u.pci.driver.name; =20 /* assign defaults for hostdev passthrough */ diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index f27c21ca8c..e0adebf7ea 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -11482,7 +11482,7 @@ qemuNodeDeviceDetachFlags(virNodeDevicePtr dev, * further validation until then. */ =20 - if (!qemuHostdevHostSupportsPassthroughVFIO()) { + if (!virHostdevHostSupportsPassthroughVFIO()) { virReportError(VIR_ERR_ARGUMENT_UNSUPPORTED, "%s", _("VFIO device assignment is currently not supporte= d on this system")); return -1; diff --git a/src/qemu/qemu_hostdev.c b/src/qemu/qemu_hostdev.c index f25ccaf1a4..ab2769d482 100644 --- a/src/qemu/qemu_hostdev.c +++ b/src/qemu/qemu_hostdev.c @@ -130,21 +130,6 @@ qemuHostdevUpdateActiveDomainDevices(virQEMUDriver *dr= iver, } =20 =20 -bool -qemuHostdevHostSupportsPassthroughVFIO(void) -{ - /* condition 1 - host has IOMMU */ - if (!virHostHasIOMMU()) - return false; - - /* condition 2 - /dev/vfio/vfio exists */ - if (!virFileExists(QEMU_DEV_VFIO)) - return false; - - return true; -} - - int qemuHostdevPrepareOneNVMeDisk(virQEMUDriver *driver, const char *name, diff --git a/src/qemu/qemu_hostdev.h b/src/qemu/qemu_hostdev.h index bbf7bb11e7..b6dd2e0207 100644 --- a/src/qemu/qemu_hostdev.h +++ b/src/qemu/qemu_hostdev.h @@ -23,8 +23,6 @@ =20 #include "qemu_conf.h" =20 -bool qemuHostdevHostSupportsPassthroughVFIO(void); - int qemuHostdevUpdateActiveNVMeDisks(virQEMUDriver *driver, virDomainDef *def); int qemuHostdevUpdateActiveMediatedDevices(virQEMUDriver *driver, diff --git a/tests/domaincapstest.c b/tests/domaincapstest.c index e557337617..e520c7d7bc 100644 --- a/tests/domaincapstest.c +++ b/tests/domaincapstest.c @@ -105,7 +105,7 @@ fillQemuCaps(virDomainCaps *domCaps, return -1; =20 /* The function above tries to query host's VFIO capabilities by calli= ng - * qemuHostdevHostSupportsPassthroughVFIO() which, however, can't be + * virHostdevHostSupportsPassthroughVFIO() which, however, can't be * successfully mocked as they are not exposed as internal APIs. There= fore, * instead of mocking set the expected values here by hand. */ VIR_DOMAIN_CAPS_ENUM_SET(domCaps->hostdev.pciBackend, --=20 2.44.0 From nobody Sun Feb 8 14:36:51 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.libvirt.org designates 8.43.85.245 as permitted sender) client-ip=8.43.85.245; envelope-from=devel-bounces@lists.libvirt.org; helo=lists.libvirt.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of lists.libvirt.org designates 8.43.85.245 as permitted sender) smtp.mailfrom=devel-bounces@lists.libvirt.org; dmarc=fail(p=none dis=none) header.from=gmail.com Return-Path: Received: from lists.libvirt.org (lists.libvirt.org [8.43.85.245]) by mx.zohomail.com with SMTPS id 1728670497179218.74214168177832; Fri, 11 Oct 2024 11:14:57 -0700 (PDT) Received: by lists.libvirt.org (Postfix, from userid 996) id 22E8C1484; Fri, 11 Oct 2024 14:14:56 -0400 (EDT) Received: from lists.libvirt.org (localhost [IPv6:::1]) by lists.libvirt.org (Postfix) with ESMTP id 2A51517B1; Fri, 11 Oct 2024 14:13:24 -0400 (EDT) Received: by lists.libvirt.org (Postfix, from userid 996) id 787321446; Fri, 11 Oct 2024 14:13:18 -0400 (EDT) Received: from mail-oa1-f52.google.com (mail-oa1-f52.google.com [209.85.160.52]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by lists.libvirt.org (Postfix) with ESMTPS id CD2E51484 for ; Fri, 11 Oct 2024 14:13:17 -0400 (EDT) Received: by mail-oa1-f52.google.com with SMTP id 586e51a60fabf-2884e7fad77so1287502fac.2 for ; Fri, 11 Oct 2024 11:13:17 -0700 (PDT) Received: from home.. ([2603:8081:c640:1::1003]) by smtp.gmail.com with ESMTPSA id 586e51a60fabf-2885844a8b7sm1047097fac.58.2024.10.11.11.13.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 11 Oct 2024 11:13:16 -0700 (PDT) X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on lists.libvirt.org X-Spam-Level: X-Spam-Status: No, score=-0.5 required=5.0 tests=DKIM_ADSP_CUSTOM_MED, DKIM_INVALID,DKIM_SIGNED,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,RCVD_IN_VALIDITY_RPBL_BLOCKED, RCVD_IN_VALIDITY_SAFE_BLOCKED,SPF_HELO_NONE autolearn=unavailable autolearn_force=no version=3.4.4 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1728670396; x=1729275196; darn=lists.libvirt.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=LWabdXhoaDtbLPQS/q+K7D7F/8888cln3zYRCp5ZVZM=; b=QCVOPKIoRYbtgoHFZr1HKowmlWVW0F5wQvPMz3S7E94rYtHHkrkMCA7UkQVw3bGJ/Z oK9wXdR95mORsH3TSN8pb4pscPs4s5+UfxtbDZUhDhu4QqfFvLSYg5W+LMwz6rk5mOwj duqFGa8twv9Zso8/mYjvJOU89ZGeuKJPQ0SplPPF0fViUk3ghGOM8m7RWfdY7Aqy91ZV L6ptchvpwxWckAYOzhgpvUM+83BPFkFmbOqplM+bGHXfwQgtiDEuNubDt75gd05wV1g8 ER3g3W5OHymfLifxsNJytLhUFe6hO1g07BzdCN/om7iwguUlIg5kYBNcAVaxypv049Hy nDOg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1728670396; x=1729275196; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=LWabdXhoaDtbLPQS/q+K7D7F/8888cln3zYRCp5ZVZM=; b=gGL06vNQRa/1YtWE5qYUEwItDyF9Lq4J2sO1Jf4lfh0gdaP08+pxJXMmt1z4IMibLD NLToO+ZVFcrEdSXuqg9ovEA/tizkfH1vAj1ho2BH6YvMSaTrThMcRUaNPUA616m0ZFLS 4nvO8LIYybk5syA9CHBSTL1quzrpO+64Qq4jtqzj+gs3dzhTicaosg1Mxiv7tgltTxYH yuBlot0KbtAmU4TyoloCH8AQCcEEHGzJ5HwNsKR65HSAOq+7uQ+dt5N3lbwZg+jUspHf tSITWASuE5DC5x64EMDQyjc/vyDXv0lVCd0+TBlZhfk/vEZF7XQ41PSPWIYflGfHQhvi YW+A== X-Gm-Message-State: AOJu0Yxu3WXoWaFkkqvsq4FDsvBqC9mxJd5l2N1cxiNhBwUcUy5lVgiP aVkiSCo4IQOaUB85hrxBfnGznRtDI3DVLKR5BYhziRncdGAieibUbkWhkw== X-Google-Smtp-Source: AGHT+IE7L3ILd0vhMbtsBprQwZE1otXFSMfo+I73p6LhanOWXiBgJM/iSMZ07JiE2aRX3SQX2pC3xg== X-Received: by 2002:a05:6870:7196:b0:287:29a0:cfe4 with SMTP id 586e51a60fabf-2886dfff304mr2241747fac.32.1728670396622; Fri, 11 Oct 2024 11:13:16 -0700 (PDT) From: Praveen K Paladugu X-Google-Original-From: Praveen K Paladugu To: devel@lists.libvirt.org Subject: [PATCH 03/10] qemu: replace qemuHostdevPreparePCIDevices Date: Fri, 11 Oct 2024 13:13:04 -0500 Message-ID: <20241011181311.6813-4-prapal@linux.microsoft.com> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20241011181311.6813-1-prapal@linux.microsoft.com> References: <20241011181311.6813-1-prapal@linux.microsoft.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Message-ID-Hash: MNECXOK2T5MDUNMBU6DURLCJ4I44GOIH X-Message-ID-Hash: MNECXOK2T5MDUNMBU6DURLCJ4I44GOIH X-MailFrom: praveenkpaladugu@gmail.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-config-1; header-match-config-2; header-match-config-3; header-match-devel.lists.libvirt.org-0; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; suspicious-header CC: liuwe@microsoft.com X-Mailman-Version: 3.2.2 Precedence: list List-Id: Development discussions about the libvirt library & tools Archived-At: List-Archive: List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1728670497686116600 Content-Type: text/plain; charset="utf-8" qemuHostdevPreparePCIDevices, virHostdevPreparePCIDevices are identical. Replacing qemu method with the generic one to reduce code duplication. This generic method will be used in ch driver to passthrough PCI devices. Signed-off-by: Praveen K Paladugu Reviewed-by: Michal Privoznik --- src/qemu/qemu_hostdev.c | 17 ++--------------- src/qemu/qemu_hostdev.h | 6 ------ src/qemu/qemu_hotplug.c | 5 +++-- 3 files changed, 5 insertions(+), 23 deletions(-) diff --git a/src/qemu/qemu_hostdev.c b/src/qemu/qemu_hostdev.c index ab2769d482..894f12e04f 100644 --- a/src/qemu/qemu_hostdev.c +++ b/src/qemu/qemu_hostdev.c @@ -152,20 +152,6 @@ qemuHostdevPrepareNVMeDisks(virQEMUDriver *driver, name, disks, ndisks); } =20 -int -qemuHostdevPreparePCIDevices(virQEMUDriver *driver, - const char *name, - const unsigned char *uuid, - virDomainHostdevDef **hostdevs, - int nhostdevs, - unsigned int flags) -{ - return virHostdevPreparePCIDevices(driver->hostdevMgr, - QEMU_DRIVER_NAME, - name, uuid, hostdevs, - nhostdevs, flags); -} - int qemuHostdevPrepareUSBDevices(virQEMUDriver *driver, const char *name, @@ -244,7 +230,8 @@ qemuHostdevPrepareDomainDevices(virQEMUDriver *driver, if (qemuHostdevPrepareNVMeDisks(driver, def->name, def->disks, def->nd= isks) < 0) return -1; =20 - if (qemuHostdevPreparePCIDevices(driver, def->name, def->uuid, + if (virHostdevPreparePCIDevices(driver->hostdevMgr, QEMU_DRIVER_NAME, + def->name, def->uuid, def->hostdevs, def->nhostdevs, flags)= < 0) return -1; =20 diff --git a/src/qemu/qemu_hostdev.h b/src/qemu/qemu_hostdev.h index b6dd2e0207..6f6c4f82bc 100644 --- a/src/qemu/qemu_hostdev.h +++ b/src/qemu/qemu_hostdev.h @@ -43,12 +43,6 @@ int qemuHostdevPrepareNVMeDisks(virQEMUDriver *driver, const char *name, virDomainDiskDef **disks, size_t ndisks); -int qemuHostdevPreparePCIDevices(virQEMUDriver *driver, - const char *name, - const unsigned char *uuid, - virDomainHostdevDef **hostdevs, - int nhostdevs, - unsigned int flags); int qemuHostdevPrepareUSBDevices(virQEMUDriver *driver, const char *name, virDomainHostdevDef **hostdevs, diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c index 4d4bcde1bc..d1c042c6a0 100644 --- a/src/qemu/qemu_hotplug.c +++ b/src/qemu/qemu_hotplug.c @@ -1544,8 +1544,9 @@ qemuDomainAttachHostPCIDevice(virQEMUDriver *driver, =20 if (!cfg->relaxedACS) flags |=3D VIR_HOSTDEV_STRICT_ACS_CHECK; - if (qemuHostdevPreparePCIDevices(driver, vm->def->name, - vm->def->uuid, &hostdev, 1, flags) < = 0) + if (virHostdevPreparePCIDevices(driver->hostdevMgr, QEMU_DRIVER_NAME, + vm->def->name, vm->def->uuid, + &hostdev, 1, flags) < 0) return -1; =20 if (qemuDomainAdjustMaxMemLockHostdev(vm, hostdev) < 0) --=20 2.44.0 From nobody Sun Feb 8 14:36:51 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.libvirt.org designates 8.43.85.245 as permitted sender) client-ip=8.43.85.245; envelope-from=devel-bounces@lists.libvirt.org; helo=lists.libvirt.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of lists.libvirt.org designates 8.43.85.245 as permitted sender) smtp.mailfrom=devel-bounces@lists.libvirt.org; dmarc=fail(p=none dis=none) header.from=gmail.com Return-Path: Received: from lists.libvirt.org (lists.libvirt.org [8.43.85.245]) by mx.zohomail.com with SMTPS id 1728670515667376.8400486091773; Fri, 11 Oct 2024 11:15:15 -0700 (PDT) Received: by lists.libvirt.org (Postfix, from userid 996) id 9ADEA17D0; Fri, 11 Oct 2024 14:15:14 -0400 (EDT) Received: from lists.libvirt.org (localhost [IPv6:::1]) by lists.libvirt.org (Postfix) with ESMTP id A51F91733; Fri, 11 Oct 2024 14:13:25 -0400 (EDT) Received: by lists.libvirt.org (Postfix, from userid 996) id DEBFE174F; Fri, 11 Oct 2024 14:13:19 -0400 (EDT) Received: from mail-ot1-f49.google.com (mail-ot1-f49.google.com [209.85.210.49]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by lists.libvirt.org (Postfix) with ESMTPS id 44FA81484 for ; Fri, 11 Oct 2024 14:13:19 -0400 (EDT) Received: by mail-ot1-f49.google.com with SMTP id 46e09a7af769-716a6e6d5a3so1548676a34.2 for ; Fri, 11 Oct 2024 11:13:19 -0700 (PDT) Received: from home.. ([2603:8081:c640:1::1003]) by smtp.gmail.com with ESMTPSA id 586e51a60fabf-2885844a8b7sm1047097fac.58.2024.10.11.11.13.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 11 Oct 2024 11:13:17 -0700 (PDT) X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on lists.libvirt.org X-Spam-Level: X-Spam-Status: No, score=-0.5 required=5.0 tests=DKIM_ADSP_CUSTOM_MED, DKIM_INVALID,DKIM_SIGNED,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,RCVD_IN_VALIDITY_RPBL_BLOCKED, RCVD_IN_VALIDITY_SAFE_BLOCKED,SPF_HELO_NONE autolearn=unavailable autolearn_force=no version=3.4.4 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1728670398; x=1729275198; darn=lists.libvirt.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=8lVjl86vepQLvpwuT31gDyACwmY1ECl7YQ/Vb0JMu3k=; b=kvfJOOIbnVz6F77DMN1E5lm1/+S8iwgPsd44sE8ucgVb0mIwpGdX0ZAgVrmEfLCuJs xKVMWw5+wC0zq1boLLS714g0+Hwzq+5jMmYieZgBrDxQ+xkxS42QWKP0tGRw7V4SAtf2 qWl3gHLri3QA0s9qbJTM32Lot2YwZ6aewGrnJoP7GTrgcknqOkSqtXeeFTqr2M+hMxVa qgmgt445B4t4MISc4xlLOyqDmRxnx8138/bGq1nD4YGzyXJSv3/Nu/4JwX4CMygs8tSd L2NpF7eLPjFE75n3wk7dqeIKnMiQMlNhPfwixFr22f5eYehuuH2JiR8dcW2lNOhVTgwO UWPw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1728670398; x=1729275198; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=8lVjl86vepQLvpwuT31gDyACwmY1ECl7YQ/Vb0JMu3k=; b=BJji2//TjNIZG5G/v6CAHLBV3NdegS9rnNcCcI6iOoFaO0Hl1JdAZMxt1UQWGpYl7F L3PQ55YmmxXY3yyoHbMNok1U9JfMgTPe3f8JEbX84OJbTwBR+HcGfMBECIui4M8I7kQ2 M/qa6W7MOSL6UeTxtx6GrQ6nX7XGj3qDGmxbUBD1hsIuHh/4TC9V0ZVeYuK5jTvAVUQy bk7dQ8uhYDKGxRdeVa8gxBeGpYuL4x2ZVVvk6y7UpepwP9fRmzjZIqHxNf7Ox0BM1uGe 5wtYhCke4j8glzv/OigBvS3dROxMAPNzUSZF3Z9CQvxL25m7z3uv/Z4jY/NE8TAuO6w/ xdnA== X-Gm-Message-State: AOJu0Yyv4r/XqGjNb6fCZ8f1mMdJXTio/LECwHTEvo9yECpWMAkSl5N5 rP/irlVpVweoNl2pvIZcl3JGmVhnnZTiIklKviv788LUrhy3mFfarmJiHw== X-Google-Smtp-Source: AGHT+IG7m3AgLQQYZ57JC0bGafON9PYIub8QwizPLqQVzUUubE0v1DL6zAvai0AMHASKHlcg9U1WgA== X-Received: by 2002:a05:6870:4725:b0:287:481:13aa with SMTP id 586e51a60fabf-2886e06e08bmr2194138fac.45.1728670397951; Fri, 11 Oct 2024 11:13:17 -0700 (PDT) From: Praveen K Paladugu X-Google-Original-From: Praveen K Paladugu To: devel@lists.libvirt.org Subject: [PATCH 04/10] ch: add host device manager to driver Date: Fri, 11 Oct 2024 13:13:05 -0500 Message-ID: <20241011181311.6813-5-prapal@linux.microsoft.com> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20241011181311.6813-1-prapal@linux.microsoft.com> References: <20241011181311.6813-1-prapal@linux.microsoft.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Message-ID-Hash: PNCKYIOUASQQ4N546HXGLOXSCRBH533S X-Message-ID-Hash: PNCKYIOUASQQ4N546HXGLOXSCRBH533S X-MailFrom: praveenkpaladugu@gmail.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-config-1; header-match-config-2; header-match-config-3; header-match-devel.lists.libvirt.org-0; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; suspicious-header CC: liuwe@microsoft.com X-Mailman-Version: 3.2.2 Precedence: list List-Id: Development discussions about the libvirt library & tools Archived-At: List-Archive: List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1728670517793116600 Content-Type: text/plain; charset="utf-8" From: Wei Liu Co-authored-by: Wei Liu Signed-off-by: Praveen K Paladugu Reviewed-by: Michal Privoznik --- src/ch/ch_conf.h | 4 ++++ src/ch/ch_driver.c | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/src/ch/ch_conf.h b/src/ch/ch_conf.h index a77cad7a2a..11061bc1b5 100644 --- a/src/ch/ch_conf.h +++ b/src/ch/ch_conf.h @@ -21,6 +21,7 @@ #pragma once =20 #include "virdomainobjlist.h" +#include "virhostdev.h" #include "virthread.h" #include "ch_capabilities.h" #include "virebtables.h" @@ -80,6 +81,9 @@ struct _virCHDriver =20 /* Immutable pointer, lockless APIs. Pointless abstraction */ ebtablesContext *ebtables; + + /* Immutable pointer to host device manager */ + virHostdevManager *hostdevMgr; }; =20 #define CH_SAVE_MAGIC "libvirt-xml\n \0 \r" diff --git a/src/ch/ch_driver.c b/src/ch/ch_driver.c index dab025edc1..17ae488a02 100644 --- a/src/ch/ch_driver.c +++ b/src/ch/ch_driver.c @@ -1365,6 +1365,7 @@ static int chStateCleanup(void) virObjectUnref(ch_driver->xmlopt); virObjectUnref(ch_driver->caps); virObjectUnref(ch_driver->domains); + virObjectUnref(ch_driver->hostdevMgr); virMutexDestroy(&ch_driver->lock); g_clear_pointer(&ch_driver, g_free); =20 @@ -1414,6 +1415,9 @@ chStateInitialize(bool privileged, if (!(ch_driver->config =3D virCHDriverConfigNew(privileged))) goto cleanup; =20 + if (!(ch_driver->hostdevMgr =3D virHostdevManagerGetDefault())) + goto cleanup; + if ((rv =3D chExtractVersion(ch_driver)) < 0) { if (rv =3D=3D -2) ret =3D VIR_DRV_STATE_INIT_SKIPPED; --=20 2.44.0 From nobody Sun Feb 8 14:36:51 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.libvirt.org designates 8.43.85.245 as permitted sender) client-ip=8.43.85.245; envelope-from=devel-bounces@lists.libvirt.org; helo=lists.libvirt.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of lists.libvirt.org designates 8.43.85.245 as permitted sender) smtp.mailfrom=devel-bounces@lists.libvirt.org; dmarc=fail(p=none dis=none) header.from=gmail.com Return-Path: Received: from lists.libvirt.org (lists.libvirt.org [8.43.85.245]) by mx.zohomail.com with SMTPS id 1728670544710174.02784452290268; Fri, 11 Oct 2024 11:15:44 -0700 (PDT) Received: by lists.libvirt.org (Postfix, from userid 996) id 9F89C17B4; Fri, 11 Oct 2024 14:15:43 -0400 (EDT) Received: from lists.libvirt.org (localhost [IPv6:::1]) by lists.libvirt.org (Postfix) with ESMTP id 5E0D617B3; Fri, 11 Oct 2024 14:13:32 -0400 (EDT) Received: by lists.libvirt.org (Postfix, from userid 996) id 3E3C4176E; Fri, 11 Oct 2024 14:13:28 -0400 (EDT) Received: from mail-oa1-f42.google.com (mail-oa1-f42.google.com [209.85.160.42]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by lists.libvirt.org (Postfix) with ESMTPS id 597061767 for ; Fri, 11 Oct 2024 14:13:20 -0400 (EDT) Received: by mail-oa1-f42.google.com with SMTP id 586e51a60fabf-2888165800fso295320fac.3 for ; Fri, 11 Oct 2024 11:13:20 -0700 (PDT) Received: from home.. ([2603:8081:c640:1::1003]) by smtp.gmail.com with ESMTPSA id 586e51a60fabf-2885844a8b7sm1047097fac.58.2024.10.11.11.13.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 11 Oct 2024 11:13:18 -0700 (PDT) X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on lists.libvirt.org X-Spam-Level: X-Spam-Status: No, score=-0.5 required=5.0 tests=DKIM_ADSP_CUSTOM_MED, DKIM_INVALID,DKIM_SIGNED,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,RCVD_IN_VALIDITY_RPBL_BLOCKED, RCVD_IN_VALIDITY_SAFE_BLOCKED,SPF_HELO_NONE autolearn=unavailable autolearn_force=no version=3.4.4 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1728670399; x=1729275199; darn=lists.libvirt.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=zXK3cs1IB1JpklDaVQdrJyY5bzMaxMHSlEe0XE+um3U=; b=G6NFVwQlap3cBf+ZEbNrzTpTxjvGRNaUc5RDQjd5EZwQjgmwhBvKuG3CqHjksrTotk Au1e3bZahh6rawJW4ugeevrjUJZw95k+zMZ+XimkN9FLHunCZUdtI6GrSIik8tBVfAZS 0zmTGgY5Gdo3Xz5Fqlq+dkUss0gTnFXS/s7pUvEw2FVxnfhjuBjrqfUonBcFBCTNtES4 1Zn1+E0nevd4sZxJ7IP0uVILyh8x8DFKNJpMbsbZIQjrlMH9aOTHG3JHC4ak8YYktyvm hJdAet4/u6vNGUgVyz2YwK20WkgA0HXxbF5VRuEU3HaDeg3EUSRHDqQo9pRv7zG2Hs5s 6d+w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1728670399; x=1729275199; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=zXK3cs1IB1JpklDaVQdrJyY5bzMaxMHSlEe0XE+um3U=; b=VCKfV0mExfTTvjzsAL3aBUZyvjvm+eFlpEtl/BEjq2+K9zHxUYDQnFPV7nRwl0Z5ZY iEnnDngX2EuU5AvyxRLUGpSkoIYX4nl/oHdfOKxvOkcgcgcz7KTo7KbmlNBpD3j/DQD7 Hazi8uIRWXuD+9IgBbvGIQflBXnB8zc0HMpyJk5tv782XVpz+t7aREslLsdNjcw19plM GXk8AMqMrs0iJHT2KUrO4F6KD3PwmWuylKqQHmZk4xVLkPEOlO4pT8poFMO5JbdAPJGh GvNbE3Af+rSOAFq54n0BFndkOMnnhHgw9lh7Ofvn2NXxMJutWMHgLN+/+Mm+nzcf7vpl sijg== X-Gm-Message-State: AOJu0Yww4043WBBU3S+kBDErvOfm0hh3qIlAHse0gtmaoUMJwA4WDS/d 6yH05zFgDaEvbflVxoPN8oEt5ZNp3WkG344eh3P5vTksOw+wfsa8wAXRFw== X-Google-Smtp-Source: AGHT+IFlYouOSt2F+HOPVFyUzqgDnF4zRKB20NvBG7/yrsqYW3xlEy2v55FPByrCxYPqi/2dA0k9CA== X-Received: by 2002:a05:6870:b6a3:b0:288:6d23:5f24 with SMTP id 586e51a60fabf-2886df88827mr3522350fac.31.1728670398899; Fri, 11 Oct 2024 11:13:18 -0700 (PDT) From: Praveen K Paladugu X-Google-Original-From: Praveen K Paladugu To: devel@lists.libvirt.org Subject: [PATCH 05/10] ch: add scaffolding for host devices management Date: Fri, 11 Oct 2024 13:13:06 -0500 Message-ID: <20241011181311.6813-6-prapal@linux.microsoft.com> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20241011181311.6813-1-prapal@linux.microsoft.com> References: <20241011181311.6813-1-prapal@linux.microsoft.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Message-ID-Hash: HPDKDDSCSA7S5QLWBGMBLTIIHVKUS3LA X-Message-ID-Hash: HPDKDDSCSA7S5QLWBGMBLTIIHVKUS3LA X-MailFrom: praveenkpaladugu@gmail.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-config-1; header-match-config-2; header-match-config-3; header-match-devel.lists.libvirt.org-0; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; suspicious-header CC: liuwe@microsoft.com X-Mailman-Version: 3.2.2 Precedence: list List-Id: Development discussions about the libvirt library & tools Archived-At: List-Archive: List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1728670545983116600 Content-Type: text/plain; charset="utf-8" From: Wei Liu They are left empty for now. Make sure CH driver still builds. Content will be filled in later. Signed-off-by: Wei Liu Signed-off-by: Praveen K Paladugu Reviewed-by: Michal Privoznik --- src/ch/ch_hostdev.c | 28 ++++++++++++++++++++++++++++ src/ch/ch_hostdev.h | 24 ++++++++++++++++++++++++ src/ch/meson.build | 2 ++ 3 files changed, 54 insertions(+) create mode 100644 src/ch/ch_hostdev.c create mode 100644 src/ch/ch_hostdev.h diff --git a/src/ch/ch_hostdev.c b/src/ch/ch_hostdev.c new file mode 100644 index 0000000000..20ce6efa10 --- /dev/null +++ b/src/ch/ch_hostdev.c @@ -0,0 +1,28 @@ +/* + * ch_hostdev.c: Cloud Hypervisor hostdev management + * + * Copyright (C) 2021 Wei Liu + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library. If not, see + * . + */ + +#include + +#include "ch_hostdev.h" +#include "virlog.h" + +#define VIR_FROM_THIS VIR_FROM_CH + +VIR_LOG_INIT("ch.ch_hostdev"); diff --git a/src/ch/ch_hostdev.h b/src/ch/ch_hostdev.h new file mode 100644 index 0000000000..02b7f9c2d8 --- /dev/null +++ b/src/ch/ch_hostdev.h @@ -0,0 +1,24 @@ +/* + * ch_hostdev.h: Cloud Hypervisor hostdev management + * + * Copyright (C) 2021 Wei Liu + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library. If not, see + * . + */ + +#pragma once + +#include "ch_conf.h" +#include "domain_conf.h" diff --git a/src/ch/meson.build b/src/ch/meson.build index 633966aac7..ca1291c158 100644 --- a/src/ch/meson.build +++ b/src/ch/meson.build @@ -13,6 +13,8 @@ ch_driver_sources =3D [ 'ch_monitor.h', 'ch_process.c', 'ch_process.h', + 'ch_hostdev.c', + 'ch_hostdev.h', ] =20 driver_source_files +=3D files(ch_driver_sources) --=20 2.44.0 From nobody Sun Feb 8 14:36:51 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.libvirt.org designates 8.43.85.245 as permitted sender) client-ip=8.43.85.245; envelope-from=devel-bounces@lists.libvirt.org; helo=lists.libvirt.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of lists.libvirt.org designates 8.43.85.245 as permitted sender) smtp.mailfrom=devel-bounces@lists.libvirt.org; dmarc=fail(p=none dis=none) header.from=gmail.com Return-Path: Received: from lists.libvirt.org (lists.libvirt.org [8.43.85.245]) by mx.zohomail.com with SMTPS id 1728670570215929.3504414125433; Fri, 11 Oct 2024 11:16:10 -0700 (PDT) Received: by lists.libvirt.org (Postfix, from userid 996) id 1027C178B; Fri, 11 Oct 2024 14:16:09 -0400 (EDT) Received: from lists.libvirt.org (localhost [IPv6:::1]) by lists.libvirt.org (Postfix) with ESMTP id 2D21C1775; Fri, 11 Oct 2024 14:13:39 -0400 (EDT) Received: by lists.libvirt.org (Postfix, from userid 996) id 1BA8217E9; Fri, 11 Oct 2024 14:13:35 -0400 (EDT) Received: from mail-ot1-f49.google.com (mail-ot1-f49.google.com [209.85.210.49]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by lists.libvirt.org (Postfix) with ESMTPS id 58418179F for ; Fri, 11 Oct 2024 14:13:21 -0400 (EDT) Received: by mail-ot1-f49.google.com with SMTP id 46e09a7af769-717bde361f6so1178452a34.3 for ; Fri, 11 Oct 2024 11:13:21 -0700 (PDT) Received: from home.. ([2603:8081:c640:1::1003]) by smtp.gmail.com with ESMTPSA id 586e51a60fabf-2885844a8b7sm1047097fac.58.2024.10.11.11.13.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 11 Oct 2024 11:13:19 -0700 (PDT) X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on lists.libvirt.org X-Spam-Level: X-Spam-Status: No, score=-0.5 required=5.0 tests=DKIM_ADSP_CUSTOM_MED, DKIM_INVALID,DKIM_SIGNED,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,RCVD_IN_VALIDITY_RPBL_BLOCKED, RCVD_IN_VALIDITY_SAFE_BLOCKED,SPF_HELO_NONE autolearn=unavailable autolearn_force=no version=3.4.4 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1728670400; x=1729275200; darn=lists.libvirt.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=whFVN9s+B1rPInD57D0hYLpQbW0IyJhtJuDQvrDNYmY=; b=SZDFzfnz8pRq/y7bNK1X8Ha8ccRYZeo4VOa2TSw4QF/KwnPVNO3KranfJM9Ti4ycNU UGOoySAsZszL4NFIeqq/rNXytKL2/333J/WwbgIDgASaLmCUuLRev8gn2hdCbFQ7N9Iq 1coSfblRXYo7iVykGoojSZHDTfc4X0TIYogVK2Yhqb6cERW7btMWz5aDrypZMAQ1O0i6 mADcfnQ73zm4op1fITBqJtA33TI8g3K78S470YA581Rd2PFf5RFMhl46Zu0yykXJbQgR mTgYiHNj0U3+/fNXkW+aAp9yUZLzcBDonr7LktY5cZyqDjtvvJ7ZsSmBG4FC8rRec0ac WUCw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1728670400; x=1729275200; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=whFVN9s+B1rPInD57D0hYLpQbW0IyJhtJuDQvrDNYmY=; b=iRUsDC8bA/5jDkAIBHrGipeIfsW768gFLxaLHLoM8M46j0//YZiuQKfN2uyxAW7DXG QNhTu/JiQaZOQ2HoKYhPCm1gtwuP59OLCN2zRdA/4XRBUJR3Fyp8Tx0xT+QbHNFtWbjO TYXSA2AleFpG3nNsbQI4WVPAuVf1cvw1+mRCy/Lf/J+to4DsRuvPADlTb/vfaNqh/KA9 uPNDWf5FJbi4U30igfU70w8RfghVgyXUKDt8a/4qk1NUyDNVNGUX71pMOiycW404aMOV FzA34jCkUHXzlaSu/ecAY+W6lSTfsm6gE0koQU7lNTzTU/w0RnarVlXbn2fLrqsroV4u nhzA== X-Gm-Message-State: AOJu0YyPGD4qrsL0eLE6WXut/osN3leCJUJUxF3RjAdZMQDb3cL/uLNR nljTLkXtpg5M6T8RwWOx8qC7M04ppiVSbVb7Yev1EwlN2nW5eTT1NwEnXw== X-Google-Smtp-Source: AGHT+IFkM0eqOi2dFTxBn/p19XOVOy4ZqExlI60Yv1J9bd9UBqiJXl7uWE26sEab28VDxm1NVduBMQ== X-Received: by 2002:a05:6870:f784:b0:254:b337:eebc with SMTP id 586e51a60fabf-288874792c0mr375214fac.35.1728670400222; Fri, 11 Oct 2024 11:13:20 -0700 (PDT) From: Praveen K Paladugu X-Google-Original-From: Praveen K Paladugu To: devel@lists.libvirt.org Subject: [PATCH 06/10] ch: prepare domain definition for pci passthrough Date: Fri, 11 Oct 2024 13:13:07 -0500 Message-ID: <20241011181311.6813-7-prapal@linux.microsoft.com> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20241011181311.6813-1-prapal@linux.microsoft.com> References: <20241011181311.6813-1-prapal@linux.microsoft.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Message-ID-Hash: LUFHI6MF2P6CKC2QQYVRULJ2UHNTENPP X-Message-ID-Hash: LUFHI6MF2P6CKC2QQYVRULJ2UHNTENPP X-MailFrom: praveenkpaladugu@gmail.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-config-1; header-match-config-2; header-match-config-3; header-match-devel.lists.libvirt.org-0; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; suspicious-header CC: liuwe@microsoft.com X-Mailman-Version: 3.2.2 Precedence: list List-Id: Development discussions about the libvirt library & tools Archived-At: List-Archive: List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1728670572152116600 Content-Type: text/plain; charset="utf-8" Check if the domain definition is valid for PCI passthrough and update it if necessary. Signed-off-by: Praveen K Paladugu Reviewed-by: Michal Privoznik --- po/POTFILES | 1 + src/ch/ch_hostdev.c | 67 +++++++++++++++++++++++++++++++++++++++++++++ src/ch/ch_hostdev.h | 3 ++ src/ch/ch_process.c | 39 ++++++++++++++++++++++++++ 4 files changed, 110 insertions(+) diff --git a/po/POTFILES b/po/POTFILES index 1ed4086d2c..66465b798f 100644 --- a/po/POTFILES +++ b/po/POTFILES @@ -21,6 +21,7 @@ src/bhyve/bhyve_process.c src/ch/ch_conf.c src/ch/ch_domain.c src/ch/ch_driver.c +src/ch/ch_hostdev.c src/ch/ch_interface.c src/ch/ch_monitor.c src/ch/ch_process.c diff --git a/src/ch/ch_hostdev.c b/src/ch/ch_hostdev.c index 20ce6efa10..1e6210e162 100644 --- a/src/ch/ch_hostdev.c +++ b/src/ch/ch_hostdev.c @@ -26,3 +26,70 @@ #define VIR_FROM_THIS VIR_FROM_CH =20 VIR_LOG_INIT("ch.ch_hostdev"); + +static int +virCHDomainPrepareHostdevPCI(virDomainHostdevDef *hostdev) +{ + bool supportsPassthroughVFIO =3D virHostdevHostSupportsPassthroughVFIO= (); + virDeviceHostdevPCIDriverName *driverName =3D + &hostdev->source.subsys.u.pci.driver.n= ame; + + /* assign defaults for hostdev passthrough */ + switch (*driverName) { + case VIR_DEVICE_HOSTDEV_PCI_DRIVER_NAME_DEFAULT: + if (supportsPassthroughVFIO) { + *driverName =3D VIR_DEVICE_HOSTDEV_PCI_DRIVER_NAME_VFIO; + } else { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("host doesn't support passthrough of host PCI= devices")); + return -1; + } + break; + + case VIR_DEVICE_HOSTDEV_PCI_DRIVER_NAME_VFIO: + if (!supportsPassthroughVFIO) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("host doesn't support VFIO PCI passthrough")); + return false; + } + break; + + case VIR_DEVICE_HOSTDEV_PCI_DRIVER_NAME_KVM: + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("host doesn't support legacy PCI passthrough")); + return false; + + case VIR_DEVICE_HOSTDEV_PCI_DRIVER_NAME_XEN: + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("CH does not support device assignment mode '%1$s= '"), + virDeviceHostdevPCIDriverNameTypeToString(*driverNa= me)); + return false; + + default: + case VIR_DEVICE_HOSTDEV_PCI_DRIVER_NAME_LAST: + virReportEnumRangeError(virDeviceHostdevPCIDriverName, *driverName= ); + break; + } + + return true; +} + +int +virCHDomainPrepareHostdev(virDomainHostdevDef *hostdev) +{ + if (hostdev->mode !=3D VIR_DOMAIN_HOSTDEV_MODE_SUBSYS) + return 0; + + switch (hostdev->source.subsys.type) { + case VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_PCI: + return virCHDomainPrepareHostdevPCI(hostdev); + case VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_SCSI: + case VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_USB: + case VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_SCSI_HOST: + case VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_MDEV: + case VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_LAST: + break; + } + + return 0; +} diff --git a/src/ch/ch_hostdev.h b/src/ch/ch_hostdev.h index 02b7f9c2d8..f9ba40ab71 100644 --- a/src/ch/ch_hostdev.h +++ b/src/ch/ch_hostdev.h @@ -22,3 +22,6 @@ =20 #include "ch_conf.h" #include "domain_conf.h" + +int +virCHDomainPrepareHostdev(virDomainHostdevDef *hostdev); diff --git a/src/ch/ch_process.c b/src/ch/ch_process.c index 9816509e49..c5b5b6ebb2 100644 --- a/src/ch/ch_process.c +++ b/src/ch/ch_process.c @@ -37,6 +37,7 @@ #include "virnuma.h" #include "virstring.h" #include "ch_interface.h" +#include "ch_hostdev.h" =20 #define VIR_FROM_THIS VIR_FROM_CH =20 @@ -808,6 +809,40 @@ virCHProcessStartValidate(virCHDriver *driver, return 0; } =20 +static int +virCHProcessPrepareDomainHostdevs(virDomainObj *vm) +{ + size_t i; + + for (i =3D 0; i < vm->def->nhostdevs; i++) { + virDomainHostdevDef *hostdev =3D vm->def->hostdevs[i]; + + if (virCHDomainPrepareHostdev(hostdev) < 0) + return -1; + } + + return 0; +} + +/** + * virCHProcessPrepareDomain: + * @vm: domain object + * + * This function groups all code that modifies only live XML of a domain w= hich + * is about to start and it's the only place to do those modifications. + * + * This function MUST be called before virCHProcessPrepareHost(). + * + */ +static int +virCHProcessPrepareDomain(virDomainObj *vm) +{ + if (virCHProcessPrepareDomainHostdevs(vm) < 0) + return -1; + + return 0; +} + /** * virCHProcessStart: * @driver: pointer to driver structure @@ -839,6 +874,10 @@ virCHProcessStart(virCHDriver *driver, return -1; } =20 + if (virCHProcessPrepareDomain(vm) < 0) { + return -1; + } + if (!priv->monitor) { /* And we can get the first monitor connection now too */ if (!(priv->monitor =3D virCHProcessConnectMonitor(driver, vm))) { --=20 2.44.0 From nobody Sun Feb 8 14:36:51 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.libvirt.org designates 8.43.85.245 as permitted sender) client-ip=8.43.85.245; envelope-from=devel-bounces@lists.libvirt.org; helo=lists.libvirt.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of lists.libvirt.org designates 8.43.85.245 as permitted sender) smtp.mailfrom=devel-bounces@lists.libvirt.org; dmarc=fail(p=none dis=none) header.from=gmail.com Return-Path: Received: from lists.libvirt.org (lists.libvirt.org [8.43.85.245]) by mx.zohomail.com with SMTPS id 1728670591428625.8274203150621; Fri, 11 Oct 2024 11:16:31 -0700 (PDT) Received: by lists.libvirt.org (Postfix, from userid 996) id 49E9D17ED; Fri, 11 Oct 2024 14:16:30 -0400 (EDT) Received: from lists.libvirt.org (localhost [IPv6:::1]) by lists.libvirt.org (Postfix) with ESMTP id 3D7BB17DC; Fri, 11 Oct 2024 14:13:41 -0400 (EDT) Received: by lists.libvirt.org (Postfix, from userid 996) id 603C4172D; Fri, 11 Oct 2024 14:13:35 -0400 (EDT) Received: from mail-oa1-f42.google.com (mail-oa1-f42.google.com [209.85.160.42]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by lists.libvirt.org (Postfix) with ESMTPS id 91D50161B for ; Fri, 11 Oct 2024 14:13:22 -0400 (EDT) Received: by mail-oa1-f42.google.com with SMTP id 586e51a60fabf-27b7a1480bdso931030fac.2 for ; Fri, 11 Oct 2024 11:13:22 -0700 (PDT) Received: from home.. ([2603:8081:c640:1::1003]) by smtp.gmail.com with ESMTPSA id 586e51a60fabf-2885844a8b7sm1047097fac.58.2024.10.11.11.13.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 11 Oct 2024 11:13:20 -0700 (PDT) X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on lists.libvirt.org X-Spam-Level: X-Spam-Status: No, score=-0.5 required=5.0 tests=DKIM_ADSP_CUSTOM_MED, DKIM_INVALID,DKIM_SIGNED,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,RCVD_IN_VALIDITY_RPBL_BLOCKED, RCVD_IN_VALIDITY_SAFE_BLOCKED,SPF_HELO_NONE autolearn=unavailable autolearn_force=no version=3.4.4 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1728670401; x=1729275201; darn=lists.libvirt.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=R/cmH8iZyppHxN0UuBH2T3B4VSnxBfDcLImcEwhxPlQ=; b=Rd1vwtXsni2PF+rvBrsAI5XXEjDK1THkhDncdDj8PTaG0z6TvJWgNFeoyBCwtLkkQQ gqHvUHnCU2UZ8mJPPfPD3eHVHnsvXe+AiXlkoBTAg58DJuuXChE7NSkVb23eYqnaS4ev 6E07LvGeT6LAHlS1QhkM1Ppr+Fl2O+7qxWlE30Xxa09EPzzJe8sHFC1JxsFFJ6+gPYXc zvSSF+fGuI51a2VxCxfGNk2R8GEP86oUnc8z5Yk/v65XtU9Em+zXHlJ5SdOHN1MVqZ9r h3ASML/vpSWnXhIcQgN0o40Xv5Ipuv5L0hUheokw4J1CrbxnPB1rrLtYwdw3MoEqG109 MkHg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1728670401; x=1729275201; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=R/cmH8iZyppHxN0UuBH2T3B4VSnxBfDcLImcEwhxPlQ=; b=UGgFKLFuSeK4VfAl6ci0FtTcKdgeruI3uMkmZkarpzBbr4tDsOZYC02O0H9v/dJSOe B5vT/KZ/ealovDLMFpWk5wSg8itfq0BeX1VdMpMXXdQeUojXKGXmbn5ZVRT1Qp9SKgHx I/LcYzLCVFLaIGkKRXzX3Pz/vFALYzTgOhifCOZy2jMIlZ0ZADQRfnzdYdVPhNhHt9/w ZiEKiKZ2jWmLwzCEPCIpmsS7cXTXo+2SO04nO1jvK6hmWwtIYXjeBfSgzB4HEc9iF6Wp Kx4c1xjxLUqG7PrXBdg+nNsk8Syx5gJspexXZYZ8V/DSTVijtTIVJzxnSjZLouLtaOGv uMIQ== X-Gm-Message-State: AOJu0Yxmdvxmtv0maVbiszDeIuT7oEUW2TZ4KS/KLG8B4c7edA0jYJ8c Mq2weFtMQqgFNXm1sdQtFElrxtVR7StdCSUsZdDgDubOC9ht89E3WRANIA== X-Google-Smtp-Source: AGHT+IE6z/ED9f5DxtoI+8B6qjy5/nzyk0HFkx91ZFp+P1UcLQl52wm0XCZTldBm5MZxWC3m/r2yWg== X-Received: by 2002:a05:6870:ab09:b0:260:fbc0:96f2 with SMTP id 586e51a60fabf-2886df73aadmr3423568fac.34.1728670401458; Fri, 11 Oct 2024 11:13:21 -0700 (PDT) From: Praveen K Paladugu X-Google-Original-From: Praveen K Paladugu To: devel@lists.libvirt.org Subject: [PATCH 07/10] ch: prepare host for PCI passthrough Date: Fri, 11 Oct 2024 13:13:08 -0500 Message-ID: <20241011181311.6813-8-prapal@linux.microsoft.com> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20241011181311.6813-1-prapal@linux.microsoft.com> References: <20241011181311.6813-1-prapal@linux.microsoft.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Message-ID-Hash: GSAJZYKFR2IBCIYB7SCDWIZYTWZT4A3P X-Message-ID-Hash: GSAJZYKFR2IBCIYB7SCDWIZYTWZT4A3P X-MailFrom: praveenkpaladugu@gmail.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-config-1; header-match-config-2; header-match-config-3; header-match-devel.lists.libvirt.org-0; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; suspicious-header CC: liuwe@microsoft.com X-Mailman-Version: 3.2.2 Precedence: list List-Id: Development discussions about the libvirt library & tools Archived-At: List-Archive: List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1728670592206116600 Content-Type: text/plain; charset="utf-8" From: Wei Liu Prepare host to passthrough PCI devices for ch guests. Co-authored-by: Wei Liu Signed-off-by: Praveen K Paladugu Reviewed-by: Michal Privoznik --- src/ch/ch_hostdev.c | 20 ++++++++++++++++++++ src/ch/ch_hostdev.h | 5 +++++ src/ch/ch_process.c | 30 ++++++++++++++++++++++++++++++ 3 files changed, 55 insertions(+) diff --git a/src/ch/ch_hostdev.c b/src/ch/ch_hostdev.c index 1e6210e162..a2ef56e098 100644 --- a/src/ch/ch_hostdev.c +++ b/src/ch/ch_hostdev.c @@ -22,11 +22,31 @@ =20 #include "ch_hostdev.h" #include "virlog.h" +#include "virerror.h" +#include "virhostdev.h" =20 #define VIR_FROM_THIS VIR_FROM_CH =20 VIR_LOG_INIT("ch.ch_hostdev"); =20 +int +virCHHostdevPrepareDomainDevices(virCHDriver *driver, + virDomainDef *def, + unsigned int flags) + +{ + if (!def->nhostdevs) + return 0; + + if (virHostdevPreparePCIDevices(driver->hostdevMgr, CH_DRIVER_NAME, + def->name, def->uuid, + def->hostdevs, def->nhostdevs, + flags) < 0) + return -1; + + return 0; +} + static int virCHDomainPrepareHostdevPCI(virDomainHostdevDef *hostdev) { diff --git a/src/ch/ch_hostdev.h b/src/ch/ch_hostdev.h index f9ba40ab71..f949ecbe87 100644 --- a/src/ch/ch_hostdev.h +++ b/src/ch/ch_hostdev.h @@ -25,3 +25,8 @@ =20 int virCHDomainPrepareHostdev(virDomainHostdevDef *hostdev); + +int +virCHHostdevPrepareDomainDevices(virCHDriver *driver, + virDomainDef *def, + unsigned int flags); diff --git a/src/ch/ch_process.c b/src/ch/ch_process.c index c5b5b6ebb2..ed0fa1fedb 100644 --- a/src/ch/ch_process.c +++ b/src/ch/ch_process.c @@ -824,6 +824,33 @@ virCHProcessPrepareDomainHostdevs(virDomainObj *vm) return 0; } =20 +/** + * virCHProcessPrepareHost: + * @driver: ch driver + * @vm: domain object + * + * This function groups all code that modifies host system to prepare + * environment for a domain which is about to start. + * + * This function MUST be called only after virCHProcessPrepareDomain(). + */ +static int +virCHProcessPrepareHost(virCHDriver *driver, virDomainObj *vm) +{ + unsigned int hostdev_flags =3D 0; + virCHDomainObjPrivate *priv =3D vm->privateData; + g_autoptr(virCHDriverConfig) cfg =3D virCHDriverGetConfig(driver); + + if (virCHHostdevPrepareDomainDevices(driver, vm->def, hostdev_flags) <= 0) + return -1; + + /* Ensure no historical cgroup for this VM is lying around */ + VIR_DEBUG("Ensuring no historical cgroup is lying around"); + virDomainCgroupRemoveCgroup(vm, priv->cgroup, priv->machineName); + + return 0; +} + /** * virCHProcessPrepareDomain: * @vm: domain object @@ -878,6 +905,9 @@ virCHProcessStart(virCHDriver *driver, return -1; } =20 + if (virCHProcessPrepareHost(driver, vm) < 0) + return -1; + if (!priv->monitor) { /* And we can get the first monitor connection now too */ if (!(priv->monitor =3D virCHProcessConnectMonitor(driver, vm))) { --=20 2.44.0 From nobody Sun Feb 8 14:36:51 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.libvirt.org designates 8.43.85.245 as permitted sender) client-ip=8.43.85.245; envelope-from=devel-bounces@lists.libvirt.org; helo=lists.libvirt.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of lists.libvirt.org designates 8.43.85.245 as permitted sender) smtp.mailfrom=devel-bounces@lists.libvirt.org; dmarc=fail(p=none dis=none) header.from=gmail.com Return-Path: Received: from lists.libvirt.org (lists.libvirt.org [8.43.85.245]) by mx.zohomail.com with SMTPS id 1728670608520150.94067734597172; Fri, 11 Oct 2024 11:16:48 -0700 (PDT) Received: by lists.libvirt.org (Postfix, from userid 996) id 6844D181C; Fri, 11 Oct 2024 14:16:47 -0400 (EDT) Received: from lists.libvirt.org (localhost [IPv6:::1]) by lists.libvirt.org (Postfix) with ESMTP id A9A8A168D; Fri, 11 Oct 2024 14:13:43 -0400 (EDT) Received: by lists.libvirt.org (Postfix, from userid 996) id C74D8171F; Fri, 11 Oct 2024 14:13:35 -0400 (EDT) Received: from mail-oa1-f46.google.com (mail-oa1-f46.google.com [209.85.160.46]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by lists.libvirt.org (Postfix) with ESMTPS id EFC9B17C1 for ; Fri, 11 Oct 2024 14:13:23 -0400 (EDT) Received: by mail-oa1-f46.google.com with SMTP id 586e51a60fabf-2887abeefbdso305228fac.0 for ; Fri, 11 Oct 2024 11:13:23 -0700 (PDT) Received: from home.. ([2603:8081:c640:1::1003]) by smtp.gmail.com with ESMTPSA id 586e51a60fabf-2885844a8b7sm1047097fac.58.2024.10.11.11.13.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 11 Oct 2024 11:13:22 -0700 (PDT) X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on lists.libvirt.org X-Spam-Level: X-Spam-Status: No, score=-0.5 required=5.0 tests=DKIM_ADSP_CUSTOM_MED, DKIM_INVALID,DKIM_SIGNED,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,RCVD_IN_VALIDITY_RPBL_BLOCKED, RCVD_IN_VALIDITY_SAFE_BLOCKED,SPF_HELO_NONE autolearn=unavailable autolearn_force=no version=3.4.4 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1728670403; x=1729275203; darn=lists.libvirt.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=uDLgukDhyZj1IUG7kVv8lBSpYLWFjS763RVgc81rjsw=; b=J6SjgvbirgdsxFQx9+oYHwNkd+NGVxBFK0vVr+yo1C0T5jilUXf7zi+Kg9HH/b+2zM 4+V5geoQriPeZuv1Do3frjQF0PMRcvbVGMiRkhdWsM+9cCcV1xyzwgHFPpqhuoDjd1ck Z0K9Hnq16hmaeeccaNSXKo2SIJWX69IuABULodelB4VBiclhcnK7IEERfv9QYFMDKVWQ 5BCqfLSHnMB78VakYtBVd6pPsYuIeDNi3dsmt+eL54js00b8JygCouoQXGiiOQWCAUua XGpuw7Fl3QToxixl/8nFFFuf+O6ejaXnx+Mv3oqFUmMeKZpLvS/lxJv8i5rhqE+xOybx 1oEA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1728670403; x=1729275203; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=uDLgukDhyZj1IUG7kVv8lBSpYLWFjS763RVgc81rjsw=; b=bzZVdLnHrKTUflyuAT5fi4U3FGSYFPFBWd2VVCwNnz90agI97sV7RoUoai1imyEcNl 3UljyBqpHNM1ZvJpagEByO5oEp8X7XUse+845ER/+klZD5mN2yMs7Vzp0BYz/0gm054Y jEfHb9695j/4cqypuWXvyP7ZGnpUP3oeuQWkWzUHDz69+1htcwWYTJGooJcO85PLVQnx XnzgzGGGvX/+g9CWu2M4KjwUz4BGo538+fnIOshGpR4GqyW432TXBCiZhaGiqOoEni97 z+9LsdCS4xX/2iv7+/TFMwZpC1r8ZcmuyW6i6hs5fxVyH0AmXZaS63HxjZp8reZJnWyD h6RQ== X-Gm-Message-State: AOJu0YzGiIv1dmSw7UT5mKYFvpYQ8DuE2TGixt7AfRROofgr9zmgnknl ytdHvPFg1TFvaNxI6aHoaUx9sxWvsIPO5pzc7JTjm1JFIlZE9kYyPtLpnw== X-Google-Smtp-Source: AGHT+IHI7E/o8p3cf3871AmB2TMKBWqtz8KvD8ACfekITOxFaJ0xmk4LOBqDgYZIfb5HU3sV9UNsEw== X-Received: by 2002:a05:6871:442:b0:287:31fe:de95 with SMTP id 586e51a60fabf-2886de4cbaemr2388096fac.28.1728670402856; Fri, 11 Oct 2024 11:13:22 -0700 (PDT) From: Praveen K Paladugu X-Google-Original-From: Praveen K Paladugu To: devel@lists.libvirt.org Subject: [PATCH 08/10] ch: allow hostdev in domain definitions Date: Fri, 11 Oct 2024 13:13:09 -0500 Message-ID: <20241011181311.6813-9-prapal@linux.microsoft.com> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20241011181311.6813-1-prapal@linux.microsoft.com> References: <20241011181311.6813-1-prapal@linux.microsoft.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Message-ID-Hash: 7XPU5SOXMIXC42FNYMTWKFEDVLTAB3A7 X-Message-ID-Hash: 7XPU5SOXMIXC42FNYMTWKFEDVLTAB3A7 X-MailFrom: praveenkpaladugu@gmail.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-config-1; header-match-config-2; header-match-config-3; header-match-devel.lists.libvirt.org-0; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; suspicious-header CC: liuwe@microsoft.com X-Mailman-Version: 3.2.2 Precedence: list List-Id: Development discussions about the libvirt library & tools Archived-At: List-Archive: List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1728670610420116600 Content-Type: text/plain; charset="utf-8" Allow hostdev configurations in ch guest definitions. Signed-off-by: Praveen K Paladugu Reviewed-by: Michal Privoznik --- src/ch/ch_domain.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ch/ch_domain.c b/src/ch/ch_domain.c index e1e14554a8..bfccabed49 100644 --- a/src/ch/ch_domain.c +++ b/src/ch/ch_domain.c @@ -158,6 +158,7 @@ chValidateDomainDeviceDef(const virDomainDeviceDef *dev, case VIR_DOMAIN_DEVICE_VSOCK: case VIR_DOMAIN_DEVICE_CONTROLLER: case VIR_DOMAIN_DEVICE_CHR: + case VIR_DOMAIN_DEVICE_HOSTDEV: break; =20 case VIR_DOMAIN_DEVICE_LEASE: @@ -165,7 +166,6 @@ chValidateDomainDeviceDef(const virDomainDeviceDef *dev, case VIR_DOMAIN_DEVICE_INPUT: case VIR_DOMAIN_DEVICE_SOUND: case VIR_DOMAIN_DEVICE_VIDEO: - case VIR_DOMAIN_DEVICE_HOSTDEV: case VIR_DOMAIN_DEVICE_WATCHDOG: case VIR_DOMAIN_DEVICE_GRAPHICS: case VIR_DOMAIN_DEVICE_HUB: --=20 2.44.0 From nobody Sun Feb 8 14:36:51 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.libvirt.org designates 8.43.85.245 as permitted sender) client-ip=8.43.85.245; envelope-from=devel-bounces@lists.libvirt.org; helo=lists.libvirt.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of lists.libvirt.org designates 8.43.85.245 as permitted sender) smtp.mailfrom=devel-bounces@lists.libvirt.org; dmarc=fail(p=none dis=none) header.from=gmail.com Return-Path: Received: from lists.libvirt.org (lists.libvirt.org [8.43.85.245]) by mx.zohomail.com with SMTPS id 1728670634225811.5378882685181; Fri, 11 Oct 2024 11:17:14 -0700 (PDT) Received: by lists.libvirt.org (Postfix, from userid 996) id 2634917C4; Fri, 11 Oct 2024 14:17:13 -0400 (EDT) Received: from lists.libvirt.org (localhost [IPv6:::1]) by lists.libvirt.org (Postfix) with ESMTP id D3F2C1805; Fri, 11 Oct 2024 14:13:44 -0400 (EDT) Received: by lists.libvirt.org (Postfix, from userid 996) id E348417CD; Fri, 11 Oct 2024 14:13:36 -0400 (EDT) Received: from mail-oi1-f182.google.com (mail-oi1-f182.google.com [209.85.167.182]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by lists.libvirt.org (Postfix) with ESMTPS id 0D4991729 for ; Fri, 11 Oct 2024 14:13:25 -0400 (EDT) Received: by mail-oi1-f182.google.com with SMTP id 5614622812f47-3e5ccec079eso350836b6e.3 for ; Fri, 11 Oct 2024 11:13:25 -0700 (PDT) Received: from home.. ([2603:8081:c640:1::1003]) by smtp.gmail.com with ESMTPSA id 586e51a60fabf-2885844a8b7sm1047097fac.58.2024.10.11.11.13.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 11 Oct 2024 11:13:23 -0700 (PDT) X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on lists.libvirt.org X-Spam-Level: X-Spam-Status: No, score=-0.5 required=5.0 tests=DKIM_ADSP_CUSTOM_MED, DKIM_INVALID,DKIM_SIGNED,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2,RCVD_IN_VALIDITY_RPBL_BLOCKED, RCVD_IN_VALIDITY_SAFE_BLOCKED,SPF_HELO_NONE autolearn=unavailable autolearn_force=no version=3.4.4 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1728670404; x=1729275204; darn=lists.libvirt.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=3xy/Hgblxh8KGaz3uPV8CQbkTtfdZ7M5SibfZ+Tmz6Y=; b=O3h2BorHdN6bOe//6cX0FPSOXUl1Gf8PbdrUmX1icpADQljMetQX1Uo86j+CCHO7KK WVDPdVGfPeKw1zLwaMsdoLST41gpz24QIC6ySJDpCI+UwkdnektLtXu2qlQ6ztDitCDi hfkAt84AuwQeQfE2xvbIHTWaocNAvxG8n1tZRVlMTOeRUjMShj7S64r6ojVLBJVaFvs1 q3a57K3wWpIHAJ44MrLtzbt3tioTnf+lfJ5Epk8BbPy10eOd+fVN02kQijygWq8URON6 fC3G4YAqXO3LXQzNxqxyrrvI6STxsYBQ443Ebp6qQGr/6Axbh80DhosmcdcaxQYLpd06 Fq9Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1728670404; x=1729275204; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=3xy/Hgblxh8KGaz3uPV8CQbkTtfdZ7M5SibfZ+Tmz6Y=; b=NpN7uG/hgaZ3rFvtvav/umUDOcBiyzcNko1AJuwycDYVn3/WmsQ/39imAcuYev3r7Z McZ1luPhcUt2QFPtLMul7n07Mbg8ygi6slLHReW4GcXlZ6GgC362de8Glpw5u58zQCPt PB94xgcY0m029e7UPS1S5xVcDJhHHFifaBdr6qJ900tuO/I3scQQzePFL1Z1H0rArB1S GuPzQKOLVu8xeyB/y0KPaJH7vAQcXVpDVESDu44UOoDpGEyZ28hnKCyx+dFRJhMMT6ix QYp38WvD+XxEFRiT7DLCFWZFweYTYm6Jdywx8vIboAuqFuqVUMkpZOauvStldcHD8HRt ai3Q== X-Gm-Message-State: AOJu0YyqNVZSsqpWcZcz5tZ1d6xC4A0XI82EWL4E85nikXiVdATaN2Js 0saAWVHktokRkOcCAnFh8BGYaI0Rg8M268zhMHaN+jd+97wfXlIQxODXqw== X-Google-Smtp-Source: AGHT+IFdb/rvZ/j1D3rIkkABeTdxZnq2F65caQYd/Ii0CTEwIhEYoz6uGKF0KtCe/WustycL+xbLVQ== X-Received: by 2002:a05:6870:d14e:b0:277:d16e:1425 with SMTP id 586e51a60fabf-2886ddbabe2mr2962002fac.20.1728670403810; Fri, 11 Oct 2024 11:13:23 -0700 (PDT) From: Praveen K Paladugu X-Google-Original-From: Praveen K Paladugu To: devel@lists.libvirt.org Subject: [PATCH 09/10] ch: reattach PCI devices to host while stopping guest Date: Fri, 11 Oct 2024 13:13:10 -0500 Message-ID: <20241011181311.6813-10-prapal@linux.microsoft.com> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20241011181311.6813-1-prapal@linux.microsoft.com> References: <20241011181311.6813-1-prapal@linux.microsoft.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Message-ID-Hash: XU2GXQAEAS34QHZ23NLMAT7BW2TURAJI X-Message-ID-Hash: XU2GXQAEAS34QHZ23NLMAT7BW2TURAJI X-MailFrom: praveenkpaladugu@gmail.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-config-1; header-match-config-2; header-match-config-3; header-match-devel.lists.libvirt.org-0; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; suspicious-header CC: liuwe@microsoft.com X-Mailman-Version: 3.2.2 Precedence: list List-Id: Development discussions about the libvirt library & tools Archived-At: List-Archive: List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1728670634496116600 Content-Type: text/plain; charset="utf-8" Reattach PCI devices to host, while stopping ch guest. Signed-off-by: Praveen K Paladugu Reviewed-by: Michal Privoznik --- src/ch/ch_process.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/ch/ch_process.c b/src/ch/ch_process.c index ed0fa1fedb..61e263b62b 100644 --- a/src/ch/ch_process.c +++ b/src/ch/ch_process.c @@ -971,12 +971,13 @@ virCHProcessStart(virCHDriver *driver, } =20 int -virCHProcessStop(virCHDriver *driver G_GNUC_UNUSED, +virCHProcessStop(virCHDriver *driver, virDomainObj *vm, virDomainShutoffReason reason) { int ret; int retries =3D 0; + unsigned int hostdev_flags =3D VIR_HOSTDEV_SP_PCI; virCHDomainObjPrivate *priv =3D vm->privateData; virCHDriverConfig *cfg =3D virCHDriverGetConfig(driver); virDomainDef *def =3D vm->def; @@ -1015,6 +1016,8 @@ virCHProcessStop(virCHDriver *driver G_GNUC_UNUSED, =20 virDomainObjSetState(vm, VIR_DOMAIN_SHUTOFF, reason); =20 + virHostdevReAttachDomainDevices(driver->hostdevMgr, CH_DRIVER_NAME, de= f, + hostdev_flags); return 0; } =20 --=20 2.44.0 From nobody Sun Feb 8 14:36:51 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.libvirt.org designates 8.43.85.245 as permitted sender) client-ip=8.43.85.245; envelope-from=devel-bounces@lists.libvirt.org; helo=lists.libvirt.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of lists.libvirt.org designates 8.43.85.245 as permitted sender) smtp.mailfrom=devel-bounces@lists.libvirt.org; dmarc=fail(p=none dis=none) header.from=gmail.com Return-Path: Received: from lists.libvirt.org (lists.libvirt.org [8.43.85.245]) by mx.zohomail.com with SMTPS id 1728670651937924.3245664513598; Fri, 11 Oct 2024 11:17:31 -0700 (PDT) Received: by lists.libvirt.org (Postfix, from userid 996) id DE4EB169E; Fri, 11 Oct 2024 14:17:30 -0400 (EDT) Received: from lists.libvirt.org (localhost [IPv6:::1]) by lists.libvirt.org (Postfix) with ESMTP id A375A180D; Fri, 11 Oct 2024 14:13:47 -0400 (EDT) Received: by lists.libvirt.org (Postfix, from userid 996) id 916B2170A; Fri, 11 Oct 2024 14:13:37 -0400 (EDT) Received: from mail-oi1-f179.google.com (mail-oi1-f179.google.com [209.85.167.179]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by lists.libvirt.org (Postfix) with ESMTPS id 3FAA817D5 for ; Fri, 11 Oct 2024 14:13:26 -0400 (EDT) Received: by mail-oi1-f179.google.com with SMTP id 5614622812f47-3e5c6dc6eb4so1017929b6e.0 for ; Fri, 11 Oct 2024 11:13:26 -0700 (PDT) Received: from home.. ([2603:8081:c640:1::1003]) by smtp.gmail.com with ESMTPSA id 586e51a60fabf-2885844a8b7sm1047097fac.58.2024.10.11.11.13.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 11 Oct 2024 11:13:24 -0700 (PDT) X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on lists.libvirt.org X-Spam-Level: X-Spam-Status: No, score=-0.5 required=5.0 tests=DKIM_ADSP_CUSTOM_MED, DKIM_INVALID,DKIM_SIGNED,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2,RCVD_IN_VALIDITY_RPBL_BLOCKED, RCVD_IN_VALIDITY_SAFE_BLOCKED,SPF_HELO_NONE autolearn=unavailable autolearn_force=no version=3.4.4 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1728670405; x=1729275205; darn=lists.libvirt.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=Q/KXeWeEa2SGcSZEZbAwvK4P65kvdli9eRp2ZPWiy/k=; b=Y63VESEML8uG+1zGYyLNZ1Y+mUUKlV/K9mqaTrvKUZbtGGwJs6zeUmUMM5PFtFgSiW occCe+l3dn27j7wPgYOrq8lyZYlJ25zgTX8M3Z3vBD2Dd22YtT5octfKG5rbZ6FWqaYq Il4pOlSFu/3isJXDsoV+9u9MCbQNBKs6XxKtvdddJhCkJJSvcDROvJZYITG4GU9YJBnx DRN4WCoQq8fqXceLoh0GoMoSX5oknZqwOuMioVbP8WLkdeUmfbof2H5ty6vTe8sDFKdv Lng43aYxi+NzAdqNrVWKvYxAj8mZ+cIs9eK/OPidprsKrSzxRn3gbkJD7sobbEVLZ8f3 KOhg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1728670405; x=1729275205; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Q/KXeWeEa2SGcSZEZbAwvK4P65kvdli9eRp2ZPWiy/k=; b=t8rvCh0qTk9cIuk0SlpOF8NshLj/tgcUhPN+WtGndg/GCjs6M51JXODxzq3qfRfaHl EPM/SHHvT+HAlI5P4WRCAWBysWQV2rWbKcdMyUiOy/pnJAwJY43fl8eNwElHQT5cuRzv JPui1DiNSzoeTaI4bELMDtsxte2Wmfz+JlTHGxtsz8ayTcJMvEV6FJQFLJ/Uplxp0cwu WEqytNBBJXFh5KMNBiDS7sbSeirh29LCLIixSlBs4NqRDdkoiIF84GT3YFePvzwHvi65 a21flBCBrHraCC6Btfde3BTPQ/B/YTDbV0Mc/gtGNJ8P4nZeFF1sDVHUaLJAEAxWQWaa SS+A== X-Gm-Message-State: AOJu0Yzc+3pESwEdGlG0863p6x/ILhCbjzVdHSmCly9GLjkRN9RlmRBH ONqXl/vqRWty6SXrwoVhglxdLMfgvAQ9ViE9FDumETrPYSIC9t7sQS1s1Q== X-Google-Smtp-Source: AGHT+IEwmu4QWbJkmWffp6H2g6hdRnx+Y/SMn5PXcXPiLb1eTSjCnCZzaGiEyDpl1KLdqybEvDBTUQ== X-Received: by 2002:a05:6870:418f:b0:270:2c3:f362 with SMTP id 586e51a60fabf-2886df67f30mr3390397fac.32.1728670405123; Fri, 11 Oct 2024 11:13:25 -0700 (PDT) From: Praveen K Paladugu X-Google-Original-From: Praveen K Paladugu To: devel@lists.libvirt.org Subject: [PATCH 10/10] ch: explicitly set INFILESIZE to 0 Date: Fri, 11 Oct 2024 13:13:11 -0500 Message-ID: <20241011181311.6813-11-prapal@linux.microsoft.com> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20241011181311.6813-1-prapal@linux.microsoft.com> References: <20241011181311.6813-1-prapal@linux.microsoft.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Message-ID-Hash: JFPPBS6VJ7XH4STXT72LC6TQLREPV464 X-Message-ID-Hash: JFPPBS6VJ7XH4STXT72LC6TQLREPV464 X-MailFrom: praveenkpaladugu@gmail.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-config-1; header-match-config-2; header-match-config-3; header-match-devel.lists.libvirt.org-0; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; suspicious-header CC: liuwe@microsoft.com X-Mailman-Version: 3.2.2 Precedence: list List-Id: Development discussions about the libvirt library & tools Archived-At: List-Archive: List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1728670652549116600 Content-Type: text/plain; charset="utf-8" While sending API requests that don't need any body, explicitly set CURLOPT_INFILESIZE to 0. Without this option, curl sends a chunked request with `Expect: 100-continu= e` header. The client, in this case curl, expects a response from the server, ch in this case, to respond within a timeout period. If guest definition has a PCI passthrough device configuration, cloud-hypervisor process cannot respond within above mentioned timeout. Even if cloud-hypervisor responds after the timeout, curl cannot read the response. Because of this, virsh request to create a guest, hangs. This only happens while using "mshv" hypervisor. By setting CURLOPT_INFILESIZE to O, curl drops the Expect header and sychronously waits for server to respond. Signed-off-by: Praveen K Paladugu Reviewed-by: Michal Privoznik --- src/ch/ch_monitor.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/ch/ch_monitor.c b/src/ch/ch_monitor.c index 3e49902791..e9b70abb69 100644 --- a/src/ch/ch_monitor.c +++ b/src/ch/ch_monitor.c @@ -684,6 +684,7 @@ virCHMonitorPutNoContent(virCHMonitor *mon, const char = *endpoint) curl_easy_setopt(mon->handle, CURLOPT_URL, url); curl_easy_setopt(mon->handle, CURLOPT_UPLOAD, 1L); curl_easy_setopt(mon->handle, CURLOPT_HTTPHEADER, NULL); + curl_easy_setopt(mon->handle, CURLOPT_INFILESIZE, 0L); =20 responseCode =3D virCHMonitorCurlPerform(mon->handle); =20 --=20 2.44.0