mirror of https://github.com/xemu-project/xemu.git
virtio-blk: fix disabled mode
We must not call virtio_blk_data_plane_notify if dataplane is disabled: we would hit a segmentation fault in notify_guest_bh as s->guest_notifier has not been setup and is NULL. Reviewed-by: Cornelia Huck <cornelia.huck@de.ibm.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> Reviewed-by: Michael S. Tsirkin <mst@redhat.com> Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
This commit is contained in:
parent
2b2cbcadc1
commit
eb41cf78fc
|
@ -29,7 +29,6 @@
|
||||||
struct VirtIOBlockDataPlane {
|
struct VirtIOBlockDataPlane {
|
||||||
bool starting;
|
bool starting;
|
||||||
bool stopping;
|
bool stopping;
|
||||||
bool disabled;
|
|
||||||
|
|
||||||
VirtIOBlkConf *conf;
|
VirtIOBlkConf *conf;
|
||||||
|
|
||||||
|
@ -234,7 +233,7 @@ void virtio_blk_data_plane_start(VirtIOBlockDataPlane *s)
|
||||||
fail_host_notifier:
|
fail_host_notifier:
|
||||||
k->set_guest_notifiers(qbus->parent, 1, false);
|
k->set_guest_notifiers(qbus->parent, 1, false);
|
||||||
fail_guest_notifiers:
|
fail_guest_notifiers:
|
||||||
s->disabled = true;
|
vblk->dataplane_disabled = true;
|
||||||
s->starting = false;
|
s->starting = false;
|
||||||
vblk->dataplane_started = true;
|
vblk->dataplane_started = true;
|
||||||
}
|
}
|
||||||
|
@ -251,8 +250,8 @@ void virtio_blk_data_plane_stop(VirtIOBlockDataPlane *s)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Better luck next time. */
|
/* Better luck next time. */
|
||||||
if (s->disabled) {
|
if (vblk->dataplane_disabled) {
|
||||||
s->disabled = false;
|
vblk->dataplane_disabled = false;
|
||||||
vblk->dataplane_started = false;
|
vblk->dataplane_started = false;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -54,7 +54,7 @@ static void virtio_blk_req_complete(VirtIOBlockReq *req, unsigned char status)
|
||||||
|
|
||||||
stb_p(&req->in->status, status);
|
stb_p(&req->in->status, status);
|
||||||
virtqueue_push(s->vq, &req->elem, req->in_len);
|
virtqueue_push(s->vq, &req->elem, req->in_len);
|
||||||
if (s->dataplane) {
|
if (s->dataplane_started && !s->dataplane_disabled) {
|
||||||
virtio_blk_data_plane_notify(s->dataplane);
|
virtio_blk_data_plane_notify(s->dataplane);
|
||||||
} else {
|
} else {
|
||||||
virtio_notify(vdev, s->vq);
|
virtio_notify(vdev, s->vq);
|
||||||
|
|
|
@ -53,6 +53,7 @@ typedef struct VirtIOBlock {
|
||||||
unsigned short sector_mask;
|
unsigned short sector_mask;
|
||||||
bool original_wce;
|
bool original_wce;
|
||||||
VMChangeStateEntry *change;
|
VMChangeStateEntry *change;
|
||||||
|
bool dataplane_disabled;
|
||||||
bool dataplane_started;
|
bool dataplane_started;
|
||||||
struct VirtIOBlockDataPlane *dataplane;
|
struct VirtIOBlockDataPlane *dataplane;
|
||||||
} VirtIOBlock;
|
} VirtIOBlock;
|
||||||
|
|
Loading…
Reference in New Issue