From nobody Thu Apr 25 23:50:02 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 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=1562789276; cv=none; d=zoho.com; s=zohoarc; b=nE8rqcG5bobFoLU4Sa4Il1Vdgk+0mxmqhyzrWvVmaJWdMQL+onXP0fwjPHfbym9ZhOoPLOmFm6VFajoMK8IBHUWmPuRXWOCf8+mZ1LOzF8Ljaxpnj8uJC8RTCCRM040hvMUdx3LZ5n+JIDCM7Rd/7q6uUeB5g7lA8WIHupcN99s= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1562789276; 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:ARC-Authentication-Results; bh=d7oFtB5L+cx2V4eAiBypCHorx1tdEzhjNLcwrseDkBU=; b=fBcmDmdq9HNJQFSaw4vGxNJGYZ921dJ+vH2Wmz20LKTV0b94lgwKKz5Itf62/h64t86i41gQnMaMJnlkt2my5Fw5gmOllUhTmSM8jy+JdbKcmJBSsOlLM7IET93LOe9gXBqcT0eV8Azy7SoHg0Pqa7EuP1xwSPHPwATP9L3r6xY= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1562789276537562.9825811368291; Wed, 10 Jul 2019 13:07:56 -0700 (PDT) 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 mx1.redhat.com (Postfix) with ESMTPS id EB99DA3B63; Wed, 10 Jul 2019 20:07:53 +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 BA6DD60C4E; Wed, 10 Jul 2019 20:07:53 +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 73AB9184365F; Wed, 10 Jul 2019 20:07:53 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x6AK7qXi030781 for ; Wed, 10 Jul 2019 16:07:52 -0400 Received: by smtp.corp.redhat.com (Postfix) id B0EF65DC1A; Wed, 10 Jul 2019 20:07:52 +0000 (UTC) Received: from aegolius.redhat.com (ovpn-116-68.phx2.redhat.com [10.3.116.68]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 6C4575D9CD for ; Wed, 10 Jul 2019 20:07:52 +0000 (UTC) From: Jonathon Jongsma To: libvir-list@redhat.com Date: Wed, 10 Jul 2019 15:07:43 -0500 Message-Id: <20190710200747.745-2-jjongsma@redhat.com> In-Reply-To: <20190710200747.745-1-jjongsma@redhat.com> References: <20190710200747.745-1-jjongsma@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 1/5] lib: add API to query info about logged-in users 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: , Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.30]); Wed, 10 Jul 2019 20:07:55 +0000 (UTC) Content-Type: text/plain; charset="utf-8" Add API for querying logged-in users from a domain implemented via guest agent. Signed-off-by: Jonathon Jongsma --- include/libvirt/libvirt-domain.h | 18 ++++++++++ src/driver-hypervisor.h | 6 ++++ src/libvirt-domain.c | 62 ++++++++++++++++++++++++++++++++ src/libvirt_public.syms | 5 +++ 4 files changed, 91 insertions(+) diff --git a/include/libvirt/libvirt-domain.h b/include/libvirt/libvirt-dom= ain.h index 2dbd74d4f3..82dbbd3fc5 100644 --- a/include/libvirt/libvirt-domain.h +++ b/include/libvirt/libvirt-domain.h @@ -4896,4 +4896,22 @@ int virDomainGetLaunchSecurityInfo(virDomainPtr doma= in, int *nparams, unsigned int flags); =20 +/** + * virDomainUserInfo: + * + * The data structure containing informationa bout logged-in users within a + * guest + */ +typedef struct _virDomainUserInfo virDomainUserInfo; +typedef virDomainUserInfo *virDomainUserInfoPtr; +struct _virDomainUserInfo { + char *user; /* username */ + char *domain; /* login domain (windows only) */ + unsigned long long loginTime; /* timestamp of login for this user in m= s since epoch */ +}; +int virDomainGetGuestUsers(virDomainPtr domain, + virDomainUserInfoPtr **info, + unsigned int flags); +void virDomainUserInfoFree(virDomainUserInfoPtr info); + #endif /* LIBVIRT_DOMAIN_H */ diff --git a/src/driver-hypervisor.h b/src/driver-hypervisor.h index b15aaa36bc..0ef7257ace 100644 --- a/src/driver-hypervisor.h +++ b/src/driver-hypervisor.h @@ -1327,6 +1327,11 @@ typedef int int *nparams, unsigned int flags); =20 +typedef int +(*virDrvDomainGetGuestUsers)(virDomainPtr domain, + virDomainUserInfoPtr **info, + unsigned int flags); + =20 typedef struct _virHypervisorDriver virHypervisorDriver; typedef virHypervisorDriver *virHypervisorDriverPtr; @@ -1579,4 +1584,5 @@ struct _virHypervisorDriver { virDrvConnectBaselineHypervisorCPU connectBaselineHypervisorCPU; virDrvNodeGetSEVInfo nodeGetSEVInfo; virDrvDomainGetLaunchSecurityInfo domainGetLaunchSecurityInfo; + virDrvDomainGetGuestUsers domainGetGuestUsers; }; diff --git a/src/libvirt-domain.c b/src/libvirt-domain.c index 3d12e7c125..80faa08758 100644 --- a/src/libvirt-domain.c +++ b/src/libvirt-domain.c @@ -12199,6 +12199,68 @@ virDomainSetVcpu(virDomainPtr domain, return -1; } =20 +/** + * virDomainGetGuestUsers: + * @domain: pointer to domain object + * @info: a pointer to a variable to store an array of user info + * @flags: currently unused, callers shall pass 0 + * + * Queries the guest agent for the list of currently active users on the + * guest. The reported data depends on the guest agent implementation. + * + * This API requires the VM to run. The caller is responsible for calling + * virTypedParamsFree to free memory returned in @params. + * + * Returns the number of returned users, or -1 in case of error. + * On success, the array of the information is stored into @info. The call= er is + * responsible for calling virDomainUserInfoFree() on each array element, = then + * calling free() on @info. On error, @info is set to NULL. + */ +int +virDomainGetGuestUsers(virDomainPtr domain, + virDomainUserInfoPtr **info, + unsigned int flags) +{ + virResetLastError(); + + virCheckDomainReturn(domain, -1); + virCheckReadOnlyGoto(domain->conn->flags, error); + + virCheckNonNullArgGoto(info, error); + + if (domain->conn->driver->domainGetGuestUsers) { + int ret; + ret =3D domain->conn->driver->domainGetGuestUsers(domain, info, + flags); + if (ret < 0) + goto error; + return ret; + } + + virReportUnsupportedError(); + + error: + virDispatchError(domain->conn); + return -1; +} + +/** + * virDomainUserInfoFree: + * @info: pointer to a UserInfo object + * + * Frees all the memory occupied by @info. + */ +void +virDomainUserInfoFree(virDomainUserInfoPtr info) +{ + if (!info) + return; + + VIR_FREE(info->user); + VIR_FREE(info->domain); + + VIR_FREE(info); +} =20 /** * virDomainSetBlockThreshold: diff --git a/src/libvirt_public.syms b/src/libvirt_public.syms index 18500ec8b2..7d0e3c7849 100644 --- a/src/libvirt_public.syms +++ b/src/libvirt_public.syms @@ -836,4 +836,9 @@ LIBVIRT_5.5.0 { virNetworkPortSetParameters; } LIBVIRT_5.2.0; =20 +LIBVIRT_5.6.0 { + global: + virDomainGetGuestUsers; + virDomainUserInfoFree; +} LIBVIRT_5.5.0; # .... define new API here using predicted next version number .... --=20 2.20.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Thu Apr 25 23:50:02 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 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=1562789280; cv=none; d=zoho.com; s=zohoarc; b=A80Pt+z8MyBU3q9uUD8y5nPCawqZ2ZmjZColeE0SZZOIWr5ttQbLFoXAeHyw1pYHV/vO3KpT4tV7iiEnTY5PfOHdqdKFkeLV+5+lF+S1ixlpTUpYlCClLq680skeFTWu1qXrz3nN1J5VpbbxNPQRrEy1+4Ni7WrWZysUrhEwJ4U= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1562789280; 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:ARC-Authentication-Results; bh=686CiFHvDojwyjHIq1HdPGFydlZY0uOwo831gsevDfw=; b=maUwxuYpv8ngl/tYRpl87JkbedlrsLUYKfThZlrY/O4TfbtsQolWDtTO/asMX2o2YWMAEwfp3iGutN1i0SkFNECFcjSdAgZiBACnvMvxHsHbJBuZg0wtnbvXjKqFCasYatQhiRwzaZmYHBqCBEqoeTB1QcokRde/N0ySRag2gAY= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1562789280421605.9408115433479; Wed, 10 Jul 2019 13:08:00 -0700 (PDT) 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 mx1.redhat.com (Postfix) with ESMTPS id 17EBD3082131; Wed, 10 Jul 2019 20:07:58 +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 962DF871FB; Wed, 10 Jul 2019 20:07:57 +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 52F2EC596; Wed, 10 Jul 2019 20:07:57 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x6AK7rf6030787 for ; Wed, 10 Jul 2019 16:07:53 -0400 Received: by smtp.corp.redhat.com (Postfix) id 1F59617D40; Wed, 10 Jul 2019 20:07:53 +0000 (UTC) Received: from aegolius.redhat.com (ovpn-116-68.phx2.redhat.com [10.3.116.68]) by smtp.corp.redhat.com (Postfix) with ESMTPS id D13215DC1A for ; Wed, 10 Jul 2019 20:07:52 +0000 (UTC) From: Jonathon Jongsma To: libvir-list@redhat.com Date: Wed, 10 Jul 2019 15:07:44 -0500 Message-Id: <20190710200747.745-3-jjongsma@redhat.com> In-Reply-To: <20190710200747.745-1-jjongsma@redhat.com> References: <20190710200747.745-1-jjongsma@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 2/5] remote: implement remote protocol for virDomainGetGuestUsers 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: , Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.42]); Wed, 10 Jul 2019 20:07:59 +0000 (UTC) Content-Type: text/plain; charset="utf-8" Add daemon and client code to serialize/deserialize virDomainUserInfo Signed-off-by: Jonathon Jongsma --- src/remote/remote_daemon_dispatch.c | 89 +++++++++++++++++++++++++++++ src/remote/remote_driver.c | 82 +++++++++++++++++++++++++- src/remote/remote_protocol.x | 26 ++++++++- src/remote_protocol-structs | 17 ++++++ 4 files changed, 212 insertions(+), 2 deletions(-) diff --git a/src/remote/remote_daemon_dispatch.c b/src/remote/remote_daemon= _dispatch.c index 856c5e48e7..05c4b11b11 100644 --- a/src/remote/remote_daemon_dispatch.c +++ b/src/remote/remote_daemon_dispatch.c @@ -7465,3 +7465,92 @@ remoteSerializeDomainDiskErrors(virDomainDiskErrorPt= r errors, } return -1; } + +static int +remoteDispatchDomainGetGuestUsers(virNetServerPtr server ATTRIBUTE_UNUSED, + virNetServerClientPtr client, + virNetMessagePtr msg ATTRIBUTE_UNUSED, + virNetMessageErrorPtr rerr, + remote_domain_get_guest_users_args *args, + remote_domain_get_guest_users_ret *ret) +{ + int rv =3D -1; + size_t i; + struct daemonClientPrivate *priv =3D virNetServerClientGetPrivateData(= client); + virDomainUserInfoPtr *info =3D NULL; + virDomainPtr dom =3D NULL; + remote_domain_userinfo *dst; + int ninfo =3D 0; + + if (!priv->conn) { + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not ope= n")); + goto cleanup; + } + + if (!(dom =3D get_nonnull_domain(priv->conn, args->dom))) + goto cleanup; + + if ((ninfo =3D virDomainGetGuestUsers(dom, &info, args->flags)) < 0) + goto cleanup; + + if (ninfo > REMOTE_DOMAIN_GUEST_USERS_MAX) { + virReportError(VIR_ERR_RPC, + _("Too many users in userinfo: %d for limit %d"), + ninfo, REMOTE_DOMAIN_GUEST_USERS_MAX); + goto cleanup; + } + + if (ninfo) { + if (VIR_ALLOC_N(ret->info.info_val, ninfo) < 0) + goto cleanup; + + ret->info.info_len =3D ninfo; + + for (i =3D 0; i < ninfo; i++) { + dst =3D &ret->info.info_val[i]; + if (VIR_STRDUP(dst->user, info[i]->user) < 0) + goto cleanup; + + if (info[i]->domain) { + if (VIR_ALLOC(*dst->domain) < 0) + goto cleanup; + if (VIR_STRDUP(*dst->domain, info[i]->domain) < 0) + goto cleanup; + } + + dst->login_time =3D info[i]->loginTime; + + } + + } else { + ret->info.info_len =3D 0; + ret->info.info_val =3D NULL; + } + + ret->ret =3D ninfo; + + rv =3D 0; + + cleanup: + if (rv < 0) { + virNetMessageSaveError(rerr); + + if (ret->info.info_val && ninfo > 0) { + for (i =3D 0; i < ninfo; i++) { + dst =3D &ret->info.info_val[i]; + VIR_FREE(dst->user); + if(dst->domain) + VIR_FREE(*dst->domain); + VIR_FREE(dst->domain); + } + VIR_FREE(ret->info.info_val); + } + } + virObjectUnref(dom); + if (ninfo >=3D 0) + for (i =3D 0; i < ninfo; i++) + virDomainUserInfoFree(info[i]); + VIR_FREE(info); + + return rv; +} diff --git a/src/remote/remote_driver.c b/src/remote/remote_driver.c index 925ada1cac..86e2071d3b 100644 --- a/src/remote/remote_driver.c +++ b/src/remote/remote_driver.c @@ -8167,6 +8167,85 @@ remoteNetworkPortGetParameters(virNetworkPortPtr por= t, return rv; } =20 +static int +remoteDomainGetGuestUsers(virDomainPtr dom, + virDomainUserInfoPtr **info, + unsigned int flags) +{ + int rv =3D -1; + size_t i; + struct private_data *priv =3D dom->conn->privateData; + remote_domain_get_guest_users_args args; + remote_domain_get_guest_users_ret ret; + remote_domain_userinfo *src; + virDomainUserInfoPtr *info_ret =3D NULL; + + remoteDriverLock(priv); + + make_nonnull_domain(&args.dom, dom); + + args.flags =3D flags; + + memset(&ret, 0, sizeof(ret)); + + if (call(dom->conn, priv, 0, REMOTE_PROC_DOMAIN_GET_GUEST_USERS, + (xdrproc_t)xdr_remote_domain_get_guest_users_args, (char *)&a= rgs, + (xdrproc_t)xdr_remote_domain_get_guest_users_ret, (char *)&re= t) =3D=3D -1) + goto done; + + if (ret.info.info_len > REMOTE_DOMAIN_GUEST_USERS_MAX) { + virReportError(VIR_ERR_INTERNAL_ERROR, + _("Too many users in userinfo: %d for limit %d"), + ret.info.info_len, REMOTE_DOMAIN_GUEST_USERS_MAX); + goto cleanup; + } + + if (info) { + if (!ret.info.info_len) { + *info =3D NULL; + rv =3D ret.ret; + goto cleanup; + } + + if (VIR_ALLOC_N(info_ret, ret.info.info_len) < 0) + goto cleanup; + + for (i =3D 0; i < ret.info.info_len; i++) { + src =3D &ret.info.info_val[i]; + + if (VIR_ALLOC(info_ret[i]) < 0) + goto cleanup; + + if (VIR_STRDUP(info_ret[i]->user, src->user) < 0) + goto cleanup; + + if (src->domain) { + if (VIR_STRDUP(info_ret[i]->domain, *src->domain) < 0) + goto cleanup; + } + + info_ret[i]->loginTime =3D src->login_time; + } + + *info =3D info_ret; + info_ret =3D NULL; + } + + rv =3D ret.ret; + + cleanup: + if (info_ret) { + for (i =3D 0; i < ret.info.info_len; i++) + virDomainUserInfoFree(info_ret[i]); + VIR_FREE(info_ret); + } + xdr_free((xdrproc_t)xdr_remote_domain_get_guest_users_ret, + (char *) &ret); + + done: + remoteDriverUnlock(priv); + return rv; +} =20 /* get_nonnull_domain and get_nonnull_network turn an on-wire * (name, uuid) pair into virDomainPtr or virNetworkPtr object. @@ -8573,7 +8652,8 @@ static virHypervisorDriver hypervisor_driver =3D { .connectCompareHypervisorCPU =3D remoteConnectCompareHypervisorCPU, /*= 4.4.0 */ .connectBaselineHypervisorCPU =3D remoteConnectBaselineHypervisorCPU, = /* 4.4.0 */ .nodeGetSEVInfo =3D remoteNodeGetSEVInfo, /* 4.5.0 */ - .domainGetLaunchSecurityInfo =3D remoteDomainGetLaunchSecurityInfo /* = 4.5.0 */ + .domainGetLaunchSecurityInfo =3D remoteDomainGetLaunchSecurityInfo, /*= 4.5.0 */ + .domainGetGuestUsers =3D remoteDomainGetGuestUsers /* 5.6.0 */ }; =20 static virNetworkDriver network_driver =3D { diff --git a/src/remote/remote_protocol.x b/src/remote/remote_protocol.x index 2e45b5cef0..5f2f350cb0 100644 --- a/src/remote/remote_protocol.x +++ b/src/remote/remote_protocol.x @@ -266,6 +266,9 @@ const REMOTE_NODE_SEV_INFO_MAX =3D 64; /* Upper limit on number of launch security information entries */ const REMOTE_DOMAIN_LAUNCH_SECURITY_INFO_PARAMS_MAX =3D 64; =20 +/* Upper limit on number of guest user information entries */ +const REMOTE_DOMAIN_GUEST_USERS_MAX =3D 64; + /* * Upper limit on list of network port parameters */ @@ -3649,6 +3652,21 @@ struct remote_network_port_delete_args { unsigned int flags; }; =20 +struct remote_domain_userinfo { + remote_nonnull_string user; + remote_string domain; + unsigned hyper login_time; +}; + +struct remote_domain_get_guest_users_args { + remote_nonnull_domain dom; + unsigned int flags; +}; + +struct remote_domain_get_guest_users_ret { + remote_domain_userinfo info; + unsigned int ret; +}; =20 /*----- Protocol. -----*/ =20 @@ -6463,5 +6481,11 @@ enum remote_procedure { * @generate: both * @acl: network_port:delete */ - REMOTE_PROC_NETWORK_PORT_DELETE =3D 410 + REMOTE_PROC_NETWORK_PORT_DELETE =3D 410, + + /** + * @generate: none + * @acl: domain:write + */ + REMOTE_PROC_DOMAIN_GET_GUEST_USERS =3D 411 }; diff --git a/src/remote_protocol-structs b/src/remote_protocol-structs index 2398494520..ee39fb2d0d 100644 --- a/src/remote_protocol-structs +++ b/src/remote_protocol-structs @@ -3043,6 +3043,22 @@ struct remote_network_port_delete_args { remote_nonnull_network_port port; u_int flags; }; +struct remote_domain_userinfo { + remote_nonnull_string user; + remote_string domain; + uint64_t login_time; +}; +struct remote_domain_get_guest_users_args { + remote_nonnull_domain dom; + u_int flags; +}; +struct remote_domain_get_guest_users_ret { + struct { + u_int info_len; + remote_domain_userinfo * info_val; + } info; + u_int ret; +}; enum remote_procedure { REMOTE_PROC_CONNECT_OPEN =3D 1, REMOTE_PROC_CONNECT_CLOSE =3D 2, @@ -3454,4 +3470,5 @@ enum remote_procedure { REMOTE_PROC_NETWORK_PORT_SET_PARAMETERS =3D 408, REMOTE_PROC_NETWORK_PORT_GET_XML_DESC =3D 409, REMOTE_PROC_NETWORK_PORT_DELETE =3D 410, + REMOTE_PROC_DOMAIN_GET_GUEST_USERS =3D 411, }; --=20 2.20.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Thu Apr 25 23:50:03 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 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=1562789278; cv=none; d=zoho.com; s=zohoarc; b=VkLSCsgTzcP2eTfziDXUbkw6hCKnREg/GbGwtB4Ysz4YxUJ9thsLtpVhRhKE5P7YmSmS6M1l83vKTTHM6UinlcqGbbqGr4+nnpk5/o2bQs/q3jxWhH4AwXIyuQekwMfYns/E+yOmSIhumY1E21JRQfoHDOL1B3liXMC/euwLWFs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1562789278; 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:ARC-Authentication-Results; bh=9hUggkY93BdbVnQGJpt+Zi2rr3GGtoSqQH5n0Y8PzEE=; b=CrpHfpjAOEC6ALQsG7FmaeAIcRielFM60vNG3fsphpGAlzN8Az2zcsri7i7CKUGVt38r1SLHRBHPSCkMjqBqdsTQ13yJC4SRRvdJMS9hCjxZAWcr0cID7Fqebg6c7K6faN0YQF7ZR/i4SLAUynlQS3NOH8li+AR6NJIZHu26OnU= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1562789278377832.2065709702099; Wed, 10 Jul 2019 13:07:58 -0700 (PDT) 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 mx1.redhat.com (Postfix) with ESMTPS id C5FEE307D96F; Wed, 10 Jul 2019 20:07:55 +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 A164A6014E; Wed, 10 Jul 2019 20:07:55 +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 5D24D1843664; Wed, 10 Jul 2019 20:07:55 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x6AK7r2T030792 for ; Wed, 10 Jul 2019 16:07:53 -0400 Received: by smtp.corp.redhat.com (Postfix) id 701B05DD93; Wed, 10 Jul 2019 20:07:53 +0000 (UTC) Received: from aegolius.redhat.com (ovpn-116-68.phx2.redhat.com [10.3.116.68]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 3CCF15DD8E for ; Wed, 10 Jul 2019 20:07:53 +0000 (UTC) From: Jonathon Jongsma To: libvir-list@redhat.com Date: Wed, 10 Jul 2019 15:07:45 -0500 Message-Id: <20190710200747.745-4-jjongsma@redhat.com> In-Reply-To: <20190710200747.745-1-jjongsma@redhat.com> References: <20190710200747.745-1-jjongsma@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 3/5] virsh: add command 'guestusers' implementing VirDomainGetGuestUsers 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: , Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.48]); Wed, 10 Jul 2019 20:07:57 +0000 (UTC) Content-Type: text/plain; charset="utf-8" Signed-off-by: Jonathon Jongsma --- tools/virsh-domain.c | 76 ++++++++++++++++++++++++++++++++++++++++++++ tools/virsh.pod | 4 +++ 2 files changed, 80 insertions(+) diff --git a/tools/virsh-domain.c b/tools/virsh-domain.c index 828ae30789..b964608987 100644 --- a/tools/virsh-domain.c +++ b/tools/virsh-domain.c @@ -14030,6 +14030,76 @@ cmdDomFSInfo(vshControl *ctl, const vshCmd *cmd) return ret; } =20 +/* + * "guestusers" command + */ +static const vshCmdInfo info_guestusers[] =3D { + {.name =3D "help", + .data =3D N_("query the users logged on in the guest (via agent)") + }, + {.name =3D "desc", + .data =3D N_("Use the guest agent to query the list of logged in user= s from guest's " + "point of view") + }, + {.name =3D NULL} +}; + +static const vshCmdOptDef opts_guestusers[] =3D { + VIRSH_COMMON_OPT_DOMAIN_FULL(VIR_CONNECT_LIST_DOMAINS_ACTIVE), + {.name =3D NULL} +}; + +static bool +cmdGuestusers(vshControl *ctl, const vshCmd *cmd) +{ + virDomainPtr dom; + virDomainUserInfoPtr *userinfo =3D NULL; + int ninfo =3D 0; + size_t i; + bool ret =3D false; + vshTablePtr table =3D NULL; + + if (!(dom =3D virshCommandOptDomain(ctl, cmd, NULL))) + return false; + + if ((ninfo =3D virDomainGetGuestUsers(dom, &userinfo, 0)) < 0) + goto cleanup; + + if (userinfo !=3D NULL) { + table =3D vshTableNew(_("User"), _("Domain"), _("Login Time"), NU= LL); + if (!table) + goto cleanup; + + for (i =3D 0; i < ninfo; i++) { + VIR_AUTOFREE(char *) loginstr =3D virTimeStringThen(userinfo[i= ]->loginTime); + if (loginstr =3D=3D NULL) + goto cleanup; + + if (vshTableRowAppend(table, + userinfo[i]->user, + userinfo[i]->domain ? userinfo[i]->domai= n : "", + loginstr, + NULL) < 0) + goto cleanup; + } + + vshTablePrintToStdout(table, ctl); + } else { + vshPrintExtra(ctl, _("No active users in the domain")); + } + + ret =3D true; + +cleanup: + if (ninfo >=3D 0) { + for (i =3D 0; i < ninfo; i++) + virDomainUserInfoFree(userinfo[i]); + } + VIR_FREE(userinfo); + virshDomainFree(dom); + return ret; +} + const vshCmdDef domManagementCmds[] =3D { {.name =3D "attach-device", .handler =3D cmdAttachDevice, @@ -14645,5 +14715,11 @@ const vshCmdDef domManagementCmds[] =3D { .info =3D info_domblkthreshold, .flags =3D 0 }, + {.name =3D "guestusers", + .handler =3D cmdGuestusers, + .opts =3D opts_guestusers, + .info =3D info_guestusers, + .flags =3D 0 + }, {.name =3D NULL} }; diff --git a/tools/virsh.pod b/tools/virsh.pod index 5168fa96b6..59cf3d5857 100644 --- a/tools/virsh.pod +++ b/tools/virsh.pod @@ -3072,6 +3072,10 @@ provided too. The desired operation is then executed= on the domain. =20 See B for information on I. =20 +=3Ditem B I + +Query the list of logged in users from guest's point of view using the gue= st agent. + =3Ditem B I =20 Output the IP address and port number for the VNC display. If the informat= ion --=20 2.20.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Thu Apr 25 23:50:03 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 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=1562789280; cv=none; d=zoho.com; s=zohoarc; b=WkjTp4c+0XFm8aQe6ccKOqMPKiqgeGZUATfQIaitBgwoItaxWR6qS54n5jwawKQcoMbXktX9NdFOszC/LhImcMPzYGEK2YwhhSSzX29XUSx6IK5sDhLijPOHUAcxxSfIp8KVy5DDzbwZ6TCbZlfRWkhky0Y3U5MnYcawNru7KYY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1562789280; 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:ARC-Authentication-Results; bh=vy0vcWFpNNDnrwlnutdh9y/AQ2qTZ2C3vp0vZ8jpXr8=; b=A6Jb0lzgDjbdKn7GOEVOROxJNkx0gE8Y5XhGrQVDxzRkY+FI4I/hE7KSFRXhZjkdpptVv66Nr7glyEaGeRbeWNa52FDA/8Tl4PQECw7MHbrfJkzB2SbvbpzDZlregzWO4pZrofVMxh3gER+v5JR720ueODgmjUZ5V8zLVlSe30k= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1562789280510191.39859389667242; Wed, 10 Jul 2019 13:08:00 -0700 (PDT) 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 mx1.redhat.com (Postfix) with ESMTPS id 17B973092664; Wed, 10 Jul 2019 20:07:58 +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 68236871F9; Wed, 10 Jul 2019 20:07:57 +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 2C84D41F63; Wed, 10 Jul 2019 20:07:57 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x6AK7rEs030800 for ; Wed, 10 Jul 2019 16:07:53 -0400 Received: by smtp.corp.redhat.com (Postfix) id C065F17D76; Wed, 10 Jul 2019 20:07:53 +0000 (UTC) Received: from aegolius.redhat.com (ovpn-116-68.phx2.redhat.com [10.3.116.68]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 8E6805DD93 for ; Wed, 10 Jul 2019 20:07:53 +0000 (UTC) From: Jonathon Jongsma To: libvir-list@redhat.com Date: Wed, 10 Jul 2019 15:07:46 -0500 Message-Id: <20190710200747.745-5-jjongsma@redhat.com> In-Reply-To: <20190710200747.745-1-jjongsma@redhat.com> References: <20190710200747.745-1-jjongsma@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 4/5] qemu_agent: add helper for getting guest users 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: , Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.43]); Wed, 10 Jul 2019 20:07:59 +0000 (UTC) Content-Type: text/plain; charset="utf-8" This function fetches the list of logged-in users from the qemu agent and converts them into a form that can be used internally in libvirt. Also add some basic tests for the function. Signed-off-by: Jonathon Jongsma --- src/qemu/qemu_agent.c | 92 +++++++++++++++++++++++++++++++ src/qemu/qemu_agent.h | 2 + tests/qemuagenttest.c | 125 ++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 219 insertions(+) diff --git a/src/qemu/qemu_agent.c b/src/qemu/qemu_agent.c index 361db299a5..b70d6806cd 100644 --- a/src/qemu/qemu_agent.c +++ b/src/qemu/qemu_agent.c @@ -2240,3 +2240,95 @@ qemuAgentSetUserPassword(qemuAgentPtr mon, VIR_FREE(password64); return ret; } + +int +qemuAgentGetUsers(qemuAgentPtr mon, + virDomainUserInfoPtr **info) +{ + int ret =3D -1; + size_t i; + virJSONValuePtr cmd; + virJSONValuePtr reply =3D NULL; + virJSONValuePtr data =3D NULL; + size_t ndata; + const char *result; + virDomainUserInfoPtr *users =3D NULL; + + if (!(cmd =3D qemuAgentMakeCommand("guest-get-users", NULL))) + return -1; + + if (qemuAgentCommand(mon, cmd, &reply, true, + VIR_DOMAIN_QEMU_AGENT_COMMAND_BLOCK) < 0) + goto cleanup; + + if (!(data =3D virJSONValueObjectGetArray(reply, "return"))) { + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("guest-get-users reply was missing return data")); + goto cleanup; + } + + if (!virJSONValueIsArray(data)) { + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("Malformed guest-get-users data array")); + goto cleanup; + } + + ndata =3D virJSONValueArraySize(data); + + if (VIR_ALLOC_N(users, ndata) < 0) + goto cleanup; + + for (i =3D 0; i < ndata; i++) { + virJSONValuePtr entry =3D virJSONValueArrayGet(data, i); + if (VIR_ALLOC(users[i]) < 0) + goto cleanup; + + if (!entry) { + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("array element missing in guest-get-users ret= urn " + "value")); + goto cleanup; + } + + if (!(result =3D virJSONValueObjectGetString(entry, "user"))) { + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("'user' missing in reply of guest-get-users")= ); + goto cleanup; + } + + if (VIR_STRDUP(users[i]->user, result) < 0) { + goto cleanup; + } + + /* 'domain' is only present for windows guests */ + if ((result =3D virJSONValueObjectGetString(entry, "domain"))) { + if (VIR_STRDUP(users[i]->domain, result) < 0) { + goto cleanup; + } + } + + double loginseconds; + if (virJSONValueObjectGetNumberDouble(entry, "login-time", &logins= econds) < 0) { + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("'login-time' missing in reply of guest-get-u= sers")); + goto cleanup; + } + /* convert to milliseconds */ + users[i]->loginTime =3D loginseconds * 1000; + } + + *info =3D users; + users =3D NULL; + ret =3D ndata; + + cleanup: + if (users) { + for (i =3D 0; i < ndata; i++) { + virDomainUserInfoFree(users[i]); + } + VIR_FREE(users); + } + virJSONValueFree(cmd); + virJSONValueFree(reply); + return ret; +} diff --git a/src/qemu/qemu_agent.h b/src/qemu/qemu_agent.h index 6ae9fe54da..70797dc894 100644 --- a/src/qemu/qemu_agent.h +++ b/src/qemu/qemu_agent.h @@ -120,3 +120,5 @@ int qemuAgentSetUserPassword(qemuAgentPtr mon, const char *user, const char *password, bool crypted); + +int qemuAgentGetUsers(qemuAgentPtr mon, virDomainUserInfoPtr **info); diff --git a/tests/qemuagenttest.c b/tests/qemuagenttest.c index 2f79986207..d97f05102e 100644 --- a/tests/qemuagenttest.c +++ b/tests/qemuagenttest.c @@ -902,6 +902,130 @@ testQemuAgentGetInterfaces(const void *data) return ret; } =20 +static const char testQemuAgentUsersResponse[] =3D + "{\"return\": " + " [" + " {\"user\": \"test\"," + " \"login-time\": 1561739203.584038" + " }," + " {\"user\": \"test2\"," + " \"login-time\": 1561739229.190697" + " }" + " ]" + "}"; + +static const char testQemuAgentUsersResponse2[] =3D + "{\"return\": " + " [" + " {\"user\": \"test\"," + " \"domain\": \"DOMAIN\"," + " \"login-time\": 1561739203.584038" + " }" + " ]" + "}"; + +static int +testQemuAgentUsers(const void *data) +{ + virDomainXMLOptionPtr xmlopt =3D (virDomainXMLOptionPtr)data; + qemuMonitorTestPtr test =3D qemuMonitorTestNewAgent(xmlopt); + virDomainUserInfoPtr *userinfo =3D NULL; + int nusers; + int ret =3D -1; + int i; + + if (!test) + return -1; + + if (qemuMonitorTestAddAgentSyncResponse(test) < 0) + goto cleanup; + + if (qemuMonitorTestAddItem(test, "guest-get-users", + testQemuAgentUsersResponse) < 0) + goto cleanup; + + /* get users */ + if ((nusers =3D qemuAgentGetUsers(qemuMonitorTestGetAgent(test), + &userinfo)) < 0) + goto cleanup; + + if (nusers !=3D 2) { + virReportError(VIR_ERR_INTERNAL_ERROR, + "Expected '2' users, got '%d'", nusers); + goto cleanup; + } + if (STRNEQ(userinfo[0]->user, "test")) { + virReportError(VIR_ERR_INTERNAL_ERROR, + "Expected user name 'test', got '%s'", userinfo[0]-= >user); + goto cleanup; + } + if (userinfo[0]->loginTime !=3D 1561739203.584038) { + virReportError(VIR_ERR_INTERNAL_ERROR, + "Expected login time of '1561739203584', got '%llu'= ", + userinfo[0]->loginTime); + goto cleanup; + } + + if (STRNEQ(userinfo[1]->user, "test2")) { + virReportError(VIR_ERR_INTERNAL_ERROR, + "Expected user name 'test2', got '%s'", userinfo[1]= ->user); + goto cleanup; + } + if (userinfo[1]->loginTime !=3D 1561739229.190697) { + virReportError(VIR_ERR_INTERNAL_ERROR, + "Expected login time of '1561739229190', got '%llu'= ", + userinfo[1]->loginTime); + goto cleanup; + } + + if (qemuMonitorTestAddAgentSyncResponse(test) < 0) + goto cleanup; + + if (qemuMonitorTestAddItem(test, "guest-get-users", + testQemuAgentUsersResponse2) < 0) + goto cleanup; + + VIR_FREE(userinfo); + /* get users with domain */ + if ((nusers =3D qemuAgentGetUsers(qemuMonitorTestGetAgent(test), + &userinfo)) < 0) + goto cleanup; + + if (nusers !=3D 1) { + virReportError(VIR_ERR_INTERNAL_ERROR, + "Expected '1' user, got '%d'", nusers); + goto cleanup; + } + + if (STRNEQ(userinfo[0]->user, "test")) { + virReportError(VIR_ERR_INTERNAL_ERROR, + "Expected user name 'test', got '%s'", userinfo[0]-= >user); + goto cleanup; + } + if (userinfo[0]->loginTime !=3D 1561739203.584038) { + virReportError(VIR_ERR_INTERNAL_ERROR, + "Expected login time of '1561739203584', got '%llu'= ", + userinfo[0]->loginTime); + goto cleanup; + } + if (STRNEQ(userinfo[0]->domain, "DOMAIN")) { + virReportError(VIR_ERR_INTERNAL_ERROR, + "Expected domain 'DOMAIN', got '%s'", userinfo[0]->= domain); + goto cleanup; + } + ret =3D 0; + + cleanup: + if (nusers >=3D 0) { + for (i =3D 0; i < nusers; i++) + virDomainUserInfoFree(userinfo[i]); + } + VIR_FREE(userinfo); + qemuMonitorTestFree(test); + return ret; +} + + static int mymain(void) { @@ -931,6 +1055,7 @@ mymain(void) DO_TEST(CPU); DO_TEST(ArbitraryCommand); DO_TEST(GetInterfaces); + DO_TEST(Users); =20 DO_TEST(Timeout); /* Timeout should always be called last */ =20 --=20 2.20.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Thu Apr 25 23:50:03 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 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=1562789283; cv=none; d=zoho.com; s=zohoarc; b=Md6wydqb6B9TUVBZxMEC+PjbcaJx35YuIdyAk3Fpgnk16hLhq1ragEkgSM0xzvFtYXkOGA5kXH8XfafH0KJDMqG11CvznR8UFnDSl6gqIPbBEOhxF8VFnuLaNM6ZLKV6BRthShFyJd3XlFRSILBKSq0lMhhSxIhblCGjLJDeX9U= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1562789283; 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:ARC-Authentication-Results; bh=wEs77e/GOn5oKUjk2eZvZisqBz48RJYNbFo6EVNN22A=; b=fPTA+w9Wl/+qDval0tvJGCx9L27oY+5HeLX/FCKHNV1palJ/N9Ux17ctj5U/1TFwtgMsk63RHyuHXuaEHvcrsa5HhVoRc0STlhFSsfPi/4EGg247NTf0Nb3iuf6Vg/yvNDfl2tpSquuK9zxYGryLccuWEChjVFW/FQdWQf9gWEE= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 15627892832891023.8962003654188; Wed, 10 Jul 2019 13:08:03 -0700 (PDT) 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 mx1.redhat.com (Postfix) with ESMTPS id 22953307CDEA; Wed, 10 Jul 2019 20:08:01 +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 ECEA319729; Wed, 10 Jul 2019 20:08:00 +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 AA8B7C843; Wed, 10 Jul 2019 20:08:00 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x6AK7skI030808 for ; Wed, 10 Jul 2019 16:07:54 -0400 Received: by smtp.corp.redhat.com (Postfix) id 2064B17D85; Wed, 10 Jul 2019 20:07:54 +0000 (UTC) Received: from aegolius.redhat.com (ovpn-116-68.phx2.redhat.com [10.3.116.68]) by smtp.corp.redhat.com (Postfix) with ESMTPS id DFB6417D76 for ; Wed, 10 Jul 2019 20:07:53 +0000 (UTC) From: Jonathon Jongsma To: libvir-list@redhat.com Date: Wed, 10 Jul 2019 15:07:47 -0500 Message-Id: <20190710200747.745-6-jjongsma@redhat.com> In-Reply-To: <20190710200747.745-1-jjongsma@redhat.com> References: <20190710200747.745-1-jjongsma@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 5/5] qemu: implement virDomainGetGuestUsers 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: , Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.49]); Wed, 10 Jul 2019 20:08:02 +0000 (UTC) Content-Type: text/plain; charset="utf-8" Signed-off-by: Jonathon Jongsma --- src/qemu/qemu_driver.c | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index 5a75f23981..27fcdd393d 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -22201,6 +22201,43 @@ qemuDomainGetLaunchSecurityInfo(virDomainPtr domai= n, return ret; } =20 +static int +qemuDomainGetGuestUsers(virDomainPtr dom, + virDomainUserInfoPtr **info, + unsigned int flags) +{ + virQEMUDriverPtr driver =3D dom->conn->privateData; + virDomainObjPtr vm =3D NULL; + qemuAgentPtr agent; + int ret =3D -1; + + virCheckFlags(0, ret); + + if (!(vm =3D qemuDomObjFromDomain(dom))) + goto cleanup; + + if (virDomainGetGuestUsersEnsureACL(dom->conn, vm->def) < 0) + goto cleanup; + + if (qemuDomainObjBeginAgentJob(driver, vm, QEMU_AGENT_JOB_QUERY) < 0) + goto cleanup; + + if (!qemuDomainAgentAvailable(vm, true)) + goto endjob; + + agent =3D qemuDomainObjEnterAgent(vm); + ret =3D qemuAgentGetUsers(agent, info); + qemuDomainObjExitAgent(vm, agent); + + endjob: + qemuDomainObjEndAgentJob(vm); + + cleanup: + virDomainObjEndAPI(&vm); + return ret; +} + + static virHypervisorDriver qemuHypervisorDriver =3D { .name =3D QEMU_DRIVER_NAME, .connectURIProbe =3D qemuConnectURIProbe, @@ -22428,6 +22465,7 @@ static virHypervisorDriver qemuHypervisorDriver =3D= { .connectBaselineHypervisorCPU =3D qemuConnectBaselineHypervisorCPU, /*= 4.4.0 */ .nodeGetSEVInfo =3D qemuNodeGetSEVInfo, /* 4.5.0 */ .domainGetLaunchSecurityInfo =3D qemuDomainGetLaunchSecurityInfo, /* 4= .5.0 */ + .domainGetGuestUsers =3D qemuDomainGetGuestUsers, /* 5.6.0 */ }; =20 =20 --=20 2.20.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list