From nobody Mon Feb 9 01:44:02 2026 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=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1681906983; cv=none; d=zohomail.com; s=zohoarc; b=cN6j62c+H89yejxljWHSLlATjiYlTTPFkQWzYCPK83SL5jnZbp7Iw7VpK01KUYWNvY12uMGzrn1HyDQqvy39jBPUpwV2dUZbyBSNMHlJvN8T6zrJ0pEBKA7yGQa3/83uo59OaHjysPyMYaUuRFE0qxdMNeepuqgtbJhwJjGJUxE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1681906983; 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; bh=IJ11Swe60qSA4ynNxMFxOAzSbBNmMHQ9SzJqE92trEA=; b=Vy3vzkNBHzFIWIA5r0dN0srX6L8+q0sl45sHcWkezk/GfiwARAIiTE4iMg3m3z0B6/DvtbC5y/VMU32SB4tlmwin0VokaeIahjC04eWzHbrXlrq/Mf9l3CpOmG8kPzYUCUQeO57E6GwLBdW6+etsPKxgSK1TxfDZaV5WymBDLJk= 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=pass 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 1681906983482674.0099761629291; Wed, 19 Apr 2023 05:23:03 -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-615-2Wjg4GDsMeW5zwGhaQobqg-1; Wed, 19 Apr 2023 08:22:42 -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 710DB87A9E8; Wed, 19 Apr 2023 12:22:40 +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 1A19A40C2064; Wed, 19 Apr 2023 12:22:40 +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 DA84319465B2; Wed, 19 Apr 2023 12:22:39 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id A118C1946A42 for ; Wed, 19 Apr 2023 12:04:45 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 42B5A492B0D; Wed, 19 Apr 2023 12:04:45 +0000 (UTC) Received: from speedmetal.redhat.com (unknown [10.45.242.23]) by smtp.corp.redhat.com (Postfix) with ESMTP id BBF5B492B07 for ; Wed, 19 Apr 2023 12:04:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1681906982; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to: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=IJ11Swe60qSA4ynNxMFxOAzSbBNmMHQ9SzJqE92trEA=; b=jQxt/j1mgFvQ3pDKrddziYVqIG2aQ7pLRTQuH/HVMTmnqjbL8hCR/yHAZkBhYR1nrPatue +nCHgmghEiP/1UPtFhDWEd3Nc8YythTjAGzFLkDC0XLdww7ReSztiW6Y3t1DK7YTPJAaKY ONnMFdk5hhvG8rPibQ2W6Pk7u2AYyLA= X-MC-Unique: 2Wjg4GDsMeW5zwGhaQobqg-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH v3 01/25] virTypedParameterAssignValue: Drop 'copystr' parameter Date: Wed, 19 Apr 2023 14:04:18 +0200 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.9 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: , 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: 1681906985322100003 Content-Type: text/plain; charset="utf-8" All callers pass 'true'. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko Reviewed-by: Martin Kletzander --- src/util/virtypedparam.c | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/src/util/virtypedparam.c b/src/util/virtypedparam.c index e6ad9ec7a9..0cca16053d 100644 --- a/src/util/virtypedparam.c +++ b/src/util/virtypedparam.c @@ -251,7 +251,6 @@ virTypedParameterAssignValueVArgs(virTypedParameterPtr = param, static int virTypedParameterAssignValue(virTypedParameterPtr param, - bool copystr, int type, ...) { @@ -259,7 +258,7 @@ virTypedParameterAssignValue(virTypedParameterPtr param, va_list ap; va_start(ap, type); - ret =3D virTypedParameterAssignValueVArgs(param, type, ap, copystr); + ret =3D virTypedParameterAssignValueVArgs(param, type, ap, true); va_end(ap); return ret; @@ -785,7 +784,7 @@ virTypedParamListAddInt(virTypedParamList *list, int ret; if (!(par =3D virTypedParamListExtend(list)) || - virTypedParameterAssignValue(par, true, VIR_TYPED_PARAM_INT, value= ) < 0) + virTypedParameterAssignValue(par, VIR_TYPED_PARAM_INT, value) < 0) return -1; va_start(ap, namefmt); @@ -807,7 +806,7 @@ virTypedParamListAddUInt(virTypedParamList *list, int ret; if (!(par =3D virTypedParamListExtend(list)) || - virTypedParameterAssignValue(par, true, VIR_TYPED_PARAM_UINT, valu= e) < 0) + virTypedParameterAssignValue(par, VIR_TYPED_PARAM_UINT, value) < 0) return -1; va_start(ap, namefmt); @@ -829,7 +828,7 @@ virTypedParamListAddLLong(virTypedParamList *list, int ret; if (!(par =3D virTypedParamListExtend(list)) || - virTypedParameterAssignValue(par, true, VIR_TYPED_PARAM_LLONG, val= ue) < 0) + virTypedParameterAssignValue(par, VIR_TYPED_PARAM_LLONG, value) < = 0) return -1; va_start(ap, namefmt); @@ -851,7 +850,7 @@ virTypedParamListAddULLong(virTypedParamList *list, int ret; if (!(par =3D virTypedParamListExtend(list)) || - virTypedParameterAssignValue(par, true, VIR_TYPED_PARAM_ULLONG, va= lue) < 0) + virTypedParameterAssignValue(par, VIR_TYPED_PARAM_ULLONG, value) <= 0) return -1; va_start(ap, namefmt); @@ -873,7 +872,7 @@ virTypedParamListAddString(virTypedParamList *list, int ret; if (!(par =3D virTypedParamListExtend(list)) || - virTypedParameterAssignValue(par, true, VIR_TYPED_PARAM_STRING, va= lue) < 0) + virTypedParameterAssignValue(par, VIR_TYPED_PARAM_STRING, value) <= 0) return -1; va_start(ap, namefmt); @@ -895,7 +894,7 @@ virTypedParamListAddBoolean(virTypedParamList *list, int ret; if (!(par =3D virTypedParamListExtend(list)) || - virTypedParameterAssignValue(par, true, VIR_TYPED_PARAM_BOOLEAN, v= alue) < 0) + virTypedParameterAssignValue(par, VIR_TYPED_PARAM_BOOLEAN, value) = < 0) return -1; va_start(ap, namefmt); @@ -917,7 +916,7 @@ virTypedParamListAddDouble(virTypedParamList *list, int ret; if (!(par =3D virTypedParamListExtend(list)) || - virTypedParameterAssignValue(par, true, VIR_TYPED_PARAM_DOUBLE, va= lue) < 0) + virTypedParameterAssignValue(par, VIR_TYPED_PARAM_DOUBLE, value) <= 0) return -1; va_start(ap, namefmt); --=20 2.39.2 From nobody Mon Feb 9 01:44:02 2026 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=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1681907299; cv=none; d=zohomail.com; s=zohoarc; b=H35ESQBZAGDRdn3NpP2BGWBe14lrmVF+clMw+mZ3GyaNcc7bsMHxiXE1qrCNtrvNAmLMuxuikXJMUJBA7mNRCbHqZu2N1IxBamZhrJIPu9dkS81z+QLvQ5S3wCxwiHB5mSO94MlHKiG2AiCuwPdU/cnXHuZuuWV9BmfOFn5IsD4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1681907299; 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; bh=olbgSJf75mkjQFe41L6peJmnrfQVs9O4OJ89sNkVPM8=; b=Y9+KYVCNEjMf2gW37ydZBc3pEm928IcoEd/sogK8jSRp9bLeE8SjunIoV8n9+YLaHbmCHV04cflsOmJSvuSRduwkK1iZuQ0gmlLSGGQeE+yPvv7cZ17FhhyHh18AbdwINFqmQRC1sEvUkERG9/PZngjdEbRvgsFQXncEM2+7zd4= 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=pass 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 1681907299379361.0142537545562; Wed, 19 Apr 2023 05:28:19 -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-240-ah_hvYc3PcehDARz6RaFnw-1; Wed, 19 Apr 2023 08:28:14 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 23F212814252; Wed, 19 Apr 2023 12:28:12 +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 9706B4014E80; Wed, 19 Apr 2023 12:28:11 +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 6398819465B1; Wed, 19 Apr 2023 12:28:06 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id BFAE119465BD for ; Wed, 19 Apr 2023 12:04:49 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 355D0492B0E; Wed, 19 Apr 2023 12:04:46 +0000 (UTC) Received: from speedmetal.redhat.com (unknown [10.45.242.23]) by smtp.corp.redhat.com (Postfix) with ESMTP id 8DFB8492B07 for ; Wed, 19 Apr 2023 12:04:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1681907298; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to: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=olbgSJf75mkjQFe41L6peJmnrfQVs9O4OJ89sNkVPM8=; b=chYSX4Xyd7UUxu/V5D7Yt+gt9qVB31OLo7XNKBbbnakQmun44V3Sh4PIV55oKyqrQ4frIK En0pQB2F/AAZ4Uu6rU91WtlH+FzgsgHGqM12+64Zkl6tiiclhhuLURTVbq/Vszejift193 Iy4T0eX2KtKOoBg5EYcadUMGfIa1wjw= X-MC-Unique: ah_hvYc3PcehDARz6RaFnw-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH v3 02/25] util: virtypedparam: Use proper enum type for all switch() statements Date: Wed, 19 Apr 2023 14:04:19 +0200 Message-Id: <77c0948dd8416a018fbd09857c2614fe9beecbc6.1681905482.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.9 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: , Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 3.1 on 10.11.54.2 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: 1681907300251100001 Content-Type: text/plain; charset="utf-8" Ensure that all switch statements in this module use the proper type in switch() statements to ensure complier protections. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko Reviewed-by: Martin Kletzander --- src/util/virtypedparam.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/util/virtypedparam.c b/src/util/virtypedparam.c index 0cca16053d..974ec51a79 100644 --- a/src/util/virtypedparam.c +++ b/src/util/virtypedparam.c @@ -170,7 +170,7 @@ virTypedParameterToString(virTypedParameterPtr param) { char *value =3D NULL; - switch (param->type) { + switch ((virTypedParameterType) param->type) { case VIR_TYPED_PARAM_INT: value =3D g_strdup_printf("%d", param->value.i); break; @@ -192,6 +192,7 @@ virTypedParameterToString(virTypedParameterPtr param) case VIR_TYPED_PARAM_STRING: value =3D g_strdup(param->value.s); break; + case VIR_TYPED_PARAM_LAST: default: virReportError(VIR_ERR_INTERNAL_ERROR, _("unexpected type %1$d for field %2$s"), @@ -204,7 +205,7 @@ virTypedParameterToString(virTypedParameterPtr param) static int virTypedParameterAssignValueVArgs(virTypedParameterPtr param, - int type, + virTypedParameterType type, va_list ap, bool copystr) { @@ -238,6 +239,7 @@ virTypedParameterAssignValueVArgs(virTypedParameterPtr = param, if (!param->value.s) param->value.s =3D g_strdup(""); break; + case VIR_TYPED_PARAM_LAST: default: virReportError(VIR_ERR_INTERNAL_ERROR, _("unexpected type %1$d for field %2$s"), type, @@ -559,7 +561,7 @@ virTypedParamsDeserialize(struct _virTypedParameterRemo= te *remote_params, } param->type =3D remote_param->value.type; - switch (param->type) { + switch ((virTypedParameterType) param->type) { case VIR_TYPED_PARAM_INT: param->value.i =3D remote_param->value.remote_typed_param_value.i; @@ -587,6 +589,7 @@ 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_LAST: default: virReportError(VIR_ERR_RPC, _("unknown parameter type: %1$d"), param->type); @@ -670,7 +673,7 @@ virTypedParamsSerialize(virTypedParameterPtr params, * depending on the calling side, i.e. server or client */ val->field =3D g_strdup(param->field); val->value.type =3D param->type; - switch (param->type) { + switch ((virTypedParameterType) param->type) { case VIR_TYPED_PARAM_INT: val->value.remote_typed_param_value.i =3D param->value.i; break; @@ -692,6 +695,7 @@ 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_LAST: default: virReportError(VIR_ERR_RPC, _("unknown parameter type: %1$d"), param->type); --=20 2.39.2 From nobody Mon Feb 9 01:44:02 2026 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=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1681907466; cv=none; d=zohomail.com; s=zohoarc; b=Mw9ZZ/S7Zx1r+fkiVoloBVFb+J5LaeYyRbS2zdx9Z3XRjU4F902xb2RAwgxGOisLmmBmypT8FuNN2WrkDIpd8mTZMFvBUkzIPanqpaf661VkviLindn73cCPWrYIP0y63F/zdqHJjEO6DCtJ7zqH7g3SfpO64YYPwuQYfO5Yhv0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1681907466; 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; bh=Le0i32sN7jblQJBjnNuGP5rLhv8O6cPzBRVsUoBcXuM=; b=Y383dDtSJPiHYp3Nahd7Cs0eeaXeJpcQ5IYs5NXxjgCXzwkHR35SZS2nWR4t+T+9IQUkCueq59XqUUP7/6JVEd60l8W5oxy8vRqQWpgZ8tzFyR8MdJY05qc8RUzzqnR5lVqSNSGwh5iT6QSbXcoLfMBmQEvGb9irz4azE4T9CkY= 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=pass 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 1681907466201891.0005420665337; Wed, 19 Apr 2023 05:31:06 -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-371-6wYZoEwQM3qD16S0hPX1QA-1; Wed, 19 Apr 2023 08:30:55 -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 92A3328135AE; Wed, 19 Apr 2023 12:30:51 +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 7F64AC08492; Wed, 19 Apr 2023 12:30:51 +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 322B419465B2; Wed, 19 Apr 2023 12:30:41 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id BED5F19465B6 for ; Wed, 19 Apr 2023 12:04:49 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 0EBD8492B09; Wed, 19 Apr 2023 12:04:47 +0000 (UTC) Received: from speedmetal.redhat.com (unknown [10.45.242.23]) by smtp.corp.redhat.com (Postfix) with ESMTP id 81C00492B07 for ; Wed, 19 Apr 2023 12:04:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1681907465; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to: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=Le0i32sN7jblQJBjnNuGP5rLhv8O6cPzBRVsUoBcXuM=; b=KH0Omv840cJBL9gCkFiwE04SeUXPACYJY5VwEvs5OMJm0veZaBQZjcP2HtX8d6Uge1CkNG u4CthF2FSAF2gj+bcUPFmk8vl5KNnB0lmg9AykHUDLixHGryAekyTvs4qq6BC/lIqbReDK JdsVNjIYtZAuHKbmw9RPY+5XkrAoPQk= X-MC-Unique: 6wYZoEwQM3qD16S0hPX1QA-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH v3 03/25] virTypedParamsDeserialize: Remove unnecessary line breaks Date: Wed, 19 Apr 2023 14:04:20 +0200 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.9 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: , 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: 1681907467125100001 Content-Type: text/plain; charset="utf-8" All changed lines even fit into 80 columns. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko Reviewed-by: Martin Kletzander --- src/util/virtypedparam.c | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/src/util/virtypedparam.c b/src/util/virtypedparam.c index 974ec51a79..fe4c04bcea 100644 --- a/src/util/virtypedparam.c +++ b/src/util/virtypedparam.c @@ -563,28 +563,22 @@ virTypedParamsDeserialize(struct _virTypedParameterRe= mote *remote_params, param->type =3D remote_param->value.type; switch ((virTypedParameterType) param->type) { case VIR_TYPED_PARAM_INT: - param->value.i =3D - remote_param->value.remote_typed_param_value.i; + param->value.i =3D remote_param->value.remote_typed_param_valu= e.i; break; case VIR_TYPED_PARAM_UINT: - param->value.ui =3D - remote_param->value.remote_typed_param_value.ui; + param->value.ui =3D remote_param->value.remote_typed_param_val= ue.ui; break; case VIR_TYPED_PARAM_LLONG: - param->value.l =3D - remote_param->value.remote_typed_param_value.l; + param->value.l =3D remote_param->value.remote_typed_param_valu= e.l; break; case VIR_TYPED_PARAM_ULLONG: - param->value.ul =3D - remote_param->value.remote_typed_param_value.ul; + param->value.ul =3D remote_param->value.remote_typed_param_val= ue.ul; break; case VIR_TYPED_PARAM_DOUBLE: - param->value.d =3D - remote_param->value.remote_typed_param_value.d; + param->value.d =3D remote_param->value.remote_typed_param_valu= e.d; break; case VIR_TYPED_PARAM_BOOLEAN: - param->value.b =3D - remote_param->value.remote_typed_param_value.b; + param->value.b =3D remote_param->value.remote_typed_param_valu= e.b; break; case VIR_TYPED_PARAM_STRING: param->value.s =3D g_strdup(remote_param->value.remote_typed_p= aram_value.s); --=20 2.39.2 From nobody Mon Feb 9 01:44:02 2026 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=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1681907009; cv=none; d=zohomail.com; s=zohoarc; b=CfAZqp0NsoUUcQQMPE96K1XeU6Hto/DZLlRcPkJjfwEZsbWgYfYte/JDoxu3DTJsA36y+Z5w+Rl0JleKr565PA/EDBgtKb5cbVbZs4s7h4twW4FWBteuaktcnLbPwTTJIgmhaB0p/ERvlI1D6XYDkBdX2B82udS1qBNOGtGPX5Y= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1681907009; 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; bh=sZe3+zfRj7PdYFnIs/iu+kQzdKR8viCEYluwUDZqBig=; b=ISsDrQ4hM2YpP21gh4SrIxjrpdKfo4n54HHqWT1yP9vDhXQhnhwIqRsTE9u+QPQ8i1Cl6d21Fuei+T8b7if1JyH5Jw4zGTKc0mv87vcXwhCToI8+0rvF6aoMV71dEzZxuGKqfANcVjMek/uEKkT/uv7X3LTXycDmIpsSvEdiPGA= 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=pass 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 1681907009775621.9333786289335; Wed, 19 Apr 2023 05:23:29 -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-608-5jwkhvK8O4u-2Hi5eivhaA-1; Wed, 19 Apr 2023 08:23:26 -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 DD5D4101A551; Wed, 19 Apr 2023 12:23:23 +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 C845751E3; Wed, 19 Apr 2023 12:23:23 +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 AAFD919465B2; Wed, 19 Apr 2023 12:23:23 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id BF75C19465B7 for ; Wed, 19 Apr 2023 12:04:49 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id DDD9B492B10; Wed, 19 Apr 2023 12:04:47 +0000 (UTC) Received: from speedmetal.redhat.com (unknown [10.45.242.23]) by smtp.corp.redhat.com (Postfix) with ESMTP id 6025A492B07 for ; Wed, 19 Apr 2023 12:04:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1681907008; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to: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=sZe3+zfRj7PdYFnIs/iu+kQzdKR8viCEYluwUDZqBig=; b=LuSzkSpuI5+OZknNbTWxFMu+mUrvuKrnsWJlhRKQ5pPBRvFDPZjFY3Lh5VDFl4DJC9w1xP 719JywipLA1I4fMkdL0xSvTXimjmmCjtrecmwSEtAVp2hR7lEb7cmaDpScfUAiiMHJbWgf GcszxjHDBE9YsbIY1PpOD7JXgst1I+8= X-MC-Unique: 5jwkhvK8O4u-2Hi5eivhaA-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH v3 04/25] virTypedParameterAssignValueVArgs: Ensure proper typed param type in caller Date: Wed, 19 Apr 2023 14:04:21 +0200 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.9 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: , 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: 1681907010969100001 Content-Type: text/plain; charset="utf-8" There are two callers of virTypedParameterAssignValueVArgs. - 'virTypedParameterAssignValue' always uses the correct type, thus doesn't need to be modified. Just use the proper type in the function declaration - 'virTypedParameterAssign' can get improper type, but we can move the validation into it decreasing the scope in which failures need to be propagated. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko Reviewed-by: Martin Kletzander --- src/util/virtypedparam.c | 29 ++++++++++++++--------------- 1 file changed, 14 insertions(+), 15 deletions(-) diff --git a/src/util/virtypedparam.c b/src/util/virtypedparam.c index fe4c04bcea..f325f3b012 100644 --- a/src/util/virtypedparam.c +++ b/src/util/virtypedparam.c @@ -203,7 +203,7 @@ virTypedParameterToString(virTypedParameterPtr param) } -static int +static void virTypedParameterAssignValueVArgs(virTypedParameterPtr param, virTypedParameterType type, va_list ap, @@ -240,30 +240,23 @@ virTypedParameterAssignValueVArgs(virTypedParameterPt= r param, param->value.s =3D g_strdup(""); break; case VIR_TYPED_PARAM_LAST: - default: - virReportError(VIR_ERR_INTERNAL_ERROR, - _("unexpected type %1$d for field %2$s"), type, - NULLSTR(param->field)); - return -1; + break; } - - return 0; } static int virTypedParameterAssignValue(virTypedParameterPtr param, - int type, + virTypedParameterType type, ...) { - int ret; va_list ap; va_start(ap, type); - ret =3D virTypedParameterAssignValueVArgs(param, type, ap, true); + virTypedParameterAssignValueVArgs(param, type, ap, true); va_end(ap); - return ret; + return 0; } @@ -276,7 +269,6 @@ virTypedParameterAssign(virTypedParameterPtr param, con= st char *name, int type, ...) { va_list ap; - int ret =3D -1; if (virStrcpyStatic(param->field, name) < 0) { virReportError(VIR_ERR_INTERNAL_ERROR, _("Field name '%1$s' too lo= ng"), @@ -284,11 +276,18 @@ virTypedParameterAssign(virTypedParameterPtr param, c= onst char *name, return -1; } + if (type < VIR_TYPED_PARAM_INT || + type >=3D VIR_TYPED_PARAM_LAST) { + virReportError(VIR_ERR_INTERNAL_ERROR, + _("unexpected type %1$d for field %2$s"), type, nam= e); + return -1; + } + va_start(ap, type); - ret =3D virTypedParameterAssignValueVArgs(param, type, ap, false); + virTypedParameterAssignValueVArgs(param, type, ap, false); va_end(ap); - return ret; + return 0; } --=20 2.39.2 From nobody Mon Feb 9 01:44:02 2026 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=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1681908411; cv=none; d=zohomail.com; s=zohoarc; b=R2otAXER932P2eCp83POcO4RGKEltdYDrlUeap0Dsdjvvxw10nKqvlQy4IxdG0uNi7eQ/8RQ3lY4j6cV/BoV8vmy7BRFmJba7YPhY3yKW4xRnCoRsFjVsFp3jix8/kpCDOKrep0YNuJUXtNxVKmiXJvtgMYq5/actLBhdMgNhR4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1681908411; 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; bh=lf36IoUj1w0/MpDbyx0tmi8I6cgLj7d5FKGIqftUT9A=; b=a8p/ay1H/ewk8mxsn1/x+WYo6nLdWqyQdx7iQ6otQwIsryQ53JHkbMEXUYAr5G6AAbfSBFa0ozrcRAOjmRNjOzPWhKtyS6dnJV/JxvYD4Giikdtn2lSaB3vHGkARZIq43d/reOhYY2yFcM3hAFmhKCCm6RzvSrVKwiE2N6gIzZc= 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=pass 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 1681908411909437.87376488819143; Wed, 19 Apr 2023 05:46:51 -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-53-XGukwj8COl6toTBiDPbcyw-1; Wed, 19 Apr 2023 08:46:49 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id ECF0C185A790; Wed, 19 Apr 2023 12:46:45 +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 96B252166B33; Wed, 19 Apr 2023 12:46:45 +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 7AC4219465B1; Wed, 19 Apr 2023 12:46:45 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id C0E8119466DF for ; Wed, 19 Apr 2023 12:04:49 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id B0526492B07; Wed, 19 Apr 2023 12:04:48 +0000 (UTC) Received: from speedmetal.redhat.com (unknown [10.45.242.23]) by smtp.corp.redhat.com (Postfix) with ESMTP id 35DBB492B0F for ; Wed, 19 Apr 2023 12:04:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1681908410; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to: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=lf36IoUj1w0/MpDbyx0tmi8I6cgLj7d5FKGIqftUT9A=; b=Qces+pfFD8K9MVu6k+H7rfUfbtJoZofIe6OS+g0qVU/sKUH49T4nFYVLQMtjAs/mfimwFc 623WX9QdI6ZP5vuEVj10MDof9Co5Txv59JW5nz+6De3ds6EY+6N86mBFeHlr1Bqoo7BBwa nwrwkoEGJCT5RGo4JjwZtNiHTRGh+c4= X-MC-Unique: XGukwj8COl6toTBiDPbcyw-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH v3 05/25] util: virtypedparam: Simplify error handling in virTypedParamListAdd* Date: Wed, 19 Apr 2023 14:04:22 +0200 Message-Id: <060518a1ff30564ad6b67f77b13edac7f3ecdac0.1681905482.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.9 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: , Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 3.1 on 10.11.54.6 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: 1681908413319100001 Content-Type: text/plain; charset="utf-8" Don't check the return value of 'virTypedParamListExtend' which will always be a valid pointer and 'virTypedParameterAssignValue' always returns 0. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko Reviewed-by: Martin Kletzander --- src/util/virtypedparam.c | 46 +++++++++++++--------------------------- 1 file changed, 15 insertions(+), 31 deletions(-) diff --git a/src/util/virtypedparam.c b/src/util/virtypedparam.c index f325f3b012..1a1a34fdb2 100644 --- a/src/util/virtypedparam.c +++ b/src/util/virtypedparam.c @@ -245,7 +245,7 @@ virTypedParameterAssignValueVArgs(virTypedParameterPtr = param, } -static int +static void virTypedParameterAssignValue(virTypedParameterPtr param, virTypedParameterType type, ...) @@ -255,8 +255,6 @@ virTypedParameterAssignValue(virTypedParameterPtr param, va_start(ap, type); virTypedParameterAssignValueVArgs(param, type, ap, true); va_end(ap); - - return 0; } @@ -776,13 +774,11 @@ virTypedParamListAddInt(virTypedParamList *list, const char *namefmt, ...) { - virTypedParameterPtr par; + virTypedParameterPtr par =3D virTypedParamListExtend(list); va_list ap; int ret; - if (!(par =3D virTypedParamListExtend(list)) || - virTypedParameterAssignValue(par, VIR_TYPED_PARAM_INT, value) < 0) - return -1; + virTypedParameterAssignValue(par, VIR_TYPED_PARAM_INT, value); va_start(ap, namefmt); ret =3D virTypedParamSetNameVPrintf(par, namefmt, ap); @@ -798,13 +794,11 @@ virTypedParamListAddUInt(virTypedParamList *list, const char *namefmt, ...) { - virTypedParameterPtr par; + virTypedParameterPtr par =3D virTypedParamListExtend(list); va_list ap; int ret; - if (!(par =3D virTypedParamListExtend(list)) || - virTypedParameterAssignValue(par, VIR_TYPED_PARAM_UINT, value) < 0) - return -1; + virTypedParameterAssignValue(par, VIR_TYPED_PARAM_UINT, value); va_start(ap, namefmt); ret =3D virTypedParamSetNameVPrintf(par, namefmt, ap); @@ -820,13 +814,11 @@ virTypedParamListAddLLong(virTypedParamList *list, const char *namefmt, ...) { - virTypedParameterPtr par; + virTypedParameterPtr par =3D virTypedParamListExtend(list); va_list ap; int ret; - if (!(par =3D virTypedParamListExtend(list)) || - virTypedParameterAssignValue(par, VIR_TYPED_PARAM_LLONG, value) < = 0) - return -1; + virTypedParameterAssignValue(par, VIR_TYPED_PARAM_LLONG, value); va_start(ap, namefmt); ret =3D virTypedParamSetNameVPrintf(par, namefmt, ap); @@ -842,13 +834,11 @@ virTypedParamListAddULLong(virTypedParamList *list, const char *namefmt, ...) { - virTypedParameterPtr par; + virTypedParameterPtr par =3D virTypedParamListExtend(list); va_list ap; int ret; - if (!(par =3D virTypedParamListExtend(list)) || - virTypedParameterAssignValue(par, VIR_TYPED_PARAM_ULLONG, value) <= 0) - return -1; + virTypedParameterAssignValue(par, VIR_TYPED_PARAM_ULLONG, value); va_start(ap, namefmt); ret =3D virTypedParamSetNameVPrintf(par, namefmt, ap); @@ -864,13 +854,11 @@ virTypedParamListAddString(virTypedParamList *list, const char *namefmt, ...) { - virTypedParameterPtr par; + virTypedParameterPtr par =3D virTypedParamListExtend(list); va_list ap; int ret; - if (!(par =3D virTypedParamListExtend(list)) || - virTypedParameterAssignValue(par, VIR_TYPED_PARAM_STRING, value) <= 0) - return -1; + virTypedParameterAssignValue(par, VIR_TYPED_PARAM_STRING, value); va_start(ap, namefmt); ret =3D virTypedParamSetNameVPrintf(par, namefmt, ap); @@ -886,13 +874,11 @@ virTypedParamListAddBoolean(virTypedParamList *list, const char *namefmt, ...) { - virTypedParameterPtr par; + virTypedParameterPtr par =3D virTypedParamListExtend(list); va_list ap; int ret; - if (!(par =3D virTypedParamListExtend(list)) || - virTypedParameterAssignValue(par, VIR_TYPED_PARAM_BOOLEAN, value) = < 0) - return -1; + virTypedParameterAssignValue(par, VIR_TYPED_PARAM_BOOLEAN, value); va_start(ap, namefmt); ret =3D virTypedParamSetNameVPrintf(par, namefmt, ap); @@ -908,13 +894,11 @@ virTypedParamListAddDouble(virTypedParamList *list, const char *namefmt, ...) { - virTypedParameterPtr par; + virTypedParameterPtr par =3D virTypedParamListExtend(list); va_list ap; int ret; - if (!(par =3D virTypedParamListExtend(list)) || - virTypedParameterAssignValue(par, VIR_TYPED_PARAM_DOUBLE, value) <= 0) - return -1; + virTypedParameterAssignValue(par, VIR_TYPED_PARAM_DOUBLE, value); va_start(ap, namefmt); ret =3D virTypedParamSetNameVPrintf(par, namefmt, ap); --=20 2.39.2 From nobody Mon Feb 9 01:44:02 2026 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=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1681907973; cv=none; d=zohomail.com; s=zohoarc; b=ZBOHGItSsCKkYWN4b+czPQ/fI4z5Aq39kXdr8FZ5MdhYMqJXNT1OU/DHvHJWN2eftN/sTLOpNIIf5GODMrwzHDYDVPBoV1BkgIs6KC/4SmctdFSXrPkIXVl7iNZV1Hda37zvMfdLgY4VT20bZO2CuWcDE6a2vFl1XpMn26XJv9A= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1681907973; 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; bh=OIkTXRLNj/sxerlFX5iDUnS95T0dAgz0uIK3Y7xDEC4=; b=FJoqpv3gtiI5hPJ8NIQt000VOigks7KStF43EWeXGsS7h6oiZaVh7RsPYwD15HPgKzwAhbeg8fxdE+L2Wo64vzbZkRRLsfnD1f23dhehSav31zmCMMAWyoAScvicDLce2wBw7CSOFF0dsW52iwTnPVYDtGUEPffDfe1Ej870Ja0= 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=pass 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 1681907973137711.0289590589985; Wed, 19 Apr 2023 05:39:33 -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-512-RWUqBpG_ON2etUq_6qzFnA-1; Wed, 19 Apr 2023 08:39:26 -0400 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.rdu2.redhat.com [10.11.54.7]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 1F9113C10251; Wed, 19 Apr 2023 12:39:24 +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 6D60F1410F1E; Wed, 19 Apr 2023 12:39:23 +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 4B4AE19465BB; Wed, 19 Apr 2023 12:39:23 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id C737619465BA for ; Wed, 19 Apr 2023 12:04:49 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 9D930492B0F; Wed, 19 Apr 2023 12:04:49 +0000 (UTC) Received: from speedmetal.redhat.com (unknown [10.45.242.23]) by smtp.corp.redhat.com (Postfix) with ESMTP id 2072B492B11 for ; Wed, 19 Apr 2023 12:04:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1681907972; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to: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=OIkTXRLNj/sxerlFX5iDUnS95T0dAgz0uIK3Y7xDEC4=; b=dEh+Z4/lB6KrdEjSoqjWa3y/Vgs6bu866vGzFjuftjyjh5ItAfqyTDv0iecUtMDTsMISh0 vfOXQiKBBBw8q2sO7gF6lBfuM1DQo1f4AQ8Wiyq2ZkU60FKMgla9aRm4+qY7wIcsAulJnR cotUl3zTeGlPq2J4Aga/mz48MMkyjwQ= X-MC-Unique: RWUqBpG_ON2etUq_6qzFnA-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH v3 06/25] virtypedparam.h: Consistently use contemporary header style Date: Wed, 19 Apr 2023 14:04:23 +0200 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.9 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: , Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 3.1 on 10.11.54.7 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: 1681907973689100001 Content-Type: text/plain; charset="utf-8" The header uses both styles randomly, switch it to the contemporary style. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko Reviewed-by: Martin Kletzander --- src/util/virtypedparam.h | 140 ++++++++++++++++++++++----------------- 1 file changed, 80 insertions(+), 60 deletions(-) diff --git a/src/util/virtypedparam.h b/src/util/virtypedparam.h index 936dac24ea..fb9815c661 100644 --- a/src/util/virtypedparam.h +++ b/src/util/virtypedparam.h @@ -55,14 +55,17 @@ struct _virTypedParameterRemote { }; -int virTypedParamsValidate(virTypedParameterPtr params, int nparams, - /* const char *name, int type ... */ ...) +int +virTypedParamsValidate(virTypedParameterPtr params, + int nparams, + /* const char *name, int type ... */ ...) G_GNUC_NULL_TERMINATED G_GNUC_WARN_UNUSED_RESULT; -bool virTypedParamsCheck(virTypedParameterPtr params, - int nparams, - const char **names, - int nnames); +bool +virTypedParamsCheck(virTypedParameterPtr params, + int nparams, + const char **names, + int nnames); int virTypedParamsGetStringList(virTypedParameterPtr params, @@ -77,36 +80,44 @@ virTypedParamsFilter(virTypedParameterPtr params, G_GNUC_WARN_UNUSED_RESULT; -int virTypedParameterAssign(virTypedParameterPtr param, const char *name, - int type, /* TYPE arg */ ...) +int +virTypedParameterAssign(virTypedParameterPtr param, + const char *name, + int type, /* TYPE arg */ ...) G_GNUC_WARN_UNUSED_RESULT; -int virTypedParamsReplaceString(virTypedParameterPtr *params, - int *nparams, - const char *name, - const char *value); +int +virTypedParamsReplaceString(virTypedParameterPtr *params, + int *nparams, + const char *name, + const char *value); -void virTypedParamsCopy(virTypedParameterPtr *dst, - virTypedParameterPtr src, - int nparams); +void +virTypedParamsCopy(virTypedParameterPtr *dst, + virTypedParameterPtr src, + int nparams); -char *virTypedParameterToString(virTypedParameterPtr param); +char * +virTypedParameterToString(virTypedParameterPtr param); -void virTypedParamsRemoteFree(struct _virTypedParameterRemote *remote_para= ms_val, - unsigned int remote_params_len); +void +virTypedParamsRemoteFree(struct _virTypedParameterRemote *remote_params_va= l, + unsigned int remote_params_len); -int virTypedParamsDeserialize(struct _virTypedParameterRemote *remote_para= ms, - unsigned int remote_params_len, - int limit, - virTypedParameterPtr *params, - int *nparams); +int +virTypedParamsDeserialize(struct _virTypedParameterRemote *remote_params, + unsigned int remote_params_len, + int limit, + virTypedParameterPtr *params, + int *nparams); -int virTypedParamsSerialize(virTypedParameterPtr params, - int nparams, - int limit, - struct _virTypedParameterRemote **remote_param= s_val, - unsigned int *remote_params_len, - unsigned int flags); +int +virTypedParamsSerialize(virTypedParameterPtr params, + int nparams, + int limit, + struct _virTypedParameterRemote **remote_params_va= l, + unsigned int *remote_params_len, + unsigned int flags); VIR_ENUM_DECL(virTypedParameter); @@ -132,48 +143,57 @@ struct _virTypedParamList { size_t par_alloc; }; -void virTypedParamListFree(virTypedParamList *list); +void +virTypedParamListFree(virTypedParamList *list); G_DEFINE_AUTOPTR_CLEANUP_FUNC(virTypedParamList, virTypedParamListFree); -size_t virTypedParamListStealParams(virTypedParamList *list, - virTypedParameterPtr *params); +size_t +virTypedParamListStealParams(virTypedParamList *list, + virTypedParameterPtr *params); virTypedParamList * virTypedParamListFromParams(virTypedParameterPtr *params, size_t nparams); -int virTypedParamListAddInt(virTypedParamList *list, - int value, - const char *namefmt, - ...) +int +virTypedParamListAddInt(virTypedParamList *list, + int value, + const char *namefmt, + ...) G_GNUC_PRINTF(3, 4) G_GNUC_WARN_UNUSED_RESULT; -int virTypedParamListAddUInt(virTypedParamList *list, - unsigned int value, - const char *namefmt, - ...) +int +virTypedParamListAddUInt(virTypedParamList *list, + unsigned int value, + const char *namefmt, + ...) G_GNUC_PRINTF(3, 4) G_GNUC_WARN_UNUSED_RESULT; -int virTypedParamListAddLLong(virTypedParamList *list, - long long value, - const char *namefmt, - ...) +int +virTypedParamListAddLLong(virTypedParamList *list, + long long value, + const char *namefmt, + ...) G_GNUC_PRINTF(3, 4) G_GNUC_WARN_UNUSED_RESULT; -int virTypedParamListAddULLong(virTypedParamList *list, - unsigned long long value, - const char *namefmt, - ...) +int +virTypedParamListAddULLong(virTypedParamList *list, + unsigned long long value, + const char *namefmt, + ...) G_GNUC_PRINTF(3, 4) G_GNUC_WARN_UNUSED_RESULT; -int virTypedParamListAddString(virTypedParamList *list, - const char *value, - const char *namefmt, - ...) +int +virTypedParamListAddString(virTypedParamList *list, + const char *value, + const char *namefmt, + ...) G_GNUC_PRINTF(3, 4) G_GNUC_WARN_UNUSED_RESULT; -int virTypedParamListAddBoolean(virTypedParamList *list, - bool value, - const char *namefmt, - ...) +int +virTypedParamListAddBoolean(virTypedParamList *list, + bool value, + const char *namefmt, + ...) G_GNUC_PRINTF(3, 4) G_GNUC_WARN_UNUSED_RESULT; -int virTypedParamListAddDouble(virTypedParamList *list, - double value, - const char *namefmt, - ...) +int +virTypedParamListAddDouble(virTypedParamList *list, + double value, + const char *namefmt, + ...) G_GNUC_PRINTF(3, 4) G_GNUC_WARN_UNUSED_RESULT; --=20 2.39.2 From nobody Mon Feb 9 01:44:02 2026 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=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1681907305; cv=none; d=zohomail.com; s=zohoarc; b=EAQu2gA6KAsyBzC0Nj0ZgLVcsflc2CBD8nQ7nEf6rV1AuPLFzCsVMyNiARAlkQNAo1I97AmLLEfDT0gol2qYF9GErpAziXV8ymsw0k3wvC7nICVl7Ld1CnVlO0+9CIUyVEyXfU7PVmTWkyj960Iis+W2dpEBoHF944zCXrrqfss= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1681907305; 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; bh=iWYYuBZyfdcCwCx2ii0kJF8djkcJ8qILpvWxdBsYTyA=; b=Fy8FihUUUO653Z1/9gzDICf75w/zHnMBXnn098rqa2iNg0OBiccOq7Sdzz5/REtC0ZOts22wWmPVhtkT7N/wzoUSVKii2+bk8R/YW19Fdt9MivWWmGBDjz93a1ZyNkB7CVFhuM+/4FwKdEao6iOn4/m7GVSDo6psx/YHkSDLHp4= 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=pass 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 16819073053861020.8865008178509; Wed, 19 Apr 2023 05:28:25 -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-357-AEPeTM-XPE-z5Geebv3vrg-1; Wed, 19 Apr 2023 08:28:20 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 5EBED3806711; Wed, 19 Apr 2023 12:28:18 +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 4AB2B4014E80; Wed, 19 Apr 2023 12:28:18 +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 B177719465B1; Wed, 19 Apr 2023 12:28:16 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 9952D19465B1 for ; Wed, 19 Apr 2023 12:04:50 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 7D461492B04; Wed, 19 Apr 2023 12:04:50 +0000 (UTC) Received: from speedmetal.redhat.com (unknown [10.45.242.23]) by smtp.corp.redhat.com (Postfix) with ESMTP id 00743492B05 for ; Wed, 19 Apr 2023 12:04:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1681907304; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to: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=iWYYuBZyfdcCwCx2ii0kJF8djkcJ8qILpvWxdBsYTyA=; b=EvS0a05SQ/vpZ5iN1flWyRLFt+1B/qlObHuuxwJKuj1aCHbDdV5K9oBNg9Syb/jByqJxFa IDAq4vh3tocaOeRlI4dOxUMzEvYXsB33unKJzNReQw4UjHwWGCgjdFno5ErvfZc7xENWwm NzW5POO/BzUFtispJkELmjemlgHC4Q4= X-MC-Unique: AEPeTM-XPE-z5Geebv3vrg-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH v3 07/25] util: virtypedparam: Introduce virTypedParamListNew() Date: Wed, 19 Apr 2023 14:04:24 +0200 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.9 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: , Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 3.1 on 10.11.54.2 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: 1681907307156100001 Content-Type: text/plain; charset="utf-8" Add an allocator function and refactor all allocations to use it. In upcoming patches 'struct _virTypedParamList' will be made private. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko Reviewed-by: Martin Kletzander --- src/admin/admin_server.c | 6 +++--- src/libvirt_private.syms | 1 + src/qemu/qemu_domainjob.c | 2 +- src/qemu/qemu_driver.c | 2 +- src/test/test_driver.c | 2 +- src/util/virtypedparam.c | 9 ++++++++- src/util/virtypedparam.h | 1 + 7 files changed, 16 insertions(+), 7 deletions(-) diff --git a/src/admin/admin_server.c b/src/admin/admin_server.c index 7ed2645f57..394de0dfab 100644 --- a/src/admin/admin_server.c +++ b/src/admin/admin_server.c @@ -76,7 +76,7 @@ adminServerGetThreadPoolParameters(virNetServer *srv, size_t freeWorkers; size_t nPrioWorkers; size_t jobQueueDepth; - g_autoptr(virTypedParamList) paramlist =3D g_new0(virTypedParamList, 1= ); + g_autoptr(virTypedParamList) paramlist =3D virTypedParamListNew(); virCheckFlags(0, -1); @@ -200,7 +200,7 @@ adminClientGetInfo(virNetServerClient *client, bool readonly; g_autofree char *sock_addr =3D NULL; const char *attr =3D NULL; - g_autoptr(virTypedParamList) paramlist =3D g_new0(virTypedParamList, 1= ); + g_autoptr(virTypedParamList) paramlist =3D virTypedParamListNew(); g_autoptr(virIdentity) identity =3D NULL; int rc; @@ -298,7 +298,7 @@ adminServerGetClientLimits(virNetServer *srv, int *nparams, unsigned int flags) { - g_autoptr(virTypedParamList) paramlist =3D g_new0(virTypedParamList, 1= ); + g_autoptr(virTypedParamList) paramlist =3D virTypedParamListNew(); virCheckFlags(0, -1); diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index 1247b67a39..c596ef0f87 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -3557,6 +3557,7 @@ virTypedParamListAddUInt; virTypedParamListAddULLong; virTypedParamListFree; virTypedParamListFromParams; +virTypedParamListNew; virTypedParamListStealParams; virTypedParamsCheck; virTypedParamsCopy; diff --git a/src/qemu/qemu_domainjob.c b/src/qemu/qemu_domainjob.c index 6376f928d5..4df1af0ce7 100644 --- a/src/qemu/qemu_domainjob.c +++ b/src/qemu/qemu_domainjob.c @@ -478,7 +478,7 @@ qemuDomainBackupJobDataToParams(virDomainJobData *jobDa= ta, { qemuDomainJobDataPrivate *priv =3D jobData->privateData; qemuDomainBackupStats *stats =3D &priv->stats.backup; - g_autoptr(virTypedParamList) par =3D g_new0(virTypedParamList, 1); + g_autoptr(virTypedParamList) par =3D virTypedParamListNew(); if (virTypedParamListAddInt(par, jobData->operation, VIR_DOMAIN_JOB_OPERATION) < 0) diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index 28e470e4a2..4cf5e8a512 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -18447,7 +18447,7 @@ qemuDomainGetStats(virConnectPtr conn, g_autoptr(virTypedParamList) params =3D NULL; size_t i; - params =3D g_new0(virTypedParamList, 1); + params =3D virTypedParamListNew(); for (i =3D 0; qemuDomainGetStatsWorkers[i].func; i++) { if (stats & qemuDomainGetStatsWorkers[i].stats) { diff --git a/src/test/test_driver.c b/src/test/test_driver.c index 7b06896d44..47c74c420c 100644 --- a/src/test/test_driver.c +++ b/src/test/test_driver.c @@ -9858,7 +9858,7 @@ testDomainGetStats(virConnectPtr conn, g_autoptr(virTypedParamList) params =3D NULL; size_t i; - params =3D g_new0(virTypedParamList, 1); + params =3D virTypedParamListNew(); for (i =3D 0; testDomainGetStatsWorkers[i].func; i++) { if (stats & testDomainGetStatsWorkers[i].stats) { diff --git a/src/util/virtypedparam.c b/src/util/virtypedparam.c index 1a1a34fdb2..de3a4e76b4 100644 --- a/src/util/virtypedparam.c +++ b/src/util/virtypedparam.c @@ -705,6 +705,13 @@ virTypedParamsSerialize(virTypedParameterPtr params, } +virTypedParamList * +virTypedParamListNew(void) +{ + return g_new0(virTypedParamList, 1); +} + + void virTypedParamListFree(virTypedParamList *list) { @@ -733,7 +740,7 @@ virTypedParamList * virTypedParamListFromParams(virTypedParameterPtr *params, size_t nparams) { - virTypedParamList *l =3D g_new0(virTypedParamList, 1); + virTypedParamList *l =3D virTypedParamListNew(); l->par =3D g_steal_pointer(params); l->npar =3D nparams; diff --git a/src/util/virtypedparam.h b/src/util/virtypedparam.h index fb9815c661..4aa597bc81 100644 --- a/src/util/virtypedparam.h +++ b/src/util/virtypedparam.h @@ -146,6 +146,7 @@ struct _virTypedParamList { void virTypedParamListFree(virTypedParamList *list); G_DEFINE_AUTOPTR_CLEANUP_FUNC(virTypedParamList, virTypedParamListFree); +virTypedParamList *virTypedParamListNew(void); size_t virTypedParamListStealParams(virTypedParamList *list, --=20 2.39.2 From nobody Mon Feb 9 01:44:02 2026 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=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1681907046; cv=none; d=zohomail.com; s=zohoarc; b=DN04wFPgkAbBKZbr5ipu1+jBk1pu1Sf1FiEdpn1QQZE3RR/8IQ10dVchB62V92CnWB9nkcxavijnWNi6naSq5b89SMITYx3h/+F/tMhB6dV3THGp5XG5buOJbujd+fJZlaJKR5d/SUrkymAeqyQET4LNxTvfLEtfUTFsWXFaH7w= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1681907046; 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; bh=1JEJ+ged3/sKuy9HbyRjHmdegAUIMcnv79tCIEMS7us=; b=OD0fn5rkpR2UmH+fgHJVT3qN/5vpJLlFOunYQM1FqSGMZtrwQqS3e5K6EFym0xOuo9Ecx16FQ9ZBM8I6p5zdOFcApPOolPUlFgSpneCLeD4UFRu61kTDmdI2cao8BaGzhZyWpm7QcJY9oSc4Omrbp6vp7S4kITKFU2oi+LktsVA= 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=pass 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 1681907046835843.8215888000842; Wed, 19 Apr 2023 05:24:06 -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-511-Fe4CXaNpMuW9nLB5FpaJFA-1; Wed, 19 Apr 2023 08:23:43 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 64BF210146E8; Wed, 19 Apr 2023 12:23:41 +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 4FDB42166B34; Wed, 19 Apr 2023 12:23:41 +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 A71AE1946A41; Wed, 19 Apr 2023 12:23:40 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 7356D19465A0 for ; Wed, 19 Apr 2023 12:04:51 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 58F23492B07; Wed, 19 Apr 2023 12:04:51 +0000 (UTC) Received: from speedmetal.redhat.com (unknown [10.45.242.23]) by smtp.corp.redhat.com (Postfix) with ESMTP id D24BD492B04 for ; Wed, 19 Apr 2023 12:04:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1681907045; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to: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=1JEJ+ged3/sKuy9HbyRjHmdegAUIMcnv79tCIEMS7us=; b=KIZdkJvmaMtxTfqt6WedFeuHwoI4JQngHsH2OMsN0J7Nvn5LORGEYkcHVoBZ+A1o7MInVZ 9cIibuxy3ghzFPbBjhEgUTLKkXBwLdVK4fO/kMaz2MSh2/Nag4fWeFJoWvPukABlXVt83v e1KrH2WX5IuwGYT51/Oxi2H2JcvDJ08= X-MC-Unique: Fe4CXaNpMuW9nLB5FpaJFA-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH v3 08/25] util: typedparam: Introduce 'virTypedParamListConcat' Date: Wed, 19 Apr 2023 14:04:25 +0200 Message-Id: <01f9010c5ad152823c65374feccb9681fdec1345.1681905482.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.9 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: , Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 3.1 on 10.11.54.6 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: 1681907049012100003 Content-Type: text/plain; charset="utf-8" Introduce a helper function to concatenate two virTypedParamLists. This will allow us to refactor qemuDomainGetStatsBlock to not access the list directly. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko Reviewed-by: Martin Kletzander --- src/libvirt_private.syms | 1 + src/util/virtypedparam.c | 24 ++++++++++++++++++++++++ src/util/virtypedparam.h | 4 ++++ 3 files changed, 29 insertions(+) diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index c596ef0f87..0f42c2de0b 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -3555,6 +3555,7 @@ virTypedParamListAddLLong; virTypedParamListAddString; virTypedParamListAddUInt; virTypedParamListAddULLong; +virTypedParamListConcat; virTypedParamListFree; virTypedParamListFromParams; virTypedParamListNew; diff --git a/src/util/virtypedparam.c b/src/util/virtypedparam.c index de3a4e76b4..f8dce9ed98 100644 --- a/src/util/virtypedparam.c +++ b/src/util/virtypedparam.c @@ -712,6 +712,30 @@ virTypedParamListNew(void) } +/** + * virTypedParamListConcat: + * + * @to: typed param list to concatenate into + * @fromptr: pointer to pointer to a typed param list to concatenate into = @from + * + * Concatenates all params from the virTypedParamList pointed to by @fromp= tr + * into @to and deallocates the list pointed to by @fromptr and clears the + * variable. + */ +void +virTypedParamListConcat(virTypedParamList *to, + virTypedParamList **fromptr) +{ + g_autoptr(virTypedParamList) from =3D g_steal_pointer(fromptr); + + VIR_RESIZE_N(to->par, to->par_alloc, to->npar, from->npar); + + memcpy(to->par + to->npar, from->par, sizeof(*(to->par)) * from->npar); + to->npar +=3D from->npar; + from->npar =3D 0; +} + + void virTypedParamListFree(virTypedParamList *list) { diff --git a/src/util/virtypedparam.h b/src/util/virtypedparam.h index 4aa597bc81..45422c2673 100644 --- a/src/util/virtypedparam.h +++ b/src/util/virtypedparam.h @@ -156,6 +156,10 @@ virTypedParamList * virTypedParamListFromParams(virTypedParameterPtr *params, size_t nparams); +void +virTypedParamListConcat(virTypedParamList *to, + virTypedParamList **fromptr); + int virTypedParamListAddInt(virTypedParamList *list, int value, --=20 2.39.2 From nobody Mon Feb 9 01:44:02 2026 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=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1681907480; cv=none; d=zohomail.com; s=zohoarc; b=QgzP5oa+l08cDolNvZtvbq2fZwX4kge4HqFWnpe9tXhKO2ZrxVFNtML/O44Z1zGs+TzCT8jS94bhqZUv2Ez92rJN26InEX73sjyM3uBYYjQezTBrk6sM21GsQCrhADvW21ZVoLL+vwBgnFcA4Jv3tFdSSSQ1oxHFfyGYuV+r5gQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1681907480; 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; bh=uW62oPzAKcDcOieZXNn6EAh4PWgJDBoq3GPVw/5vC+8=; b=klphpV0dHrAKmYKBQ5dAFR5HllD2WWGBI7MsyP4NbXYG6pX/9yG4p49/UpZ68QnPAnD34RyuBkFKCVXwwn5MHS4ucSuLzJZ4iieAxahCCEg5r25gqO78FFs2AbHbJoSlqT03fTRmeBjj3L0Y4uUOMhuC/uns9LWUOvakn4CPu3g= 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=pass 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 1681907480874798.4484490470091; Wed, 19 Apr 2023 05:31:20 -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-103-plz2M2SQO4q_eWs6l8R-vw-1; Wed, 19 Apr 2023 08:31:17 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 96164185A794; Wed, 19 Apr 2023 12:31:14 +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 801E04014E82; Wed, 19 Apr 2023 12:31:14 +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 4C84619465B5; Wed, 19 Apr 2023 12:31:14 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 4C03919465A0 for ; Wed, 19 Apr 2023 12:04:52 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 3FEE2492B05; Wed, 19 Apr 2023 12:04:52 +0000 (UTC) Received: from speedmetal.redhat.com (unknown [10.45.242.23]) by smtp.corp.redhat.com (Postfix) with ESMTP id B71B4492B04 for ; Wed, 19 Apr 2023 12:04:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1681907479; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to: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=uW62oPzAKcDcOieZXNn6EAh4PWgJDBoq3GPVw/5vC+8=; b=A0JCkdMA+C3CHdqGVOYFApRT2gw0QhdQi/pObjyK6t8WLolBrzcczrXMXr38RsCxy/UtL9 phs0Tgm6ZPRBsQPnc9vHuDls0nAng4ZUjlBPI/D2UaymzMVsmd6MLFPTsfXyW31uht/pHq A1d+lNe/Kx1rt99jYHqQ89k/ylS9SQo= X-MC-Unique: plz2M2SQO4q_eWs6l8R-vw-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH v3 09/25] qemuDomainGetStatsBlock: Don't directly access virTypedParamList Date: Wed, 19 Apr 2023 14:04:26 +0200 Message-Id: <5c1c343dd1efd01b078d4fb1ce0e339cf93f35a0.1681905482.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.9 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: , Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 3.1 on 10.11.54.2 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: 1681907482713100001 Content-Type: text/plain; charset="utf-8" The struct will be made private in upcoming patches. Construct the list of block entries into a separate list and append them rather than remember the index of the count element. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko Reviewed-by: Martin Kletzander --- src/qemu/qemu_driver.c | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index 4cf5e8a512..b89bf176bb 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -18107,9 +18107,9 @@ qemuDomainGetStatsBlock(virQEMUDriver *driver, g_autoptr(GHashTable) stats =3D NULL; qemuDomainObjPrivate *priv =3D dom->privateData; g_autoptr(virQEMUDriverConfig) cfg =3D virQEMUDriverGetConfig(driver); - int count_index =3D -1; size_t visited =3D 0; bool visitBacking =3D !!(privflags & QEMU_DOMAIN_STATS_BACKING); + g_autoptr(virTypedParamList) blockparams =3D virTypedParamListNew(); if (HAVE_JOB(privflags) && virDomainObjIsActive(dom)) { qemuDomainObjEnterMonitor(dom); @@ -18126,21 +18126,17 @@ qemuDomainGetStatsBlock(virQEMUDriver *driver, virResetLastError(); } - /* When listing backing chains, it's easier to fix up the count - * after the iteration than it is to iterate twice; but we still - * want count listed first. */ - count_index =3D params->npar; - if (virTypedParamListAddUInt(params, 0, "block.count") < 0) - return -1; - for (i =3D 0; i < dom->def->ndisks; i++) { if (qemuDomainGetStatsBlockExportDisk(dom->def->disks[i], stats, - params, &visited, + blockparams, &visited, visitBacking, driver, cfg, d= om) < 0) return -1; } - params->par[count_index].value.ui =3D visited; + if (virTypedParamListAddUInt(params, 0, "block.count") < 0) + return -1; + + virTypedParamListConcat(params, &blockparams); return 0; } --=20 2.39.2 From nobody Mon Feb 9 01:44:02 2026 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=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1681907322; cv=none; d=zohomail.com; s=zohoarc; b=WrvteOodXi8Z6vDDep9681IMQLufyrVFsvV6r7I9pT1rDuQInUWcgwHKbu3wsbr2KJ9c2Ulp7tUCcAbTJkCIj+nTuHeMyCvEijWOHYoDtnV/AfjdLgkSem/JtE0h0qNXcHW3HUA2bqrn5KTnRMrAoNqsY4oLdp/M+pTxQpNzQmY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1681907322; 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; bh=CUCqhcrEZtVFjgYhhJi2gMdhOU42ijzzsPuhqfdsFM8=; b=OoBGcl2U1DOadJhVeTN11tam0ZyUqlCB80ldPOHrTTBIDiui9NtuGTl1G776CYTYZj8YWMdngAMv0Rc4GXcEZH7uC7wXzNuQOjx9S8fPiGKnTqjma12mBVdACJ4RQh1mK7h4hcZOrLeS4yA+lpUg7JPDbz1edvcGiPvi5b3peg0= 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=pass 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 1681907322096853.510820461766; Wed, 19 Apr 2023 05:28:42 -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-515-_xnUwfVXOZGx8Tg6X2rQ7Q-1; Wed, 19 Apr 2023 08:28:35 -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 6AB4B811E7D; Wed, 19 Apr 2023 12:28:32 +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 56FD0C16024; Wed, 19 Apr 2023 12:28:32 +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 A036419465B3; Wed, 19 Apr 2023 12:28:17 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 3C3A919465B1 for ; Wed, 19 Apr 2023 12:04:53 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 13703492B05; Wed, 19 Apr 2023 12:04:53 +0000 (UTC) Received: from speedmetal.redhat.com (unknown [10.45.242.23]) by smtp.corp.redhat.com (Postfix) with ESMTP id 8E400492B04 for ; Wed, 19 Apr 2023 12:04:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1681907321; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to: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=CUCqhcrEZtVFjgYhhJi2gMdhOU42ijzzsPuhqfdsFM8=; b=SgwRjPwz1++rcwI/+oqBlfrK+gc2/gbk1tx5s6y+qBFPdjtk1MkApAzOmvnAMDeqkhKAHz uSvlabUxLq1ynRJPd+k0L2PCIOYahSMARyemaJHyIbddZZjULA2Iq3coxwcsfypF2FNl7b BZYXYLBqG6p3pxas4cNzmG7/bLlpUkU= X-MC-Unique: _xnUwfVXOZGx8Tg6X2rQ7Q-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH v3 10/25] util: virtypedparam: Introduce 'virTypedParamListFetch' Date: Wed, 19 Apr 2023 14:04:27 +0200 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.9 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: , 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: 1681907323197100003 Content-Type: text/plain; charset="utf-8" Introduce a helper that fetches the typed parameters from the list while still preserving ownership of the pointer by the list. In the future this will be also able to report errors stored in the list. Signed-off-by: Peter Krempa --- src/libvirt_private.syms | 1 + src/util/virtypedparam.c | 26 ++++++++++++++++++++++++++ src/util/virtypedparam.h | 6 ++++++ 3 files changed, 33 insertions(+) diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index 0f42c2de0b..f1999d0e99 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -3556,6 +3556,7 @@ virTypedParamListAddString; virTypedParamListAddUInt; virTypedParamListAddULLong; virTypedParamListConcat; +virTypedParamListFetch; virTypedParamListFree; virTypedParamListFromParams; virTypedParamListNew; diff --git a/src/util/virtypedparam.c b/src/util/virtypedparam.c index f8dce9ed98..6e837c65bc 100644 --- a/src/util/virtypedparam.c +++ b/src/util/virtypedparam.c @@ -747,6 +747,32 @@ virTypedParamListFree(virTypedParamList *list) } +/** + * virTypedParamListFetch: + * + * @list: virTypedParamList object + * @par: if not NULL filled with the typed parameters stored in @list + * @npar: if not NULL filled with the number of typed parameters stored in= @list + * + * Checks that @list has no errors stored and optionally fills @par and @n= par + * with a valid list of typed parametes. The typed parameters still belong= to + * @list and will be freed together. + */ +int +virTypedParamListFetch(virTypedParamList *list, + virTypedParameterPtr *par, + size_t *npar) +{ + if (par) + *par =3D list->par; + + if (npar) + *npar =3D list->npar; + + return 0; +} + + size_t virTypedParamListStealParams(virTypedParamList *list, virTypedParameterPtr *params) diff --git a/src/util/virtypedparam.h b/src/util/virtypedparam.h index 45422c2673..628c951432 100644 --- a/src/util/virtypedparam.h +++ b/src/util/virtypedparam.h @@ -152,6 +152,12 @@ size_t virTypedParamListStealParams(virTypedParamList *list, virTypedParameterPtr *params); +int +virTypedParamListFetch(virTypedParamList *list, + virTypedParameterPtr *par, + size_t *npar) + G_GNUC_WARN_UNUSED_RESULT; + virTypedParamList * virTypedParamListFromParams(virTypedParameterPtr *params, size_t nparams); --=20 2.39.2 From nobody Mon Feb 9 01:44:02 2026 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=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1681907318; cv=none; d=zohomail.com; s=zohoarc; b=fQdVcGplIIe5UH2dbDOprLjZwq5Um7xAbu0s7K7kNMuj13Sm/qrBK6bn8ZHo8HuPvs5nGKttY8AFqwJmxIlOR67fvfx86tTZiazHIioQKkBqK6gGa31CUfjv9aNZPLSVs2RdjyoCg5732oQ0/2JuAyZbl0PZRlqgLaGIfk4VzsA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1681907318; 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; bh=rbAOkxA9QCm9R7hDOlLVMizkFcO9NPoVU/UZNuBXoKQ=; b=Rw9zWKOkdXwC9E6OrHW/Gj268UyepzXPRoKXHgtDOajd2jQmf2nrsSY9e6qkfXgxfOT1fGnJdPUWjb/sMe4RmuxmiH7uUBnkXhxSf9xcQfM2lRB6Ihcq+lh7XockLsIS4YLfWH8ZZAtfwObVSEQb+7R7VatuzdHxa3e3G5zv7Sw= 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=pass 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 1681907318901443.2118741927685; Wed, 19 Apr 2023 05:28:38 -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-22-RUl28ro3P6KlgQ0dWEQX6g-1; Wed, 19 Apr 2023 08:28:31 -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 530C88996F3; Wed, 19 Apr 2023 12:28:28 +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 3EF32C16026; Wed, 19 Apr 2023 12:28:28 +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 04D0719465B9; Wed, 19 Apr 2023 12:28:22 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id E468719465A0 for ; Wed, 19 Apr 2023 12:04:53 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id D7D02492B05; Wed, 19 Apr 2023 12:04:53 +0000 (UTC) Received: from speedmetal.redhat.com (unknown [10.45.242.23]) by smtp.corp.redhat.com (Postfix) with ESMTP id 5F60C492B04 for ; Wed, 19 Apr 2023 12:04:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1681907317; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to: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=rbAOkxA9QCm9R7hDOlLVMizkFcO9NPoVU/UZNuBXoKQ=; b=ZpD0/WzRAphVS3EIdHiEJLtxYKMzIi0LqEb8bTfQ3A7tK0h2MdRev2MQsV3feksBAmqcNT 1qxvk19XOZPXIi6BKpwuy2dMBcRcqq9+QJE2YG9PjwsIKTcJ0V3Uq76stkV7hdGKRGisCa LifpZPQpOq4iz5UfuWuFtwoRPrZly/Q= X-MC-Unique: RUl28ro3P6KlgQ0dWEQX6g-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH v3 11/25] Use 'virTypedParamListFetch' for extracting identity parameters list Date: Wed, 19 Apr 2023 14:04:28 +0200 Message-Id: <26e88c649376c7e7914abcd253a27158e439a2f6.1681905482.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.9 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: , 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: 1681907319158100001 Content-Type: text/plain; charset="utf-8" Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/driver.c | 7 ++++++- src/remote/remote_daemon_dispatch.c | 8 +++++++- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/src/driver.c b/src/driver.c index c7a9c2659f..35f8156605 100644 --- a/src/driver.c +++ b/src/driver.c @@ -165,8 +165,13 @@ virGetConnectGeneric(virThreadLocal *threadPtr, const = char *name) ident =3D virIdentityGetCurrent(); if (ident) { g_autoptr(virTypedParamList) tmp =3D virIdentityGetParamet= ers(ident); + virTypedParameterPtr par; + size_t npar; - if (virConnectSetIdentity(conn, tmp->par, tmp->npar, 0) < = 0) + if (virTypedParamListFetch(tmp, &par, &npar) < 0) + goto error; + + if (virConnectSetIdentity(conn, par, npar, 0) < 0) goto error; } } diff --git a/src/remote/remote_daemon_dispatch.c b/src/remote/remote_daemon= _dispatch.c index 4fc83dbd90..7144e9e7ca 100644 --- a/src/remote/remote_daemon_dispatch.c +++ b/src/remote/remote_daemon_dispatch.c @@ -1824,7 +1824,13 @@ remoteOpenConn(const char *uri, VIR_DEBUG("Opened driver %p", newconn); if (preserveIdentity) { - if (virConnectSetIdentity(newconn, identparams->par, identparams->= npar, 0) < 0) + virTypedParameterPtr par; + size_t npar; + + if (virTypedParamListFetch(identparams, &par, &npar) < 0) + return -1; + + if (virConnectSetIdentity(newconn, par, npar, 0) < 0) return -1; VIR_DEBUG("Forwarded current identity to secondary driver"); --=20 2.39.2 From nobody Mon Feb 9 01:44:02 2026 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=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1681907046; cv=none; d=zohomail.com; s=zohoarc; b=huqY5V6q6PSOOjxRg2/kbGQn0GoHHP4QCmcLj6E5FmiulkpjkaLixksi0eedMLtnGSi2GHy8ecpSI19H1vMNiQXZHKjDzQJ5eMZorMhLWRp8yxjchOJ3eRU8rjtKkce3oduWy0Fo7Hb9m0UbJ6GykNB6GiQAM1e2oPFiRFixoKk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1681907046; 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; bh=CFbrtQfC6QNmQB5b0Y3yeT87Gs+QrC7P2dMKuLnc7hQ=; b=WYj92TjTsLMVPr1HYV7O3XEYcwgtWjGW1liT7Kw2sRtFp/C0QxXvvrTyv6IutYfw+GIq5zFMgyVleh0lDiLVu9SncbbN0WqYPKtHd0EdGfnUzMopzWDDnp4M5v7tFnfRYkPEolfuLXekyGsUp3ZT/7QxLTdG7QP/w6GAkCVR1Qg= 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=pass 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 1681907046873261.41502725160024; Wed, 19 Apr 2023 05:24:06 -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-321-vQ4GkhcVNUOU8w_JbCyAQA-1; Wed, 19 Apr 2023 08:23:43 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id B5A61858F09; Wed, 19 Apr 2023 12:23:40 +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 9D8A520239E0; Wed, 19 Apr 2023 12:23:40 +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 6B8E819465B1; Wed, 19 Apr 2023 12:23:40 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id B56F419465A0 for ; Wed, 19 Apr 2023 12:04:54 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id AB4EB492B05; Wed, 19 Apr 2023 12:04:54 +0000 (UTC) Received: from speedmetal.redhat.com (unknown [10.45.242.23]) by smtp.corp.redhat.com (Postfix) with ESMTP id 3131C492B04 for ; Wed, 19 Apr 2023 12:04:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1681907045; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to: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=CFbrtQfC6QNmQB5b0Y3yeT87Gs+QrC7P2dMKuLnc7hQ=; b=ILxgb4zqpuOI8TTpyaajWmPb6A/VoItWvOf0b8GK4W+Xev80C9OmmXUacyj7tozDCTILnN /cWu9xVz3VjgFH91Qc7ilN10nYO/N1PQSnT3izxlg199SWCE9itWBYiZbXGcJJ5+dm8dgK tsiiK2LJvtkGofD52WnczEFLqwH23Jk= X-MC-Unique: vQ4GkhcVNUOU8w_JbCyAQA-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH v3 12/25] util: virtypedparam: Privatize definition of struct _virTypedParamList Date: Wed, 19 Apr 2023 14:04:29 +0200 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.9 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: , Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 3.1 on 10.11.54.4 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: 1681907049040100004 Content-Type: text/plain; charset="utf-8" Ensure that all callers access it via the APIs. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/util/virtypedparam.c | 7 +++++++ src/util/virtypedparam.h | 5 ----- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/src/util/virtypedparam.c b/src/util/virtypedparam.c index 6e837c65bc..e03e112d1e 100644 --- a/src/util/virtypedparam.c +++ b/src/util/virtypedparam.c @@ -705,6 +705,13 @@ virTypedParamsSerialize(virTypedParameterPtr params, } +struct _virTypedParamList { + virTypedParameterPtr par; + size_t npar; + size_t par_alloc; +}; + + virTypedParamList * virTypedParamListNew(void) { diff --git a/src/util/virtypedparam.h b/src/util/virtypedparam.h index 628c951432..b6ad209e25 100644 --- a/src/util/virtypedparam.h +++ b/src/util/virtypedparam.h @@ -137,11 +137,6 @@ VIR_ENUM_DECL(virTypedParameter); } while (0) typedef struct _virTypedParamList virTypedParamList; -struct _virTypedParamList { - virTypedParameterPtr par; - size_t npar; - size_t par_alloc; -}; void virTypedParamListFree(virTypedParamList *list); --=20 2.39.2 From nobody Mon Feb 9 01:44:02 2026 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=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1681908477; cv=none; d=zohomail.com; s=zohoarc; b=SYiT0PT3X7bg2NCS+W5EUyhXeedqPVEcv/JxnZEV/RTHVEay8Ta0wsjURognB7K3QqPgYn3O0qFz9yhet+UQ0M9b1zKFqk0Fkzv8Z6ytoTODpD+ja2Y3EHn20YiadFakvNdwlwhIGAcjV21b+5FEqKEKCwzB4su0vNrB1l9MOes= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1681908477; 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; bh=3K26FwnwhlEMTIetuGnkanTvWQHxkcxfyVmm2Vb2l4g=; b=U5sXguV/+oLNAIYm2COBk0eGbv1DiFcR+jP7QgREmYAViWdu7a6VndqeKIA9W8hQl6AppWkxy61blLRsKvSewLPlucWA7iaePXOU5qPmd0D5onhlhS+UHaZkS8+MJjirHugWun0E0hqQFlWTo3bGxxMx96uSu7tK0j0G71Kga+A= 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=pass 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 1681908477979470.76491904572515; Wed, 19 Apr 2023 05:47:57 -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-638-1HNs9cBUMfCJk0pQK0t9Mw-1; Wed, 19 Apr 2023 08:47:53 -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 940DA280D582; Wed, 19 Apr 2023 12:47:50 +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 816E763A5D; Wed, 19 Apr 2023 12:47:50 +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 59C1A19465B1; Wed, 19 Apr 2023 12:47:50 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 9ABE819465B1 for ; Wed, 19 Apr 2023 12:04:55 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 8E32F492B07; Wed, 19 Apr 2023 12:04:55 +0000 (UTC) Received: from speedmetal.redhat.com (unknown [10.45.242.23]) by smtp.corp.redhat.com (Postfix) with ESMTP id 14607492B06 for ; Wed, 19 Apr 2023 12:04:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1681908477; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to: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=3K26FwnwhlEMTIetuGnkanTvWQHxkcxfyVmm2Vb2l4g=; b=HWW6wMYdRioF0F5i3if3AObHGe8l6P7Fu+76h3k1Wu8IE4pI/M7vWF9fjYIpcSQFQarReG avy6gyc9jpoDbjSkzhUwYmVyOH4/Gby5HkojzgT35pGEHLjYnX454iRHTGcnwTW5MykaPm J3SDwwOq72nystTuliZlcC3fsPQoDds= X-MC-Unique: 1HNs9cBUMfCJk0pQK0t9Mw-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH v3 13/25] util: virtypedparam: Refactor return value of virTypedParamListStealParams Date: Wed, 19 Apr 2023 14:04:30 +0200 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.9 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: , 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: 1681908479865100001 Content-Type: text/plain; charset="utf-8" Return the number of parameters via pointer passed as argument to free up possibility to report errors. Strangely all callers actually use 'int' as type for storing the count of elements, thus this function will use the same. The function is also renamed to virTypedParamListSteal. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/admin/admin_server.c | 10 +++++++--- src/libvirt_private.syms | 2 +- src/qemu/qemu_domainjob.c | 4 +++- src/qemu/qemu_driver.c | 4 +++- src/test/test_driver.c | 4 +++- src/util/virtypedparam.c | 20 ++++++++++++++------ src/util/virtypedparam.h | 7 ++++--- 7 files changed, 35 insertions(+), 16 deletions(-) diff --git a/src/admin/admin_server.c b/src/admin/admin_server.c index 394de0dfab..1d1ae97f2f 100644 --- a/src/admin/admin_server.c +++ b/src/admin/admin_server.c @@ -113,7 +113,8 @@ adminServerGetThreadPoolParameters(virNetServer *srv, "%s", VIR_THREADPOOL_JOB_QUEUE_DEPTH) < 0) return -1; - *nparams =3D virTypedParamListStealParams(paramlist, params); + if (virTypedParamListSteal(paramlist, params, nparams) < 0) + return -1; return 0; } @@ -279,7 +280,9 @@ adminClientGetInfo(virNetServerClient *client, "%s", VIR_CLIENT_INFO_SELINUX_CONTEXT) = < 0) return -1; - *nparams =3D virTypedParamListStealParams(paramlist, params); + if (virTypedParamListSteal(paramlist, params, nparams) < 0) + return -1; + return 0; } @@ -322,7 +325,8 @@ adminServerGetClientLimits(virNetServer *srv, "%s", VIR_SERVER_CLIENTS_UNAUTH_CURRENT) = < 0) return -1; - *nparams =3D virTypedParamListStealParams(paramlist, params); + if (virTypedParamListSteal(paramlist, params, nparams) < 0) + return -1; return 0; } diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index f1999d0e99..b58be6aa33 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -3560,7 +3560,7 @@ virTypedParamListFetch; virTypedParamListFree; virTypedParamListFromParams; virTypedParamListNew; -virTypedParamListStealParams; +virTypedParamListSteal; virTypedParamsCheck; virTypedParamsCopy; virTypedParamsDeserialize; diff --git a/src/qemu/qemu_domainjob.c b/src/qemu/qemu_domainjob.c index 4df1af0ce7..6be48118b9 100644 --- a/src/qemu/qemu_domainjob.c +++ b/src/qemu/qemu_domainjob.c @@ -522,7 +522,9 @@ qemuDomainBackupJobDataToParams(virDomainJobData *jobDa= ta, virTypedParamListAddString(par, jobData->errmsg, VIR_DOMAIN_JOB_ER= RMSG) < 0) return -1; - *nparams =3D virTypedParamListStealParams(par, params); + if (virTypedParamListSteal(par, params, nparams) < 0) + return -1; + *type =3D virDomainJobStatusToType(jobData->status); return 0; } diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index b89bf176bb..9c409948f0 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -18459,7 +18459,9 @@ qemuDomainGetStats(virConnectPtr conn, dom->def->uuid, dom->def->id))) return -1; - tmp->nparams =3D virTypedParamListStealParams(params, &tmp->params); + if (virTypedParamListSteal(params, &tmp->params, &tmp->nparams) < 0) + return -1; + *record =3D g_steal_pointer(&tmp); return 0; } diff --git a/src/test/test_driver.c b/src/test/test_driver.c index 47c74c420c..ac12488de9 100644 --- a/src/test/test_driver.c +++ b/src/test/test_driver.c @@ -9873,7 +9873,9 @@ testDomainGetStats(virConnectPtr conn, dom->def->uuid, dom->def->id))) return -1; - tmp->nparams =3D virTypedParamListStealParams(params, &tmp->params); + if (virTypedParamListSteal(params, &tmp->params, &tmp->nparams) < 0) + return -1; + *record =3D g_steal_pointer(&tmp); return 0; } diff --git a/src/util/virtypedparam.c b/src/util/virtypedparam.c index e03e112d1e..68698fe583 100644 --- a/src/util/virtypedparam.c +++ b/src/util/virtypedparam.c @@ -780,19 +780,27 @@ virTypedParamListFetch(virTypedParamList *list, } -size_t -virTypedParamListStealParams(virTypedParamList *list, - virTypedParameterPtr *params) +int +virTypedParamListSteal(virTypedParamList *list, + virTypedParameterPtr *par, + int *npar) { - size_t ret =3D list->npar; + size_t nparams; + + if (virTypedParamListFetch(list, par, &nparams) < 0) + return -1; - *params =3D g_steal_pointer(&list->par); + /* most callers expect 'int', so help them out */ + *npar =3D nparams; + + list->par =3D NULL; list->npar =3D 0; list->par_alloc =3D 0; - return ret; + return 0; } + virTypedParamList * virTypedParamListFromParams(virTypedParameterPtr *params, size_t nparams) diff --git a/src/util/virtypedparam.h b/src/util/virtypedparam.h index b6ad209e25..b2869173e1 100644 --- a/src/util/virtypedparam.h +++ b/src/util/virtypedparam.h @@ -143,9 +143,10 @@ virTypedParamListFree(virTypedParamList *list); G_DEFINE_AUTOPTR_CLEANUP_FUNC(virTypedParamList, virTypedParamListFree); virTypedParamList *virTypedParamListNew(void); -size_t -virTypedParamListStealParams(virTypedParamList *list, - virTypedParameterPtr *params); +int +virTypedParamListSteal(virTypedParamList *list, + virTypedParameterPtr *par, + int *npar); int virTypedParamListFetch(virTypedParamList *list, --=20 2.39.2 From nobody Mon Feb 9 01:44:02 2026 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=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1681906449; cv=none; d=zohomail.com; s=zohoarc; b=n/VlrYXE7+kRNM1OPvrRhtfn/Y6psDfNAoTzuccEWzQKu0WXSP9SMopBc9tqOP3pUOkjljtga1j3QPL3c8t0e+CZzGQ6s6yr0NhBbzCA78YCJuZJPzQy8R7juqoVuFK+hf8K6KTbtEi5FLK8eeqX8aLUu1SjdLT5D2Xt5HwEz2M= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1681906449; 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; bh=2ydJfqfaBm/3WgPRF8v//tk5Ceze6MAnakX34ztshf8=; b=SjV+GyMgmzsE+7WQsHL4NSOyLHSq1GoWBtzuk0GSGpuVAgxgXE6xiqbUde3ZQnUGXGknAilxSDy8wgc8ZTKdUQfojJw8A6EhHNOKrQGwFCVRzj9oiCMmKZ+TiQkdVzRTrfRboA0tWLGQxzcxdveFlcW9NUGrjcCsDNOeMLoUNOQ= 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=pass 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 168190644978582.17509554785647; Wed, 19 Apr 2023 05:14:09 -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-658-RZhmtcR5PxKHvzJIyOOkdw-1; Wed, 19 Apr 2023 08:14:06 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 1D0E48996F3; Wed, 19 Apr 2023 12:14: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 0DB1E2026D25; Wed, 19 Apr 2023 12:13:59 +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 B4D0819465B1; Wed, 19 Apr 2023 12:13:59 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 9D18119465A0 for ; Wed, 19 Apr 2023 12:04:56 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 9258D492B04; Wed, 19 Apr 2023 12:04:56 +0000 (UTC) Received: from speedmetal.redhat.com (unknown [10.45.242.23]) by smtp.corp.redhat.com (Postfix) with ESMTP id E048B492B06 for ; Wed, 19 Apr 2023 12:04:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1681906448; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to: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=2ydJfqfaBm/3WgPRF8v//tk5Ceze6MAnakX34ztshf8=; b=W0gWIckgN1tjWRwQgJLQY3VjfYMsRbKb1jJRR5b6jvfVrISyVPu+Idedz0SnOKWachxEKs eSUaMjyR8WrxfmUIKi4FMmJ/WuD8eFLl4XVDPAnNxLJKKWhheiOJkLDik5o9r8HyDoDUs+ Y/6W26dua6LS13X8BwHXxkqVupOskGg= X-MC-Unique: RZhmtcR5PxKHvzJIyOOkdw-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH v3 14/25] util: virtypedparam: Store errors inside virTypedParamList Date: Wed, 19 Apr 2023 14:04:31 +0200 Message-Id: <0ea41656416185c6e425cdad981a9a768cc6bc63.1681905482.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.9 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: , Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 3.1 on 10.11.54.4 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: 1681906450962100001 Content-Type: text/plain; charset="utf-8" The only non-abort()-ing error which can happen is if the field name is too long. Store the overly long name in the virTypedParamList container so that in upcoming patches the helpers adding to the list can be refactored to not have a return value. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/util/virtypedparam.c | 62 ++++++++++++++++++++++------------------ 1 file changed, 34 insertions(+), 28 deletions(-) diff --git a/src/util/virtypedparam.c b/src/util/virtypedparam.c index 68698fe583..046164d36c 100644 --- a/src/util/virtypedparam.c +++ b/src/util/virtypedparam.c @@ -709,6 +709,8 @@ struct _virTypedParamList { virTypedParameterPtr par; size_t npar; size_t par_alloc; + + char *err_name; /* overly long field name for error message */ }; @@ -740,6 +742,9 @@ virTypedParamListConcat(virTypedParamList *to, memcpy(to->par + to->npar, from->par, sizeof(*(to->par)) * from->npar); to->npar +=3D from->npar; from->npar =3D 0; + + if (!to->err_name) + to->err_name =3D g_steal_pointer(&from->err_name); } @@ -750,6 +755,7 @@ virTypedParamListFree(virTypedParamList *list) return; virTypedParamsFree(list->par, list->npar); + g_free(list->err_name); g_free(list); } @@ -770,6 +776,12 @@ virTypedParamListFetch(virTypedParamList *list, virTypedParameterPtr *par, size_t *npar) { + if (list->err_name) { + virReportError(VIR_ERR_INTERNAL_ERROR, _("Field name '%1$s' too lo= ng"), + list->err_name); + return -1; + } + if (par) *par =3D list->par; @@ -815,17 +827,18 @@ virTypedParamListFromParams(virTypedParameterPtr *par= ams, } -static int G_GNUC_PRINTF(2, 0) -virTypedParamSetNameVPrintf(virTypedParameterPtr par, +static void G_GNUC_PRINTF(3, 0) +virTypedParamSetNameVPrintf(virTypedParamList *list, + virTypedParameterPtr par, const char *fmt, va_list ap) { - if (g_vsnprintf(par->field, VIR_TYPED_PARAM_FIELD_LENGTH, fmt, ap) > V= IR_TYPED_PARAM_FIELD_LENGTH) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("Field name too lon= g")); - return -1; - } + g_autofree char *name =3D g_strdup_vprintf(fmt, ap); - return 0; + if (virStrcpyStatic(par->field, name) < 0) { + if (!list->err_name) + list->err_name =3D g_steal_pointer(&name); + } } @@ -848,15 +861,14 @@ virTypedParamListAddInt(virTypedParamList *list, { virTypedParameterPtr par =3D virTypedParamListExtend(list); va_list ap; - int ret; virTypedParameterAssignValue(par, VIR_TYPED_PARAM_INT, value); va_start(ap, namefmt); - ret =3D virTypedParamSetNameVPrintf(par, namefmt, ap); + virTypedParamSetNameVPrintf(list, par, namefmt, ap); va_end(ap); - return ret; + return 0; } @@ -868,15 +880,14 @@ virTypedParamListAddUInt(virTypedParamList *list, { virTypedParameterPtr par =3D virTypedParamListExtend(list); va_list ap; - int ret; virTypedParameterAssignValue(par, VIR_TYPED_PARAM_UINT, value); va_start(ap, namefmt); - ret =3D virTypedParamSetNameVPrintf(par, namefmt, ap); + virTypedParamSetNameVPrintf(list, par, namefmt, ap); va_end(ap); - return ret; + return 0; } @@ -888,15 +899,14 @@ virTypedParamListAddLLong(virTypedParamList *list, { virTypedParameterPtr par =3D virTypedParamListExtend(list); va_list ap; - int ret; virTypedParameterAssignValue(par, VIR_TYPED_PARAM_LLONG, value); va_start(ap, namefmt); - ret =3D virTypedParamSetNameVPrintf(par, namefmt, ap); + virTypedParamSetNameVPrintf(list, par, namefmt, ap); va_end(ap); - return ret; + return 0; } @@ -908,15 +918,14 @@ virTypedParamListAddULLong(virTypedParamList *list, { virTypedParameterPtr par =3D virTypedParamListExtend(list); va_list ap; - int ret; virTypedParameterAssignValue(par, VIR_TYPED_PARAM_ULLONG, value); va_start(ap, namefmt); - ret =3D virTypedParamSetNameVPrintf(par, namefmt, ap); + virTypedParamSetNameVPrintf(list, par, namefmt, ap); va_end(ap); - return ret; + return 0; } @@ -928,15 +937,14 @@ virTypedParamListAddString(virTypedParamList *list, { virTypedParameterPtr par =3D virTypedParamListExtend(list); va_list ap; - int ret; virTypedParameterAssignValue(par, VIR_TYPED_PARAM_STRING, value); va_start(ap, namefmt); - ret =3D virTypedParamSetNameVPrintf(par, namefmt, ap); + virTypedParamSetNameVPrintf(list, par, namefmt, ap); va_end(ap); - return ret; + return 0; } @@ -948,15 +956,14 @@ virTypedParamListAddBoolean(virTypedParamList *list, { virTypedParameterPtr par =3D virTypedParamListExtend(list); va_list ap; - int ret; virTypedParameterAssignValue(par, VIR_TYPED_PARAM_BOOLEAN, value); va_start(ap, namefmt); - ret =3D virTypedParamSetNameVPrintf(par, namefmt, ap); + virTypedParamSetNameVPrintf(list, par, namefmt, ap); va_end(ap); - return ret; + return 0; } @@ -968,13 +975,12 @@ virTypedParamListAddDouble(virTypedParamList *list, { virTypedParameterPtr par =3D virTypedParamListExtend(list); va_list ap; - int ret; virTypedParameterAssignValue(par, VIR_TYPED_PARAM_DOUBLE, value); va_start(ap, namefmt); - ret =3D virTypedParamSetNameVPrintf(par, namefmt, ap); + virTypedParamSetNameVPrintf(list, par, namefmt, ap); va_end(ap); - return ret; + return 0; } --=20 2.39.2 From nobody Mon Feb 9 01:44:02 2026 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=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1681907060; cv=none; d=zohomail.com; s=zohoarc; b=TZYzn/txD2pU566wMUUKxD+mJY+BNHVqC4s+MJdtO8Vy6wn3n3AhFTxm2ziT8ZWr3rx3LegoUstvCarBSG0VJldwt+suaYm8Y6c1FvG7AO8cCUifrK+kEiNDvv15mia2G4lDGixWTASthb4CfuQ03MP/cwnkdIOdI8+nlX+7BbQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1681907060; 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; bh=LZxsP6jcNRl3kIm8lrRymOaRVIjfL8IUp2UhK9gWe8I=; b=LSvrHo2oL5cBO6eKyG99Lm7rJlo+KHy0Lx1mnOy8sjPaLFocFBaQ6+tbF7P9CRNe8PYCOBlj5uFTlWpBrO7aNdFTwQSCsyGO7bG6qDTqD7xEJgxCC3vXAjE368ArYi6LCWeJRfq4zrNNgC4QQbknrOUVG5V/Dop/Adsdp0QwU8Q= 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=pass 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 1681907060865143.80054048745342; Wed, 19 Apr 2023 05:24:20 -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-196-_vgtNVESNNSwFxaCaCnPEA-1; Wed, 19 Apr 2023 08:23:16 -0400 Received: from smtp.corp.redhat.com (int-mx10.intmail.prod.int.rdu2.redhat.com [10.11.54.10]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id BA1428996FB; Wed, 19 Apr 2023 12:23:13 +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 A0CDA492C3E; Wed, 19 Apr 2023 12:23:13 +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 63D9819465B1; Wed, 19 Apr 2023 12:23:13 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 1547019465A0 for ; Wed, 19 Apr 2023 12:04:58 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id EB9A5492B05; Wed, 19 Apr 2023 12:04:57 +0000 (UTC) Received: from speedmetal.redhat.com (unknown [10.45.242.23]) by smtp.corp.redhat.com (Postfix) with ESMTP id E7EF3492B04 for ; Wed, 19 Apr 2023 12:04:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1681907058; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to: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=LZxsP6jcNRl3kIm8lrRymOaRVIjfL8IUp2UhK9gWe8I=; b=IA6DxCeLGhC6Udlimk99CDz/bq8Ak4/2vHrnyXCpbKuh0J5+l9LgXlQyw57Dz2zTNv9ZOL nCWNwMBPn7WiXqGXjWjKVeiHrhAzLxFRBe09eK4MAAe5H4aZrrvPip0Odjjh8K+D55vuAC FtmAakhwNR/HT1d3zHTJv1bM6sDBtoo= X-MC-Unique: _vgtNVESNNSwFxaCaCnPEA-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH v3 15/25] util: virtypedparam: Remove return values from virTypedParamListAdd* APIs Date: Wed, 19 Apr 2023 14:04:32 +0200 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.9 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: , Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 3.1 on 10.11.54.10 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: 1681907061775100001 Content-Type: text/plain; charset="utf-8" The function now return always 0. Refactor the code and remove return values. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/admin/admin_server.c | 108 ++++--------- src/qemu/qemu_domainjob.c | 45 ++---- src/qemu/qemu_driver.c | 330 ++++++++++++-------------------------- src/test/test_driver.c | 28 ++-- src/util/virtypedparam.c | 28 +--- src/util/virtypedparam.h | 28 ++-- 6 files changed, 173 insertions(+), 394 deletions(-) diff --git a/src/admin/admin_server.c b/src/admin/admin_server.c index 1d1ae97f2f..2498a1309a 100644 --- a/src/admin/admin_server.c +++ b/src/admin/admin_server.c @@ -89,29 +89,12 @@ adminServerGetThreadPoolParameters(virNetServer *srv, return -1; } - if (virTypedParamListAddUInt(paramlist, minWorkers, - "%s", VIR_THREADPOOL_WORKERS_MIN) < 0) - return -1; - - if (virTypedParamListAddUInt(paramlist, maxWorkers, - "%s", VIR_THREADPOOL_WORKERS_MAX) < 0) - return -1; - - if (virTypedParamListAddUInt(paramlist, nWorkers, - "%s", VIR_THREADPOOL_WORKERS_CURRENT) < 0) - return -1; - - if (virTypedParamListAddUInt(paramlist, freeWorkers, - "%s", VIR_THREADPOOL_WORKERS_FREE) < 0) - return -1; - - if (virTypedParamListAddUInt(paramlist, nPrioWorkers, - "%s", VIR_THREADPOOL_WORKERS_PRIORITY) < = 0) - return -1; - - if (virTypedParamListAddUInt(paramlist, jobQueueDepth, - "%s", VIR_THREADPOOL_JOB_QUEUE_DEPTH) < 0) - return -1; + virTypedParamListAddUInt(paramlist, minWorkers, VIR_THREADPOOL_WORKERS= _MIN); + virTypedParamListAddUInt(paramlist, maxWorkers, VIR_THREADPOOL_WORKERS= _MAX); + virTypedParamListAddUInt(paramlist, nWorkers, VIR_THREADPOOL_WORKERS_C= URRENT); + virTypedParamListAddUInt(paramlist, freeWorkers, VIR_THREADPOOL_WORKER= S_FREE); + virTypedParamListAddUInt(paramlist, nPrioWorkers, VIR_THREADPOOL_WORKE= RS_PRIORITY); + virTypedParamListAddUInt(paramlist, jobQueueDepth, VIR_THREADPOOL_JOB_= QUEUE_DEPTH); if (virTypedParamListSteal(paramlist, params, nparams) < 0) return -1; @@ -211,74 +194,54 @@ adminClientGetInfo(virNetServerClient *client, &sock_addr, &identity) < 0) return -1; - if (virTypedParamListAddBoolean(paramlist, readonly, - "%s", VIR_CLIENT_INFO_READONLY) < 0) - return -1; + virTypedParamListAddBoolean(paramlist, readonly, VIR_CLIENT_INFO_READO= NLY); if ((rc =3D virIdentityGetSASLUserName(identity, &attr)) < 0) return -1; - if (rc =3D=3D 1 && - virTypedParamListAddString(paramlist, attr, - "%s", VIR_CLIENT_INFO_SASL_USER_NAME) <= 0) - return -1; + if (rc =3D=3D 1) + virTypedParamListAddString(paramlist, attr, VIR_CLIENT_INFO_SASL_U= SER_NAME); if (!virNetServerClientIsLocal(client)) { - if (virTypedParamListAddString(paramlist, sock_addr, - "%s", VIR_CLIENT_INFO_SOCKET_ADDR) = < 0) - return -1; + virTypedParamListAddString(paramlist, sock_addr, VIR_CLIENT_INFO_S= OCKET_ADDR); if ((rc =3D virIdentityGetX509DName(identity, &attr)) < 0) return -1; - if (rc =3D=3D 1 && - virTypedParamListAddString(paramlist, attr, - "%s", VIR_CLIENT_INFO_X509_DISTINGU= ISHED_NAME) < 0) - return -1; + if (rc =3D=3D 1) + virTypedParamListAddString(paramlist, attr, VIR_CLIENT_INFO_X5= 09_DISTINGUISHED_NAME); } else { pid_t pid; uid_t uid; gid_t gid; if ((rc =3D virIdentityGetUNIXUserID(identity, &uid)) < 0) return -1; - if (rc =3D=3D 1 && - virTypedParamListAddInt(paramlist, uid, - "%s", VIR_CLIENT_INFO_UNIX_USER_ID) < = 0) - return -1; + if (rc =3D=3D 1) + virTypedParamListAddInt(paramlist, uid, VIR_CLIENT_INFO_UNIX_U= SER_ID); if ((rc =3D virIdentityGetUserName(identity, &attr)) < 0) return -1; - if (rc =3D=3D 1 && - virTypedParamListAddString(paramlist, attr, - "%s", VIR_CLIENT_INFO_UNIX_USER_NAM= E) < 0) - return -1; + if (rc =3D=3D 1) + virTypedParamListAddString(paramlist, attr, VIR_CLIENT_INFO_UN= IX_USER_NAME); if ((rc =3D virIdentityGetUNIXGroupID(identity, &gid)) < 0) return -1; - if (rc =3D=3D 1 && - virTypedParamListAddInt(paramlist, gid, - "%s", VIR_CLIENT_INFO_UNIX_GROUP_ID) <= 0) - return -1; + if (rc =3D=3D 1) + virTypedParamListAddInt(paramlist, gid, VIR_CLIENT_INFO_UNIX_G= ROUP_ID); if ((rc =3D virIdentityGetGroupName(identity, &attr)) < 0) return -1; - if (rc =3D=3D 1 && - virTypedParamListAddString(paramlist, attr, - "%s", VIR_CLIENT_INFO_UNIX_GROUP_NA= ME) < 0) - return -1; + if (rc =3D=3D 1) + virTypedParamListAddString(paramlist, attr, VIR_CLIENT_INFO_UN= IX_GROUP_NAME); if ((rc =3D virIdentityGetProcessID(identity, &pid)) < 0) return -1; - if (rc =3D=3D 1 && - virTypedParamListAddInt(paramlist, pid, - "%s", VIR_CLIENT_INFO_UNIX_PROCESS_ID)= < 0) - return -1; + if (rc =3D=3D 1) + virTypedParamListAddInt(paramlist, pid, VIR_CLIENT_INFO_UNIX_P= ROCESS_ID); } if ((rc =3D virIdentityGetSELinuxContext(identity, &attr)) < 0) return -1; - if (rc =3D=3D 1 && - virTypedParamListAddString(paramlist, attr, - "%s", VIR_CLIENT_INFO_SELINUX_CONTEXT) = < 0) - return -1; + if (rc =3D=3D 1) + virTypedParamListAddString(paramlist, attr, VIR_CLIENT_INFO_SELINU= X_CONTEXT); if (virTypedParamListSteal(paramlist, params, nparams) < 0) return -1; @@ -305,25 +268,10 @@ adminServerGetClientLimits(virNetServer *srv, virCheckFlags(0, -1); - if (virTypedParamListAddUInt(paramlist, - virNetServerGetMaxClients(srv), - "%s", VIR_SERVER_CLIENTS_MAX) < 0) - return -1; - - if (virTypedParamListAddUInt(paramlist, - virNetServerGetCurrentClients(srv), - "%s", VIR_SERVER_CLIENTS_CURRENT) < 0) - return -1; - - if (virTypedParamListAddUInt(paramlist, - virNetServerGetMaxUnauthClients(srv), - "%s", VIR_SERVER_CLIENTS_UNAUTH_MAX) < 0) - return -1; - - if (virTypedParamListAddUInt(paramlist, - virNetServerGetCurrentUnauthClients(srv), - "%s", VIR_SERVER_CLIENTS_UNAUTH_CURRENT) = < 0) - return -1; + virTypedParamListAddUInt(paramlist, virNetServerGetMaxClients(srv), VI= R_SERVER_CLIENTS_MAX); + virTypedParamListAddUInt(paramlist, virNetServerGetCurrentClients(srv)= , VIR_SERVER_CLIENTS_CURRENT); + virTypedParamListAddUInt(paramlist, virNetServerGetMaxUnauthClients(sr= v), VIR_SERVER_CLIENTS_UNAUTH_MAX); + virTypedParamListAddUInt(paramlist, virNetServerGetCurrentUnauthClient= s(srv), VIR_SERVER_CLIENTS_UNAUTH_CURRENT); if (virTypedParamListSteal(paramlist, params, nparams) < 0) return -1; diff --git a/src/qemu/qemu_domainjob.c b/src/qemu/qemu_domainjob.c index 6be48118b9..245e51f14b 100644 --- a/src/qemu/qemu_domainjob.c +++ b/src/qemu/qemu_domainjob.c @@ -480,47 +480,26 @@ qemuDomainBackupJobDataToParams(virDomainJobData *job= Data, qemuDomainBackupStats *stats =3D &priv->stats.backup; g_autoptr(virTypedParamList) par =3D virTypedParamListNew(); - if (virTypedParamListAddInt(par, jobData->operation, - VIR_DOMAIN_JOB_OPERATION) < 0) - return -1; - - if (virTypedParamListAddULLong(par, jobData->timeElapsed, - VIR_DOMAIN_JOB_TIME_ELAPSED) < 0) - return -1; + virTypedParamListAddInt(par, jobData->operation, VIR_DOMAIN_JOB_OPERAT= ION); + virTypedParamListAddULLong(par, jobData->timeElapsed, VIR_DOMAIN_JOB_T= IME_ELAPSED); if (stats->transferred > 0 || stats->total > 0) { - if (virTypedParamListAddULLong(par, stats->total, - VIR_DOMAIN_JOB_DISK_TOTAL) < 0) - return -1; - - if (virTypedParamListAddULLong(par, stats->transferred, - VIR_DOMAIN_JOB_DISK_PROCESSED) < 0) - return -1; - - if (virTypedParamListAddULLong(par, stats->total - stats->transfer= red, - VIR_DOMAIN_JOB_DISK_REMAINING) < 0) - return -1; + virTypedParamListAddULLong(par, stats->total, VIR_DOMAIN_JOB_DISK_= TOTAL); + virTypedParamListAddULLong(par, stats->transferred, VIR_DOMAIN_JOB= _DISK_PROCESSED); + virTypedParamListAddULLong(par, stats->total - stats->transferred,= VIR_DOMAIN_JOB_DISK_REMAINING); } if (stats->tmp_used > 0 || stats->tmp_total > 0) { - if (virTypedParamListAddULLong(par, stats->tmp_used, - VIR_DOMAIN_JOB_DISK_TEMP_USED) < 0) - return -1; - - if (virTypedParamListAddULLong(par, stats->tmp_total, - VIR_DOMAIN_JOB_DISK_TEMP_TOTAL) < 0) - return -1; + virTypedParamListAddULLong(par, stats->tmp_used, VIR_DOMAIN_JOB_DI= SK_TEMP_USED); + virTypedParamListAddULLong(par, stats->tmp_total, VIR_DOMAIN_JOB_D= ISK_TEMP_TOTAL); } - if (jobData->status !=3D VIR_DOMAIN_JOB_STATUS_ACTIVE && - virTypedParamListAddBoolean(par, - jobData->status =3D=3D VIR_DOMAIN_JOB_= STATUS_COMPLETED, - VIR_DOMAIN_JOB_SUCCESS) < 0) - return -1; + if (jobData->status !=3D VIR_DOMAIN_JOB_STATUS_ACTIVE) + virTypedParamListAddBoolean(par, jobData->status =3D=3D VIR_DOMAIN= _JOB_STATUS_COMPLETED, + VIR_DOMAIN_JOB_SUCCESS); - if (jobData->errmsg && - virTypedParamListAddString(par, jobData->errmsg, VIR_DOMAIN_JOB_ER= RMSG) < 0) - return -1; + if (jobData->errmsg) + virTypedParamListAddString(par, jobData->errmsg, VIR_DOMAIN_JOB_ER= RMSG); if (virTypedParamListSteal(par, params, nparams) < 0) return -1; diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index 9c409948f0..d47c1883f0 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -17020,11 +17020,8 @@ qemuDomainGetStatsState(virQEMUDriver *driver G_GN= UC_UNUSED, virTypedParamList *params, unsigned int privflags G_GNUC_UNUSED) { - if (virTypedParamListAddInt(params, dom->state.state, "state.state") <= 0) - return -1; - - if (virTypedParamListAddInt(params, dom->state.reason, "state.reason")= < 0) - return -1; + virTypedParamListAddInt(params, dom->state.state, "state.state"); + virTypedParamListAddInt(params, dom->state.reason, "state.reason"); return 0; } @@ -17183,33 +17180,16 @@ qemuDomainGetStatsMemoryBandwidth(virQEMUDriver *= driver, if (nresdata =3D=3D 0) return 0; - if (virTypedParamListAddUInt(params, nresdata, - "memory.bandwidth.monitor.count") < 0) - goto cleanup; + virTypedParamListAddUInt(params, nresdata, "memory.bandwidth.monitor.c= ount"); for (i =3D 0; i < nresdata; i++) { - if (virTypedParamListAddString(params, resdata[i]->name, - "memory.bandwidth.monitor.%zu.name", - i) < 0) - goto cleanup; - - if (virTypedParamListAddString(params, resdata[i]->vcpus, - "memory.bandwidth.monitor.%zu.vcpus= ", - i) < 0) - goto cleanup; - - if (virTypedParamListAddUInt(params, resdata[i]->nstats, - "memory.bandwidth.monitor.%zu.node.co= unt", - i) < 0) - goto cleanup; - + virTypedParamListAddString(params, resdata[i]->name, "memory.bandw= idth.monitor.%zu.name", i); + virTypedParamListAddString(params, resdata[i]->vcpus, "memory.band= width.monitor.%zu.vcpus", i); + virTypedParamListAddUInt(params, resdata[i]->nstats, "memory.bandw= idth.monitor.%zu.node.count", i); for (j =3D 0; j < resdata[i]->nstats; j++) { - if (virTypedParamListAddUInt(params, resdata[i]->stats[j]->id, - "memory.bandwidth.monitor.%zu." - "node.%zu.id", - i, j) < 0) - goto cleanup; + virTypedParamListAddUInt(params, resdata[i]->stats[j]->id, + "memory.bandwidth.monitor.%zu.node.%z= u.id", i, j); features =3D resdata[i]->stats[j]->features; @@ -17217,23 +17197,15 @@ qemuDomainGetStatsMemoryBandwidth(virQEMUDriver *= driver, if (STREQ(features[k], "mbm_local_bytes")) { /* The accumulative data passing through local memory * controller is recorded with 64 bit counter. */ - if (virTypedParamListAddULLong(params, - resdata[i]->stats[j]->v= als[k], - "memory.bandwidth.monit= or." - "%zu.node.%zu.bytes.loc= al", - i, j) < 0) - goto cleanup; + virTypedParamListAddULLong(params, resdata[i]->stats[j= ]->vals[k], + "memory.bandwidth.monitor.%= zu.node.%zu.bytes.local", i, j); } if (STREQ(features[k], "mbm_total_bytes")) { /* The accumulative data passing through local and rem= ote * memory controller is recorded with 64 bit counter. = */ - if (virTypedParamListAddULLong(params, - resdata[i]->stats[j]->v= als[k], - "memory.bandwidth.monit= or." - "%zu.node.%zu.bytes.tot= al", - i, j) < 0) - goto cleanup; + virTypedParamListAddULLong(params, resdata[i]->stats[j= ]->vals[k], + "memory.bandwidth.monitor.%= zu.node.%zu.bytes.total", i, j); } } } @@ -17266,26 +17238,16 @@ qemuDomainGetStatsCpuCache(virQEMUDriver *driver, VIR_RESCTRL_MONITOR_TYPE_CACHE) < 0) goto cleanup; - if (virTypedParamListAddUInt(params, nresdata, "cpu.cache.monitor.coun= t") < 0) - goto cleanup; + virTypedParamListAddUInt(params, nresdata, "cpu.cache.monitor.count"); for (i =3D 0; i < nresdata; i++) { - if (virTypedParamListAddString(params, resdata[i]->name, - "cpu.cache.monitor.%zu.name", i) < = 0) - goto cleanup; - - if (virTypedParamListAddString(params, resdata[i]->vcpus, - "cpu.cache.monitor.%zu.vcpus", i) <= 0) - goto cleanup; - - if (virTypedParamListAddUInt(params, resdata[i]->nstats, - "cpu.cache.monitor.%zu.bank.count", i= ) < 0) - goto cleanup; + virTypedParamListAddString(params, resdata[i]->name, "cpu.cache.mo= nitor.%zu.name", i); + virTypedParamListAddString(params, resdata[i]->vcpus, "cpu.cache.m= onitor.%zu.vcpus", i); + virTypedParamListAddUInt(params, resdata[i]->nstats, "cpu.cache.mo= nitor.%zu.bank.count", i); for (j =3D 0; j < resdata[i]->nstats; j++) { - if (virTypedParamListAddUInt(params, resdata[i]->stats[j]->id, - "cpu.cache.monitor.%zu.bank.%zu.i= d", i, j) < 0) - goto cleanup; + virTypedParamListAddUInt(params, resdata[i]->stats[j]->id, + "cpu.cache.monitor.%zu.bank.%zu.id", = i, j); /* 'resdata[i]->stats[j]->vals[0]' keeps the value of how many= last * level cache in bank j currently occupied by the vcpus liste= d in @@ -17296,11 +17258,8 @@ qemuDomainGetStatsCpuCache(virQEMUDriver *driver, * than 4G bytes in size, to keep the 'domstats' interface * historically consistent, it is safe to report the value wit= h a * truncated 'UInt' data type here. */ - if (virTypedParamListAddUInt(params, - (unsigned int)resdata[i]->stats[j= ]->vals[0], - "cpu.cache.monitor.%zu.bank.%zu.b= ytes", - i, j) < 0) - goto cleanup; + virTypedParamListAddUInt(params, (unsigned int)resdata[i]->sta= ts[j]->vals[0], + "cpu.cache.monitor.%zu.bank.%zu.bytes= ", i, j); } } @@ -17321,20 +17280,17 @@ qemuDomainGetStatsCpuCgroup(virDomainObj *dom, unsigned long long cpu_time =3D 0; unsigned long long user_time =3D 0; unsigned long long sys_time =3D 0; - int err =3D 0; if (!priv->cgroup) return 0; - err =3D virCgroupGetCpuacctUsage(priv->cgroup, &cpu_time); - if (!err && virTypedParamListAddULLong(params, cpu_time, "cpu.time") <= 0) - return -1; + if (virCgroupGetCpuacctUsage(priv->cgroup, &cpu_time) =3D=3D 0) + virTypedParamListAddULLong(params, cpu_time, "cpu.time"); - err =3D virCgroupGetCpuacctStat(priv->cgroup, &user_time, &sys_time); - if (!err && virTypedParamListAddULLong(params, user_time, "cpu.user") = < 0) - return -1; - if (!err && virTypedParamListAddULLong(params, sys_time, "cpu.system")= < 0) - return -1; + if (virCgroupGetCpuacctStat(priv->cgroup, &user_time, &sys_time) =3D= =3D 0) { + virTypedParamListAddULLong(params, user_time, "cpu.user"); + virTypedParamListAddULLong(params, sys_time, "cpu.system"); + } return 0; } @@ -17354,10 +17310,9 @@ qemuDomainGetStatsCpuProc(virDomainObj *vm, return 0; } - if (virTypedParamListAddULLong(params, cpuTime, "cpu.time") < 0 || - virTypedParamListAddULLong(params, userTime, "cpu.user") < 0 || - virTypedParamListAddULLong(params, sysTime, "cpu.system") < 0) - return -1; + virTypedParamListAddULLong(params, cpuTime, "cpu.time"); + virTypedParamListAddULLong(params, userTime, "cpu.user"); + virTypedParamListAddULLong(params, sysTime, "cpu.system"); return 0; } @@ -17445,9 +17400,8 @@ qemuDomainGetStatsCpuHaltPollTime(virDomainObj *dom, virHostCPUGetHaltPollTime(dom->pid, &haltPollSuccess, &haltPollFai= l) < 0) return 0; - if (virTypedParamListAddULLong(params, haltPollSuccess, "cpu.haltpoll.= success.time") < 0 || - virTypedParamListAddULLong(params, haltPollFail, "cpu.haltpoll.fai= l.time") < 0) - return -1; + virTypedParamListAddULLong(params, haltPollSuccess, "cpu.haltpoll.succ= ess.time"); + virTypedParamListAddULLong(params, haltPollFail, "cpu.haltpoll.fail.ti= me"); return 0; } @@ -17506,12 +17460,8 @@ qemuDomainGetStatsBalloon(virQEMUDriver *driver G_= GNUC_UNUSED, cur_balloon =3D dom->def->mem.cur_balloon; } - if (virTypedParamListAddULLong(params, cur_balloon, "balloon.current")= < 0) - return -1; - - if (virTypedParamListAddULLong(params, virDomainDefGetMemoryTotal(dom-= >def), - "balloon.maximum") < 0) - return -1; + virTypedParamListAddULLong(params, cur_balloon, "balloon.current"); + virTypedParamListAddULLong(params, virDomainDefGetMemoryTotal(dom->def= ), "balloon.maximum"); if (!HAVE_JOB(privflags) || !virDomainObjIsActive(dom)) return 0; @@ -17523,8 +17473,7 @@ qemuDomainGetStatsBalloon(virQEMUDriver *driver G_G= NUC_UNUSED, #define STORE_MEM_RECORD(TAG, NAME) \ if (stats[i].tag =3D=3D VIR_DOMAIN_MEMORY_STAT_ ##TAG) \ - if (virTypedParamListAddULLong(params, stats[i].val, "balloon." NA= ME) < 0) \ - return -1; + virTypedParamListAddULLong(params, stats[i].val, "balloon." NAME); for (i =3D 0; i < nr_stats; i++) { STORE_MEM_RECORD(SWAP_IN, "swap_in") @@ -17593,16 +17542,14 @@ qemuDomainAddStatsFromHashTable(GHashTable *stats, if (virJSONValueGetBoolean(value, &stat) < 0) continue; - ignore_value(virTypedParamListAddBoolean(params, stat, "%s.%s.= %s", - prefix, key, type)); + virTypedParamListAddBoolean(params, stat, "%s.%s.%s", prefix, = key, type); } else { unsigned long long stat; if (virJSONValueGetNumberUlong(value, &stat) < 0) continue; - ignore_value(virTypedParamListAddULLong(params, stat, "%s.%s.%= s", - prefix, key, type)); + virTypedParamListAddULLong(params, stat, "%s.%s.%s", prefix, k= ey, type); } } } @@ -17623,13 +17570,8 @@ qemuDomainGetStatsVcpu(virQEMUDriver *driver G_GNU= C_UNUSED, qemuDomainObjPrivate *priv =3D dom->privateData; g_autoptr(virJSONValue) queried_stats =3D NULL; - if (virTypedParamListAddUInt(params, virDomainDefGetVcpus(dom->def), - "vcpu.current") < 0) - return -1; - - if (virTypedParamListAddUInt(params, virDomainDefGetVcpusMax(dom->def), - "vcpu.maximum") < 0) - return -1; + virTypedParamListAddUInt(params, virDomainDefGetVcpus(dom->def), "vcpu= .current"); + virTypedParamListAddUInt(params, virDomainDefGetVcpusMax(dom->def), "v= cpu.maximum"); cpuinfo =3D g_new0(virVcpuInfo, virDomainDefGetVcpus(dom->def)); cpuwait =3D g_new0(unsigned long long, virDomainDefGetVcpus(dom->def)); @@ -17662,25 +17604,15 @@ qemuDomainGetStatsVcpu(virQEMUDriver *driver G_GN= UC_UNUSED, g_autoptr(GHashTable) stats =3D NULL; g_autofree char *prefix =3D g_strdup_printf("vcpu.%u", cpuinfo[i].= number); - if (virTypedParamListAddInt(params, cpuinfo[i].state, - "vcpu.%u.state", cpuinfo[i].number) < = 0) - return -1; + virTypedParamListAddInt(params, cpuinfo[i].state, "vcpu.%u.state",= cpuinfo[i].number); /* stats below are available only if the VM is alive */ if (!virDomainObjIsActive(dom)) continue; - if (virTypedParamListAddULLong(params, cpuinfo[i].cpuTime, - "vcpu.%u.time", cpuinfo[i].number) = < 0) - return -1; - - if (virTypedParamListAddULLong(params, cpuwait[i], - "vcpu.%u.wait", cpuinfo[i].number) = < 0) - return -1; - - if (virTypedParamListAddULLong(params, cpudelay[i], - "vcpu.%u.delay", cpuinfo[i].number= ) < 0) - return -1; + virTypedParamListAddULLong(params, cpuinfo[i].cpuTime, "vcpu.%u.ti= me", cpuinfo[i].number); + virTypedParamListAddULLong(params, cpuwait[i], "vcpu.%u.wait", cpu= info[i].number); + virTypedParamListAddULLong(params, cpudelay[i], "vcpu.%u.delay", c= puinfo[i].number); /* state below is extracted from the individual vcpu structs */ if (!(vcpu =3D virDomainDefGetVcpu(dom->def, cpuinfo[i].number))) @@ -17689,11 +17621,8 @@ qemuDomainGetStatsVcpu(virQEMUDriver *driver G_GNU= C_UNUSED, vcpupriv =3D QEMU_DOMAIN_VCPU_PRIVATE(vcpu); if (vcpupriv->halted !=3D VIR_TRISTATE_BOOL_ABSENT) { - if (virTypedParamListAddBoolean(params, - vcpupriv->halted =3D=3D VIR_TR= ISTATE_BOOL_YES, - "vcpu.%u.halted", - cpuinfo[i].number) < 0) - return -1; + virTypedParamListAddBoolean(params, vcpupriv->halted =3D=3D VI= R_TRISTATE_BOOL_YES, + "vcpu.%u.halted", cpuinfo[i].numbe= r); } if (!queried_stats) @@ -17709,9 +17638,8 @@ qemuDomainGetStatsVcpu(virQEMUDriver *driver G_GNUC= _UNUSED, } #define QEMU_ADD_NET_PARAM(params, num, name, value) \ - if (value >=3D 0 && \ - virTypedParamListAddULLong((params), (value), "net.%zu.%s", (num),= (name)) < 0) \ - return -1; + if (value >=3D 0)\ + virTypedParamListAddULLong((params), (value), "net.%zu.%s", (num),= (name)); static int qemuDomainGetStatsInterface(virQEMUDriver *driver G_GNUC_UNUSED, @@ -17725,8 +17653,7 @@ qemuDomainGetStatsInterface(virQEMUDriver *driver G= _GNUC_UNUSED, if (!virDomainObjIsActive(dom)) return 0; - if (virTypedParamListAddUInt(params, dom->def->nnets, "net.count") < 0) - return -1; + virTypedParamListAddUInt(params, dom->def->nnets, "net.count"); /* Check the path is one of the domain's network interfaces. */ for (i =3D 0; i < dom->def->nnets; i++) { @@ -17740,8 +17667,7 @@ qemuDomainGetStatsInterface(virQEMUDriver *driver G= _GNUC_UNUSED, actualType =3D virDomainNetGetActualType(net); - if (virTypedParamListAddString(params, net->ifname, "net.%zu.name"= , i) < 0) - return -1; + virTypedParamListAddString(params, net->ifname, "net.%zu.name", i); if (actualType =3D=3D VIR_DOMAIN_NET_TYPE_VHOSTUSER) { if (virNetDevOpenvswitchInterfaceStats(net->ifname, &tmp) < 0)= { @@ -17756,22 +17682,14 @@ qemuDomainGetStatsInterface(virQEMUDriver *driver= G_GNUC_UNUSED, } } - QEMU_ADD_NET_PARAM(params, i, - "rx.bytes", tmp.rx_bytes); - QEMU_ADD_NET_PARAM(params, i, - "rx.pkts", tmp.rx_packets); - QEMU_ADD_NET_PARAM(params, i, - "rx.errs", tmp.rx_errs); - QEMU_ADD_NET_PARAM(params, i, - "rx.drop", tmp.rx_drop); - QEMU_ADD_NET_PARAM(params, i, - "tx.bytes", tmp.tx_bytes); - QEMU_ADD_NET_PARAM(params, i, - "tx.pkts", tmp.tx_packets); - QEMU_ADD_NET_PARAM(params, i, - "tx.errs", tmp.tx_errs); - QEMU_ADD_NET_PARAM(params, i, - "tx.drop", tmp.tx_drop); + QEMU_ADD_NET_PARAM(params, i, "rx.bytes", tmp.rx_bytes); + QEMU_ADD_NET_PARAM(params, i, "rx.pkts", tmp.rx_packets); + QEMU_ADD_NET_PARAM(params, i, "rx.errs", tmp.rx_errs); + QEMU_ADD_NET_PARAM(params, i, "rx.drop", tmp.rx_drop); + QEMU_ADD_NET_PARAM(params, i, "tx.bytes", tmp.tx_bytes); + QEMU_ADD_NET_PARAM(params, i, "tx.pkts", tmp.tx_packets); + QEMU_ADD_NET_PARAM(params, i, "tx.errs", tmp.tx_errs); + QEMU_ADD_NET_PARAM(params, i, "tx.drop", tmp.tx_drop); } return 0; @@ -17799,20 +17717,14 @@ qemuDomainGetStatsOneBlockFallback(virQEMUDriver = *driver, return 0; } - if (src->allocation && - virTypedParamListAddULLong(params, src->allocation, - "block.%zu.allocation", block_idx) < 0) - return -1; + if (src->allocation) + virTypedParamListAddULLong(params, src->allocation, "block.%zu.all= ocation", block_idx); - if (src->capacity && - virTypedParamListAddULLong(params, src->capacity, - "block.%zu.capacity", block_idx) < 0) - return -1; + if (src->capacity) + virTypedParamListAddULLong(params, src->capacity, "block.%zu.capac= ity", block_idx); - if (src->physical && - virTypedParamListAddULLong(params, src->physical, - "block.%zu.physical", block_idx) < 0) - return -1; + if (src->physical) + virTypedParamListAddULLong(params, src->physical, "block.%zu.physi= cal", block_idx); return 0; } @@ -17843,24 +17755,16 @@ qemuDomainGetStatsOneBlock(virQEMUDriver *driver, if (!stats || !entryname || !(entry =3D virHashLookup(stats, entryname= ))) return 0; - if (virTypedParamListAddULLong(params, entry->wr_highest_offset, - "block.%zu.allocation", block_idx) < 0) - return -1; + virTypedParamListAddULLong(params, entry->wr_highest_offset, "block.%z= u.allocation", block_idx); - if (entry->capacity && - virTypedParamListAddULLong(params, entry->capacity, - "block.%zu.capacity", block_idx) < 0) - return -1; + if (entry->capacity) + virTypedParamListAddULLong(params, entry->capacity, "block.%zu.cap= acity", block_idx); if (entry->physical) { - if (virTypedParamListAddULLong(params, entry->physical, - "block.%zu.physical", block_idx) < = 0) - return -1; + virTypedParamListAddULLong(params, entry->physical, "block.%zu.phy= sical", block_idx); } else { if (qemuDomainStorageUpdatePhysical(driver, cfg, dom, src) =3D=3D = 0) { - if (virTypedParamListAddULLong(params, src->physical, - "block.%zu.physical", block_idx= ) < 0) - return -1; + virTypedParamListAddULLong(params, src->physical, "block.%zu.p= hysical", block_idx); } } @@ -17879,10 +17783,8 @@ qemuDomainGetStatsBlockExportBackendStorage(const = char *entryname, if (!stats || !entryname || !(entry =3D virHashLookup(stats, entryname= ))) return 0; - if (entry->write_threshold && - virTypedParamListAddULLong(params, entry->write_threshold, - "block.%zu.threshold", recordnr) < 0) - return -1; + if (entry->write_threshold) + virTypedParamListAddULLong(params, entry->write_threshold, "block.= %zu.threshold", recordnr); return 0; } @@ -17902,15 +17804,14 @@ qemuDomainGetStatsBlockExportFrontend(const char = *frontendname, if (!stats || !frontendname || !(en =3D virHashLookup(stats, frontendn= ame))) return 0; - if (virTypedParamListAddULLong(par, en->rd_req, "block.%zu.rd.reqs", i= dx) < 0 || - virTypedParamListAddULLong(par, en->rd_bytes, "block.%zu.rd.bytes"= , idx) < 0 || - virTypedParamListAddULLong(par, en->rd_total_times, "block.%zu.rd.= times", idx) < 0 || - virTypedParamListAddULLong(par, en->wr_req, "block.%zu.wr.reqs", i= dx) < 0 || - virTypedParamListAddULLong(par, en->wr_bytes, "block.%zu.wr.bytes"= , idx) < 0 || - virTypedParamListAddULLong(par, en->wr_total_times, "block.%zu.wr.= times", idx) < 0 || - virTypedParamListAddULLong(par, en->flush_req, "block.%zu.fl.reqs"= , idx) < 0 || - virTypedParamListAddULLong(par, en->flush_total_times, "block.%zu.= fl.times", idx) < 0) - return -1; + virTypedParamListAddULLong(par, en->rd_req, "block.%zu.rd.reqs", idx); + virTypedParamListAddULLong(par, en->rd_bytes, "block.%zu.rd.bytes", id= x); + virTypedParamListAddULLong(par, en->rd_total_times, "block.%zu.rd.time= s", idx); + virTypedParamListAddULLong(par, en->wr_req, "block.%zu.wr.reqs", idx); + virTypedParamListAddULLong(par, en->wr_bytes, "block.%zu.wr.bytes", id= x); + virTypedParamListAddULLong(par, en->wr_total_times, "block.%zu.wr.time= s", idx); + virTypedParamListAddULLong(par, en->flush_req, "block.%zu.fl.reqs", id= x); + virTypedParamListAddULLong(par, en->flush_total_times, "block.%zu.fl.t= imes", idx); return 0; } @@ -17922,16 +17823,13 @@ qemuDomainGetStatsBlockExportHeader(virDomainDisk= Def *disk, size_t recordnr, virTypedParamList *params) { - if (virTypedParamListAddString(params, disk->dst, "block.%zu.name", re= cordnr) < 0) - return -1; + virTypedParamListAddString(params, disk->dst, "block.%zu.name", record= nr); - if (virStorageSourceIsLocalStorage(src) && src->path && - virTypedParamListAddString(params, src->path, "block.%zu.path", re= cordnr) < 0) - return -1; + if (virStorageSourceIsLocalStorage(src) && src->path) + virTypedParamListAddString(params, src->path, "block.%zu.path", re= cordnr); - if (src->id && - virTypedParamListAddUInt(params, src->id, "block.%zu.backingIndex"= , recordnr) < 0) - return -1; + if (src->id) + virTypedParamListAddUInt(params, src->id, "block.%zu.backingIndex"= , recordnr); return 0; } @@ -18133,9 +18031,7 @@ qemuDomainGetStatsBlock(virQEMUDriver *driver, return -1; } - if (virTypedParamListAddUInt(params, 0, "block.count") < 0) - return -1; - + virTypedParamListAddUInt(params, 0, "block.count"); virTypedParamListConcat(params, &blockparams); return 0; @@ -18166,23 +18062,19 @@ qemuDomainGetStatsIOThread(virQEMUDriver *driver = G_GNUC_UNUSED, goto cleanup; } - if (virTypedParamListAddUInt(params, niothreads, "iothread.count") < 0) - goto cleanup; + virTypedParamListAddUInt(params, niothreads, "iothread.count"); for (i =3D 0; i < niothreads; i++) { if (iothreads[i]->poll_valid) { - if (virTypedParamListAddULLong(params, iothreads[i]->poll_max_= ns, - "iothread.%u.poll-max-ns", - iothreads[i]->iothread_id) < 0) - goto cleanup; - if (virTypedParamListAddUInt(params, iothreads[i]->poll_grow, - "iothread.%u.poll-grow", - iothreads[i]->iothread_id) < 0) - goto cleanup; - if (virTypedParamListAddUInt(params, iothreads[i]->poll_shrink, - "iothread.%u.poll-shrink", - iothreads[i]->iothread_id) < 0) - goto cleanup; + virTypedParamListAddULLong(params, iothreads[i]->poll_max_ns, + "iothread.%u.poll-max-ns", + iothreads[i]->iothread_id); + virTypedParamListAddUInt(params, iothreads[i]->poll_grow, + "iothread.%u.poll-grow", + iothreads[i]->iothread_id); + virTypedParamListAddUInt(params, iothreads[i]->poll_shrink, + "iothread.%u.poll-shrink", + iothreads[i]->iothread_id); } } @@ -18207,9 +18099,7 @@ qemuDomainGetStatsPerfOneEvent(virPerf *perf, if (virPerfReadEvent(perf, type, &value) < 0) return -1; - if (virTypedParamListAddULLong(params, value, "perf.%s", - virPerfEventTypeToString(type)) < 0) - return -1; + virTypedParamListAddULLong(params, value, "perf.%s", virPerfEventTypeT= oString(type)); return 0; } @@ -18262,35 +18152,21 @@ qemuDomainGetStatsDirtyRate(virQEMUDriver *driver= G_GNUC_UNUSED, if (qemuDomainGetStatsDirtyRateMon(dom, &info) < 0) return -1; - if (virTypedParamListAddInt(params, info.status, - "dirtyrate.calc_status") < 0) - return -1; - - if (virTypedParamListAddLLong(params, info.startTime, - "dirtyrate.calc_start_time") < 0) - return -1; - - if (virTypedParamListAddInt(params, info.calcTime, - "dirtyrate.calc_period") < 0) - return -1; - - if (virTypedParamListAddString(params, - qemuMonitorDirtyRateCalcModeTypeToStrin= g(info.mode), - "dirtyrate.calc_mode") < 0) - return -1; + virTypedParamListAddInt(params, info.status, "dirtyrate.calc_status"); + virTypedParamListAddLLong(params, info.startTime, "dirtyrate.calc_star= t_time"); + virTypedParamListAddInt(params, info.calcTime, "dirtyrate.calc_period"= ); + virTypedParamListAddString(params, qemuMonitorDirtyRateCalcModeTypeToS= tring(info.mode), + "dirtyrate.calc_mode"); if (info.status =3D=3D VIR_DOMAIN_DIRTYRATE_MEASURED) { - if (virTypedParamListAddLLong(params, info.dirtyRate, - "dirtyrate.megabytes_per_second") < = 0) - return -1; + virTypedParamListAddLLong(params, info.dirtyRate, "dirtyrate.megab= ytes_per_second"); if (info.mode =3D=3D QEMU_MONITOR_DIRTYRATE_CALC_MODE_DIRTY_RING) { size_t i; for (i =3D 0; i < info.nvcpus; i++) { - if (virTypedParamListAddULLong(params, info.rates[i].value, - "dirtyrate.vcpu.%d.megabyte= s_per_second", - info.rates[i].idx) < 0) - return -1; + virTypedParamListAddULLong(params, info.rates[i].value, + "dirtyrate.vcpu.%d.megabytes_pe= r_second", + info.rates[i].idx); } } } diff --git a/src/test/test_driver.c b/src/test/test_driver.c index ac12488de9..e7fce053b4 100644 --- a/src/test/test_driver.c +++ b/src/test/test_driver.c @@ -9784,11 +9784,8 @@ static int testDomainGetStatsState(virDomainObj *dom, virTypedParamList *params) { - if (virTypedParamListAddInt(params, dom->state.state, "state.state") <= 0) - return -1; - - if (virTypedParamListAddInt(params, dom->state.reason, "state.reason")= < 0) - return -1; + virTypedParamListAddInt(params, dom->state.state, "state.state"); + virTypedParamListAddInt(params, dom->state.reason, "state.reason"); return 0; } @@ -9810,24 +9807,17 @@ testDomainGetStatsIOThread(virDomainObj *dom, return 0; } - if (virTypedParamListAddUInt(params, niothreads, "iothread.count") < 0) - return -1; + virTypedParamListAddUInt(params, niothreads, "iothread.count"); for (i =3D 0; i < niothreads; i++) { testIOThreadInfo iothread =3D g_array_index(priv->iothreads, testIOThreadInfo, i); - if (virTypedParamListAddULLong(params, iothread.poll_max_ns, - "iothread.%u.poll-max-ns", - iothread.iothread_id) < 0) - return -1; - if (virTypedParamListAddUInt(params, iothread.poll_grow, - "iothread.%u.poll-grow", - iothread.iothread_id) < 0) - return -1; - if (virTypedParamListAddUInt(params, iothread.poll_shrink, - "iothread.%u.poll-shrink", - iothread.iothread_id) < 0) - return -1; + virTypedParamListAddULLong(params, iothread.poll_max_ns, + "iothread.%u.poll-max-ns", iothread.iot= hread_id); + virTypedParamListAddUInt(params, iothread.poll_grow, + "iothread.%u.poll-grow", iothread.iothrea= d_id); + virTypedParamListAddUInt(params, iothread.poll_shrink, + "iothread.%u.poll-shrink", iothread.iothr= ead_id); } return 0; diff --git a/src/util/virtypedparam.c b/src/util/virtypedparam.c index 046164d36c..ee9c6d1c45 100644 --- a/src/util/virtypedparam.c +++ b/src/util/virtypedparam.c @@ -853,7 +853,7 @@ virTypedParamListExtend(virTypedParamList *list) } -int +void virTypedParamListAddInt(virTypedParamList *list, int value, const char *namefmt, @@ -867,12 +867,10 @@ virTypedParamListAddInt(virTypedParamList *list, va_start(ap, namefmt); virTypedParamSetNameVPrintf(list, par, namefmt, ap); va_end(ap); - - return 0; } -int +void virTypedParamListAddUInt(virTypedParamList *list, unsigned int value, const char *namefmt, @@ -886,12 +884,10 @@ virTypedParamListAddUInt(virTypedParamList *list, va_start(ap, namefmt); virTypedParamSetNameVPrintf(list, par, namefmt, ap); va_end(ap); - - return 0; } -int +void virTypedParamListAddLLong(virTypedParamList *list, long long value, const char *namefmt, @@ -905,12 +901,10 @@ virTypedParamListAddLLong(virTypedParamList *list, va_start(ap, namefmt); virTypedParamSetNameVPrintf(list, par, namefmt, ap); va_end(ap); - - return 0; } -int +void virTypedParamListAddULLong(virTypedParamList *list, unsigned long long value, const char *namefmt, @@ -924,12 +918,10 @@ virTypedParamListAddULLong(virTypedParamList *list, va_start(ap, namefmt); virTypedParamSetNameVPrintf(list, par, namefmt, ap); va_end(ap); - - return 0; } -int +void virTypedParamListAddString(virTypedParamList *list, const char *value, const char *namefmt, @@ -943,12 +935,10 @@ virTypedParamListAddString(virTypedParamList *list, va_start(ap, namefmt); virTypedParamSetNameVPrintf(list, par, namefmt, ap); va_end(ap); - - return 0; } -int +void virTypedParamListAddBoolean(virTypedParamList *list, bool value, const char *namefmt, @@ -962,12 +952,10 @@ virTypedParamListAddBoolean(virTypedParamList *list, va_start(ap, namefmt); virTypedParamSetNameVPrintf(list, par, namefmt, ap); va_end(ap); - - return 0; } -int +void virTypedParamListAddDouble(virTypedParamList *list, double value, const char *namefmt, @@ -981,6 +969,4 @@ virTypedParamListAddDouble(virTypedParamList *list, va_start(ap, namefmt); virTypedParamSetNameVPrintf(list, par, namefmt, ap); va_end(ap); - - return 0; } diff --git a/src/util/virtypedparam.h b/src/util/virtypedparam.h index b2869173e1..7065683297 100644 --- a/src/util/virtypedparam.h +++ b/src/util/virtypedparam.h @@ -162,45 +162,45 @@ void virTypedParamListConcat(virTypedParamList *to, virTypedParamList **fromptr); -int +void virTypedParamListAddInt(virTypedParamList *list, int value, const char *namefmt, ...) - G_GNUC_PRINTF(3, 4) G_GNUC_WARN_UNUSED_RESULT; -int + G_GNUC_PRINTF(3, 4); +void virTypedParamListAddUInt(virTypedParamList *list, unsigned int value, const char *namefmt, ...) - G_GNUC_PRINTF(3, 4) G_GNUC_WARN_UNUSED_RESULT; -int + G_GNUC_PRINTF(3, 4); +void virTypedParamListAddLLong(virTypedParamList *list, long long value, const char *namefmt, ...) - G_GNUC_PRINTF(3, 4) G_GNUC_WARN_UNUSED_RESULT; -int + G_GNUC_PRINTF(3, 4); +void virTypedParamListAddULLong(virTypedParamList *list, unsigned long long value, const char *namefmt, ...) - G_GNUC_PRINTF(3, 4) G_GNUC_WARN_UNUSED_RESULT; -int + G_GNUC_PRINTF(3, 4); +void virTypedParamListAddString(virTypedParamList *list, const char *value, const char *namefmt, ...) - G_GNUC_PRINTF(3, 4) G_GNUC_WARN_UNUSED_RESULT; -int + G_GNUC_PRINTF(3, 4); +void virTypedParamListAddBoolean(virTypedParamList *list, bool value, const char *namefmt, ...) - G_GNUC_PRINTF(3, 4) G_GNUC_WARN_UNUSED_RESULT; -int + G_GNUC_PRINTF(3, 4); +void virTypedParamListAddDouble(virTypedParamList *list, double value, const char *namefmt, ...) - G_GNUC_PRINTF(3, 4) G_GNUC_WARN_UNUSED_RESULT; + G_GNUC_PRINTF(3, 4); --=20 2.39.2 From nobody Mon Feb 9 01:44:02 2026 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=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1681908543; cv=none; d=zohomail.com; s=zohoarc; b=HvoavGoEIOYq5uYYfcG+2wmem0lRX1I8Vbylb4Cb/9O2KCT01kQK95rqe99K1XVzWuSTUjN53AAWkT6Kq/teYGGZQRFYzMB4oDBelvqe7V9+Y5W30zBkVHoJ769njpjwTepSPPwGcwO7/ZLQU13C+K5Rd98adOjN/Vp87aVlpX8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1681908543; 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; bh=Ow6e6F3oaq34QovLMQO/LpV5cSowveVa+3FGBEekpBo=; b=FgIeMoYpsBJtHWLfirzI/8KDWeo87RZnlgKB8wx+LBBj4FHzKlYWXAfVy5TjvNT6seyL6lzUoi3f0XNioPxHcwze/NcV7DP0siCJoUy7FWb7DnAKC/ePbo5Hqz3/umCVFp8LMHU/9Cvcewmy4ONNTT2ppietmL0uHrK+/2pXwsQ= 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=pass 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 1681908543912930.3939765020224; Wed, 19 Apr 2023 05:49:03 -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-554-hZJGegxUNp2ABBTh1Z6_ig-1; Wed, 19 Apr 2023 08:48:04 -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 D61E9185A790; Wed, 19 Apr 2023 12:48:00 +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 C32ED1121315; Wed, 19 Apr 2023 12:48:00 +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 935F519465B1; Wed, 19 Apr 2023 12:48:00 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id D96F919465A0 for ; Wed, 19 Apr 2023 12:04:58 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id BCB7B492B05; Wed, 19 Apr 2023 12:04:58 +0000 (UTC) Received: from speedmetal.redhat.com (unknown [10.45.242.23]) by smtp.corp.redhat.com (Postfix) with ESMTP id 458CF492B04 for ; Wed, 19 Apr 2023 12:04:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1681908542; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to: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=Ow6e6F3oaq34QovLMQO/LpV5cSowveVa+3FGBEekpBo=; b=W6ULyrni56QwApgQa4DlXkrupC2WxAqgzR68LGq8Kde2Smc/oSZAP01X9cvFiZY59qhK7d 7VWyoDqhLxjM9n44pSTjPawnkg0yq+/EHUh8LZ4STwsU70oBmT4/5kjfKCS3Z0lh3ySGVd j1s5AooijQpMnX23SypCNQZT4e6yztQ= X-MC-Unique: hZJGegxUNp2ABBTh1Z6_ig-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH v3 16/25] util: typedparam: Introduce virTypedParamListAddUnsigned Date: Wed, 19 Apr 2023 14:04:33 +0200 Message-Id: <018b563c6ca7fd0f7a213624a1866273dd4ba18e.1681905482.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.9 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: , 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: 1681908546011100001 Content-Type: text/plain; charset="utf-8" The new helper adds a unsigned value, stored as _UINT if it fits into the type and stored as _ULLONG otherwise. This is useful for the statistics code which is quite tolerant to changes in type in cases when we'll need more range for the value. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/libvirt_private.syms | 1 + src/util/virtypedparam.c | 36 ++++++++++++++++++++++++++++++++++++ src/util/virtypedparam.h | 6 ++++++ 3 files changed, 43 insertions(+) diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index b58be6aa33..4e21851c53 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -3555,6 +3555,7 @@ virTypedParamListAddLLong; virTypedParamListAddString; virTypedParamListAddUInt; virTypedParamListAddULLong; +virTypedParamListAddUnsigned; virTypedParamListConcat; virTypedParamListFetch; virTypedParamListFree; diff --git a/src/util/virtypedparam.c b/src/util/virtypedparam.c index ee9c6d1c45..52eea0fc54 100644 --- a/src/util/virtypedparam.c +++ b/src/util/virtypedparam.c @@ -921,6 +921,42 @@ virTypedParamListAddULLong(virTypedParamList *list, } +/** + * virTypedParamListAddUnsigned: + * @list: typed parameter list + * @value: value to add (see below on details) + * @namefmt: formatting string for constructing the name of the added value + * @...: additional parameters to format the name + * + * Adds a new typed parameter to @list. The name of the parameter is forma= tted + * from @fmt. + * + * @value is added as VIR_TYPED_PARAM_UINT, unless it doesn't fit into the= data + * type in which case it's added as VIR_TYPED_PARAM_ULLONG. + */ +void +virTypedParamListAddUnsigned(virTypedParamList *list, + unsigned long long value, + const char *namefmt, + ...) +{ + virTypedParameterPtr par =3D virTypedParamListExtend(list); + va_list ap; + + if (value > UINT_MAX) { + virTypedParameterAssignValue(par, VIR_TYPED_PARAM_ULLONG, value); + } else { + unsigned int ival =3D value; + + virTypedParameterAssignValue(par, VIR_TYPED_PARAM_UINT, ival); + } + + va_start(ap, namefmt); + virTypedParamSetNameVPrintf(list, par, namefmt, ap); + va_end(ap); +} + + void virTypedParamListAddString(virTypedParamList *list, const char *value, diff --git a/src/util/virtypedparam.h b/src/util/virtypedparam.h index 7065683297..88f810bf78 100644 --- a/src/util/virtypedparam.h +++ b/src/util/virtypedparam.h @@ -187,6 +187,12 @@ virTypedParamListAddULLong(virTypedParamList *list, ...) G_GNUC_PRINTF(3, 4); void +virTypedParamListAddUnsigned(virTypedParamList *list, + unsigned long long value, + const char *namefmt, + ...) + G_GNUC_PRINTF(3, 4); +void virTypedParamListAddString(virTypedParamList *list, const char *value, const char *namefmt, --=20 2.39.2 From nobody Mon Feb 9 01:44:02 2026 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=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1681907321; cv=none; d=zohomail.com; s=zohoarc; b=lnfIX1f0hkzGf6bzAdadDbeRVwT0MNJ1K6l+UlDUZttt3sG7oSsZfQb94GxmFxd1ZY6aujHtqgHAcOe9uhgDoNB7VmZQ46gC52dwoLM96UoXFEMAN6whjlvFmL6AE1VJlLHEkirY9BwLXQV5VN3jJWwmYRgUs5E6YOTp1USSW2c= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1681907321; 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; bh=2pI2FNxa07aKwmnAVbwb68CXVLQ6JBCCkDZW3xBCnd8=; b=Ppi4xU/tTrRdxNzRncLSnYTd95C1Thg4ARExfXl3ZNhoGyNgFRZ4SC7IdNurf0SxX7scT7CuJ0ZutIOr47jQ5wly+7R/K0w9DPT8M2cqH0b/glOoLzENQjLpHz4xcq8M4j5iK7Jn4RYjSlUAhg5cO6OzfgzQhcoTR8MFINUgbgc= 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=pass 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 1681907321213895.426877920516; Wed, 19 Apr 2023 05:28:41 -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-549-Vn50weboMXmo6-zVypWcFg-1; Wed, 19 Apr 2023 08:28:35 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 705E2185A78F; Wed, 19 Apr 2023 12:28:32 +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 5CBE92026D16; Wed, 19 Apr 2023 12:28:32 +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 434DB1946A63; Wed, 19 Apr 2023 12:28:22 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id A06A319465A0 for ; Wed, 19 Apr 2023 12:04:59 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 93DE5492B06; Wed, 19 Apr 2023 12:04:59 +0000 (UTC) Received: from speedmetal.redhat.com (unknown [10.45.242.23]) by smtp.corp.redhat.com (Postfix) with ESMTP id 1BBD4492B04 for ; Wed, 19 Apr 2023 12:04:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1681907320; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to: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=2pI2FNxa07aKwmnAVbwb68CXVLQ6JBCCkDZW3xBCnd8=; b=Rppt3bFLZlbtJD8N+G+x0GiAHvyMGSBWbS+xCmtE8OrrVjzkCZ+CgS8eT5/tRojbDngzNT tuclYYAchh6FValzdE+vYmeJRpydJgWuHdHYwPav0uPo/zesmx19zkJldPQEkx8neLumgi KfbTBDsHFNlS7YGYhoso3Cu7HHutSco= X-MC-Unique: Vn50weboMXmo6-zVypWcFg-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH v3 17/25] util: virtypedparam: Introduce virTypedParamsGetUnsigned Date: Wed, 19 Apr 2023 14:04:34 +0200 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.9 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: , Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 3.1 on 10.11.54.4 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: 1681907321946100001 Content-Type: text/plain; charset="utf-8" Add an internal helper for fetching a typed parameter which can be either of the '_UINT' or '_ULONG' type and store it in a unsigned long long variable. Since this is an internal helper it offers less protections against invalid use compared to those we expose as public API. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/libvirt_private.syms | 1 + src/util/virtypedparam.c | 51 ++++++++++++++++++++++++++++++++++++++++ src/util/virtypedparam.h | 5 ++++ 3 files changed, 57 insertions(+) diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index 4e21851c53..62c296bf5f 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -3567,6 +3567,7 @@ virTypedParamsCopy; virTypedParamsDeserialize; virTypedParamsFilter; virTypedParamsGetStringList; +virTypedParamsGetUnsigned; virTypedParamsRemoteFree; virTypedParamsReplaceString; virTypedParamsSerialize; diff --git a/src/util/virtypedparam.c b/src/util/virtypedparam.c index 52eea0fc54..d0e6cf6d9b 100644 --- a/src/util/virtypedparam.c +++ b/src/util/virtypedparam.c @@ -456,6 +456,57 @@ virTypedParamsGetStringList(virTypedParameterPtr param= s, } +/** + * virTypedParamsGetUnsigned: + * @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 'unsigned long long' or + * 'unsigned int' value in @value. + * + * This is an internal variand which expects that the typed parameters were + * already validated by calling virTypedParamsValidate and the appropriate + * parameter has the expected type. + * + * Returns 1 on success, 0 when the parameter does not exist in @params, or + * -1 on invalid usage. + */ +int +virTypedParamsGetUnsigned(virTypedParameterPtr params, + int nparams, + const char *name, + unsigned long long *value) +{ + virTypedParameterPtr param; + + if (!(param =3D virTypedParamsGet(params, nparams, name))) + return 0; + + switch ((virTypedParameterType) param->type) { + case VIR_TYPED_PARAM_UINT: + *value =3D param->value.ui; + break; + + case VIR_TYPED_PARAM_ULLONG: + *value =3D param->value.ul; + break; + + case VIR_TYPED_PARAM_INT: + case VIR_TYPED_PARAM_LLONG: + case VIR_TYPED_PARAM_DOUBLE: + case VIR_TYPED_PARAM_BOOLEAN: + case VIR_TYPED_PARAM_STRING: + case VIR_TYPED_PARAM_LAST: + default: + return -1; + } + + return 1; +} + + /** * virTypedParamsRemoteFree: * @remote_params_val: array of typed parameters as specified by diff --git a/src/util/virtypedparam.h b/src/util/virtypedparam.h index 88f810bf78..c2f58e994c 100644 --- a/src/util/virtypedparam.h +++ b/src/util/virtypedparam.h @@ -79,6 +79,11 @@ virTypedParamsFilter(virTypedParameterPtr params, virTypedParameterPtr **ret) G_GNUC_WARN_UNUSED_RESULT; +int +virTypedParamsGetUnsigned(virTypedParameterPtr params, + int nparams, + const char *name, + unsigned long long *value); int virTypedParameterAssign(virTypedParameterPtr param, --=20 2.39.2 From nobody Mon Feb 9 01:44:02 2026 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=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1681907023; cv=none; d=zohomail.com; s=zohoarc; b=k6Hv3rvatuQecSNzNSWSgni+eg7Vuxr8bmLEDDuWNxKS+j0zby9qheknVz239difPKI42a6I2zzgpWE2bkdO4i3PykmUe7o5Ka8raPG3rlfzzpTNtS7iZVxbCsIAKuIZJqZpl7FPC63CHczDHYPLNGM+I78hnaAZhveK4LJaTCM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1681907023; 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; bh=xvxwDNUk+nkeVRG5VQbwfXuJpW10YqoOn22rQDvpWKc=; b=Cn42FXpF3CUF0wGnFGhpPR1w+dF38ssp/9ibNC4Jkr0swExK+vifBOBsB1L9y/rBNpAUXvSy5Lvp35aKIZIipxRWBw53zvKn5UvHFmGyznPQE8WITDKN8q5GcXVY4h0INUf0Aq/io9+UjBd5aOH6Zem+gwPnZye50tLaKYoUx4s= 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=pass 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 1681907023050248.58329691339497; Wed, 19 Apr 2023 05:23:43 -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-332-_cZfCLqLPwaapPptuqbSxg-1; Wed, 19 Apr 2023 08:23:36 -0400 Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 3EB71185A78B; Wed, 19 Apr 2023 12:23:34 +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 2AF31492B04; Wed, 19 Apr 2023 12:23:34 +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 E8BB219465B1; Wed, 19 Apr 2023 12:23:33 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 7E2C519465B1 for ; Wed, 19 Apr 2023 12:05:00 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 70B56492B07; Wed, 19 Apr 2023 12:05:00 +0000 (UTC) Received: from speedmetal.redhat.com (unknown [10.45.242.23]) by smtp.corp.redhat.com (Postfix) with ESMTP id E3CA2492B04 for ; Wed, 19 Apr 2023 12:04:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1681907022; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to: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=xvxwDNUk+nkeVRG5VQbwfXuJpW10YqoOn22rQDvpWKc=; b=jD+cKQDzNHDj0zxlR2BOD6DbiFGt6NjMTGAw/1TqKiRt0Koi9nqSpVzEH8Bh3e96g2qHaR tYAotvZMEcbg078Whryd1FZIpSpNHUXRTNIm9DtiMPLD1yfXdnakFvH07XL8TD2EPHI12v fZFtgjrWzOfAYmqS45M6piOw0aKFou8= X-MC-Unique: _cZfCLqLPwaapPptuqbSxg-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH v3 18/25] virTypedParamsValidate: Refactor variable declaration and cleanup Date: Wed, 19 Apr 2023 14:04:35 +0200 Message-Id: <502ef5c6320340daa35d281798b0b238c5c592e8.1681905482.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.9 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: , Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 3.1 on 10.11.54.9 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: 1681907024976100003 Content-Type: text/plain; charset="utf-8" Use automatic memory cleanup for the 'keys' and 'sorted' helpers and remove the 'cleanup' label. Since this patch is modifying variable declarations ensure that all declarations conform with our coding style. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/util/virtypedparam.c | 31 ++++++++++++++++--------------- 1 file changed, 16 insertions(+), 15 deletions(-) diff --git a/src/util/virtypedparam.c b/src/util/virtypedparam.c index d0e6cf6d9b..c71d4415a1 100644 --- a/src/util/virtypedparam.c +++ b/src/util/virtypedparam.c @@ -59,12 +59,15 @@ int virTypedParamsValidate(virTypedParameterPtr params, int nparams, ...) { va_list ap; - int ret =3D -1; - size_t i, j; - const char *name, *last_name =3D NULL; + size_t i; + size_t j; + const char *name; + const char *last_name =3D NULL; int type; - size_t nkeys =3D 0, nkeysalloc =3D 0; - virTypedParameterPtr sorted =3D NULL, keys =3D NULL; + size_t nkeys =3D 0; + size_t nkeysalloc =3D 0; + g_autofree virTypedParameterPtr sorted =3D NULL; + g_autofree virTypedParameterPtr keys =3D NULL; va_start(ap, nparams); @@ -82,7 +85,8 @@ virTypedParamsValidate(virTypedParameterPtr params, int n= params, ...) if (virStrcpyStatic(keys[nkeys].field, name) < 0) { virReportError(VIR_ERR_INTERNAL_ERROR, _("Field name '%1$s' too long"), name); - goto cleanup; + va_end(ap); + return -1; } keys[nkeys].type =3D type & ~VIR_TYPED_PARAM_MULTIPLE; @@ -93,6 +97,8 @@ virTypedParamsValidate(virTypedParameterPtr params, int n= params, ...) name =3D va_arg(ap, const char *); } + va_end(ap); + qsort(keys, nkeys, sizeof(*keys), virTypedParamsSortName); for (i =3D 0, j =3D 0; i < nparams && j < nkeys;) { @@ -104,7 +110,7 @@ virTypedParamsValidate(virTypedParameterPtr params, int= nparams, ...) virReportError(VIR_ERR_INVALID_ARG, _("parameter '%1$s' occurs multiple times"), sorted[i].field); - goto cleanup; + return -1; } if (sorted[i].type !=3D keys[j].type) { const char *badtype; @@ -116,7 +122,7 @@ virTypedParamsValidate(virTypedParameterPtr params, int= nparams, ...) _("invalid type '%1$s' for parameter '%2$s'= , expected '%3$s'"), badtype, sorted[i].field, virTypedParameterTypeToString(keys[j].type)= ); - goto cleanup; + return -1; } last_name =3D sorted[i].field; i++; @@ -127,15 +133,10 @@ virTypedParamsValidate(virTypedParameterPtr params, i= nt nparams, ...) virReportError(VIR_ERR_ARGUMENT_UNSUPPORTED, _("parameter '%1$s' not supported"), sorted[i].field); - goto cleanup; + return -1; } - ret =3D 0; - cleanup: - va_end(ap); - VIR_FREE(sorted); - VIR_FREE(keys); - return ret; + return 0; } --=20 2.39.2 From nobody Mon Feb 9 01:44:02 2026 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=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1681908003; cv=none; d=zohomail.com; s=zohoarc; b=k9+0VUbzrir+6kAgLkjVTBGFGgQTAOxJuBYDrWTsuf4kqdSZ6bm9yNrXKWwxGLllSUuWhsciP893k9O5UdR5hd81mGCh1yqbW8he+auwT+lQISODXg66SqEXa7kGc9pY/BBDaxjxjuAx5FQbRH5GnYeiAQVJRKJoWrPDJO3JLkc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1681908003; 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; bh=G6ZMZb/fAeCIhCKIH0Du8hmiyiDz3jK0xZ2piQ/7Wf0=; b=ZX1bQVNr4nYYltjptC55/Q9feZAUJULpMzYnf9SFoKfpYoCQREbt8OA3tla+VS5WTfcab+EJWwgnjhp+QNG5NePA5FmvqOhdyqxWRaaj6GMMkzjoK0ya02gB/qYFvhlt6cFZPVA2+wylohXK1yItf/OwTW8o8UFgUHYhYz+8sLQ= 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=pass 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 16819080033801015.3004639011081; Wed, 19 Apr 2023 05:40:03 -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-325-3PZ6qqWROZCxcgV9UFh0Cg-1; Wed, 19 Apr 2023 08:39:26 -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 2243B823D46; Wed, 19 Apr 2023 12:39:24 +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 0F59840C2064; Wed, 19 Apr 2023 12:39:24 +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 987D919465B9; Wed, 19 Apr 2023 12:39:23 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 5CD4019465A0 for ; Wed, 19 Apr 2023 12:05:01 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 43475492B06; Wed, 19 Apr 2023 12:05:01 +0000 (UTC) Received: from speedmetal.redhat.com (unknown [10.45.242.23]) by smtp.corp.redhat.com (Postfix) with ESMTP id BBDC0492B04 for ; Wed, 19 Apr 2023 12:05:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1681908002; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to: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=G6ZMZb/fAeCIhCKIH0Du8hmiyiDz3jK0xZ2piQ/7Wf0=; b=XaVodI71/sAsxqYocF+qjcMg3KmHLWhECs5aJytKsmZXunj/XvNXgSxQ9P0BLushAxT5TV IL+Wtb1Ea5/eG6brdZp9je9rqjXy/fC+anEH9Hp3XmlsQSVr0+pfq5NvDUyox+dT1uROzn kIueFajzgXd+y1rSkfZt7m/dPCA6QA4= X-MC-Unique: 3PZ6qqWROZCxcgV9UFh0Cg-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH v3 19/25] virTypedParamsValidate: Allow typed params to be both _UINT and _ULLONG Date: Wed, 19 Apr 2023 14:04:36 +0200 Message-Id: <9bd6878d910680d67f16d259f279f401df29bee4.1681905482.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.9 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: , 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: 1681908005183100001 Content-Type: text/plain; charset="utf-8" For certain typed parameters we want to extend the supproted range by switching to VIR_TYPED_PARAM_ULLONG. To preserve compatibility we've added APIs such as 'virTypedParamsGetUnsigned' and 'virTypedParamListAddUnsigned' which automatically select the bigger type if necessary. This patch adds a new internal macro VIR_TYPED_PARAM_UNSIGNED which is used with virTypedParamsValidate to allow both types and adjusts the code to handle it properly. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/util/virtypedparam.c | 19 ++++++++++++++----- src/util/virtypedparam.h | 9 +++++++++ 2 files changed, 23 insertions(+), 5 deletions(-) diff --git a/src/util/virtypedparam.c b/src/util/virtypedparam.c index c71d4415a1..c3bc1237c1 100644 --- a/src/util/virtypedparam.c +++ b/src/util/virtypedparam.c @@ -63,7 +63,6 @@ virTypedParamsValidate(virTypedParameterPtr params, int n= params, ...) size_t j; const char *name; const char *last_name =3D NULL; - int type; size_t nkeys =3D 0; size_t nkeysalloc =3D 0; g_autofree virTypedParameterPtr sorted =3D NULL; @@ -79,7 +78,7 @@ virTypedParamsValidate(virTypedParameterPtr params, int n= params, ...) name =3D va_arg(ap, const char *); while (name) { - type =3D va_arg(ap, int); + int type =3D va_arg(ap, int); VIR_RESIZE_N(keys, nkeysalloc, nkeys, 1); if (virStrcpyStatic(keys[nkeys].field, name) < 0) { @@ -105,6 +104,9 @@ virTypedParamsValidate(virTypedParameterPtr params, int= nparams, ...) if (STRNEQ(sorted[i].field, keys[j].field)) { j++; } else { + const char *expecttype =3D virTypedParameterTypeToString(keys[= j].type); + int type =3D sorted[i].type; + if (STREQ_NULLABLE(last_name, sorted[i].field) && !(keys[j].value.i & VIR_TYPED_PARAM_MULTIPLE)) { virReportError(VIR_ERR_INVALID_ARG, @@ -112,7 +114,15 @@ virTypedParamsValidate(virTypedParameterPtr params, in= t nparams, ...) sorted[i].field); return -1; } - if (sorted[i].type !=3D keys[j].type) { + + if (keys[j].type =3D=3D VIR_TYPED_PARAM_UNSIGNED && + (type =3D=3D VIR_TYPED_PARAM_UINT || + type =3D=3D VIR_TYPED_PARAM_ULLONG)) { + type =3D VIR_TYPED_PARAM_UNSIGNED; + expecttype =3D "uint, ullong"; + } + + if (type !=3D keys[j].type) { const char *badtype; badtype =3D virTypedParameterTypeToString(sorted[i].type); @@ -120,8 +130,7 @@ virTypedParamsValidate(virTypedParameterPtr params, int= nparams, ...) badtype =3D virTypedParameterTypeToString(0); virReportError(VIR_ERR_INVALID_ARG, _("invalid type '%1$s' for parameter '%2$s'= , expected '%3$s'"), - badtype, sorted[i].field, - virTypedParameterTypeToString(keys[j].type)= ); + badtype, sorted[i].field, expecttype); return -1; } last_name =3D sorted[i].field; diff --git a/src/util/virtypedparam.h b/src/util/virtypedparam.h index c2f58e994c..7454ef3ce0 100644 --- a/src/util/virtypedparam.h +++ b/src/util/virtypedparam.h @@ -24,6 +24,15 @@ #include "internal.h" #include "virenum.h" + +/** + * VIR_TYPED_PARAM_UNSIGNED: + * + * Special typed parameter type only used with virTypedParamsValidate to + * indicate that both VIR_TYPED_PARAM_UINT and VIR_TYPED_PARAM_ULLONG types + * are acceptable for given value. + */ +#define VIR_TYPED_PARAM_UNSIGNED (VIR_TYPED_PARAM_LAST + 1) /** * VIR_TYPED_PARAM_MULTIPLE: * --=20 2.39.2 From nobody Mon Feb 9 01:44:02 2026 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=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1681908500; cv=none; d=zohomail.com; s=zohoarc; b=kxXo2xR0pyD6qg1uMQNjiePZEJjHSH3K3G67gQrlul8FASvp0Yz4z/Ad2f3X6n8AwfSKBK0ju1pEo2OxZn2hjPVxHkNZkcJJZB+ejUzep4mgWjWPJjvRp/uuRXvVNNgzlH4+4c3kw7E15hl1muiyCJqte8RujadcTbjU1oU+qis= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1681908500; 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; bh=rfR3Tse64igClYFCNidkhWvzthPMRc2akILfWfnmjCQ=; b=JuagecCXL/EgSjTS69HheLjiOeExfd/PjaeyaZZUA8IUhDGpJNUkRIom6Wf6dy8pWM/DyyAAyJZMOF4xewf70/RLHANDCmaLCwzvDbBtDPbvJvRBBDOhUVD8Ihn3TnlbLHDg5qSZSDEe77piF3yU8bY2Z7Ixwc/W0dvVZ/SbhK8= 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=pass 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 1681908500666291.70234043483276; Wed, 19 Apr 2023 05:48:20 -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-199-P7yBu0LkNc2nyvL3IEgD_Q-1; Wed, 19 Apr 2023 08:48:13 -0400 Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 3651485A588; Wed, 19 Apr 2023 12:48:11 +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 20776492B06; Wed, 19 Apr 2023 12:48:11 +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 C52C519465B1; Wed, 19 Apr 2023 12:48:10 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id AB22B19465A0 for ; Wed, 19 Apr 2023 12:05:02 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 395C7492B04; Wed, 19 Apr 2023 12:05:02 +0000 (UTC) Received: from speedmetal.redhat.com (unknown [10.45.242.23]) by smtp.corp.redhat.com (Postfix) with ESMTP id 93554492B05 for ; Wed, 19 Apr 2023 12:05:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1681908496; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to: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=rfR3Tse64igClYFCNidkhWvzthPMRc2akILfWfnmjCQ=; b=dvdjpqKib+Gn2U4wQRLjhGhPGCFlbBrHxrnNU5cC/ZC0gsxrsR/6jQJolQNsRC1B976gsF vujozfSL+u49nMDx02emhIjnfKFRcJJtic/ouMKpfcZEec2mGYDmvRTzW0FDAjvUAhx7DN Of5wfup75afWK6sF/fR2iVcMlhQdets= X-MC-Unique: P7yBu0LkNc2nyvL3IEgD_Q-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH v3 20/25] virsh: cmdIOThreadSet: Refactor to use virTypedParamList Date: Wed, 19 Apr 2023 14:04:37 +0200 Message-Id: <3195573abf47b105dc44eaf20561f2a33b320353.1681905482.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.9 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: , Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 3.1 on 10.11.54.9 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: 1681908501754100001 Content-Type: text/plain; charset="utf-8" Refactor to use the new data type so that we can use the APIs of it in upcoming patches. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- tools/virsh-domain.c | 78 ++++++++++++++++++-------------------------- 1 file changed, 31 insertions(+), 47 deletions(-) diff --git a/tools/virsh-domain.c b/tools/virsh-domain.c index 6850843a25..d37e27000b 100644 --- a/tools/virsh-domain.c +++ b/tools/virsh-domain.c @@ -7846,14 +7846,13 @@ cmdIOThreadSet(vshControl *ctl, const vshCmd *cmd) { g_autoptr(virshDomain) dom =3D NULL; int id =3D 0; - bool ret =3D false; bool current =3D vshCommandOptBool(cmd, "current"); bool config =3D vshCommandOptBool(cmd, "config"); bool live =3D vshCommandOptBool(cmd, "live"); unsigned int flags =3D VIR_DOMAIN_AFFECT_CURRENT; - virTypedParameterPtr params =3D NULL; - int nparams =3D 0; - int maxparams =3D 0; + g_autoptr(virTypedParamList) params =3D virTypedParamListNew(); + virTypedParameterPtr par; + size_t npar =3D 0; unsigned long long poll_max; unsigned int poll_val; int thread_val; @@ -7871,64 +7870,49 @@ cmdIOThreadSet(vshControl *ctl, const vshCmd *cmd) return false; if (vshCommandOptInt(ctl, cmd, "id", &id) < 0) - goto cleanup; + return false; if (id <=3D 0) { vshError(ctl, _("Invalid IOThread id value: '%1$d'"), id); - goto cleanup; + return false; } - poll_val =3D 0; if ((rc =3D vshCommandOptULongLong(ctl, cmd, "poll-max-ns", &poll_max)= ) < 0) - goto cleanup; - if (rc > 0 && virTypedParamsAddULLong(¶ms, &nparams, &maxparams, - VIR_DOMAIN_IOTHREAD_POLL_MAX_NS, - poll_max) < 0) - goto save_error; + return false; + if (rc > 0) + virTypedParamListAddULLong(params, poll_max, VIR_DOMAIN_IOTHREAD_P= OLL_MAX_NS); -#define VSH_IOTHREAD_SET_UINT_PARAMS(opt, param) \ - poll_val =3D 0; \ - if ((rc =3D vshCommandOptUInt(ctl, cmd, opt, &poll_val)) < 0) \ - goto cleanup; \ - if (rc > 0 && \ - virTypedParamsAddUInt(¶ms, &nparams, &maxparams, \ - param, poll_val) < 0) \ - goto save_error; + if ((rc =3D vshCommandOptUInt(ctl, cmd, "poll-grow", &poll_val)) < 0) + return false; + if (rc > 0) + virTypedParamListAddUInt(params, poll_val, VIR_DOMAIN_IOTHREAD_POL= L_GROW); - VSH_IOTHREAD_SET_UINT_PARAMS("poll-grow", VIR_DOMAIN_IOTHREAD_POLL_GRO= W) - VSH_IOTHREAD_SET_UINT_PARAMS("poll-shrink", VIR_DOMAIN_IOTHREAD_POLL_S= HRINK) + if ((rc =3D vshCommandOptUInt(ctl, cmd, "poll-shrink", &poll_val)) < 0) + return false; + if (rc > 0) + virTypedParamListAddUInt(params, poll_val, VIR_DOMAIN_IOTHREAD_POL= L_SHRINK); -#undef VSH_IOTHREAD_SET_UINT_PARAMS + if ((rc =3D vshCommandOptInt(ctl, cmd, "thread-pool-min", &thread_val)= ) < 0) + return false; + if (rc > 0) + virTypedParamListAddInt(params, thread_val, VIR_DOMAIN_IOTHREAD_TH= READ_POOL_MIN); -#define VSH_IOTHREAD_SET_INT_PARAMS(opt, param) \ - thread_val =3D -1; \ - if ((rc =3D vshCommandOptInt(ctl, cmd, opt, &thread_val)) < 0) \ - goto cleanup; \ - if (rc > 0 && \ - virTypedParamsAddInt(¶ms, &nparams, &maxparams, \ - param, thread_val) < 0) \ - goto save_error; + if ((rc =3D vshCommandOptInt(ctl, cmd, "thread-pool-max", &thread_val)= ) < 0) + return false; + if (rc > 0) + virTypedParamListAddInt(params, thread_val, VIR_DOMAIN_IOTHREAD_TH= READ_POOL_MAX); - VSH_IOTHREAD_SET_INT_PARAMS("thread-pool-min", VIR_DOMAIN_IOTHREAD_THR= EAD_POOL_MIN) - VSH_IOTHREAD_SET_INT_PARAMS("thread-pool-max", VIR_DOMAIN_IOTHREAD_THR= EAD_POOL_MAX) -#undef VSH_IOTHREAD_SET_INT_PARAMS + if (virTypedParamListFetch(params, &par, &npar) < 0) + return false; - if (nparams =3D=3D 0) { + if (npar =3D=3D 0) { vshError(ctl, _("Not enough arguments passed, nothing to set")); - goto cleanup; + return false; } - if (virDomainSetIOThreadParams(dom, id, params, nparams, flags) < 0) - goto cleanup; - - ret =3D true; - - cleanup: - virTypedParamsFree(params, nparams); - return ret; + if (virDomainSetIOThreadParams(dom, id, par, npar, flags) < 0) + return false; - save_error: - vshSaveLibvirtError(); - goto cleanup; + return true; } --=20 2.39.2 From nobody Mon Feb 9 01:44:02 2026 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=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1681907046; cv=none; d=zohomail.com; s=zohoarc; b=gwSleFM2CPn8suDGROSr5AOvCSBKNpfq1yJFKD2outIkns+SVJId/952kFZa1+F5r3tDKDdPJCfhn7fi8gNBq5tQcUpBsdxn6r2dvKV4elwb3HL8usy7E93tX133ahY3onwl7aYIFMy497ivYWK1vMIiUr+Xs6kDrFzcN56mOSg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1681907046; 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; bh=PPdceNBn9jToPK+BhJawO2LKB5g+IfxwksOgZIS2dPs=; b=bHe61RTBzPwB2n2iM4J/pvNqSPuNvErsw/u/pl7EpvvEXoP5eU9joLKQp3N32PEy7SkPkWItLzLvgfNUETEHYuWHqaxTjnBb++dgD05/JsVILak9uwvkK1gD1Jlkuv09WjfLeLZrMSaEFEnxs+qgndnMxIf4Zy73iULMKQjTvrk= 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=pass 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 1681907046766520.7056458917896; Wed, 19 Apr 2023 05:24:06 -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-284-2rLk3sqWNvyk1XXFR6VXxQ-1; Wed, 19 Apr 2023 08:23:37 -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 2D45B3C10691; Wed, 19 Apr 2023 12:23:35 +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 D0D2D5AB7A; Wed, 19 Apr 2023 12:23:34 +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 2D8711946A41; Wed, 19 Apr 2023 12:23:34 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 32EDE19465A0 for ; Wed, 19 Apr 2023 12:05:03 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 168AA492B04; Wed, 19 Apr 2023 12:05:03 +0000 (UTC) Received: from speedmetal.redhat.com (unknown [10.45.242.23]) by smtp.corp.redhat.com (Postfix) with ESMTP id 8BE77492B05 for ; Wed, 19 Apr 2023 12:05:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1681907045; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to: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=PPdceNBn9jToPK+BhJawO2LKB5g+IfxwksOgZIS2dPs=; b=AUF5dOurnhE45u4eM20xflyGApeZBVMy01z6GL5PJpVOx4hpo9q1A4QK41kYg9ZvJAQzDc +vWZ0ebqdaXtVOBHzrXKVstWYPyszPiXtA9D7xx1KEjYfZWJEaZ3YVYAX/dRIMQ22FpDX6 WARUSEJQfgXIHj4Ndzc6vVg27B7kr8E= X-MC-Unique: 2rLk3sqWNvyk1XXFR6VXxQ-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH v3 21/25] qemu: Remove iothread 'poll-' value validation Date: Wed, 19 Apr 2023 14:04:38 +0200 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.9 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: , 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: 1681907047725100001 Content-Type: text/plain; charset="utf-8" QEMU accepts even values bigger than INT_MAX. The reasoning for these checks was that the QAPI definition declares them as 'int', but in QAPI terms that's any number as it's JSON. Remove the validation as well as the comment missintepreting the QAPI definiton. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/qemu/qemu_driver.c | 21 --------------------- src/qemu/qemu_monitor_json.c | 7 ------- 2 files changed, 28 deletions(-) diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index d47c1883f0..23646b7289 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -5234,27 +5234,6 @@ qemuDomainIOThreadParseParams(virTypedParameterPtr p= arams, if (rc =3D=3D 1) iothread->set_thread_pool_max =3D true; - if (iothread->set_poll_max_ns && iothread->poll_max_ns > INT_MAX) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, - _("poll-max-ns (%1$llu) must be less than or equal = to %2$d"), - iothread->poll_max_ns, INT_MAX); - return -1; - } - - if (iothread->set_poll_grow && iothread->poll_grow > INT_MAX) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, - _("poll-grow (%1$u) must be less than or equal to %= 2$d"), - iothread->poll_grow, INT_MAX); - return -1; - } - - if (iothread->set_poll_shrink && iothread->poll_shrink > INT_MAX) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, - _("poll-shrink (%1$u) must be less than or equal to= %2$d"), - iothread->poll_shrink, INT_MAX); - return -1; - } - if (iothread->set_thread_pool_min && iothread->thread_pool_min < -1) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, _("thread_pool_min (%1$d) must be equal to or great= er than -1"), diff --git a/src/qemu/qemu_monitor_json.c b/src/qemu/qemu_monitor_json.c index b2c0b20a11..3454e85e43 100644 --- a/src/qemu/qemu_monitor_json.c +++ b/src/qemu/qemu_monitor_json.c @@ -7128,13 +7128,6 @@ qemuMonitorJSONGetIOThreads(qemuMonitor *mon, goto cleanup; } - /* Fetch poll values (since QEMU 2.9 ) if available. QEMU - * stores these values as int64_t's; however, the qapi type - * is an int. The qapi/misc.json also mis-describes the grow - * and shrink values as pure add/remove values. The source - * util/aio-posix.c function aio_poll uses them as a factor - * or divisor in it's calculation. We will fetch and store - * them as defined in our structures. */ if (virJSONValueObjectGetNumberUlong(child, "poll-max-ns", &info->poll_max_ns) =3D=3D 0 = && virJSONValueObjectGetNumberUint(child, "poll-grow", --=20 2.39.2 From nobody Mon Feb 9 01:44:02 2026 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=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1681906505; cv=none; d=zohomail.com; s=zohoarc; b=NVQ3lxmImT5zNZKs7ih8l73h1HBS8f7HtzqSMrcaeWxBLm8OVNurobaX9rHZ0gATqaFP6zRnV17M1vn7Bb4/EyOaJFlKHkcUU+xdgP1eV0TYK7uKIeV8e5OG2PobWjsycLFKlzQ8RNTvBjJ7dFRWC7UFuygDtGoygnVOvHLhJ7U= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1681906505; 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; bh=bpNs0NX/YaGm3K3yZPr1nvbVXGri/KUEn++m9S/EHBw=; b=HJZuxONAzi332J/UGTXNbayz5G1v8YZaXW6sUz5qNo0f2heGk+9sTnXqlHY+qVEFkPEkcmEwp23dqiEJQBBFoWRyssg0827MDg/pG5X0mhz+mmjPlizuBBqK1ru/eMJi23TalKm1Tsn3rUzZZ6YAJS3MFRD9xrJuyz+x9/6O+uk= 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=pass 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 1681906505929460.4312308320368; Wed, 19 Apr 2023 05:15:05 -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-148-hvs0qtEJMN-2otFBmTUohQ-1; Wed, 19 Apr 2023 08:14:14 -0400 Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 58A0A1C12986; Wed, 19 Apr 2023 12:14:10 +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 400A4492B04; Wed, 19 Apr 2023 12:14:10 +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 0604619465B1; Wed, 19 Apr 2023 12:14:10 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id ECED519465A0 for ; Wed, 19 Apr 2023 12:05:03 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id DCC73492B04; Wed, 19 Apr 2023 12:05:03 +0000 (UTC) Received: from speedmetal.redhat.com (unknown [10.45.242.23]) by smtp.corp.redhat.com (Postfix) with ESMTP id 61CC8492B05 for ; Wed, 19 Apr 2023 12:05:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1681906504; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to: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=bpNs0NX/YaGm3K3yZPr1nvbVXGri/KUEn++m9S/EHBw=; b=jFOIat43qZnUmQ9xZwKgnfFagNvTxnRVTEvCbBJfpr8tLnlR03nOCZQttdBWLN37dzwUAe zGOOvwZSV+PmFGQKjNKA/XU3BpDmzEft7azZQFtTkrDc6KymoaEMSes96Ebr2yZBivrTup jHmxPHI8lyrTAi8Vnc+zdcE8BtHlJCM= X-MC-Unique: hvs0qtEJMN-2otFBmTUohQ-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH v3 22/25] qemu: Store all iothread's 'poll*' attributes as unsigned long long Date: Wed, 19 Apr 2023 14:04:39 +0200 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.9 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: , Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 3.1 on 10.11.54.9 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: 1681906507238100001 Content-Type: text/plain; charset="utf-8" Convert the internal types to unsigned long long. Luckily we can also covert the external types too: - 'qemuDomainSetIOThreadParams' can accept both _UINT and _ULLONG by converting to 'virTypedParamsGetUnsigned' - querying is handled via the bulk stats API which is flexible: - we use virTypedParamListAddUnsigned to use the bigger type only if necessary - most users don't even notice because the bindings abstract the data types Apart from the code modifications we also improve the documenataion which was missing for the setters. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- include/libvirt/libvirt-domain.h | 4 +++- src/libvirt-domain.c | 14 +++++++---- src/qemu/qemu_driver.c | 28 +++++++++++----------- src/qemu/qemu_monitor.h | 4 ++-- src/qemu/qemu_monitor_json.c | 41 ++++++++++++++++++++------------ 5 files changed, 54 insertions(+), 37 deletions(-) diff --git a/include/libvirt/libvirt-domain.h b/include/libvirt/libvirt-dom= ain.h index 3ebb2c6642..20862a69f2 100644 --- a/include/libvirt/libvirt-domain.h +++ b/include/libvirt/libvirt-domain.h @@ -2482,7 +2482,7 @@ int virDomainDelIOThread(virDomainPt= r domain, * poll_grow and poll_shrink parameters provided. A value set too large * will cause more CPU time to be allocated the guest. A value set too * small will not provide enough cycles for the guest to process data. - * The polling interval is not available for statistical purposes. + * Accepted type is VIR_TYPED_PARAM_ULLONG. * * Since: 4.10.0 */ @@ -2495,6 +2495,7 @@ int virDomainDelIOThread(virDomainPt= r domain, * use to grow its polling interval up to the poll_max_ns value. A value * of 0 (zero) allows the hypervisor to choose its own value. The algorithm * to use for adjustment is hypervisor specific. + * Accepted type is VIR_TYPED_PARAM_UINT or since 9.3.0 VIR_TYPED_PARAM_UL= LONG. * * Since: 4.10.0 */ @@ -2508,6 +2509,7 @@ int virDomainDelIOThread(virDomainPt= r domain, * the poll_max_ns value. A value of 0 (zero) allows the hypervisor to * choose its own value. The algorithm to use for adjustment is hypervisor * specific. + * Accepted type is VIR_TYPED_PARAM_UINT or since 9.3.0 VIR_TYPED_PARAM_UL= LONG. * * Since: 4.10.0 */ diff --git a/src/libvirt-domain.c b/src/libvirt-domain.c index 63829bb028..ec42bb9a53 100644 --- a/src/libvirt-domain.c +++ b/src/libvirt-domain.c @@ -12449,14 +12449,18 @@ virConnectGetDomainCapabilities(virConnectPtr con= n, * "iothread..poll-max-ns" - maximum polling time in ns as an unsi= gned * long long. A 0 (zero) means polling is * disabled. - * "iothread..poll-grow" - polling time factor as an unsigned int. + * "iothread..poll-grow" - polling time factor as an unsigned int = or + * unsigned long long if exceeding range of + * unsigned int. * A 0 (zero) indicates to allow the under= lying * hypervisor to choose how to grow the * polling time. - * "iothread..poll-shrink" - polling time divisor as an unsigned i= nt. - * A 0 (zero) indicates to allow the under= lying - * hypervisor to choose how to shrink the - * polling time. + * "iothread..poll-shrink" - polling time divisor as an unsigned i= nt or + * unsigned long long if exceeding range= of + * unsigned int. + * A 0 (zero) indicates to allow the und= erlying + * hypervisor to choose how to shrink the + * polling time. * * VIR_DOMAIN_STATS_MEMORY: * Return memory bandwidth statistics and the usage information. The t= yped diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index 23646b7289..dafe8af8a6 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -5189,9 +5189,9 @@ qemuDomainIOThreadParseParams(virTypedParameterPtr pa= rams, VIR_DOMAIN_IOTHREAD_POLL_MAX_NS, VIR_TYPED_PARAM_ULLONG, VIR_DOMAIN_IOTHREAD_POLL_GROW, - VIR_TYPED_PARAM_UINT, + VIR_TYPED_PARAM_UNSIGNED, VIR_DOMAIN_IOTHREAD_POLL_SHRINK, - VIR_TYPED_PARAM_UINT, + VIR_TYPED_PARAM_UNSIGNED, VIR_DOMAIN_IOTHREAD_THREAD_POOL_MIN, VIR_TYPED_PARAM_INT, VIR_DOMAIN_IOTHREAD_THREAD_POOL_MAX, @@ -5206,16 +5206,16 @@ qemuDomainIOThreadParseParams(virTypedParameterPtr = params, if (rc =3D=3D 1) iothread->set_poll_max_ns =3D true; - if ((rc =3D virTypedParamsGetUInt(params, nparams, - VIR_DOMAIN_IOTHREAD_POLL_GROW, - &iothread->poll_grow)) < 0) + if ((rc =3D virTypedParamsGetUnsigned(params, nparams, + VIR_DOMAIN_IOTHREAD_POLL_GROW, + &iothread->poll_grow)) < 0) return -1; if (rc =3D=3D 1) iothread->set_poll_grow =3D true; - if ((rc =3D virTypedParamsGetUInt(params, nparams, - VIR_DOMAIN_IOTHREAD_POLL_SHRINK, - &iothread->poll_shrink)) < 0) + if ((rc =3D virTypedParamsGetUnsigned(params, nparams, + VIR_DOMAIN_IOTHREAD_POLL_SHRINK, + &iothread->poll_shrink)) < 0) return -1; if (rc =3D=3D 1) iothread->set_poll_shrink =3D true; @@ -18048,12 +18048,12 @@ qemuDomainGetStatsIOThread(virQEMUDriver *driver = G_GNUC_UNUSED, virTypedParamListAddULLong(params, iothreads[i]->poll_max_ns, "iothread.%u.poll-max-ns", iothreads[i]->iothread_id); - virTypedParamListAddUInt(params, iothreads[i]->poll_grow, - "iothread.%u.poll-grow", - iothreads[i]->iothread_id); - virTypedParamListAddUInt(params, iothreads[i]->poll_shrink, - "iothread.%u.poll-shrink", - iothreads[i]->iothread_id); + virTypedParamListAddUnsigned(params, iothreads[i]->poll_grow, + "iothread.%u.poll-grow", + iothreads[i]->iothread_id); + virTypedParamListAddUnsigned(params, iothreads[i]->poll_shrink, + "iothread.%u.poll-shrink", + iothreads[i]->iothread_id); } } diff --git a/src/qemu/qemu_monitor.h b/src/qemu/qemu_monitor.h index 72db0c0838..09f22f2328 100644 --- a/src/qemu/qemu_monitor.h +++ b/src/qemu/qemu_monitor.h @@ -1254,8 +1254,8 @@ struct _qemuMonitorIOThreadInfo { int thread_id; bool poll_valid; unsigned long long poll_max_ns; - unsigned int poll_grow; - unsigned int poll_shrink; + unsigned long long poll_grow; + unsigned long long poll_shrink; int thread_pool_min; int thread_pool_max; bool set_poll_max_ns; diff --git a/src/qemu/qemu_monitor_json.c b/src/qemu/qemu_monitor_json.c index 3454e85e43..745d83e2b6 100644 --- a/src/qemu/qemu_monitor_json.c +++ b/src/qemu/qemu_monitor_json.c @@ -7130,10 +7130,10 @@ qemuMonitorJSONGetIOThreads(qemuMonitor *mon, if (virJSONValueObjectGetNumberUlong(child, "poll-max-ns", &info->poll_max_ns) =3D=3D 0 = && - virJSONValueObjectGetNumberUint(child, "poll-grow", - &info->poll_grow) =3D=3D 0 && - virJSONValueObjectGetNumberUint(child, "poll-shrink", - &info->poll_shrink) =3D=3D 0) + virJSONValueObjectGetNumberUlong(child, "poll-grow", + &info->poll_grow) =3D=3D 0 && + virJSONValueObjectGetNumberUlong(child, "poll-shrink", + &info->poll_shrink) =3D=3D 0) info->poll_valid =3D true; } @@ -7161,18 +7161,20 @@ qemuMonitorJSONSetIOThread(qemuMonitor *mon, path =3D g_strdup_printf("/objects/iothread%u", iothreadInfo->iothread= _id); -#define VIR_IOTHREAD_SET_PROP(propName, propVal) \ +#define VIR_IOTHREAD_SET_PROP_UL(propName, propVal) \ if (iothreadInfo->set_##propVal) { \ memset(&prop, 0, sizeof(qemuMonitorJSONObjectProperty)); \ - prop.type =3D QEMU_MONITOR_OBJECT_PROPERTY_INT; \ - prop.val.iv =3D iothreadInfo->propVal; \ + prop.type =3D QEMU_MONITOR_OBJECT_PROPERTY_ULONG; \ + prop.val.ul =3D iothreadInfo->propVal; \ if (qemuMonitorJSONSetObjectProperty(mon, path, propName, &prop) <= 0) \ return -1; \ } - VIR_IOTHREAD_SET_PROP("poll-max-ns", poll_max_ns); - VIR_IOTHREAD_SET_PROP("poll-grow", poll_grow); - VIR_IOTHREAD_SET_PROP("poll-shrink", poll_shrink); + VIR_IOTHREAD_SET_PROP_UL("poll-max-ns", poll_max_ns); + VIR_IOTHREAD_SET_PROP_UL("poll-grow", poll_grow); + VIR_IOTHREAD_SET_PROP_UL("poll-shrink", poll_shrink); + +#undef VIR_IOTHREAD_SET_PROP_UL if (iothreadInfo->set_thread_pool_min && iothreadInfo->set_thread_pool_max) { @@ -7192,15 +7194,24 @@ qemuMonitorJSONSetIOThread(qemuMonitor *mon, setMaxFirst =3D true; } +#define VIR_IOTHREAD_SET_PROP_INT(propName, propVal) \ + if (iothreadInfo->set_##propVal) { \ + memset(&prop, 0, sizeof(qemuMonitorJSONObjectProperty)); \ + prop.type =3D QEMU_MONITOR_OBJECT_PROPERTY_INT; \ + prop.val.iv =3D iothreadInfo->propVal; \ + if (qemuMonitorJSONSetObjectProperty(mon, path, propName, &prop) <= 0) \ + return -1; \ + } + if (setMaxFirst) { - VIR_IOTHREAD_SET_PROP("thread-pool-max", thread_pool_max); - VIR_IOTHREAD_SET_PROP("thread-pool-min", thread_pool_min); + VIR_IOTHREAD_SET_PROP_INT("thread-pool-max", thread_pool_max); + VIR_IOTHREAD_SET_PROP_INT("thread-pool-min", thread_pool_min); } else { - VIR_IOTHREAD_SET_PROP("thread-pool-min", thread_pool_min); - VIR_IOTHREAD_SET_PROP("thread-pool-max", thread_pool_max); + VIR_IOTHREAD_SET_PROP_INT("thread-pool-min", thread_pool_min); + VIR_IOTHREAD_SET_PROP_INT("thread-pool-max", thread_pool_max); } -#undef VIR_IOTHREAD_SET_PROP +#undef VIR_IOTHREAD_SET_PROP_INT return 0; } --=20 2.39.2 From nobody Mon Feb 9 01:44:02 2026 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=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1681906458; cv=none; d=zohomail.com; s=zohoarc; b=g1KZH0XEa5j+3dJtJwvycKQu8rPRRhQjhS54EEhdGJvKtTbZA3KTTYXceeH2I9TTqYyNJgFWz6pKuWpGHdQy2R/CcF9B2kZsuEM7ntPwykJ+b/0vZZtVEoiLHaznkhEtObaUcUQt/7n36Xuq84hmIeBj/O3kBemJKxdkZOkJJGA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1681906458; 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; bh=9TNZDdvQ5LBDrVuYoY12s+rySpVmwIoXWdMTOaP/HmY=; b=Hz/2wbuzKYOBcYdEJ+jpV6qqGprzJg3vvqeQFbmNnM4MvYI/zwRem83Ww/yHtPCrcBTTqb2DvjhlOOCZBPS2zHgaxL0omWFAIe7t+SwiN2n55UJWVDl978TPEFTQczlAsHDvt61cgAQ2CXaQiRbfPyHHhD6oTWSfe1bzBEjBNus= 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=pass 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 1681906458850422.41882250225717; Wed, 19 Apr 2023 05:14:18 -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-427-zprYPQP_ML6N05kC99kFkw-1; Wed, 19 Apr 2023 08:14:13 -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 CACEA857FBC; Wed, 19 Apr 2023 12:14:10 +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 A784D112131B; Wed, 19 Apr 2023 12:14:10 +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 42DB01946A46; Wed, 19 Apr 2023 12:14:10 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id C195C19465A0 for ; Wed, 19 Apr 2023 12:05:04 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id B3B82492B06; Wed, 19 Apr 2023 12:05:04 +0000 (UTC) Received: from speedmetal.redhat.com (unknown [10.45.242.23]) by smtp.corp.redhat.com (Postfix) with ESMTP id 35AC6492B04 for ; Wed, 19 Apr 2023 12:05:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1681906457; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to: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=9TNZDdvQ5LBDrVuYoY12s+rySpVmwIoXWdMTOaP/HmY=; b=B7Jxq32mkYy3Nx4+utKoocsnc0MpYWxLJ2tHPUT6sh7X6V51fzUD39NP8dqM4hO7AWJcUO pEfSlRD9NCpqd/w1RmYKzMujxr7Y4vDwXhKE73raLhFtSQInwHnyrDo3vYBHKRbrOEfT5Y tkn9g7wWjNZ1y8ocD2gZyVDm9b1Kj2w= X-MC-Unique: zprYPQP_ML6N05kC99kFkw-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH v3 23/25] virsh: cmdIOThreadSet: Use bigger types for --poll-grow and --poll-shrink Date: Wed, 19 Apr 2023 14:04:40 +0200 Message-Id: <4f644b2ed6b9b886f2cdcb708f2fc0a847ebc2c7.1681905482.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.9 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: , 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: 1681906460647100001 Content-Type: text/plain; charset="utf-8" The qemu driver now accepts also _ULLONG as type for bigger numbers. Use the 'virTypedParamListAddUnsigned' helper to use the bigger typed parameter type if necessary to allow full range of the values while preserving compatibility. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- tools/virsh-domain.c | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/tools/virsh-domain.c b/tools/virsh-domain.c index d37e27000b..db47d63d85 100644 --- a/tools/virsh-domain.c +++ b/tools/virsh-domain.c @@ -7853,8 +7853,7 @@ cmdIOThreadSet(vshControl *ctl, const vshCmd *cmd) g_autoptr(virTypedParamList) params =3D virTypedParamListNew(); virTypedParameterPtr par; size_t npar =3D 0; - unsigned long long poll_max; - unsigned int poll_val; + unsigned long long poll_val; int thread_val; int rc; @@ -7876,20 +7875,20 @@ cmdIOThreadSet(vshControl *ctl, const vshCmd *cmd) return false; } - if ((rc =3D vshCommandOptULongLong(ctl, cmd, "poll-max-ns", &poll_max)= ) < 0) + if ((rc =3D vshCommandOptULongLong(ctl, cmd, "poll-max-ns", &poll_val)= ) < 0) return false; if (rc > 0) - virTypedParamListAddULLong(params, poll_max, VIR_DOMAIN_IOTHREAD_P= OLL_MAX_NS); + virTypedParamListAddULLong(params, poll_val, VIR_DOMAIN_IOTHREAD_P= OLL_MAX_NS); - if ((rc =3D vshCommandOptUInt(ctl, cmd, "poll-grow", &poll_val)) < 0) + if ((rc =3D vshCommandOptULongLong(ctl, cmd, "poll-grow", &poll_val)) = < 0) return false; if (rc > 0) - virTypedParamListAddUInt(params, poll_val, VIR_DOMAIN_IOTHREAD_POL= L_GROW); + virTypedParamListAddUnsigned(params, poll_val, VIR_DOMAIN_IOTHREAD= _POLL_GROW); - if ((rc =3D vshCommandOptUInt(ctl, cmd, "poll-shrink", &poll_val)) < 0) + if ((rc =3D vshCommandOptULongLong(ctl, cmd, "poll-shrink", &poll_val)= ) < 0) return false; if (rc > 0) - virTypedParamListAddUInt(params, poll_val, VIR_DOMAIN_IOTHREAD_POL= L_SHRINK); + virTypedParamListAddUnsigned(params, poll_val, VIR_DOMAIN_IOTHREAD= _POLL_SHRINK); if ((rc =3D vshCommandOptInt(ctl, cmd, "thread-pool-min", &thread_val)= ) < 0) return false; --=20 2.39.2 From nobody Mon Feb 9 01:44:02 2026 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=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1681907323; cv=none; d=zohomail.com; s=zohoarc; b=XNQxiXG9jS2HD8M5Ht28BZ223+hNOkdKqTSSHPiZyuFMOCDCrTycVRtIV4hZczmo5Dv+fpIzmLZk9IMiq463ZhHGSNS65GSuAKk6B+MwlvtA/dFokF0fGGRFuu8DOJuuBH6rWewFk9B3cEuYuA1NmgKzqq7YCwN/BJ5MTJB9WHM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1681907323; 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; bh=duCffovOfzByXVSa6Ttvn00CL6w9NuSg5oYaQCp9QEE=; b=kPhc7pZBEm3JJ1jnMSziK1mxFoPEu7gtylMGxNfgV3Kbdguwo0m9lj9nLIN6WyAVteG6rItOcyGiryiddUhpxJe2GEbKJ8RFOprZLbFHtsxZJBpWW+l6h6woyzJgbOXvD6RdkfCJgdjZQFdkaZM76e6xDJ0/aR6PwXzPYHRkKHY= 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=pass 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 1681907323601151.89069790391898; Wed, 19 Apr 2023 05:28:43 -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-6-24w7TpB1OROryyTaw3lmgw-1; Wed, 19 Apr 2023 08:28:38 -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 B2C8F857A93; Wed, 19 Apr 2023 12:28:35 +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 9F91BC164E7; Wed, 19 Apr 2023 12:28:35 +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 DDB1219465B9; Wed, 19 Apr 2023 12:28:29 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id A9DD019465B2 for ; Wed, 19 Apr 2023 12:05:05 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 89B2E492B06; Wed, 19 Apr 2023 12:05:05 +0000 (UTC) Received: from speedmetal.redhat.com (unknown [10.45.242.23]) by smtp.corp.redhat.com (Postfix) with ESMTP id 0ECEC492B04 for ; Wed, 19 Apr 2023 12:05:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1681907322; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to: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=duCffovOfzByXVSa6Ttvn00CL6w9NuSg5oYaQCp9QEE=; b=W4XW5syCAuDJPCza5vpMHLkAW2qOiIExdtAIGS7C8lO74XqQBCL16utq9d5QUwWKqG0ZGe wEH71LfXAYPl/s3PRVAdeggmQ1N6xCPRxjJ9bA9erdorTpIkQihfV5Fni349li4k9GoAcs M7QrRupMVq3xcWrLmMdiXQ6UV70FEyc= X-MC-Unique: 24w7TpB1OROryyTaw3lmgw-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH v3 24/25] conf: Store the iothread 'poll' settings in the XML Date: Wed, 19 Apr 2023 14:04:41 +0200 Message-Id: <22c2f385a11a55d2071223d54de984a452746071.1681905482.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.9 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: , 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: 1681907324382100005 Content-Type: text/plain; charset="utf-8" Currently we allow configuring the 'poll-max-ns', 'poll-grow', and 'poll-shrink' parameters of qemu iothreads only during runtime and they are not persisted. Add XML machinery to persist them. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- docs/formatdomain.rst | 11 ++++- src/conf/domain_conf.c | 41 ++++++++++++++++++- src/conf/domain_conf.h | 7 ++++ src/conf/schemas/domaincommon.rng | 19 +++++++++ .../iothreads-ids-pool-sizes.xml | 12 ++++-- 5 files changed, 85 insertions(+), 5 deletions(-) diff --git a/docs/formatdomain.rst b/docs/formatdomain.rst index c31c2fe35c..bfef1c63e6 100644 --- a/docs/formatdomain.rst +++ b/docs/formatdomain.rst @@ -740,7 +740,9 @@ host/guest with many LUNs. :since:`Since 1.2.8 (QEMU on= ly)` - + + + ... @@ -766,6 +768,13 @@ host/guest with many LUNs. :since:`Since 1.2.8 (QEMU o= nly)` ``thread_pool_max`` which allow setting lower and upper boundary for nu= mber of worker threads for given IOThread. While the former can be value of = zero, the latter can't. :since:`Since 8.5.0` + :since:`Since 9.1.0` an optional sub-element ``poll`` with can be used = to + override the hypervisor-default interval of polling for the iothread be= fore + it switches back to events. The optional attribute ``max`` sets the max= imum + time polling should be used in nanoseconds. Setting ``max`` to ``0`` di= sables + polling. Attributes ``grow`` and ``shrink`` override (or disable when s= et to + ``0`` the default steps for increasing/decreasing the polling interval = if + the set interval is deemed insufficient or extensive. ``defaultiothread`` This element represents the default event loop within hypervisor, where= I/O requests from devices not assigned to a specific IOThread are processed. diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index b03a3ff011..eccabe07bc 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -15742,6 +15742,7 @@ static virDomainIOThreadIDDef * virDomainIOThreadIDDefParseXML(xmlNodePtr node) { g_autoptr(virDomainIOThreadIDDef) iothrid =3D virDomainIOThreadIDDefNe= w(); + xmlNodePtr pollNode; if (virXMLPropUInt(node, "id", 10, VIR_XML_PROP_REQUIRED | VIR_XML_PROP_NONZERO, @@ -15758,6 +15759,28 @@ virDomainIOThreadIDDefParseXML(xmlNodePtr node) &iothrid->thread_pool_max, -1) < 0) return NULL; + if ((pollNode =3D virXMLNodeGetSubelement(node, "poll"))) { + int rc; + + if ((rc =3D virXMLPropULongLong(pollNode, "max", 10, VIR_XML_PROP_= NONE, + &iothrid->poll_max_ns)) < 0) + return NULL; + + iothrid->set_poll_max_ns =3D rc =3D=3D 1; + + if ((rc =3D virXMLPropULongLong(pollNode, "grow", 10, VIR_XML_PROP= _NONE, + &iothrid->poll_grow)) < 0) + return NULL; + + iothrid->set_poll_grow =3D rc =3D=3D 1; + + if ((rc =3D virXMLPropULongLong(pollNode, "shrink", 10, VIR_XML_PR= OP_NONE, + &iothrid->poll_shrink)) < 0) + return NULL; + + iothrid->set_poll_shrink =3D rc =3D=3D 1; + } + return g_steal_pointer(&iothrid); } @@ -26652,6 +26675,9 @@ virDomainDefIothreadShouldFormat(const virDomainDef= *def) for (i =3D 0; i < def->niothreadids; i++) { if (!def->iothreadids[i]->autofill || + def->iothreadids[i]->set_poll_max_ns || + def->iothreadids[i]->set_poll_grow || + def->iothreadids[i]->set_poll_shrink || def->iothreadids[i]->thread_pool_min >=3D 0 || def->iothreadids[i]->thread_pool_max >=3D 0) return true; @@ -26700,6 +26726,8 @@ virDomainDefIOThreadsFormat(virBuffer *buf, for (i =3D 0; i < def->niothreadids; i++) { virDomainIOThreadIDDef *iothread =3D def->iothreadids[i]; g_auto(virBuffer) attrBuf =3D VIR_BUFFER_INITIALIZER; + g_auto(virBuffer) iothreadChildBuf =3D VIR_BUFFER_INIT_CHILD(&= childrenBuf); + g_auto(virBuffer) pollAttrBuf =3D VIR_BUFFER_INITIALIZER; virBufferAsprintf(&attrBuf, " id=3D'%u'", iothread->iothread_id); @@ -26714,7 +26742,18 @@ virDomainDefIOThreadsFormat(virBuffer *buf, iothread->thread_pool_max); } - virXMLFormatElement(&childrenBuf, "iothread", &attrBuf, NULL); + if (iothread->set_poll_max_ns) + virBufferAsprintf(&pollAttrBuf, " max=3D'%llu'", iothread-= >poll_max_ns); + + if (iothread->set_poll_grow) + virBufferAsprintf(&pollAttrBuf, " grow=3D'%llu'", iothread= ->poll_grow); + + if (iothread->set_poll_shrink) + virBufferAsprintf(&pollAttrBuf, " shrink=3D'%llu'", iothre= ad->poll_shrink); + + virXMLFormatElement(&iothreadChildBuf, "poll", &pollAttrBuf, N= ULL); + + virXMLFormatElement(&childrenBuf, "iothread", &attrBuf, &iothr= eadChildBuf); } virXMLFormatElement(buf, "iothreadids", NULL, &childrenBuf); diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h index 511067a050..83d3da45d7 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -2714,6 +2714,13 @@ struct _virDomainIOThreadIDDef { virDomainThreadSchedParam sched; + unsigned long long poll_max_ns; + bool set_poll_max_ns; + unsigned long long poll_grow; + bool set_poll_grow; + unsigned long long poll_shrink; + bool set_poll_shrink; + int thread_pool_min; int thread_pool_max; }; diff --git a/src/conf/schemas/domaincommon.rng b/src/conf/schemas/domaincom= mon.rng index 6158ed79ac..57fb4a5e33 100644 --- a/src/conf/schemas/domaincommon.rng +++ b/src/conf/schemas/domaincommon.rng @@ -885,6 +885,25 @@ + + + + + + + + + + + + + + + + + + + diff --git a/tests/qemuxml2argvdata/iothreads-ids-pool-sizes.xml b/tests/qe= muxml2argvdata/iothreads-ids-pool-sizes.xml index df4b291a7a..63fb4a52f6 100644 --- a/tests/qemuxml2argvdata/iothreads-ids-pool-sizes.xml +++ b/tests/qemuxml2argvdata/iothreads-ids-pool-sizes.xml @@ -7,9 +7,15 @@ 5 - - - + + + + + + + + + --=20 2.39.2 From nobody Mon Feb 9 01:44:02 2026 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=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1681907022; cv=none; d=zohomail.com; s=zohoarc; b=YR8T2OBK4wrb4rv7Z3F5feSM4yTTUZzrmYKGeomMiXlRQZ4oOWp8XU+fDQp5vDxsM5CBLz8vTINd9FXAcEKsg6MCbN1sIV8tvBb/5eMIQu9LfP+BNva7H5a5u9Nx9hlbygK5qRZzROWAc2BgPEAfQ3UkkgpNNGQH823CX9PkvSQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1681907022; 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; bh=dSByu7q2Ebpuni7w8e78PAUecpqoyVJwg8mFKv8TKps=; b=WayFnjEY9x7VGITteCzJxbpy2ivycasW+PCc3wW2RuDZgA8J12gLJ5i/+8tsPRTlKKYs3x+uO+yU/tA0NTgt0qsE98scbENSsEMGBphEeZZIz/ALlmPdOqAWspNHDhAvzvDopLs/aQLjTJ8bXUrnpjbQ9eQ+8iVT+S27RqRoWR8= 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=pass 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 1681907022249920.2553929819367; Wed, 19 Apr 2023 05:23:42 -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-320-x_Z8GIZ3N3OSChEy2qRwdg-1; Wed, 19 Apr 2023 08:23:38 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 5CE701C08973; Wed, 19 Apr 2023 12:23:35 +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 44EC92166B44; Wed, 19 Apr 2023 12:23:35 +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 6889119465B3; Wed, 19 Apr 2023 12:23:34 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 8413719465A0 for ; Wed, 19 Apr 2023 12:05:06 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 67BFE492B05; Wed, 19 Apr 2023 12:05:06 +0000 (UTC) Received: from speedmetal.redhat.com (unknown [10.45.242.23]) by smtp.corp.redhat.com (Postfix) with ESMTP id D792B492B04 for ; Wed, 19 Apr 2023 12:05:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1681907021; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to: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=dSByu7q2Ebpuni7w8e78PAUecpqoyVJwg8mFKv8TKps=; b=XrU9FQIOHUVdlaBrTytqCMgl6ig/wRBD7gNedo2xvzpPWlRtcxc9Cu+Oan43340KFaa2Te HnjQNVMwHVwjLQMuCXhAB52J1tjP4vgF55tb3W4whfQbT1egPauXvdb0kqWjwvViiY4E+Y lUU5IBlFuFPCdvp0LzQ7buIj2jdrixA= X-MC-Unique: x_Z8GIZ3N3OSChEy2qRwdg-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH v3 25/25] qemu: Use configured iothread poll parameters on startup Date: Wed, 19 Apr 2023 14:04:42 +0200 Message-Id: <0eb1a9aa652c4f5b344840572a2f24aadbe962ef.1681905482.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.9 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: , Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 3.1 on 10.11.54.6 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: 1681907023608100001 Content-Type: text/plain; charset="utf-8" Implement the support for the persisted poll parameters and remove restrictions on saving config when modifying them during runtime. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/qemu/qemu_command.c | 18 +++++++++++ src/qemu/qemu_driver.c | 30 ++++++++++--------- ...othreads-ids-pool-sizes.x86_64-latest.args | 6 ++-- 3 files changed, 37 insertions(+), 17 deletions(-) diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index 4ca93bf3dc..f5b1971f07 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -7298,6 +7298,24 @@ qemuBuildIOThreadCommandLine(virCommand *cmd, NULL) < 0) return -1; + if (iothread->set_poll_max_ns && + virJSONValueObjectAdd(&props, + "U:poll-max-ns", iothread->poll_max_ns, + NULL) < 0) + return -1; + + if (iothread->set_poll_grow && + virJSONValueObjectAdd(&props, + "U:poll-grow", iothread->poll_grow, + NULL) < 0) + return -1; + + if (iothread->set_poll_shrink && + virJSONValueObjectAdd(&props, + "U:poll-shrink", iothread->poll_shrink, + NULL) < 0) + return -1; + if (qemuBuildObjectCommandlineFromJSON(cmd, props, qemuCaps) < 0) return -1; } diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index dafe8af8a6..1917e7e079 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -5067,23 +5067,30 @@ qemuDomainHotplugModIOThread(virDomainObj *vm, } -static int +static void qemuDomainHotplugModIOThreadIDDef(virDomainIOThreadIDDef *def, qemuMonitorIOThreadInfo mondef) { - /* These have no representation in domain XML */ - if (mondef.set_poll_grow || - mondef.set_poll_max_ns || - mondef.set_poll_shrink) - return -1; + if (mondef.set_poll_max_ns) { + def->poll_max_ns =3D mondef.poll_max_ns; + def->set_poll_max_ns =3D true; + } + + if (mondef.set_poll_grow) { + def->poll_grow =3D mondef.poll_grow; + def->set_poll_grow =3D true; + } + + if (mondef.set_poll_shrink) { + def->poll_shrink =3D mondef.poll_shrink; + def->set_poll_shrink =3D true; + } if (mondef.set_thread_pool_min) def->thread_pool_min =3D mondef.thread_pool_min; if (mondef.set_thread_pool_max) def->thread_pool_max =3D mondef.thread_pool_max; - - return 0; } @@ -5380,12 +5387,7 @@ qemuDomainChgIOThread(virQEMUDriver *driver, if (qemuDomainIOThreadValidate(iothreaddef, iothread, false) <= 0) goto endjob; - if (qemuDomainHotplugModIOThreadIDDef(iothreaddef, iothread) <= 0) { - virReportError(VIR_ERR_OPERATION_UNSUPPORTED, "%s", - _("configuring persistent polling values is= not supported")); - goto endjob; - } - + qemuDomainHotplugModIOThreadIDDef(iothreaddef, iothread); break; } } diff --git a/tests/qemuxml2argvdata/iothreads-ids-pool-sizes.x86_64-latest.= args b/tests/qemuxml2argvdata/iothreads-ids-pool-sizes.x86_64-latest.args index 4f5a11aab1..1422e94e35 100644 --- a/tests/qemuxml2argvdata/iothreads-ids-pool-sizes.x86_64-latest.args +++ b/tests/qemuxml2argvdata/iothreads-ids-pool-sizes.x86_64-latest.args @@ -18,9 +18,9 @@ XDG_CONFIG_HOME=3D/var/lib/libvirt/qemu/domain--1-QEMUGue= st1/.config \ -overcommit mem-lock=3Doff \ -smp 6,sockets=3D6,cores=3D1,threads=3D1 \ -object '{"qom-type":"iothread","id":"iothread2","thread-pool-min":0,"thre= ad-pool-max":60}' \ --object '{"qom-type":"iothread","id":"iothread4","thread-pool-min":1,"thre= ad-pool-max":1}' \ --object '{"qom-type":"iothread","id":"iothread1"}' \ --object '{"qom-type":"iothread","id":"iothread3"}' \ +-object '{"qom-type":"iothread","id":"iothread4","thread-pool-min":1,"thre= ad-pool-max":1,"poll-max-ns":123}' \ +-object '{"qom-type":"iothread","id":"iothread1","poll-grow":456,"poll-shr= ink":789}' \ +-object '{"qom-type":"iothread","id":"iothread3","poll-max-ns":123000,"pol= l-grow":456,"poll-shrink":789}' \ -object '{"qom-type":"iothread","id":"iothread5"}' \ -object '{"qom-type":"main-loop","id":"main-loop","thread-pool-min":8,"thr= ead-pool-max":16}' \ -uuid c7a5fdbd-edaf-9455-926a-d65c16db1809 \ --=20 2.39.2