[PATCH 1/2] qemu: Fix hyperv spinlock retries count type mismatch

Friedrich Oslage posted 2 patches 1 week ago
[PATCH 1/2] qemu: Fix hyperv spinlock retries count type mismatch
Posted by Friedrich Oslage 1 week ago
From: Friedrich Oslage <friedrich@oslage.de>

Use unsigned int for sprintf and update tests to ensure it can hold INT_MAX+1.

Signed-off-by: Friedrich Oslage <friedrich@oslage.de>
---
 src/conf/domain_conf.c                          | 2 +-
 tests/qemuxmlconfdata/hyperv.x86_64-latest.args | 2 +-
 tests/qemuxmlconfdata/hyperv.x86_64-latest.xml  | 2 +-
 tests/qemuxmlconfdata/hyperv.xml                | 2 +-
 4 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 4737594487..7c951fdc32 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -28633,7 +28633,7 @@ virDomainFeaturesHyperVDefFormat(virBuffer *buf,
         case VIR_DOMAIN_HYPERV_SPINLOCKS:
             if (def->hyperv.features[j] == VIR_TRISTATE_SWITCH_ON) {
                 virBufferAsprintf(&hypervAttrBuf,
-                                  " retries='%d'", def->hyperv.spinlocks);
+                                  " retries='%u'", def->hyperv.spinlocks);
             }
             break;
 
diff --git a/tests/qemuxmlconfdata/hyperv.x86_64-latest.args b/tests/qemuxmlconfdata/hyperv.x86_64-latest.args
index 30d63bae6b..ea4b77de74 100644
--- a/tests/qemuxmlconfdata/hyperv.x86_64-latest.args
+++ b/tests/qemuxmlconfdata/hyperv.x86_64-latest.args
@@ -12,7 +12,7 @@ XDG_CONFIG_HOME=/var/lib/libvirt/qemu/domain--1-QEMUGuest1/.config \
 -object '{"qom-type":"secret","id":"masterKey0","format":"raw","file":"/var/lib/libvirt/qemu/domain--1-QEMUGuest1/master-key.aes"}' \
 -machine pc,usb=off,dump-guest-core=off,memory-backend=pc.ram,acpi=on \
 -accel tcg \
--cpu 'qemu64,hv-time=on,hv-relaxed=on,hv-vapic=on,hv-spinlocks=0x2fff,hv-vpindex=on,hv-runtime=on,hv-synic=on,hv-stimer=on,hv-reset=on,hv-vendor-id=KVM Hv,hv-frequencies=on,hv-reenlightenment=on,hv-tlbflush=on,hv-tlbflush-direct=on,hv-tlbflush-ext=on,hv-ipi=on,hv-evmcs=on,hv-avic=on,hv-emsr-bitmap=on,hv-xmm-input=on' \
+-cpu 'qemu64,hv-time=on,hv-relaxed=on,hv-vapic=on,hv-spinlocks=0x80000000,hv-vpindex=on,hv-runtime=on,hv-synic=on,hv-stimer=on,hv-reset=on,hv-vendor-id=KVM Hv,hv-frequencies=on,hv-reenlightenment=on,hv-tlbflush=on,hv-tlbflush-direct=on,hv-tlbflush-ext=on,hv-ipi=on,hv-evmcs=on,hv-avic=on,hv-emsr-bitmap=on,hv-xmm-input=on' \
 -m size=219136k \
 -object '{"qom-type":"memory-backend-ram","id":"pc.ram","size":224395264}' \
 -overcommit mem-lock=off \
diff --git a/tests/qemuxmlconfdata/hyperv.x86_64-latest.xml b/tests/qemuxmlconfdata/hyperv.x86_64-latest.xml
index ee412164ed..fdcab661a6 100644
--- a/tests/qemuxmlconfdata/hyperv.x86_64-latest.xml
+++ b/tests/qemuxmlconfdata/hyperv.x86_64-latest.xml
@@ -13,7 +13,7 @@
     <hyperv mode='custom'>
       <relaxed state='on'/>
       <vapic state='on'/>
-      <spinlocks state='on' retries='12287'/>
+      <spinlocks state='on' retries='2147483648'/>
       <vpindex state='on'/>
       <runtime state='on'/>
       <synic state='on'/>
diff --git a/tests/qemuxmlconfdata/hyperv.xml b/tests/qemuxmlconfdata/hyperv.xml
index 44aec004a8..9a47dd0ec8 100644
--- a/tests/qemuxmlconfdata/hyperv.xml
+++ b/tests/qemuxmlconfdata/hyperv.xml
@@ -13,7 +13,7 @@
     <hyperv>
       <relaxed state='on'/>
       <vapic state='on'/>
-      <spinlocks state='on' retries='12287'/>
+      <spinlocks state='on' retries='2147483648'/>
       <vpindex state='on'/>
       <runtime state='on'/>
       <synic state='on'/>
-- 
2.51.0