From nobody Wed Mar 12 17:59:09 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.libvirt.org designates 8.43.85.245 as permitted sender) client-ip=8.43.85.245; envelope-from=devel-bounces@lists.libvirt.org; helo=lists.libvirt.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of lists.libvirt.org designates 8.43.85.245 as permitted sender) smtp.mailfrom=devel-bounces@lists.libvirt.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.libvirt.org (lists.libvirt.org [8.43.85.245]) by mx.zohomail.com with SMTPS id 1740587805373944.9455285944679; Wed, 26 Feb 2025 08:36:45 -0800 (PST) Received: by lists.libvirt.org (Postfix, from userid 996) id 3B51C1626; Wed, 26 Feb 2025 11:36:44 -0500 (EST) Received: from lists.libvirt.org (localhost [IPv6:::1]) by lists.libvirt.org (Postfix) with ESMTP id 4CF08176A; Wed, 26 Feb 2025 11:31:50 -0500 (EST) Received: by lists.libvirt.org (Postfix, from userid 996) id 2A96B1793; Wed, 26 Feb 2025 11:31:42 -0500 (EST) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by lists.libvirt.org (Postfix) with ESMTPS id 59AA11602 for ; Wed, 26 Feb 2025 11:31:25 -0500 (EST) Received: from mx-prod-mc-06.mail-002.prod.us-west-2.aws.redhat.com (ec2-35-165-154-97.us-west-2.compute.amazonaws.com [35.165.154.97]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-201-U7R0x1y5MWiZiZYwqR_JeA-1; Wed, 26 Feb 2025 11:31:23 -0500 Received: from mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.111]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 02CEE180087B for ; Wed, 26 Feb 2025 16:31:23 +0000 (UTC) Received: from speedmetal.lan (unknown [10.44.22.10]) by mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 33D131800949 for ; Wed, 26 Feb 2025 16:31:21 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on lists.libvirt.org X-Spam-Level: X-Spam-Status: No, score=-0.8 required=5.0 tests=DKIM_INVALID,DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H5,RCVD_IN_MSPIKE_WL,RCVD_IN_VALIDITY_RPBL_BLOCKED, RCVD_IN_VALIDITY_SAFE_BLOCKED,SPF_HELO_NONE autolearn=unavailable autolearn_force=no version=3.4.4 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1740587485; h=from:from: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; bh=r2RUWUXVyyTBfD79JKZ8ru51Y64bm0u4QKd+zBekID8=; b=UWR29VhFIPHOR2JceErslEd3BCVQzWsu5QQyK1wwaaArDtx/OGXTizmUTxFrhOxbMJ4cFJ CLGnFmr7bVJf1hRoffVOsuH8egEV+t/vK49kvRYOVHrO7IN+CirVGviHFwbCW4Wo2hhzX2 ZbqZgOUJ99qlqtrYA/micO6f68DqBSQ= X-MC-Unique: U7R0x1y5MWiZiZYwqR_JeA-1 X-Mimecast-MFC-AGG-ID: U7R0x1y5MWiZiZYwqR_JeA_1740587483 From: Peter Krempa To: devel@lists.libvirt.org Subject: [PATCH 07/10] qemuAgentGetOSInfo: Convert to virTypedParamList Date: Wed, 26 Feb 2025 17:31:07 +0100 Message-ID: <6b3f642da4a272a158a2b4383a7610dac7ad3fa1.1740586286.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.111 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: 3tDtuyibnGc8giKEd_e7y38KnA4HOQbx0v2lg8tsfQw_1740587483 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Message-ID-Hash: M6OVRUBCTCFGWZCOHZBHEKTPLEKJNAW6 X-Message-ID-Hash: M6OVRUBCTCFGWZCOHZBHEKTPLEKJNAW6 X-MailFrom: pkrempa@redhat.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-config-1; header-match-config-2; header-match-config-3; header-match-devel.lists.libvirt.org-0; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; suspicious-header X-Mailman-Version: 3.2.2 Precedence: list List-Id: Development discussions about the libvirt library & tools Archived-At: List-Archive: List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1740587805870019100 Content-Type: text/plain; charset="utf-8" Signed-off-by: Peter Krempa --- src/qemu/qemu_agent.c | 9 ++----- src/qemu/qemu_agent.h | 4 +--- src/qemu/qemu_driver.c | 2 +- tests/qemuagenttest.c | 54 ++++++++++++++++++++---------------------- 4 files changed, 30 insertions(+), 39 deletions(-) diff --git a/src/qemu/qemu_agent.c b/src/qemu/qemu_agent.c index e158b3d7ab..fcfe50dd9e 100644 --- a/src/qemu/qemu_agent.c +++ b/src/qemu/qemu_agent.c @@ -2257,9 +2257,7 @@ qemuAgentGetUsers(qemuAgent *agent, */ int qemuAgentGetOSInfo(qemuAgent *agent, - virTypedParameterPtr *params, - int *nparams, - int *maxparams, + virTypedParamList *list, bool report_unsupported) { g_autoptr(virJSONValue) cmd =3D NULL; @@ -2284,10 +2282,7 @@ qemuAgentGetOSInfo(qemuAgent *agent, do { \ const char *result; \ if ((result =3D virJSONValueObjectGetString(data, agent_string_)))= { \ - if (virTypedParamsAddString(params, nparams, maxparams, \ - param_string_, result) < 0) { \ - return -1; \ - } \ + virTypedParamListAddString(list, result, param_string_); \ } \ } while (0) OSINFO_ADD_PARAM("id", "os.id"); diff --git a/src/qemu/qemu_agent.h b/src/qemu/qemu_agent.h index 3f25f0e5a6..ac2c8506a2 100644 --- a/src/qemu/qemu_agent.h +++ b/src/qemu/qemu_agent.h @@ -163,9 +163,7 @@ int qemuAgentGetUsers(qemuAgent *mon, bool report_unsupported); int qemuAgentGetOSInfo(qemuAgent *mon, - virTypedParameterPtr *params, - int *nparams, - int *maxparams, + virTypedParamList *list, bool report_unsupported); int qemuAgentGetTimezone(qemuAgent *mon, diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index 53be46ce0a..201ac89de6 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -19404,7 +19404,7 @@ qemuDomainGetGuestInfo(virDomainPtr dom, goto exitagent; if (supportedTypes & VIR_DOMAIN_GUEST_INFO_OS && - qemuAgentGetOSInfo(agent, params, nparams, &maxparams, report_unsu= pported) =3D=3D -1) + qemuAgentGetOSInfo(agent, list, report_unsupported) =3D=3D -1) goto exitagent; if (supportedTypes & VIR_DOMAIN_GUEST_INFO_TIMEZONE && diff --git a/tests/qemuagenttest.c b/tests/qemuagenttest.c index 5fd4d70a70..93f88083fe 100644 --- a/tests/qemuagenttest.c +++ b/tests/qemuagenttest.c @@ -1191,30 +1191,31 @@ testQemuAgentOSInfo(const void *data) { virDomainXMLOption *xmlopt =3D (virDomainXMLOption *)data; g_autoptr(qemuMonitorTest) test =3D qemuMonitorTestNewAgent(xmlopt); - virTypedParameterPtr params =3D NULL; - int nparams =3D 0; - int maxparams =3D 0; - int ret =3D -1; + g_autoptr(virTypedParamList) list =3D virTypedParamListNew(); + virTypedParameterPtr params; + size_t nparams; if (!test) return -1; if (qemuMonitorTestAddAgentSyncResponse(test) < 0) - goto cleanup; + return -1; if (qemuMonitorTestAddItem(test, "guest-get-osinfo", testQemuAgentOSInfoResponse) < 0) - goto cleanup; + return -1; /* get osinfo */ - if (qemuAgentGetOSInfo(qemuMonitorTestGetAgent(test), - ¶ms, &nparams, &maxparams, true) < 0) - goto cleanup; + if (qemuAgentGetOSInfo(qemuMonitorTestGetAgent(test), list, true) < 0) + return -1; + + if (virTypedParamListFetch(list, ¶ms, &nparams) < 0) + return -1; if (nparams !=3D 8) { virReportError(VIR_ERR_INTERNAL_ERROR, - "Expected 8 params, got %d", nparams); - goto cleanup; + "Expected 8 params, got %zu", nparams); + return -1; } #define VALIDATE_PARAM(param_name_, expected_) \ do { \ @@ -1222,12 +1223,12 @@ testQemuAgentOSInfo(const void *data) if (virTypedParamsGetString(params, nparams, param_name_, &value_)= < 0 || \ value_ =3D=3D NULL) { \ virReportError(VIR_ERR_INTERNAL_ERROR, "missing param '%s'", p= aram_name_); \ - goto cleanup; \ + return -1; \ } \ if (STRNEQ(value_, expected_)) { \ virReportError(VIR_ERR_INTERNAL_ERROR, \ "Expected name '%s', got '%s'", expected_, valu= e_); \ - goto cleanup; \ + return -1; \ } \ } while (0) @@ -1239,24 +1240,25 @@ testQemuAgentOSInfo(const void *data) VALIDATE_PARAM("os.kernel-release", "3.10.0-862.14.4.el7.x86_64"); VALIDATE_PARAM("os.kernel-version", "#1 SMP Wed Sep 26 15:12:11 UTC 20= 18"); VALIDATE_PARAM("os.machine", "x86_64"); - virTypedParamsFree(params, nparams); - params =3D NULL; - nparams =3D 0; - maxparams =3D 0; + + g_clear_pointer(&list, virTypedParamListFree); + list =3D virTypedParamListNew(); if (qemuMonitorTestAddItem(test, "guest-get-osinfo", testQemuAgentOSInfoResponse2) < 0) - goto cleanup; + return -1; /* get users with domain */ - if (qemuAgentGetOSInfo(qemuMonitorTestGetAgent(test), - ¶ms, &nparams, &maxparams, true) < 0) - goto cleanup; + if (qemuAgentGetOSInfo(qemuMonitorTestGetAgent(test), list, true) < 0) + return -1; + + if (virTypedParamListFetch(list, ¶ms, &nparams) < 0) + return -1; if (nparams !=3D 10) { virReportError(VIR_ERR_INTERNAL_ERROR, - "Expected 10 params, got %d", nparams); - goto cleanup; + "Expected 10 params, got %zu", nparams); + return -1; } VALIDATE_PARAM("os.id", "mswindows"); @@ -1270,11 +1272,7 @@ testQemuAgentOSInfo(const void *data) VALIDATE_PARAM("os.kernel-version", "6.1"); VALIDATE_PARAM("os.machine", "x86_64"); - ret =3D 0; - - cleanup: - virTypedParamsFree(params, nparams); - return ret; + return 0; } static const char testQemuAgentTimezoneResponse1[] =3D --=20 2.48.1