From nobody Fri May 3 06:59:16 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=fail(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1564308319; cv=none; d=zoho.com; s=zohoarc; b=I3MKkvT635RhVvUpnBU7AEcjsBP8wkP5imG49kIvzR8RSzduaq4OaG06VItiTju/1za1twYBUZPr98gtCBD1Fmo+ApPVVhxu08Oqj+DejdY9Op3Z0z1sJHRBXKsn3hvAyhkt5cDhIoC1C8TJyO/0W+xfHGKVQButgsDOeIDyll0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1564308319; 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:ARC-Authentication-Results; bh=LGiH4cTLggaiJhu1NsHNUESYJ5ULye6FGE3i+xjoqLM=; b=HuFEL09JrXst8Dv+TU7jSOdiQEsK+1a5g2qvZ2XGzKTQoDCOB7VfH08Mh7DhpStNyI+tDA4ejij4BfuwJlox2fQVf/MuXGw88aK3P3GNA1gsE9L6xmQ7znXpd+8XXQTiCNrEgwwV02KMG2DQlirYT1sI/nI06WRYlqMIkPDl5ZA= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=fail; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1564308319150962.5130183588274; Sun, 28 Jul 2019 03:05:19 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 9B5B783F3E; Sun, 28 Jul 2019 10:05:17 +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 699C0600C0; Sun, 28 Jul 2019 10:05:17 +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 29C3341F53; Sun, 28 Jul 2019 10:05:17 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x6SA2i64028656 for ; Sun, 28 Jul 2019 06:02:44 -0400 Received: by smtp.corp.redhat.com (Postfix) id 5B79360C44; Sun, 28 Jul 2019 10:02:44 +0000 (UTC) Received: from mx1.redhat.com (ext-mx09.extmail.prod.ext.phx2.redhat.com [10.5.110.38]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 5687160BF1 for ; Sun, 28 Jul 2019 10:02:44 +0000 (UTC) Received: from mail-wm1-f66.google.com (mail-wm1-f66.google.com [209.85.128.66]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 26D0F335C2 for ; Sun, 28 Jul 2019 10:02:43 +0000 (UTC) Received: by mail-wm1-f66.google.com with SMTP id g67so46879900wme.1 for ; Sun, 28 Jul 2019 03:02:43 -0700 (PDT) Received: from archpc.localdomain (x8d1ee222.agdsn.tu-dresden.de. [141.30.226.34]) by smtp.gmail.com with ESMTPSA id g11sm58261923wru.24.2019.07.28.03.02.40 for (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Sun, 28 Jul 2019 03:02:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=Hyv2J4nYtiHOAqlCftBjBJrDx8zvTB/b3r73hcLR/wg=; b=FkFQodNQwdYpsBbCSsZYHmn8m40l4e2MQIGEFVC/S69l1T0vw0op/O8V/YeZTlYU/o AvNLKqOFN9fP8b1pYubBwodwZ8oqr8vCkd46fsFiLCccFCrTqsDv8HQFjenoFjtNOXUr O+G+gXVrJgHQ3QYgsclkJ2X2Mc3NpYNFcsbmZ+gDZdbDdVK/2VMBJI4uC0YWGalGRiiw fNJzd7/eXZ5K+UPZya/5iEOzPD+Lmp2/2pjwqIVyZY8oGyZe7ihNhfJutDK96xN3652O JSey6qznp+GGcq3tDYPn4wRX23i9X6/z41dwcpKIJIFUOo9eSuhkr1lVfF95To3AJkd5 4yXg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=Hyv2J4nYtiHOAqlCftBjBJrDx8zvTB/b3r73hcLR/wg=; b=nMoHcmCRFAvBpwe5/xdRMDGB7Zd8lw6Jei4BunhcUdEARfYxaPsHeFx7i99vMmhJaG BQT+fot+XByRJcgShpk4AcnrQ7tBYw1n/N278qIU7naF+YJAPSf6+yduBlP2ZQJj7wWA 05TwgldxcB6VV0udX5dzTDcNKq+Hava++lrM7X+JylxVE8l3Zj0aganNxVx1+EpRlpBc mJlRssVscB1qWdKr9VHV+rmMtToJawoaPImcKYMmjdX6M4E4qSoJny3FcYDzDHD5gBlH FU2RA6i8qy4rrVYAi0PfeSGPBi/k4a6k+vcNNuJHfQx3EmbWnu2EQpuT5DguC2Jdf6y1 X2Uw== X-Gm-Message-State: APjAAAXEK3b6JiObk4NZrxtm1rkKf3BJ3tBfkJ2uhfUYHWeg4OS+WM3F XF1oWDCSii5kamoAM0n59gA5dxsrDmfJOg== X-Google-Smtp-Source: APXvYqxxOyn+73FNhCI031a96zrskD/lZ9NFHIbJBn1oshaFYbHGhXUAOSewCpLntstUiaXiVbFuLQ== X-Received: by 2002:a1c:c78d:: with SMTP id x135mr87060935wmf.82.1564308161459; Sun, 28 Jul 2019 03:02:41 -0700 (PDT) From: Ilias Stamatis To: libvir-list@redhat.com Date: Sun, 28 Jul 2019 12:02:20 +0200 Message-Id: <20190728100221.2253-2-stamatis.iliass@gmail.com> In-Reply-To: <20190728100221.2253-1-stamatis.iliass@gmail.com> References: <20190728100221.2253-1-stamatis.iliass@gmail.com> MIME-Version: 1.0 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Sun, 28 Jul 2019 10:02:43 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Sun, 28 Jul 2019 10:02:43 +0000 (UTC) for IP:'209.85.128.66' DOMAIN:'mail-wm1-f66.google.com' HELO:'mail-wm1-f66.google.com' FROM:'stamatis.iliass@gmail.com' RCPT:'' X-RedHat-Spam-Score: -0.099 (DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, FREEMAIL_FROM, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS) 209.85.128.66 mail-wm1-f66.google.com 209.85.128.66 mail-wm1-f66.google.com X-Scanned-By: MIMEDefang 2.78 on 10.5.110.38 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH v2 1/2] tests: virsh-optparse: remove no longer valid cpu-stats test cases 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: , Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Sun, 28 Jul 2019 10:05:18 +0000 (UTC) X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" These test cases are no longer valid since this series provides an implementation of the virDomainGetCPUStats API for the test driver. Signed-off-by: Ilias Stamatis Reviewed-by: Erik Skultety --- tests/virsh-optparse | 20 -------------------- 1 file changed, 20 deletions(-) diff --git a/tests/virsh-optparse b/tests/virsh-optparse index 090d6c205c..d9c8f3c731 100755 --- a/tests/virsh-optparse +++ b/tests/virsh-optparse @@ -179,26 +179,6 @@ virsh -q -c $test_url cpu-stats test --start -1 >out 2= >err && fail=3D1 test -s out && fail=3D1 compare exp-err err || fail=3D1 -# Zero. The test driver doesn't support the operation so the command -# fails, but the value has been parsed correctly -cat <<\EOF > exp-err || framework_failure -error: Failed to retrieve CPU statistics for domain 'test' -error: this function is not supported by the connection driver: virDomainG= etCPUStats -EOF -virsh -q -c $test_url cpu-stats test --start 0 >out 2>err && fail=3D1 -test -s out && fail=3D1 -compare exp-err err || fail=3D1 - -# Valid numeric value. The test driver doesn't support the operation -# so the command fails, but the value has been parsed correctly -cat <<\EOF > exp-err || framework_failure -error: Failed to retrieve CPU statistics for domain 'test' -error: this function is not supported by the connection driver: virDomainG= etCPUStats -EOF -virsh -q -c $test_url cpu-stats test --start 42 >out 2>err && fail=3D1 -test -s out && fail=3D1 -compare exp-err err || fail=3D1 - ### Test a scaled numeric option # Non-numeric value -- 2.22.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Fri May 3 06:59:16 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=fail(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1564308265; cv=none; d=zoho.com; s=zohoarc; b=nMNhJguADDDIz+RtUpANmg0MNcyEij3BSBDpWGDiEVtj9gks9oNDOsnK8EvqhIFIGlbyqkHxFvrVD3IO/1HDZS6uDsOf84JUhyINjmW2j6PABpgXwgQHTEopTyEaoeglkHHtY5a8p3B1r7E7BPRDRia/uoyT/AzarpAHidCl8jw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1564308265; 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:ARC-Authentication-Results; bh=HlrsMldj50AjxSlRx/WHSoFsVCpst6/TrWxPTPrFokk=; b=FUmfAMRF7rPihO1zb3YYnwTLtrdmCJZx/jUBNSGjl7E9MBY47c+V1ZjOJoRq4NnmeJvy9XqedNYRwIByts39rTer+24HniISVihvxw1dzfAnr9Fb8vkEFYPiL1JGkzJuKZ1PwQaetQh33Xnq6/RPhKwFfm+zlWgm49y8wdcsf7U= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=fail; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1564308265465148.20677293791084; Sun, 28 Jul 2019 03:04:25 -0700 (PDT) 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 mx1.redhat.com (Postfix) with ESMTPS id C4EBE3082E91; Sun, 28 Jul 2019 10:04:23 +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 A10B460BF1; Sun, 28 Jul 2019 10:04:23 +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 6C87841F40; Sun, 28 Jul 2019 10:04:23 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x6SA3FxW028691 for ; Sun, 28 Jul 2019 06:03:15 -0400 Received: by smtp.corp.redhat.com (Postfix) id 2706F5DA97; Sun, 28 Jul 2019 10:03:15 +0000 (UTC) Received: from mx1.redhat.com (ext-mx11.extmail.prod.ext.phx2.redhat.com [10.5.110.40]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 21A676713C for ; Sun, 28 Jul 2019 10:03:12 +0000 (UTC) Received: from mail-wr1-f66.google.com (mail-wr1-f66.google.com [209.85.221.66]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 6676D30842A9 for ; Sun, 28 Jul 2019 10:03:11 +0000 (UTC) Received: by mail-wr1-f66.google.com with SMTP id r1so58667010wrl.7 for ; Sun, 28 Jul 2019 03:03:11 -0700 (PDT) Received: from archpc.localdomain (x8d1ee222.agdsn.tu-dresden.de. [141.30.226.34]) by smtp.gmail.com with ESMTPSA id g11sm58261923wru.24.2019.07.28.03.03.08 for (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Sun, 28 Jul 2019 03:03:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=xyKazQ7l3YtCrmiVXFSWcYLHDch0Ln1VdX6sK56XbxU=; b=BZoCd2hvUcUPJY9pQwLyAurW4P/GTEdAdvh/FV3eSsbBeC6V4U4x+zE/T+8aZMEWcw 59Hb0Ci07iCAWViHiDrFmS7EPtGHlBaUg6xwBqBYeYL6WhiTHLMuOpEarDSMULwA0Hwc D8xT8tRbrreLSzDtwpjwPB/jIRD3AkAEVM9atrqaaXlBLBTbjlqwkFVcxKFluMPyJSQI DVhTNNk+F7blhl3LtnSWB+5DY7xcfS402RAB/Zzdbp46Bpa2M56yl9eD50P4g5a3CAYT uMGb6mJKzj4qjLaNVng1FM8b8UXWCIH/zXZFvC2PoOqOG8ZW2+Yft56355TSVVC8Urkl e4oA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=xyKazQ7l3YtCrmiVXFSWcYLHDch0Ln1VdX6sK56XbxU=; b=UprF7EKTuekTS6cI12Gq07+KecSJDim8FvkbRIXooLeqEnijHieJibnBrsMtXSMVnS NxD+b+MbWUrcw5vP71ok/k5j0LIvrPjB7wfFDucb9q2dRtuZCCwom9qp/uN3uWyAZGkt mawhcLtQUY9mTVGBdzVhA43CLesdOipSfr/NVWSnB3E4Gpd6UUNrw5+jadhW3GIOMTdt diMW6PAP4AgjlkweIKsfJlD8pc36EvcphNuer1Orou5dKu5oj5e6OQXGrsdbjtiZzpfs 4obqCsqCyJnDSVNJdbDP6mhLaTLmBFVmf4XPQmh9b3K/CWHUpW+U2yhJn+0JfIIm4Pw2 a4uw== X-Gm-Message-State: APjAAAUEzxpHJSd36azCi9WkWKD4HN3PmQSvXAwsZf7LrSRDRWtyzdW0 oRca/ZqFYW/PtPdTK1KS4sec3bAXfIy2dg== X-Google-Smtp-Source: APXvYqwmlsdwkySexfmdjEi59gJ7T3iIVxVkOWoOmPeqroeiftYIUs8JBAjI1RCpBUfDPmEC+jTXXQ== X-Received: by 2002:a5d:408c:: with SMTP id o12mr17893990wrp.176.1564308189786; Sun, 28 Jul 2019 03:03:09 -0700 (PDT) From: Ilias Stamatis To: libvir-list@redhat.com Date: Sun, 28 Jul 2019 12:02:21 +0200 Message-Id: <20190728100221.2253-3-stamatis.iliass@gmail.com> In-Reply-To: <20190728100221.2253-1-stamatis.iliass@gmail.com> References: <20190728100221.2253-1-stamatis.iliass@gmail.com> MIME-Version: 1.0 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.40]); Sun, 28 Jul 2019 10:03:11 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.40]); Sun, 28 Jul 2019 10:03:11 +0000 (UTC) for IP:'209.85.221.66' DOMAIN:'mail-wr1-f66.google.com' HELO:'mail-wr1-f66.google.com' FROM:'stamatis.iliass@gmail.com' RCPT:'' X-RedHat-Spam-Score: -0.1 (DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, FREEMAIL_FROM, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_PASS) 209.85.221.66 mail-wr1-f66.google.com 209.85.221.66 mail-wr1-f66.google.com X-Scanned-By: MIMEDefang 2.84 on 10.5.110.40 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH v2 2/2] test_driver: implement virDomainGetCPUStats 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: , Content-Transfer-Encoding: quoted-printable 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-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.46]); Sun, 28 Jul 2019 10:04:24 +0000 (UTC) X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" Signed-off-by: Ilias Stamatis Reviewed-by: Erik Skultety --- src/test/test_driver.c | 132 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 132 insertions(+) diff --git a/src/test/test_driver.c b/src/test/test_driver.c index ab0f8b06d6..56f08fc3d2 100755 --- a/src/test/test_driver.c +++ b/src/test/test_driver.c @@ -3629,6 +3629,137 @@ static int testDomainSetMetadata(virDomainPtr dom, return ret; } +#define TEST_TOTAL_CPUTIME 48772617035 + +static int +testDomainGetDomainTotalCpuStats(virTypedParameterPtr params, + int nparams) +{ + if (nparams =3D=3D 0) /* return supported number of params */ + return 3; + + if (virTypedParameterAssign(¶ms[0], VIR_DOMAIN_CPU_STATS_CPUTIME, + VIR_TYPED_PARAM_ULLONG, TEST_TOTAL_CPUTIME= ) < 0) + return -1; + + if (nparams > 1 && + virTypedParameterAssign(¶ms[1], + VIR_DOMAIN_CPU_STATS_USERTIME, + VIR_TYPED_PARAM_ULLONG, 5540000000) < 0) + return -1; + + if (nparams > 2 && + virTypedParameterAssign(¶ms[2], + VIR_DOMAIN_CPU_STATS_SYSTEMTIME, + VIR_TYPED_PARAM_ULLONG, 6460000000) < 0) + return -1; + + if (nparams > 3) + nparams =3D 3; + + return nparams; +} + + +static int +testDomainGetPercpuStats(virTypedParameterPtr params, + unsigned int nparams, + int start_cpu, + unsigned int ncpus, + int total_cpus) +{ + size_t i; + int need_cpus; + int param_idx; + int ret =3D -1; + + /* return the number of supported params */ + if (nparams =3D=3D 0 && ncpus !=3D 0) + return 2; + + /* return total number of cpus */ + if (ncpus =3D=3D 0) { + ret =3D total_cpus; + goto cleanup; + } + + if (start_cpu >=3D total_cpus) { + virReportError(VIR_ERR_INVALID_ARG, + _("start_cpu %d larger than maximum of %d"), + start_cpu, total_cpus - 1); + goto cleanup; + } + + /* return percpu cputime in index 0 */ + param_idx =3D 0; + + /* number of cpus to compute */ + need_cpus =3D MIN(total_cpus, start_cpu + ncpus); + + for (i =3D 0; i < need_cpus; i++) { + if (i < start_cpu) + continue; + int idx =3D (i - start_cpu) * nparams + param_idx; + if (virTypedParameterAssign(¶ms[idx], + VIR_DOMAIN_CPU_STATS_CPUTIME, + VIR_TYPED_PARAM_ULLONG, + (TEST_TOTAL_CPUTIME / total_cpus) + i)= < 0) + goto cleanup; + } + + /* return percpu vcputime in index 1 */ + param_idx =3D 1; + + if (param_idx < nparams) { + for (i =3D start_cpu; i < need_cpus; i++) { + int idx =3D (i - start_cpu) * nparams + param_idx; + if (virTypedParameterAssign(¶ms[idx], + VIR_DOMAIN_CPU_STATS_VCPUTIME, + VIR_TYPED_PARAM_ULLONG, + (TEST_TOTAL_CPUTIME / total_cpus) = - 1234567890 + i) < 0) + goto cleanup; + } + param_idx++; + } + + ret =3D param_idx; + cleanup: + return ret; +} + + +static int +testDomainGetCPUStats(virDomainPtr dom, + virTypedParameterPtr params, + unsigned int nparams, + int start_cpu, + unsigned int ncpus, + unsigned int flags) +{ + virDomainObjPtr vm =3D NULL; + testDriverPtr privconn =3D dom->conn->privateData; + int ret =3D -1; + + virCheckFlags(VIR_TYPED_PARAM_STRING_OKAY, -1); + + if (!(vm =3D testDomObjFromDomain(dom))) + return -1; + + if (virDomainObjCheckActive(vm) < 0) + goto cleanup; + + if (start_cpu =3D=3D -1) + ret =3D testDomainGetDomainTotalCpuStats(params, nparams); + else + ret =3D testDomainGetPercpuStats(params, nparams, start_cpu, ncpus, + privconn->nodeInfo.cores); + + cleanup: + virDomainObjEndAPI(&vm); + return ret; +} + + static int testDomainSendProcessSignal(virDomainPtr dom, long long pid_value, @@ -8552,6 +8683,7 @@ static virHypervisorDriver testHypervisorDriver =3D { .domainSendKey =3D testDomainSendKey, /* 5.5.0 */ .domainGetMetadata =3D testDomainGetMetadata, /* 1.1.3 */ .domainSetMetadata =3D testDomainSetMetadata, /* 1.1.3 */ + .domainGetCPUStats =3D testDomainGetCPUStats, /* 5.6.0 */ .domainSendProcessSignal =3D testDomainSendProcessSignal, /* 5.5.0 */ .connectGetCPUModelNames =3D testConnectGetCPUModelNames, /* 1.1.3 */ .domainManagedSave =3D testDomainManagedSave, /* 1.1.4 */ -- 2.22.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list