From nobody Tue Nov 26 19:58:19 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=1566577897; cv=none; d=zoho.com; s=zohoarc; b=IajHA2k2gUsoo5gVbCHEDh6SLZNqNLfU1g7/nISF2Tl7TzfmnzaxmQlPacQeTOoys8JVb1qr6FubsGqTYjfr0uLq3CcdSifTL86y54sPV61Dvscl2eiWbZiCSi6mz7Qt7FobNRLi7BUlbQ3iVYCtph8MiOWTEFncg3Zlwt+yssI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1566577897; 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=AaGx1kg2UEgZlYSddxGwAt2/jWtu3OFQCVKzim4+100=; b=aR+Vwii+GwsdIbXteTVwhq8vF2fzAW7o1DfgFN0DC7MzoAf259GcjIizTdMBoGFKKo8AZaJBeDZ5o4N6wNvwIbTMuYk1u088D3XEPKZAAck+wd1ANg/BGri6vZTL7uaRFBC1No47eaAnTxH/xpaOmdJXpOH47x9Sx704Niut7k4= 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 1566577897566268.1612794885825; Fri, 23 Aug 2019 09:31:37 -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 674ED30A5A62; Fri, 23 Aug 2019 16:31:36 +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 43BDB5D6B2; Fri, 23 Aug 2019 16:31:36 +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 09998E203; Fri, 23 Aug 2019 16:31:36 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x7NGVZhG006856 for ; Fri, 23 Aug 2019 12:31:35 -0400 Received: by smtp.corp.redhat.com (Postfix) id 2E04D5C1B5; Fri, 23 Aug 2019 16:31:35 +0000 (UTC) Received: from himantopus.redhat.com (ovpn-117-62.phx2.redhat.com [10.3.117.62]) by smtp.corp.redhat.com (Postfix) with ESMTPS id F119B5C3FA for ; Fri, 23 Aug 2019 16:31:32 +0000 (UTC) From: Jonathon Jongsma To: libvir-list@redhat.com Date: Fri, 23 Aug 2019 11:31:16 -0500 Message-Id: <20190823163123.21683-3-jjongsma@redhat.com> In-Reply-To: <20190823163123.21683-1-jjongsma@redhat.com> References: <20190823163123.21683-1-jjongsma@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH v3 2/9] remote: implement virDomainGetGuestInfo 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.47]); Fri, 23 Aug 2019 16:31:36 +0000 (UTC) Content-Type: text/plain; charset="utf-8" Add daemon and client code to serialize/deserialize virDomainGetGuestInfo(). Signed-off-by: Jonathon Jongsma Reviewed-by: Daniel Henrique Barboza Tested-by: Daniel Henrique Barboza --- src/remote/remote_daemon_dispatch.c | 41 ++++++++++++++++++++++ src/remote/remote_driver.c | 53 +++++++++++++++++++++++++++++ src/remote/remote_protocol.x | 21 +++++++++++- src/remote_protocol-structs | 12 +++++++ 4 files changed, 126 insertions(+), 1 deletion(-) diff --git a/src/remote/remote_daemon_dispatch.c b/src/remote/remote_daemon= _dispatch.c index 1bd281dd6d..665d938a99 100644 --- a/src/remote/remote_daemon_dispatch.c +++ b/src/remote/remote_daemon_dispatch.c @@ -7650,3 +7650,44 @@ remoteSerializeDomainDiskErrors(virDomainDiskErrorPt= r errors, } return -1; } + +static int +remoteDispatchDomainGetGuestInfo(virNetServerPtr server ATTRIBUTE_UNUSED, + virNetServerClientPtr client, + virNetMessagePtr msg ATTRIBUTE_UNUSED, + virNetMessageErrorPtr rerr, + remote_domain_get_guest_info_args *args, + remote_domain_get_guest_info_ret *ret) +{ + int rv =3D -1; + struct daemonClientPrivate *priv =3D virNetServerClientGetPrivateData(= client); + virDomainPtr dom =3D NULL; + virTypedParameterPtr params =3D NULL; + int nparams =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 (virDomainGetGuestInfo(dom, args->types, ¶ms, &nparams, args->f= lags) < 0) + goto cleanup; + + if (virTypedParamsSerialize(params, nparams, + (virTypedParameterRemotePtr *) &ret->param= s.params_val, + &ret->params.params_len, + VIR_TYPED_PARAM_STRING_OKAY) < 0) + goto cleanup; + + rv =3D 0; + + cleanup: + if (rv < 0) + virNetMessageSaveError(rerr); + virObjectUnref(dom); + + return rv; +} diff --git a/src/remote/remote_driver.c b/src/remote/remote_driver.c index daac506672..5ba144648a 100644 --- a/src/remote/remote_driver.c +++ b/src/remote/remote_driver.c @@ -8306,6 +8306,58 @@ remoteNetworkPortGetParameters(virNetworkPortPtr por= t, return rv; } =20 +static int +remoteDomainGetGuestInfo(virDomainPtr dom, + unsigned int types, + virTypedParameterPtr *params, + int *nparams, + unsigned int flags) +{ + int rv =3D -1; + struct private_data *priv =3D dom->conn->privateData; + remote_domain_get_guest_info_args args; + remote_domain_get_guest_info_ret ret; + + remoteDriverLock(priv); + + make_nonnull_domain(&args.dom, dom); + + args.types =3D types; + args.flags =3D flags; + + memset(&ret, 0, sizeof(ret)); + + if (call(dom->conn, priv, 0, REMOTE_PROC_DOMAIN_GET_GUEST_INFO, + (xdrproc_t)xdr_remote_domain_get_guest_info_args, (char *)&ar= gs, + (xdrproc_t)xdr_remote_domain_get_guest_info_ret, (char *)&ret= ) =3D=3D -1) + goto done; + + if (ret.params.params_len > REMOTE_DOMAIN_GUEST_INFO_PARAMS_MAX) { + virReportError(VIR_ERR_INTERNAL_ERROR, + _("Too many params in guestinfo: %d for limit %d"), + ret.params.params_len, REMOTE_DOMAIN_GUEST_INFO_PAR= AMS_MAX); + goto cleanup; + } + + if (params) { + if (virTypedParamsDeserialize((virTypedParameterRemotePtr) ret.par= ams.params_val, + ret.params.params_len, + REMOTE_DOMAIN_GUEST_INFO_PARAMS_MAX, + params, + nparams) < 0) + goto cleanup; + } + + rv =3D 0; + + cleanup: + xdr_free((xdrproc_t)xdr_remote_domain_get_guest_info_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. @@ -8733,6 +8785,7 @@ static virHypervisorDriver hypervisor_driver =3D { .domainCheckpointLookupByName =3D remoteDomainCheckpointLookupByName, = /* 5.6.0 */ .domainCheckpointGetParent =3D remoteDomainCheckpointGetParent, /* 5.6= .0 */ .domainCheckpointDelete =3D remoteDomainCheckpointDelete, /* 5.6.0 */ + .domainGetGuestInfo =3D remoteDomainGetGuestInfo, /* 5.6.0 */ }; =20 static virNetworkDriver network_driver =3D { diff --git a/src/remote/remote_protocol.x b/src/remote/remote_protocol.x index 118369e2b3..75c2bc69ff 100644 --- a/src/remote/remote_protocol.x +++ b/src/remote/remote_protocol.x @@ -269,6 +269,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 parameters describing a guest */ +const REMOTE_DOMAIN_GUEST_INFO_PARAMS_MAX =3D 2048; + /* * Upper limit on list of network port parameters */ @@ -3723,6 +3726,16 @@ struct remote_domain_checkpoint_delete_args { unsigned int flags; }; =20 +struct remote_domain_get_guest_info_args { + remote_nonnull_domain dom; + unsigned int types; + unsigned int flags; +}; + +struct remote_domain_get_guest_info_ret { + remote_typed_param params; +}; + /*----- Protocol. -----*/ =20 /* Define the program number, protocol version and procedure numbers here.= */ @@ -6584,5 +6597,11 @@ enum remote_procedure { * @generate: both * @acl: domain:checkpoint */ - REMOTE_PROC_DOMAIN_CHECKPOINT_DELETE =3D 417 + REMOTE_PROC_DOMAIN_CHECKPOINT_DELETE =3D 417, + + /** + * @generate: none + * @acl: domain:write + */ + REMOTE_PROC_DOMAIN_GET_GUEST_INFO =3D 418 }; diff --git a/src/remote_protocol-structs b/src/remote_protocol-structs index a42b4a9671..616c3d5d52 100644 --- a/src/remote_protocol-structs +++ b/src/remote_protocol-structs @@ -3105,6 +3105,17 @@ struct remote_domain_checkpoint_delete_args { remote_nonnull_domain_checkpoint checkpoint; u_int flags; }; +struct remote_domain_get_guest_info_args { + remote_nonnull_domain dom; + u_int types; + u_int flags; +}; +struct remote_domain_get_guest_info_ret { + struct { + u_int params_len; + remote_typed_param * params_val; + } params; +}; enum remote_procedure { REMOTE_PROC_CONNECT_OPEN =3D 1, REMOTE_PROC_CONNECT_CLOSE =3D 2, @@ -3523,4 +3534,5 @@ enum remote_procedure { REMOTE_PROC_DOMAIN_CHECKPOINT_LOOKUP_BY_NAME =3D 415, REMOTE_PROC_DOMAIN_CHECKPOINT_GET_PARENT =3D 416, REMOTE_PROC_DOMAIN_CHECKPOINT_DELETE =3D 417, + REMOTE_PROC_DOMAIN_GET_GUEST_INFO =3D 418, }; --=20 2.21.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list