[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH v2 14/16] vhost-pci-slave: add support to delete a v
From: |
Wei Wang |
Subject: |
[Qemu-devel] [PATCH v2 14/16] vhost-pci-slave: add support to delete a vhost-pci device |
Date: |
Fri, 12 May 2017 16:35:46 +0800 |
Signed-off-by: Wei Wang <address@hidden>
---
hw/virtio/vhost-pci-slave.c | 41 +++++++++++++++++++++++++++++++++++++++++
1 file changed, 41 insertions(+)
diff --git a/hw/virtio/vhost-pci-slave.c b/hw/virtio/vhost-pci-slave.c
index a7d3c8d..cde122c 100644
--- a/hw/virtio/vhost-pci-slave.c
+++ b/hw/virtio/vhost-pci-slave.c
@@ -139,6 +139,42 @@ static int vp_slave_send_u64(int request, uint64_t u64)
return 0;
}
+static DeviceState *virtio_to_pci_dev(VirtIODevice *vdev, uint16_t virtio_id)
+{
+ DeviceState *qdev = NULL;
+ VhostPCINet *vpnet;
+ VhostPCINetPCI *netpci;
+
+ if (!vdev) {
+ return NULL;
+ }
+
+ switch (virtio_id) {
+ case VIRTIO_ID_NET:
+ vpnet = VHOST_PCI_NET(vdev);
+ netpci = container_of(vpnet, VhostPCINetPCI, vdev);
+ qdev = &netpci->parent_obj.pci_dev.qdev;
+ break;
+ default:
+ error_report("virtio_to_pci_dev: device type %d not supported",
+ virtio_id);
+ }
+
+ return qdev;
+}
+
+static void vp_slave_device_del(VirtIODevice *vdev)
+{
+ Error *errp = NULL;
+ VhostPCIDev *vp_dev = vp_slave->vp_dev;
+ DeviceState *qdev = virtio_to_pci_dev(vdev, vp_dev->dev_type);
+
+ if (qdev != NULL) {
+ qdev_unplug(qdev, &errp);
+ vp_dev_cleanup();
+ }
+}
+
int vp_slave_send_feature_bits(uint64_t features)
{
return vp_slave_send_u64(VHOST_USER_SET_FEATURES, features);
@@ -146,10 +182,13 @@ int vp_slave_send_feature_bits(uint64_t features)
static void vp_slave_event(void *opaque, int event)
{
+ VhostPCIDev *vp_dev = vp_slave->vp_dev;
+
switch (event) {
case CHR_EVENT_OPENED:
break;
case CHR_EVENT_CLOSED:
+ vp_slave_device_del(vp_dev->vdev);
break;
}
}
@@ -416,6 +455,8 @@ static int vp_slave_set_vhost_pci(VhostUserMsg *msg)
}
break;
case VHOST_USER_SET_VHOST_PCI_STOP:
+ vp_slave_device_del(vp_dev->vdev);
+ ret = 0;
break;
default:
error_report("%s: cmd %d not supported", __func__, cmd);
--
2.7.4
- [Qemu-devel] [PATCH v2 05/16] vhost-pci-net-pci: add vhost-pci-net-pci, (continued)
- [Qemu-devel] [PATCH v2 05/16] vhost-pci-net-pci: add vhost-pci-net-pci, Wei Wang, 2017/05/12
- [Qemu-devel] [PATCH v2 06/16] virtio: add inter-vm notification support, Wei Wang, 2017/05/12
- [Qemu-devel] [PATCH v2 08/16] vhost-user: send guest physical address of virtqueues to the slave, Wei Wang, 2017/05/12
- [Qemu-devel] [PATCH v2 09/16] vhost-user: send VHOST_USER_SET_VHOST_PCI_START/STOP, Wei Wang, 2017/05/12
- [Qemu-devel] [PATCH v2 10/16] vhost-pci-net: send the negotiated feature bits to the master, Wei Wang, 2017/05/12
- [Qemu-devel] [PATCH v2 11/16] vhost-user: add asynchronous read for the vhost-user master, Wei Wang, 2017/05/12
- [Qemu-devel] [PATCH v2 12/16] vhost-user: handling VHOST_USER_SET_FEATURES, Wei Wang, 2017/05/12
- [Qemu-devel] [PATCH v2 13/16] vhost-pci-slave: add "reset_virtio", Wei Wang, 2017/05/12
- [Qemu-devel] [PATCH v2 14/16] vhost-pci-slave: add support to delete a vhost-pci device,
Wei Wang <=
- [Qemu-devel] [PATCH v2 15/16] vhost-pci-net: tell the driver that it is ready to send packets, Wei Wang, 2017/05/12
- [Qemu-devel] [PATCH v2 16/16] vl: enable vhost-pci-slave, Wei Wang, 2017/05/12
- Re: [Qemu-devel] [PATCH v2 00/16] Vhost-pci for inter-VM communication, no-reply, 2017/05/12
- Re: [Qemu-devel] [PATCH v2 00/16] Vhost-pci for inter-VM communication, Jason Wang, 2017/05/16