From nobody Wed Mar 12 17:25:40 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 1740587601188816.1553832661411; Wed, 26 Feb 2025 08:33:21 -0800 (PST) Received: by lists.libvirt.org (Postfix, from userid 996) id 11447187F; Wed, 26 Feb 2025 11:33:20 -0500 (EST) Received: from lists.libvirt.org (localhost [IPv6:::1]) by lists.libvirt.org (Postfix) with ESMTP id 7133517E6; Wed, 26 Feb 2025 11:31:35 -0500 (EST) Received: by lists.libvirt.org (Postfix, from userid 996) id DB8F614B6; Wed, 26 Feb 2025 11:31:30 -0500 (EST) 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 AC5C31743 for ; Wed, 26 Feb 2025 11:31:22 -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-398-ia_sDGJOOjaoLav_E-nUPQ-1; Wed, 26 Feb 2025 11:31:20 -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 DE9461800876 for ; Wed, 26 Feb 2025 16:31:19 +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 1CAC0180035E for ; Wed, 26 Feb 2025 16:31:18 +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=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=FOVYpFF2QZD38AZs0mTJ5OoU1LryjYmjtGkwErUG8Os=; b=HuMymrXvZ/Bo78tZ64jOKD+Yy1WZD/eRLI1VbwkF/xsZGQtpmhqq0/FKdWg8egVdBS8rtM mzD75x8amUWKOg8rVMUzmgwPkGsi91Jfv8Xqyf+wMYaibWOX+pLE9X3cEnbViQXYxMo8P7 UdDMWM0kWhMR1dF/mK9KeZok3APOVvE= X-MC-Unique: ia_sDGJOOjaoLav_E-nUPQ-1 X-Mimecast-MFC-AGG-ID: ia_sDGJOOjaoLav_E-nUPQ_1740587480 From: Peter Krempa To: devel@lists.libvirt.org Subject: [PATCH 05/10] qemuAgentFSInfoFormatParams: Convert interface code to virTypedParamList Date: Wed, 26 Feb 2025 17:31:05 +0100 Message-ID: <4aca3382219aba546cb47d380c42de10b6d81d03.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: VwIcwCzFOZTAn3e3JQH0wt-x0xY3KiEMdmiHKL38qAY_1740587480 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Message-ID-Hash: 5VD6NQGLFTKJAVPZN6XQ35CW66YJSHE2 X-Message-ID-Hash: 5VD6NQGLFTKJAVPZN6XQ35CW66YJSHE2 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: 1740587603245019100 Content-Type: text/plain; charset="utf-8" Also remove stale TODO comment as we already report disk target. Signed-off-by: Peter Krempa --- src/qemu/qemu_driver.c | 86 +++++++++++------------------------------- 1 file changed, 23 insertions(+), 63 deletions(-) diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index 515577b71a..0d88f182b8 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -19265,59 +19265,32 @@ static void qemuAgentFSInfoFormatParams(qemuAgentFSInfo **fsinfo, int nfs, virDomainDef *vmdef, - virTypedParameterPtr *params, - int *nparams, int *maxparams) + virTypedParamList *list) { - size_t i, j; - - /* FIXME: get disk target */ + size_t i; - if (virTypedParamsAddUInt(params, nparams, maxparams, - "fs.count", nfs) < 0) - return; + virTypedParamListAddUInt(list, nfs, "fs.count"); for (i =3D 0; i < nfs; i++) { - char param_name[VIR_TYPED_PARAM_FIELD_LENGTH]; - g_snprintf(param_name, VIR_TYPED_PARAM_FIELD_LENGTH, - "fs.%zu.name", i); - if (virTypedParamsAddString(params, nparams, maxparams, - param_name, fsinfo[i]->name) < 0) - return; - g_snprintf(param_name, VIR_TYPED_PARAM_FIELD_LENGTH, - "fs.%zu.mountpoint", i); - if (virTypedParamsAddString(params, nparams, maxparams, - param_name, fsinfo[i]->mountpoint) < 0) - return; - g_snprintf(param_name, VIR_TYPED_PARAM_FIELD_LENGTH, - "fs.%zu.fstype", i); - if (virTypedParamsAddString(params, nparams, maxparams, - param_name, fsinfo[i]->fstype) < 0) - return; + size_t j; + + virTypedParamListAddString(list, fsinfo[i]->name, "fs.%zu.name", i= ); + virTypedParamListAddString(list, fsinfo[i]->mountpoint, "fs.%zu.mo= untpoint", i); + virTypedParamListAddString(list, fsinfo[i]->fstype, "fs.%zu.fstype= ", i); /* disk usage values are not returned by older guest agents, so * only add the params if the value is set */ - g_snprintf(param_name, VIR_TYPED_PARAM_FIELD_LENGTH, - "fs.%zu.total-bytes", i); - if (fsinfo[i]->total_bytes !=3D -1 && - virTypedParamsAddULLong(params, nparams, maxparams, - param_name, fsinfo[i]->total_bytes) < = 0) - return; + if (fsinfo[i]->total_bytes !=3D -1) + virTypedParamListAddULLong(list, fsinfo[i]->total_bytes, "fs.%= zu.total-bytes", i); + if (fsinfo[i]->used_bytes !=3D -1) + virTypedParamListAddULLong(list, fsinfo[i]->used_bytes, "fs.%z= u.used-bytes", i); - g_snprintf(param_name, VIR_TYPED_PARAM_FIELD_LENGTH, - "fs.%zu.used-bytes", i); - if (fsinfo[i]->used_bytes !=3D -1 && - virTypedParamsAddULLong(params, nparams, maxparams, - param_name, fsinfo[i]->used_bytes) < 0) - return; + virTypedParamListAddUInt(list, fsinfo[i]->ndisks, "fs.%zu.disk.cou= nt", i); - g_snprintf(param_name, VIR_TYPED_PARAM_FIELD_LENGTH, - "fs.%zu.disk.count", i); - if (virTypedParamsAddUInt(params, nparams, maxparams, - param_name, fsinfo[i]->ndisks) < 0) - return; for (j =3D 0; j < fsinfo[i]->ndisks; j++) { virDomainDiskDef *diskdef =3D NULL; qemuAgentDiskAddress *d =3D fsinfo[i]->disks[j]; + /* match the disk to the target in the vm definition */ diskdef =3D virDomainDiskByAddress(vmdef, &d->pci_controller, @@ -19325,28 +19298,15 @@ qemuAgentFSInfoFormatParams(qemuAgentFSInfo **fsi= nfo, d->bus, d->target, d->unit); - if (diskdef) { - g_snprintf(param_name, VIR_TYPED_PARAM_FIELD_LENGTH, - "fs.%zu.disk.%zu.alias", i, j); - if (diskdef->dst && - virTypedParamsAddString(params, nparams, maxparams, - param_name, diskdef->dst) < 0) - return; - } + if (diskdef && diskdef->dst) + virTypedParamListAddString(list, diskdef->dst, + "fs.%zu.disk.%zu.alias", i, j); + + if (d->serial) + virTypedParamListAddString(list, d->serial, "fs.%zu.disk.%= zu.serial", i, j); - g_snprintf(param_name, VIR_TYPED_PARAM_FIELD_LENGTH, - "fs.%zu.disk.%zu.serial", i, j); - if (d->serial && - virTypedParamsAddString(params, nparams, maxparams, - param_name, d->serial) < 0) - return; - - g_snprintf(param_name, VIR_TYPED_PARAM_FIELD_LENGTH, - "fs.%zu.disk.%zu.device", i, j); - if (d->devnode && - virTypedParamsAddString(params, nparams, maxparams, - param_name, d->devnode) < 0) - return; + if (d->devnode) + virTypedParamListAddString(list, d->devnode, "fs.%zu.disk.= %zu.device", i, j); } } } @@ -19504,7 +19464,7 @@ qemuDomainGetGuestInfo(virDomainPtr dom, /* we need to convert the agent fsinfo struct to parameters and ma= tch * it to the vm disk target */ if (nfs > 0) - qemuAgentFSInfoFormatParams(agentfsinfo, nfs, vm->def, params,= nparams, &maxparams); + qemuAgentFSInfoFormatParams(agentfsinfo, nfs, vm->def, list); if (ndisks > 0) qemuAgentDiskInfoFormatParams(agentdiskinfo, ndisks, vm->def, = list); --=20 2.48.1