From nobody Sat Dec 21 12:34:43 2024 Delivered-To: importer@patchew.org Received-SPF: none (zohomail.com: 8.43.85.245 is neither permitted nor denied by domain of lists.libvirt.org) client-ip=8.43.85.245; envelope-from=devel-bounces@lists.libvirt.org; helo=lists.libvirt.org; Authentication-Results: mx.zohomail.com; spf=none (zohomail.com: 8.43.85.245 is neither permitted nor denied by domain of lists.libvirt.org) smtp.mailfrom=devel-bounces@lists.libvirt.org; dmarc=fail(p=none dis=none) header.from=linux.microsoft.com Return-Path: Received: from lists.libvirt.org (lists.libvirt.org [8.43.85.245]) by mx.zohomail.com with SMTPS id 1706647590376142.05484668051406; Tue, 30 Jan 2024 12:46:30 -0800 (PST) Received: by lists.libvirt.org (Postfix, from userid 996) id 498FF1CF4; Tue, 30 Jan 2024 15:46:28 -0500 (EST) Received: from lists.libvirt.org.85.43.8.in-addr.arpa (localhost [IPv6:::1]) by lists.libvirt.org (Postfix) with ESMTP id 086371C6D; Tue, 30 Jan 2024 15:44:58 -0500 (EST) Received: by lists.libvirt.org (Postfix, from userid 996) id D3C541C6B; Tue, 30 Jan 2024 15:44:54 -0500 (EST) Received: from linux.microsoft.com (linux.microsoft.com [13.77.154.182]) by lists.libvirt.org (Postfix) with ESMTP id 2E2321C67 for ; Tue, 30 Jan 2024 15:44:54 -0500 (EST) Received: from home.. (072-191-074-189.res.spectrum.com [72.191.74.189]) by linux.microsoft.com (Postfix) with ESMTPSA id C75A920B2001; Tue, 30 Jan 2024 12:44:52 -0800 (PST) X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on lists.libvirt.org X-Spam-Level: X-Spam-Status: No, score=-0.8 required=5.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.4 DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com C75A920B2001 From: Praveen K Paladugu To: devel@lists.libvirt.org Subject: [PATCH 1/2] conf: Introduce mshv hypervisor type Date: Tue, 30 Jan 2024 14:44:40 -0600 Message-ID: <20240130204441.30740-2-prapal@linux.microsoft.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240130204441.30740-1-prapal@linux.microsoft.com> References: <20240130204441.30740-1-prapal@linux.microsoft.com> MIME-Version: 1.0 Message-ID-Hash: 5GE7C57A43AZVZM6B6JXA2IIKPGPJTGP X-Message-ID-Hash: 5GE7C57A43AZVZM6B6JXA2IIKPGPJTGP X-MailFrom: prapal@linux.microsoft.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: Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZM-MESSAGEID: 1706647593097100001 This hypervisor type is available on a host running Microsoft Hypervisor and Linux as the Dom0. The Dom0 should load "mshv" drivers to expose the hypervisor device to userspace. Cloud-Hypervisor supports running guests on Linux Hosts with mshv as the hypervisor. Signed-off-by: Praveen K Paladugu --- src/conf/domain_conf.c | 1 + src/conf/domain_conf.h | 1 + src/qemu/qemu_command.c | 1 + 3 files changed, 3 insertions(+) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index fb5a5cc351..d0b33e97e6 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -122,6 +122,7 @@ VIR_ENUM_IMPL(virDomainVirt, "test", "vmware", "hyperv", + "mshv", "vbox", "phyp", "parallels", diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h index bd283d42df..128b058161 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -136,6 +136,7 @@ typedef enum { VIR_DOMAIN_VIRT_TEST, VIR_DOMAIN_VIRT_VMWARE, VIR_DOMAIN_VIRT_HYPERV, + VIR_DOMAIN_VIRT_MSHV, VIR_DOMAIN_VIRT_VBOX, VIR_DOMAIN_VIRT_PHYP, VIR_DOMAIN_VIRT_PARALLELS, diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index 31d42495f4..af38ade0c0 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -7184,6 +7184,7 @@ qemuBuildAccelCommandLine(virCommand *cmd, case VIR_DOMAIN_VIRT_TEST: case VIR_DOMAIN_VIRT_VMWARE: case VIR_DOMAIN_VIRT_HYPERV: + case VIR_DOMAIN_VIRT_MSHV: case VIR_DOMAIN_VIRT_VBOX: case VIR_DOMAIN_VIRT_PHYP: case VIR_DOMAIN_VIRT_PARALLELS: --=20 2.43.0 _______________________________________________ Devel mailing list -- devel@lists.libvirt.org To unsubscribe send an email to devel-leave@lists.libvirt.org From nobody Sat Dec 21 12:34:43 2024 Delivered-To: importer@patchew.org Received-SPF: none (zohomail.com: 8.43.85.245 is neither permitted nor denied by domain of lists.libvirt.org) client-ip=8.43.85.245; envelope-from=devel-bounces@lists.libvirt.org; helo=lists.libvirt.org; Authentication-Results: mx.zohomail.com; spf=none (zohomail.com: 8.43.85.245 is neither permitted nor denied by domain of lists.libvirt.org) smtp.mailfrom=devel-bounces@lists.libvirt.org; dmarc=fail(p=none dis=none) header.from=linux.microsoft.com Return-Path: Received: from lists.libvirt.org (lists.libvirt.org [8.43.85.245]) by mx.zohomail.com with SMTPS id 1706647756737534.016859576516; Tue, 30 Jan 2024 12:49:16 -0800 (PST) Received: by lists.libvirt.org (Postfix, from userid 996) id A60DC1CA7; Tue, 30 Jan 2024 15:49:15 -0500 (EST) Received: from lists.libvirt.org.85.43.8.in-addr.arpa (localhost [IPv6:::1]) by lists.libvirt.org (Postfix) with ESMTP id 4C61E1C94; Tue, 30 Jan 2024 15:45:20 -0500 (EST) Received: by lists.libvirt.org (Postfix, from userid 996) id B51591926; Tue, 30 Jan 2024 15:44:55 -0500 (EST) Received: from linux.microsoft.com (linux.microsoft.com [13.77.154.182]) by lists.libvirt.org (Postfix) with ESMTP id AC8501C6C for ; Tue, 30 Jan 2024 15:44:54 -0500 (EST) Received: from home.. (072-191-074-189.res.spectrum.com [72.191.74.189]) by linux.microsoft.com (Postfix) with ESMTPSA id 3D81420B2002; Tue, 30 Jan 2024 12:44:53 -0800 (PST) X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on lists.libvirt.org X-Spam-Level: X-Spam-Status: No, score=-0.8 required=5.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.4 DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com 3D81420B2002 From: Praveen K Paladugu To: devel@lists.libvirt.org Subject: [PATCH 2/2] ch: Check for hypervisor while starting guests Date: Tue, 30 Jan 2024 14:44:41 -0600 Message-ID: <20240130204441.30740-3-prapal@linux.microsoft.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240130204441.30740-1-prapal@linux.microsoft.com> References: <20240130204441.30740-1-prapal@linux.microsoft.com> MIME-Version: 1.0 Message-ID-Hash: H7DNGK6J2I64VMAKC2FQ7IKM5YFEZ7NP X-Message-ID-Hash: H7DNGK6J2I64VMAKC2FQ7IKM5YFEZ7NP X-MailFrom: prapal@linux.microsoft.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: Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZM-MESSAGEID: 1706647757465100001 While initializing ch driver, confirm either /dev/kvm or /dev/mshv device is present. Before starting domains, validate the requested hypervisor device exists on the host. Users can specify hypervisor in ch guests's domain definitions like below: _or_ Signed-off-by: Praveen K Paladugu --- src/ch/ch_conf.c | 2 ++ src/ch/ch_driver.c | 7 +++++++ src/ch/ch_process.c | 34 ++++++++++++++++++++++++++++++++++ 3 files changed, 43 insertions(+) diff --git a/src/ch/ch_conf.c b/src/ch/ch_conf.c index f421af5121..7cb113bca5 100644 --- a/src/ch/ch_conf.c +++ b/src/ch/ch_conf.c @@ -69,6 +69,8 @@ virCaps *virCHDriverCapsInit(void) =20 virCapabilitiesAddGuestDomain(guest, VIR_DOMAIN_VIRT_KVM, NULL, NULL, 0, NULL); + virCapabilitiesAddGuestDomain(guest, VIR_DOMAIN_VIRT_MSHV, + NULL, NULL, 0, NULL); return g_steal_pointer(&caps); } =20 diff --git a/src/ch/ch_driver.c b/src/ch/ch_driver.c index 96de5044ac..d6294c76ee 100644 --- a/src/ch/ch_driver.c +++ b/src/ch/ch_driver.c @@ -32,6 +32,7 @@ #include "viraccessapicheck.h" #include "virchrdev.h" #include "virerror.h" +#include "virfile.h" #include "virlog.h" #include "virobject.h" #include "virtypedparam.h" @@ -876,6 +877,12 @@ static int chStateInitialize(bool privileged, return -1; } =20 + if (!(virFileExists("/dev/kvm") || virFileExists("/dev/mshv"))) { + virReportError(VIR_ERR_DEVICE_MISSING, "%s", + _("/dev/kvm and /dev/mshv. ch driver failed to init= ialize.")); + return VIR_DRV_STATE_INIT_ERROR; + } + ch_driver =3D g_new0(virCHDriver, 1); =20 if (virMutexInit(&ch_driver->lock) < 0) { diff --git a/src/ch/ch_process.c b/src/ch/ch_process.c index f3bb4a7280..d9f943c50b 100644 --- a/src/ch/ch_process.c +++ b/src/ch/ch_process.c @@ -28,6 +28,7 @@ #include "ch_process.h" #include "domain_cgroup.h" #include "virerror.h" +#include "virfile.h" #include "virjson.h" #include "virlog.h" =20 @@ -448,6 +449,35 @@ virCHProcessSetupVcpus(virDomainObj *vm) return 0; } =20 +/** + * virCHProcessStartValidate: + * @vm: domain object + * + * Checks done before starting a VM. + * + * Returns 0 on success or -1 in case of error + */ +static int virCHProcessStartValidate(virDomainObj *vm) +{ + if (vm->def->virtType =3D=3D VIR_DOMAIN_VIRT_KVM) { + VIR_DEBUG("Checking for KVM availability"); + if (!virFileExists("/dev/kvm")) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("Domain requires KVM, but it is not avail= able. Check that virtualization is enabled in the host BIOS, and host confi= guration is setup to load the kvm modules.")); + return -1; + } + } else if (vm->def->virtType =3D=3D VIR_DOMAIN_VIRT_MSHV) { + VIR_DEBUG("Checking for MSHV availability"); + if (!virFileExists("/dev/mshv")) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("Domain requires MSHV, but it is not avai= lable. Check that virtualization is enabled in the host BIOS, and host conf= iguration is setup to load the mshv modules.")); + return -1; + } + } + return 0; + +} + /** * virCHProcessStart: * @driver: pointer to driver structure @@ -475,6 +505,10 @@ virCHProcessStart(virCHDriver *driver, return -1; } =20 + if (virCHProcessStartValidate(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.43.0 _______________________________________________ Devel mailing list -- devel@lists.libvirt.org To unsubscribe send an email to devel-leave@lists.libvirt.org