hv: remove vm_description_array
When we create an UOS, we didn't indicate the vmid. Thus we can't get the vm description for the vm description array. Instead we use a temporary vm description to save data to fill the vm structure when crate an UOS. It's uselesss once UOS has created. So we don't need to maintain vm description array here for UOS. Signed-off-by: Li, Fei1 <fei1.li@intel.com> Reviewed-by: Kevin Tian <kevin.tian@intel.com>
This commit is contained in:
parent
3fb7b75eda
commit
6c8fc0a4df
|
@ -29,7 +29,6 @@
|
|||
*/
|
||||
|
||||
#include <hypervisor.h>
|
||||
#include <bsp_extern.h>
|
||||
#include <schedule.h>
|
||||
#include <version.h>
|
||||
|
||||
|
|
|
@ -292,31 +292,13 @@ int vm_resume(struct vm *vm)
|
|||
return 0;
|
||||
}
|
||||
|
||||
/* Finally, we will remove the array and only maintain vm0 desc */
|
||||
struct vm_description *get_vm_desc(int idx)
|
||||
{
|
||||
struct vm_description_array *vm_desc_array;
|
||||
|
||||
/* Obtain base of user defined VM description array data
|
||||
* structure
|
||||
*/
|
||||
vm_desc_array = (struct vm_description_array *)get_vm_desc_base();
|
||||
/* Obtain VM description array base */
|
||||
if (idx >= vm_desc_array->num_vm_desc)
|
||||
return NULL;
|
||||
else
|
||||
return &vm_desc_array->vm_desc_array[idx];
|
||||
}
|
||||
|
||||
/* Create vm/vcpu for vm0 */
|
||||
int prepare_vm0(void)
|
||||
{
|
||||
int i, ret;
|
||||
struct vm *vm = NULL;
|
||||
struct vm_description *vm_desc = NULL;
|
||||
struct vm_description *vm_desc = &vm0_desc;
|
||||
|
||||
vm_desc = get_vm_desc(0);
|
||||
ASSERT(vm_desc, "get vm desc failed");
|
||||
ret = create_vm(vm_desc, &vm);
|
||||
ASSERT(ret == 0, "VM creation failed!");
|
||||
|
||||
|
@ -360,16 +342,10 @@ static inline bool vcpu_in_vm_desc(struct vcpu *vcpu,
|
|||
void vm_fixup(struct vm *vm)
|
||||
{
|
||||
if (is_vm0(vm) && (vm->hw.exp_num_vcpus < vm->hw.num_vcpus)) {
|
||||
struct vm_description *vm_desc = NULL;
|
||||
struct vm_description *vm_desc = &vm0_desc;
|
||||
struct vcpu *vcpu;
|
||||
int i;
|
||||
|
||||
vm_desc = get_vm_desc(0);
|
||||
if (vm_desc == NULL) {
|
||||
pr_err("get VM0 description failed.");
|
||||
return;
|
||||
}
|
||||
|
||||
foreach_vcpu(i, vm, vcpu) {
|
||||
if (!vcpu_in_vm_desc(vcpu, vm_desc)) {
|
||||
pause_vcpu(vcpu, VCPU_ZOMBIE);
|
||||
|
|
|
@ -46,12 +46,9 @@
|
|||
/**********************************/
|
||||
/* EXTERNAL VARIABLES */
|
||||
/**********************************/
|
||||
extern struct vm_description vm0_desc;
|
||||
|
||||
/* BSP Interfaces */
|
||||
void init_bsp(void);
|
||||
|
||||
/* External Interfaces */
|
||||
struct _vm_description_array;
|
||||
const struct _vm_description_array *get_vm_desc_base(void);
|
||||
void init_bsp(void);
|
||||
|
||||
#endif /* BSP_EXTERN_H */
|
||||
|
|
|
@ -30,32 +30,16 @@
|
|||
|
||||
#include <hypervisor.h>
|
||||
|
||||
#define NUM_USER_VMS 2
|
||||
|
||||
/* Number of CPUs in VM0 */
|
||||
#define VM0_NUM_CPUS 1
|
||||
|
||||
/* Logical CPU IDs assigned to VM0 */
|
||||
int VM0_CPUS[VM0_NUM_CPUS] = {0};
|
||||
|
||||
const struct vm_description_array vm_desc = {
|
||||
/* Number of user virtual machines */
|
||||
.num_vm_desc = NUM_USER_VMS,
|
||||
|
||||
/* Virtual Machine descriptions */
|
||||
.vm_desc_array = {
|
||||
{
|
||||
/* Internal variable, MUSTBE init to -1 */
|
||||
.vm_attr_name = "vm_0",
|
||||
.vm_hw_num_cores = VM0_NUM_CPUS,
|
||||
.vm_hw_logical_core_ids = &VM0_CPUS[0],
|
||||
.vm_state_info_privilege = VM_PRIVILEGE_LEVEL_HIGH,
|
||||
.vm_created = false,
|
||||
},
|
||||
}
|
||||
struct vm_description vm0_desc = {
|
||||
.vm_attr_name = "vm_0",
|
||||
.vm_hw_num_cores = VM0_NUM_CPUS,
|
||||
.vm_hw_logical_core_ids = &VM0_CPUS[0],
|
||||
.vm_state_info_privilege = VM_PRIVILEGE_LEVEL_HIGH,
|
||||
.vm_created = false,
|
||||
};
|
||||
|
||||
const struct vm_description_array *get_vm_desc_base(void)
|
||||
{
|
||||
return &vm_desc;
|
||||
}
|
||||
|
|
|
@ -30,31 +30,16 @@
|
|||
|
||||
#include <hypervisor.h>
|
||||
|
||||
#define NUM_USER_VMS 2
|
||||
|
||||
/* Number of CPUs in VM0 */
|
||||
#define VM0_NUM_CPUS 1
|
||||
|
||||
/* Logical CPU IDs assigned to VM0 */
|
||||
int VM0_CPUS[VM0_NUM_CPUS] = {0};
|
||||
|
||||
const struct vm_description_array vm_desc = {
|
||||
/* Number of user virtual machines */
|
||||
.num_vm_desc = NUM_USER_VMS,
|
||||
|
||||
/* Virtual Machine descriptions */
|
||||
.vm_desc_array = {
|
||||
{
|
||||
.vm_attr_name = "vm_0",
|
||||
.vm_hw_num_cores = VM0_NUM_CPUS,
|
||||
.vm_hw_logical_core_ids = &VM0_CPUS[0],
|
||||
.vm_state_info_privilege = VM_PRIVILEGE_LEVEL_HIGH,
|
||||
.vm_created = false,
|
||||
},
|
||||
}
|
||||
struct vm_description vm0_desc = {
|
||||
.vm_attr_name = "vm_0",
|
||||
.vm_hw_num_cores = VM0_NUM_CPUS,
|
||||
.vm_hw_logical_core_ids = &VM0_CPUS[0],
|
||||
.vm_state_info_privilege = VM_PRIVILEGE_LEVEL_HIGH,
|
||||
.vm_created = false,
|
||||
};
|
||||
|
||||
const struct vm_description_array *get_vm_desc_base(void)
|
||||
{
|
||||
return &vm_desc;
|
||||
}
|
||||
|
|
|
@ -130,10 +130,7 @@ void vcpu_thread(struct vcpu *vcpu)
|
|||
|
||||
static bool is_vm0_bsp(int pcpu_id)
|
||||
{
|
||||
struct vm_description *vm_desc = get_vm_desc(0);
|
||||
|
||||
ASSERT(vm_desc, "get vm desc failed");
|
||||
return pcpu_id == vm_desc->vm_hw_logical_core_ids[0];
|
||||
return pcpu_id == vm0_desc.vm_hw_logical_core_ids[0];
|
||||
}
|
||||
|
||||
int hv_main(int cpu_id)
|
||||
|
|
|
@ -30,6 +30,7 @@
|
|||
|
||||
#ifndef VM_H_
|
||||
#define VM_H_
|
||||
#include <bsp_extern.h>
|
||||
|
||||
enum vm_privilege_level {
|
||||
VM_PRIVILEGE_LEVEL_HIGH = 0,
|
||||
|
@ -209,11 +210,6 @@ struct vm_description {
|
|||
bool sworld_enabled;
|
||||
};
|
||||
|
||||
struct vm_description_array {
|
||||
int num_vm_desc;
|
||||
struct vm_description vm_desc_array[];
|
||||
};
|
||||
|
||||
int shutdown_vm(struct vm *vm);
|
||||
int pause_vm(struct vm *vm);
|
||||
int start_vm(struct vm *vm);
|
||||
|
@ -222,7 +218,6 @@ int prepare_vm0(void);
|
|||
void vm_fixup(struct vm *vm);
|
||||
|
||||
struct vm *get_vm_from_vmid(int vm_id);
|
||||
struct vm_description *get_vm_desc(int idx);
|
||||
|
||||
extern struct list_head vm_list;
|
||||
extern spinlock_t vm_list_lock;
|
||||
|
|
Loading…
Reference in New Issue