From nobody Sat May 18 14:09:58 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) client-ip=170.10.133.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1650987277; cv=none; d=zohomail.com; s=zohoarc; b=RyqtL1pmA/M0AGgJtDcTJxfrKmFCJLE6rTpWL6EvDZEXiKTch+jh232izYhmo/KbB8/ebG2GNARebqThbGZHOzq07tExbBKjaOBUqXfn9eFvnBX6gKVEM3EIxwesuiRABaUHU6d0DO4GH9wuQZKe6o4lhZByqJCc+8CNzfAmPYg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1650987277; 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; bh=4eleLeXEKEljxOroa07740dxWcdqN/ydBQ0E6HIdxh4=; b=UE55PYQjNVVQfhSzU1O84L0Wdn/qbxEcw1Eds+JcLLhxLIx+9Fhtd55IZ2mmb9qn1lqqiOI3OPFIFL97+fyAqIJtwxXwoydBmo4UiCBsEQMH82c+IN9kGB+waR+1Kn/wGKtRmoVk37qyTwu9QALZRNFVVDMihHo0Tr6AtgWP71A= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mx.zohomail.com with SMTPS id 1650987277144565.7900451251812; Tue, 26 Apr 2022 08:34:37 -0700 (PDT) Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-2-x6r-9WBOMdutGqrEzFeC-Q-1; Tue, 26 Apr 2022 11:34:33 -0400 Received: from smtp.corp.redhat.com (int-mx10.intmail.prod.int.rdu2.redhat.com [10.11.54.10]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id E1F18381A827; Tue, 26 Apr 2022 15:34:30 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id CA7ED463ED1; Tue, 26 Apr 2022 15:34:30 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 7B4F11947BBB; Tue, 26 Apr 2022 15:34:30 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 64C0819451EC for ; Tue, 26 Apr 2022 15:34:29 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 48D5340D2824; Tue, 26 Apr 2022 15:34:29 +0000 (UTC) Received: from speedmetal.lan (unknown [10.40.208.14]) by smtp.corp.redhat.com (Postfix) with ESMTP id 73D79403D19A for ; Tue, 26 Apr 2022 15:34:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1650987276; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to: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=4eleLeXEKEljxOroa07740dxWcdqN/ydBQ0E6HIdxh4=; b=UBVAw8gXAZyMyecbaUwJZ0dI6qRAQxssnwsWdJmDMiJ1h1L+sM/Z5YCBoHonJuaICOIwYG UYg32cUio8jGIntMiTSBrOa5Umn+mZhzJ5Bv+yFHKBjIkfy2dfiEpZ3qeix+IgEc47bQFv GDmaOaX3eql0yZVN88WrU4Zn7YsuYHg= X-MC-Unique: x6r-9WBOMdutGqrEzFeC-Q-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Peter Krempa To: libvir-list@redhat.com Subject: [RFC PATCH 1/2] conf: Introduce 'absolute' clock offset Date: Tue, 26 Apr 2022 17:34:21 +0200 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.11.54.2 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 2.85 on 10.11.54.10 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1650987279260100001 Content-Type: text/plain; charset="utf-8" The 'absolute' clock offset type has a 'start' attribute which is an unix epoch timestamp to which the hardware clock is always set at start of the VM. This is useful if some VM needs to be kept set to an arbitrary time for e.g. testing or working around broken software. Signed-off-by: Peter Krempa Reviewed-by: Michal Privoznik --- docs/formatdomain.rst | 4 ++ src/conf/domain_conf.c | 13 +++++++ src/conf/domain_conf.h | 4 ++ src/conf/schemas/domaincommon.rng | 8 ++++ src/libxl/libxl_conf.c | 1 + tests/qemuxml2argvdata/clock-absolute.xml | 30 +++++++++++++++ .../clock-absolute.x86_64-latest.xml | 38 +++++++++++++++++++ tests/qemuxml2xmltest.c | 1 + 8 files changed, 99 insertions(+) create mode 100644 tests/qemuxml2argvdata/clock-absolute.xml create mode 100644 tests/qemuxml2xmloutdata/clock-absolute.x86_64-latest.x= ml diff --git a/docs/formatdomain.rst b/docs/formatdomain.rst index 9be305f3e6..5639a3014b 100644 --- a/docs/formatdomain.rst +++ b/docs/formatdomain.rst @@ -2170,6 +2170,10 @@ Windows, however, expects it to be in so called 'loc= altime'. the RTC adjustments are lost at each reboot. :since:`Since 0.7.7` :since:`Since 0.9.11` the ``basis`` attribute can be either 'utc' (default) or 'localtime'. + ``absolute`` + The guest clock will be always set to the value of the ``start`` + attribute. The ``start`` attribute takes the an epoch timestamp. + :since:`Since 8.4.0`. A ``clock`` may have zero or more ``timer`` sub-elements. :since:`Since 0.8.0` diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index bd2884088c..d0c88e6d7f 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -1171,6 +1171,7 @@ VIR_ENUM_IMPL(virDomainClockOffset, "localtime", "variable", "timezone", + "absolute", ); VIR_ENUM_IMPL(virDomainClockBasis, @@ -19412,6 +19413,15 @@ virDomainDefClockParse(virDomainDef *def, return -1; } break; + + case VIR_DOMAIN_CLOCK_OFFSET_ABSOLUTE: + if (virXPathULongLong("number(./clock/@start)", ctxt, + &def->clock.data.starttime) < 0) { + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("missing 'start' attribute for clock with off= set=3D'absolute'")); + return -1; + } + break; } if ((n =3D virXPathNodeSet("./clock/timer", ctxt, &nodes)) < 0) @@ -26202,6 +26212,9 @@ virDomainClockDefFormat(virBuffer *buf, case VIR_DOMAIN_CLOCK_OFFSET_TIMEZONE: virBufferEscapeString(&clockAttr, " timezone=3D'%s'", def->data.ti= mezone); break; + case VIR_DOMAIN_CLOCK_OFFSET_ABSOLUTE: + virBufferAsprintf(&clockAttr, " start=3D'%llu'", def->data.startti= me); + break; } for (n =3D 0; n < def->ntimers; n++) { diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h index 88a411d00c..3bdf4b51b1 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -2449,6 +2449,7 @@ typedef enum { VIR_DOMAIN_CLOCK_OFFSET_LOCALTIME =3D 1, VIR_DOMAIN_CLOCK_OFFSET_VARIABLE =3D 2, VIR_DOMAIN_CLOCK_OFFSET_TIMEZONE =3D 3, + VIR_DOMAIN_CLOCK_OFFSET_ABSOLUTE =3D 4, VIR_DOMAIN_CLOCK_OFFSET_LAST } virDomainClockOffsetType; @@ -2483,6 +2484,9 @@ struct _virDomainClockDef { /* Timezone name, when * offset =3D=3D VIR_DOMAIN_CLOCK_OFFSET_LOCALTIME */ char *timezone; + + /* absolute clock start time for VIR_DOMAIN_CLOCK_OFFSET_ABSOLUTE = */ + unsigned long long starttime; } data; size_t ntimers; diff --git a/src/conf/schemas/domaincommon.rng b/src/conf/schemas/domaincom= mon.rng index 8afb0dadd4..d0c9ea7973 100644 --- a/src/conf/schemas/domaincommon.rng +++ b/src/conf/schemas/domaincommon.rng @@ -1252,6 +1252,14 @@ + + + absolute + + + + + diff --git a/src/libxl/libxl_conf.c b/src/libxl/libxl_conf.c index 6398129195..a0d4ba51ba 100644 --- a/src/libxl/libxl_conf.c +++ b/src/libxl/libxl_conf.c @@ -391,6 +391,7 @@ libxlMakeDomBuildInfo(virDomainDef *def, virDomainClockOffsetTypeToString(clock.offset)); return -1; + case VIR_DOMAIN_CLOCK_OFFSET_ABSOLUTE: case VIR_DOMAIN_CLOCK_OFFSET_LAST: default: virReportError(VIR_ERR_CONFIG_UNSUPPORTED, diff --git a/tests/qemuxml2argvdata/clock-absolute.xml b/tests/qemuxml2argv= data/clock-absolute.xml new file mode 100644 index 0000000000..e79f53ed3c --- /dev/null +++ b/tests/qemuxml2argvdata/clock-absolute.xml @@ -0,0 +1,30 @@ + + QEMUGuest1 + c7a5fdbd-edaf-9455-926a-d65c16db1809 + 219100 + 219100 + 1 + + hvm + + + + destroy + restart + destroy + + /usr/bin/qemu-system-x86_64 + + + + +
+ + + + + + + + + diff --git a/tests/qemuxml2xmloutdata/clock-absolute.x86_64-latest.xml b/te= sts/qemuxml2xmloutdata/clock-absolute.x86_64-latest.xml new file mode 100644 index 0000000000..b313a74039 --- /dev/null +++ b/tests/qemuxml2xmloutdata/clock-absolute.x86_64-latest.xml @@ -0,0 +1,38 @@ + + QEMUGuest1 + c7a5fdbd-edaf-9455-926a-d65c16db1809 + 219100 + 219100 + 1 + + hvm + + + + qemu64 + + + destroy + restart + destroy + + /usr/bin/qemu-system-x86_64 + + + + +
+ + +
+ + +
+ + + + +