[libvirt PATCH] schema: Add support for high TSC frequency

Jiri Denemark posted 1 patch 3 years, 4 months ago
Test syntax-check failed
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/libvirt tags/patchew/3f09ad8c6b33e66bd19f21c76cc5651723dd4466.1605095014.git.jdenemar@redhat.com
docs/schemas/domaincommon.rng                 |  2 +-
.../cpu-tsc-high-frequency.x86_64-latest.args | 38 +++++++++++++++++++
.../cpu-tsc-high-frequency.xml                | 35 +++++++++++++++++
tests/qemuxml2argvtest.c                      |  1 +
4 files changed, 75 insertions(+), 1 deletion(-)
create mode 100644 tests/qemuxml2argvdata/cpu-tsc-high-frequency.x86_64-latest.args
create mode 100644 tests/qemuxml2argvdata/cpu-tsc-high-frequency.xml
[libvirt PATCH] schema: Add support for high TSC frequency
Posted by Jiri Denemark 3 years, 4 months ago
The unsignedInt XML schema type allows for values up to 2^32 - 1, i.e.,
using 4294967296 or greater TSC frequency would fail schema validation.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
---
 docs/schemas/domaincommon.rng                 |  2 +-
 .../cpu-tsc-high-frequency.x86_64-latest.args | 38 +++++++++++++++++++
 .../cpu-tsc-high-frequency.xml                | 35 +++++++++++++++++
 tests/qemuxml2argvtest.c                      |  1 +
 4 files changed, 75 insertions(+), 1 deletion(-)
 create mode 100644 tests/qemuxml2argvdata/cpu-tsc-high-frequency.x86_64-latest.args
 create mode 100644 tests/qemuxml2argvdata/cpu-tsc-high-frequency.xml

diff --git a/docs/schemas/domaincommon.rng b/docs/schemas/domaincommon.rng
index 97fa873977..e0d09f9c03 100644
--- a/docs/schemas/domaincommon.rng
+++ b/docs/schemas/domaincommon.rng
@@ -1235,7 +1235,7 @@
           </optional>
           <optional>
             <attribute name="frequency">
-              <ref name="unsignedInt"/>
+              <ref name="unsignedLong"/>
             </attribute>
           </optional>
           <optional>
diff --git a/tests/qemuxml2argvdata/cpu-tsc-high-frequency.x86_64-latest.args b/tests/qemuxml2argvdata/cpu-tsc-high-frequency.x86_64-latest.args
new file mode 100644
index 0000000000..16a4282ab1
--- /dev/null
+++ b/tests/qemuxml2argvdata/cpu-tsc-high-frequency.x86_64-latest.args
@@ -0,0 +1,38 @@
+LC_ALL=C \
+PATH=/bin \
+HOME=/tmp/lib/domain--1-QEMUGuest1 \
+USER=test \
+LOGNAME=test \
+XDG_DATA_HOME=/tmp/lib/domain--1-QEMUGuest1/.local/share \
+XDG_CACHE_HOME=/tmp/lib/domain--1-QEMUGuest1/.cache \
+XDG_CONFIG_HOME=/tmp/lib/domain--1-QEMUGuest1/.config \
+QEMU_AUDIO_DRV=none \
+/usr/bin/qemu-system-x86_64 \
+-name guest=QEMUGuest1,debug-threads=on \
+-S \
+-object secret,id=masterKey0,format=raw,\
+file=/tmp/lib/domain--1-QEMUGuest1/master-key.aes \
+-machine pc,accel=kvm,usb=off,dump-guest-core=off,memory-backend=pc.ram \
+-cpu EPYC-Rome,x2apic=on,tsc-deadline=on,hypervisor=on,tsc-adjust=on,stibp=on,\
+arch-capabilities=on,ssbd=on,xsaves=on,cmp-legacy=on,amd-ssbd=on,virt-ssbd=on,\
+rdctl-no=on,skip-l1dfl-vmentry=on,mds-no=on,pschange-mc-no=on,invtsc=on,\
+tsc-frequency=4567890000 \
+-m 214 \
+-object memory-backend-ram,id=pc.ram,size=224395264 \
+-overcommit mem-lock=off \
+-smp 1,sockets=1,cores=1,threads=1 \
+-uuid c7a5fdbd-edaf-9455-926a-d65c16db1809 \
+-display none \
+-no-user-config \
+-nodefaults \
+-chardev socket,id=charmonitor,fd=1729,server,nowait \
+-mon chardev=charmonitor,id=monitor,mode=control \
+-rtc base=utc \
+-no-shutdown \
+-no-acpi \
+-boot strict=on \
+-device piix3-usb-uhci,id=usb,bus=pci.0,addr=0x1.0x2 \
+-device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x2 \
+-sandbox on,obsolete=deny,elevateprivileges=deny,spawn=deny,\
+resourcecontrol=deny \
+-msg timestamp=on
diff --git a/tests/qemuxml2argvdata/cpu-tsc-high-frequency.xml b/tests/qemuxml2argvdata/cpu-tsc-high-frequency.xml
new file mode 100644
index 0000000000..afaef6e8e5
--- /dev/null
+++ b/tests/qemuxml2argvdata/cpu-tsc-high-frequency.xml
@@ -0,0 +1,35 @@
+<domain type='kvm'>
+  <name>QEMUGuest1</name>
+  <uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid>
+  <title>A description of the test machine.</title>
+  <description>
+      A test of qemu&apos;s minimal configuration.
+      This test also tests the description and title elements.
+  </description>
+  <memory unit='KiB'>219100</memory>
+  <currentMemory unit='KiB'>219100</currentMemory>
+  <vcpu placement='static'>1</vcpu>
+  <os>
+    <type arch='x86_64' machine='pc'>hvm</type>
+    <boot dev='hd'/>
+  </os>
+  <cpu mode='host-model'>
+    <model fallback='allow'/>
+    <feature policy='require' name='invtsc'/>
+  </cpu>
+  <clock offset='utc'>
+    <timer name='tsc' frequency='4567890000'/>
+  </clock>
+  <on_poweroff>destroy</on_poweroff>
+  <on_reboot>restart</on_reboot>
+  <on_crash>destroy</on_crash>
+  <devices>
+    <emulator>/usr/bin/qemu-system-x86_64</emulator>
+    <controller type='usb' index='0'/>
+    <controller type='ide' index='0'/>
+    <controller type='pci' index='0' model='pci-root'/>
+    <input type='mouse' bus='ps2'/>
+    <input type='keyboard' bus='ps2'/>
+    <memballoon model='virtio'/>
+  </devices>
+</domain>
diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c
index ec33134a97..174294c0f1 100644
--- a/tests/qemuxml2argvtest.c
+++ b/tests/qemuxml2argvtest.c
@@ -1953,6 +1953,7 @@ mymain(void)
     DO_TEST_CAPS_VER("cpu-host-model-cmt", "4.0.0");
     DO_TEST("cpu-tsc-frequency", QEMU_CAPS_KVM);
     DO_TEST_CAPS_VER("cpu-tsc-frequency", "4.0.0");
