aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn Levon <john.levon@nutanix.com>2025-05-07 16:20:11 +0100
committerCédric Le Goater <clg@redhat.com>2025-05-09 12:42:28 +0200
commit5363a1a117ea6e1af520d1faed303f944975f760 (patch)
treec9a010fa01dd218801d98df22dedf1e3f1b63bd3
parent2e27becf17be231bc15588a51c0b61efec68d021 (diff)
downloadqemu-5363a1a117ea6e1af520d1faed303f944975f760.zip
qemu-5363a1a117ea6e1af520d1faed303f944975f760.tar.gz
qemu-5363a1a117ea6e1af520d1faed303f944975f760.tar.bz2
vfio: add strread/writeerror()
Add simple helpers to correctly report failures from read/write routines using the return -errno style. Signed-off-by: John Levon <john.levon@nutanix.com> Reviewed-by: Cédric Le Goater <clg@redhat.com> Link: https://lore.kernel.org/qemu-devel/20250507152020.1254632-7-john.levon@nutanix.com Signed-off-by: Cédric Le Goater <clg@redhat.com>
-rw-r--r--include/hw/vfio/vfio-device.h14
1 files changed, 14 insertions, 0 deletions
diff --git a/include/hw/vfio/vfio-device.h b/include/hw/vfio/vfio-device.h
index a7eaaa3..4a32202 100644
--- a/include/hw/vfio/vfio-device.h
+++ b/include/hw/vfio/vfio-device.h
@@ -115,6 +115,20 @@ struct VFIODeviceOps {
int (*vfio_load_config)(VFIODevice *vdev, QEMUFile *f);
};
+/*
+ * Given a return value of either a short number of bytes read or -errno,
+ * construct a meaningful error message.
+ */
+#define strreaderror(ret) \
+ (ret < 0 ? strerror(-ret) : "short read")
+
+/*
+ * Given a return value of either a short number of bytes written or -errno,
+ * construct a meaningful error message.
+ */
+#define strwriteerror(ret) \
+ (ret < 0 ? strerror(-ret) : "short write")
+
void vfio_device_irq_disable(VFIODevice *vbasedev, int index);
void vfio_device_irq_unmask(VFIODevice *vbasedev, int index);
void vfio_device_irq_mask(VFIODevice *vbasedev, int index);