* [Qemu-devel] [PATCH 1/3] virtio: interface to enable/disable host notifiers
2015-04-07 10:45 [Qemu-devel] [PATCH 0/3] virtio: host notifier API cleanup Michael S. Tsirkin
@ 2015-04-07 10:45 ` Michael S. Tsirkin
2015-04-07 11:32 ` Cornelia Huck
2015-04-07 10:45 ` [Qemu-devel] [PATCH 2/3] dataplane/virtio-blk.c: new API to enable notifiers Michael S. Tsirkin
2015-04-07 10:46 ` [Qemu-devel] [PATCH 3/3] dataplane/virtio-scsi: new API to enable host notifiers Michael S. Tsirkin
2 siblings, 1 reply; 7+ messages in thread
From: Michael S. Tsirkin @ 2015-04-07 10:45 UTC (permalink / raw)
To: qemu-devel; +Cc: Jason Wang
generalize and move these from vhost to virtio.
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
---
include/hw/virtio/virtio.h | 3 +++
hw/virtio/vhost.c | 45 ++--------------------------------------
hw/virtio/virtio.c | 51 ++++++++++++++++++++++++++++++++++++++++++++++
3 files changed, 56 insertions(+), 43 deletions(-)
diff --git a/include/hw/virtio/virtio.h b/include/hw/virtio/virtio.h
index d95f8b6..e1cff22 100644
--- a/include/hw/virtio/virtio.h
+++ b/include/hw/virtio/virtio.h
@@ -219,6 +219,9 @@ void virtio_queue_set_host_notifier_fd_handler(VirtQueue *vq, bool assign,
void virtio_queue_notify_vq(VirtQueue *vq);
void virtio_irq(VirtQueue *vq);
+int virtio_enable_host_notifiers(VirtIODevice *vdev, int startvq, int nvqs);
+void virtio_disable_host_notifiers(VirtIODevice *vdev, int startvq, int nvqs);
+
static inline void virtio_add_feature(uint32_t *features, unsigned int fbit)
{
assert(fbit < 32);
diff --git a/hw/virtio/vhost.c b/hw/virtio/vhost.c
index 5a12861..8dd2f59 100644
--- a/hw/virtio/vhost.c
+++ b/hw/virtio/vhost.c
@@ -918,36 +918,7 @@ bool vhost_dev_query(struct vhost_dev *hdev, VirtIODevice *vdev)
*/
int vhost_dev_enable_notifiers(struct vhost_dev *hdev, VirtIODevice *vdev)
{
- BusState *qbus = BUS(qdev_get_parent_bus(DEVICE(vdev)));
- VirtioBusState *vbus = VIRTIO_BUS(qbus);
- VirtioBusClass *k = VIRTIO_BUS_GET_CLASS(vbus);
- int i, r;
- if (!k->set_host_notifier) {
- fprintf(stderr, "binding does not support host notifiers\n");
- r = -ENOSYS;
- goto fail;
- }
-
- for (i = 0; i < hdev->nvqs; ++i) {
- r = k->set_host_notifier(qbus->parent, hdev->vq_index + i, true);
- if (r < 0) {
- fprintf(stderr, "vhost VQ %d notifier binding failed: %d\n", i, -r);
- goto fail_vq;
- }
- }
-
- return 0;
-fail_vq:
- while (--i >= 0) {
- r = k->set_host_notifier(qbus->parent, hdev->vq_index + i, false);
- if (r < 0) {
- fprintf(stderr, "vhost VQ %d notifier cleanup error: %d\n", i, -r);
- fflush(stderr);
- }
- assert (r >= 0);
- }
-fail:
- return r;
+ return virtio_enable_host_notifiers(vdev, hdev->vq_index, hdev->nvqs);
}
/* Stop processing guest IO notifications in vhost.
@@ -957,19 +928,7 @@ fail:
*/
void vhost_dev_disable_notifiers(struct vhost_dev *hdev, VirtIODevice *vdev)
{
- BusState *qbus = BUS(qdev_get_parent_bus(DEVICE(vdev)));
- VirtioBusState *vbus = VIRTIO_BUS(qbus);
- VirtioBusClass *k = VIRTIO_BUS_GET_CLASS(vbus);
- int i, r;
-
- for (i = 0; i < hdev->nvqs; ++i) {
- r = k->set_host_notifier(qbus->parent, hdev->vq_index + i, false);
- if (r < 0) {
- fprintf(stderr, "vhost VQ %d notifier cleanup failed: %d\n", i, -r);
- fflush(stderr);
- }
- assert (r >= 0);
- }
+ virtio_disable_host_notifiers(vdev, hdev->vq_index, hdev->nvqs);
}
/* Test and clear event pending status.
diff --git a/hw/virtio/virtio.c b/hw/virtio/virtio.c
index 17c1260..e7ee069 100644
--- a/hw/virtio/virtio.c
+++ b/hw/virtio/virtio.c
@@ -1283,6 +1283,57 @@ void virtio_device_set_child_bus_name(VirtIODevice *vdev, char *bus_name)
vdev->bus_name = g_strdup(bus_name);
}
+int virtio_enable_host_notifiers(VirtIODevice *vdev, int startvq, int nvqs)
+{
+ BusState *qbus = BUS(qdev_get_parent_bus(DEVICE(vdev)));
+ VirtioBusState *vbus = VIRTIO_BUS(qbus);
+ VirtioBusClass *k = VIRTIO_BUS_GET_CLASS(vbus);
+ int i, r;
+ if (!k->set_host_notifier) {
+ fprintf(stderr, "binding does not support host notifiers\n");
+ r = -ENOSYS;
+ goto fail;
+ }
+
+ for (i = 0; i < nvqs; ++i) {
+ r = k->set_host_notifier(qbus->parent, startvq + i, true);
+ if (r < 0) {
+ fprintf(stderr, "vhost VQ %d notifier binding failed: %d\n", i, -r);
+ goto fail_vq;
+ }
+ }
+
+ return 0;
+fail_vq:
+ while (--i >= 0) {
+ r = k->set_host_notifier(qbus->parent, startvq + i, false);
+ if (r < 0) {
+ fprintf(stderr, "vhost VQ %d notifier cleanup error: %d\n", i, -r);
+ fflush(stderr);
+ }
+ assert (r >= 0);
+ }
+fail:
+ return r;
+}
+
+void virtio_disable_host_notifiers(VirtIODevice *vdev, int startvq, int nvqs)
+{
+ BusState *qbus = BUS(qdev_get_parent_bus(DEVICE(vdev)));
+ VirtioBusState *vbus = VIRTIO_BUS(qbus);
+ VirtioBusClass *k = VIRTIO_BUS_GET_CLASS(vbus);
+ int i, r;
+
+ for (i = 0; i < nvqs; ++i) {
+ r = k->set_host_notifier(qbus->parent, startvq + i, false);
+ if (r < 0) {
+ fprintf(stderr, "vhost VQ %d notifier cleanup failed: %d\n", i, -r);
+ fflush(stderr);
+ }
+ assert (r >= 0);
+ }
+}
+
static void virtio_device_realize(DeviceState *dev, Error **errp)
{
VirtIODevice *vdev = VIRTIO_DEVICE(dev);
--
MST
^ permalink raw reply related [flat|nested] 7+ messages in thread* Re: [Qemu-devel] [PATCH 1/3] virtio: interface to enable/disable host notifiers
2015-04-07 10:45 ` [Qemu-devel] [PATCH 1/3] virtio: interface to enable/disable host notifiers Michael S. Tsirkin
@ 2015-04-07 11:32 ` Cornelia Huck
0 siblings, 0 replies; 7+ messages in thread
From: Cornelia Huck @ 2015-04-07 11:32 UTC (permalink / raw)
To: Michael S. Tsirkin; +Cc: Jason Wang, qemu-devel
On Tue, 7 Apr 2015 12:45:56 +0200
"Michael S. Tsirkin" <mst@redhat.com> wrote:
> generalize and move these from vhost to virtio.
>
> Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
> ---
> include/hw/virtio/virtio.h | 3 +++
> hw/virtio/vhost.c | 45 ++--------------------------------------
> hw/virtio/virtio.c | 51 ++++++++++++++++++++++++++++++++++++++++++++++
> 3 files changed, 56 insertions(+), 43 deletions(-)
>
> diff --git a/hw/virtio/virtio.c b/hw/virtio/virtio.c
> index 17c1260..e7ee069 100644
> --- a/hw/virtio/virtio.c
> +++ b/hw/virtio/virtio.c
> @@ -1283,6 +1283,57 @@ void virtio_device_set_child_bus_name(VirtIODevice *vdev, char *bus_name)
> vdev->bus_name = g_strdup(bus_name);
> }
>
> +int virtio_enable_host_notifiers(VirtIODevice *vdev, int startvq, int nvqs)
I realize that you just move the function, but would it make sense to
verify that startvq + nvqs is actually still a valid queue?
> +{
> + BusState *qbus = BUS(qdev_get_parent_bus(DEVICE(vdev)));
> + VirtioBusState *vbus = VIRTIO_BUS(qbus);
> + VirtioBusClass *k = VIRTIO_BUS_GET_CLASS(vbus);
> + int i, r;
> + if (!k->set_host_notifier) {
> + fprintf(stderr, "binding does not support host notifiers\n");
> + r = -ENOSYS;
> + goto fail;
> + }
> +
> + for (i = 0; i < nvqs; ++i) {
> + r = k->set_host_notifier(qbus->parent, startvq + i, true);
> + if (r < 0) {
> + fprintf(stderr, "vhost VQ %d notifier binding failed: %d\n", i, -r);
I think you'll want to get rid of the vhost in the message here. And
the number of the failing virtqueue is startvq+i, no?
Also: would it make sense to convert this to the error reporting
infrastructure?
> + goto fail_vq;
> + }
> + }
> +
> + return 0;
> +fail_vq:
> + while (--i >= 0) {
> + r = k->set_host_notifier(qbus->parent, startvq + i, false);
> + if (r < 0) {
> + fprintf(stderr, "vhost VQ %d notifier cleanup error: %d\n", i, -r);
> + fflush(stderr);
> + }
> + assert (r >= 0);
> + }
> +fail:
> + return r;
> +}
> +
> +void virtio_disable_host_notifiers(VirtIODevice *vdev, int startvq, int nvqs)
> +{
> + BusState *qbus = BUS(qdev_get_parent_bus(DEVICE(vdev)));
> + VirtioBusState *vbus = VIRTIO_BUS(qbus);
> + VirtioBusClass *k = VIRTIO_BUS_GET_CLASS(vbus);
> + int i, r;
> +
> + for (i = 0; i < nvqs; ++i) {
> + r = k->set_host_notifier(qbus->parent, startvq + i, false);
Should a generic function maybe check for ->set_host_notifier and bail
out early if it doesn't exist? Probably depends on how the callers want
to handle non-existence of host notifiers.
> + if (r < 0) {
> + fprintf(stderr, "vhost VQ %d notifier cleanup failed: %d\n", i, -r);
> + fflush(stderr);
> + }
> + assert (r >= 0);
> + }
> +}
> +
> static void virtio_device_realize(DeviceState *dev, Error **errp)
> {
> VirtIODevice *vdev = VIRTIO_DEVICE(dev);
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Qemu-devel] [PATCH 2/3] dataplane/virtio-blk.c: new API to enable notifiers
2015-04-07 10:45 [Qemu-devel] [PATCH 0/3] virtio: host notifier API cleanup Michael S. Tsirkin
2015-04-07 10:45 ` [Qemu-devel] [PATCH 1/3] virtio: interface to enable/disable host notifiers Michael S. Tsirkin
@ 2015-04-07 10:45 ` Michael S. Tsirkin
2015-04-07 11:35 ` Cornelia Huck
2015-04-07 10:46 ` [Qemu-devel] [PATCH 3/3] dataplane/virtio-scsi: new API to enable host notifiers Michael S. Tsirkin
2 siblings, 1 reply; 7+ messages in thread
From: Michael S. Tsirkin @ 2015-04-07 10:45 UTC (permalink / raw)
To: qemu-devel; +Cc: Kevin Wolf, Jason Wang, Stefan Hajnoczi
Switch to new API, no functional changes.
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
---
hw/block/dataplane/virtio-blk.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/hw/block/dataplane/virtio-blk.c b/hw/block/dataplane/virtio-blk.c
index cd41478..c9ac70e 100644
--- a/hw/block/dataplane/virtio-blk.c
+++ b/hw/block/dataplane/virtio-blk.c
@@ -263,7 +263,7 @@ void virtio_blk_data_plane_start(VirtIOBlockDataPlane *s)
s->guest_notifier = virtio_queue_get_guest_notifier(vq);
/* Set up virtqueue notify */
- r = k->set_host_notifier(qbus->parent, 0, true);
+ r = virtio_enable_host_notifiers(s->vdev, 0, 1);
if (r != 0) {
fprintf(stderr, "virtio-blk failed to set host notifier (%d)\n", r);
goto fail_host_notifier;
@@ -289,7 +289,7 @@ void virtio_blk_data_plane_start(VirtIOBlockDataPlane *s)
return;
fail_host_notifier:
- k->set_guest_notifiers(qbus->parent, 1, false);
+ virtio_disable_host_notifiers(s->vdev, 0, 1);
fail_guest_notifiers:
vring_teardown(&s->vring, s->vdev, 0);
s->disabled = true;
@@ -332,7 +332,7 @@ void virtio_blk_data_plane_stop(VirtIOBlockDataPlane *s)
*/
vring_teardown(&s->vring, s->vdev, 0);
- k->set_host_notifier(qbus->parent, 0, false);
+ virtio_disable_host_notifiers(s->vdev, 0, 1);
/* Clean up guest notifier (irq) */
k->set_guest_notifiers(qbus->parent, 1, false);
--
MST
^ permalink raw reply related [flat|nested] 7+ messages in thread* Re: [Qemu-devel] [PATCH 2/3] dataplane/virtio-blk.c: new API to enable notifiers
2015-04-07 10:45 ` [Qemu-devel] [PATCH 2/3] dataplane/virtio-blk.c: new API to enable notifiers Michael S. Tsirkin
@ 2015-04-07 11:35 ` Cornelia Huck
0 siblings, 0 replies; 7+ messages in thread
From: Cornelia Huck @ 2015-04-07 11:35 UTC (permalink / raw)
To: Michael S. Tsirkin; +Cc: Kevin Wolf, Jason Wang, qemu-devel, Stefan Hajnoczi
On Tue, 7 Apr 2015 12:45:58 +0200
"Michael S. Tsirkin" <mst@redhat.com> wrote:
> Switch to new API, no functional changes.
>
> Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
> ---
> hw/block/dataplane/virtio-blk.c | 6 +++---
> 1 file changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/hw/block/dataplane/virtio-blk.c b/hw/block/dataplane/virtio-blk.c
> index cd41478..c9ac70e 100644
> --- a/hw/block/dataplane/virtio-blk.c
> +++ b/hw/block/dataplane/virtio-blk.c
> @@ -263,7 +263,7 @@ void virtio_blk_data_plane_start(VirtIOBlockDataPlane *s)
> s->guest_notifier = virtio_queue_get_guest_notifier(vq);
>
> /* Set up virtqueue notify */
> - r = k->set_host_notifier(qbus->parent, 0, true);
> + r = virtio_enable_host_notifiers(s->vdev, 0, 1);
> if (r != 0) {
> fprintf(stderr, "virtio-blk failed to set host notifier (%d)\n", r);
> goto fail_host_notifier;
> @@ -289,7 +289,7 @@ void virtio_blk_data_plane_start(VirtIOBlockDataPlane *s)
> return;
>
> fail_host_notifier:
> - k->set_guest_notifiers(qbus->parent, 1, false);
> + virtio_disable_host_notifiers(s->vdev, 0, 1);
This one is supposed to disable the guest notifier, not the host
notifier.
> fail_guest_notifiers:
> vring_teardown(&s->vring, s->vdev, 0);
> s->disabled = true;
> @@ -332,7 +332,7 @@ void virtio_blk_data_plane_stop(VirtIOBlockDataPlane *s)
> */
> vring_teardown(&s->vring, s->vdev, 0);
>
> - k->set_host_notifier(qbus->parent, 0, false);
> + virtio_disable_host_notifiers(s->vdev, 0, 1);
>
> /* Clean up guest notifier (irq) */
> k->set_guest_notifiers(qbus->parent, 1, false);
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Qemu-devel] [PATCH 3/3] dataplane/virtio-scsi: new API to enable host notifiers
2015-04-07 10:45 [Qemu-devel] [PATCH 0/3] virtio: host notifier API cleanup Michael S. Tsirkin
2015-04-07 10:45 ` [Qemu-devel] [PATCH 1/3] virtio: interface to enable/disable host notifiers Michael S. Tsirkin
2015-04-07 10:45 ` [Qemu-devel] [PATCH 2/3] dataplane/virtio-blk.c: new API to enable notifiers Michael S. Tsirkin
@ 2015-04-07 10:46 ` Michael S. Tsirkin
2015-04-07 11:41 ` Cornelia Huck
2 siblings, 1 reply; 7+ messages in thread
From: Michael S. Tsirkin @ 2015-04-07 10:46 UTC (permalink / raw)
To: qemu-devel; +Cc: Paolo Bonzini, Jason Wang
Switch to new API.
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
---
include/hw/virtio/virtio.h | 1 -
hw/scsi/virtio-scsi-dataplane.c | 14 ++++----------
hw/virtio/virtio.c | 8 +++++++-
3 files changed, 11 insertions(+), 12 deletions(-)
diff --git a/include/hw/virtio/virtio.h b/include/hw/virtio/virtio.h
index e1cff22..7e70193 100644
--- a/include/hw/virtio/virtio.h
+++ b/include/hw/virtio/virtio.h
@@ -217,7 +217,6 @@ EventNotifier *virtio_queue_get_host_notifier(VirtQueue *vq);
void virtio_queue_set_host_notifier_fd_handler(VirtQueue *vq, bool assign,
bool set_handler);
void virtio_queue_notify_vq(VirtQueue *vq);
-void virtio_irq(VirtQueue *vq);
int virtio_enable_host_notifiers(VirtIODevice *vdev, int startvq, int nvqs);
void virtio_disable_host_notifiers(VirtIODevice *vdev, int startvq, int nvqs);
diff --git a/hw/scsi/virtio-scsi-dataplane.c b/hw/scsi/virtio-scsi-dataplane.c
index 5575648..965ccb8 100644
--- a/hw/scsi/virtio-scsi-dataplane.c
+++ b/hw/scsi/virtio-scsi-dataplane.c
@@ -43,13 +43,11 @@ static VirtIOSCSIVring *virtio_scsi_vring_init(VirtIOSCSI *s,
EventNotifierHandler *handler,
int n)
{
- BusState *qbus = BUS(qdev_get_parent_bus(DEVICE(s)));
- VirtioBusClass *k = VIRTIO_BUS_GET_CLASS(qbus);
VirtIOSCSIVring *r;
int rc;
/* Set up virtqueue notify */
- rc = k->set_host_notifier(qbus->parent, n, true);
+ rc = virtio_enable_host_notifiers(VIRTIO_DEVICE(s), n, 1);
if (rc != 0) {
fprintf(stderr, "virtio-scsi: Failed to set host notifier (%d)\n",
rc);
@@ -72,7 +70,7 @@ static VirtIOSCSIVring *virtio_scsi_vring_init(VirtIOSCSI *s,
fail_vring:
aio_set_event_notifier(s->ctx, &r->host_notifier, NULL);
- k->set_host_notifier(qbus->parent, n, false);
+ virtio_disable_host_notifiers(VIRTIO_DEVICE(s), n, 1);
g_slice_free(VirtIOSCSIVring, r);
return NULL;
}
@@ -261,9 +259,7 @@ fail_vrings:
virtio_scsi_clear_aio(s);
aio_context_release(s->ctx);
virtio_scsi_vring_teardown(s);
- for (i = 0; i < vs->conf.num_queues + 2; i++) {
- k->set_host_notifier(qbus->parent, i, false);
- }
+ virtio_disable_host_notifiers(VIRTIO_DEVICE(s), 0, vs->conf.num_queues + 2);
k->set_guest_notifiers(qbus->parent, vs->conf.num_queues + 2, false);
fail_guest_notifiers:
s->dataplane_starting = false;
@@ -305,9 +301,7 @@ void virtio_scsi_dataplane_stop(VirtIOSCSI *s)
*/
virtio_scsi_vring_teardown(s);
- for (i = 0; i < vs->conf.num_queues + 2; i++) {
- k->set_host_notifier(qbus->parent, i, false);
- }
+ virtio_disable_host_notifiers(VIRTIO_DEVICE(s), 0, vs->conf.num_queues + 2);
/* Clean up guest notifier (irq) */
k->set_guest_notifiers(qbus->parent, vs->conf.num_queues + 2, false);
diff --git a/hw/virtio/virtio.c b/hw/virtio/virtio.c
index e7ee069..60d10cd 100644
--- a/hw/virtio/virtio.c
+++ b/hw/virtio/virtio.c
@@ -84,6 +84,9 @@ struct VirtQueue
int inuse;
+ /* Host notifier enabled? */
+ bool host_notifier_enabled;
+
uint16_t vector;
void (*handle_output)(VirtIODevice *vdev, VirtQueue *vq);
VirtIODevice *vdev;
@@ -813,7 +816,7 @@ void virtio_del_queue(VirtIODevice *vdev, int n)
vdev->vq[n].vring.num = 0;
}
-void virtio_irq(VirtQueue *vq)
+static void virtio_irq(VirtQueue *vq)
{
trace_virtio_irq(vq);
vq->vdev->isr |= 0x01;
@@ -1301,11 +1304,13 @@ int virtio_enable_host_notifiers(VirtIODevice *vdev, int startvq, int nvqs)
fprintf(stderr, "vhost VQ %d notifier binding failed: %d\n", i, -r);
goto fail_vq;
}
+ vdev->vq[startvq + i].host_notifier_enabled = true;
}
return 0;
fail_vq:
while (--i >= 0) {
+ vdev->vq[startvq + i].host_notifier_enabled = false;
r = k->set_host_notifier(qbus->parent, startvq + i, false);
if (r < 0) {
fprintf(stderr, "vhost VQ %d notifier cleanup error: %d\n", i, -r);
@@ -1325,6 +1330,7 @@ void virtio_disable_host_notifiers(VirtIODevice *vdev, int startvq, int nvqs)
int i, r;
for (i = 0; i < nvqs; ++i) {
+ vdev->vq[startvq + i].host_notifier_enabled = false;
r = k->set_host_notifier(qbus->parent, startvq + i, false);
if (r < 0) {
fprintf(stderr, "vhost VQ %d notifier cleanup failed: %d\n", i, -r);
--
MST
^ permalink raw reply related [flat|nested] 7+ messages in thread* Re: [Qemu-devel] [PATCH 3/3] dataplane/virtio-scsi: new API to enable host notifiers
2015-04-07 10:46 ` [Qemu-devel] [PATCH 3/3] dataplane/virtio-scsi: new API to enable host notifiers Michael S. Tsirkin
@ 2015-04-07 11:41 ` Cornelia Huck
0 siblings, 0 replies; 7+ messages in thread
From: Cornelia Huck @ 2015-04-07 11:41 UTC (permalink / raw)
To: Michael S. Tsirkin; +Cc: Paolo Bonzini, Jason Wang, qemu-devel
On Tue, 7 Apr 2015 12:46:01 +0200
"Michael S. Tsirkin" <mst@redhat.com> wrote:
> Switch to new API.
>
> Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
> ---
> include/hw/virtio/virtio.h | 1 -
> hw/scsi/virtio-scsi-dataplane.c | 14 ++++----------
> hw/virtio/virtio.c | 8 +++++++-
> 3 files changed, 11 insertions(+), 12 deletions(-)
>
> diff --git a/include/hw/virtio/virtio.h b/include/hw/virtio/virtio.h
> index e1cff22..7e70193 100644
> --- a/include/hw/virtio/virtio.h
> +++ b/include/hw/virtio/virtio.h
> @@ -217,7 +217,6 @@ EventNotifier *virtio_queue_get_host_notifier(VirtQueue *vq);
> void virtio_queue_set_host_notifier_fd_handler(VirtQueue *vq, bool assign,
> bool set_handler);
> void virtio_queue_notify_vq(VirtQueue *vq);
> -void virtio_irq(VirtQueue *vq);
Unrelated cleanup?
>
> int virtio_enable_host_notifiers(VirtIODevice *vdev, int startvq, int nvqs);
> void virtio_disable_host_notifiers(VirtIODevice *vdev, int startvq, int nvqs);
(...)
> diff --git a/hw/virtio/virtio.c b/hw/virtio/virtio.c
> index e7ee069..60d10cd 100644
> --- a/hw/virtio/virtio.c
> +++ b/hw/virtio/virtio.c
> @@ -84,6 +84,9 @@ struct VirtQueue
>
> int inuse;
>
> + /* Host notifier enabled? */
> + bool host_notifier_enabled;
This looks to be write-only. Have you maybe mixed in some unrelated
changes?
> +
> uint16_t vector;
> void (*handle_output)(VirtIODevice *vdev, VirtQueue *vq);
> VirtIODevice *vdev;
> @@ -813,7 +816,7 @@ void virtio_del_queue(VirtIODevice *vdev, int n)
> vdev->vq[n].vring.num = 0;
> }
>
> -void virtio_irq(VirtQueue *vq)
> +static void virtio_irq(VirtQueue *vq)
> {
> trace_virtio_irq(vq);
> vq->vdev->isr |= 0x01;
> @@ -1301,11 +1304,13 @@ int virtio_enable_host_notifiers(VirtIODevice *vdev, int startvq, int nvqs)
> fprintf(stderr, "vhost VQ %d notifier binding failed: %d\n", i, -r);
> goto fail_vq;
> }
> + vdev->vq[startvq + i].host_notifier_enabled = true;
> }
>
> return 0;
> fail_vq:
> while (--i >= 0) {
> + vdev->vq[startvq + i].host_notifier_enabled = false;
> r = k->set_host_notifier(qbus->parent, startvq + i, false);
> if (r < 0) {
> fprintf(stderr, "vhost VQ %d notifier cleanup error: %d\n", i, -r);
> @@ -1325,6 +1330,7 @@ void virtio_disable_host_notifiers(VirtIODevice *vdev, int startvq, int nvqs)
> int i, r;
>
> for (i = 0; i < nvqs; ++i) {
> + vdev->vq[startvq + i].host_notifier_enabled = false;
> r = k->set_host_notifier(qbus->parent, startvq + i, false);
> if (r < 0) {
> fprintf(stderr, "vhost VQ %d notifier cleanup failed: %d\n", i, -r);
^ permalink raw reply [flat|nested] 7+ messages in thread