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 <rbradford@meta.com>
This commit is contained in:
Rob Bradford
2026-04-20 09:53:11 +01:00
parent 8685eb5c53
commit ae3282dc86

View File

@@ -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::<VirtioPmemResp>() as u32,
Err(e) => {
error!("Bad guest memory address: {e}");
0
}
}
}
Err(e) => {
error!("Failed to parse available descriptor chain: {e:?}");