Sophie

Sophie

distrib > Scientific%20Linux > 5x > x86_64 > by-pkgid > 340e01248478ba8b78a6d4d1809b1eff > files > 620

kvm-83-270.el5_11.src.rpm

From 91dc8d6730472184b46ba3e096bb42910ef9792e Mon Sep 17 00:00:00 2001
From: Alex Williamson <alex.williamson@redhat.com>
Date: Wed, 21 Sep 2011 15:23:51 +0200
Subject: [PATCH 1/2] pci-assign: limit number of assigned devices via hotplug

RH-Author: Alex Williamson <alex.williamson@redhat.com>
Message-id: <20110921152327.10545.30645.stgit@x201.home>
Patchwork-id: 33087
O-Subject: [RHEL5.8 kvm PATCH] pci-assign: limit number of assigned devices via hotplug
Bugzilla: 701616
RH-Acked-by: Amit Shah <amit.shah@redhat.com>
RH-Acked-by: Don Dutile <ddutile@redhat.com>
RH-Acked-by: Paolo Bonzini <pbonzini@redhat.com>

Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=701616
Brew build: https://brewweb.devel.redhat.com/taskinfo?taskID=3654509
Upstream status: N/A

The current limit of assigned devices is only applied for
cold-plug devices.  Also restrict hot-plug by counting
devices each time we add one.

Signed-off-by: Alex Williamson <alex.williamson@redhat.com>
---

 qemu/hw/device-assignment.c |   11 ++++++++++-
 1 files changed, 10 insertions(+), 1 deletions(-)

Signed-off-by: Michal Novotny <mignov@gmail.com>
---
 qemu/hw/device-assignment.c |   11 ++++++++++-
 1 files changed, 10 insertions(+), 1 deletions(-)

diff --git a/qemu/hw/device-assignment.c b/qemu/hw/device-assignment.c
index 560887b..245d011 100644
--- a/qemu/hw/device-assignment.c
+++ b/qemu/hw/device-assignment.c
@@ -1227,10 +1227,19 @@ AssignedDevInfo *add_assigned_device(const char *arg)
 {
     char device[16];
     char dma[6];
-    int r;
+    int r, assigned_devs = 0;
     AssignedDevInfo *adev;
     static int reset_registered = 0;
 
+    LIST_FOREACH(adev, &adev_head, next) {
+        assigned_devs++;
+    }
+
+    if (assigned_devs >= MAX_DEV_ASSIGN_CMDLINE) {
+        fprintf(stderr, "Too many assigned devices\n");
+        return NULL;
+    }
+
     adev = qemu_mallocz(sizeof(AssignedDevInfo));
     if (adev == NULL) {
         fprintf(stderr, "%s: Out of memory\n", __func__);
-- 
1.7.4.4