From nobody Sat May 4 16:38: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 1630014822954487.12617203033835; Thu, 26 Aug 2021 14:53:42 -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-214-w7_fzY7dNne0caCUXFUSJg-1; Thu, 26 Aug 2021 17:53:40 -0400 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 1EFBB800EB8; Thu, 26 Aug 2021 21:53:35 +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 D3C342854F; Thu, 26 Aug 2021 21:53:34 +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 A29774A707; Thu, 26 Aug 2021 21:53:34 +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 17QLrG0w011764 for ; Thu, 26 Aug 2021 17:53:17 -0400 Received: by smtp.corp.redhat.com (Postfix) id CC06414193D; Thu, 26 Aug 2021 21:53:16 +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 C4D5C121134 for ; Thu, 26 Aug 2021 21:53:13 +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 C8A4518A01A0 for ; Thu, 26 Aug 2021 21:53:13 +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-376-2Mv9dC_LPa6gX0iImoTAew-2; Thu, 26 Aug 2021 17:53:11 -0400 Received: from orsmga007.jf.intel.com ([10.7.209.58]) by orsmga105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 26 Aug 2021 14:52:01 -0700 Received: from wdouglas-dev.jf.intel.com (HELO desk.jf.intel.com) ([10.7.200.157]) by orsmga007-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 26 Aug 2021 14:51:58 -0700 X-MC-Unique: w7_fzY7dNne0caCUXFUSJg-1 X-MC-Unique: 2Mv9dC_LPa6gX0iImoTAew-2 X-IronPort-AV: E=McAfee;i="6200,9189,10088"; a="281568206" X-IronPort-AV: E=Sophos;i="5.84,354,1620716400"; d="scan'208";a="281568206" X-IronPort-AV: E=Sophos;i="5.84,354,1620716400"; d="scan'208";a="465266018" From: William Douglas To: libvir-list@redhat.com Subject: [PATCH 1/8] ch_domain: Add virChrdevs for console support Date: Thu, 26 Aug 2021 14:59:15 -0700 Message-Id: <20210826215922.703741-2-william.douglas@intel.com> In-Reply-To: <20210826215922.703741-1-william.douglas@intel.com> References: <20210826215922.703741-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.23 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: 1630014824218100002 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 Sat May 4 16:38: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 1630014810055894.5418537969222; Thu, 26 Aug 2021 14:53:30 -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-447-n9IP4J-ZNi-HroGS6NEmxw-1; Thu, 26 Aug 2021 17:53:27 -0400 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 1315E871803; Thu, 26 Aug 2021 21:53:22 +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 9F5283CC7; Thu, 26 Aug 2021 21:53:20 +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 95DAC4BB7C; Thu, 26 Aug 2021 21:53:16 +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 17QLrDkM011751 for ; Thu, 26 Aug 2021 17:53:14 -0400 Received: by smtp.corp.redhat.com (Postfix) id 782492097D79; Thu, 26 Aug 2021 21:53:13 +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 731482097D77 for ; Thu, 26 Aug 2021 21:53:08 +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 CBD2318A01A9 for ; Thu, 26 Aug 2021 21:53:08 +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-376-0fj_YalfNwqBXlgRsrS_2Q-1; Thu, 26 Aug 2021 17:53:06 -0400 Received: from orsmga007.jf.intel.com ([10.7.209.58]) by orsmga105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 26 Aug 2021 14:52:01 -0700 Received: from wdouglas-dev.jf.intel.com (HELO desk.jf.intel.com) ([10.7.200.157]) by orsmga007-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 26 Aug 2021 14:51:58 -0700 X-MC-Unique: n9IP4J-ZNi-HroGS6NEmxw-1 X-MC-Unique: 0fj_YalfNwqBXlgRsrS_2Q-1 X-IronPort-AV: E=McAfee;i="6200,9189,10088"; a="281568207" X-IronPort-AV: E=Sophos;i="5.84,354,1620716400"; d="scan'208";a="281568207" X-IronPort-AV: E=Sophos;i="5.84,354,1620716400"; d="scan'208";a="465266021" From: William Douglas To: libvir-list@redhat.com Subject: [PATCH 2/8] ch_monitor: Make unused function static Date: Thu, 26 Aug 2021 14:59:16 -0700 Message-Id: <20210826215922.703741-3-william.douglas@intel.com> In-Reply-To: <20210826215922.703741-1-william.douglas@intel.com> References: <20210826215922.703741-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.84 on 10.5.11.23 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: 1630014811641100003 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 0f8752d1ed..b4bc10bfcf 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) @@ -612,7 +611,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 Sat May 4 16:38: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 1630014829397608.6029368156627; Thu, 26 Aug 2021 14:53:49 -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-313-Hp6lmxd5M22tqhI6roy3hw-1; Thu, 26 Aug 2021 17:53:46 -0400 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 44ED61853031; Thu, 26 Aug 2021 21:53:41 +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 1E1D72854E; Thu, 26 Aug 2021 21:53:41 +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 E1E5A4A70D; Thu, 26 Aug 2021 21:53:40 +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 17QLrJLo011786 for ; Thu, 26 Aug 2021 17:53:19 -0400 Received: by smtp.corp.redhat.com (Postfix) id 1AEAA10A1435; Thu, 26 Aug 2021 21:53:19 +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 165C410A7E3E for ; Thu, 26 Aug 2021 21:53:16 +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 5353B800B28 for ; Thu, 26 Aug 2021 21:53:16 +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-376-tfr1D5EGM1Kf7scgmi-TIQ-4; Thu, 26 Aug 2021 17:53:14 -0400 Received: from orsmga007.jf.intel.com ([10.7.209.58]) by orsmga105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 26 Aug 2021 14:52:01 -0700 Received: from wdouglas-dev.jf.intel.com (HELO desk.jf.intel.com) ([10.7.200.157]) by orsmga007-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 26 Aug 2021 14:51:58 -0700 X-MC-Unique: Hp6lmxd5M22tqhI6roy3hw-1 X-MC-Unique: tfr1D5EGM1Kf7scgmi-TIQ-4 X-IronPort-AV: E=McAfee;i="6200,9189,10088"; a="281568209" X-IronPort-AV: E=Sophos;i="5.84,354,1620716400"; d="scan'208";a="281568209" X-IronPort-AV: E=Sophos;i="5.84,354,1620716400"; d="scan'208";a="465266025" From: William Douglas To: libvir-list@redhat.com Subject: [PATCH 3/8] ch_monitor: Update virCHMonitorGet to handle accept a response Date: Thu, 26 Aug 2021 14:59:17 -0700 Message-Id: <20210826215922.703741-4-william.douglas@intel.com> In-Reply-To: <20210826215922.703741-1-william.douglas@intel.com> References: <20210826215922.703741-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.84 on 10.5.11.23 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: 1630014830342100015 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 b4bc10bfcf..ee7e4683e3 100644 --- a/src/ch/ch_monitor.c +++ b/src/ch/ch_monitor.c @@ -611,12 +611,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 @@ -628,12 +652,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 Sat May 4 16:38: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 1630014825626688.3843618591835; Thu, 26 Aug 2021 14:53:45 -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-400-j2KtPZ1TP1udUFblN-qMww-1; Thu, 26 Aug 2021 17:53:42 -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 E52CA1082921; Thu, 26 Aug 2021 21:53:37 +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 C9C15604CC; Thu, 26 Aug 2021 21:53:37 +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 99827181A2AC; Thu, 26 Aug 2021 21:53:37 +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 17QLrIjU011776 for ; Thu, 26 Aug 2021 17:53:18 -0400 Received: by smtp.corp.redhat.com (Postfix) id 3BB1614193D; Thu, 26 Aug 2021 21:53:18 +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 368D8141939 for ; Thu, 26 Aug 2021 21:53:18 +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 1EA0F185A7A4 for ; Thu, 26 Aug 2021 21:53:18 +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-376-EqHCE92vPzCm0RY3FsXcVw-5; Thu, 26 Aug 2021 17:53:16 -0400 Received: from orsmga007.jf.intel.com ([10.7.209.58]) by orsmga105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 26 Aug 2021 14:52:01 -0700 Received: from wdouglas-dev.jf.intel.com (HELO desk.jf.intel.com) ([10.7.200.157]) by orsmga007-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 26 Aug 2021 14:51:58 -0700 X-MC-Unique: j2KtPZ1TP1udUFblN-qMww-1 X-MC-Unique: EqHCE92vPzCm0RY3FsXcVw-5 X-IronPort-AV: E=McAfee;i="6200,9189,10088"; a="281568213" X-IronPort-AV: E=Sophos;i="5.84,354,1620716400"; d="scan'208";a="281568213" X-IronPort-AV: E=Sophos;i="5.84,354,1620716400"; d="scan'208";a="465266028" From: William Douglas To: libvir-list@redhat.com Subject: [PATCH 4/8] ch_monitor: Use virCHMonitorGet to access cloud-hypervisor API Date: Thu, 26 Aug 2021 14:59:18 -0700 Message-Id: <20210826215922.703741-5-william.douglas@intel.com> In-Reply-To: <20210826215922.703741-1-william.douglas@intel.com> References: <20210826215922.703741-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.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: 1630014826109100007 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 ee7e4683e3..28d1c213cc 100644 --- a/src/ch/ch_monitor.c +++ b/src/ch/ch_monitor.c @@ -751,3 +751,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 Sat May 4 16:38: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 1630014811464759.7784143584462; Thu, 26 Aug 2021 14:53:31 -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-291---86KUK8MIGfDUBkCprJ-Q-1; Thu, 26 Aug 2021 17:53:29 -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 3C00F1853027; Thu, 26 Aug 2021 21:53:24 +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 1FFA710016F4; Thu, 26 Aug 2021 21:53:24 +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 E534B4A7CB; Thu, 26 Aug 2021 21:53:23 +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 17QLrJp9011787 for ; Thu, 26 Aug 2021 17:53:19 -0400 Received: by smtp.corp.redhat.com (Postfix) id 481A820A8466; Thu, 26 Aug 2021 21:53:19 +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 42EFA20A8463 for ; Thu, 26 Aug 2021 21:53:19 +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 1F78918A01A5 for ; Thu, 26 Aug 2021 21:53:19 +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-376-gjq-4KL0M-KmOSzjLn4IGw-6; Thu, 26 Aug 2021 17:53:17 -0400 Received: from orsmga007.jf.intel.com ([10.7.209.58]) by orsmga105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 26 Aug 2021 14:52:01 -0700 Received: from wdouglas-dev.jf.intel.com (HELO desk.jf.intel.com) ([10.7.200.157]) by orsmga007-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 26 Aug 2021 14:51:58 -0700 X-MC-Unique: --86KUK8MIGfDUBkCprJ-Q-1 X-MC-Unique: gjq-4KL0M-KmOSzjLn4IGw-6 X-IronPort-AV: E=McAfee;i="6200,9189,10088"; a="281568215" X-IronPort-AV: E=Sophos;i="5.84,354,1620716400"; d="scan'208";a="281568215" X-IronPort-AV: E=Sophos;i="5.84,354,1620716400"; d="scan'208";a="465266032" From: William Douglas To: libvir-list@redhat.com Subject: [PATCH 5/8] ch_monitor: Add pty json builder function Date: Thu, 26 Aug 2021 14:59:19 -0700 Message-Id: <20210826215922.703741-6-william.douglas@intel.com> In-Reply-To: <20210826215922.703741-1-william.douglas@intel.com> References: <20210826215922.703741-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.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: 1630014813311100005 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 28d1c213cc..1ff956b61e 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 Sat May 4 16:38: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 1630014822783877.3722762666279; Thu, 26 Aug 2021 14:53:42 -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-458-d4tE1wBiMMKlFAZjBir4fQ-1; Thu, 26 Aug 2021 17:53:40 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 1A626801AC5; Thu, 26 Aug 2021 21:53:35 +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 EF4666A90A; Thu, 26 Aug 2021 21:53:34 +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 A55D3181A2A5; Thu, 26 Aug 2021 21:53:34 +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 17QLrKqP011796 for ; Thu, 26 Aug 2021 17:53:20 -0400 Received: by smtp.corp.redhat.com (Postfix) id F2C1220A8466; Thu, 26 Aug 2021 21:53:19 +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 ED69420A8463 for ; Thu, 26 Aug 2021 21:53:19 +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 D628B88647C for ; Thu, 26 Aug 2021 21:53:19 +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-472-on_HXp4bPGGqeO5FA9Gzjg-1; Thu, 26 Aug 2021 17:53:17 -0400 Received: from orsmga007.jf.intel.com ([10.7.209.58]) by orsmga105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 26 Aug 2021 14:52:01 -0700 Received: from wdouglas-dev.jf.intel.com (HELO desk.jf.intel.com) ([10.7.200.157]) by orsmga007-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 26 Aug 2021 14:51:58 -0700 X-MC-Unique: d4tE1wBiMMKlFAZjBir4fQ-1 X-MC-Unique: on_HXp4bPGGqeO5FA9Gzjg-1 X-IronPort-AV: E=McAfee;i="6200,9189,10088"; a="281568232" X-IronPort-AV: E=Sophos;i="5.84,354,1620716400"; d="scan'208";a="281568232" X-IronPort-AV: E=Sophos;i="5.84,354,1620716400"; d="scan'208";a="465266035" From: William Douglas To: libvir-list@redhat.com Subject: [PATCH 6/8] ch_process: Handle enabled console devices Date: Thu, 26 Aug 2021 14:59:20 -0700 Message-Id: <20210826215922.703741-7-william.douglas@intel.com> In-Reply-To: <20210826215922.703741-1-william.douglas@intel.com> References: <20210826215922.703741-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.15 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: 1630014824225100003 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 by updating the domain with console path information. This has to be run after the VM is created by cloud-hypervisor. Signed-off-by: William Douglas --- src/ch/ch_process.c | 67 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 67 insertions(+) diff --git a/src/ch/ch_process.c b/src/ch/ch_process.c index 93b1f7f97e..f6ae1677fd 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 @@ -92,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 Sat May 4 16:38: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 1630014822918670.9825559397586; Thu, 26 Aug 2021 14:53:42 -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-541-GQVB7sk2NHe-Ih5_aepNtA-1; Thu, 26 Aug 2021 17:53:40 -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 036EE87180C; Thu, 26 Aug 2021 21:53:35 +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 BE22010016F4; Thu, 26 Aug 2021 21:53:34 +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 8E838181A2A6; Thu, 26 Aug 2021 21:53:34 +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 17QLrKo9011804 for ; Thu, 26 Aug 2021 17:53:20 -0400 Received: by smtp.corp.redhat.com (Postfix) id 5598F10A1432; Thu, 26 Aug 2021 21:53:20 +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 51AE310A1431 for ; Thu, 26 Aug 2021 21:53:20 +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 3B714802A6A for ; Thu, 26 Aug 2021 21:53:20 +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-376-UZ6zwbkfNoC3zb_N1Tw3HQ-7; Thu, 26 Aug 2021 17:53:18 -0400 Received: from orsmga007.jf.intel.com ([10.7.209.58]) by orsmga105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 26 Aug 2021 14:52:02 -0700 Received: from wdouglas-dev.jf.intel.com (HELO desk.jf.intel.com) ([10.7.200.157]) by orsmga007-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 26 Aug 2021 14:51:58 -0700 X-MC-Unique: GQVB7sk2NHe-Ih5_aepNtA-1 X-MC-Unique: UZ6zwbkfNoC3zb_N1Tw3HQ-7 X-IronPort-AV: E=McAfee;i="6200,9189,10088"; a="281568234" X-IronPort-AV: E=Sophos;i="5.84,354,1620716400"; d="scan'208";a="281568234" X-IronPort-AV: E=Sophos;i="5.84,354,1620716400"; d="scan'208";a="465266038" From: William Douglas To: libvir-list@redhat.com Subject: [PATCH 7/8] ch_domain: Allow controller and chr devices Date: Thu, 26 Aug 2021 14:59:21 -0700 Message-Id: <20210826215922.703741-8-william.douglas@intel.com> In-Reply-To: <20210826215922.703741-1-william.douglas@intel.com> References: <20210826215922.703741-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.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: 1630014824216100001 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 Sat May 4 16:38: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 163001482761511.241627800078732; Thu, 26 Aug 2021 14:53:47 -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-153-jS1kFwpjOYCh4tcfkmKW3Q-1; Thu, 26 Aug 2021 17:53:45 -0400 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id BF02F3E746; Thu, 26 Aug 2021 21:53:37 +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 9317B2855A; Thu, 26 Aug 2021 21:53:37 +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 5E0974A709; Thu, 26 Aug 2021 21:53:37 +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 17QLrK5l011809 for ; Thu, 26 Aug 2021 17:53:20 -0400 Received: by smtp.corp.redhat.com (Postfix) id AC01814193D; Thu, 26 Aug 2021 21:53:20 +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 A6B8414E78B for ; Thu, 26 Aug 2021 21:53:20 +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 8F22418A01A5 for ; Thu, 26 Aug 2021 21:53:20 +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-472-PTAmQhKLPLaR5t7xK-MyOw-2; Thu, 26 Aug 2021 17:53:18 -0400 Received: from orsmga007.jf.intel.com ([10.7.209.58]) by orsmga105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 26 Aug 2021 14:52:02 -0700 Received: from wdouglas-dev.jf.intel.com (HELO desk.jf.intel.com) ([10.7.200.157]) by orsmga007-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 26 Aug 2021 14:51:58 -0700 X-MC-Unique: jS1kFwpjOYCh4tcfkmKW3Q-1 X-MC-Unique: PTAmQhKLPLaR5t7xK-MyOw-2 X-IronPort-AV: E=McAfee;i="6200,9189,10088"; a="281568243" X-IronPort-AV: E=Sophos;i="5.84,354,1620716400"; d="scan'208";a="281568243" X-IronPort-AV: E=Sophos;i="5.84,354,1620716400"; d="scan'208";a="465266040" From: William Douglas To: libvir-list@redhat.com Subject: [PATCH 8/8] ch_driver: Add handler for console API Date: Thu, 26 Aug 2021 14:59:22 -0700 Message-Id: <20210826215922.703741-9-william.douglas@intel.com> In-Reply-To: <20210826215922.703741-1-william.douglas@intel.com> References: <20210826215922.703741-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.23 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: 1630014828147100010 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