[PATCH] conf, schema: Switch iothread/poll values to unsignedLong

Martin Kletzander posted 1 patch 9 months, 2 weeks ago
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/libvirt tags/patchew/c68f59c42ca491a112aef35628f82634e68f38ff.1693603934.git.mkletzan@redhat.com
src/conf/schemas/domaincommon.rng          |  6 +++---
tests/genericxml2xmlindata/iothreadids.xml | 23 ++++++++++++++++++++++
tests/genericxml2xmltest.c                 |  2 ++
3 files changed, 28 insertions(+), 3 deletions(-)
create mode 100644 tests/genericxml2xmlindata/iothreadids.xml
[PATCH] conf, schema: Switch iothread/poll values to unsignedLong
Posted by Martin Kletzander 9 months, 2 weeks ago
They represent nanoseconds, and we accept such values already.  Not that
anyone would use such values in the wild, but even one person testing
QEMU could put in a bigger value and will be bothered with validation
errors after every `virsh edit`.  Also add a test for it.

Resolves: https://issues.redhat.com/browse/RHEL-1717

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
---
 src/conf/schemas/domaincommon.rng          |  6 +++---
 tests/genericxml2xmlindata/iothreadids.xml | 23 ++++++++++++++++++++++
 tests/genericxml2xmltest.c                 |  2 ++
 3 files changed, 28 insertions(+), 3 deletions(-)
 create mode 100644 tests/genericxml2xmlindata/iothreadids.xml

diff --git a/src/conf/schemas/domaincommon.rng b/src/conf/schemas/domaincommon.rng
index de3bd1c35c55..2f9ba31c0aec 100644
--- a/src/conf/schemas/domaincommon.rng
+++ b/src/conf/schemas/domaincommon.rng
@@ -876,17 +876,17 @@
                 <element name="poll">
                   <optional>
                     <attribute name="max">
-                      <ref name="unsignedInt"/>
+                      <ref name="unsignedLong"/>
                     </attribute>
                   </optional>
                   <optional>
                     <attribute name="grow">
-                      <ref name="unsignedInt"/>
+                      <ref name="unsignedLong"/>
                     </attribute>
                   </optional>
                   <optional>
                     <attribute name="shrink">
-                      <ref name="unsignedInt"/>
+                      <ref name="unsignedLong"/>
                     </attribute>
                   </optional>
                 </element>
diff --git a/tests/genericxml2xmlindata/iothreadids.xml b/tests/genericxml2xmlindata/iothreadids.xml
new file mode 100644
index 000000000000..671a4672958d
--- /dev/null
+++ b/tests/genericxml2xmlindata/iothreadids.xml
@@ -0,0 +1,23 @@
+<domain type='kvm'>
+  <name>foo</name>
+  <uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid>
+  <memory unit='KiB'>219136</memory>
+  <currentMemory unit='KiB'>219136</currentMemory>
+  <vcpu placement='static'>1</vcpu>
+  <iothreads>1</iothreads>
+  <iothreadids>
+    <iothread id='8' thread_pool_min='2147483647' thread_pool_max='2147483647'>
+      <poll max='9223372036854775807' grow='456' shrink='789'/>
+    </iothread>
+  </iothreadids>
+  <os>
+    <type arch='i686' machine='pc'>hvm</type>
+    <boot dev='hd'/>
+  </os>
+  <clock offset='utc'/>
+  <on_poweroff>destroy</on_poweroff>
+  <on_reboot>restart</on_reboot>
+  <on_crash>destroy</on_crash>
+  <devices>
+  </devices>
+</domain>
diff --git a/tests/genericxml2xmltest.c b/tests/genericxml2xmltest.c
index 3501eadf5597..ce8073e85a30 100644
--- a/tests/genericxml2xmltest.c
+++ b/tests/genericxml2xmltest.c
@@ -249,6 +249,8 @@ mymain(void)
     DO_TEST("cpu-phys-bits-emulate");
     DO_TEST("cpu-phys-bits-passthrough");
 
+    DO_TEST("iothreadids");
+
     virObjectUnref(caps);
     virObjectUnref(xmlopt);
 
