From nobody Sun May 19 01:15:13 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) client-ip=170.10.133.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 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=fail(p=none dis=none) header.from=weirdnatto.in ARC-Seal: i=1; a=rsa-sha256; t=1663813210; cv=none; d=zohomail.com; s=zohoarc; b=KXKRQY1sOPwPaKz/G+UfcJSspHpfzNviGNR2tIwW3E90S+1D1xFvauHt/GiACgtuLv9KV8skWZ5n++U40pfFdrobBA4Yms93+Dk7q/QDHDk5fjWVTgPf7Fr/gPIu9aOFB9BNK+5DoNGRYcOX60rAsPcZve8prcTh1KKlm4/eX2E= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1663813210; h=Content-Type:Content-Transfer-Encoding:Cc: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=JFBCI9OgJC1r+pAXEXBQPCxV1YXU7zRM/Rc7SVS2sH4=; b=HA6Inctn0wSvWBnOaG4C6zgsgCmLNP8bb0qpmy51ohKMxQ3RgMyApsO74GiEjfMXsjs94To9IsHNVxHa09w/UkkqQFf78IVTS7Rc7kAWJECkBpdcywOOPCXvjHQwoVP8H069ppsc1oTcufVKRpugnhvdvCcCezBTlaCfRfcRJ2s= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=fail header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mx.zohomail.com with SMTPS id 1663813210060523.376818679322; Wed, 21 Sep 2022 19:20:10 -0700 (PDT) Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-346-CRh0jk4hNzqHz0oGkKLRSw-1; Wed, 21 Sep 2022 22:20:05 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id C4301380408D; Thu, 22 Sep 2022 02:20:03 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (unknown [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id AC068112131B; Thu, 22 Sep 2022 02:20:03 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 7302D1946A67; Thu, 22 Sep 2022 02:20:03 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id A527F19465B1 for ; Thu, 22 Sep 2022 02:20:02 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 967FE40C6EC6; Thu, 22 Sep 2022 02:20:02 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast09.extmail.prod.ext.rdu2.redhat.com [10.11.55.25]) by smtp.corp.redhat.com (Postfix) with ESMTPS id D1D6140C6E13 for ; Thu, 22 Sep 2022 02:20:01 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [205.139.110.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 5E3BB294EDE6 for ; Thu, 22 Sep 2022 02:20:01 +0000 (UTC) Received: from mail.weirdnatto.in (140.238.225.67 [140.238.225.67]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-484-o4Vp7CoTPqWiABke1ZdfdQ-1; Wed, 21 Sep 2022 22:19:57 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1663813209; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc: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=JFBCI9OgJC1r+pAXEXBQPCxV1YXU7zRM/Rc7SVS2sH4=; b=gysCT4XOJxvqTDvKqy5gJrD4snLEh3AjqBQM2zoDo8dyqJhlpqhJ3xxBPdTYo/MfKSq9EG nulgJijkSUpjbowWc12KGhPs2FJW7o37aHlTO7UXFWA3ZinZti/W1m/b64Cwc0TLgw9QzK GDHB7Ad0ahVVKU49uHUw8Q7gDiGbn2U= X-MC-Unique: CRh0jk4hNzqHz0oGkKLRSw-1 X-Original-To: libvir-list@listman.corp.redhat.com X-MC-Unique: o4Vp7CoTPqWiABke1ZdfdQ-1 From: Amneesh Singh To: libvir-list@redhat.com Subject: [RFC PATCH 1/5] virtypedparam: add virHistogram as a virTypedParameterType Date: Thu, 22 Sep 2022 07:48:59 +0530 Message-Id: <20220922021903.376973-2-natto@weirdnatto.in> In-Reply-To: <20220922021903.376973-1-natto@weirdnatto.in> References: <20220922021903.376973-1-natto@weirdnatto.in> MIME-Version: 1.0 X-Mimecast-Impersonation-Protect: Policy=CLT - Impersonation Protection Definition; Similar Internal Domain=false; Similar Monitored External Domain=false; Custom External Domain=false; Mimecast External Domain=false; Newly Observed Domain=false; Internal User Name=false; Custom Display Name List=false; Reply-to Address Mismatch=false; Targeted Threat Dictionary=false; Mimecast Threat Dictionary=false; Custom Threat Dictionary=false X-Scanned-By: MIMEDefang 3.1 on 10.11.54.2 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: mkletzan@redhat.com, pbonzini@redhat.com, Amneesh Singh Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 3.1 on 10.11.54.3 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1663813211544100003 Content-Type: text/plain; charset="utf-8"; x-default="true" This patch adds virHistogram, a list of (x,y) pairs denoting a histogram as a virTypedParameterType. Signed-off-by: Amneesh Singh --- include/libvirt/libvirt-common.h.in | 54 +++++++++-- src/libvirt_private.syms | 7 ++ src/libvirt_public.syms | 6 ++ src/util/virtypedparam-public.c | 101 ++++++++++++++++++++ src/util/virtypedparam.c | 138 ++++++++++++++++++++++++++++ src/util/virtypedparam.h | 22 +++++ tools/vsh.c | 5 + 7 files changed, 326 insertions(+), 7 deletions(-) diff --git a/include/libvirt/libvirt-common.h.in b/include/libvirt/libvirt-= common.h.in index ccdbb2a100..11338d9191 100644 --- a/include/libvirt/libvirt-common.h.in +++ b/include/libvirt/libvirt-common.h.in @@ -128,6 +128,35 @@ typedef enum { # endif } virConnectCloseReason; =20 +/** + * virHistogramBucket: + * + * Simple wrapper for containing the values corresponding to the X and Y a= xes + * of a histogram entry. + * + * Since: 8.8.0 + */ +typedef struct _virHistogramBucket virHistogramBucket; + +struct _virHistogramBucket { + long long x; + long long y; +}; + +/** + * virHistogram: + * + * Contains a list of virHistogramBuckets to represent a histogram. + * + * Since: 8.8.0 + */ +typedef struct _virHistogram virHistogram; + +struct _virHistogram { + size_t nbuckets; + virHistogramBucket *buckets; +}; + /** * virTypedParameterType: * @@ -136,13 +165,14 @@ typedef enum { * Since: 0.9.2 */ typedef enum { - VIR_TYPED_PARAM_INT =3D 1, /* integer case (Since: 0.9.2) */ - VIR_TYPED_PARAM_UINT =3D 2, /* unsigned integer case (Since: 0.9.2)= */ - VIR_TYPED_PARAM_LLONG =3D 3, /* long long case (Since: 0.9.2) */ - VIR_TYPED_PARAM_ULLONG =3D 4, /* unsigned long long case (Since: 0.9.= 2) */ - VIR_TYPED_PARAM_DOUBLE =3D 5, /* double case (Since: 0.9.2) */ - VIR_TYPED_PARAM_BOOLEAN =3D 6, /* boolean(character) case (Since: 0.9.= 2) */ - VIR_TYPED_PARAM_STRING =3D 7, /* string case (Since: 0.9.8) */ + VIR_TYPED_PARAM_INT =3D 1, /* integer case (Since: 0.9.2) */ + VIR_TYPED_PARAM_UINT =3D 2, /* unsigned integer case (Since: 0.9.= 2) */ + VIR_TYPED_PARAM_LLONG =3D 3, /* long long case (Since: 0.9.2) */ + VIR_TYPED_PARAM_ULLONG =3D 4, /* unsigned long long case (Since: 0.= 9.2) */ + VIR_TYPED_PARAM_DOUBLE =3D 5, /* double case (Since: 0.9.2) */ + VIR_TYPED_PARAM_BOOLEAN =3D 6, /* boolean(character) case (Since: 0.= 9.2) */ + VIR_TYPED_PARAM_STRING =3D 7, /* string case (Since: 0.9.8) */ + VIR_TYPED_PARAM_HISTOGRAM =3D 8, /* histogram case (Since: 8.8.0) */ =20 # ifdef VIR_ENUM_SENTINELS VIR_TYPED_PARAM_LAST /* (Since: 0.9.10) */ @@ -211,6 +241,7 @@ struct _virTypedParameter { double d; /* type is DOUBLE */ char b; /* type is BOOLEAN */ char *s; /* type is STRING, may not be NULL */ + virHistogram *h; /* type is HISTOGRAM, may not be NULL = */ } value; /* parameter value */ }; =20 @@ -254,6 +285,10 @@ int virTypedParamsGetString(virTypedParameterPtr param= s, int nparams, const char *name, const char **value); +int virTypedParamsGetHistogram(virTypedParameterPtr params, + int nparams, + const char *name, + virHistogram **value); =20 int virTypedParamsAddInt(virTypedParameterPtr *params, int *nparams, @@ -290,6 +325,11 @@ int virTypedParamsAddString(virTypedParameterPtr *para= ms, int *maxparams, const char *name, const char *value); +int virTypedParamsAddHistogram(virTypedParameterPtr *params, + int *nparams, + int *maxparams, + const char *name, + virHistogram *value); int virTypedParamsAddStringList(virTypedParameterPtr *params, int *nparams, int *maxparams, diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index 25794bc2f4..c60b21babe 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -3517,12 +3517,19 @@ virTPMSwtpmSetupFeatureTypeFromString; =20 =20 # util/virtypedparam.h +virHistogramBucketToString; +virHistogramCopy; +virHistogramFree; +virHistogramFromString; +virHistogramNew; +virHistogramToString; virTypedParameterAssign; virTypedParameterToString; virTypedParameterTypeFromString; virTypedParameterTypeToString; virTypedParamListAddBoolean; virTypedParamListAddDouble; +virTypedParamListAddHistogram; virTypedParamListAddInt; virTypedParamListAddLLong; virTypedParamListAddString; diff --git a/src/libvirt_public.syms b/src/libvirt_public.syms index 297a2c436a..e5c04bd992 100644 --- a/src/libvirt_public.syms +++ b/src/libvirt_public.syms @@ -927,4 +927,10 @@ LIBVIRT_8.5.0 { virDomainAbortJobFlags; } LIBVIRT_8.4.0; =20 +LIBVIRT_8.8.0 { + global: + virTypedParamsAddHistogram; + virTypedParamsGetHistogram; +} LIBVIRT_8.5.0; + # .... define new API here using predicted next version number .... diff --git a/src/util/virtypedparam-public.c b/src/util/virtypedparam-publi= c.c index 5bd207d1e6..d9336337c3 100644 --- a/src/util/virtypedparam-public.c +++ b/src/util/virtypedparam-public.c @@ -106,6 +106,9 @@ virTypedParameterAssignFromStr(virTypedParameterPtr par= am, case VIR_TYPED_PARAM_STRING: param->value.s =3D g_strdup(val); break; + case VIR_TYPED_PARAM_HISTOGRAM: + param->value.h =3D virHistogramFromString(val); + break; default: virReportError(VIR_ERR_INTERNAL_ERROR, _("unexpected type %d for field %s"), type, name); @@ -432,6 +435,46 @@ virTypedParamsGetString(virTypedParameterPtr params, } =20 =20 +/** + * virTypedParamsGetHistogram: + * @params: array of typed parameters + * @nparams: number of parameters in the @params array + * @name: name of the parameter to find + * @value: where to store the parameter's value + * + * Finds typed parameter called @name and store its virHistogram * value i= n @value. + * The function does not create a copy of the string and the caller must n= ot + * free the virHistogram @value points to. The function fails with + * VIR_ERR_INVALID_ARG error if the parameter does not have the expected t= ype. + * By passing NULL as @value, the function may be used to check presence a= nd + * type of the parameter. + * + * Returns 1 on success, 0 when the parameter does not exist in @params, or + * -1 on error. + * + * Since: 8.8.0 + */ +int +virTypedParamsGetHistogram(virTypedParameterPtr params, + int nparams, + const char *name, + virHistogram **value) +{ + virTypedParameterPtr param; + + virResetLastError(); + + if (!(param =3D virTypedParamsGet(params, nparams, name))) + return 0; + + VIR_TYPED_PARAM_CHECK_TYPE(VIR_TYPED_PARAM_HISTOGRAM); + if (value) + *value =3D param->value.h; + + return 1; +} + + /** * virTypedParamsAddInt: * @params: pointer to the array of typed parameters @@ -774,6 +817,62 @@ virTypedParamsAddString(virTypedParameterPtr *params, return -1; } =20 + +/** + * virTypedParamsAddHistogram: + * @params: pointer to the array of typed parameters + * @nparams: number of parameters in the @params array + * @maxparams: maximum number of parameters that can be stored in @params + * array without allocating more memory + * @name: name of the parameter to find + * @value: the value to store into the new parameter + * + * Adds new parameter called @name with virHistogram * type and sets its v= alue to + * @value. The function creates its own copy of virHistogram, which needs = to + * be freed using virTypedParamsFree or virTypedParamsClear. If @params ar= ray + * points to NULL or to a space that is not large enough to accommodate the + * new parameter (@maxparams < @nparams + 1), the function allocates more + * space for it and updates @maxparams. On success, @nparams is incremented + * by one. The function fails with VIR_ERR_INVALID_ARG error if the parame= ter + * already exists in @params. + * + * Returns 0 on success, -1 on error. + * + * Since: 8.8.0 + */ +int +virTypedParamsAddHistogram(virTypedParameterPtr *params, + int *nparams, + int *maxparams, + const char *name, + virHistogram *value) +{ + virHistogram *copy =3D NULL; + size_t max =3D *maxparams; + size_t n =3D *nparams; + + virResetLastError(); + + VIR_RESIZE_N(*params, max, n, 1); + *maxparams =3D max; + + copy =3D virHistogramCopy(value); + + if (virTypedParameterAssign(*params + n, name, + VIR_TYPED_PARAM_HISTOGRAM, copy) < 0) { + virHistogramFree(copy); + goto error; + } + + *nparams +=3D 1; + return 0; + + error: + virDispatchError(NULL); + return -1; +} + + /** * virTypedParamsAddStringList: * @params: array of typed parameters @@ -889,6 +988,8 @@ virTypedParamsClear(virTypedParameterPtr params, for (i =3D 0; i < nparams; i++) { if (params[i].type =3D=3D VIR_TYPED_PARAM_STRING) VIR_FREE(params[i].value.s); + else if (params[i].type =3D=3D VIR_TYPED_PARAM_HISTOGRAM) + virHistogramFree(params[i].value.h); } } =20 diff --git a/src/util/virtypedparam.c b/src/util/virtypedparam.c index 2d7e4ab354..87fa69271b 100644 --- a/src/util/virtypedparam.c +++ b/src/util/virtypedparam.c @@ -40,6 +40,7 @@ VIR_ENUM_IMPL(virTypedParameter, "double", "boolean", "string", + "histogram", ); =20 static int @@ -166,6 +167,71 @@ virTypedParamsCheck(virTypedParameterPtr params, return true; } =20 + +char * +virHistogramBucketToString(virHistogramBucket *bucket) { + if (!bucket) + return NULL; + + return g_strdup_printf("(%lld - %lld)", bucket->x, bucket->y); +} + + +char * +virHistogramToString(virHistogram *histogram) +{ + size_t i; + g_autoptr(GString) value =3D g_string_new(""); + + if (!histogram) + return NULL; + + if (histogram->nbuckets =3D=3D 0) + return g_strdup(""); + + for (i =3D 0; i < histogram->nbuckets; i++) { + g_autofree char *bucket_str =3D virHistogramBucketToString(histogr= am->buckets + i); + + g_string_append(value, bucket_str); + + if (i !=3D histogram->nbuckets - 1) + g_string_append(value, ", "); + } + + return g_strdup(value->str); +} + + +virHistogram * +virHistogramFromString(const char *str) +{ + g_auto(GStrv) split_str =3D g_strsplit(str, ",", -1); + g_autoptr(virHistogram) hist =3D NULL; + unsigned int len; + size_t i; + + if (split_str =3D=3D NULL) + return NULL; + + len =3D g_strv_length(split_str); + hist =3D virHistogramNew(len); + + for (i =3D 0; i < len; i++) { + virHistogramBucket *bucket =3D hist->buckets + i; + long long x, y; + + if (sscanf(split_str[i], + " (%lld - %lld)", + &x, &y) < 2) + return NULL; + + bucket->x =3D x; + bucket->y =3D y; + } + + return g_steal_pointer(&hist); +} + char * virTypedParameterToString(virTypedParameterPtr param) { @@ -193,6 +259,9 @@ virTypedParameterToString(virTypedParameterPtr param) case VIR_TYPED_PARAM_STRING: value =3D g_strdup(param->value.s); break; + case VIR_TYPED_PARAM_HISTOGRAM: + value =3D virHistogramToString(param->value.h); + break; default: virReportError(VIR_ERR_INTERNAL_ERROR, _("unexpected type %d for field %s"), @@ -239,6 +308,9 @@ virTypedParameterAssignValueVArgs(virTypedParameterPtr = param, if (!param->value.s) param->value.s =3D g_strdup(""); break; + case VIR_TYPED_PARAM_HISTOGRAM: + param->value.h =3D va_arg(ap, virHistogram *); + break; default: virReportError(VIR_ERR_INTERNAL_ERROR, _("unexpected type %d for field %s"), type, @@ -347,6 +419,42 @@ virTypedParamsReplaceString(virTypedParameterPtr *para= ms, } =20 =20 +virHistogram * +virHistogramNew(size_t size) +{ + virHistogram *histogram =3D g_new(virHistogram, 1); + histogram->nbuckets =3D size; + histogram->buckets =3D g_new0(virHistogramBucket, size); + + return histogram; +} + + +void +virHistogramFree(virHistogram *histogram) +{ + g_free(histogram->buckets); + g_free(histogram); +} + + +virHistogram * +virHistogramCopy(virHistogram *src) +{ + virHistogram *dst =3D NULL; + + if (!src) + return NULL; + + dst =3D g_new0(virHistogram, 1); + dst->nbuckets =3D src->nbuckets; + dst->buckets =3D g_new0(virHistogramBucket, dst->nbuckets); + memcpy(dst->buckets, src->buckets, dst->nbuckets * sizeof(virHistogram= Bucket)); + + return g_steal_pointer(&dst); +} + + int virTypedParamsCopy(virTypedParameterPtr *dst, virTypedParameterPtr src, @@ -365,6 +473,8 @@ virTypedParamsCopy(virTypedParameterPtr *dst, (*dst)[i].type =3D src[i].type; if (src[i].type =3D=3D VIR_TYPED_PARAM_STRING) { (*dst)[i].value.s =3D g_strdup(src[i].value.s); + } else if (src[i].type =3D=3D VIR_TYPED_PARAM_HISTOGRAM) { + (*dst)[i].value.h =3D virHistogramCopy(src[i].value.h); } else { (*dst)[i].value =3D src[i].value; } @@ -486,6 +596,8 @@ virTypedParamsRemoteFree(struct _virTypedParameterRemot= e *remote_params_val, g_free(remote_params_val[i].field); if (remote_params_val[i].value.type =3D=3D VIR_TYPED_PARAM_STRING) g_free(remote_params_val[i].value.remote_typed_param_value.s); + else if (remote_params_val[i].value.type =3D=3D VIR_TYPED_PARAM_HI= STOGRAM) + g_free(remote_params_val[i].value.remote_typed_param_value.h); } g_free(remote_params_val); } @@ -591,6 +703,9 @@ virTypedParamsDeserialize(struct _virTypedParameterRemo= te *remote_params, case VIR_TYPED_PARAM_STRING: param->value.s =3D g_strdup(remote_param->value.remote_typed_p= aram_value.s); break; + case VIR_TYPED_PARAM_HISTOGRAM: + param->value.h =3D virHistogramCopy(remote_param->value.remote= _typed_param_value.h); + break; default: virReportError(VIR_ERR_RPC, _("unknown parameter type: %d"), param->type); @@ -696,6 +811,9 @@ virTypedParamsSerialize(virTypedParameterPtr params, case VIR_TYPED_PARAM_STRING: val->value.remote_typed_param_value.s =3D g_strdup(param->valu= e.s); break; + case VIR_TYPED_PARAM_HISTOGRAM: + val->value.remote_typed_param_value.h =3D virHistogramCopy(par= am->value.h); + break; default: virReportError(VIR_ERR_RPC, _("unknown parameter type: %d"), param->type); @@ -929,3 +1047,23 @@ virTypedParamListAddDouble(virTypedParamList *list, =20 return ret; } + +int virTypedParamListAddHistogram(virTypedParamList *list, + virHistogram *value, + const char *namefmt, + ...) +{ + virTypedParameterPtr par; + va_list ap; + int ret; + + if (!(par =3D virTypedParamListExtend(list)) || + virTypedParameterAssignValue(par, true, VIR_TYPED_PARAM_HISTOGRAM,= value) < 0) + return -1; + + va_start(ap, namefmt); + ret =3D virTypedParamSetNameVPrintf(par, namefmt, ap); + va_end(ap); + + return ret; +} diff --git a/src/util/virtypedparam.h b/src/util/virtypedparam.h index c4bc58ee8f..8138197493 100644 --- a/src/util/virtypedparam.h +++ b/src/util/virtypedparam.h @@ -45,6 +45,7 @@ struct _virTypedParameterRemoteValue { double d; char b; char *s; + virHistogram *h; } remote_typed_param_value; }; =20 @@ -86,10 +87,25 @@ int virTypedParamsReplaceString(virTypedParameterPtr *p= arams, const char *name, const char *value); =20 +virHistogram *virHistogramNew(size_t size); + +void virHistogramFree(virHistogram *histogram); + +G_DEFINE_AUTOPTR_CLEANUP_FUNC(virHistogram, + virHistogramFree); + +virHistogram *virHistogramCopy(virHistogram *src); + int virTypedParamsCopy(virTypedParameterPtr *dst, virTypedParameterPtr src, int nparams); =20 +char *virHistogramBucketToString(virHistogramBucket *bucket); + +char *virHistogramToString(virHistogram *histogram); + +virHistogram *virHistogramFromString(const char *str); + char *virTypedParameterToString(virTypedParameterPtr param); =20 void virTypedParamsRemoteFree(struct _virTypedParameterRemote *remote_para= ms_val, @@ -177,3 +193,9 @@ int virTypedParamListAddDouble(virTypedParamList *list, const char *namefmt, ...) G_GNUC_PRINTF(3, 4) G_GNUC_WARN_UNUSED_RESULT; + +int virTypedParamListAddHistogram(virTypedParamList *list, + virHistogram *value, + const char *namefmt, + ...) + G_GNUC_PRINTF(3, 4) G_GNUC_WARN_UNUSED_RESULT; diff --git a/tools/vsh.c b/tools/vsh.c index 0066504ebe..d808524568 100644 --- a/tools/vsh.c +++ b/tools/vsh.c @@ -45,6 +45,7 @@ #include "vircommand.h" #include "virstring.h" #include "virutil.h" +#include "virtypedparam.h" =20 #ifdef WITH_READLINE /* For autocompletion */ @@ -1835,6 +1836,10 @@ vshGetTypedParamValue(vshControl *ctl, virTypedParam= eterPtr item) return g_strdup(item->value.s); break; =20 + case VIR_TYPED_PARAM_HISTOGRAM: + return virHistogramToString(item->value.h); + break; + default: vshError(ctl, _("unimplemented parameter type %d"), item->type); exit(EXIT_FAILURE); --=20 2.37.1 From nobody Sun May 19 01:15:13 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) client-ip=170.10.129.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 170.10.129.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=fail(p=none dis=none) header.from=weirdnatto.in ARC-Seal: i=1; a=rsa-sha256; t=1663813211; cv=none; d=zohomail.com; s=zohoarc; b=ncSQXRG+vlESCzcR8nL3p/Dtg5GhGN9cKiI/6P9Z1XXLaY3h/IvRAuqV/sAKXuzZcOzucvpQ2avPo0s/vS8zBP4Jn4eUZZ+klqQ9Lj5z2Iy0q2iBfEKU4wk/Q+JT0kDw+hAebkQU40SrnOWWpLRL9w0M/nIoRiOForSUg9Kofp8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1663813211; h=Content-Type:Content-Transfer-Encoding:Cc: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=UxC6d/mgyKDkIoLaVzzygutXAow0At6Av6Efd+4ppaE=; b=ejPYg388/+ZoVu0cFqm4VvyMtD4p1rwhMDEhJVjZt6aTpWm3czu6mAIeXQSPUnx/KPeiJFOStc3FEDlQoJHh3qrrIWXX0D4sWhDIkMOb9Cox4MEPLkhmFLCc1P1wwX8TNlpcVsYkOvg7ErpB8nJC0ZbLqmixTfJDzJ2MeeOIIs4= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=fail header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by mx.zohomail.com with SMTPS id 1663813211119717.4945390370091; Wed, 21 Sep 2022 19:20:11 -0700 (PDT) Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-447-ePfwaxT_M5G5dd6bO4cL-A-1; Wed, 21 Sep 2022 22:20:06 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 475AF3804080; Thu, 22 Sep 2022 02:20:03 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (unknown [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id 334E640C2064; Thu, 22 Sep 2022 02:20:03 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 1FE4419465A4; Thu, 22 Sep 2022 02:20:03 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.rdu2.redhat.com [10.11.54.7]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 55E3219465A4 for ; Thu, 22 Sep 2022 02:20:02 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 3940C1400AFC; Thu, 22 Sep 2022 02:20:02 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast02.extmail.prod.ext.rdu2.redhat.com [10.11.55.18]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 3246C140EBF6 for ; Thu, 22 Sep 2022 02:20:02 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [205.139.110.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 17CB7801231 for ; Thu, 22 Sep 2022 02:20:02 +0000 (UTC) Received: from mail.weirdnatto.in (140.238.225.67 [140.238.225.67]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-150-mHsghstUP7a--TsmoNF0GQ-1; Wed, 21 Sep 2022 22:19:58 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1663813210; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc: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=UxC6d/mgyKDkIoLaVzzygutXAow0At6Av6Efd+4ppaE=; b=PU7+eg3Apv3En+G8NQqlv0QQVQZAwYEuDXVYuDlbZqaH0dpCGf3xd8fOKQURHhdgWuhmj2 3NMSI0dEzT+KOnvhE2Hn+vttqkImKHLkka4ehZf1aciSoRqMHlz4K7OotzrgDl3cba5mqv n/UE5kcrX3cA/RSF9xwkD39PdS/Y2V8= X-MC-Unique: ePfwaxT_M5G5dd6bO4cL-A-1 X-Original-To: libvir-list@listman.corp.redhat.com X-MC-Unique: mHsghstUP7a--TsmoNF0GQ-1 From: Amneesh Singh To: libvir-list@redhat.com Subject: [RFC PATCH 2/5] add a global feature for supporting virHistogram Date: Thu, 22 Sep 2022 07:49:00 +0530 Message-Id: <20220922021903.376973-3-natto@weirdnatto.in> In-Reply-To: <20220922021903.376973-1-natto@weirdnatto.in> References: <20220922021903.376973-1-natto@weirdnatto.in> MIME-Version: 1.0 X-Mimecast-Impersonation-Protect: Policy=CLT - Impersonation Protection Definition; Similar Internal Domain=false; Similar Monitored External Domain=false; Custom External Domain=false; Mimecast External Domain=false; Newly Observed Domain=false; Internal User Name=false; Custom Display Name List=false; Reply-to Address Mismatch=false; Targeted Threat Dictionary=false; Mimecast Threat Dictionary=false; Custom Threat Dictionary=false X-Scanned-By: MIMEDefang 3.1 on 10.11.54.7 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: mkletzan@redhat.com, pbonzini@redhat.com, Amneesh Singh Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 3.1 on 10.11.54.1 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1663813211549100004 Content-Type: text/plain; charset="utf-8"; x-default="true" Signed-off-by: Amneesh Singh --- src/ch/ch_driver.c | 1 + src/driver.c | 1 + src/esx/esx_driver.c | 1 + src/libvirt_internal.h | 5 +++++ src/libxl/libxl_driver.c | 1 + src/lxc/lxc_driver.c | 1 + src/network/bridge_driver.c | 1 + src/openvz/openvz_driver.c | 1 + src/qemu/qemu_driver.c | 1 + src/remote/remote_daemon_dispatch.c | 1 + src/test/test_driver.c | 1 + src/vz/vz_driver.c | 1 + 12 files changed, 16 insertions(+) diff --git a/src/ch/ch_driver.c b/src/ch/ch_driver.c index db2a66d131..80afc4a870 100644 --- a/src/ch/ch_driver.c +++ b/src/ch/ch_driver.c @@ -927,6 +927,7 @@ chConnectSupportsFeature(virConnectPtr conn, case VIR_DRV_FEATURE_REMOTE_CLOSE_CALLBACK: case VIR_DRV_FEATURE_REMOTE_EVENT_CALLBACK: case VIR_DRV_FEATURE_TYPED_PARAM_STRING: + case VIR_DRV_FEATURE_TYPED_PARAM_HISTOGRAM: case VIR_DRV_FEATURE_NETWORK_UPDATE_HAS_CORRECT_ORDER: case VIR_DRV_FEATURE_FD_PASSING: virReportError(VIR_ERR_CONFIG_UNSUPPORTED, diff --git a/src/driver.c b/src/driver.c index cea74bdf95..99ff963d2e 100644 --- a/src/driver.c +++ b/src/driver.c @@ -357,6 +357,7 @@ virDriverFeatureIsGlobal(virDrvFeature feat, * At this point everything supports them and thus also drivers need to * always advertise this feature */ case VIR_DRV_FEATURE_TYPED_PARAM_STRING: + case VIR_DRV_FEATURE_TYPED_PARAM_HISTOGRAM: /* Feature flag exposes that the accidental switching of order of argu= ments * in the public API trampoline virNetworkUpdate is known. Updated cli= ents * thus use the correct ordering with an updated server. All drivers m= ust diff --git a/src/esx/esx_driver.c b/src/esx/esx_driver.c index 9dc5489411..b8bac39c5b 100644 --- a/src/esx/esx_driver.c +++ b/src/esx/esx_driver.c @@ -1028,6 +1028,7 @@ esxConnectSupportsFeature(virConnectPtr conn, int fea= ture) case VIR_DRV_FEATURE_REMOTE_CLOSE_CALLBACK: case VIR_DRV_FEATURE_REMOTE_EVENT_CALLBACK: case VIR_DRV_FEATURE_TYPED_PARAM_STRING: + case VIR_DRV_FEATURE_TYPED_PARAM_HISTOGRAM: case VIR_DRV_FEATURE_NETWORK_UPDATE_HAS_CORRECT_ORDER: case VIR_DRV_FEATURE_FD_PASSING: virReportError(VIR_ERR_CONFIG_UNSUPPORTED, diff --git a/src/libvirt_internal.h b/src/libvirt_internal.h index 1ae3e2b2e0..b8b4525e6d 100644 --- a/src/libvirt_internal.h +++ b/src/libvirt_internal.h @@ -132,6 +132,11 @@ typedef enum { * Whether the virNetworkUpdate() API implementation passes arguments = to * the driver's callback in correct order. */ VIR_DRV_FEATURE_NETWORK_UPDATE_HAS_CORRECT_ORDER =3D 16, + + /* + * Support for VIR_TYPED_PARAM_HISTOGRAM + */ + VIR_DRV_FEATURE_TYPED_PARAM_HISTOGRAM =3D 17, } virDrvFeature; =20 =20 diff --git a/src/libxl/libxl_driver.c b/src/libxl/libxl_driver.c index 1b8b40e9e0..f3d47c83a5 100644 --- a/src/libxl/libxl_driver.c +++ b/src/libxl/libxl_driver.c @@ -5698,6 +5698,7 @@ libxlConnectSupportsFeature(virConnectPtr conn, int f= eature) case VIR_DRV_FEATURE_REMOTE_CLOSE_CALLBACK: case VIR_DRV_FEATURE_REMOTE_EVENT_CALLBACK: case VIR_DRV_FEATURE_TYPED_PARAM_STRING: + case VIR_DRV_FEATURE_TYPED_PARAM_HISTOGRAM: case VIR_DRV_FEATURE_NETWORK_UPDATE_HAS_CORRECT_ORDER: case VIR_DRV_FEATURE_FD_PASSING: virReportError(VIR_ERR_CONFIG_UNSUPPORTED, diff --git a/src/lxc/lxc_driver.c b/src/lxc/lxc_driver.c index d66c26221c..76cd612447 100644 --- a/src/lxc/lxc_driver.c +++ b/src/lxc/lxc_driver.c @@ -1622,6 +1622,7 @@ lxcConnectSupportsFeature(virConnectPtr conn, int fea= ture) case VIR_DRV_FEATURE_REMOTE_CLOSE_CALLBACK: case VIR_DRV_FEATURE_REMOTE_EVENT_CALLBACK: case VIR_DRV_FEATURE_TYPED_PARAM_STRING: + case VIR_DRV_FEATURE_TYPED_PARAM_HISTOGRAM: case VIR_DRV_FEATURE_NETWORK_UPDATE_HAS_CORRECT_ORDER: case VIR_DRV_FEATURE_FD_PASSING: virReportError(VIR_ERR_CONFIG_UNSUPPORTED, diff --git a/src/network/bridge_driver.c b/src/network/bridge_driver.c index 7c6430b4e3..fe5ee1f781 100644 --- a/src/network/bridge_driver.c +++ b/src/network/bridge_driver.c @@ -825,6 +825,7 @@ networkConnectSupportsFeature(virConnectPtr conn, int f= eature) case VIR_DRV_FEATURE_REMOTE_CLOSE_CALLBACK: case VIR_DRV_FEATURE_REMOTE_EVENT_CALLBACK: case VIR_DRV_FEATURE_TYPED_PARAM_STRING: + case VIR_DRV_FEATURE_TYPED_PARAM_HISTOGRAM: case VIR_DRV_FEATURE_NETWORK_UPDATE_HAS_CORRECT_ORDER: case VIR_DRV_FEATURE_FD_PASSING: virReportError(VIR_ERR_CONFIG_UNSUPPORTED, diff --git a/src/openvz/openvz_driver.c b/src/openvz/openvz_driver.c index 5c18f5238b..2a7fbd3bde 100644 --- a/src/openvz/openvz_driver.c +++ b/src/openvz/openvz_driver.c @@ -1914,6 +1914,7 @@ openvzConnectSupportsFeature(virConnectPtr conn G_GNU= C_UNUSED, int feature) case VIR_DRV_FEATURE_REMOTE_CLOSE_CALLBACK: case VIR_DRV_FEATURE_REMOTE_EVENT_CALLBACK: case VIR_DRV_FEATURE_TYPED_PARAM_STRING: + case VIR_DRV_FEATURE_TYPED_PARAM_HISTOGRAM: case VIR_DRV_FEATURE_NETWORK_UPDATE_HAS_CORRECT_ORDER: case VIR_DRV_FEATURE_FD_PASSING: virReportError(VIR_ERR_CONFIG_UNSUPPORTED, diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index 8370b8593b..52e1f88568 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -1187,6 +1187,7 @@ qemuConnectSupportsFeature(virConnectPtr conn, int fe= ature) case VIR_DRV_FEATURE_REMOTE_CLOSE_CALLBACK: case VIR_DRV_FEATURE_REMOTE_EVENT_CALLBACK: case VIR_DRV_FEATURE_TYPED_PARAM_STRING: + case VIR_DRV_FEATURE_TYPED_PARAM_HISTOGRAM: case VIR_DRV_FEATURE_NETWORK_UPDATE_HAS_CORRECT_ORDER: case VIR_DRV_FEATURE_FD_PASSING: virReportError(VIR_ERR_CONFIG_UNSUPPORTED, diff --git a/src/remote/remote_daemon_dispatch.c b/src/remote/remote_daemon= _dispatch.c index 7efe58b36b..a5837dce26 100644 --- a/src/remote/remote_daemon_dispatch.c +++ b/src/remote/remote_daemon_dispatch.c @@ -4969,6 +4969,7 @@ static int remoteDispatchConnectSupportsFeature(virNe= tServer *server G_GNUC_UNUS case VIR_DRV_FEATURE_MIGRATION_V3: case VIR_DRV_FEATURE_MIGRATE_CHANGE_PROTECTION: case VIR_DRV_FEATURE_TYPED_PARAM_STRING: + case VIR_DRV_FEATURE_TYPED_PARAM_HISTOGRAM: case VIR_DRV_FEATURE_XML_MIGRATABLE: case VIR_DRV_FEATURE_MIGRATION_OFFLINE: case VIR_DRV_FEATURE_MIGRATION_PARAMS: diff --git a/src/test/test_driver.c b/src/test/test_driver.c index 686ff051a8..795c8e0798 100644 --- a/src/test/test_driver.c +++ b/src/test/test_driver.c @@ -1666,6 +1666,7 @@ testConnectSupportsFeature(virConnectPtr conn G_GNUC_= UNUSED, =20 switch ((virDrvFeature) feature) { case VIR_DRV_FEATURE_TYPED_PARAM_STRING: + case VIR_DRV_FEATURE_TYPED_PARAM_HISTOGRAM: case VIR_DRV_FEATURE_NETWORK_UPDATE_HAS_CORRECT_ORDER: return 1; case VIR_DRV_FEATURE_MIGRATION_V2: diff --git a/src/vz/vz_driver.c b/src/vz/vz_driver.c index 4f5e340d53..bcc4073520 100644 --- a/src/vz/vz_driver.c +++ b/src/vz/vz_driver.c @@ -3021,6 +3021,7 @@ vzConnectSupportsFeature(virConnectPtr conn G_GNUC_UN= USED, int feature) case VIR_DRV_FEATURE_REMOTE_CLOSE_CALLBACK: case VIR_DRV_FEATURE_REMOTE_EVENT_CALLBACK: case VIR_DRV_FEATURE_TYPED_PARAM_STRING: + case VIR_DRV_FEATURE_TYPED_PARAM_HISTOGRAM: case VIR_DRV_FEATURE_XML_MIGRATABLE: default: return 0; --=20 2.37.1 From nobody Sun May 19 01:15:13 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) client-ip=170.10.129.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 170.10.129.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=fail(p=none dis=none) header.from=weirdnatto.in ARC-Seal: i=1; a=rsa-sha256; t=1663813212; cv=none; d=zohomail.com; s=zohoarc; b=nw+n3FaZjmIJF7t6aOwP6h3tXJP22eSMcsKoMKWdltyuZQZp3/JM8Kd2NaVMdbt8NN5Y4ZOwmTxhQQ81O4fVXvPPxaJfumlvV+a77s2YojGFE8P0ECxM0uOG4MExpfFzx409wUvfwKIn+7NZpbUGrNkcRe27BQvmHsz0Si+yn/Q= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1663813212; h=Content-Type:Content-Transfer-Encoding:Cc: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=MEygmxUbK42VfSECkfqd5MLmtZIGfAdHc40jxyyRif4=; b=nqbVBEyV52iuV9YB1T5g8QQfk3utN5UXCIpiqVX9cJT85pa3ToqNIHQlofeHTbPbIac5fOv3xAbDdVHexwh7eLlpN0fMUruIHcbcmf/n+n4/ptvq+HqhTrICP9QNhAVq2hVd+6i+zMESMfjFJTRJsP42SiISQ66nOipkIu/Oyc0= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=fail header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by mx.zohomail.com with SMTPS id 1663813212343753.8826030770717; Wed, 21 Sep 2022 19:20:12 -0700 (PDT) Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-335-JDWy5Nk4O4yZeKvVOEV1qw-1; Wed, 21 Sep 2022 22:20:08 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 42B6381DB86; Thu, 22 Sep 2022 02:20:05 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (unknown [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id 2D9EC17582; Thu, 22 Sep 2022 02:20:05 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 1B42519465B1; Thu, 22 Sep 2022 02:20:05 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 9BE351946A5A for ; Thu, 22 Sep 2022 02:20:03 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 8BA4C1121315; Thu, 22 Sep 2022 02:20:03 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast05.extmail.prod.ext.rdu2.redhat.com [10.11.55.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 84389112131B for ; Thu, 22 Sep 2022 02:20:03 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [205.139.110.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 60E06833941 for ; Thu, 22 Sep 2022 02:20:03 +0000 (UTC) Received: from mail.weirdnatto.in (140.238.225.67 [140.238.225.67]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-596-0gXhABM3MYGHCHZM_zgxmw-1; Wed, 21 Sep 2022 22:19:59 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1663813211; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc: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=MEygmxUbK42VfSECkfqd5MLmtZIGfAdHc40jxyyRif4=; b=SVcwNufUPZktGh4hGUosjUvYmuOt4LSQa6x0PiS296BQXoq9NXvIucojPxBNe8BI0f6k7r cC1Myurziq3DgEPEVcW1eCIahXXWYySCS9T3Pmg/FzrAxi8xJ7m1v9S3o+MuO4Rqs3mlET FWE4NtDKPqBHS443LBsoz7l0FylSLVs= X-MC-Unique: JDWy5Nk4O4yZeKvVOEV1qw-1 X-Original-To: libvir-list@listman.corp.redhat.com X-MC-Unique: 0gXhABM3MYGHCHZM_zgxmw-1 From: Amneesh Singh To: libvir-list@redhat.com Subject: [RFC PATCH 3/5] virtypedparams: add VIR_TYPED_PARAM_HISTOGRAM_OKAY Date: Thu, 22 Sep 2022 07:49:01 +0530 Message-Id: <20220922021903.376973-4-natto@weirdnatto.in> In-Reply-To: <20220922021903.376973-1-natto@weirdnatto.in> References: <20220922021903.376973-1-natto@weirdnatto.in> MIME-Version: 1.0 X-Mimecast-Impersonation-Protect: Policy=CLT - Impersonation Protection Definition; Similar Internal Domain=false; Similar Monitored External Domain=false; Custom External Domain=false; Mimecast External Domain=false; Newly Observed Domain=false; Internal User Name=false; Custom Display Name List=false; Reply-to Address Mismatch=false; Targeted Threat Dictionary=false; Mimecast Threat Dictionary=false; Custom Threat Dictionary=false X-Scanned-By: MIMEDefang 3.1 on 10.11.54.3 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: mkletzan@redhat.com, pbonzini@redhat.com, Amneesh Singh Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 3.1 on 10.11.54.5 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1663813213573100007 Content-Type: text/plain; charset="utf-8"; x-default="true" This patch adds a flag VIR_TYPED_PARAM_HISTOGRAM_OKAY which works similar to VIR_TYPED_PARAM_STRING_OKAY to maintain server-client compatibility. Signed-off-by: Amneesh Singh --- include/libvirt/libvirt-common.h.in | 5 ++++ src/admin/admin_server_dispatch.c | 6 +++- src/libvirt.c | 46 +++++++++++++++++++---------- src/remote/remote_daemon_dispatch.c | 14 +++++---- src/remote/remote_driver.c | 16 ++++++---- src/rpc/gendispatch.pl | 4 +-- src/util/virtypedparam.c | 7 +++++ 7 files changed, 69 insertions(+), 29 deletions(-) diff --git a/include/libvirt/libvirt-common.h.in b/include/libvirt/libvirt-= common.h.in index 11338d9191..39f96691c3 100644 --- a/include/libvirt/libvirt-common.h.in +++ b/include/libvirt/libvirt-common.h.in @@ -206,6 +206,11 @@ typedef enum { */ VIR_TYPED_PARAM_STRING_OKAY =3D 1 << 2, =20 + /* Same as VIR_TYPED_PARAM_STRING_OKAY but for histograms + * Since: 8.8.0 + */ + VIR_TYPED_PARAM_HISTOGRAM_OKAY =3D 1 << 3, + } virTypedParameterFlags; =20 /** diff --git a/src/admin/admin_server_dispatch.c b/src/admin/admin_server_dis= patch.c index b3e7be8965..0bf852b053 100644 --- a/src/admin/admin_server_dispatch.c +++ b/src/admin/admin_server_dispatch.c @@ -37,6 +37,10 @@ =20 VIR_LOG_INIT("daemon.admin"); =20 +#define VIR_TYPED_PARAM_OKAY_FLAGS \ + VIR_TYPED_PARAM_STRING_OKAY | \ + VIR_TYPED_PARAM_HISTOGRAM_OKAY + typedef struct daemonAdmClientPrivate daemonAdmClientPrivate; /* Separate private data for admin connection */ struct daemonAdmClientPrivate { @@ -322,7 +326,7 @@ adminDispatchClientGetInfo(virNetServer *server G_GNUC_= UNUSED, ADMIN_CLIENT_INFO_PARAMETERS_MAX, (struct _virTypedParameterRemote **) &ret-= >params.params_val, &ret->params.params_len, - VIR_TYPED_PARAM_STRING_OKAY) < 0) + VIR_TYPED_PARAM_OKAY_FLAGS) < 0) goto cleanup; =20 rv =3D 0; diff --git a/src/libvirt.c b/src/libvirt.c index 748f2d8ba0..6dbb11aeb5 100644 --- a/src/libvirt.c +++ b/src/libvirt.c @@ -1331,12 +1331,36 @@ virTypedParameterValidateSet(virConnectPtr conn, int nparams) { int string_okay; + int histogram_okay; size_t i; =20 string_okay =3D VIR_DRV_SUPPORTS_FEATURE(conn->driver, conn, VIR_DRV_FEATURE_TYPED_PARAM_STR= ING); if (string_okay < 0) return -1; + + histogram_okay =3D VIR_DRV_SUPPORTS_FEATURE(conn->driver, conn, + VIR_DRV_FEATURE_TYPED_PARAM_= HISTOGRAM); + if (histogram_okay < 0) + return -1; + +#define VALIDATE_NULLABLE_PARAM_TYPE(LVAR, UVAR, UNIONMEM) \ + if (params[i].type =3D=3D VIR_TYPED_PARAM_##UVAR) { \ + if (LVAR##_okay) { \ + if (!params[i].value.UNIONMEM) { \ + virReportInvalidArg(params, \ + _("NULL "#LVAR" parameter '%s'"), \ + params[i].field); \ + return -1; \ + } \ + } else { \ + virReportInvalidArg(params, \ + _(#LVAR" parameter '%s' unsupported"),= \ + params[i].field); \ + return -1; \ + } \ + } + for (i =3D 0; i < nparams; i++) { if (strnlen(params[i].field, VIR_TYPED_PARAM_FIELD_LENGTH) =3D=3D VIR_TYPED_PARAM_FIELD_LENGTH) { @@ -1346,21 +1370,13 @@ virTypedParameterValidateSet(virConnectPtr conn, params[i].field); return -1; } - if (params[i].type =3D=3D VIR_TYPED_PARAM_STRING) { - if (string_okay) { - if (!params[i].value.s) { - virReportInvalidArg(params, - _("NULL string parameter '%s'"), - params[i].field); - return -1; - } - } else { - virReportInvalidArg(params, - _("string parameter '%s' unsupported"), - params[i].field); - return -1; - } - } + + VALIDATE_NULLABLE_PARAM_TYPE(string, STRING, s); + VALIDATE_NULLABLE_PARAM_TYPE(histogram, HISTOGRAM, h); + } + +#undef VALIDATE_NULLABLE_PARAM_TYPE + return 0; } diff --git a/src/remote/remote_daemon_dispatch.c b/src/remote/remote_daemon= _dispatch.c index a5837dce26..888dee10b9 100644 --- a/src/remote/remote_daemon_dispatch.c +++ b/src/remote/remote_daemon_dispatch.c @@ -69,6 +69,10 @@ VIR_LOG_INIT("daemon.remote"); # define HYPER_TO_ULONG(_to, _from) (_to) =3D (_from) #endif =20 +#define VIR_TYPED_PARAM_OKAY_FLAGS \ + VIR_TYPED_PARAM_STRING_OKAY | \ + VIR_TYPED_PARAM_HISTOGRAM_OKAY + struct daemonClientEventCallback { virNetServerClient *client; virNetServerProgram *program; @@ -1033,7 +1037,7 @@ remoteRelayDomainEventTunable(virConnectPtr conn, REMOTE_DOMAIN_EVENT_TUNABLE_MAX, (struct _virTypedParameterRemote **) &data= .params.params_val, &data.params.params_len, - VIR_TYPED_PARAM_STRING_OKAY) < 0) + VIR_TYPED_PARAM_OKAY_FLAGS) < 0) return -1; =20 data.callbackID =3D callback->callbackID; @@ -1173,7 +1177,7 @@ remoteRelayDomainEventJobCompleted(virConnectPtr conn, REMOTE_DOMAIN_JOB_STATS_MAX, (struct _virTypedParameterRemote **) &data= .params.params_val, &data.params.params_len, - VIR_TYPED_PARAM_STRING_OKAY) < 0) + VIR_TYPED_PARAM_OKAY_FLAGS) < 0) return -1; =20 data.callbackID =3D callback->callbackID; @@ -5468,7 +5472,7 @@ remoteDispatchDomainGetJobStats(virNetServer *server = G_GNUC_UNUSED, REMOTE_DOMAIN_JOB_STATS_MAX, (struct _virTypedParameterRemote **) &ret-= >params.params_val, &ret->params.params_len, - VIR_TYPED_PARAM_STRING_OKAY) < 0) + VIR_TYPED_PARAM_OKAY_FLAGS) < 0) goto cleanup; =20 rv =3D 0; @@ -6757,7 +6761,7 @@ remoteDispatchConnectGetAllDomainStats(virNetServer *= server G_GNUC_UNUSED, REMOTE_CONNECT_GET_ALL_DOMAIN_STAT= S_MAX, (struct _virTypedParameterRemote *= *) &dst->params.params_val, &dst->params.params_len, - VIR_TYPED_PARAM_STRING_OKAY) < 0) + VIR_TYPED_PARAM_OKAY_FLAGS) < 0) goto cleanup; } } else { @@ -7308,7 +7312,7 @@ remoteDispatchDomainGetGuestInfo(virNetServer *server= G_GNUC_UNUSED, REMOTE_DOMAIN_GUEST_INFO_PARAMS_MAX, (struct _virTypedParameterRemote **) &ret-= >params.params_val, &ret->params.params_len, - VIR_TYPED_PARAM_STRING_OKAY) < 0) + VIR_TYPED_PARAM_OKAY_FLAGS) < 0) goto cleanup; =20 rv =3D 0; diff --git a/src/remote/remote_driver.c b/src/remote/remote_driver.c index a4efe101a3..d226bedf19 100644 --- a/src/remote/remote_driver.c +++ b/src/remote/remote_driver.c @@ -72,6 +72,10 @@ VIR_LOG_INIT("remote.remote_driver"); # define HYPER_TO_ULONG(_to, _from) (_to) =3D (_from) #endif =20 +#define VIR_TYPED_PARAM_OKAY_FLAGS \ + VIR_TYPED_PARAM_STRING_OKAY | \ + VIR_TYPED_PARAM_HISTOGRAM_OKAY + static bool inside_daemon; static bool monolithic_daemon; =20 @@ -6918,7 +6922,7 @@ remoteDomainMigrateBegin3Params(virDomainPtr domain, REMOTE_DOMAIN_MIGRATE_PARAM_LIST_MAX, (struct _virTypedParameterRemote **) &args= .params.params_val, &args.params.params_len, - VIR_TYPED_PARAM_STRING_OKAY) < 0) { + VIR_TYPED_PARAM_OKAY_FLAGS) < 0) { xdr_free((xdrproc_t) xdr_remote_domain_migrate_begin3_params_args, (char *) &args); goto cleanup; @@ -6980,7 +6984,7 @@ remoteDomainMigratePrepare3Params(virConnectPtr dconn, REMOTE_DOMAIN_MIGRATE_PARAM_LIST_MAX, (struct _virTypedParameterRemote **) &args= .params.params_val, &args.params.params_len, - VIR_TYPED_PARAM_STRING_OKAY) < 0) { + VIR_TYPED_PARAM_OKAY_FLAGS) < 0) { xdr_free((xdrproc_t) xdr_remote_domain_migrate_prepare3_params_arg= s, (char *) &args); goto cleanup; @@ -7062,7 +7066,7 @@ remoteDomainMigratePrepareTunnel3Params(virConnectPtr= dconn, REMOTE_DOMAIN_MIGRATE_PARAM_LIST_MAX, (struct _virTypedParameterRemote **) &args= .params.params_val, &args.params.params_len, - VIR_TYPED_PARAM_STRING_OKAY) < 0) { + VIR_TYPED_PARAM_OKAY_FLAGS) < 0) { xdr_free((xdrproc_t) xdr_remote_domain_migrate_prepare_tunnel3_par= ams_args, (char *) &args); goto cleanup; @@ -7148,7 +7152,7 @@ remoteDomainMigratePerform3Params(virDomainPtr dom, REMOTE_DOMAIN_MIGRATE_PARAM_LIST_MAX, (struct _virTypedParameterRemote **) &args= .params.params_val, &args.params.params_len, - VIR_TYPED_PARAM_STRING_OKAY) < 0) { + VIR_TYPED_PARAM_OKAY_FLAGS) < 0) { xdr_free((xdrproc_t) xdr_remote_domain_migrate_perform3_params_arg= s, (char *) &args); goto cleanup; @@ -7215,7 +7219,7 @@ remoteDomainMigrateFinish3Params(virConnectPtr dconn, REMOTE_DOMAIN_MIGRATE_PARAM_LIST_MAX, (struct _virTypedParameterRemote **) &args= .params.params_val, &args.params.params_len, - VIR_TYPED_PARAM_STRING_OKAY) < 0) { + VIR_TYPED_PARAM_OKAY_FLAGS) < 0) { xdr_free((xdrproc_t) xdr_remote_domain_migrate_finish3_params_args, (char *) &args); goto cleanup; @@ -7283,7 +7287,7 @@ remoteDomainMigrateConfirm3Params(virDomainPtr domain, REMOTE_DOMAIN_MIGRATE_PARAM_LIST_MAX, (struct _virTypedParameterRemote **) &args= .params.params_val, &args.params.params_len, - VIR_TYPED_PARAM_STRING_OKAY) < 0) { + VIR_TYPED_PARAM_OKAY_FLAGS) < 0) { xdr_free((xdrproc_t) xdr_remote_domain_migrate_confirm3_params_arg= s, (char *) &args); goto cleanup; diff --git a/src/rpc/gendispatch.pl b/src/rpc/gendispatch.pl index 5f2b163ea0..e5615735fd 100755 --- a/src/rpc/gendispatch.pl +++ b/src/rpc/gendispatch.pl @@ -961,7 +961,7 @@ elsif ($mode eq "server") { " $2,\n= " . " (stru= ct _virTypedParameterRemote **) &ret->$1.$1_val,\n" . " &ret-= >$1.$1_len,\n" . - " VIR_T= YPED_PARAM_STRING_OKAY) < 0)\n" . + " VIR_T= YPED_PARAM_STRING_OKAY | VIR_TYPED_PARAM_HISTOGRAM_OKAY) < 0)\n" . " goto cleanup;\n"); =20 push(@free_list, " virTypedParamsFree($1, $1_len);"= ); @@ -1445,7 +1445,7 @@ elsif ($mode eq "client") { " = $2,\n" . " = (struct _virTypedParameterRemote **) &args.$1.$1_val,\n" . " = &args.$1.$1_len,\n" . - " = VIR_TYPED_PARAM_STRING_OKAY) < 0) {\n" . + " = VIR_TYPED_PARAM_STRING_OKAY | VIR_TYPED_PARAM_HISTOGRAM_OKAY) < 0) {\n" . " xdr_free((xdrproc_t)xdr_= $call->{args}, (char *)&args);\n" . " goto done;\n" . " }"); diff --git a/src/util/virtypedparam.c b/src/util/virtypedparam.c index 87fa69271b..b6ffa64135 100644 --- a/src/util/virtypedparam.c +++ b/src/util/virtypedparam.c @@ -785,6 +785,13 @@ virTypedParamsSerialize(virTypedParameterPtr params, continue; } =20 + if (!param->type || + (!(flags & VIR_TYPED_PARAM_HISTOGRAM_OKAY) && + param->type =3D=3D VIR_TYPED_PARAM_HISTOGRAM)) { + --params_len; + continue; + } + /* This will be either freed by virNetServerDispatchCall or call(), * depending on the calling side, i.e. server or client */ val->field =3D g_strdup(param->field); --=20 2.37.1 From nobody Sun May 19 01:15:13 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) client-ip=170.10.129.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 170.10.129.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=fail(p=none dis=none) header.from=weirdnatto.in ARC-Seal: i=1; a=rsa-sha256; t=1663813214; cv=none; d=zohomail.com; s=zohoarc; b=AhKQsoCoFYsE/stNuIPRMqgGPYFLHo1huARoFHuAgXdqkIy3FfBsniT4n4d4vNLkBLFr/DzFBXYAYABx6uBR/JnotcBmKconPlOOnIluuYCvOUzEFoIoybGJ68vt//2j6Le4HGc4866+Od0W74M6okfy55r7xrCq4f2zR45jfVg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1663813214; h=Content-Type:Content-Transfer-Encoding:Cc: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=2figj+zmjd5Slotskr3FTCKTJWicE27FKzLpOvbkKxw=; b=koCymDLup0g7K5uw3G8dwdkaqAeC2HKTTtDU1mA3PbI0BFnK7MjabDi09l2h89pk0RY9dtkrU3y0HJqEkQ3f2yFx15bU8cART4KP6EdKuOZUynoAmvrtRKrVmkfzyATUbCxh/yD3zhq3WUWUKK8i9LIl9jgOKaDukc4M5IE2ljo= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=fail header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by mx.zohomail.com with SMTPS id 166381321467878.20651682329935; Wed, 21 Sep 2022 19:20:14 -0700 (PDT) Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-479-AmObTg_7Pi6TvH6Tuism6g-1; Wed, 21 Sep 2022 22:20:09 -0400 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.rdu2.redhat.com [10.11.54.8]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id E5D27857F90; Thu, 22 Sep 2022 02:20:06 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (unknown [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id D16D3C2C8CD; Thu, 22 Sep 2022 02:20:06 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id B508E19465B5; Thu, 22 Sep 2022 02:20:06 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id D12D119465A4 for ; Thu, 22 Sep 2022 02:20:02 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id C46DA40C2066; Thu, 22 Sep 2022 02:20:02 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast05.extmail.prod.ext.rdu2.redhat.com [10.11.55.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id BCDBA40C2064 for ; Thu, 22 Sep 2022 02:20:02 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-1.mimecast.com [207.211.31.81]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 9FFFE83394E for ; Thu, 22 Sep 2022 02:20:02 +0000 (UTC) Received: from mail.weirdnatto.in (140.238.225.67 [140.238.225.67]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-595-IIsdIXJBNiK8C3LK23SZFg-1; Wed, 21 Sep 2022 22:20:00 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1663813213; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc: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=2figj+zmjd5Slotskr3FTCKTJWicE27FKzLpOvbkKxw=; b=Ui65d/xR+1l0TVA3Pq/9bAraSKWUhER5pxK0G5iwbqEGAf0Sf2dQ64v3BFzWRpxDxA4DeK ABtuNGpgRcuzf1Onk8SU41nTUMksq+uSdGlo9ZqFNIUh112xx5CIDL+zCf8OnnM/QSLIDL 2HopL2UL7S7uKjeNedlZnhsSVT/jCYQ= X-MC-Unique: AmObTg_7Pi6TvH6Tuism6g-1 X-Original-To: libvir-list@listman.corp.redhat.com X-MC-Unique: IIsdIXJBNiK8C3LK23SZFg-1 From: Amneesh Singh To: libvir-list@redhat.com Subject: [RFC PATCH 4/5] qemu_driver: add histograms to the stats Date: Thu, 22 Sep 2022 07:49:02 +0530 Message-Id: <20220922021903.376973-5-natto@weirdnatto.in> In-Reply-To: <20220922021903.376973-1-natto@weirdnatto.in> References: <20220922021903.376973-1-natto@weirdnatto.in> MIME-Version: 1.0 X-Mimecast-Impersonation-Protect: Policy=CLT - Impersonation Protection Definition; Similar Internal Domain=false; Similar Monitored External Domain=false; Custom External Domain=false; Mimecast External Domain=false; Newly Observed Domain=false; Internal User Name=false; Custom Display Name List=false; Reply-to Address Mismatch=false; Targeted Threat Dictionary=false; Mimecast Threat Dictionary=false; Custom Threat Dictionary=false X-Scanned-By: MIMEDefang 3.1 on 10.11.54.1 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: mkletzan@redhat.com, pbonzini@redhat.com, Amneesh Singh Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 3.1 on 10.11.54.8 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1663813215514100009 Content-Type: text/plain; charset="utf-8"; x-default="true" This patch adds histograms to the stats which were previously ignored due to them not being a virTypedParameterType earlier. Signed-off-by: Amneesh Singh --- src/qemu/qemu_driver.c | 41 +++++++++++++++++++++++++++++++++++++++-- 1 file changed, 39 insertions(+), 2 deletions(-) diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index 52e1f88568..bc6f484d88 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -17989,13 +17989,50 @@ qemuDomainAddStatsFromHashTable(GHashTable *stats, case QEMU_MONITOR_QUERY_STATS_TYPE_INSTANT: type =3D "cur"; break; - case QEMU_MONITOR_QUERY_STATS_TYPE_PEAK: type =3D "max"; break; =20 - case QEMU_MONITOR_QUERY_STATS_TYPE_LOG2_HISTOGRAM: case QEMU_MONITOR_QUERY_STATS_TYPE_LINEAR_HISTOGRAM: + case QEMU_MONITOR_QUERY_STATS_TYPE_LOG2_HISTOGRAM: { + virHistogram *histogram; + size_t size; + size_t i; + int flag =3D 0; + + if (!virJSONValueIsArray(value)) + continue; + + if (data->type =3D=3D QEMU_MONITOR_QUERY_STATS_TYPE_LINEAR_HIS= TOGRAM && + data->bucket_size =3D=3D 0) + continue; + + size =3D virJSONValueArraySize(value); + histogram =3D virHistogramNew(size); + + for (i =3D 0; i < size; i++) { + virHistogramBucket *bucket =3D histogram->buckets + i; + virJSONValue *current =3D virJSONValueArrayGet(value, i); + + bucket->x =3D (data->type =3D=3D QEMU_MONITOR_QUERY_STATS_= TYPE_LINEAR_HISTOGRAM ? + (i + 1) * data->bucket_size : + 1LL << i); + + if (virJSONValueGetNumberLong(current, &(bucket->y)) < 0) { + flag =3D 1; + break; + } + } + + if (flag) { + virHistogramFree(histogram); + continue; + } + + ignore_value(virTypedParamListAddHistogram(params, histogram, = "%s.%s", + prefix, key)); + } + case QEMU_MONITOR_QUERY_STATS_TYPE_LAST: default: continue; --=20 2.37.1 From nobody Sun May 19 01:15:13 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) client-ip=170.10.129.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 170.10.129.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=fail(p=none dis=none) header.from=weirdnatto.in ARC-Seal: i=1; a=rsa-sha256; t=1663813216; cv=none; d=zohomail.com; s=zohoarc; b=b7KmNEmZWNaeBhl86C6+thxprCpCyFVO8ePFQak6HLCryHe3ucL3F0W/8P/DHgYx3zO2u+1zM8Ib0SYqpYg1t2HinxfBoTcrZhgtJQI8n6tlIue9FQFwI46nPugp7eQN7u6231G80DX7hRBnDaDOISe1YlOFrlRIfJgqr338OWM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1663813216; h=Content-Type:Content-Transfer-Encoding:Cc: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=/Gftm64LwuiXLyU9EF1zKthLFBPJo8+0AHZkGDdnBjc=; b=nbR2dBLtc+wzFIXhthFxbQGmLnXrVivG5RKyV45F7sZD31/qSf04Lyxi6qvvukqHjM/+mZ0f+zDtPEFxoBgQ+QvHl+A5TqkwSde0pzD8HFKc4v7ZvTo/f+0i7F4D91dcH7F3QJvAKZWt+Vok4rjNI2eEtqXS39NXE+X1bv1zJg4= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=fail header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by mx.zohomail.com with SMTPS id 1663813216663310.105038234552; Wed, 21 Sep 2022 19:20:16 -0700 (PDT) Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-507-LTgTtA4qM323_lmE5nx6qQ-1; Wed, 21 Sep 2022 22:20:10 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 955733C0D860; Thu, 22 Sep 2022 02:20:08 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (unknown [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id 814F61121314; Thu, 22 Sep 2022 02:20:08 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 7387919465B1; Thu, 22 Sep 2022 02:20:08 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 06E901946A66 for ; Thu, 22 Sep 2022 02:20:07 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id EE0311121315; Thu, 22 Sep 2022 02:20:06 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast02.extmail.prod.ext.rdu2.redhat.com [10.11.55.18]) by smtp.corp.redhat.com (Postfix) with ESMTPS id E382E1121314 for ; Thu, 22 Sep 2022 02:20:06 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-2.mimecast.com [207.211.31.81]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id C81BC802801 for ; Thu, 22 Sep 2022 02:20:06 +0000 (UTC) Received: from mail.weirdnatto.in (140.238.225.67 [140.238.225.67]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-241-zbC2VGy1Nq-1jf6T65qLfA-1; Wed, 21 Sep 2022 22:20:02 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1663813215; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc: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=/Gftm64LwuiXLyU9EF1zKthLFBPJo8+0AHZkGDdnBjc=; b=Bp0JL1XjeAovyTF+aj7T68kuvtCnkukNoHRLKIuLMje4aWgRydm11x94RhIzXbJRJKLlK5 +J1IAQy6u3sESnsbGrLOF1xZImiRFkRS361VnDlVVTUU2pJnjn5WaLAdyHoK+R0a9XG9CF sdnNEoakDnItqglLIB9eUjX3+r0y6Js= X-MC-Unique: LTgTtA4qM323_lmE5nx6qQ-1 X-Original-To: libvir-list@listman.corp.redhat.com X-MC-Unique: zbC2VGy1Nq-1jf6T65qLfA-1 From: Amneesh Singh To: libvir-list@redhat.com Subject: [RFC PATCH 5/5] remote: add virHistogram support for RPC as a virTypedParameterType Date: Thu, 22 Sep 2022 07:49:03 +0530 Message-Id: <20220922021903.376973-6-natto@weirdnatto.in> In-Reply-To: <20220922021903.376973-1-natto@weirdnatto.in> References: <20220922021903.376973-1-natto@weirdnatto.in> MIME-Version: 1.0 X-Mimecast-Impersonation-Protect: Policy=CLT - Impersonation Protection Definition; Similar Internal Domain=false; Similar Monitored External Domain=false; Custom External Domain=false; Mimecast External Domain=false; Newly Observed Domain=false; Internal User Name=false; Custom Display Name List=false; Reply-to Address Mismatch=false; Targeted Threat Dictionary=false; Mimecast Threat Dictionary=false; Custom Threat Dictionary=false X-Scanned-By: MIMEDefang 3.1 on 10.11.54.3 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: mkletzan@redhat.com, pbonzini@redhat.com, Amneesh Singh Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 3.1 on 10.11.54.3 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1663813217531100011 Content-Type: text/plain; charset="utf-8"; x-default="true" Signed-off-by: Amneesh Singh --- src/remote/remote_protocol.x | 16 ++++++++++++++++ src/remote_protocol-structs | 13 +++++++++++++ 2 files changed, 29 insertions(+) diff --git a/src/remote/remote_protocol.x b/src/remote/remote_protocol.x index 79ffc63f03..c23e184d3a 100644 --- a/src/remote/remote_protocol.x +++ b/src/remote/remote_protocol.x @@ -418,6 +418,20 @@ struct remote_vcpu_info { int cpu; }; =20 +const REMOTE_HISTOGRAM_BUCKET_MAX =3D 32; + +struct remote_histogram_bucket { + hyper x; + hyper y; +}; + +struct remote_histogram { + remote_histogram_bucket buckets; + unsigned int nbuckets; +}; + +typedef remote_histogram *remote_nonnull_histogram; + /* Wire encoding of virTypedParameter. * Note the enum (type) which must remain binary compatible. */ @@ -436,6 +450,8 @@ union remote_typed_param_value switch (int type) { int b; case VIR_TYPED_PARAM_STRING: remote_nonnull_string s; + case VIR_TYPED_PARAM_HISTOGRAM: + remote_nonnull_histogram h; }; =20 struct remote_typed_param { diff --git a/src/remote_protocol-structs b/src/remote_protocol-structs index ca5222439d..95fc4a15fe 100644 --- a/src/remote_protocol-structs +++ b/src/remote_protocol-structs @@ -73,6 +73,18 @@ struct remote_vcpu_info { uint64_t cpu_time; int cpu; }; +struct remote_histogram_bucket { + int64_t x; + int64_t y; +}; +struct remote_histogram { + struct { + u_int buckets_len; + remote_histogram_bucket * buckets_val; + } buckets; + u_int nbuckets; +}; +typedef remote_histogram *remote_nonnull_histogram; struct remote_typed_param_value { int type; union { @@ -83,6 +95,7 @@ struct remote_typed_param_value { double d; int b; remote_nonnull_string s; + remote_nonnull_histogram h; } remote_typed_param_value_u; }; struct remote_typed_param { --=20 2.37.1