From nobody Wed Feb 11 10:09:39 2026 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.zoho.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 1490361937820963.9461252331114; Fri, 24 Mar 2017 06:25:37 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id B33C19D433; Fri, 24 Mar 2017 13:25:36 +0000 (UTC) Received: from colo-mx.corp.redhat.com (unknown [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 7CD927A227; Fri, 24 Mar 2017 13:25:36 +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 30DE25EC63; Fri, 24 Mar 2017 13:25:36 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id v2ODPVxp003400 for ; Fri, 24 Mar 2017 09:25:31 -0400 Received: by smtp.corp.redhat.com (Postfix) id B4C5B84400; Fri, 24 Mar 2017 13:25:31 +0000 (UTC) Received: from virval.usersys.redhat.com (dhcp129-92.brq.redhat.com [10.34.129.92]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 5651F8440D for ; Fri, 24 Mar 2017 13:25:29 +0000 (UTC) Received: by virval.usersys.redhat.com (Postfix, from userid 500) id 4CB0910322A; Fri, 24 Mar 2017 14:25:28 +0100 (CET) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com B33C19D433 Authentication-Results: ext-mx10.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx10.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=libvir-list-bounces@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com B33C19D433 From: Jiri Denemark To: libvir-list@redhat.com Date: Fri, 24 Mar 2017 14:25:20 +0100 Message-Id: <3eb39a8814697b0e71d99d9190fc167eda82a844.1490361810.git.jdenemar@redhat.com> In-Reply-To: References: In-Reply-To: References: Mail-Followup-To: libvir-list@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 2/4] qemu: Add support for setting TSC frequency 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.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.39]); Fri, 24 Mar 2017 13:25:37 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" QEMU allows for TSC frequency to be explicitly set to enable migration with invtsc (migration fails if the destination QEMU cannot set the exact same frequency used when starting the domain on the source host). Libvirt already supports setting the TSC frequency in the XML using which will be transformed into -cpu Model,tsc-frequency=3D1234567890 QEMU command line. Signed-off-by: Jiri Denemark --- src/qemu/qemu_command.c | 16 ++++++---- .../qemuxml2argv-cpu-tsc-frequency.args | 23 ++++++++++++++ .../qemuxml2argv-cpu-tsc-frequency.xml | 35 ++++++++++++++++++= ++++ tests/qemuxml2argvtest.c | 1 + 4 files changed, 69 insertions(+), 6 deletions(-) create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-cpu-tsc-frequency.a= rgs create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-cpu-tsc-frequency.x= ml diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index 2045c2e7c..8c2e43e60 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -6284,12 +6284,12 @@ qemuBuildClockCommandLine(virCommandPtr cmd, for (i =3D 0; i < def->clock.ntimers; i++) { switch ((virDomainTimerNameType) def->clock.timers[i]->name) { case VIR_DOMAIN_TIMER_NAME_PLATFORM: - case VIR_DOMAIN_TIMER_NAME_TSC: virReportError(VIR_ERR_CONFIG_UNSUPPORTED, _("unsupported timer type (name) '%s'"), virDomainTimerNameTypeToString(def->clock.timer= s[i]->name)); return -1; =20 + case VIR_DOMAIN_TIMER_NAME_TSC: case VIR_DOMAIN_TIMER_NAME_KVMCLOCK: case VIR_DOMAIN_TIMER_NAME_HYPERVCLOCK: /* Timers above are handled when building -cpu. */ @@ -6876,19 +6876,23 @@ qemuBuildCpuCommandLine(virCommandPtr cmd, for (i =3D 0; i < def->clock.ntimers; i++) { virDomainTimerDefPtr timer =3D def->clock.timers[i]; =20 - if (timer->present =3D=3D -1) - continue; - - if (timer->name =3D=3D VIR_DOMAIN_TIMER_NAME_KVMCLOCK) { + if (timer->name =3D=3D VIR_DOMAIN_TIMER_NAME_KVMCLOCK && + timer->present !=3D -1) { virBufferAsprintf(&buf, "%s,%ckvmclock", have_cpu ? "" : default_model, timer->present ? '+' : '-'); have_cpu =3D true; } else if (timer->name =3D=3D VIR_DOMAIN_TIMER_NAME_HYPERVCLOCK && - timer->present) { + timer->present =3D=3D 1) { virBufferAsprintf(&buf, "%s,hv_time", have_cpu ? "" : default_model); have_cpu =3D true; + } else if (timer->name =3D=3D VIR_DOMAIN_TIMER_NAME_TSC && + timer->frequency > 0) { + virBufferAsprintf(&buf, "%s,tsc-frequency=3D%lu", + have_cpu ? "" : default_model, + timer->frequency); + have_cpu =3D true; } } =20 diff --git a/tests/qemuxml2argvdata/qemuxml2argv-cpu-tsc-frequency.args b/t= ests/qemuxml2argvdata/qemuxml2argv-cpu-tsc-frequency.args new file mode 100644 index 000000000..50223fab2 --- /dev/null +++ b/tests/qemuxml2argvdata/qemuxml2argv-cpu-tsc-frequency.args @@ -0,0 +1,23 @@ +LC_ALL=3DC \ +PATH=3D/bin \ +HOME=3D/home/test \ +USER=3Dtest \ +LOGNAME=3Dtest \ +QEMU_AUDIO_DRV=3Dnone \ +/usr/bin/qemu \ +-name QEMUGuest1 \ +-S \ +-M pc \ +-cpu Haswell,+vme,+ds,+acpi,+ss,+ht,+tm,+pbe,+dtes64,+monitor,+ds_cpl,+vmx= ,\ ++smx,+est,+tm2,+xtpr,+pdcm,+osxsave,+f16c,+rdrand,+pdpe1gb,+abm,+lahf_lm,\ ++invtsc,tsc-frequency=3D3504000000 \ +-m 214 \ +-smp 1,sockets=3D1,cores=3D1,threads=3D1 \ +-uuid c7a5fdbd-edaf-9455-926a-d65c16db1809 \ +-nographic \ +-nodefaults \ +-monitor unix:/tmp/lib/domain--1-QEMUGuest1/monitor.sock,server,nowait \ +-no-acpi \ +-boot c \ +-usb \ +-device virtio-balloon-pci,id=3Dballoon0,bus=3Dpci.0,addr=3D0x3 diff --git a/tests/qemuxml2argvdata/qemuxml2argv-cpu-tsc-frequency.xml b/te= sts/qemuxml2argvdata/qemuxml2argv-cpu-tsc-frequency.xml new file mode 100644 index 000000000..72afe6cd2 --- /dev/null +++ b/tests/qemuxml2argvdata/qemuxml2argv-cpu-tsc-frequency.xml @@ -0,0 +1,35 @@ + + QEMUGuest1 + c7a5fdbd-edaf-9455-926a-d65c16db1809 + A description of the test machine. + + A test of qemu's minimal configuration. + This test also tests the description and title elements. + + 219100 + 219100 + 1 + + hvm + + + + + + + + + + destroy + restart + destroy + + /usr/bin/qemu + + + + + + + + diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c index ec73ac7e3..339048d8e 100644 --- a/tests/qemuxml2argvtest.c +++ b/tests/qemuxml2argvtest.c @@ -1543,6 +1543,7 @@ mymain(void) DO_TEST("cpu-Haswell3", QEMU_CAPS_KVM); DO_TEST("cpu-Haswell-noTSX", QEMU_CAPS_KVM); DO_TEST("cpu-host-model-cmt", NONE); + DO_TEST("cpu-tsc-frequency", QEMU_CAPS_KVM); qemuTestSetHostCPU(driver.caps, NULL); =20 DO_TEST("encrypted-disk", NONE); --=20 2.12.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list