From nobody Sat Feb 7 12:35:03 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 63.128.21.124 as permitted sender) client-ip=63.128.21.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 63.128.21.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1612886495; cv=none; d=zohomail.com; s=zohoarc; b=WBKkhZiTV+gQx7A/diH9HeXyztV1GhCrHfan+/MSNSMKBWabx3HEBcExZIjVAgPeNoSJA/2ZOwClIx7dKHJVELYbrM7vmoUP9t4QdwepsRXZDe51nQs8L0tGHylrRhdKXl4lLdQ30sUVX9eeTo4llZOMzaAquuvtjX8bGz7CHX0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1612886495; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=vCweLWNASDVMQeqXCudVdjiGbS2fWgNiCOhXFp0m3vM=; b=XIJ45HPnPfOasdtWoWo64i6uSEf/Y8yG/y6fl1X46J9lGASblaIyb+UOnqUGSPwaMzBRgLwh9/mmvYFVj3bYrKIlKXnQyZ0+r2u8qhcMDG20ZwGUoYVFkHpuY2i3rRrg9PTG5sVQjoduTsBLk+2WwsmvV8RflI5tyST7O46yWkE= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 63.128.21.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [63.128.21.124]) by mx.zohomail.com with SMTPS id 1612886495665869.5247742582571; Tue, 9 Feb 2021 08:01:35 -0800 (PST) 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-206-sMfdi9xAOW6TJEBbEkuc9w-1; Tue, 09 Feb 2021 11:01:29 -0500 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 B0838192CC4B; Tue, 9 Feb 2021 16:01:23 +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 8367219727; Tue, 9 Feb 2021 16:01:23 +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 454CF57DFF; Tue, 9 Feb 2021 16:01:23 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 119G1IiE010785 for ; Tue, 9 Feb 2021 11:01:18 -0500 Received: by smtp.corp.redhat.com (Postfix) id 9EEA860861; Tue, 9 Feb 2021 16:01:18 +0000 (UTC) Received: from localhost.localdomain.com (ovpn-115-66.ams2.redhat.com [10.36.115.66]) by smtp.corp.redhat.com (Postfix) with ESMTP id BBDC060CD2; Tue, 9 Feb 2021 16:01:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1612886493; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=vCweLWNASDVMQeqXCudVdjiGbS2fWgNiCOhXFp0m3vM=; b=hCamH/Ulgc1/71ycMBCTg0SmUowtSeolk+QEVc57xu6iZjVA2PrlWBqiaGPXtuq8n+h8J2 GbFUi3lj3/Ia7M2DBLyiBz73OnLh/MgSeCCE6nGnsPU4b/mH3jZFl13eJNRF98kN4Pz93h d0SqZBAsLzeAwVhxbiyNoDr4wtLVSWQ= X-MC-Unique: sMfdi9xAOW6TJEBbEkuc9w-1 From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= To: libvir-list@redhat.com Subject: [libvirt PATCH v2 3/6] src: define virDomainGetMessages API Date: Tue, 9 Feb 2021 16:01:06 +0000 Message-Id: <20210209160109.1229387-4-berrange@redhat.com> In-Reply-To: <20210209160109.1229387-1-berrange@redhat.com> References: <20210209160109.1229387-1-berrange@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-loop: libvir-list@redhat.com 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-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) This API allows fetching a list of informational messages recorded against the domain. This provides a way to give information about tainting of the guest due to undesirable actions/configs, as well as provide details of deprecated features. The output of this API is explicitly targetted at humans, not machines, so it is inappropriate to attempt to pattern match on the strings and take action off them, not least because the messages are marked for translation. Should there be a demand for machine targetted information, this would have to be addressed via a new API, and is not planned at this point in time. Signed-off-by: Daniel P. Berrang=C3=A9 --- include/libvirt/libvirt-domain.h | 9 ++++++ src/driver-hypervisor.h | 6 ++++ src/libvirt-domain.c | 54 ++++++++++++++++++++++++++++++++ src/libvirt_public.syms | 5 +++ 4 files changed, 74 insertions(+) diff --git a/include/libvirt/libvirt-domain.h b/include/libvirt/libvirt-dom= ain.h index de2456812c..8011cf9fe1 100644 --- a/include/libvirt/libvirt-domain.h +++ b/include/libvirt/libvirt-domain.h @@ -5119,4 +5119,13 @@ int virDomainAuthorizedSSHKeysSet(virDomainPtr domai= n, unsigned int nkeys, unsigned int flags); =20 +typedef enum { + VIR_DOMAIN_MESSAGE_DEPRECATION =3D (1 << 0), + VIR_DOMAIN_MESSAGE_TAINTING =3D (1 << 1), +} virDomainMessageType; + +int virDomainGetMessages(virDomainPtr domain, + char ***msgs, + unsigned int flags); + #endif /* LIBVIRT_DOMAIN_H */ diff --git a/src/driver-hypervisor.h b/src/driver-hypervisor.h index 9e8fe89921..05d7dfb5c7 100644 --- a/src/driver-hypervisor.h +++ b/src/driver-hypervisor.h @@ -1400,6 +1400,11 @@ typedef int unsigned int nkeys, unsigned int flags); =20 +typedef int +(*virDrvDomainGetMessages)(virDomainPtr domain, + char ***msgs, + unsigned int flags); + typedef struct _virHypervisorDriver virHypervisorDriver; typedef virHypervisorDriver *virHypervisorDriverPtr; =20 @@ -1665,4 +1670,5 @@ struct _virHypervisorDriver { virDrvDomainBackupGetXMLDesc domainBackupGetXMLDesc; virDrvDomainAuthorizedSSHKeysGet domainAuthorizedSSHKeysGet; virDrvDomainAuthorizedSSHKeysSet domainAuthorizedSSHKeysSet; + virDrvDomainGetMessages domainGetMessages; }; diff --git a/src/libvirt-domain.c b/src/libvirt-domain.c index dba89a7d3a..ae318f4a1a 100644 --- a/src/libvirt-domain.c +++ b/src/libvirt-domain.c @@ -13102,3 +13102,57 @@ virDomainAuthorizedSSHKeysSet(virDomainPtr domain, virDispatchError(conn); return -1; } + + +/** + * virDomainGetMessages: + * @domain: a domain object + * @msgs: pointer to a variable to store messages + * @flags: zero or more virDomainMessageType flags + * + * Fetch a list of all messages recorded against the VM and + * store them into @msgs array which is allocated upon + * successful return and is NULL terminated. The caller is + * responsible for freeing @msgs when no longer needed. + * + * If @flags is zero then all messages are reported. The + * virDomainMessageType constants can be used to restrict + * results to certain types of message. + * + * Note it is hypervisor dependant whether messages are + * available for shutoff guests, or running guests, or + * both. Thus a client should be prepared to re-fetch + * messages when a guest transitions between running + * and shutoff states. + * + * Returns: number of messages stored in @msgs, + * -1 otherwise. + */ +int +virDomainGetMessages(virDomainPtr domain, + char ***msgs, + unsigned int flags) +{ + virConnectPtr conn; + + VIR_DOMAIN_DEBUG(domain, "msgs=3D%p, flags=3D0x%x", msgs, flags); + + virResetLastError(); + + virCheckDomainReturn(domain, -1); + conn =3D domain->conn; + virCheckNonNullArgGoto(msgs, error); + + if (conn->driver->domainGetMessages) { + int ret; + ret =3D conn->driver->domainGetMessages(domain, msgs, flags); + if (ret < 0) + goto error; + return ret; + } + + virReportUnsupportedError(); + error: + virDispatchError(conn); + return -1; +} diff --git a/src/libvirt_public.syms b/src/libvirt_public.syms index cf31f937d5..d851333eb0 100644 --- a/src/libvirt_public.syms +++ b/src/libvirt_public.syms @@ -879,4 +879,9 @@ LIBVIRT_6.10.0 { virDomainAuthorizedSSHKeysSet; } LIBVIRT_6.0.0; =20 +LIBVIRT_7.1.0 { + global: + virDomainGetMessages; +} LIBVIRT_6.10.0; + # .... define new API here using predicted next version number .... --=20 2.29.2