From ae3282dc86fda35872a786423c7dd1525400994b Mon Sep 17 00:00:00 2001 From: Rob Bradford Date: Mon, 20 Apr 2026 09:53:11 +0100 Subject: [PATCH] virtio-devices: pmem: Write a status respone for invalid commands The virtio spec requires that a status response is always written on error. This was missing from the path where we had a valid request but not for one we support. Signed-off-by: Rob Bradford --- virtio-devices/src/pmem.rs | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/virtio-devices/src/pmem.rs b/virtio-devices/src/pmem.rs index 9024bcfa2..80d41ad5d 100644 --- a/virtio-devices/src/pmem.rs +++ b/virtio-devices/src/pmem.rs @@ -191,7 +191,17 @@ impl PmemEpollHandler { Ok(ref req) => { // Currently, there is only one virtio-pmem request, FLUSH. error!("Invalid virtio request type {:?}", req.type_); - 0 + // The virtio spec requires a status response even on error. + let resp = VirtioPmemResp { + ret: VIRTIO_PMEM_RESP_TYPE_EIO, + }; + match desc_chain.memory().write_obj(resp, req.status_addr) { + Ok(()) => size_of::() as u32, + Err(e) => { + error!("Bad guest memory address: {e}"); + 0 + } + } } Err(e) => { error!("Failed to parse available descriptor chain: {e:?}");