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