yeahuh / rpms / qemu-kvm

Forked from rpms/qemu-kvm 2 years ago
Clone

Blame SOURCES/kvm-virtio-scsi-Report-error-if-num_queues-is-0-or-too-l.patch

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