On 12/19/2016 01:59 PM, Wei Wang wrote:
If the featuer bits sent by the slave are not equal to the ones that
were sent by the master, perform a reset of the master device.
Signed-off-by: Wei Wang <wei.w.w...@intel.com>
---
hw/net/vhost_net.c | 2 ++
hw/virtio/vhost-user.c | 20 ++++++++++++++++++++
hw/virtio/virtio-pci.c | 20 ++++++++++++++++++++
hw/virtio/virtio-pci.h | 2 ++
include/net/vhost-user.h | 14 ++++++++++++++
net/vhost-user.c | 14 +++++---------
6 files changed, 63 insertions(+), 9 deletions(-)
diff --git a/hw/net/vhost_net.c b/hw/net/vhost_net.c
index 8256018..e8a2d4f 100644
--- a/hw/net/vhost_net.c
+++ b/hw/net/vhost_net.c
/* virtio-net-pci */
+void master_reset_virtio_net(VirtIODevice *vdev)
+{
+ VirtIONet *net = VIRTIO_NET(vdev);
+ VirtIONetPCI *net_pci = container_of(net, VirtIONetPCI, vdev);
+ VirtIOPCIProxy *proxy = &net_pci->parent_obj;
+ DeviceState *qdev = DEVICE(proxy);
+ DeviceState *qdev_new;
+ Error *err = NULL;
+
+ virtio_pci_reset(qdev);
+ qdev_unplug(qdev, &err);
+ qdev->realized = false;
+ qdev_new = qdev_device_add(qdev->opts, &err);
+ if (!qdev_new) {
+ qemu_opts_del(qdev->opts);
+ }
+ object_unref(OBJECT(qdev));
+}
+
I still have a problem with this patch. Looks like the virtio reset here
only clears the registers and queue related things. Do we have a power
reset of virtio, which has the same effect as re-plugging into the
virtio device (the driver probe() are re-invoked and feature bits are
re-negotiated). Thanks.
Best,
Wei