-- 
2.41.0
Re: [PATCH] conf, schema: Switch iothread/poll values to unsignedLong
Posted by Peter Krempa 9 months, 1 week ago
On Fri, Sep 01, 2023 at 23:32:14 +0200, Martin Kletzander wrote:
> They represent nanoseconds, and we accept such values already.  Not that
> anyone would use such values in the wild, but even one person testing
> QEMU could put in a bigger value and will be bothered with validation
> errors after every `virsh edit`.  Also add a test for it.
> 
> Resolves: https://issues.redhat.com/browse/RHEL-1717
> 
> Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
> ---
>  src/conf/schemas/domaincommon.rng          |  6 +++---
>  tests/genericxml2xmlindata/iothreadids.xml | 23 ++++++++++++++++++++++
>  tests/genericxml2xmltest.c                 |  2 ++
>  3 files changed, 28 insertions(+), 3 deletions(-)
>  create mode 100644 tests/genericxml2xmlindata/iothreadids.xml
> 
> diff --git a/src/conf/schemas/domaincommon.rng b/src/conf/schemas/domaincommon.rng
> index de3bd1c35c55..2f9ba31c0aec 100644
> --- a/src/conf/schemas/domaincommon.rng
> +++ b/src/conf/schemas/domaincommon.rng
> @@ -876,17 +876,17 @@
>                  <element name="poll">
>                    <optional>
>                      <attribute name="max">
> -                      <ref name="unsignedInt"/>
> +                      <ref name="unsignedLong"/>
>                      </attribute>

I've looked originally at 'src/conf/schemas/basictypes.rng' which has:

  <define name="unsignedInt">
    <data type="unsignedInt">
      <param name="pattern">[0-9]+</param>
    </data>
  </define>


And concluded that there's no actual difference between that and
'unsignedLong' not realizing that this is not the full definition of the
type.


>                    </optional>
>                    <optional>
>                      <attribute name="grow">

Reviewed-by: Peter Krempa <pkrempa@redhat.com>
Re: [PATCH] conf, schema: Switch iothread/poll values to unsignedLong
Posted by Martin Kletzander 9 months, 1 week ago
On Mon, Sep 04, 2023 at 09:22:54AM +0200, Peter Krempa wrote:
>On Fri, Sep 01, 2023 at 23:32:14 +0200, Martin Kletzander wrote:
>> They represent nanoseconds, and we accept such values already.  Not that
>> anyone would use such values in the wild, but even one person testing
>> QEMU could put in a bigger value and will be bothered with validation
>> errors after every `virsh edit`.  Also add a test for it.
>>
>> Resolves: https://issues.redhat.com/browse/RHEL-1717
>>
>> Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
>> ---
>>  src/conf/schemas/domaincommon.rng          |  6 +++---
>>  tests/genericxml2xmlindata/iothreadids.xml | 23 ++++++++++++++++++++++
>>  tests/genericxml2xmltest.c                 |  2 ++
>>  3 files changed, 28 insertions(+), 3 deletions(-)
>>  create mode 100644 tests/genericxml2xmlindata/iothreadids.xml
>>
>> diff --git a/src/conf/schemas/domaincommon.rng b/src/conf/schemas/domaincommon.rng
>> index de3bd1c35c55..2f9ba31c0aec 100644
>> --- a/src/conf/schemas/domaincommon.rng
>> +++ b/src/conf/schemas/domaincommon.rng
>> @@ -876,17 +876,17 @@
>>                  <element name="poll">
>>                    <optional>
>>                      <attribute name="max">
>> -                      <ref name="unsignedInt"/>
>> +                      <ref name="unsignedLong"/>
>>                      </attribute>
>
>I've looked originally at 'src/conf/schemas/basictypes.rng' which has:
>
>  <define name="unsignedInt">
>    <data type="unsignedInt">
>      <param name="pattern">[0-9]+</param>
>    </data>
>  </define>
>
>
>And concluded that there's no actual difference between that and
>'unsignedLong' not realizing that this is not the full definition of the
>type.
>

Exactly.  It took me quite some time to figure out where they come from, it can
actually be used from various XML namespaces, but hunting this down, for someone
like me, took longer than I would want to admit.

>
>>                    </optional>
>>                    <optional>
>>                      <attribute name="grow">
>
>Reviewed-by: Peter Krempa <pkrempa@redhat.com>
>

Thanks ;)