From nobody Sun Feb 8 14:12:07 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=fail(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1582554310; cv=none; d=zohomail.com; s=zohoarc; b=oLL+hRzDPY6Z4EJoNaZ7KpkpJGH7FNbLf9DsKCuFkovoEPrubUA52HQqKPd4dW/lTMtiH9HjdJjQ+RPpXvr8snuXWshD/0I4738ar3XI7IZdkIBT0DTE2m8pfOy+DXg20OSyOYHB6C472J5RU3aKkAvjrRl2pzeZuZ8VqBVEPfo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1582554310; h=Content-Type:Content-Transfer-Encoding:Cc: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=RnSCunTpqkHkiymR7T6Zo02tC+i/xNNIP+vijgKeGcs=; b=HS79YuNvOreN29tgb9YW/JxXzKVijyPIKL1UPaptCXSDTFT4NRcqTAE3y0LDqm34um6HGfUGX2QlHEv2vubpPagfEACnfAlGeZvCilmXGySmNTZW2+FeEZe30xS59mt0vEXq/oG6hsimSWOt1g78TgGVvVO3NNrLK7lCfnMoCt8= 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=fail 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 1582554310279167.46793348596782; Mon, 24 Feb 2020 06:25:10 -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-45-vn2t3lDJO0OP7_t5Upf7vg-1; Mon, 24 Feb 2020 09:25:06 -0500 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 mimecast-mx01.redhat.com (Postfix) with ESMTPS id 680818018A3; Mon, 24 Feb 2020 14:24:59 +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 3DB13909EE; Mon, 24 Feb 2020 14:24:59 +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 EDD0A18089CE; Mon, 24 Feb 2020 14:24:58 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 01OEOv4J023368 for ; Mon, 24 Feb 2020 09:24:57 -0500 Received: by smtp.corp.redhat.com (Postfix) id 686952063209; Mon, 24 Feb 2020 14:24:57 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast04.extmail.prod.ext.rdu2.redhat.com [10.11.55.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 635A32026D68 for ; Mon, 24 Feb 2020 14:24:55 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [207.211.31.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 8AEAC101A55F for ; Mon, 24 Feb 2020 14:24:55 +0000 (UTC) Received: from mail-qk1-f195.google.com (mail-qk1-f195.google.com [209.85.222.195]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-123-u2aZWSCRPlOlkpVC3xVuZg-1; Mon, 24 Feb 2020 09:24:52 -0500 Received: by mail-qk1-f195.google.com with SMTP id h4so8834728qkm.0 for ; Mon, 24 Feb 2020 06:24:52 -0800 (PST) Received: from localhost.localdomain (201-69-8-70.dial-up.telesp.net.br. [201.69.8.70]) by smtp.gmail.com with ESMTPSA id o16sm6092364qtr.28.2020.02.24.06.24.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 24 Feb 2020 06:24:50 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1582554309; 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: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=RnSCunTpqkHkiymR7T6Zo02tC+i/xNNIP+vijgKeGcs=; b=GZBp2I2HpDxECInXRrTRr1+3rIBJUYlohrihYjLmBiAuCsmd2hBCt9BYPPcJMWvFoCrnve oUalxdEbAhit4CCYbbW6axsg2NYmkHjqMV7c3607dUHmONAx0bfR2vxrIRH+jZhObxDLex w8YCkTij3E0zkglCKJMrvavYlGNA6lY= X-MC-Unique: vn2t3lDJO0OP7_t5Upf7vg-1 X-MC-Unique: u2aZWSCRPlOlkpVC3xVuZg-1 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:in-reply-to :references:mime-version:content-transfer-encoding; bh=XLMk3zjX9KpwEoOEtgunTvjxcUgvOK/YvW9kntLWM7I=; b=dl3CZ/6ZYPBi0e02e524QqTvq2FsmRNYaWyJrx1ztFwEBhT00v9AVms8OmP2/abkUZ q9uLIbU0gaEWRgT91iLie5nFxVTiAVDRmlwsxRqDJgIAAAmbFUXiySqrGDSc7pWluKLs X1k0uvVWuhjtBta/7lLbuub4h5MKnFihvLZr/8HIc4gJsH3lB8tavUgdFMNSoT7r8ubB 7VQTI9ifjUww1DZU1jOG1u3BOjSrfvRx6tP3iNTJAAdwlBuLzpKIya3RBOeEs/K+mjDh fzb3DExXQ4nZ1xQ60JkPfbafSfqu33x1tih1DfBuWNabYQLTsHAWYmbd2bKvolxgIbJ2 PsCA== X-Gm-Message-State: APjAAAXpKYbQ2OmdTuhZLVWvoSoStHGQt4lCof4KKF1Q02zPqyK0BPe0 tY63MGyeMSf9OhMzjqeTKXutGd0z X-Google-Smtp-Source: APXvYqyrnYuwJNR4cTMOZ+BOal8STvwkXz/2GXIXeiGTZ7u1gXpWWj7+bQfO7j2era0VdTMqF6pDyA== X-Received: by 2002:a37:610d:: with SMTP id v13mr12372825qkb.484.1582554291379; Mon, 24 Feb 2020 06:24:51 -0800 (PST) From: Julio Faracco To: libvir-list@redhat.com Subject: [PATCH v4 2/5] lxc: Add HPET device into allowed devices Date: Mon, 24 Feb 2020 11:24:25 -0300 Message-Id: <20200224142428.538-3-jcfaracco@gmail.com> In-Reply-To: <20200224142428.538-1-jcfaracco@gmail.com> References: <20200224142428.538-1-jcfaracco@gmail.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.78 on 10.11.54.4 X-MIME-Autoconverted: from quoted-printable to 8bit by lists01.pubmisc.prod.ext.phx2.redhat.com id 01OEOv4J023368 X-loop: libvir-list@redhat.com Cc: danielhb413@gmail.com 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.13 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" This commit is related to RTC timer device too. HPET is being shared from host device through `localtime` clock. This timer is available creating a new timer using `hpet` name. Signed-off-by: Julio Faracco --- docs/formatdomain.html.in | 2 +- src/lxc/lxc_cgroup.c | 17 +++++++++++++---- src/lxc/lxc_controller.c | 33 +++++++++++++++++++++++++++++---- 3 files changed, 43 insertions(+), 9 deletions(-) diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in index 5598bf41b4..8571db89dc 100644 --- a/docs/formatdomain.html.in +++ b/docs/formatdomain.html.in @@ -2464,7 +2464,7 @@ The name attribute selects which timer is being modified, and can be one of "platform" (currently unsupported), - "hpet" (libxl, xen, qemu), "kvmclock" (qemu), + "hpet" (libxl, xen, qemu, lxc), "kvmclock" (qemu), "pit" (qemu), "rtc" (qemu, lxc), "tsc" (libxl, qemu - since 3.2.0), "hypervclock" (qemu - since 1.2.2) or diff --git a/src/lxc/lxc_cgroup.c b/src/lxc/lxc_cgroup.c index 6a103055a4..997a5c3dfa 100644 --- a/src/lxc/lxc_cgroup.c +++ b/src/lxc/lxc_cgroup.c @@ -344,20 +344,19 @@ static int virLXCCgroupSetupDeviceACL(virDomainDefPtr= def, for (i =3D 0; i < def->clock.ntimers; i++) { virDomainTimerDefPtr timer =3D def->clock.timers[i]; =20 + if (!timer->present) + break; + switch ((virDomainTimerNameType)timer->name) { case VIR_DOMAIN_TIMER_NAME_PLATFORM: case VIR_DOMAIN_TIMER_NAME_TSC: case VIR_DOMAIN_TIMER_NAME_KVMCLOCK: case VIR_DOMAIN_TIMER_NAME_HYPERVCLOCK: case VIR_DOMAIN_TIMER_NAME_PIT: - case VIR_DOMAIN_TIMER_NAME_HPET: case VIR_DOMAIN_TIMER_NAME_ARMVTIMER: case VIR_DOMAIN_TIMER_NAME_LAST: break; case VIR_DOMAIN_TIMER_NAME_RTC: - if (!timer->present) - break; - if (virFileExists("/dev/rtc")) { if (virCgroupAllowDevicePath(cgroup, "/dev/rtc", VIR_CGROUP_DEVICE_READ, @@ -367,6 +366,16 @@ static int virLXCCgroupSetupDeviceACL(virDomainDefPtr = def, VIR_DEBUG("Ignoring non-existent device /dev/rtc"); } break; + case VIR_DOMAIN_TIMER_NAME_HPET: + if (virFileExists("/dev/hpet")) { + if (virCgroupAllowDevicePath(cgroup, "/dev/hpet", + VIR_CGROUP_DEVICE_READ, + false) < 0) + return -1; + } else { + VIR_DEBUG("Ignoring non-existent device /dev/hpet"); + } + break; } } } else { diff --git a/src/lxc/lxc_controller.c b/src/lxc/lxc_controller.c index eba6bfe0bf..518967ee83 100644 --- a/src/lxc/lxc_controller.c +++ b/src/lxc/lxc_controller.c @@ -1566,13 +1566,15 @@ virLXCControllerSetupTimers(virLXCControllerPtr ctr= l) dev_t dev; virDomainTimerDefPtr timer =3D def->clock.timers[i]; =20 + if (!timer->present) + continue; + switch ((virDomainTimerNameType)timer->name) { case VIR_DOMAIN_TIMER_NAME_PLATFORM: case VIR_DOMAIN_TIMER_NAME_TSC: case VIR_DOMAIN_TIMER_NAME_KVMCLOCK: case VIR_DOMAIN_TIMER_NAME_HYPERVCLOCK: case VIR_DOMAIN_TIMER_NAME_PIT: - case VIR_DOMAIN_TIMER_NAME_HPET: case VIR_DOMAIN_TIMER_NAME_ARMVTIMER: case VIR_DOMAIN_TIMER_NAME_LAST: virReportError(VIR_ERR_CONFIG_UNSUPPORTED, @@ -1580,9 +1582,6 @@ virLXCControllerSetupTimers(virLXCControllerPtr ctrl) virDomainTimerNameTypeToString(timer->name)); return -1; case VIR_DOMAIN_TIMER_NAME_RTC: - if (!timer->present) - break; - if (stat("/dev/rtc", &sb) < 0) { if (errno =3D=3D EACCES) return -1; @@ -1605,6 +1604,32 @@ virLXCControllerSetupTimers(virLXCControllerPtr ctrl) return -1; } =20 + if (lxcContainerChown(ctrl->def, path) < 0) + return -1; + break; + case VIR_DOMAIN_TIMER_NAME_HPET: + if (stat("/dev/hpet", &sb) < 0) { + if (errno =3D=3D EACCES) + return -1; + + virReportSystemError(errno, + _("Path '%s' is not accessible"), + path); + return -1; + } + + path =3D g_strdup_printf("/%s/%s.dev/%s", LXC_STATE_DIR, + ctrl->def->name, "/hpet"); + + dev =3D makedev(major(sb.st_rdev), minor(sb.st_rdev)); + if (mknod(path, S_IFCHR, dev) < 0 || + chmod(path, sb.st_mode)) { + virReportSystemError(errno, + _("Failed to make device %s"), + path); + return -1; + } + if (lxcContainerChown(ctrl->def, path) < 0) return -1; break; --=20 2.20.1