Changeset View
Standalone View
sys/amd64/vmm/vmm.c
Context not available. | |||||
struct vmspace *vmspace; /* (o) guest's address space */ | struct vmspace *vmspace; /* (o) guest's address space */ | ||||
char name[VM_MAX_NAMELEN]; /* (o) virtual machine name */ | char name[VM_MAX_NAMELEN]; /* (o) virtual machine name */ | ||||
struct vcpu vcpu[VM_MAXCPU]; /* (i) guest vcpus */ | struct vcpu vcpu[VM_MAXCPU]; /* (i) guest vcpus */ | ||||
/* The following describe the vm cpu topology */ | |||||
uint16_t sockets; /* (o) num of sockets */ | |||||
grehan: uint16_t -> uint16_t | |||||
uint16_t cores; /* (o) num of cores/socket */ | |||||
uint16_t threads; /* (o) num of threads/core */ | |||||
uint16_t maxcpus; /* (o) max pluggable cpus */ | |||||
}; | }; | ||||
static int vmm_initialized; | static int vmm_initialized; | ||||
Done Inline ActionsThese can be deleted. grehan: These can be deleted. | |||||
Context not available. | |||||
vcpu_init(vm, i, create); | vcpu_init(vm, i, create); | ||||
} | } | ||||
/* | |||||
Done Inline Actionsu_int -> uint16_t grehan: u_int -> uint16_t | |||||
Done Inline ActionsThis is an existing interface with an existing data type, I wish to maintain the old type for compatibility with stable/11, once this change is merged back there shall be a review for depreciating these 2 sysctl's with notification in stable/11 and removal in ^head. rgrimes: This is an existing interface with an existing data type, I wish to maintain the old type for… | |||||
* The default CPU topology is a single thread per package. | |||||
*/ | |||||
u_int cores_per_package = 1; | |||||
u_int threads_per_core = 1; | |||||
int | int | ||||
vm_create(const char *name, struct vm **retvm) | vm_create(const char *name, struct vm **retvm) | ||||
{ | { | ||||
Context not available. | |||||
vm->vmspace = vmspace; | vm->vmspace = vmspace; | ||||
mtx_init(&vm->rendezvous_mtx, "vm rendezvous lock", 0, MTX_DEF); | mtx_init(&vm->rendezvous_mtx, "vm rendezvous lock", 0, MTX_DEF); | ||||
vm->sockets = 1; | |||||
Done Inline ActionsMinor style(9), space around = grehan: Minor style(9), space around = | |||||
Done Inline ActionsFixed in my local copy rgrimes: Fixed in my local copy | |||||
vm->cores = cores_per_package; /* XXX backwards compatibility */ | |||||
vm->threads = threads_per_core; /* XXX backwards compatibility */ | |||||
vm->maxcpus = 0; /* XXX not implemented */ | |||||
vm_init(vm, true); | vm_init(vm, true); | ||||
*retvm = vm; | *retvm = vm; | ||||
Done Inline Actionsminor - style(9) wants spaces either side of the '='. grehan: minor - style(9) wants spaces either side of the '='. | |||||
Context not available. | |||||
return (0); | return (0); | ||||
} | } | ||||
void | |||||
vm_get_topology(struct vm *vm, uint16_t *sockets, uint16_t *cores, | |||||
uint16_t *threads, uint16_t *maxcpus) | |||||
Done Inline Actionsuint64_t -> uint16_t grehan: uint64_t -> uint16_t | |||||
{ | |||||
*sockets = vm->sockets; | |||||
*cores = vm->cores; | |||||
*threads = vm->threads; | |||||
Done Inline ActionsAs above, style(9) on the '=', but don't need the indirect reference here. Also there should be some error checking on the params, with an error propagated back up to the ioctl caller. grehan: As above, style(9) on the '=', but don't need the indirect reference here.
Also there should… | |||||
Done Inline ActionsFrom reading manual page and code we currently have a limit of 16 vCPU, so should I just simply check for sockets*cores*threads <=16, and if not through EINVAL? rgrimes: From reading manual page and code we currently have a limit of 16 vCPU, so should I just simply… | |||||
*maxcpus = vm->maxcpus; | |||||
} | |||||
int | |||||
vm_set_topology(struct vm *vm, uint16_t sockets, uint16_t cores, | |||||
uint16_t threads, uint16_t maxcpus) | |||||
Done Inline Actionsuint64_t -> uint16_t grehan: uint64_t -> uint16_t | |||||
{ | |||||
if (maxcpus != 0) | |||||
Done Inline Actionsminor style(9), return statement should be on newline. grehan: minor style(9), return statement should be on newline. | |||||
Done Inline ActionsDone in local copy, also next line has same problem. Fixed. rgrimes: Done in local copy, also next line has same problem. Fixed. | |||||
return (EINVAL); /* XXX remove when supported */ | |||||
if ((sockets * cores * threads) > VM_MAXCPU) | |||||
return (EINVAL); | |||||
/* XXX need to check sockets * cores * threads == vCPU, how? */ | |||||
vm->sockets = sockets; | |||||
vm->cores = cores; | |||||
vm->threads = threads; | |||||
vm->maxcpus = maxcpus; | |||||
return(0); | |||||
} | |||||
static void | static void | ||||
vm_cleanup(struct vm *vm, bool destroy) | vm_cleanup(struct vm *vm, bool destroy) | ||||
{ | { | ||||
Context not available. |
uint16_t -> uint16_t