From nobody Tue May 7 12:43:16 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 205.139.110.120 as permitted sender) client-ip=205.139.110.120; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zoho.com: domain of redhat.com designates 205.139.110.120 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=1571630110; cv=none; d=zoho.com; s=zohoarc; b=jTSz/uTVW/3jlxxAEK0Gdeb8Iuev23vXXlIYkmYvERvVqhaYH1ugtE6m5WGlz97JHZQ3bU0ZIyBwPf4LvEwmQLtQn4pKfleH9S1mDaoInXu+B9P6nSli+iurbUnFZ1RYEUMF5f0TESlmYYhsNf3KCfgOLrImHR8nFGtwlK7L0WQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1571630110; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:To; bh=zHwa1zQoKA7iIEzIbju/pElig0Y4NYf5YPO1ngWoJtQ=; b=kj3pcQiCEjr9oe+fxsGCUBl6FL0PgdOaBWkWraa6V5d5Fx+LWiO2kfrI4I/u6In9Dm4xtJbe7RMecoPVn1OX93Saa9MhEdDC+qL0lhQ2y93GcDM997ahrr5tEy3drPc+zr6DuAIKHzLL5qR/UDusXyqQ057qcR436HY+gkEtJmU= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=pass; spf=pass (zoho.com: domain of redhat.com designates 205.139.110.120 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [205.139.110.120]) by mx.zohomail.com with SMTPS id 1571630110771279.65282418766014; Sun, 20 Oct 2019 20:55:10 -0700 (PDT) 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-358-ujiHmySdNl6nQ0nkDs8Ovw-1; Sun, 20 Oct 2019 23:55:06 -0400 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 08BE1107AD31; Mon, 21 Oct 2019 03:55:01 +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 45DC160BE2; Mon, 21 Oct 2019 03:54: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 780214E589; Mon, 21 Oct 2019 03:54:51 +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 x9L3snAJ027564 for ; Sun, 20 Oct 2019 23:54:49 -0400 Received: by smtp.corp.redhat.com (Postfix) id 0AC9460C5D; Mon, 21 Oct 2019 03:54:49 +0000 (UTC) Received: from mx1.redhat.com (ext-mx13.extmail.prod.ext.phx2.redhat.com [10.5.110.42]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 051C560BE2 for ; Mon, 21 Oct 2019 03:54:46 +0000 (UTC) Received: from mail-qt1-f172.google.com (mail-qt1-f172.google.com [209.85.160.172]) (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 55F633082132 for ; Mon, 21 Oct 2019 03:54:45 +0000 (UTC) Received: by mail-qt1-f172.google.com with SMTP id w14so18864090qto.9 for ; Sun, 20 Oct 2019 20:54:45 -0700 (PDT) Received: from localhost.localdomain ([2804:431:c7ca:34c:a94f:d944:2d:9514]) by smtp.gmail.com with ESMTPSA id k2sm8806208qti.24.2019.10.20.20.54.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 20 Oct 2019 20:54:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1571630109; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=zHwa1zQoKA7iIEzIbju/pElig0Y4NYf5YPO1ngWoJtQ=; b=Gqpa4er+mfPUv8GPs1Y/HCtqg0bG/EStxdAf49CLAABMJCA4MREOMelqJzXOx46ydjVZf7 UrL9FzVY/JyMkVFyc65JDAdHbQojcCcv5CLXCGW14zhCu26bvthn/3UII15dxF4fOhsOZl 6jpCTBrYgx+PRILi0TX0lJiaHnp46qk= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=ko4CCMazUXz6McDbBskGh+X/RbusosP2hrBDcdOy6Oo=; b=VV/tKnhaQBKwdLk9LsDHneLMEI0BqksJ2EjbmqiRCDzBE7TuV7XIE0a60dvdgTsOvy NwBMfPjr0Zd8PFXiCVYbL0z3I6gn9BqLBruWIoeT6k2313wqUFTBWcG1cWWOLw+UTXHX HZeL2dIGMugjAHtF+P4tmWomhbgGmdk9F/eu3hRlAROYF/MRK1JcsyorxYwEXSvbinnm TE3+MKZG0vNMKcoOfT9XALKPeQ8nMp+ZqUlBBHsnIVyWiPG+GXWwFAcJLR1cUOFKqiJi sZcrhzsZcY6A0zyHAinbTsLLf9C1JexSrelxjWfoV21yckYN6tWYR2ZI9UruMgmDcOp1 uVxQ== X-Gm-Message-State: APjAAAW5tUn2N1aPBnAkodQ3duUIqpDcdDhL61OKMWD+j1Pzc7beYWrE jjzdKwDfBQbeMmSFSKunrADHMFtTPZo= X-Google-Smtp-Source: APXvYqzYuH1AqCPd7NvgnP20fatCx71UbZlYTd+nthMP3093/79LEw96tscMl9DgOxYkdiqN5dQd1A== X-Received: by 2002:a05:6214:2c:: with SMTP id b12mr21639934qvr.10.1571630083968; Sun, 20 Oct 2019 20:54:43 -0700 (PDT) From: jcfaracco@gmail.com To: libvir-list@redhat.com Date: Mon, 21 Oct 2019 00:54:36 -0300 Message-Id: <20191021035436.14063-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.42]); Mon, 21 Oct 2019 03:54:45 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.42]); Mon, 21 Oct 2019 03:54:45 +0000 (UTC) for IP:'209.85.160.172' DOMAIN:'mail-qt1-f172.google.com' HELO:'mail-qt1-f172.google.com' FROM:'jcfaracco@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.160.172 mail-qt1-f172.google.com 209.85.160.172 mail-qt1-f172.google.com X-Scanned-By: MIMEDefang 2.84 on 10.5.110.42 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-loop: libvir-list@redhat.com Cc: Julio Faracco Subject: [libvirt] [PATCH] lxc: Fix 'domblkstat' error with attached disk devices. 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: ujiHmySdNl6nQ0nkDs8Ovw-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" From: Julio Faracco LXC was not working when you attached a new disk that points to block device. See: https://bugzilla.redhat.com/show_bug.cgi?id=3D1697115. Command line from virsh was showing problems with alias first (this feature is not supported) and after, problems to query block device. It was happening because extra disks were not being included into cgroup blkio.throttle properties and libvirt could not query this info. Applying those devices into 'allowed' list is not enough, libvirt should reset blkio.throttle as a workaround to include disks into container's cgroup directory. Before: virsh # domblkstat CentOS hda error: Failed to get block stats for domain 'CentOS' device 'hda' error: internal error: domain stats query failed Now: virsh # domblkstat CentOS hda hda rd_req 0 hda rd_bytes 0 hda wr_req 0 hda wr_bytes 0 Signed-off-by: Julio Faracco --- src/lxc/lxc_cgroup.c | 29 ++++++++++++++++++++++++++++- src/lxc/lxc_cgroup.h | 4 ++++ src/lxc/lxc_driver.c | 8 ++++---- 3 files changed, 36 insertions(+), 5 deletions(-) diff --git a/src/lxc/lxc_cgroup.c b/src/lxc/lxc_cgroup.c index 5efb495b56..de6d892521 100644 --- a/src/lxc/lxc_cgroup.c +++ b/src/lxc/lxc_cgroup.c @@ -302,6 +302,24 @@ virLXCTeardownHostUSBDeviceCgroup(virUSBDevicePtr dev = G_GNUC_UNUSED, return 0; } =20 +int +virLXCCgroupResetBlkioDeviceThrottle(virCgroupPtr cgroup, + const char *path) +{ + if (virCgroupSetBlkioDeviceReadBps(cgroup, path, 0) < 0) + return -1; + + if (virCgroupSetBlkioDeviceWriteBps(cgroup, path, 0) < 0) + return -1; + + if (virCgroupSetBlkioDeviceReadIops(cgroup, path, 0) < 0) + return -1; + + if (virCgroupSetBlkioDeviceWriteIops(cgroup, path, 0) < 0) + return -1; + + return 0; +} =20 static int virLXCCgroupSetupDeviceACL(virDomainDefPtr def, virCgroupPtr cgroup) @@ -309,6 +327,7 @@ static int virLXCCgroupSetupDeviceACL(virDomainDefPtr d= ef, int capMknod =3D def->caps_features[VIR_DOMAIN_CAPS_FEATURE_MKNOD]; int ret =3D -1; size_t i; + const char *src_path =3D NULL; static virLXCCgroupDevicePolicy devices[] =3D { {'c', LXC_DEV_MAJ_MEMORY, LXC_DEV_MIN_NULL}, {'c', LXC_DEV_MAJ_MEMORY, LXC_DEV_MIN_ZERO}, @@ -346,8 +365,16 @@ static int virLXCCgroupSetupDeviceACL(virDomainDefPtr = def, !virStorageSourceIsBlockLocal(def->disks[i]->src)) continue; =20 + /* Workaround to include disks into blkio.throttle. + * To include it, we need to reset any feature of + * blkio.throttle.* */ + src_path =3D virDomainDiskGetSource(def->disks[i]); + if (virLXCCgroupResetBlkioDeviceThrottle(cgroup, + src_path) < 0) + goto cleanup; + if (virCgroupAllowDevicePath(cgroup, - virDomainDiskGetSource(def->disks[i]), + src_path, (def->disks[i]->src->readonly ? VIR_CGROUP_DEVICE_READ : VIR_CGROUP_DEVICE_RW) | diff --git a/src/lxc/lxc_cgroup.h b/src/lxc/lxc_cgroup.h index 63e9e837b0..3d643a4fea 100644 --- a/src/lxc/lxc_cgroup.h +++ b/src/lxc/lxc_cgroup.h @@ -46,3 +46,7 @@ int virLXCTeardownHostUSBDeviceCgroup(virUSBDevicePtr dev, const char *path, void *opaque); + +int +virLXCCgroupResetBlkioDeviceThrottle(virCgroupPtr cgroup, + const char *path); diff --git a/src/lxc/lxc_driver.c b/src/lxc/lxc_driver.c index 204a3ed522..87da55f308 100644 --- a/src/lxc/lxc_driver.c +++ b/src/lxc/lxc_driver.c @@ -2339,14 +2339,14 @@ lxcDomainBlockStats(virDomainPtr dom, goto endjob; } =20 - if (!disk->info.alias) { + if (!disk->src->path) { virReportError(VIR_ERR_INTERNAL_ERROR, _("missing disk device alias name for %s"), disk->d= st); goto endjob; } =20 ret =3D virCgroupGetBlkioIoDeviceServiced(priv->cgroup, - disk->info.alias, + disk->src->path, &stats->rd_bytes, &stats->wr_bytes, &stats->rd_req, @@ -2424,14 +2424,14 @@ lxcDomainBlockStatsFlags(virDomainPtr dom, goto endjob; } =20 - if (!disk->info.alias) { + if (!disk->src->path) { virReportError(VIR_ERR_INTERNAL_ERROR, _("missing disk device alias name for %s"), dis= k->dst); goto endjob; } =20 if (virCgroupGetBlkioIoDeviceServiced(priv->cgroup, - disk->info.alias, + disk->src->path, &rd_bytes, &wr_bytes, &rd_req, --=20 2.20.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list