[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v10 14/14] vfio-user: handle reset of remote device
From: |
Jagannathan Raman |
Subject: |
[PATCH v10 14/14] vfio-user: handle reset of remote device |
Date: |
Tue, 24 May 2022 11:30:33 -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 eeb165a805..c0c2277bfc 100644
--- a/hw/remote/vfio-user-obj.c
+++ b/hw/remote/vfio-user-obj.c
@@ -632,6 +632,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
@@ -751,6 +765,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
- [PATCH v10 02/14] remote/machine: add HotplugHandler for remote machine, (continued)
- [PATCH v10 02/14] remote/machine: add HotplugHandler for remote machine, Jagannathan Raman, 2022/05/24
- [PATCH v10 01/14] qdev: unplug blocker for devices, Jagannathan Raman, 2022/05/24
- [PATCH v10 06/14] vfio-user: instantiate vfio-user context, Jagannathan Raman, 2022/05/24
- [PATCH v10 03/14] remote/machine: add vfio-user property, Jagannathan Raman, 2022/05/24
- [PATCH v10 04/14] vfio-user: build library, Jagannathan Raman, 2022/05/24
- [PATCH v10 08/14] vfio-user: run vfio-user context, Jagannathan Raman, 2022/05/24
- [PATCH v10 07/14] vfio-user: find and init PCI device, Jagannathan Raman, 2022/05/24
- [PATCH v10 09/14] vfio-user: handle PCI config space accesses, Jagannathan Raman, 2022/05/24
- [PATCH v10 05/14] vfio-user: define vfio-user-server object, Jagannathan Raman, 2022/05/24
- [PATCH v10 14/14] vfio-user: handle reset of remote device,
Jagannathan Raman <=
- [PATCH v10 12/14] vfio-user: handle PCI BAR accesses, Jagannathan Raman, 2022/05/24
- [PATCH v10 11/14] vfio-user: handle DMA mappings, Jagannathan Raman, 2022/05/24
- [PATCH v10 10/14] vfio-user: IOMMU support for remote device, Jagannathan Raman, 2022/05/24
- [PATCH v10 13/14] vfio-user: handle device interrupts, Jagannathan Raman, 2022/05/24
Re: [PATCH v10 00/14] vfio-user server in QEMU, Stefan Hajnoczi, 2022/05/25