yeahuh / rpms / qemu-kvm

Forked from rpms/qemu-kvm 2 years ago
Clone
Blob Blame History Raw
From fbbdbb9f62c7239d8e299b17be82e5ac3b5eca09 Mon Sep 17 00:00:00 2001
From: Marcelo Tosatti <mtosatti@redhat.com>
Date: Tue, 20 Aug 2013 21:45:54 +0200
Subject: [PATCH 26/28] kvm-all.c: max_cpus should not exceed KVM vcpu limit

RH-Author: Marcelo Tosatti <mtosatti@redhat.com>
Message-id: <20130820214554.GB9334@amt.cnet>
Patchwork-id: 53621
O-Subject: [RHEL7 qemu-kvm PATCH] kvm-all.c: max_cpus should not exceed KVM vcpu limit
Bugzilla: 996258
RH-Acked-by: Andrew Jones <drjones@redhat.com>
RH-Acked-by: Paolo Bonzini <pbonzini@redhat.com>
RH-Acked-by: Eduardo Habkost <ehabkost@redhat.com>

commit 7dc52526850849e8e0fe56ced809d0798481a2f6 of uq/master branch
of qemu-kvm.git repository

maxcpus, which specifies the maximum number of hotpluggable CPUs,
should not exceed KVM's vcpu limit.

Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
[Reword message. - Paolo]
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
BZ: 996258

Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
---
 kvm-all.c |    7 +++++++
 1 files changed, 7 insertions(+), 0 deletions(-)

diff --git a/kvm-all.c b/kvm-all.c
index 6c9d51e..545b470 100644
--- a/kvm-all.c
+++ b/kvm-all.c
@@ -1358,6 +1358,13 @@ int kvm_init(void)
         goto err;
     }
 
+    if (max_cpus > max_vcpus) {
+        ret = -EINVAL;
+        fprintf(stderr, "Number of hotpluggable cpus requested (%d) exceeds max cpus "
+                "supported by KVM (%d)\n", max_cpus, max_vcpus);
+        goto err;
+    }
+
     s->vmfd = kvm_ioctl(s, KVM_CREATE_VM, 0);
     if (s->vmfd < 0) {
 #ifdef TARGET_S390X
-- 
1.7.1