From nobody Wed Mar 12 17:15:00 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 1740587624972810.994273113386; Wed, 26 Feb 2025 08:33:44 -0800 (PST) Received: by lists.libvirt.org (Postfix, from userid 996) id EAD0517EC; Wed, 26 Feb 2025 11:33:43 -0500 (EST) Received: from lists.libvirt.org (localhost [IPv6:::1]) by lists.libvirt.org (Postfix) with ESMTP id 28E47170F; Wed, 26 Feb 2025 11:31:37 -0500 (EST) Received: by lists.libvirt.org (Postfix, from userid 996) id B24451572; Wed, 26 Feb 2025 11:31:31 -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 1A8EC1776 for ; Wed, 26 Feb 2025 11:31:23 -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-159-ia1pL7dFPhaLtQnQGOY2sw-1; Wed, 26 Feb 2025 11:31:19 -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 86ADE180034E for ; Wed, 26 Feb 2025 16:31:18 +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 B9093180087F for ; Wed, 26 Feb 2025 16:31:17 +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=1740587482; 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=+YF7GgT9wI0eHfrFYMYJ/SxML/tzSlxWg3RWg8np8Tw=; b=LL/vBl6fM0ZsxfWPgudZTB9mm8T/WAQgbkccU7qK8BRTcaTOWSQqhb+QRBYpXcJJSxvghA xdn1eG/lIjGPGp2llDPdSVsOTIPJpbBRIecoaqcIdINqC7X1Q31LAk3VcGUQTA/zFloweA My/u0yQTPV0Up+iUZltSe+QpvShy4jo= X-MC-Unique: ia1pL7dFPhaLtQnQGOY2sw-1 X-Mimecast-MFC-AGG-ID: ia1pL7dFPhaLtQnQGOY2sw_1740587478 From: Peter Krempa To: devel@lists.libvirt.org Subject: [PATCH 04/10] qemuAgentDiskInfoFormatParams: Convert interface code to virTypedParamList Date: Wed, 26 Feb 2025 17:31:04 +0100 Message-ID: <49e465984744ccf112344f683e0d6ebbd8161c1e.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: JUDYipiQhtpFP5gtUBJghQboXeo6p-FPpkU_seN26m4_1740587478 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Message-ID-Hash: W5RQBOQWZUZMTD56K5FTRYYTEQTD56IN X-Message-ID-Hash: W5RQBOQWZUZMTD56K5FTRYYTEQTD56IN 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: 1740587627284019100 Content-Type: text/plain; charset="utf-8" Signed-off-by: Peter Krempa --- src/qemu/qemu_driver.c | 81 +++++++++++------------------------------- 1 file changed, 21 insertions(+), 60 deletions(-) diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index 3ebc712f9a..515577b71a 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -19210,44 +19210,26 @@ static void qemuAgentDiskInfoFormatParams(qemuAgentDiskInfo **info, int ndisks, virDomainDef *vmdef, - virTypedParameterPtr *params, - int *nparams, int *maxparams) + virTypedParamList *list) { - size_t i, j, ndeps; + size_t i; - if (virTypedParamsAddUInt(params, nparams, maxparams, - "disk.count", ndisks) < 0) - return; + virTypedParamListAddUInt(list, ndisks, "disk.count"); for (i =3D 0; i < ndisks; i++) { - char param_name[VIR_TYPED_PARAM_FIELD_LENGTH]; + virTypedParamListAddString(list, info[i]->name, "disk.%zu.name", i= ); + virTypedParamListAddBoolean(list, info[i]->partition, "disk.%zu.pa= rtition", i); - g_snprintf(param_name, VIR_TYPED_PARAM_FIELD_LENGTH, - "disk.%zu.name", i); - if (virTypedParamsAddString(params, nparams, maxparams, - param_name, info[i]->name) < 0) - return; + if (info[i]->dependencies) { + size_t ndeps =3D g_strv_length(info[i]->dependencies); + size_t j; - g_snprintf(param_name, VIR_TYPED_PARAM_FIELD_LENGTH, - "disk.%zu.partition", i); - if (virTypedParamsAddBoolean(params, nparams, maxparams, - param_name, info[i]->partition) < 0) - return; + if (ndeps > 0) + virTypedParamListAddUInt(list, ndeps, "disk.%zu.dependency= .count", i); - if (info[i]->dependencies) { - ndeps =3D g_strv_length(info[i]->dependencies); - g_snprintf(param_name, VIR_TYPED_PARAM_FIELD_LENGTH, - "disk.%zu.dependency.count", i); - if (ndeps && - virTypedParamsAddUInt(params, nparams, maxparams, - param_name, ndeps) < 0) - return; for (j =3D 0; j < ndeps; j++) { - g_snprintf(param_name, VIR_TYPED_PARAM_FIELD_LENGTH, - "disk.%zu.dependency.%zu.name", i, j); - if (virTypedParamsAddString(params, nparams, maxparams, - param_name, info[i]->dependenc= ies[j]) < 0) - return; + virTypedParamListAddString(list, info[i]->dependencies[j], + "disk.%zu.dependency.%zu.name",= i, j); } } @@ -19255,13 +19237,8 @@ qemuAgentDiskInfoFormatParams(qemuAgentDiskInfo **= info, qemuAgentDiskAddress *address =3D info[i]->address; virDomainDiskDef *diskdef =3D NULL; - if (address->serial) { - g_snprintf(param_name, VIR_TYPED_PARAM_FIELD_LENGTH, - "disk.%zu.serial", i); - if (virTypedParamsAddString(params, nparams, maxparams, - param_name, address->serial) <= 0) - return; - } + if (address->serial) + virTypedParamListAddString(list, address->serial, "disk.%z= u.serial", i); /* match the disk to the target in the vm definition */ diskdef =3D virDomainDiskByAddress(vmdef, @@ -19270,32 +19247,16 @@ qemuAgentDiskInfoFormatParams(qemuAgentDiskInfo *= *info, address->bus, address->target, address->unit); - if (diskdef) { - g_snprintf(param_name, VIR_TYPED_PARAM_FIELD_LENGTH, - "disk.%zu.alias", i); - if (diskdef->dst && - virTypedParamsAddString(params, nparams, maxparams, - param_name, diskdef->dst) < 0) - return; - } - if (address->bus_type) { - g_snprintf(param_name, VIR_TYPED_PARAM_FIELD_LENGTH, - "disk.%zu.guest_bus", i); + if (diskdef && diskdef->dst) + virTypedParamListAddString(list, diskdef->dst, "disk.%zu.a= lias", i); - if (virTypedParamsAddString(params, nparams, maxparams, - param_name, address->bus_type)= < 0) - return; - } + if (address->bus_type) + virTypedParamListAddString(list, address->bus_type, "disk.= %zu.guest_bus", i); } - if (info[i]->alias) { - g_snprintf(param_name, VIR_TYPED_PARAM_FIELD_LENGTH, - "disk.%zu.guest_alias", i); - if (virTypedParamsAddString(params, nparams, maxparams, - param_name, info[i]->alias) < 0) - return; - } + if (info[i]->alias) + virTypedParamListAddString(list, info[i]->alias, "disk.%zu.gue= st_alias", i); } } @@ -19546,7 +19507,7 @@ qemuDomainGetGuestInfo(virDomainPtr dom, qemuAgentFSInfoFormatParams(agentfsinfo, nfs, vm->def, params,= nparams, &maxparams); if (ndisks > 0) - qemuAgentDiskInfoFormatParams(agentdiskinfo, ndisks, vm->def, = params, nparams, &maxparams); + qemuAgentDiskInfoFormatParams(agentdiskinfo, ndisks, vm->def, = list); endjob: virDomainObjEndJob(vm); --=20 2.48.1