aboutsummaryrefslogtreecommitdiffstats
path: root/virt/kvm
diff options
context:
space:
mode:
authorAmos Kong <akong@redhat.com>2013-05-24 18:44:15 -0400
committerGleb Natapov <gleb@redhat.com>2013-06-04 04:49:38 -0400
commit6ea34c9b78c10289846db0abeebd6b84d5aca084 (patch)
tree23b7139d16f9bf7c0a5ccd306c39d1b66570b61c /virt/kvm
parent566af9404bf57267ea4fc29ca6b4628a17ee3ea7 (diff)
kvm: exclude ioeventfd from counting kvm_io_range limit
We can easily reach the 1000 limit by start VM with a couple hundred I/O devices (multifunction=on). The hardcode limit already been adjusted 3 times (6 ~ 200 ~ 300 ~ 1000). In userspace, we already have maximum file descriptor to limit ioeventfd count. But kvm_io_bus devices also are used for pit, pic, ioapic, coalesced_mmio. They couldn't be limited by maximum file descriptor. Currently only ioeventfds take too much kvm_io_bus devices, so just exclude it from counting kvm_io_range limit. Also fixed one indent issue in kvm_host.h Signed-off-by: Amos Kong <akong@redhat.com> Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com> Signed-off-by: Gleb Natapov <gleb@redhat.com>
Diffstat (limited to 'virt/kvm')
-rw-r--r--virt/kvm/eventfd.c2
-rw-r--r--virt/kvm/kvm_main.c3
2 files changed, 4 insertions, 1 deletions
diff --git a/virt/kvm/eventfd.c b/virt/kvm/eventfd.c
index 64ee720b75c7..1550637d1b10 100644
--- a/virt/kvm/eventfd.c
+++ b/virt/kvm/eventfd.c
@@ -753,6 +753,7 @@ kvm_assign_ioeventfd(struct kvm *kvm, struct kvm_ioeventfd *args)
753 if (ret < 0) 753 if (ret < 0)
754 goto unlock_fail; 754 goto unlock_fail;
755 755
756 kvm->buses[bus_idx]->ioeventfd_count++;
756 list_add_tail(&p->list, &kvm->ioeventfds); 757 list_add_tail(&p->list, &kvm->ioeventfds);
757 758
758 mutex_unlock(&kvm->slots_lock); 759 mutex_unlock(&kvm->slots_lock);
@@ -798,6 +799,7 @@ kvm_deassign_ioeventfd(struct kvm *kvm, struct kvm_ioeventfd *args)
798 continue; 799 continue;
799 800
800 kvm_io_bus_unregister_dev(kvm, bus_idx, &p->dev); 801 kvm_io_bus_unregister_dev(kvm, bus_idx, &p->dev);
802 kvm->buses[bus_idx]->ioeventfd_count--;
801 ioeventfd_release(p); 803 ioeventfd_release(p);
802 ret = 0; 804 ret = 0;
803 break; 805 break;
diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c
index b547a1ceecbc..1580dd4ace4e 100644
--- a/virt/kvm/kvm_main.c
+++ b/virt/kvm/kvm_main.c
@@ -2926,7 +2926,8 @@ int kvm_io_bus_register_dev(struct kvm *kvm, enum kvm_bus bus_idx, gpa_t addr,
2926 struct kvm_io_bus *new_bus, *bus; 2926 struct kvm_io_bus *new_bus, *bus;
2927 2927
2928 bus = kvm->buses[bus_idx]; 2928 bus = kvm->buses[bus_idx];
2929 if (bus->dev_count > NR_IOBUS_DEVS - 1) 2929 /* exclude ioeventfd which is limited by maximum fd */
2930 if (bus->dev_count - bus->ioeventfd_count > NR_IOBUS_DEVS - 1)
2930 return -ENOSPC; 2931 return -ENOSPC;
2931 2932
2932 new_bus = kzalloc(sizeof(*bus) + ((bus->dev_count + 1) * 2933 new_bus = kzalloc(sizeof(*bus) + ((bus->dev_count + 1) *