summaryrefslogtreecommitdiff
path: root/usr.sbin
diff options
context:
space:
mode:
authorMark Kettenis <kettenis@cvs.openbsd.org>2013-04-03 15:38:49 +0000
committerMark Kettenis <kettenis@cvs.openbsd.org>2013-04-03 15:38:49 +0000
commitb4cd55b6e591713a9ad1e9426ed1553e664de952 (patch)
treeba1bd875291a25bfb11770a279982854d8f361bf /usr.sbin
parentc42f03ba8716e23be5fa894c8ac86518db1e6e04 (diff)
Make it possible to explicitly specify the number of vcpus and the amount
of memory for the primary domain. As a bonus this prevents people from shooting themselves in the foot by creating two domains names "primary".
Diffstat (limited to 'usr.sbin')
-rw-r--r--usr.sbin/ldomctl/config.c28
1 files changed, 19 insertions, 9 deletions
diff --git a/usr.sbin/ldomctl/config.c b/usr.sbin/ldomctl/config.c
index 42c64259d2b..7cef14167d7 100644
--- a/usr.sbin/ldomctl/config.c
+++ b/usr.sbin/ldomctl/config.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: config.c,v 1.17 2013/04/01 17:51:56 kettenis Exp $ */
+/* $OpenBSD: config.c,v 1.18 2013/04/03 15:38:48 kettenis Exp $ */
/*
* Copyright (c) 2012 Mark Kettenis
@@ -2284,8 +2284,8 @@ build_config(const char *filename)
struct domain *domain;
struct vdisk *vdisk;
struct vnet *vnet;
- uint64_t num_cpus;
- uint64_t memory;
+ uint64_t num_cpus, primary_num_cpus;
+ uint64_t memory, primary_memory;
SIMPLEQ_INIT(&conf.domain_list);
if (parse_config(filename, &conf) < 0)
@@ -2301,15 +2301,23 @@ build_config(const char *filename)
pri_init(pri);
pri_alloc_memory(hv_membase, hv_memsize);
- num_cpus = 0;
- memory = 0;
+ num_cpus = primary_num_cpus = 0;
+ memory = primary_memory = 0;
SIMPLEQ_FOREACH(domain, &conf.domain_list, entry) {
+ if (strcmp(domain->name, "primary") == 0) {
+ primary_num_cpus = domain->vcpu;
+ primary_memory = domain->memory;
+ }
num_cpus += domain->vcpu;
memory += domain->memory;
}
- if (num_cpus >= total_cpus)
+ if (primary_num_cpus == 0 && total_cpus > num_cpus)
+ primary_num_cpus = total_cpus - num_cpus;
+ if (primary_memory == 0 && total_memory > memory)
+ primary_memory = total_memory - memory;
+ if (num_cpus > total_cpus || primary_num_cpus == 0)
errx(1, "not enough VCPU resources available");
- if (memory >= total_memory)
+ if (memory > total_memory || primary_memory == 0)
errx(1, "not enough memory available");
hvmd_init(hvmd);
@@ -2326,12 +2334,14 @@ build_config(const char *filename)
primary->endpoint_id = endpoint->channel + 1;
}
- for (i = total_cpus - num_cpus; i < max_cpus; i++)
+ for (i = primary_num_cpus; i < max_cpus; i++)
guest_delete_cpu(primary, i);
guest_delete_memory(primary);
- guest_add_memory(primary, -1, total_memory - memory);
+ guest_add_memory(primary, -1, primary_memory);
SIMPLEQ_FOREACH(domain, &conf.domain_list, entry) {
+ if (strcmp(domain->name, "primary") == 0)
+ continue;
guest = guest_create(domain->name);
for (i = 0; i < domain->vcpu; i++)
guest_add_cpu(guest);