From nobody Fri May 17 10:44:24 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) client-ip=170.10.129.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=fail(p=none dis=none) header.from=linux.microsoft.com ARC-Seal: i=1; a=rsa-sha256; t=1696974201; cv=none; d=zohomail.com; s=zohoarc; b=OWtA/JEnuw8JZFem1bt6YiXmhLa/WfAYLZaB5pBgbsumFbngKjr7zncAkJOGGhsofsR9fwXgw+MRnWEHkOiMRN0IROtUF06aWguxu0PKVpJubuq/nXffei1XVKskpltfjJNBmB3S+iYaQ6rJ8dW5he4vTUahgnR8IEtse8HA1Hg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1696974201; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=g1JSVvCSCBCnMSa3LAwLKKSXjc43IqnsVaW9krbiue0=; b=d76NaqqsCPgADg75eWhoZNmZqG4X75ScQ3gZDNXKiMTdEe7AGsMHNfbAS1affvSBTC+96DHjUO5etqLoK6X5gg11vnpjnru9gLmj73QQrtEtA7tS/qAYvB7J8j0COxk0qBmg8DW1cQsWpFX861MaPdasWXYU7Xzi0EzxNpZFDxo= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=fail header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by mx.zohomail.com with SMTPS id 1696974201214934.1586850671283; Tue, 10 Oct 2023 14:43:21 -0700 (PDT) Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-483-hucO5nZEO7mL51bVGyjntw-1; Tue, 10 Oct 2023 17:43:16 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 55B0785A5BA; Tue, 10 Oct 2023 21:43:14 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id 403C263F45; Tue, 10 Oct 2023 21:43:14 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 19B5719465B8; Tue, 10 Oct 2023 21:43:14 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 433C41946597 for ; Tue, 10 Oct 2023 21:43:10 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 2560320292A8; Tue, 10 Oct 2023 21:43:10 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast02.extmail.prod.ext.rdu2.redhat.com [10.11.55.18]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 1DE572029296 for ; Tue, 10 Oct 2023 21:43:10 +0000 (UTC) Received: from us-smtp-inbound-delivery-1.mimecast.com (us-smtp-1.mimecast.com [205.139.110.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id F1D5F887E47 for ; Tue, 10 Oct 2023 21:43:09 +0000 (UTC) Received: from linux.microsoft.com (linux.microsoft.com [13.77.154.182]) by relay.mimecast.com with ESMTP id us-mta-266-oF2-LNLBPTG0LPN5o7AHMw-1; Tue, 10 Oct 2023 17:43:07 -0400 Received: from home-fedora.. (072-191-074-189.res.spectrum.com [72.191.74.189]) by linux.microsoft.com (Postfix) with ESMTPSA id 00DA220B74C1; Tue, 10 Oct 2023 14:43:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1696974200; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=g1JSVvCSCBCnMSa3LAwLKKSXjc43IqnsVaW9krbiue0=; b=Z6GV9EiMEiZ8E+DdpwVOWFEYXqwEISJE0fqtH/bKGWXFpe+Ox2z3zG98+SJ1MD+KS4NVut 8ATGBFL1s95TsDS9OrfxyJeLq50lTt2/Szjz2OZElaJFcM+v7pahP/4BCLrJmEmRnbpkL+ oqvdW7ZotTcj4UkTPnKNH111DN8pyng= X-MC-Unique: hucO5nZEO7mL51bVGyjntw-1 X-Original-To: libvir-list@listman.corp.redhat.com X-MC-Unique: oF2-LNLBPTG0LPN5o7AHMw-1 DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com 00DA220B74C1 From: Praveen K Paladugu To: libvir-list@redhat.com Subject: [libvirt PATCH 1/2] ch: use payload api to send kernel details Date: Tue, 10 Oct 2023 16:42:57 -0500 Message-ID: <20231010214258.51894-2-prapal@linux.microsoft.com> In-Reply-To: <20231010214258.51894-1-prapal@linux.microsoft.com> References: <20231010214258.51894-1-prapal@linux.microsoft.com> MIME-Version: 1.0 X-Mimecast-Impersonation-Protect: Policy=CLT - Impersonation Protection Definition; Similar Internal Domain=false; Similar Monitored External Domain=false; Custom External Domain=false; Mimecast External Domain=false; Newly Observed Domain=false; Internal User Name=false; Custom Display Name List=false; Reply-to Address Mismatch=false; Targeted Threat Dictionary=false; Mimecast Threat Dictionary=false; Custom Threat Dictionary=false X-Scanned-By: MIMEDefang 3.1 on 10.11.54.4 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: liuwe@microsoft.com Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 3.1 on 10.11.54.5 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: linux.microsoft.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1696974201987100003 Content-Type: text/plain; charset="utf-8"; x-default="true" Starting with v28.0 cloud-hypervisor requires the use of "payload" api to p= ass kernel, initramfs and cmdline options. Extend ch driver to use the new api based on ch version. Signed-off-by: Praveen K Paladugu Reviewed-by: Michal Privoznik --- src/ch/ch_capabilities.c | 55 ++++++++++++++++++++++++++++++++++++++++ src/ch/ch_capabilities.h | 34 +++++++++++++++++++++++++ src/ch/ch_conf.h | 6 +++++ src/ch/ch_driver.c | 3 +++ src/ch/ch_monitor.c | 48 +++++++++++++++++++++++++++++++---- src/ch/ch_monitor.h | 4 ++- src/ch/ch_process.c | 2 +- src/ch/meson.build | 2 ++ 8 files changed, 147 insertions(+), 7 deletions(-) create mode 100644 src/ch/ch_capabilities.c create mode 100644 src/ch/ch_capabilities.h diff --git a/src/ch/ch_capabilities.c b/src/ch/ch_capabilities.c new file mode 100644 index 0000000000..b10485820c --- /dev/null +++ b/src/ch/ch_capabilities.c @@ -0,0 +1,55 @@ +/* + * Copyright Microsoft Corp. 2023 + * + * ch_capabilities.h: CH capabilities + * + * 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_capabilities.h" + +static void +virCHCapsSet(virBitmap *chCaps, + virCHCapsFlags flag) +{ + ignore_value(virBitmapSetBit(chCaps, flag)); +} + +/** + * virCHCapsInitCHVersionCaps: + * + * Set all CH capabilities based on version of CH. + */ +virBitmap * +virCHCapsInitCHVersionCaps(int version) +{ + g_autoptr(virBitmap) chCaps =3D NULL; + chCaps =3D virBitmapNew(CH_CAPS_LAST); + + /* Version 28 deprecated kernel API: + * https://github.com/cloud-hypervisor/cloud-hypervisor/releases/tag/v= 28.0 + */ + if (version >=3D 28000000) + virCHCapsSet(chCaps, CH_KERNEL_API_DEPRCATED); + + + /* Starting Version 18, serial and console can be used in parallel */ + if (version >=3D 18000000) + virCHCapsSet(chCaps, CH_SERIAL_CONSOLE_IN_PARALLEL); + + return g_steal_pointer(&chCaps); + +} diff --git a/src/ch/ch_capabilities.h b/src/ch/ch_capabilities.h new file mode 100644 index 0000000000..703a6dbfe2 --- /dev/null +++ b/src/ch/ch_capabilities.h @@ -0,0 +1,34 @@ +/* + * Copyright Microsoft Corp. 2023 + * + * ch_capabilities.h: CH capabilities + * + * 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 "virbitmap.h" + + +typedef enum { + /* 0 */ + CH_KERNEL_API_DEPRCATED, /* Use `payload` in place of `kernel` api */ + CH_SERIAL_CONSOLE_IN_PARALLEL, /* Serial and Console ports can work in= parallel */ + + CH_CAPS_LAST /* this must always be the last item */ +} virCHCapsFlags; + +virBitmap * +virCHCapsInitCHVersionCaps(int version); diff --git a/src/ch/ch_conf.h b/src/ch/ch_conf.h index b927621a97..5b9b42540d 100644 --- a/src/ch/ch_conf.h +++ b/src/ch/ch_conf.h @@ -22,6 +22,7 @@ =20 #include "virdomainobjlist.h" #include "virthread.h" +#include "ch_capabilities.h" =20 #define CH_DRIVER_NAME "CH" #define CH_CMD "cloud-hypervisor" @@ -54,6 +55,11 @@ struct _virCHDriver * lockless access thereafter */ virCaps *caps; =20 + /* Immutable pointer, Immutable object + * Initialized once and reused as needed + */ + virBitmap *chCaps; + /* Immutable pointer, Immutable object */ virDomainXMLOption *xmlopt; =20 diff --git a/src/ch/ch_driver.c b/src/ch/ch_driver.c index b62645a8c8..bd271fc0ee 100644 --- a/src/ch/ch_driver.c +++ b/src/ch/ch_driver.c @@ -20,6 +20,7 @@ =20 #include =20 +#include "ch_capabilities.h" #include "ch_conf.h" #include "ch_domain.h" #include "ch_driver.h" @@ -899,6 +900,8 @@ static int chStateInitialize(bool privileged, goto cleanup; } =20 + ch_driver->chCaps =3D virCHCapsInitCHVersionCaps(ch_driver->version); + ch_driver->privileged =3D privileged; ret =3D VIR_DRV_STATE_INIT_COMPLETE; =20 diff --git a/src/ch/ch_monitor.c b/src/ch/ch_monitor.c index 1691a4efb6..6f960c3a51 100644 --- a/src/ch/ch_monitor.c +++ b/src/ch/ch_monitor.c @@ -106,6 +106,37 @@ virCHMonitorBuildPTYJson(virJSONValue *content, virDom= ainDef *vmdef) return 0; } =20 +static int +virCHMonitorBuildPayloadJson(virJSONValue *content, virDomainDef *vmdef) +{ + g_autoptr(virJSONValue) payload =3D virJSONValueNewObject(); + + + if (vmdef->os.kernel =3D=3D NULL) { + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("Kernel image path in this domain is not defined"= )); + return -1; + } else { + if (virJSONValueObjectAppendString(payload, "kernel", vmdef->os.ke= rnel) < 0) + return -1; + } + + if (vmdef->os.cmdline) { + if (virJSONValueObjectAppendString(payload, "cmdline", vmdef->os.c= mdline) < 0) + return -1; + } + + if (vmdef->os.initrd !=3D NULL) { + if (virJSONValueObjectAppendString(payload, "initramfs", vmdef->os= .initrd) < 0) + return -1; + } + + if (virJSONValueObjectAppend(content, "payload", &payload) < 0) + return -1; + + return 0; +} + static int virCHMonitorBuildKernelRelatedJson(virJSONValue *content, virDomainDef *vm= def) { @@ -425,7 +456,8 @@ virCHMonitorBuildDevicesJson(virJSONValue *content, } =20 static int -virCHMonitorBuildVMJson(virDomainDef *vmdef, +virCHMonitorBuildVMJson(virCHDriver *driver, + virDomainDef *vmdef, char **jsonstr, size_t *nnicindexes, int **nicindexes) @@ -447,8 +479,13 @@ virCHMonitorBuildVMJson(virDomainDef *vmdef, if (virCHMonitorBuildMemoryJson(content, vmdef) < 0) return -1; =20 - if (virCHMonitorBuildKernelRelatedJson(content, vmdef) < 0) - return -1; + if (virBitmapIsBitSet(driver->chCaps, CH_KERNEL_API_DEPRCATED)) { + if (virCHMonitorBuildPayloadJson(content, vmdef) < 0) + return -1; + } else if (virCHMonitorBuildKernelRelatedJson(content, vmdef) < 0) { + return -1; + } + =20 if (virCHMonitorBuildDisksJson(content, vmdef) < 0) return -1; @@ -840,7 +877,8 @@ virCHMonitorShutdownVMM(virCHMonitor *mon) } =20 int -virCHMonitorCreateVM(virCHMonitor *mon, +virCHMonitorCreateVM(virCHDriver *driver, + virCHMonitor *mon, size_t *nnicindexes, int **nicindexes) { @@ -854,7 +892,7 @@ virCHMonitorCreateVM(virCHMonitor *mon, headers =3D curl_slist_append(headers, "Accept: application/json"); headers =3D curl_slist_append(headers, "Content-Type: application/json= "); =20 - if (virCHMonitorBuildVMJson(mon->vm->def, &payload, + if (virCHMonitorBuildVMJson(driver, mon->vm->def, &payload, nnicindexes, nicindexes) !=3D 0) return -1; =20 diff --git a/src/ch/ch_monitor.h b/src/ch/ch_monitor.h index ffc80e8910..bbfa77cdff 100644 --- a/src/ch/ch_monitor.h +++ b/src/ch/ch_monitor.h @@ -25,6 +25,7 @@ #include "virobject.h" #include "virjson.h" #include "domain_conf.h" +#include "ch_conf.h" =20 #define URL_ROOT "http://localhost/api/v1" #define URL_VMM_SHUTDOWN "vmm.shutdown" @@ -103,7 +104,8 @@ void virCHMonitorClose(virCHMonitor *mon); G_DEFINE_AUTOPTR_CLEANUP_FUNC(virCHMonitor, virCHMonitorClose); =20 =20 -int virCHMonitorCreateVM(virCHMonitor *mon, +int virCHMonitorCreateVM(virCHDriver *driver, + virCHMonitor *mon, size_t *nnicindexes, int **nicindexes); int virCHMonitorBootVM(virCHMonitor *mon); diff --git a/src/ch/ch_process.c b/src/ch/ch_process.c index 6d3a9612bd..f3bb4a7280 100644 --- a/src/ch/ch_process.c +++ b/src/ch/ch_process.c @@ -483,7 +483,7 @@ virCHProcessStart(virCHDriver *driver, goto cleanup; } =20 - if (virCHMonitorCreateVM(priv->monitor, + if (virCHMonitorCreateVM(driver, priv->monitor, &nnicindexes, &nicindexes) < 0) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("failed to create guest VM")); diff --git a/src/ch/meson.build b/src/ch/meson.build index df246ef9b0..6311b84f3e 100644 --- a/src/ch/meson.build +++ b/src/ch/meson.build @@ -1,4 +1,6 @@ ch_driver_sources =3D [ + 'ch_capabilities.h', + 'ch_capabilities.c', 'ch_conf.c', 'ch_conf.h', 'ch_domain.c', --=20 2.41.0 From nobody Fri May 17 10:44:24 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) client-ip=170.10.129.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=fail(p=none dis=none) header.from=linux.microsoft.com ARC-Seal: i=1; a=rsa-sha256; t=1696974203; cv=none; d=zohomail.com; s=zohoarc; b=d93eETWRkETdPV1ELHKAIrulEpdV9C3qlLSc3gY6hfJGhqPbS/dAd6D2rN9Zl08f41/Xrurf6y6F6kbV7nwN/W/6re5l0wRG3RTn2Nmxz81hiaUEySq8ZNrtOR0/mFVWMOjz1hgPkZFbX9bFcJNTzYGhqiGQtSbSiJlso01XEwc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1696974203; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=hDHRokRPDP3PLfLWHCfaHmnT8aceH3OPzvJgpYC2hgQ=; b=P5kjebyz9o4aaMDTAooppXDPxgZrtSGQDVHHumjljktNnvQzfZ0WfgcBExZ+ldqK6SF4ADhDX20ZFUjnC1bfTM2ePTtgNXoulWwBKO6oSycwrCzvKheX1Xrabe0C60brmHLK+o0iGslBSn30eFvqS8LmjTl/5Q9r6ZvWs9cyvFM= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=fail header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by mx.zohomail.com with SMTPS id 1696974203398696.5730166223501; Tue, 10 Oct 2023 14:43:23 -0700 (PDT) Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-465-QYTSV2wfO_yq055Ee2SRPg-1; Tue, 10 Oct 2023 17:43:19 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id BC868101A53B; Tue, 10 Oct 2023 21:43:16 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id A870B2062BE8; Tue, 10 Oct 2023 21:43:16 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 6E0E519465B8; Tue, 10 Oct 2023 21:43:16 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 743861946597 for ; Tue, 10 Oct 2023 21:43:15 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 4A2422062BE8; Tue, 10 Oct 2023 21:43:15 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast01.extmail.prod.ext.rdu2.redhat.com [10.11.55.17]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 42B052062BEC for ; Tue, 10 Oct 2023 21:43:15 +0000 (UTC) Received: from us-smtp-inbound-delivery-1.mimecast.com (us-smtp-delivery-1.mimecast.com [205.139.110.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 24FCD8582B4 for ; Tue, 10 Oct 2023 21:43:15 +0000 (UTC) Received: from linux.microsoft.com (linux.microsoft.com [13.77.154.182]) by relay.mimecast.com with ESMTP id us-mta-590-E-5h5myqOSKwYvevXFQwDA-1; Tue, 10 Oct 2023 17:43:08 -0400 Received: from home-fedora.. (072-191-074-189.res.spectrum.com [72.191.74.189]) by linux.microsoft.com (Postfix) with ESMTPSA id 652DF20B74C2; Tue, 10 Oct 2023 14:43:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1696974202; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=hDHRokRPDP3PLfLWHCfaHmnT8aceH3OPzvJgpYC2hgQ=; b=JvDLWX8C39vD0STHXdR3HTeevTGF5c0/Zkn9eK3gcNoqZgMBSymg81AM+3Fz+jKGj/ulbJ xi0QYhb29hySCve0+0PNuY+VZJh9CfPsPKHS72cdTCv8MW7uRpSan9AsD6ZgApe9B7lSXK xc4i97kzOPhubDu5T71anm1XVpIOEmM= X-MC-Unique: QYTSV2wfO_yq055Ee2SRPg-1 X-Original-To: libvir-list@listman.corp.redhat.com X-MC-Unique: E-5h5myqOSKwYvevXFQwDA-1 DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com 652DF20B74C2 From: Praveen K Paladugu To: libvir-list@redhat.com Subject: [libvirt PATCH 2/2] ch: support serial and console devices in parallel Date: Tue, 10 Oct 2023 16:42:58 -0500 Message-ID: <20231010214258.51894-3-prapal@linux.microsoft.com> In-Reply-To: <20231010214258.51894-1-prapal@linux.microsoft.com> References: <20231010214258.51894-1-prapal@linux.microsoft.com> MIME-Version: 1.0 X-Mimecast-Impersonation-Protect: Policy=CLT - Impersonation Protection Definition; Similar Internal Domain=false; Similar Monitored External Domain=false; Custom External Domain=false; Mimecast External Domain=false; Newly Observed Domain=false; Internal User Name=false; Custom Display Name List=false; Reply-to Address Mismatch=false; Targeted Threat Dictionary=false; Mimecast Threat Dictionary=false; Custom Threat Dictionary=false X-Scanned-By: MIMEDefang 3.1 on 10.11.54.6 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: liuwe@microsoft.com Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 3.1 on 10.11.54.6 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: linux.microsoft.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1696974203960100005 Content-Type: text/plain; charset="utf-8"; x-default="true" Starting v18, cloud-hypervisor supports serial and console devices in parallel. Drop related check based on ch version. Signed-off-by: Praveen K Paladugu Reviewed-by: Michal Privoznik --- src/ch/ch_domain.c | 28 ++++++++++++++++++---------- 1 file changed, 18 insertions(+), 10 deletions(-) diff --git a/src/ch/ch_domain.c b/src/ch/ch_domain.c index 866f0d899a..c0d6c75b1d 100644 --- a/src/ch/ch_domain.c +++ b/src/ch/ch_domain.c @@ -142,10 +142,11 @@ virDomainXMLPrivateDataCallbacks virCHDriverPrivateDa= taCallbacks =3D { =20 static int chValidateDomainDeviceDef(const virDomainDeviceDef *dev, - const virDomainDef *def G_GNUC_UNUSED, - void *opaque G_GNUC_UNUSED, + const virDomainDef *def, + void *opaque, void *parseOpaque G_GNUC_UNUSED) { + virCHDriver *driver =3D opaque; switch (dev->type) { case VIR_DOMAIN_DEVICE_DISK: case VIR_DOMAIN_DEVICE_NET: @@ -191,18 +192,25 @@ chValidateDomainDeviceDef(const virDomainDeviceDef *d= ev, return -1; } =20 - if ((def->nconsoles && - def->consoles[0]->source->type =3D=3D VIR_DOMAIN_CHR_TYPE_PTY) - && (def->nserials && - def->serials[0]->source->type =3D=3D VIR_DOMAIN_CHR_TYPE_PTY))= { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + if (!virBitmapIsBitSet(driver->chCaps, CH_SERIAL_CONSOLE_IN_PARALLEL))= { + if ((def->nconsoles && + def->consoles[0]->source->type =3D=3D VIR_DOMAIN_CHR_TYPE_= PTY) + && (def->nserials && + def->serials[0]->source->type =3D=3D VIR_DOMAIN_CHR_TYPE_P= TY)) { + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("Only a single console or serial can be configure= d for this domain")); - return -1; - } else if (def->nconsoles > 1) { + return -1; + } + } + + + if (def->nconsoles > 1) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("Only a single console can be configured for this= domain")); return -1; - } else if (def->nserials > 1) { + } + + if (def->nserials > 1) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("Only a single serial can be configured for this = domain")); return -1; --=20 2.41.0