+    DO_TEST_CAPS_LATEST("cpu-tsc-high-frequency");
     DO_TEST_CAPS_VER("cpu-translation", "4.0.0");
     DO_TEST_CAPS_LATEST("cpu-translation");
     qemuTestSetHostCPU(&driver, driver.hostarch, NULL);
-- 
2.29.2

Re: [libvirt PATCH] schema: Add support for high TSC frequency
Posted by Peter Krempa 3 years, 4 months ago
On Wed, Nov 11, 2020 at 12:43:34 +0100, Jiri Denemark wrote:
> The unsignedInt XML schema type allows for values up to 2^32 - 1, i.e.,
> using 4294967296 or greater TSC frequency would fail schema validation.
> 
> Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
> ---

Reviewed-by: Peter Krempa <pkrempa@redhat.com>

Re: [libvirt PATCH] schema: Add support for high TSC frequency
Posted by Ján Tomko 3 years, 4 months ago
On a Wednesday in 2020, Jiri Denemark wrote:
>The unsignedInt XML schema type allows for values up to 2^32 - 1, i.e.,
>using 4294967296 or greater TSC frequency would fail schema validation.
>
>Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
>---
> docs/schemas/domaincommon.rng                 |  2 +-
> .../cpu-tsc-high-frequency.x86_64-latest.args | 38 +++++++++++++++++++
> .../cpu-tsc-high-frequency.xml                | 35 +++++++++++++++++
> tests/qemuxml2argvtest.c                      |  1 +
> 4 files changed, 75 insertions(+), 1 deletion(-)
> create mode 100644 tests/qemuxml2argvdata/cpu-tsc-high-frequency.x86_64-latest.args
> create mode 100644 tests/qemuxml2argvdata/cpu-tsc-high-frequency.xml
>
>diff --git a/docs/schemas/domaincommon.rng b/docs/schemas/domaincommon.rng
>index 97fa873977..e0d09f9c03 100644
>--- a/docs/schemas/domaincommon.rng
>+++ b/docs/schemas/domaincommon.rng
>@@ -1235,7 +1235,7 @@
>           </optional>
>           <optional>
>             <attribute name="frequency">
>-              <ref name="unsignedInt"/>
>+              <ref name="unsignedLong"/>

Even though Relax NG's unisgnedLong (which our unisgnedLong is based on)
is 64-bit, the same does not hold up for C's unsigned long.

You need to change the C type as well to appease i686 debian:
https://gitlab.com/libvirt/libvirt/-/jobs/843130876

Jano

