From nobody Wed Mar 12 17:34:44 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 1741694405776306.75201395344584; Tue, 11 Mar 2025 05:00:05 -0700 (PDT) Received: by lists.libvirt.org (Postfix, from userid 996) id BB4971C69; Tue, 11 Mar 2025 08:00:04 -0400 (EDT) Received: from lists.libvirt.org (localhost [IPv6:::1]) by lists.libvirt.org (Postfix) with ESMTP id 971F21CD9; Tue, 11 Mar 2025 07:59:16 -0400 (EDT) Received: by lists.libvirt.org (Postfix, from userid 996) id A65C31BFF; Tue, 11 Mar 2025 07:59:12 -0400 (EDT) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.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 294961B9C for ; Tue, 11 Mar 2025 07:59:12 -0400 (EDT) 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-350-mFUEuK8BPAi959d4iFprsA-1; Tue, 11 Mar 2025 07:59:10 -0400 Received: from mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.40]) (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 16E2D1800266 for ; Tue, 11 Mar 2025 11:59:09 +0000 (UTC) Received: from speedmetal.lan (unknown [10.44.22.2]) by mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 1B2C619560AF for ; Tue, 11 Mar 2025 11:59:07 +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_H2,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=1741694351; 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=Dbhfx3XpsxBPt8eLm3dp6EaXrjeM1TTgJVzur6hRFHI=; b=AtNYVLoj4cxc3VbTaMnvtKuz/3NQzIxq6j3TZKSyaCzUtDEs0HZy8ywjG8jXrUynrl598t jQcT2+A4acwiUKFNC23Rp3lmzgbXPNgfALFabjy7KLlWPi/1JUClz9InVmvd6QDV94bq1u 5L1xxP1jFh85aNIAHceXZuVKBQXelvE= X-MC-Unique: mFUEuK8BPAi959d4iFprsA-1 X-Mimecast-MFC-AGG-ID: mFUEuK8BPAi959d4iFprsA_1741694349 From: Peter Krempa To: devel@lists.libvirt.org Subject: [PATCH 2/3] qemuDomainGetLaunchSecurityInfo: Use virTypedParamList to construct return value Date: Tue, 11 Mar 2025 12:59:02 +0100 Message-ID: <4b36d60fde66e200ea66cbc9bddf4929886bc458.1741694252.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.0 on 10.30.177.40 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: 82UpnRHsFmzdY5KdXhKO8f7rF7vJD-IdyU1PtaDUZ4s_1741694349 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Message-ID-Hash: IRB7PC5RRVLIH6FDKR7HWTPMIOCFKDCI X-Message-ID-Hash: IRB7PC5RRVLIH6FDKR7HWTPMIOCFKDCI 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: 1741694407289019100 Content-Type: text/plain; charset="utf-8" Simplify the code by using the modern helpers. Signed-off-by: Peter Krempa --- src/qemu/qemu_driver.c | 42 ++++++++++++++---------------------------- 1 file changed, 14 insertions(+), 28 deletions(-) diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index 45bb3c09aa..a40db1dd2e 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -18948,15 +18948,13 @@ qemuNodeGetSEVInfo(virConnectPtr conn, static int qemuDomainGetSEVInfo(virDomainObj *vm, - virTypedParameterPtr *params, - int *nparams, + virTypedParamList *list, unsigned int flags) { int ret =3D -1; int rv; g_autofree char *tmp =3D NULL; qemuMonitorSEVInfo info =3D { }; - int maxpar =3D 0; virCheckFlags(VIR_TYPED_PARAM_STRING_OKAY, -1); @@ -18981,36 +18979,20 @@ qemuDomainGetSEVInfo(virDomainObj *vm, if (rv < 0) goto endjob; - if (virTypedParamsAddString(params, nparams, &maxpar, - VIR_DOMAIN_LAUNCH_SECURITY_SEV_MEASUREMENT, - tmp) < 0) - goto endjob; - if (virTypedParamsAddUInt(params, nparams, &maxpar, - VIR_DOMAIN_LAUNCH_SECURITY_SEV_API_MAJOR, - info.apiMajor) < 0) - goto endjob; - if (virTypedParamsAddUInt(params, nparams, &maxpar, - VIR_DOMAIN_LAUNCH_SECURITY_SEV_API_MINOR, - info.apiMinor) < 0) - goto endjob; - if (virTypedParamsAddUInt(params, nparams, &maxpar, - VIR_DOMAIN_LAUNCH_SECURITY_SEV_BUILD_ID, - info.buildID) < 0) - goto endjob; + virTypedParamListAddString(list, tmp, VIR_DOMAIN_LAUNCH_SECURITY_SEV_M= EASUREMENT); + virTypedParamListAddUInt(list, info.apiMajor, VIR_DOMAIN_LAUNCH_SECURI= TY_SEV_API_MAJOR); + virTypedParamListAddUInt(list, info.apiMinor, VIR_DOMAIN_LAUNCH_SECURI= TY_SEV_API_MINOR); + virTypedParamListAddUInt(list, info.buildID, VIR_DOMAIN_LAUNCH_SECURIT= Y_SEV_BUILD_ID); switch (info.type) { case QEMU_MONITOR_SEV_GUEST_TYPE_SEV: - if (virTypedParamsAddUInt(params, nparams, &maxpar, - VIR_DOMAIN_LAUNCH_SECURITY_SEV_POLICY, - info.data.sev.policy) < 0) - goto endjob; + virTypedParamListAddUInt(list, info.data.sev.policy, + VIR_DOMAIN_LAUNCH_SECURITY_SEV_POLICY); break; case QEMU_MONITOR_SEV_GUEST_TYPE_SEV_SNP: - if (virTypedParamsAddULLong(params, nparams, &maxpar, - VIR_DOMAIN_LAUNCH_SECURITY_SEV_SNP_POL= ICY, - info.data.sev_snp.snp_policy) < 0) - goto endjob; + virTypedParamListAddULLong(list, info.data.sev_snp.snp_policy, + VIR_DOMAIN_LAUNCH_SECURITY_SEV_SNP_POLI= CY); break; case QEMU_MONITOR_SEV_GUEST_TYPE_LAST: @@ -19031,6 +19013,7 @@ qemuDomainGetLaunchSecurityInfo(virDomainPtr domain, int *nparams, unsigned int flags) { + g_autoptr(virTypedParamList) list =3D virTypedParamListNew(); virDomainObj *vm; int ret =3D -1; @@ -19048,7 +19031,7 @@ qemuDomainGetLaunchSecurityInfo(virDomainPtr domain, switch (vm->def->sec->sectype) { case VIR_DOMAIN_LAUNCH_SECURITY_SEV: case VIR_DOMAIN_LAUNCH_SECURITY_SEV_SNP: - if (qemuDomainGetSEVInfo(vm, params, nparams, flags) < 0) + if (qemuDomainGetSEVInfo(vm, list, flags) < 0) goto cleanup; break; case VIR_DOMAIN_LAUNCH_SECURITY_PV: @@ -19059,6 +19042,9 @@ qemuDomainGetLaunchSecurityInfo(virDomainPtr domain, goto cleanup; } + if (virTypedParamListSteal(list, params, nparams) < 0) + goto cleanup; + ret =3D 0; cleanup: --=20 2.48.1