diff options
author | Jiang, Yunhong <yunhong.jiang@intel.com> | 2012-03-23 13:47:38 +0800 |
---|---|---|
committer | Jiang, Yunhong <yunhong.jiang@intel.com> | 2012-04-07 22:36:08 +0800 |
commit | 8a539eaab40dc7a8047dbf97c081467029e6c518 (patch) | |
tree | f429032dc6e26dfd4af5ffb27a5ddbb1bffae45f /target-i386 | |
parent | f597bde4b03c8732013c673ca920599d1ee3160d (diff) | |
download | external_qemu-8a539eaab40dc7a8047dbf97c081467029e6c518.zip external_qemu-8a539eaab40dc7a8047dbf97c081467029e6c518.tar.gz external_qemu-8a539eaab40dc7a8047dbf97c081467029e6c518.tar.bz2 |
Add a HAXM interface for QEMU API version
Add a HAXM interface so that QEMU can communicate its API version to HAXM.
With this, HAXM can keep better backward compatibility, for example, masking
of the new features if qemu does not support new features.
Change-Id: I24c7c8d353653978f507739f6e53a9d389d06e43
Signed-off-by: Jiang, Yunhong <yunhong.jiang@intel.com>
Diffstat (limited to 'target-i386')
-rw-r--r-- | target-i386/hax-all.c | 4 | ||||
-rw-r--r-- | target-i386/hax-darwin.c | 17 | ||||
-rw-r--r-- | target-i386/hax-darwin.h | 8 | ||||
-rw-r--r-- | target-i386/hax-i386.h | 1 | ||||
-rw-r--r-- | target-i386/hax-interface.h | 9 | ||||
-rw-r--r-- | target-i386/hax-windows.c | 23 | ||||
-rw-r--r-- | target-i386/hax-windows.h | 2 |
7 files changed, 64 insertions, 0 deletions
diff --git a/target-i386/hax-all.c b/target-i386/hax-all.c index 0c3b589..2c13250 100644 --- a/target-i386/hax-all.c +++ b/target-i386/hax-all.c @@ -340,6 +340,7 @@ int hax_set_ramsize(uint64_t ramsize) int hax_init(int smp_cpus) { struct hax_state *hax = NULL; + struct hax_qemu_version qversion; int ret; hax_support = 0; @@ -378,6 +379,9 @@ int hax_init(int smp_cpus) goto error; } + qversion.cur_version = hax_cur_version; + qversion.least_version = hax_lest_version; + hax_notify_qemu_version(hax->vm->fd, &qversion); hax_support = 1; qemu_register_reset( hax_reset_vcpu_state, 0, NULL); diff --git a/target-i386/hax-darwin.c b/target-i386/hax-darwin.c index 1522d39..19a1c2d 100644 --- a/target-i386/hax-darwin.c +++ b/target-i386/hax-darwin.c @@ -181,6 +181,23 @@ hax_fd hax_host_open_vm(struct hax_state *hax, int vm_id) return fd; } +int hax_notify_qemu_version(hax_fd vm_fd, struct hax_qemu_version *qversion) +{ + int ret; + + if (hax_invalid_fd(vm_fd)) + return -EINVAL; + + ret = ioctl(vm_fd, HAX_VM_IOCTL_NOTIFY_QEMU_VERSION, qversion); + if (ret == -1) + { + dprint("Failed to notify qemu API version\n"); + return -errno; + } + + return 0; +} + /* * Simply assume that the size should be bigger than the hax_tunnel, * since the hax_tunnel can be extended later with backward diff --git a/target-i386/hax-darwin.h b/target-i386/hax-darwin.h index 2c6129b..95a9b31 100644 --- a/target-i386/hax-darwin.h +++ b/target-i386/hax-darwin.h @@ -59,6 +59,14 @@ static inline void hax_close_fd(hax_fd fd) * Setup translation between guest physical address and host physical address */ #define HAX_VM_IOCTL_SET_RAM _IOWR(0, 0x82, struct hax_set_ram_info) + +/* + * QEMU notify HAXM driver of the API version currently in use, so that + * HAXM driver will not present features that possibly not supported + * by QEMU + */ +#define HAX_VM_IOCTL_NOTIFY_QEMU_VERSION _IOW(0, 0x84, struct hax_qemu_version) + /* Run the guest in non-root mode */ #define HAX_VCPU_IOCTL_RUN _IO(0, 0xc0) /* Sync QEMU's guest MSR value to HAX driver */ diff --git a/target-i386/hax-i386.h b/target-i386/hax-i386.h index a5a7e1d..66869da 100644 --- a/target-i386/hax-i386.h +++ b/target-i386/hax-i386.h @@ -69,6 +69,7 @@ int hax_sync_msr(CPUState *env, struct hax_msr_data *msrs, int set); int hax_sync_fpu(CPUState *env, struct fx_layout *fl, int set); int hax_vm_destroy(struct hax_vm *vm); int hax_capability(struct hax_state *hax, struct hax_capabilityinfo *cap); +int hax_notify_qemu_version(hax_fd vm_fd, struct hax_qemu_version *qversion); /* Common host function */ int hax_host_create_vm(struct hax_state *hax, int *vm_id); diff --git a/target-i386/hax-interface.h b/target-i386/hax-interface.h index 569eeba..cb6d7c8 100644 --- a/target-i386/hax-interface.h +++ b/target-i386/hax-interface.h @@ -328,6 +328,15 @@ struct hax_module_version uint32_t cur_version; }; +/* This interface is support only after API version 2 */ +struct hax_qemu_version +{ + /* Current API version in QEMU*/ + uint32_t cur_version; + /* The least API version supported by QEMU */ + uint32_t least_version; +}; + /* See comments for HAX_VM_IOCTL_ALLOC_RAM ioctl */ struct hax_alloc_ram_info { diff --git a/target-i386/hax-windows.c b/target-i386/hax-windows.c index 0035d21..6c52388 100644 --- a/target-i386/hax-windows.c +++ b/target-i386/hax-windows.c @@ -279,6 +279,29 @@ hax_fd hax_host_open_vm(struct hax_state *hax, int vm_id) return hDeviceVM; } +int hax_notify_qemu_version(hax_fd vm_fd, struct hax_qemu_version *qversion) +{ + int ret; + DWORD dSize = 0; + + if (hax_invalid_fd(vm_fd)) + return -EINVAL; + + ret = DeviceIoControl(vm_fd, + HAX_VM_IOCTL_NOTIFY_QEMU_VERSION, + qversion, sizeof(struct hax_qemu_version), + NULL, 0, + &dSize, + (LPOVERLAPPED) NULL); + if (!ret) + { + dprint("Failed to notify qemu API version\n"); + return -1; + } + + return 0; +} + int hax_host_create_vcpu(hax_fd vm_fd, int vcpuid) { int ret; diff --git a/target-i386/hax-windows.h b/target-i386/hax-windows.h index 9e596d3..d0c821d 100644 --- a/target-i386/hax-windows.h +++ b/target-i386/hax-windows.h @@ -63,4 +63,6 @@ static inline int hax_invalid_fd(hax_fd fd) #define HAX_VCPU_SET_REGS CTL_CODE(HAX_DEVICE_TYPE, 0x90d, METHOD_BUFFERED, FILE_ANY_ACCESS) #define HAX_VCPU_GET_REGS CTL_CODE(HAX_DEVICE_TYPE, 0x90e, METHOD_BUFFERED, FILE_ANY_ACCESS) +#define HAX_VM_IOCTL_NOTIFY_QEMU_VERSION CTL_CODE(HAX_DEVICE_TYPE, 0x910, METHOD_BUFFERED, FILE_ANY_ACCESS) + #endif |