From nobody Sat Feb 7 10:15:50 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) client-ip=170.10.133.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 170.10.133.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 [170.10.133.124]) by mx.zohomail.com with SMTPS id 1625007558112799.2089404869108; Tue, 29 Jun 2021 15:59:18 -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-578-ZFhwrzvyMIWuRDLjHZxZFA-1; Tue, 29 Jun 2021 18:59:15 -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 C19A8100B3B9; Tue, 29 Jun 2021 22:59:09 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id A16605DA61; Tue, 29 Jun 2021 22:59:09 +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 419334EA3B; Tue, 29 Jun 2021 22:59:09 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 15TMwquw004473 for ; Tue, 29 Jun 2021 18:58:52 -0400 Received: by smtp.corp.redhat.com (Postfix) id E300F21EE574; Tue, 29 Jun 2021 22:58:51 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast04.extmail.prod.ext.rdu2.redhat.com [10.11.55.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id DAA0021EE56D for ; Tue, 29 Jun 2021 22:58:49 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [207.211.31.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 F2124108C0A2 for ; Tue, 29 Jun 2021 22:58:48 +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-429-Ho3zHaMEPW6PY1BR4rTOHg-1; Tue, 29 Jun 2021 18:58:46 -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:46 -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:46 -0700 X-MC-Unique: ZFhwrzvyMIWuRDLjHZxZFA-1 X-MC-Unique: Ho3zHaMEPW6PY1BR4rTOHg-1 X-IronPort-AV: E=McAfee;i="6200,9189,10030"; a="293892002" X-IronPort-AV: E=Sophos;i="5.83,310,1616482800"; d="scan'208";a="293892002" X-IronPort-AV: E=Sophos;i="5.83,310,1616482800"; d="scan'208";a="643883955" From: William Douglas To: libvir-list@redhat.com Subject: [PATCH 06/10] ch_process: Handle enabled console devices Date: Tue, 29 Jun 2021 16:05:49 -0700 Message-Id: <20210629230553.66273-7-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.6 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 functionality to allow libvirt console to connect to the cloud-hypervisor created PTY associated with a VM. This will need to be run once the VM is created by cloud-hypervisor. Signed-off-by: William Douglas --- src/ch/ch_process.c | 64 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 64 insertions(+) diff --git a/src/ch/ch_process.c b/src/ch/ch_process.c index 93b1f7f97e..90344f14ea 100644 --- a/src/ch/ch_process.c +++ b/src/ch/ch_process.c @@ -28,6 +28,7 @@ #include "ch_process.h" #include "viralloc.h" #include "virerror.h" +#include "virjson.h" #include "virlog.h" =20 #define VIR_FROM_THIS VIR_FROM_CH @@ -52,6 +53,69 @@ virCHProcessConnectMonitor(virCHDriver *driver, return monitor; } =20 +static void +virCHProcessUpdateConsoleDevice(virDomainObj *vm, + virJSONValue *config, + const char *device) +{ + const char *path; + virDomainChrDef *chr =3D NULL; + virJSONValue *dev, *file; + + if (!config) + return; + + dev =3D virJSONValueObjectGet(config, device); + if (!dev) + return; + + file =3D virJSONValueObjectGet(dev, "file"); + if (!file) + return; + + path =3D virJSONValueGetString(file); + if (!path) + return; + + if (STREQ(device, "console")) { + chr =3D vm->def->consoles[0]; + } else if (STREQ(device, "serial")) { + chr =3D vm->def->serials[0]; + } + + if (chr && chr->source) + chr->source->data.file.path =3D g_strdup(path); +} + +static void +virCHProcessUpdateConsole(virDomainObj *vm, + virJSONValue *info) +{ + virJSONValue *config; + + config =3D virJSONValueObjectGet(info, "config"); + if (!config) + return; + + virCHProcessUpdateConsoleDevice(vm, config, "console"); + virCHProcessUpdateConsoleDevice(vm, config, "serial"); +} + +static int +virCHProcessUpdateInfo(virDomainObj *vm) +{ + virJSONValue *info; + virCHDomainObjPrivate *priv =3D vm->privateData; + if (virCHMonitorGetInfo(priv->monitor, &info) < 0) + return -1; + + virCHProcessUpdateConsole(vm, info); + + virJSONValueFree(info); + + return 0; +} + /** * virCHProcessStart: * @driver: pointer to driver structure --=20 2.31.1