Thread (21 messages) flat view 21 messages, 3 authors, 2015-06-24
STALE4112d

[PATCH v3 07/10] limit number of VCPUs on demand

From: andre.przywara@arm.com (Andre Przywara)
Date: 2015-06-17 13:14:52
Also in: kvm, kvmarm

On 06/17/2015 01:53 PM, Marc Zyngier wrote:
On 17/06/15 12:21, Andre Przywara wrote:
quoted
Currently the ARM GIC checks the number of VCPUs against a fixed
limit, which is GICv2 specific. Don't pretend we know better than the
kernel and let's get rid of that explicit check.
Instead be more relaxed about KVM_CREATE_VCPU failing with EINVAL,
which is the way the kernel communicates having reached a VCPU limit.
If we see this and have at least brought up one VCPU already
successfully, then don't panic, but limit the number of VCPUs instead.

Signed-off-by: Andre Przywara <andre.przywara@arm.com>
...
quoted
diff --git a/arm/kvm-cpu.c b/arm/kvm-cpu.c
index 7780251..c1cf51d 100644
--- a/arm/kvm-cpu.c
+++ b/arm/kvm-cpu.c
@@ -47,12 +47,19 @@ struct kvm_cpu *kvm_cpu__arch_init(struct kvm *kvm, unsigned long cpu_id)
 	};
 
 	vcpu = calloc(1, sizeof(struct kvm_cpu));
-	if (!vcpu)
+	if (!vcpu) {
+		errno = ENOMEM;
 		return NULL;
+	}
Isn't errno already set when calloc fails?
Ah yes, that seems to be true at least for glibc or UNIX 98, according
to the manpage. I was misguided by the fact that calloc is not a
syscall. So I can drop this hunk.

Thanks,
Andre.
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help