Add the ability to control the CPU topology of created VMs
from userland without the need to use sysctls, it allows the old sysctls to continue to function, but deprecates them at FreeBSD_version 1200060 (Relnotes for deprecate). The command line of bhyve is maintained in a backwards compatible way. The API of libvmmapi is maintained in a backwards compatible way. The sysctl's are maintained in a backwards compatible way. Added command option looks like: bhyve -c [[cpus=]n][,sockets=n][,cores=n][,threads=n][,maxcpus=n] The optional parts can be specified in any order, but only a single integer invokes the backwards compatible parse. [,maxcpus=n] is hidden by #ifdef until kernel support is added, though the api is put in place. bhyvectl --get-cpu-topology option added. Reviewed by: grehan (maintainer, earlier version), Reviewed by: bcr (manpages) Approved by: bde (mentor), phk (mentor) Tested by: Oleg Ginzburg <olevole@olevole.ru> (cbsd) MFC after: 1 week Relnotes: Y Differential Revision: https://reviews.freebsd.org/D9930
This commit is contained in:
+33
-1
@@ -1505,6 +1505,38 @@ vm_restart_instruction(void *arg, int vcpu)
|
||||
return (ioctl(ctx->fd, VM_RESTART_INSTRUCTION, &vcpu));
|
||||
}
|
||||
|
||||
int
|
||||
vm_set_topology(struct vmctx *ctx,
|
||||
uint16_t sockets, uint16_t cores, uint16_t threads, uint16_t maxcpus)
|
||||
{
|
||||
struct vm_cpu_topology topology;
|
||||
|
||||
bzero(&topology, sizeof (struct vm_cpu_topology));
|
||||
topology.sockets = sockets;
|
||||
topology.cores = cores;
|
||||
topology.threads = threads;
|
||||
topology.maxcpus = maxcpus;
|
||||
return (ioctl(ctx->fd, VM_SET_TOPOLOGY, &topology));
|
||||
}
|
||||
|
||||
int
|
||||
vm_get_topology(struct vmctx *ctx,
|
||||
uint16_t *sockets, uint16_t *cores, uint16_t *threads, uint16_t *maxcpus)
|
||||
{
|
||||
struct vm_cpu_topology topology;
|
||||
int error;
|
||||
|
||||
bzero(&topology, sizeof (struct vm_cpu_topology));
|
||||
error = ioctl(ctx->fd, VM_GET_TOPOLOGY, &topology);
|
||||
if (error == 0) {
|
||||
*sockets = topology.sockets;
|
||||
*cores = topology.cores;
|
||||
*threads = topology.threads;
|
||||
*maxcpus = topology.maxcpus;
|
||||
}
|
||||
return (error);
|
||||
}
|
||||
|
||||
int
|
||||
vm_get_device_fd(struct vmctx *ctx)
|
||||
{
|
||||
@@ -1535,7 +1567,7 @@ vm_get_ioctls(size_t *len)
|
||||
VM_ACTIVATE_CPU, VM_GET_CPUS, VM_SUSPEND_CPU, VM_RESUME_CPU,
|
||||
VM_SET_INTINFO, VM_GET_INTINFO,
|
||||
VM_RTC_WRITE, VM_RTC_READ, VM_RTC_SETTIME, VM_RTC_GETTIME,
|
||||
VM_RESTART_INSTRUCTION };
|
||||
VM_RESTART_INSTRUCTION, VM_SET_TOPOLOGY, VM_GET_TOPOLOGY };
|
||||
|
||||
if (len == NULL) {
|
||||
cmds = malloc(sizeof(vm_ioctl_cmds));
|
||||
|
||||
@@ -221,6 +221,12 @@ int vm_activate_cpu(struct vmctx *ctx, int vcpu);
|
||||
int vm_suspend_cpu(struct vmctx *ctx, int vcpu);
|
||||
int vm_resume_cpu(struct vmctx *ctx, int vcpu);
|
||||
|
||||
/* CPU topology */
|
||||
int vm_set_topology(struct vmctx *ctx, uint16_t sockets, uint16_t cores,
|
||||
uint16_t threads, uint16_t maxcpus);
|
||||
int vm_get_topology(struct vmctx *ctx, uint16_t *sockets, uint16_t *cores,
|
||||
uint16_t *threads, uint16_t *maxcpus);
|
||||
|
||||
/*
|
||||
* FreeBSD specific APIs
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user