>             </attribute>
>           </optional>
>           <optional>
>diff --git a/tests/qemuxml2argvdata/cpu-tsc-high-frequency.x86_64-latest.args b/tests/qemuxml2argvdata/cpu-tsc-high-frequency.x86_64-latest.args
>new file mode 100644
>index 0000000000..16a4282ab1
>--- /dev/null
>+++ b/tests/qemuxml2argvdata/cpu-tsc-high-frequency.x86_64-latest.args
>@@ -0,0 +1,38 @@
>+LC_ALL=C \
>+PATH=/bin \
>+HOME=/tmp/lib/domain--1-QEMUGuest1 \
>+USER=test \
>+LOGNAME=test \
>+XDG_DATA_HOME=/tmp/lib/domain--1-QEMUGuest1/.local/share \
>+XDG_CACHE_HOME=/tmp/lib/domain--1-QEMUGuest1/.cache \
>+XDG_CONFIG_HOME=/tmp/lib/domain--1-QEMUGuest1/.config \
>+QEMU_AUDIO_DRV=none \
>+/usr/bin/qemu-system-x86_64 \
>+-name guest=QEMUGuest1,debug-threads=on \
>+-S \
>+-object secret,id=masterKey0,format=raw,\
>+file=/tmp/lib/domain--1-QEMUGuest1/master-key.aes \
>+-machine pc,accel=kvm,usb=off,dump-guest-core=off,memory-backend=pc.ram \
>+-cpu EPYC-Rome,x2apic=on,tsc-deadline=on,hypervisor=on,tsc-adjust=on,stibp=on,\
>+arch-capabilities=on,ssbd=on,xsaves=on,cmp-legacy=on,amd-ssbd=on,virt-ssbd=on,\
>+rdctl-no=on,skip-l1dfl-vmentry=on,mds-no=on,pschange-mc-no=on,invtsc=on,\
>+tsc-frequency=4567890000 \
>+-m 214 \
>+-object memory-backend-ram,id=pc.ram,size=224395264 \
>+-overcommit mem-lock=off \
>+-smp 1,sockets=1,cores=1,threads=1 \
>+-uuid c7a5fdbd-edaf-9455-926a-d65c16db1809 \
>+-display none \
>+-no-user-config \
>+-nodefaults \
>+-chardev socket,id=charmonitor,fd=1729,server,nowait \
>+-mon chardev=charmonitor,id=monitor,mode=control \
>+-rtc base=utc \
>+-no-shutdown \
>+-no-acpi \
>+-boot strict=on \
>+-device piix3-usb-uhci,id=usb,bus=pci.0,addr=0x1.0x2 \
>+-device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x2 \
>+-sandbox on,obsolete=deny,elevateprivileges=deny,spawn=deny,\
>+resourcecontrol=deny \
>+-msg timestamp=on
>diff --git a/tests/qemuxml2argvdata/cpu-tsc-high-frequency.xml b/tests/qemuxml2argvdata/cpu-tsc-high-frequency.xml
>new file mode 100644
>index 0000000000..afaef6e8e5
>--- /dev/null
>+++ b/tests/qemuxml2argvdata/cpu-tsc-high-frequency.xml
>@@ -0,0 +1,35 @@
>+<domain type='kvm'>
>+  <name>QEMUGuest1</name>
>+  <uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid>
>+  <title>A description of the test machine.</title>
>+  <description>
>+      A test of qemu&apos;s minimal configuration.
>+      This test also tests the description and title elements.
>+  </description>
>+  <memory unit='KiB'>219100</memory>
>+  <currentMemory unit='KiB'>219100</currentMemory>
>+  <vcpu placement='static'>1</vcpu>
>+  <os>
>+    <type arch='x86_64' machine='pc'>hvm</type>
>+    <boot dev='hd'/>
>+  </os>
>+  <cpu mode='host-model'>
>+    <model fallback='allow'/>
>+    <feature policy='require' name='invtsc'/>
>+  </cpu>
>+  <clock offset='utc'>
>+    <timer name='tsc' frequency='4567890000'/>
>+  </clock>
>+  <on_poweroff>destroy</on_poweroff>
>+  <on_reboot>restart</on_reboot>
>+  <on_crash>destroy</on_crash>
>+  <devices>
>+    <emulator>/usr/bin/qemu-system-x86_64</emulator>
>+    <controller type='usb' index='0'/>
>+    <controller type='ide' index='0'/>
>+    <controller type='pci' index='0' model='pci-root'/>
>+    <input type='mouse' bus='ps2'/>
>+    <input type='keyboard' bus='ps2'/>
>+    <memballoon model='virtio'/>
>+  </devices>
>+</domain>
>diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c
>index ec33134a97..174294c0f1 100644
>--- a/tests/qemuxml2argvtest.c
>+++ b/tests/qemuxml2argvtest.c
>@@ -1953,6 +1953,7 @@ mymain(void)
>     DO_TEST_CAPS_VER("cpu-host-model-cmt", "4.0.0");
>     DO_TEST("cpu-tsc-frequency", QEMU_CAPS_KVM);
>     DO_TEST_CAPS_VER("cpu-tsc-frequency", "4.0.0");
>+    DO_TEST_CAPS_LATEST("cpu-tsc-high-frequency");
>     DO_TEST_CAPS_VER("cpu-translation", "4.0.0");
>     DO_TEST_CAPS_LATEST("cpu-translation");
>     qemuTestSetHostCPU(&driver, driver.hostarch, NULL);
>-- 
>2.29.2
>