From nobody Thu Apr 18 14:32:57 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 Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1552337797193356.9845576558304; Mon, 11 Mar 2019 13:56:37 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 783D4307E059; Mon, 11 Mar 2019 20:56:34 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 57C485DD74; Mon, 11 Mar 2019 20:56:32 +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 1A81F181A136; Mon, 11 Mar 2019 20:56:30 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x2BKuS3o021790 for ; Mon, 11 Mar 2019 16:56:29 -0400 Received: by smtp.corp.redhat.com (Postfix) id F0EA519739; Mon, 11 Mar 2019 20:56:28 +0000 (UTC) Received: from mx1.redhat.com (ext-mx17.extmail.prod.ext.phx2.redhat.com [10.5.110.46]) by smtp.corp.redhat.com (Postfix) with ESMTPS id EB56619743 for ; Mon, 11 Mar 2019 20:56:26 +0000 (UTC) Received: from mail-qt1-f196.google.com (mail-qt1-f196.google.com [209.85.160.196]) (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 6C69A3082D9E for ; Mon, 11 Mar 2019 20:56:25 +0000 (UTC) Received: by mail-qt1-f196.google.com with SMTP id x20so224646qto.1 for ; Mon, 11 Mar 2019 13:56:25 -0700 (PDT) Received: from localhost.localdomain ([2804:431:b704:983c:4497:62af:9e84:1841]) by smtp.gmail.com with ESMTPSA id w1sm4329157qtc.75.2019.03.11.13.56.23 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 11 Mar 2019 13:56:23 -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=WsVlAR0pO5a42Af1n7p0F2S5J4GKgEoSh5pXgaVX244=; b=D/71HBUC9qD6Z+sgdC5UWM1jj6IxUm8sQ6+iJ6XKzSt3SgN1oOKgdI0VAPyaIef7fq FOjdgwUuwsxucWsr1mBP5ntNuDCro/AYEwumGJTG9np+g9Wo1u4CzUmiNZVSzifilWUH bhKe0jrEHEULjbpEfvqZOw1OlkO6XJJjd4M92r8+Wn++TpGc08JfZ7ifWvi0//jvZyzr Nslm8vjSQg4f1AsM3Uk6rlxKTbuAHan+9+o4MN5ecNubHpKQQBMQjYXoaYv68tlGc5L/ PkE00fx5JLW1Ckd/ZhkdVEXi7F7oUpUYvoLUGvDuwnHuZpGw1HOIeTCc4m0G84dp1PDg Qa7w== 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=WsVlAR0pO5a42Af1n7p0F2S5J4GKgEoSh5pXgaVX244=; b=IZIw9CucPpJD3TF5yo18+//8Xey2+QS6pmmbHbDZZ15L5Kvd2YmaiGiHWCVZ17xEqF KWVUt4zEjzqwvuOZ5w5MT7Nzfye63OsQhBbCZdTOZevMM6fBQAZ/PGmH/ip8LYCV6BLi GEVkumndwogZmv7nCQ3BBrmA7PVwfzqYZIjzUINzW0TjLsLSBEkVLBQjzuR/lk/C36a7 FUXPGnw2K2W/xmxioz01Sq5ewWh5I3nK1Z17OYn8aFpHaZJEH6z+nELMlRUuknc9wjho jPzrkwRySoMY26+SBJPNQFU+YiI0KIag0JD/XBMLP5CLrXoWvnEMy2c5StcF0JaxUdTl YXGw== X-Gm-Message-State: APjAAAUPEngzRlUykhgGVnpjUrcY9nCW2eeMguv94iBWe89O8CU014jz FiUjCnKdyDt+/5Vz3x4GSSc6Pp65 X-Google-Smtp-Source: APXvYqxIFHd1EHkv9ebi0gaDYSP1QRStfEbCE3sgvOB8N+Q/oVF+nf8FRadNBri1rKghnN2k+iLCGA== X-Received: by 2002:aed:3947:: with SMTP id l65mr25714581qte.86.1552337784244; Mon, 11 Mar 2019 13:56:24 -0700 (PDT) From: Julio Faracco To: libvir-list@redhat.com Date: Mon, 11 Mar 2019 17:56:13 -0300 Message-Id: <20190311205618.6588-2-jcfaracco@gmail.com> In-Reply-To: <20190311205618.6588-1-jcfaracco@gmail.com> References: <20190311205618.6588-1-jcfaracco@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.46]); Mon, 11 Mar 2019 20:56:25 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.46]); Mon, 11 Mar 2019 20:56:25 +0000 (UTC) for IP:'209.85.160.196' DOMAIN:'mail-qt1-f196.google.com' HELO:'mail-qt1-f196.google.com' FROM:'jcfaracco@gmail.com' RCPT:'' X-RedHat-Spam-Score: -0.13 (DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, FREEMAIL_FROM, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, SPF_PASS) 209.85.160.196 mail-qt1-f196.google.com 209.85.160.196 mail-qt1-f196.google.com X-Scanned-By: MIMEDefang 2.84 on 10.5.110.46 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 1/6] lxc: Introduce method lxcConnectGetAllDomainStats(). 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.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.42]); Mon, 11 Mar 2019 20:56:35 +0000 (UTC) X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" This is an implementation of method used by driver to retrieve stats from all domain. Right now, this is a simple implementation considering only State, CPU, Disks and Balloon. Signed-off-by: Julio Faracco --- src/lxc/lxc_driver.c | 83 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 83 insertions(+) diff --git a/src/lxc/lxc_driver.c b/src/lxc/lxc_driver.c index 760f9f8bdf..1ab6179572 100644 --- a/src/lxc/lxc_driver.c +++ b/src/lxc/lxc_driver.c @@ -5277,6 +5277,88 @@ lxcDomainGetMetadata(virDomainPtr dom, return ret; } =20 +static int +lxcConnectGetAllDomainStats(virConnectPtr conn, + virDomainPtr *doms, + unsigned int ndoms, + unsigned int stats, + virDomainStatsRecordPtr **retStats, + unsigned int flags) +{ + virLXCDriverPtr driver =3D conn->privateData; + virDomainObjPtr *vms =3D NULL; + virDomainObjPtr vm; + size_t nvms; + virDomainStatsRecordPtr *tmpstats =3D NULL; + int nstats =3D 0; + size_t i; + int ret =3D -1; + unsigned int lflags =3D flags & (VIR_CONNECT_LIST_DOMAINS_FILTERS_ACTI= VE | + VIR_CONNECT_LIST_DOMAINS_FILTERS_PERSIS= TENT | + VIR_CONNECT_LIST_DOMAINS_FILTERS_STATE); + unsigned int supported =3D VIR_DOMAIN_STATS_STATE | + VIR_DOMAIN_STATS_CPU_TOTAL | + VIR_DOMAIN_STATS_BLOCK | + VIR_DOMAIN_STATS_BALLOON; + + virCheckFlags(VIR_CONNECT_LIST_DOMAINS_FILTERS_ACTIVE | + VIR_CONNECT_LIST_DOMAINS_FILTERS_PERSISTENT | + VIR_CONNECT_LIST_DOMAINS_FILTERS_STATE | + VIR_CONNECT_GET_ALL_DOMAINS_STATS_ENFORCE_STATS, -1); + + if (virConnectGetAllDomainStatsEnsureACL(conn) < 0) + return -1; + + if (!stats) { + stats =3D supported; + } else if ((flags & VIR_CONNECT_GET_ALL_DOMAINS_STATS_ENFORCE_STATS) && + (stats & ~supported)) { + virReportError(VIR_ERR_ARGUMENT_UNSUPPORTED, + _("Stats types bits 0x%x are not supported by this = daemon"), + stats & ~supported); + return -1; + } + + if (ndoms) { + if (virDomainObjListConvert(driver->domains, conn, doms, ndoms, &v= ms, + &nvms, virConnectGetAllDomainStatsChec= kACL, + lflags, true) < 0) + return -1; + } else { + if (virDomainObjListCollect(driver->domains, conn, &vms, &nvms, + virConnectGetAllDomainStatsCheckACL, + lflags) < 0) + return -1; + } + + if (VIR_ALLOC_N(tmpstats, ndoms + 1) < 0) + goto cleanup; + + for (i =3D 0; i < nvms; i++) { + virDomainStatsRecordPtr tmp; + vm =3D vms[i]; + + virObjectLock(vm); + tmp =3D lxcDomainGetStats(conn, vm); + virObjectUnlock(vm); + + if (!tmp) + goto cleanup; + + tmpstats[nstats++] =3D tmp; + + } + + *retStats =3D tmpstats; + tmpstats =3D NULL; + ret =3D nstats; + + cleanup: + virDomainStatsRecordListFree(tmpstats); + virObjectListFreeCount(vms, nvms); + + return ret; +} =20 static int lxcDomainGetCPUStats(virDomainPtr dom, @@ -5448,6 +5530,7 @@ static virHypervisorDriver lxcHypervisorDriver =3D { .domainMemoryStats =3D lxcDomainMemoryStats, /* 1.2.2 */ .nodeGetCPUStats =3D lxcNodeGetCPUStats, /* 0.9.3 */ .nodeGetMemoryStats =3D lxcNodeGetMemoryStats, /* 0.9.3 */ + .connectGetAllDomainStats =3D lxcConnectGetAllDomainStats, /* 5.1.0 */ .nodeGetCellsFreeMemory =3D lxcNodeGetCellsFreeMemory, /* 0.6.5 */ .nodeGetFreeMemory =3D lxcNodeGetFreeMemory, /* 0.6.5 */ .nodeGetCPUMap =3D lxcNodeGetCPUMap, /* 1.0.0 */ --=20 2.19.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Thu Apr 18 14:32:57 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 Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1552337858664522.161060315454; Mon, 11 Mar 2019 13:57:38 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 4CE21356DB; Mon, 11 Mar 2019 20:57:36 +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 239FC5C553; Mon, 11 Mar 2019 20:57:36 +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 E0A8341F3E; Mon, 11 Mar 2019 20:57:35 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x2BKuTtQ021800 for ; Mon, 11 Mar 2019 16:56:29 -0400 Received: by smtp.corp.redhat.com (Postfix) id 6BC166013D; Mon, 11 Mar 2019 20:56:29 +0000 (UTC) Received: from mx1.redhat.com (ext-mx19.extmail.prod.ext.phx2.redhat.com [10.5.110.48]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 6358B600CD for ; Mon, 11 Mar 2019 20:56:27 +0000 (UTC) Received: from mail-qk1-f196.google.com (mail-qk1-f196.google.com [209.85.222.196]) (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 AEEF4307D842 for ; Mon, 11 Mar 2019 20:56:26 +0000 (UTC) Received: by mail-qk1-f196.google.com with SMTP id h28so154708qkk.7 for ; Mon, 11 Mar 2019 13:56:26 -0700 (PDT) Received: from localhost.localdomain ([2804:431:b704:983c:4497:62af:9e84:1841]) by smtp.gmail.com with ESMTPSA id w1sm4329157qtc.75.2019.03.11.13.56.24 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 11 Mar 2019 13:56:25 -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=FTSNumeDWMKKTvpHPIKHeXOCrqHXfnOa1EP4ukbNIGI=; b=gVcv2CIOjaOociwS46cZiJBRpUVBy6wanUgjDVqr1NH2jIZl7fNVcdqGpFt2Jjs56R o9uAFp1P4JVqXhxNGNAqKdsgJRbdgI63eGDezc3/Y6bOeVukkxcDYnuV0xvCpWTEN8Hh w04lzg/WQzppc8vDdqj9Tcc5EzeodfApCAD440pgH3UXsJXO3QY1LM1DmbI8jzMYwHVz Idi44S3XaF0oakp7lFOm+sKGndecst9p8W0pbwVTr8WkfR4d7ubXTLw7zTRPRAHQkw67 EI7bZlASp4T6mhectVnk5eZonEZ5XKVSnBrjeKJV6ofQoPox5Wze/W1eOX4qHoplt2Uw IeEg== 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=FTSNumeDWMKKTvpHPIKHeXOCrqHXfnOa1EP4ukbNIGI=; b=sWFmaqFEBbwrlur1koIiGNT8VOAEST9cs1+j0crNsp1hUrBt8uXBV4qfbiaiGnhnXI ufEOzOXe16mdpH2TK3ChmR3Rf0usBBNxiQTtBtShnXiZ/yrUxliEcT6kJCmcVzBtXHOV ym1elByEafoFyxn1JttEe+Z1jEkFn0wDVknBJM1QRPOkpt8JwS04Z9z8YxgfpdC16joI iLEzUy2ljVovOgKAhKy/C4R6AW2u5KnCvBm/QDfeubjFcK7fGG3fPwMyF1T2c52kt9pk HHwhFobzHk5/UAqCYjkb+894JQWQkwMq1aeezPkn4gA6TO1unBwajTR0Vg3N5rp/cWos 2wwA== X-Gm-Message-State: APjAAAUVVqP9poYXqSHaYWnMtjtSVBIb33clk7hrhx2tm2OnFv5M0X1b dOs9XQ1QxMdS96eDsvk8Lf2GuSJC X-Google-Smtp-Source: APXvYqyFHq2QyU135aV0D/oHdZSA7Xh6eCkJBHw2ulYIWHv1sxKnwCvF1lAwxazmbFALdLLYyxlk0A== X-Received: by 2002:a37:d685:: with SMTP id p5mr6505816qkl.329.1552337785646; Mon, 11 Mar 2019 13:56:25 -0700 (PDT) From: Julio Faracco To: libvir-list@redhat.com Date: Mon, 11 Mar 2019 17:56:14 -0300 Message-Id: <20190311205618.6588-3-jcfaracco@gmail.com> In-Reply-To: <20190311205618.6588-1-jcfaracco@gmail.com> References: <20190311205618.6588-1-jcfaracco@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.48]); Mon, 11 Mar 2019 20:56:26 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.48]); Mon, 11 Mar 2019 20:56:26 +0000 (UTC) for IP:'209.85.222.196' DOMAIN:'mail-qk1-f196.google.com' HELO:'mail-qk1-f196.google.com' FROM:'jcfaracco@gmail.com' RCPT:'' X-RedHat-Spam-Score: -0.111 (DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, FREEMAIL_FROM, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_PASS) 209.85.222.196 mail-qk1-f196.google.com 209.85.222.196 mail-qk1-f196.google.com X-Scanned-By: MIMEDefang 2.84 on 10.5.110.48 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 2/6] lxc: Introduce method lxcDomainGetStats(). 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.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.30]); Mon, 11 Mar 2019 20:57:37 +0000 (UTC) X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" This method is responsible to fetch data like State, CPU, Disk and Balloon info (all single domain info) from each domain 'virDomainObjPtr'. Signed-off-by: Julio Faracco --- src/lxc/lxc_driver.c | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) diff --git a/src/lxc/lxc_driver.c b/src/lxc/lxc_driver.c index 1ab6179572..72639e0d7d 100644 --- a/src/lxc/lxc_driver.c +++ b/src/lxc/lxc_driver.c @@ -5277,6 +5277,48 @@ lxcDomainGetMetadata(virDomainPtr dom, return ret; } =20 +static virDomainStatsRecordPtr +lxcDomainGetStats(virConnectPtr conn, + virDomainObjPtr dom) +{ + virLXCDriverPtr driver =3D conn->privateData; + virDomainStatsRecordPtr stat; + int maxparams =3D 0; + + if (VIR_ALLOC(stat) < 0) + return NULL; + + if (!(stat->dom =3D virGetDomain(conn, dom->def->name, dom->def->uuid,= dom->def->id))) + goto error; + + if (virLXCDomainObjBeginJob(driver, dom, LXC_JOB_QUERY) < 0) + goto error; + + if (lxcDomainGetStatsState(dom, stat, &maxparams) < 0) + goto endjob; + + if (lxcDomainGetStatsCpu(dom, stat, &maxparams) < 0) + goto endjob; + + if (lxcDomainGetBlockStats(dom, stat, &maxparams) < 0) + goto endjob; + + if (lxcDomainGetBalloonStats(dom, stat, &maxparams) < 0) + goto endjob; + + virLXCDomainObjEndJob(driver, dom); + return stat; + + endjob: + virLXCDomainObjEndJob(driver, dom); + + error: + virTypedParamsFree(stat->params, stat->nparams); + virObjectUnref(stat->dom); + VIR_FREE(stat); + return NULL; +} + static int lxcConnectGetAllDomainStats(virConnectPtr conn, virDomainPtr *doms, --=20 2.19.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Thu Apr 18 14:32:57 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 Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1552337923849900.7979848330814; Mon, 11 Mar 2019 13:58:43 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id BDB54307E066; Mon, 11 Mar 2019 20:58:41 +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 926611001E6E; Mon, 11 Mar 2019 20:58:41 +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 57FAC131F9; Mon, 11 Mar 2019 20:58:41 +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 x2BKuYbW021844 for ; Mon, 11 Mar 2019 16:56:34 -0400 Received: by smtp.corp.redhat.com (Postfix) id 3B3CA60C55; Mon, 11 Mar 2019 20:56:34 +0000 (UTC) Received: from mx1.redhat.com (ext-mx04.extmail.prod.ext.phx2.redhat.com [10.5.110.28]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 35EF160BF1 for ; Mon, 11 Mar 2019 20:56:29 +0000 (UTC) Received: from mail-qt1-f193.google.com (mail-qt1-f193.google.com [209.85.160.193]) (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 73F7D8830F for ; Mon, 11 Mar 2019 20:56:28 +0000 (UTC) Received: by mail-qt1-f193.google.com with SMTP id d2so143064qti.11 for ; Mon, 11 Mar 2019 13:56:28 -0700 (PDT) Received: from localhost.localdomain ([2804:431:b704:983c:4497:62af:9e84:1841]) by smtp.gmail.com with ESMTPSA id w1sm4329157qtc.75.2019.03.11.13.56.25 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 11 Mar 2019 13:56:26 -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=jky0isJiryN4Z3IP0ItPSX+oOrTzl2pSg0lB9jsKS/s=; b=Yvn/aLc1l8+lGtdXi2QkzXnrnGR2b1JyB2t32rRG4U24ZPhjCY3fPQu47JDMz2xMCP BSabTXYVA0YOsBOIr2J8XDJHWnRU+WJp73RlIRoVAbwy7BW3TG3YePTEW5rF8VtJCRPf XC8eLY42Sc7b4Ii3ntYotWthtnCq4Kh3D3Gu4xGJ7i5309wGt3jzPX9HlA8gCiQZbqBe PhpuE1dtubjqeDs6H02EIJlzli/lJ+gG6WtmqI9kSfNeQ6T/OrDuwEHd/WdhP/bT4J1q f786ePu7ikNuZUjIWEYbRj0c3bbkn7DIa4RRefGCAkLGgN5SVDrp8Kucn9MZ6w8mEbHQ 6Azg== 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=jky0isJiryN4Z3IP0ItPSX+oOrTzl2pSg0lB9jsKS/s=; b=ry+ehCzqoiEHyLzRcCHrbRYKavnsqZ9qQn9dYsS+KJEU/2LJ9xiUkk8CQ1ntDqyfmq 9+7sBXrmFkhOojn+be0l2cE6zjCiJqfmiY3iEZsDUYD3ksBpKGyqg19MexxE/9IP9+kU SyT7aX5409xn03t1nbJWBXmxQdp5Mza7SWKIw7A15kv3R1LtkcelmRFp0HKVs5xLzLpd hwvD1EQwM/P3z5xQFPq4C1E6kVIT7ar9XulkmcahbLLur8M3aU0vqmcM4bU0RE7FYGn3 F2bjBxuVzCJ4eB4+vMhMZWdcx0qq9sju7CeLywQnUWuoM8ZxZclGoQOKB4PabhpTlHCU FIFg== X-Gm-Message-State: APjAAAUx3CYKri9Z1PlcFa4yPSc9XyvnksRW9TQDLjxHLpvKSRSJKoey kOg2NBsuWcUTpg1WyMU3806cLdDK X-Google-Smtp-Source: APXvYqwOSBVyYddvGoE/q5sJZPPTQEDH5HJ42qH3a9IC7WLKQ+wVlErX/DgLe+Bh8KLd38IadjA2Ug== X-Received: by 2002:a0c:b059:: with SMTP id l25mr27397379qvc.23.1552337787114; Mon, 11 Mar 2019 13:56:27 -0700 (PDT) From: Julio Faracco To: libvir-list@redhat.com Date: Mon, 11 Mar 2019 17:56:15 -0300 Message-Id: <20190311205618.6588-4-jcfaracco@gmail.com> In-Reply-To: <20190311205618.6588-1-jcfaracco@gmail.com> References: <20190311205618.6588-1-jcfaracco@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.28]); Mon, 11 Mar 2019 20:56:28 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.28]); Mon, 11 Mar 2019 20:56:28 +0000 (UTC) for IP:'209.85.160.193' DOMAIN:'mail-qt1-f193.google.com' HELO:'mail-qt1-f193.google.com' FROM:'jcfaracco@gmail.com' RCPT:'' X-RedHat-Spam-Score: -0.13 (DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, FREEMAIL_FROM, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, SPF_PASS) 209.85.160.193 mail-qt1-f193.google.com 209.85.160.193 mail-qt1-f193.google.com X-Scanned-By: MIMEDefang 2.78 on 10.5.110.28 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 3/6] lxc: Introduce method lxcDomainGetStatsCpu(). 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.84 on 10.5.11.22 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.42]); Mon, 11 Mar 2019 20:58:42 +0000 (UTC) X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" This method is responsible to fetch all CPU Cgroup Stats and store data into virDomainStatsRecordPtr structure. Signed-off-by: Julio Faracco --- src/lxc/lxc_driver.c | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/src/lxc/lxc_driver.c b/src/lxc/lxc_driver.c index 72639e0d7d..86c98517d2 100644 --- a/src/lxc/lxc_driver.c +++ b/src/lxc/lxc_driver.c @@ -5277,6 +5277,45 @@ lxcDomainGetMetadata(virDomainPtr dom, return ret; } =20 +static int +lxcDomainGetStatsCpu(virDomainObjPtr dom, + virDomainStatsRecordPtr record, + int *maxparams) +{ + virLXCDomainObjPrivatePtr priv =3D dom->privateData; + unsigned long long cpu_time =3D 0; + unsigned long long user_time =3D 0; + unsigned long long sys_time =3D 0; + int err =3D 0; + + if (!priv->cgroup) + return 0; + + err =3D virCgroupGetCpuacctUsage(priv->cgroup, &cpu_time); + if (!err && virTypedParamsAddULLong(&record->params, + &record->nparams, + maxparams, + "cpu.time", + cpu_time) < 0) + return -1; + + err =3D virCgroupGetCpuacctStat(priv->cgroup, &user_time, &sys_time); + if (!err && virTypedParamsAddULLong(&record->params, + &record->nparams, + maxparams, + "cpu.user", + user_time) < 0) + return -1; + if (!err && virTypedParamsAddULLong(&record->params, + &record->nparams, + maxparams, + "cpu.system", + sys_time) < 0) + return -1; + + return 0; +} + static virDomainStatsRecordPtr lxcDomainGetStats(virConnectPtr conn, virDomainObjPtr dom) --=20 2.19.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Thu Apr 18 14:32:57 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 Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1552337913806194.38645975633108; Mon, 11 Mar 2019 13:58:33 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id D07C737E8B; Mon, 11 Mar 2019 20:58:31 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id A8FD1608C8; Mon, 11 Mar 2019 20:58:31 +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 71B20181A006; Mon, 11 Mar 2019 20:58:31 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x2BKuUps021808 for ; Mon, 11 Mar 2019 16:56:30 -0400 Received: by smtp.corp.redhat.com (Postfix) id 1A3F219736; Mon, 11 Mar 2019 20:56:30 +0000 (UTC) Received: from mx1.redhat.com (ext-mx03.extmail.prod.ext.phx2.redhat.com [10.5.110.27]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 1399119739 for ; Mon, 11 Mar 2019 20:56:30 +0000 (UTC) Received: from mail-qt1-f194.google.com (mail-qt1-f194.google.com [209.85.160.194]) (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 5EC7781F2F for ; Mon, 11 Mar 2019 20:56:29 +0000 (UTC) Received: by mail-qt1-f194.google.com with SMTP id v20so133853qtv.12 for ; Mon, 11 Mar 2019 13:56:29 -0700 (PDT) Received: from localhost.localdomain ([2804:431:b704:983c:4497:62af:9e84:1841]) by smtp.gmail.com with ESMTPSA id w1sm4329157qtc.75.2019.03.11.13.56.27 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 11 Mar 2019 13:56:28 -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=UjXhsymfBN0AEOi+AfH400vs9H/xbhUuX2Lw5ziwmMA=; b=IgXKl0i3RDqkN7mtGjIWEXUBdHammCKnasXOblqRNj3Mrb30wU3KRmeIoff2DIcGHn wCZ4lroL122taKjncShTPuQHkXfcyNA1z6U6dssMyp0I5C6bOcoD9c13lmdmWrYLJj9r LheeNkH79idcJAkItbeEeyJAx1kFseZs4vnB82v8XPy14lRsVNE6UDXLUaXEv4EB9vpW piruVeXDMxjfAUqtbFshm5fi+nXxLSopDcQwwFtAAdqIb8XKvTh2sPGMTjU4frU2OFO+ l3rkm9wVuejbrMiqKvAGVTY7CSkx7KEFnjUaazz3v8focOnpzVq7x1PepSyQEpc7dggC y32A== 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=UjXhsymfBN0AEOi+AfH400vs9H/xbhUuX2Lw5ziwmMA=; b=PvZ5vK8DnGh1D8hTVaFE6IS7O+WUqB3UOch/MnS53xfw4XuD2oD1FNT1s1kSCIse79 jnF6uef4/yJ1qBkP1SEH0zMO8UJiHZXDEW6/swbaiVdeEcBZJhcLnLkWCnap5zKQfXpj HuhAkMzjWNBHI+IN6PH5ETLgsP8CekhJkvBiYkIfzPBq6ix4AA7G8XTH85JZALL4lyjt 5VnsS6opSft9zzfAmtf6iRI875tdFtYk3ETfPPRJe3gTtHbT7qk/iBHa6SreLq7eTX+e iAjR4HItY56g7k7LZRaqFtbaS/yHnV/gE2pZz+DYbckkt5S2HjsJgNHOn4NyginQqQ13 ++0A== X-Gm-Message-State: APjAAAX6yvU/t23pj74ysc5Qu7+t2vMbnNLvTDYlBUQeU9DytYA/DZFY ZomRFGvAXTOWr6zafO4jE7wey418 X-Google-Smtp-Source: APXvYqxHFZP8QLCUUq9MX1d/whjKrHhF1r2OFPkaDcg183JTrebUDV3rFonJK4Zqe0qqQlRVTtNNXw== X-Received: by 2002:a0c:f885:: with SMTP id u5mr4808071qvn.63.1552337788440; Mon, 11 Mar 2019 13:56:28 -0700 (PDT) From: Julio Faracco To: libvir-list@redhat.com Date: Mon, 11 Mar 2019 17:56:16 -0300 Message-Id: <20190311205618.6588-5-jcfaracco@gmail.com> In-Reply-To: <20190311205618.6588-1-jcfaracco@gmail.com> References: <20190311205618.6588-1-jcfaracco@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.27]); Mon, 11 Mar 2019 20:56:29 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Mon, 11 Mar 2019 20:56:29 +0000 (UTC) for IP:'209.85.160.194' DOMAIN:'mail-qt1-f194.google.com' HELO:'mail-qt1-f194.google.com' FROM:'jcfaracco@gmail.com' RCPT:'' X-RedHat-Spam-Score: -0.13 (DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, FREEMAIL_FROM, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, SPF_PASS) 209.85.160.194 mail-qt1-f194.google.com 209.85.160.194 mail-qt1-f194.google.com X-Scanned-By: MIMEDefang 2.78 on 10.5.110.27 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 4/6] lxc: Introduce method lxcDomainGetStatsState(). 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.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.29]); Mon, 11 Mar 2019 20:58:32 +0000 (UTC) X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" This method is responsible to fetch all State Stats and store data into virDomainStatsRecordPtr structure. Signed-off-by: Julio Faracco --- src/lxc/lxc_driver.c | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/src/lxc/lxc_driver.c b/src/lxc/lxc_driver.c index 86c98517d2..5fd3bdc5ec 100644 --- a/src/lxc/lxc_driver.c +++ b/src/lxc/lxc_driver.c @@ -5277,6 +5277,28 @@ lxcDomainGetMetadata(virDomainPtr dom, return ret; } =20 +static int +lxcDomainGetStatsState(virDomainObjPtr dom, + virDomainStatsRecordPtr record, + int *maxparams) +{ + if (virTypedParamsAddInt(&record->params, + &record->nparams, + maxparams, + "state.state", + dom->state.state) < 0) + return -1; + + if (virTypedParamsAddInt(&record->params, + &record->nparams, + maxparams, + "state.reason", + dom->state.reason) < 0) + return -1; + + return 0; +} + static int lxcDomainGetStatsCpu(virDomainObjPtr dom, virDomainStatsRecordPtr record, --=20 2.19.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Thu Apr 18 14:32:57 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 Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1552337816769673.2028076632951; Mon, 11 Mar 2019 13:56:56 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id F3BC581F31; Mon, 11 Mar 2019 20:56:54 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id C996C183F4; Mon, 11 Mar 2019 20:56:54 +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 8096C181A138; Mon, 11 Mar 2019 20:56:54 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x2BKuWOJ021826 for ; Mon, 11 Mar 2019 16:56:32 -0400 Received: by smtp.corp.redhat.com (Postfix) id 2CB9B6013D; Mon, 11 Mar 2019 20:56:32 +0000 (UTC) Received: from mx1.redhat.com (ext-mx12.extmail.prod.ext.phx2.redhat.com [10.5.110.41]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 2603F600CD for ; Mon, 11 Mar 2019 20:56:32 +0000 (UTC) Received: from mail-qt1-f196.google.com (mail-qt1-f196.google.com [209.85.160.196]) (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 B2003309175F for ; Mon, 11 Mar 2019 20:56:30 +0000 (UTC) Received: by mail-qt1-f196.google.com with SMTP id h39so216112qte.2 for ; Mon, 11 Mar 2019 13:56:30 -0700 (PDT) Received: from localhost.localdomain ([2804:431:b704:983c:4497:62af:9e84:1841]) by smtp.gmail.com with ESMTPSA id w1sm4329157qtc.75.2019.03.11.13.56.28 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 11 Mar 2019 13:56:29 -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=Vj6FdVC7BQoZaAgxWifG//PdeoFJgrAbvGzAOXFxhsk=; b=nFkz0rqA8R7+kXN6q3XCAFAGqRBn6J6H4/X/JjPzfJNYRxq8iiHErxRdbnuDwzbku2 UOkgh9TbU8FTeyXEedWcNgg1ObKdHw6gB3y9ynecMnFqDX6D+8jbX5T4vZI4W6RUMDYO C4L5sWKpjoPX6135FeRMvNXsDzl5lhvVlK3GM6fCSgbRx5DBnsGEhKaKlb1I44qwQUqO C+kBqoxWFSo55jlosenwQ0MzE4I2UtW9Mxg3RqfvoIxNWA1g0hoou10A+G9gpmavzUxP 0MOXtW8imW7jt7wqkihRnqyKgl1Gp90g6jkc95E3wqHtXIzibqXoN6wvNmzC0ZWKRH2m 4llw== 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=Vj6FdVC7BQoZaAgxWifG//PdeoFJgrAbvGzAOXFxhsk=; b=MIfv5wLzfWDWmQegnhLyDC+Yl1ItnO1O7NIcPkXAx52wX78DwYAtQdm98tsRFzu27X 7EvBP6FOKW1izxCmtge6zQB1fPo+DMgNbBJNzx7+2BAM9tDoKBFjvObjDJi2ZGiG2ppZ U7SrbS58jZ5iUF1LuBSWEQfVdXTCS+ifchVv5TyiuFG9AS4n6o6Opcbqx0j31pfPiBSY U90W6PYOjPZ/5PRAeKYrB3lRNyLTeUzHvjhLmo+2eYiCmgZwMy89C38Lr4NqSiZF1eBF yHGJJG/vADtE6B3KlXOJcZN1ACUTrV/15VzON1sQ7dlYkvUWouyOErvXQ6IL/j1750on 5FjQ== X-Gm-Message-State: APjAAAUSCDwMjGkJYS6qRltvS2F+Bpi7aix7elx4d7DVpgSBjXzDwtkl oTzCqagtj/qoJf4KSXGbHWf6Gbs1 X-Google-Smtp-Source: APXvYqwhKM5PRbNwCf40d95v7pKZcC/pQXrfB36xVEKrpjCEdMZBue0KHpHSAN37rhHBXheKC+1ApA== X-Received: by 2002:a0c:be81:: with SMTP id n1mr4832938qvi.226.1552337789746; Mon, 11 Mar 2019 13:56:29 -0700 (PDT) From: Julio Faracco To: libvir-list@redhat.com Date: Mon, 11 Mar 2019 17:56:17 -0300 Message-Id: <20190311205618.6588-6-jcfaracco@gmail.com> In-Reply-To: <20190311205618.6588-1-jcfaracco@gmail.com> References: <20190311205618.6588-1-jcfaracco@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.41]); Mon, 11 Mar 2019 20:56:31 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.41]); Mon, 11 Mar 2019 20:56:31 +0000 (UTC) for IP:'209.85.160.196' DOMAIN:'mail-qt1-f196.google.com' HELO:'mail-qt1-f196.google.com' FROM:'jcfaracco@gmail.com' RCPT:'' X-RedHat-Spam-Score: -0.13 (DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, FREEMAIL_FROM, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, SPF_PASS) 209.85.160.196 mail-qt1-f196.google.com 209.85.160.196 mail-qt1-f196.google.com X-Scanned-By: MIMEDefang 2.84 on 10.5.110.41 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 5/6] lxc: Introduce method lxcDomainGetBlockStats(). 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.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Mon, 11 Mar 2019 20:56:55 +0000 (UTC) X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" This method is responsible to fetch all Block Stats and store data into virDomainStatsRecordPtr structure. This particular method checks for LXC filesystem in host disk/partition and check for block disks like physical disks and partition that are considered block types. If the block type does not have a CGroup associated, it returns an error. Signed-off-by: Julio Faracco --- src/lxc/lxc_driver.c | 100 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 100 insertions(+) diff --git a/src/lxc/lxc_driver.c b/src/lxc/lxc_driver.c index 5fd3bdc5ec..1190d67a81 100644 --- a/src/lxc/lxc_driver.c +++ b/src/lxc/lxc_driver.c @@ -2482,6 +2482,106 @@ lxcDomainBlockStatsFlags(virDomainPtr dom, return ret; } =20 +#define LXC_STORE_DISK_RECORD(FIELD, COUNTER) \ +do { \ + if (stats.FIELD !=3D -1) { \ + snprintf(param_name, VIR_TYPED_PARAM_FIELD_LENGTH, \ + "block.%zu." COUNTER, i); \ + if (virTypedParamsAddULLong(&record->params, \ + &record->nparams, \ + maxparams, \ + param_name, \ + stats.FIELD) < 0) \ + return -1; \ + } \ +} while (0) + +static int +lxcDomainGetBlockStats(virDomainObjPtr dom, + virDomainStatsRecordPtr record, + int *maxparams) +{ + virLXCDomainObjPrivatePtr priv =3D dom->privateData; + virDomainBlockStatsStruct stats; + size_t i =3D 0; + size_t ndisks =3D 1; + char param_name[VIR_TYPED_PARAM_FIELD_LENGTH]; + + if (virCgroupGetBlkioIoServiced(priv->cgroup, + &stats.rd_bytes, + &stats.wr_bytes, + &stats.rd_req, + &stats.wr_req) < 0) + return -1; + + LXC_STORE_DISK_RECORD(rd_req, "rd.reqs"); + LXC_STORE_DISK_RECORD(rd_bytes, "rd.bytes"); + LXC_STORE_DISK_RECORD(wr_req, "wr.reqs"); + LXC_STORE_DISK_RECORD(wr_bytes, "wr.bytes"); + + for (i =3D 0; i < dom->def->ndisks; i++) { + virDomainDiskDefPtr disk =3D dom->def->disks[i]; + + if (virDomainDiskGetType(disk) =3D=3D VIR_STORAGE_TYPE_BLOCK) { + if (virCgroupGetBlkioIoDeviceServiced(priv->cgroup, + disk->src->path, + &stats.rd_bytes, + &stats.wr_bytes, + &stats.rd_req, + &stats.wr_req) < 0) + return -1; + + snprintf(param_name, VIR_TYPED_PARAM_FIELD_LENGTH, + "block.%zu.name", i); + if (virTypedParamsAddString(&record->params, + &record->nparams, + maxparams, + param_name, + disk->dst) < 0) + return -1; + + if (virStorageSourceIsLocalStorage(disk->src) && disk->src->pa= th) { + snprintf(param_name, VIR_TYPED_PARAM_FIELD_LENGTH, + "block.%zu.path", i); + if (virTypedParamsAddString(&record->params, + &record->nparams, + maxparams, + param_name, + disk->src->path) < 0) + return -1; + } + + LXC_STORE_DISK_RECORD(rd_req, "rd.reqs"); + LXC_STORE_DISK_RECORD(rd_bytes, "rd.bytes"); + LXC_STORE_DISK_RECORD(wr_req, "wr.reqs"); + LXC_STORE_DISK_RECORD(wr_bytes, "wr.bytes"); + + if (disk->device =3D=3D VIR_DOMAIN_DISK_DEVICE_DISK) { + snprintf(param_name, VIR_TYPED_PARAM_FIELD_LENGTH, + "block.%zu.capacity", i); + if (virTypedParamsAddULLong(&record->params, + &record->nparams, + maxparams, + param_name, + disk->src->capacity) < 0) + return -1; + } + + ndisks++; + } + } + + if (virTypedParamsAddUInt(&record->params, + &record->nparams, + maxparams, + "block.count", + ndisks) < 0) + return -1; + + return 0; +} + +#undef LXC_STORE_DISK_RECORD =20 static int lxcDomainSetBlkioParameters(virDomainPtr dom, --=20 2.19.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Thu Apr 18 14:32:57 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 Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1552337919910686.2870197754012; Mon, 11 Mar 2019 13:58:39 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 3D7CFFECD; Mon, 11 Mar 2019 20:58:38 +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 160AF19724; Mon, 11 Mar 2019 20:58:38 +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 CE66041F3D; Mon, 11 Mar 2019 20:58:37 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x2BKuXTl021831 for ; Mon, 11 Mar 2019 16:56:33 -0400 Received: by smtp.corp.redhat.com (Postfix) id 549DB6013D; Mon, 11 Mar 2019 20:56:33 +0000 (UTC) Received: from mx1.redhat.com (ext-mx05.extmail.prod.ext.phx2.redhat.com [10.5.110.29]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 4AEDC600CD for ; Mon, 11 Mar 2019 20:56:33 +0000 (UTC) Received: from mail-qt1-f195.google.com (mail-qt1-f195.google.com [209.85.160.195]) (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 07D3E3DE07 for ; Mon, 11 Mar 2019 20:56:32 +0000 (UTC) Received: by mail-qt1-f195.google.com with SMTP id x20so225015qto.1 for ; Mon, 11 Mar 2019 13:56:31 -0700 (PDT) Received: from localhost.localdomain ([2804:431:b704:983c:4497:62af:9e84:1841]) by smtp.gmail.com with ESMTPSA id w1sm4329157qtc.75.2019.03.11.13.56.29 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 11 Mar 2019 13:56:30 -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=LaDmLzUSjCSSf4e3WBIIM6DxendGZ+f1dJ0VHbQqqzc=; b=UB98nNnBTbG73TM0Sxvvd9wa5lEAp86iwSOphZXXE9ZwJAmkvI266E0L3FRHC4XXUy 6fKu1W6JtxbLOOe7AKYniejEOn5fPS3F8xpeJQrBh72oLKQfl8UJDuzUpu1s6NVDw+Ma B/Hd3mzxy0asmscnqyQ1atw+3K3Y6vPeNNfYalMkDWGfG9TbdmB4LfD+p9miU+4l8Bo/ Hk6bpvNB+mVpBxfnjiWXUrjNEGHeax1IPoyVgT2GPsVPqs8BhSr/0uhFrNRinUxNB6fY jbQQt89ShBSkIivURq11kL0i2QjnNZuIhsUfhMVM1s/1LoCNONcbyeLo2ORKG/OZoHvi rVog== 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=LaDmLzUSjCSSf4e3WBIIM6DxendGZ+f1dJ0VHbQqqzc=; b=nCB/ZvI4v41CDA4rSxpoXAfeNDMHEz4ST4KMw88UW80fIya8nsFLQEIusS2NJbrH4W X5dzdmkszxywzQkABWN5vEcbuDTos6yTQsZeX6tf62RxE9bks/kbSgseGokjf9pa7zrd poXoPaDsQXurYtRFETo+VAf+3OsBIhyIck6S5zSSdCdC3ElZGx1mcURuAYvsmpvBhCDj Xl/B+h/wNiBin6m6BLB/vYSmpiYZkaU1EMyXJRMjP6hCecs1UcYR8q5DstUwQIFunapy ST4hRhxArPRfkP55K7XoZjMu+nRyy1je7qULVX1IzNIFr9K8BfL4miFspxg8Bb1/xvVA ESKw== X-Gm-Message-State: APjAAAVP9K3wWWM0DGQR3c1KjryY7MjrGSCSIB9EKzGnKI4BPsAZkeYk AH3gSGJTdi9zHZDj5aSuwVr87q1z X-Google-Smtp-Source: APXvYqx/zCnFs3bpNXjwAfqNOyexpiFwMIeJZc/hYydloV6QgRkKQFBRV4uA3cg6/0cyhyDkr35OeA== X-Received: by 2002:ac8:2d68:: with SMTP id o37mr26387257qta.377.1552337791031; Mon, 11 Mar 2019 13:56:31 -0700 (PDT) From: Julio Faracco To: libvir-list@redhat.com Date: Mon, 11 Mar 2019 17:56:18 -0300 Message-Id: <20190311205618.6588-7-jcfaracco@gmail.com> In-Reply-To: <20190311205618.6588-1-jcfaracco@gmail.com> References: <20190311205618.6588-1-jcfaracco@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.29]); Mon, 11 Mar 2019 20:56:32 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.29]); Mon, 11 Mar 2019 20:56:32 +0000 (UTC) for IP:'209.85.160.195' DOMAIN:'mail-qt1-f195.google.com' HELO:'mail-qt1-f195.google.com' FROM:'jcfaracco@gmail.com' RCPT:'' X-RedHat-Spam-Score: -0.11 (DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, FREEMAIL_FROM, RCVD_IN_DNSWL_NONE, SPF_PASS) 209.85.160.195 mail-qt1-f195.google.com 209.85.160.195 mail-qt1-f195.google.com X-Scanned-By: MIMEDefang 2.78 on 10.5.110.29 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 6/6] lxc: Introduce method lxcDomainGetBalloonStats(). 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.84 on 10.5.11.23 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.29]); Mon, 11 Mar 2019 20:58:38 +0000 (UTC) X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" This method is responsible to fetch all Balloon Memory Stats and store data into virDomainStatsRecordPtr structure. Signed-off-by: Julio Faracco --- src/lxc/lxc_driver.c | 71 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 71 insertions(+) diff --git a/src/lxc/lxc_driver.c b/src/lxc/lxc_driver.c index 1190d67a81..ea48214073 100644 --- a/src/lxc/lxc_driver.c +++ b/src/lxc/lxc_driver.c @@ -2876,6 +2876,77 @@ lxcDomainGetBlkioParameters(virDomainPtr dom, return ret; } =20 +static int +lxcDomainGetBalloonStats(virDomainObjPtr dom, + virDomainStatsRecordPtr record, + int *maxparams) +{ + virLXCDomainObjPrivatePtr priv =3D dom->privateData; + virDomainMemoryStatStruct stats[VIR_DOMAIN_MEMORY_STAT_NR]; + unsigned long long swap_usage; + unsigned long mem_usage; + size_t i; + int ret =3D -1; + + if (virTypedParamsAddULLong(&record->params, + &record->nparams, + maxparams, + "balloon.maximum", + virDomainDefGetMemoryTotal(dom->def)) < 0) + return -1; + + if (virTypedParamsAddULLong(&record->params, + &record->nparams, + maxparams, + "balloon.current", + virDomainDefGetMemoryTotal(dom->def)) < 0) + return -1; + + if (virCgroupGetMemSwapUsage(priv->cgroup, &swap_usage) < 0) + return -1; + + if (virCgroupGetMemoryUsage(priv->cgroup, &mem_usage) < 0) + return -1; + + ret =3D 0; + if (ret < *maxparams) { + stats[ret].tag =3D VIR_DOMAIN_MEMORY_STAT_ACTUAL_BALLOON; + stats[ret].val =3D dom->def->mem.cur_balloon; + ret++; + } + if (ret < *maxparams) { + stats[ret].tag =3D VIR_DOMAIN_MEMORY_STAT_SWAP_IN; + stats[ret].val =3D swap_usage; + ret++; + } + if (ret < *maxparams) { + stats[ret].tag =3D VIR_DOMAIN_MEMORY_STAT_RSS; + stats[ret].val =3D mem_usage; + ret++; + } + +#define LXC_STORE_MEM_RECORD(TAG, NAME) \ + if (stats[i].tag =3D=3D VIR_DOMAIN_MEMORY_STAT_ ##TAG) \ + if (virTypedParamsAddULLong(&record->params, \ + &record->nparams, \ + maxparams, \ + "balloon." NAME, \ + stats[i].val) < 0) \ + return -1; + + for (i =3D 0; i < ret; i++) { + LXC_STORE_MEM_RECORD(SWAP_IN, "swap_in") + LXC_STORE_MEM_RECORD(SWAP_OUT, "swap_out") + LXC_STORE_MEM_RECORD(MAJOR_FAULT, "major_fault") + LXC_STORE_MEM_RECORD(MINOR_FAULT, "minor_fault") + LXC_STORE_MEM_RECORD(AVAILABLE, "available") + LXC_STORE_MEM_RECORD(UNUSED, "unused") + } + +#undef LXC_STORE_MEM_RECORD + + return 0; +} =20 static int lxcDomainInterfaceStats(virDomainPtr dom, --=20 2.19.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list