OSDN Git Service

hax: Dynamic allocate vcpu state structure
authorWangBowen <bowen.wang@intel.com>
Sat, 9 May 2020 03:59:52 +0000 (11:59 +0800)
committerPaolo Bonzini <pbonzini@redhat.com>
Wed, 10 Jun 2020 16:09:59 +0000 (12:09 -0400)
commit34a0950605855870017bbe4d96110bf06a075982
tree441f41710c6e7402e321592109d982c5082ba571
parent6c1ddc36d8ddcb21e905dfdecfb9f2e4d4fd8acc
hax: Dynamic allocate vcpu state structure

Dynamic allocating vcpu state structure according to smp value to be
more precise and safe. Previously it will alloccate array of fixed size
HAX_MAX_VCPU.

This is achieved by using g_new0 to dynamic allocate the array. The
allocated size is obtained from smp.max_cpus in MachineState. Also, the
size is compared with HAX_MAX_VCPU when creating the vm. The reason for
choosing dynamic array over linked list is because the status is visited
by index all the time.

This will lead to QEMU checking whether the smp value is larger than the
HAX_MAX_VCPU when creating vm, if larger, the process will terminate,
otherwise it will allocate array of size smp to store the status.

V2: Check max_cpus before open vm. (Philippe)

Signed-off-by: WangBowen <bowen.wang@intel.com>
Signed-off-by: Colin Xu <colin.xu@intel.com>
Message-Id: <20200509035952.187615-1-colin.xu@intel.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
target/i386/hax-all.c
target/i386/hax-i386.h