From nobody Wed May 8 07:17:34 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; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1519172984270995.6661246589433; Tue, 20 Feb 2018 16:29:44 -0800 (PST) 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 A234B80462; Wed, 21 Feb 2018 00:29:41 +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 59CA05D9CA; Wed, 21 Feb 2018 00:29:40 +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 0638A18033EA; Wed, 21 Feb 2018 00:29:37 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w1L0TZFf011803 for ; Tue, 20 Feb 2018 19:29:35 -0500 Received: by smtp.corp.redhat.com (Postfix) id 8A5C55D75C; Wed, 21 Feb 2018 00:29:35 +0000 (UTC) Received: from mx1.redhat.com (ext-mx10.extmail.prod.ext.phx2.redhat.com [10.5.110.39]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 8298C5D70C for ; Wed, 21 Feb 2018 00:29:33 +0000 (UTC) Received: from smtp2.provo.novell.com (smtp2.provo.novell.com [137.65.250.81]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id D87675D5F4 for ; Wed, 21 Feb 2018 00:29:31 +0000 (UTC) Received: from linux-tbji.provo.novell.com (prv-ext-foundry1int.gns.novell.com [137.65.251.240]) by smtp2.provo.novell.com with ESMTP (NOT encrypted); Tue, 20 Feb 2018 17:29:28 -0700 From: Jim Fehlig To: libvir-list@redhat.com Date: Tue, 20 Feb 2018 17:28:57 -0700 Message-Id: <20180221002857.13438-1-jfehlig@suse.com> X-Greylist: Sender passed SPF test, Sender IP whitelisted by DNSRBL, ACL 207 matched, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.39]); Wed, 21 Feb 2018 00:29:32 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.39]); Wed, 21 Feb 2018 00:29:32 +0000 (UTC) for IP:'137.65.250.81' DOMAIN:'smtp2.provo.novell.com' HELO:'smtp2.provo.novell.com' FROM:'jfehlig@suse.com' RCPT:'' X-RedHat-Spam-Score: -2.301 (RCVD_IN_DNSWL_MED, SPF_PASS) 137.65.250.81 smtp2.provo.novell.com 137.65.250.81 smtp2.provo.novell.com X-Scanned-By: MIMEDefang 2.78 on 10.5.110.39 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH] libxl: add support for specifying clock offset and adjustment 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: , MIME-Version: 1.0 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.28]); Wed, 21 Feb 2018 00:29:43 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" libxl supports setting the domain real time clock to local time or UTC via the localtime field of libxl_domain_build_info. Adjustment of the clock is also supported via the rtc_timeoffset field. The libvirt libxl driver has never supported these settings, instead relying on libxl's default of a UTC real time clock with adjustment set to 0. There is at least one user that would like the ability to change the defaults https://www.redhat.com/archives/libvirt-users/2018-February/msg00059.html Add support for specifying a local time clock and for specifying an adjustment for both local time and UTC clocks. Add a test case to verify the XML to libxl_domain_config conversion. Local time clock and clock adjustment is already supported by the XML <-> xl.cfg converter. What is missing is an explicit test for the conversion. There are plenty of existing tests that all use UTC with 0 adjustment. Hijack test-fullvirt-tsc-timer to test a local time clock with 1 hour adjustment. Signed-off-by: Jim Fehlig Reviewed-by: Daniel P. Berrang=C3=A9 --- src/libxl/libxl_conf.c | 35 +++++++-- .../libxlxml2domconfigdata/variable-clock-hvm.json | 91 ++++++++++++++++++= ++++ .../libxlxml2domconfigdata/variable-clock-hvm.xml | 36 +++++++++ tests/libxlxml2domconfigtest.c | 1 + tests/xlconfigdata/test-fullvirt-tsc-timer.cfg | 4 +- tests/xlconfigdata/test-fullvirt-tsc-timer.xml | 2 +- 6 files changed, 160 insertions(+), 9 deletions(-) diff --git a/src/libxl/libxl_conf.c b/src/libxl/libxl_conf.c index 0c5de344d..39ae709c7 100644 --- a/src/libxl/libxl_conf.c +++ b/src/libxl/libxl_conf.c @@ -274,6 +274,7 @@ libxlMakeDomBuildInfo(virDomainDefPtr def, virCapsPtr caps, libxl_domain_config *d_config) { + virDomainClockDef clock =3D def->clock; libxl_domain_build_info *b_info =3D &d_config->b_info; int hvm =3D def->os.type =3D=3D VIR_DOMAIN_OSTYPE_HVM; size_t i; @@ -293,10 +294,32 @@ libxlMakeDomBuildInfo(virDomainDefPtr def, for (i =3D 0; i < virDomainDefGetVcpus(def); i++) libxl_bitmap_set((&b_info->avail_vcpus), i); =20 - for (i =3D 0; i < def->clock.ntimers; i++) { - switch ((virDomainTimerNameType) def->clock.timers[i]->name) { + switch (clock.offset) { + case VIR_DOMAIN_CLOCK_OFFSET_VARIABLE: + if (clock.data.variable.basis =3D=3D VIR_DOMAIN_CLOCK_BASIS_LOCALT= IME) + libxl_defbool_set(&b_info->localtime, true); + b_info->rtc_timeoffset =3D clock.data.variable.adjustment; + break; + + case VIR_DOMAIN_CLOCK_OFFSET_LOCALTIME: + libxl_defbool_set(&b_info->localtime, true); + break; + + /* Nothing to do since UTC is the default in libxl */ + case VIR_DOMAIN_CLOCK_OFFSET_UTC: + break; + + default: + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("unsupported clock offset '%s'"), + virDomainClockOffsetTypeToString(clock.offset)); + return -1; + } + + for (i =3D 0; i < clock.ntimers; i++) { + switch ((virDomainTimerNameType) clock.timers[i]->name) { case VIR_DOMAIN_TIMER_NAME_TSC: - switch (def->clock.timers[i]->mode) { + switch (clock.timers[i]->mode) { case VIR_DOMAIN_TIMER_MODE_NATIVE: b_info->tsc_mode =3D LIBXL_TSC_MODE_NATIVE; break; @@ -315,10 +338,10 @@ libxlMakeDomBuildInfo(virDomainDefPtr def, if (!hvm) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, _("unsupported timer type (name) '%s'"), - virDomainTimerNameTypeToString(def->clock.t= imers[i]->name)); + virDomainTimerNameTypeToString(clock.timers= [i]->name)); return -1; } - if (def->clock.timers[i]->present =3D=3D 1) + if (clock.timers[i]->present =3D=3D 1) libxl_defbool_set(&b_info->u.hvm.hpet, 1); break; =20 @@ -329,7 +352,7 @@ libxlMakeDomBuildInfo(virDomainDefPtr def, case VIR_DOMAIN_TIMER_NAME_PIT: virReportError(VIR_ERR_CONFIG_UNSUPPORTED, _("unsupported timer type (name) '%s'"), - virDomainTimerNameTypeToString(def->clock.timer= s[i]->name)); + virDomainTimerNameTypeToString(clock.timers[i]-= >name)); return -1; =20 case VIR_DOMAIN_TIMER_NAME_LAST: diff --git a/tests/libxlxml2domconfigdata/variable-clock-hvm.json b/tests/l= ibxlxml2domconfigdata/variable-clock-hvm.json new file mode 100644 index 000000000..49d0a4330 --- /dev/null +++ b/tests/libxlxml2domconfigdata/variable-clock-hvm.json @@ -0,0 +1,91 @@ +{ + "c_info": { + "type": "hvm", + "name": "test-hvm", + "uuid": "2147d599-9cc6-c0dc-92ab-4064b5446e9b" + }, + "b_info": { + "max_vcpus": 4, + "avail_vcpus": [ + 0, + 1, + 2, + 3 + ], + "max_memkb": 1048576, + "target_memkb": 1048576, + "video_memkb": 8192, + "shadow_memkb": 12288, + "rtc_timeoffset": 3600, + "localtime": "True", + "device_model_version": "qemu_xen", + "device_model": "/bin/true", + "sched_params": { + "weight": 1000 + }, + "type.hvm": { + "pae": "True", + "apic": "True", + "acpi": "True", + "vga": { + "kind": "cirrus" + }, + "vnc": { + "enable": "True", + "listen": "0.0.0.0", + "findunused": "False" + }, + "sdl": { + "enable": "False" + }, + "spice": { + + }, + "boot": "c", + "rdm": { + + } + }, + "arch_arm": { + + } + }, + "disks": [ + { + "pdev_path": "/var/lib/xen/images/test-hvm.img", + "vdev": "hda", + "backend": "qdisk", + "format": "raw", + "removable": 1, + "readwrite": 1 + } + ], + "nics": [ + { + "devid": 0, + "mac": "00:16:3e:66:12:b4", + "bridge": "br0", + "script": "/etc/xen/scripts/vif-bridge", + "nictype": "vif_ioemu" + } + ], + "vfbs": [ + { + "devid": -1, + "vnc": { + "enable": "True", + "listen": "0.0.0.0", + "findunused": "False" + }, + "sdl": { + "enable": "False" + } + } + ], + "vkbs": [ + { + "devid": -1 + } + ], + "on_reboot": "restart" +} diff --git a/tests/libxlxml2domconfigdata/variable-clock-hvm.xml b/tests/li= bxlxml2domconfigdata/variable-clock-hvm.xml new file mode 100644 index 000000000..608788779 --- /dev/null +++ b/tests/libxlxml2domconfigdata/variable-clock-hvm.xml @@ -0,0 +1,36 @@ + + test-hvm + None + 2147d599-9cc6-c0dc-92ab-4064b5446e9b + 1048576 + 1048576 + 4 + destroy + restart + destroy + + + hvm + /usr/lib/xen/boot/hvmloader + + + + + + + + + /bin/true + + + + + + + + +