Devel
Threads by month
- ----- 2026 -----
- July
- June
- May
- April
- March
- February
- January
- ----- 2025 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2024 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2023 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2022 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2021 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2020 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2019 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2018 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2017 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2016 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2015 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2014 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2013 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2012 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2011 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2010 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2009 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2008 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2007 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2006 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2005 -----
- December
August 2023
- 32 participants
- 96 discussions
I had this problem and another user confirmed the same behavior on his machine:
http://pastie.caboo.se/65417
Haven't tried it with *2925.10* yet. Also, is there a way to get more verbose
info about what calls are causing the "configuration file syntax error" errors?
Thanks.
virt-install
How large would you like the disk () to be (in gigabytes)? 4
ERROR: Must provide a file, not a directory for the disk
What would you like to use as the disk (path)? /xen/images/x6.img
Would you like to enable graphics support? (yes or no) no
What is the install location?
http://mirror.anl.gov/pub/fedora-linux-core/test/6.93/Fedora/i386/os/
Starting install...
libvir: Xen Daemon error : GET operation failed:
libvir: error : configuration file syntax error: expecting a name
libvir: error : configuration file syntax error: expecting a name
libvir: error : configuration file syntax error: expecting a name
Retrieving Fedora... 276 kB 00:01
Retrieving vmlinuz... 100% |=========================| 2.1 MB 00:16
Retrieving initrd.img... 100% |=========================| 5.4 MB 00:28
libvir: Xen Daemon error : GET operation failed:
libvir: error : configuration file syntax error: expecting a name
libvir: error : configuration file syntax error: expecting a name
libvir: error : configuration file syntax error: expecting a name
Creating domain... 0 B 00:06
Linux version 2.6.20-2925.5.fc7xen (brewbuilder(a)ls20-bc1-14.build.redhat.com)
(gcc version 4.1.2 20070317 (Red Hat 4.1.2-5)) #1 SMP Thu Mar 22 13:51:38 EDT 2007
BIOS-provided physical RAM map:
sanitize start
sanitize bail 0
copy_e820_map() start: 0000000000000000 size: 0000000020800000 end:
0000000020800000 type: 1
Xen: 0000000000000000 - 0000000020800000 (usable)
0MB HIGHMEM available.
520MB LOWMEM available.
Using x86 segment limits to approximate NX protection
Zone PFN ranges:
DMA 0 -> 133120
Normal 133120 -> 133120
HighMem 133120 -> 133120
early_node_map[1] active PFN ranges
0: 0 -> 133120
ACPI in unprivileged domain disabled
Built 1 zonelists. Total pages: 132080
Kernel command line:
method=http://mirror.anl.gov/pub/fedora-linux-core/test/6.93/Fedora/i386/os/
Enabling fast FPU save and restore... done.
Enabling unmasked SIMD FPU exception support... done.
Initializing CPU#0
CPU 0 irqstacks, hard=c135f000 soft=c133f000
PID hash table entries: 4096 (order: 12, 16384 bytes)
Xen reported: 1694.994 MHz processor.
Console: colour dummy device 80x25
Lock dependency validator: Copyright (c) 2006 Red Hat, Inc., Ingo Molnar
... MAX_LOCKDEP_SUBCLASSES: 8
... MAX_LOCK_DEPTH: 30
... MAX_LOCKDEP_KEYS: 2048
... CLASSHASH_SIZE: 1024
... MAX_LOCKDEP_ENTRIES: 8192
... MAX_LOCKDEP_CHAINS: 16384
... CHAINHASH_SIZE: 8192
memory used by lock dependency info: 1064 kB
per task-struct memory footprint: 1200 bytes
Dentry cache hash table entries: 131072 (order: 7, 524288 bytes)
Inode-cache hash table entries: 65536 (order: 6, 262144 bytes)
Software IO TLB disabled
vmalloc area: e1000000-f4ffe000, maxmem 2d7fe000
Memory: 503936k/532480k available (2030k kernel code, 19948k reserved, 1079k
data, 180k init, 0k highmem)
virtual kernel memory layout:
fixmap : 0xf5315000 - 0xf57fe000 (5028 kB)
pkmap : 0xf5000000 - 0xf5200000 (2048 kB)
vmalloc : 0xe1000000 - 0xf4ffe000 ( 319 MB)
lowmem : 0xc0000000 - 0xe0800000 ( 520 MB)
.init : 0xc130e000 - 0xc133b000 ( 180 kB)
.data : 0xc11fb9d9 - 0xc1309714 (1079 kB)
.text : 0xc1000000 - 0xc11fb9d9 (2030 kB)
Checking if this processor honours the WP bit even in supervisor mode... Ok.
Calibrating delay using timer specific routine.. 4262.67 BogoMIPS (lpj=8525343)
Security Framework v1.0.0 initialized
SELinux: Initializing.
SELinux: Starting in permissive mode
selinux_register_security: Registering secondary module capability
Capability LSM initialized as secondary
Mount-cache hash table entries: 512
CPU: Trace cache: 12K uops, L1 D cache: 8K
CPU: L2 cache: 256K
Checking 'hlt' instruction... OK.
SMP alternatives: switching to UP code
Freeing SMP alternatives: 11k freed
Brought up 1 CPUs
Grant table initialized
NET: Registered protocol family 16
Brought up 1 CPUs
PCI: Fatal: No config space access function found
PCI: setting up Xen PCI frontend stub
Setting up standard PCI resources
ACPI: Interpreter disabled.
Linux Plug and Play Support v0.97 (c) Adam Belay
pnp: PnP ACPI: disabled
xen_mem: Initialising balloon driver.
usbcore: registered new interface driver usbfs
usbcore: registered new interface driver hub
usbcore: registered new device driver usb
PCI: System does not support PCI
PCI: System does not support PCI
NetLabel: Initializing
NetLabel: domain hash size = 128
NetLabel: protocols = UNLABELED CIPSOv4
NetLabel: unlabeled traffic allowed by default
NET: Registered protocol family 2
IP route cache hash table entries: 32768 (order: 5, 131072 bytes)
TCP established hash table entries: 131072 (order: 10, 4194304 bytes)
TCP bind hash table entries: 65536 (order: 9, 2097152 bytes)
TCP: Hash tables configured (established 131072 bind 65536)
TCP reno registered
checking if image is initramfs... it is
Freeing initrd memory: 7256k freed
IA-32 Microcode Update Driver: v1.14-xen <tigran(a)veritas.com>
audit: initializing netlink socket (disabled)
audit(1180379657.981:1): initialized
VFS: Disk quotas dquot_6.5.1
Dquot-cache hash table entries: 1024 (order 0, 4096 bytes)
SELinux: Registering netfilter hooks
io scheduler noop registered
io scheduler anticipatory registered
io scheduler deadline registered
io scheduler cfq registered (default)
pci_hotplug: PCI Hot Plug PCI Core version: 0.5
BUG: at kernel/fork.c:994 copy_process()
[<c1005d9a>] show_trace_log_lvl+0x1a/0x2f
[<c1006343>] show_trace+0x12/0x14
[<c10063be>] dump_stack+0x16/0x18
[<c101d044>] copy_process+0x195/0x1245
[<c101e144>] do_fork+0x50/0x117
[<c1003351>] kernel_thread+0x8e/0x96
[<c102c701>] __call_usermodehelper+0x2d/0x46
[<c102cd4f>] run_workqueue+0x89/0x145
[<c102d711>] worker_thread+0xd5/0x102
[<c102ff27>] kthread+0xb3/0xdc
[<c10058db>] kernel_thread_helper+0x7/0x10
=======================
rtc: IRQ 8 is not free.
Non-volatile memory driver v1.2
Linux agpgart interface v0.101 (c) Dave Jones
RAMDISK driver initialized: 16 RAM disks of 16384K size 4096 blocksize
input: Macintosh mouse button emulation as /class/input/input0
Xen virtual console successfully installed as xvc0
Event-channel device installed.
usbcore: registered new interface driver libusual
usbcore: registered new interface driver hiddev
usbcore: registered new interface driver usbhid
drivers/usb/input/hid-core.c: v2.6:USB HID core driver
PNP: No PS/2 controller found. Probing ports directly.
i8042.c: No controller found.
mice: PS/2 mouse device common for all mice
TCP bic registered
Initializing XFRM netlink socket
NET: Registered protocol family 1
NET: Registered protocol family 17
Using IPI No-Shortcut mode
XENBUS: Device with no driver: device/vbd/51712
XENBUS: Device with no driver: device/vif/0
Freeing unused kernel memory: 180k freed
Write protecting the kernel read-only data: 762k
^[Domain installation still in progress. You can reconnect
2
1
[libvirt] [PATCH] Fix python error reporting for some storage operations
by Cole Robinson 07 Mar '25
by Cole Robinson 07 Mar '25
07 Mar '25
In the python bindings, all vir* classes expect to be
passed a virConnect object when instantiated. Before
the storage stuff, these classes were only instantiated
in virConnect methods, so the generator is hardcoded to
pass 'self' as the connection instance to these classes.
Problem is there are some methods that return pool or vol
instances which aren't called from virConnect: you can
lookup a storage volume's associated pool, and can lookup
volumes from a pool. In these cases passing 'self' doesn't
give the vir* instance a connection, so when it comes time
to raise an exception crap hits the fan.
Rather than rework the generator to accomodate this edge
case, I just fixed the init functions for virStorage* to
pull the associated connection out of the passed value
if it's not a virConnect instance.
Thanks,
Cole
diff --git a/python/generator.py b/python/generator.py
index 01a17da..c706b19 100755
--- a/python/generator.py
+++ b/python/generator.py
@@ -962,8 +962,12 @@ def buildWrappers():
list = reference_keepers[classname]
for ref in list:
classes.write(" self.%s = None\n" % ref[1])
- if classname in [ "virDomain", "virNetwork", "virStoragePool", "virStorageVol" ]:
+ if classname in [ "virDomain", "virNetwork" ]:
classes.write(" self._conn = conn\n")
+ elif classname in [ "virStorageVol", "virStoragePool" ]:
+ classes.write(" self._conn = conn\n" + \
+ " if not isinstance(conn, virConnect):\n" + \
+ " self._conn = conn._conn\n")
classes.write(" if _obj != None:self._o = _obj;return\n")
classes.write(" self._o = None\n\n");
destruct=None
4
3
[libvirt PATCH 00/28] native support for nftables in virtual network driver
by Laine Stump 12 Jun '24
by Laine Stump 12 Jun '24
12 Jun '24
This patch series enables libvirt to use nftables rules rather than
iptables *when setting up virtual networks* (it does *not* add
nftables support to the nwfilter driver). It accomplishes this by
abstracting several iptables functions (from viriptables.[ch] called
by the virtual network driver into a rudimentary "virNetfilter API"
(in virnetfilter.[ch], having the virtual network driver call the
virNetFilter API rather than calling the existing iptables functions
directly, and then finally adding an equivalent virNftables backend
that can be used instead of iptables (selected manually via a
network.conf setting, or automatically if iptables isn't found on the
host).
A first look at the result may have you thinking that it's filled with
a lot of bad decisions. While I would agree with that in many cases, I
think that overall they are the "least bad" decisions, or at least
"bad within acceptable limits / no worse than something else", and
point out that it's been done in a way that minimizes (actually
eliminates) the need for immediate changes to nwfilter (the other
consumer of iptables, which *also* needs to be updated to use native
nftables), and makes it much easier to change our mind about the
details in the future.
When I first started on this (long, protracted, repeatedly interrupted
for extended periods - many of these patches are > a year old) task, I
considered doing an all-at-once complete replacement of iptables with
nftables, since all the Linux distros we support have had nftables for
several years, and I'm pretty sure nobody has it disabled (not even
sure if it's possible to disable nftables while still enabling
iptables, since they both use xtables in the kernel). But due to
libvirt's use of "-t mangle -j CHECKSUM --checksum-fill" (see commit
fd5b15ff all the way back in July 2010 for details) which has no
equivalent in nftables rules (and we don't *want* it to!!), and the
desire to be able to easily switch back to iptables in case of an
unforeseen regression, we decided that both iptables and nftables need
to be supported (for now), with the default (for now) remaining as
iptables.
Just allowing for dual backends complicated matters, since it means
that we have to have a config file, a setting, detection of which
backends are available, and of course some sort of concept of an
abstracted frontend that can use either backend based on the config
setting (and/or auto-detection). Combining that with the fact that it
would just be "too big" of a project to switch over nwfilter's
iptables usage at the same time means that we have to keep around a
lot of existing code for compatibility's sake rather than just wiping
it all away and starting over.
So, what I've ended up with is:
1) a network.conf file (didn't exist before) with a single setting
"firewall_backend". If unset, the network driver tries to use iptables
on the backend, and if that's missing, then tries to use nftables.
2) a new (internal-only, so transient!) virNetFilterXXX API that is
used by the network driver in place of the iptablesXXX API, and calls
either iptablesXXX or:
3) a virNftablesXXX API that exactly replicates the filtering rules of
the existing iptablesXXX API (except in the custom "libvirt" base
table rather than the system "filter" and "nat" tables). This means
that:
4) when the nftables backend is used, the rules added are *exactly the
same* (functionally speaking) as we currently add for iptables (except
they are in the "libvirt" table).
We had spent some time in IRC discussing different ways of using new
functionality available in nftables to make a more
efficient/performant implemention of the desired filtering, and there
are some really great possibilities that need to be explored, but in
the end there were too many details up in the air, and I decided that
it would be more "accomplishable" (coined a new word there!) to first
replicate existing behavior with nftables, but do it inside a
framework that makes it easy to modify the details in the future (in
particular making it painless to switch back and forth between builds
with differing filter models at runtime) - this way we'll be able to
separate the infrastructure work from the details of the rules (which
we can then more easily work on and experiment with). (This implies
that the main objective right now is "get rid of iptables
dependencies", not "make the filtering faster and more efficient").
Notable features of this patchset:
* allows switching between iptables/nftables backends without
rebooting or restarting networks/guests.
Because the commands required to remove a network's filter rules are
now saved in the network status XML, each time libvirtd (or
virtnetworkd) is restarted, it will execute exactly the commands
needed to remove the filter rules that had been added by the
previous libvirtd/virtnetworkd (rather than just making a guess, as
we've always done up until now), and then add new rules using the
current backend+binary's set of rules (while also saving the info
needed for future removal of these new rules back into the network's
status XML).
* firewall_backend can be explicitly set in (new)
/etc/libvirt/network.conf, but if it's not explicitly set, libvirt
will default to the iptables backend if the iptables binary is
found, and otherwise fall back to nftables as long as the nft
binary is found; otherwise the first attempt to start a network will
fail with an appropriate error.
Things that seem ugly / that I would like to clean up / that I think
are just fine as they are:
* virFirewall does *not* provide a backend-agnostic interface [this is fine]
* We need to maintain a backward-compatible API for virFirewall so
that we don't have to touch nwfilter code. Trying to make its API
backend-agnostic would require individually considering/changing
every nwfilter use of virFirewall.
* instead virFirewall objects are just a way to build a collection
of commands to execute to build a firewall, then execute them
while collecting info for and building a collection of commands
that will tear down that firewall in the future.
Do I want to "fix" this in the future by making virFirewall a higher
level interface that accepts tokens describing the type of rule to
add (rather than backend-specific arguments to a backend-specific
command)? No. I think I like the way virFirewall works (as
described in that previous bullet-point), instead I'm thinking that
it is just slightly mis-named - I've lately been thinking of it as a
"virNetFilterCmdList". Similarly, the virFirewallRules that it has a
list of aren't really "rules", they are better described as commands
or actions, so maybe they should be renamed to virNetfilterCmd or
virNetfilterAction. But that is just cosmetic, so I didn't want to
get into it in these patches (especially in case someone disagrees,
or has a better idea for naming).
* Speaking of renaming - I should probably rename all the
"iptablesXXX" functions to "virIptablesXXX" to be consistent with so
much of our other code. I lost the ambition to deal with it right
now though, so I'm leaving that for later cleanup (or I could do it
now if it really makes someone's day :-).
* I could have chosen a higher place in the callchain to make the
virNetfilter abstraction, e.g. at the level of
"networkAddXXXFirewallRules()" rather than at the lower level of
iptablesXXX(). That is actually probably what will happen in the
future (since it will be necessary in order for an nftables-based
firewall to be significantly different in structure from an
iptables-based firewall). But that's the beauty of an API being
private - we can freely add/remove things as needed. the important
thing is that we now have the basic structure there.
For now, the split is just above the existing iptablesXXX API
(util/viriptables.[ch], which seems like a "narrow" enough
place. Most iptablesXXX functions are written in terms of just 10
*other* iptablesXXX functions that add iptables-specific commands -
I've just moved those functions into virnetfilter.[ch]
(appropriately renamed), and changed them to call the 10
virNetfilterXXX functions that will in-turn call those 10
iptablesXXX (or equivalent virNftablesXXX) functions.
* Some people may dislike that the 10 virNetfilterXXX functions are
each written with a switch statement that has cases to directly call
each backend, rather than each backend driver having a table of
pointers to API functions, with the virNetfilter API function
calling backends[fwBackend]->XXX() (ie the pattern for so many
drivers in libvirt). But for just 2 backends, that really seemed
like overkill and unnecessary obfuscation.
* As implemented here, I am storing a "<fwRemoval>" element in the
network status XML - it contains a serialized virFirewall object
that directly contains the commands necessary to remove the
firewall. I could instead just store "<firewall>", which would
include all the commands that were used to *create* the firewall in
addition to the commands needed to remove the firewall. The way it's
done currently takes up less space; switching to storing the full
firewall *might* be more informative to somebody, but on the other
hand would make the network status XML *very* long. If anybody has
an opinion about this, now is the time to bring it up - do you think
it's worth having a separate list of all the commands that were used
to create a network's firewall (keeping in mind that there is no
public API to access it)? Or is it enough to just store what's
needed to remove the firewall?
* Several months ago Eric Garver posted patches for a pure firewalld
backend, and I requested that they not be pushed because I wanted
that to be integrated with my nftables backend support. Due to the
fact that the firewalld backend is almost entirely implemented by
putting the bridge into a new firewalld "zone", with no individual
rules added, that won't happen as just another backend driver file
in parallel to iptables and nftables; it will instead work by
checking firewall_backend at a higher level in the network driver,
thus avoiding the calls to virNetfilterXXX() entirely. I have
locally merged Eric's patches over the top of these patches, and
there are surprisingly few conflicts, but since his patches didn't
account for a user-settable config (but instead just always used the
firewalld backend if firewalld was active), some of the patches are
going to require a bit of rework, which I'll take care of after
getting these patches in.
Laine Stump (28):
util: add -w/--concurrent when applying the rule rather than when
building it
util: new virFirewallRuleGet*() APIs
util: determine ignoreErrors value when creating rule, not when
applying
util: rename iptables helpers that will become the frontend for
ip&nftables
util: move backend-agnostic virNetfilter*() functions to their own
file
util: make netfilter action a proper typedefed (virFirewall) enum
util: #define the names used for private packet filter chains
util: move/rename virFirewallApplyRuleDirect to
virIptablesApplyFirewallRule
util/network: reintroduce virFirewallBackend, but different
network: add (empty) network.conf file to distribution files
network: allow setting firewallBackend from network.conf
network: do not add DHCP checksum mangle rule unless using iptables
network: call backend agnostic function to init private filter chains
util: setup functions in virnetfilter which will call appropriate
backend
build: add nft to the list of binaries we attempt to locate
util: add nftables backend to virnetfilter API used by network driver
tests: test cases for nftables backend
util: new functions to support adding individual rollback rules
util: check for 0 args when applying iptables rule
util: implement rollback rule autosave for iptables backend
util: implement rollback rule autosave for nftables backend
network: turn on auto-rollback for the rules added for virtual
networks
util: new function virFirewallNewFromRollback()
util: new functions virFirewallParseXML() and virFirewallFormat()
conf: add a virFirewall object to virNetworkObj
network: use previously saved list of firewall rules when removing
network: save network status when firewall rules are reloaded
network: improve log message when reloading virtual network firewall
rules
libvirt.spec.in | 5 +
meson.build | 1 +
po/POTFILES | 2 +
src/conf/virnetworkobj.c | 40 +
src/conf/virnetworkobj.h | 11 +
src/libvirt_private.syms | 68 +-
src/network/bridge_driver.c | 40 +-
src/network/bridge_driver_conf.c | 44 +
src/network/bridge_driver_conf.h | 3 +
src/network/bridge_driver_linux.c | 241 +++--
src/network/bridge_driver_nop.c | 6 +-
src/network/bridge_driver_platform.h | 6 +-
src/network/libvirtd_network.aug | 39 +
src/network/meson.build | 11 +
src/network/network.conf | 24 +
src/network/test_libvirtd_network.aug.in | 5 +
src/nwfilter/nwfilter_ebiptables_driver.c | 16 +-
src/util/meson.build | 2 +
src/util/virebtables.c | 4 +-
src/util/virfirewall.c | 490 ++++++++--
src/util/virfirewall.h | 51 +-
src/util/viriptables.c | 762 ++++-----------
src/util/viriptables.h | 222 ++---
src/util/virnetfilter.c | 892 ++++++++++++++++++
src/util/virnetfilter.h | 159 ++++
src/util/virnftables.c | 698 ++++++++++++++
src/util/virnftables.h | 118 +++
.../{base.args => base.iptables} | 0
tests/networkxml2firewalldata/base.nftables | 256 +++++
...-linux.args => nat-default-linux.iptables} | 0
.../nat-default-linux.nftables | 248 +++++
...pv6-linux.args => nat-ipv6-linux.iptables} | 0
.../nat-ipv6-linux.nftables | 384 ++++++++
...rgs => nat-ipv6-masquerade-linux.iptables} | 0
.../nat-ipv6-masquerade-linux.nftables | 456 +++++++++
...linux.args => nat-many-ips-linux.iptables} | 0
.../nat-many-ips-linux.nftables | 472 +++++++++
...-linux.args => nat-no-dhcp-linux.iptables} | 0
.../nat-no-dhcp-linux.nftables | 384 ++++++++
...ftp-linux.args => nat-tftp-linux.iptables} | 0
.../nat-tftp-linux.nftables | 274 ++++++
...inux.args => route-default-linux.iptables} | 0
.../route-default-linux.nftables | 162 ++++
tests/networkxml2firewalltest.c | 56 +-
tests/virfirewalltest.c | 20 +-
45 files changed, 5718 insertions(+), 954 deletions(-)
create mode 100644 src/network/libvirtd_network.aug
create mode 100644 src/network/network.conf
create mode 100644 src/network/test_libvirtd_network.aug.in
create mode 100644 src/util/virnetfilter.c
create mode 100644 src/util/virnetfilter.h
create mode 100644 src/util/virnftables.c
create mode 100644 src/util/virnftables.h
rename tests/networkxml2firewalldata/{base.args => base.iptables} (100%)
create mode 100644 tests/networkxml2firewalldata/base.nftables
rename tests/networkxml2firewalldata/{nat-default-linux.args => nat-default-linux.iptables} (100%)
create mode 100644 tests/networkxml2firewalldata/nat-default-linux.nftables
rename tests/networkxml2firewalldata/{nat-ipv6-linux.args => nat-ipv6-linux.iptables} (100%)
create mode 100644 tests/networkxml2firewalldata/nat-ipv6-linux.nftables
rename tests/networkxml2firewalldata/{nat-ipv6-masquerade-linux.args => nat-ipv6-masquerade-linux.iptables} (100%)
create mode 100644 tests/networkxml2firewalldata/nat-ipv6-masquerade-linux.nftables
rename tests/networkxml2firewalldata/{nat-many-ips-linux.args => nat-many-ips-linux.iptables} (100%)
create mode 100644 tests/networkxml2firewalldata/nat-many-ips-linux.nftables
rename tests/networkxml2firewalldata/{nat-no-dhcp-linux.args => nat-no-dhcp-linux.iptables} (100%)
create mode 100644 tests/networkxml2firewalldata/nat-no-dhcp-linux.nftables
rename tests/networkxml2firewalldata/{nat-tftp-linux.args => nat-tftp-linux.iptables} (100%)
create mode 100644 tests/networkxml2firewalldata/nat-tftp-linux.nftables
rename tests/networkxml2firewalldata/{route-default-linux.args => route-default-linux.iptables} (100%)
create mode 100644 tests/networkxml2firewalldata/route-default-linux.nftables
--
2.39.2
7
78
This series something I was hacking on a little while back in an
attempt to make our RPC layer more maintainable. There are many
aspects I'm unhappy about with current code
* When serializing a message we have no clue how big
it will be, but xdrmem_create wants a fixed size,
so we have to keep trying to serialize in a loop
making it bigger each time
* We don't control memory allocation/free'ing directly
so we can't do a virSecureErase on fields inside the
RPC message struct that handle secrets.
* The XDR API is generally unpleasant to use as it is
outside our virNetMessage object. Ideally we would
be reading/writing directly from/to the virNetMessage
buffer with APIs on virNetMessage,instead of indirectly
via a XDR object.
* We want more from XDR than it actually gives us. Our
XDR protocol files have annotations to express what
we want our code generator todo, or for ACLs. The
relationship between the structs and the message
numbers is implicit. Essentially we've defined our
own language indirectly via comments, and then
parse this with regexes which is horrid.
* The code rpcgen creates is poor quality which we have
to post-process to fix bugs/problems. It also lacks
support for modern features like g_auto.
Anyway, in a fit of rage I looked at the XDR RFC and thought..
This language is trivial, why do we need to outsource to
rpcgen and libtirpc instead of dealing with it directly.
This small series moves in that direction. It creates an
XDR language lexer and parser, and then a code generator
which emits code that is (nearly) identical to what rpcgen
would emit. This is sufficient to eliminate rpcgen usage
and support g_auto. Since we're still using libtirpc
at this stage we can be confident we're still doing the
same thing on the wire. I've got some unit tests too
with the rpcgen generation to validate stuff.
The next step is to change the code generator so that
instead of generating code for libtirpc APIs, it will
instead directly speak virNetMessage APIs. That would
give us full control over our RPC stack guaranteed to
be platform portable instead of fighting slight differences
in RPC libraries (eg xdr_quad vs xdr_int64 madness).
I was going to wait until I had written such code before
sending this series, but I've got diverted onto other more
important tasks. So here at least is what I have so far.
After that foundation is done, we are in a place where
we can actually do more innovative things. For example
we can directly extend the XDR protocol language if we
like, turning our magic comments into properly parsable
constructs.
With this, we would be in a position to replace our
Perl RPC client/server dispatch code generators with
something that is more supportable in Python. The python
code would work with properly represented objects and
formal parsers and not regexes and anonymous complex
perl data structures.
Daniel P. Berrangé (16):
rpcgen: drop type-puning workarounds
build-aux: skip E203 and W503 flake8 checks
build-aux: introduce 'black' tool for python formatting
rpcgen: add an XDR protocol lexer
rpcgen: add an XDR protocol abstract syntax tree
rpcgen: add an XDR protocol parser
rpcgen: define a visitor API for XDR protocol specs
rpcgen: add a C code generator for XDR protocol specs
rpcgen: add test case for XDR serialization
rpcgen: define entrypoint for running new rpcgen impl
build: switch over to new rpc generator code
rpcgen: add g_auto function support
rpc: use g_auto for client RPC return parameters
admin: use g_auto for client RPC return parameters
remote: use g_auto for client RPC return parameters
rpc: add helpers for XDR type serialization
build-aux/Makefile.in | 1 +
build-aux/meson.build | 5 +
build-aux/syntax-check.mk | 42 +-
libvirt.spec.in | 2 +-
meson.build | 13 +-
scripts/meson.build | 2 +
scripts/rpcgen/main.py | 90 ++
scripts/rpcgen/meson.build | 16 +
scripts/rpcgen/rpcgen/ast.py | 270 ++++++
scripts/rpcgen/rpcgen/generator.py | 509 ++++++++++++
scripts/rpcgen/rpcgen/lexer.py | 213 +++++
scripts/rpcgen/rpcgen/meson.build | 7 +
scripts/rpcgen/rpcgen/parser.py | 497 +++++++++++
scripts/rpcgen/rpcgen/visitor.py | 156 ++++
scripts/rpcgen/tests/demo.c | 495 +++++++++++
scripts/rpcgen/tests/demo.h | 264 ++++++
scripts/rpcgen/tests/demo.x | 127 +++
scripts/rpcgen/tests/meson.build | 20 +
scripts/rpcgen/tests/simple.x | 35 +
scripts/rpcgen/tests/test_demo.c | 782 ++++++++++++++++++
scripts/rpcgen/tests/test_demo_enum.bin | Bin 0 -> 4 bytes
.../tests/test_demo_enum_fixed_array.bin | Bin 0 -> 52 bytes
.../tests/test_demo_enum_pointer_null.bin | Bin 0 -> 4 bytes
.../tests/test_demo_enum_pointer_set.bin | Bin 0 -> 8 bytes
.../rpcgen/tests/test_demo_enum_scalar.bin | Bin 0 -> 4 bytes
.../test_demo_enum_variable_array_empty.bin | Bin 0 -> 4 bytes
.../test_demo_enum_variable_array_set.bin | Bin 0 -> 16 bytes
.../tests/test_demo_int_fixed_array.bin | Bin 0 -> 12 bytes
.../tests/test_demo_int_pointer_null.bin | Bin 0 -> 4 bytes
.../tests/test_demo_int_pointer_set.bin | Bin 0 -> 8 bytes
scripts/rpcgen/tests/test_demo_int_scalar.bin | Bin 0 -> 4 bytes
.../test_demo_int_variable_array_empty.bin | Bin 0 -> 4 bytes
.../test_demo_int_variable_array_set.bin | Bin 0 -> 16 bytes
.../tests/test_demo_opaque_fixed_array.bin | Bin 0 -> 12 bytes
.../test_demo_opaque_variable_array_empty.bin | Bin 0 -> 4 bytes
.../test_demo_opaque_variable_array_set.bin | Bin 0 -> 8 bytes
.../test_demo_string_variable_array_empty.bin | Bin 0 -> 4 bytes
.../test_demo_string_variable_array_set.bin | Bin 0 -> 12 bytes
scripts/rpcgen/tests/test_demo_struct.bin | Bin 0 -> 8 bytes
.../tests/test_demo_struct_fixed_array.bin | Bin 0 -> 136 bytes
.../tests/test_demo_struct_pointer_null.bin | Bin 0 -> 4 bytes
.../tests/test_demo_struct_pointer_set.bin | Bin 0 -> 12 bytes
.../rpcgen/tests/test_demo_struct_scalar.bin | 1 +
.../test_demo_struct_variable_array_empty.bin | Bin 0 -> 4 bytes
.../test_demo_struct_variable_array_set.bin | Bin 0 -> 28 bytes
.../tests/test_demo_test_struct_all_types.bin | Bin 0 -> 1752 bytes
scripts/rpcgen/tests/test_demo_union_case.bin | Bin 0 -> 8 bytes
.../rpcgen/tests/test_demo_union_default.bin | Bin 0 -> 8 bytes
.../tests/test_demo_union_fixed_array.bin | Bin 0 -> 168 bytes
.../tests/test_demo_union_no_default_case.bin | Bin 0 -> 8 bytes
.../tests/test_demo_union_pointer_null.bin | Bin 0 -> 4 bytes
.../tests/test_demo_union_pointer_set.bin | Bin 0 -> 12 bytes
.../rpcgen/tests/test_demo_union_scalar.bin | Bin 0 -> 8 bytes
.../test_demo_union_variable_array_empty.bin | Bin 0 -> 4 bytes
.../test_demo_union_variable_array_set.bin | Bin 0 -> 28 bytes
.../test_demo_union_void_default_case.bin | Bin 0 -> 8 bytes
.../test_demo_union_void_default_default.bin | 1 +
scripts/rpcgen/tests/test_generator.py | 60 ++
scripts/rpcgen/tests/test_lexer.py | 116 +++
scripts/rpcgen/tests/test_parser.py | 91 ++
src/admin/admin_remote.c | 50 +-
src/admin/meson.build | 8 +-
src/locking/meson.build | 8 +-
src/logging/meson.build | 8 +-
src/lxc/meson.build | 12 +-
src/remote/meson.build | 8 +-
src/remote/remote_driver.c | 754 ++++++-----------
src/rpc/gendispatch.pl | 60 +-
src/rpc/genprotocol.pl | 144 ----
src/rpc/meson.build | 9 +-
src/rpc/virnetmessage.c | 704 ++++++++++++++++
src/rpc/virnetmessage.h | 88 ++
72 files changed, 4897 insertions(+), 771 deletions(-)
create mode 100755 scripts/rpcgen/main.py
create mode 100644 scripts/rpcgen/meson.build
create mode 100644 scripts/rpcgen/rpcgen/ast.py
create mode 100644 scripts/rpcgen/rpcgen/generator.py
create mode 100644 scripts/rpcgen/rpcgen/lexer.py
create mode 100644 scripts/rpcgen/rpcgen/meson.build
create mode 100644 scripts/rpcgen/rpcgen/parser.py
create mode 100644 scripts/rpcgen/rpcgen/visitor.py
create mode 100644 scripts/rpcgen/tests/demo.c
create mode 100644 scripts/rpcgen/tests/demo.h
create mode 100644 scripts/rpcgen/tests/demo.x
create mode 100644 scripts/rpcgen/tests/meson.build
create mode 100644 scripts/rpcgen/tests/simple.x
create mode 100644 scripts/rpcgen/tests/test_demo.c
create mode 100644 scripts/rpcgen/tests/test_demo_enum.bin
create mode 100644 scripts/rpcgen/tests/test_demo_enum_fixed_array.bin
create mode 100644 scripts/rpcgen/tests/test_demo_enum_pointer_null.bin
create mode 100644 scripts/rpcgen/tests/test_demo_enum_pointer_set.bin
create mode 100644 scripts/rpcgen/tests/test_demo_enum_scalar.bin
create mode 100644 scripts/rpcgen/tests/test_demo_enum_variable_array_empty.bin
create mode 100644 scripts/rpcgen/tests/test_demo_enum_variable_array_set.bin
create mode 100644 scripts/rpcgen/tests/test_demo_int_fixed_array.bin
create mode 100644 scripts/rpcgen/tests/test_demo_int_pointer_null.bin
create mode 100644 scripts/rpcgen/tests/test_demo_int_pointer_set.bin
create mode 100644 scripts/rpcgen/tests/test_demo_int_scalar.bin
create mode 100644 scripts/rpcgen/tests/test_demo_int_variable_array_empty.bin
create mode 100644 scripts/rpcgen/tests/test_demo_int_variable_array_set.bin
create mode 100644 scripts/rpcgen/tests/test_demo_opaque_fixed_array.bin
create mode 100644 scripts/rpcgen/tests/test_demo_opaque_variable_array_empty.bin
create mode 100644 scripts/rpcgen/tests/test_demo_opaque_variable_array_set.bin
create mode 100644 scripts/rpcgen/tests/test_demo_string_variable_array_empty.bin
create mode 100644 scripts/rpcgen/tests/test_demo_string_variable_array_set.bin
create mode 100644 scripts/rpcgen/tests/test_demo_struct.bin
create mode 100644 scripts/rpcgen/tests/test_demo_struct_fixed_array.bin
create mode 100644 scripts/rpcgen/tests/test_demo_struct_pointer_null.bin
create mode 100644 scripts/rpcgen/tests/test_demo_struct_pointer_set.bin
create mode 100644 scripts/rpcgen/tests/test_demo_struct_scalar.bin
create mode 100644 scripts/rpcgen/tests/test_demo_struct_variable_array_empty.bin
create mode 100644 scripts/rpcgen/tests/test_demo_struct_variable_array_set.bin
create mode 100644 scripts/rpcgen/tests/test_demo_test_struct_all_types.bin
create mode 100644 scripts/rpcgen/tests/test_demo_union_case.bin
create mode 100644 scripts/rpcgen/tests/test_demo_union_default.bin
create mode 100644 scripts/rpcgen/tests/test_demo_union_fixed_array.bin
create mode 100644 scripts/rpcgen/tests/test_demo_union_no_default_case.bin
create mode 100644 scripts/rpcgen/tests/test_demo_union_pointer_null.bin
create mode 100644 scripts/rpcgen/tests/test_demo_union_pointer_set.bin
create mode 100644 scripts/rpcgen/tests/test_demo_union_scalar.bin
create mode 100644 scripts/rpcgen/tests/test_demo_union_variable_array_empty.bin
create mode 100644 scripts/rpcgen/tests/test_demo_union_variable_array_set.bin
create mode 100644 scripts/rpcgen/tests/test_demo_union_void_default_case.bin
create mode 100644 scripts/rpcgen/tests/test_demo_union_void_default_default.bin
create mode 100644 scripts/rpcgen/tests/test_generator.py
create mode 100644 scripts/rpcgen/tests/test_lexer.py
create mode 100644 scripts/rpcgen/tests/test_parser.py
delete mode 100755 src/rpc/genprotocol.pl
--
2.39.1
3
27
Re: [libvirt] [Qemu-devel] Qemu migration with vhost-user-blk on top of local storage
by Stefan Hajnoczi 27 Oct '23
by Stefan Hajnoczi 27 Oct '23
27 Oct '23
On Wed, Jan 09, 2019 at 06:23:42PM +0800, wuzhouhui wrote:
> Hi everyone,
>
> I'm working qemu with vhost target (e.g. spdk), and I attempt to migrate VM with
> 2 local storages. One local storage is a regular file, e.g. /tmp/c74.qcow2, and
> the other is a malloc bdev that spdk created. This malloc bdev will exported to
> VM via vhost-user-blk. When I execute following command:
>
> virsh migrate --live --persistent --unsafe --undefinesource --copy-storage-all \
> --p2p --auto-converge --verbose --desturi qemu+tcp://<uri>/system vm0
>
> The libvirt reports:
>
> qemu-2.12.1: error: internal error: unable to execute QEMU command \
> 'nbd-server-add': Cannot find device=drive-virtio-disk1 nor \
> node_name=drive-virtio-disk1
Please post your libvirt domain XML.
> Does it means that qemu with spdk on top of local storage don't support migration?
>
> QEMU: 2.12.1
> SPDK: 18.10
vhost-user-blk bypasses the QEMU block layer, so NBD storage migration
at the QEMU level will not work for the vhost-user-blk disk.
Stefan
4
4
[libvirt] [PATCH v3] openvswitch: Add new port VLAN mode "dot1q-tunnel"
by luzhipengï¼ uniudc.com 27 Oct '23
by luzhipengï¼ uniudc.com 27 Oct '23
27 Oct '23
From: ZhiPeng Lu <luzhipeng(a)uniudc.com>
Signed-off-by: ZhiPeng Lu <luzhipeng(a)uniudc.com>
---
v1->v2:
1. Fix "make syntax-check" failure
v2->v3:
1. remove other_config when updating vlan
docs/formatnetwork.html.in | 17 +++++++++--------
docs/schemas/networkcommon.rng | 1 +
src/conf/netdev_vlan_conf.c | 2 +-
src/util/virnetdevopenvswitch.c | 7 +++++++
src/util/virnetdevvlan.h | 1 +
5 files changed, 19 insertions(+), 9 deletions(-)
diff --git a/docs/formatnetwork.html.in b/docs/formatnetwork.html.in
index 363a72b..3c1ae62 100644
--- a/docs/formatnetwork.html.in
+++ b/docs/formatnetwork.html.in
@@ -688,16 +688,17 @@
</p>
<p>
For network connections using Open vSwitch it is also possible
- to configure 'native-tagged' and 'native-untagged' VLAN modes
+ to configure 'native-tagged' and 'native-untagged' and 'dot1q-tunnel'
+ VLAN modes.
<span class="since">Since 1.1.0.</span> This is done with the
- optional <code>nativeMode</code> attribute on
- the <code><tag></code> subelement: <code>nativeMode</code>
- may be set to 'tagged' or 'untagged'. The <code>id</code>
- attribute of the <code><tag></code> subelement
- containing <code>nativeMode</code> sets which VLAN is considered
- to be the "native" VLAN for this interface, and
+ optional <code>nativeMode</code> attribute on the
+ <code><tag></code> subelement: <code>nativeMode</code>
+ may be set to 'tagged' or 'untagged' or 'dot1q-tunnel'.
+ The <code>id</code> attribute of the <code><tag></code>
+ subelement containing <code>nativeMode</code> sets which VLAN is
+ considered to be the "native" VLAN for this interface, and
the <code>nativeMode</code> attribute determines whether or not
- traffic for that VLAN will be tagged.
+ traffic for that VLAN will be tagged or QinQ.
</p>
<p>
<code><vlan></code> elements can also be specified in
diff --git a/docs/schemas/networkcommon.rng b/docs/schemas/networkcommon.rng
index 2699555..11c48ff 100644
--- a/docs/schemas/networkcommon.rng
+++ b/docs/schemas/networkcommon.rng
@@ -223,6 +223,7 @@
<choice>
<value>tagged</value>
<value>untagged</value>
+ <value>dot1q-tunnel</value>
</choice>
</attribute>
</optional>
diff --git a/src/conf/netdev_vlan_conf.c b/src/conf/netdev_vlan_conf.c
index dff49c6..79710d9 100644
--- a/src/conf/netdev_vlan_conf.c
+++ b/src/conf/netdev_vlan_conf.c
@@ -29,7 +29,7 @@
#define VIR_FROM_THIS VIR_FROM_NONE
VIR_ENUM_IMPL(virNativeVlanMode, VIR_NATIVE_VLAN_MODE_LAST,
- "default", "tagged", "untagged")
+ "default", "tagged", "untagged", "dot1q-tunnel")
int
virNetDevVlanParse(xmlNodePtr node, xmlXPathContextPtr ctxt, virNetDevVlanPtr def)
diff --git a/src/util/virnetdevopenvswitch.c b/src/util/virnetdevopenvswitch.c
index 8fe06fd..9fec30b 100644
--- a/src/util/virnetdevopenvswitch.c
+++ b/src/util/virnetdevopenvswitch.c
@@ -91,6 +91,11 @@ virNetDevOpenvswitchConstructVlans(virCommandPtr cmd, virNetDevVlanPtr virtVlan)
virCommandAddArg(cmd, "vlan_mode=native-untagged");
virCommandAddArgFormat(cmd, "tag=%d", virtVlan->nativeTag);
break;
+ case VIR_NATIVE_VLAN_MODE_DOT1Q_TUNNEL:
+ virCommandAddArg(cmd, "vlan_mode=dot1q-tunnel");
+ virCommandAddArg(cmd, "other_config:qinq-ethtype=802.1q");
+ virCommandAddArgFormat(cmd, "tag=%d", virtVlan->nativeTag);
+ break;
case VIR_NATIVE_VLAN_MODE_DEFAULT:
default:
break;
@@ -504,6 +509,8 @@ int virNetDevOpenvswitchUpdateVlan(const char *ifname,
"--", "--if-exists", "clear", "Port", ifname, "tag",
"--", "--if-exists", "clear", "Port", ifname, "trunk",
"--", "--if-exists", "clear", "Port", ifname, "vlan_mode",
+ "--", "--if-exists", "remove", "Port", ifname, "other_config",
+ "qinq-ethtype", NULL,
"--", "--if-exists", "set", "Port", ifname, NULL);
if (virNetDevOpenvswitchConstructVlans(cmd, virtVlan) < 0)
diff --git a/src/util/virnetdevvlan.h b/src/util/virnetdevvlan.h
index be85f59..0667f9d 100644
--- a/src/util/virnetdevvlan.h
+++ b/src/util/virnetdevvlan.h
@@ -29,6 +29,7 @@ typedef enum {
VIR_NATIVE_VLAN_MODE_DEFAULT = 0,
VIR_NATIVE_VLAN_MODE_TAGGED,
VIR_NATIVE_VLAN_MODE_UNTAGGED,
+ VIR_NATIVE_VLAN_MODE_DOT1Q_TUNNEL,
VIR_NATIVE_VLAN_MODE_LAST
} virNativeVlanMode;
--
1.8.3.1
3
2
Seems a backport miss. An extra member is passed to struct
virLXCBasicMountInfo.
Signed-off-by: Yang hongyang <hongyang.yang(a)easystack.cn>
---
src/lxc/lxc_container.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/src/lxc/lxc_container.c b/src/lxc/lxc_container.c
index 28dabec..1c65fa9 100644
--- a/src/lxc/lxc_container.c
+++ b/src/lxc/lxc_container.c
@@ -760,7 +760,7 @@ typedef struct {
static const virLXCBasicMountInfo lxcBasicMounts[] = {
{ "proc", "/proc", "proc", MS_NOSUID|MS_NOEXEC|MS_NODEV, false, false },
- { "/proc/sys", "/proc/sys", NULL, MS_BIND|MS_NOSUID|MS_NOEXEC|MS_NODEV|MS_RDONLY, false, false, false },
+ { "/proc/sys", "/proc/sys", NULL, MS_BIND|MS_NOSUID|MS_NOEXEC|MS_NODEV|MS_RDONLY, false, false },
{ "sysfs", "/sys", "sysfs", MS_NOSUID|MS_NOEXEC|MS_NODEV|MS_RDONLY, false, false },
{ "securityfs", "/sys/kernel/security", "securityfs", MS_NOSUID|MS_NOEXEC|MS_NODEV|MS_RDONLY, true, true },
#if WITH_SELINUX
--
1.7.1
3
2
This adds more information about the different macvtap device modes.
Regards,
Stefan
3
2
27 Oct '23
Disclaimer: I am neither an SR-IOV nor a vhost-net expert, but I've CC'd
people that are who can throw tomatoes at me for getting bits wrong :-)
I wanted to start a discussion about supporting vhost-net in libvirt.
vhost-net has not yet been merged into qemu but I expect it will be soon
so it's a good time to start this discussion.
There are two modes worth supporting for vhost-net in libvirt. The
first mode is where vhost-net backs to a tun/tap device. This is
behaves in very much the same way that -net tap behaves in qemu today.
Basically, the difference is that the virtio backend is in the kernel
instead of in qemu so there should be some performance improvement.
Current, libvirt invokes qemu with -net tap,fd=X where X is an already
open fd to a tun/tap device. I suspect that after we merge vhost-net,
libvirt could support vhost-net in this mode by just doing -net
vhost,fd=X. I think the only real question for libvirt is whether to
provide a user visible switch to use vhost or to just always use vhost
when it's available and it makes sense. Personally, I think the later
makes sense.
The more interesting invocation of vhost-net though is one where the
vhost-net device backs directly to a physical network card. In this
mode, vhost should get considerably better performance than the current
implementation. I don't know the syntax yet, but I think it's
reasonable to assume that it will look something like -net
tap,dev=eth0. The effect will be that eth0 is dedicated to the guest.
On most modern systems, there is a small number of network devices so
this model is not all that useful except when dealing with SR-IOV
adapters. In that case, each physical device can be exposed as many
virtual devices (VFs). There are a few restrictions here though. The
biggest is that currently, you can only change the number of VFs by
reloading a kernel module so it's really a parameter that must be set at
startup time.
I think there are a few ways libvirt could support vhost-net in this
second mode. The simplest would be to introduce a new tag similar to
<source network='br0'>. In fact, if you probed the device type for the
network parameter, you could probably do something like <source
network='eth0'> and have it Just Work.
Another model would be to have libvirt see an SR-IOV adapter as a
network pool whereas it handled all of the VF management. Considering
how inflexible SR-IOV is today, I'm not sure whether this is the best model.
Has anyone put any more thought into this problem or how this should be
modeled in libvirt? Michael, could you share your current thinking for
-net syntax?
--
Regards,
Anthony Liguori
8
26
This is v11 of the multifd save prototype, which focuses on saving
to a single file instead of requiring multiple separate files for
multifd channels.
This series demonstrates a way to save and restore from a single file
by using interleaved channels of a size equal to the transfer buffer
size (1MB), and relying on UNIX holes to avoid wasting physical disk
space due to channels of different size.
KNOWN ISSUES:
a) still applies only to save/restore (no managed save etc)
b) this is not not done in QEMU, where it could be possible to teach
QEMU to migrate directly to a file or block device in a
block-aligned way by altering the migration stream code and the
state migration code of all devices.
changes from v10:
* virfile: add new API virFileDiskCopyChannel, which extends the
existing virFileDiskCopy to work with parallel channels in the file.
* drop use of virthread API, use GLIB for threads.
* pass only a single FD to the multifd-helper, which will then open
additional FDs as required for the multithreaded I/O.
* simplify virQEMUSaveFd API, separating the initialization from the
addition of extra channels.
* adapt all documentation to mention a single file instead of multiple.
* remove the "Lim" versions of virFileDirectRead and Write, they are
not needed.
---
changes from v9:
* exposed virFileDirectAlign
* separated the >= 2 QEMU_SAVE_VERSION change in own patch
* reworked the write code to add the alignment padding to the
data_len, making the on disk format compatible when loaded
from an older libvirt.
* reworked the read code to use direct I/O APIs only for actual
direct I/O file descriptors, so as to make old images work
with newer libvirt.
---
changes from v8:
* rebased on master
* reordered patches to add more upstreamable content at the start
* split introduction of virQEMUSaveFd, so the first part is multifd-free
* new virQEMUSaveDataRead as a mirror of virQEMUSaveDataWrite
* introduced virFileDirect API, using it in virFileDisk operations and
for virQEMUSaveRead and virQEMUSaveWrite
---
changes from v7:
* [ base params API and iohelper refactoring upstreamed ]
* extended the QEMU save image format more, to record the nr
of multifd channels on save. Made the data header struct packed.
* removed --parallel-connections from the restore command, as now
it is useless due to QEMU save image format extension.
* separate out patches to expose migration_params APIs to saveimage,
including qemuMigrationParamsSetString, SetCap, SetInt.
* fixed bugs in the ImageOpen patch (missing saveFd init), removed
some whitespace, and fixed some convoluted code paths for return
value -3.
---
changes from v6:
* improved error path handling, with error messages and especially
cancellation of qemu process on error during restore.
* split patches more and reordered them to keep general refactoring
at the beginning before the --parallel stuff is introduced.
* improved multifd compression support, including adding an enum
and extending the QEMU save image format to record the compression
used on save, and pick it up automatically on restore.
---
changes from v4:
* runIO renamed to virFileDiskCopy and rethought arguments
* renamed new APIs from ...ParametersFlags to ...Params
* introduce the new virDomainSaveParams and virDomainRestoreParams
without any additional parameters, so they can be upstreamed first.
* solved the issue in the gendispatch.pl script generating code that
was missing the conn parameter.
---
changes from v3:
* reordered series to have all helper-related change at the start
* solved all reported issues from ninja test, including documentation
* fixed most broken migration capabilities code (still imperfect likely)
* added G_GNUC_UNUSED as needed
* after multifd restore, added what I think were the missing operations:
qemuProcessRefreshState(),
qemuProcessStartCPUs() - most importantly,
virDomainObjSave()
The domain now starts running after restore without further encouragement
* removed the sleep(10) from the multifd-helper
---
changes from v2:
* added ability to restore the VM from disk using multifd
* fixed the multifd-helper to work in both directions,
assuming the need to listen for save, and connect for restore.
* fixed a large number of bugs, and probably introduced some :-)
---
Claudio Fontana (33):
virfile: introduce virFileDirect APIs
virfile: use virFileDirect API in runIOCopy
qemu: saveimage: rework image read/write to be O_DIRECT friendly
qemu: saveimage: assume future formats will also support compression
virfile: virFileDiskCopy: prepare for O_DIRECT files without wrapper
qemu: saveimage: introduce virQEMUSaveFd
qemu: saveimage: convert qemuSaveImageCreate to use virQEMUSaveFd
qemu: saveimage: convert qemuSaveImageOpen to use virQEMUSaveFd
tools: prepare doSave to use parameters
tools: prepare cmdRestore to use parameters
libvirt: add new VIR_DOMAIN_SAVE_PARALLEL flag and parameter
qemu: add stub support for VIR_DOMAIN_SAVE_PARALLEL in save
qemu: add stub support for VIR_DOMAIN_SAVE_PARALLEL in restore
virfile: add new API virFileDiskCopyChannel
multifd-helper: new helper for parallel save/restore
qemu: saveimage: update virQEMUSaveFd struct for parallel save
qemu: saveimage: wire up saveimage code with the multifd helper
qemu: capabilities: add multifd to the probed migration capabilities
qemu: saveimage: add multifd related fields to save format
qemu: migration_params: add APIs to set Int and Cap
qemu: migration: implement qemuMigrationSrcToFilesMultiFd for save
qemu: add parameter to qemuMigrationDstRun to skip waiting
qemu: implement qemuSaveImageLoadMultiFd for restore
tools: add parallel parameter to virsh save command
tools: add parallel parameter to virsh restore command
qemu: add migration parameter multifd-compression
libvirt: add new VIR_DOMAIN_SAVE_PARAM_PARALLEL_COMPRESSION
qemu: saveimage: add parallel compression argument to ImageCreate
qemu: saveimage: add stub support for multifd compression parameter
qemu: migration: expose qemuMigrationParamsSetString
qemu: saveimage: implement multifd-compression in parallel save
qemu: saveimage: restore compressed parallel images
tools: add parallel-compression parameter to virsh save command
docs/manpages/virsh.rst | 26 +-
include/libvirt/libvirt-domain.h | 24 +
po/POTFILES | 1 +
src/libvirt_private.syms | 6 +
src/qemu/qemu_capabilities.c | 4 +
src/qemu/qemu_capabilities.h | 2 +
src/qemu/qemu_driver.c | 146 ++--
src/qemu/qemu_migration.c | 160 ++--
src/qemu/qemu_migration.h | 16 +-
src/qemu/qemu_migration_params.c | 71 +-
src/qemu/qemu_migration_params.h | 15 +
src/qemu/qemu_process.c | 3 +-
src/qemu/qemu_process.h | 5 +-
src/qemu/qemu_saveimage.c | 703 +++++++++++++-----
src/qemu/qemu_saveimage.h | 69 +-
src/qemu/qemu_snapshot.c | 6 +-
src/util/iohelper.c | 3 +
src/util/meson.build | 16 +
src/util/multifd-helper.c | 359 +++++++++
src/util/virfile.c | 391 +++++++---
src/util/virfile.h | 11 +
.../caps_4.0.0.aarch64.xml | 1 +
.../qemucapabilitiesdata/caps_4.0.0.ppc64.xml | 1 +
.../caps_4.0.0.riscv32.xml | 1 +
.../caps_4.0.0.riscv64.xml | 1 +
.../qemucapabilitiesdata/caps_4.0.0.s390x.xml | 1 +
.../caps_4.0.0.x86_64.xml | 1 +
.../caps_4.1.0.x86_64.xml | 1 +
.../caps_4.2.0.aarch64.xml | 1 +
.../qemucapabilitiesdata/caps_4.2.0.ppc64.xml | 1 +
.../qemucapabilitiesdata/caps_4.2.0.s390x.xml | 1 +
.../caps_4.2.0.x86_64.xml | 1 +
.../caps_5.0.0.aarch64.xml | 2 +
.../qemucapabilitiesdata/caps_5.0.0.ppc64.xml | 2 +
.../caps_5.0.0.riscv64.xml | 2 +
.../caps_5.0.0.x86_64.xml | 2 +
.../qemucapabilitiesdata/caps_5.1.0.sparc.xml | 2 +
.../caps_5.1.0.x86_64.xml | 2 +
.../caps_5.2.0.aarch64.xml | 2 +
.../qemucapabilitiesdata/caps_5.2.0.ppc64.xml | 2 +
.../caps_5.2.0.riscv64.xml | 2 +
.../qemucapabilitiesdata/caps_5.2.0.s390x.xml | 2 +
.../caps_5.2.0.x86_64.xml | 2 +
.../caps_6.0.0.aarch64.xml | 2 +
.../qemucapabilitiesdata/caps_6.0.0.s390x.xml | 2 +
.../caps_6.0.0.x86_64.xml | 2 +
.../caps_6.1.0.x86_64.xml | 2 +
.../caps_6.2.0.aarch64.xml | 2 +
.../qemucapabilitiesdata/caps_6.2.0.ppc64.xml | 2 +
.../caps_6.2.0.x86_64.xml | 2 +
.../caps_7.0.0.aarch64.xml | 2 +
.../qemucapabilitiesdata/caps_7.0.0.ppc64.xml | 2 +
.../caps_7.0.0.x86_64.xml | 2 +
.../caps_7.1.0.x86_64.xml | 2 +
tools/virsh-domain.c | 101 ++-
55 files changed, 1748 insertions(+), 445 deletions(-)
create mode 100644 src/util/multifd-helper.c
--
2.26.2
2
40
[libvirt PATCH v8 00/37] Use nbdkit for http/ftp/ssh network drives in libvirt
by Jonathon Jongsma 22 Sep '23
by Jonathon Jongsma 22 Sep '23
22 Sep '23
This is the eighth version of this patch series. See
https://bugzilla.redhat.com/show_bug.cgi?id=2016527 for more information.
Note that testing this requires selinux policy changes which are not fully
done, but there is a new policy in development that has allowed me to run with
selinux in enforcing mode for the common cases. See
https://bugzilla.redhat.com/show_bug.cgi?id=2182505 for more information. The
following scenarios should work now with selinux enabled using the selinux
policy from that bug:
- http/https disks
- ssh disks with password authentication
- ssh disks with passwordless keyfile
The one major thing that doesn't work and is difficult to get working with
selinux enabled is the ssh-agent. This is because there doesn't seem to be any
selinux policy for ssh-agent, so by default the ssh-agent socket is labeled
unconfined_t. We cannot allow access from the libvirt/qemu to unconfined_t
because that would open up access to just about anything on the host. So
additional work will likely be necessary for ssh-agent/libvirt interaction in
the future. Fortunately ssh-agent is something that never was really supported
with the old qemu block driver either, so I think we could potentially merge
this patchset either without the ssh-agent patches or with a note that
ssh-agent won't work with selinux enabled.
Changes in v8:
- Hopefully addressed all of Peter's issues, in addition to:
- updated documentation to say 9.8.0, since 9.7.0 is currently in freeze
- used WITH_NBDKIT instead of WITH_DECL_SYS_PIDFD_OPEN to make the code a bit
more concise and understandable
- enabled ci by adding libnbd to the dependencies, which uncovered a couple
additional minor issues with those platforms that don't support the
pidfd_open syscall
- don't run nbdkit tests when WITH_NBDKIT is not defined
- avoid warnings with unused function arguments
- note that the ubuntu containers are currently failing due to a
LeakSanitizer error, but I haven't reproduced it locally and can't figure
out how to get better information from the leak sanitizer. Pointers
appreciated: https://gitlab.com/jjongsma/libvirt/-/jobs/4991631193
- One change of note is a new patch "qemu: improve error handling when
restarting nbdkit". In order to provide better error reporting to the
user and avoid VIR_WARN as suggested by Peter, some functions now return an
error and this error is propagated up to qemuProcessReconnect(). This could
potentially result in running domains being killed upon a libvirt restart,
but only if they were in a state where they were was not a running nbdkit
backend or libvirt couldn't monitor the process nbdkit.
Jonathon Jongsma (37):
schema: allow 'ssh' as a protocol for network disks
qemu: Add functions for determining nbdkit availability
qemu: expand nbdkit capabilities
util: Allow virFileCache data to be any GObject
qemu: implement basic virFileCache for nbdkit caps
qemu: implement persistent file cache for nbdkit caps
qemu: use file cache for nbdkit caps
qemu: Add qemuNbdkitProcess
qemu: query nbdkit module dir from binary
qemu: add functions to start and stop nbdkit
Generalize qemuDomainLogContextNew()
qemu: Extract qemuDomainLogContext into a new file
qemu: move qemuProcessReadLog() to qemuLogContext
qemu: log error output from nbdkit
tests: add ability to test various nbdkit capabilities
qemu: split qemuDomainSecretStorageSourcePrepare
qemu: include nbdkit state in private xml
util: secure erase virCommand send buffers
qemu: pass sensitive data to nbdkit via pipe
qemu: use nbdkit to serve network disks if available
util: make virCommandSetSendBuffer testable
tests: add tests for nbdkit invocation
qemu: add test for authenticating a https network disk
qemu: Add Taint for nbdkit restart failure
qemu: Monitor nbdkit process for exit
qemu: improve error handling when restarting nbdkit
qemu: try to connect to nbdkit early to detect errors
schema: add password configuration for ssh disk
qemu: implement password auth for ssh disks with nbdkit
schema: add configuration for host verification of ssh disks
qemu: implement knownHosts for ssh disks with nbdkit
schema: add keyfile configuration for ssh disks
qemu: implement keyfile auth for ssh disks with nbdkit
schema: add ssh-agent configuration for ssh disks
qemu: implement ssh-agent auth for ssh disks with nbdkit
rpm: update spec file for for nbdkit support
ci: add libnbd to build
build-aux/syntax-check.mk | 2 +-
ci/buildenv/almalinux-8.sh | 1 +
ci/buildenv/centos-stream-8.sh | 1 +
ci/buildenv/centos-stream-9.sh | 1 +
ci/buildenv/debian-12-cross-aarch64.sh | 1 +
ci/buildenv/debian-12-cross-armv6l.sh | 1 +
ci/buildenv/debian-12-cross-armv7l.sh | 1 +
ci/buildenv/debian-12-cross-i686.sh | 1 +
ci/buildenv/debian-12-cross-mips64el.sh | 1 +
ci/buildenv/debian-12-cross-mipsel.sh | 1 +
ci/buildenv/debian-12-cross-ppc64le.sh | 1 +
ci/buildenv/debian-12-cross-s390x.sh | 1 +
ci/buildenv/debian-12.sh | 1 +
ci/buildenv/debian-sid-cross-aarch64.sh | 1 +
ci/buildenv/debian-sid-cross-armv6l.sh | 1 +
ci/buildenv/debian-sid-cross-armv7l.sh | 1 +
ci/buildenv/debian-sid-cross-i686.sh | 1 +
ci/buildenv/debian-sid-cross-mips64el.sh | 1 +
ci/buildenv/debian-sid-cross-mipsel.sh | 1 +
ci/buildenv/debian-sid-cross-ppc64le.sh | 1 +
ci/buildenv/debian-sid-cross-s390x.sh | 1 +
ci/buildenv/debian-sid.sh | 1 +
ci/buildenv/fedora-37.sh | 1 +
ci/buildenv/fedora-38-cross-mingw32.sh | 1 +
ci/buildenv/fedora-38-cross-mingw64.sh | 1 +
ci/buildenv/fedora-38.sh | 1 +
ci/buildenv/fedora-rawhide-cross-mingw32.sh | 1 +
ci/buildenv/fedora-rawhide-cross-mingw64.sh | 1 +
ci/buildenv/fedora-rawhide.sh | 1 +
ci/buildenv/opensuse-leap-15.sh | 1 +
ci/buildenv/opensuse-tumbleweed.sh | 1 +
ci/buildenv/ubuntu-2204.sh | 1 +
ci/containers/almalinux-8.Dockerfile | 1 +
ci/containers/centos-stream-8.Dockerfile | 1 +
ci/containers/centos-stream-9.Dockerfile | 1 +
.../debian-12-cross-aarch64.Dockerfile | 1 +
.../debian-12-cross-armv6l.Dockerfile | 1 +
.../debian-12-cross-armv7l.Dockerfile | 1 +
ci/containers/debian-12-cross-i686.Dockerfile | 1 +
.../debian-12-cross-mips64el.Dockerfile | 1 +
.../debian-12-cross-mipsel.Dockerfile | 1 +
.../debian-12-cross-ppc64le.Dockerfile | 1 +
.../debian-12-cross-s390x.Dockerfile | 1 +
ci/containers/debian-12.Dockerfile | 1 +
.../debian-sid-cross-aarch64.Dockerfile | 1 +
.../debian-sid-cross-armv6l.Dockerfile | 1 +
.../debian-sid-cross-armv7l.Dockerfile | 1 +
.../debian-sid-cross-i686.Dockerfile | 1 +
.../debian-sid-cross-mips64el.Dockerfile | 1 +
.../debian-sid-cross-mipsel.Dockerfile | 1 +
.../debian-sid-cross-ppc64le.Dockerfile | 1 +
.../debian-sid-cross-s390x.Dockerfile | 1 +
ci/containers/debian-sid.Dockerfile | 1 +
ci/containers/fedora-37.Dockerfile | 1 +
.../fedora-38-cross-mingw32.Dockerfile | 1 +
.../fedora-38-cross-mingw64.Dockerfile | 1 +
ci/containers/fedora-38.Dockerfile | 1 +
.../fedora-rawhide-cross-mingw32.Dockerfile | 1 +
.../fedora-rawhide-cross-mingw64.Dockerfile | 1 +
ci/containers/fedora-rawhide.Dockerfile | 1 +
ci/containers/opensuse-leap-15.Dockerfile | 1 +
ci/containers/opensuse-tumbleweed.Dockerfile | 1 +
ci/containers/ubuntu-2204.Dockerfile | 1 +
ci/lcitool/projects/libvirt.yml | 1 +
docs/formatdomain.rst | 45 +-
libvirt.spec.in | 8 +
meson.build | 18 +
meson_options.txt | 1 +
po/POTFILES | 2 +
src/conf/domain_conf.c | 38 +
src/conf/domain_conf.h | 1 +
src/conf/schemas/domaincommon.rng | 55 +
src/conf/storage_source_conf.c | 6 +
src/conf/storage_source_conf.h | 6 +-
src/libvirt_private.syms | 1 +
src/qemu/meson.build | 3 +
src/qemu/qemu_block.c | 162 ++-
src/qemu/qemu_conf.c | 22 +
src/qemu/qemu_conf.h | 6 +
src/qemu/qemu_domain.c | 436 +++---
src/qemu/qemu_domain.h | 31 +-
src/qemu/qemu_driver.c | 20 +
src/qemu/qemu_extdevice.c | 62 +
src/qemu/qemu_hotplug.c | 7 +
src/qemu/qemu_logcontext.c | 329 +++++
src/qemu/qemu_logcontext.h | 41 +
src/qemu/qemu_nbdkit.c | 1291 +++++++++++++++++
src/qemu/qemu_nbdkit.h | 119 ++
src/qemu/qemu_nbdkitpriv.h | 31 +
src/qemu/qemu_process.c | 126 +-
src/qemu/qemu_process.h | 3 +
src/util/vircommand.c | 19 +-
src/util/vircommand.h | 8 +
src/util/vircommandpriv.h | 4 +
src/util/virfilecache.c | 14 +-
src/util/virfilecache.h | 2 +-
tests/meson.build | 5 +
tests/qemublocktest.c | 2 +-
...w2-invalid.json => network-ssh-qcow2.json} | 0
...cow2-invalid.xml => network-ssh-qcow2.xml} | 0
.../disk-cdrom-network.args.disk0 | 6 +
.../disk-cdrom-network.args.disk1 | 8 +
.../disk-cdrom-network.args.disk1.pipe.778 | 1 +
.../disk-cdrom-network.args.disk2 | 8 +
.../disk-cdrom-network.args.disk2.pipe.780 | 1 +
.../disk-network-http.args.disk0 | 6 +
.../disk-network-http.args.disk1 | 5 +
.../disk-network-http.args.disk2 | 6 +
.../disk-network-http.args.disk2.pipe.778 | 1 +
.../disk-network-http.args.disk3 | 7 +
.../disk-network-http.args.disk3.pipe.780 | 1 +
...work-source-curl-nbdkit-backing.args.disk0 | 7 +
...ce-curl-nbdkit-backing.args.disk0.pipe.778 | 1 +
.../disk-network-source-curl.args.disk0 | 7 +
...sk-network-source-curl.args.disk0.pipe.778 | 1 +
.../disk-network-source-curl.args.disk1 | 9 +
...sk-network-source-curl.args.disk1.pipe.780 | 1 +
...sk-network-source-curl.args.disk1.pipe.782 | 1 +
.../disk-network-source-curl.args.disk2 | 7 +
...sk-network-source-curl.args.disk2.pipe.782 | 1 +
...sk-network-source-curl.args.disk2.pipe.784 | 1 +
.../disk-network-source-curl.args.disk3 | 6 +
.../disk-network-source-curl.args.disk4 | 6 +
.../disk-network-ssh-key.args.disk0 | 9 +
.../disk-network-ssh-key.args.disk1 | 9 +
.../disk-network-ssh-password.args.disk0 | 9 +
...k-network-ssh-password.args.disk0.pipe.778 | 1 +
.../disk-network-ssh.args.disk0 | 7 +
.../disk-network-ssh.args.disk1 | 8 +
.../disk-network-ssh.args.disk1.pipe.778 | 1 +
.../disk-network-ssh.args.disk2 | 9 +
tests/qemunbdkittest.c | 310 ++++
tests/qemustatusxml2xmldata/modern-in.xml | 4 +
...sk-cdrom-network-nbdkit.x86_64-latest.args | 42 +
.../disk-cdrom-network-nbdkit.xml | 1 +
...isk-network-http-nbdkit.x86_64-latest.args | 44 +
.../disk-network-http-nbdkit.xml | 1 +
...rce-curl-nbdkit-backing.x86_64-latest.args | 37 +
...isk-network-source-curl-nbdkit-backing.xml | 45 +
...work-source-curl-nbdkit.x86_64-latest.args | 49 +
.../disk-network-source-curl-nbdkit.xml | 1 +
...isk-network-source-curl.x86_64-latest.args | 53 +
.../disk-network-source-curl.xml | 74 +
.../qemuxml2argvdata/disk-network-ssh-key.xml | 44 +
...disk-network-ssh-nbdkit.x86_64-latest.args | 35 +
.../disk-network-ssh-nbdkit.xml | 1 +
...sk-network-ssh-password.x86_64-latest.args | 35 +
.../disk-network-ssh-password.xml | 35 +
.../disk-network-ssh.x86_64-latest.args | 35 +
tests/qemuxml2argvdata/disk-network-ssh.xml | 32 +
tests/qemuxml2argvtest.c | 23 +
tests/testutilsqemu.c | 26 +
tests/testutilsqemu.h | 4 +
153 files changed, 3599 insertions(+), 472 deletions(-)
create mode 100644 src/qemu/qemu_logcontext.c
create mode 100644 src/qemu/qemu_logcontext.h
create mode 100644 src/qemu/qemu_nbdkit.c
create mode 100644 src/qemu/qemu_nbdkit.h
create mode 100644 src/qemu/qemu_nbdkitpriv.h
rename tests/qemublocktestdata/imagecreate/{network-ssh-qcow2-invalid.json => network-ssh-qcow2.json} (100%)
rename tests/qemublocktestdata/imagecreate/{network-ssh-qcow2-invalid.xml => network-ssh-qcow2.xml} (100%)
create mode 100644 tests/qemunbdkitdata/disk-cdrom-network.args.disk0
create mode 100644 tests/qemunbdkitdata/disk-cdrom-network.args.disk1
create mode 100644 tests/qemunbdkitdata/disk-cdrom-network.args.disk1.pipe.778
create mode 100644 tests/qemunbdkitdata/disk-cdrom-network.args.disk2
create mode 100644 tests/qemunbdkitdata/disk-cdrom-network.args.disk2.pipe.780
create mode 100644 tests/qemunbdkitdata/disk-network-http.args.disk0
create mode 100644 tests/qemunbdkitdata/disk-network-http.args.disk1
create mode 100644 tests/qemunbdkitdata/disk-network-http.args.disk2
create mode 100644 tests/qemunbdkitdata/disk-network-http.args.disk2.pipe.778
create mode 100644 tests/qemunbdkitdata/disk-network-http.args.disk3
create mode 100644 tests/qemunbdkitdata/disk-network-http.args.disk3.pipe.780
create mode 100644 tests/qemunbdkitdata/disk-network-source-curl-nbdkit-backing.args.disk0
create mode 100644 tests/qemunbdkitdata/disk-network-source-curl-nbdkit-backing.args.disk0.pipe.778
create mode 100644 tests/qemunbdkitdata/disk-network-source-curl.args.disk0
create mode 100644 tests/qemunbdkitdata/disk-network-source-curl.args.disk0.pipe.778
create mode 100644 tests/qemunbdkitdata/disk-network-source-curl.args.disk1
create mode 100644 tests/qemunbdkitdata/disk-network-source-curl.args.disk1.pipe.780
create mode 100644 tests/qemunbdkitdata/disk-network-source-curl.args.disk1.pipe.782
create mode 100644 tests/qemunbdkitdata/disk-network-source-curl.args.disk2
create mode 100644 tests/qemunbdkitdata/disk-network-source-curl.args.disk2.pipe.782
create mode 100644 tests/qemunbdkitdata/disk-network-source-curl.args.disk2.pipe.784
create mode 100644 tests/qemunbdkitdata/disk-network-source-curl.args.disk3
create mode 100644 tests/qemunbdkitdata/disk-network-source-curl.args.disk4
create mode 100644 tests/qemunbdkitdata/disk-network-ssh-key.args.disk0
create mode 100644 tests/qemunbdkitdata/disk-network-ssh-key.args.disk1
create mode 100644 tests/qemunbdkitdata/disk-network-ssh-password.args.disk0
create mode 100644 tests/qemunbdkitdata/disk-network-ssh-password.args.disk0.pipe.778
create mode 100644 tests/qemunbdkitdata/disk-network-ssh.args.disk0
create mode 100644 tests/qemunbdkitdata/disk-network-ssh.args.disk1
create mode 100644 tests/qemunbdkitdata/disk-network-ssh.args.disk1.pipe.778
create mode 100644 tests/qemunbdkitdata/disk-network-ssh.args.disk2
create mode 100644 tests/qemunbdkittest.c
create mode 100644 tests/qemuxml2argvdata/disk-cdrom-network-nbdkit.x86_64-latest.args
create mode 120000 tests/qemuxml2argvdata/disk-cdrom-network-nbdkit.xml
create mode 100644 tests/qemuxml2argvdata/disk-network-http-nbdkit.x86_64-latest.args
create mode 120000 tests/qemuxml2argvdata/disk-network-http-nbdkit.xml
create mode 100644 tests/qemuxml2argvdata/disk-network-source-curl-nbdkit-backing.x86_64-latest.args
create mode 100644 tests/qemuxml2argvdata/disk-network-source-curl-nbdkit-backing.xml
create mode 100644 tests/qemuxml2argvdata/disk-network-source-curl-nbdkit.x86_64-latest.args
create mode 120000 tests/qemuxml2argvdata/disk-network-source-curl-nbdkit.xml
create mode 100644 tests/qemuxml2argvdata/disk-network-source-curl.x86_64-latest.args
create mode 100644 tests/qemuxml2argvdata/disk-network-source-curl.xml
create mode 100644 tests/qemuxml2argvdata/disk-network-ssh-key.xml
create mode 100644 tests/qemuxml2argvdata/disk-network-ssh-nbdkit.x86_64-latest.args
create mode 120000 tests/qemuxml2argvdata/disk-network-ssh-nbdkit.xml
create mode 100644 tests/qemuxml2argvdata/disk-network-ssh-password.x86_64-latest.args
create mode 100644 tests/qemuxml2argvdata/disk-network-ssh-password.xml
create mode 100644 tests/qemuxml2argvdata/disk-network-ssh.x86_64-latest.args
create mode 100644 tests/qemuxml2argvdata/disk-network-ssh.xml
--
2.41.0
3
48
I wanted to deal with https://bugzilla.redhat.com/2043498 and I got a
suggesstion that removing deprecated features could actually make it
easier to propagate the error. In the end (last patch) it turns out the
error is still just reported with error_fatal, so it probably is not
really needed, but I really wanted to dig into QEMU more and learn some
of the internals for quite some time now. So I used the opportunity.
The one-liner ended up being an 18 patch series which was, for someone
who has just one commit in QEMU codebase, a pretty challenging task.
Although I tried my best to do things properly, I am not sure whether I
handled everything correctly, hence the RFC.
Any comments are very much appreciated. Thanks and have a nice day ;)
Martin Kletzander (18):
hw/audio: Remove -soundhw support
hw/input/tsc210x: Extract common init code into new function
hw/audio: Simplify hda audio init
hw/audio/lm4549: Add errp error reporting to init function
tests/qtest: Specify audiodev= and -audiodev
ui/vnc: Require audiodev=
Introduce machine's default-audiodev property
audio: Add easy dummy audio initialiser
hw/display/xlnx_dp.c: Add audiodev property
hw/input/tsc210x.c: Support machine-default audiodev with fallback
hw/arm: Support machine-default audiodev with fallback
hw/ppc: Support machine-default audiodev with fallback
audio: Make AUD_register_card fallible and require audiodev=
audio: Require AudioState in AUD_add_capture
audio: Be more strict during audio backend initialisation
audio: Remove legacy audio environment variables and options
audio: Remove unused can_be_default
audio/spiceaudio: Fail initialisation when not using spice
audio/alsaaudio.c | 1 -
audio/audio.c | 204 +++----
audio/audio.h | 5 +-
audio/audio_int.h | 1 -
audio/audio_legacy.c | 555 ------------------
audio/coreaudio.m | 1 -
audio/dbusaudio.c | 1 -
audio/dsoundaudio.c | 1 -
audio/jackaudio.c | 1 -
audio/meson.build | 1 -
audio/noaudio.c | 1 -
audio/ossaudio.c | 1 -
audio/paaudio.c | 1 -
audio/sdlaudio.c | 1 -
audio/spiceaudio.c | 3 +-
audio/wavaudio.c | 1 -
docs/about/deprecated.rst | 24 -
docs/about/removed-features.rst | 27 +
docs/qdev-device-use.txt | 21 +-
docs/replay.txt | 2 +-
hw/arm/integratorcp.c | 8 +-
hw/arm/musicpal.c | 8 +-
hw/arm/omap2.c | 11 +-
hw/arm/realview.c | 3 +
hw/arm/spitz.c | 10 +-
hw/arm/versatilepb.c | 3 +
hw/arm/vexpress.c | 3 +
hw/arm/xlnx-zcu102.c | 4 +
hw/arm/z2.c | 12 +-
hw/audio/ac97.c | 9 +-
hw/audio/adlib.c | 9 +-
hw/audio/cs4231a.c | 8 +-
hw/audio/es1370.c | 8 +-
hw/audio/gus.c | 6 +-
hw/audio/hda-codec.c | 37 +-
hw/audio/intel-hda.c | 25 +-
hw/audio/intel-hda.h | 2 +-
hw/audio/lm4549.c | 7 +-
hw/audio/lm4549.h | 3 +-
hw/audio/meson.build | 1 -
hw/audio/pcspk.c | 15 +-
hw/audio/pl041.c | 2 +-
hw/audio/sb16.c | 9 +-
hw/audio/soundhw.c | 177 ------
hw/audio/wm8750.c | 5 +-
hw/core/machine.c | 23 +
hw/display/xlnx_dp.c | 12 +-
hw/input/tsc210x.c | 79 ++-
hw/ppc/prep.c | 4 +
hw/usb/dev-audio.c | 5 +-
include/hw/audio/soundhw.h | 15 -
include/hw/boards.h | 1 +
qemu-options.hx | 37 --
.../codeconverter/test_regexps.py | 1 -
softmmu/qdev-monitor.c | 2 -
softmmu/vl.c | 10 -
tests/qtest/ac97-test.c | 3 +-
tests/qtest/es1370-test.c | 3 +-
tests/qtest/fuzz/generic_fuzz_configs.h | 6 +-
tests/qtest/intel-hda-test.c | 15 +-
ui/vnc.c | 15 +-
61 files changed, 329 insertions(+), 1140 deletions(-)
delete mode 100644 audio/audio_legacy.c
delete mode 100644 hw/audio/soundhw.c
delete mode 100644 include/hw/audio/soundhw.h
--
2.35.1
5
43
see https://bugzilla.redhat.com/show_bug.cgi?id=1900770.
Jonathon Jongsma (5):
conf: add ability to configure a vdpa block disk device
qemu: add virtio-blk-vhost-vdpa capability
qemu: make vdpa connect function more generic
qemu: consider vdpa block devices for memlock limits
qemu: Implement support for vDPA block devices
docs/formatdomain.rst | 19 ++++++++-
src/ch/ch_monitor.c | 1 +
src/conf/domain_conf.c | 7 ++++
src/conf/schemas/domaincommon.rng | 13 +++++++
src/conf/storage_source_conf.c | 6 ++-
src/conf/storage_source_conf.h | 1 +
src/libxl/xen_xl.c | 1 +
src/qemu/qemu_block.c | 20 ++++++++++
src/qemu/qemu_capabilities.c | 2 +
src/qemu/qemu_capabilities.h | 1 +
src/qemu/qemu_command.c | 24 +++++++++++-
src/qemu/qemu_command.h | 1 +
src/qemu/qemu_domain.c | 37 +++++++++++++++++-
src/qemu/qemu_interface.c | 23 -----------
src/qemu/qemu_interface.h | 2 -
src/qemu/qemu_migration.c | 2 +
src/qemu/qemu_snapshot.c | 4 ++
src/qemu/qemu_validate.c | 45 +++++++++++++++++++---
src/storage_file/storage_source.c | 1 +
tests/qemuhotplugmock.c | 4 +-
tests/qemuxml2argvdata/disk-vhostvdpa.args | 35 +++++++++++++++++
tests/qemuxml2argvdata/disk-vhostvdpa.xml | 21 ++++++++++
tests/qemuxml2argvmock.c | 2 +-
tests/qemuxml2argvtest.c | 2 +
24 files changed, 235 insertions(+), 39 deletions(-)
create mode 100644 tests/qemuxml2argvdata/disk-vhostvdpa.args
create mode 100644 tests/qemuxml2argvdata/disk-vhostvdpa.xml
--
2.40.1
3
22
Error : virHostCPUGetKVMMaxVCPUs:1228 : KVM is not supported on this platform: Function not implemented.
by Mario Marietto 07 Sep '23
by Mario Marietto 07 Sep '23
07 Sep '23
Hello.
I'm running Debian bookworm on my ARM Chromebook,model "xe303c12" and
I've recompiled the kernel (5.4) to enable KVM,so now my system sounds like
this :
$ lsb_release -a
No LSB modules are available.
Distributor ID: Debian
Description: Debian GNU/Linux 12 (bookworm)
Release: 12
Codename: bookworm
$ uname -a
Linux chromarietto 5.4.244-stb-cbe
#8 SMP PREEMPT Sat Aug 19 22:19:32 UTC 2023 armv7l GNU/Linux
$ uname -r
5.4.244-stb-cbe
$ kvm-ok
INFO: /dev/kvm exists
KVM acceleration can be used
$ qemu-system-arm --version
QEMU emulator version 5.1.0 (v5.1.0-dirty)
Copyright (c) 2003-2020 Fabrice Bellard and the QEMU Project developers
$ python3 --version
Python 3.11.2
I have installed libvirt 9.7.0,qemu 5.1 and virt-manager from source
code with the final goal to be able to connect qemu,kvm and libvirt
together to virtualize FreeBSD 13.2 for arm 32 bit.
Some useful informations about my platform :
root@chromarietto:/home/marietto/Desktop# virt-host-validate
QEMU: Checking if device /dev/kvm exists : PASS
QEMU: Checking if device /dev/kvm is accessible : PASS
QEMU: Checking if device /dev/vhost-net exists : PASS
QEMU: Checking if device /dev/net/tun exists : PASS
QEMU: Checking for cgroup 'cpu' controller support : PASS
QEMU: Checking for cgroup 'cpuacct' controller support : PASS
QEMU: Checking for cgroup 'cpuset' controller support : PASS
QEMU: Checking for cgroup 'memory' controller support : PASS
QEMU: Checking for cgroup 'devices' controller support : PASS
QEMU: Checking for cgroup 'blkio' controller support : PASS
QEMU: Checking for device assignment IOMMU support
: WARN
(No ACPI IORT table found, IOMMU not supported by this hardware platform)
QEMU: Checking for secure guest support
: WARN
(Unknown if this platform has Secure Guest support)
LXC: Checking for Linux >= 2.6.26 : PASS
LXC: Checking for namespace ipc : PASS
LXC: Checking for namespace mnt : PASS
LXC: Checking for namespace pid : PASS
LXC: Checking for namespace uts : PASS
LXC: Checking for namespace net : PASS
LXC: Checking for namespace user : PASS
LXC: Checking for cgroup 'cpu' controller support : PASS
LXC: Checking for cgroup 'cpuacct' controller support : PASS
LXC: Checking for cgroup 'cpuset' controller support : PASS
LXC: Checking for cgroup 'memory' controller support : PASS
LXC: Checking for cgroup 'devices' controller support : PASS
LXC: Checking for cgroup 'freezer' controller support : FAIL
(Enable 'freezer' in kernel Kconfig file or mount/enable cgroup
controller in your system)
LXC: Checking for cgroup 'blkio' controller support : PASS
LXC: Checking if device /sys/fs/fuse/connections exists : PASS
# lsmod | grep kvm
no errors (I have embedded the options needed to enable KVM inside the kernel)
# virsh --connect qemu:///system capabilities | grep baselabel
<baselabel type='kvm'>+1002:+1002</baselabel>
<baselabel type='qemu'>+1002:+1002</baselabel>
The error that I'm not able to fix is the following one :
root@chromarietto:~# virsh domcapabilities --machine virt
--emulatorbin /usr/local/bin/qemu-system-arm
2023-08-29 10:17:59.110+0000: 1763: error : virHostCPUGetKVMMaxVCPUs:1228 :
KVM is not supported on this platform: Function not implemented ;
error: failed to get emulator capabilities
error: KVM is not supported on this platform: Function not implemented
and this is the log that I've got when I ran libvirtd with the debug
option enabled
root@chromarietto:~# libvirtd --debug
[Tue, 29 Aug 2023 10:10:11 virt-manager 2141] DEBUG (createvm:494)
UEFI found, setting it as default.
[Tue, 29 Aug 2023 10:10:11 virt-manager 2141] DEBUG (createvm:728)
Guest type set to os_type=hvm, arch=armv7l, dom_type=kvm
[Tue, 29 Aug 2023 10:10:11 virt-manager 2141] DEBUG (guest:546) Prefer
EFI => True
2023-08-29 10:10:12.972+0000: 1765: error :
virHostCPUGetKVMMaxVCPUs:1228 : KVM is not supported on this platform:
Function not implemented
[Tue, 29 Aug 2023 10:10:12 virt-manager 2141] DEBUG
(domcapabilities:250) Error fetching domcapabilities XML
Traceback (most recent call last):
File "/usr/local/share/virt-manager/virtinst/domcapabilities.py",
line 245, in build_from_params
xml = conn.getDomainCapabilities(emulator, arch,
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3/dist-packages/libvirt.py", line 4612, in
getDomainCapabilities
raise libvirtError('virConnectGetDomainCapabilities() failed')
libvirt.libvirtError: KVM is not supported on this platform: Function
not implemented
*2023-08-29 10:10:14.157+0000: 1762: error : virHostCPUGetKVMMaxVCPUs:1228
: KVM is not supported on this platform: Function not implemented*
[Tue, 29 Aug 2023 10:10:14 virt-manager 2141] DEBUG
(domcapabilities:250) Error fetching domcapabilities XML
Traceback (most recent call last):
File "/usr/local/share/virt-manager/virtinst/domcapabilities.py",
line 245, in build_from_params
xml = conn.getDomainCapabilities(emulator, arch,
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3/dist-packages/libvirt.py", line 4612, in
getDomainCapabilities
raise libvirtError('virConnectGetDomainCapabilities() failed')
libvirt.libvirtError: KVM is not supported on this platform: Function
not implemented
[Tue, 29 Aug 2023 10:10:14 virt-manager 2141] DEBUG (createvm:497)
Error checking for UEFI default
Traceback (most recent call last):
File "/usr/local/share/virt-manager/virtManager/createvm.py", line
491, in _set_caps_state
guest.enable_uefi()
File "/usr/local/share/virt-manager/virtinst/guest.py", line 589, in
enable_uefi
path = self._lookup_default_uefi_path()
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/share/virt-manager/virtinst/guest.py", line 848, in
_lookup_default_uefi_path
raise RuntimeError(_("Libvirt version does not support UEFI."))
RuntimeError: Libvirt version does not support UEFI
Does anyone know how to fix that error ?
--
Mario.
3
6
Hi, This is the latest version for the series, comparing with version
1, there are some key modifications has made inspired and
suggested by Peter, see as follows:
1. Introduce XML for dirty limit persistent configuration
2. Merge the cancel API into the set API
3. Extend the domstats/virDomainListGetStats API for dirty limit
information query
4. Introduce the virDomainModificationImpact flags to control the
behavior of the API
5. Enrich the comments and docs about the feature and API
The patch set introduce the new API virDomainSetVcpuDirtyLimit to
allow upper Apps to set upper limits of dirty page rate for virtual
CPUs,
the corresponding virsh API as follows:
# limit-dirty-page-rate <domain> <rate> [--vcpu <number>] \
[--config] [--live] [--current]
We put the dirty limit persistent info with the "vcpus" element in
domain XML and
extend dirtylimit statistics for domGetStats:
<domain>
...
<vcpu current='2'>3</vcpu>
<vcpus>
<vcpu id='0' hotpluggable='no' dirty_limit='10' order='1'.../>
<vcpu id='1' hotpluggable='yes' dirty_limit='10' order='2'.../>
</vcpus>
...
If --vcpu option is not passed in the virsh command, set all virtual
CPUs;
if rate is set to zero, cancel the upper limit.
Examples:
To set the dirty page rate upper limit 10 MB/s for all virtual CPUs in
c81_node1, use:
[root@srv2 my_libvirt]# virsh limit-dirty-page-rate c81_node1 --rate 10
--live
Set dirty page rate limit 10(MB/s) for all virtual CPUs successfully
[root@srv2 my_libvirt]# virsh dumpxml c81_node1 | grep dirty_limit
<vcpu id='0' enabled='yes' hotpluggable='no' order='1'
dirty_limit='10'/>
<vcpu id='1' enabled='yes' hotpluggable='no' order='2'
dirty_limit='10'/>
<vcpu id='2' enabled='yes' hotpluggable='no' order='3'
dirty_limit='10'/>
<vcpu id='3' enabled='no' hotpluggable='yes' dirty_limit='10'/>
<vcpu id='4' enabled='no' hotpluggable='yes' dirty_limit='10'/>
......
Query the dirty limit info dynamically:
[root@srv2 my_libvirt]# virsh domstats c81_node1 --dirtylimit
Domain: 'c81_node1'
dirtylimit.vcpu.0.limit=10
dirtylimit.vcpu.0.current=0
dirtylimit.vcpu.1.limit=10
dirtylimit.vcpu.1.current=0
dirtylimit.vcpu.2.limit=10
dirtylimit.vcpu.2.current=0
dirtylimit.vcpu.3.limit=10
dirtylimit.vcpu.3.current=0
dirtylimit.vcpu.4.limit=10
dirtylimit.vcpu.4.current=0
......
To cancel the upper limit, use:
[root@srv2 my_libvirt]# virsh limit-dirty-page-rate c81_node1 \
--rate 0 --live
Cancel dirty page rate limit for all virtual CPUs successfully
[root@srv2 my_libvirt]# virsh dumpxml c81_node1 | grep dirty_limit
[root@srv2 my_libvirt]# virsh domstats c81_node1 --dirtylimit
Domain: 'c81_node1'
The dirty limit uses the QEMU dirty-limit feature introduced since
7.1.0, this feature allows CPU to be throttled as needed to keep
their dirty page rate within the limit. It could, in some scenes, be
used to provide quality-of-service in the aspect of the memory
workload for virtual CPUs and QEMU itself use the feature to
implement the dirty-limit throttle algorithm and apply it on the
live migration, which improve responsiveness of large guests
during live migration and can result in more stable read
performance. The other application scenarios remain
unexplored, before that, Libvirt could provide the basic API.
Please review, thanks
Yong
Hyman Huang(黄勇) (10):
qemu_capabilities: Introduce QEMU_CAPS_VCPU_DIRTY_LIMIT capability
conf: Introduce XML for dirty limit configuration
libvirt: Add virDomainSetVcpuDirtyLimit API
qemu_driver: Implement qemuDomainSetVcpuDirtyLimit
domain_validate: Export virDomainDefHasDirtyLimitStartupVcpus symbol
qemu_process: Setup dirty limit after launching VM
virsh: Introduce limit-dirty-page-rate api
qemu_monitor: Implement qemuMonitorQueryVcpuDirtyLimit
qemu_driver: Extend dirtlimit statistics for domGetStats
virsh: Introduce command 'virsh domstats --dirtylimit'
docs/formatdomain.rst | 7 +-
docs/manpages/virsh.rst | 33 +++-
include/libvirt/libvirt-domain.h | 5 +
src/conf/domain_conf.c | 26 +++
src/conf/domain_conf.h | 8 +
src/conf/domain_validate.c | 33 ++++
src/conf/domain_validate.h | 2 +
src/conf/schemas/domaincommon.rng | 5 +
src/driver-hypervisor.h | 7 +
src/libvirt-domain.c | 68 +++++++
src/libvirt_private.syms | 1 +
src/libvirt_public.syms | 5 +
src/qemu/qemu_capabilities.c | 2 +
src/qemu/qemu_capabilities.h | 1 +
src/qemu/qemu_driver.c | 181 ++++++++++++++++++
src/qemu/qemu_monitor.c | 25 +++
src/qemu/qemu_monitor.h | 22 +++
src/qemu/qemu_monitor_json.c | 107 +++++++++++
src/qemu/qemu_monitor_json.h | 9 +
src/qemu/qemu_process.c | 44 +++++
src/remote/remote_driver.c | 1 +
src/remote/remote_protocol.x | 17 +-
src/remote_protocol-structs | 7 +
.../qemucapabilitiesdata/caps_7.1.0_ppc64.xml | 1 +
.../caps_7.1.0_x86_64.xml | 1 +
tests/qemucapabilitiesdata/caps_7.2.0_ppc.xml | 1 +
.../caps_7.2.0_x86_64+hvf.xml | 1 +
.../caps_7.2.0_x86_64.xml | 1 +
.../caps_8.0.0_riscv64.xml | 1 +
.../caps_8.0.0_x86_64.xml | 1 +
.../qemucapabilitiesdata/caps_8.1.0_s390x.xml | 1 +
.../caps_8.1.0_x86_64.xml | 1 +
tools/virsh-domain-monitor.c | 7 +
tools/virsh-domain.c | 109 +++++++++++
34 files changed, 737 insertions(+), 4 deletions(-)
--
2.38.5
3
15
05 Sep '23
Few outstanding patches of code compiled only on FreeBSD
Pipeline:
https://gitlab.com/pipo.sk/libvirt/-/pipelines/986470469
Peter Krempa (8):
bhyve: Don't stack-allocate huge error buffers
virHostValidateBhyve: Declare one variable per line
virHostValidateBhyve: Heap allocate massive 'struct kld_file_stat'
nss: aiforaf: Format one argument/variable per line
nss: aiforaf: Remove unused 'ret' variable
nss: aiforaf: Drop unused buffer 'port'
nss: aiforaf: Decrease stack size by scoping off large buffers.
build: Decrease maximum stack frame size to 2048
meson.build | 2 +-
src/bhyve/bhyve_process.c | 4 +-
tools/nss/libvirt_nss.c | 105 ++++++++++++++++++-------------
tools/virt-host-validate-bhyve.c | 20 +++---
4 files changed, 74 insertions(+), 57 deletions(-)
--
2.41.0
4
24
[libvirt PATCH 00/33] ci: Unify the GitLab CI jobs with local executions && adopt lcitool container executions
by Erik Skultety 01 Sep '23
by Erik Skultety 01 Sep '23
01 Sep '23
Technically a v2 of:
https://listman.redhat.com/archives/libvir-list/2023-February/237552.html
However, the approach here is slightly different and what that series said
about migration to lcitool container executions as a replacement for
ci/Makefile is actually done here. One of the core problems of the above
pointed out in review was that more Shell logic was introduced including CLI
parsing, conditional executions, etc. which we fought hard to get rid of in the
past. I reworked the Shell functions quite a bit and dropped whatever extra
Shell logic the original series added.
Obviously we can't get rid of Shell completely because of .gitlab-ci.yml and so
I merely extracted the recipes into functions which are then sourced as
ci/build.sh and executed. Now, that on its own would hide the actual commands
being run in the GitLab job log, so before any command is actually executed, it
is formatted with a color sequence so we don't miss that information as that
would be a regression to the status quo.
Lastly, this series then takes the effort inside the ci/build.sh script and
basically mirrors whatever GitLab would do to run a job inside a local
container which is executed by lcitool (yes, we already have that capability).
Please give this a try and I'm already looking forward to comments as I'd like
to expand this effort to local VM executions running the TCK integration tests,
so this series is quite important in that regard.
Erik Skultety (33):
ci: build.sh: Add variables from .gitlab-ci.yml
ci: build.sh: Add GIT_ROOT env helper variable
ci: build.sh: Don't mention that MESON_ARGS are available via CLI
ci: build.sh: Add a wrapper function over meson's setup
ci: build.sh: Add a wrapper function executing 'shell' commands
ci: build.sh: Add a wrapper function over the 'build' job
ci: build.sh: Add a helper function to create the dist tarball
ci: build.sh: Add a wrapper function over the 'test' job
ci: build.sh: Add a wrapper function over the 'codestyle' job
ci: build.sh: Add a wrapper function over the 'potfile' job
ci: build.sh: Add a wrapper function over the 'rpmbuild' job
ci: build.sh: Add a wrapper function over the 'website' job
ci: build.sh: Drop changing working directory to CI_CONT_DIR
ci: build.sh: Drop direct invocation of meson/ninja commands
ci: build.sh: Drop MESON_ARGS definition from global level
gitlab-ci.yml: Add 'after_script' stage to prep for artifact
collection
.gitlab-ci.yml: Convert the native build job to the build.sh usage
.gitlab-ci.yml: Convert the cross build job to the build.sh usage
.gitlab-ci.yml: Convert the website build job to the build.sh usage
.gitlab-ci.yml: Convert the codestyle job to the build.sh usage
.gitlab-ci.yml: Convert the potfile job to the build.sh usage
ci: helper: Drop _lcitool_get_targets method
ci: helper: Don't make ':' literal a static part of the image tag
ci: helper: Add --lcitool-path CLI option
ci: helper: Add a job argparse subparser
ci: helper: Add a required_deps higher order helper/decorator
ci: helper: Add Python code hangling git clones
ci: helper: Add a helper to create a local repo clone Pythonic way
ci: helper: Rework _lcitool_run method logic
ci: helper: Add an action to run the container workload via lcitool
ci: helper: Drop original actions
ci: helper: Drop the --meson-args/--ninja-args CLI options
ci: helper: Drop the _make_run method
.gitlab-ci.yml | 47 +++++++------
ci/build.sh | 105 +++++++++++++++++++++++++----
ci/helper | 176 ++++++++++++++++++++++++++++---------------------
3 files changed, 218 insertions(+), 110 deletions(-)
--
2.41.0
2
83
Ref to patchset implementing the above:
https://listman.redhat.com/archives/libvir-list/2023-August/241250.html
Signed-off-by: K Shiva Kiran <shiva_kr(a)riseup.net>
---
This is a v2 of:
https://listman.redhat.com/archives/libvir-list/2023-August/241469.html
Diff to v1:
- Shortened the text and put all text under one section.
NEWS.rst | 11 +++++++++++
1 file changed, 11 insertions(+)
diff --git a/NEWS.rst b/NEWS.rst
index e40c8ac259..5275a8299a 100644
--- a/NEWS.rst
+++ b/NEWS.rst
@@ -28,6 +28,17 @@ v9.7.0 (unreleased)
2) pre-binding the variant driver using the ``--driver`` option of
``virsh nodedev-detach``.
+ * network: Support for ``<title>`` and ``<description>`` fields in Network XML
+
+ The network object adds two more user defined metadata fields ``<title>``
+ and ``<description>``.
+ Two new APIs ``virNetworkGetMetadata()`` and ``virNetworkSetMetadata()`` can be
+ used to view and modify the above including the existing ``<metadata>`` field.
+
+ virsh adds two new commands ``net-desc`` and ``net-metadata`` to view/modify the same.
+ ``net-list`` adds a new option ``--title`` that prints the content of ``<title>``
+ in an extra column within the default ``--table`` output.
+
* **Improvements**
* **Bug fixes**
--
2.42.0
2
1
It's been a while since libvirt-snmp was actively developed. Now it
receives only libvirt-ci related commits. The code compiles with
net-snmp-5.9.3 but the freshly released net-snmp-5.9.4 [1] breaks
compilation [2]. Now, libvirt-snmp has this crazy architecture, where
some sources are manually generated from src/LIBVIRT-MIB.txt, then
edited (added code to talk to libvirt) and then added to git.
This is labor extensive and since I don't think libvirt-snmp is actually
used I'd like to sunset it. According to repology [3] only Gentoo (and
its clones) has the latest version (released ~5 years ago). And I doubt
it has any real users there.
Thoughts?
1: https://sourceforge.net/projects/net-snmp/files/net-snmp/5.9.4/
2: https://bugs.gentoo.org/show_bug.cgi?id=912582
2: https://repology.org/project/libvirt-snmp/versions
Michal
4
9
Fixes the following bug:
Command: `net-desc --config [--title] my_network`
Expected Output: Title/Description of persistent config
Output: Title/Description of live config
This was caused due to the usage of a single `flags` variable in
`virshGetNetworkDescription()` which ended up in a wrong enum being
passed to `virNetworkGetMetadata()` (enum being that of LIVE instead of
CONFIG).
Although the domain object has the same code, this didn't cause a problem
there because the enum values of `VIR_DOMAIN_INACTIVE_XML` and
`VIR_DOMAIN_METADATA_CONFIG` turn out to be the same (1 << 1), whereas
they are not for network equivalent ones (1 << 0, 1 << 1).
Signed-off-by: K Shiva Kiran <shiva_kr(a)riseup.net>
---
tools/virsh-network.c | 11 ++++++-----
1 file changed, 6 insertions(+), 5 deletions(-)
diff --git a/tools/virsh-network.c b/tools/virsh-network.c
index 49778d0f4f..8965d87c9c 100644
--- a/tools/virsh-network.c
+++ b/tools/virsh-network.c
@@ -366,7 +366,8 @@ static const vshCmdOptDef opts_network_desc[] = {
/* extract description or title from network xml */
static char *
virshGetNetworkDescription(vshControl *ctl, virNetworkPtr net,
- bool title, unsigned int flags)
+ bool title, unsigned int flags,
+ unsigned int queryflags)
{
char *desc = NULL;
g_autoptr(xmlDoc) doc = NULL;
@@ -394,7 +395,7 @@ virshGetNetworkDescription(vshControl *ctl, virNetworkPtr net,
}
/* fall back to xml */
- if (virshNetworkGetXMLFromNet(ctl, net, flags, &doc, &ctxt) < 0)
+ if (virshNetworkGetXMLFromNet(ctl, net, queryflags, &doc, &ctxt) < 0)
return NULL;
if (title)
@@ -454,7 +455,7 @@ cmdNetworkDesc(vshControl *ctl, const vshCmd *cmd)
g_autofree char *descNet = NULL;
g_autofree char *descNew = NULL;
- if (!(descNet = virshGetNetworkDescription(ctl, net, title, queryflags)))
+ if (!(descNet = virshGetNetworkDescription(ctl, net, title, flags, queryflags)))
return false;
if (!descArg)
@@ -515,7 +516,7 @@ cmdNetworkDesc(vshControl *ctl, const vshCmd *cmd)
vshPrintExtra(ctl, "%s", _("Network description updated successfully"));
} else {
- g_autofree char *desc = virshGetNetworkDescription(ctl, net, title, queryflags);
+ g_autofree char *desc = virshGetNetworkDescription(ctl, net, title, flags, queryflags);
if (!desc)
return false;
@@ -1128,7 +1129,7 @@ cmdNetworkList(vshControl *ctl, const vshCmd *cmd G_GNUC_UNUSED)
if (optTitle) {
g_autofree char *title = NULL;
- if (!(title = virshGetNetworkDescription(ctl, network, true, 0)))
+ if (!(title = virshGetNetworkDescription(ctl, network, true, 0, 0)))
goto cleanup;
if (vshTableRowAppend(table,
virNetworkGetName(network),
--
2.42.0
2
1
This fixes reverting external snapshots to not error out in cases where
it should work and makes it correctly load the memory state when
reverting to snapshot of running VM.
Pavel Hrdina (7):
qemu_saveimage: extract starting process to qemuSaveImageStartProcess
qemuSaveImageStartProcess: allow setting reason for audit log
qemuSaveImageStartProcess: add snapshot argument
qemuSaveImageStartProcess: make it possible to use without header
qemu_snapshot: fix reverting external snapshot when not all disks are
included
qemu_snapshot: correctly load the saved memory state file
NEWS: document support for reverting external snapshots
NEWS.rst | 8 +++
src/qemu/qemu_saveimage.c | 111 ++++++++++++++++++++++++++------------
src/qemu/qemu_saveimage.h | 14 +++++
src/qemu/qemu_snapshot.c | 90 ++++++++++++++++++++-----------
4 files changed, 158 insertions(+), 65 deletions(-)
--
2.41.0
2
18
I have just tagged v9.7.0-rc1 in the repository and pushed signed
tarballs and source RPMs to https://download.libvirt.org/
Please give the release candidate some testing and in case you find a
serious issue which should have a fix in the upcoming release, feel
free to reply to this thread to make sure the issue is more visible.
If you have not done so yet, please update NEWS.rst to document any
significant change you made since the last release.
Thanks,
Jirka
2
2
HAX is deprecated since commits 73741fda6c ("MAINTAINERS: Abort
HAXM maintenance") and 90c167a1da ("docs/about/deprecated: Mark
HAXM in QEMU as deprecated"), released in v8.0.0.
Per the latest HAXM release (v7.8 [*]), the latest QEMU supported
is v7.2:
Note: Up to this release, HAXM supports QEMU from 2.9.0 to 7.2.0.
The next commit (https://github.com/intel/haxm/commit/da1b8ec072)
added:
HAXM v7.8.0 is our last release and we will not accept
pull requests or respond to issues after this.
It became very hard to build and test HAXM. Its previous
maintainers made it clear they won't help. It doesn't seem to be
a very good use of QEMU maintainers to spend their time in a dead
project. Save our time by removing this orphan zombie code.
[*] https://github.com/intel/haxm/releases/tag/v7.8.0
Reviewed-by: Richard Henderson <richard.henderson(a)linaro.org>
Acked-by: Markus Armbruster <armbru(a)redhat.com>
Signed-off-by: Philippe Mathieu-Daudé <philmd(a)linaro.org>
---
I plan to commit this in my next PR.
---
MAINTAINERS | 8 -
docs/about/build-platforms.rst | 2 +-
docs/about/deprecated.rst | 6 -
docs/about/index.rst | 2 +-
docs/about/removed-features.rst | 11 +-
docs/system/index.rst | 2 +-
docs/system/introduction.rst | 3 -
meson.build | 7 -
include/exec/poison.h | 1 -
include/hw/core/cpu.h | 2 +-
include/sysemu/hax.h | 49 -
include/sysemu/hw_accel.h | 1 -
target/i386/hax/hax-accel-ops.h | 31 -
target/i386/hax/hax-i386.h | 98 --
target/i386/hax/hax-interface.h | 369 ------
target/i386/hax/hax-posix.h | 61 -
target/i386/hax/hax-windows.h | 88 --
accel/stubs/hax-stub.c | 24 -
hw/intc/apic_common.c | 3 +-
softmmu/cpus.c | 6 -
softmmu/vl.c | 6 -
target/i386/hax/hax-accel-ops.c | 105 --
target/i386/hax/hax-all.c | 1141 -----------------
target/i386/hax/hax-mem.c | 323 -----
target/i386/hax/hax-posix.c | 305 -----
target/i386/hax/hax-windows.c | 485 -------
accel/Kconfig | 3 -
accel/stubs/meson.build | 1 -
meson_options.txt | 2 -
qemu-options.hx | 8 +-
.../ci/org.centos/stream/8/x86_64/configure | 1 -
scripts/meson-buildoptions.sh | 3 -
target/i386/hax/meson.build | 7 -
target/i386/meson.build | 1 -
34 files changed, 16 insertions(+), 3149 deletions(-)
delete mode 100644 include/sysemu/hax.h
delete mode 100644 target/i386/hax/hax-accel-ops.h
delete mode 100644 target/i386/hax/hax-i386.h
delete mode 100644 target/i386/hax/hax-interface.h
delete mode 100644 target/i386/hax/hax-posix.h
delete mode 100644 target/i386/hax/hax-windows.h
delete mode 100644 accel/stubs/hax-stub.c
delete mode 100644 target/i386/hax/hax-accel-ops.c
delete mode 100644 target/i386/hax/hax-all.c
delete mode 100644 target/i386/hax/hax-mem.c
delete mode 100644 target/i386/hax/hax-posix.c
delete mode 100644 target/i386/hax/hax-windows.c
delete mode 100644 target/i386/hax/meson.build
diff --git a/MAINTAINERS b/MAINTAINERS
index 6111b6b4d9..3b29568ed4 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -543,14 +543,6 @@ F: include/sysemu/xen.h
F: include/sysemu/xen-mapcache.h
F: stubs/xen-hw-stub.c
-Guest CPU Cores (HAXM)
----------------------
-X86 HAXM CPUs
-S: Orphan
-F: accel/stubs/hax-stub.c
-F: include/sysemu/hax.h
-F: target/i386/hax/
-
Guest CPU Cores (NVMM)
----------------------
NetBSD Virtual Machine Monitor (NVMM) CPU support
diff --git a/docs/about/build-platforms.rst b/docs/about/build-platforms.rst
index 0e2cb9e770..f2a7aec56f 100644
--- a/docs/about/build-platforms.rst
+++ b/docs/about/build-platforms.rst
@@ -52,7 +52,7 @@ Those hosts are officially supported, with various accelerators:
* - SPARC
- tcg
* - x86
- - hax, hvf (64 bit only), kvm, nvmm, tcg, whpx (64 bit only), xen
+ - hvf (64 bit only), kvm, nvmm, tcg, whpx (64 bit only), xen
Other host architectures are not supported. It is possible to build QEMU system
emulation on an unsupported host architecture using the configure
diff --git a/docs/about/deprecated.rst b/docs/about/deprecated.rst
index 92a2bafd2b..dc4da95329 100644
--- a/docs/about/deprecated.rst
+++ b/docs/about/deprecated.rst
@@ -105,12 +105,6 @@ Use ``-machine hpet=off`` instead.
The ``-no-acpi`` setting has been turned into a machine property.
Use ``-machine acpi=off`` instead.
-``-accel hax`` (since 8.0)
-''''''''''''''''''''''''''
-
-The HAXM project has been retired (see https://github.com/intel/haxm#status)
-Use "whpx" (on Windows) or "hvf" (on macOS) instead.
-
``-async-teardown`` (since 8.1)
'''''''''''''''''''''''''''''''
diff --git a/docs/about/index.rst b/docs/about/index.rst
index b00b584b31..4f96ab5d91 100644
--- a/docs/about/index.rst
+++ b/docs/about/index.rst
@@ -8,7 +8,7 @@ QEMU can be used in several different ways. The most common is for
:ref:`System Emulation`, where it provides a virtual model of an
entire machine (CPU, memory and emulated devices) to run a guest OS.
In this mode the CPU may be fully emulated, or it may work with a
-hypervisor such as KVM, Xen, Hax or Hypervisor.Framework to allow the
+hypervisor such as KVM, Xen or Hypervisor.Framework to allow the
guest to run directly on the host CPU.
The second supported way to use QEMU is :ref:`User Mode Emulation`,
diff --git a/docs/about/removed-features.rst b/docs/about/removed-features.rst
index 5b258b446b..c2043fd415 100644
--- a/docs/about/removed-features.rst
+++ b/docs/about/removed-features.rst
@@ -659,15 +659,18 @@ Use ``Icelake-Server`` instead.
System accelerators
-------------------
-Userspace local APIC with KVM (x86, removed 8.0)
-''''''''''''''''''''''''''''''''''''''''''''''''
+Userspace local APIC with KVM (x86, removed in 8.0)
+'''''''''''''''''''''''''''''''''''''''''''''''''''
``-M kernel-irqchip=off`` cannot be used on KVM if the CPU model includes
a local APIC. The ``split`` setting is supported, as is using ``-M
kernel-irqchip=off`` when the CPU does not have a local APIC.
-System accelerators
--------------------
+HAXM (``-accel hax``) (removed in 8.2)
+''''''''''''''''''''''''''''''''''''''
+
+The HAXM project has been retired (see https://github.com/intel/haxm#status)
+Use "whpx" (on Windows) or "hvf" (on macOS) instead.
MIPS "Trap-and-Emulate" KVM support (removed in 8.0)
''''''''''''''''''''''''''''''''''''''''''''''''''''
diff --git a/docs/system/index.rst b/docs/system/index.rst
index 3605bbe1ce..45bf1f19e7 100644
--- a/docs/system/index.rst
+++ b/docs/system/index.rst
@@ -6,7 +6,7 @@ System Emulation
This section of the manual is the overall guide for users using QEMU
for full system emulation (as opposed to user-mode emulation).
-This includes working with hypervisors such as KVM, Xen, Hax
+This includes working with hypervisors such as KVM, Xen
or Hypervisor.Framework.
.. toctree::
diff --git a/docs/system/introduction.rst b/docs/system/introduction.rst
index 3e256f8326..51ac132d6c 100644
--- a/docs/system/introduction.rst
+++ b/docs/system/introduction.rst
@@ -21,9 +21,6 @@ Tiny Code Generator (TCG) capable of emulating many CPUs.
* - Xen
- Linux (as dom0)
- Arm, x86
- * - Intel HAXM (hax)
- - Linux, Windows
- - x86
* - Hypervisor Framework (hvf)
- MacOS
- x86 (64 bit only), Arm (64 bit only)
diff --git a/meson.build b/meson.build
index 98e68ef0b1..ec14079c67 100644
--- a/meson.build
+++ b/meson.build
@@ -140,7 +140,6 @@ if cpu in ['x86', 'x86_64', 'arm', 'aarch64']
endif
if cpu in ['x86', 'x86_64']
accelerator_targets += {
- 'CONFIG_HAX': ['i386-softmmu', 'x86_64-softmmu'],
'CONFIG_HVF': ['x86_64-softmmu'],
'CONFIG_NVMM': ['i386-softmmu', 'x86_64-softmmu'],
'CONFIG_WHPX': ['i386-softmmu', 'x86_64-softmmu'],
@@ -663,11 +662,6 @@ if get_option('hvf').allowed()
accelerators += 'CONFIG_HVF'
endif
endif
-if get_option('hax').allowed()
- if get_option('hax').enabled() or targetos in ['windows', 'darwin', 'netbsd']
- accelerators += 'CONFIG_HAX'
- endif
-endif
if targetos == 'netbsd'
nvmm = cc.find_library('nvmm', required: get_option('nvmm'))
if nvmm.found()
@@ -4140,7 +4134,6 @@ endif
summary_info = {}
if have_system
summary_info += {'KVM support': config_all.has_key('CONFIG_KVM')}
- summary_info += {'HAX support': config_all.has_key('CONFIG_HAX')}
summary_info += {'HVF support': config_all.has_key('CONFIG_HVF')}
summary_info += {'WHPX support': config_all.has_key('CONFIG_WHPX')}
summary_info += {'NVMM support': config_all.has_key('CONFIG_NVMM')}
diff --git a/include/exec/poison.h b/include/exec/poison.h
index e94ee8dfef..1ea5633eb3 100644
--- a/include/exec/poison.h
+++ b/include/exec/poison.h
@@ -81,7 +81,6 @@
#pragma GCC poison CONFIG_SPARC_DIS
#pragma GCC poison CONFIG_XTENSA_DIS
-#pragma GCC poison CONFIG_HAX
#pragma GCC poison CONFIG_HVF
#pragma GCC poison CONFIG_LINUX_USER
#pragma GCC poison CONFIG_KVM
diff --git a/include/hw/core/cpu.h b/include/hw/core/cpu.h
index fdcbe87352..92a4234439 100644
--- a/include/hw/core/cpu.h
+++ b/include/hw/core/cpu.h
@@ -422,7 +422,7 @@ struct CPUState {
int32_t exception_index;
AccelCPUState *accel;
- /* shared by kvm, hax and hvf */
+ /* shared by kvm and hvf */
bool vcpu_dirty;
/* Used to keep track of an outstanding cpu throttle thread for migration
diff --git a/include/sysemu/hax.h b/include/sysemu/hax.h
deleted file mode 100644
index 80fc716f80..0000000000
--- a/include/sysemu/hax.h
+++ /dev/null
@@ -1,49 +0,0 @@
-/*
- * QEMU HAXM support
- *
- * Copyright IBM, Corp. 2008
- *
- * Authors:
- * Anthony Liguori <aliguori(a)us.ibm.com>
- *
- * Copyright (c) 2011 Intel Corporation
- * Written by:
- * Jiang Yunhong<yunhong.jiang(a)intel.com>
- * Xin Xiaohui<xiaohui.xin(a)intel.com>
- * Zhang Xiantao<xiantao.zhang(a)intel.com>
- *
- * Copyright 2016 Google, Inc.
- *
- * This work is licensed under the terms of the GNU GPL, version 2 or later.
- * See the COPYING file in the top-level directory.
- *
- */
-
-/* header to be included in non-HAX-specific code */
-
-#ifndef QEMU_HAX_H
-#define QEMU_HAX_H
-
-int hax_sync_vcpus(void);
-
-#ifdef NEED_CPU_H
-# ifdef CONFIG_HAX
-# define CONFIG_HAX_IS_POSSIBLE
-# endif
-#else /* !NEED_CPU_H */
-# define CONFIG_HAX_IS_POSSIBLE
-#endif
-
-#ifdef CONFIG_HAX_IS_POSSIBLE
-
-extern bool hax_allowed;
-
-#define hax_enabled() (hax_allowed)
-
-#else /* !CONFIG_HAX_IS_POSSIBLE */
-
-#define hax_enabled() (0)
-
-#endif /* CONFIG_HAX_IS_POSSIBLE */
-
-#endif /* QEMU_HAX_H */
diff --git a/include/sysemu/hw_accel.h b/include/sysemu/hw_accel.h
index 22903a55f7..c71b77e71f 100644
--- a/include/sysemu/hw_accel.h
+++ b/include/sysemu/hw_accel.h
@@ -12,7 +12,6 @@
#define QEMU_HW_ACCEL_H
#include "hw/core/cpu.h"
-#include "sysemu/hax.h"
#include "sysemu/kvm.h"
#include "sysemu/hvf.h"
#include "sysemu/whpx.h"
diff --git a/target/i386/hax/hax-accel-ops.h b/target/i386/hax/hax-accel-ops.h
deleted file mode 100644
index 9e357e7b40..0000000000
--- a/target/i386/hax/hax-accel-ops.h
+++ /dev/null
@@ -1,31 +0,0 @@
-/*
- * Accelerator CPUS Interface
- *
- * Copyright 2020 SUSE LLC
- *
- * This work is licensed under the terms of the GNU GPL, version 2 or later.
- * See the COPYING file in the top-level directory.
- */
-
-#ifndef TARGET_I386_HAX_ACCEL_OPS_H
-#define TARGET_I386_HAX_ACCEL_OPS_H
-
-#include "sysemu/cpus.h"
-
-#include "hax-interface.h"
-#include "hax-i386.h"
-
-int hax_init_vcpu(CPUState *cpu);
-int hax_smp_cpu_exec(CPUState *cpu);
-int hax_populate_ram(uint64_t va, uint64_t size);
-
-void hax_cpu_synchronize_state(CPUState *cpu);
-void hax_cpu_synchronize_post_reset(CPUState *cpu);
-void hax_cpu_synchronize_post_init(CPUState *cpu);
-void hax_cpu_synchronize_pre_loadvm(CPUState *cpu);
-
-int hax_vcpu_destroy(CPUState *cpu);
-void hax_raise_event(CPUState *cpu);
-void hax_reset_vcpu_state(void *opaque);
-
-#endif /* TARGET_I386_HAX_ACCEL_OPS_H */
diff --git a/target/i386/hax/hax-i386.h b/target/i386/hax/hax-i386.h
deleted file mode 100644
index 87153f40ab..0000000000
--- a/target/i386/hax/hax-i386.h
+++ /dev/null
@@ -1,98 +0,0 @@
-/*
- * QEMU HAXM support
- *
- * Copyright (c) 2011 Intel Corporation
- * Written by:
- * Jiang Yunhong<yunhong.jiang(a)intel.com>
- *
- * This work is licensed under the terms of the GNU GPL, version 2 or later.
- * See the COPYING file in the top-level directory.
- *
- */
-
-#ifndef HAX_I386_H
-#define HAX_I386_H
-
-#include "cpu.h"
-#include "sysemu/hax.h"
-
-#ifdef CONFIG_POSIX
-typedef int hax_fd;
-#endif
-
-#ifdef CONFIG_WIN32
-typedef HANDLE hax_fd;
-#endif
-
-extern struct hax_state hax_global;
-
-struct AccelCPUState {
-#ifdef _WIN32
- HANDLE hThread;
-#endif
- hax_fd fd;
- int vcpu_id;
- struct hax_tunnel *tunnel;
- unsigned char *iobuf;
-};
-
-struct hax_state {
- hax_fd fd; /* the global hax device interface */
- uint32_t version;
- struct hax_vm *vm;
- uint64_t mem_quota;
- bool supports_64bit_ramblock;
-};
-
-#define HAX_MAX_VCPU 0x10
-
-struct hax_vm {
- hax_fd fd;
- int id;
- int numvcpus;
- AccelCPUState **vcpus;
-};
-
-/* Functions exported to host specific mode */
-hax_fd hax_vcpu_get_fd(CPUArchState *env);
-int valid_hax_tunnel_size(uint16_t size);
-
-/* Host specific functions */
-int hax_mod_version(struct hax_state *hax, struct hax_module_version *version);
-int hax_inject_interrupt(CPUArchState *env, int vector);
-struct hax_vm *hax_vm_create(struct hax_state *hax, int max_cpus);
-int hax_vcpu_run(AccelCPUState *vcpu);
-int hax_vcpu_create(int id);
-void hax_kick_vcpu_thread(CPUState *cpu);
-
-int hax_sync_vcpu_state(CPUArchState *env, struct vcpu_state_t *state,
- int set);
-int hax_sync_msr(CPUArchState *env, struct hax_msr_data *msrs, int set);
-int hax_sync_fpu(CPUArchState *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);
-int hax_set_ram(uint64_t start_pa, uint32_t size, uint64_t host_va, int flags);
-
-/* Common host function */
-int hax_host_create_vm(struct hax_state *hax, int *vm_id);
-hax_fd hax_host_open_vm(struct hax_state *hax, int vm_id);
-int hax_host_create_vcpu(hax_fd vm_fd, int vcpuid);
-hax_fd hax_host_open_vcpu(int vmid, int vcpuid);
-int hax_host_setup_vcpu_channel(AccelCPUState *vcpu);
-hax_fd hax_mod_open(void);
-void hax_memory_init(void);
-
-
-#ifdef CONFIG_POSIX
-#include "hax-posix.h"
-#endif
-
-#ifdef CONFIG_WIN32
-#include "hax-windows.h"
-#endif
-
-#include "hax-interface.h"
-
-#endif
diff --git a/target/i386/hax/hax-interface.h b/target/i386/hax/hax-interface.h
deleted file mode 100644
index 537ae084e9..0000000000
--- a/target/i386/hax/hax-interface.h
+++ /dev/null
@@ -1,369 +0,0 @@
-/*
- * QEMU HAXM support
- *
- * Copyright (c) 2011 Intel Corporation
- * Written by:
- * Jiang Yunhong<yunhong.jiang(a)intel.com>
- * Xin Xiaohui<xiaohui.xin(a)intel.com>
- * Zhang Xiantao<xiantao.zhang(a)intel.com>
- *
- * This work is licensed under the terms of the GNU GPL, version 2 or later.
- * See the COPYING file in the top-level directory.
- *
- */
-
-/* Interface with HAX kernel module */
-
-#ifndef HAX_INTERFACE_H
-#define HAX_INTERFACE_H
-
-/* fx_layout has 3 formats table 3-56, 512bytes */
-struct fx_layout {
- uint16_t fcw;
- uint16_t fsw;
- uint8_t ftw;
- uint8_t res1;
- uint16_t fop;
- union {
- struct {
- uint32_t fip;
- uint16_t fcs;
- uint16_t res2;
- };
- uint64_t fpu_ip;
- };
- union {
- struct {
- uint32_t fdp;
- uint16_t fds;
- uint16_t res3;
- };
- uint64_t fpu_dp;
- };
- uint32_t mxcsr;
- uint32_t mxcsr_mask;
- uint8_t st_mm[8][16];
- uint8_t mmx_1[8][16];
- uint8_t mmx_2[8][16];
- uint8_t pad[96];
-} __attribute__ ((aligned(8)));
-
-struct vmx_msr {
- uint64_t entry;
- uint64_t value;
-} __attribute__ ((__packed__));
-
-/*
- * Fixed array is not good, but it makes Mac support a bit easier by avoiding
- * memory map or copyin staff.
- */
-#define HAX_MAX_MSR_ARRAY 0x20
-struct hax_msr_data {
- uint16_t nr_msr;
- uint16_t done;
- uint16_t pad[2];
- struct vmx_msr entries[HAX_MAX_MSR_ARRAY];
-} __attribute__ ((__packed__));
-
-union interruptibility_state_t {
- uint32_t raw;
- struct {
- uint32_t sti_blocking:1;
- uint32_t movss_blocking:1;
- uint32_t smi_blocking:1;
- uint32_t nmi_blocking:1;
- uint32_t reserved:28;
- };
- uint64_t pad;
-};
-
-typedef union interruptibility_state_t interruptibility_state_t;
-
-/* Segment descriptor */
-struct segment_desc_t {
- uint16_t selector;
- uint16_t _dummy;
- uint32_t limit;
- uint64_t base;
- union {
- struct {
- uint32_t type:4;
- uint32_t desc:1;
- uint32_t dpl:2;
- uint32_t present:1;
- uint32_t:4;
- uint32_t available:1;
- uint32_t long_mode:1;
- uint32_t operand_size:1;
- uint32_t granularity:1;
- uint32_t null:1;
- uint32_t:15;
- };
- uint32_t ar;
- };
- uint32_t ipad;
-};
-
-typedef struct segment_desc_t segment_desc_t;
-
-struct vcpu_state_t {
- union {
- uint64_t _regs[16];
- struct {
- union {
- struct {
- uint8_t _al, _ah;
- };
- uint16_t _ax;
- uint32_t _eax;
- uint64_t _rax;
- };
- union {
- struct {
- uint8_t _cl, _ch;
- };
- uint16_t _cx;
- uint32_t _ecx;
- uint64_t _rcx;
- };
- union {
- struct {
- uint8_t _dl, _dh;
- };
- uint16_t _dx;
- uint32_t _edx;
- uint64_t _rdx;
- };
- union {
- struct {
- uint8_t _bl, _bh;
- };
- uint16_t _bx;
- uint32_t _ebx;
- uint64_t _rbx;
- };
- union {
- uint16_t _sp;
- uint32_t _esp;
- uint64_t _rsp;
- };
- union {
- uint16_t _bp;
- uint32_t _ebp;
- uint64_t _rbp;
- };
- union {
- uint16_t _si;
- uint32_t _esi;
- uint64_t _rsi;
- };
- union {
- uint16_t _di;
- uint32_t _edi;
- uint64_t _rdi;
- };
-
- uint64_t _r8;
- uint64_t _r9;
- uint64_t _r10;
- uint64_t _r11;
- uint64_t _r12;
- uint64_t _r13;
- uint64_t _r14;
- uint64_t _r15;
- };
- };
-
- union {
- uint32_t _eip;
- uint64_t _rip;
- };
-
- union {
- uint32_t _eflags;
- uint64_t _rflags;
- };
-
- segment_desc_t _cs;
- segment_desc_t _ss;
- segment_desc_t _ds;
- segment_desc_t _es;
- segment_desc_t _fs;
- segment_desc_t _gs;
- segment_desc_t _ldt;
- segment_desc_t _tr;
-
- segment_desc_t _gdt;
- segment_desc_t _idt;
-
- uint64_t _cr0;
- uint64_t _cr2;
- uint64_t _cr3;
- uint64_t _cr4;
-
- uint64_t _dr0;
- uint64_t _dr1;
- uint64_t _dr2;
- uint64_t _dr3;
- uint64_t _dr6;
- uint64_t _dr7;
- uint64_t _pde;
-
- uint32_t _efer;
-
- uint32_t _sysenter_cs;
- uint64_t _sysenter_eip;
- uint64_t _sysenter_esp;
-
- uint32_t _activity_state;
- uint32_t pad;
- interruptibility_state_t _interruptibility_state;
-};
-
-/* HAX exit status */
-enum exit_status {
- /* IO port request */
- HAX_EXIT_IO = 1,
- /* MMIO instruction emulation */
- HAX_EXIT_MMIO,
- /* QEMU emulation mode request, currently means guest enter non-PG mode */
- HAX_EXIT_REAL,
- /*
- * Interrupt window open, qemu can inject interrupt now
- * Also used when signal pending since at that time qemu usually need
- * check interrupt
- */
- HAX_EXIT_INTERRUPT,
- /* Unknown vmexit, mostly trigger reboot */
- HAX_EXIT_UNKNOWN_VMEXIT,
- /* HALT from guest */
- HAX_EXIT_HLT,
- /* Reboot request, like because of tripple fault in guest */
- HAX_EXIT_STATECHANGE,
- /* the vcpu is now only paused when destroy, so simply return to hax */
- HAX_EXIT_PAUSED,
- HAX_EXIT_FAST_MMIO,
-};
-
-/*
- * The interface definition:
- * 1. vcpu_run execute will return 0 on success, otherwise mean failed
- * 2. exit_status return the exit reason, as stated in enum exit_status
- * 3. exit_reason is the vmx exit reason
- */
-struct hax_tunnel {
- uint32_t _exit_reason;
- uint32_t _exit_flag;
- uint32_t _exit_status;
- uint32_t user_event_pending;
- int ready_for_interrupt_injection;
- int request_interrupt_window;
- union {
- struct {
- /* 0: read, 1: write */
-#define HAX_EXIT_IO_IN 1
-#define HAX_EXIT_IO_OUT 0
- uint8_t _direction;
- uint8_t _df;
- uint16_t _size;
- uint16_t _port;
- uint16_t _count;
- uint8_t _flags;
- uint8_t _pad0;
- uint16_t _pad1;
- uint32_t _pad2;
- uint64_t _vaddr;
- } pio;
- struct {
- uint64_t gla;
- } mmio;
- struct {
- } state;
- };
-} __attribute__ ((__packed__));
-
-struct hax_module_version {
- uint32_t compat_version;
- uint32_t cur_version;
-} __attribute__ ((__packed__));
-
-/* This interface is support only after API version 2 */
-struct hax_qemu_version {
- /* Current API version in QEMU */
- uint32_t cur_version;
- /* The minimum API version supported by QEMU */
- uint32_t min_version;
-} __attribute__ ((__packed__));
-
-/* The mac specfic interface to qemu, mostly is ioctl related */
-struct hax_tunnel_info {
- uint64_t va;
- uint64_t io_va;
- uint16_t size;
- uint16_t pad[3];
-} __attribute__ ((__packed__));
-
-struct hax_alloc_ram_info {
- uint32_t size;
- uint32_t pad;
- uint64_t va;
-} __attribute__ ((__packed__));
-
-struct hax_ramblock_info {
- uint64_t start_va;
- uint64_t size;
- uint64_t reserved;
-} __attribute__ ((__packed__));
-
-#define HAX_RAM_INFO_ROM 0x01 /* Read-Only */
-#define HAX_RAM_INFO_INVALID 0x80 /* Unmapped, usually used for MMIO */
-struct hax_set_ram_info {
- uint64_t pa_start;
- uint32_t size;
- uint8_t flags;
- uint8_t pad[3];
- uint64_t va;
-} __attribute__ ((__packed__));
-
-#define HAX_CAP_STATUS_WORKING 0x1
-#define HAX_CAP_STATUS_NOTWORKING 0x0
-#define HAX_CAP_WORKSTATUS_MASK 0x1
-
-#define HAX_CAP_FAILREASON_VT 0x1
-#define HAX_CAP_FAILREASON_NX 0x2
-
-#define HAX_CAP_MEMQUOTA 0x2
-#define HAX_CAP_UG 0x4
-#define HAX_CAP_64BIT_RAMBLOCK 0x8
-
-struct hax_capabilityinfo {
- /* bit 0: 1 - working
- * 0 - not working, possibly because NT/NX disabled
- * bit 1: 1 - memory limitation working
- * 0 - no memory limitation
- */
- uint16_t wstatus;
- /* valid when not working
- * bit 0: VT not enabeld
- * bit 1: NX not enabled*/
- uint16_t winfo;
- uint32_t pad;
- uint64_t mem_quota;
-} __attribute__ ((__packed__));
-
-struct hax_fastmmio {
- uint64_t gpa;
- union {
- uint64_t value;
- uint64_t gpa2; /* since HAX API v4 */
- };
- uint8_t size;
- uint8_t direction;
- uint16_t reg_index;
- uint32_t pad0;
- uint64_t _cr0;
- uint64_t _cr2;
- uint64_t _cr3;
- uint64_t _cr4;
-} __attribute__ ((__packed__));
-#endif
diff --git a/target/i386/hax/hax-posix.h b/target/i386/hax/hax-posix.h
deleted file mode 100644
index fb7c64426d..0000000000
--- a/target/i386/hax/hax-posix.h
+++ /dev/null
@@ -1,61 +0,0 @@
-/*
- * QEMU HAXM support
- *
- * Copyright (c) 2011 Intel Corporation
- * Written by:
- * Jiang Yunhong<yunhong.jiang(a)intel.com>
- * Xin Xiaohui<xiaohui.xin(a)intel.com>
- * Zhang Xiantao<xiantao.zhang(a)intel.com>
- *
- * This work is licensed under the terms of the GNU GPL, version 2 or later.
- * See the COPYING file in the top-level directory.
- *
- */
-
-#ifndef TARGET_I386_HAX_POSIX_H
-#define TARGET_I386_HAX_POSIX_H
-
-#include <sys/ioctl.h>
-
-#define HAX_INVALID_FD (-1)
-static inline int hax_invalid_fd(hax_fd fd)
-{
- return fd <= 0;
-}
-
-static inline void hax_mod_close(struct hax_state *hax)
-{
- close(hax->fd);
-}
-
-static inline void hax_close_fd(hax_fd fd)
-{
- close(fd);
-}
-
-/* HAX model level ioctl */
-#define HAX_IOCTL_VERSION _IOWR(0, 0x20, struct hax_module_version)
-#define HAX_IOCTL_CREATE_VM _IOWR(0, 0x21, uint32_t)
-#define HAX_IOCTL_DESTROY_VM _IOW(0, 0x22, uint32_t)
-#define HAX_IOCTL_CAPABILITY _IOR(0, 0x23, struct hax_capabilityinfo)
-
-#define HAX_VM_IOCTL_VCPU_CREATE _IOWR(0, 0x80, uint32_t)
-#define HAX_VM_IOCTL_ALLOC_RAM _IOWR(0, 0x81, struct hax_alloc_ram_info)
-#define HAX_VM_IOCTL_SET_RAM _IOWR(0, 0x82, struct hax_set_ram_info)
-#define HAX_VM_IOCTL_VCPU_DESTROY _IOW(0, 0x83, uint32_t)
-#define HAX_VM_IOCTL_NOTIFY_QEMU_VERSION _IOW(0, 0x84, struct hax_qemu_version)
-#define HAX_VM_IOCTL_ADD_RAMBLOCK _IOW(0, 0x85, struct hax_ramblock_info)
-
-#define HAX_VCPU_IOCTL_RUN _IO(0, 0xc0)
-#define HAX_VCPU_IOCTL_SET_MSRS _IOWR(0, 0xc1, struct hax_msr_data)
-#define HAX_VCPU_IOCTL_GET_MSRS _IOWR(0, 0xc2, struct hax_msr_data)
-
-#define HAX_VCPU_IOCTL_SET_FPU _IOW(0, 0xc3, struct fx_layout)
-#define HAX_VCPU_IOCTL_GET_FPU _IOR(0, 0xc4, struct fx_layout)
-
-#define HAX_VCPU_IOCTL_SETUP_TUNNEL _IOWR(0, 0xc5, struct hax_tunnel_info)
-#define HAX_VCPU_IOCTL_INTERRUPT _IOWR(0, 0xc6, uint32_t)
-#define HAX_VCPU_SET_REGS _IOWR(0, 0xc7, struct vcpu_state_t)
-#define HAX_VCPU_GET_REGS _IOWR(0, 0xc8, struct vcpu_state_t)
-
-#endif /* TARGET_I386_HAX_POSIX_H */
diff --git a/target/i386/hax/hax-windows.h b/target/i386/hax/hax-windows.h
deleted file mode 100644
index b1f5d4f32f..0000000000
--- a/target/i386/hax/hax-windows.h
+++ /dev/null
@@ -1,88 +0,0 @@
-/*
- * QEMU HAXM support
- *
- * Copyright IBM, Corp. 2008
- *
- * Authors:
- * Anthony Liguori <aliguori(a)us.ibm.com>
- *
- * Copyright (c) 2011 Intel Corporation
- * Written by:
- * Jiang Yunhong<yunhong.jiang(a)intel.com>
- * Xin Xiaohui<xiaohui.xin(a)intel.com>
- * Zhang Xiantao<xiantao.zhang(a)intel.com>
- *
- * This work is licensed under the terms of the GNU GPL, version 2 or later.
- * See the COPYING file in the top-level directory.
- *
- */
-
-#ifndef TARGET_I386_HAX_WINDOWS_H
-#define TARGET_I386_HAX_WINDOWS_H
-
-#include <winioctl.h>
-#include <windef.h>
-
-#include "hax-accel-ops.h"
-
-#define HAX_INVALID_FD INVALID_HANDLE_VALUE
-
-static inline void hax_mod_close(struct hax_state *hax)
-{
- CloseHandle(hax->fd);
-}
-
-static inline void hax_close_fd(hax_fd fd)
-{
- CloseHandle(fd);
-}
-
-static inline int hax_invalid_fd(hax_fd fd)
-{
- return (fd == INVALID_HANDLE_VALUE);
-}
-
-#define HAX_DEVICE_TYPE 0x4000
-
-#define HAX_IOCTL_VERSION CTL_CODE(HAX_DEVICE_TYPE, 0x900, \
- METHOD_BUFFERED, FILE_ANY_ACCESS)
-#define HAX_IOCTL_CREATE_VM CTL_CODE(HAX_DEVICE_TYPE, 0x901, \
- METHOD_BUFFERED, FILE_ANY_ACCESS)
-#define HAX_IOCTL_CAPABILITY CTL_CODE(HAX_DEVICE_TYPE, 0x910, \
- METHOD_BUFFERED, FILE_ANY_ACCESS)
-
-#define HAX_VM_IOCTL_VCPU_CREATE CTL_CODE(HAX_DEVICE_TYPE, 0x902, \
- METHOD_BUFFERED, FILE_ANY_ACCESS)
-#define HAX_VM_IOCTL_ALLOC_RAM CTL_CODE(HAX_DEVICE_TYPE, 0x903, \
- METHOD_BUFFERED, FILE_ANY_ACCESS)
-#define HAX_VM_IOCTL_SET_RAM CTL_CODE(HAX_DEVICE_TYPE, 0x904, \
- METHOD_BUFFERED, FILE_ANY_ACCESS)
-#define HAX_VM_IOCTL_VCPU_DESTROY CTL_CODE(HAX_DEVICE_TYPE, 0x905, \
- METHOD_BUFFERED, FILE_ANY_ACCESS)
-#define HAX_VM_IOCTL_ADD_RAMBLOCK CTL_CODE(HAX_DEVICE_TYPE, 0x913, \
- METHOD_BUFFERED, FILE_ANY_ACCESS)
-
-#define HAX_VCPU_IOCTL_RUN CTL_CODE(HAX_DEVICE_TYPE, 0x906, \
- METHOD_BUFFERED, FILE_ANY_ACCESS)
-#define HAX_VCPU_IOCTL_SET_MSRS CTL_CODE(HAX_DEVICE_TYPE, 0x907, \
- METHOD_BUFFERED, FILE_ANY_ACCESS)
-#define HAX_VCPU_IOCTL_GET_MSRS CTL_CODE(HAX_DEVICE_TYPE, 0x908, \
- METHOD_BUFFERED, FILE_ANY_ACCESS)
-#define HAX_VCPU_IOCTL_SET_FPU CTL_CODE(HAX_DEVICE_TYPE, 0x909, \
- METHOD_BUFFERED, FILE_ANY_ACCESS)
-#define HAX_VCPU_IOCTL_GET_FPU CTL_CODE(HAX_DEVICE_TYPE, 0x90a, \
- METHOD_BUFFERED, FILE_ANY_ACCESS)
-
-#define HAX_VCPU_IOCTL_SETUP_TUNNEL CTL_CODE(HAX_DEVICE_TYPE, 0x90b, \
- METHOD_BUFFERED, FILE_ANY_ACCESS)
-#define HAX_VCPU_IOCTL_INTERRUPT CTL_CODE(HAX_DEVICE_TYPE, 0x90c, \
- METHOD_BUFFERED, FILE_ANY_ACCESS)
-#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 /* TARGET_I386_HAX_WINDOWS_H */
diff --git a/accel/stubs/hax-stub.c b/accel/stubs/hax-stub.c
deleted file mode 100644
index 2fe31aaa9a..0000000000
--- a/accel/stubs/hax-stub.c
+++ /dev/null
@@ -1,24 +0,0 @@
-/*
- * QEMU HAXM support
- *
- * Copyright (c) 2015, Intel Corporation
- *
- * Copyright 2016 Google, Inc.
- *
- * This software is licensed under the terms of the GNU General Public
- * License version 2, as published by the Free Software Foundation, and
- * may be copied, distributed, and modified under those terms.
- *
- * See the COPYING file in the top-level directory.
- *
- */
-
-#include "qemu/osdep.h"
-#include "sysemu/hax.h"
-
-bool hax_allowed;
-
-int hax_sync_vcpus(void)
-{
- return 0;
-}
diff --git a/hw/intc/apic_common.c b/hw/intc/apic_common.c
index 4a34f03047..68ad30e2f5 100644
--- a/hw/intc/apic_common.c
+++ b/hw/intc/apic_common.c
@@ -28,7 +28,6 @@
#include "hw/intc/kvm_irqcount.h"
#include "trace.h"
#include "hw/boards.h"
-#include "sysemu/hax.h"
#include "sysemu/kvm.h"
#include "hw/qdev-properties.h"
#include "hw/sysbus.h"
@@ -271,7 +270,7 @@ static void apic_common_realize(DeviceState *dev, Error **errp)
/* Note: We need at least 1M to map the VAPIC option ROM */
if (!vapic && s->vapic_control & VAPIC_ENABLE_MASK &&
- !hax_enabled() && current_machine->ram_size >= 1024 * 1024) {
+ current_machine->ram_size >= 1024 * 1024) {
vapic = sysbus_create_simple("kvmvapic", -1, NULL);
}
s->vapic = vapic;
diff --git a/softmmu/cpus.c b/softmmu/cpus.c
index fed20ffb5d..0848e0dbdb 100644
--- a/softmmu/cpus.c
+++ b/softmmu/cpus.c
@@ -427,12 +427,6 @@ void qemu_wait_io_event(CPUState *cpu)
qemu_plugin_vcpu_resume_cb(cpu);
}
-#ifdef _WIN32
- /* Eat dummy APC queued by cpus_kick_thread. */
- if (hax_enabled()) {
- SleepEx(0, TRUE);
- }
-#endif
qemu_wait_io_event_common(cpu);
}
diff --git a/softmmu/vl.c b/softmmu/vl.c
index b0b96f67fa..5a10b3c309 100644
--- a/softmmu/vl.c
+++ b/softmmu/vl.c
@@ -86,7 +86,6 @@
#include "migration/colo.h"
#include "migration/postcopy-ram.h"
#include "sysemu/kvm.h"
-#include "sysemu/hax.h"
#include "qapi/qobject-input-visitor.h"
#include "qemu/option.h"
#include "qemu/config-file.h"
@@ -2546,11 +2545,6 @@ static void qemu_init_board(void)
drive_check_orphaned();
realtime_init();
-
- if (hax_enabled()) {
- /* FIXME: why isn't cpu_synchronize_all_post_init enough? */
- hax_sync_vcpus();
- }
}
static void qemu_create_cli_devices(void)
diff --git a/target/i386/hax/hax-accel-ops.c b/target/i386/hax/hax-accel-ops.c
deleted file mode 100644
index 5031096760..0000000000
--- a/target/i386/hax/hax-accel-ops.c
+++ /dev/null
@@ -1,105 +0,0 @@
-/*
- * QEMU HAX support
- *
- * Copyright IBM, Corp. 2008
- * Red Hat, Inc. 2008
- *
- * Authors:
- * Anthony Liguori <aliguori(a)us.ibm.com>
- * Glauber Costa <gcosta(a)redhat.com>
- *
- * Copyright (c) 2011 Intel Corporation
- * Written by:
- * Jiang Yunhong<yunhong.jiang(a)intel.com>
- * Xin Xiaohui<xiaohui.xin(a)intel.com>
- * Zhang Xiantao<xiantao.zhang(a)intel.com>
- *
- * This work is licensed under the terms of the GNU GPL, version 2 or later.
- * See the COPYING file in the top-level directory.
- *
- */
-
-#include "qemu/osdep.h"
-#include "qemu/error-report.h"
-#include "qemu/main-loop.h"
-#include "sysemu/runstate.h"
-#include "sysemu/cpus.h"
-#include "qemu/guest-random.h"
-
-#include "hax-accel-ops.h"
-
-static void *hax_cpu_thread_fn(void *arg)
-{
- CPUState *cpu = arg;
- int r;
-
- rcu_register_thread();
- qemu_mutex_lock_iothread();
- qemu_thread_get_self(cpu->thread);
-
- cpu->thread_id = qemu_get_thread_id();
- current_cpu = cpu;
- hax_init_vcpu(cpu);
- cpu_thread_signal_created(cpu);
- qemu_guest_random_seed_thread_part2(cpu->random_seed);
-
- do {
- if (cpu_can_run(cpu)) {
- r = hax_smp_cpu_exec(cpu);
- if (r == EXCP_DEBUG) {
- cpu_handle_guest_debug(cpu);
- }
- }
-
- qemu_wait_io_event(cpu);
- } while (!cpu->unplug || cpu_can_run(cpu));
- hax_vcpu_destroy(cpu);
- cpu_thread_signal_destroyed(cpu);
- rcu_unregister_thread();
- return NULL;
-}
-
-static void hax_start_vcpu_thread(CPUState *cpu)
-{
- char thread_name[VCPU_THREAD_NAME_SIZE];
-
- cpu->thread = g_new0(QemuThread, 1);
- cpu->halt_cond = g_new0(QemuCond, 1);
- qemu_cond_init(cpu->halt_cond);
-
- snprintf(thread_name, VCPU_THREAD_NAME_SIZE, "CPU %d/HAX",
- cpu->cpu_index);
- qemu_thread_create(cpu->thread, thread_name, hax_cpu_thread_fn,
- cpu, QEMU_THREAD_JOINABLE);
- assert(cpu->accel);
-#ifdef _WIN32
- cpu->accel->hThread = qemu_thread_get_handle(cpu->thread);
-#endif
-}
-
-static void hax_accel_ops_class_init(ObjectClass *oc, void *data)
-{
- AccelOpsClass *ops = ACCEL_OPS_CLASS(oc);
-
- ops->create_vcpu_thread = hax_start_vcpu_thread;
- ops->kick_vcpu_thread = hax_kick_vcpu_thread;
-
- ops->synchronize_post_reset = hax_cpu_synchronize_post_reset;
- ops->synchronize_post_init = hax_cpu_synchronize_post_init;
- ops->synchronize_state = hax_cpu_synchronize_state;
- ops->synchronize_pre_loadvm = hax_cpu_synchronize_pre_loadvm;
-}
-
-static const TypeInfo hax_accel_ops_type = {
- .name = ACCEL_OPS_NAME("hax"),
-
- .parent = TYPE_ACCEL_OPS,
- .class_init = hax_accel_ops_class_init,
- .abstract = true,
-};
-
-static void hax_accel_ops_register_types(void)
-{
- type_register_static(&hax_accel_ops_type);
-}
-type_init(hax_accel_ops_register_types);
diff --git a/target/i386/hax/hax-all.c b/target/i386/hax/hax-all.c
deleted file mode 100644
index 18d78e5b6b..0000000000
--- a/target/i386/hax/hax-all.c
+++ /dev/null
@@ -1,1141 +0,0 @@
-/*
- * QEMU HAX support
- *
- * Copyright IBM, Corp. 2008
- * Red Hat, Inc. 2008
- *
- * Authors:
- * Anthony Liguori <aliguori(a)us.ibm.com>
- * Glauber Costa <gcosta(a)redhat.com>
- *
- * Copyright (c) 2011 Intel Corporation
- * Written by:
- * Jiang Yunhong<yunhong.jiang(a)intel.com>
- * Xin Xiaohui<xiaohui.xin(a)intel.com>
- * Zhang Xiantao<xiantao.zhang(a)intel.com>
- *
- * This work is licensed under the terms of the GNU GPL, version 2 or later.
- * See the COPYING file in the top-level directory.
- *
- */
-
-/*
- * HAX common code for both windows and darwin
- */
-
-#include "qemu/osdep.h"
-#include "cpu.h"
-#include "exec/address-spaces.h"
-
-#include "qemu/accel.h"
-#include "sysemu/reset.h"
-#include "sysemu/runstate.h"
-#include "hw/boards.h"
-
-#include "hax-accel-ops.h"
-
-#define DEBUG_HAX 0
-
-#define DPRINTF(fmt, ...) \
- do { \
- if (DEBUG_HAX) { \
- fprintf(stdout, fmt, ## __VA_ARGS__); \
- } \
- } while (0)
-
-/* Current version */
-const uint32_t hax_cur_version = 0x4; /* API v4: unmapping and MMIO moves */
-/* Minimum HAX kernel version */
-const uint32_t hax_min_version = 0x4; /* API v4: supports unmapping */
-
-bool hax_allowed;
-
-struct hax_state hax_global;
-
-static void hax_vcpu_sync_state(CPUArchState *env, int modified);
-static int hax_arch_get_registers(CPUArchState *env);
-
-int valid_hax_tunnel_size(uint16_t size)
-{
- return size >= sizeof(struct hax_tunnel);
-}
-
-hax_fd hax_vcpu_get_fd(CPUArchState *env)
-{
- AccelCPUState *vcpu = env_cpu(env)->accel;
- if (!vcpu) {
- return HAX_INVALID_FD;
- }
- return vcpu->fd;
-}
-
-static int hax_get_capability(struct hax_state *hax)
-{
- int ret;
- struct hax_capabilityinfo capinfo, *cap = &capinfo;
-
- ret = hax_capability(hax, cap);
- if (ret) {
- return ret;
- }
-
- if ((cap->wstatus & HAX_CAP_WORKSTATUS_MASK) == HAX_CAP_STATUS_NOTWORKING) {
- if (cap->winfo & HAX_CAP_FAILREASON_VT) {
- DPRINTF
- ("VTX feature is not enabled, HAX driver will not work.\n");
- } else if (cap->winfo & HAX_CAP_FAILREASON_NX) {
- DPRINTF
- ("NX feature is not enabled, HAX driver will not work.\n");
- }
- return -ENXIO;
-
- }
-
- if (!(cap->winfo & HAX_CAP_UG)) {
- fprintf(stderr, "UG mode is not supported by the hardware.\n");
- return -ENOTSUP;
- }
-
- hax->supports_64bit_ramblock = !!(cap->winfo & HAX_CAP_64BIT_RAMBLOCK);
-
- if (cap->wstatus & HAX_CAP_MEMQUOTA) {
- if (cap->mem_quota < hax->mem_quota) {
- fprintf(stderr, "The VM memory needed exceeds the driver limit.\n");
- return -ENOSPC;
- }
- }
- return 0;
-}
-
-static int hax_version_support(struct hax_state *hax)
-{
- int ret;
- struct hax_module_version version;
-
- ret = hax_mod_version(hax, &version);
- if (ret < 0) {
- return 0;
- }
-
- if (hax_min_version > version.cur_version) {
- fprintf(stderr, "Incompatible HAX module version %d,",
- version.cur_version);
- fprintf(stderr, "requires minimum version %d\n", hax_min_version);
- return 0;
- }
- if (hax_cur_version < version.compat_version) {
- fprintf(stderr, "Incompatible QEMU HAX API version %x,",
- hax_cur_version);
- fprintf(stderr, "requires minimum HAX API version %x\n",
- version.compat_version);
- return 0;
- }
-
- return 1;
-}
-
-int hax_vcpu_create(int id)
-{
- AccelCPUState *vcpu = NULL;
- int ret;
-
- if (!hax_global.vm) {
- fprintf(stderr, "vcpu %x created failed, vm is null\n", id);
- return -1;
- }
-
- if (hax_global.vm->vcpus[id]) {
- fprintf(stderr, "vcpu %x allocated already\n", id);
- return 0;
- }
-
- vcpu = g_new0(AccelCPUState, 1);
-
- ret = hax_host_create_vcpu(hax_global.vm->fd, id);
- if (ret) {
- fprintf(stderr, "Failed to create vcpu %x\n", id);
- goto error;
- }
-
- vcpu->vcpu_id = id;
- vcpu->fd = hax_host_open_vcpu(hax_global.vm->id, id);
- if (hax_invalid_fd(vcpu->fd)) {
- fprintf(stderr, "Failed to open the vcpu\n");
- ret = -ENODEV;
- goto error;
- }
-
- hax_global.vm->vcpus[id] = vcpu;
-
- ret = hax_host_setup_vcpu_channel(vcpu);
- if (ret) {
- fprintf(stderr, "Invalid hax tunnel size\n");
- ret = -EINVAL;
- goto error;
- }
- return 0;
-
- error:
- /* vcpu and tunnel will be closed automatically */
- if (vcpu && !hax_invalid_fd(vcpu->fd)) {
- hax_close_fd(vcpu->fd);
- }
-
- hax_global.vm->vcpus[id] = NULL;
- g_free(vcpu);
- return -1;
-}
-
-int hax_vcpu_destroy(CPUState *cpu)
-{
- AccelCPUState *vcpu = cpu->accel;
-
- if (!hax_global.vm) {
- fprintf(stderr, "vcpu %x destroy failed, vm is null\n", vcpu->vcpu_id);
- return -1;
- }
-
- if (!vcpu) {
- return 0;
- }
-
- /*
- * 1. The hax_tunnel is also destroyed when vcpu is destroyed
- * 2. close fd will cause hax module vcpu be cleaned
- */
- hax_close_fd(vcpu->fd);
- hax_global.vm->vcpus[vcpu->vcpu_id] = NULL;
-#ifdef _WIN32
- CloseHandle(vcpu->hThread);
-#endif
- g_free(vcpu);
- cpu->accel = NULL;
- return 0;
-}
-
-int hax_init_vcpu(CPUState *cpu)
-{
- int ret;
-
- ret = hax_vcpu_create(cpu->cpu_index);
- if (ret < 0) {
- fprintf(stderr, "Failed to create HAX vcpu\n");
- exit(-1);
- }
-
- cpu->accel = hax_global.vm->vcpus[cpu->cpu_index];
- cpu->vcpu_dirty = true;
- qemu_register_reset(hax_reset_vcpu_state, cpu->env_ptr);
-
- return ret;
-}
-
-struct hax_vm *hax_vm_create(struct hax_state *hax, int max_cpus)
-{
- struct hax_vm *vm;
- int vm_id = 0, ret, i;
-
- if (hax_invalid_fd(hax->fd)) {
- return NULL;
- }
-
- if (hax->vm) {
- return hax->vm;
- }
-
- if (max_cpus > HAX_MAX_VCPU) {
- fprintf(stderr, "Maximum VCPU number QEMU supported is %d\n", HAX_MAX_VCPU);
- return NULL;
- }
-
- vm = g_new0(struct hax_vm, 1);
-
- ret = hax_host_create_vm(hax, &vm_id);
- if (ret) {
- fprintf(stderr, "Failed to create vm %x\n", ret);
- goto error;
- }
- vm->id = vm_id;
- vm->fd = hax_host_open_vm(hax, vm_id);
- if (hax_invalid_fd(vm->fd)) {
- fprintf(stderr, "Failed to open vm %d\n", vm_id);
- goto error;
- }
-
- vm->numvcpus = max_cpus;
- vm->vcpus = g_new0(AccelCPUState *, vm->numvcpus);
- for (i = 0; i < vm->numvcpus; i++) {
- vm->vcpus[i] = NULL;
- }
-
- hax->vm = vm;
- return vm;
-
- error:
- g_free(vm);
- hax->vm = NULL;
- return NULL;
-}
-
-int hax_vm_destroy(struct hax_vm *vm)
-{
- int i;
-
- for (i = 0; i < vm->numvcpus; i++)
- if (vm->vcpus[i]) {
- fprintf(stderr, "VCPU should be cleaned before vm clean\n");
- return -1;
- }
- hax_close_fd(vm->fd);
- vm->numvcpus = 0;
- g_free(vm->vcpus);
- g_free(vm);
- hax_global.vm = NULL;
- return 0;
-}
-
-static int hax_init(ram_addr_t ram_size, int max_cpus)
-{
- struct hax_state *hax = NULL;
- struct hax_qemu_version qversion;
- int ret;
-
- hax = &hax_global;
-
- memset(hax, 0, sizeof(struct hax_state));
- hax->mem_quota = ram_size;
-
- hax->fd = hax_mod_open();
- if (hax_invalid_fd(hax->fd)) {
- hax->fd = 0;
- ret = -ENODEV;
- goto error;
- }
-
- ret = hax_get_capability(hax);
-
- if (ret) {
- if (ret != -ENOSPC) {
- ret = -EINVAL;
- }
- goto error;
- }
-
- if (!hax_version_support(hax)) {
- ret = -EINVAL;
- goto error;
- }
-
- hax->vm = hax_vm_create(hax, max_cpus);
- if (!hax->vm) {
- fprintf(stderr, "Failed to create HAX VM\n");
- ret = -EINVAL;
- goto error;
- }
-
- hax_memory_init();
-
- qversion.cur_version = hax_cur_version;
- qversion.min_version = hax_min_version;
- hax_notify_qemu_version(hax->vm->fd, &qversion);
-
- return ret;
- error:
- if (hax->vm) {
- hax_vm_destroy(hax->vm);
- }
- if (hax->fd) {
- hax_mod_close(hax);
- }
-
- return ret;
-}
-
-static int hax_accel_init(MachineState *ms)
-{
- int ret = hax_init(ms->ram_size, (int)ms->smp.max_cpus);
-
- if (ret && (ret != -ENOSPC)) {
- fprintf(stderr, "No accelerator found.\n");
- } else {
- fprintf(stdout, "HAX is %s and emulator runs in %s mode.\n",
- !ret ? "working" : "not working",
- !ret ? "fast virt" : "emulation");
- fprintf(stdout,
- "NOTE: HAX is deprecated and will be removed in a future release.\n"
- " Use 'whpx' (on Windows) or 'hvf' (on macOS) instead.\n");
- }
- return ret;
-}
-
-static int hax_handle_fastmmio(CPUArchState *env, struct hax_fastmmio *hft)
-{
- if (hft->direction < 2) {
- cpu_physical_memory_rw(hft->gpa, &hft->value, hft->size,
- hft->direction);
- } else {
- /*
- * HAX API v4 supports transferring data between two MMIO addresses,
- * hft->gpa and hft->gpa2 (instructions such as MOVS require this):
- * hft->direction == 2: gpa ==> gpa2
- */
- uint64_t value;
- cpu_physical_memory_read(hft->gpa, &value, hft->size);
- cpu_physical_memory_write(hft->gpa2, &value, hft->size);
- }
-
- return 0;
-}
-
-static int hax_handle_io(CPUArchState *env, uint32_t df, uint16_t port,
- int direction, int size, int count, void *buffer)
-{
- uint8_t *ptr;
- int i;
- MemTxAttrs attrs = { 0 };
-
- if (!df) {
- ptr = buffer;
- } else {
- ptr = buffer + size * count - size;
- }
- for (i = 0; i < count; i++) {
- address_space_rw(&address_space_io, port, attrs,
- ptr, size, direction == HAX_EXIT_IO_OUT);
- if (!df) {
- ptr += size;
- } else {
- ptr -= size;
- }
- }
-
- return 0;
-}
-
-static int hax_vcpu_interrupt(CPUArchState *env)
-{
- CPUState *cpu = env_cpu(env);
- AccelCPUState *vcpu = cpu->accel;
- struct hax_tunnel *ht = vcpu->tunnel;
-
- /*
- * Try to inject an interrupt if the guest can accept it
- * Unlike KVM, HAX kernel check for the eflags, instead of qemu
- */
- if (ht->ready_for_interrupt_injection &&
- (cpu->interrupt_request & CPU_INTERRUPT_HARD)) {
- int irq;
-
- irq = cpu_get_pic_interrupt(env);
- if (irq >= 0) {
- hax_inject_interrupt(env, irq);
- cpu->interrupt_request &= ~CPU_INTERRUPT_HARD;
- }
- }
-
- /* If we have an interrupt but the guest is not ready to receive an
- * interrupt, request an interrupt window exit. This will
- * cause a return to userspace as soon as the guest is ready to
- * receive interrupts. */
- if ((cpu->interrupt_request & CPU_INTERRUPT_HARD)) {
- ht->request_interrupt_window = 1;
- } else {
- ht->request_interrupt_window = 0;
- }
- return 0;
-}
-
-void hax_raise_event(CPUState *cpu)
-{
- AccelCPUState *vcpu = cpu->accel;
-
- if (!vcpu) {
- return;
- }
- vcpu->tunnel->user_event_pending = 1;
-}
-
-/*
- * Ask hax kernel module to run the CPU for us till:
- * 1. Guest crash or shutdown
- * 2. Need QEMU's emulation like guest execute MMIO instruction
- * 3. Guest execute HLT
- * 4. QEMU have Signal/event pending
- * 5. An unknown VMX exit happens
- */
-static int hax_vcpu_hax_exec(CPUArchState *env)
-{
- int ret = 0;
- CPUState *cpu = env_cpu(env);
- X86CPU *x86_cpu = X86_CPU(cpu);
- AccelCPUState *vcpu = cpu->accel;
- struct hax_tunnel *ht = vcpu->tunnel;
-
- if (!hax_enabled()) {
- DPRINTF("Trying to vcpu execute at eip:" TARGET_FMT_lx "\n", env->eip);
- return 0;
- }
-
- if (cpu->interrupt_request & CPU_INTERRUPT_POLL) {
- cpu->interrupt_request &= ~CPU_INTERRUPT_POLL;
- apic_poll_irq(x86_cpu->apic_state);
- }
-
- /* After a vcpu is halted (either because it is an AP and has just been
- * reset, or because it has executed the HLT instruction), it will not be
- * run (hax_vcpu_run()) until it is unhalted. The next few if blocks check
- * for events that may change the halted state of this vcpu:
- * a) Maskable interrupt, when RFLAGS.IF is 1;
- * Note: env->eflags may not reflect the current RFLAGS state, because
- * it is not updated after each hax_vcpu_run(). We cannot afford
- * to fail to recognize any unhalt-by-maskable-interrupt event
- * (in which case the vcpu will halt forever), and yet we cannot
- * afford the overhead of hax_vcpu_sync_state(). The current
- * solution is to err on the side of caution and have the HLT
- * handler (see case HAX_EXIT_HLT below) unconditionally set the
- * IF_MASK bit in env->eflags, which, in effect, disables the
- * RFLAGS.IF check.
- * b) NMI;
- * c) INIT signal;
- * d) SIPI signal.
- */
- if (((cpu->interrupt_request & CPU_INTERRUPT_HARD) &&
- (env->eflags & IF_MASK)) ||
- (cpu->interrupt_request & CPU_INTERRUPT_NMI)) {
- cpu->halted = 0;
- }
-
- if (cpu->interrupt_request & CPU_INTERRUPT_INIT) {
- DPRINTF("\nhax_vcpu_hax_exec: handling INIT for %d\n",
- cpu->cpu_index);
- do_cpu_init(x86_cpu);
- hax_vcpu_sync_state(env, 1);
- }
-
- if (cpu->interrupt_request & CPU_INTERRUPT_SIPI) {
- DPRINTF("hax_vcpu_hax_exec: handling SIPI for %d\n",
- cpu->cpu_index);
- hax_vcpu_sync_state(env, 0);
- do_cpu_sipi(x86_cpu);
- hax_vcpu_sync_state(env, 1);
- }
-
- if (cpu->halted) {
- /* If this vcpu is halted, we must not ask HAXM to run it. Instead, we
- * break out of hax_smp_cpu_exec() as if this vcpu had executed HLT.
- * That way, this vcpu thread will be trapped in qemu_wait_io_event(),
- * until the vcpu is unhalted.
- */
- cpu->exception_index = EXCP_HLT;
- return 0;
- }
-
- do {
- int hax_ret;
-
- if (cpu->exit_request) {
- ret = 1;
- break;
- }
-
- hax_vcpu_interrupt(env);
-
- qemu_mutex_unlock_iothread();
- cpu_exec_start(cpu);
- hax_ret = hax_vcpu_run(vcpu);
- cpu_exec_end(cpu);
- qemu_mutex_lock_iothread();
-
- /* Simply continue the vcpu_run if system call interrupted */
- if (hax_ret == -EINTR || hax_ret == -EAGAIN) {
- DPRINTF("io window interrupted\n");
- continue;
- }
-
- if (hax_ret < 0) {
- fprintf(stderr, "vcpu run failed for vcpu %x\n", vcpu->vcpu_id);
- abort();
- }
- switch (ht->_exit_status) {
- case HAX_EXIT_IO:
- ret = hax_handle_io(env, ht->pio._df, ht->pio._port,
- ht->pio._direction,
- ht->pio._size, ht->pio._count, vcpu->iobuf);
- break;
- case HAX_EXIT_FAST_MMIO:
- ret = hax_handle_fastmmio(env, (struct hax_fastmmio *) vcpu->iobuf);
- break;
- /* Guest state changed, currently only for shutdown */
- case HAX_EXIT_STATECHANGE:
- fprintf(stdout, "VCPU shutdown request\n");
- qemu_system_shutdown_request(SHUTDOWN_CAUSE_GUEST_SHUTDOWN);
- hax_vcpu_sync_state(env, 0);
- ret = 1;
- break;
- case HAX_EXIT_UNKNOWN_VMEXIT:
- fprintf(stderr, "Unknown VMX exit %x from guest\n",
- ht->_exit_reason);
- qemu_system_reset_request(SHUTDOWN_CAUSE_GUEST_RESET);
- hax_vcpu_sync_state(env, 0);
- cpu_dump_state(cpu, stderr, 0);
- ret = -1;
- break;
- case HAX_EXIT_HLT:
- if (!(cpu->interrupt_request & CPU_INTERRUPT_HARD) &&
- !(cpu->interrupt_request & CPU_INTERRUPT_NMI)) {
- /* hlt instruction with interrupt disabled is shutdown */
- env->eflags |= IF_MASK;
- cpu->halted = 1;
- cpu->exception_index = EXCP_HLT;
- ret = 1;
- }
- break;
- /* these situations will continue to hax module */
- case HAX_EXIT_INTERRUPT:
- case HAX_EXIT_PAUSED:
- break;
- case HAX_EXIT_MMIO:
- /* Should not happen on UG system */
- fprintf(stderr, "HAX: unsupported MMIO emulation\n");
- ret = -1;
- break;
- case HAX_EXIT_REAL:
- /* Should not happen on UG system */
- fprintf(stderr, "HAX: unimplemented real mode emulation\n");
- ret = -1;
- break;
- default:
- fprintf(stderr, "Unknown exit %x from HAX\n", ht->_exit_status);
- qemu_system_reset_request(SHUTDOWN_CAUSE_GUEST_RESET);
- hax_vcpu_sync_state(env, 0);
- cpu_dump_state(cpu, stderr, 0);
- ret = 1;
- break;
- }
- } while (!ret);
-
- if (cpu->exit_request) {
- cpu->exit_request = 0;
- cpu->exception_index = EXCP_INTERRUPT;
- }
- return ret < 0;
-}
-
-static void do_hax_cpu_synchronize_state(CPUState *cpu, run_on_cpu_data arg)
-{
- CPUArchState *env = cpu->env_ptr;
-
- hax_arch_get_registers(env);
- cpu->vcpu_dirty = true;
-}
-
-void hax_cpu_synchronize_state(CPUState *cpu)
-{
- if (!cpu->vcpu_dirty) {
- run_on_cpu(cpu, do_hax_cpu_synchronize_state, RUN_ON_CPU_NULL);
- }
-}
-
-static void do_hax_cpu_synchronize_post_reset(CPUState *cpu,
- run_on_cpu_data arg)
-{
- CPUArchState *env = cpu->env_ptr;
-
- hax_vcpu_sync_state(env, 1);
- cpu->vcpu_dirty = false;
-}
-
-void hax_cpu_synchronize_post_reset(CPUState *cpu)
-{
- run_on_cpu(cpu, do_hax_cpu_synchronize_post_reset, RUN_ON_CPU_NULL);
-}
-
-static void do_hax_cpu_synchronize_post_init(CPUState *cpu, run_on_cpu_data arg)
-{
- CPUArchState *env = cpu->env_ptr;
-
- hax_vcpu_sync_state(env, 1);
- cpu->vcpu_dirty = false;
-}
-
-void hax_cpu_synchronize_post_init(CPUState *cpu)
-{
- run_on_cpu(cpu, do_hax_cpu_synchronize_post_init, RUN_ON_CPU_NULL);
-}
-
-static void do_hax_cpu_synchronize_pre_loadvm(CPUState *cpu, run_on_cpu_data arg)
-{
- cpu->vcpu_dirty = true;
-}
-
-void hax_cpu_synchronize_pre_loadvm(CPUState *cpu)
-{
- run_on_cpu(cpu, do_hax_cpu_synchronize_pre_loadvm, RUN_ON_CPU_NULL);
-}
-
-int hax_smp_cpu_exec(CPUState *cpu)
-{
- CPUArchState *env = cpu->env_ptr;
- int fatal;
- int ret;
-
- while (1) {
- if (cpu->exception_index >= EXCP_INTERRUPT) {
- ret = cpu->exception_index;
- cpu->exception_index = -1;
- break;
- }
-
- fatal = hax_vcpu_hax_exec(env);
-
- if (fatal) {
- fprintf(stderr, "Unsupported HAX vcpu return\n");
- abort();
- }
- }
-
- return ret;
-}
-
-static void set_v8086_seg(struct segment_desc_t *lhs, const SegmentCache *rhs)
-{
- memset(lhs, 0, sizeof(struct segment_desc_t));
- lhs->selector = rhs->selector;
- lhs->base = rhs->base;
- lhs->limit = rhs->limit;
- lhs->type = 3;
- lhs->present = 1;
- lhs->dpl = 3;
- lhs->operand_size = 0;
- lhs->desc = 1;
- lhs->long_mode = 0;
- lhs->granularity = 0;
- lhs->available = 0;
-}
-
-static void get_seg(SegmentCache *lhs, const struct segment_desc_t *rhs)
-{
- lhs->selector = rhs->selector;
- lhs->base = rhs->base;
- lhs->limit = rhs->limit;
- lhs->flags = (rhs->type << DESC_TYPE_SHIFT)
- | (rhs->present * DESC_P_MASK)
- | (rhs->dpl << DESC_DPL_SHIFT)
- | (rhs->operand_size << DESC_B_SHIFT)
- | (rhs->desc * DESC_S_MASK)
- | (rhs->long_mode << DESC_L_SHIFT)
- | (rhs->granularity * DESC_G_MASK) | (rhs->available * DESC_AVL_MASK);
-}
-
-static void set_seg(struct segment_desc_t *lhs, const SegmentCache *rhs)
-{
- unsigned flags = rhs->flags;
-
- memset(lhs, 0, sizeof(struct segment_desc_t));
- lhs->selector = rhs->selector;
- lhs->base = rhs->base;
- lhs->limit = rhs->limit;
- lhs->type = (flags >> DESC_TYPE_SHIFT) & 15;
- lhs->present = (flags & DESC_P_MASK) != 0;
- lhs->dpl = rhs->selector & 3;
- lhs->operand_size = (flags >> DESC_B_SHIFT) & 1;
- lhs->desc = (flags & DESC_S_MASK) != 0;
- lhs->long_mode = (flags >> DESC_L_SHIFT) & 1;
- lhs->granularity = (flags & DESC_G_MASK) != 0;
- lhs->available = (flags & DESC_AVL_MASK) != 0;
-}
-
-static void hax_getput_reg(uint64_t *hax_reg, target_ulong *qemu_reg, int set)
-{
- target_ulong reg = *hax_reg;
-
- if (set) {
- *hax_reg = *qemu_reg;
- } else {
- *qemu_reg = reg;
- }
-}
-
-/* The sregs has been synced with HAX kernel already before this call */
-static int hax_get_segments(CPUArchState *env, struct vcpu_state_t *sregs)
-{
- get_seg(&env->segs[R_CS], &sregs->_cs);
- get_seg(&env->segs[R_DS], &sregs->_ds);
- get_seg(&env->segs[R_ES], &sregs->_es);
- get_seg(&env->segs[R_FS], &sregs->_fs);
- get_seg(&env->segs[R_GS], &sregs->_gs);
- get_seg(&env->segs[R_SS], &sregs->_ss);
-
- get_seg(&env->tr, &sregs->_tr);
- get_seg(&env->ldt, &sregs->_ldt);
- env->idt.limit = sregs->_idt.limit;
- env->idt.base = sregs->_idt.base;
- env->gdt.limit = sregs->_gdt.limit;
- env->gdt.base = sregs->_gdt.base;
- return 0;
-}
-
-static int hax_set_segments(CPUArchState *env, struct vcpu_state_t *sregs)
-{
- if ((env->eflags & VM_MASK)) {
- set_v8086_seg(&sregs->_cs, &env->segs[R_CS]);
- set_v8086_seg(&sregs->_ds, &env->segs[R_DS]);
- set_v8086_seg(&sregs->_es, &env->segs[R_ES]);
- set_v8086_seg(&sregs->_fs, &env->segs[R_FS]);
- set_v8086_seg(&sregs->_gs, &env->segs[R_GS]);
- set_v8086_seg(&sregs->_ss, &env->segs[R_SS]);
- } else {
- set_seg(&sregs->_cs, &env->segs[R_CS]);
- set_seg(&sregs->_ds, &env->segs[R_DS]);
- set_seg(&sregs->_es, &env->segs[R_ES]);
- set_seg(&sregs->_fs, &env->segs[R_FS]);
- set_seg(&sregs->_gs, &env->segs[R_GS]);
- set_seg(&sregs->_ss, &env->segs[R_SS]);
-
- if (env->cr[0] & CR0_PE_MASK) {
- /* force ss cpl to cs cpl */
- sregs->_ss.selector = (sregs->_ss.selector & ~3) |
- (sregs->_cs.selector & 3);
- sregs->_ss.dpl = sregs->_ss.selector & 3;
- }
- }
-
- set_seg(&sregs->_tr, &env->tr);
- set_seg(&sregs->_ldt, &env->ldt);
- sregs->_idt.limit = env->idt.limit;
- sregs->_idt.base = env->idt.base;
- sregs->_gdt.limit = env->gdt.limit;
- sregs->_gdt.base = env->gdt.base;
- return 0;
-}
-
-static int hax_sync_vcpu_register(CPUArchState *env, int set)
-{
- struct vcpu_state_t regs;
- int ret;
- memset(®s, 0, sizeof(struct vcpu_state_t));
-
- if (!set) {
- ret = hax_sync_vcpu_state(env, ®s, 0);
- if (ret < 0) {
- return -1;
- }
- }
-
- /* generic register */
- hax_getput_reg(®s._rax, &env->regs[R_EAX], set);
- hax_getput_reg(®s._rbx, &env->regs[R_EBX], set);
- hax_getput_reg(®s._rcx, &env->regs[R_ECX], set);
- hax_getput_reg(®s._rdx, &env->regs[R_EDX], set);
- hax_getput_reg(®s._rsi, &env->regs[R_ESI], set);
- hax_getput_reg(®s._rdi, &env->regs[R_EDI], set);
- hax_getput_reg(®s._rsp, &env->regs[R_ESP], set);
- hax_getput_reg(®s._rbp, &env->regs[R_EBP], set);
-#ifdef TARGET_X86_64
- hax_getput_reg(®s._r8, &env->regs[8], set);
- hax_getput_reg(®s._r9, &env->regs[9], set);
- hax_getput_reg(®s._r10, &env->regs[10], set);
- hax_getput_reg(®s._r11, &env->regs[11], set);
- hax_getput_reg(®s._r12, &env->regs[12], set);
- hax_getput_reg(®s._r13, &env->regs[13], set);
- hax_getput_reg(®s._r14, &env->regs[14], set);
- hax_getput_reg(®s._r15, &env->regs[15], set);
-#endif
- hax_getput_reg(®s._rflags, &env->eflags, set);
- hax_getput_reg(®s._rip, &env->eip, set);
-
- if (set) {
- regs._cr0 = env->cr[0];
- regs._cr2 = env->cr[2];
- regs._cr3 = env->cr[3];
- regs._cr4 = env->cr[4];
- hax_set_segments(env, ®s);
- } else {
- env->cr[0] = regs._cr0;
- env->cr[2] = regs._cr2;
- env->cr[3] = regs._cr3;
- env->cr[4] = regs._cr4;
- hax_get_segments(env, ®s);
- }
-
- if (set) {
- ret = hax_sync_vcpu_state(env, ®s, 1);
- if (ret < 0) {
- return -1;
- }
- }
- return 0;
-}
-
-static void hax_msr_entry_set(struct vmx_msr *item, uint32_t index,
- uint64_t value)
-{
- item->entry = index;
- item->value = value;
-}
-
-static int hax_get_msrs(CPUArchState *env)
-{
- struct hax_msr_data md;
- struct vmx_msr *msrs = md.entries;
- int ret, i, n;
-
- n = 0;
- msrs[n++].entry = MSR_IA32_SYSENTER_CS;
- msrs[n++].entry = MSR_IA32_SYSENTER_ESP;
- msrs[n++].entry = MSR_IA32_SYSENTER_EIP;
- msrs[n++].entry = MSR_IA32_TSC;
-#ifdef TARGET_X86_64
- msrs[n++].entry = MSR_EFER;
- msrs[n++].entry = MSR_STAR;
- msrs[n++].entry = MSR_LSTAR;
- msrs[n++].entry = MSR_CSTAR;
- msrs[n++].entry = MSR_FMASK;
- msrs[n++].entry = MSR_KERNELGSBASE;
-#endif
- md.nr_msr = n;
- ret = hax_sync_msr(env, &md, 0);
- if (ret < 0) {
- return ret;
- }
-
- for (i = 0; i < md.done; i++) {
- switch (msrs[i].entry) {
- case MSR_IA32_SYSENTER_CS:
- env->sysenter_cs = msrs[i].value;
- break;
- case MSR_IA32_SYSENTER_ESP:
- env->sysenter_esp = msrs[i].value;
- break;
- case MSR_IA32_SYSENTER_EIP:
- env->sysenter_eip = msrs[i].value;
- break;
- case MSR_IA32_TSC:
- env->tsc = msrs[i].value;
- break;
-#ifdef TARGET_X86_64
- case MSR_EFER:
- env->efer = msrs[i].value;
- break;
- case MSR_STAR:
- env->star = msrs[i].value;
- break;
- case MSR_LSTAR:
- env->lstar = msrs[i].value;
- break;
- case MSR_CSTAR:
- env->cstar = msrs[i].value;
- break;
- case MSR_FMASK:
- env->fmask = msrs[i].value;
- break;
- case MSR_KERNELGSBASE:
- env->kernelgsbase = msrs[i].value;
- break;
-#endif
- }
- }
-
- return 0;
-}
-
-static int hax_set_msrs(CPUArchState *env)
-{
- struct hax_msr_data md;
- struct vmx_msr *msrs;
- msrs = md.entries;
- int n = 0;
-
- memset(&md, 0, sizeof(struct hax_msr_data));
- hax_msr_entry_set(&msrs[n++], MSR_IA32_SYSENTER_CS, env->sysenter_cs);
- hax_msr_entry_set(&msrs[n++], MSR_IA32_SYSENTER_ESP, env->sysenter_esp);
- hax_msr_entry_set(&msrs[n++], MSR_IA32_SYSENTER_EIP, env->sysenter_eip);
- hax_msr_entry_set(&msrs[n++], MSR_IA32_TSC, env->tsc);
-#ifdef TARGET_X86_64
- hax_msr_entry_set(&msrs[n++], MSR_EFER, env->efer);
- hax_msr_entry_set(&msrs[n++], MSR_STAR, env->star);
- hax_msr_entry_set(&msrs[n++], MSR_LSTAR, env->lstar);
- hax_msr_entry_set(&msrs[n++], MSR_CSTAR, env->cstar);
- hax_msr_entry_set(&msrs[n++], MSR_FMASK, env->fmask);
- hax_msr_entry_set(&msrs[n++], MSR_KERNELGSBASE, env->kernelgsbase);
-#endif
- md.nr_msr = n;
- md.done = 0;
-
- return hax_sync_msr(env, &md, 1);
-}
-
-static int hax_get_fpu(CPUArchState *env)
-{
- struct fx_layout fpu;
- int i, ret;
-
- ret = hax_sync_fpu(env, &fpu, 0);
- if (ret < 0) {
- return ret;
- }
-
- env->fpstt = (fpu.fsw >> 11) & 7;
- env->fpus = fpu.fsw;
- env->fpuc = fpu.fcw;
- for (i = 0; i < 8; ++i) {
- env->fptags[i] = !((fpu.ftw >> i) & 1);
- }
- memcpy(env->fpregs, fpu.st_mm, sizeof(env->fpregs));
-
- for (i = 0; i < 8; i++) {
- env->xmm_regs[i].ZMM_Q(0) = ldq_p(&fpu.mmx_1[i][0]);
- env->xmm_regs[i].ZMM_Q(1) = ldq_p(&fpu.mmx_1[i][8]);
- if (CPU_NB_REGS > 8) {
- env->xmm_regs[i + 8].ZMM_Q(0) = ldq_p(&fpu.mmx_2[i][0]);
- env->xmm_regs[i + 8].ZMM_Q(1) = ldq_p(&fpu.mmx_2[i][8]);
- }
- }
- env->mxcsr = fpu.mxcsr;
-
- return 0;
-}
-
-static int hax_set_fpu(CPUArchState *env)
-{
- struct fx_layout fpu;
- int i;
-
- memset(&fpu, 0, sizeof(fpu));
- fpu.fsw = env->fpus & ~(7 << 11);
- fpu.fsw |= (env->fpstt & 7) << 11;
- fpu.fcw = env->fpuc;
-
- for (i = 0; i < 8; ++i) {
- fpu.ftw |= (!env->fptags[i]) << i;
- }
-
- memcpy(fpu.st_mm, env->fpregs, sizeof(env->fpregs));
- for (i = 0; i < 8; i++) {
- stq_p(&fpu.mmx_1[i][0], env->xmm_regs[i].ZMM_Q(0));
- stq_p(&fpu.mmx_1[i][8], env->xmm_regs[i].ZMM_Q(1));
- if (CPU_NB_REGS > 8) {
- stq_p(&fpu.mmx_2[i][0], env->xmm_regs[i + 8].ZMM_Q(0));
- stq_p(&fpu.mmx_2[i][8], env->xmm_regs[i + 8].ZMM_Q(1));
- }
- }
-
- fpu.mxcsr = env->mxcsr;
-
- return hax_sync_fpu(env, &fpu, 1);
-}
-
-static int hax_arch_get_registers(CPUArchState *env)
-{
- int ret;
-
- ret = hax_sync_vcpu_register(env, 0);
- if (ret < 0) {
- return ret;
- }
-
- ret = hax_get_fpu(env);
- if (ret < 0) {
- return ret;
- }
-
- ret = hax_get_msrs(env);
- if (ret < 0) {
- return ret;
- }
-
- x86_update_hflags(env);
- return 0;
-}
-
-static int hax_arch_set_registers(CPUArchState *env)
-{
- int ret;
- ret = hax_sync_vcpu_register(env, 1);
-
- if (ret < 0) {
- fprintf(stderr, "Failed to sync vcpu reg\n");
- return ret;
- }
- ret = hax_set_fpu(env);
- if (ret < 0) {
- fprintf(stderr, "FPU failed\n");
- return ret;
- }
- ret = hax_set_msrs(env);
- if (ret < 0) {
- fprintf(stderr, "MSR failed\n");
- return ret;
- }
-
- return 0;
-}
-
-static void hax_vcpu_sync_state(CPUArchState *env, int modified)
-{
- if (hax_enabled()) {
- if (modified) {
- hax_arch_set_registers(env);
- } else {
- hax_arch_get_registers(env);
- }
- }
-}
-
-/*
- * much simpler than kvm, at least in first stage because:
- * We don't need consider the device pass-through, we don't need
- * consider the framebuffer, and we may even remove the bios at all
- */
-int hax_sync_vcpus(void)
-{
- if (hax_enabled()) {
- CPUState *cpu;
-
- cpu = first_cpu;
- if (!cpu) {
- return 0;
- }
-
- for (; cpu != NULL; cpu = CPU_NEXT(cpu)) {
- int ret;
-
- ret = hax_arch_set_registers(cpu->env_ptr);
- if (ret < 0) {
- return ret;
- }
- }
- }
-
- return 0;
-}
-
-void hax_reset_vcpu_state(void *opaque)
-{
- CPUState *cpu;
- for (cpu = first_cpu; cpu != NULL; cpu = CPU_NEXT(cpu)) {
- cpu->accel->tunnel->user_event_pending = 0;
- cpu->accel->tunnel->ready_for_interrupt_injection = 0;
- }
-}
-
-static void hax_accel_class_init(ObjectClass *oc, void *data)
-{
- AccelClass *ac = ACCEL_CLASS(oc);
- ac->name = "HAX";
- ac->init_machine = hax_accel_init;
- ac->allowed = &hax_allowed;
-}
-
-static const TypeInfo hax_accel_type = {
- .name = ACCEL_CLASS_NAME("hax"),
- .parent = TYPE_ACCEL,
- .class_init = hax_accel_class_init,
-};
-
-static void hax_type_init(void)
-{
- type_register_static(&hax_accel_type);
-}
-
-type_init(hax_type_init);
diff --git a/target/i386/hax/hax-mem.c b/target/i386/hax/hax-mem.c
deleted file mode 100644
index bb5ffbc9ac..0000000000
--- a/target/i386/hax/hax-mem.c
+++ /dev/null
@@ -1,323 +0,0 @@
-/*
- * HAX memory mapping operations
- *
- * Copyright (c) 2015-16 Intel Corporation
- * Copyright 2016 Google, Inc.
- *
- * This work is licensed under the terms of the GNU GPL, version 2. See
- * the COPYING file in the top-level directory.
- */
-
-#include "qemu/osdep.h"
-#include "cpu.h"
-#include "exec/address-spaces.h"
-#include "qemu/error-report.h"
-
-#include "hax-accel-ops.h"
-#include "qemu/queue.h"
-
-#define DEBUG_HAX_MEM 0
-
-#define DPRINTF(fmt, ...) \
- do { \
- if (DEBUG_HAX_MEM) { \
- fprintf(stdout, fmt, ## __VA_ARGS__); \
- } \
- } while (0)
-
-/**
- * HAXMapping: describes a pending guest physical memory mapping
- *
- * @start_pa: a guest physical address marking the start of the region; must be
- * page-aligned
- * @size: a guest physical address marking the end of the region; must be
- * page-aligned
- * @host_va: the host virtual address of the start of the mapping
- * @flags: mapping parameters e.g. HAX_RAM_INFO_ROM or HAX_RAM_INFO_INVALID
- * @entry: additional fields for linking #HAXMapping instances together
- */
-typedef struct HAXMapping {
- uint64_t start_pa;
- uint32_t size;
- uint64_t host_va;
- int flags;
- QTAILQ_ENTRY(HAXMapping) entry;
-} HAXMapping;
-
-/*
- * A doubly-linked list (actually a tail queue) of the pending page mappings
- * for the ongoing memory transaction.
- *
- * It is used to optimize the number of page mapping updates done through the
- * kernel module. For example, it's effective when a driver is digging an MMIO
- * hole inside an existing memory mapping. It will get a deletion of the whole
- * region, then the addition of the 2 remaining RAM areas around the hole and
- * finally the memory transaction commit. During the commit, it will effectively
- * send to the kernel only the removal of the pages from the MMIO hole after
- * having computed locally the result of the deletion and additions.
- */
-static QTAILQ_HEAD(, HAXMapping) mappings =
- QTAILQ_HEAD_INITIALIZER(mappings);
-
-/**
- * hax_mapping_dump_list: dumps @mappings to stdout (for debugging)
- */
-static void hax_mapping_dump_list(void)
-{
- HAXMapping *entry;
-
- DPRINTF("%s updates:\n", __func__);
- QTAILQ_FOREACH(entry, &mappings, entry) {
- DPRINTF("\t%c 0x%016" PRIx64 "->0x%016" PRIx64 " VA 0x%016" PRIx64
- "%s\n", entry->flags & HAX_RAM_INFO_INVALID ? '-' : '+',
- entry->start_pa, entry->start_pa + entry->size, entry->host_va,
- entry->flags & HAX_RAM_INFO_ROM ? " ROM" : "");
- }
-}
-
-static void hax_insert_mapping_before(HAXMapping *next, uint64_t start_pa,
- uint32_t size, uint64_t host_va,
- uint8_t flags)
-{
- HAXMapping *entry;
-
- entry = g_malloc0(sizeof(*entry));
- entry->start_pa = start_pa;
- entry->size = size;
- entry->host_va = host_va;
- entry->flags = flags;
- if (!next) {
- QTAILQ_INSERT_TAIL(&mappings, entry, entry);
- } else {
- QTAILQ_INSERT_BEFORE(next, entry, entry);
- }
-}
-
-static bool hax_mapping_is_opposite(HAXMapping *entry, uint64_t host_va,
- uint8_t flags)
-{
- /* removed then added without change for the read-only flag */
- bool nop_flags = (entry->flags ^ flags) == HAX_RAM_INFO_INVALID;
-
- return (entry->host_va == host_va) && nop_flags;
-}
-
-static void hax_update_mapping(uint64_t start_pa, uint32_t size,
- uint64_t host_va, uint8_t flags)
-{
- uint64_t end_pa = start_pa + size;
- HAXMapping *entry, *next;
-
- QTAILQ_FOREACH_SAFE(entry, &mappings, entry, next) {
- uint32_t chunk_sz;
- if (start_pa >= entry->start_pa + entry->size) {
- continue;
- }
- if (start_pa < entry->start_pa) {
- chunk_sz = end_pa <= entry->start_pa ? size
- : entry->start_pa - start_pa;
- hax_insert_mapping_before(entry, start_pa, chunk_sz,
- host_va, flags);
- start_pa += chunk_sz;
- host_va += chunk_sz;
- size -= chunk_sz;
- } else if (start_pa > entry->start_pa) {
- /* split the existing chunk at start_pa */
- chunk_sz = start_pa - entry->start_pa;
- hax_insert_mapping_before(entry, entry->start_pa, chunk_sz,
- entry->host_va, entry->flags);
- entry->start_pa += chunk_sz;
- entry->host_va += chunk_sz;
- entry->size -= chunk_sz;
- }
- /* now start_pa == entry->start_pa */
- chunk_sz = MIN(size, entry->size);
- if (chunk_sz) {
- bool nop = hax_mapping_is_opposite(entry, host_va, flags);
- bool partial = chunk_sz < entry->size;
- if (partial) {
- /* remove the beginning of the existing chunk */
- entry->start_pa += chunk_sz;
- entry->host_va += chunk_sz;
- entry->size -= chunk_sz;
- if (!nop) {
- hax_insert_mapping_before(entry, start_pa, chunk_sz,
- host_va, flags);
- }
- } else { /* affects the full mapping entry */
- if (nop) { /* no change to this mapping, remove it */
- QTAILQ_REMOVE(&mappings, entry, entry);
- g_free(entry);
- } else { /* update mapping properties */
- entry->host_va = host_va;
- entry->flags = flags;
- }
- }
- start_pa += chunk_sz;
- host_va += chunk_sz;
- size -= chunk_sz;
- }
- if (!size) { /* we are done */
- break;
- }
- }
- if (size) { /* add the leftover */
- hax_insert_mapping_before(NULL, start_pa, size, host_va, flags);
- }
-}
-
-static void hax_process_section(MemoryRegionSection *section, uint8_t flags)
-{
- MemoryRegion *mr = section->mr;
- hwaddr start_pa = section->offset_within_address_space;
- ram_addr_t size = int128_get64(section->size);
- unsigned int delta;
- uint64_t host_va;
- uint32_t max_mapping_size;
-
- /* We only care about RAM and ROM regions */
- if (!memory_region_is_ram(mr)) {
- if (memory_region_is_romd(mr)) {
- /* HAXM kernel module does not support ROMD yet */
- warn_report("Ignoring ROMD region 0x%016" PRIx64 "->0x%016" PRIx64,
- start_pa, start_pa + size);
- }
- return;
- }
-
- /* Adjust start_pa and size so that they are page-aligned. (Cf
- * kvm_set_phys_mem() in kvm-all.c).
- */
- delta = qemu_real_host_page_size() - (start_pa & ~qemu_real_host_page_mask());
- delta &= ~qemu_real_host_page_mask();
- if (delta > size) {
- return;
- }
- start_pa += delta;
- size -= delta;
- size &= qemu_real_host_page_mask();
- if (!size || (start_pa & ~qemu_real_host_page_mask())) {
- return;
- }
-
- host_va = (uintptr_t)memory_region_get_ram_ptr(mr)
- + section->offset_within_region + delta;
- if (memory_region_is_rom(section->mr)) {
- flags |= HAX_RAM_INFO_ROM;
- }
-
- /*
- * The kernel module interface uses 32-bit sizes:
- * https://github.com/intel/haxm/blob/master/API.md#hax_vm_ioctl_set_ram
- *
- * If the mapping size is longer than 32 bits, we can't process it in one
- * call into the kernel. Instead, we split the mapping into smaller ones,
- * and call hax_update_mapping() on each.
- */
- max_mapping_size = UINT32_MAX & qemu_real_host_page_mask();
- while (size > max_mapping_size) {
- hax_update_mapping(start_pa, max_mapping_size, host_va, flags);
- start_pa += max_mapping_size;
- size -= max_mapping_size;
- host_va += max_mapping_size;
- }
- /* Now size <= max_mapping_size */
- hax_update_mapping(start_pa, (uint32_t)size, host_va, flags);
-}
-
-static void hax_region_add(MemoryListener *listener,
- MemoryRegionSection *section)
-{
- memory_region_ref(section->mr);
- hax_process_section(section, 0);
-}
-
-static void hax_region_del(MemoryListener *listener,
- MemoryRegionSection *section)
-{
- hax_process_section(section, HAX_RAM_INFO_INVALID);
- memory_region_unref(section->mr);
-}
-
-static void hax_transaction_begin(MemoryListener *listener)
-{
- g_assert(QTAILQ_EMPTY(&mappings));
-}
-
-static void hax_transaction_commit(MemoryListener *listener)
-{
- if (!QTAILQ_EMPTY(&mappings)) {
- HAXMapping *entry, *next;
-
- if (DEBUG_HAX_MEM) {
- hax_mapping_dump_list();
- }
- QTAILQ_FOREACH_SAFE(entry, &mappings, entry, next) {
- if (entry->flags & HAX_RAM_INFO_INVALID) {
- /* for unmapping, put the values expected by the kernel */
- entry->flags = HAX_RAM_INFO_INVALID;
- entry->host_va = 0;
- }
- if (hax_set_ram(entry->start_pa, entry->size,
- entry->host_va, entry->flags)) {
- fprintf(stderr, "%s: Failed mapping @0x%016" PRIx64 "+0x%"
- PRIx32 " flags %02x\n", __func__, entry->start_pa,
- entry->size, entry->flags);
- }
- QTAILQ_REMOVE(&mappings, entry, entry);
- g_free(entry);
- }
- }
-}
-
-/* currently we fake the dirty bitmap sync, always dirty */
-static void hax_log_sync(MemoryListener *listener,
- MemoryRegionSection *section)
-{
- MemoryRegion *mr = section->mr;
-
- if (!memory_region_is_ram(mr)) {
- /* Skip MMIO regions */
- return;
- }
-
- memory_region_set_dirty(mr, 0, int128_get64(section->size));
-}
-
-static MemoryListener hax_memory_listener = {
- .name = "hax",
- .begin = hax_transaction_begin,
- .commit = hax_transaction_commit,
- .region_add = hax_region_add,
- .region_del = hax_region_del,
- .log_sync = hax_log_sync,
- .priority = MEMORY_LISTENER_PRIORITY_ACCEL,
-};
-
-static void hax_ram_block_added(RAMBlockNotifier *n, void *host, size_t size,
- size_t max_size)
-{
- /*
- * We must register each RAM block with the HAXM kernel module, or
- * hax_set_ram() will fail for any mapping into the RAM block:
- * https://github.com/intel/haxm/blob/master/API.md#hax_vm_ioctl_alloc_ram
- *
- * Old versions of the HAXM kernel module (< 6.2.0) used to preallocate all
- * host physical pages for the RAM block as part of this registration
- * process, hence the name hax_populate_ram().
- */
- if (hax_populate_ram((uint64_t)(uintptr_t)host, max_size) < 0) {
- fprintf(stderr, "HAX failed to populate RAM\n");
- abort();
- }
-}
-
-static struct RAMBlockNotifier hax_ram_notifier = {
- .ram_block_added = hax_ram_block_added,
-};
-
-void hax_memory_init(void)
-{
- ram_block_notifier_add(&hax_ram_notifier);
- memory_listener_register(&hax_memory_listener, &address_space_memory);
-}
diff --git a/target/i386/hax/hax-posix.c b/target/i386/hax/hax-posix.c
deleted file mode 100644
index a057a5bd94..0000000000
--- a/target/i386/hax/hax-posix.c
+++ /dev/null
@@ -1,305 +0,0 @@
-/*
- * QEMU HAXM support
- *
- * Copyright (c) 2011 Intel Corporation
- * Written by:
- * Jiang Yunhong<yunhong.jiang(a)intel.com>
- *
- * This work is licensed under the terms of the GNU GPL, version 2 or later.
- * See the COPYING file in the top-level directory.
- *
- */
-
-/* HAX module interface - darwin version */
-#include "qemu/osdep.h"
-#include <sys/ioctl.h>
-
-#include "sysemu/cpus.h"
-#include "hax-accel-ops.h"
-
-hax_fd hax_mod_open(void)
-{
- int fd = open("/dev/HAX", O_RDWR);
- if (fd == -1) {
- fprintf(stderr, "Failed to open the hax module\n");
- }
-
- qemu_set_cloexec(fd);
-
- return fd;
-}
-
-int hax_populate_ram(uint64_t va, uint64_t size)
-{
- int ret;
-
- if (!hax_global.vm || !hax_global.vm->fd) {
- fprintf(stderr, "Allocate memory before vm create?\n");
- return -EINVAL;
- }
-
- if (hax_global.supports_64bit_ramblock) {
- struct hax_ramblock_info ramblock = {
- .start_va = va,
- .size = size,
- .reserved = 0
- };
-
- ret = ioctl(hax_global.vm->fd, HAX_VM_IOCTL_ADD_RAMBLOCK, &ramblock);
- } else {
- struct hax_alloc_ram_info info = {
- .size = (uint32_t)size,
- .pad = 0,
- .va = va
- };
-
- ret = ioctl(hax_global.vm->fd, HAX_VM_IOCTL_ALLOC_RAM, &info);
- }
- if (ret < 0) {
- fprintf(stderr, "Failed to register RAM block: ret=%d, va=0x%" PRIx64
- ", size=0x%" PRIx64 ", method=%s\n", ret, va, size,
- hax_global.supports_64bit_ramblock ? "new" : "legacy");
- return ret;
- }
- return 0;
-}
-
-int hax_set_ram(uint64_t start_pa, uint32_t size, uint64_t host_va, int flags)
-{
- struct hax_set_ram_info info;
- int ret;
-
- info.pa_start = start_pa;
- info.size = size;
- info.va = host_va;
- info.flags = (uint8_t) flags;
-
- ret = ioctl(hax_global.vm->fd, HAX_VM_IOCTL_SET_RAM, &info);
- if (ret < 0) {
- return -errno;
- }
- return 0;
-}
-
-int hax_capability(struct hax_state *hax, struct hax_capabilityinfo *cap)
-{
- int ret;
-
- ret = ioctl(hax->fd, HAX_IOCTL_CAPABILITY, cap);
- if (ret == -1) {
- fprintf(stderr, "Failed to get HAX capability\n");
- return -errno;
- }
-
- return 0;
-}
-
-int hax_mod_version(struct hax_state *hax, struct hax_module_version *version)
-{
- int ret;
-
- ret = ioctl(hax->fd, HAX_IOCTL_VERSION, version);
- if (ret == -1) {
- fprintf(stderr, "Failed to get HAX version\n");
- return -errno;
- }
-
- return 0;
-}
-
-static char *hax_vm_devfs_string(int vm_id)
-{
- return g_strdup_printf("/dev/hax_vm/vm%02d", vm_id);
-}
-
-static char *hax_vcpu_devfs_string(int vm_id, int vcpu_id)
-{
- return g_strdup_printf("/dev/hax_vm%02d/vcpu%02d", vm_id, vcpu_id);
-}
-
-int hax_host_create_vm(struct hax_state *hax, int *vmid)
-{
- int ret;
- int vm_id = 0;
-
- if (hax_invalid_fd(hax->fd)) {
- return -EINVAL;
- }
-
- if (hax->vm) {
- return 0;
- }
-
- ret = ioctl(hax->fd, HAX_IOCTL_CREATE_VM, &vm_id);
- *vmid = vm_id;
- return ret;
-}
-
-hax_fd hax_host_open_vm(struct hax_state *hax, int vm_id)
-{
- hax_fd fd;
- char *vm_name = NULL;
-
- vm_name = hax_vm_devfs_string(vm_id);
- if (!vm_name) {
- return -1;
- }
-
- fd = open(vm_name, O_RDWR);
- g_free(vm_name);
-
- qemu_set_cloexec(fd);
-
- 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 < 0) {
- fprintf(stderr, "Failed to notify qemu API version\n");
- return ret;
- }
- return 0;
-}
-
-/* Simply assume the size should be bigger than the hax_tunnel,
- * since the hax_tunnel can be extended later with compatibility considered
- */
-int hax_host_create_vcpu(hax_fd vm_fd, int vcpuid)
-{
- int ret;
-
- ret = ioctl(vm_fd, HAX_VM_IOCTL_VCPU_CREATE, &vcpuid);
- if (ret < 0) {
- fprintf(stderr, "Failed to create vcpu %x\n", vcpuid);
- }
-
- return ret;
-}
-
-hax_fd hax_host_open_vcpu(int vmid, int vcpuid)
-{
- char *devfs_path = NULL;
- hax_fd fd;
-
- devfs_path = hax_vcpu_devfs_string(vmid, vcpuid);
- if (!devfs_path) {
- fprintf(stderr, "Failed to get the devfs\n");
- return -EINVAL;
- }
-
- fd = open(devfs_path, O_RDWR);
- g_free(devfs_path);
- if (fd < 0) {
- fprintf(stderr, "Failed to open the vcpu devfs\n");
- }
- qemu_set_cloexec(fd);
- return fd;
-}
-
-int hax_host_setup_vcpu_channel(AccelCPUState *vcpu)
-{
- int ret;
- struct hax_tunnel_info info;
-
- ret = ioctl(vcpu->fd, HAX_VCPU_IOCTL_SETUP_TUNNEL, &info);
- if (ret) {
- fprintf(stderr, "Failed to setup the hax tunnel\n");
- return ret;
- }
-
- if (!valid_hax_tunnel_size(info.size)) {
- fprintf(stderr, "Invalid hax tunnel size %x\n", info.size);
- ret = -EINVAL;
- return ret;
- }
-
- vcpu->tunnel = (struct hax_tunnel *) (intptr_t) (info.va);
- vcpu->iobuf = (unsigned char *) (intptr_t) (info.io_va);
- return 0;
-}
-
-int hax_vcpu_run(AccelCPUState *vcpu)
-{
- return ioctl(vcpu->fd, HAX_VCPU_IOCTL_RUN, NULL);
-}
-
-int hax_sync_fpu(CPUArchState *env, struct fx_layout *fl, int set)
-{
- int ret, fd;
-
- fd = hax_vcpu_get_fd(env);
- if (fd <= 0) {
- return -1;
- }
-
- if (set) {
- ret = ioctl(fd, HAX_VCPU_IOCTL_SET_FPU, fl);
- } else {
- ret = ioctl(fd, HAX_VCPU_IOCTL_GET_FPU, fl);
- }
- return ret;
-}
-
-int hax_sync_msr(CPUArchState *env, struct hax_msr_data *msrs, int set)
-{
- int ret, fd;
-
- fd = hax_vcpu_get_fd(env);
- if (fd <= 0) {
- return -1;
- }
- if (set) {
- ret = ioctl(fd, HAX_VCPU_IOCTL_SET_MSRS, msrs);
- } else {
- ret = ioctl(fd, HAX_VCPU_IOCTL_GET_MSRS, msrs);
- }
- return ret;
-}
-
-int hax_sync_vcpu_state(CPUArchState *env, struct vcpu_state_t *state, int set)
-{
- int ret, fd;
-
- fd = hax_vcpu_get_fd(env);
- if (fd <= 0) {
- return -1;
- }
-
- if (set) {
- ret = ioctl(fd, HAX_VCPU_SET_REGS, state);
- } else {
- ret = ioctl(fd, HAX_VCPU_GET_REGS, state);
- }
- return ret;
-}
-
-int hax_inject_interrupt(CPUArchState *env, int vector)
-{
- int fd;
-
- fd = hax_vcpu_get_fd(env);
- if (fd <= 0) {
- return -1;
- }
-
- return ioctl(fd, HAX_VCPU_IOCTL_INTERRUPT, &vector);
-}
-
-void hax_kick_vcpu_thread(CPUState *cpu)
-{
- /*
- * FIXME: race condition with the exit_request check in
- * hax_vcpu_hax_exec
- */
- cpu->exit_request = 1;
- cpus_kick_thread(cpu);
-}
diff --git a/target/i386/hax/hax-windows.c b/target/i386/hax/hax-windows.c
deleted file mode 100644
index 4bf6cc08d2..0000000000
--- a/target/i386/hax/hax-windows.c
+++ /dev/null
@@ -1,485 +0,0 @@
-/*
- * QEMU HAXM support
- *
- * Copyright (c) 2011 Intel Corporation
- * Written by:
- * Jiang Yunhong<yunhong.jiang(a)intel.com>
- *
- * This work is licensed under the terms of the GNU GPL, version 2 or later.
- * See the COPYING file in the top-level directory.
- *
- */
-
-#include "qemu/osdep.h"
-#include "cpu.h"
-#include "hax-accel-ops.h"
-
-/*
- * return 0 when success, -1 when driver not loaded,
- * other negative value for other failure
- */
-static int hax_open_device(hax_fd *fd)
-{
- uint32_t errNum = 0;
- HANDLE hDevice;
-
- if (!fd) {
- return -2;
- }
-
- hDevice = CreateFile("\\\\.\\HAX",
- GENERIC_READ | GENERIC_WRITE,
- 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
-
- if (hDevice == INVALID_HANDLE_VALUE) {
- fprintf(stderr, "Failed to open the HAX device!\n");
- errNum = GetLastError();
- if (errNum == ERROR_FILE_NOT_FOUND) {
- return -1;
- }
- return -2;
- }
- *fd = hDevice;
- return 0;
-}
-
-/* hax_fd hax_mod_open */
- hax_fd hax_mod_open(void)
-{
- int ret;
- hax_fd fd = NULL;
-
- ret = hax_open_device(&fd);
- if (ret != 0) {
- fprintf(stderr, "Open HAX device failed\n");
- }
-
- return fd;
-}
-
-int hax_populate_ram(uint64_t va, uint64_t size)
-{
- int ret;
- HANDLE hDeviceVM;
- DWORD dSize = 0;
-
- if (!hax_global.vm || !hax_global.vm->fd) {
- fprintf(stderr, "Allocate memory before vm create?\n");
- return -EINVAL;
- }
-
- hDeviceVM = hax_global.vm->fd;
- if (hax_global.supports_64bit_ramblock) {
- struct hax_ramblock_info ramblock = {
- .start_va = va,
- .size = size,
- .reserved = 0
- };
-
- ret = DeviceIoControl(hDeviceVM,
- HAX_VM_IOCTL_ADD_RAMBLOCK,
- &ramblock, sizeof(ramblock), NULL, 0, &dSize,
- (LPOVERLAPPED) NULL);
- } else {
- struct hax_alloc_ram_info info = {
- .size = (uint32_t) size,
- .pad = 0,
- .va = va
- };
-
- ret = DeviceIoControl(hDeviceVM,
- HAX_VM_IOCTL_ALLOC_RAM,
- &info, sizeof(info), NULL, 0, &dSize,
- (LPOVERLAPPED) NULL);
- }
-
- if (!ret) {
- fprintf(stderr, "Failed to register RAM block: va=0x%" PRIx64
- ", size=0x%" PRIx64 ", method=%s\n", va, size,
- hax_global.supports_64bit_ramblock ? "new" : "legacy");
- return ret;
- }
-
- return 0;
-}
-
-int hax_set_ram(uint64_t start_pa, uint32_t size, uint64_t host_va, int flags)
-{
- struct hax_set_ram_info info;
- HANDLE hDeviceVM = hax_global.vm->fd;
- DWORD dSize = 0;
- int ret;
-
- info.pa_start = start_pa;
- info.size = size;
- info.va = host_va;
- info.flags = (uint8_t) flags;
-
- ret = DeviceIoControl(hDeviceVM, HAX_VM_IOCTL_SET_RAM,
- &info, sizeof(info), NULL, 0, &dSize,
- (LPOVERLAPPED) NULL);
-
- if (!ret) {
- return -EFAULT;
- } else {
- return 0;
- }
-}
-
-int hax_capability(struct hax_state *hax, struct hax_capabilityinfo *cap)
-{
- int ret;
- HANDLE hDevice = hax->fd; /* handle to hax module */
- DWORD dSize = 0;
- DWORD err = 0;
-
- if (hax_invalid_fd(hDevice)) {
- fprintf(stderr, "Invalid fd for hax device!\n");
- return -ENODEV;
- }
-
- ret = DeviceIoControl(hDevice, HAX_IOCTL_CAPABILITY, NULL, 0, cap,
- sizeof(*cap), &dSize, (LPOVERLAPPED) NULL);
-
- if (!ret) {
- err = GetLastError();
- if (err == ERROR_INSUFFICIENT_BUFFER || err == ERROR_MORE_DATA) {
- fprintf(stderr, "hax capability is too long to hold.\n");
- }
- fprintf(stderr, "Failed to get Hax capability:%luu\n", err);
- return -EFAULT;
- } else {
- return 0;
- }
-}
-
-int hax_mod_version(struct hax_state *hax, struct hax_module_version *version)
-{
- int ret;
- HANDLE hDevice = hax->fd; /* handle to hax module */
- DWORD dSize = 0;
- DWORD err = 0;
-
- if (hax_invalid_fd(hDevice)) {
- fprintf(stderr, "Invalid fd for hax device!\n");
- return -ENODEV;
- }
-
- ret = DeviceIoControl(hDevice,
- HAX_IOCTL_VERSION,
- NULL, 0,
- version, sizeof(*version), &dSize,
- (LPOVERLAPPED) NULL);
-
- if (!ret) {
- err = GetLastError();
- if (err == ERROR_INSUFFICIENT_BUFFER || err == ERROR_MORE_DATA) {
- fprintf(stderr, "hax module verion is too long to hold.\n");
- }
- fprintf(stderr, "Failed to get Hax module version:%lu\n", err);
- return -EFAULT;
- } else {
- return 0;
- }
-}
-
-static char *hax_vm_devfs_string(int vm_id)
-{
- return g_strdup_printf("\\\\.\\hax_vm%02d", vm_id);
-}
-
-static char *hax_vcpu_devfs_string(int vm_id, int vcpu_id)
-{
- return g_strdup_printf("\\\\.\\hax_vm%02d_vcpu%02d", vm_id, vcpu_id);
-}
-
-int hax_host_create_vm(struct hax_state *hax, int *vmid)
-{
- int ret;
- int vm_id = 0;
- DWORD dSize = 0;
-
- if (hax_invalid_fd(hax->fd)) {
- return -EINVAL;
- }
-
- if (hax->vm) {
- return 0;
- }
-
- ret = DeviceIoControl(hax->fd,
- HAX_IOCTL_CREATE_VM,
- NULL, 0, &vm_id, sizeof(vm_id), &dSize,
- (LPOVERLAPPED) NULL);
- if (!ret) {
- fprintf(stderr, "Failed to create VM. Error code: %lu\n",
- GetLastError());
- return -1;
- }
- *vmid = vm_id;
- return 0;
-}
-
-hax_fd hax_host_open_vm(struct hax_state *hax, int vm_id)
-{
- char *vm_name = NULL;
- hax_fd hDeviceVM;
-
- vm_name = hax_vm_devfs_string(vm_id);
- if (!vm_name) {
- fprintf(stderr, "Failed to open VM. VM name is null\n");
- return INVALID_HANDLE_VALUE;
- }
-
- hDeviceVM = CreateFile(vm_name,
- GENERIC_READ | GENERIC_WRITE,
- 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
- if (hDeviceVM == INVALID_HANDLE_VALUE) {
- fprintf(stderr, "Open the vm device error:%s, ec:%lu\n",
- vm_name, GetLastError());
- }
-
- g_free(vm_name);
- 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) {
- fprintf(stderr, "Failed to notify qemu API version\n");
- return -1;
- }
- return 0;
-}
-
-int hax_host_create_vcpu(hax_fd vm_fd, int vcpuid)
-{
- int ret;
- DWORD dSize = 0;
-
- ret = DeviceIoControl(vm_fd,
- HAX_VM_IOCTL_VCPU_CREATE,
- &vcpuid, sizeof(vcpuid), NULL, 0, &dSize,
- (LPOVERLAPPED) NULL);
- if (!ret) {
- fprintf(stderr, "Failed to create vcpu %x\n", vcpuid);
- return -1;
- }
-
- return 0;
-}
-
-hax_fd hax_host_open_vcpu(int vmid, int vcpuid)
-{
- char *devfs_path = NULL;
- hax_fd hDeviceVCPU;
-
- devfs_path = hax_vcpu_devfs_string(vmid, vcpuid);
- if (!devfs_path) {
- fprintf(stderr, "Failed to get the devfs\n");
- return INVALID_HANDLE_VALUE;
- }
-
- hDeviceVCPU = CreateFile(devfs_path,
- GENERIC_READ | GENERIC_WRITE,
- 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL,
- NULL);
-
- if (hDeviceVCPU == INVALID_HANDLE_VALUE) {
- fprintf(stderr, "Failed to open the vcpu devfs\n");
- }
- g_free(devfs_path);
- return hDeviceVCPU;
-}
-
-int hax_host_setup_vcpu_channel(AccelCPUState *vcpu)
-{
- hax_fd hDeviceVCPU = vcpu->fd;
- int ret;
- struct hax_tunnel_info info;
- DWORD dSize = 0;
-
- ret = DeviceIoControl(hDeviceVCPU,
- HAX_VCPU_IOCTL_SETUP_TUNNEL,
- NULL, 0, &info, sizeof(info), &dSize,
- (LPOVERLAPPED) NULL);
- if (!ret) {
- fprintf(stderr, "Failed to setup the hax tunnel\n");
- return -1;
- }
-
- if (!valid_hax_tunnel_size(info.size)) {
- fprintf(stderr, "Invalid hax tunnel size %x\n", info.size);
- ret = -EINVAL;
- return ret;
- }
- vcpu->tunnel = (struct hax_tunnel *) (intptr_t) (info.va);
- vcpu->iobuf = (unsigned char *) (intptr_t) (info.io_va);
- return 0;
-}
-
-int hax_vcpu_run(AccelCPUState *vcpu)
-{
- int ret;
- HANDLE hDeviceVCPU = vcpu->fd;
- DWORD dSize = 0;
-
- ret = DeviceIoControl(hDeviceVCPU,
- HAX_VCPU_IOCTL_RUN,
- NULL, 0, NULL, 0, &dSize, (LPOVERLAPPED) NULL);
- if (!ret) {
- return -EFAULT;
- } else {
- return 0;
- }
-}
-
-int hax_sync_fpu(CPUArchState *env, struct fx_layout *fl, int set)
-{
- int ret;
- hax_fd fd;
- HANDLE hDeviceVCPU;
- DWORD dSize = 0;
-
- fd = hax_vcpu_get_fd(env);
- if (hax_invalid_fd(fd)) {
- return -1;
- }
-
- hDeviceVCPU = fd;
-
- if (set) {
- ret = DeviceIoControl(hDeviceVCPU,
- HAX_VCPU_IOCTL_SET_FPU,
- fl, sizeof(*fl), NULL, 0, &dSize,
- (LPOVERLAPPED) NULL);
- } else {
- ret = DeviceIoControl(hDeviceVCPU,
- HAX_VCPU_IOCTL_GET_FPU,
- NULL, 0, fl, sizeof(*fl), &dSize,
- (LPOVERLAPPED) NULL);
- }
- if (!ret) {
- return -EFAULT;
- } else {
- return 0;
- }
-}
-
-int hax_sync_msr(CPUArchState *env, struct hax_msr_data *msrs, int set)
-{
- int ret;
- hax_fd fd;
- HANDLE hDeviceVCPU;
- DWORD dSize = 0;
-
- fd = hax_vcpu_get_fd(env);
- if (hax_invalid_fd(fd)) {
- return -1;
- }
- hDeviceVCPU = fd;
-
- if (set) {
- ret = DeviceIoControl(hDeviceVCPU,
- HAX_VCPU_IOCTL_SET_MSRS,
- msrs, sizeof(*msrs),
- msrs, sizeof(*msrs), &dSize, (LPOVERLAPPED) NULL);
- } else {
- ret = DeviceIoControl(hDeviceVCPU,
- HAX_VCPU_IOCTL_GET_MSRS,
- msrs, sizeof(*msrs),
- msrs, sizeof(*msrs), &dSize, (LPOVERLAPPED) NULL);
- }
- if (!ret) {
- return -EFAULT;
- } else {
- return 0;
- }
-}
-
-int hax_sync_vcpu_state(CPUArchState *env, struct vcpu_state_t *state, int set)
-{
- int ret;
- hax_fd fd;
- HANDLE hDeviceVCPU;
- DWORD dSize;
-
- fd = hax_vcpu_get_fd(env);
- if (hax_invalid_fd(fd)) {
- return -1;
- }
-
- hDeviceVCPU = fd;
-
- if (set) {
- ret = DeviceIoControl(hDeviceVCPU,
- HAX_VCPU_SET_REGS,
- state, sizeof(*state),
- NULL, 0, &dSize, (LPOVERLAPPED) NULL);
- } else {
- ret = DeviceIoControl(hDeviceVCPU,
- HAX_VCPU_GET_REGS,
- NULL, 0,
- state, sizeof(*state), &dSize,
- (LPOVERLAPPED) NULL);
- }
- if (!ret) {
- return -EFAULT;
- } else {
- return 0;
- }
-}
-
-int hax_inject_interrupt(CPUArchState *env, int vector)
-{
- int ret;
- hax_fd fd;
- HANDLE hDeviceVCPU;
- DWORD dSize;
-
- fd = hax_vcpu_get_fd(env);
- if (hax_invalid_fd(fd)) {
- return -1;
- }
-
- hDeviceVCPU = fd;
-
- ret = DeviceIoControl(hDeviceVCPU,
- HAX_VCPU_IOCTL_INTERRUPT,
- &vector, sizeof(vector), NULL, 0, &dSize,
- (LPOVERLAPPED) NULL);
- if (!ret) {
- return -EFAULT;
- } else {
- return 0;
- }
-}
-
-static void CALLBACK dummy_apc_func(ULONG_PTR unused)
-{
-}
-
-void hax_kick_vcpu_thread(CPUState *cpu)
-{
- /*
- * FIXME: race condition with the exit_request check in
- * hax_vcpu_hax_exec
- */
- cpu->exit_request = 1;
- if (!qemu_cpu_is_self(cpu)) {
- if (!QueueUserAPC(dummy_apc_func, cpu->accel->hThread, 0)) {
- fprintf(stderr, "%s: QueueUserAPC failed with error %lu\n",
- __func__, GetLastError());
- exit(1);
- }
- }
-}
diff --git a/accel/Kconfig b/accel/Kconfig
index 8bdedb7d15..a30cf2eb48 100644
--- a/accel/Kconfig
+++ b/accel/Kconfig
@@ -4,9 +4,6 @@ config WHPX
config NVMM
bool
-config HAX
- bool
-
config HVF
bool
diff --git a/accel/stubs/meson.build b/accel/stubs/meson.build
index f7a9486e06..6b0f200efe 100644
--- a/accel/stubs/meson.build
+++ b/accel/stubs/meson.build
@@ -1,5 +1,4 @@
sysemu_stubs_ss = ss.source_set()
-sysemu_stubs_ss.add(when: 'CONFIG_HAX', if_false: files('hax-stub.c'))
sysemu_stubs_ss.add(when: 'CONFIG_XEN', if_false: files('xen-stub.c'))
sysemu_stubs_ss.add(when: 'CONFIG_KVM', if_false: files('kvm-stub.c'))
sysemu_stubs_ss.add(when: 'CONFIG_TCG', if_false: files('tcg-stub.c'))
diff --git a/meson_options.txt b/meson_options.txt
index aaea5ddd77..4f3b1ecab0 100644
--- a/meson_options.txt
+++ b/meson_options.txt
@@ -69,8 +69,6 @@ option('malloc', type : 'combo', choices : ['system', 'tcmalloc', 'jemalloc'],
option('kvm', type: 'feature', value: 'auto',
description: 'KVM acceleration support')
-option('hax', type: 'feature', value: 'auto',
- description: 'HAX acceleration support')
option('whpx', type: 'feature', value: 'auto',
description: 'WHPX acceleration support')
option('hvf', type: 'feature', value: 'auto',
diff --git a/qemu-options.hx b/qemu-options.hx
index 29b98c3d4c..463f520c57 100644
--- a/qemu-options.hx
+++ b/qemu-options.hx
@@ -26,7 +26,7 @@ DEF("machine", HAS_ARG, QEMU_OPTION_machine, \
"-machine [type=]name[,prop[=value][,...]]\n"
" selects emulated machine ('-machine help' for list)\n"
" property accel=accel1[:accel2[:...]] selects accelerator\n"
- " supported accelerators are kvm, xen, hax, hvf, nvmm, whpx or tcg (default: tcg)\n"
+ " supported accelerators are kvm, xen, hvf, nvmm, whpx or tcg (default: tcg)\n"
" vmport=on|off|auto controls emulation of vmport (default: auto)\n"
" dump-guest-core=on|off include guest memory in a core dump (default=on)\n"
" mem-merge=on|off controls memory merge support (default: on)\n"
@@ -59,7 +59,7 @@ SRST
``accel=accels1[:accels2[:...]]``
This is used to enable an accelerator. Depending on the target
- architecture, kvm, xen, hax, hvf, nvmm, whpx or tcg can be available.
+ architecture, kvm, xen, hvf, nvmm, whpx or tcg can be available.
By default, tcg is used. If there is more than one accelerator
specified, the next one is used if the previous one fails to
initialize.
@@ -178,7 +178,7 @@ ERST
DEF("accel", HAS_ARG, QEMU_OPTION_accel,
"-accel [accel=]accelerator[,prop[=value][,...]]\n"
- " select accelerator (kvm, xen, hax, hvf, nvmm, whpx or tcg; use 'help' for a list)\n"
+ " select accelerator (kvm, xen, hvf, nvmm, whpx or tcg; use 'help' for a list)\n"
" igd-passthru=on|off (enable Xen integrated Intel graphics passthrough, default=off)\n"
" kernel-irqchip=on|off|split controls accelerated irqchip support (default=on)\n"
" kvm-shadow-mem=size of KVM shadow MMU in bytes\n"
@@ -191,7 +191,7 @@ DEF("accel", HAS_ARG, QEMU_OPTION_accel,
SRST
``-accel name[,prop=value[,...]]``
This is used to enable an accelerator. Depending on the target
- architecture, kvm, xen, hax, hvf, nvmm, whpx or tcg can be available. By
+ architecture, kvm, xen, hvf, nvmm, whpx or tcg can be available. By
default, tcg is used. If there is more than one accelerator
specified, the next one is used if the previous one fails to
initialize.
diff --git a/scripts/ci/org.centos/stream/8/x86_64/configure b/scripts/ci/org.centos/stream/8/x86_64/configure
index d02b09a4b9..131f8ee5f3 100755
--- a/scripts/ci/org.centos/stream/8/x86_64/configure
+++ b/scripts/ci/org.centos/stream/8/x86_64/configure
@@ -68,7 +68,6 @@
--disable-gtk \
--disable-guest-agent \
--disable-guest-agent-msi \
---disable-hax \
--disable-hvf \
--disable-iconv \
--disable-kvm \
diff --git a/scripts/meson-buildoptions.sh b/scripts/meson-buildoptions.sh
index 9da3fe299b..504a61ad01 100644
--- a/scripts/meson-buildoptions.sh
+++ b/scripts/meson-buildoptions.sh
@@ -110,7 +110,6 @@ meson_options_help() {
printf "%s\n" ' gtk-clipboard clipboard support for the gtk UI (EXPERIMENTAL, MAY HANG)'
printf "%s\n" ' guest-agent Build QEMU Guest Agent'
printf "%s\n" ' guest-agent-msi Build MSI package for the QEMU Guest Agent'
- printf "%s\n" ' hax HAX acceleration support'
printf "%s\n" ' hvf HVF acceleration support'
printf "%s\n" ' iconv Font glyph conversion support'
printf "%s\n" ' jack JACK sound support'
@@ -312,8 +311,6 @@ _meson_option_parse() {
--disable-guest-agent) printf "%s" -Dguest_agent=disabled ;;
--enable-guest-agent-msi) printf "%s" -Dguest_agent_msi=enabled ;;
--disable-guest-agent-msi) printf "%s" -Dguest_agent_msi=disabled ;;
- --enable-hax) printf "%s" -Dhax=enabled ;;
- --disable-hax) printf "%s" -Dhax=disabled ;;
--enable-hexagon-idef-parser) printf "%s" -Dhexagon_idef_parser=true ;;
--disable-hexagon-idef-parser) printf "%s" -Dhexagon_idef_parser=false ;;
--enable-hvf) printf "%s" -Dhvf=enabled ;;
diff --git a/target/i386/hax/meson.build b/target/i386/hax/meson.build
deleted file mode 100644
index 6ac314aa35..0000000000
--- a/target/i386/hax/meson.build
+++ /dev/null
@@ -1,7 +0,0 @@
-i386_system_ss.add(when: 'CONFIG_HAX', if_true: files(
- 'hax-all.c',
- 'hax-mem.c',
- 'hax-accel-ops.c',
-))
-i386_system_ss.add(when: ['CONFIG_HAX', 'CONFIG_POSIX'], if_true: files('hax-posix.c'))
-i386_system_ss.add(when: ['CONFIG_HAX', 'CONFIG_WIN32'], if_true: files('hax-windows.c'))
diff --git a/target/i386/meson.build b/target/i386/meson.build
index 1effe1ed9a..6f1036d469 100644
--- a/target/i386/meson.build
+++ b/target/i386/meson.build
@@ -25,7 +25,6 @@ i386_system_ss.add(when: 'CONFIG_SEV', if_true: files('sev.c'), if_false: files(
i386_user_ss = ss.source_set()
subdir('kvm')
-subdir('hax')
subdir('whpx')
subdir('nvmm')
subdir('hvf')
--
2.41.0
3
2
HAX is deprecated since commits 73741fda6c ("MAINTAINERS: Abort
HAXM maintenance") and 90c167a1da ("docs/about/deprecated: Mark
HAXM in QEMU as deprecated"), released in v8.0.0.
Per the latest HAXM release (v7.8 [*]), the latest QEMU supported
is v7.2:
Note: Up to this release, HAXM supports QEMU from 2.9.0 to 7.2.0.
The next commit (https://github.com/intel/haxm/commit/da1b8ec072)
added:
HAXM v7.8.0 is our last release and we will not accept
pull requests or respond to issues after this.
It became very hard to build and test HAXM. Its previous
maintainers made it clear they won't help. It doesn't seem to be
a very good use of QEMU maintainers to spend their time in a dead
project. Save our time by removing this orphan zombie code.
[*] https://github.com/intel/haxm/releases/tag/v7.8.0
Reviewed-by: Richard Henderson <richard.henderson(a)linaro.org>
Acked-by: Markus Armbruster <armbru(a)redhat.com>
Signed-off-by: Philippe Mathieu-Daudé <philmd(a)linaro.org>
Reviewed-by: Thomas Huth <thuth(a)redhat.com>
Message-Id: <20230831082016.60885-1-philmd(a)linaro.org>
---
MAINTAINERS | 8 -
docs/about/build-platforms.rst | 2 +-
docs/about/deprecated.rst | 6 -
docs/about/index.rst | 2 +-
docs/about/removed-features.rst | 11 +-
docs/system/index.rst | 2 +-
docs/system/introduction.rst | 3 -
meson.build | 7 -
include/exec/poison.h | 1 -
include/hw/core/cpu.h | 2 +-
include/sysemu/hax.h | 49 -
include/sysemu/hw_accel.h | 1 -
target/i386/hax/hax-accel-ops.h | 31 -
target/i386/hax/hax-i386.h | 98 --
target/i386/hax/hax-interface.h | 369 ------
target/i386/hax/hax-posix.h | 61 -
target/i386/hax/hax-windows.h | 88 --
accel/stubs/hax-stub.c | 24 -
hw/intc/apic_common.c | 3 +-
softmmu/cpus.c | 6 -
softmmu/vl.c | 6 -
target/i386/hax/hax-accel-ops.c | 105 --
target/i386/hax/hax-all.c | 1141 -----------------
target/i386/hax/hax-mem.c | 323 -----
target/i386/hax/hax-posix.c | 305 -----
target/i386/hax/hax-windows.c | 485 -------
accel/Kconfig | 3 -
accel/stubs/meson.build | 1 -
meson_options.txt | 2 -
qemu-options.hx | 8 +-
.../ci/org.centos/stream/8/x86_64/configure | 1 -
scripts/meson-buildoptions.sh | 3 -
target/i386/hax/meson.build | 7 -
target/i386/meson.build | 1 -
34 files changed, 16 insertions(+), 3149 deletions(-)
delete mode 100644 include/sysemu/hax.h
delete mode 100644 target/i386/hax/hax-accel-ops.h
delete mode 100644 target/i386/hax/hax-i386.h
delete mode 100644 target/i386/hax/hax-interface.h
delete mode 100644 target/i386/hax/hax-posix.h
delete mode 100644 target/i386/hax/hax-windows.h
delete mode 100644 accel/stubs/hax-stub.c
delete mode 100644 target/i386/hax/hax-accel-ops.c
delete mode 100644 target/i386/hax/hax-all.c
delete mode 100644 target/i386/hax/hax-mem.c
delete mode 100644 target/i386/hax/hax-posix.c
delete mode 100644 target/i386/hax/hax-windows.c
delete mode 100644 target/i386/hax/meson.build
diff --git a/MAINTAINERS b/MAINTAINERS
index 6111b6b4d9..3b29568ed4 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -543,14 +543,6 @@ F: include/sysemu/xen.h
F: include/sysemu/xen-mapcache.h
F: stubs/xen-hw-stub.c
-Guest CPU Cores (HAXM)
----------------------
-X86 HAXM CPUs
-S: Orphan
-F: accel/stubs/hax-stub.c
-F: include/sysemu/hax.h
-F: target/i386/hax/
-
Guest CPU Cores (NVMM)
----------------------
NetBSD Virtual Machine Monitor (NVMM) CPU support
diff --git a/docs/about/build-platforms.rst b/docs/about/build-platforms.rst
index 0e2cb9e770..f2a7aec56f 100644
--- a/docs/about/build-platforms.rst
+++ b/docs/about/build-platforms.rst
@@ -52,7 +52,7 @@ Those hosts are officially supported, with various accelerators:
* - SPARC
- tcg
* - x86
- - hax, hvf (64 bit only), kvm, nvmm, tcg, whpx (64 bit only), xen
+ - hvf (64 bit only), kvm, nvmm, tcg, whpx (64 bit only), xen
Other host architectures are not supported. It is possible to build QEMU system
emulation on an unsupported host architecture using the configure
diff --git a/docs/about/deprecated.rst b/docs/about/deprecated.rst
index 92a2bafd2b..dc4da95329 100644
--- a/docs/about/deprecated.rst
+++ b/docs/about/deprecated.rst
@@ -105,12 +105,6 @@ Use ``-machine hpet=off`` instead.
The ``-no-acpi`` setting has been turned into a machine property.
Use ``-machine acpi=off`` instead.
-``-accel hax`` (since 8.0)
-''''''''''''''''''''''''''
-
-The HAXM project has been retired (see https://github.com/intel/haxm#status)
-Use "whpx" (on Windows) or "hvf" (on macOS) instead.
-
``-async-teardown`` (since 8.1)
'''''''''''''''''''''''''''''''
diff --git a/docs/about/index.rst b/docs/about/index.rst
index b00b584b31..4f96ab5d91 100644
--- a/docs/about/index.rst
+++ b/docs/about/index.rst
@@ -8,7 +8,7 @@ QEMU can be used in several different ways. The most common is for
:ref:`System Emulation`, where it provides a virtual model of an
entire machine (CPU, memory and emulated devices) to run a guest OS.
In this mode the CPU may be fully emulated, or it may work with a
-hypervisor such as KVM, Xen, Hax or Hypervisor.Framework to allow the
+hypervisor such as KVM, Xen or Hypervisor.Framework to allow the
guest to run directly on the host CPU.
The second supported way to use QEMU is :ref:`User Mode Emulation`,
diff --git a/docs/about/removed-features.rst b/docs/about/removed-features.rst
index 5b258b446b..c2043fd415 100644
--- a/docs/about/removed-features.rst
+++ b/docs/about/removed-features.rst
@@ -659,15 +659,18 @@ Use ``Icelake-Server`` instead.
System accelerators
-------------------
-Userspace local APIC with KVM (x86, removed 8.0)
-''''''''''''''''''''''''''''''''''''''''''''''''
+Userspace local APIC with KVM (x86, removed in 8.0)
+'''''''''''''''''''''''''''''''''''''''''''''''''''
``-M kernel-irqchip=off`` cannot be used on KVM if the CPU model includes
a local APIC. The ``split`` setting is supported, as is using ``-M
kernel-irqchip=off`` when the CPU does not have a local APIC.
-System accelerators
--------------------
+HAXM (``-accel hax``) (removed in 8.2)
+''''''''''''''''''''''''''''''''''''''
+
+The HAXM project has been retired (see https://github.com/intel/haxm#status)
+Use "whpx" (on Windows) or "hvf" (on macOS) instead.
MIPS "Trap-and-Emulate" KVM support (removed in 8.0)
''''''''''''''''''''''''''''''''''''''''''''''''''''
diff --git a/docs/system/index.rst b/docs/system/index.rst
index 3605bbe1ce..45bf1f19e7 100644
--- a/docs/system/index.rst
+++ b/docs/system/index.rst
@@ -6,7 +6,7 @@ System Emulation
This section of the manual is the overall guide for users using QEMU
for full system emulation (as opposed to user-mode emulation).
-This includes working with hypervisors such as KVM, Xen, Hax
+This includes working with hypervisors such as KVM, Xen
or Hypervisor.Framework.
.. toctree::
diff --git a/docs/system/introduction.rst b/docs/system/introduction.rst
index 3e256f8326..51ac132d6c 100644
--- a/docs/system/introduction.rst
+++ b/docs/system/introduction.rst
@@ -21,9 +21,6 @@ Tiny Code Generator (TCG) capable of emulating many CPUs.
* - Xen
- Linux (as dom0)
- Arm, x86
- * - Intel HAXM (hax)
- - Linux, Windows
- - x86
* - Hypervisor Framework (hvf)
- MacOS
- x86 (64 bit only), Arm (64 bit only)
diff --git a/meson.build b/meson.build
index 98e68ef0b1..ec14079c67 100644
--- a/meson.build
+++ b/meson.build
@@ -140,7 +140,6 @@ if cpu in ['x86', 'x86_64', 'arm', 'aarch64']
endif
if cpu in ['x86', 'x86_64']
accelerator_targets += {
- 'CONFIG_HAX': ['i386-softmmu', 'x86_64-softmmu'],
'CONFIG_HVF': ['x86_64-softmmu'],
'CONFIG_NVMM': ['i386-softmmu', 'x86_64-softmmu'],
'CONFIG_WHPX': ['i386-softmmu', 'x86_64-softmmu'],
@@ -663,11 +662,6 @@ if get_option('hvf').allowed()
accelerators += 'CONFIG_HVF'
endif
endif
-if get_option('hax').allowed()
- if get_option('hax').enabled() or targetos in ['windows', 'darwin', 'netbsd']
- accelerators += 'CONFIG_HAX'
- endif
-endif
if targetos == 'netbsd'
nvmm = cc.find_library('nvmm', required: get_option('nvmm'))
if nvmm.found()
@@ -4140,7 +4134,6 @@ endif
summary_info = {}
if have_system
summary_info += {'KVM support': config_all.has_key('CONFIG_KVM')}
- summary_info += {'HAX support': config_all.has_key('CONFIG_HAX')}
summary_info += {'HVF support': config_all.has_key('CONFIG_HVF')}
summary_info += {'WHPX support': config_all.has_key('CONFIG_WHPX')}
summary_info += {'NVMM support': config_all.has_key('CONFIG_NVMM')}
diff --git a/include/exec/poison.h b/include/exec/poison.h
index e94ee8dfef..1ea5633eb3 100644
--- a/include/exec/poison.h
+++ b/include/exec/poison.h
@@ -81,7 +81,6 @@
#pragma GCC poison CONFIG_SPARC_DIS
#pragma GCC poison CONFIG_XTENSA_DIS
-#pragma GCC poison CONFIG_HAX
#pragma GCC poison CONFIG_HVF
#pragma GCC poison CONFIG_LINUX_USER
#pragma GCC poison CONFIG_KVM
diff --git a/include/hw/core/cpu.h b/include/hw/core/cpu.h
index fdcbe87352..92a4234439 100644
--- a/include/hw/core/cpu.h
+++ b/include/hw/core/cpu.h
@@ -422,7 +422,7 @@ struct CPUState {
int32_t exception_index;
AccelCPUState *accel;
- /* shared by kvm, hax and hvf */
+ /* shared by kvm and hvf */
bool vcpu_dirty;
/* Used to keep track of an outstanding cpu throttle thread for migration
diff --git a/include/sysemu/hax.h b/include/sysemu/hax.h
deleted file mode 100644
index 80fc716f80..0000000000
--- a/include/sysemu/hax.h
+++ /dev/null
@@ -1,49 +0,0 @@
-/*
- * QEMU HAXM support
- *
- * Copyright IBM, Corp. 2008
- *
- * Authors:
- * Anthony Liguori <aliguori(a)us.ibm.com>
- *
- * Copyright (c) 2011 Intel Corporation
- * Written by:
- * Jiang Yunhong<yunhong.jiang(a)intel.com>
- * Xin Xiaohui<xiaohui.xin(a)intel.com>
- * Zhang Xiantao<xiantao.zhang(a)intel.com>
- *
- * Copyright 2016 Google, Inc.
- *
- * This work is licensed under the terms of the GNU GPL, version 2 or later.
- * See the COPYING file in the top-level directory.
- *
- */
-
-/* header to be included in non-HAX-specific code */
-
-#ifndef QEMU_HAX_H
-#define QEMU_HAX_H
-
-int hax_sync_vcpus(void);
-
-#ifdef NEED_CPU_H
-# ifdef CONFIG_HAX
-# define CONFIG_HAX_IS_POSSIBLE
-# endif
-#else /* !NEED_CPU_H */
-# define CONFIG_HAX_IS_POSSIBLE
-#endif
-
-#ifdef CONFIG_HAX_IS_POSSIBLE
-
-extern bool hax_allowed;
-
-#define hax_enabled() (hax_allowed)
-
-#else /* !CONFIG_HAX_IS_POSSIBLE */
-
-#define hax_enabled() (0)
-
-#endif /* CONFIG_HAX_IS_POSSIBLE */
-
-#endif /* QEMU_HAX_H */
diff --git a/include/sysemu/hw_accel.h b/include/sysemu/hw_accel.h
index 22903a55f7..c71b77e71f 100644
--- a/include/sysemu/hw_accel.h
+++ b/include/sysemu/hw_accel.h
@@ -12,7 +12,6 @@
#define QEMU_HW_ACCEL_H
#include "hw/core/cpu.h"
-#include "sysemu/hax.h"
#include "sysemu/kvm.h"
#include "sysemu/hvf.h"
#include "sysemu/whpx.h"
diff --git a/target/i386/hax/hax-accel-ops.h b/target/i386/hax/hax-accel-ops.h
deleted file mode 100644
index 9e357e7b40..0000000000
--- a/target/i386/hax/hax-accel-ops.h
+++ /dev/null
@@ -1,31 +0,0 @@
-/*
- * Accelerator CPUS Interface
- *
- * Copyright 2020 SUSE LLC
- *
- * This work is licensed under the terms of the GNU GPL, version 2 or later.
- * See the COPYING file in the top-level directory.
- */
-
-#ifndef TARGET_I386_HAX_ACCEL_OPS_H
-#define TARGET_I386_HAX_ACCEL_OPS_H
-
-#include "sysemu/cpus.h"
-
-#include "hax-interface.h"
-#include "hax-i386.h"
-
-int hax_init_vcpu(CPUState *cpu);
-int hax_smp_cpu_exec(CPUState *cpu);
-int hax_populate_ram(uint64_t va, uint64_t size);
-
-void hax_cpu_synchronize_state(CPUState *cpu);
-void hax_cpu_synchronize_post_reset(CPUState *cpu);
-void hax_cpu_synchronize_post_init(CPUState *cpu);
-void hax_cpu_synchronize_pre_loadvm(CPUState *cpu);
-
-int hax_vcpu_destroy(CPUState *cpu);
-void hax_raise_event(CPUState *cpu);
-void hax_reset_vcpu_state(void *opaque);
-
-#endif /* TARGET_I386_HAX_ACCEL_OPS_H */
diff --git a/target/i386/hax/hax-i386.h b/target/i386/hax/hax-i386.h
deleted file mode 100644
index 87153f40ab..0000000000
--- a/target/i386/hax/hax-i386.h
+++ /dev/null
@@ -1,98 +0,0 @@
-/*
- * QEMU HAXM support
- *
- * Copyright (c) 2011 Intel Corporation
- * Written by:
- * Jiang Yunhong<yunhong.jiang(a)intel.com>
- *
- * This work is licensed under the terms of the GNU GPL, version 2 or later.
- * See the COPYING file in the top-level directory.
- *
- */
-
-#ifndef HAX_I386_H
-#define HAX_I386_H
-
-#include "cpu.h"
-#include "sysemu/hax.h"
-
-#ifdef CONFIG_POSIX
-typedef int hax_fd;
-#endif
-
-#ifdef CONFIG_WIN32
-typedef HANDLE hax_fd;
-#endif
-
-extern struct hax_state hax_global;
-
-struct AccelCPUState {
-#ifdef _WIN32
- HANDLE hThread;
-#endif
- hax_fd fd;
- int vcpu_id;
- struct hax_tunnel *tunnel;
- unsigned char *iobuf;
-};
-
-struct hax_state {
- hax_fd fd; /* the global hax device interface */
- uint32_t version;
- struct hax_vm *vm;
- uint64_t mem_quota;
- bool supports_64bit_ramblock;
-};
-
-#define HAX_MAX_VCPU 0x10
-
-struct hax_vm {
- hax_fd fd;
- int id;
- int numvcpus;
- AccelCPUState **vcpus;
-};
-
-/* Functions exported to host specific mode */
-hax_fd hax_vcpu_get_fd(CPUArchState *env);
-int valid_hax_tunnel_size(uint16_t size);
-
-/* Host specific functions */
-int hax_mod_version(struct hax_state *hax, struct hax_module_version *version);
-int hax_inject_interrupt(CPUArchState *env, int vector);
-struct hax_vm *hax_vm_create(struct hax_state *hax, int max_cpus);
-int hax_vcpu_run(AccelCPUState *vcpu);
-int hax_vcpu_create(int id);
-void hax_kick_vcpu_thread(CPUState *cpu);
-
-int hax_sync_vcpu_state(CPUArchState *env, struct vcpu_state_t *state,
- int set);
-int hax_sync_msr(CPUArchState *env, struct hax_msr_data *msrs, int set);
-int hax_sync_fpu(CPUArchState *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);
-int hax_set_ram(uint64_t start_pa, uint32_t size, uint64_t host_va, int flags);
-
-/* Common host function */
-int hax_host_create_vm(struct hax_state *hax, int *vm_id);
-hax_fd hax_host_open_vm(struct hax_state *hax, int vm_id);
-int hax_host_create_vcpu(hax_fd vm_fd, int vcpuid);
-hax_fd hax_host_open_vcpu(int vmid, int vcpuid);
-int hax_host_setup_vcpu_channel(AccelCPUState *vcpu);
-hax_fd hax_mod_open(void);
-void hax_memory_init(void);
-
-
-#ifdef CONFIG_POSIX
-#include "hax-posix.h"
-#endif
-
-#ifdef CONFIG_WIN32
-#include "hax-windows.h"
-#endif
-
-#include "hax-interface.h"
-
-#endif
diff --git a/target/i386/hax/hax-interface.h b/target/i386/hax/hax-interface.h
deleted file mode 100644
index 537ae084e9..0000000000
--- a/target/i386/hax/hax-interface.h
+++ /dev/null
@@ -1,369 +0,0 @@
-/*
- * QEMU HAXM support
- *
- * Copyright (c) 2011 Intel Corporation
- * Written by:
- * Jiang Yunhong<yunhong.jiang(a)intel.com>
- * Xin Xiaohui<xiaohui.xin(a)intel.com>
- * Zhang Xiantao<xiantao.zhang(a)intel.com>
- *
- * This work is licensed under the terms of the GNU GPL, version 2 or later.
- * See the COPYING file in the top-level directory.
- *
- */
-
-/* Interface with HAX kernel module */
-
-#ifndef HAX_INTERFACE_H
-#define HAX_INTERFACE_H
-
-/* fx_layout has 3 formats table 3-56, 512bytes */
-struct fx_layout {
- uint16_t fcw;
- uint16_t fsw;
- uint8_t ftw;
- uint8_t res1;
- uint16_t fop;
- union {
- struct {
- uint32_t fip;
- uint16_t fcs;
- uint16_t res2;
- };
- uint64_t fpu_ip;
- };
- union {
- struct {
- uint32_t fdp;
- uint16_t fds;
- uint16_t res3;
- };
- uint64_t fpu_dp;
- };
- uint32_t mxcsr;
- uint32_t mxcsr_mask;
- uint8_t st_mm[8][16];
- uint8_t mmx_1[8][16];
- uint8_t mmx_2[8][16];
- uint8_t pad[96];
-} __attribute__ ((aligned(8)));
-
-struct vmx_msr {
- uint64_t entry;
- uint64_t value;
-} __attribute__ ((__packed__));
-
-/*
- * Fixed array is not good, but it makes Mac support a bit easier by avoiding
- * memory map or copyin staff.
- */
-#define HAX_MAX_MSR_ARRAY 0x20
-struct hax_msr_data {
- uint16_t nr_msr;
- uint16_t done;
- uint16_t pad[2];
- struct vmx_msr entries[HAX_MAX_MSR_ARRAY];
-} __attribute__ ((__packed__));
-
-union interruptibility_state_t {
- uint32_t raw;
- struct {
- uint32_t sti_blocking:1;
- uint32_t movss_blocking:1;
- uint32_t smi_blocking:1;
- uint32_t nmi_blocking:1;
- uint32_t reserved:28;
- };
- uint64_t pad;
-};
-
-typedef union interruptibility_state_t interruptibility_state_t;
-
-/* Segment descriptor */
-struct segment_desc_t {
- uint16_t selector;
- uint16_t _dummy;
- uint32_t limit;
- uint64_t base;
- union {
- struct {
- uint32_t type:4;
- uint32_t desc:1;
- uint32_t dpl:2;
- uint32_t present:1;
- uint32_t:4;
- uint32_t available:1;
- uint32_t long_mode:1;
- uint32_t operand_size:1;
- uint32_t granularity:1;
- uint32_t null:1;
- uint32_t:15;
- };
- uint32_t ar;
- };
- uint32_t ipad;
-};
-
-typedef struct segment_desc_t segment_desc_t;
-
-struct vcpu_state_t {
- union {
- uint64_t _regs[16];
- struct {
- union {
- struct {
- uint8_t _al, _ah;
- };
- uint16_t _ax;
- uint32_t _eax;
- uint64_t _rax;
- };
- union {
- struct {
- uint8_t _cl, _ch;
- };
- uint16_t _cx;
- uint32_t _ecx;
- uint64_t _rcx;
- };
- union {
- struct {
- uint8_t _dl, _dh;
- };
- uint16_t _dx;
- uint32_t _edx;
- uint64_t _rdx;
- };
- union {
- struct {
- uint8_t _bl, _bh;
- };
- uint16_t _bx;
- uint32_t _ebx;
- uint64_t _rbx;
- };
- union {
- uint16_t _sp;
- uint32_t _esp;
- uint64_t _rsp;
- };
- union {
- uint16_t _bp;
- uint32_t _ebp;
- uint64_t _rbp;
- };
- union {
- uint16_t _si;
- uint32_t _esi;
- uint64_t _rsi;
- };
- union {
- uint16_t _di;
- uint32_t _edi;
- uint64_t _rdi;
- };
-
- uint64_t _r8;
- uint64_t _r9;
- uint64_t _r10;
- uint64_t _r11;
- uint64_t _r12;
- uint64_t _r13;
- uint64_t _r14;
- uint64_t _r15;
- };
- };
-
- union {
- uint32_t _eip;
- uint64_t _rip;
- };
-
- union {
- uint32_t _eflags;
- uint64_t _rflags;
- };
-
- segment_desc_t _cs;
- segment_desc_t _ss;
- segment_desc_t _ds;
- segment_desc_t _es;
- segment_desc_t _fs;
- segment_desc_t _gs;
- segment_desc_t _ldt;
- segment_desc_t _tr;
-
- segment_desc_t _gdt;
- segment_desc_t _idt;
-
- uint64_t _cr0;
- uint64_t _cr2;
- uint64_t _cr3;
- uint64_t _cr4;
-
- uint64_t _dr0;
- uint64_t _dr1;
- uint64_t _dr2;
- uint64_t _dr3;
- uint64_t _dr6;
- uint64_t _dr7;
- uint64_t _pde;
-
- uint32_t _efer;
-
- uint32_t _sysenter_cs;
- uint64_t _sysenter_eip;
- uint64_t _sysenter_esp;
-
- uint32_t _activity_state;
- uint32_t pad;
- interruptibility_state_t _interruptibility_state;
-};
-
-/* HAX exit status */
-enum exit_status {
- /* IO port request */
- HAX_EXIT_IO = 1,
- /* MMIO instruction emulation */
- HAX_EXIT_MMIO,
- /* QEMU emulation mode request, currently means guest enter non-PG mode */
- HAX_EXIT_REAL,
- /*
- * Interrupt window open, qemu can inject interrupt now
- * Also used when signal pending since at that time qemu usually need
- * check interrupt
- */
- HAX_EXIT_INTERRUPT,
- /* Unknown vmexit, mostly trigger reboot */
- HAX_EXIT_UNKNOWN_VMEXIT,
- /* HALT from guest */
- HAX_EXIT_HLT,
- /* Reboot request, like because of tripple fault in guest */
- HAX_EXIT_STATECHANGE,
- /* the vcpu is now only paused when destroy, so simply return to hax */
- HAX_EXIT_PAUSED,
- HAX_EXIT_FAST_MMIO,
-};
-
-/*
- * The interface definition:
- * 1. vcpu_run execute will return 0 on success, otherwise mean failed
- * 2. exit_status return the exit reason, as stated in enum exit_status
- * 3. exit_reason is the vmx exit reason
- */
-struct hax_tunnel {
- uint32_t _exit_reason;
- uint32_t _exit_flag;
- uint32_t _exit_status;
- uint32_t user_event_pending;
- int ready_for_interrupt_injection;
- int request_interrupt_window;
- union {
- struct {
- /* 0: read, 1: write */
-#define HAX_EXIT_IO_IN 1
-#define HAX_EXIT_IO_OUT 0
- uint8_t _direction;
- uint8_t _df;
- uint16_t _size;
- uint16_t _port;
- uint16_t _count;
- uint8_t _flags;
- uint8_t _pad0;
- uint16_t _pad1;
- uint32_t _pad2;
- uint64_t _vaddr;
- } pio;
- struct {
- uint64_t gla;
- } mmio;
- struct {
- } state;
- };
-} __attribute__ ((__packed__));
-
-struct hax_module_version {
- uint32_t compat_version;
- uint32_t cur_version;
-} __attribute__ ((__packed__));
-
-/* This interface is support only after API version 2 */
-struct hax_qemu_version {
- /* Current API version in QEMU */
- uint32_t cur_version;
- /* The minimum API version supported by QEMU */
- uint32_t min_version;
-} __attribute__ ((__packed__));
-
-/* The mac specfic interface to qemu, mostly is ioctl related */
-struct hax_tunnel_info {
- uint64_t va;
- uint64_t io_va;
- uint16_t size;
- uint16_t pad[3];
-} __attribute__ ((__packed__));
-
-struct hax_alloc_ram_info {
- uint32_t size;
- uint32_t pad;
- uint64_t va;
-} __attribute__ ((__packed__));
-
-struct hax_ramblock_info {
- uint64_t start_va;
- uint64_t size;
- uint64_t reserved;
-} __attribute__ ((__packed__));
-
-#define HAX_RAM_INFO_ROM 0x01 /* Read-Only */
-#define HAX_RAM_INFO_INVALID 0x80 /* Unmapped, usually used for MMIO */
-struct hax_set_ram_info {
- uint64_t pa_start;
- uint32_t size;
- uint8_t flags;
- uint8_t pad[3];
- uint64_t va;
-} __attribute__ ((__packed__));
-
-#define HAX_CAP_STATUS_WORKING 0x1
-#define HAX_CAP_STATUS_NOTWORKING 0x0
-#define HAX_CAP_WORKSTATUS_MASK 0x1
-
-#define HAX_CAP_FAILREASON_VT 0x1
-#define HAX_CAP_FAILREASON_NX 0x2
-
-#define HAX_CAP_MEMQUOTA 0x2
-#define HAX_CAP_UG 0x4
-#define HAX_CAP_64BIT_RAMBLOCK 0x8
-
-struct hax_capabilityinfo {
- /* bit 0: 1 - working
- * 0 - not working, possibly because NT/NX disabled
- * bit 1: 1 - memory limitation working
- * 0 - no memory limitation
- */
- uint16_t wstatus;
- /* valid when not working
- * bit 0: VT not enabeld
- * bit 1: NX not enabled*/
- uint16_t winfo;
- uint32_t pad;
- uint64_t mem_quota;
-} __attribute__ ((__packed__));
-
-struct hax_fastmmio {
- uint64_t gpa;
- union {
- uint64_t value;
- uint64_t gpa2; /* since HAX API v4 */
- };
- uint8_t size;
- uint8_t direction;
- uint16_t reg_index;
- uint32_t pad0;
- uint64_t _cr0;
- uint64_t _cr2;
- uint64_t _cr3;
- uint64_t _cr4;
-} __attribute__ ((__packed__));
-#endif
diff --git a/target/i386/hax/hax-posix.h b/target/i386/hax/hax-posix.h
deleted file mode 100644
index fb7c64426d..0000000000
--- a/target/i386/hax/hax-posix.h
+++ /dev/null
@@ -1,61 +0,0 @@
-/*
- * QEMU HAXM support
- *
- * Copyright (c) 2011 Intel Corporation
- * Written by:
- * Jiang Yunhong<yunhong.jiang(a)intel.com>
- * Xin Xiaohui<xiaohui.xin(a)intel.com>
- * Zhang Xiantao<xiantao.zhang(a)intel.com>
- *
- * This work is licensed under the terms of the GNU GPL, version 2 or later.
- * See the COPYING file in the top-level directory.
- *
- */
-
-#ifndef TARGET_I386_HAX_POSIX_H
-#define TARGET_I386_HAX_POSIX_H
-
-#include <sys/ioctl.h>
-
-#define HAX_INVALID_FD (-1)
-static inline int hax_invalid_fd(hax_fd fd)
-{
- return fd <= 0;
-}
-
-static inline void hax_mod_close(struct hax_state *hax)
-{
- close(hax->fd);
-}
-
-static inline void hax_close_fd(hax_fd fd)
-{
- close(fd);
-}
-
-/* HAX model level ioctl */
-#define HAX_IOCTL_VERSION _IOWR(0, 0x20, struct hax_module_version)
-#define HAX_IOCTL_CREATE_VM _IOWR(0, 0x21, uint32_t)
-#define HAX_IOCTL_DESTROY_VM _IOW(0, 0x22, uint32_t)
-#define HAX_IOCTL_CAPABILITY _IOR(0, 0x23, struct hax_capabilityinfo)
-
-#define HAX_VM_IOCTL_VCPU_CREATE _IOWR(0, 0x80, uint32_t)
-#define HAX_VM_IOCTL_ALLOC_RAM _IOWR(0, 0x81, struct hax_alloc_ram_info)
-#define HAX_VM_IOCTL_SET_RAM _IOWR(0, 0x82, struct hax_set_ram_info)
-#define HAX_VM_IOCTL_VCPU_DESTROY _IOW(0, 0x83, uint32_t)
-#define HAX_VM_IOCTL_NOTIFY_QEMU_VERSION _IOW(0, 0x84, struct hax_qemu_version)
-#define HAX_VM_IOCTL_ADD_RAMBLOCK _IOW(0, 0x85, struct hax_ramblock_info)
-
-#define HAX_VCPU_IOCTL_RUN _IO(0, 0xc0)
-#define HAX_VCPU_IOCTL_SET_MSRS _IOWR(0, 0xc1, struct hax_msr_data)
-#define HAX_VCPU_IOCTL_GET_MSRS _IOWR(0, 0xc2, struct hax_msr_data)
-
-#define HAX_VCPU_IOCTL_SET_FPU _IOW(0, 0xc3, struct fx_layout)
-#define HAX_VCPU_IOCTL_GET_FPU _IOR(0, 0xc4, struct fx_layout)
-
-#define HAX_VCPU_IOCTL_SETUP_TUNNEL _IOWR(0, 0xc5, struct hax_tunnel_info)
-#define HAX_VCPU_IOCTL_INTERRUPT _IOWR(0, 0xc6, uint32_t)
-#define HAX_VCPU_SET_REGS _IOWR(0, 0xc7, struct vcpu_state_t)
-#define HAX_VCPU_GET_REGS _IOWR(0, 0xc8, struct vcpu_state_t)
-
-#endif /* TARGET_I386_HAX_POSIX_H */
diff --git a/target/i386/hax/hax-windows.h b/target/i386/hax/hax-windows.h
deleted file mode 100644
index b1f5d4f32f..0000000000
--- a/target/i386/hax/hax-windows.h
+++ /dev/null
@@ -1,88 +0,0 @@
-/*
- * QEMU HAXM support
- *
- * Copyright IBM, Corp. 2008
- *
- * Authors:
- * Anthony Liguori <aliguori(a)us.ibm.com>
- *
- * Copyright (c) 2011 Intel Corporation
- * Written by:
- * Jiang Yunhong<yunhong.jiang(a)intel.com>
- * Xin Xiaohui<xiaohui.xin(a)intel.com>
- * Zhang Xiantao<xiantao.zhang(a)intel.com>
- *
- * This work is licensed under the terms of the GNU GPL, version 2 or later.
- * See the COPYING file in the top-level directory.
- *
- */
-
-#ifndef TARGET_I386_HAX_WINDOWS_H
-#define TARGET_I386_HAX_WINDOWS_H
-
-#include <winioctl.h>
-#include <windef.h>
-
-#include "hax-accel-ops.h"
-
-#define HAX_INVALID_FD INVALID_HANDLE_VALUE
-
-static inline void hax_mod_close(struct hax_state *hax)
-{
- CloseHandle(hax->fd);
-}
-
-static inline void hax_close_fd(hax_fd fd)
-{
- CloseHandle(fd);
-}
-
-static inline int hax_invalid_fd(hax_fd fd)
-{
- return (fd == INVALID_HANDLE_VALUE);
-}
-
-#define HAX_DEVICE_TYPE 0x4000
-
-#define HAX_IOCTL_VERSION CTL_CODE(HAX_DEVICE_TYPE, 0x900, \
- METHOD_BUFFERED, FILE_ANY_ACCESS)
-#define HAX_IOCTL_CREATE_VM CTL_CODE(HAX_DEVICE_TYPE, 0x901, \
- METHOD_BUFFERED, FILE_ANY_ACCESS)
-#define HAX_IOCTL_CAPABILITY CTL_CODE(HAX_DEVICE_TYPE, 0x910, \
- METHOD_BUFFERED, FILE_ANY_ACCESS)
-
-#define HAX_VM_IOCTL_VCPU_CREATE CTL_CODE(HAX_DEVICE_TYPE, 0x902, \
- METHOD_BUFFERED, FILE_ANY_ACCESS)
-#define HAX_VM_IOCTL_ALLOC_RAM CTL_CODE(HAX_DEVICE_TYPE, 0x903, \
- METHOD_BUFFERED, FILE_ANY_ACCESS)
-#define HAX_VM_IOCTL_SET_RAM CTL_CODE(HAX_DEVICE_TYPE, 0x904, \
- METHOD_BUFFERED, FILE_ANY_ACCESS)
-#define HAX_VM_IOCTL_VCPU_DESTROY CTL_CODE(HAX_DEVICE_TYPE, 0x905, \
- METHOD_BUFFERED, FILE_ANY_ACCESS)
-#define HAX_VM_IOCTL_ADD_RAMBLOCK CTL_CODE(HAX_DEVICE_TYPE, 0x913, \
- METHOD_BUFFERED, FILE_ANY_ACCESS)
-
-#define HAX_VCPU_IOCTL_RUN CTL_CODE(HAX_DEVICE_TYPE, 0x906, \
- METHOD_BUFFERED, FILE_ANY_ACCESS)
-#define HAX_VCPU_IOCTL_SET_MSRS CTL_CODE(HAX_DEVICE_TYPE, 0x907, \
- METHOD_BUFFERED, FILE_ANY_ACCESS)
-#define HAX_VCPU_IOCTL_GET_MSRS CTL_CODE(HAX_DEVICE_TYPE, 0x908, \
- METHOD_BUFFERED, FILE_ANY_ACCESS)
-#define HAX_VCPU_IOCTL_SET_FPU CTL_CODE(HAX_DEVICE_TYPE, 0x909, \
- METHOD_BUFFERED, FILE_ANY_ACCESS)
-#define HAX_VCPU_IOCTL_GET_FPU CTL_CODE(HAX_DEVICE_TYPE, 0x90a, \
- METHOD_BUFFERED, FILE_ANY_ACCESS)
-
-#define HAX_VCPU_IOCTL_SETUP_TUNNEL CTL_CODE(HAX_DEVICE_TYPE, 0x90b, \
- METHOD_BUFFERED, FILE_ANY_ACCESS)
-#define HAX_VCPU_IOCTL_INTERRUPT CTL_CODE(HAX_DEVICE_TYPE, 0x90c, \
- METHOD_BUFFERED, FILE_ANY_ACCESS)
-#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 /* TARGET_I386_HAX_WINDOWS_H */
diff --git a/accel/stubs/hax-stub.c b/accel/stubs/hax-stub.c
deleted file mode 100644
index 2fe31aaa9a..0000000000
--- a/accel/stubs/hax-stub.c
+++ /dev/null
@@ -1,24 +0,0 @@
-/*
- * QEMU HAXM support
- *
- * Copyright (c) 2015, Intel Corporation
- *
- * Copyright 2016 Google, Inc.
- *
- * This software is licensed under the terms of the GNU General Public
- * License version 2, as published by the Free Software Foundation, and
- * may be copied, distributed, and modified under those terms.
- *
- * See the COPYING file in the top-level directory.
- *
- */
-
-#include "qemu/osdep.h"
-#include "sysemu/hax.h"
-
-bool hax_allowed;
-
-int hax_sync_vcpus(void)
-{
- return 0;
-}
diff --git a/hw/intc/apic_common.c b/hw/intc/apic_common.c
index 4a34f03047..68ad30e2f5 100644
--- a/hw/intc/apic_common.c
+++ b/hw/intc/apic_common.c
@@ -28,7 +28,6 @@
#include "hw/intc/kvm_irqcount.h"
#include "trace.h"
#include "hw/boards.h"
-#include "sysemu/hax.h"
#include "sysemu/kvm.h"
#include "hw/qdev-properties.h"
#include "hw/sysbus.h"
@@ -271,7 +270,7 @@ static void apic_common_realize(DeviceState *dev, Error **errp)
/* Note: We need at least 1M to map the VAPIC option ROM */
if (!vapic && s->vapic_control & VAPIC_ENABLE_MASK &&
- !hax_enabled() && current_machine->ram_size >= 1024 * 1024) {
+ current_machine->ram_size >= 1024 * 1024) {
vapic = sysbus_create_simple("kvmvapic", -1, NULL);
}
s->vapic = vapic;
diff --git a/softmmu/cpus.c b/softmmu/cpus.c
index fed20ffb5d..0848e0dbdb 100644
--- a/softmmu/cpus.c
+++ b/softmmu/cpus.c
@@ -427,12 +427,6 @@ void qemu_wait_io_event(CPUState *cpu)
qemu_plugin_vcpu_resume_cb(cpu);
}
-#ifdef _WIN32
- /* Eat dummy APC queued by cpus_kick_thread. */
- if (hax_enabled()) {
- SleepEx(0, TRUE);
- }
-#endif
qemu_wait_io_event_common(cpu);
}
diff --git a/softmmu/vl.c b/softmmu/vl.c
index b0b96f67fa..5a10b3c309 100644
--- a/softmmu/vl.c
+++ b/softmmu/vl.c
@@ -86,7 +86,6 @@
#include "migration/colo.h"
#include "migration/postcopy-ram.h"
#include "sysemu/kvm.h"
-#include "sysemu/hax.h"
#include "qapi/qobject-input-visitor.h"
#include "qemu/option.h"
#include "qemu/config-file.h"
@@ -2546,11 +2545,6 @@ static void qemu_init_board(void)
drive_check_orphaned();
realtime_init();
-
- if (hax_enabled()) {
- /* FIXME: why isn't cpu_synchronize_all_post_init enough? */
- hax_sync_vcpus();
- }
}
static void qemu_create_cli_devices(void)
diff --git a/target/i386/hax/hax-accel-ops.c b/target/i386/hax/hax-accel-ops.c
deleted file mode 100644
index 5031096760..0000000000
--- a/target/i386/hax/hax-accel-ops.c
+++ /dev/null
@@ -1,105 +0,0 @@
-/*
- * QEMU HAX support
- *
- * Copyright IBM, Corp. 2008
- * Red Hat, Inc. 2008
- *
- * Authors:
- * Anthony Liguori <aliguori(a)us.ibm.com>
- * Glauber Costa <gcosta(a)redhat.com>
- *
- * Copyright (c) 2011 Intel Corporation
- * Written by:
- * Jiang Yunhong<yunhong.jiang(a)intel.com>
- * Xin Xiaohui<xiaohui.xin(a)intel.com>
- * Zhang Xiantao<xiantao.zhang(a)intel.com>
- *
- * This work is licensed under the terms of the GNU GPL, version 2 or later.
- * See the COPYING file in the top-level directory.
- *
- */
-
-#include "qemu/osdep.h"
-#include "qemu/error-report.h"
-#include "qemu/main-loop.h"
-#include "sysemu/runstate.h"
-#include "sysemu/cpus.h"
-#include "qemu/guest-random.h"
-
-#include "hax-accel-ops.h"
-
-static void *hax_cpu_thread_fn(void *arg)
-{
- CPUState *cpu = arg;
- int r;
-
- rcu_register_thread();
- qemu_mutex_lock_iothread();
- qemu_thread_get_self(cpu->thread);
-
- cpu->thread_id = qemu_get_thread_id();
- current_cpu = cpu;
- hax_init_vcpu(cpu);
- cpu_thread_signal_created(cpu);
- qemu_guest_random_seed_thread_part2(cpu->random_seed);
-
- do {
- if (cpu_can_run(cpu)) {
- r = hax_smp_cpu_exec(cpu);
- if (r == EXCP_DEBUG) {
- cpu_handle_guest_debug(cpu);
- }
- }
-
- qemu_wait_io_event(cpu);
- } while (!cpu->unplug || cpu_can_run(cpu));
- hax_vcpu_destroy(cpu);
- cpu_thread_signal_destroyed(cpu);
- rcu_unregister_thread();
- return NULL;
-}
-
-static void hax_start_vcpu_thread(CPUState *cpu)
-{
- char thread_name[VCPU_THREAD_NAME_SIZE];
-
- cpu->thread = g_new0(QemuThread, 1);
- cpu->halt_cond = g_new0(QemuCond, 1);
- qemu_cond_init(cpu->halt_cond);
-
- snprintf(thread_name, VCPU_THREAD_NAME_SIZE, "CPU %d/HAX",
- cpu->cpu_index);
- qemu_thread_create(cpu->thread, thread_name, hax_cpu_thread_fn,
- cpu, QEMU_THREAD_JOINABLE);
- assert(cpu->accel);
-#ifdef _WIN32
- cpu->accel->hThread = qemu_thread_get_handle(cpu->thread);
-#endif
-}
-
-static void hax_accel_ops_class_init(ObjectClass *oc, void *data)
-{
- AccelOpsClass *ops = ACCEL_OPS_CLASS(oc);
-
- ops->create_vcpu_thread = hax_start_vcpu_thread;
- ops->kick_vcpu_thread = hax_kick_vcpu_thread;
-
- ops->synchronize_post_reset = hax_cpu_synchronize_post_reset;
- ops->synchronize_post_init = hax_cpu_synchronize_post_init;
- ops->synchronize_state = hax_cpu_synchronize_state;
- ops->synchronize_pre_loadvm = hax_cpu_synchronize_pre_loadvm;
-}
-
-static const TypeInfo hax_accel_ops_type = {
- .name = ACCEL_OPS_NAME("hax"),
-
- .parent = TYPE_ACCEL_OPS,
- .class_init = hax_accel_ops_class_init,
- .abstract = true,
-};
-
-static void hax_accel_ops_register_types(void)
-{
- type_register_static(&hax_accel_ops_type);
-}
-type_init(hax_accel_ops_register_types);
diff --git a/target/i386/hax/hax-all.c b/target/i386/hax/hax-all.c
deleted file mode 100644
index 18d78e5b6b..0000000000
--- a/target/i386/hax/hax-all.c
+++ /dev/null
@@ -1,1141 +0,0 @@
-/*
- * QEMU HAX support
- *
- * Copyright IBM, Corp. 2008
- * Red Hat, Inc. 2008
- *
- * Authors:
- * Anthony Liguori <aliguori(a)us.ibm.com>
- * Glauber Costa <gcosta(a)redhat.com>
- *
- * Copyright (c) 2011 Intel Corporation
- * Written by:
- * Jiang Yunhong<yunhong.jiang(a)intel.com>
- * Xin Xiaohui<xiaohui.xin(a)intel.com>
- * Zhang Xiantao<xiantao.zhang(a)intel.com>
- *
- * This work is licensed under the terms of the GNU GPL, version 2 or later.
- * See the COPYING file in the top-level directory.
- *
- */
-
-/*
- * HAX common code for both windows and darwin
- */
-
-#include "qemu/osdep.h"
-#include "cpu.h"
-#include "exec/address-spaces.h"
-
-#include "qemu/accel.h"
-#include "sysemu/reset.h"
-#include "sysemu/runstate.h"
-#include "hw/boards.h"
-
-#include "hax-accel-ops.h"
-
-#define DEBUG_HAX 0
-
-#define DPRINTF(fmt, ...) \
- do { \
- if (DEBUG_HAX) { \
- fprintf(stdout, fmt, ## __VA_ARGS__); \
- } \
- } while (0)
-
-/* Current version */
-const uint32_t hax_cur_version = 0x4; /* API v4: unmapping and MMIO moves */
-/* Minimum HAX kernel version */
-const uint32_t hax_min_version = 0x4; /* API v4: supports unmapping */
-
-bool hax_allowed;
-
-struct hax_state hax_global;
-
-static void hax_vcpu_sync_state(CPUArchState *env, int modified);
-static int hax_arch_get_registers(CPUArchState *env);
-
-int valid_hax_tunnel_size(uint16_t size)
-{
- return size >= sizeof(struct hax_tunnel);
-}
-
-hax_fd hax_vcpu_get_fd(CPUArchState *env)
-{
- AccelCPUState *vcpu = env_cpu(env)->accel;
- if (!vcpu) {
- return HAX_INVALID_FD;
- }
- return vcpu->fd;
-}
-
-static int hax_get_capability(struct hax_state *hax)
-{
- int ret;
- struct hax_capabilityinfo capinfo, *cap = &capinfo;
-
- ret = hax_capability(hax, cap);
- if (ret) {
- return ret;
- }
-
- if ((cap->wstatus & HAX_CAP_WORKSTATUS_MASK) == HAX_CAP_STATUS_NOTWORKING) {
- if (cap->winfo & HAX_CAP_FAILREASON_VT) {
- DPRINTF
- ("VTX feature is not enabled, HAX driver will not work.\n");
- } else if (cap->winfo & HAX_CAP_FAILREASON_NX) {
- DPRINTF
- ("NX feature is not enabled, HAX driver will not work.\n");
- }
- return -ENXIO;
-
- }
-
- if (!(cap->winfo & HAX_CAP_UG)) {
- fprintf(stderr, "UG mode is not supported by the hardware.\n");
- return -ENOTSUP;
- }
-
- hax->supports_64bit_ramblock = !!(cap->winfo & HAX_CAP_64BIT_RAMBLOCK);
-
- if (cap->wstatus & HAX_CAP_MEMQUOTA) {
- if (cap->mem_quota < hax->mem_quota) {
- fprintf(stderr, "The VM memory needed exceeds the driver limit.\n");
- return -ENOSPC;
- }
- }
- return 0;
-}
-
-static int hax_version_support(struct hax_state *hax)
-{
- int ret;
- struct hax_module_version version;
-
- ret = hax_mod_version(hax, &version);
- if (ret < 0) {
- return 0;
- }
-
- if (hax_min_version > version.cur_version) {
- fprintf(stderr, "Incompatible HAX module version %d,",
- version.cur_version);
- fprintf(stderr, "requires minimum version %d\n", hax_min_version);
- return 0;
- }
- if (hax_cur_version < version.compat_version) {
- fprintf(stderr, "Incompatible QEMU HAX API version %x,",
- hax_cur_version);
- fprintf(stderr, "requires minimum HAX API version %x\n",
- version.compat_version);
- return 0;
- }
-
- return 1;
-}
-
-int hax_vcpu_create(int id)
-{
- AccelCPUState *vcpu = NULL;
- int ret;
-
- if (!hax_global.vm) {
- fprintf(stderr, "vcpu %x created failed, vm is null\n", id);
- return -1;
- }
-
- if (hax_global.vm->vcpus[id]) {
- fprintf(stderr, "vcpu %x allocated already\n", id);
- return 0;
- }
-
- vcpu = g_new0(AccelCPUState, 1);
-
- ret = hax_host_create_vcpu(hax_global.vm->fd, id);
- if (ret) {
- fprintf(stderr, "Failed to create vcpu %x\n", id);
- goto error;
- }
-
- vcpu->vcpu_id = id;
- vcpu->fd = hax_host_open_vcpu(hax_global.vm->id, id);
- if (hax_invalid_fd(vcpu->fd)) {
- fprintf(stderr, "Failed to open the vcpu\n");
- ret = -ENODEV;
- goto error;
- }
-
- hax_global.vm->vcpus[id] = vcpu;
-
- ret = hax_host_setup_vcpu_channel(vcpu);
- if (ret) {
- fprintf(stderr, "Invalid hax tunnel size\n");
- ret = -EINVAL;
- goto error;
- }
- return 0;
-
- error:
- /* vcpu and tunnel will be closed automatically */
- if (vcpu && !hax_invalid_fd(vcpu->fd)) {
- hax_close_fd(vcpu->fd);
- }
-
- hax_global.vm->vcpus[id] = NULL;
- g_free(vcpu);
- return -1;
-}
-
-int hax_vcpu_destroy(CPUState *cpu)
-{
- AccelCPUState *vcpu = cpu->accel;
-
- if (!hax_global.vm) {
- fprintf(stderr, "vcpu %x destroy failed, vm is null\n", vcpu->vcpu_id);
- return -1;
- }
-
- if (!vcpu) {
- return 0;
- }
-
- /*
- * 1. The hax_tunnel is also destroyed when vcpu is destroyed
- * 2. close fd will cause hax module vcpu be cleaned
- */
- hax_close_fd(vcpu->fd);
- hax_global.vm->vcpus[vcpu->vcpu_id] = NULL;
-#ifdef _WIN32
- CloseHandle(vcpu->hThread);
-#endif
- g_free(vcpu);
- cpu->accel = NULL;
- return 0;
-}
-
-int hax_init_vcpu(CPUState *cpu)
-{
- int ret;
-
- ret = hax_vcpu_create(cpu->cpu_index);
- if (ret < 0) {
- fprintf(stderr, "Failed to create HAX vcpu\n");
- exit(-1);
- }
-
- cpu->accel = hax_global.vm->vcpus[cpu->cpu_index];
- cpu->vcpu_dirty = true;
- qemu_register_reset(hax_reset_vcpu_state, cpu->env_ptr);
-
- return ret;
-}
-
-struct hax_vm *hax_vm_create(struct hax_state *hax, int max_cpus)
-{
- struct hax_vm *vm;
- int vm_id = 0, ret, i;
-
- if (hax_invalid_fd(hax->fd)) {
- return NULL;
- }
-
- if (hax->vm) {
- return hax->vm;
- }
-
- if (max_cpus > HAX_MAX_VCPU) {
- fprintf(stderr, "Maximum VCPU number QEMU supported is %d\n", HAX_MAX_VCPU);
- return NULL;
- }
-
- vm = g_new0(struct hax_vm, 1);
-
- ret = hax_host_create_vm(hax, &vm_id);
- if (ret) {
- fprintf(stderr, "Failed to create vm %x\n", ret);
- goto error;
- }
- vm->id = vm_id;
- vm->fd = hax_host_open_vm(hax, vm_id);
- if (hax_invalid_fd(vm->fd)) {
- fprintf(stderr, "Failed to open vm %d\n", vm_id);
- goto error;
- }
-
- vm->numvcpus = max_cpus;
- vm->vcpus = g_new0(AccelCPUState *, vm->numvcpus);
- for (i = 0; i < vm->numvcpus; i++) {
- vm->vcpus[i] = NULL;
- }
-
- hax->vm = vm;
- return vm;
-
- error:
- g_free(vm);
- hax->vm = NULL;
- return NULL;
-}
-
-int hax_vm_destroy(struct hax_vm *vm)
-{
- int i;
-
- for (i = 0; i < vm->numvcpus; i++)
- if (vm->vcpus[i]) {
- fprintf(stderr, "VCPU should be cleaned before vm clean\n");
- return -1;
- }
- hax_close_fd(vm->fd);
- vm->numvcpus = 0;
- g_free(vm->vcpus);
- g_free(vm);
- hax_global.vm = NULL;
- return 0;
-}
-
-static int hax_init(ram_addr_t ram_size, int max_cpus)
-{
- struct hax_state *hax = NULL;
- struct hax_qemu_version qversion;
- int ret;
-
- hax = &hax_global;
-
- memset(hax, 0, sizeof(struct hax_state));
- hax->mem_quota = ram_size;
-
- hax->fd = hax_mod_open();
- if (hax_invalid_fd(hax->fd)) {
- hax->fd = 0;
- ret = -ENODEV;
- goto error;
- }
-
- ret = hax_get_capability(hax);
-
- if (ret) {
- if (ret != -ENOSPC) {
- ret = -EINVAL;
- }
- goto error;
- }
-
- if (!hax_version_support(hax)) {
- ret = -EINVAL;
- goto error;
- }
-
- hax->vm = hax_vm_create(hax, max_cpus);
- if (!hax->vm) {
- fprintf(stderr, "Failed to create HAX VM\n");
- ret = -EINVAL;
- goto error;
- }
-
- hax_memory_init();
-
- qversion.cur_version = hax_cur_version;
- qversion.min_version = hax_min_version;
- hax_notify_qemu_version(hax->vm->fd, &qversion);
-
- return ret;
- error:
- if (hax->vm) {
- hax_vm_destroy(hax->vm);
- }
- if (hax->fd) {
- hax_mod_close(hax);
- }
-
- return ret;
-}
-
-static int hax_accel_init(MachineState *ms)
-{
- int ret = hax_init(ms->ram_size, (int)ms->smp.max_cpus);
-
- if (ret && (ret != -ENOSPC)) {
- fprintf(stderr, "No accelerator found.\n");
- } else {
- fprintf(stdout, "HAX is %s and emulator runs in %s mode.\n",
- !ret ? "working" : "not working",
- !ret ? "fast virt" : "emulation");
- fprintf(stdout,
- "NOTE: HAX is deprecated and will be removed in a future release.\n"
- " Use 'whpx' (on Windows) or 'hvf' (on macOS) instead.\n");
- }
- return ret;
-}
-
-static int hax_handle_fastmmio(CPUArchState *env, struct hax_fastmmio *hft)
-{
- if (hft->direction < 2) {
- cpu_physical_memory_rw(hft->gpa, &hft->value, hft->size,
- hft->direction);
- } else {
- /*
- * HAX API v4 supports transferring data between two MMIO addresses,
- * hft->gpa and hft->gpa2 (instructions such as MOVS require this):
- * hft->direction == 2: gpa ==> gpa2
- */
- uint64_t value;
- cpu_physical_memory_read(hft->gpa, &value, hft->size);
- cpu_physical_memory_write(hft->gpa2, &value, hft->size);
- }
-
- return 0;
-}
-
-static int hax_handle_io(CPUArchState *env, uint32_t df, uint16_t port,
- int direction, int size, int count, void *buffer)
-{
- uint8_t *ptr;
- int i;
- MemTxAttrs attrs = { 0 };
-
- if (!df) {
- ptr = buffer;
- } else {
- ptr = buffer + size * count - size;
- }
- for (i = 0; i < count; i++) {
- address_space_rw(&address_space_io, port, attrs,
- ptr, size, direction == HAX_EXIT_IO_OUT);
- if (!df) {
- ptr += size;
- } else {
- ptr -= size;
- }
- }
-
- return 0;
-}
-
-static int hax_vcpu_interrupt(CPUArchState *env)
-{
- CPUState *cpu = env_cpu(env);
- AccelCPUState *vcpu = cpu->accel;
- struct hax_tunnel *ht = vcpu->tunnel;
-
- /*
- * Try to inject an interrupt if the guest can accept it
- * Unlike KVM, HAX kernel check for the eflags, instead of qemu
- */
- if (ht->ready_for_interrupt_injection &&
- (cpu->interrupt_request & CPU_INTERRUPT_HARD)) {
- int irq;
-
- irq = cpu_get_pic_interrupt(env);
- if (irq >= 0) {
- hax_inject_interrupt(env, irq);
- cpu->interrupt_request &= ~CPU_INTERRUPT_HARD;
- }
- }
-
- /* If we have an interrupt but the guest is not ready to receive an
- * interrupt, request an interrupt window exit. This will
- * cause a return to userspace as soon as the guest is ready to
- * receive interrupts. */
- if ((cpu->interrupt_request & CPU_INTERRUPT_HARD)) {
- ht->request_interrupt_window = 1;
- } else {
- ht->request_interrupt_window = 0;
- }
- return 0;
-}
-
-void hax_raise_event(CPUState *cpu)
-{
- AccelCPUState *vcpu = cpu->accel;
-
- if (!vcpu) {
- return;
- }
- vcpu->tunnel->user_event_pending = 1;
-}
-
-/*
- * Ask hax kernel module to run the CPU for us till:
- * 1. Guest crash or shutdown
- * 2. Need QEMU's emulation like guest execute MMIO instruction
- * 3. Guest execute HLT
- * 4. QEMU have Signal/event pending
- * 5. An unknown VMX exit happens
- */
-static int hax_vcpu_hax_exec(CPUArchState *env)
-{
- int ret = 0;
- CPUState *cpu = env_cpu(env);
- X86CPU *x86_cpu = X86_CPU(cpu);
- AccelCPUState *vcpu = cpu->accel;
- struct hax_tunnel *ht = vcpu->tunnel;
-
- if (!hax_enabled()) {
- DPRINTF("Trying to vcpu execute at eip:" TARGET_FMT_lx "\n", env->eip);
- return 0;
- }
-
- if (cpu->interrupt_request & CPU_INTERRUPT_POLL) {
- cpu->interrupt_request &= ~CPU_INTERRUPT_POLL;
- apic_poll_irq(x86_cpu->apic_state);
- }
-
- /* After a vcpu is halted (either because it is an AP and has just been
- * reset, or because it has executed the HLT instruction), it will not be
- * run (hax_vcpu_run()) until it is unhalted. The next few if blocks check
- * for events that may change the halted state of this vcpu:
- * a) Maskable interrupt, when RFLAGS.IF is 1;
- * Note: env->eflags may not reflect the current RFLAGS state, because
- * it is not updated after each hax_vcpu_run(). We cannot afford
- * to fail to recognize any unhalt-by-maskable-interrupt event
- * (in which case the vcpu will halt forever), and yet we cannot
- * afford the overhead of hax_vcpu_sync_state(). The current
- * solution is to err on the side of caution and have the HLT
- * handler (see case HAX_EXIT_HLT below) unconditionally set the
- * IF_MASK bit in env->eflags, which, in effect, disables the
- * RFLAGS.IF check.
- * b) NMI;
- * c) INIT signal;
- * d) SIPI signal.
- */
- if (((cpu->interrupt_request & CPU_INTERRUPT_HARD) &&
- (env->eflags & IF_MASK)) ||
- (cpu->interrupt_request & CPU_INTERRUPT_NMI)) {
- cpu->halted = 0;
- }
-
- if (cpu->interrupt_request & CPU_INTERRUPT_INIT) {
- DPRINTF("\nhax_vcpu_hax_exec: handling INIT for %d\n",
- cpu->cpu_index);
- do_cpu_init(x86_cpu);
- hax_vcpu_sync_state(env, 1);
- }
-
- if (cpu->interrupt_request & CPU_INTERRUPT_SIPI) {
- DPRINTF("hax_vcpu_hax_exec: handling SIPI for %d\n",
- cpu->cpu_index);
- hax_vcpu_sync_state(env, 0);
- do_cpu_sipi(x86_cpu);
- hax_vcpu_sync_state(env, 1);
- }
-
- if (cpu->halted) {
- /* If this vcpu is halted, we must not ask HAXM to run it. Instead, we
- * break out of hax_smp_cpu_exec() as if this vcpu had executed HLT.
- * That way, this vcpu thread will be trapped in qemu_wait_io_event(),
- * until the vcpu is unhalted.
- */
- cpu->exception_index = EXCP_HLT;
- return 0;
- }
-
- do {
- int hax_ret;
-
- if (cpu->exit_request) {
- ret = 1;
- break;
- }
-
- hax_vcpu_interrupt(env);
-
- qemu_mutex_unlock_iothread();
- cpu_exec_start(cpu);
- hax_ret = hax_vcpu_run(vcpu);
- cpu_exec_end(cpu);
- qemu_mutex_lock_iothread();
-
- /* Simply continue the vcpu_run if system call interrupted */
- if (hax_ret == -EINTR || hax_ret == -EAGAIN) {
- DPRINTF("io window interrupted\n");
- continue;
- }
-
- if (hax_ret < 0) {
- fprintf(stderr, "vcpu run failed for vcpu %x\n", vcpu->vcpu_id);
- abort();
- }
- switch (ht->_exit_status) {
- case HAX_EXIT_IO:
- ret = hax_handle_io(env, ht->pio._df, ht->pio._port,
- ht->pio._direction,
- ht->pio._size, ht->pio._count, vcpu->iobuf);
- break;
- case HAX_EXIT_FAST_MMIO:
- ret = hax_handle_fastmmio(env, (struct hax_fastmmio *) vcpu->iobuf);
- break;
- /* Guest state changed, currently only for shutdown */
- case HAX_EXIT_STATECHANGE:
- fprintf(stdout, "VCPU shutdown request\n");
- qemu_system_shutdown_request(SHUTDOWN_CAUSE_GUEST_SHUTDOWN);
- hax_vcpu_sync_state(env, 0);
- ret = 1;
- break;
- case HAX_EXIT_UNKNOWN_VMEXIT:
- fprintf(stderr, "Unknown VMX exit %x from guest\n",
- ht->_exit_reason);
- qemu_system_reset_request(SHUTDOWN_CAUSE_GUEST_RESET);
- hax_vcpu_sync_state(env, 0);
- cpu_dump_state(cpu, stderr, 0);
- ret = -1;
- break;
- case HAX_EXIT_HLT:
- if (!(cpu->interrupt_request & CPU_INTERRUPT_HARD) &&
- !(cpu->interrupt_request & CPU_INTERRUPT_NMI)) {
- /* hlt instruction with interrupt disabled is shutdown */
- env->eflags |= IF_MASK;
- cpu->halted = 1;
- cpu->exception_index = EXCP_HLT;
- ret = 1;
- }
- break;
- /* these situations will continue to hax module */
- case HAX_EXIT_INTERRUPT:
- case HAX_EXIT_PAUSED:
- break;
- case HAX_EXIT_MMIO:
- /* Should not happen on UG system */
- fprintf(stderr, "HAX: unsupported MMIO emulation\n");
- ret = -1;
- break;
- case HAX_EXIT_REAL:
- /* Should not happen on UG system */
- fprintf(stderr, "HAX: unimplemented real mode emulation\n");
- ret = -1;
- break;
- default:
- fprintf(stderr, "Unknown exit %x from HAX\n", ht->_exit_status);
- qemu_system_reset_request(SHUTDOWN_CAUSE_GUEST_RESET);
- hax_vcpu_sync_state(env, 0);
- cpu_dump_state(cpu, stderr, 0);
- ret = 1;
- break;
- }
- } while (!ret);
-
- if (cpu->exit_request) {
- cpu->exit_request = 0;
- cpu->exception_index = EXCP_INTERRUPT;
- }
- return ret < 0;
-}
-
-static void do_hax_cpu_synchronize_state(CPUState *cpu, run_on_cpu_data arg)
-{
- CPUArchState *env = cpu->env_ptr;
-
- hax_arch_get_registers(env);
- cpu->vcpu_dirty = true;
-}
-
-void hax_cpu_synchronize_state(CPUState *cpu)
-{
- if (!cpu->vcpu_dirty) {
- run_on_cpu(cpu, do_hax_cpu_synchronize_state, RUN_ON_CPU_NULL);
- }
-}
-
-static void do_hax_cpu_synchronize_post_reset(CPUState *cpu,
- run_on_cpu_data arg)
-{
- CPUArchState *env = cpu->env_ptr;
-
- hax_vcpu_sync_state(env, 1);
- cpu->vcpu_dirty = false;
-}
-
-void hax_cpu_synchronize_post_reset(CPUState *cpu)
-{
- run_on_cpu(cpu, do_hax_cpu_synchronize_post_reset, RUN_ON_CPU_NULL);
-}
-
-static void do_hax_cpu_synchronize_post_init(CPUState *cpu, run_on_cpu_data arg)
-{
- CPUArchState *env = cpu->env_ptr;
-
- hax_vcpu_sync_state(env, 1);
- cpu->vcpu_dirty = false;
-}
-
-void hax_cpu_synchronize_post_init(CPUState *cpu)
-{
- run_on_cpu(cpu, do_hax_cpu_synchronize_post_init, RUN_ON_CPU_NULL);
-}
-
-static void do_hax_cpu_synchronize_pre_loadvm(CPUState *cpu, run_on_cpu_data arg)
-{
- cpu->vcpu_dirty = true;
-}
-
-void hax_cpu_synchronize_pre_loadvm(CPUState *cpu)
-{
- run_on_cpu(cpu, do_hax_cpu_synchronize_pre_loadvm, RUN_ON_CPU_NULL);
-}
-
-int hax_smp_cpu_exec(CPUState *cpu)
-{
- CPUArchState *env = cpu->env_ptr;
- int fatal;
- int ret;
-
- while (1) {
- if (cpu->exception_index >= EXCP_INTERRUPT) {
- ret = cpu->exception_index;
- cpu->exception_index = -1;
- break;
- }
-
- fatal = hax_vcpu_hax_exec(env);
-
- if (fatal) {
- fprintf(stderr, "Unsupported HAX vcpu return\n");
- abort();
- }
- }
-
- return ret;
-}
-
-static void set_v8086_seg(struct segment_desc_t *lhs, const SegmentCache *rhs)
-{
- memset(lhs, 0, sizeof(struct segment_desc_t));
- lhs->selector = rhs->selector;
- lhs->base = rhs->base;
- lhs->limit = rhs->limit;
- lhs->type = 3;
- lhs->present = 1;
- lhs->dpl = 3;
- lhs->operand_size = 0;
- lhs->desc = 1;
- lhs->long_mode = 0;
- lhs->granularity = 0;
- lhs->available = 0;
-}
-
-static void get_seg(SegmentCache *lhs, const struct segment_desc_t *rhs)
-{
- lhs->selector = rhs->selector;
- lhs->base = rhs->base;
- lhs->limit = rhs->limit;
- lhs->flags = (rhs->type << DESC_TYPE_SHIFT)
- | (rhs->present * DESC_P_MASK)
- | (rhs->dpl << DESC_DPL_SHIFT)
- | (rhs->operand_size << DESC_B_SHIFT)
- | (rhs->desc * DESC_S_MASK)
- | (rhs->long_mode << DESC_L_SHIFT)
- | (rhs->granularity * DESC_G_MASK) | (rhs->available * DESC_AVL_MASK);
-}
-
-static void set_seg(struct segment_desc_t *lhs, const SegmentCache *rhs)
-{
- unsigned flags = rhs->flags;
-
- memset(lhs, 0, sizeof(struct segment_desc_t));
- lhs->selector = rhs->selector;
- lhs->base = rhs->base;
- lhs->limit = rhs->limit;
- lhs->type = (flags >> DESC_TYPE_SHIFT) & 15;
- lhs->present = (flags & DESC_P_MASK) != 0;
- lhs->dpl = rhs->selector & 3;
- lhs->operand_size = (flags >> DESC_B_SHIFT) & 1;
- lhs->desc = (flags & DESC_S_MASK) != 0;
- lhs->long_mode = (flags >> DESC_L_SHIFT) & 1;
- lhs->granularity = (flags & DESC_G_MASK) != 0;
- lhs->available = (flags & DESC_AVL_MASK) != 0;
-}
-
-static void hax_getput_reg(uint64_t *hax_reg, target_ulong *qemu_reg, int set)
-{
- target_ulong reg = *hax_reg;
-
- if (set) {
- *hax_reg = *qemu_reg;
- } else {
- *qemu_reg = reg;
- }
-}
-
-/* The sregs has been synced with HAX kernel already before this call */
-static int hax_get_segments(CPUArchState *env, struct vcpu_state_t *sregs)
-{
- get_seg(&env->segs[R_CS], &sregs->_cs);
- get_seg(&env->segs[R_DS], &sregs->_ds);
- get_seg(&env->segs[R_ES], &sregs->_es);
- get_seg(&env->segs[R_FS], &sregs->_fs);
- get_seg(&env->segs[R_GS], &sregs->_gs);
- get_seg(&env->segs[R_SS], &sregs->_ss);
-
- get_seg(&env->tr, &sregs->_tr);
- get_seg(&env->ldt, &sregs->_ldt);
- env->idt.limit = sregs->_idt.limit;
- env->idt.base = sregs->_idt.base;
- env->gdt.limit = sregs->_gdt.limit;
- env->gdt.base = sregs->_gdt.base;
- return 0;
-}
-
-static int hax_set_segments(CPUArchState *env, struct vcpu_state_t *sregs)
-{
- if ((env->eflags & VM_MASK)) {
- set_v8086_seg(&sregs->_cs, &env->segs[R_CS]);
- set_v8086_seg(&sregs->_ds, &env->segs[R_DS]);
- set_v8086_seg(&sregs->_es, &env->segs[R_ES]);
- set_v8086_seg(&sregs->_fs, &env->segs[R_FS]);
- set_v8086_seg(&sregs->_gs, &env->segs[R_GS]);
- set_v8086_seg(&sregs->_ss, &env->segs[R_SS]);
- } else {
- set_seg(&sregs->_cs, &env->segs[R_CS]);
- set_seg(&sregs->_ds, &env->segs[R_DS]);
- set_seg(&sregs->_es, &env->segs[R_ES]);
- set_seg(&sregs->_fs, &env->segs[R_FS]);
- set_seg(&sregs->_gs, &env->segs[R_GS]);
- set_seg(&sregs->_ss, &env->segs[R_SS]);
-
- if (env->cr[0] & CR0_PE_MASK) {
- /* force ss cpl to cs cpl */
- sregs->_ss.selector = (sregs->_ss.selector & ~3) |
- (sregs->_cs.selector & 3);
- sregs->_ss.dpl = sregs->_ss.selector & 3;
- }
- }
-
- set_seg(&sregs->_tr, &env->tr);
- set_seg(&sregs->_ldt, &env->ldt);
- sregs->_idt.limit = env->idt.limit;
- sregs->_idt.base = env->idt.base;
- sregs->_gdt.limit = env->gdt.limit;
- sregs->_gdt.base = env->gdt.base;
- return 0;
-}
-
-static int hax_sync_vcpu_register(CPUArchState *env, int set)
-{
- struct vcpu_state_t regs;
- int ret;
- memset(®s, 0, sizeof(struct vcpu_state_t));
-
- if (!set) {
- ret = hax_sync_vcpu_state(env, ®s, 0);
- if (ret < 0) {
- return -1;
- }
- }
-
- /* generic register */
- hax_getput_reg(®s._rax, &env->regs[R_EAX], set);
- hax_getput_reg(®s._rbx, &env->regs[R_EBX], set);
- hax_getput_reg(®s._rcx, &env->regs[R_ECX], set);
- hax_getput_reg(®s._rdx, &env->regs[R_EDX], set);
- hax_getput_reg(®s._rsi, &env->regs[R_ESI], set);
- hax_getput_reg(®s._rdi, &env->regs[R_EDI], set);
- hax_getput_reg(®s._rsp, &env->regs[R_ESP], set);
- hax_getput_reg(®s._rbp, &env->regs[R_EBP], set);
-#ifdef TARGET_X86_64
- hax_getput_reg(®s._r8, &env->regs[8], set);
- hax_getput_reg(®s._r9, &env->regs[9], set);
- hax_getput_reg(®s._r10, &env->regs[10], set);
- hax_getput_reg(®s._r11, &env->regs[11], set);
- hax_getput_reg(®s._r12, &env->regs[12], set);
- hax_getput_reg(®s._r13, &env->regs[13], set);
- hax_getput_reg(®s._r14, &env->regs[14], set);
- hax_getput_reg(®s._r15, &env->regs[15], set);
-#endif
- hax_getput_reg(®s._rflags, &env->eflags, set);
- hax_getput_reg(®s._rip, &env->eip, set);
-
- if (set) {
- regs._cr0 = env->cr[0];
- regs._cr2 = env->cr[2];
- regs._cr3 = env->cr[3];
- regs._cr4 = env->cr[4];
- hax_set_segments(env, ®s);
- } else {
- env->cr[0] = regs._cr0;
- env->cr[2] = regs._cr2;
- env->cr[3] = regs._cr3;
- env->cr[4] = regs._cr4;
- hax_get_segments(env, ®s);
- }
-
- if (set) {
- ret = hax_sync_vcpu_state(env, ®s, 1);
- if (ret < 0) {
- return -1;
- }
- }
- return 0;
-}
-
-static void hax_msr_entry_set(struct vmx_msr *item, uint32_t index,
- uint64_t value)
-{
- item->entry = index;
- item->value = value;
-}
-
-static int hax_get_msrs(CPUArchState *env)
-{
- struct hax_msr_data md;
- struct vmx_msr *msrs = md.entries;
- int ret, i, n;
-
- n = 0;
- msrs[n++].entry = MSR_IA32_SYSENTER_CS;
- msrs[n++].entry = MSR_IA32_SYSENTER_ESP;
- msrs[n++].entry = MSR_IA32_SYSENTER_EIP;
- msrs[n++].entry = MSR_IA32_TSC;
-#ifdef TARGET_X86_64
- msrs[n++].entry = MSR_EFER;
- msrs[n++].entry = MSR_STAR;
- msrs[n++].entry = MSR_LSTAR;
- msrs[n++].entry = MSR_CSTAR;
- msrs[n++].entry = MSR_FMASK;
- msrs[n++].entry = MSR_KERNELGSBASE;
-#endif
- md.nr_msr = n;
- ret = hax_sync_msr(env, &md, 0);
- if (ret < 0) {
- return ret;
- }
-
- for (i = 0; i < md.done; i++) {
- switch (msrs[i].entry) {
- case MSR_IA32_SYSENTER_CS:
- env->sysenter_cs = msrs[i].value;
- break;
- case MSR_IA32_SYSENTER_ESP:
- env->sysenter_esp = msrs[i].value;
- break;
- case MSR_IA32_SYSENTER_EIP:
- env->sysenter_eip = msrs[i].value;
- break;
- case MSR_IA32_TSC:
- env->tsc = msrs[i].value;
- break;
-#ifdef TARGET_X86_64
- case MSR_EFER:
- env->efer = msrs[i].value;
- break;
- case MSR_STAR:
- env->star = msrs[i].value;
- break;
- case MSR_LSTAR:
- env->lstar = msrs[i].value;
- break;
- case MSR_CSTAR:
- env->cstar = msrs[i].value;
- break;
- case MSR_FMASK:
- env->fmask = msrs[i].value;
- break;
- case MSR_KERNELGSBASE:
- env->kernelgsbase = msrs[i].value;
- break;
-#endif
- }
- }
-
- return 0;
-}
-
-static int hax_set_msrs(CPUArchState *env)
-{
- struct hax_msr_data md;
- struct vmx_msr *msrs;
- msrs = md.entries;
- int n = 0;
-
- memset(&md, 0, sizeof(struct hax_msr_data));
- hax_msr_entry_set(&msrs[n++], MSR_IA32_SYSENTER_CS, env->sysenter_cs);
- hax_msr_entry_set(&msrs[n++], MSR_IA32_SYSENTER_ESP, env->sysenter_esp);
- hax_msr_entry_set(&msrs[n++], MSR_IA32_SYSENTER_EIP, env->sysenter_eip);
- hax_msr_entry_set(&msrs[n++], MSR_IA32_TSC, env->tsc);
-#ifdef TARGET_X86_64
- hax_msr_entry_set(&msrs[n++], MSR_EFER, env->efer);
- hax_msr_entry_set(&msrs[n++], MSR_STAR, env->star);
- hax_msr_entry_set(&msrs[n++], MSR_LSTAR, env->lstar);
- hax_msr_entry_set(&msrs[n++], MSR_CSTAR, env->cstar);
- hax_msr_entry_set(&msrs[n++], MSR_FMASK, env->fmask);
- hax_msr_entry_set(&msrs[n++], MSR_KERNELGSBASE, env->kernelgsbase);
-#endif
- md.nr_msr = n;
- md.done = 0;
-
- return hax_sync_msr(env, &md, 1);
-}
-
-static int hax_get_fpu(CPUArchState *env)
-{
- struct fx_layout fpu;
- int i, ret;
-
- ret = hax_sync_fpu(env, &fpu, 0);
- if (ret < 0) {
- return ret;
- }
-
- env->fpstt = (fpu.fsw >> 11) & 7;
- env->fpus = fpu.fsw;
- env->fpuc = fpu.fcw;
- for (i = 0; i < 8; ++i) {
- env->fptags[i] = !((fpu.ftw >> i) & 1);
- }
- memcpy(env->fpregs, fpu.st_mm, sizeof(env->fpregs));
-
- for (i = 0; i < 8; i++) {
- env->xmm_regs[i].ZMM_Q(0) = ldq_p(&fpu.mmx_1[i][0]);
- env->xmm_regs[i].ZMM_Q(1) = ldq_p(&fpu.mmx_1[i][8]);
- if (CPU_NB_REGS > 8) {
- env->xmm_regs[i + 8].ZMM_Q(0) = ldq_p(&fpu.mmx_2[i][0]);
- env->xmm_regs[i + 8].ZMM_Q(1) = ldq_p(&fpu.mmx_2[i][8]);
- }
- }
- env->mxcsr = fpu.mxcsr;
-
- return 0;
-}
-
-static int hax_set_fpu(CPUArchState *env)
-{
- struct fx_layout fpu;
- int i;
-
- memset(&fpu, 0, sizeof(fpu));
- fpu.fsw = env->fpus & ~(7 << 11);
- fpu.fsw |= (env->fpstt & 7) << 11;
- fpu.fcw = env->fpuc;
-
- for (i = 0; i < 8; ++i) {
- fpu.ftw |= (!env->fptags[i]) << i;
- }
-
- memcpy(fpu.st_mm, env->fpregs, sizeof(env->fpregs));
- for (i = 0; i < 8; i++) {
- stq_p(&fpu.mmx_1[i][0], env->xmm_regs[i].ZMM_Q(0));
- stq_p(&fpu.mmx_1[i][8], env->xmm_regs[i].ZMM_Q(1));
- if (CPU_NB_REGS > 8) {
- stq_p(&fpu.mmx_2[i][0], env->xmm_regs[i + 8].ZMM_Q(0));
- stq_p(&fpu.mmx_2[i][8], env->xmm_regs[i + 8].ZMM_Q(1));
- }
- }
-
- fpu.mxcsr = env->mxcsr;
-
- return hax_sync_fpu(env, &fpu, 1);
-}
-
-static int hax_arch_get_registers(CPUArchState *env)
-{
- int ret;
-
- ret = hax_sync_vcpu_register(env, 0);
- if (ret < 0) {
- return ret;
- }
-
- ret = hax_get_fpu(env);
- if (ret < 0) {
- return ret;
- }
-
- ret = hax_get_msrs(env);
- if (ret < 0) {
- return ret;
- }
-
- x86_update_hflags(env);
- return 0;
-}
-
-static int hax_arch_set_registers(CPUArchState *env)
-{
- int ret;
- ret = hax_sync_vcpu_register(env, 1);
-
- if (ret < 0) {
- fprintf(stderr, "Failed to sync vcpu reg\n");
- return ret;
- }
- ret = hax_set_fpu(env);
- if (ret < 0) {
- fprintf(stderr, "FPU failed\n");
- return ret;
- }
- ret = hax_set_msrs(env);
- if (ret < 0) {
- fprintf(stderr, "MSR failed\n");
- return ret;
- }
-
- return 0;
-}
-
-static void hax_vcpu_sync_state(CPUArchState *env, int modified)
-{
- if (hax_enabled()) {
- if (modified) {
- hax_arch_set_registers(env);
- } else {
- hax_arch_get_registers(env);
- }
- }
-}
-
-/*
- * much simpler than kvm, at least in first stage because:
- * We don't need consider the device pass-through, we don't need
- * consider the framebuffer, and we may even remove the bios at all
- */
-int hax_sync_vcpus(void)
-{
- if (hax_enabled()) {
- CPUState *cpu;
-
- cpu = first_cpu;
- if (!cpu) {
- return 0;
- }
-
- for (; cpu != NULL; cpu = CPU_NEXT(cpu)) {
- int ret;
-
- ret = hax_arch_set_registers(cpu->env_ptr);
- if (ret < 0) {
- return ret;
- }
- }
- }
-
- return 0;
-}
-
-void hax_reset_vcpu_state(void *opaque)
-{
- CPUState *cpu;
- for (cpu = first_cpu; cpu != NULL; cpu = CPU_NEXT(cpu)) {
- cpu->accel->tunnel->user_event_pending = 0;
- cpu->accel->tunnel->ready_for_interrupt_injection = 0;
- }
-}
-
-static void hax_accel_class_init(ObjectClass *oc, void *data)
-{
- AccelClass *ac = ACCEL_CLASS(oc);
- ac->name = "HAX";
- ac->init_machine = hax_accel_init;
- ac->allowed = &hax_allowed;
-}
-
-static const TypeInfo hax_accel_type = {
- .name = ACCEL_CLASS_NAME("hax"),
- .parent = TYPE_ACCEL,
- .class_init = hax_accel_class_init,
-};
-
-static void hax_type_init(void)
-{
- type_register_static(&hax_accel_type);
-}
-
-type_init(hax_type_init);
diff --git a/target/i386/hax/hax-mem.c b/target/i386/hax/hax-mem.c
deleted file mode 100644
index bb5ffbc9ac..0000000000
--- a/target/i386/hax/hax-mem.c
+++ /dev/null
@@ -1,323 +0,0 @@
-/*
- * HAX memory mapping operations
- *
- * Copyright (c) 2015-16 Intel Corporation
- * Copyright 2016 Google, Inc.
- *
- * This work is licensed under the terms of the GNU GPL, version 2. See
- * the COPYING file in the top-level directory.
- */
-
-#include "qemu/osdep.h"
-#include "cpu.h"
-#include "exec/address-spaces.h"
-#include "qemu/error-report.h"
-
-#include "hax-accel-ops.h"
-#include "qemu/queue.h"
-
-#define DEBUG_HAX_MEM 0
-
-#define DPRINTF(fmt, ...) \
- do { \
- if (DEBUG_HAX_MEM) { \
- fprintf(stdout, fmt, ## __VA_ARGS__); \
- } \
- } while (0)
-
-/**
- * HAXMapping: describes a pending guest physical memory mapping
- *
- * @start_pa: a guest physical address marking the start of the region; must be
- * page-aligned
- * @size: a guest physical address marking the end of the region; must be
- * page-aligned
- * @host_va: the host virtual address of the start of the mapping
- * @flags: mapping parameters e.g. HAX_RAM_INFO_ROM or HAX_RAM_INFO_INVALID
- * @entry: additional fields for linking #HAXMapping instances together
- */
-typedef struct HAXMapping {
- uint64_t start_pa;
- uint32_t size;
- uint64_t host_va;
- int flags;
- QTAILQ_ENTRY(HAXMapping) entry;
-} HAXMapping;
-
-/*
- * A doubly-linked list (actually a tail queue) of the pending page mappings
- * for the ongoing memory transaction.
- *
- * It is used to optimize the number of page mapping updates done through the
- * kernel module. For example, it's effective when a driver is digging an MMIO
- * hole inside an existing memory mapping. It will get a deletion of the whole
- * region, then the addition of the 2 remaining RAM areas around the hole and
- * finally the memory transaction commit. During the commit, it will effectively
- * send to the kernel only the removal of the pages from the MMIO hole after
- * having computed locally the result of the deletion and additions.
- */
-static QTAILQ_HEAD(, HAXMapping) mappings =
- QTAILQ_HEAD_INITIALIZER(mappings);
-
-/**
- * hax_mapping_dump_list: dumps @mappings to stdout (for debugging)
- */
-static void hax_mapping_dump_list(void)
-{
- HAXMapping *entry;
-
- DPRINTF("%s updates:\n", __func__);
- QTAILQ_FOREACH(entry, &mappings, entry) {
- DPRINTF("\t%c 0x%016" PRIx64 "->0x%016" PRIx64 " VA 0x%016" PRIx64
- "%s\n", entry->flags & HAX_RAM_INFO_INVALID ? '-' : '+',
- entry->start_pa, entry->start_pa + entry->size, entry->host_va,
- entry->flags & HAX_RAM_INFO_ROM ? " ROM" : "");
- }
-}
-
-static void hax_insert_mapping_before(HAXMapping *next, uint64_t start_pa,
- uint32_t size, uint64_t host_va,
- uint8_t flags)
-{
- HAXMapping *entry;
-
- entry = g_malloc0(sizeof(*entry));
- entry->start_pa = start_pa;
- entry->size = size;
- entry->host_va = host_va;
- entry->flags = flags;
- if (!next) {
- QTAILQ_INSERT_TAIL(&mappings, entry, entry);
- } else {
- QTAILQ_INSERT_BEFORE(next, entry, entry);
- }
-}
-
-static bool hax_mapping_is_opposite(HAXMapping *entry, uint64_t host_va,
- uint8_t flags)
-{
- /* removed then added without change for the read-only flag */
- bool nop_flags = (entry->flags ^ flags) == HAX_RAM_INFO_INVALID;
-
- return (entry->host_va == host_va) && nop_flags;
-}
-
-static void hax_update_mapping(uint64_t start_pa, uint32_t size,
- uint64_t host_va, uint8_t flags)
-{
- uint64_t end_pa = start_pa + size;
- HAXMapping *entry, *next;
-
- QTAILQ_FOREACH_SAFE(entry, &mappings, entry, next) {
- uint32_t chunk_sz;
- if (start_pa >= entry->start_pa + entry->size) {
- continue;
- }
- if (start_pa < entry->start_pa) {
- chunk_sz = end_pa <= entry->start_pa ? size
- : entry->start_pa - start_pa;
- hax_insert_mapping_before(entry, start_pa, chunk_sz,
- host_va, flags);
- start_pa += chunk_sz;
- host_va += chunk_sz;
- size -= chunk_sz;
- } else if (start_pa > entry->start_pa) {
- /* split the existing chunk at start_pa */
- chunk_sz = start_pa - entry->start_pa;
- hax_insert_mapping_before(entry, entry->start_pa, chunk_sz,
- entry->host_va, entry->flags);
- entry->start_pa += chunk_sz;
- entry->host_va += chunk_sz;
- entry->size -= chunk_sz;
- }
- /* now start_pa == entry->start_pa */
- chunk_sz = MIN(size, entry->size);
- if (chunk_sz) {
- bool nop = hax_mapping_is_opposite(entry, host_va, flags);
- bool partial = chunk_sz < entry->size;
- if (partial) {
- /* remove the beginning of the existing chunk */
- entry->start_pa += chunk_sz;
- entry->host_va += chunk_sz;
- entry->size -= chunk_sz;
- if (!nop) {
- hax_insert_mapping_before(entry, start_pa, chunk_sz,
- host_va, flags);
- }
- } else { /* affects the full mapping entry */
- if (nop) { /* no change to this mapping, remove it */
- QTAILQ_REMOVE(&mappings, entry, entry);
- g_free(entry);
- } else { /* update mapping properties */
- entry->host_va = host_va;
- entry->flags = flags;
- }
- }
- start_pa += chunk_sz;
- host_va += chunk_sz;
- size -= chunk_sz;
- }
- if (!size) { /* we are done */
- break;
- }
- }
- if (size) { /* add the leftover */
- hax_insert_mapping_before(NULL, start_pa, size, host_va, flags);
- }
-}
-
-static void hax_process_section(MemoryRegionSection *section, uint8_t flags)
-{
- MemoryRegion *mr = section->mr;
- hwaddr start_pa = section->offset_within_address_space;
- ram_addr_t size = int128_get64(section->size);
- unsigned int delta;
- uint64_t host_va;
- uint32_t max_mapping_size;
-
- /* We only care about RAM and ROM regions */
- if (!memory_region_is_ram(mr)) {
- if (memory_region_is_romd(mr)) {
- /* HAXM kernel module does not support ROMD yet */
- warn_report("Ignoring ROMD region 0x%016" PRIx64 "->0x%016" PRIx64,
- start_pa, start_pa + size);
- }
- return;
- }
-
- /* Adjust start_pa and size so that they are page-aligned. (Cf
- * kvm_set_phys_mem() in kvm-all.c).
- */
- delta = qemu_real_host_page_size() - (start_pa & ~qemu_real_host_page_mask());
- delta &= ~qemu_real_host_page_mask();
- if (delta > size) {
- return;
- }
- start_pa += delta;
- size -= delta;
- size &= qemu_real_host_page_mask();
- if (!size || (start_pa & ~qemu_real_host_page_mask())) {
- return;
- }
-
- host_va = (uintptr_t)memory_region_get_ram_ptr(mr)
- + section->offset_within_region + delta;
- if (memory_region_is_rom(section->mr)) {
- flags |= HAX_RAM_INFO_ROM;
- }
-
- /*
- * The kernel module interface uses 32-bit sizes:
- * https://github.com/intel/haxm/blob/master/API.md#hax_vm_ioctl_set_ram
- *
- * If the mapping size is longer than 32 bits, we can't process it in one
- * call into the kernel. Instead, we split the mapping into smaller ones,
- * and call hax_update_mapping() on each.
- */
- max_mapping_size = UINT32_MAX & qemu_real_host_page_mask();
- while (size > max_mapping_size) {
- hax_update_mapping(start_pa, max_mapping_size, host_va, flags);
- start_pa += max_mapping_size;
- size -= max_mapping_size;
- host_va += max_mapping_size;
- }
- /* Now size <= max_mapping_size */
- hax_update_mapping(start_pa, (uint32_t)size, host_va, flags);
-}
-
-static void hax_region_add(MemoryListener *listener,
- MemoryRegionSection *section)
-{
- memory_region_ref(section->mr);
- hax_process_section(section, 0);
-}
-
-static void hax_region_del(MemoryListener *listener,
- MemoryRegionSection *section)
-{
- hax_process_section(section, HAX_RAM_INFO_INVALID);
- memory_region_unref(section->mr);
-}
-
-static void hax_transaction_begin(MemoryListener *listener)
-{
- g_assert(QTAILQ_EMPTY(&mappings));
-}
-
-static void hax_transaction_commit(MemoryListener *listener)
-{
- if (!QTAILQ_EMPTY(&mappings)) {
- HAXMapping *entry, *next;
-
- if (DEBUG_HAX_MEM) {
- hax_mapping_dump_list();
- }
- QTAILQ_FOREACH_SAFE(entry, &mappings, entry, next) {
- if (entry->flags & HAX_RAM_INFO_INVALID) {
- /* for unmapping, put the values expected by the kernel */
- entry->flags = HAX_RAM_INFO_INVALID;
- entry->host_va = 0;
- }
- if (hax_set_ram(entry->start_pa, entry->size,
- entry->host_va, entry->flags)) {
- fprintf(stderr, "%s: Failed mapping @0x%016" PRIx64 "+0x%"
- PRIx32 " flags %02x\n", __func__, entry->start_pa,
- entry->size, entry->flags);
- }
- QTAILQ_REMOVE(&mappings, entry, entry);
- g_free(entry);
- }
- }
-}
-
-/* currently we fake the dirty bitmap sync, always dirty */
-static void hax_log_sync(MemoryListener *listener,
- MemoryRegionSection *section)
-{
- MemoryRegion *mr = section->mr;
-
- if (!memory_region_is_ram(mr)) {
- /* Skip MMIO regions */
- return;
- }
-
- memory_region_set_dirty(mr, 0, int128_get64(section->size));
-}
-
-static MemoryListener hax_memory_listener = {
- .name = "hax",
- .begin = hax_transaction_begin,
- .commit = hax_transaction_commit,
- .region_add = hax_region_add,
- .region_del = hax_region_del,
- .log_sync = hax_log_sync,
- .priority = MEMORY_LISTENER_PRIORITY_ACCEL,
-};
-
-static void hax_ram_block_added(RAMBlockNotifier *n, void *host, size_t size,
- size_t max_size)
-{
- /*
- * We must register each RAM block with the HAXM kernel module, or
- * hax_set_ram() will fail for any mapping into the RAM block:
- * https://github.com/intel/haxm/blob/master/API.md#hax_vm_ioctl_alloc_ram
- *
- * Old versions of the HAXM kernel module (< 6.2.0) used to preallocate all
- * host physical pages for the RAM block as part of this registration
- * process, hence the name hax_populate_ram().
- */
- if (hax_populate_ram((uint64_t)(uintptr_t)host, max_size) < 0) {
- fprintf(stderr, "HAX failed to populate RAM\n");
- abort();
- }
-}
-
-static struct RAMBlockNotifier hax_ram_notifier = {
- .ram_block_added = hax_ram_block_added,
-};
-
-void hax_memory_init(void)
-{
- ram_block_notifier_add(&hax_ram_notifier);
- memory_listener_register(&hax_memory_listener, &address_space_memory);
-}
diff --git a/target/i386/hax/hax-posix.c b/target/i386/hax/hax-posix.c
deleted file mode 100644
index a057a5bd94..0000000000
--- a/target/i386/hax/hax-posix.c
+++ /dev/null
@@ -1,305 +0,0 @@
-/*
- * QEMU HAXM support
- *
- * Copyright (c) 2011 Intel Corporation
- * Written by:
- * Jiang Yunhong<yunhong.jiang(a)intel.com>
- *
- * This work is licensed under the terms of the GNU GPL, version 2 or later.
- * See the COPYING file in the top-level directory.
- *
- */
-
-/* HAX module interface - darwin version */
-#include "qemu/osdep.h"
-#include <sys/ioctl.h>
-
-#include "sysemu/cpus.h"
-#include "hax-accel-ops.h"
-
-hax_fd hax_mod_open(void)
-{
- int fd = open("/dev/HAX", O_RDWR);
- if (fd == -1) {
- fprintf(stderr, "Failed to open the hax module\n");
- }
-
- qemu_set_cloexec(fd);
-
- return fd;
-}
-
-int hax_populate_ram(uint64_t va, uint64_t size)
-{
- int ret;
-
- if (!hax_global.vm || !hax_global.vm->fd) {
- fprintf(stderr, "Allocate memory before vm create?\n");
- return -EINVAL;
- }
-
- if (hax_global.supports_64bit_ramblock) {
- struct hax_ramblock_info ramblock = {
- .start_va = va,
- .size = size,
- .reserved = 0
- };
-
- ret = ioctl(hax_global.vm->fd, HAX_VM_IOCTL_ADD_RAMBLOCK, &ramblock);
- } else {
- struct hax_alloc_ram_info info = {
- .size = (uint32_t)size,
- .pad = 0,
- .va = va
- };
-
- ret = ioctl(hax_global.vm->fd, HAX_VM_IOCTL_ALLOC_RAM, &info);
- }
- if (ret < 0) {
- fprintf(stderr, "Failed to register RAM block: ret=%d, va=0x%" PRIx64
- ", size=0x%" PRIx64 ", method=%s\n", ret, va, size,
- hax_global.supports_64bit_ramblock ? "new" : "legacy");
- return ret;
- }
- return 0;
-}
-
-int hax_set_ram(uint64_t start_pa, uint32_t size, uint64_t host_va, int flags)
-{
- struct hax_set_ram_info info;
- int ret;
-
- info.pa_start = start_pa;
- info.size = size;
- info.va = host_va;
- info.flags = (uint8_t) flags;
-
- ret = ioctl(hax_global.vm->fd, HAX_VM_IOCTL_SET_RAM, &info);
- if (ret < 0) {
- return -errno;
- }
- return 0;
-}
-
-int hax_capability(struct hax_state *hax, struct hax_capabilityinfo *cap)
-{
- int ret;
-
- ret = ioctl(hax->fd, HAX_IOCTL_CAPABILITY, cap);
- if (ret == -1) {
- fprintf(stderr, "Failed to get HAX capability\n");
- return -errno;
- }
-
- return 0;
-}
-
-int hax_mod_version(struct hax_state *hax, struct hax_module_version *version)
-{
- int ret;
-
- ret = ioctl(hax->fd, HAX_IOCTL_VERSION, version);
- if (ret == -1) {
- fprintf(stderr, "Failed to get HAX version\n");
- return -errno;
- }
-
- return 0;
-}
-
-static char *hax_vm_devfs_string(int vm_id)
-{
- return g_strdup_printf("/dev/hax_vm/vm%02d", vm_id);
-}
-
-static char *hax_vcpu_devfs_string(int vm_id, int vcpu_id)
-{
- return g_strdup_printf("/dev/hax_vm%02d/vcpu%02d", vm_id, vcpu_id);
-}
-
-int hax_host_create_vm(struct hax_state *hax, int *vmid)
-{
- int ret;
- int vm_id = 0;
-
- if (hax_invalid_fd(hax->fd)) {
- return -EINVAL;
- }
-
- if (hax->vm) {
- return 0;
- }
-
- ret = ioctl(hax->fd, HAX_IOCTL_CREATE_VM, &vm_id);
- *vmid = vm_id;
- return ret;
-}
-
-hax_fd hax_host_open_vm(struct hax_state *hax, int vm_id)
-{
- hax_fd fd;
- char *vm_name = NULL;
-
- vm_name = hax_vm_devfs_string(vm_id);
- if (!vm_name) {
- return -1;
- }
-
- fd = open(vm_name, O_RDWR);
- g_free(vm_name);
-
- qemu_set_cloexec(fd);
-
- 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 < 0) {
- fprintf(stderr, "Failed to notify qemu API version\n");
- return ret;
- }
- return 0;
-}
-
-/* Simply assume the size should be bigger than the hax_tunnel,
- * since the hax_tunnel can be extended later with compatibility considered
- */
-int hax_host_create_vcpu(hax_fd vm_fd, int vcpuid)
-{
- int ret;
-
- ret = ioctl(vm_fd, HAX_VM_IOCTL_VCPU_CREATE, &vcpuid);
- if (ret < 0) {
- fprintf(stderr, "Failed to create vcpu %x\n", vcpuid);
- }
-
- return ret;
-}
-
-hax_fd hax_host_open_vcpu(int vmid, int vcpuid)
-{
- char *devfs_path = NULL;
- hax_fd fd;
-
- devfs_path = hax_vcpu_devfs_string(vmid, vcpuid);
- if (!devfs_path) {
- fprintf(stderr, "Failed to get the devfs\n");
- return -EINVAL;
- }
-
- fd = open(devfs_path, O_RDWR);
- g_free(devfs_path);
- if (fd < 0) {
- fprintf(stderr, "Failed to open the vcpu devfs\n");
- }
- qemu_set_cloexec(fd);
- return fd;
-}
-
-int hax_host_setup_vcpu_channel(AccelCPUState *vcpu)
-{
- int ret;
- struct hax_tunnel_info info;
-
- ret = ioctl(vcpu->fd, HAX_VCPU_IOCTL_SETUP_TUNNEL, &info);
- if (ret) {
- fprintf(stderr, "Failed to setup the hax tunnel\n");
- return ret;
- }
-
- if (!valid_hax_tunnel_size(info.size)) {
- fprintf(stderr, "Invalid hax tunnel size %x\n", info.size);
- ret = -EINVAL;
- return ret;
- }
-
- vcpu->tunnel = (struct hax_tunnel *) (intptr_t) (info.va);
- vcpu->iobuf = (unsigned char *) (intptr_t) (info.io_va);
- return 0;
-}
-
-int hax_vcpu_run(AccelCPUState *vcpu)
-{
- return ioctl(vcpu->fd, HAX_VCPU_IOCTL_RUN, NULL);
-}
-
-int hax_sync_fpu(CPUArchState *env, struct fx_layout *fl, int set)
-{
- int ret, fd;
-
- fd = hax_vcpu_get_fd(env);
- if (fd <= 0) {
- return -1;
- }
-
- if (set) {
- ret = ioctl(fd, HAX_VCPU_IOCTL_SET_FPU, fl);
- } else {
- ret = ioctl(fd, HAX_VCPU_IOCTL_GET_FPU, fl);
- }
- return ret;
-}
-
-int hax_sync_msr(CPUArchState *env, struct hax_msr_data *msrs, int set)
-{
- int ret, fd;
-
- fd = hax_vcpu_get_fd(env);
- if (fd <= 0) {
- return -1;
- }
- if (set) {
- ret = ioctl(fd, HAX_VCPU_IOCTL_SET_MSRS, msrs);
- } else {
- ret = ioctl(fd, HAX_VCPU_IOCTL_GET_MSRS, msrs);
- }
- return ret;
-}
-
-int hax_sync_vcpu_state(CPUArchState *env, struct vcpu_state_t *state, int set)
-{
- int ret, fd;
-
- fd = hax_vcpu_get_fd(env);
- if (fd <= 0) {
- return -1;
- }
-
- if (set) {
- ret = ioctl(fd, HAX_VCPU_SET_REGS, state);
- } else {
- ret = ioctl(fd, HAX_VCPU_GET_REGS, state);
- }
- return ret;
-}
-
-int hax_inject_interrupt(CPUArchState *env, int vector)
-{
- int fd;
-
- fd = hax_vcpu_get_fd(env);
- if (fd <= 0) {
- return -1;
- }
-
- return ioctl(fd, HAX_VCPU_IOCTL_INTERRUPT, &vector);
-}
-
-void hax_kick_vcpu_thread(CPUState *cpu)
-{
- /*
- * FIXME: race condition with the exit_request check in
- * hax_vcpu_hax_exec
- */
- cpu->exit_request = 1;
- cpus_kick_thread(cpu);
-}
diff --git a/target/i386/hax/hax-windows.c b/target/i386/hax/hax-windows.c
deleted file mode 100644
index 4bf6cc08d2..0000000000
--- a/target/i386/hax/hax-windows.c
+++ /dev/null
@@ -1,485 +0,0 @@
-/*
- * QEMU HAXM support
- *
- * Copyright (c) 2011 Intel Corporation
- * Written by:
- * Jiang Yunhong<yunhong.jiang(a)intel.com>
- *
- * This work is licensed under the terms of the GNU GPL, version 2 or later.
- * See the COPYING file in the top-level directory.
- *
- */
-
-#include "qemu/osdep.h"
-#include "cpu.h"
-#include "hax-accel-ops.h"
-
-/*
- * return 0 when success, -1 when driver not loaded,
- * other negative value for other failure
- */
-static int hax_open_device(hax_fd *fd)
-{
- uint32_t errNum = 0;
- HANDLE hDevice;
-
- if (!fd) {
- return -2;
- }
-
- hDevice = CreateFile("\\\\.\\HAX",
- GENERIC_READ | GENERIC_WRITE,
- 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
-
- if (hDevice == INVALID_HANDLE_VALUE) {
- fprintf(stderr, "Failed to open the HAX device!\n");
- errNum = GetLastError();
- if (errNum == ERROR_FILE_NOT_FOUND) {
- return -1;
- }
- return -2;
- }
- *fd = hDevice;
- return 0;
-}
-
-/* hax_fd hax_mod_open */
- hax_fd hax_mod_open(void)
-{
- int ret;
- hax_fd fd = NULL;
-
- ret = hax_open_device(&fd);
- if (ret != 0) {
- fprintf(stderr, "Open HAX device failed\n");
- }
-
- return fd;
-}
-
-int hax_populate_ram(uint64_t va, uint64_t size)
-{
- int ret;
- HANDLE hDeviceVM;
- DWORD dSize = 0;
-
- if (!hax_global.vm || !hax_global.vm->fd) {
- fprintf(stderr, "Allocate memory before vm create?\n");
- return -EINVAL;
- }
-
- hDeviceVM = hax_global.vm->fd;
- if (hax_global.supports_64bit_ramblock) {
- struct hax_ramblock_info ramblock = {
- .start_va = va,
- .size = size,
- .reserved = 0
- };
-
- ret = DeviceIoControl(hDeviceVM,
- HAX_VM_IOCTL_ADD_RAMBLOCK,
- &ramblock, sizeof(ramblock), NULL, 0, &dSize,
- (LPOVERLAPPED) NULL);
- } else {
- struct hax_alloc_ram_info info = {
- .size = (uint32_t) size,
- .pad = 0,
- .va = va
- };
-
- ret = DeviceIoControl(hDeviceVM,
- HAX_VM_IOCTL_ALLOC_RAM,
- &info, sizeof(info), NULL, 0, &dSize,
- (LPOVERLAPPED) NULL);
- }
-
- if (!ret) {
- fprintf(stderr, "Failed to register RAM block: va=0x%" PRIx64
- ", size=0x%" PRIx64 ", method=%s\n", va, size,
- hax_global.supports_64bit_ramblock ? "new" : "legacy");
- return ret;
- }
-
- return 0;
-}
-
-int hax_set_ram(uint64_t start_pa, uint32_t size, uint64_t host_va, int flags)
-{
- struct hax_set_ram_info info;
- HANDLE hDeviceVM = hax_global.vm->fd;
- DWORD dSize = 0;
- int ret;
-
- info.pa_start = start_pa;
- info.size = size;
- info.va = host_va;
- info.flags = (uint8_t) flags;
-
- ret = DeviceIoControl(hDeviceVM, HAX_VM_IOCTL_SET_RAM,
- &info, sizeof(info), NULL, 0, &dSize,
- (LPOVERLAPPED) NULL);
-
- if (!ret) {
- return -EFAULT;
- } else {
- return 0;
- }
-}
-
-int hax_capability(struct hax_state *hax, struct hax_capabilityinfo *cap)
-{
- int ret;
- HANDLE hDevice = hax->fd; /* handle to hax module */
- DWORD dSize = 0;
- DWORD err = 0;
-
- if (hax_invalid_fd(hDevice)) {
- fprintf(stderr, "Invalid fd for hax device!\n");
- return -ENODEV;
- }
-
- ret = DeviceIoControl(hDevice, HAX_IOCTL_CAPABILITY, NULL, 0, cap,
- sizeof(*cap), &dSize, (LPOVERLAPPED) NULL);
-
- if (!ret) {
- err = GetLastError();
- if (err == ERROR_INSUFFICIENT_BUFFER || err == ERROR_MORE_DATA) {
- fprintf(stderr, "hax capability is too long to hold.\n");
- }
- fprintf(stderr, "Failed to get Hax capability:%luu\n", err);
- return -EFAULT;
- } else {
- return 0;
- }
-}
-
-int hax_mod_version(struct hax_state *hax, struct hax_module_version *version)
-{
- int ret;
- HANDLE hDevice = hax->fd; /* handle to hax module */
- DWORD dSize = 0;
- DWORD err = 0;
-
- if (hax_invalid_fd(hDevice)) {
- fprintf(stderr, "Invalid fd for hax device!\n");
- return -ENODEV;
- }
-
- ret = DeviceIoControl(hDevice,
- HAX_IOCTL_VERSION,
- NULL, 0,
- version, sizeof(*version), &dSize,
- (LPOVERLAPPED) NULL);
-
- if (!ret) {
- err = GetLastError();
- if (err == ERROR_INSUFFICIENT_BUFFER || err == ERROR_MORE_DATA) {
- fprintf(stderr, "hax module verion is too long to hold.\n");
- }
- fprintf(stderr, "Failed to get Hax module version:%lu\n", err);
- return -EFAULT;
- } else {
- return 0;
- }
-}
-
-static char *hax_vm_devfs_string(int vm_id)
-{
- return g_strdup_printf("\\\\.\\hax_vm%02d", vm_id);
-}
-
-static char *hax_vcpu_devfs_string(int vm_id, int vcpu_id)
-{
- return g_strdup_printf("\\\\.\\hax_vm%02d_vcpu%02d", vm_id, vcpu_id);
-}
-
-int hax_host_create_vm(struct hax_state *hax, int *vmid)
-{
- int ret;
- int vm_id = 0;
- DWORD dSize = 0;
-
- if (hax_invalid_fd(hax->fd)) {
- return -EINVAL;
- }
-
- if (hax->vm) {
- return 0;
- }
-
- ret = DeviceIoControl(hax->fd,
- HAX_IOCTL_CREATE_VM,
- NULL, 0, &vm_id, sizeof(vm_id), &dSize,
- (LPOVERLAPPED) NULL);
- if (!ret) {
- fprintf(stderr, "Failed to create VM. Error code: %lu\n",
- GetLastError());
- return -1;
- }
- *vmid = vm_id;
- return 0;
-}
-
-hax_fd hax_host_open_vm(struct hax_state *hax, int vm_id)
-{
- char *vm_name = NULL;
- hax_fd hDeviceVM;
-
- vm_name = hax_vm_devfs_string(vm_id);
- if (!vm_name) {
- fprintf(stderr, "Failed to open VM. VM name is null\n");
- return INVALID_HANDLE_VALUE;
- }
-
- hDeviceVM = CreateFile(vm_name,
- GENERIC_READ | GENERIC_WRITE,
- 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
- if (hDeviceVM == INVALID_HANDLE_VALUE) {
- fprintf(stderr, "Open the vm device error:%s, ec:%lu\n",
- vm_name, GetLastError());
- }
-
- g_free(vm_name);
- 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) {
- fprintf(stderr, "Failed to notify qemu API version\n");
- return -1;
- }
- return 0;
-}
-
-int hax_host_create_vcpu(hax_fd vm_fd, int vcpuid)
-{
- int ret;
- DWORD dSize = 0;
-
- ret = DeviceIoControl(vm_fd,
- HAX_VM_IOCTL_VCPU_CREATE,
- &vcpuid, sizeof(vcpuid), NULL, 0, &dSize,
- (LPOVERLAPPED) NULL);
- if (!ret) {
- fprintf(stderr, "Failed to create vcpu %x\n", vcpuid);
- return -1;
- }
-
- return 0;
-}
-
-hax_fd hax_host_open_vcpu(int vmid, int vcpuid)
-{
- char *devfs_path = NULL;
- hax_fd hDeviceVCPU;
-
- devfs_path = hax_vcpu_devfs_string(vmid, vcpuid);
- if (!devfs_path) {
- fprintf(stderr, "Failed to get the devfs\n");
- return INVALID_HANDLE_VALUE;
- }
-
- hDeviceVCPU = CreateFile(devfs_path,
- GENERIC_READ | GENERIC_WRITE,
- 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL,
- NULL);
-
- if (hDeviceVCPU == INVALID_HANDLE_VALUE) {
- fprintf(stderr, "Failed to open the vcpu devfs\n");
- }
- g_free(devfs_path);
- return hDeviceVCPU;
-}
-
-int hax_host_setup_vcpu_channel(AccelCPUState *vcpu)
-{
- hax_fd hDeviceVCPU = vcpu->fd;
- int ret;
- struct hax_tunnel_info info;
- DWORD dSize = 0;
-
- ret = DeviceIoControl(hDeviceVCPU,
- HAX_VCPU_IOCTL_SETUP_TUNNEL,
- NULL, 0, &info, sizeof(info), &dSize,
- (LPOVERLAPPED) NULL);
- if (!ret) {
- fprintf(stderr, "Failed to setup the hax tunnel\n");
- return -1;
- }
-
- if (!valid_hax_tunnel_size(info.size)) {
- fprintf(stderr, "Invalid hax tunnel size %x\n", info.size);
- ret = -EINVAL;
- return ret;
- }
- vcpu->tunnel = (struct hax_tunnel *) (intptr_t) (info.va);
- vcpu->iobuf = (unsigned char *) (intptr_t) (info.io_va);
- return 0;
-}
-
-int hax_vcpu_run(AccelCPUState *vcpu)
-{
- int ret;
- HANDLE hDeviceVCPU = vcpu->fd;
- DWORD dSize = 0;
-
- ret = DeviceIoControl(hDeviceVCPU,
- HAX_VCPU_IOCTL_RUN,
- NULL, 0, NULL, 0, &dSize, (LPOVERLAPPED) NULL);
- if (!ret) {
- return -EFAULT;
- } else {
- return 0;
- }
-}
-
-int hax_sync_fpu(CPUArchState *env, struct fx_layout *fl, int set)
-{
- int ret;
- hax_fd fd;
- HANDLE hDeviceVCPU;
- DWORD dSize = 0;
-
- fd = hax_vcpu_get_fd(env);
- if (hax_invalid_fd(fd)) {
- return -1;
- }
-
- hDeviceVCPU = fd;
-
- if (set) {
- ret = DeviceIoControl(hDeviceVCPU,
- HAX_VCPU_IOCTL_SET_FPU,
- fl, sizeof(*fl), NULL, 0, &dSize,
- (LPOVERLAPPED) NULL);
- } else {
- ret = DeviceIoControl(hDeviceVCPU,
- HAX_VCPU_IOCTL_GET_FPU,
- NULL, 0, fl, sizeof(*fl), &dSize,
- (LPOVERLAPPED) NULL);
- }
- if (!ret) {
- return -EFAULT;
- } else {
- return 0;
- }
-}
-
-int hax_sync_msr(CPUArchState *env, struct hax_msr_data *msrs, int set)
-{
- int ret;
- hax_fd fd;
- HANDLE hDeviceVCPU;
- DWORD dSize = 0;
-
- fd = hax_vcpu_get_fd(env);
- if (hax_invalid_fd(fd)) {
- return -1;
- }
- hDeviceVCPU = fd;
-
- if (set) {
- ret = DeviceIoControl(hDeviceVCPU,
- HAX_VCPU_IOCTL_SET_MSRS,
- msrs, sizeof(*msrs),
- msrs, sizeof(*msrs), &dSize, (LPOVERLAPPED) NULL);
- } else {
- ret = DeviceIoControl(hDeviceVCPU,
- HAX_VCPU_IOCTL_GET_MSRS,
- msrs, sizeof(*msrs),
- msrs, sizeof(*msrs), &dSize, (LPOVERLAPPED) NULL);
- }
- if (!ret) {
- return -EFAULT;
- } else {
- return 0;
- }
-}
-
-int hax_sync_vcpu_state(CPUArchState *env, struct vcpu_state_t *state, int set)
-{
- int ret;
- hax_fd fd;
- HANDLE hDeviceVCPU;
- DWORD dSize;
-
- fd = hax_vcpu_get_fd(env);
- if (hax_invalid_fd(fd)) {
- return -1;
- }
-
- hDeviceVCPU = fd;
-
- if (set) {
- ret = DeviceIoControl(hDeviceVCPU,
- HAX_VCPU_SET_REGS,
- state, sizeof(*state),
- NULL, 0, &dSize, (LPOVERLAPPED) NULL);
- } else {
- ret = DeviceIoControl(hDeviceVCPU,
- HAX_VCPU_GET_REGS,
- NULL, 0,
- state, sizeof(*state), &dSize,
- (LPOVERLAPPED) NULL);
- }
- if (!ret) {
- return -EFAULT;
- } else {
- return 0;
- }
-}
-
-int hax_inject_interrupt(CPUArchState *env, int vector)
-{
- int ret;
- hax_fd fd;
- HANDLE hDeviceVCPU;
- DWORD dSize;
-
- fd = hax_vcpu_get_fd(env);
- if (hax_invalid_fd(fd)) {
- return -1;
- }
-
- hDeviceVCPU = fd;
-
- ret = DeviceIoControl(hDeviceVCPU,
- HAX_VCPU_IOCTL_INTERRUPT,
- &vector, sizeof(vector), NULL, 0, &dSize,
- (LPOVERLAPPED) NULL);
- if (!ret) {
- return -EFAULT;
- } else {
- return 0;
- }
-}
-
-static void CALLBACK dummy_apc_func(ULONG_PTR unused)
-{
-}
-
-void hax_kick_vcpu_thread(CPUState *cpu)
-{
- /*
- * FIXME: race condition with the exit_request check in
- * hax_vcpu_hax_exec
- */
- cpu->exit_request = 1;
- if (!qemu_cpu_is_self(cpu)) {
- if (!QueueUserAPC(dummy_apc_func, cpu->accel->hThread, 0)) {
- fprintf(stderr, "%s: QueueUserAPC failed with error %lu\n",
- __func__, GetLastError());
- exit(1);
- }
- }
-}
diff --git a/accel/Kconfig b/accel/Kconfig
index 8bdedb7d15..a30cf2eb48 100644
--- a/accel/Kconfig
+++ b/accel/Kconfig
@@ -4,9 +4,6 @@ config WHPX
config NVMM
bool
-config HAX
- bool
-
config HVF
bool
diff --git a/accel/stubs/meson.build b/accel/stubs/meson.build
index f7a9486e06..6b0f200efe 100644
--- a/accel/stubs/meson.build
+++ b/accel/stubs/meson.build
@@ -1,5 +1,4 @@
sysemu_stubs_ss = ss.source_set()
-sysemu_stubs_ss.add(when: 'CONFIG_HAX', if_false: files('hax-stub.c'))
sysemu_stubs_ss.add(when: 'CONFIG_XEN', if_false: files('xen-stub.c'))
sysemu_stubs_ss.add(when: 'CONFIG_KVM', if_false: files('kvm-stub.c'))
sysemu_stubs_ss.add(when: 'CONFIG_TCG', if_false: files('tcg-stub.c'))
diff --git a/meson_options.txt b/meson_options.txt
index aaea5ddd77..4f3b1ecab0 100644
--- a/meson_options.txt
+++ b/meson_options.txt
@@ -69,8 +69,6 @@ option('malloc', type : 'combo', choices : ['system', 'tcmalloc', 'jemalloc'],
option('kvm', type: 'feature', value: 'auto',
description: 'KVM acceleration support')
-option('hax', type: 'feature', value: 'auto',
- description: 'HAX acceleration support')
option('whpx', type: 'feature', value: 'auto',
description: 'WHPX acceleration support')
option('hvf', type: 'feature', value: 'auto',
diff --git a/qemu-options.hx b/qemu-options.hx
index 29b98c3d4c..463f520c57 100644
--- a/qemu-options.hx
+++ b/qemu-options.hx
@@ -26,7 +26,7 @@ DEF("machine", HAS_ARG, QEMU_OPTION_machine, \
"-machine [type=]name[,prop[=value][,...]]\n"
" selects emulated machine ('-machine help' for list)\n"
" property accel=accel1[:accel2[:...]] selects accelerator\n"
- " supported accelerators are kvm, xen, hax, hvf, nvmm, whpx or tcg (default: tcg)\n"
+ " supported accelerators are kvm, xen, hvf, nvmm, whpx or tcg (default: tcg)\n"
" vmport=on|off|auto controls emulation of vmport (default: auto)\n"
" dump-guest-core=on|off include guest memory in a core dump (default=on)\n"
" mem-merge=on|off controls memory merge support (default: on)\n"
@@ -59,7 +59,7 @@ SRST
``accel=accels1[:accels2[:...]]``
This is used to enable an accelerator. Depending on the target
- architecture, kvm, xen, hax, hvf, nvmm, whpx or tcg can be available.
+ architecture, kvm, xen, hvf, nvmm, whpx or tcg can be available.
By default, tcg is used. If there is more than one accelerator
specified, the next one is used if the previous one fails to
initialize.
@@ -178,7 +178,7 @@ ERST
DEF("accel", HAS_ARG, QEMU_OPTION_accel,
"-accel [accel=]accelerator[,prop[=value][,...]]\n"
- " select accelerator (kvm, xen, hax, hvf, nvmm, whpx or tcg; use 'help' for a list)\n"
+ " select accelerator (kvm, xen, hvf, nvmm, whpx or tcg; use 'help' for a list)\n"
" igd-passthru=on|off (enable Xen integrated Intel graphics passthrough, default=off)\n"
" kernel-irqchip=on|off|split controls accelerated irqchip support (default=on)\n"
" kvm-shadow-mem=size of KVM shadow MMU in bytes\n"
@@ -191,7 +191,7 @@ DEF("accel", HAS_ARG, QEMU_OPTION_accel,
SRST
``-accel name[,prop=value[,...]]``
This is used to enable an accelerator. Depending on the target
- architecture, kvm, xen, hax, hvf, nvmm, whpx or tcg can be available. By
+ architecture, kvm, xen, hvf, nvmm, whpx or tcg can be available. By
default, tcg is used. If there is more than one accelerator
specified, the next one is used if the previous one fails to
initialize.
diff --git a/scripts/ci/org.centos/stream/8/x86_64/configure b/scripts/ci/org.centos/stream/8/x86_64/configure
index d02b09a4b9..131f8ee5f3 100755
--- a/scripts/ci/org.centos/stream/8/x86_64/configure
+++ b/scripts/ci/org.centos/stream/8/x86_64/configure
@@ -68,7 +68,6 @@
--disable-gtk \
--disable-guest-agent \
--disable-guest-agent-msi \
---disable-hax \
--disable-hvf \
--disable-iconv \
--disable-kvm \
diff --git a/scripts/meson-buildoptions.sh b/scripts/meson-buildoptions.sh
index 9da3fe299b..504a61ad01 100644
--- a/scripts/meson-buildoptions.sh
+++ b/scripts/meson-buildoptions.sh
@@ -110,7 +110,6 @@ meson_options_help() {
printf "%s\n" ' gtk-clipboard clipboard support for the gtk UI (EXPERIMENTAL, MAY HANG)'
printf "%s\n" ' guest-agent Build QEMU Guest Agent'
printf "%s\n" ' guest-agent-msi Build MSI package for the QEMU Guest Agent'
- printf "%s\n" ' hax HAX acceleration support'
printf "%s\n" ' hvf HVF acceleration support'
printf "%s\n" ' iconv Font glyph conversion support'
printf "%s\n" ' jack JACK sound support'
@@ -312,8 +311,6 @@ _meson_option_parse() {
--disable-guest-agent) printf "%s" -Dguest_agent=disabled ;;
--enable-guest-agent-msi) printf "%s" -Dguest_agent_msi=enabled ;;
--disable-guest-agent-msi) printf "%s" -Dguest_agent_msi=disabled ;;
- --enable-hax) printf "%s" -Dhax=enabled ;;
- --disable-hax) printf "%s" -Dhax=disabled ;;
--enable-hexagon-idef-parser) printf "%s" -Dhexagon_idef_parser=true ;;
--disable-hexagon-idef-parser) printf "%s" -Dhexagon_idef_parser=false ;;
--enable-hvf) printf "%s" -Dhvf=enabled ;;
diff --git a/target/i386/hax/meson.build b/target/i386/hax/meson.build
deleted file mode 100644
index 6ac314aa35..0000000000
--- a/target/i386/hax/meson.build
+++ /dev/null
@@ -1,7 +0,0 @@
-i386_system_ss.add(when: 'CONFIG_HAX', if_true: files(
- 'hax-all.c',
- 'hax-mem.c',
- 'hax-accel-ops.c',
-))
-i386_system_ss.add(when: ['CONFIG_HAX', 'CONFIG_POSIX'], if_true: files('hax-posix.c'))
-i386_system_ss.add(when: ['CONFIG_HAX', 'CONFIG_WIN32'], if_true: files('hax-windows.c'))
diff --git a/target/i386/meson.build b/target/i386/meson.build
index 1effe1ed9a..6f1036d469 100644
--- a/target/i386/meson.build
+++ b/target/i386/meson.build
@@ -25,7 +25,6 @@ i386_system_ss.add(when: 'CONFIG_SEV', if_true: files('sev.c'), if_false: files(
i386_user_ss = ss.source_set()
subdir('kvm')
-subdir('hax')
subdir('whpx')
subdir('nvmm')
subdir('hvf')
--
2.41.0
1
0
[libvirt PATCH] rpm: Recommend libvirt-daemon for with_modular_daemons distros
by Andrea Bolognani 31 Aug '23
by Andrea Bolognani 31 Aug '23
31 Aug '23
A default deployment on modern distros uses modular daemons but
switching back to the monolithic daemon, while not recommended,
is still considered a perfectly valid option.
For a monolithic daemon deployment, the upgrade to libvirt 9.2.0
or newer works as expected; a subsequent call to dnf autoremove,
however, results in the libvirt-daemon package being removed and
the deployment no longer working.
In order to avoid that situation, mark the libvirt-daemon as
recommended.
This will unfortunately result in it being included in most
installations despite not being necessary, but considering that
the alternative is breaking existing setups on upgrade it feels
like a reasonable tradeoff.
Moreover, since the dependency on libvirt-daemon is just a weak
one, it's still possible for people looking to minimize the
footprint of their installation to manually remove the package
after installation, mitigating the drawbacks of this approach.
https://bugzilla.redhat.com/show_bug.cgi?id=2232805
Signed-off-by: Andrea Bolognani <abologna(a)redhat.com>
---
libvirt.spec.in | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/libvirt.spec.in b/libvirt.spec.in
index 6bbc7a0e9a..b471afebb1 100644
--- a/libvirt.spec.in
+++ b/libvirt.spec.in
@@ -830,6 +830,7 @@ Requires: libvirt-daemon-log = %{version}-%{release}
Requires: libvirt-daemon-lock = %{version}-%{release}
Requires: libvirt-daemon-plugin-lockd = %{version}-%{release}
Requires: libvirt-daemon-proxy = %{version}-%{release}
+Recommends: libvirt-daemon = %{version}-%{release}
%else
Requires: libvirt-daemon = %{version}-%{release}
%endif
@@ -857,6 +858,7 @@ Requires: libvirt-daemon-log = %{version}-%{release}
Requires: libvirt-daemon-lock = %{version}-%{release}
Requires: libvirt-daemon-plugin-lockd = %{version}-%{release}
Requires: libvirt-daemon-proxy = %{version}-%{release}
+Recommends: libvirt-daemon = %{version}-%{release}
%else
Requires: libvirt-daemon = %{version}-%{release}
%endif
@@ -881,6 +883,7 @@ Summary: Server side daemon & driver required to run LXC guests
%if %{with_modular_daemons}
Requires: libvirt-daemon-common = %{version}-%{release}
Requires: libvirt-daemon-proxy = %{version}-%{release}
+Recommends: libvirt-daemon = %{version}-%{release}
%else
Requires: libvirt-daemon = %{version}-%{release}
%endif
@@ -906,6 +909,7 @@ Requires: libvirt-daemon-common = %{version}-%{release}
Requires: libvirt-daemon-lock = %{version}-%{release}
Requires: libvirt-daemon-plugin-lockd = %{version}-%{release}
Requires: libvirt-daemon-proxy = %{version}-%{release}
+Recommends: libvirt-daemon = %{version}-%{release}
%else
Requires: libvirt-daemon = %{version}-%{release}
%endif
@@ -930,6 +934,7 @@ Summary: Server side daemon & driver required to run VirtualBox guests
%if %{with_modular_daemons}
Requires: libvirt-daemon-common = %{version}-%{release}
Requires: libvirt-daemon-proxy = %{version}-%{release}
+Recommends: libvirt-daemon = %{version}-%{release}
%else
Requires: libvirt-daemon = %{version}-%{release}
%endif
--
2.41.0
3
8