From nobody Sat Feb 7 10:15:14 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) client-ip=216.205.24.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=fail(p=none dis=none) header.from=intel.com Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by mx.zohomail.com with SMTPS id 1625007565303214.67904366599635; Tue, 29 Jun 2021 15:59:25 -0700 (PDT) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-557-wd5En7-BMdK9X8xDk5eohQ-1; Tue, 29 Jun 2021 18:59:22 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 51AE880414C; Tue, 29 Jun 2021 22:59:16 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 0F8FF5DA61; Tue, 29 Jun 2021 22:59:16 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id CC0BA1800FDB; Tue, 29 Jun 2021 22:59:15 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 15TMwq0w004476 for ; Tue, 29 Jun 2021 18:58:52 -0400 Received: by smtp.corp.redhat.com (Postfix) id 0746711558BE; Tue, 29 Jun 2021 22:58:52 +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 F3E5C10130E5 for ; Tue, 29 Jun 2021 22:58:48 +0000 (UTC) Received: from us-smtp-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 C869D800B36 for ; Tue, 29 Jun 2021 22:58:47 +0000 (UTC) Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-62-nJpM2E3nPjG6OCpwpQEfNA-4; Tue, 29 Jun 2021 18:58:45 -0400 Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by fmsmga105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 29 Jun 2021 15:58:44 -0700 Received: from wdouglas-dev.jf.intel.com (HELO desk.jf.intel.com) ([10.7.200.157]) by fmsmga005-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 29 Jun 2021 15:58:44 -0700 X-MC-Unique: wd5En7-BMdK9X8xDk5eohQ-1 X-MC-Unique: nJpM2E3nPjG6OCpwpQEfNA-4 X-IronPort-AV: E=McAfee;i="6200,9189,10030"; a="293891998" X-IronPort-AV: E=Sophos;i="5.83,310,1616482800"; d="scan'208";a="293891998" X-IronPort-AV: E=Sophos;i="5.83,310,1616482800"; d="scan'208";a="643883943" From: William Douglas To: libvir-list@redhat.com Subject: [PATCH 04/10] ch_monitor: Add pty json builder function Date: Tue, 29 Jun 2021 16:05:47 -0700 Message-Id: <20210629230553.66273-5-william.douglas@intel.com> In-Reply-To: <20210629230553.66273-1-william.douglas@intel.com> References: <20210629230553.66273-1-william.douglas@intel.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 2.78 on 10.11.54.3 X-loop: libvir-list@redhat.com Cc: William Douglas X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Add function to build the the json structure to configure a PTY in cloud-hypervisor. The configuration only supports a single serial or console device. Signed-off-by: William Douglas --- src/ch/ch_monitor.c | 59 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 59 insertions(+) diff --git a/src/ch/ch_monitor.c b/src/ch/ch_monitor.c index 5e7d6e3189..d4289b75ce 100644 --- a/src/ch/ch_monitor.c +++ b/src/ch/ch_monitor.c @@ -89,6 +89,65 @@ virCHMonitorBuildCPUJson(virJSONValue *content, virDomai= nDef *vmdef) return -1; } =20 +static int +virCHMonitorBuildPTYJson(virJSONValue *content, virDomainDef *vmdef) +{ + virJSONValue *ptyc =3D virJSONValueNewObject(); + virJSONValue *ptys =3D virJSONValueNewObject(); + + if (vmdef->nconsoles || vmdef->nserials) { + if ((vmdef->nconsoles && + vmdef->consoles[0]->source->type =3D=3D VIR_DOMAIN_CHR_TYPE_P= TY) + && (vmdef->nserials && + vmdef->serials[0]->source->type =3D=3D VIR_DOMAIN_CHR_TYPE= _PTY)) { + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("Only a single console or serial can be confi= gured for this domain")); + goto cleanup; + } else if (vmdef->nconsoles > 1) { + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("Only a single console can be configured for = this domain")); + goto cleanup; + } else if (vmdef->nserials > 1) { + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("Only a single serial can be configured for t= his domain")); + goto cleanup; + } + } + + if (vmdef->nconsoles) { + if (vmdef->consoles[0]->source->type =3D=3D VIR_DOMAIN_CHR_TYPE_PT= Y) { + if (virJSONValueObjectAppendString(ptyc, "mode", "Pty") < 0) + goto cleanup; + if (virJSONValueObjectAppend(content, "console", &ptyc) < 0) + goto cleanup; + } else { + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("Console can only be enabled for a PTY")); + goto cleanup; + } + } + + if (vmdef->nserials) { + if (vmdef->serials[0]->source->type =3D=3D VIR_DOMAIN_CHR_TYPE_PTY= ) { + if (virJSONValueObjectAppendString(ptys, "mode", "Pty") < 0) + goto cleanup; + if (virJSONValueObjectAppend(content, "serial", &ptys) < 0) + goto cleanup; + } else { + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("Serial can only be enabled for a PTY")); + goto cleanup; + } + } + + return 0; + + cleanup: + virJSONValueFree(ptyc); + virJSONValueFree(ptys); + return -1; +} + static int virCHMonitorBuildKernelRelatedJson(virJSONValue *content, virDomainDef *vm= def) { --=20 2.31.1