Re: [PATCH 5/5] vfio: selftests: Add test for device power state transitions

From: Alex Williamson

Date: Tue Nov 03 2026 - 17:36:18 EST


On Thu, 29 Oct 2026 20:33:24 +0000
David Matlack <dmatlack@xxxxxxxxxx> wrote:
> +/*
> + * Put the device into D3hot via config space and then close it. VFIO must
> + * return the device to D0 when it is closed.
> + */

But we're only testing that it's re-opened into D0, there are multiple
ways that could have happened. It's pretty common that a guest
shutdown might put devices into a low power state and it's brought back
to D0 on close, on reset, on the next open, or even on the reset in
open. So I don't think we're testing what we claim to test here. I'm
not sure this specific D0 transition is observable, even if we were to
resort to pci-sysfs. Thanks,

Alex

> +TEST_F(vfio_pci_power_state_test, close_in_d3hot)
> +{
> + power_state_set(self->device, self->pm_cap, D3HOT);
> + ASSERT_EQ(power_state_get(self->device, self->pm_cap), D3HOT);
> +
> + vfio_pci_device_cleanup(self->device);
> +
> + self->device = vfio_pci_device_init(device_bdf, self->iommu);
> + ASSERT_EQ(power_state_get(self->device, self->pm_cap), D0);
> +}