[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v9 16/17] vfio-user: handle reset of remote device
From: |
Jagannathan Raman |
Subject: |
[PATCH v9 16/17] vfio-user: handle reset of remote device |
Date: |
Tue, 3 May 2022 10:16:57 -0400 |
Adds handler to reset a remote device
Signed-off-by: Elena Ufimtseva <elena.ufimtseva@oracle.com>
Signed-off-by: John G Johnson <john.g.johnson@oracle.com>
Signed-off-by: Jagannathan Raman <jag.raman@oracle.com>
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
---
hw/remote/vfio-user-obj.c | 20 ++++++++++++++++++++
1 file changed, 20 insertions(+)
diff --git a/hw/remote/vfio-user-obj.c b/hw/remote/vfio-user-obj.c
index d351b1daa3..15b06744f9 100644
--- a/hw/remote/vfio-user-obj.c
+++ b/hw/remote/vfio-user-obj.c
@@ -630,6 +630,20 @@ void vfu_object_set_bus_irq(PCIBus *pci_bus)
pci_bus_irqs(pci_bus, vfu_object_set_irq, vfu_object_map_irq, pci_bus, 1);
}
+static int vfu_object_device_reset(vfu_ctx_t *vfu_ctx, vfu_reset_type_t type)
+{
+ VfuObject *o = vfu_get_private(vfu_ctx);
+
+ /* vfu_object_ctx_run() handles lost connection */
+ if (type == VFU_RESET_LOST_CONN) {
+ return 0;
+ }
+
+ qdev_reset_all(DEVICE(o->pci_dev));
+
+ return 0;
+}
+
/*
* TYPE_VFU_OBJECT depends on the availability of the 'socket' and 'device'
* properties. It also depends on devices instantiated in QEMU. These
@@ -735,6 +749,12 @@ static void vfu_object_init_ctx(VfuObject *o, Error **errp)
goto fail;
}
+ ret = vfu_setup_device_reset_cb(o->vfu_ctx, &vfu_object_device_reset);
+ if (ret < 0) {
+ error_setg(errp, "vfu: Failed to setup reset callback");
+ goto fail;
+ }
+
ret = vfu_realize_ctx(o->vfu_ctx);
if (ret < 0) {
error_setg(errp, "vfu: Failed to realize device %s- %s",
--
2.20.1
- Re: [PATCH v9 10/17] vfio-user: run vfio-user context, (continued)
[PATCH v9 08/17] vfio-user: instantiate vfio-user context, Jagannathan Raman, 2022/05/03
[PATCH v9 11/17] vfio-user: handle PCI config space accesses, Jagannathan Raman, 2022/05/03
[PATCH v9 13/17] vfio-user: handle DMA mappings, Jagannathan Raman, 2022/05/03
[PATCH v9 12/17] vfio-user: IOMMU support for remote device, Jagannathan Raman, 2022/05/03
[PATCH v9 15/17] vfio-user: handle device interrupts, Jagannathan Raman, 2022/05/03
[PATCH v9 14/17] vfio-user: handle PCI BAR accesses, Jagannathan Raman, 2022/05/03
[PATCH v9 16/17] vfio-user: handle reset of remote device,
Jagannathan Raman <=
[PATCH v9 17/17] vfio-user: avocado tests for vfio-user, Jagannathan Raman, 2022/05/03
Re: [PATCH v9 00/17] vfio-user server in QEMU, Markus Armbruster, 2022/05/04