From nobody Mon Feb 9 12:44:14 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 207.211.31.81 as permitted sender) client-ip=207.211.31.81; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 207.211.31.81 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=1574694185; cv=none; d=zohomail.com; s=zohoarc; b=BVwdVsGs6aQzj0y01UrAbH2C3pwoXyTQhxadvWEl7cbcF2I2rM6ldrr8ehxW+FPSB5S7MREGGX/ciXOMrCJHqXpfPoaigTcUBU4dhuQtshhva+tjR1WCfL2T5mPEmMv2XOZZda3QoIX4cgQnJnlkM/XrTb+Zx5k8dZZ7yryFqMQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1574694185; 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=AW1r6GdCcSnpKWPcmQa5EDFgC+2rcJlX3SKOg7BbVww=; b=YjsjMrzqzngw8meimVQ2CCPtY+hf1aXnR/EhmqxL1mWm7cjN8pF3WsIp2BTXCgmfytdH+QidQUIklUI0eJX+HZM1qJdkUFBC1Bn25rmQVKNCj79C2AcQkEsUowBcio3A0oqENfr+90AFlifYMnahToMhcqiUZJ/H5TitSNG1UM0= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 207.211.31.81 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-delivery-1.mimecast.com (us-smtp-2.mimecast.com [207.211.31.81]) by mx.zohomail.com with SMTPS id 157469418512599.21362846045974; Mon, 25 Nov 2019 07:03:05 -0800 (PST) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-150-A-L-oVRcMpCN-s2PswKEKg-1; Mon, 25 Nov 2019 10:02:06 -0500 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 5AF758A2E20; Mon, 25 Nov 2019 15:01:59 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id F3BA460C18; Mon, 25 Nov 2019 15:01:58 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id A2ABF41F02; Mon, 25 Nov 2019 15:01:58 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id xAPF1jVF021994 for ; Mon, 25 Nov 2019 10:01:45 -0500 Received: by smtp.corp.redhat.com (Postfix) id 1A7BD5D6AE; Mon, 25 Nov 2019 15:01:45 +0000 (UTC) Received: from angien.redhat.com (unknown [10.43.2.48]) by smtp.corp.redhat.com (Postfix) with ESMTP id 930905D6A0 for ; Mon, 25 Nov 2019 15:01:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1574694182; 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=AW1r6GdCcSnpKWPcmQa5EDFgC+2rcJlX3SKOg7BbVww=; b=U16xn9ZY6PE2WWlVBlVSriWzMb5fxM7gBPll66AufhN66wEFANjviNVB8r/IQrEhsq7rbn FATaX24IlgN4/yqISce58jnbOb+N1V9VjGletEhJvH+eG5nDnltzrT7z70oGetEu5Bf4c1 jYLnYeycd6HPMTYqMQ96b0zJMon1X9g= From: Peter Krempa To: libvir-list@redhat.com Date: Mon, 25 Nov 2019 16:01:28 +0100 Message-Id: <6a695bd599055a2d7ef9881d5b29b061839a54f6.1574693958.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 1/9] virsh: domain: Extract the code converting domain job stats to virDomainJobInfo X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-MC-Unique: A-L-oVRcMpCN-s2PswKEKg-1 X-Mimecast-Spam-Score: 0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" To simplify the stats printer code we convert the new statistics from the typed parameter list into the old stats structure. Extract this code since it takes a lot of space. Signed-off-by: Peter Krempa Reviewed-by: Eric Blake --- tools/virsh-domain.c | 72 +++++++++++++++++++++++--------------------- 1 file changed, 38 insertions(+), 34 deletions(-) diff --git a/tools/virsh-domain.c b/tools/virsh-domain.c index 6be9780836..99194c2f81 100644 --- a/tools/virsh-domain.c +++ b/tools/virsh-domain.c @@ -6065,6 +6065,42 @@ virshDomainJobOperationToString(int op) return str ? _(str) : _("unknown"); } + +static int +virshDomainJobStatsToDomainJobInfo(virTypedParameterPtr params, + int nparams, + virDomainJobInfo *info) +{ + if (virTypedParamsGetULLong(params, nparams, VIR_DOMAIN_JOB_TIME_ELAPS= ED, + &info->timeElapsed) < 0 || + virTypedParamsGetULLong(params, nparams, VIR_DOMAIN_JOB_TIME_REMAI= NING, + &info->timeRemaining) < 0 || + virTypedParamsGetULLong(params, nparams, VIR_DOMAIN_JOB_DATA_TOTAL, + &info->dataTotal) < 0 || + virTypedParamsGetULLong(params, nparams, VIR_DOMAIN_JOB_DATA_PROCE= SSED, + &info->dataProcessed) < 0 || + virTypedParamsGetULLong(params, nparams, VIR_DOMAIN_JOB_DATA_REMAI= NING, + &info->dataRemaining) < 0 || + virTypedParamsGetULLong(params, nparams, VIR_DOMAIN_JOB_MEMORY_TOT= AL, + &info->memTotal) < 0 || + virTypedParamsGetULLong(params, nparams, VIR_DOMAIN_JOB_MEMORY_PRO= CESSED, + &info->memProcessed) < 0 || + virTypedParamsGetULLong(params, nparams, VIR_DOMAIN_JOB_MEMORY_REM= AINING, + &info->memRemaining) < 0 || + virTypedParamsGetULLong(params, nparams, VIR_DOMAIN_JOB_DISK_TOTAL, + &info->fileTotal) < 0 || + virTypedParamsGetULLong(params, nparams, VIR_DOMAIN_JOB_DISK_PROCE= SSED, + &info->fileProcessed) < 0 || + virTypedParamsGetULLong(params, nparams, VIR_DOMAIN_JOB_DISK_REMAI= NING, + &info->fileRemaining) < 0) { + vshSaveLibvirtError(); + return -1; + } + + return 0; +} + + static bool cmdDomjobinfo(vshControl *ctl, const vshCmd *cmd) { @@ -6091,40 +6127,8 @@ cmdDomjobinfo(vshControl *ctl, const vshCmd *cmd) rc =3D virDomainGetJobStats(dom, &info.type, ¶ms, &nparams, flags); if (rc =3D=3D 0) { - if (virTypedParamsGetULLong(params, nparams, - VIR_DOMAIN_JOB_TIME_ELAPSED, - &info.timeElapsed) < 0 || - virTypedParamsGetULLong(params, nparams, - VIR_DOMAIN_JOB_TIME_REMAINING, - &info.timeRemaining) < 0 || - virTypedParamsGetULLong(params, nparams, - VIR_DOMAIN_JOB_DATA_TOTAL, - &info.dataTotal) < 0 || - virTypedParamsGetULLong(params, nparams, - VIR_DOMAIN_JOB_DATA_PROCESSED, - &info.dataProcessed) < 0 || - virTypedParamsGetULLong(params, nparams, - VIR_DOMAIN_JOB_DATA_REMAINING, - &info.dataRemaining) < 0 || - virTypedParamsGetULLong(params, nparams, - VIR_DOMAIN_JOB_MEMORY_TOTAL, - &info.memTotal) < 0 || - virTypedParamsGetULLong(params, nparams, - VIR_DOMAIN_JOB_MEMORY_PROCESSED, - &info.memProcessed) < 0 || - virTypedParamsGetULLong(params, nparams, - VIR_DOMAIN_JOB_MEMORY_REMAINING, - &info.memRemaining) < 0 || - virTypedParamsGetULLong(params, nparams, - VIR_DOMAIN_JOB_DISK_TOTAL, - &info.fileTotal) < 0 || - virTypedParamsGetULLong(params, nparams, - VIR_DOMAIN_JOB_DISK_PROCESSED, - &info.fileProcessed) < 0 || - virTypedParamsGetULLong(params, nparams, - VIR_DOMAIN_JOB_DISK_REMAINING, - &info.fileRemaining) < 0) - goto save_error; + if (virshDomainJobStatsToDomainJobInfo(params, nparams, &info) < 0) + goto cleanup; } else if (last_error->code =3D=3D VIR_ERR_NO_SUPPORT) { if (flags) { vshError(ctl, "%s", _("Optional flags are not supported by the= " --=20 2.23.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list