|
|
9ae3a8 |
From c4f4c924bac393b2112ce89c66b825730327159f Mon Sep 17 00:00:00 2001
|
|
|
9ae3a8 |
From: Fam Zheng <famz@redhat.com>
|
|
|
9ae3a8 |
Date: Tue, 4 Nov 2014 03:06:39 +0100
|
|
|
9ae3a8 |
Subject: [PATCH 5/9] virtio-scsi: Report error if num_queues is 0 or too large
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
Message-id: <1415070401-21222-2-git-send-email-famz@redhat.com>
|
|
|
9ae3a8 |
Patchwork-id: 62060
|
|
|
9ae3a8 |
O-Subject: [RHEL-7.1 qemu-kvm PATCH v2 1/3] virtio-scsi: Report error if num_queues is 0 or too large
|
|
|
9ae3a8 |
Bugzilla: 1089606
|
|
|
9ae3a8 |
RH-Acked-by: Markus Armbruster <armbru@redhat.com>
|
|
|
9ae3a8 |
RH-Acked-by: Paolo Bonzini <pbonzini@redhat.com>
|
|
|
9ae3a8 |
RH-Acked-by: Max Reitz <mreitz@redhat.com>
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
No cmd vq surprises guest (Linux panics in virtscsi_probe), too many
|
|
|
9ae3a8 |
queues abort qemu (in the following virtio_add_queue).
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
Signed-off-by: Fam Zheng <famz@redhat.com>
|
|
|
9ae3a8 |
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
|
|
|
9ae3a8 |
(cherry picked from commit c9f6552803d852d593dec9ef5bb39b7a61091963)
|
|
|
9ae3a8 |
Signed-off-by: Fam Zheng <famz@redhat.com>
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
Downstream notes: changed error_setg -> error_report because downstream
|
|
|
9ae3a8 |
oesn't have errp. Also changed "return;" -> "return -1".
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
|
|
|
9ae3a8 |
---
|
|
|
9ae3a8 |
hw/scsi/virtio-scsi.c | 6 ++++++
|
|
|
9ae3a8 |
1 file changed, 6 insertions(+)
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
diff --git a/hw/scsi/virtio-scsi.c b/hw/scsi/virtio-scsi.c
|
|
|
9ae3a8 |
index 35b3d65..73f5ad1 100644
|
|
|
9ae3a8 |
--- a/hw/scsi/virtio-scsi.c
|
|
|
9ae3a8 |
+++ b/hw/scsi/virtio-scsi.c
|
|
|
9ae3a8 |
@@ -605,6 +605,12 @@ int virtio_scsi_common_init(VirtIOSCSICommon *s)
|
|
|
9ae3a8 |
virtio_init(VIRTIO_DEVICE(s), "virtio-scsi", VIRTIO_ID_SCSI,
|
|
|
9ae3a8 |
sizeof(VirtIOSCSIConfig));
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
+ if (s->conf.num_queues <= 0 || s->conf.num_queues > VIRTIO_PCI_QUEUE_MAX) {
|
|
|
9ae3a8 |
+ error_report("Invalid number of queues (= %" PRId32 "), "
|
|
|
9ae3a8 |
+ "must be a positive integer less than %d.",
|
|
|
9ae3a8 |
+ s->conf.num_queues, VIRTIO_PCI_QUEUE_MAX);
|
|
|
9ae3a8 |
+ return -1;
|
|
|
9ae3a8 |
+ }
|
|
|
9ae3a8 |
s->cmd_vqs = g_malloc0(s->conf.num_queues * sizeof(VirtQueue *));
|
|
|
9ae3a8 |
s->sense_size = VIRTIO_SCSI_SENSE_SIZE;
|
|
|
9ae3a8 |
s->cdb_size = VIRTIO_SCSI_CDB_SIZE;
|
|
|
9ae3a8 |
--
|
|
|
9ae3a8 |
1.8.3.1
|
|
|
9ae3a8 |
|