mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-04 08:13:54 -06:00
virtio: allow to fail setting status
virtio-1 allow setting of the FEATURES_OK status bit to fail if the negotiated feature bits are inconsistent: let's fail virtio_set_status() in that case and update virtio-ccw to post an error to the guest. Signed-off-by: Cornelia Huck <cornelia.huck@de.ibm.com> Reviewed-by: Michael S. Tsirkin <mst@redhat.com> Signed-off-by: Michael S. Tsirkin <mst@redhat.com> Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
This commit is contained in:
parent
6c0196d702
commit
0b352fd680
3 changed files with 37 additions and 10 deletions
|
@ -544,15 +544,37 @@ void virtio_update_irq(VirtIODevice *vdev)
|
|||
virtio_notify_vector(vdev, VIRTIO_NO_VECTOR);
|
||||
}
|
||||
|
||||
void virtio_set_status(VirtIODevice *vdev, uint8_t val)
|
||||
static int virtio_validate_features(VirtIODevice *vdev)
|
||||
{
|
||||
VirtioDeviceClass *k = VIRTIO_DEVICE_GET_CLASS(vdev);
|
||||
|
||||
if (k->validate_features) {
|
||||
return k->validate_features(vdev);
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
int virtio_set_status(VirtIODevice *vdev, uint8_t val)
|
||||
{
|
||||
VirtioDeviceClass *k = VIRTIO_DEVICE_GET_CLASS(vdev);
|
||||
trace_virtio_set_status(vdev, val);
|
||||
|
||||
if (virtio_has_feature(vdev, VIRTIO_F_VERSION_1)) {
|
||||
if (!(vdev->status & VIRTIO_CONFIG_S_FEATURES_OK) &&
|
||||
val & VIRTIO_CONFIG_S_FEATURES_OK) {
|
||||
int ret = virtio_validate_features(vdev);
|
||||
|
||||
if (ret) {
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (k->set_status) {
|
||||
k->set_status(vdev, val);
|
||||
}
|
||||
vdev->status = val;
|
||||
return 0;
|
||||
}
|
||||
|
||||
bool target_words_bigendian(void);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue