From nobody Mon Feb 9 15:09:22 2026 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