From nobody Tue Nov 26 08:56:42 2024 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=1582516533; cv=none; d=zohomail.com; s=zohoarc; b=HH+94lRno/p/pHttRwK9FHwgcYLMynniI0NYxsGlvxQxF7o2Lq8TNYLgMwDIHPvjoO5xv6hdO8ElQl7zMxmyDiWw+ldjyaCLQV6+1ePUsUtXHYVMvDwgcv4EiJmK1I9qgNAVRF5o+ST48oL6y0UxFVCtI0m8w0yfpc9uONzn15s= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1582516533; 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=mOCdW8xGdhQguxKmJ+W8Zdl/GxDxAcSZRzZrNycgERb6iVhOXLiQzxqhY2Esp0BVUcguul4AZ+DBVVCV/U7ch4B0CuT9/rcDtZ21Beu2wdNwappdzpLiY32twZN4qRi8HnsrcRVPh5MHMe68WNjuunlQlLaMwIsB8NPBTf4PQCc= 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 1582516533759352.89762763498516; Sun, 23 Feb 2020 19:55:33 -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-197-F8-DgMrqMRqw2nbVe2nBbw-1; Sun, 23 Feb 2020 22:55:30 -0500 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 mimecast-mx01.redhat.com (Postfix) with ESMTPS id 037DE1408; Mon, 24 Feb 2020 03:55:25 +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 A5C493A2; Mon, 24 Feb 2020 03:55:24 +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 5D52F18089CF; Mon, 24 Feb 2020 03:55:24 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 01O3tK2e014596 for ; Sun, 23 Feb 2020 22:55:20 -0500 Received: by smtp.corp.redhat.com (Postfix) id 32D542166B2E; Mon, 24 Feb 2020 03:55:20 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast05.extmail.prod.ext.rdu2.redhat.com [10.11.55.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 2E89C2166B2B for ; Mon, 24 Feb 2020 03:55:17 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [205.139.110.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 941D8800260 for ; Mon, 24 Feb 2020 03:55:17 +0000 (UTC) Received: from mail-qt1-f196.google.com (mail-qt1-f196.google.com [209.85.160.196]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-28-rZr_MUx3OcGbRCynBTaC3A-1; Sun, 23 Feb 2020 22:55:15 -0500 Received: by mail-qt1-f196.google.com with SMTP id l21so5690729qtr.8 for ; Sun, 23 Feb 2020 19:55:15 -0800 (PST) Received: from localhost.localdomain ([191.254.236.241]) by smtp.gmail.com with ESMTPSA id 64sm2652392qkd.78.2020.02.23.19.55.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 23 Feb 2020 19:55:13 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1582516532; 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=jHi1Qbzz7g9LP9KfsqPG9mhnLKIbTk415nq6zRX99o1ixvHauTpzJ1lJxAM9SXtaT9cZ5M hTq8Rnqs5D4xWFbrgJeXkHFXxzzQDmt/B+g3H+dvZpxdcfXY6l+gMUPcLMoBaqMFkQtt3v 7zmKAd+l+prRnfGqP0lz8EhwRaypV5w= X-MC-Unique: F8-DgMrqMRqw2nbVe2nBbw-1 X-MC-Unique: rZr_MUx3OcGbRCynBTaC3A-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=sdhXEjJeDd5YSPzmW8BUsFmEsikWzjooH6dpdpSPzgKrhH8JqgeVBG4CouD2lXSQuK WBeSYOX2vtgDWf7lr+2i1Bw4O3FvpJY+jJ8IRZSaPOaY9mz58W78bh8sD6aJgcpDNI9o o9Esm5mfDp4RDh5/sPgOuV+DINJb0U0/A7YjKc6fqx94q2Im6K+e4XqaRWRkxUNKtu3q Cjli2hsOUajsp9flnTtkLebJU9WWLumAKhjTSvWd6U2vNDqPdtVtufGEkcFljQfU2+hk lYT9a1l8IPinEc27Z6Avaeu55mVLasabRXexvCmmQEyKjroJnHsX0fU5onUdrEJmCy8q Xuog== X-Gm-Message-State: APjAAAUleu131aPkS7CRYw26mR90alfoZZGjScSqkk9OWKkzsGw49L7m pc+9Za5EPPFmv9L7wwRx7REXRXr9 X-Google-Smtp-Source: APXvYqwIjDL1sqV8E2CftEjIAISzFG/BCjiT6rh+Dfv0PzwZF1Yq8EFhLu5YS4vVLaKUaj73Bl2vuA== X-Received: by 2002:aed:2510:: with SMTP id v16mr45518708qtc.306.1582516514552; Sun, 23 Feb 2020 19:55:14 -0800 (PST) From: Julio Faracco To: libvir-list@redhat.com Subject: [PATCH v2 2/5] lxc: Add HPET device into allowed devices Date: Mon, 24 Feb 2020 00:54:27 -0300 Message-Id: <20200224035429.3973-3-jcfaracco@gmail.com> In-Reply-To: <20200224035429.3973-1-jcfaracco@gmail.com> References: <20200224035429.3973-1-jcfaracco@gmail.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.78 on 10.11.54.6 X-MIME-Autoconverted: from quoted-printable to 8bit by lists01.pubmisc.prod.ext.phx2.redhat.com id 01O3tK2e014596 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.84 on 10.5.11.23 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