From nobody Mon May 13 11:38:49 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=gmail.com Return-Path: Received: from lists.libvirt.org (lists.libvirt.org [8.43.85.245]) by mx.zohomail.com with SMTPS id 1708466863336751.171057555558; Tue, 20 Feb 2024 14:07:43 -0800 (PST) Received: by lists.libvirt.org (Postfix, from userid 996) id 143D91D34; Tue, 20 Feb 2024 17:07:42 -0500 (EST) Received: from lists.libvirt.org (localhost [IPv6:::1]) by lists.libvirt.org (Postfix) with ESMTP id 35535168; Tue, 20 Feb 2024 17:06:16 -0500 (EST) Received: by lists.libvirt.org (Postfix, from userid 996) id C64B81778; Tue, 20 Feb 2024 17:06:11 -0500 (EST) Received: from mail-oa1-f44.google.com (mail-oa1-f44.google.com [209.85.160.44]) (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 4585C175D for ; Tue, 20 Feb 2024 17:06:06 -0500 (EST) Received: by mail-oa1-f44.google.com with SMTP id 586e51a60fabf-21e45ece781so3662415fac.0 for ; Tue, 20 Feb 2024 14:06:06 -0800 (PST) Received: from home.. (2603-8081-c640-0001-0000-0000-0000-1007.res6.spectrum.com. [2603:8081:c640:1::1007]) by smtp.gmail.com with ESMTPSA id gu15-20020a056870ab0f00b0021e7862c59fsm2044682oab.13.2024.02.20.14.06.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 20 Feb 2024 14:06:04 -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.5 required=5.0 tests=DKIM_ADSP_CUSTOM_MED, FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE, T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.4 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708466765; x=1709071565; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=clSj9aimY6pDrMf0QAMDyxkad/HHbUE52uAhsf3caX8=; b=pz/uJiR5X0pSLsOwA1Giag3NS0v11Zvp6JDdEC4KkoabUmfAoGPbj1omBTKoJ9t4WB /T1GEBKg1+i8eyWLfyxcLZAw967+Sv9LERvdWXpzP06U6XWpa5/NEqen6VF0q5Bs2Tur T0Q1NukE4EEHwAZwbhdN53z2NWcf899WVNZPSxL2r0jvpdSLokoSXS2BSCGArXjqGiXT ADGtkFxajf6g1NdiHr4MTfdbtavmNJD4bnoEFb2nB1P7iacTjNt6MIE+HDza8iCT2Nbp bE0UIzSC38NTxAE9M6mkBA38tATeV3bJDc8EZjIQ+GqRGeAcTOKeYi7RJdf5R3pdhkFM 2Oaw== X-Gm-Message-State: AOJu0YywWd+50YdtzIQ7w0B0lBZViLqVqgv7ukVpAwVDnyzH9Bvoody1 OmQVA8n/OhJqojxZ5yxaA3M2rbbS8tP4RaD1ZM/2NjnFbZSkJqIeeQLL2H7Joe4= X-Google-Smtp-Source: AGHT+IEFsOStC0f2+pneybD2aZ4EDX5GazCNDXT71wfjW9ChvYv5Mli0+KACcBCQC0IrThdo251cSw== X-Received: by 2002:a05:6870:40c9:b0:21e:a76f:2d66 with SMTP id l9-20020a05687040c900b0021ea76f2d66mr10505747oal.13.1708466764923; Tue, 20 Feb 2024 14:06:04 -0800 (PST) From: Praveen K Paladugu To: devel@lists.libvirt.org Subject: [PATCH v2] ch: Enable hyperv hypervisor Date: Tue, 20 Feb 2024 16:06:03 -0600 Message-ID: <20240220220603.22979-1-praveenkpaladugu@gmail.com> X-Mailer: git-send-email 2.43.0 MIME-Version: 1.0 Message-ID-Hash: OEP6HH4DACM47GL7BHS2APPYKH7PZESK X-Message-ID-Hash: OEP6HH4DACM47GL7BHS2APPYKH7PZESK 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: prapal@linux.microsoft.com, 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: 1708466865208100001 From: Praveen K Paladugu Cloud-Hypervisor is capable of running VMs with kvm or mshv as the hypervisor on Linux Host. Guest to hypevisor ABI with mshv hypervisor is the same as in the case of VIR_DOMAIN_VIRT_HYPERV. So, VIR_DOMAIN_VIRT_HYPE= RV type will be reused to represent the config with Linux Host and mshv as the hypervisor. While initializing ch driver, check if either of /dev/kvm or /dev/mshv device is present on the host. Before starting ch domains, check if the requested hypervisor device is present on the host. Users can specify hypervisor in ch guests's domain definitions like below: _or_ Signed-off-by: Praveen K Paladugu Signed-off-by: Praveen K Paladugu Reviewed-by: Michal Privoznik --- src/ch/ch_conf.c | 2 ++ src/ch/ch_driver.c | 7 +++++++ src/ch/ch_process.c | 35 +++++++++++++++++++++++++++++++++++ 3 files changed, 44 insertions(+) diff --git a/src/ch/ch_conf.c b/src/ch/ch_conf.c index f421af5121..1911ae8f8b 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_HYPERV, + 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 3bde9d9dcf..640f72a9ca 100644 --- a/src/ch/ch_process.c +++ b/src/ch/ch_process.c @@ -637,6 +637,37 @@ chProcessAddNetworkDevices(virCHDriver *driver, 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_HYPERV) { + VIR_DEBUG("Checking for mshv availability"); + if (!virFileExists("/dev/mshv")) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("Domain requires MSHV device, but it is n= ot available. Check that virtualization is enabled in the host BIOS, and ho= st configuration is setup to load the mshv modules.")); + return -1; + } + } else { + return -1; + } + return 0; + +} + /** * virCHProcessStart: * @driver: pointer to driver structure @@ -664,6 +695,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