* [PULL 0/6] Functional test framework improvements & bug fixes
@ 2026-08-14 10:09 Thomas Huth
2026-08-14 10:09 ` [PULL 1/6] tests/functional: add skipWithoutSudo() decorator Thomas Huth
` (5 more replies)
0 siblings, 6 replies; 7+ messages in thread
From: Thomas Huth @ 2026-08-14 10:09 UTC (permalink / raw)
To: qemu-devel, Richard Henderson
Hi Richard!
The following changes since commit 539bc315538afe036a4b99088659aa82e3b489f2:
Merge tag 'pull-loongarch-20260813' of https://github.com/bibo-mao/qemu into staging (2026-08-13 07:16:25 -0700)
are available in the Git repository at:
https://gitlab.com/thuth/qemu.git tags/pull-request-2026-08-14
for you to fetch changes up to 4adfb431c0c3abd84909d1228b4954bfd68a1dbc:
hw/i386/amd_iommu: Avoid undefined behavior in amdvi_setevent_bits() (2026-08-14 09:14:58 +0200)
----------------------------------------------------------------
* Some minor updates to the functional testing framework
* Fix a guest-triggerable abort() in the usb uas code
* Fix a guest-triggerable abort() in the vmxnet3 code
* Fix a undefined behavior problem in the amd_iommu code
----------------------------------------------------------------
Thomas Huth (3):
hw/usb/dev-uas: Don't abort if guest provided an undersized buffer for status
hw/net/vmxnet3: Do not abort if guest provides bad interrupt numbers
hw/i386/amd_iommu: Avoid undefined behavior in amdvi_setevent_bits()
Vladimir Sementsov-Ogievskiy (3):
tests/functional: add skipWithoutSudo() decorator
tests/functional/qemu_test: drop *args argument from .get_vm()
tests/testcase.py: passthrough monitor_address
hw/i386/amd_iommu.c | 2 +-
hw/net/vmxnet3.c | 34 ++++++++++++++++++++++++--------
hw/usb/dev-uas.c | 19 ++++++++++++++++--
tests/functional/migration.py | 3 ++-
tests/functional/qemu_test/decorators.py | 16 +++++++++++++++
tests/functional/qemu_test/testcase.py | 12 +++++------
6 files changed, 67 insertions(+), 19 deletions(-)
^ permalink raw reply [flat|nested] 7+ messages in thread
* [PULL 1/6] tests/functional: add skipWithoutSudo() decorator
2026-08-14 10:09 [PULL 0/6] Functional test framework improvements & bug fixes Thomas Huth
@ 2026-08-14 10:09 ` Thomas Huth
2026-08-14 10:09 ` [PULL 2/6] tests/functional/qemu_test: drop *args argument from .get_vm() Thomas Huth
` (4 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: Thomas Huth @ 2026-08-14 10:09 UTC (permalink / raw)
To: qemu-devel, Richard Henderson
Cc: Vladimir Sementsov-Ogievskiy, Daniel P. Berrangé, Lei Yang,
Maksim Davydov, Ben Chaney
From: Vladimir Sementsov-Ogievskiy <vsementsov@yandex-team.ru>
To be used in the next commit: that would be a test for TAP
networking, and it will need to setup TAP device.
Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@yandex-team.ru>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
Reviewed-by: Thomas Huth <thuth@redhat.com>
Tested-by: Lei Yang <leiyang@redhat.com>
Reviewed-by: Maksim Davydov <davydov-max@yandex-team.ru>
Reviewed-by: Ben Chaney <bchaney@akamai.com>
Message-ID: <20260729091334.1863155-15-vsementsov@yandex-team.ru>
Signed-off-by: Thomas Huth <thuth@redhat.com>
---
tests/functional/qemu_test/decorators.py | 16 ++++++++++++++++
1 file changed, 16 insertions(+)
diff --git a/tests/functional/qemu_test/decorators.py b/tests/functional/qemu_test/decorators.py
index fcf236ecfdf..aa135acc785 100644
--- a/tests/functional/qemu_test/decorators.py
+++ b/tests/functional/qemu_test/decorators.py
@@ -6,6 +6,7 @@
import os
import platform
import resource
+import subprocess
from unittest import skipIf, skipUnless
from .cmd import which
@@ -177,3 +178,18 @@ def skipLockedMemoryTest(locked_memory):
ulimit_memory == resource.RLIM_INFINITY or ulimit_memory >= locked_memory * 1024,
f'Test required {locked_memory} kB of available locked memory',
)
+
+'''
+Decorator to skip execution of a test if passwordless
+sudo command is not available.
+'''
+def skipWithoutSudo():
+ proc = subprocess.run(["sudo", "-n", "/bin/true"],
+ stdin=subprocess.PIPE,
+ stdout=subprocess.PIPE,
+ stderr=subprocess.STDOUT,
+ universal_newlines=True,
+ check=False)
+
+ return skipUnless(proc.returncode == 0,
+ f'requires password-less sudo access: {proc.stdout}')
--
2.55.0
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PULL 2/6] tests/functional/qemu_test: drop *args argument from .get_vm()
2026-08-14 10:09 [PULL 0/6] Functional test framework improvements & bug fixes Thomas Huth
2026-08-14 10:09 ` [PULL 1/6] tests/functional: add skipWithoutSudo() decorator Thomas Huth
@ 2026-08-14 10:09 ` Thomas Huth
2026-08-14 10:09 ` [PULL 3/6] tests/testcase.py: passthrough monitor_address Thomas Huth
` (3 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: Thomas Huth @ 2026-08-14 10:09 UTC (permalink / raw)
To: qemu-devel, Richard Henderson; +Cc: Vladimir Sementsov-Ogievskiy
From: Vladimir Sementsov-Ogievskiy <vsementsov@yandex-team.ru>
It's redundant. Only one caller use it, and it may be simply
substituted by .add_args().
Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@yandex-team.ru>
Reviewed-by: Thomas Huth <thuth@redhat.com>
Message-ID: <20260729093146.1893719-3-vsementsov@yandex-team.ru>
Signed-off-by: Thomas Huth <thuth@redhat.com>
---
tests/functional/migration.py | 3 ++-
tests/functional/qemu_test/testcase.py | 9 +++------
2 files changed, 5 insertions(+), 7 deletions(-)
diff --git a/tests/functional/migration.py b/tests/functional/migration.py
index 4344e03be41..8d2428efc24 100644
--- a/tests/functional/migration.py
+++ b/tests/functional/migration.py
@@ -63,7 +63,8 @@ def migrate_vms(self, dst_uri, src_uri, dst_vm, src_vm):
self.assert_dest_vm(dst_vm)
def migrate(self, dst_uri, src_uri=None):
- dst_vm = self.get_vm('-incoming', 'defer', name="dst-qemu")
+ dst_vm = self.get_vm("dst-qemu")
+ dst_vm.add_args('-incoming', 'defer')
self.configure_machine(dst_vm)
dst_vm.launch()
diff --git a/tests/functional/qemu_test/testcase.py b/tests/functional/qemu_test/testcase.py
index e4179d165c0..12ef84281c4 100644
--- a/tests/functional/qemu_test/testcase.py
+++ b/tests/functional/qemu_test/testcase.py
@@ -381,7 +381,7 @@ def require_device(self, devicename):
if helptxt.find(devicename) < 0:
self.skipTest('no support for device ' + devicename)
- def _new_vm(self, name, *args):
+ def _new_vm(self, name):
vm = QEMUMachine(self.qemu_bin,
name=name,
base_temp_dir=self.workdir,
@@ -394,20 +394,17 @@ def _new_vm(self, name, *args):
vm.add_args("-chardev",
f"socket,id=backdoor,path={sockpath},server=on,wait=off",
"-mon", "chardev=backdoor,mode=control")
-
- if args:
- vm.add_args(*args)
return vm
@property
def vm(self):
return self.get_vm(name='default')
- def get_vm(self, *args, name=None):
+ def get_vm(self, name=None):
if not name:
name = str(uuid.uuid4())
if self._vms.get(name) is None:
- self._vms[name] = self._new_vm(name, *args)
+ self._vms[name] = self._new_vm(name)
if self.cpu is not None:
self._vms[name].add_args('-cpu', self.cpu)
if self.machine is not None:
--
2.55.0
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PULL 3/6] tests/testcase.py: passthrough monitor_address
2026-08-14 10:09 [PULL 0/6] Functional test framework improvements & bug fixes Thomas Huth
2026-08-14 10:09 ` [PULL 1/6] tests/functional: add skipWithoutSudo() decorator Thomas Huth
2026-08-14 10:09 ` [PULL 2/6] tests/functional/qemu_test: drop *args argument from .get_vm() Thomas Huth
@ 2026-08-14 10:09 ` Thomas Huth
2026-08-14 10:09 ` [PULL 4/6] hw/usb/dev-uas: Don't abort if guest provided an undersized buffer for status Thomas Huth
` (2 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: Thomas Huth @ 2026-08-14 10:09 UTC (permalink / raw)
To: qemu-devel, Richard Henderson; +Cc: Vladimir Sementsov-Ogievskiy
From: Vladimir Sementsov-Ogievskiy <vsementsov@yandex-team.ru>
We'll need it soon to implement test for cpr-exec mode of
tap-fd-migration.
Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@yandex-team.ru>
Reviewed-by: Thomas Huth <thuth@redhat.com>
Message-ID: <20260729093146.1893719-5-vsementsov@yandex-team.ru>
Signed-off-by: Thomas Huth <thuth@redhat.com>
---
tests/functional/qemu_test/testcase.py | 9 +++++----
1 file changed, 5 insertions(+), 4 deletions(-)
diff --git a/tests/functional/qemu_test/testcase.py b/tests/functional/qemu_test/testcase.py
index 12ef84281c4..69d3d06cc0e 100644
--- a/tests/functional/qemu_test/testcase.py
+++ b/tests/functional/qemu_test/testcase.py
@@ -381,11 +381,12 @@ def require_device(self, devicename):
if helptxt.find(devicename) < 0:
self.skipTest('no support for device ' + devicename)
- def _new_vm(self, name):
+ def _new_vm(self, name, monitor_address):
vm = QEMUMachine(self.qemu_bin,
name=name,
base_temp_dir=self.workdir,
- log_dir=self.log_file())
+ log_dir=self.log_file(),
+ monitor_address=monitor_address)
self.log.debug('QEMUMachine "%s" created', name)
self.log.debug('QEMUMachine "%s" temp_dir: %s', name, vm.temp_dir)
@@ -400,11 +401,11 @@ def _new_vm(self, name):
def vm(self):
return self.get_vm(name='default')
- def get_vm(self, name=None):
+ def get_vm(self, name=None, monitor_address=None):
if not name:
name = str(uuid.uuid4())
if self._vms.get(name) is None:
- self._vms[name] = self._new_vm(name)
+ self._vms[name] = self._new_vm(name, monitor_address)
if self.cpu is not None:
self._vms[name].add_args('-cpu', self.cpu)
if self.machine is not None:
--
2.55.0
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PULL 4/6] hw/usb/dev-uas: Don't abort if guest provided an undersized buffer for status
2026-08-14 10:09 [PULL 0/6] Functional test framework improvements & bug fixes Thomas Huth
` (2 preceding siblings ...)
2026-08-14 10:09 ` [PULL 3/6] tests/testcase.py: passthrough monitor_address Thomas Huth
@ 2026-08-14 10:09 ` Thomas Huth
2026-08-14 10:09 ` [PULL 5/6] hw/net/vmxnet3: Do not abort if guest provides bad interrupt numbers Thomas Huth
2026-08-14 10:09 ` [PULL 6/6] hw/i386/amd_iommu: Avoid undefined behavior in amdvi_setevent_bits() Thomas Huth
5 siblings, 0 replies; 7+ messages in thread
From: Thomas Huth @ 2026-08-14 10:09 UTC (permalink / raw)
To: qemu-devel, Richard Henderson; +Cc: Feifan Qian
QEMU currently aborts if the guest provides an undersized buffer
for the status packet (8 bytes):
hw/usb/core.c:623: usb_packet_copy:
Assertion `p->actual_length + bytes <= iov->size' failed.
If we hit this situation, log a guest error and continue by simply
only providing the bytes that the guest asked for.
(Note: This is e.g. similar to the UAS_PIPE_ID_COMMAND case that
also clamps the length with: length = MIN(sizeof(iu), p->iov.size))
Resolves: https://gitlab.com/qemu-project/qemu/-/work_items/3900
Reported-by: Feifan Qian <bea1e@proton.me>
Signed-off-by: Thomas Huth <thuth@redhat.com>
Message-ID: <20260730163901.1154791-1-thuth@redhat.com>
---
hw/usb/dev-uas.c | 19 +++++++++++++++++--
1 file changed, 17 insertions(+), 2 deletions(-)
diff --git a/hw/usb/dev-uas.c b/hw/usb/dev-uas.c
index 963c0433b38..be8c3667e83 100644
--- a/hw/usb/dev-uas.c
+++ b/hw/usb/dev-uas.c
@@ -359,6 +359,7 @@ static void usb_uas_send_status_bh(void *opaque)
UASDevice *uas = opaque;
UASStatus *st;
USBPacket *p;
+ uint32_t length;
while ((st = QTAILQ_FIRST(&uas->results)) != NULL) {
if (uas_using_streams(uas)) {
@@ -373,7 +374,14 @@ static void usb_uas_send_status_bh(void *opaque)
break;
}
- usb_packet_copy(p, &st->status, st->length);
+ length = st->length;
+ if (length > p->iov.size) {
+ qemu_log_mask(LOG_GUEST_ERROR,
+ "usb uas: packet (%zd) too small for status (%d)\n",
+ p->iov.size, length);
+ length = p->iov.size;
+ }
+ usb_packet_copy(p, &st->status, length);
QTAILQ_REMOVE(&uas->results, st, next);
g_free(st);
@@ -875,7 +883,14 @@ static void usb_uas_handle_data(USBDevice *dev, USBPacket *p)
break;
}
}
- usb_packet_copy(p, &st->status, st->length);
+ length = st->length;
+ if (length > p->iov.size) {
+ qemu_log_mask(LOG_GUEST_ERROR,
+ "usb uas: packet (%zd) too small for status (%d)\n",
+ p->iov.size, length);
+ length = p->iov.size;
+ }
+ usb_packet_copy(p, &st->status, length);
QTAILQ_REMOVE(&uas->results, st, next);
g_free(st);
break;
--
2.55.0
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PULL 5/6] hw/net/vmxnet3: Do not abort if guest provides bad interrupt numbers
2026-08-14 10:09 [PULL 0/6] Functional test framework improvements & bug fixes Thomas Huth
` (3 preceding siblings ...)
2026-08-14 10:09 ` [PULL 4/6] hw/usb/dev-uas: Don't abort if guest provided an undersized buffer for status Thomas Huth
@ 2026-08-14 10:09 ` Thomas Huth
2026-08-14 10:09 ` [PULL 6/6] hw/i386/amd_iommu: Avoid undefined behavior in amdvi_setevent_bits() Thomas Huth
5 siblings, 0 replies; 7+ messages in thread
From: Thomas Huth @ 2026-08-14 10:09 UTC (permalink / raw)
To: qemu-devel, Richard Henderson; +Cc: Philippe Mathieu-Daudé
vmxnet3_validate_interrupts() currently aborts via hw_error() if
the guest provided bad interrupt numbers. This should not happen,
QEMU should rather refuse to activate the device in this case instead.
Thus propagate the error to the callers to handle it more gracefully
there.
Resolves: https://gitlab.com/qemu-project/qemu/-/work_items/539
Reviewed-by: Philippe Mathieu-Daudé <philmd@oss.qualcomm.com>
Signed-off-by: Thomas Huth <thuth@redhat.com>
Message-ID: <20260731113352.189066-1-thuth@redhat.com>
---
hw/net/vmxnet3.c | 34 ++++++++++++++++++++++++++--------
1 file changed, 26 insertions(+), 8 deletions(-)
diff --git a/hw/net/vmxnet3.c b/hw/net/vmxnet3.c
index 8569484b2f2..24c551a0547 100644
--- a/hw/net/vmxnet3.c
+++ b/hw/net/vmxnet3.c
@@ -1336,32 +1336,46 @@ static bool vmxnet3_verify_intx(VMXNET3State *s, int intx)
|| intx == pci_get_byte(s->parent_obj.config + PCI_INTERRUPT_PIN) - 1;
}
-static void vmxnet3_validate_interrupt_idx(bool is_msix, int idx)
+static bool vmxnet3_validate_irq_idx(const char *type, bool is_msix, int idx)
{
int max_ints = is_msix ? VMXNET3_MAX_INTRS : VMXNET3_MAX_NMSIX_INTRS;
+
if (idx >= max_ints) {
- hw_error("Bad interrupt index: %d\n", idx);
+ qemu_log_mask(LOG_GUEST_ERROR,
+ "vmxnet3: Bad %s queue interrupt index: %d\n",
+ type, idx);
+ return false;
}
+
+ return true;
}
-static void vmxnet3_validate_interrupts(VMXNET3State *s)
+static bool vmxnet3_validate_interrupts(VMXNET3State *s)
{
int i;
VMW_CFPRN("Verifying event interrupt index (%d)", s->event_int_idx);
- vmxnet3_validate_interrupt_idx(s->msix_used, s->event_int_idx);
+ if (!vmxnet3_validate_irq_idx("event", s->msix_used, s->event_int_idx)) {
+ return false;
+ }
for (i = 0; i < s->txq_num; i++) {
int idx = s->txq_descr[i].intr_idx;
VMW_CFPRN("Verifying TX queue %d interrupt index (%d)", i, idx);
- vmxnet3_validate_interrupt_idx(s->msix_used, idx);
+ if (!vmxnet3_validate_irq_idx("TX", s->msix_used, idx)) {
+ return false;
+ }
}
for (i = 0; i < s->rxq_num; i++) {
int idx = s->rxq_descr[i].intr_idx;
VMW_CFPRN("Verifying RX queue %d interrupt index (%d)", i, idx);
- vmxnet3_validate_interrupt_idx(s->msix_used, idx);
+ if (!vmxnet3_validate_irq_idx("RX", s->msix_used, idx)) {
+ return false;
+ }
}
+
+ return true;
}
static bool vmxnet3_validate_queues(VMXNET3State *s)
@@ -1554,7 +1568,9 @@ static void vmxnet3_activate_device(VMXNET3State *s)
sizeof(s->rxq_descr[i].rxq_stats));
}
- vmxnet3_validate_interrupts(s);
+ if (!vmxnet3_validate_interrupts(s)) {
+ return;
+ }
/* Make sure everything is in place before device activation */
smp_wmb();
@@ -2392,7 +2408,9 @@ static int vmxnet3_post_load(void *opaque, int version_id)
if (!vmxnet3_validate_queues(s)) {
return -1;
}
- vmxnet3_validate_interrupts(s);
+ if (!vmxnet3_validate_interrupts(s)) {
+ return -1;
+ }
return 0;
}
--
2.55.0
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PULL 6/6] hw/i386/amd_iommu: Avoid undefined behavior in amdvi_setevent_bits()
2026-08-14 10:09 [PULL 0/6] Functional test framework improvements & bug fixes Thomas Huth
` (4 preceding siblings ...)
2026-08-14 10:09 ` [PULL 5/6] hw/net/vmxnet3: Do not abort if guest provides bad interrupt numbers Thomas Huth
@ 2026-08-14 10:09 ` Thomas Huth
5 siblings, 0 replies; 7+ messages in thread
From: Thomas Huth @ 2026-08-14 10:09 UTC (permalink / raw)
To: qemu-devel, Richard Henderson; +Cc: Alejandro Jimenez
The code in amdvi_encode_event() calls amdvi_setevent_bits() with
start = 64:
amdvi_setevent_bits(evt, addr, 64, 64);
and amdvi_setevent_bits() then calculates:
uint64_t mask = MAKE_64BIT_MASK(start, length);
but this MAKE_64BIT_MASK() macro shifts a value left by "start" bit
positions. Shifting left by more than 63 is undefined behavior and
could have unexpected results with different compilers / architectures.
Fix it by using "bitpos" instead, which was likely the original
intended behavior anyway. (bitpos is calculated as bitpos = start % 64).
Resolves: https://gitlab.com/qemu-project/qemu/-/work_items/3633
Fixes: 1d5b128cbeea ("hw/iommu: Fix problems reported by Coverity scan")
Reviewed-by: Alejandro Jimenez <alejandro.j.jimenez@oracle.com>
Signed-off-by: Thomas Huth <thuth@redhat.com>
Message-ID: <20260731140229.259272-1-thuth@redhat.com>
---
hw/i386/amd_iommu.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/hw/i386/amd_iommu.c b/hw/i386/amd_iommu.c
index 90252c52af4..578c27ccbef 100644
--- a/hw/i386/amd_iommu.c
+++ b/hw/i386/amd_iommu.c
@@ -323,7 +323,7 @@ static void amdvi_setevent_bits(uint64_t *buffer, uint64_t value, int start,
int length)
{
int index = start / 64, bitpos = start % 64;
- uint64_t mask = MAKE_64BIT_MASK(start, length);
+ uint64_t mask = MAKE_64BIT_MASK(bitpos, length);
buffer[index] &= ~mask;
buffer[index] |= (value << bitpos) & mask;
}
--
2.55.0
^ permalink raw reply related [flat|nested] 7+ messages in thread
end of thread, other threads:[~2026-08-14 10:10 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-08-14 10:09 [PULL 0/6] Functional test framework improvements & bug fixes Thomas Huth
2026-08-14 10:09 ` [PULL 1/6] tests/functional: add skipWithoutSudo() decorator Thomas Huth
2026-08-14 10:09 ` [PULL 2/6] tests/functional/qemu_test: drop *args argument from .get_vm() Thomas Huth
2026-08-14 10:09 ` [PULL 3/6] tests/testcase.py: passthrough monitor_address Thomas Huth
2026-08-14 10:09 ` [PULL 4/6] hw/usb/dev-uas: Don't abort if guest provided an undersized buffer for status Thomas Huth
2026-08-14 10:09 ` [PULL 5/6] hw/net/vmxnet3: Do not abort if guest provides bad interrupt numbers Thomas Huth
2026-08-14 10:09 ` [PULL 6/6] hw/i386/amd_iommu: Avoid undefined behavior in amdvi_setevent_bits() Thomas Huth
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.