On Mon, Dec 17, 2012 at 05:24:35PM +0100, Paolo Bonzini wrote: > After discussion with mst on the topic of resetting virtio devices, > here is a series that hopefully clarifies the semantics of bus and > device resets. > > After this series, there are two kinds of resets:
So just to clarify, what I proposed was this (on top of my type safety patch). Then all transports can call virtio_config_reset when appropriate (e.g. when PA is set to 0). Signed-off-by: Michael S. Tsirkin <m...@redhat.com> diff --git a/hw/virtio.c b/hw/virtio.c index f40a8c5..e65d7c8 100644 --- a/hw/virtio.c +++ b/hw/virtio.c @@ -554,6 +554,14 @@ void virtio_reset(void *opaque) } } +/* Device-specific reset through virtio config space. + * Reset virtio config and backend child devices if any. + */ +void virtio_config_reset(VirtIODevice *vdev) +{ + qdev_reset_all(vdev->binding_opaque); +} + uint32_t virtio_config_readb(VirtIODevice *vdev, uint32_t addr) { uint8_t val; diff --git a/hw/virtio.h b/hw/virtio.h index 7c17f7b..e2e57a4 100644 --- a/hw/virtio.h +++ b/hw/virtio.h @@ -187,11 +187,12 @@ uint16_t virtio_queue_vector(VirtIODevice *vdev, int n); void virtio_queue_set_vector(VirtIODevice *vdev, int n, uint16_t vector); void virtio_set_status(VirtIODevice *vdev, uint8_t val); void virtio_reset(void *opaque); +void virtio_config_reset(VirtIODevice *vdev); void virtio_update_irq(VirtIODevice *vdev); int virtio_set_features(VirtIODevice *vdev, uint32_t val); void virtio_bind_device(VirtIODevice *vdev, const VirtIOBindings *binding, DeviceState *opaque); /* Base devices. */ typedef struct VirtIOBlkConf VirtIOBlkConf;