From nobody Sun Apr 28 23:30:39 2024 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 1626327989071712.7493456167123; Wed, 14 Jul 2021 22:46:29 -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-77-h3hieC5qNmycfBjCdeW1YA-1; Thu, 15 Jul 2021 01:46:19 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id ADE74804145; Thu, 15 Jul 2021 05:46:05 +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 8D7A75C232; Thu, 15 Jul 2021 05:46:05 +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 57E7C4EA3D; Thu, 15 Jul 2021 05:46:05 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 16F5jkXp020236 for ; Thu, 15 Jul 2021 01:45:46 -0400 Received: by smtp.corp.redhat.com (Postfix) id 3375E2084829; Thu, 15 Jul 2021 05:45:46 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast05.extmail.prod.ext.rdu2.redhat.com [10.11.55.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 2DCEC2087455 for ; Thu, 15 Jul 2021 05:45:42 +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 96EAC800963 for ; Thu, 15 Jul 2021 05:45:42 +0000 (UTC) Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-196-Z1Za4x1cPPClLTRc1a3BIg-1; Thu, 15 Jul 2021 01:45:40 -0400 Received: from orsmga003.jf.intel.com ([10.7.209.27]) by orsmga103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 14 Jul 2021 22:45:37 -0700 Received: from wdouglas-dev.jf.intel.com (HELO desk.jf.intel.com) ([10.7.200.157]) by orsmga003-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 14 Jul 2021 22:45:37 -0700 X-MC-Unique: h3hieC5qNmycfBjCdeW1YA-1 X-MC-Unique: Z1Za4x1cPPClLTRc1a3BIg-1 X-IronPort-AV: E=McAfee;i="6200,9189,10045"; a="210520206" X-IronPort-AV: E=Sophos;i="5.84,240,1620716400"; d="scan'208";a="210520206" X-IronPort-AV: E=Sophos;i="5.84,240,1620716400"; d="scan'208";a="413534915" From: William Douglas To: libvir-list@redhat.com Subject: [PATCH 1/9] ch_domain: Add virChrdevs for console support Date: Wed, 14 Jul 2021 22:52:30 -0700 Message-Id: <20210715055238.353772-2-william.douglas@intel.com> In-Reply-To: <20210715055238.353772-1-william.douglas@intel.com> References: <20210715055238.353772-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.4 X-loop: libvir-list@redhat.com Cc: mprivozn@redhat.com, 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.16 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 X-ZM-MESSAGEID: 1626327990650100001 Content-Type: text/plain; charset="utf-8" Add and initialize a virChrdevs to the _virCHDomainObjPrivate structure in order to eventually track the consoles in use by a domain. Signed-off-by: William Douglas --- src/ch/ch_domain.c | 7 +++++++ src/ch/ch_domain.h | 3 +++ 2 files changed, 10 insertions(+) diff --git a/src/ch/ch_domain.c b/src/ch/ch_domain.c index 780a46ba00..a6b87e28e5 100644 --- a/src/ch/ch_domain.c +++ b/src/ch/ch_domain.c @@ -22,6 +22,7 @@ =20 #include "ch_domain.h" #include "viralloc.h" +#include "virchrdev.h" #include "virlog.h" #include "virtime.h" =20 @@ -146,6 +147,11 @@ virCHDomainObjPrivateAlloc(void *opaque G_GNUC_UNUSED) return NULL; } =20 + if (!(priv->chrdevs =3D virChrdevAlloc())) { + g_free(priv); + return NULL; + } + return priv; } =20 @@ -154,6 +160,7 @@ virCHDomainObjPrivateFree(void *data) { virCHDomainObjPrivate *priv =3D data; =20 + virChrdevFree(priv->chrdevs); virCHDomainObjFreeJob(priv); g_free(priv); } diff --git a/src/ch/ch_domain.h b/src/ch/ch_domain.h index b4e0d4c212..61b34b0467 100644 --- a/src/ch/ch_domain.h +++ b/src/ch/ch_domain.h @@ -22,6 +22,7 @@ =20 #include "ch_conf.h" #include "ch_monitor.h" +#include "virchrdev.h" =20 /* Give up waiting for mutex after 30 seconds */ #define CH_JOB_WAIT_TIME (1000ull * 30) @@ -52,6 +53,8 @@ struct _virCHDomainObjPrivate { struct virCHDomainJobObj job; =20 virCHMonitor *monitor; + + virChrdevs *chrdevs; }; =20 extern virDomainXMLPrivateDataCallbacks virCHDriverPrivateDataCallbacks; --=20 2.31.1 From nobody Sun Apr 28 23:30:39 2024 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 1626327957086396.5176641923488; Wed, 14 Jul 2021 22:45:57 -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-329-ZbIMap9EO4yhOFHYNRHNOw-1; Thu, 15 Jul 2021 01:45:54 -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 A89581084F57; Thu, 15 Jul 2021 05:45:48 +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 4FE185D9DD; Thu, 15 Jul 2021 05:45:48 +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 797374A702; Thu, 15 Jul 2021 05:45:46 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 16F5jjH4020226 for ; Thu, 15 Jul 2021 01:45:45 -0400 Received: by smtp.corp.redhat.com (Postfix) id 19F65FDCE6; Thu, 15 Jul 2021 05:45:45 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast05.extmail.prod.ext.rdu2.redhat.com [10.11.55.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 158FDFED2C for ; Thu, 15 Jul 2021 05:45:45 +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 F2824800BED for ; Thu, 15 Jul 2021 05:45:44 +0000 (UTC) Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-431-sSEOme2OPuqtCjDxYre-lw-1; Thu, 15 Jul 2021 01:45:41 -0400 Received: from orsmga003.jf.intel.com ([10.7.209.27]) by orsmga103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 14 Jul 2021 22:45:39 -0700 Received: from wdouglas-dev.jf.intel.com (HELO desk.jf.intel.com) ([10.7.200.157]) by orsmga003-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 14 Jul 2021 22:45:39 -0700 X-MC-Unique: ZbIMap9EO4yhOFHYNRHNOw-1 X-MC-Unique: sSEOme2OPuqtCjDxYre-lw-1 X-IronPort-AV: E=McAfee;i="6200,9189,10045"; a="210520209" X-IronPort-AV: E=Sophos;i="5.84,240,1620716400"; d="scan'208";a="210520209" X-IronPort-AV: E=Sophos;i="5.84,240,1620716400"; d="scan'208";a="413534923" From: William Douglas To: libvir-list@redhat.com Subject: [PATCH 2/9] ch_monitor: Make unused function static Date: Wed, 14 Jul 2021 22:52:31 -0700 Message-Id: <20210715055238.353772-3-william.douglas@intel.com> In-Reply-To: <20210715055238.353772-1-william.douglas@intel.com> References: <20210715055238.353772-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.79 on 10.11.54.5 X-loop: libvir-list@redhat.com Cc: mprivozn@redhat.com, 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 X-ZM-MESSAGEID: 1626327959368100001 Content-Type: text/plain; charset="utf-8" The virCHMonitorGet function wasn't in use and was declared as non-static (though not in a header file). This function isn't going to be used outside of the monitor though so remove the initial declaration and define the function to be static. Future work should adjust this function to allow reading VM state needed for PTY enablement. Signed-off-by: William Douglas --- src/ch/ch_monitor.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/ch/ch_monitor.c b/src/ch/ch_monitor.c index 1648d05017..f76bc2b423 100644 --- a/src/ch/ch_monitor.c +++ b/src/ch/ch_monitor.c @@ -54,7 +54,6 @@ VIR_ONCE_GLOBAL_INIT(virCHMonitor); =20 int virCHMonitorShutdownVMM(virCHMonitor *mon); int virCHMonitorPutNoContent(virCHMonitor *mon, const char *endpoint); -int virCHMonitorGet(virCHMonitor *mon, const char *endpoint); =20 static int virCHMonitorBuildCPUJson(virJSONValue *content, virDomainDef *vmdef) @@ -613,7 +612,7 @@ virCHMonitorPutNoContent(virCHMonitor *mon, const char = *endpoint) return ret; } =20 -int +static int virCHMonitorGet(virCHMonitor *mon, const char *endpoint) { g_autofree char *url =3D NULL; --=20 2.31.1 From nobody Sun Apr 28 23:30:39 2024 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 1626327970731473.5665985558122; Wed, 14 Jul 2021 22:46:10 -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-211-8jNZv5bZP6-a296pEKBXJw-1; Thu, 15 Jul 2021 01:46:08 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id BABF01084F55; Thu, 15 Jul 2021 05:46:02 +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 9D6126090F; Thu, 15 Jul 2021 05:46:02 +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 68D4D4EA3C; Thu, 15 Jul 2021 05:46:02 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 16F5jihW020221 for ; Thu, 15 Jul 2021 01:45:44 -0400 Received: by smtp.corp.redhat.com (Postfix) id 8162BFED2A; Thu, 15 Jul 2021 05:45:44 +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 7D083FDCE6 for ; Thu, 15 Jul 2021 05:45:44 +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 661431078461 for ; Thu, 15 Jul 2021 05:45:44 +0000 (UTC) Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-196-t25aKAtHN_KSYk_rC6esrw-2; Thu, 15 Jul 2021 01:45:41 -0400 Received: from orsmga003.jf.intel.com ([10.7.209.27]) by orsmga103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 14 Jul 2021 22:45:40 -0700 Received: from wdouglas-dev.jf.intel.com (HELO desk.jf.intel.com) ([10.7.200.157]) by orsmga003-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 14 Jul 2021 22:45:40 -0700 X-MC-Unique: 8jNZv5bZP6-a296pEKBXJw-1 X-MC-Unique: t25aKAtHN_KSYk_rC6esrw-2 X-IronPort-AV: E=McAfee;i="6200,9189,10045"; a="210520212" X-IronPort-AV: E=Sophos;i="5.84,240,1620716400"; d="scan'208";a="210520212" X-IronPort-AV: E=Sophos;i="5.84,240,1620716400"; d="scan'208";a="413534930" From: William Douglas To: libvir-list@redhat.com Subject: [PATCH 3/9] ch_monitor: Update virCHMonitorGet to handle accept a response Date: Wed, 14 Jul 2021 22:52:32 -0700 Message-Id: <20210715055238.353772-4-william.douglas@intel.com> In-Reply-To: <20210715055238.353772-1-william.douglas@intel.com> References: <20210715055238.353772-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.79 on 10.11.54.5 X-loop: libvir-list@redhat.com Cc: mprivozn@redhat.com, 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.13 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 X-ZM-MESSAGEID: 1626327971785100001 Content-Type: text/plain; charset="utf-8" The virCHMonitorGet function needed to be able to return data from the hypervisor. This functionality is needed in order for the driver to support PTY enablement and getting details about the VM state. Signed-off-by: William Douglas --- src/ch/ch_monitor.c | 44 ++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 42 insertions(+), 2 deletions(-) diff --git a/src/ch/ch_monitor.c b/src/ch/ch_monitor.c index f76bc2b423..228c537c72 100644 --- a/src/ch/ch_monitor.c +++ b/src/ch/ch_monitor.c @@ -612,12 +612,36 @@ virCHMonitorPutNoContent(virCHMonitor *mon, const cha= r *endpoint) return ret; } =20 +struct curl_data { + char *content; + size_t size; +}; + +static size_t +curl_callback(void *contents, size_t size, size_t nmemb, void *userp) +{ + size_t content_size =3D size * nmemb; + struct curl_data *data =3D (struct curl_data *)userp; + + if (content_size =3D=3D 0) + return content_size; + + data->content =3D g_realloc(data->content, data->size + content_size); + + memcpy(&(data->content[data->size]), contents, content_size); + data->size +=3D content_size; + + return content_size; +} + static int -virCHMonitorGet(virCHMonitor *mon, const char *endpoint) +virCHMonitorGet(virCHMonitor *mon, const char *endpoint, virJSONValue **re= sponse) { g_autofree char *url =3D NULL; int responseCode =3D 0; int ret =3D -1; + struct curl_slist *headers =3D NULL; + struct curl_data data =3D {0}; =20 url =3D g_strdup_printf("%s/%s", URL_ROOT, endpoint); =20 @@ -629,12 +653,28 @@ virCHMonitorGet(virCHMonitor *mon, const char *endpoi= nt) curl_easy_setopt(mon->handle, CURLOPT_UNIX_SOCKET_PATH, mon->socketpat= h); curl_easy_setopt(mon->handle, CURLOPT_URL, url); =20 + if (response) { + headers =3D curl_slist_append(headers, "Accept: application/json"); + headers =3D curl_slist_append(headers, "Content-Type: application/= json"); + curl_easy_setopt(mon->handle, CURLOPT_HTTPHEADER, headers); + curl_easy_setopt(mon->handle, CURLOPT_WRITEFUNCTION, curl_callback= ); + curl_easy_setopt(mon->handle, CURLOPT_WRITEDATA, (void *)&data); + } + responseCode =3D virCHMonitorCurlPerform(mon->handle); =20 virObjectUnlock(mon); =20 - if (responseCode =3D=3D 200 || responseCode =3D=3D 204) + if (responseCode =3D=3D 200 || responseCode =3D=3D 204) { ret =3D 0; + if (response) { + data.content =3D g_realloc(data.content, data.size + 1); + data.content[data.size] =3D 0; + *response =3D virJSONValueFromString(data.content); + } + } + + g_free(data.content); =20 return ret; } --=20 2.31.1 From nobody Sun Apr 28 23:30:39 2024 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 1626327963264241.38741806685584; Wed, 14 Jul 2021 22:46:03 -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-230-HWi9bt-jOWaDLYeFJtdVBg-1; Thu, 15 Jul 2021 01:45:53 -0400 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id D105F804142; Thu, 15 Jul 2021 05:45:48 +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 835B9100F49F; Thu, 15 Jul 2021 05:45:48 +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 D901C4E9F4; Thu, 15 Jul 2021 05:45:46 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 16F5jjVJ020228 for ; Thu, 15 Jul 2021 01:45:45 -0400 Received: by smtp.corp.redhat.com (Postfix) id 4C1F6FDCFD; Thu, 15 Jul 2021 05:45:45 +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 47C5AFED2B for ; Thu, 15 Jul 2021 05:45:45 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-2.mimecast.com [207.211.31.81]) (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 31364866DF4 for ; Thu, 15 Jul 2021 05:45:45 +0000 (UTC) Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-431-x2FT5bPhP7KAp9o9_J-vIA-2; Thu, 15 Jul 2021 01:45:42 -0400 Received: from orsmga003.jf.intel.com ([10.7.209.27]) by orsmga103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 14 Jul 2021 22:45:41 -0700 Received: from wdouglas-dev.jf.intel.com (HELO desk.jf.intel.com) ([10.7.200.157]) by orsmga003-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 14 Jul 2021 22:45:41 -0700 X-MC-Unique: HWi9bt-jOWaDLYeFJtdVBg-1 X-MC-Unique: x2FT5bPhP7KAp9o9_J-vIA-2 X-IronPort-AV: E=McAfee;i="6200,9189,10045"; a="210520213" X-IronPort-AV: E=Sophos;i="5.84,240,1620716400"; d="scan'208";a="210520213" X-IronPort-AV: E=Sophos;i="5.84,240,1620716400"; d="scan'208";a="413534934" From: William Douglas To: libvir-list@redhat.com Subject: [PATCH 4/9] ch_monitor: Use virCHMonitorGet to access cloud-hypervisor API Date: Wed, 14 Jul 2021 22:52:33 -0700 Message-Id: <20210715055238.353772-5-william.douglas@intel.com> In-Reply-To: <20210715055238.353772-1-william.douglas@intel.com> References: <20210715055238.353772-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.79 on 10.11.54.5 X-loop: libvir-list@redhat.com Cc: mprivozn@redhat.com, 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.84 on 10.5.11.22 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 X-ZM-MESSAGEID: 1626327965561100001 Content-Type: text/plain; charset="utf-8" Now that virCHMonitorGet is capable of handling data returned by the cloud-hypervisor API, make use of this via virCHMonitorGetInfo to call into the vm.info endpoint. Signed-off-by: William Douglas --- src/ch/ch_monitor.c | 15 +++++++++++++++ src/ch/ch_monitor.h | 3 +++ 2 files changed, 18 insertions(+) diff --git a/src/ch/ch_monitor.c b/src/ch/ch_monitor.c index 228c537c72..10c52ad6a8 100644 --- a/src/ch/ch_monitor.c +++ b/src/ch/ch_monitor.c @@ -752,3 +752,18 @@ virCHMonitorResumeVM(virCHMonitor *mon) { return virCHMonitorPutNoContent(mon, URL_VM_RESUME); } + +/** + * virCHMonitorGetInfo: + * @mon: Pointer to the monitor + * @info: Get VM info + * + * Retrive the VM info and store in @info + * + * Returns 0 on success. + */ +int +virCHMonitorGetInfo(virCHMonitor *mon, virJSONValue **info) +{ + return virCHMonitorGet(mon, URL_VM_INFO, info); +} diff --git a/src/ch/ch_monitor.h b/src/ch/ch_monitor.h index e717e11cbc..e39b4eb8b2 100644 --- a/src/ch/ch_monitor.h +++ b/src/ch/ch_monitor.h @@ -23,6 +23,7 @@ #include =20 #include "virobject.h" +#include "virjson.h" #include "domain_conf.h" =20 #define URL_ROOT "http://localhost/api/v1" @@ -34,6 +35,7 @@ #define URL_VM_REBOOT "vm.reboot" #define URL_VM_Suspend "vm.pause" #define URL_VM_RESUME "vm.resume" +#define URL_VM_INFO "vm.info" =20 typedef struct _virCHMonitor virCHMonitor; =20 @@ -58,3 +60,4 @@ int virCHMonitorShutdownVM(virCHMonitor *mon); int virCHMonitorRebootVM(virCHMonitor *mon); int virCHMonitorSuspendVM(virCHMonitor *mon); int virCHMonitorResumeVM(virCHMonitor *mon); +int virCHMonitorGetInfo(virCHMonitor *mon, virJSONValue **info); --=20 2.31.1 From nobody Sun Apr 28 23:30:39 2024 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 1626327971764164.99831372950086; Wed, 14 Jul 2021 22:46:11 -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-592-OoJDs4zVPGS_FxnFH9ivzg-1; Thu, 15 Jul 2021 01:46:09 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 49AF2100B3B5; Thu, 15 Jul 2021 05:46:04 +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 2875960C04; Thu, 15 Jul 2021 05:46:04 +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 E7B4A1809CB2; Thu, 15 Jul 2021 05:46:03 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 16F5jnZ1020259 for ; Thu, 15 Jul 2021 01:45:49 -0400 Received: by smtp.corp.redhat.com (Postfix) id 71203208484F; Thu, 15 Jul 2021 05:45:49 +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 6CD932084848 for ; Thu, 15 Jul 2021 05:45: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 55D3D1078462 for ; Thu, 15 Jul 2021 05:45:49 +0000 (UTC) Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-431-7ziJUVnuP5mSolyZP0A5Ug-3; Thu, 15 Jul 2021 01:45:45 -0400 Received: from orsmga003.jf.intel.com ([10.7.209.27]) by orsmga103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 14 Jul 2021 22:45:44 -0700 Received: from wdouglas-dev.jf.intel.com (HELO desk.jf.intel.com) ([10.7.200.157]) by orsmga003-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 14 Jul 2021 22:45:44 -0700 X-MC-Unique: OoJDs4zVPGS_FxnFH9ivzg-1 X-MC-Unique: 7ziJUVnuP5mSolyZP0A5Ug-3 X-IronPort-AV: E=McAfee;i="6200,9189,10045"; a="210520219" X-IronPort-AV: E=Sophos;i="5.84,240,1620716400"; d="scan'208";a="210520219" X-IronPort-AV: E=Sophos;i="5.84,240,1620716400"; d="scan'208";a="413534937" From: William Douglas To: libvir-list@redhat.com Subject: [PATCH 5/9] ch_monitor: Add pty json builder function Date: Wed, 14 Jul 2021 22:52:34 -0700 Message-Id: <20210715055238.353772-6-william.douglas@intel.com> In-Reply-To: <20210715055238.353772-1-william.douglas@intel.com> References: <20210715055238.353772-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.4 X-loop: libvir-list@redhat.com Cc: mprivozn@redhat.com, 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.12 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 X-ZM-MESSAGEID: 1626327974095100001 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. The devices themselves still aren't allowed in configurations yet though. Signed-off-by: William Douglas --- src/ch/ch_monitor.c | 56 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) diff --git a/src/ch/ch_monitor.c b/src/ch/ch_monitor.c index 10c52ad6a8..2a36324d49 100644 --- a/src/ch/ch_monitor.c +++ b/src/ch/ch_monitor.c @@ -89,6 +89,59 @@ virCHMonitorBuildCPUJson(virJSONValue *content, virDomai= nDef *vmdef) return -1; } =20 +static int +virCHMonitorBuildPTYJson(virJSONValue *content, virDomainDef *vmdef) +{ + virJSONValue *ptys =3D virJSONValueNewObject(); + + if ((vmdef->nconsoles && + vmdef->consoles[0]->source->type =3D=3D VIR_DOMAIN_CHR_TYPE_PTY) + && (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 configure= d for this domain")); + return -1; + } else if (vmdef->nconsoles > 1) { + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("Only a single console can be configured for this= domain")); + return -1; + } else if (vmdef->nserials > 1) { + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("Only a single serial can be configured for this = domain")); + return -1; + } + + if (vmdef->nconsoles) { + g_autoptr(virJSONValue) pty =3D virJSONValueNewObject(); + if (vmdef->consoles[0]->source->type =3D=3D VIR_DOMAIN_CHR_TYPE_PT= Y) { + if (virJSONValueObjectAppendString(pty, "mode", "Pty") < 0) + return -1; + if (virJSONValueObjectAppend(content, "console", &pty) < 0) + return -1; + } else { + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("Console can only be enabled for a PTY")); + return -1; + } + } + + if (vmdef->nserials) { + g_autoptr(virJSONValue) pty =3D virJSONValueNewObject(); + if (vmdef->serials[0]->source->type =3D=3D VIR_DOMAIN_CHR_TYPE_PTY= ) { + if (virJSONValueObjectAppendString(ptys, "mode", "Pty") < 0) + return -1; + if (virJSONValueObjectAppend(content, "serial", &pty) < 0) + return -1; + } else { + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("Serial can only be enabled for a PTY")); + return -1; + } + } + + return 0; +} + static int virCHMonitorBuildKernelRelatedJson(virJSONValue *content, virDomainDef *vm= def) { @@ -370,6 +423,9 @@ virCHMonitorBuildVMJson(virDomainDef *vmdef, char **jso= nstr) goto cleanup; } =20 + if (virCHMonitorBuildPTYJson(content, vmdef) < 0) + goto cleanup; + if (virCHMonitorBuildCPUJson(content, vmdef) < 0) goto cleanup; =20 --=20 2.31.1 From nobody Sun Apr 28 23:30:39 2024 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 1626327977186157.2369792619944; Wed, 14 Jul 2021 22:46:17 -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-167-1zQpJ4GENTCvMwgcMK-APw-1; Thu, 15 Jul 2021 01:46:14 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 8F710804309; Thu, 15 Jul 2021 05:46:08 +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 6E3C060C04; Thu, 15 Jul 2021 05:46:08 +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 3B8694EA40; Thu, 15 Jul 2021 05:46:08 +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 16F5jvOU020312 for ; Thu, 15 Jul 2021 01:45:58 -0400 Received: by smtp.corp.redhat.com (Postfix) id DF0E020D698C; Thu, 15 Jul 2021 05:45:57 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast06.extmail.prod.ext.rdu2.redhat.com [10.11.55.22]) by smtp.corp.redhat.com (Postfix) with ESMTPS id DA77420D698B for ; Thu, 15 Jul 2021 05:45:55 +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 0DE66185A794 for ; Thu, 15 Jul 2021 05:45:55 +0000 (UTC) Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-431-PR-N7S9fPH6gzb2TfGQerQ-4; Thu, 15 Jul 2021 01:45:52 -0400 Received: from orsmga003.jf.intel.com ([10.7.209.27]) by orsmga103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 14 Jul 2021 22:45:45 -0700 Received: from wdouglas-dev.jf.intel.com (HELO desk.jf.intel.com) ([10.7.200.157]) by orsmga003-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 14 Jul 2021 22:45:45 -0700 X-MC-Unique: 1zQpJ4GENTCvMwgcMK-APw-1 X-MC-Unique: PR-N7S9fPH6gzb2TfGQerQ-4 X-IronPort-AV: E=McAfee;i="6200,9189,10045"; a="210520221" X-IronPort-AV: E=Sophos;i="5.84,240,1620716400"; d="scan'208";a="210520221" X-IronPort-AV: E=Sophos;i="5.84,240,1620716400"; d="scan'208";a="413534943" From: William Douglas To: libvir-list@redhat.com Subject: [PATCH 6/9] ch_process: Handle enabled console devices Date: Wed, 14 Jul 2021 22:52:35 -0700 Message-Id: <20210715055238.353772-7-william.douglas@intel.com> In-Reply-To: <20210715055238.353772-1-william.douglas@intel.com> References: <20210715055238.353772-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: mprivozn@redhat.com, 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.12 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 X-ZM-MESSAGEID: 1626327978281100001 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 From nobody Sun Apr 28 23:30:39 2024 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 1626327982426211.12702894067365; Wed, 14 Jul 2021 22:46:22 -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-204-d1EZx1-PMPiiOks-GxwJTg-1; Thu, 15 Jul 2021 01:46:19 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id A3B1D1084F60; Thu, 15 Jul 2021 05:46:13 +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 8332B5C22A; Thu, 15 Jul 2021 05:46:13 +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 4F2754EA45; Thu, 15 Jul 2021 05:46:13 +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 16F5jwnu020313 for ; Thu, 15 Jul 2021 01:45:58 -0400 Received: by smtp.corp.redhat.com (Postfix) id 3858A10166CD; Thu, 15 Jul 2021 05:45:58 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast03.extmail.prod.ext.rdu2.redhat.com [10.11.55.19]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 340F81013138 for ; Thu, 15 Jul 2021 05:45:55 +0000 (UTC) Received: from us-smtp-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 B438F800FFB for ; Thu, 15 Jul 2021 05:45:55 +0000 (UTC) Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-398-_NrnY9IUPEO6-Utt7dWNUw-1; Thu, 15 Jul 2021 01:45:53 -0400 Received: from orsmga003.jf.intel.com ([10.7.209.27]) by orsmga103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 14 Jul 2021 22:45:52 -0700 Received: from wdouglas-dev.jf.intel.com (HELO desk.jf.intel.com) ([10.7.200.157]) by orsmga003-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 14 Jul 2021 22:45:47 -0700 X-MC-Unique: d1EZx1-PMPiiOks-GxwJTg-1 X-MC-Unique: _NrnY9IUPEO6-Utt7dWNUw-1 X-IronPort-AV: E=McAfee;i="6200,9189,10045"; a="210520222" X-IronPort-AV: E=Sophos;i="5.84,240,1620716400"; d="scan'208";a="210520222" X-IronPort-AV: E=Sophos;i="5.84,240,1620716400"; d="scan'208";a="413534949" From: William Douglas To: libvir-list@redhat.com Subject: [PATCH 7/9] ch_process: Update the domain with console path information Date: Wed, 14 Jul 2021 22:52:36 -0700 Message-Id: <20210715055238.353772-8-william.douglas@intel.com> In-Reply-To: <20210715055238.353772-1-william.douglas@intel.com> References: <20210715055238.353772-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: mprivozn@redhat.com, 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.16 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 X-ZM-MESSAGEID: 1626327984427100001 Content-Type: text/plain; charset="utf-8" Add call to update the domain with console path information from cloud-hypervisor as part of the last stages of initializing the domain. Signed-off-by: William Douglas --- src/ch/ch_process.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/ch/ch_process.c b/src/ch/ch_process.c index 90344f14ea..f6ae1677fd 100644 --- a/src/ch/ch_process.c +++ b/src/ch/ch_process.c @@ -156,6 +156,9 @@ int virCHProcessStart(virCHDriver *driver, =20 vm->pid =3D priv->monitor->pid; vm->def->id =3D vm->pid; + + virCHProcessUpdateInfo(vm); + virDomainObjSetState(vm, VIR_DOMAIN_RUNNING, reason); =20 return 0; --=20 2.31.1 From nobody Sun Apr 28 23:30:39 2024 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 162632798056533.12894185982816; Wed, 14 Jul 2021 22:46:20 -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-308-zd_WURevPn6_TjAB_PXkzw-1; Thu, 15 Jul 2021 01:46:17 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id E0D0E1084F5C; Thu, 15 Jul 2021 05:46:10 +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 C3C4819CBA; Thu, 15 Jul 2021 05:46:10 +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 90CF74EA42; Thu, 15 Jul 2021 05:46:10 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 16F5juXS020302 for ; Thu, 15 Jul 2021 01:45:56 -0400 Received: by smtp.corp.redhat.com (Postfix) id 2BCE72084829; Thu, 15 Jul 2021 05:45:56 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast05.extmail.prod.ext.rdu2.redhat.com [10.11.55.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 26A262084828 for ; Thu, 15 Jul 2021 05:45:56 +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 0F31B802A5E for ; Thu, 15 Jul 2021 05:45:56 +0000 (UTC) Received: from mga07.intel.com (mga07.intel.com [134.134.136.100]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-487-A6guBpL_PjGWzAKIQ3Yw5w-2; Thu, 15 Jul 2021 01:45:51 -0400 Received: from orsmga003.jf.intel.com ([10.7.209.27]) by orsmga105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 14 Jul 2021 22:45:48 -0700 Received: from wdouglas-dev.jf.intel.com (HELO desk.jf.intel.com) ([10.7.200.157]) by orsmga003-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 14 Jul 2021 22:45:48 -0700 X-MC-Unique: zd_WURevPn6_TjAB_PXkzw-1 X-MC-Unique: A6guBpL_PjGWzAKIQ3Yw5w-2 X-IronPort-AV: E=McAfee;i="6200,9189,10045"; a="274305631" X-IronPort-AV: E=Sophos;i="5.84,240,1620716400"; d="scan'208";a="274305631" X-IronPort-AV: E=Sophos;i="5.84,240,1620716400"; d="scan'208";a="413534955" From: William Douglas To: libvir-list@redhat.com Subject: [PATCH 8/9] ch_domain: Allow controller and chr devices Date: Wed, 14 Jul 2021 22:52:37 -0700 Message-Id: <20210715055238.353772-9-william.douglas@intel.com> In-Reply-To: <20210715055238.353772-1-william.douglas@intel.com> References: <20210715055238.353772-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.4 X-loop: libvir-list@redhat.com Cc: mprivozn@redhat.com, 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.11 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 X-ZM-MESSAGEID: 1626327982320100001 Content-Type: text/plain; charset="utf-8" With the console and serial device handling fully functional, allow the required device types to be specified in the domain configuration. Signed-off-by: William Douglas --- src/ch/ch_domain.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/ch/ch_domain.c b/src/ch/ch_domain.c index a6b87e28e5..89a8ad8f45 100644 --- a/src/ch/ch_domain.c +++ b/src/ch/ch_domain.c @@ -215,6 +215,8 @@ chValidateDomainDeviceDef(const virDomainDeviceDef *dev, case VIR_DOMAIN_DEVICE_NET: case VIR_DOMAIN_DEVICE_MEMORY: case VIR_DOMAIN_DEVICE_VSOCK: + case VIR_DOMAIN_DEVICE_CONTROLLER: + case VIR_DOMAIN_DEVICE_CHR: break; =20 case VIR_DOMAIN_DEVICE_LEASE: @@ -224,12 +226,10 @@ chValidateDomainDeviceDef(const virDomainDeviceDef *d= ev, case VIR_DOMAIN_DEVICE_VIDEO: case VIR_DOMAIN_DEVICE_HOSTDEV: case VIR_DOMAIN_DEVICE_WATCHDOG: - case VIR_DOMAIN_DEVICE_CONTROLLER: case VIR_DOMAIN_DEVICE_GRAPHICS: case VIR_DOMAIN_DEVICE_HUB: case VIR_DOMAIN_DEVICE_REDIRDEV: case VIR_DOMAIN_DEVICE_SMARTCARD: - case VIR_DOMAIN_DEVICE_CHR: case VIR_DOMAIN_DEVICE_MEMBALLOON: case VIR_DOMAIN_DEVICE_NVRAM: case VIR_DOMAIN_DEVICE_RNG: --=20 2.31.1 From nobody Sun Apr 28 23:30:39 2024 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 1626327974955335.4139773093415; Wed, 14 Jul 2021 22:46:14 -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-384-W_OumE9INTCegzlaxqV_WQ-1; Thu, 15 Jul 2021 01:46:12 -0400 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 654B5804142; Thu, 15 Jul 2021 05:46:07 +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 3BB3A10016F5; Thu, 15 Jul 2021 05:46:07 +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 058A51809CB6; Thu, 15 Jul 2021 05:46:07 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 16F5jqiQ020275 for ; Thu, 15 Jul 2021 01:45:53 -0400 Received: by smtp.corp.redhat.com (Postfix) id D764BFDCFD; Thu, 15 Jul 2021 05:45:52 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast05.extmail.prod.ext.rdu2.redhat.com [10.11.55.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id D22F0FED2C for ; Thu, 15 Jul 2021 05:45:52 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-1.mimecast.com [207.211.31.81]) (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 B97CD800BED for ; Thu, 15 Jul 2021 05:45:52 +0000 (UTC) Received: from mga07.intel.com (mga07.intel.com [134.134.136.100]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-487-EJomhE6AN6uIEXdv0mvryA-1; Thu, 15 Jul 2021 01:45:50 -0400 Received: from orsmga003.jf.intel.com ([10.7.209.27]) by orsmga105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 14 Jul 2021 22:45:49 -0700 Received: from wdouglas-dev.jf.intel.com (HELO desk.jf.intel.com) ([10.7.200.157]) by orsmga003-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 14 Jul 2021 22:45:49 -0700 X-MC-Unique: W_OumE9INTCegzlaxqV_WQ-1 X-MC-Unique: EJomhE6AN6uIEXdv0mvryA-1 X-IronPort-AV: E=McAfee;i="6200,9189,10045"; a="274305632" X-IronPort-AV: E=Sophos;i="5.84,240,1620716400"; d="scan'208";a="274305632" X-IronPort-AV: E=Sophos;i="5.84,240,1620716400"; d="scan'208";a="413534960" From: William Douglas To: libvir-list@redhat.com Subject: [PATCH 9/9] ch_driver: Add handler for console API Date: Wed, 14 Jul 2021 22:52:38 -0700 Message-Id: <20210715055238.353772-10-william.douglas@intel.com> In-Reply-To: <20210715055238.353772-1-william.douglas@intel.com> References: <20210715055238.353772-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.79 on 10.11.54.5 X-loop: libvir-list@redhat.com Cc: mprivozn@redhat.com, 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.84 on 10.5.11.22 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 X-ZM-MESSAGEID: 1626327976124100003 Content-Type: text/plain; charset="utf-8" Enable the handler function to find and open the console character device that will be used by the console API. Signed-off-by: William Douglas --- src/ch/ch_driver.c | 78 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 78 insertions(+) diff --git a/src/ch/ch_driver.c b/src/ch/ch_driver.c index ac958d73a8..a11357f83a 100644 --- a/src/ch/ch_driver.c +++ b/src/ch/ch_driver.c @@ -30,6 +30,7 @@ #include "viraccessapicheck.h" #include "viralloc.h" #include "virbuffer.h" +#include "virchrdev.h" #include "vircommand.h" #include "virerror.h" #include "virfile.h" @@ -816,6 +817,82 @@ static int chDomainGetInfo(virDomainPtr dom, return ret; } =20 +static int +chDomainOpenConsole(virDomainPtr dom, + const char *dev_name, + virStreamPtr st, + unsigned int flags) +{ + virDomainObj *vm =3D NULL; + int ret =3D -1; + size_t i; + virDomainChrDef *chr =3D NULL; + virCHDomainObjPrivate *priv; + + virCheckFlags(VIR_DOMAIN_CONSOLE_SAFE | VIR_DOMAIN_CONSOLE_FORCE, -1); + + if (!(vm =3D chDomObjFromDomain(dom))) + goto cleanup; + + if (virDomainOpenConsoleEnsureACL(dom->conn, vm->def) < 0) + goto cleanup; + + if (virDomainObjCheckActive(vm) < 0) + goto cleanup; + + priv =3D vm->privateData; + + if (dev_name) { + for (i =3D 0; !chr && i < vm->def->nconsoles; i++) { + if (vm->def->consoles[i]->info.alias && + STREQ(dev_name, vm->def->consoles[i]->info.alias)) + chr =3D vm->def->consoles[i]; + } + for (i =3D 0; !chr && i < vm->def->nserials; i++) { + if (STREQ(dev_name, vm->def->serials[i]->info.alias)) + chr =3D vm->def->serials[i]; + } + for (i =3D 0; !chr && i < vm->def->nparallels; i++) { + if (STREQ(dev_name, vm->def->parallels[i]->info.alias)) + chr =3D vm->def->parallels[i]; + } + } else { + if (vm->def->nconsoles && + vm->def->consoles[0]->source->type =3D=3D VIR_DOMAIN_CHR_TYP= E_PTY) + chr =3D vm->def->consoles[0]; + else if (vm->def->nserials && + vm->def->serials[0]->source->type =3D=3D VIR_DOMAIN_CHR= _TYPE_PTY) + chr =3D vm->def->serials[0]; + } + + if (!chr) { + virReportError(VIR_ERR_INTERNAL_ERROR, _("cannot find character = device %s"), + NULLSTR(dev_name)); + goto cleanup; + } + + if (chr->source->type !=3D VIR_DOMAIN_CHR_TYPE_PTY) { + virReportError(VIR_ERR_INTERNAL_ERROR, + _("character device %s is not using a PTY"), + dev_name ? dev_name : NULLSTR(chr->info.alias)); + goto cleanup; + } + + /* handle mutually exclusive access to console devices */ + ret =3D virChrdevOpen(priv->chrdevs, chr->source, st, + (flags & VIR_DOMAIN_CONSOLE_FORCE) !=3D 0); + + if (ret =3D=3D 1) { + virReportError(VIR_ERR_OPERATION_FAILED, "%s", + _("Active console session exists for this domain"= )); + ret =3D -1; + } + + cleanup: + virDomainObjEndAPI(&vm); + return ret; +} + static int chStateCleanup(void) { if (ch_driver =3D=3D NULL) @@ -913,6 +990,7 @@ static virHypervisorDriver chHypervisorDriver =3D { .domainGetXMLDesc =3D chDomainGetXMLDesc, /* 7.5.0 */ .domainGetInfo =3D chDomainGetInfo, /* 7.5.0 */ .domainIsActive =3D chDomainIsActive, /* 7.5.0 */ + .domainOpenConsole =3D chDomainOpenConsole, /* 7.6.0 */ .nodeGetInfo =3D chNodeGetInfo, /* 7.5.0 */ }; =20 --=20 2.31.1