[PATCH 4/4] check-block: replace -makecheck with TAP output

2022-01-15 Thread Paolo Bonzini
Let "meson test" take care of showing the results of the individual tests,
consistently with other output from "make check V=1".

Signed-off-by: Paolo Bonzini 
---
 tests/check-block.sh |  6 ++--
 tests/qemu-iotests/check |  6 ++--
 tests/qemu-iotests/meson.build   |  1 +
 tests/qemu-iotests/testenv.py| 30 +--
 tests/qemu-iotests/testrunner.py | 49 +---
 5 files changed, 48 insertions(+), 44 deletions(-)

diff --git a/tests/check-block.sh b/tests/check-block.sh
index 88e02453d2..720a46bc36 100755
--- a/tests/check-block.sh
+++ b/tests/check-block.sh
@@ -14,8 +14,8 @@ else
 fi
 
 skip() {
-echo "$*"
-exit 77
+echo "1..0 #SKIP $*"
+exit 0
 }
 
 if grep -q "CONFIG_GPROF=y" config-host.mak 2>/dev/null ; then
@@ -79,7 +79,7 @@ JOBS=$(echo "$MAKEFLAGS" | sed -n 's/\(^\|.* 
\)-j\([0-9]\+\)\( .*\|$\)/-j \2/p')
 
 ret=0
 for fmt in $format_list ; do
-${PYTHON} ./check $JOBS -makecheck -$fmt $group || ret=1
+${PYTHON} ./check $JOBS -tap -$fmt $group || ret=1
 done
 
 exit $ret
diff --git a/tests/qemu-iotests/check b/tests/qemu-iotests/check
index 0c27721a41..75de1b4691 100755
--- a/tests/qemu-iotests/check
+++ b/tests/qemu-iotests/check
@@ -32,8 +32,6 @@ def make_argparser() -> argparse.ArgumentParser:
 
 p.add_argument('-n', '--dry-run', action='store_true',
help='show me, do not run tests')
-p.add_argument('-makecheck', action='store_true',
-   help='pretty print output for make check')
 p.add_argument('-j', dest='jobs', type=int, default=1,
help='run tests in multiple parallel jobs')
 
@@ -53,6 +51,8 @@ def make_argparser() -> argparse.ArgumentParser:
 p.add_argument('--color', choices=['on', 'off', 'auto'],
default='auto', help="use terminal colors. The default "
"'auto' value means use colors if terminal stdout detected")
+p.add_argument('-tap', action='store_true',
+   help='produce TAP output')
 
 g_env = p.add_argument_group('test environment options')
 mg = g_env.add_mutually_exclusive_group()
@@ -164,7 +164,7 @@ if __name__ == '__main__':
 if args.dry_run:
 print('\n'.join(tests))
 else:
-with TestRunner(env, makecheck=args.makecheck,
+with TestRunner(env, tap=args.tap,
 color=args.color) as tr:
 paths = [os.path.join(env.source_iotests, t) for t in tests]
 ok = tr.run_tests(paths, args.jobs)
diff --git a/tests/qemu-iotests/meson.build b/tests/qemu-iotests/meson.build
index 94f161d59c..319a3872ef 100644
--- a/tests/qemu-iotests/meson.build
+++ b/tests/qemu-iotests/meson.build
@@ -22,6 +22,7 @@ if have_tools
 endif
 test('qemu-iotests ' + format, sh, args: [files('../check-block.sh'), 
format],
  depends: qemu_iotests_binaries, env: qemu_iotests_env,
+ protocol: 'tap',
  suite: suites,
  timeout: 0,
  is_parallel: false)
diff --git a/tests/qemu-iotests/testenv.py b/tests/qemu-iotests/testenv.py
index c33454fa68..0f32897fe8 100644
--- a/tests/qemu-iotests/testenv.py
+++ b/tests/qemu-iotests/testenv.py
@@ -287,21 +287,21 @@ def __enter__(self) -> 'TestEnv':
 def __exit__(self, exc_type: Any, exc_value: Any, traceback: Any) -> None:
 self.close()
 
-def print_env(self) -> None:
+def print_env(self, prefix: str = '') -> None:
 template = """\
-QEMU  -- "{QEMU_PROG}" {QEMU_OPTIONS}
-QEMU_IMG  -- "{QEMU_IMG_PROG}" {QEMU_IMG_OPTIONS}
-QEMU_IO   -- "{QEMU_IO_PROG}" {QEMU_IO_OPTIONS}
-QEMU_NBD  -- "{QEMU_NBD_PROG}" {QEMU_NBD_OPTIONS}
-IMGFMT-- {IMGFMT}{imgopts}
-IMGPROTO  -- {IMGPROTO}
-PLATFORM  -- {platform}
-TEST_DIR  -- {TEST_DIR}
-SOCK_DIR  -- {SOCK_DIR}
-GDB_OPTIONS   -- {GDB_OPTIONS}
-VALGRIND_QEMU -- {VALGRIND_QEMU}
-PRINT_QEMU_OUTPUT -- {PRINT_QEMU}
-"""
+{prefix}QEMU  -- "{QEMU_PROG}" {QEMU_OPTIONS}
+{prefix}QEMU_IMG  -- "{QEMU_IMG_PROG}" {QEMU_IMG_OPTIONS}
+{prefix}QEMU_IO   -- "{QEMU_IO_PROG}" {QEMU_IO_OPTIONS}
+{prefix}QEMU_NBD  -- "{QEMU_NBD_PROG}" {QEMU_NBD_OPTIONS}
+{prefix}IMGFMT-- {IMGFMT}{imgopts}
+{prefix}IMGPROTO  -- {IMGPROTO}
+{prefix}PLATFORM  -- {platform}
+{prefix}TEST_DIR  -- {TEST_DIR}
+{prefix}SOCK_DIR  -- {SOCK_DIR}
+{prefix}GDB_OPTIONS   -- {GDB_OPTIONS}
+{prefix}VALGRIND_QEMU -- {VALGRIND_QEMU}
+{prefix}PRINT_QEMU_OUTPUT -- {PRINT_QEMU}
+{prefix}"""
 
 args = collections.defaultdict(str, self.get_env())
 
@@ -310,5 +310,5 @@ def print_env(self) -> None:
 
 u = os.uname()
 args['platform'] = f'{u.sysname}/{u.machine} {u.nodename} {u.release}'
-
+args['pre

[PATCH 3/4] qemu-iotests: require at least an argument to check-block.sh

2022-01-15 Thread Paolo Bonzini
This is anyway how check-block.sh is used in practice, and by removing the
list of formats in the script we avoid duplication between meson.build
and check-block.sh.

Signed-off-by: Paolo Bonzini 
---
 tests/check-block.sh | 21 +
 1 file changed, 9 insertions(+), 12 deletions(-)

diff --git a/tests/check-block.sh b/tests/check-block.sh
index 9afeea5275..88e02453d2 100755
--- a/tests/check-block.sh
+++ b/tests/check-block.sh
@@ -1,19 +1,16 @@
 #!/bin/sh
 
-# Honor the SPEED environment variable, just like we do it for "meson test"
-if [ "$SPEED" = "slow" ]; then
-format_list="raw qcow2"
-group=
-elif [ "$SPEED" = "thorough" ]; then
-format_list="raw qcow2 qed vmdk vpc"
-group=
-else
-format_list=qcow2
-group="-g auto"
+if [ "$#" -eq 0 ]; then
+echo "Usage: $0 fmt..." >&2
+exit 99
 fi
 
-if [ "$#" -ne 0 ]; then
-format_list="$@"
+# Honor the SPEED environment variable, just like we do it for "meson test"
+format_list="$@"
+if [ "$SPEED" = "slow" ] || [ "$SPEED" = "thorough" ]; then
+group=
+else
+group="-g auto"
 fi
 
 skip() {
-- 
2.33.1





[PATCH 2/4] build: make check-block a meson test

2022-01-15 Thread Paolo Bonzini
"meson test" can be asked to run tests verbosely; this makes it usable
also for qemu-iotests's own harness, and it lets "make check-block"
reuse mtest2make.py's infrastructure to find and build test dependencies.

Adjust check-block.sh to use the standard exit code that reports a test
as skipped.  Alternatively, in the future we could make it produce TAP
output, which is consistent with all other "make check" tests.

Signed-off-by: Paolo Bonzini 
---
 meson.build|  6 +++---
 scripts/mtest2make.py  | 10 +-
 tests/Makefile.include | 16 +++-
 tests/check-block.sh   | 28 +---
 tests/meson.build  |  1 +
 tests/qemu-iotests/meson.build | 29 +
 6 files changed, 58 insertions(+), 32 deletions(-)
 create mode 100644 tests/qemu-iotests/meson.build

diff --git a/meson.build b/meson.build
index c9004bd25e..229061f971 100644
--- a/meson.build
+++ b/meson.build
@@ -3,9 +3,9 @@ project('qemu', ['c'], meson_version: '>=0.58.2',
   'b_staticpic=false', 'stdsplit=false'],
 version: files('VERSION'))
 
-add_test_setup('quick', exclude_suites: ['slow', 'thorough'], is_default: true)
-add_test_setup('slow', exclude_suites: ['thorough'], env: ['G_TEST_SLOW=1', 
'SPEED=slow'])
-add_test_setup('thorough', env: ['G_TEST_SLOW=1', 'SPEED=thorough'])
+add_test_setup('quick', exclude_suites: ['block', 'slow', 'thorough'], 
is_default: true)
+add_test_setup('slow', exclude_suites: ['block', 'thorough'], env: 
['G_TEST_SLOW=1', 'SPEED=slow'])
+add_test_setup('thorough', exclude_suites: ['block'], env: ['G_TEST_SLOW=1', 
'SPEED=thorough'])
 
 not_found = dependency('', required: false)
 keyval = import('keyval')
diff --git a/scripts/mtest2make.py b/scripts/mtest2make.py
index 4b9c561b30..4d542e8aaa 100644
--- a/scripts/mtest2make.py
+++ b/scripts/mtest2make.py
@@ -79,7 +79,7 @@ def emit_prolog(suites, prefix):
 print(f'{prefix}-report.junit.xml $(all-{prefix}-xml): 
{prefix}-report%.junit.xml: run-ninja')
 print(f'\t$(MAKE) {prefix}$* MTESTARGS="$(MTESTARGS) --logbase 
{prefix}-report$*" && ln -f meson-logs/$@ .')
 
-def emit_suite(name, suite, prefix):
+def emit_suite_deps(name, suite, prefix):
 deps = ' '.join(suite.deps)
 targets = f'{prefix}-{name} {prefix}-report-{name}.junit.xml {prefix} 
{prefix}-report.junit.xml'
 print()
@@ -87,6 +87,10 @@ def emit_suite(name, suite, prefix):
 print(f'ifneq ($(filter {prefix}-build {targets}, $(MAKECMDGOALS)),)')
 print(f'.{prefix}.build-suites += {name}')
 print(f'endif')
+
+def emit_suite(name, suite, prefix):
+emit_suite_deps(name, suite, prefix)
+targets = f'{prefix}-{name} {prefix}-report-{name}.junit.xml {prefix} 
{prefix}-report.junit.xml'
 print(f'ifneq ($(filter {targets}, $(MAKECMDGOALS)),)')
 print(f'.{prefix}.mtest-suites += ' + ' '.join(suite.names(name)))
 print(f'endif')
@@ -97,6 +101,10 @@ def emit_suite(name, suite, prefix):
 testsuites = defaultdict(Suite)
 for test in introspect['tests']:
 process_tests(test, targets, testsuites)
+# HACK: check-block is a separate target so that it runs with --verbose;
+# only write the dependencies
+emit_suite_deps('block', testsuites['block'], 'check')
+del testsuites['block']
 emit_prolog(testsuites, 'check')
 for name, suite in testsuites.items():
 emit_suite(name, suite, 'check')
diff --git a/tests/Makefile.include b/tests/Makefile.include
index 4c564cf789..722ff15145 100644
--- a/tests/Makefile.include
+++ b/tests/Makefile.include
@@ -156,19 +156,9 @@ check:
 
 ifeq ($(CONFIG_TOOLS)$(CONFIG_POSIX),yy)
 check: check-block
-export PYTHON
-
-ifneq ($(filter check check-block check-build, $(MAKECMDGOALS)),)
-ninja-cmd-goals += \
-   qemu-img$(EXESUF) \
-   qemu-io$(EXESUF) \
-   qemu-nbd$(EXESUF) \
-   storage-daemon/qemu-storage-daemon$(EXESUF) \
-   $(filter qemu-system-%, $(ninja-targets))
-endif
-
-check-block: $(SRC_PATH)/tests/check-block.sh run-ninja
-   @$<
+check-block: run-ninja
+   $(if $(MAKE.n),,+)$(MESON) test $(MTESTARGS) $(.mtestargs) --verbose \
+   --logbase iotestslog $(call .speed.$(SPEED), block block-slow 
block-thorough)
 endif
 
 check-build: run-ninja
diff --git a/tests/check-block.sh b/tests/check-block.sh
index d98d49ad63..9afeea5275 100755
--- a/tests/check-block.sh
+++ b/tests/check-block.sh
@@ -1,6 +1,6 @@
 #!/bin/sh
 
-# Honor the SPEED environment variable, just like we do it for the qtests.
+# Honor the SPEED environment variable, just like we do it for "meson test"
 if [ "$SPEED" = "slow" ]; then
 format_list="raw qcow2"
 group=
@@ -16,9 +16,13 @@ if [ "$#" -ne 0 ]; then
 format_list="$@"
 fi
 
+skip() {
+echo "$*"
+exit 77
+}
+
 if grep -q "CONFIG_GPROF=y" config-host.mak 2>/dev/null ; then
-   

[PATCH 1/4] scripts/mtest2make: add support for SPEED=thorough

2022-01-15 Thread Paolo Bonzini
Signed-off-by: Paolo Bonzini 
---
 meson.build   |  5 +++--
 scripts/mtest2make.py | 10 +++---
 2 files changed, 10 insertions(+), 5 deletions(-)

diff --git a/meson.build b/meson.build
index 762d7cee85..c9004bd25e 100644
--- a/meson.build
+++ b/meson.build
@@ -3,8 +3,9 @@ project('qemu', ['c'], meson_version: '>=0.58.2',
   'b_staticpic=false', 'stdsplit=false'],
 version: files('VERSION'))
 
-add_test_setup('quick', exclude_suites: 'slow', is_default: true)
-add_test_setup('slow', env: ['G_TEST_SLOW=1', 'SPEED=slow'])
+add_test_setup('quick', exclude_suites: ['slow', 'thorough'], is_default: true)
+add_test_setup('slow', exclude_suites: ['thorough'], env: ['G_TEST_SLOW=1', 
'SPEED=slow'])
+add_test_setup('thorough', env: ['G_TEST_SLOW=1', 'SPEED=thorough'])
 
 not_found = dependency('', required: false)
 keyval = import('keyval')
diff --git a/scripts/mtest2make.py b/scripts/mtest2make.py
index 7067bdadf5..4b9c561b30 100644
--- a/scripts/mtest2make.py
+++ b/scripts/mtest2make.py
@@ -23,8 +23,9 @@ def names(self, base):
 print('''
 SPEED = quick
 
-.speed.quick = $(foreach s,$(sort $(filter-out %-slow, $1)), --suite $s)
-.speed.slow = $(foreach s,$(sort $1), --suite $s)
+.speed.quick = $(foreach s,$(sort $(filter-out %-slow %-thorough, $1)), 
--suite $s)
+.speed.slow = $(foreach s,$(sort $(filter-out %-thorough, $1)), --suite $s)
+.speed.thorough = $(foreach s,$(sort $1), --suite $s)
 
 .mtestargs = --no-rebuild -t 0
 ifneq ($(SPEED), quick)
@@ -52,11 +53,14 @@ def process_tests(test, targets, suites):
 for s in test_suites:
 # The suite name in the introspection info is "PROJECT:SUITE"
 s = s.split(':')[1]
-if s == 'slow':
+if s == 'slow' or s == 'thorough':
 continue
 if s.endswith('-slow'):
 s = s[:-5]
 suites[s].speeds.append('slow')
+if s.endswith('-thorough'):
+s = s[:-9]
+suites[s].speeds.append('thorough')
 suites[s].deps.update(deps)
 
 def emit_prolog(suites, prefix):
-- 
2.33.1





[PATCH 0/4] make check-block a meson test

2022-01-15 Thread Paolo Bonzini
This series makes "meson test" run the block layer tests, reporting
their outcome in the same way as the other TAP tests.

Based-on: <20211223183933.1497037-1-vsement...@virtuozzo.com>

Paolo Bonzini (4):
  scripts/mtest2make: add support for SPEED=thorough
  build: make check-block a meson test
  qemu-iotests: require at least an argument to check-block.sh
  check-block: replace -makecheck with TAP output

 meson.build  |  5 ++--
 scripts/mtest2make.py| 20 ++---
 tests/Makefile.include   | 16 ++-
 tests/check-block.sh | 45 +
 tests/meson.build|  1 +
 tests/qemu-iotests/check |  6 ++--
 tests/qemu-iotests/meson.build   | 30 +++
 tests/qemu-iotests/testenv.py| 30 +--
 tests/qemu-iotests/testrunner.py | 49 +---
 9 files changed, 117 insertions(+), 85 deletions(-)
 create mode 100644 tests/qemu-iotests/meson.build

-- 
2.33.1




[PATCH 0/4] make check-block a meson test

2022-01-15 Thread Paolo Bonzini
This series makes "meson test" run the block layer tests, reporting
their outcome in the same way as the other TAP tests.

Based-on: <20211223183933.1497037-1-vsement...@virtuozzo.com>

Paolo Bonzini (4):
  scripts/mtest2make: add support for SPEED=thorough
  build: make check-block a meson test
  qemu-iotests: require at least an argument to check-block.sh
  check-block: replace -makecheck with TAP output

 meson.build  |  5 ++--
 scripts/mtest2make.py| 20 ++---
 tests/Makefile.include   | 16 ++-
 tests/check-block.sh | 45 +
 tests/meson.build|  1 +
 tests/qemu-iotests/check |  6 ++--
 tests/qemu-iotests/meson.build   | 30 +++
 tests/qemu-iotests/testenv.py| 30 +--
 tests/qemu-iotests/testrunner.py | 49 +---
 9 files changed, 117 insertions(+), 85 deletions(-)
 create mode 100644 tests/qemu-iotests/meson.build

-- 
2.33.1




Re: [PATCH v2 0/3] Support fd-based KVM stats

2022-01-15 Thread Paolo Bonzini

On 11/19/21 20:51, Mark Kanda wrote:

v2: [Paolo]
- generalize the interface
- add support for querying stat schema and instances
- add additional HMP semantic processing for a few exponent/unit
   combinations (related to seconds and bytes)

This patchset adds QEMU support for querying fd-based KVM stats. The
kernel support was introduced by:

cb082bfab59a ("KVM: stats: Add fd-based API to read binary stats data")


Hi Mark,

sorry for the late review.  Fortunately there's very little that I'd change.

In particular:

* please change the callbacks to accept a NULL name and type, instead of 
having the "bool"/"const char *" pair.  You can probably benefit from a 
function to cutils.c like


bool qemu_match_string(const char *value, const char *request) {
return !request || g_str_equal(value, request);
}

* please pass a single const struct to add_stats_callbacks, using GList 
so that the struct can be const.


Putting both together it would be something like:

typedef struct StatsCallbacks {
char *name;
StatsList *(*get_values)(StatsList *list, const char *name,
   const char *type, Error **errp);
StatsSchemaList *(*get_schemas)(StatsSchemaList *list,
const char *name, Error **errp);
StatsInstanceList *(*get_instances)(StatsInstanceList *list,
Error **errp);
} StatsCallbacks;

Finally, please put everything in a new header include/monitor/stats.h, 
so that we can document everything and please it in docs/devel.  I can 
take care of that though.


Thanks,

Paolo



Mark Kanda (3):
   qmp: Support for querying stats
   hmp: Support for querying stats
   kvm: Support for querying fd-based stats

  accel/kvm/kvm-all.c   | 399 ++
  hmp-commands-info.hx  |  40 
  include/monitor/hmp.h |   3 +
  include/monitor/monitor.h |  27 +++
  monitor/hmp-cmds.c| 125 
  monitor/qmp-cmds.c|  71 +++
  qapi/misc.json| 142 ++
  7 files changed, 807 insertions(+)






Re: [PATCH] build-sys: fix a meson deprecation warning

2022-01-15 Thread Paolo Bonzini

On 1/13/22 17:21, marcandre.lur...@redhat.com wrote:

From: Marc-André Lureau 

WARNING: Deprecated features used:
  * 0.56.0: {'meson.source_root'}

Signed-off-by: Marc-André Lureau 
Reported-by: Peter Maydell 
---
  tests/qtest/meson.build | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tests/qtest/meson.build b/tests/qtest/meson.build
index 37e1eaa4498e..2f6687576757 100644
--- a/tests/qtest/meson.build
+++ b/tests/qtest/meson.build
@@ -103,7 +103,7 @@ if dbus_daemon.found() and 
config_host.has_key('GDBUS_CODEGEN')
#qtests_i386 += ['dbus-vmstate-test']
dbus_vmstate1 = custom_target('dbus-vmstate description',
  output: ['dbus-vmstate1.h', 
'dbus-vmstate1.c'],
-input: meson.source_root() / 
'backends/dbus-vmstate1.xml',
+input: meson.project_source_root() / 
'backends/dbus-vmstate1.xml',
  command: [config_host['GDBUS_CODEGEN'],
'@INPUT@',
'--interface-prefix', 'org.qemu',


Queued, thanks.

Paolo



Re: [PATCH 1/2] build-sys: fix undefined ARCH error

2022-01-15 Thread Paolo Bonzini

On 1/14/22 09:43, marcandre.lur...@redhat.com wrote:

From: Marc-André Lureau 

../qga/meson.build:76:4: ERROR: Key ARCH is not in the dictionary.

Fixes commit 823eb013 ("configure, meson: move ARCH to meson.build")

Signed-off-by: Marc-André Lureau 
---
  qga/meson.build | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/qga/meson.build b/qga/meson.build
index cfb1fbc0853c..613ecb980286 100644
--- a/qga/meson.build
+++ b/qga/meson.build
@@ -75,7 +75,7 @@ if targetos == 'windows'
  endif
  qga_msi = custom_target('QGA MSI',
  input: files('installer/qemu-ga.wxs'),
-output: 
'qemu-ga-@0@.msi'.format(config_host['ARCH']),
+output: 'qemu-ga-@0@.msi'.format(host_arch),
  depends: deps,
  command: [
find_program('env'),


Queued both, thanks.

Paolo



Re: [PATCH 6/6] tests/qtest/libqos: Add pci-arm and add a pci-arm producer in arm-virt machine

2022-01-15 Thread Paolo Bonzini

On 1/10/22 22:19, Eric Auger wrote:

Up to now the virt-machine node contains a virtio-mmio node.
However no driver produces any PCI interface node. Hence, PCI
tests cannot be run with aarch64 binary.

Add a GPEX driver node that produces a pci interface node. This latter
then can be consumed by all the pci tests. One of the first motivation
was to be able to run the virtio-iommu-pci tests.

We still face an issue with pci hotplug tests as hotplug cannot happen
on the pcie root bus and require a generic root port. This will be
addressed later on.

Signed-off-by: Eric Auger 


Hey Eric,

it's great to have gpex support in libqos/qgraph!  On the next versions 
you might also Cc Emanuele since he was the author of the framework.



---
  tests/qtest/libqos/arm-virt-machine.c |  47 +-
  tests/qtest/libqos/meson.build|   3 +
  tests/qtest/libqos/pci-arm.c  | 219 ++
  tests/qtest/libqos/pci-arm.h  |  56 +++
  tests/qtest/libqos/pci.h  |   1 +
  tests/qtest/libqos/qgraph.c   |   7 +
  tests/qtest/libqos/qgraph.h   |  15 ++
  7 files changed, 344 insertions(+), 4 deletions(-)
  create mode 100644 tests/qtest/libqos/pci-arm.c
  create mode 100644 tests/qtest/libqos/pci-arm.h

diff --git a/tests/qtest/libqos/arm-virt-machine.c 
b/tests/qtest/libqos/arm-virt-machine.c
index e0f59322845..130c45c51e2 100644
--- a/tests/qtest/libqos/arm-virt-machine.c
+++ b/tests/qtest/libqos/arm-virt-machine.c
@@ -22,6 +22,8 @@
  #include "malloc.h"
  #include "qgraph.h"
  #include "virtio-mmio.h"
+#include "pci-arm.h"
+#include "hw/pci/pci_regs.h"
  
  #define ARM_PAGE_SIZE   4096

  #define VIRTIO_MMIO_BASE_ADDR   0x0A003E00
@@ -30,13 +32,40 @@
  #define VIRTIO_MMIO_SIZE0x0200
  
  typedef struct QVirtMachine QVirtMachine;

+typedef struct QGenericPCIHost QGenericPCIHost;
+
+struct QGenericPCIHost {
+QOSGraphObject obj;
+QPCIBusARM pci;
+};


You can rename QPCIBusARM to QGenericPCIBus and move QGenericPCIHost to 
the same file.  There's nothing ARM specific in either file, and nothing 
specific to -M virt in QGenericPCIHost.



  struct QVirtMachine {
  QOSGraphObject obj;
  QGuestAllocator alloc;
  QVirtioMMIODevice virtio_mmio;
+QGenericPCIHost bridge;
  };
  
+/* QGenericPCIHost */

+
+static QOSGraphObject *generic_pcihost_get_device(void *obj, const char 
*device)
+{
+QGenericPCIHost *host = obj;
+if (!g_strcmp0(device, "pci-bus-arm")) {
+return >pci.obj;
+}
+fprintf(stderr, "%s not present in generic-pcihost\n", device);
+g_assert_not_reached();
+}
+
+static void qos_create_generic_pcihost(QGenericPCIHost *host,
+   QTestState *qts,
+   QGuestAllocator *alloc)
+{
+host->obj.get_device = generic_pcihost_get_device;
+qpci_init_arm(>pci, qts, alloc, false);
+}
+
  static void virt_destructor(QOSGraphObject *obj)
  {
  QVirtMachine *machine = (QVirtMachine *) obj;


This should also be in the same file as the bus implementation.


+qos_node_create_driver("generic-pcihost", NULL);
+qos_node_contains("generic-pcihost", "pci-bus-arm", NULL);


This too, with a new libqos_init.



+static uint8_t qpci_arm_config_readb(QPCIBus *bus, int devfn, uint8_t offset)
+{
+uint64_t addr = bus->ecam_alloc_ptr + ((0 << 20) | (devfn << 12) | offset);


ecam_alloc_ptr should be in QPCIBusARM (to be renamed to 
QGenericPCIBus), which you can retrieve from the "bus" QPCIBus* via 
container_of.



diff --git a/tests/qtest/libqos/pci-arm.h b/tests/qtest/libqos/pci-arm.h
new file mode 100644
index 000..8cd49ec2969
--- /dev/null
+++ b/tests/qtest/libqos/pci-arm.h
@@ -0,0 +1,56 @@
+/*
+ * libqos PCI bindings for ARM
+ *
+ * Copyright Red Hat Inc., 2021
+ *
+ * Authors:
+ *  Eric Auger   
+ *
+ * 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 LIBQOS_PCI_ARM_H
+#define LIBQOS_PCI_ARM_H
+
+#include "pci.h"
+#include "malloc.h"
+#include "qgraph.h"
+
+typedef struct QPCIBusARM {
+QOSGraphObject obj;
+QPCIBus bus;
+uint64_t gpex_pio_base;
+} QPCIBusARM;
+
+/*
+ * qpci_init_arm():
+ * @ret: A valid QPCIBusARM * pointer
+ * @qts: The %QTestState for this ARM machine
+ * @alloc: A previously initialized @alloc providing memory for @qts
+ * @bool: devices can be hotplugged on this bus
+ *
+ * This function initializes an already allocated
+ * QPCIBusARM object.
+ */
+void qpci_init_arm(QPCIBusARM *ret, QTestState *qts,
+   QGuestAllocator *alloc, bool hotpluggable);
+
+/*
+ * qpci_arm_new():
+ * @qts: The %QTestState for this ARM machine
+ * @alloc: A previously initialized @alloc providing memory for @qts
+ * @hotpluggable: the pci bus is hotpluggable
+ *
+ * This function creates a new QPCIBusARM object,
+ * and properly initialize its fields.
+ *
+ * Returns the QPCIBus 

Re: /usr/shared/qemu binaries

2022-01-13 Thread Paolo Bonzini

On 1/12/22 14:56, Peter Maydell wrote:

Those are UEFI firmware images which are suitable for using with
the arm/aarch64 "virt" board. They're only used if the user specifically
asks to use them on the command line (eg with
"-drive if=pflash,format=raw,file=pc-bios/edk2-aarch64-code.fd" or
similar).


There must be lots of zeros in there. Maybe we should tell QEMU to 
unpack firmware .gz or .lzo files?


Paolo



[PULL v5 00/18] Build system and KVM changes for 2021-12-23

2022-01-12 Thread Paolo Bonzini
The following changes since commit b37778b840f6dc6d1bbaf0e8e0641b3d48ad77c5:

  linux-user: Fix clang warning for nios2-linux-user code (2022-01-12 09:22:01 
+)

are available in the Git repository at:

  https://gitlab.com/bonzini/qemu.git tags/for-upstream

for you to fetch changes up to 9d30c78c7d3b994825cbe63fa277279ae3ef4248:

  meson: reenable filemonitor-inotify compilation (2022-01-12 14:09:06 +0100)


* configure and meson cleanups
* KVM_GET/SET_SREGS2 support for x86


v4->v5: remove --enable/disable-xfsctl

Maxim Levitsky (1):
  KVM: use KVM_{GET|SET}_SREGS2 when supported.

Paolo Bonzini (14):
  meson: reuse common_user_inc when building files specific to user-mode 
emulators
  user: move common-user includes to a subdirectory of {bsd,linux}-user/
  meson: cleanup common-user/ build
  configure: simplify creation of plugin symbol list
  configure: do not set bsd_user/linux_user early
  configure, makefile: remove traces of really old files
  configure: parse --enable/--disable-strip automatically, flip default
  configure: move non-command-line variables away from command-line parsing 
section
  meson: build contrib/ executables after generated headers
  configure, meson: move config-poison.h to meson
  meson: add comments in the target-specific flags section
  KVM: x86: ignore interrupt_bitmap field of KVM_GET/SET_SREGS
  configure: do not create roms/seabios/config.mak if SeaBIOS not present
  meson: build all modules by default

Philippe Mathieu-Daudé (1):
  tests/tcg: Fix target-specific Makefile variables path for user-mode

Thomas Huth (1):
  block/file-posix: Simplify the XFS_IOC_DIOINFO handling

Volker Rümelin (1):
  meson: reenable filemonitor-inotify compilation

 Makefile   |  11 +-
 block/file-posix.c |  37 ++--
 bsd-user/{ => include}/special-errno.h |   0
 bsd-user/meson.build   |   2 +-
 common-user/meson.build|   2 +-
 configure  | 189 -
 contrib/elf2dmp/meson.build|   2 +-
 contrib/ivshmem-client/meson.build |   2 +-
 contrib/ivshmem-server/meson.build |   2 +-
 contrib/rdmacm-mux/meson.build |   2 +-
 .../{ => include}/host/aarch64/host-signal.h   |   0
 linux-user/{ => include}/host/alpha/host-signal.h  |   0
 linux-user/{ => include}/host/arm/host-signal.h|   0
 linux-user/{ => include}/host/i386/host-signal.h   |   0
 .../{ => include}/host/loongarch64/host-signal.h   |   0
 linux-user/{ => include}/host/mips/host-signal.h   |   0
 linux-user/{ => include}/host/ppc/host-signal.h|   0
 linux-user/{ => include}/host/ppc64/host-signal.h  |   0
 linux-user/{ => include}/host/riscv/host-signal.h  |   0
 linux-user/{ => include}/host/s390/host-signal.h   |   0
 linux-user/{ => include}/host/s390x/host-signal.h  |   0
 linux-user/{ => include}/host/sparc/host-signal.h  |   0
 .../{ => include}/host/sparc64/host-signal.h   |   0
 linux-user/{ => include}/host/x32/host-signal.h|   0
 linux-user/{ => include}/host/x86_64/host-signal.h |   0
 linux-user/{ => include}/special-errno.h   |   0
 linux-user/meson.build |   4 +-
 meson.build|  37 ++--
 pc-bios/s390-ccw/Makefile  |   2 -
 plugins/meson.build|  13 +-
 scripts/ci/org.centos/stream/8/x86_64/configure|   1 -
 scripts/coverity-scan/run-coverity-scan|   2 +-
 scripts/make-config-poison.sh  |  16 ++
 scripts/meson-buildoptions.py  |  21 ++-
 scripts/meson-buildoptions.sh  |   3 +
 target/i386/cpu.h  |   3 +
 target/i386/kvm/kvm.c  | 130 --
 target/i386/machine.c  |  29 
 tests/qtest/meson.build|   3 +-
 tests/tcg/Makefile.target  |   2 +-
 tests/unit/meson.build |   2 +-
 util/meson.build   |   7 +-
 42 files changed, 276 insertions(+), 248 deletions(-)
 rename bsd-user/{ => include}/special-errno.h (100%)
 rename linux-user/{ => include}/host/aarch64/host-signal.h (100%)
 rename linux-user/{ => include}/host/alpha/host-signal.h (100%)
 rename linux-user/{ => include}/host/arm/host-signal.h (100%)
 rename linux-user/{ => include}/host/i386/host-signal.h (100%)
 rename linux-user/{ => include}/host/loongarch64/host-signal.h (100%)
 rename linux-user/{ =&

[PULL v5 04/18] block/file-posix: Simplify the XFS_IOC_DIOINFO handling

2022-01-12 Thread Paolo Bonzini
From: Thomas Huth 

The handling for the XFS_IOC_DIOINFO ioctl is currently quite excessive:
This is not a "real" feature like the other features that we provide with
the "--enable-xxx" and "--disable-xxx" switches for the configure script,
since this does not influence lots of code (it's only about one call to
xfsctl() in file-posix.c), so people don't gain much with the ability to
disable this with "--disable-xfsctl".
It's also unfortunate that the ioctl will be disabled on Linux in case
the user did not install the right xfsprogs-devel package before running
configure. Thus let's simplify this by providing the ioctl definition
on our own, so we can completely get rid of the header dependency and
thus the related code in the configure script.

Suggested-by: Paolo Bonzini 
Signed-off-by: Thomas Huth 
Message-Id: <20211215125824.250091-1-th...@redhat.com>
Signed-off-by: Paolo Bonzini 
---
 block/file-posix.c| 37 ---
 configure | 31 
 meson.build   |  1 -
 .../ci/org.centos/stream/8/x86_64/configure   |  1 -
 scripts/coverity-scan/run-coverity-scan   |  2 +-
 5 files changed, 17 insertions(+), 55 deletions(-)

diff --git a/block/file-posix.c b/block/file-posix.c
index b283093e5b..1f1756e192 100644
--- a/block/file-posix.c
+++ b/block/file-posix.c
@@ -106,10 +106,6 @@
 #include 
 #endif
 
-#ifdef CONFIG_XFS
-#include 
-#endif
-
 /* OS X does not have O_DSYNC */
 #ifndef O_DSYNC
 #ifdef O_SYNC
@@ -156,9 +152,6 @@ typedef struct BDRVRawState {
 int perm_change_flags;
 BDRVReopenState *reopen_state;
 
-#ifdef CONFIG_XFS
-bool is_xfs:1;
-#endif
 bool has_discard:1;
 bool has_write_zeroes:1;
 bool discard_zeroes:1;
@@ -409,14 +402,22 @@ static void raw_probe_alignment(BlockDriverState *bs, int 
fd, Error **errp)
 if (probe_logical_blocksize(fd, >bl.request_alignment) < 0) {
 bs->bl.request_alignment = 0;
 }
-#ifdef CONFIG_XFS
-if (s->is_xfs) {
-struct dioattr da;
-if (xfsctl(NULL, fd, XFS_IOC_DIOINFO, ) >= 0) {
-bs->bl.request_alignment = da.d_miniosz;
-/* The kernel returns wrong information for d_mem */
-/* s->buf_align = da.d_mem; */
-}
+
+#ifdef __linux__
+/*
+ * The XFS ioctl definitions are shipped in extra packages that might
+ * not always be available. Since we just need the XFS_IOC_DIOINFO ioctl
+ * here, we simply use our own definition instead:
+ */
+struct xfs_dioattr {
+uint32_t d_mem;
+uint32_t d_miniosz;
+uint32_t d_maxiosz;
+} da;
+if (ioctl(fd, _IOR('X', 30, struct xfs_dioattr), ) >= 0) {
+bs->bl.request_alignment = da.d_miniosz;
+/* The kernel returns wrong information for d_mem */
+/* s->buf_align = da.d_mem; */
 }
 #endif
 
@@ -798,12 +799,6 @@ static int raw_open_common(BlockDriverState *bs, QDict 
*options,
 #endif
 s->needs_alignment = raw_needs_alignment(bs);
 
-#ifdef CONFIG_XFS
-if (platform_test_xfs_fd(s->fd)) {
-s->is_xfs = true;
-}
-#endif
-
 bs->supported_zero_flags = BDRV_REQ_MAY_UNMAP | BDRV_REQ_NO_FALLBACK;
 if (S_ISREG(st.st_mode)) {
 /* When extending regular files, we get zeros from the OS */
diff --git a/configure b/configure
index 030728d11e..3a523a3d14 100755
--- a/configure
+++ b/configure
@@ -291,7 +291,6 @@ EXTRA_CXXFLAGS=""
 EXTRA_LDFLAGS=""
 
 xen_ctrl_version="$default_feature"
-xfs="$default_feature"
 membarrier="$default_feature"
 vhost_kernel="$default_feature"
 vhost_net="$default_feature"
@@ -1021,10 +1020,6 @@ for opt do
   ;;
   --enable-opengl) opengl="yes"
   ;;
-  --disable-xfsctl) xfs="no"
-  ;;
-  --enable-xfsctl) xfs="yes"
-  ;;
   --disable-zlib-test)
   ;;
   --enable-guest-agent) guest_agent="yes"
@@ -1431,7 +1426,6 @@ cat << EOF
   avx512f AVX512F optimization support
   replication replication support
   opengl  opengl support
-  xfsctl  xfsctl support
   qom-cast-debug  cast debugging support
   tools   build qemu-io, qemu-nbd and qemu-img tools
   bochs   bochs image format support
@@ -2323,28 +2317,6 @@ EOF
 fi
 fi
 
-##
-# xfsctl() probe, used for file-posix.c
-if test "$xfs" != "no" ; then
-  cat > $TMPC << EOF
-#include   /* NULL */
-#include 
-int main(void)
-{
-xfsctl(NULL, 0, 0, NULL);
-return 0;
-}
-EOF
-  if compile_prog "" "" ; then
-xfs="yes"
-  else
-if test "$xfs" = "yes" ; then
-  feature_not_found "xfs" "Install xfsprogs/xfslibs devel"
-fi
-xfs=no
-  fi
-fi
-
 ###

[PULL 15/18] tests/tcg: Fix target-specific Makefile variables path for user-mode

2022-01-10 Thread Paolo Bonzini
From: Philippe Mathieu-Daudé 

Commit 812b31d3f91 refactor missed to update this path.

Fixes: 812b31d3f91 ("configs: rename default-configs to configs and reorganise")
Signed-off-by: Philippe Mathieu-Daudé 
Message-Id: <20211226001541.3807919-1-f4...@amsat.org>
Signed-off-by: Paolo Bonzini 
---
 tests/tcg/Makefile.target | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tests/tcg/Makefile.target b/tests/tcg/Makefile.target
index 0f8645f782..ae8004c76e 100644
--- a/tests/tcg/Makefile.target
+++ b/tests/tcg/Makefile.target
@@ -33,7 +33,7 @@ all:
 -include ../../../config-host.mak
 -include ../config-$(TARGET).mak
 ifeq ($(CONFIG_USER_ONLY),y)
--include $(SRC_PATH)/default-configs/targets/$(TARGET).mak
+-include $(SRC_PATH)/configs/targets/$(TARGET)/default.mak
 endif
 
 # for including , in command strings
-- 
2.33.1





[PULL 14/18] KVM: x86: ignore interrupt_bitmap field of KVM_GET/SET_SREGS

2022-01-10 Thread Paolo Bonzini
This is unnecessary, because the interrupt would be retrieved and queued
anyway by KVM_GET_VCPU_EVENTS and KVM_SET_VCPU_EVENTS respectively,
and it makes the flow more similar to the one for KVM_GET/SET_SREGS2.

Signed-off-by: Paolo Bonzini 
---
 target/i386/kvm/kvm.c | 24 +---
 1 file changed, 9 insertions(+), 15 deletions(-)

diff --git a/target/i386/kvm/kvm.c b/target/i386/kvm/kvm.c
index d81745620b..2c8feb4a6f 100644
--- a/target/i386/kvm/kvm.c
+++ b/target/i386/kvm/kvm.c
@@ -2607,11 +2607,11 @@ static int kvm_put_sregs(X86CPU *cpu)
 CPUX86State *env = >env;
 struct kvm_sregs sregs;
 
+/*
+ * The interrupt_bitmap is ignored because KVM_SET_SREGS is
+ * always followed by KVM_SET_VCPU_EVENTS.
+ */
 memset(sregs.interrupt_bitmap, 0, sizeof(sregs.interrupt_bitmap));
-if (env->interrupt_injected >= 0) {
-sregs.interrupt_bitmap[env->interrupt_injected / 64] |=
-(uint64_t)1 << (env->interrupt_injected % 64);
-}
 
 if ((env->eflags & VM_MASK)) {
 set_v8086_seg(, >segs[R_CS]);
@@ -3341,23 +3341,17 @@ static int kvm_get_sregs(X86CPU *cpu)
 {
 CPUX86State *env = >env;
 struct kvm_sregs sregs;
-int bit, i, ret;
+int ret;
 
 ret = kvm_vcpu_ioctl(CPU(cpu), KVM_GET_SREGS, );
 if (ret < 0) {
 return ret;
 }
 
-/* There can only be one pending IRQ set in the bitmap at a time, so try
-   to find it and save its number instead (-1 for none). */
-env->interrupt_injected = -1;
-for (i = 0; i < ARRAY_SIZE(sregs.interrupt_bitmap); i++) {
-if (sregs.interrupt_bitmap[i]) {
-bit = ctz64(sregs.interrupt_bitmap[i]);
-env->interrupt_injected = i * 64 + bit;
-break;
-}
-}
+/*
+ * The interrupt_bitmap is ignored because KVM_GET_SREGS is
+ * always preceded by KVM_GET_VCPU_EVENTS.
+ */
 
 get_seg(>segs[R_CS], );
 get_seg(>segs[R_DS], );
-- 
2.33.1





[PULL 13/18] KVM: use KVM_{GET|SET}_SREGS2 when supported.

2022-01-10 Thread Paolo Bonzini
From: Maxim Levitsky 

This allows to make PDPTRs part of the migration
stream and thus not reload them after migration which
is against X86 spec.

Signed-off-by: Maxim Levitsky 
Message-Id: <20211101132300.192584-2-mlevi...@redhat.com>
Signed-off-by: Paolo Bonzini 
---
 target/i386/cpu.h |   3 ++
 target/i386/kvm/kvm.c | 108 +-
 target/i386/machine.c |  29 
 3 files changed, 138 insertions(+), 2 deletions(-)

diff --git a/target/i386/cpu.h b/target/i386/cpu.h
index 04f2b790c9..9911d7c871 100644
--- a/target/i386/cpu.h
+++ b/target/i386/cpu.h
@@ -1455,6 +1455,9 @@ typedef struct CPUX86State {
 SegmentCache idt; /* only base and limit are used */
 
 target_ulong cr[5]; /* NOTE: cr1 is unused */
+
+bool pdptrs_valid;
+uint64_t pdptrs[4];
 int32_t a20_mask;
 
 BNDReg bnd_regs[4];
diff --git a/target/i386/kvm/kvm.c b/target/i386/kvm/kvm.c
index 13f8e30c2a..d81745620b 100644
--- a/target/i386/kvm/kvm.c
+++ b/target/i386/kvm/kvm.c
@@ -124,6 +124,7 @@ static uint32_t num_architectural_pmu_fixed_counters;
 static int has_xsave;
 static int has_xcrs;
 static int has_pit_state2;
+static int has_sregs2;
 static int has_exception_payload;
 
 static bool has_msr_mcg_ext_ctl;
@@ -2324,6 +2325,7 @@ int kvm_arch_init(MachineState *ms, KVMState *s)
 has_xsave = kvm_check_extension(s, KVM_CAP_XSAVE);
 has_xcrs = kvm_check_extension(s, KVM_CAP_XCRS);
 has_pit_state2 = kvm_check_extension(s, KVM_CAP_PIT_STATE2);
+has_sregs2 = kvm_check_extension(s, KVM_CAP_SREGS2) > 0;
 
 hv_vpindex_settable = kvm_check_extension(s, KVM_CAP_HYPERV_VP_INDEX);
 
@@ -2650,6 +2652,61 @@ static int kvm_put_sregs(X86CPU *cpu)
 return kvm_vcpu_ioctl(CPU(cpu), KVM_SET_SREGS, );
 }
 
+static int kvm_put_sregs2(X86CPU *cpu)
+{
+CPUX86State *env = >env;
+struct kvm_sregs2 sregs;
+int i;
+
+sregs.flags = 0;
+
+if ((env->eflags & VM_MASK)) {
+set_v8086_seg(, >segs[R_CS]);
+set_v8086_seg(, >segs[R_DS]);
+set_v8086_seg(, >segs[R_ES]);
+set_v8086_seg(, >segs[R_FS]);
+set_v8086_seg(, >segs[R_GS]);
+set_v8086_seg(, >segs[R_SS]);
+} else {
+set_seg(, >segs[R_CS]);
+set_seg(, >segs[R_DS]);
+set_seg(, >segs[R_ES]);
+set_seg(, >segs[R_FS]);
+set_seg(, >segs[R_GS]);
+set_seg(, >segs[R_SS]);
+}
+
+set_seg(, >tr);
+set_seg(, >ldt);
+
+sregs.idt.limit = env->idt.limit;
+sregs.idt.base = env->idt.base;
+memset(sregs.idt.padding, 0, sizeof sregs.idt.padding);
+sregs.gdt.limit = env->gdt.limit;
+sregs.gdt.base = env->gdt.base;
+memset(sregs.gdt.padding, 0, sizeof sregs.gdt.padding);
+
+sregs.cr0 = env->cr[0];
+sregs.cr2 = env->cr[2];
+sregs.cr3 = env->cr[3];
+sregs.cr4 = env->cr[4];
+
+sregs.cr8 = cpu_get_apic_tpr(cpu->apic_state);
+sregs.apic_base = cpu_get_apic_base(cpu->apic_state);
+
+sregs.efer = env->efer;
+
+if (env->pdptrs_valid) {
+for (i = 0; i < 4; i++) {
+sregs.pdptrs[i] = env->pdptrs[i];
+}
+sregs.flags |= KVM_SREGS2_FLAGS_PDPTRS_VALID;
+}
+
+return kvm_vcpu_ioctl(CPU(cpu), KVM_SET_SREGS2, );
+}
+
+
 static void kvm_msr_buf_reset(X86CPU *cpu)
 {
 memset(cpu->kvm_msr_buf, 0, MSR_BUF_SIZE);
@@ -3330,6 +3387,53 @@ static int kvm_get_sregs(X86CPU *cpu)
 return 0;
 }
 
+static int kvm_get_sregs2(X86CPU *cpu)
+{
+CPUX86State *env = >env;
+struct kvm_sregs2 sregs;
+int i, ret;
+
+ret = kvm_vcpu_ioctl(CPU(cpu), KVM_GET_SREGS2, );
+if (ret < 0) {
+return ret;
+}
+
+get_seg(>segs[R_CS], );
+get_seg(>segs[R_DS], );
+get_seg(>segs[R_ES], );
+get_seg(>segs[R_FS], );
+get_seg(>segs[R_GS], );
+get_seg(>segs[R_SS], );
+
+get_seg(>tr, );
+get_seg(>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;
+
+env->cr[0] = sregs.cr0;
+env->cr[2] = sregs.cr2;
+env->cr[3] = sregs.cr3;
+env->cr[4] = sregs.cr4;
+
+env->efer = sregs.efer;
+
+env->pdptrs_valid = sregs.flags & KVM_SREGS2_FLAGS_PDPTRS_VALID;
+
+if (env->pdptrs_valid) {
+for (i = 0; i < 4; i++) {
+env->pdptrs[i] = sregs.pdptrs[i];
+}
+}
+
+/* changes to apic base and cr8/tpr are read back via kvm_arch_post_run */
+x86_update_hflags(env);
+
+return 0;
+}
+
 static int kvm_get_msrs(X86CPU *cpu)
 {
 CPUX86State *env = >env;
@@ -4173,7 +4277,7 @@ int kvm_arch_put_registers(CPUState *cpu, int level)
 assert(cpu_is_stopped(cpu) || qemu_cpu_is_self(cpu));
 
 /* must be before kvm_put_nested_state so that EFER.SVME is set */
-ret = kvm_put_sregs(x86_cpu);
+

[PULL 18/18] meson: reenable filemonitor-inotify compilation

2022-01-10 Thread Paolo Bonzini
From: Volker Rümelin 

Reenable util/filemonitor-inotify compilation. Compilation was
disabled when commit a620fbe9ac ("configure: convert compiler tests
to meson, part 5") moved CONFIG_INOTIFY1 from config-host.mak to
config-host.h.

This fixes the usb-mtp device and reenables test-util-filemonitor.

Fixes: a620fbe9ac ("configure: convert compiler tests to meson, part 5")
Resolves: https://gitlab.com/qemu-project/qemu/-/issues/800
Signed-off-by: Volker Rümelin 
Message-Id: <20220107133514.7785-1-vr_q...@t-online.de>
Signed-off-by: Paolo Bonzini 
---
 tests/unit/meson.build | 2 +-
 util/meson.build   | 7 +--
 2 files changed, 6 insertions(+), 3 deletions(-)

diff --git a/tests/unit/meson.build b/tests/unit/meson.build
index 90acf5b0da..64a5e7bfde 100644
--- a/tests/unit/meson.build
+++ b/tests/unit/meson.build
@@ -129,7 +129,7 @@ if have_system
 'test-vmstate': [migration, io],
 'test-yank': ['socket-helpers.c', qom, io, chardev]
   }
-  if 'CONFIG_INOTIFY1' in config_host
+  if config_host_data.get('CONFIG_INOTIFY1')
 tests += {'test-util-filemonitor': []}
   endif
 
diff --git a/util/meson.build b/util/meson.build
index e676b2f6c6..c9a9cc1cf5 100644
--- a/util/meson.build
+++ b/util/meson.build
@@ -84,7 +84,10 @@ if have_block
   util_ss.add(files('readline.c'))
   util_ss.add(files('throttle.c'))
   util_ss.add(files('timed-average.c'))
-  util_ss.add(when: 'CONFIG_INOTIFY1', if_true: files('filemonitor-inotify.c'),
-if_false: files('filemonitor-stub.c'))
+  if config_host_data.get('CONFIG_INOTIFY1')
+util_ss.add(files('filemonitor-inotify.c'))
+  else
+util_ss.add(files('filemonitor-stub.c'))
+  endif
   util_ss.add(when: 'CONFIG_LINUX', if_true: files('vfio-helpers.c'))
 endif
-- 
2.33.1




[PULL 12/18] meson: add comments in the target-specific flags section

2022-01-10 Thread Paolo Bonzini
Signed-off-by: Paolo Bonzini 
---
 meson.build | 5 +
 1 file changed, 5 insertions(+)

diff --git a/meson.build b/meson.build
index 36fc720ba3..6489ff8425 100644
--- a/meson.build
+++ b/meson.build
@@ -238,6 +238,7 @@ endif
 # Target-specific checks and dependencies #
 ###
 
+# Fuzzing
 if get_option('fuzzing') and get_option('fuzzing_engine') == '' and \
 not cc.links('''
   #include 
@@ -249,6 +250,7 @@ if get_option('fuzzing') and get_option('fuzzing_engine') 
== '' and \
   error('Your compiler does not support -fsanitize=fuzzer')
 endif
 
+# Tracing backends
 if 'ftrace' in get_option('trace_backends') and targetos != 'linux'
   error('ftrace is supported only on Linux')
 endif
@@ -262,6 +264,7 @@ if 'syslog' in get_option('trace_backends') and not 
cc.compiles('''
   error('syslog is not supported on this system')
 endif
 
+# Miscellaneous Linux-only features
 if targetos != 'linux' and get_option('mpath').enabled()
   error('Multipath is supported only on Linux')
 endif
@@ -271,6 +274,7 @@ if targetos != 'linux' and 
get_option('multiprocess').enabled()
 endif
 multiprocess_allowed = targetos == 'linux' and not 
get_option('multiprocess').disabled()
 
+# Target-specific libraries and flags
 libm = cc.find_library('m', required: false)
 threads = dependency('threads')
 util = cc.find_library('util', required: false)
@@ -311,6 +315,7 @@ elif targetos == 'openbsd'
   endif
 endif
 
+# Target-specific configuration of accelerators
 accelerators = []
 if not get_option('kvm').disabled() and targetos == 'linux'
   accelerators += 'CONFIG_KVM'
-- 
2.33.1





[PULL 11/18] configure, meson: move config-poison.h to meson

2022-01-10 Thread Paolo Bonzini
This ensures that the file is regenerated properly whenever config-target.h
or config-devices.h files change.

Signed-off-by: Paolo Bonzini 
---
 Makefile  |  2 +-
 configure | 11 ---
 meson.build   | 12 
 scripts/make-config-poison.sh | 16 
 4 files changed, 29 insertions(+), 12 deletions(-)
 create mode 100755 scripts/make-config-poison.sh

diff --git a/Makefile b/Makefile
index 8037f73b35..9e2e3bf004 100644
--- a/Makefile
+++ b/Makefile
@@ -221,7 +221,7 @@ qemu-%.tar.bz2:
 
 distclean: clean
-$(quiet-@)test -f build.ninja && $(NINJA) $(NINJAFLAGS) -t clean -g || 
:
-   rm -f config-host.mak config-poison.h
+   rm -f config-host.mak
rm -f tests/tcg/config-*.mak
rm -f config.status
rm -f roms/seabios/config.mak
diff --git a/configure b/configure
index 56c113bd83..0026388343 100755
--- a/configure
+++ b/configure
@@ -3834,17 +3834,6 @@ if test -n "${deprecated_features}"; then
 echo "  features: ${deprecated_features}"
 fi
 
-# Create list of config switches that should be poisoned in common code...
-# but filter out CONFIG_TCG and CONFIG_USER_ONLY which are special.
-target_configs_h=$(ls *-config-devices.h *-config-target.h 2>/dev/null)
-if test -n "$target_configs_h" ; then
-sed -n -e '/CONFIG_TCG/d' -e '/CONFIG_USER_ONLY/d' \
--e '/^#define / { s///; s/ .*//; s/^/#pragma GCC poison /p; }' \
-$target_configs_h | sort -u > config-poison.h
-else
-:> config-poison.h
-fi
-
 # Save the configure command line for later reuse.
 cat <config.status
 #!/bin/sh
diff --git a/meson.build b/meson.build
index 5a57906e98..36fc720ba3 100644
--- a/meson.build
+++ b/meson.build
@@ -2028,6 +2028,18 @@ config_all += {
   'CONFIG_ALL': true,
 }
 
+target_configs_h = []
+foreach target: target_dirs
+  target_configs_h += config_target_h[target]
+  target_configs_h += config_devices_h.get(target, [])
+endforeach
+genh += custom_target('config-poison.h',
+  input: [target_configs_h],
+  output: 'config-poison.h',
+  capture: true,
+  command: [find_program('scripts/make-config-poison.sh'),
+target_configs_h])
+
 ##
 # Submodules #
 ##
diff --git a/scripts/make-config-poison.sh b/scripts/make-config-poison.sh
new file mode 100755
index 00..d222a04304
--- /dev/null
+++ b/scripts/make-config-poison.sh
@@ -0,0 +1,16 @@
+#! /bin/sh
+
+if test $# = 0; then
+  exit 0
+fi
+
+# Create list of config switches that should be poisoned in common code...
+# but filter out CONFIG_TCG and CONFIG_USER_ONLY which are special.
+exec sed -n \
+  -e' /CONFIG_TCG/d' \
+  -e '/CONFIG_USER_ONLY/d' \
+  -e '/^#define / {' \
+  -e's///' \
+  -e's/ .*//' \
+  -e's/^/#pragma GCC poison /p' \
+  -e '}' "$@"
-- 
2.33.1





[PULL 08/18] configure: parse --enable/--disable-strip automatically, flip default

2022-01-10 Thread Paolo Bonzini
Always include the STRIP variable in config-host.mak (it's only used
by the s390-ccw firmware build, and it adds a default if configure
omitted it), and use meson-buildoptions.sh to turn
--enable/--disable-strip into -Dstrip.

The default is now not to strip the binaries like for almost every other
package that has a configure script.

Signed-off-by: Paolo Bonzini 
---
 configure | 10 +-
 pc-bios/s390-ccw/Makefile |  2 --
 scripts/meson-buildoptions.py | 21 ++---
 scripts/meson-buildoptions.sh |  3 +++
 4 files changed, 18 insertions(+), 18 deletions(-)

diff --git a/configure b/configure
index a02febe09c..be05bcf856 100755
--- a/configure
+++ b/configure
@@ -307,7 +307,6 @@ debug="no"
 sanitizers="no"
 tsan="no"
 fortify_source="$default_feature"
-strip_opt="yes"
 mingw32="no"
 gcov="no"
 EXESUF=""
@@ -892,7 +891,6 @@ for opt do
   debug_tcg="yes"
   debug_mutex="yes"
   debug="yes"
-  strip_opt="no"
   fortify_source="no"
   ;;
   --enable-sanitizers) sanitizers="yes"
@@ -903,8 +901,6 @@ for opt do
   ;;
   --disable-tsan) tsan="no"
   ;;
-  --disable-strip) strip_opt="no"
-  ;;
   --disable-slirp) slirp="disabled"
   ;;
   --enable-slirp) slirp="enabled"
@@ -1367,7 +1363,6 @@ Advanced options (experts only):
   --enable-debug   enable common debug build options
   --enable-sanitizers  enable default sanitizers
   --enable-tsanenable thread sanitizer
-  --disable-strip  disable stripping binaries
   --disable-werror disable compilation abort on warning
   --disable-stack-protector disable compiler-provided stack protection
   --audio-drv-list=LISTset audio drivers to try if -audiodev is not used
@@ -3315,9 +3310,6 @@ echo "GIT_SUBMODULES_ACTION=$git_submodules_action" >> 
$config_host_mak
 if test "$debug_tcg" = "yes" ; then
   echo "CONFIG_DEBUG_TCG=y" >> $config_host_mak
 fi
-if test "$strip_opt" = "yes" ; then
-  echo "STRIP=${strip}" >> $config_host_mak
-fi
 if test "$mingw32" = "yes" ; then
   echo "CONFIG_WIN32=y" >> $config_host_mak
   if test "$guest_agent_with_vss" = "yes" ; then
@@ -3595,6 +3587,7 @@ echo "GLIB_LIBS=$glib_libs" >> $config_host_mak
 echo "GLIB_VERSION=$(pkg-config --modversion glib-2.0)" >> $config_host_mak
 echo "QEMU_LDFLAGS=$QEMU_LDFLAGS" >> $config_host_mak
 echo "LD_I386_EMULATION=$ld_i386_emulation" >> $config_host_mak
+echo "STRIP=$strip" >> $config_host_mak
 echo "EXESUF=$EXESUF" >> $config_host_mak
 echo "LIBS_QGA=$libs_qga" >> $config_host_mak
 
@@ -3812,7 +3805,6 @@ if test "$skip_meson" = no; then
 -Doptimization=$(if test "$debug" = yes; then echo 0; else echo 2; fi) 
\
 -Ddebug=$(if test "$debug_info" = yes; then echo true; else echo 
false; fi) \
 -Dwerror=$(if test "$werror" = yes; then echo true; else echo false; 
fi) \
--Dstrip=$(if test "$strip_opt" = yes; then echo true; else echo false; 
fi) \
 -Db_pie=$(if test "$pie" = yes; then echo true; else echo false; fi) \
 -Db_coverage=$(if test "$gcov" = yes; then echo true; else echo false; 
fi) \
 -Db_lto=$lto -Dcfi=$cfi -Dtcg=$tcg -Dxen=$xen \
diff --git a/pc-bios/s390-ccw/Makefile b/pc-bios/s390-ccw/Makefile
index cee9d2c63b..0eb68efc7b 100644
--- a/pc-bios/s390-ccw/Makefile
+++ b/pc-bios/s390-ccw/Makefile
@@ -44,8 +44,6 @@ build-all: s390-ccw.img s390-netboot.img
 s390-ccw.elf: $(OBJECTS)
$(call quiet-command,$(CC) $(LDFLAGS) -o $@ 
$(OBJECTS),"BUILD","$(TARGET_DIR)$@")
 
-STRIP ?= strip
-
 s390-ccw.img: s390-ccw.elf
$(call quiet-command,$(STRIP) --strip-unneeded $< -o 
$@,"STRIP","$(TARGET_DIR)$@")
 
diff --git a/scripts/meson-buildoptions.py b/scripts/meson-buildoptions.py
index 96969d89ee..98ae944148 100755
--- a/scripts/meson-buildoptions.py
+++ b/scripts/meson-buildoptions.py
@@ -36,6 +36,10 @@
 "trace_file",
 }
 
+BUILTIN_OPTIONS = {
+"strip",
+}
+
 LINE_WIDTH = 76
 
 
@@ -90,14 +94,17 @@ def allow_arg(opt):
 return not (set(opt["choices"]) <= {"auto", "disabled", "enabled"})
 
 
+def filter_options(json):
+if ":" in json["name"]:
+return False
+if json["section"] == "user":
+return json["name"] not in SKIP_OPTIONS
+else:
+return json["name"] in BUILTIN_OPTIONS
+
+
 def load_options(json):

[PULL 09/18] configure: move non-command-line variables away from command-line parsing section

2022-01-10 Thread Paolo Bonzini
This makes it easier to identify candidates for moving to Meson.

Reviewed-by: Philippe Mathieu-Daudé 
Signed-off-by: Paolo Bonzini 
---
 configure | 13 ++---
 1 file changed, 6 insertions(+), 7 deletions(-)

diff --git a/configure b/configure
index be05bcf856..56c113bd83 100755
--- a/configure
+++ b/configure
@@ -307,16 +307,12 @@ debug="no"
 sanitizers="no"
 tsan="no"
 fortify_source="$default_feature"
-mingw32="no"
 gcov="no"
 EXESUF=""
 modules="no"
 module_upgrades="no"
 prefix="/usr/local"
 qemu_suffix="qemu"
-bsd="no"
-linux="no"
-solaris="no"
 profiler="no"
 softmmu="yes"
 linux_user=""
@@ -330,8 +326,6 @@ opengl="$default_feature"
 cpuid_h="no"
 avx2_opt="$default_feature"
 guest_agent="$default_feature"
-guest_agent_with_vss="no"
-guest_agent_ntddscsi="no"
 vss_win32_sdk="$default_feature"
 win_sdk="no"
 want_tools="$default_feature"
@@ -526,6 +520,10 @@ fi
 
 # OS specific
 
+mingw32="no"
+bsd="no"
+linux="no"
+solaris="no"
 case $targetos in
 windows)
   mingw32="yes"
@@ -2549,6 +2547,7 @@ fi
 ##
 # check if we have VSS SDK headers for win
 
+guest_agent_with_vss="no"
 if test "$mingw32" = "yes" && test "$guest_agent" != "no" && \
 test "$vss_win32_sdk" != "no" ; then
   case "$vss_win32_sdk" in
@@ -2579,7 +2578,6 @@ EOF
   echo "ERROR: The headers are extracted in the directory \`inc'."
   feature_not_found "VSS support"
 fi
-guest_agent_with_vss="no"
   fi
 fi
 
@@ -2606,6 +2604,7 @@ fi
 
 ##
 # check if mingw environment provides a recent ntddscsi.h
+guest_agent_ntddscsi="no"
 if test "$mingw32" = "yes" && test "$guest_agent" != "no"; then
   cat > $TMPC << EOF
 #include 
-- 
2.33.1





[PULL 04/18] block/file-posix: Simplify the XFS_IOC_DIOINFO handling

2022-01-10 Thread Paolo Bonzini
From: Thomas Huth 

The handling for the XFS_IOC_DIOINFO ioctl is currently quite excessive:
This is not a "real" feature like the other features that we provide with
the "--enable-xxx" and "--disable-xxx" switches for the configure script,
since this does not influence lots of code (it's only about one call to
xfsctl() in file-posix.c), so people don't gain much with the ability to
disable this with "--disable-xfsctl".
It's also unfortunate that the ioctl will be disabled on Linux in case
the user did not install the right xfsprogs-devel package before running
configure. Thus let's simplify this by providing the ioctl definition
on our own, so we can completely get rid of the header dependency and
thus the related code in the configure script.

Suggested-by: Paolo Bonzini 
Signed-off-by: Thomas Huth 
Message-Id: <20211215125824.250091-1-th...@redhat.com>
Signed-off-by: Paolo Bonzini 
---
 block/file-posix.c | 37 -
 configure  | 31 ---
 meson.build|  1 -
 3 files changed, 16 insertions(+), 53 deletions(-)

diff --git a/block/file-posix.c b/block/file-posix.c
index b283093e5b..1f1756e192 100644
--- a/block/file-posix.c
+++ b/block/file-posix.c
@@ -106,10 +106,6 @@
 #include 
 #endif
 
-#ifdef CONFIG_XFS
-#include 
-#endif
-
 /* OS X does not have O_DSYNC */
 #ifndef O_DSYNC
 #ifdef O_SYNC
@@ -156,9 +152,6 @@ typedef struct BDRVRawState {
 int perm_change_flags;
 BDRVReopenState *reopen_state;
 
-#ifdef CONFIG_XFS
-bool is_xfs:1;
-#endif
 bool has_discard:1;
 bool has_write_zeroes:1;
 bool discard_zeroes:1;
@@ -409,14 +402,22 @@ static void raw_probe_alignment(BlockDriverState *bs, int 
fd, Error **errp)
 if (probe_logical_blocksize(fd, >bl.request_alignment) < 0) {
 bs->bl.request_alignment = 0;
 }
-#ifdef CONFIG_XFS
-if (s->is_xfs) {
-struct dioattr da;
-if (xfsctl(NULL, fd, XFS_IOC_DIOINFO, ) >= 0) {
-bs->bl.request_alignment = da.d_miniosz;
-/* The kernel returns wrong information for d_mem */
-/* s->buf_align = da.d_mem; */
-}
+
+#ifdef __linux__
+/*
+ * The XFS ioctl definitions are shipped in extra packages that might
+ * not always be available. Since we just need the XFS_IOC_DIOINFO ioctl
+ * here, we simply use our own definition instead:
+ */
+struct xfs_dioattr {
+uint32_t d_mem;
+uint32_t d_miniosz;
+uint32_t d_maxiosz;
+} da;
+if (ioctl(fd, _IOR('X', 30, struct xfs_dioattr), ) >= 0) {
+bs->bl.request_alignment = da.d_miniosz;
+/* The kernel returns wrong information for d_mem */
+/* s->buf_align = da.d_mem; */
 }
 #endif
 
@@ -798,12 +799,6 @@ static int raw_open_common(BlockDriverState *bs, QDict 
*options,
 #endif
 s->needs_alignment = raw_needs_alignment(bs);
 
-#ifdef CONFIG_XFS
-if (platform_test_xfs_fd(s->fd)) {
-s->is_xfs = true;
-}
-#endif
-
 bs->supported_zero_flags = BDRV_REQ_MAY_UNMAP | BDRV_REQ_NO_FALLBACK;
 if (S_ISREG(st.st_mode)) {
 /* When extending regular files, we get zeros from the OS */
diff --git a/configure b/configure
index 030728d11e..3a523a3d14 100755
--- a/configure
+++ b/configure
@@ -291,7 +291,6 @@ EXTRA_CXXFLAGS=""
 EXTRA_LDFLAGS=""
 
 xen_ctrl_version="$default_feature"
-xfs="$default_feature"
 membarrier="$default_feature"
 vhost_kernel="$default_feature"
 vhost_net="$default_feature"
@@ -1021,10 +1020,6 @@ for opt do
   ;;
   --enable-opengl) opengl="yes"
   ;;
-  --disable-xfsctl) xfs="no"
-  ;;
-  --enable-xfsctl) xfs="yes"
-  ;;
   --disable-zlib-test)
   ;;
   --enable-guest-agent) guest_agent="yes"
@@ -1431,7 +1426,6 @@ cat << EOF
   avx512f AVX512F optimization support
   replication replication support
   opengl  opengl support
-  xfsctl  xfsctl support
   qom-cast-debug  cast debugging support
   tools   build qemu-io, qemu-nbd and qemu-img tools
   bochs   bochs image format support
@@ -2323,28 +2317,6 @@ EOF
 fi
 fi
 
-##
-# xfsctl() probe, used for file-posix.c
-if test "$xfs" != "no" ; then
-  cat > $TMPC << EOF
-#include   /* NULL */
-#include 
-int main(void)
-{
-xfsctl(NULL, 0, 0, NULL);
-return 0;
-}
-EOF
-  if compile_prog "" "" ; then
-xfs="yes"
-  else
-if test "$xfs" = "yes" ; then
-  feature_not_found "xfs" "Install xfsprogs/xfslibs devel"
-fi
-xfs=no
-  fi
-fi
-
 ##
 # plugin linker support probe
 
@@ -3456,9 +3428,6 @@ echo "CONFIG_BDRV_RO_WHITELIST=$block_drv_ro_whitelist" 

[PULL 03/18] meson: cleanup common-user/ build

2022-01-10 Thread Paolo Bonzini
It is not necessary to have a separate static_library just for common_user
files; using the one that already covers the rest of common_ss is enough
unless you need to reuse some source files between emulators and tests.
Just place common files for all user-mode emulators in common_ss,
similar to what is already done for softmmu_ss in full system emulators.

The only disadvantage is that the include_directories under bsd-user/include/
and linux-user/include/ are now enabled for all targets rather than only
user mode emulators.  This however is not different from how include/sysemu/
is available when building user mode emulators.

Tested-by: Richard Henderson 
Reviewed-by: Richard Henderson 
Signed-off-by: Paolo Bonzini 
---
 common-user/meson.build |  2 +-
 meson.build | 13 +
 2 files changed, 2 insertions(+), 13 deletions(-)

diff --git a/common-user/meson.build b/common-user/meson.build
index 5cb42bc664..26212dda5c 100644
--- a/common-user/meson.build
+++ b/common-user/meson.build
@@ -1,6 +1,6 @@
 common_user_inc += include_directories('host/' / host_arch)
 
-common_user_ss.add(files(
+user_ss.add(files(
   'safe-syscall.S',
   'safe-syscall-error.c',
 ))
diff --git a/meson.build b/meson.build
index de111d6fa1..5f0b6300b4 100644
--- a/meson.build
+++ b/meson.build
@@ -2399,7 +2399,6 @@ blockdev_ss = ss.source_set()
 block_ss = ss.source_set()
 chardev_ss = ss.source_set()
 common_ss = ss.source_set()
-common_user_ss = ss.source_set()
 crypto_ss = ss.source_set()
 hwcore_ss = ss.source_set()
 io_ss = ss.source_set()
@@ -2651,17 +2650,6 @@ subdir('common-user')
 subdir('bsd-user')
 subdir('linux-user')
 
-common_user_ss = common_user_ss.apply(config_all, strict: false)
-common_user = static_library('common-user',
- sources: common_user_ss.sources(),
- dependencies: common_user_ss.dependencies(),
- include_directories: common_user_inc,
- name_suffix: 'fa',
- build_by_default: false)
-common_user = declare_dependency(link_with: common_user)
-
-user_ss.add(common_user)
-
 # needed for fuzzing binaries
 subdir('tests/qtest/libqos')
 subdir('tests/qtest/fuzz')
@@ -2879,6 +2867,7 @@ common_all = common_ss.apply(config_all, strict: false)
 common_all = static_library('common',
 build_by_default: false,
 sources: common_all.sources() + genh,
+include_directories: common_user_inc,
 implicit_include_directories: false,
 dependencies: common_all.dependencies(),
 name_suffix: 'fa')
-- 
2.33.1





[PULL 02/18] user: move common-user includes to a subdirectory of {bsd, linux}-user/

2022-01-10 Thread Paolo Bonzini
Avoid polluting the compilation of common-user/ with local include files;
making an include file available to common-user/ should be a deliberate
decision in order to keep a clear interface that can be used by both
bsd-user/ and linux-user/.

Reviewed-by: Richard Henderson 
Signed-off-by: Paolo Bonzini 
---
 bsd-user/{ => include}/special-errno.h  | 0
 bsd-user/meson.build| 2 +-
 linux-user/{ => include}/host/aarch64/host-signal.h | 0
 linux-user/{ => include}/host/alpha/host-signal.h   | 0
 linux-user/{ => include}/host/arm/host-signal.h | 0
 linux-user/{ => include}/host/i386/host-signal.h| 0
 linux-user/{ => include}/host/loongarch64/host-signal.h | 0
 linux-user/{ => include}/host/mips/host-signal.h| 0
 linux-user/{ => include}/host/ppc/host-signal.h | 0
 linux-user/{ => include}/host/ppc64/host-signal.h   | 0
 linux-user/{ => include}/host/riscv/host-signal.h   | 0
 linux-user/{ => include}/host/s390/host-signal.h| 0
 linux-user/{ => include}/host/s390x/host-signal.h   | 0
 linux-user/{ => include}/host/sparc/host-signal.h   | 0
 linux-user/{ => include}/host/sparc64/host-signal.h | 0
 linux-user/{ => include}/host/x32/host-signal.h | 0
 linux-user/{ => include}/host/x86_64/host-signal.h  | 0
 linux-user/{ => include}/special-errno.h| 0
 linux-user/meson.build  | 4 ++--
 19 files changed, 3 insertions(+), 3 deletions(-)
 rename bsd-user/{ => include}/special-errno.h (100%)
 rename linux-user/{ => include}/host/aarch64/host-signal.h (100%)
 rename linux-user/{ => include}/host/alpha/host-signal.h (100%)
 rename linux-user/{ => include}/host/arm/host-signal.h (100%)
 rename linux-user/{ => include}/host/i386/host-signal.h (100%)
 rename linux-user/{ => include}/host/loongarch64/host-signal.h (100%)
 rename linux-user/{ => include}/host/mips/host-signal.h (100%)
 rename linux-user/{ => include}/host/ppc/host-signal.h (100%)
 rename linux-user/{ => include}/host/ppc64/host-signal.h (100%)
 rename linux-user/{ => include}/host/riscv/host-signal.h (100%)
 rename linux-user/{ => include}/host/s390/host-signal.h (100%)
 rename linux-user/{ => include}/host/s390x/host-signal.h (100%)
 rename linux-user/{ => include}/host/sparc/host-signal.h (100%)
 rename linux-user/{ => include}/host/sparc64/host-signal.h (100%)
 rename linux-user/{ => include}/host/x32/host-signal.h (100%)
 rename linux-user/{ => include}/host/x86_64/host-signal.h (100%)
 rename linux-user/{ => include}/special-errno.h (100%)

diff --git a/bsd-user/special-errno.h b/bsd-user/include/special-errno.h
similarity index 100%
rename from bsd-user/special-errno.h
rename to bsd-user/include/special-errno.h
diff --git a/bsd-user/meson.build b/bsd-user/meson.build
index 9fcb80c3fa..8380fa44c2 100644
--- a/bsd-user/meson.build
+++ b/bsd-user/meson.build
@@ -4,7 +4,7 @@ endif
 
 bsd_user_ss = ss.source_set()
 
-common_user_inc += include_directories('.')
+common_user_inc += include_directories('include')
 
 bsd_user_ss.add(files(
   'bsdload.c',
diff --git a/linux-user/host/aarch64/host-signal.h 
b/linux-user/include/host/aarch64/host-signal.h
similarity index 100%
rename from linux-user/host/aarch64/host-signal.h
rename to linux-user/include/host/aarch64/host-signal.h
diff --git a/linux-user/host/alpha/host-signal.h 
b/linux-user/include/host/alpha/host-signal.h
similarity index 100%
rename from linux-user/host/alpha/host-signal.h
rename to linux-user/include/host/alpha/host-signal.h
diff --git a/linux-user/host/arm/host-signal.h 
b/linux-user/include/host/arm/host-signal.h
similarity index 100%
rename from linux-user/host/arm/host-signal.h
rename to linux-user/include/host/arm/host-signal.h
diff --git a/linux-user/host/i386/host-signal.h 
b/linux-user/include/host/i386/host-signal.h
similarity index 100%
rename from linux-user/host/i386/host-signal.h
rename to linux-user/include/host/i386/host-signal.h
diff --git a/linux-user/host/loongarch64/host-signal.h 
b/linux-user/include/host/loongarch64/host-signal.h
similarity index 100%
rename from linux-user/host/loongarch64/host-signal.h
rename to linux-user/include/host/loongarch64/host-signal.h
diff --git a/linux-user/host/mips/host-signal.h 
b/linux-user/include/host/mips/host-signal.h
similarity index 100%
rename from linux-user/host/mips/host-signal.h
rename to linux-user/include/host/mips/host-signal.h
diff --git a/linux-user/host/ppc/host-signal.h 
b/linux-user/include/host/ppc/host-signal.h
similarity index 100%
rename from linux-user/host/ppc/host-signal.h
rename to linux-user/include/host/ppc/host-signal.h
diff --git a/linux-user/host/ppc64/host-signal.h 
b/linux-user/include/host/ppc64/host-signal.h
similarity index 100%
rename from linux-user/host/ppc64/host-signal.h
rename to linux-user/include/host/ppc64/host-si

[PULL v4 00/18] Build system and KVM changes for 2021-12-23

2022-01-10 Thread Paolo Bonzini
The following changes since commit afe33262585565b64df706c62b4b0f6e0ad30c71:

  Merge tag 'pull-riscv-to-apply-20220108' of github.com:alistair23/qemu into 
staging (2022-01-07 22:09:24 -0800)

are available in the Git repository at:

  https://gitlab.com/bonzini/qemu.git tags/for-upstream

for you to fetch changes up to fb714a07243a88c41002c23a24e174c5d9d40d57:

  meson: reenable filemonitor-inotify compilation (2022-01-09 17:45:02 +0100)


* configure and meson cleanups
* KVM_GET/SET_SREGS2 support for x86


Maxim Levitsky (1):
  KVM: use KVM_{GET|SET}_SREGS2 when supported.

Paolo Bonzini (14):
  meson: reuse common_user_inc when building files specific to user-mode 
emulators
  user: move common-user includes to a subdirectory of {bsd,linux}-user/
  meson: cleanup common-user/ build
  configure: simplify creation of plugin symbol list
  configure: do not set bsd_user/linux_user early
  configure, makefile: remove traces of really old files
  configure: parse --enable/--disable-strip automatically, flip default
  configure: move non-command-line variables away from command-line parsing 
section
  meson: build contrib/ executables after generated headers
  configure, meson: move config-poison.h to meson
  meson: add comments in the target-specific flags section
  KVM: x86: ignore interrupt_bitmap field of KVM_GET/SET_SREGS
  configure: do not create roms/seabios/config.mak if SeaBIOS not present
  meson: build all modules by default

Philippe Mathieu-Daudé (1):
  tests/tcg: Fix target-specific Makefile variables path for user-mode

Thomas Huth (1):
  block/file-posix: Simplify the XFS_IOC_DIOINFO handling

Volker Rümelin (1):
  meson: reenable filemonitor-inotify compilation

 Makefile   |  11 +-
 block/file-posix.c |  37 ++--
 bsd-user/{ => include}/special-errno.h |   0
 bsd-user/meson.build   |   2 +-
 common-user/meson.build|   2 +-
 configure  | 189 -
 contrib/elf2dmp/meson.build|   2 +-
 contrib/ivshmem-client/meson.build |   2 +-
 contrib/ivshmem-server/meson.build |   2 +-
 contrib/rdmacm-mux/meson.build |   2 +-
 .../{ => include}/host/aarch64/host-signal.h   |   0
 linux-user/{ => include}/host/alpha/host-signal.h  |   0
 linux-user/{ => include}/host/arm/host-signal.h|   0
 linux-user/{ => include}/host/i386/host-signal.h   |   0
 .../{ => include}/host/loongarch64/host-signal.h   |   0
 linux-user/{ => include}/host/mips/host-signal.h   |   0
 linux-user/{ => include}/host/ppc/host-signal.h|   0
 linux-user/{ => include}/host/ppc64/host-signal.h  |   0
 linux-user/{ => include}/host/riscv/host-signal.h  |   0
 linux-user/{ => include}/host/s390/host-signal.h   |   0
 linux-user/{ => include}/host/s390x/host-signal.h  |   0
 linux-user/{ => include}/host/sparc/host-signal.h  |   0
 .../{ => include}/host/sparc64/host-signal.h   |   0
 linux-user/{ => include}/host/x32/host-signal.h|   0
 linux-user/{ => include}/host/x86_64/host-signal.h |   0
 linux-user/{ => include}/special-errno.h   |   0
 linux-user/meson.build |   4 +-
 meson.build|  37 ++--
 pc-bios/s390-ccw/Makefile  |   2 -
 plugins/meson.build|  13 +-
 scripts/make-config-poison.sh  |  16 ++
 scripts/meson-buildoptions.py  |  21 ++-
 scripts/meson-buildoptions.sh  |   3 +
 target/i386/cpu.h  |   3 +
 target/i386/kvm/kvm.c  | 130 --
 target/i386/machine.c  |  29 
 tests/qtest/meson.build|   3 +-
 tests/tcg/Makefile.target  |   2 +-
 tests/unit/meson.build |   2 +-
 util/meson.build   |   7 +-
 40 files changed, 275 insertions(+), 246 deletions(-)
 rename bsd-user/{ => include}/special-errno.h (100%)
 rename linux-user/{ => include}/host/aarch64/host-signal.h (100%)
 rename linux-user/{ => include}/host/alpha/host-signal.h (100%)
 rename linux-user/{ => include}/host/arm/host-signal.h (100%)
 rename linux-user/{ => include}/host/i386/host-signal.h (100%)
 rename linux-user/{ => include}/host/loongarch64/host-signal.h (100%)
 rename linux-user/{ => include}/host/mips/host-signal.h (100%)
 rename linux-user/{ => include}/host/ppc/host-signal.h (100%)
 rename linux-user/{ 

[PULL 01/18] meson: reuse common_user_inc when building files specific to user-mode emulators

2022-01-10 Thread Paolo Bonzini
Reviewed-by: Richard Henderson 
Signed-off-by: Paolo Bonzini 
---
 meson.build | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/meson.build b/meson.build
index 53065e96ec..de111d6fa1 100644
--- a/meson.build
+++ b/meson.build
@@ -2919,6 +2919,7 @@ foreach target : target_dirs
   else
 abi = config_target['TARGET_ABI_DIR']
 target_type='user'
+target_inc += common_user_inc
 qemu_target_name = 'qemu-' + target_name
 if target_base_arch in target_user_arch
   t = target_user_arch[target_base_arch].apply(config_target, strict: 
false)
@@ -2927,7 +2928,6 @@ foreach target : target_dirs
 endif
 if 'CONFIG_LINUX_USER' in config_target
   base_dir = 'linux-user'
-  target_inc += include_directories('linux-user/host/' / host_arch)
 endif
 if 'CONFIG_BSD_USER' in config_target
   base_dir = 'bsd-user'
-- 
2.33.1





[PULL 17/18] meson: build all modules by default

2022-01-10 Thread Paolo Bonzini
With more recent versions of Meson, the build.ninja file is more selective
as to what is built by default, and not building the modules results in test
failures.

Mark the modules as built-by-default and, to make the dependencies more
precise, also require them to be up-to-date before running tests.

Resolves: https://gitlab.com/qemu-project/qemu/-/issues/801
Tested-by: Li Zhang 
Signed-off-by: Paolo Bonzini 
---
 meson.build | 4 +++-
 tests/qtest/meson.build | 3 +--
 2 files changed, 4 insertions(+), 3 deletions(-)

diff --git a/meson.build b/meson.build
index 6489ff8425..703eefea13 100644
--- a/meson.build
+++ b/meson.build
@@ -2866,8 +2866,10 @@ common_ss.add(hwcore)
 # Targets #
 ###
 
+emulator_modules = []
 foreach m : block_mods + softmmu_mods
-  shared_module(m.name(),
+  emulator_modules += shared_module(m.name(),
+build_by_default: true,
 name_prefix: '',
 link_whole: m,
 install: true,
diff --git a/tests/qtest/meson.build b/tests/qtest/meson.build
index 37e1eaa449..26937deb6d 100644
--- a/tests/qtest/meson.build
+++ b/tests/qtest/meson.build
@@ -335,10 +335,9 @@ foreach dir : target_dirs
 test: executable(test, src, dependencies: deps)
   }
 endif
-# FIXME: missing dependency on the emulator binary and qemu-img
 test('qtest-@0@/@1@'.format(target_base, test),
  qtest_executables[test],
- depends: [test_deps, qtest_emulator],
+ depends: [test_deps, qtest_emulator, emulator_modules],
  env: qtest_env,
  args: ['--tap', '-k'],
  protocol: 'tap',
-- 
2.33.1





[PULL 07/18] configure, makefile: remove traces of really old files

2022-01-10 Thread Paolo Bonzini
These files have been removed for more than year in the best
case, or for more than ten years for some really old TCG files.
Remove any traces of it.

Acked-by: Richard Henderson 
Signed-off-by: Paolo Bonzini 
---
 Makefile  | 11 ---
 configure |  9 -
 2 files changed, 4 insertions(+), 16 deletions(-)

diff --git a/Makefile b/Makefile
index 5d66c35ea5..8037f73b35 100644
--- a/Makefile
+++ b/Makefile
@@ -206,14 +206,11 @@ recurse-clean: $(addsuffix /clean, $(ROM_DIRS))
 clean: recurse-clean
-$(quiet-@)test -f build.ninja && $(NINJA) $(NINJAFLAGS) -t clean || :
-$(quiet-@)test -f build.ninja && $(NINJA) $(NINJAFLAGS) clean-ctlist 
|| :
-# avoid old build problems by removing potentially incorrect old files
-   rm -f config.mak op-i386.h opc-i386.h gen-op-i386.h op-arm.h opc-arm.h 
gen-op-arm.h
find . \( -name '*.so' -o -name '*.dll' -o -name '*.[oda]' \) -type f \
! -path ./roms/edk2/ArmPkg/Library/GccLto/liblto-aarch64.a \
! -path ./roms/edk2/ArmPkg/Library/GccLto/liblto-arm.a \
-exec rm {} +
-   rm -f TAGS cscope.* *.pod *~ */*~
-   rm -f fsdev/*.pod scsi/*.pod
+   rm -f TAGS cscope.* *~ */*~
 
 VERSION = $(shell cat $(SRC_PATH)/VERSION)
 
@@ -224,10 +221,10 @@ qemu-%.tar.bz2:
 
 distclean: clean
-$(quiet-@)test -f build.ninja && $(NINJA) $(NINJAFLAGS) -t clean -g || 
:
-   rm -f config-host.mak config-host.h* config-poison.h
+   rm -f config-host.mak config-poison.h
rm -f tests/tcg/config-*.mak
-   rm -f config-all-disas.mak config.status
-   rm -f roms/seabios/config.mak roms/vgabios/config.mak
+   rm -f config.status
+   rm -f roms/seabios/config.mak
rm -f qemu-plugins-ld.symbols qemu-plugins-ld64.symbols
rm -f *-config-target.h *-config-devices.mak *-config-devices.h
rm -rf meson-private meson-logs meson-info compile_commands.json
diff --git a/configure b/configure
index f35d3f198f..a02febe09c 100755
--- a/configure
+++ b/configure
@@ -3672,9 +3672,6 @@ fi
 # so the build tree will be missing the link back to the new file, and
 # tests might fail. Prefer to keep the relevant files in their own
 # directory and symlink the directory instead.
-# UNLINK is used to remove symlinks from older development versions
-# that might get into the way when doing "git update" without doing
-# a "make distclean" in between.
 LINKS="Makefile"
 LINKS="$LINKS tests/tcg/Makefile.target"
 LINKS="$LINKS pc-bios/optionrom/Makefile"
@@ -3686,7 +3683,6 @@ LINKS="$LINKS tests/avocado tests/data"
 LINKS="$LINKS tests/qemu-iotests/check"
 LINKS="$LINKS python"
 LINKS="$LINKS contrib/plugins/Makefile "
-UNLINK="pc-bios/keymaps"
 for bios_file in \
 $source_path/pc-bios/*.bin \
 $source_path/pc-bios/*.elf \
@@ -3708,11 +3704,6 @@ for f in $LINKS ; do
 symlink "$source_path/$f" "$f"
 fi
 done
-for f in $UNLINK ; do
-if [ -L "$f" ]; then
-rm -f "$f"
-fi
-done
 
 (for i in $cross_cc_vars; do
   export $i
-- 
2.33.1





[PULL 16/18] configure: do not create roms/seabios/config.mak if SeaBIOS not present

2022-01-10 Thread Paolo Bonzini
If roms/seabios/Makefile is not present, the configure script
is not creating the roms/seabios directory anymore (commit
5dce7b8d8c, "configure: remove DIRS", 2021-12-18); thus, creating
roms/seabios/config.mak fails.

The easiest thing to do is to not create the file, since it will not
be used.

Signed-off-by: Paolo Bonzini 
---
 configure | 6 --
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/configure b/configure
index 0026388343..e1a31fb332 100755
--- a/configure
+++ b/configure
@@ -3704,7 +3704,8 @@ export target_list source_path use_containers cpu
 $source_path/tests/tcg/configure.sh)
 
 # temporary config to build submodules
-for rom in seabios; do
+if test -f $source_path/roms/seabios/Makefile; then
+  for rom in seabios; do
 config_mak=roms/$rom/config.mak
 echo "# Automatically generated by configure - do not modify" > $config_mak
 echo "SRC_PATH=$source_path/roms/$rom" >> $config_mak
@@ -3717,7 +3718,8 @@ for rom in seabios; do
 echo "IASL=$iasl" >> $config_mak
 echo "LD=$ld" >> $config_mak
 echo "RANLIB=$ranlib" >> $config_mak
-done
+  done
+fi
 
 config_mak=pc-bios/optionrom/config.mak
 echo "# Automatically generated by configure - do not modify" > $config_mak
-- 
2.33.1





[PULL 06/18] configure: do not set bsd_user/linux_user early

2022-01-10 Thread Paolo Bonzini
Similar to other optional features, leave the variables empty and compute
the actual value later.  Use the existence of include or source directories
to detect whether an OS or CPU supports respectively bsd-user and linux-user.

For now, BSD user-mode emulation is buildable even on TCI-only
architectures.  This probably will change once safe signals are
brought over from linux-user.

Reviewed-by: Richard Henderson 
Signed-off-by: Paolo Bonzini 
---
 configure | 28 +---
 1 file changed, 17 insertions(+), 11 deletions(-)

diff --git a/configure b/configure
index 1b5fa5ae93..f35d3f198f 100755
--- a/configure
+++ b/configure
@@ -320,8 +320,8 @@ linux="no"
 solaris="no"
 profiler="no"
 softmmu="yes"
-linux_user="no"
-bsd_user="no"
+linux_user=""
+bsd_user=""
 pkgversion=""
 pie=""
 qom_cast_debug="yes"
@@ -538,7 +538,6 @@ gnu/kfreebsd)
 ;;
 freebsd)
   bsd="yes"
-  bsd_user="yes"
   make="${MAKE-gmake}"
   # needed for kinfo_getvmmap(3) in libutil.h
 ;;
@@ -583,7 +582,6 @@ haiku)
 ;;
 linux)
   linux="yes"
-  linux_user="yes"
   vhost_user=${default_feature:-yes}
 ;;
 esac
@@ -1259,18 +1257,26 @@ if eval test -z "\${cross_cc_$cpu}"; then
 cross_cc_vars="$cross_cc_vars cross_cc_${cpu}"
 fi
 
-# For user-mode emulation the host arch has to be one we explicitly
-# support, even if we're using TCI.
-if [ "$ARCH" = "unknown" ]; then
-  bsd_user="no"
-  linux_user="no"
-fi
-
 default_target_list=""
 deprecated_targets_list=ppc64abi32-linux-user
 deprecated_features=""
 mak_wilds=""
 
+if [ "$linux_user" != no ]; then
+if [ "$targetos" = linux ] && [ -d 
$source_path/linux-user/include/host/$cpu ]; then
+linux_user=yes
+elif [ "$linux_user" = yes ]; then
+error_exit "linux-user not supported on this architecture"
+fi
+fi
+if [ "$bsd_user" != no ]; then
+if [ "$bsd_user" = "" ]; then
+test $targetos = freebsd && bsd_user=yes
+fi
+if [ "$bsd_user" = yes ] && ! [ -d $source_path/bsd-user/$targetos ]; then
+error_exit "bsd-user not supported on this host OS"
+fi
+fi
 if [ "$softmmu" = "yes" ]; then
 mak_wilds="${mak_wilds} $source_path/configs/targets/*-softmmu.mak"
 fi
-- 
2.33.1





[PULL 10/18] meson: build contrib/ executables after generated headers

2022-01-10 Thread Paolo Bonzini
This will be needed as soon as config-poison.h moves from configure to
a meson custom_target (which is built at "ninja" time).

Reviewed-by: Philippe Mathieu-Daudé 
Signed-off-by: Paolo Bonzini 
---
 contrib/elf2dmp/meson.build| 2 +-
 contrib/ivshmem-client/meson.build | 2 +-
 contrib/ivshmem-server/meson.build | 2 +-
 contrib/rdmacm-mux/meson.build | 2 +-
 4 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/contrib/elf2dmp/meson.build b/contrib/elf2dmp/meson.build
index 4d86cb390a..6707d43c4f 100644
--- a/contrib/elf2dmp/meson.build
+++ b/contrib/elf2dmp/meson.build
@@ -1,5 +1,5 @@
 if curl.found()
-  executable('elf2dmp', files('main.c', 'addrspace.c', 'download.c', 'pdb.c', 
'qemu_elf.c'),
+  executable('elf2dmp', files('main.c', 'addrspace.c', 'download.c', 'pdb.c', 
'qemu_elf.c'), genh,
  dependencies: [glib, curl],
  install: true)
 endif
diff --git a/contrib/ivshmem-client/meson.build 
b/contrib/ivshmem-client/meson.build
index 1b171efb4f..ce8dcca84d 100644
--- a/contrib/ivshmem-client/meson.build
+++ b/contrib/ivshmem-client/meson.build
@@ -1,4 +1,4 @@
-executable('ivshmem-client', files('ivshmem-client.c', 'main.c'),
+executable('ivshmem-client', files('ivshmem-client.c', 'main.c'), genh,
dependencies: glib,
build_by_default: targetos == 'linux',
install: false)
diff --git a/contrib/ivshmem-server/meson.build 
b/contrib/ivshmem-server/meson.build
index 3a53942201..c6c3c82e89 100644
--- a/contrib/ivshmem-server/meson.build
+++ b/contrib/ivshmem-server/meson.build
@@ -1,4 +1,4 @@
-executable('ivshmem-server', files('ivshmem-server.c', 'main.c'),
+executable('ivshmem-server', files('ivshmem-server.c', 'main.c'), genh,
dependencies: [qemuutil, rt],
build_by_default: targetos == 'linux',
install: false)
diff --git a/contrib/rdmacm-mux/meson.build b/contrib/rdmacm-mux/meson.build
index 6cc5016747..7674f54cc5 100644
--- a/contrib/rdmacm-mux/meson.build
+++ b/contrib/rdmacm-mux/meson.build
@@ -2,7 +2,7 @@ if 'CONFIG_PVRDMA' in config_host
   # if not found, CONFIG_PVRDMA should not be set
   # FIXME: broken on big endian architectures
   libumad = cc.find_library('ibumad', required: true)
-  executable('rdmacm-mux', files('main.c'),
+  executable('rdmacm-mux', files('main.c'), genh,
  dependencies: [glib, libumad],
  build_by_default: false,
  install: false)
-- 
2.33.1





[PULL 05/18] configure: simplify creation of plugin symbol list

2022-01-10 Thread Paolo Bonzini
--dynamic-list is present on all supported ELF (not Windows or Darwin)
platforms, since it dates back to 2006; -exported_symbols_list is
likewise present on all supported versions of macOS.  Do not bother
doing a functional test in configure.

Remove the file creation from configure as well: for Darwin, move the
the creation of the Darwin-formatted symbols to meson; for ELF, use the
file in the source path directly and switch from -Wl, to -Xlinker to
not break weird paths that include a comma.

Reviewed-by: Richard Henderson 
Signed-off-by: Paolo Bonzini 
---
 configure   | 81 +
 plugins/meson.build | 13 +---
 2 files changed, 10 insertions(+), 84 deletions(-)

diff --git a/configure b/configure
index 3a523a3d14..1b5fa5ae93 100755
--- a/configure
+++ b/configure
@@ -78,7 +78,6 @@ TMPC="${TMPDIR1}/${TMPB}.c"
 TMPO="${TMPDIR1}/${TMPB}.o"
 TMPCXX="${TMPDIR1}/${TMPB}.cxx"
 TMPE="${TMPDIR1}/${TMPB}.exe"
-TMPTXT="${TMPDIR1}/${TMPB}.txt"
 
 rm -f config.log
 
@@ -1696,6 +1695,7 @@ if test "$static" = "yes" ; then
 plugins="no"
   fi
 fi
+test "$plugins" = "" && plugins=yes
 
 cat > $TMPC << EOF
 
@@ -2317,69 +2317,6 @@ EOF
 fi
 fi
 
-##
-# plugin linker support probe
-
-if test "$plugins" != "no"; then
-
-#
-# See if --dynamic-list is supported by the linker
-
-ld_dynamic_list="no"
-cat > $TMPTXT < $TMPC <
-void foo(void);
-
-void foo(void)
-{
-  printf("foo\n");
-}
-
-int main(void)
-{
-  foo();
-  return 0;
-}
-EOF
-
-if compile_prog "" "-Wl,--dynamic-list=$TMPTXT" ; then
-ld_dynamic_list="yes"
-fi
-
-#
-# See if -exported_symbols_list is supported by the linker
-
-ld_exported_symbols_list="no"
-cat > $TMPTXT <> $config_host_mak
-# Copy the export object list to the build dir
-if test "$ld_dynamic_list" = "yes" ; then
-   echo "CONFIG_HAS_LD_DYNAMIC_LIST=yes" >> $config_host_mak
-   ld_symbols=qemu-plugins-ld.symbols
-   cp "$source_path/plugins/qemu-plugins.symbols" $ld_symbols
-elif test "$ld_exported_symbols_list" = "yes" ; then
-   echo "CONFIG_HAS_LD_EXPORTED_SYMBOLS_LIST=yes" >> $config_host_mak
-   ld64_symbols=qemu-plugins-ld64.symbols
-   echo "# Automatically generated by configure - do not modify" > 
$ld64_symbols
-   grep 'qemu_' "$source_path/plugins/qemu-plugins.symbols" | sed 's/;//g' 
| \
-   sed -E 's/^[[:space:]]*(.*)/_\1/' >> $ld64_symbols
-else
-   error_exit \
-   "If \$plugins=yes, either \$ld_dynamic_list or " \
-   "\$ld_exported_symbols_list should have been set to 'yes'."
-fi
 fi
 
 if test -n "$gdb_bin"; then
diff --git a/plugins/meson.build b/plugins/meson.build
index b3de57853b..fa12047327 100644
--- a/plugins/meson.build
+++ b/plugins/meson.build
@@ -1,10 +1,15 @@
 plugin_ldflags = []
 # Modules need more symbols than just those in plugins/qemu-plugins.symbols
 if not enable_modules
-  if 'CONFIG_HAS_LD_DYNAMIC_LIST' in config_host
-plugin_ldflags = ['-Wl,--dynamic-list=qemu-plugins-ld.symbols']
-  elif 'CONFIG_HAS_LD_EXPORTED_SYMBOLS_LIST' in config_host
-plugin_ldflags = ['-Wl,-exported_symbols_list,qemu-plugins-ld64.symbols']
+  if targetos == 'darwin'
+qemu_plugins_symbols_list = configure_file(
+  input: files('qemu-plugins.symbols'),
+  output: 'qemu-plugins-ld64.symbols',
+  capture: true,
+  command: ['sed', '-ne', 's/^[[:space:]]*\\(qemu_.*\\);/_\\1/p', 
'@INPUT@'])
+plugin_ldflags = 
['-Wl,-exported_symbols_list,plugins/qemu-plugins-ld64.symbols']
+  else
+plugin_ldflags = ['-Xlinker', '--dynamic-list=' + 
(meson.project_source_root() / 'plugins/qemu-plugins.symbols')]
   endif
 endif
 
-- 
2.33.1





Re: [PATCH] meson: reenable filemonitor-inotify compilation

2022-01-07 Thread Paolo Bonzini

On 1/7/22 14:35, Volker Rümelin wrote:

Reenable util/filemonitor-inotify compilation. Compilation was
disabled when commit a620fbe9ac ("configure: convert compiler tests
to meson, part 5") moved CONFIG_INOTIFY1 from config-host.mak to
config-host.h.

This fixes the usb-mtp device and reenables test-util-filemonitor.

Fixes: a620fbe9ac ("configure: convert compiler tests to meson, part 5")
Resolves: https://gitlab.com/qemu-project/qemu/-/issues/800
Signed-off-by: Volker Rümelin 
---
  tests/unit/meson.build | 2 +-
  util/meson.build   | 7 +--
  2 files changed, 6 insertions(+), 3 deletions(-)

diff --git a/tests/unit/meson.build b/tests/unit/meson.build
index 90acf5b0da..64a5e7bfde 100644
--- a/tests/unit/meson.build
+++ b/tests/unit/meson.build
@@ -129,7 +129,7 @@ if have_system
  'test-vmstate': [migration, io],
  'test-yank': ['socket-helpers.c', qom, io, chardev]
}
-  if 'CONFIG_INOTIFY1' in config_host
+  if config_host_data.get('CONFIG_INOTIFY1')
  tests += {'test-util-filemonitor': []}
endif
  
diff --git a/util/meson.build b/util/meson.build

index 05b593055a..71543e1a85 100644
--- a/util/meson.build
+++ b/util/meson.build
@@ -83,7 +83,10 @@ if have_block
util_ss.add(files('readline.c'))
util_ss.add(files('throttle.c'))
util_ss.add(files('timed-average.c'))
-  util_ss.add(when: 'CONFIG_INOTIFY1', if_true: files('filemonitor-inotify.c'),
-if_false: files('filemonitor-stub.c'))
+  if config_host_data.get('CONFIG_INOTIFY1')
+util_ss.add(files('filemonitor-inotify.c'))
+  else
+util_ss.add(files('filemonitor-stub.c'))
+  endif
util_ss.add(when: 'CONFIG_LINUX', if_true: files('vfio-helpers.c'))
  endif


Queued, thanks.

Paolo



Re: test_isa_retry_flush() in ide-test.c

2022-01-07 Thread Paolo Bonzini

On 1/7/22 17:01, Thomas Huth wrote:

  Hi John!

I just notice that test_isa_retry_flush() is not doing anything useful 
anymore: It likely was supposed to run the test_retry_flush() function 
with the "isapc" machine type, but actually test_retry_flush() ignores 
the machine option parameter completely and always uses PCI accessor 
functions nowadays (since commit 9c268f8ae84ae186).
Question is: Is it worth the effort to try to restore the original 
intended behavior for the ISA test here, or shall we rather simply 
remove it instead to save some testing cycles?


The right way to fix it would be to use qgraph.  Second best option is 
to nuke it, because the conversion to qgraph would give the test back 
for free without writing more code.


Paolo



Re: [PATCH] configure: Silence warnings about missing roms/seabios directory

2022-01-07 Thread Paolo Bonzini

On 1/7/22 13:15, Thomas Huth wrote:

The configure script tries to always create a config.mak file
in the roms/seabios/ subdirectory. However, since commit
5dce7b8d8ce6 ("configure: remove DIRS"), this subdirectory is not
created anymore if the git submodule hasn't been checked out.
Thus let's properly check for the existance of the folder first
now to get rid of the warnings.

Fixes: 5dce7b8d8ce6 ("configure: remove DIRS")
Signed-off-by: Thomas Huth 


I beat you to it shortly:

[PATCH] configure: do not create roms/seabios/config.mak if SeaBIOS not 
present


(I didn't see your reply to the pull request).

"test -d" is not really enough, what you need is test -f 
$source_path/roms/seabios/Makefile.


Paolo


---
  configure | 6 +++---
  1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/configure b/configure
index c798e48faf..51b13b273c 100755
--- a/configure
+++ b/configure
@@ -3773,8 +3773,8 @@ export target_list source_path use_containers cpu
  $source_path/tests/tcg/configure.sh)
  
  # temporary config to build submodules

-for rom in seabios; do
-config_mak=roms/$rom/config.mak
+if test -d roms/seabios ; then
+config_mak=roms/seabios/config.mak
  echo "# Automatically generated by configure - do not modify" > 
$config_mak
  echo "SRC_PATH=$source_path/roms/$rom" >> $config_mak
  echo "AS=$as" >> $config_mak
@@ -3786,7 +3786,7 @@ for rom in seabios; do
  echo "IASL=$iasl" >> $config_mak
  echo "LD=$ld" >> $config_mak
  echo "RANLIB=$ranlib" >> $config_mak
-done
+fi
  
  config_mak=pc-bios/optionrom/config.mak

  echo "# Automatically generated by configure - do not modify" > $config_mak





Re: [PATCH] hw/i386: Add the possibility to disable the 'isapc' machine

2022-01-07 Thread Paolo Bonzini

On 1/7/22 17:07, Thomas Huth wrote:

We already have a CONFIG_ISAPC switch - but we're not using it yet.
Add some "#ifdefs" to make it possible to disable this machine now.

Signed-off-by: Thomas Huth 
---
  hw/i386/pc_piix.c| 5 -
  tests/qtest/cdrom-test.c | 2 +-
  2 files changed, 5 insertions(+), 2 deletions(-)

diff --git a/hw/i386/pc_piix.c b/hw/i386/pc_piix.c
index 1999190276..5147e1ee74 100644
--- a/hw/i386/pc_piix.c
+++ b/hw/i386/pc_piix.c
@@ -357,10 +357,12 @@ static void pc_compat_1_4_fn(MachineState *machine)
  pc_compat_1_5_fn(machine);
  }
  
+#ifdef CONFIG_ISAPC

  static void pc_init_isa(MachineState *machine)
  {
  pc_init1(machine, TYPE_I440FX_PCI_HOST_BRIDGE, TYPE_I440FX_PCI_DEVICE);
  }
+#endif
  
  #ifdef CONFIG_XEN

  static void pc_xen_hvm_init_pci(MachineState *machine)
@@ -916,6 +918,7 @@ void igd_passthrough_isa_bridge_create(PCIBus *bus, 
uint16_t gpu_dev_id)
  pci_config_set_revision(bridge_dev->config, pch_rev_id);
  }
  
+#ifdef CONFIG_ISAPC

  static void isapc_machine_options(MachineClass *m)
  {
  PCMachineClass *pcmc = PC_MACHINE_CLASS(m);
@@ -935,7 +938,7 @@ static void isapc_machine_options(MachineClass *m)
  
  DEFINE_PC_MACHINE(isapc, "isapc", pc_init_isa,

isapc_machine_options);
-
+#endif
  
  #ifdef CONFIG_XEN

  static void xenfv_4_2_machine_options(MachineClass *m)
diff --git a/tests/qtest/cdrom-test.c b/tests/qtest/cdrom-test.c
index cfca24fa94..fdd889a487 100644
--- a/tests/qtest/cdrom-test.c
+++ b/tests/qtest/cdrom-test.c
@@ -138,7 +138,7 @@ static void add_x86_tests(void)
   * Unstable CI test under load
   * See https://lists.gnu.org/archive/html/qemu-devel/2019-02/msg05509.html
   */
-if (g_test_slow()) {
+if (g_test_slow() && qtest_has_machine("isapc")) {
  qtest_add_data_func("cdrom/boot/isapc", "-M isapc "
  "-drive if=ide,media=cdrom,file=", test_cdboot);
  }


Acked-by: Paolo Bonzini 



[PATCH] meson: build all modules by default

2022-01-07 Thread Paolo Bonzini
With more recent versions of Meson, the build.ninja file is more selective
as to what is built by default, and not building the modules results in test
failures.

Mark the modules as built-by-default and, to make the dependencies more
precise, also require them to be up-to-date before running tests.

Resolves: https://gitlab.com/qemu-project/qemu/-/issues/801
Signed-off-by: Paolo Bonzini 
---
 meson.build | 4 +++-
 tests/qtest/meson.build | 3 +--
 2 files changed, 4 insertions(+), 3 deletions(-)

diff --git a/meson.build b/meson.build
index 6489ff8425..703eefea13 100644
--- a/meson.build
+++ b/meson.build
@@ -2866,8 +2866,10 @@ common_ss.add(hwcore)
 # Targets #
 ###
 
+emulator_modules = []
 foreach m : block_mods + softmmu_mods
-  shared_module(m.name(),
+  emulator_modules += shared_module(m.name(),
+build_by_default: true,
 name_prefix: '',
 link_whole: m,
 install: true,
diff --git a/tests/qtest/meson.build b/tests/qtest/meson.build
index 37e1eaa449..26937deb6d 100644
--- a/tests/qtest/meson.build
+++ b/tests/qtest/meson.build
@@ -335,10 +335,9 @@ foreach dir : target_dirs
 test: executable(test, src, dependencies: deps)
   }
 endif
-# FIXME: missing dependency on the emulator binary and qemu-img
 test('qtest-@0@/@1@'.format(target_base, test),
  qtest_executables[test],
- depends: [test_deps, qtest_emulator],
+ depends: [test_deps, qtest_emulator, emulator_modules],
  env: qtest_env,
  args: ['--tap', '-k'],
  protocol: 'tap',
-- 
2.33.1




[PATCH] configure: do not create roms/seabios/config.mak if SeaBIOS not present

2022-01-07 Thread Paolo Bonzini
If roms/seabios/Makefile is not present, the configure script
is not creating the roms/seabios directory anymore (commit
5dce7b8d8c, "configure: remove DIRS", 2021-12-18); thus, creating
roms/seabios/config.mak fails.

The easiest thing to do is to not create the file, since it will not
be used.

Signed-off-by: Paolo Bonzini 
---
 configure | 6 --
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/configure b/configure
index 0026388343..e1a31fb332 100755
--- a/configure
+++ b/configure
@@ -3704,7 +3704,8 @@ export target_list source_path use_containers cpu
 $source_path/tests/tcg/configure.sh)
 
 # temporary config to build submodules
-for rom in seabios; do
+if test -f $source_path/roms/seabios/Makefile; then
+  for rom in seabios; do
 config_mak=roms/$rom/config.mak
 echo "# Automatically generated by configure - do not modify" > $config_mak
 echo "SRC_PATH=$source_path/roms/$rom" >> $config_mak
@@ -3717,7 +3718,8 @@ for rom in seabios; do
 echo "IASL=$iasl" >> $config_mak
 echo "LD=$ld" >> $config_mak
 echo "RANLIB=$ranlib" >> $config_mak
-done
+  done
+fi
 
 config_mak=pc-bios/optionrom/config.mak
 echo "# Automatically generated by configure - do not modify" > $config_mak
-- 
2.33.1




[PULL 14/15] KVM: x86: ignore interrupt_bitmap field of KVM_GET/SET_SREGS

2022-01-04 Thread Paolo Bonzini
This is unnecessary, because the interrupt would be retrieved and queued
anyway by KVM_GET_VCPU_EVENTS and KVM_SET_VCPU_EVENTS respectively,
and it makes the flow more similar to the one for KVM_GET/SET_SREGS2.

Signed-off-by: Paolo Bonzini 
---
 target/i386/kvm/kvm.c | 24 +---
 1 file changed, 9 insertions(+), 15 deletions(-)

diff --git a/target/i386/kvm/kvm.c b/target/i386/kvm/kvm.c
index d81745620b..2c8feb4a6f 100644
--- a/target/i386/kvm/kvm.c
+++ b/target/i386/kvm/kvm.c
@@ -2607,11 +2607,11 @@ static int kvm_put_sregs(X86CPU *cpu)
 CPUX86State *env = >env;
 struct kvm_sregs sregs;
 
+/*
+ * The interrupt_bitmap is ignored because KVM_SET_SREGS is
+ * always followed by KVM_SET_VCPU_EVENTS.
+ */
 memset(sregs.interrupt_bitmap, 0, sizeof(sregs.interrupt_bitmap));
-if (env->interrupt_injected >= 0) {
-sregs.interrupt_bitmap[env->interrupt_injected / 64] |=
-(uint64_t)1 << (env->interrupt_injected % 64);
-}
 
 if ((env->eflags & VM_MASK)) {
 set_v8086_seg(, >segs[R_CS]);
@@ -3341,23 +3341,17 @@ static int kvm_get_sregs(X86CPU *cpu)
 {
 CPUX86State *env = >env;
 struct kvm_sregs sregs;
-int bit, i, ret;
+int ret;
 
 ret = kvm_vcpu_ioctl(CPU(cpu), KVM_GET_SREGS, );
 if (ret < 0) {
 return ret;
 }
 
-/* There can only be one pending IRQ set in the bitmap at a time, so try
-   to find it and save its number instead (-1 for none). */
-env->interrupt_injected = -1;
-for (i = 0; i < ARRAY_SIZE(sregs.interrupt_bitmap); i++) {
-if (sregs.interrupt_bitmap[i]) {
-bit = ctz64(sregs.interrupt_bitmap[i]);
-env->interrupt_injected = i * 64 + bit;
-break;
-}
-}
+/*
+ * The interrupt_bitmap is ignored because KVM_GET_SREGS is
+ * always preceded by KVM_GET_VCPU_EVENTS.
+ */
 
 get_seg(>segs[R_CS], );
 get_seg(>segs[R_DS], );
-- 
2.33.1





[PULL 12/15] meson: add comments in the target-specific flags section

2022-01-04 Thread Paolo Bonzini
Signed-off-by: Paolo Bonzini 
---
 meson.build | 5 +
 1 file changed, 5 insertions(+)

diff --git a/meson.build b/meson.build
index 36fc720ba3..6489ff8425 100644
--- a/meson.build
+++ b/meson.build
@@ -238,6 +238,7 @@ endif
 # Target-specific checks and dependencies #
 ###
 
+# Fuzzing
 if get_option('fuzzing') and get_option('fuzzing_engine') == '' and \
 not cc.links('''
   #include 
@@ -249,6 +250,7 @@ if get_option('fuzzing') and get_option('fuzzing_engine') 
== '' and \
   error('Your compiler does not support -fsanitize=fuzzer')
 endif
 
+# Tracing backends
 if 'ftrace' in get_option('trace_backends') and targetos != 'linux'
   error('ftrace is supported only on Linux')
 endif
@@ -262,6 +264,7 @@ if 'syslog' in get_option('trace_backends') and not 
cc.compiles('''
   error('syslog is not supported on this system')
 endif
 
+# Miscellaneous Linux-only features
 if targetos != 'linux' and get_option('mpath').enabled()
   error('Multipath is supported only on Linux')
 endif
@@ -271,6 +274,7 @@ if targetos != 'linux' and 
get_option('multiprocess').enabled()
 endif
 multiprocess_allowed = targetos == 'linux' and not 
get_option('multiprocess').disabled()
 
+# Target-specific libraries and flags
 libm = cc.find_library('m', required: false)
 threads = dependency('threads')
 util = cc.find_library('util', required: false)
@@ -311,6 +315,7 @@ elif targetos == 'openbsd'
   endif
 endif
 
+# Target-specific configuration of accelerators
 accelerators = []
 if not get_option('kvm').disabled() and targetos == 'linux'
   accelerators += 'CONFIG_KVM'
-- 
2.33.1





[PULL 10/15] meson: build contrib/ executables after generated headers

2022-01-04 Thread Paolo Bonzini
This will be needed as soon as config-poison.h moves from configure to
a meson custom_target (which is built at "ninja" time).

Reviewed-by: Philippe Mathieu-Daudé 
Signed-off-by: Paolo Bonzini 
---
 contrib/elf2dmp/meson.build| 2 +-
 contrib/ivshmem-client/meson.build | 2 +-
 contrib/ivshmem-server/meson.build | 2 +-
 contrib/rdmacm-mux/meson.build | 2 +-
 4 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/contrib/elf2dmp/meson.build b/contrib/elf2dmp/meson.build
index 4d86cb390a..6707d43c4f 100644
--- a/contrib/elf2dmp/meson.build
+++ b/contrib/elf2dmp/meson.build
@@ -1,5 +1,5 @@
 if curl.found()
-  executable('elf2dmp', files('main.c', 'addrspace.c', 'download.c', 'pdb.c', 
'qemu_elf.c'),
+  executable('elf2dmp', files('main.c', 'addrspace.c', 'download.c', 'pdb.c', 
'qemu_elf.c'), genh,
  dependencies: [glib, curl],
  install: true)
 endif
diff --git a/contrib/ivshmem-client/meson.build 
b/contrib/ivshmem-client/meson.build
index 1b171efb4f..ce8dcca84d 100644
--- a/contrib/ivshmem-client/meson.build
+++ b/contrib/ivshmem-client/meson.build
@@ -1,4 +1,4 @@
-executable('ivshmem-client', files('ivshmem-client.c', 'main.c'),
+executable('ivshmem-client', files('ivshmem-client.c', 'main.c'), genh,
dependencies: glib,
build_by_default: targetos == 'linux',
install: false)
diff --git a/contrib/ivshmem-server/meson.build 
b/contrib/ivshmem-server/meson.build
index 3a53942201..c6c3c82e89 100644
--- a/contrib/ivshmem-server/meson.build
+++ b/contrib/ivshmem-server/meson.build
@@ -1,4 +1,4 @@
-executable('ivshmem-server', files('ivshmem-server.c', 'main.c'),
+executable('ivshmem-server', files('ivshmem-server.c', 'main.c'), genh,
dependencies: [qemuutil, rt],
build_by_default: targetos == 'linux',
install: false)
diff --git a/contrib/rdmacm-mux/meson.build b/contrib/rdmacm-mux/meson.build
index 6cc5016747..7674f54cc5 100644
--- a/contrib/rdmacm-mux/meson.build
+++ b/contrib/rdmacm-mux/meson.build
@@ -2,7 +2,7 @@ if 'CONFIG_PVRDMA' in config_host
   # if not found, CONFIG_PVRDMA should not be set
   # FIXME: broken on big endian architectures
   libumad = cc.find_library('ibumad', required: true)
-  executable('rdmacm-mux', files('main.c'),
+  executable('rdmacm-mux', files('main.c'), genh,
  dependencies: [glib, libumad],
  build_by_default: false,
  install: false)
-- 
2.33.1





[PULL 15/15] tests/tcg: Fix target-specific Makefile variables path for user-mode

2022-01-04 Thread Paolo Bonzini
From: Philippe Mathieu-Daudé 

Commit 812b31d3f91 refactor missed to update this path.

Fixes: 812b31d3f91 ("configs: rename default-configs to configs and reorganise")
Signed-off-by: Philippe Mathieu-Daudé 
Message-Id: <20211226001541.3807919-1-f4...@amsat.org>
Signed-off-by: Paolo Bonzini 
---
 tests/tcg/Makefile.target | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tests/tcg/Makefile.target b/tests/tcg/Makefile.target
index 0f8645f782..ae8004c76e 100644
--- a/tests/tcg/Makefile.target
+++ b/tests/tcg/Makefile.target
@@ -33,7 +33,7 @@ all:
 -include ../../../config-host.mak
 -include ../config-$(TARGET).mak
 ifeq ($(CONFIG_USER_ONLY),y)
--include $(SRC_PATH)/default-configs/targets/$(TARGET).mak
+-include $(SRC_PATH)/configs/targets/$(TARGET)/default.mak
 endif
 
 # for including , in command strings
-- 
2.33.1




[PULL 09/15] configure: move non-command-line variables away from command-line parsing section

2022-01-04 Thread Paolo Bonzini
This makes it easier to identify candidates for moving to Meson.

Reviewed-by: Philippe Mathieu-Daudé 
Signed-off-by: Paolo Bonzini 
---
 configure | 13 ++---
 1 file changed, 6 insertions(+), 7 deletions(-)

diff --git a/configure b/configure
index 9e01b2278e..e3d603d381 100755
--- a/configure
+++ b/configure
@@ -307,16 +307,12 @@ debug="no"
 sanitizers="no"
 tsan="no"
 fortify_source="$default_feature"
-mingw32="no"
 gcov="no"
 EXESUF=""
 modules="no"
 module_upgrades="no"
 prefix="/usr/local"
 qemu_suffix="qemu"
-bsd="no"
-linux="no"
-solaris="no"
 profiler="no"
 softmmu="yes"
 linux_user=""
@@ -330,8 +326,6 @@ opengl="$default_feature"
 cpuid_h="no"
 avx2_opt="$default_feature"
 guest_agent="$default_feature"
-guest_agent_with_vss="no"
-guest_agent_ntddscsi="no"
 vss_win32_sdk="$default_feature"
 win_sdk="no"
 want_tools="$default_feature"
@@ -526,6 +520,10 @@ fi
 
 # OS specific
 
+mingw32="no"
+bsd="no"
+linux="no"
+solaris="no"
 case $targetos in
 windows)
   mingw32="yes"
@@ -2548,6 +2546,7 @@ fi
 ##
 # check if we have VSS SDK headers for win
 
+guest_agent_with_vss="no"
 if test "$mingw32" = "yes" && test "$guest_agent" != "no" && \
 test "$vss_win32_sdk" != "no" ; then
   case "$vss_win32_sdk" in
@@ -2578,7 +2577,6 @@ EOF
   echo "ERROR: The headers are extracted in the directory \`inc'."
   feature_not_found "VSS support"
 fi
-guest_agent_with_vss="no"
   fi
 fi
 
@@ -2605,6 +2603,7 @@ fi
 
 ##
 # check if mingw environment provides a recent ntddscsi.h
+guest_agent_ntddscsi="no"
 if test "$mingw32" = "yes" && test "$guest_agent" != "no"; then
   cat > $TMPC << EOF
 #include 
-- 
2.33.1





[PULL 13/15] KVM: use KVM_{GET|SET}_SREGS2 when supported.

2022-01-04 Thread Paolo Bonzini
From: Maxim Levitsky 

This allows to make PDPTRs part of the migration
stream and thus not reload them after migration which
is against X86 spec.

Signed-off-by: Maxim Levitsky 
Message-Id: <20211101132300.192584-2-mlevi...@redhat.com>
Signed-off-by: Paolo Bonzini 
---
 target/i386/cpu.h |   3 ++
 target/i386/kvm/kvm.c | 108 +-
 target/i386/machine.c |  29 
 3 files changed, 138 insertions(+), 2 deletions(-)

diff --git a/target/i386/cpu.h b/target/i386/cpu.h
index 04f2b790c9..9911d7c871 100644
--- a/target/i386/cpu.h
+++ b/target/i386/cpu.h
@@ -1455,6 +1455,9 @@ typedef struct CPUX86State {
 SegmentCache idt; /* only base and limit are used */
 
 target_ulong cr[5]; /* NOTE: cr1 is unused */
+
+bool pdptrs_valid;
+uint64_t pdptrs[4];
 int32_t a20_mask;
 
 BNDReg bnd_regs[4];
diff --git a/target/i386/kvm/kvm.c b/target/i386/kvm/kvm.c
index 13f8e30c2a..d81745620b 100644
--- a/target/i386/kvm/kvm.c
+++ b/target/i386/kvm/kvm.c
@@ -124,6 +124,7 @@ static uint32_t num_architectural_pmu_fixed_counters;
 static int has_xsave;
 static int has_xcrs;
 static int has_pit_state2;
+static int has_sregs2;
 static int has_exception_payload;
 
 static bool has_msr_mcg_ext_ctl;
@@ -2324,6 +2325,7 @@ int kvm_arch_init(MachineState *ms, KVMState *s)
 has_xsave = kvm_check_extension(s, KVM_CAP_XSAVE);
 has_xcrs = kvm_check_extension(s, KVM_CAP_XCRS);
 has_pit_state2 = kvm_check_extension(s, KVM_CAP_PIT_STATE2);
+has_sregs2 = kvm_check_extension(s, KVM_CAP_SREGS2) > 0;
 
 hv_vpindex_settable = kvm_check_extension(s, KVM_CAP_HYPERV_VP_INDEX);
 
@@ -2650,6 +2652,61 @@ static int kvm_put_sregs(X86CPU *cpu)
 return kvm_vcpu_ioctl(CPU(cpu), KVM_SET_SREGS, );
 }
 
+static int kvm_put_sregs2(X86CPU *cpu)
+{
+CPUX86State *env = >env;
+struct kvm_sregs2 sregs;
+int i;
+
+sregs.flags = 0;
+
+if ((env->eflags & VM_MASK)) {
+set_v8086_seg(, >segs[R_CS]);
+set_v8086_seg(, >segs[R_DS]);
+set_v8086_seg(, >segs[R_ES]);
+set_v8086_seg(, >segs[R_FS]);
+set_v8086_seg(, >segs[R_GS]);
+set_v8086_seg(, >segs[R_SS]);
+} else {
+set_seg(, >segs[R_CS]);
+set_seg(, >segs[R_DS]);
+set_seg(, >segs[R_ES]);
+set_seg(, >segs[R_FS]);
+set_seg(, >segs[R_GS]);
+set_seg(, >segs[R_SS]);
+}
+
+set_seg(, >tr);
+set_seg(, >ldt);
+
+sregs.idt.limit = env->idt.limit;
+sregs.idt.base = env->idt.base;
+memset(sregs.idt.padding, 0, sizeof sregs.idt.padding);
+sregs.gdt.limit = env->gdt.limit;
+sregs.gdt.base = env->gdt.base;
+memset(sregs.gdt.padding, 0, sizeof sregs.gdt.padding);
+
+sregs.cr0 = env->cr[0];
+sregs.cr2 = env->cr[2];
+sregs.cr3 = env->cr[3];
+sregs.cr4 = env->cr[4];
+
+sregs.cr8 = cpu_get_apic_tpr(cpu->apic_state);
+sregs.apic_base = cpu_get_apic_base(cpu->apic_state);
+
+sregs.efer = env->efer;
+
+if (env->pdptrs_valid) {
+for (i = 0; i < 4; i++) {
+sregs.pdptrs[i] = env->pdptrs[i];
+}
+sregs.flags |= KVM_SREGS2_FLAGS_PDPTRS_VALID;
+}
+
+return kvm_vcpu_ioctl(CPU(cpu), KVM_SET_SREGS2, );
+}
+
+
 static void kvm_msr_buf_reset(X86CPU *cpu)
 {
 memset(cpu->kvm_msr_buf, 0, MSR_BUF_SIZE);
@@ -3330,6 +3387,53 @@ static int kvm_get_sregs(X86CPU *cpu)
 return 0;
 }
 
+static int kvm_get_sregs2(X86CPU *cpu)
+{
+CPUX86State *env = >env;
+struct kvm_sregs2 sregs;
+int i, ret;
+
+ret = kvm_vcpu_ioctl(CPU(cpu), KVM_GET_SREGS2, );
+if (ret < 0) {
+return ret;
+}
+
+get_seg(>segs[R_CS], );
+get_seg(>segs[R_DS], );
+get_seg(>segs[R_ES], );
+get_seg(>segs[R_FS], );
+get_seg(>segs[R_GS], );
+get_seg(>segs[R_SS], );
+
+get_seg(>tr, );
+get_seg(>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;
+
+env->cr[0] = sregs.cr0;
+env->cr[2] = sregs.cr2;
+env->cr[3] = sregs.cr3;
+env->cr[4] = sregs.cr4;
+
+env->efer = sregs.efer;
+
+env->pdptrs_valid = sregs.flags & KVM_SREGS2_FLAGS_PDPTRS_VALID;
+
+if (env->pdptrs_valid) {
+for (i = 0; i < 4; i++) {
+env->pdptrs[i] = sregs.pdptrs[i];
+}
+}
+
+/* changes to apic base and cr8/tpr are read back via kvm_arch_post_run */
+x86_update_hflags(env);
+
+return 0;
+}
+
 static int kvm_get_msrs(X86CPU *cpu)
 {
 CPUX86State *env = >env;
@@ -4173,7 +4277,7 @@ int kvm_arch_put_registers(CPUState *cpu, int level)
 assert(cpu_is_stopped(cpu) || qemu_cpu_is_self(cpu));
 
 /* must be before kvm_put_nested_state so that EFER.SVME is set */
-ret = kvm_put_sregs(x86_cpu);
+

[PULL 11/15] configure, meson: move config-poison.h to meson

2022-01-04 Thread Paolo Bonzini
This ensures that the file is regenerated properly whenever config-target.h
or config-devices.h files change.

Signed-off-by: Paolo Bonzini 
---
 Makefile  |  2 +-
 configure | 11 ---
 meson.build   | 12 
 scripts/make-config-poison.sh | 16 
 4 files changed, 29 insertions(+), 12 deletions(-)
 create mode 100755 scripts/make-config-poison.sh

diff --git a/Makefile b/Makefile
index 8037f73b35..9e2e3bf004 100644
--- a/Makefile
+++ b/Makefile
@@ -221,7 +221,7 @@ qemu-%.tar.bz2:
 
 distclean: clean
-$(quiet-@)test -f build.ninja && $(NINJA) $(NINJAFLAGS) -t clean -g || 
:
-   rm -f config-host.mak config-poison.h
+   rm -f config-host.mak
rm -f tests/tcg/config-*.mak
rm -f config.status
rm -f roms/seabios/config.mak
diff --git a/configure b/configure
index e3d603d381..187632c371 100755
--- a/configure
+++ b/configure
@@ -3833,17 +3833,6 @@ if test -n "${deprecated_features}"; then
 echo "  features: ${deprecated_features}"
 fi
 
-# Create list of config switches that should be poisoned in common code...
-# but filter out CONFIG_TCG and CONFIG_USER_ONLY which are special.
-target_configs_h=$(ls *-config-devices.h *-config-target.h 2>/dev/null)
-if test -n "$target_configs_h" ; then
-sed -n -e '/CONFIG_TCG/d' -e '/CONFIG_USER_ONLY/d' \
--e '/^#define / { s///; s/ .*//; s/^/#pragma GCC poison /p; }' \
-$target_configs_h | sort -u > config-poison.h
-else
-:> config-poison.h
-fi
-
 # Save the configure command line for later reuse.
 cat <config.status
 #!/bin/sh
diff --git a/meson.build b/meson.build
index 5a57906e98..36fc720ba3 100644
--- a/meson.build
+++ b/meson.build
@@ -2028,6 +2028,18 @@ config_all += {
   'CONFIG_ALL': true,
 }
 
+target_configs_h = []
+foreach target: target_dirs
+  target_configs_h += config_target_h[target]
+  target_configs_h += config_devices_h.get(target, [])
+endforeach
+genh += custom_target('config-poison.h',
+  input: [target_configs_h],
+  output: 'config-poison.h',
+  capture: true,
+  command: [find_program('scripts/make-config-poison.sh'),
+target_configs_h])
+
 ##
 # Submodules #
 ##
diff --git a/scripts/make-config-poison.sh b/scripts/make-config-poison.sh
new file mode 100755
index 00..d222a04304
--- /dev/null
+++ b/scripts/make-config-poison.sh
@@ -0,0 +1,16 @@
+#! /bin/sh
+
+if test $# = 0; then
+  exit 0
+fi
+
+# Create list of config switches that should be poisoned in common code...
+# but filter out CONFIG_TCG and CONFIG_USER_ONLY which are special.
+exec sed -n \
+  -e' /CONFIG_TCG/d' \
+  -e '/CONFIG_USER_ONLY/d' \
+  -e '/^#define / {' \
+  -e's///' \
+  -e's/ .*//' \
+  -e's/^/#pragma GCC poison /p' \
+  -e '}' "$@"
-- 
2.33.1





[PULL 07/15] configure, makefile: remove traces of really old files

2022-01-04 Thread Paolo Bonzini
These files have been removed for more than year in the best
case, or for more than ten years for some really old TCG files.
Remove any traces of it.

Acked-by: Richard Henderson 
Signed-off-by: Paolo Bonzini 
---
 Makefile  | 11 ---
 configure |  9 -
 2 files changed, 4 insertions(+), 16 deletions(-)

diff --git a/Makefile b/Makefile
index 5d66c35ea5..8037f73b35 100644
--- a/Makefile
+++ b/Makefile
@@ -206,14 +206,11 @@ recurse-clean: $(addsuffix /clean, $(ROM_DIRS))
 clean: recurse-clean
-$(quiet-@)test -f build.ninja && $(NINJA) $(NINJAFLAGS) -t clean || :
-$(quiet-@)test -f build.ninja && $(NINJA) $(NINJAFLAGS) clean-ctlist 
|| :
-# avoid old build problems by removing potentially incorrect old files
-   rm -f config.mak op-i386.h opc-i386.h gen-op-i386.h op-arm.h opc-arm.h 
gen-op-arm.h
find . \( -name '*.so' -o -name '*.dll' -o -name '*.[oda]' \) -type f \
! -path ./roms/edk2/ArmPkg/Library/GccLto/liblto-aarch64.a \
! -path ./roms/edk2/ArmPkg/Library/GccLto/liblto-arm.a \
-exec rm {} +
-   rm -f TAGS cscope.* *.pod *~ */*~
-   rm -f fsdev/*.pod scsi/*.pod
+   rm -f TAGS cscope.* *~ */*~
 
 VERSION = $(shell cat $(SRC_PATH)/VERSION)
 
@@ -224,10 +221,10 @@ qemu-%.tar.bz2:
 
 distclean: clean
-$(quiet-@)test -f build.ninja && $(NINJA) $(NINJAFLAGS) -t clean -g || 
:
-   rm -f config-host.mak config-host.h* config-poison.h
+   rm -f config-host.mak config-poison.h
rm -f tests/tcg/config-*.mak
-   rm -f config-all-disas.mak config.status
-   rm -f roms/seabios/config.mak roms/vgabios/config.mak
+   rm -f config.status
+   rm -f roms/seabios/config.mak
rm -f qemu-plugins-ld.symbols qemu-plugins-ld64.symbols
rm -f *-config-target.h *-config-devices.mak *-config-devices.h
rm -rf meson-private meson-logs meson-info compile_commands.json
diff --git a/configure b/configure
index b93ba2c86c..851eb35dbe 100755
--- a/configure
+++ b/configure
@@ -3671,9 +3671,6 @@ fi
 # so the build tree will be missing the link back to the new file, and
 # tests might fail. Prefer to keep the relevant files in their own
 # directory and symlink the directory instead.
-# UNLINK is used to remove symlinks from older development versions
-# that might get into the way when doing "git update" without doing
-# a "make distclean" in between.
 LINKS="Makefile"
 LINKS="$LINKS tests/tcg/Makefile.target"
 LINKS="$LINKS pc-bios/optionrom/Makefile"
@@ -3685,7 +3682,6 @@ LINKS="$LINKS tests/avocado tests/data"
 LINKS="$LINKS tests/qemu-iotests/check"
 LINKS="$LINKS python"
 LINKS="$LINKS contrib/plugins/Makefile "
-UNLINK="pc-bios/keymaps"
 for bios_file in \
 $source_path/pc-bios/*.bin \
 $source_path/pc-bios/*.elf \
@@ -3707,11 +3703,6 @@ for f in $LINKS ; do
 symlink "$source_path/$f" "$f"
 fi
 done
-for f in $UNLINK ; do
-if [ -L "$f" ]; then
-rm -f "$f"
-fi
-done
 
 (for i in $cross_cc_vars; do
   export $i
-- 
2.33.1





[PULL 03/15] meson: cleanup common-user/ build

2022-01-04 Thread Paolo Bonzini
It is not necessary to have a separate static_library just for common_user
files; using the one that already covers the rest of common_ss is enough
unless you need to reuse some source files between emulators and tests.
Just place common files for all user-mode emulators in common_ss,
similar to what is already done for softmmu_ss in full system emulators.

The only disadvantage is that the include_directories under bsd-user/include/
and linux-user/include/ are now enabled for all targets rather than only
user mode emulators.  This however is not different from how include/sysemu/
is available when building user mode emulators.

Tested-by: Richard Henderson 
Reviewed-by: Richard Henderson 
Signed-off-by: Paolo Bonzini 
---
 common-user/meson.build |  2 +-
 meson.build | 13 +
 2 files changed, 2 insertions(+), 13 deletions(-)

diff --git a/common-user/meson.build b/common-user/meson.build
index 5cb42bc664..26212dda5c 100644
--- a/common-user/meson.build
+++ b/common-user/meson.build
@@ -1,6 +1,6 @@
 common_user_inc += include_directories('host/' / host_arch)
 
-common_user_ss.add(files(
+user_ss.add(files(
   'safe-syscall.S',
   'safe-syscall-error.c',
 ))
diff --git a/meson.build b/meson.build
index de111d6fa1..5f0b6300b4 100644
--- a/meson.build
+++ b/meson.build
@@ -2399,7 +2399,6 @@ blockdev_ss = ss.source_set()
 block_ss = ss.source_set()
 chardev_ss = ss.source_set()
 common_ss = ss.source_set()
-common_user_ss = ss.source_set()
 crypto_ss = ss.source_set()
 hwcore_ss = ss.source_set()
 io_ss = ss.source_set()
@@ -2651,17 +2650,6 @@ subdir('common-user')
 subdir('bsd-user')
 subdir('linux-user')
 
-common_user_ss = common_user_ss.apply(config_all, strict: false)
-common_user = static_library('common-user',
- sources: common_user_ss.sources(),
- dependencies: common_user_ss.dependencies(),
- include_directories: common_user_inc,
- name_suffix: 'fa',
- build_by_default: false)
-common_user = declare_dependency(link_with: common_user)
-
-user_ss.add(common_user)
-
 # needed for fuzzing binaries
 subdir('tests/qtest/libqos')
 subdir('tests/qtest/fuzz')
@@ -2879,6 +2867,7 @@ common_all = common_ss.apply(config_all, strict: false)
 common_all = static_library('common',
 build_by_default: false,
 sources: common_all.sources() + genh,
+include_directories: common_user_inc,
 implicit_include_directories: false,
 dependencies: common_all.dependencies(),
 name_suffix: 'fa')
-- 
2.33.1





[PULL 08/15] configure: parse --enable/--disable-strip automatically, flip default

2022-01-04 Thread Paolo Bonzini
Always include the STRIP variable in config-host.mak (it's only used
by the s390-ccw firmware build, and it adds a default if configure
omitted it), and use meson-buildoptions.sh to turn
--enable/--disable-strip into -Dstrip.

The default is now not to strip the binaries like for almost every other
package that has a configure script.

Signed-off-by: Paolo Bonzini 
---
 configure | 10 +-
 pc-bios/s390-ccw/Makefile |  2 --
 scripts/meson-buildoptions.py | 21 ++---
 scripts/meson-buildoptions.sh |  3 +++
 4 files changed, 18 insertions(+), 18 deletions(-)

diff --git a/configure b/configure
index 851eb35dbe..9e01b2278e 100755
--- a/configure
+++ b/configure
@@ -307,7 +307,6 @@ debug="no"
 sanitizers="no"
 tsan="no"
 fortify_source="$default_feature"
-strip_opt="yes"
 mingw32="no"
 gcov="no"
 EXESUF=""
@@ -892,7 +891,6 @@ for opt do
   debug_tcg="yes"
   debug_mutex="yes"
   debug="yes"
-  strip_opt="no"
   fortify_source="no"
   ;;
   --enable-sanitizers) sanitizers="yes"
@@ -903,8 +901,6 @@ for opt do
   ;;
   --disable-tsan) tsan="no"
   ;;
-  --disable-strip) strip_opt="no"
-  ;;
   --disable-slirp) slirp="disabled"
   ;;
   --enable-slirp) slirp="enabled"
@@ -1367,7 +1363,6 @@ Advanced options (experts only):
   --enable-debug   enable common debug build options
   --enable-sanitizers  enable default sanitizers
   --enable-tsanenable thread sanitizer
-  --disable-strip  disable stripping binaries
   --disable-werror disable compilation abort on warning
   --disable-stack-protector disable compiler-provided stack protection
   --audio-drv-list=LISTset audio drivers to try if -audiodev is not used
@@ -3314,9 +3309,6 @@ echo "GIT_SUBMODULES_ACTION=$git_submodules_action" >> 
$config_host_mak
 if test "$debug_tcg" = "yes" ; then
   echo "CONFIG_DEBUG_TCG=y" >> $config_host_mak
 fi
-if test "$strip_opt" = "yes" ; then
-  echo "STRIP=${strip}" >> $config_host_mak
-fi
 if test "$mingw32" = "yes" ; then
   echo "CONFIG_WIN32=y" >> $config_host_mak
   if test "$guest_agent_with_vss" = "yes" ; then
@@ -3594,6 +3586,7 @@ echo "GLIB_LIBS=$glib_libs" >> $config_host_mak
 echo "GLIB_VERSION=$(pkg-config --modversion glib-2.0)" >> $config_host_mak
 echo "QEMU_LDFLAGS=$QEMU_LDFLAGS" >> $config_host_mak
 echo "LD_I386_EMULATION=$ld_i386_emulation" >> $config_host_mak
+echo "STRIP=$strip" >> $config_host_mak
 echo "EXESUF=$EXESUF" >> $config_host_mak
 echo "LIBS_QGA=$libs_qga" >> $config_host_mak
 
@@ -3811,7 +3804,6 @@ if test "$skip_meson" = no; then
 -Doptimization=$(if test "$debug" = yes; then echo 0; else echo 2; fi) 
\
 -Ddebug=$(if test "$debug_info" = yes; then echo true; else echo 
false; fi) \
 -Dwerror=$(if test "$werror" = yes; then echo true; else echo false; 
fi) \
--Dstrip=$(if test "$strip_opt" = yes; then echo true; else echo false; 
fi) \
 -Db_pie=$(if test "$pie" = yes; then echo true; else echo false; fi) \
 -Db_coverage=$(if test "$gcov" = yes; then echo true; else echo false; 
fi) \
 -Db_lto=$lto -Dcfi=$cfi -Dtcg=$tcg -Dxen=$xen \
diff --git a/pc-bios/s390-ccw/Makefile b/pc-bios/s390-ccw/Makefile
index cee9d2c63b..0eb68efc7b 100644
--- a/pc-bios/s390-ccw/Makefile
+++ b/pc-bios/s390-ccw/Makefile
@@ -44,8 +44,6 @@ build-all: s390-ccw.img s390-netboot.img
 s390-ccw.elf: $(OBJECTS)
$(call quiet-command,$(CC) $(LDFLAGS) -o $@ 
$(OBJECTS),"BUILD","$(TARGET_DIR)$@")
 
-STRIP ?= strip
-
 s390-ccw.img: s390-ccw.elf
$(call quiet-command,$(STRIP) --strip-unneeded $< -o 
$@,"STRIP","$(TARGET_DIR)$@")
 
diff --git a/scripts/meson-buildoptions.py b/scripts/meson-buildoptions.py
index 96969d89ee..98ae944148 100755
--- a/scripts/meson-buildoptions.py
+++ b/scripts/meson-buildoptions.py
@@ -36,6 +36,10 @@
 "trace_file",
 }
 
+BUILTIN_OPTIONS = {
+"strip",
+}
+
 LINE_WIDTH = 76
 
 
@@ -90,14 +94,17 @@ def allow_arg(opt):
 return not (set(opt["choices"]) <= {"auto", "disabled", "enabled"})
 
 
+def filter_options(json):
+if ":" in json["name"]:
+return False
+if json["section"] == "user":
+return json["name"] not in SKIP_OPTIONS
+else:
+return json["name"] in BUILTIN_OPTIONS
+
+
 def load_options(json):

[PULL 06/15] configure: do not set bsd_user/linux_user early

2022-01-04 Thread Paolo Bonzini
Similar to other optional features, leave the variables empty and compute
the actual value later.  Use the existence of include or source directories
to detect whether an OS or CPU supports respectively bsd-user and linux-user.

For now, BSD user-mode emulation is buildable even on TCI-only
architectures.  This probably will change once safe signals are
brought over from linux-user.

Reviewed-by: Richard Henderson 
Signed-off-by: Paolo Bonzini 
---
 configure | 28 +---
 1 file changed, 17 insertions(+), 11 deletions(-)

diff --git a/configure b/configure
index 5e61439761..b93ba2c86c 100755
--- a/configure
+++ b/configure
@@ -320,8 +320,8 @@ linux="no"
 solaris="no"
 profiler="no"
 softmmu="yes"
-linux_user="no"
-bsd_user="no"
+linux_user=""
+bsd_user=""
 pkgversion=""
 pie=""
 qom_cast_debug="yes"
@@ -538,7 +538,6 @@ gnu/kfreebsd)
 ;;
 freebsd)
   bsd="yes"
-  bsd_user="yes"
   make="${MAKE-gmake}"
   # needed for kinfo_getvmmap(3) in libutil.h
 ;;
@@ -583,7 +582,6 @@ haiku)
 ;;
 linux)
   linux="yes"
-  linux_user="yes"
   vhost_user=${default_feature:-yes}
 ;;
 esac
@@ -1259,18 +1257,26 @@ if eval test -z "\${cross_cc_$cpu}"; then
 cross_cc_vars="$cross_cc_vars cross_cc_${cpu}"
 fi
 
-# For user-mode emulation the host arch has to be one we explicitly
-# support, even if we're using TCI.
-if [ "$ARCH" = "unknown" ]; then
-  bsd_user="no"
-  linux_user="no"
-fi
-
 default_target_list=""
 deprecated_targets_list=ppc64abi32-linux-user
 deprecated_features=""
 mak_wilds=""
 
+if [ "$linux_user" != no ]; then
+if [ "$targetos" = linux ] && [ -d 
$source_path/linux-user/include/host/$cpu ]; then
+linux_user=yes
+elif [ "$linux_user" = yes ]; then
+error_exit "linux-user not supported on this architecture"
+fi
+fi
+if [ "$bsd_user" != no ]; then
+if [ "$bsd_user" = "" ]; then
+test $targetos = freebsd && bsd_user=yes
+fi
+if [ "$bsd_user" = yes ] && ! [ -d $source_path/bsd-user/$targetos ]; then
+error_exit "bsd-user not supported on this host OS"
+fi
+fi
 if [ "$softmmu" = "yes" ]; then
 mak_wilds="${mak_wilds} $source_path/configs/targets/*-softmmu.mak"
 fi
-- 
2.33.1





[PULL 05/15] configure: simplify creation of plugin symbol list

2022-01-04 Thread Paolo Bonzini
--dynamic-list is present on all supported ELF (not Windows or Darwin)
platforms, since it dates back to 2006; -exported_symbols_list is
likewise present on all supported versions of macOS.  Do not bother
doing a functional test in configure.

Remove the file creation from configure as well: for Darwin, move the
the creation of the Darwin-formatted symbols to meson; for ELF, use the
file in the source path directly and switch from -Wl, to -Xlinker to
not break weird paths that include a comma.

Reviewed-by: Richard Henderson 
Signed-off-by: Paolo Bonzini 
---
 configure   | 80 -
 plugins/meson.build | 11 +--
 2 files changed, 8 insertions(+), 83 deletions(-)

diff --git a/configure b/configure
index 3a523a3d14..5e61439761 100755
--- a/configure
+++ b/configure
@@ -78,7 +78,6 @@ TMPC="${TMPDIR1}/${TMPB}.c"
 TMPO="${TMPDIR1}/${TMPB}.o"
 TMPCXX="${TMPDIR1}/${TMPB}.cxx"
 TMPE="${TMPDIR1}/${TMPB}.exe"
-TMPTXT="${TMPDIR1}/${TMPB}.txt"
 
 rm -f config.log
 
@@ -2317,69 +2316,6 @@ EOF
 fi
 fi
 
-##
-# plugin linker support probe
-
-if test "$plugins" != "no"; then
-
-#
-# See if --dynamic-list is supported by the linker
-
-ld_dynamic_list="no"
-cat > $TMPTXT < $TMPC <
-void foo(void);
-
-void foo(void)
-{
-  printf("foo\n");
-}
-
-int main(void)
-{
-  foo();
-  return 0;
-}
-EOF
-
-if compile_prog "" "-Wl,--dynamic-list=$TMPTXT" ; then
-ld_dynamic_list="yes"
-fi
-
-#
-# See if -exported_symbols_list is supported by the linker
-
-ld_exported_symbols_list="no"
-cat > $TMPTXT <> $config_host_mak
-# Copy the export object list to the build dir
-if test "$ld_dynamic_list" = "yes" ; then
-   echo "CONFIG_HAS_LD_DYNAMIC_LIST=yes" >> $config_host_mak
-   ld_symbols=qemu-plugins-ld.symbols
-   cp "$source_path/plugins/qemu-plugins.symbols" $ld_symbols
-elif test "$ld_exported_symbols_list" = "yes" ; then
-   echo "CONFIG_HAS_LD_EXPORTED_SYMBOLS_LIST=yes" >> $config_host_mak
-   ld64_symbols=qemu-plugins-ld64.symbols
-   echo "# Automatically generated by configure - do not modify" > 
$ld64_symbols
-   grep 'qemu_' "$source_path/plugins/qemu-plugins.symbols" | sed 's/;//g' 
| \
-   sed -E 's/^[[:space:]]*(.*)/_\1/' >> $ld64_symbols
-else
-   error_exit \
-   "If \$plugins=yes, either \$ld_dynamic_list or " \
-   "\$ld_exported_symbols_list should have been set to 'yes'."
-fi
 fi
 
 if test -n "$gdb_bin"; then
diff --git a/plugins/meson.build b/plugins/meson.build
index b3de57853b..d0a2ee94cf 100644
--- a/plugins/meson.build
+++ b/plugins/meson.build
@@ -1,10 +1,15 @@
 plugin_ldflags = []
 # Modules need more symbols than just those in plugins/qemu-plugins.symbols
 if not enable_modules
-  if 'CONFIG_HAS_LD_DYNAMIC_LIST' in config_host
-plugin_ldflags = ['-Wl,--dynamic-list=qemu-plugins-ld.symbols']
-  elif 'CONFIG_HAS_LD_EXPORTED_SYMBOLS_LIST' in config_host
+  if targetos == 'darwin'
+qemu_plugins_symbols_list = configure_file(
+  input: files('qemu-plugins.symbols'),
+  output: 'qemu-plugins-ld64.symbols',
+  capture: true,
+  command: ['sed', '-ne', 's/^[[:space:]]*\\(qemu_.*\\);/_\\1/p', 
'@INPUT@'])
 plugin_ldflags = ['-Wl,-exported_symbols_list,qemu-plugins-ld64.symbols']
+  else
+plugin_ldflags = ['-Xlinker', '--dynamic-list=' + 
(meson.project_source_root() / 'plugins/qemu-plugins.symbols')]
   endif
 endif
 
-- 
2.33.1





[PULL 01/15] meson: reuse common_user_inc when building files specific to user-mode emulators

2022-01-04 Thread Paolo Bonzini
Reviewed-by: Richard Henderson 
Signed-off-by: Paolo Bonzini 
---
 meson.build | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/meson.build b/meson.build
index 53065e96ec..de111d6fa1 100644
--- a/meson.build
+++ b/meson.build
@@ -2919,6 +2919,7 @@ foreach target : target_dirs
   else
 abi = config_target['TARGET_ABI_DIR']
 target_type='user'
+target_inc += common_user_inc
 qemu_target_name = 'qemu-' + target_name
 if target_base_arch in target_user_arch
   t = target_user_arch[target_base_arch].apply(config_target, strict: 
false)
@@ -2927,7 +2928,6 @@ foreach target : target_dirs
 endif
 if 'CONFIG_LINUX_USER' in config_target
   base_dir = 'linux-user'
-  target_inc += include_directories('linux-user/host/' / host_arch)
 endif
 if 'CONFIG_BSD_USER' in config_target
   base_dir = 'bsd-user'
-- 
2.33.1





[PULL v3 00/15] Build system and KVM changes for 2021-12-23

2022-01-04 Thread Paolo Bonzini
The following changes since commit b5a3d8bc9146ba22a25116cb748c97341bf99737:

  Merge tag 'pull-misc-20220103' of https://gitlab.com/rth7680/qemu into 
staging (2022-01-03 09:34:41 -0800)

are available in the Git repository at:

  https://gitlab.com/bonzini/qemu.git tags/for-upstream

for you to fetch changes up to a2c137e7e00d1bfcc80a17ff8e5104d0e1de2f9a:

  tests/tcg: Fix target-specific Makefile variables path for user-mode 
(2022-01-04 14:08:44 +0100)


* configure and meson cleanups
* KVM_GET/SET_SREGS2 support for x86



I dropped the tricore Dockerfile change because it is still broken occasionally
with the patch.

Maxim Levitsky (1):
  KVM: use KVM_{GET|SET}_SREGS2 when supported.

Paolo Bonzini (12):
  meson: reuse common_user_inc when building files specific to user-mode 
emulators
  user: move common-user includes to a subdirectory of {bsd,linux}-user/
  meson: cleanup common-user/ build
  configure: simplify creation of plugin symbol list
  configure: do not set bsd_user/linux_user early
  configure, makefile: remove traces of really old files
  configure: parse --enable/--disable-strip automatically, flip default
  configure: move non-command-line variables away from command-line parsing 
section
  meson: build contrib/ executables after generated headers
  configure, meson: move config-poison.h to meson
  meson: add comments in the target-specific flags section
  KVM: x86: ignore interrupt_bitmap field of KVM_GET/SET_SREGS

Philippe Mathieu-Daudé (1):
  tests/tcg: Fix target-specific Makefile variables path for user-mode

Thomas Huth (1):
  block/file-posix: Simplify the XFS_IOC_DIOINFO handling

 Makefile   |  11 +-
 block/file-posix.c |  37 ++---
 bsd-user/{ => include}/special-errno.h |   0
 bsd-user/meson.build   |   2 +-
 common-user/meson.build|   2 +-
 configure  | 182 +++--
 contrib/elf2dmp/meson.build|   2 +-
 contrib/ivshmem-client/meson.build |   2 +-
 contrib/ivshmem-server/meson.build |   2 +-
 contrib/rdmacm-mux/meson.build |   2 +-
 .../{ => include}/host/aarch64/host-signal.h   |   0
 linux-user/{ => include}/host/alpha/host-signal.h  |   0
 linux-user/{ => include}/host/arm/host-signal.h|   0
 linux-user/{ => include}/host/i386/host-signal.h   |   0
 .../{ => include}/host/loongarch64/host-signal.h   |   0
 linux-user/{ => include}/host/mips/host-signal.h   |   0
 linux-user/{ => include}/host/ppc/host-signal.h|   0
 linux-user/{ => include}/host/ppc64/host-signal.h  |   0
 linux-user/{ => include}/host/riscv/host-signal.h  |   0
 linux-user/{ => include}/host/s390/host-signal.h   |   0
 linux-user/{ => include}/host/s390x/host-signal.h  |   0
 linux-user/{ => include}/host/sparc/host-signal.h  |   0
 .../{ => include}/host/sparc64/host-signal.h   |   0
 linux-user/{ => include}/host/x32/host-signal.h|   0
 linux-user/{ => include}/host/x86_64/host-signal.h |   0
 linux-user/{ => include}/special-errno.h   |   0
 linux-user/meson.build |   4 +-
 meson.build|  33 ++--
 pc-bios/s390-ccw/Makefile  |   2 -
 plugins/meson.build|  11 +-
 scripts/make-config-poison.sh  |  16 ++
 scripts/meson-buildoptions.py  |  21 ++-
 scripts/meson-buildoptions.sh  |   3 +
 target/i386/cpu.h  |   3 +
 target/i386/kvm/kvm.c  | 130 +--
 target/i386/machine.c  |  29 
 tests/tcg/Makefile.target  |   2 +-
 37 files changed, 259 insertions(+), 237 deletions(-)
 rename bsd-user/{ => include}/special-errno.h (100%)
 rename linux-user/{ => include}/host/aarch64/host-signal.h (100%)
 rename linux-user/{ => include}/host/alpha/host-signal.h (100%)
 rename linux-user/{ => include}/host/arm/host-signal.h (100%)
 rename linux-user/{ => include}/host/i386/host-signal.h (100%)
 rename linux-user/{ => include}/host/loongarch64/host-signal.h (100%)
 rename linux-user/{ => include}/host/mips/host-signal.h (100%)
 rename linux-user/{ => include}/host/ppc/host-signal.h (100%)
 rename linux-user/{ => include}/host/ppc64/host-signal.h (100%)
 rename linux-user/{ => include}/host/riscv/host-signal.h (100%)
 rename linux-user/{ => include}/host/s390/host-signal.h (100%)
 rename linux-user/{ => include}/host/s390x/host-signal.h (100%)
 rename linux-u

[PULL 04/15] block/file-posix: Simplify the XFS_IOC_DIOINFO handling

2022-01-04 Thread Paolo Bonzini
From: Thomas Huth 

The handling for the XFS_IOC_DIOINFO ioctl is currently quite excessive:
This is not a "real" feature like the other features that we provide with
the "--enable-xxx" and "--disable-xxx" switches for the configure script,
since this does not influence lots of code (it's only about one call to
xfsctl() in file-posix.c), so people don't gain much with the ability to
disable this with "--disable-xfsctl".
It's also unfortunate that the ioctl will be disabled on Linux in case
the user did not install the right xfsprogs-devel package before running
configure. Thus let's simplify this by providing the ioctl definition
on our own, so we can completely get rid of the header dependency and
thus the related code in the configure script.

Suggested-by: Paolo Bonzini 
Signed-off-by: Thomas Huth 
Message-Id: <20211215125824.250091-1-th...@redhat.com>
Signed-off-by: Paolo Bonzini 
---
 block/file-posix.c | 37 -
 configure  | 31 ---
 meson.build|  1 -
 3 files changed, 16 insertions(+), 53 deletions(-)

diff --git a/block/file-posix.c b/block/file-posix.c
index b283093e5b..1f1756e192 100644
--- a/block/file-posix.c
+++ b/block/file-posix.c
@@ -106,10 +106,6 @@
 #include 
 #endif
 
-#ifdef CONFIG_XFS
-#include 
-#endif
-
 /* OS X does not have O_DSYNC */
 #ifndef O_DSYNC
 #ifdef O_SYNC
@@ -156,9 +152,6 @@ typedef struct BDRVRawState {
 int perm_change_flags;
 BDRVReopenState *reopen_state;
 
-#ifdef CONFIG_XFS
-bool is_xfs:1;
-#endif
 bool has_discard:1;
 bool has_write_zeroes:1;
 bool discard_zeroes:1;
@@ -409,14 +402,22 @@ static void raw_probe_alignment(BlockDriverState *bs, int 
fd, Error **errp)
 if (probe_logical_blocksize(fd, >bl.request_alignment) < 0) {
 bs->bl.request_alignment = 0;
 }
-#ifdef CONFIG_XFS
-if (s->is_xfs) {
-struct dioattr da;
-if (xfsctl(NULL, fd, XFS_IOC_DIOINFO, ) >= 0) {
-bs->bl.request_alignment = da.d_miniosz;
-/* The kernel returns wrong information for d_mem */
-/* s->buf_align = da.d_mem; */
-}
+
+#ifdef __linux__
+/*
+ * The XFS ioctl definitions are shipped in extra packages that might
+ * not always be available. Since we just need the XFS_IOC_DIOINFO ioctl
+ * here, we simply use our own definition instead:
+ */
+struct xfs_dioattr {
+uint32_t d_mem;
+uint32_t d_miniosz;
+uint32_t d_maxiosz;
+} da;
+if (ioctl(fd, _IOR('X', 30, struct xfs_dioattr), ) >= 0) {
+bs->bl.request_alignment = da.d_miniosz;
+/* The kernel returns wrong information for d_mem */
+/* s->buf_align = da.d_mem; */
 }
 #endif
 
@@ -798,12 +799,6 @@ static int raw_open_common(BlockDriverState *bs, QDict 
*options,
 #endif
 s->needs_alignment = raw_needs_alignment(bs);
 
-#ifdef CONFIG_XFS
-if (platform_test_xfs_fd(s->fd)) {
-s->is_xfs = true;
-}
-#endif
-
 bs->supported_zero_flags = BDRV_REQ_MAY_UNMAP | BDRV_REQ_NO_FALLBACK;
 if (S_ISREG(st.st_mode)) {
 /* When extending regular files, we get zeros from the OS */
diff --git a/configure b/configure
index 030728d11e..3a523a3d14 100755
--- a/configure
+++ b/configure
@@ -291,7 +291,6 @@ EXTRA_CXXFLAGS=""
 EXTRA_LDFLAGS=""
 
 xen_ctrl_version="$default_feature"
-xfs="$default_feature"
 membarrier="$default_feature"
 vhost_kernel="$default_feature"
 vhost_net="$default_feature"
@@ -1021,10 +1020,6 @@ for opt do
   ;;
   --enable-opengl) opengl="yes"
   ;;
-  --disable-xfsctl) xfs="no"
-  ;;
-  --enable-xfsctl) xfs="yes"
-  ;;
   --disable-zlib-test)
   ;;
   --enable-guest-agent) guest_agent="yes"
@@ -1431,7 +1426,6 @@ cat << EOF
   avx512f AVX512F optimization support
   replication replication support
   opengl  opengl support
-  xfsctl  xfsctl support
   qom-cast-debug  cast debugging support
   tools   build qemu-io, qemu-nbd and qemu-img tools
   bochs   bochs image format support
@@ -2323,28 +2317,6 @@ EOF
 fi
 fi
 
-##
-# xfsctl() probe, used for file-posix.c
-if test "$xfs" != "no" ; then
-  cat > $TMPC << EOF
-#include   /* NULL */
-#include 
-int main(void)
-{
-xfsctl(NULL, 0, 0, NULL);
-return 0;
-}
-EOF
-  if compile_prog "" "" ; then
-xfs="yes"
-  else
-if test "$xfs" = "yes" ; then
-  feature_not_found "xfs" "Install xfsprogs/xfslibs devel"
-fi
-xfs=no
-  fi
-fi
-
 ##
 # plugin linker support probe
 
@@ -3456,9 +3428,6 @@ echo "CONFIG_BDRV_RO_WHITELIST=$block_drv_ro_whitelist" 

[PULL 02/15] user: move common-user includes to a subdirectory of {bsd, linux}-user/

2022-01-04 Thread Paolo Bonzini
Avoid polluting the compilation of common-user/ with local include files;
making an include file available to common-user/ should be a deliberate
decision in order to keep a clear interface that can be used by both
bsd-user/ and linux-user/.

Reviewed-by: Richard Henderson 
Signed-off-by: Paolo Bonzini 
---
 bsd-user/{ => include}/special-errno.h  | 0
 bsd-user/meson.build| 2 +-
 linux-user/{ => include}/host/aarch64/host-signal.h | 0
 linux-user/{ => include}/host/alpha/host-signal.h   | 0
 linux-user/{ => include}/host/arm/host-signal.h | 0
 linux-user/{ => include}/host/i386/host-signal.h| 0
 linux-user/{ => include}/host/loongarch64/host-signal.h | 0
 linux-user/{ => include}/host/mips/host-signal.h| 0
 linux-user/{ => include}/host/ppc/host-signal.h | 0
 linux-user/{ => include}/host/ppc64/host-signal.h   | 0
 linux-user/{ => include}/host/riscv/host-signal.h   | 0
 linux-user/{ => include}/host/s390/host-signal.h| 0
 linux-user/{ => include}/host/s390x/host-signal.h   | 0
 linux-user/{ => include}/host/sparc/host-signal.h   | 0
 linux-user/{ => include}/host/sparc64/host-signal.h | 0
 linux-user/{ => include}/host/x32/host-signal.h | 0
 linux-user/{ => include}/host/x86_64/host-signal.h  | 0
 linux-user/{ => include}/special-errno.h| 0
 linux-user/meson.build  | 4 ++--
 19 files changed, 3 insertions(+), 3 deletions(-)
 rename bsd-user/{ => include}/special-errno.h (100%)
 rename linux-user/{ => include}/host/aarch64/host-signal.h (100%)
 rename linux-user/{ => include}/host/alpha/host-signal.h (100%)
 rename linux-user/{ => include}/host/arm/host-signal.h (100%)
 rename linux-user/{ => include}/host/i386/host-signal.h (100%)
 rename linux-user/{ => include}/host/loongarch64/host-signal.h (100%)
 rename linux-user/{ => include}/host/mips/host-signal.h (100%)
 rename linux-user/{ => include}/host/ppc/host-signal.h (100%)
 rename linux-user/{ => include}/host/ppc64/host-signal.h (100%)
 rename linux-user/{ => include}/host/riscv/host-signal.h (100%)
 rename linux-user/{ => include}/host/s390/host-signal.h (100%)
 rename linux-user/{ => include}/host/s390x/host-signal.h (100%)
 rename linux-user/{ => include}/host/sparc/host-signal.h (100%)
 rename linux-user/{ => include}/host/sparc64/host-signal.h (100%)
 rename linux-user/{ => include}/host/x32/host-signal.h (100%)
 rename linux-user/{ => include}/host/x86_64/host-signal.h (100%)
 rename linux-user/{ => include}/special-errno.h (100%)

diff --git a/bsd-user/special-errno.h b/bsd-user/include/special-errno.h
similarity index 100%
rename from bsd-user/special-errno.h
rename to bsd-user/include/special-errno.h
diff --git a/bsd-user/meson.build b/bsd-user/meson.build
index 9fcb80c3fa..8380fa44c2 100644
--- a/bsd-user/meson.build
+++ b/bsd-user/meson.build
@@ -4,7 +4,7 @@ endif
 
 bsd_user_ss = ss.source_set()
 
-common_user_inc += include_directories('.')
+common_user_inc += include_directories('include')
 
 bsd_user_ss.add(files(
   'bsdload.c',
diff --git a/linux-user/host/aarch64/host-signal.h 
b/linux-user/include/host/aarch64/host-signal.h
similarity index 100%
rename from linux-user/host/aarch64/host-signal.h
rename to linux-user/include/host/aarch64/host-signal.h
diff --git a/linux-user/host/alpha/host-signal.h 
b/linux-user/include/host/alpha/host-signal.h
similarity index 100%
rename from linux-user/host/alpha/host-signal.h
rename to linux-user/include/host/alpha/host-signal.h
diff --git a/linux-user/host/arm/host-signal.h 
b/linux-user/include/host/arm/host-signal.h
similarity index 100%
rename from linux-user/host/arm/host-signal.h
rename to linux-user/include/host/arm/host-signal.h
diff --git a/linux-user/host/i386/host-signal.h 
b/linux-user/include/host/i386/host-signal.h
similarity index 100%
rename from linux-user/host/i386/host-signal.h
rename to linux-user/include/host/i386/host-signal.h
diff --git a/linux-user/host/loongarch64/host-signal.h 
b/linux-user/include/host/loongarch64/host-signal.h
similarity index 100%
rename from linux-user/host/loongarch64/host-signal.h
rename to linux-user/include/host/loongarch64/host-signal.h
diff --git a/linux-user/host/mips/host-signal.h 
b/linux-user/include/host/mips/host-signal.h
similarity index 100%
rename from linux-user/host/mips/host-signal.h
rename to linux-user/include/host/mips/host-signal.h
diff --git a/linux-user/host/ppc/host-signal.h 
b/linux-user/include/host/ppc/host-signal.h
similarity index 100%
rename from linux-user/host/ppc/host-signal.h
rename to linux-user/include/host/ppc/host-signal.h
diff --git a/linux-user/host/ppc64/host-signal.h 
b/linux-user/include/host/ppc64/host-signal.h
similarity index 100%
rename from linux-user/host/ppc64/host-signal.h
rename to linux-user/include/host/ppc64/host-si

Re: QEMU CI failure of cross-i386-* targets (meson picks wrong glib for native target)

2021-12-24 Thread Paolo Bonzini
Is the configure script setting $cross_compile to yes? That will decide
whether meson getting a --cross-file or a --native-file option, and
consequently whether it treats the host and build machines as equal or
different.

Paolo

Il ven 24 dic 2021, 12:09 Alessandro Di Federico  ha scritto:

> Hi Paolo, I'm trying to get the QEMU CI run successfully for the
> idef-parser patchset. However I'm facing an issue I haven't been able
> to work around with meson. Maybe you can help?
>
> The failing tests are cross-i386-*
>
> https://gitlab.com/carl.cudig/qemu/-/jobs/1437392669
> https://gitlab.com/carl.cudig/qemu/-/jobs/1437392673
> https://gitlab.com/carl.cudig/qemu/-/jobs/1437392671
>
> I think the problem is that we're adding a new build-time dependency:
> glib. However glib is also a run-time dependency and, AFAIU, when cross
> compiling for x86 on a x86-64 machine, if you create a native
> executable, meson picks up the x86 version of glib (as opposed to the
> x86-64).
>
> I've been fiddling with this for a while, unsuccessfully.
>
> Relevant portion of the code:
>
>
> https://gitlab.com/carl.cudig/qemu/-/commit/c020958c37fa723f7e933a58b1bb1c3668ff4cff#8145a41027f26ff426d5a2c8b00c56f227943165_198_202
>
> Happy holidays!
>
> --
> Alessandro Di Federico
> rev.ng Labs Srl
>
>


Re: [PATCH v3 kvm/queue 06/16] KVM: Implement fd-based memory using MEMFD_OPS interfaces

2021-12-23 Thread Paolo Bonzini

On 12/23/21 19:34, Sean Christopherson wrote:

select HAVE_KVM_PM_NOTIFIER if PM
+   select MEMFD_OPS

MEMFD_OPS is a weird Kconfig name given that it's not just memfd() that can
implement the ops.



Or, it's kvm that implements them to talk to memfd?

Paolo



[PULL 13/15] meson: add comments in the target-specific flags section

2021-12-23 Thread Paolo Bonzini
Signed-off-by: Paolo Bonzini 
---
 meson.build | 5 +
 1 file changed, 5 insertions(+)

diff --git a/meson.build b/meson.build
index a61eb7cee5..3519ed51e3 100644
--- a/meson.build
+++ b/meson.build
@@ -233,6 +233,7 @@ endif
 # Target-specific checks and dependencies #
 ###
 
+# Fuzzing
 if get_option('fuzzing') and get_option('fuzzing_engine') == '' and \
 not cc.links('''
   #include 
@@ -244,6 +245,7 @@ if get_option('fuzzing') and get_option('fuzzing_engine') 
== '' and \
   error('Your compiler does not support -fsanitize=fuzzer')
 endif
 
+# Tracing backends
 if 'ftrace' in get_option('trace_backends') and targetos != 'linux'
   error('ftrace is supported only on Linux')
 endif
@@ -257,6 +259,7 @@ if 'syslog' in get_option('trace_backends') and not 
cc.compiles('''
   error('syslog is not supported on this system')
 endif
 
+# Miscellaneous Linux-only features
 if targetos != 'linux' and get_option('mpath').enabled()
   error('Multipath is supported only on Linux')
 endif
@@ -266,6 +269,7 @@ if targetos != 'linux' and 
get_option('multiprocess').enabled()
 endif
 multiprocess_allowed = targetos == 'linux' and not 
get_option('multiprocess').disabled()
 
+# Target-specific libraries and flags
 libm = cc.find_library('m', required: false)
 threads = dependency('threads')
 util = cc.find_library('util', required: false)
@@ -306,6 +310,7 @@ elif targetos == 'openbsd'
   endif
 endif
 
+# Target-specific configuration of accelerators
 accelerators = []
 if not get_option('kvm').disabled() and targetos == 'linux'
   accelerators += 'CONFIG_KVM'
-- 
2.33.1





[PULL 12/15] configure, meson: move config-poison.h to meson

2021-12-23 Thread Paolo Bonzini
This ensures that the file is regenerated properly whenever config-target.h
or config-devices.h files change.

Signed-off-by: Paolo Bonzini 
---
 Makefile  |  2 +-
 configure | 11 ---
 meson.build   | 12 
 scripts/make-config-poison.sh | 16 
 4 files changed, 29 insertions(+), 12 deletions(-)
 create mode 100755 scripts/make-config-poison.sh

diff --git a/Makefile b/Makefile
index 06ad8a61e1..2f80f56a4a 100644
--- a/Makefile
+++ b/Makefile
@@ -220,7 +220,7 @@ qemu-%.tar.bz2:
 
 distclean: clean
-$(quiet-@)test -f build.ninja && $(NINJA) $(NINJAFLAGS) -t clean -g || 
:
-   rm -f config-host.mak config-poison.h
+   rm -f config-host.mak
rm -f tests/tcg/config-*.mak
rm -f config.status
rm -f roms/seabios/config.mak
diff --git a/configure b/configure
index 8eb8e4c2cc..d2f12bc2d6 100755
--- a/configure
+++ b/configure
@@ -3827,17 +3827,6 @@ if test -n "${deprecated_features}"; then
 echo "  features: ${deprecated_features}"
 fi
 
-# Create list of config switches that should be poisoned in common code...
-# but filter out CONFIG_TCG and CONFIG_USER_ONLY which are special.
-target_configs_h=$(ls *-config-devices.h *-config-target.h 2>/dev/null)
-if test -n "$target_configs_h" ; then
-sed -n -e '/CONFIG_TCG/d' -e '/CONFIG_USER_ONLY/d' \
--e '/^#define / { s///; s/ .*//; s/^/#pragma GCC poison /p; }' \
-$target_configs_h | sort -u > config-poison.h
-else
-:> config-poison.h
-fi
-
 # Save the configure command line for later reuse.
 cat <config.status
 #!/bin/sh
diff --git a/meson.build b/meson.build
index 993a591983..a61eb7cee5 100644
--- a/meson.build
+++ b/meson.build
@@ -2006,6 +2006,18 @@ config_all += {
   'CONFIG_ALL': true,
 }
 
+target_configs_h = []
+foreach target: target_dirs
+  target_configs_h += config_target_h[target]
+  target_configs_h += config_devices_h.get(target, [])
+endforeach
+genh += custom_target('config-poison.h',
+  input: [target_configs_h],
+  output: 'config-poison.h',
+  capture: true,
+  command: [find_program('scripts/make-config-poison.sh'),
+target_configs_h])
+
 ##
 # Submodules #
 ##
diff --git a/scripts/make-config-poison.sh b/scripts/make-config-poison.sh
new file mode 100755
index 00..d222a04304
--- /dev/null
+++ b/scripts/make-config-poison.sh
@@ -0,0 +1,16 @@
+#! /bin/sh
+
+if test $# = 0; then
+  exit 0
+fi
+
+# Create list of config switches that should be poisoned in common code...
+# but filter out CONFIG_TCG and CONFIG_USER_ONLY which are special.
+exec sed -n \
+  -e' /CONFIG_TCG/d' \
+  -e '/CONFIG_USER_ONLY/d' \
+  -e '/^#define / {' \
+  -e's///' \
+  -e's/ .*//' \
+  -e's/^/#pragma GCC poison /p' \
+  -e '}' "$@"
-- 
2.33.1





[PULL 11/15] meson: build contrib/ executables after generated headers

2021-12-23 Thread Paolo Bonzini
This will be needed as soon as config-poison.h moves from configure to
a meson custom_target (which is built at "ninja" time).

Reviewed-by: Philippe Mathieu-Daudé 
Signed-off-by: Paolo Bonzini 
---
 contrib/elf2dmp/meson.build| 2 +-
 contrib/ivshmem-client/meson.build | 2 +-
 contrib/ivshmem-server/meson.build | 2 +-
 contrib/rdmacm-mux/meson.build | 2 +-
 4 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/contrib/elf2dmp/meson.build b/contrib/elf2dmp/meson.build
index 4d86cb390a..6707d43c4f 100644
--- a/contrib/elf2dmp/meson.build
+++ b/contrib/elf2dmp/meson.build
@@ -1,5 +1,5 @@
 if curl.found()
-  executable('elf2dmp', files('main.c', 'addrspace.c', 'download.c', 'pdb.c', 
'qemu_elf.c'),
+  executable('elf2dmp', files('main.c', 'addrspace.c', 'download.c', 'pdb.c', 
'qemu_elf.c'), genh,
  dependencies: [glib, curl],
  install: true)
 endif
diff --git a/contrib/ivshmem-client/meson.build 
b/contrib/ivshmem-client/meson.build
index 1b171efb4f..ce8dcca84d 100644
--- a/contrib/ivshmem-client/meson.build
+++ b/contrib/ivshmem-client/meson.build
@@ -1,4 +1,4 @@
-executable('ivshmem-client', files('ivshmem-client.c', 'main.c'),
+executable('ivshmem-client', files('ivshmem-client.c', 'main.c'), genh,
dependencies: glib,
build_by_default: targetos == 'linux',
install: false)
diff --git a/contrib/ivshmem-server/meson.build 
b/contrib/ivshmem-server/meson.build
index 3a53942201..c6c3c82e89 100644
--- a/contrib/ivshmem-server/meson.build
+++ b/contrib/ivshmem-server/meson.build
@@ -1,4 +1,4 @@
-executable('ivshmem-server', files('ivshmem-server.c', 'main.c'),
+executable('ivshmem-server', files('ivshmem-server.c', 'main.c'), genh,
dependencies: [qemuutil, rt],
build_by_default: targetos == 'linux',
install: false)
diff --git a/contrib/rdmacm-mux/meson.build b/contrib/rdmacm-mux/meson.build
index 6cc5016747..7674f54cc5 100644
--- a/contrib/rdmacm-mux/meson.build
+++ b/contrib/rdmacm-mux/meson.build
@@ -2,7 +2,7 @@ if 'CONFIG_PVRDMA' in config_host
   # if not found, CONFIG_PVRDMA should not be set
   # FIXME: broken on big endian architectures
   libumad = cc.find_library('ibumad', required: true)
-  executable('rdmacm-mux', files('main.c'),
+  executable('rdmacm-mux', files('main.c'), genh,
  dependencies: [glib, libumad],
  build_by_default: false,
  install: false)
-- 
2.33.1





[PULL 09/15] configure: parse --enable/--disable-strip automatically, flip default

2021-12-23 Thread Paolo Bonzini
Always include the STRIP variable in config-host.mak (it's only used
by the s390-ccw firmware build, and it adds a default if configure
omitted it), and use meson-buildoptions.sh to turn
--enable/--disable-strip into -Dstrip.

The default is now not to strip the binaries like for almost every other
package that has a configure script.

Signed-off-by: Paolo Bonzini 
---
 configure | 10 +-
 pc-bios/s390-ccw/Makefile |  2 --
 scripts/meson-buildoptions.py | 21 ++---
 scripts/meson-buildoptions.sh |  3 +++
 4 files changed, 18 insertions(+), 18 deletions(-)

diff --git a/configure b/configure
index c8b32e7277..302d58102b 100755
--- a/configure
+++ b/configure
@@ -307,7 +307,6 @@ debug="no"
 sanitizers="no"
 tsan="no"
 fortify_source="$default_feature"
-strip_opt="yes"
 mingw32="no"
 gcov="no"
 EXESUF=""
@@ -890,7 +889,6 @@ for opt do
   debug_tcg="yes"
   debug_mutex="yes"
   debug="yes"
-  strip_opt="no"
   fortify_source="no"
   ;;
   --enable-sanitizers) sanitizers="yes"
@@ -901,8 +899,6 @@ for opt do
   ;;
   --disable-tsan) tsan="no"
   ;;
-  --disable-strip) strip_opt="no"
-  ;;
   --disable-slirp) slirp="disabled"
   ;;
   --enable-slirp) slirp="enabled"
@@ -1365,7 +1361,6 @@ Advanced options (experts only):
   --enable-debug   enable common debug build options
   --enable-sanitizers  enable default sanitizers
   --enable-tsanenable thread sanitizer
-  --disable-strip  disable stripping binaries
   --disable-werror disable compilation abort on warning
   --disable-stack-protector disable compiler-provided stack protection
   --audio-drv-list=LISTset audio drivers to try if -audiodev is not used
@@ -3312,9 +3307,6 @@ echo "GIT_SUBMODULES_ACTION=$git_submodules_action" >> 
$config_host_mak
 if test "$debug_tcg" = "yes" ; then
   echo "CONFIG_DEBUG_TCG=y" >> $config_host_mak
 fi
-if test "$strip_opt" = "yes" ; then
-  echo "STRIP=${strip}" >> $config_host_mak
-fi
 if test "$mingw32" = "yes" ; then
   echo "CONFIG_WIN32=y" >> $config_host_mak
   if test "$guest_agent_with_vss" = "yes" ; then
@@ -3591,6 +3583,7 @@ echo "GLIB_CFLAGS=$glib_cflags" >> $config_host_mak
 echo "GLIB_LIBS=$glib_libs" >> $config_host_mak
 echo "QEMU_LDFLAGS=$QEMU_LDFLAGS" >> $config_host_mak
 echo "LD_I386_EMULATION=$ld_i386_emulation" >> $config_host_mak
+echo "STRIP=$strip" >> $config_host_mak
 echo "EXESUF=$EXESUF" >> $config_host_mak
 echo "LIBS_QGA=$libs_qga" >> $config_host_mak
 
@@ -3805,7 +3798,6 @@ if test "$skip_meson" = no; then
 -Doptimization=$(if test "$debug" = yes; then echo 0; else echo 2; fi) 
\
 -Ddebug=$(if test "$debug_info" = yes; then echo true; else echo 
false; fi) \
 -Dwerror=$(if test "$werror" = yes; then echo true; else echo false; 
fi) \
--Dstrip=$(if test "$strip_opt" = yes; then echo true; else echo false; 
fi) \
 -Db_pie=$(if test "$pie" = yes; then echo true; else echo false; fi) \
 -Db_coverage=$(if test "$gcov" = yes; then echo true; else echo false; 
fi) \
 -Db_lto=$lto -Dcfi=$cfi -Dtcg=$tcg -Dxen=$xen \
diff --git a/pc-bios/s390-ccw/Makefile b/pc-bios/s390-ccw/Makefile
index cee9d2c63b..0eb68efc7b 100644
--- a/pc-bios/s390-ccw/Makefile
+++ b/pc-bios/s390-ccw/Makefile
@@ -44,8 +44,6 @@ build-all: s390-ccw.img s390-netboot.img
 s390-ccw.elf: $(OBJECTS)
$(call quiet-command,$(CC) $(LDFLAGS) -o $@ 
$(OBJECTS),"BUILD","$(TARGET_DIR)$@")
 
-STRIP ?= strip
-
 s390-ccw.img: s390-ccw.elf
$(call quiet-command,$(STRIP) --strip-unneeded $< -o 
$@,"STRIP","$(TARGET_DIR)$@")
 
diff --git a/scripts/meson-buildoptions.py b/scripts/meson-buildoptions.py
index 96969d89ee..98ae944148 100755
--- a/scripts/meson-buildoptions.py
+++ b/scripts/meson-buildoptions.py
@@ -36,6 +36,10 @@
 "trace_file",
 }
 
+BUILTIN_OPTIONS = {
+"strip",
+}
+
 LINE_WIDTH = 76
 
 
@@ -90,14 +94,17 @@ def allow_arg(opt):
 return not (set(opt["choices"]) <= {"auto", "disabled", "enabled"})
 
 
+def filter_options(json):
+if ":" in json["name"]:
+return False
+if json["section"] == "user":
+return json["name"] not in SKIP_OPTIONS
+else:
+return json["name"] in BUILTIN_OPTIONS
+
+
 def load_options(json):
-json = [
-x
-for x in js

[PULL 10/15] configure: move non-command-line variables away from command-line parsing section

2021-12-23 Thread Paolo Bonzini
This makes it easier to identify candidates for moving to Meson.

Reviewed-by: Philippe Mathieu-Daudé 
Signed-off-by: Paolo Bonzini 
---
 configure | 13 ++---
 1 file changed, 6 insertions(+), 7 deletions(-)

diff --git a/configure b/configure
index 302d58102b..8eb8e4c2cc 100755
--- a/configure
+++ b/configure
@@ -307,16 +307,12 @@ debug="no"
 sanitizers="no"
 tsan="no"
 fortify_source="$default_feature"
-mingw32="no"
 gcov="no"
 EXESUF=""
 modules="no"
 module_upgrades="no"
 prefix="/usr/local"
 qemu_suffix="qemu"
-bsd="no"
-linux="no"
-solaris="no"
 profiler="no"
 softmmu="yes"
 linux_user=""
@@ -330,8 +326,6 @@ opengl="$default_feature"
 cpuid_h="no"
 avx2_opt="$default_feature"
 guest_agent="$default_feature"
-guest_agent_with_vss="no"
-guest_agent_ntddscsi="no"
 vss_win32_sdk="$default_feature"
 win_sdk="no"
 want_tools="$default_feature"
@@ -526,6 +520,10 @@ fi
 
 # OS specific
 
+mingw32="no"
+bsd="no"
+linux="no"
+solaris="no"
 case $targetos in
 windows)
   mingw32="yes"
@@ -2546,6 +2544,7 @@ fi
 ##
 # check if we have VSS SDK headers for win
 
+guest_agent_with_vss="no"
 if test "$mingw32" = "yes" && test "$guest_agent" != "no" && \
 test "$vss_win32_sdk" != "no" ; then
   case "$vss_win32_sdk" in
@@ -2576,7 +2575,6 @@ EOF
   echo "ERROR: The headers are extracted in the directory \`inc'."
   feature_not_found "VSS support"
 fi
-guest_agent_with_vss="no"
   fi
 fi
 
@@ -2603,6 +2601,7 @@ fi
 
 ##
 # check if mingw environment provides a recent ntddscsi.h
+guest_agent_ntddscsi="no"
 if test "$mingw32" = "yes" && test "$guest_agent" != "no"; then
   cat > $TMPC << EOF
 #include 
-- 
2.33.1





[PULL 06/15] configure: simplify creation of plugin symbol list

2021-12-23 Thread Paolo Bonzini
--dynamic-list is present on all supported ELF (not Windows or Darwin)
platforms, since it dates back to 2006; -exported_symbols_list is
likewise present on all supported versions of macOS.  Do not bother
doing a functional test in configure.

Remove the file creation from configure as well: for Darwin, move the
the creation of the Darwin-formatted symbols to meson; for ELF, use the
file in the source path directly and switch from -Wl, to -Xlinker to
not break weird paths that include a comma.

Reviewed-by: Richard Henderson 
Signed-off-by: Paolo Bonzini 
---
 configure   | 80 -
 plugins/meson.build | 11 +--
 2 files changed, 8 insertions(+), 83 deletions(-)

diff --git a/configure b/configure
index b66ab31834..0306f0c8bc 100755
--- a/configure
+++ b/configure
@@ -78,7 +78,6 @@ TMPC="${TMPDIR1}/${TMPB}.c"
 TMPO="${TMPDIR1}/${TMPB}.o"
 TMPCXX="${TMPDIR1}/${TMPB}.cxx"
 TMPE="${TMPDIR1}/${TMPB}.exe"
-TMPTXT="${TMPDIR1}/${TMPB}.txt"
 
 rm -f config.log
 
@@ -2315,69 +2314,6 @@ EOF
 fi
 fi
 
-##
-# plugin linker support probe
-
-if test "$plugins" != "no"; then
-
-#
-# See if --dynamic-list is supported by the linker
-
-ld_dynamic_list="no"
-cat > $TMPTXT < $TMPC <
-void foo(void);
-
-void foo(void)
-{
-  printf("foo\n");
-}
-
-int main(void)
-{
-  foo();
-  return 0;
-}
-EOF
-
-if compile_prog "" "-Wl,--dynamic-list=$TMPTXT" ; then
-ld_dynamic_list="yes"
-fi
-
-#
-# See if -exported_symbols_list is supported by the linker
-
-ld_exported_symbols_list="no"
-cat > $TMPTXT <> $config_host_mak
-# Copy the export object list to the build dir
-if test "$ld_dynamic_list" = "yes" ; then
-   echo "CONFIG_HAS_LD_DYNAMIC_LIST=yes" >> $config_host_mak
-   ld_symbols=qemu-plugins-ld.symbols
-   cp "$source_path/plugins/qemu-plugins.symbols" $ld_symbols
-elif test "$ld_exported_symbols_list" = "yes" ; then
-   echo "CONFIG_HAS_LD_EXPORTED_SYMBOLS_LIST=yes" >> $config_host_mak
-   ld64_symbols=qemu-plugins-ld64.symbols
-   echo "# Automatically generated by configure - do not modify" > 
$ld64_symbols
-   grep 'qemu_' "$source_path/plugins/qemu-plugins.symbols" | sed 's/;//g' 
| \
-   sed -E 's/^[[:space:]]*(.*)/_\1/' >> $ld64_symbols
-else
-   error_exit \
-   "If \$plugins=yes, either \$ld_dynamic_list or " \
-   "\$ld_exported_symbols_list should have been set to 'yes'."
-fi
 fi
 
 if test -n "$gdb_bin"; then
diff --git a/plugins/meson.build b/plugins/meson.build
index b3de57853b..d0a2ee94cf 100644
--- a/plugins/meson.build
+++ b/plugins/meson.build
@@ -1,10 +1,15 @@
 plugin_ldflags = []
 # Modules need more symbols than just those in plugins/qemu-plugins.symbols
 if not enable_modules
-  if 'CONFIG_HAS_LD_DYNAMIC_LIST' in config_host
-plugin_ldflags = ['-Wl,--dynamic-list=qemu-plugins-ld.symbols']
-  elif 'CONFIG_HAS_LD_EXPORTED_SYMBOLS_LIST' in config_host
+  if targetos == 'darwin'
+qemu_plugins_symbols_list = configure_file(
+  input: files('qemu-plugins.symbols'),
+  output: 'qemu-plugins-ld64.symbols',
+  capture: true,
+  command: ['sed', '-ne', 's/^[[:space:]]*\\(qemu_.*\\);/_\\1/p', 
'@INPUT@'])
 plugin_ldflags = ['-Wl,-exported_symbols_list,qemu-plugins-ld64.symbols']
+  else
+plugin_ldflags = ['-Xlinker', '--dynamic-list=' + 
(meson.project_source_root() / 'plugins/qemu-plugins.symbols')]
   endif
 endif
 
-- 
2.33.1





[PULL 05/15] block/file-posix: Simplify the XFS_IOC_DIOINFO handling

2021-12-23 Thread Paolo Bonzini
From: Thomas Huth 

The handling for the XFS_IOC_DIOINFO ioctl is currently quite excessive:
This is not a "real" feature like the other features that we provide with
the "--enable-xxx" and "--disable-xxx" switches for the configure script,
since this does not influence lots of code (it's only about one call to
xfsctl() in file-posix.c), so people don't gain much with the ability to
disable this with "--disable-xfsctl".
It's also unfortunate that the ioctl will be disabled on Linux in case
the user did not install the right xfsprogs-devel package before running
configure. Thus let's simplify this by providing the ioctl definition
on our own, so we can completely get rid of the header dependency and
thus the related code in the configure script.

Suggested-by: Paolo Bonzini 
Signed-off-by: Thomas Huth 
Message-Id: <20211215125824.250091-1-th...@redhat.com>
Signed-off-by: Paolo Bonzini 
---
 block/file-posix.c | 37 -
 configure  | 31 ---
 meson.build|  1 -
 3 files changed, 16 insertions(+), 53 deletions(-)

diff --git a/block/file-posix.c b/block/file-posix.c
index b283093e5b..1f1756e192 100644
--- a/block/file-posix.c
+++ b/block/file-posix.c
@@ -106,10 +106,6 @@
 #include 
 #endif
 
-#ifdef CONFIG_XFS
-#include 
-#endif
-
 /* OS X does not have O_DSYNC */
 #ifndef O_DSYNC
 #ifdef O_SYNC
@@ -156,9 +152,6 @@ typedef struct BDRVRawState {
 int perm_change_flags;
 BDRVReopenState *reopen_state;
 
-#ifdef CONFIG_XFS
-bool is_xfs:1;
-#endif
 bool has_discard:1;
 bool has_write_zeroes:1;
 bool discard_zeroes:1;
@@ -409,14 +402,22 @@ static void raw_probe_alignment(BlockDriverState *bs, int 
fd, Error **errp)
 if (probe_logical_blocksize(fd, >bl.request_alignment) < 0) {
 bs->bl.request_alignment = 0;
 }
-#ifdef CONFIG_XFS
-if (s->is_xfs) {
-struct dioattr da;
-if (xfsctl(NULL, fd, XFS_IOC_DIOINFO, ) >= 0) {
-bs->bl.request_alignment = da.d_miniosz;
-/* The kernel returns wrong information for d_mem */
-/* s->buf_align = da.d_mem; */
-}
+
+#ifdef __linux__
+/*
+ * The XFS ioctl definitions are shipped in extra packages that might
+ * not always be available. Since we just need the XFS_IOC_DIOINFO ioctl
+ * here, we simply use our own definition instead:
+ */
+struct xfs_dioattr {
+uint32_t d_mem;
+uint32_t d_miniosz;
+uint32_t d_maxiosz;
+} da;
+if (ioctl(fd, _IOR('X', 30, struct xfs_dioattr), ) >= 0) {
+bs->bl.request_alignment = da.d_miniosz;
+/* The kernel returns wrong information for d_mem */
+/* s->buf_align = da.d_mem; */
 }
 #endif
 
@@ -798,12 +799,6 @@ static int raw_open_common(BlockDriverState *bs, QDict 
*options,
 #endif
 s->needs_alignment = raw_needs_alignment(bs);
 
-#ifdef CONFIG_XFS
-if (platform_test_xfs_fd(s->fd)) {
-s->is_xfs = true;
-}
-#endif
-
 bs->supported_zero_flags = BDRV_REQ_MAY_UNMAP | BDRV_REQ_NO_FALLBACK;
 if (S_ISREG(st.st_mode)) {
 /* When extending regular files, we get zeros from the OS */
diff --git a/configure b/configure
index 8ccfe51673..b66ab31834 100755
--- a/configure
+++ b/configure
@@ -291,7 +291,6 @@ EXTRA_CXXFLAGS=""
 EXTRA_LDFLAGS=""
 
 xen_ctrl_version="$default_feature"
-xfs="$default_feature"
 membarrier="$default_feature"
 vhost_kernel="$default_feature"
 vhost_net="$default_feature"
@@ -1019,10 +1018,6 @@ for opt do
   ;;
   --enable-opengl) opengl="yes"
   ;;
-  --disable-xfsctl) xfs="no"
-  ;;
-  --enable-xfsctl) xfs="yes"
-  ;;
   --disable-zlib-test)
   ;;
   --enable-guest-agent) guest_agent="yes"
@@ -1429,7 +1424,6 @@ cat << EOF
   avx512f AVX512F optimization support
   replication replication support
   opengl  opengl support
-  xfsctl  xfsctl support
   qom-cast-debug  cast debugging support
   tools   build qemu-io, qemu-nbd and qemu-img tools
   bochs   bochs image format support
@@ -2321,28 +2315,6 @@ EOF
 fi
 fi
 
-##
-# xfsctl() probe, used for file-posix.c
-if test "$xfs" != "no" ; then
-  cat > $TMPC << EOF
-#include   /* NULL */
-#include 
-int main(void)
-{
-xfsctl(NULL, 0, 0, NULL);
-return 0;
-}
-EOF
-  if compile_prog "" "" ; then
-xfs="yes"
-  else
-if test "$xfs" = "yes" ; then
-  feature_not_found "xfs" "Install xfsprogs/xfslibs devel"
-fi
-xfs=no
-  fi
-fi
-
 ##
 # plugin linker support probe
 
@@ -3454,9 +3426,6 @@ echo "CONFIG_BDRV_RO_WHITELIST=$block_drv_ro_whitelist" 

[PULL 08/15] configure, makefile: remove traces of really old files

2021-12-23 Thread Paolo Bonzini
These files have been removed for more than year in the best
case, or for more than ten years for some really old TCG files.
Remove any traces of it.

Acked-by: Richard Henderson 
Signed-off-by: Paolo Bonzini 
---
 Makefile  | 11 ---
 configure |  9 -
 2 files changed, 4 insertions(+), 16 deletions(-)

diff --git a/Makefile b/Makefile
index 74c5b46d38..06ad8a61e1 100644
--- a/Makefile
+++ b/Makefile
@@ -205,14 +205,11 @@ recurse-clean: $(addsuffix /clean, $(ROM_DIRS))
 clean: recurse-clean
-$(quiet-@)test -f build.ninja && $(NINJA) $(NINJAFLAGS) -t clean || :
-$(quiet-@)test -f build.ninja && $(NINJA) $(NINJAFLAGS) clean-ctlist 
|| :
-# avoid old build problems by removing potentially incorrect old files
-   rm -f config.mak op-i386.h opc-i386.h gen-op-i386.h op-arm.h opc-arm.h 
gen-op-arm.h
find . \( -name '*.so' -o -name '*.dll' -o -name '*.[oda]' \) -type f \
! -path ./roms/edk2/ArmPkg/Library/GccLto/liblto-aarch64.a \
! -path ./roms/edk2/ArmPkg/Library/GccLto/liblto-arm.a \
-exec rm {} +
-   rm -f TAGS cscope.* *.pod *~ */*~
-   rm -f fsdev/*.pod scsi/*.pod
+   rm -f TAGS cscope.* *~ */*~
 
 VERSION = $(shell cat $(SRC_PATH)/VERSION)
 
@@ -223,10 +220,10 @@ qemu-%.tar.bz2:
 
 distclean: clean
-$(quiet-@)test -f build.ninja && $(NINJA) $(NINJAFLAGS) -t clean -g || 
:
-   rm -f config-host.mak config-host.h* config-poison.h
+   rm -f config-host.mak config-poison.h
rm -f tests/tcg/config-*.mak
-   rm -f config-all-disas.mak config.status
-   rm -f roms/seabios/config.mak roms/vgabios/config.mak
+   rm -f config.status
+   rm -f roms/seabios/config.mak
rm -f qemu-plugins-ld.symbols qemu-plugins-ld64.symbols
rm -f *-config-target.h *-config-devices.mak *-config-devices.h
rm -rf meson-private meson-logs meson-info compile_commands.json
diff --git a/configure b/configure
index 6516ec243c..c8b32e7277 100755
--- a/configure
+++ b/configure
@@ -3665,9 +3665,6 @@ fi
 # so the build tree will be missing the link back to the new file, and
 # tests might fail. Prefer to keep the relevant files in their own
 # directory and symlink the directory instead.
-# UNLINK is used to remove symlinks from older development versions
-# that might get into the way when doing "git update" without doing
-# a "make distclean" in between.
 LINKS="Makefile"
 LINKS="$LINKS tests/tcg/Makefile.target"
 LINKS="$LINKS pc-bios/optionrom/Makefile"
@@ -3679,7 +3676,6 @@ LINKS="$LINKS tests/avocado tests/data"
 LINKS="$LINKS tests/qemu-iotests/check"
 LINKS="$LINKS python"
 LINKS="$LINKS contrib/plugins/Makefile "
-UNLINK="pc-bios/keymaps"
 for bios_file in \
 $source_path/pc-bios/*.bin \
 $source_path/pc-bios/*.elf \
@@ -3701,11 +3697,6 @@ for f in $LINKS ; do
 symlink "$source_path/$f" "$f"
 fi
 done
-for f in $UNLINK ; do
-if [ -L "$f" ]; then
-rm -f "$f"
-fi
-done
 
 (for i in $cross_cc_vars; do
   export $i
-- 
2.33.1





[PULL 03/15] user: move common-user includes to a subdirectory of {bsd, linux}-user/

2021-12-23 Thread Paolo Bonzini
Avoid polluting the compilation of common-user/ with local include files;
making an include file available to common-user/ should be a deliberate
decision in order to keep a clear interface that can be used by both
bsd-user/ and linux-user/.

Reviewed-by: Richard Henderson 
Signed-off-by: Paolo Bonzini 
---
 bsd-user/{ => include}/special-errno.h  | 0
 bsd-user/meson.build| 2 +-
 linux-user/{ => include}/host/aarch64/host-signal.h | 0
 linux-user/{ => include}/host/alpha/host-signal.h   | 0
 linux-user/{ => include}/host/arm/host-signal.h | 0
 linux-user/{ => include}/host/i386/host-signal.h| 0
 linux-user/{ => include}/host/mips/host-signal.h| 0
 linux-user/{ => include}/host/ppc/host-signal.h | 0
 linux-user/{ => include}/host/ppc64/host-signal.h   | 0
 linux-user/{ => include}/host/riscv/host-signal.h   | 0
 linux-user/{ => include}/host/s390/host-signal.h| 0
 linux-user/{ => include}/host/s390x/host-signal.h   | 0
 linux-user/{ => include}/host/sparc/host-signal.h   | 0
 linux-user/{ => include}/host/sparc64/host-signal.h | 0
 linux-user/{ => include}/host/x32/host-signal.h | 0
 linux-user/{ => include}/host/x86_64/host-signal.h  | 0
 linux-user/{ => include}/special-errno.h| 0
 linux-user/meson.build  | 4 ++--
 18 files changed, 3 insertions(+), 3 deletions(-)
 rename bsd-user/{ => include}/special-errno.h (100%)
 rename linux-user/{ => include}/host/aarch64/host-signal.h (100%)
 rename linux-user/{ => include}/host/alpha/host-signal.h (100%)
 rename linux-user/{ => include}/host/arm/host-signal.h (100%)
 rename linux-user/{ => include}/host/i386/host-signal.h (100%)
 rename linux-user/{ => include}/host/mips/host-signal.h (100%)
 rename linux-user/{ => include}/host/ppc/host-signal.h (100%)
 rename linux-user/{ => include}/host/ppc64/host-signal.h (100%)
 rename linux-user/{ => include}/host/riscv/host-signal.h (100%)
 rename linux-user/{ => include}/host/s390/host-signal.h (100%)
 rename linux-user/{ => include}/host/s390x/host-signal.h (100%)
 rename linux-user/{ => include}/host/sparc/host-signal.h (100%)
 rename linux-user/{ => include}/host/sparc64/host-signal.h (100%)
 rename linux-user/{ => include}/host/x32/host-signal.h (100%)
 rename linux-user/{ => include}/host/x86_64/host-signal.h (100%)
 rename linux-user/{ => include}/special-errno.h (100%)

diff --git a/bsd-user/special-errno.h b/bsd-user/include/special-errno.h
similarity index 100%
rename from bsd-user/special-errno.h
rename to bsd-user/include/special-errno.h
diff --git a/bsd-user/meson.build b/bsd-user/meson.build
index 9fcb80c3fa..8380fa44c2 100644
--- a/bsd-user/meson.build
+++ b/bsd-user/meson.build
@@ -4,7 +4,7 @@ endif
 
 bsd_user_ss = ss.source_set()
 
-common_user_inc += include_directories('.')
+common_user_inc += include_directories('include')
 
 bsd_user_ss.add(files(
   'bsdload.c',
diff --git a/linux-user/host/aarch64/host-signal.h 
b/linux-user/include/host/aarch64/host-signal.h
similarity index 100%
rename from linux-user/host/aarch64/host-signal.h
rename to linux-user/include/host/aarch64/host-signal.h
diff --git a/linux-user/host/alpha/host-signal.h 
b/linux-user/include/host/alpha/host-signal.h
similarity index 100%
rename from linux-user/host/alpha/host-signal.h
rename to linux-user/include/host/alpha/host-signal.h
diff --git a/linux-user/host/arm/host-signal.h 
b/linux-user/include/host/arm/host-signal.h
similarity index 100%
rename from linux-user/host/arm/host-signal.h
rename to linux-user/include/host/arm/host-signal.h
diff --git a/linux-user/host/i386/host-signal.h 
b/linux-user/include/host/i386/host-signal.h
similarity index 100%
rename from linux-user/host/i386/host-signal.h
rename to linux-user/include/host/i386/host-signal.h
diff --git a/linux-user/host/mips/host-signal.h 
b/linux-user/include/host/mips/host-signal.h
similarity index 100%
rename from linux-user/host/mips/host-signal.h
rename to linux-user/include/host/mips/host-signal.h
diff --git a/linux-user/host/ppc/host-signal.h 
b/linux-user/include/host/ppc/host-signal.h
similarity index 100%
rename from linux-user/host/ppc/host-signal.h
rename to linux-user/include/host/ppc/host-signal.h
diff --git a/linux-user/host/ppc64/host-signal.h 
b/linux-user/include/host/ppc64/host-signal.h
similarity index 100%
rename from linux-user/host/ppc64/host-signal.h
rename to linux-user/include/host/ppc64/host-signal.h
diff --git a/linux-user/host/riscv/host-signal.h 
b/linux-user/include/host/riscv/host-signal.h
similarity index 100%
rename from linux-user/host/riscv/host-signal.h
rename to linux-user/include/host/riscv/host-signal.h
diff --git a/linux-user/host/s390/host-signal.h 
b/linux-user/include/host/s390/host-signal.h
similarity index 100%
rename from linux-user/host/s390/host-signal.h
rename to linux-user/include/host/s390/host-signal.h
diff --git

[PULL 15/15] KVM: x86: ignore interrupt_bitmap field of KVM_GET/SET_SREGS

2021-12-23 Thread Paolo Bonzini
This is unnecessary, because the interrupt would be retrieved and queued
anyway by KVM_GET_VCPU_EVENTS and KVM_SET_VCPU_EVENTS respectively,
and it makes the flow more similar to the one for KVM_GET/SET_SREGS2.

Signed-off-by: Paolo Bonzini 
---
 target/i386/kvm/kvm.c | 24 +---
 1 file changed, 9 insertions(+), 15 deletions(-)

diff --git a/target/i386/kvm/kvm.c b/target/i386/kvm/kvm.c
index d81745620b..2c8feb4a6f 100644
--- a/target/i386/kvm/kvm.c
+++ b/target/i386/kvm/kvm.c
@@ -2607,11 +2607,11 @@ static int kvm_put_sregs(X86CPU *cpu)
 CPUX86State *env = >env;
 struct kvm_sregs sregs;
 
+/*
+ * The interrupt_bitmap is ignored because KVM_SET_SREGS is
+ * always followed by KVM_SET_VCPU_EVENTS.
+ */
 memset(sregs.interrupt_bitmap, 0, sizeof(sregs.interrupt_bitmap));
-if (env->interrupt_injected >= 0) {
-sregs.interrupt_bitmap[env->interrupt_injected / 64] |=
-(uint64_t)1 << (env->interrupt_injected % 64);
-}
 
 if ((env->eflags & VM_MASK)) {
 set_v8086_seg(, >segs[R_CS]);
@@ -3341,23 +3341,17 @@ static int kvm_get_sregs(X86CPU *cpu)
 {
 CPUX86State *env = >env;
 struct kvm_sregs sregs;
-int bit, i, ret;
+int ret;
 
 ret = kvm_vcpu_ioctl(CPU(cpu), KVM_GET_SREGS, );
 if (ret < 0) {
 return ret;
 }
 
-/* There can only be one pending IRQ set in the bitmap at a time, so try
-   to find it and save its number instead (-1 for none). */
-env->interrupt_injected = -1;
-for (i = 0; i < ARRAY_SIZE(sregs.interrupt_bitmap); i++) {
-if (sregs.interrupt_bitmap[i]) {
-bit = ctz64(sregs.interrupt_bitmap[i]);
-env->interrupt_injected = i * 64 + bit;
-break;
-}
-}
+/*
+ * The interrupt_bitmap is ignored because KVM_GET_SREGS is
+ * always preceded by KVM_GET_VCPU_EVENTS.
+ */
 
 get_seg(>segs[R_CS], );
 get_seg(>segs[R_DS], );
-- 
2.33.1




[PULL 04/15] meson: cleanup common-user/ build

2021-12-23 Thread Paolo Bonzini
It is not necessary to have a separate static_library just for common_user
files; using the one that already covers the rest of common_ss is enough
unless you need to reuse some source files between emulators and tests.
Just place common files for all user-mode emulators in common_ss,
similar to what is already done for softmmu_ss in full system emulators.

The only disadvantage is that the include_directories under bsd-user/include/
and linux-user/include/ are now enabled for all targets rather than only
user mode emulators.  This however is not different from how include/sysemu/
is available when building user mode emulators.

Tested-by: Richard Henderson 
Reviewed-by: Richard Henderson 
Signed-off-by: Paolo Bonzini 
---
 common-user/meson.build |  2 +-
 meson.build | 13 +
 2 files changed, 2 insertions(+), 13 deletions(-)

diff --git a/common-user/meson.build b/common-user/meson.build
index 5cb42bc664..26212dda5c 100644
--- a/common-user/meson.build
+++ b/common-user/meson.build
@@ -1,6 +1,6 @@
 common_user_inc += include_directories('host/' / host_arch)
 
-common_user_ss.add(files(
+user_ss.add(files(
   'safe-syscall.S',
   'safe-syscall-error.c',
 ))
diff --git a/meson.build b/meson.build
index b0af02b805..879628ab68 100644
--- a/meson.build
+++ b/meson.build
@@ -2377,7 +2377,6 @@ blockdev_ss = ss.source_set()
 block_ss = ss.source_set()
 chardev_ss = ss.source_set()
 common_ss = ss.source_set()
-common_user_ss = ss.source_set()
 crypto_ss = ss.source_set()
 hwcore_ss = ss.source_set()
 io_ss = ss.source_set()
@@ -2629,17 +2628,6 @@ subdir('common-user')
 subdir('bsd-user')
 subdir('linux-user')
 
-common_user_ss = common_user_ss.apply(config_all, strict: false)
-common_user = static_library('common-user',
- sources: common_user_ss.sources(),
- dependencies: common_user_ss.dependencies(),
- include_directories: common_user_inc,
- name_suffix: 'fa',
- build_by_default: false)
-common_user = declare_dependency(link_with: common_user)
-
-user_ss.add(common_user)
-
 # needed for fuzzing binaries
 subdir('tests/qtest/libqos')
 subdir('tests/qtest/fuzz')
@@ -2857,6 +2845,7 @@ common_all = common_ss.apply(config_all, strict: false)
 common_all = static_library('common',
 build_by_default: false,
 sources: common_all.sources() + genh,
+include_directories: common_user_inc,
 implicit_include_directories: false,
 dependencies: common_all.dependencies(),
 name_suffix: 'fa')
-- 
2.33.1





[PULL 07/15] configure: do not set bsd_user/linux_user early

2021-12-23 Thread Paolo Bonzini
Similar to other optional features, leave the variables empty and compute
the actual value later.  Use the existence of include or source directories
to detect whether an OS or CPU supports respectively bsd-user and linux-user.

For now, BSD user-mode emulation is buildable even on TCI-only
architectures.  This probably will change once safe signals are
brought over from linux-user.

Reviewed-by: Richard Henderson 
Signed-off-by: Paolo Bonzini 
---
 configure | 28 +---
 1 file changed, 17 insertions(+), 11 deletions(-)

diff --git a/configure b/configure
index 0306f0c8bc..6516ec243c 100755
--- a/configure
+++ b/configure
@@ -320,8 +320,8 @@ linux="no"
 solaris="no"
 profiler="no"
 softmmu="yes"
-linux_user="no"
-bsd_user="no"
+linux_user=""
+bsd_user=""
 pkgversion=""
 pie=""
 qom_cast_debug="yes"
@@ -538,7 +538,6 @@ gnu/kfreebsd)
 ;;
 freebsd)
   bsd="yes"
-  bsd_user="yes"
   make="${MAKE-gmake}"
   # needed for kinfo_getvmmap(3) in libutil.h
 ;;
@@ -583,7 +582,6 @@ haiku)
 ;;
 linux)
   linux="yes"
-  linux_user="yes"
   vhost_user=${default_feature:-yes}
 ;;
 esac
@@ -1257,18 +1255,26 @@ if eval test -z "\${cross_cc_$cpu}"; then
 cross_cc_vars="$cross_cc_vars cross_cc_${cpu}"
 fi
 
-# For user-mode emulation the host arch has to be one we explicitly
-# support, even if we're using TCI.
-if [ "$ARCH" = "unknown" ]; then
-  bsd_user="no"
-  linux_user="no"
-fi
-
 default_target_list=""
 deprecated_targets_list=ppc64abi32-linux-user
 deprecated_features=""
 mak_wilds=""
 
+if [ "$linux_user" != no ]; then
+if [ "$targetos" = linux ] && [ -d $source_path/linux-user/host/$cpu ]; 
then
+linux_user=yes
+elif [ "$linux_user" = yes ]; then
+error_exit "linux-user not supported on this architecture"
+fi
+fi
+if [ "$bsd_user" != no ]; then
+if [ "$bsd_user" = "" ]; then
+test $targetos = freebsd && bsd_user=yes
+fi
+if [ "$bsd_user" = yes ] && ! [ -d $source_path/bsd-user/$targetos ]; then
+error_exit "bsd-user not supported on this host OS"
+fi
+fi
 if [ "$softmmu" = "yes" ]; then
 mak_wilds="${mak_wilds} $source_path/configs/targets/*-softmmu.mak"
 fi
-- 
2.33.1





[PULL 01/15] docker: include bison in debian-tricore-cross

2021-12-23 Thread Paolo Bonzini
Binutils sometimes fail to build if bison is not installed:

  /bin/sh ./ylwrap `test -f arparse.y || echo ./`arparse.y y.tab.c arparse.c 
y.tab.h arparse.h y.output arparse.output --  -d
  ./ylwrap: 109: ./ylwrap: -d: not found

(the correct invocation of ylwrap would have "bison -d" after the double
dash).  Work around by installing it in the container.

Cc: Alex Bennée 
Resolves: https://gitlab.com/qemu-project/qemu/-/issues/596
Reviewed-by: Philippe Mathieu-Daudé 
Reviewed-by: Richard Henderson 
Signed-off-by: Paolo Bonzini 
---
 tests/docker/dockerfiles/debian-tricore-cross.docker | 1 +
 1 file changed, 1 insertion(+)

diff --git a/tests/docker/dockerfiles/debian-tricore-cross.docker 
b/tests/docker/dockerfiles/debian-tricore-cross.docker
index d8df2c6117..3f6b55562c 100644
--- a/tests/docker/dockerfiles/debian-tricore-cross.docker
+++ b/tests/docker/dockerfiles/debian-tricore-cross.docker
@@ -16,6 +16,7 @@ MAINTAINER Philippe Mathieu-Daudé 
 RUN apt update && \
 DEBIAN_FRONTEND=noninteractive apt install -yy eatmydata && \
 DEBIAN_FRONTEND=noninteractive eatmydata apt install -yy \
+   bison \
bzip2 \
ca-certificates \
ccache \
-- 
2.33.1





[PULL 14/15] KVM: use KVM_{GET|SET}_SREGS2 when supported.

2021-12-23 Thread Paolo Bonzini
From: Maxim Levitsky 

This allows to make PDPTRs part of the migration
stream and thus not reload them after migration which
is against X86 spec.

Signed-off-by: Maxim Levitsky 
Message-Id: <20211101132300.192584-2-mlevi...@redhat.com>
Signed-off-by: Paolo Bonzini 
---
 target/i386/cpu.h |   3 ++
 target/i386/kvm/kvm.c | 108 +-
 target/i386/machine.c |  29 
 3 files changed, 138 insertions(+), 2 deletions(-)

diff --git a/target/i386/cpu.h b/target/i386/cpu.h
index 04f2b790c9..9911d7c871 100644
--- a/target/i386/cpu.h
+++ b/target/i386/cpu.h
@@ -1455,6 +1455,9 @@ typedef struct CPUX86State {
 SegmentCache idt; /* only base and limit are used */
 
 target_ulong cr[5]; /* NOTE: cr1 is unused */
+
+bool pdptrs_valid;
+uint64_t pdptrs[4];
 int32_t a20_mask;
 
 BNDReg bnd_regs[4];
diff --git a/target/i386/kvm/kvm.c b/target/i386/kvm/kvm.c
index 13f8e30c2a..d81745620b 100644
--- a/target/i386/kvm/kvm.c
+++ b/target/i386/kvm/kvm.c
@@ -124,6 +124,7 @@ static uint32_t num_architectural_pmu_fixed_counters;
 static int has_xsave;
 static int has_xcrs;
 static int has_pit_state2;
+static int has_sregs2;
 static int has_exception_payload;
 
 static bool has_msr_mcg_ext_ctl;
@@ -2324,6 +2325,7 @@ int kvm_arch_init(MachineState *ms, KVMState *s)
 has_xsave = kvm_check_extension(s, KVM_CAP_XSAVE);
 has_xcrs = kvm_check_extension(s, KVM_CAP_XCRS);
 has_pit_state2 = kvm_check_extension(s, KVM_CAP_PIT_STATE2);
+has_sregs2 = kvm_check_extension(s, KVM_CAP_SREGS2) > 0;
 
 hv_vpindex_settable = kvm_check_extension(s, KVM_CAP_HYPERV_VP_INDEX);
 
@@ -2650,6 +2652,61 @@ static int kvm_put_sregs(X86CPU *cpu)
 return kvm_vcpu_ioctl(CPU(cpu), KVM_SET_SREGS, );
 }
 
+static int kvm_put_sregs2(X86CPU *cpu)
+{
+CPUX86State *env = >env;
+struct kvm_sregs2 sregs;
+int i;
+
+sregs.flags = 0;
+
+if ((env->eflags & VM_MASK)) {
+set_v8086_seg(, >segs[R_CS]);
+set_v8086_seg(, >segs[R_DS]);
+set_v8086_seg(, >segs[R_ES]);
+set_v8086_seg(, >segs[R_FS]);
+set_v8086_seg(, >segs[R_GS]);
+set_v8086_seg(, >segs[R_SS]);
+} else {
+set_seg(, >segs[R_CS]);
+set_seg(, >segs[R_DS]);
+set_seg(, >segs[R_ES]);
+set_seg(, >segs[R_FS]);
+set_seg(, >segs[R_GS]);
+set_seg(, >segs[R_SS]);
+}
+
+set_seg(, >tr);
+set_seg(, >ldt);
+
+sregs.idt.limit = env->idt.limit;
+sregs.idt.base = env->idt.base;
+memset(sregs.idt.padding, 0, sizeof sregs.idt.padding);
+sregs.gdt.limit = env->gdt.limit;
+sregs.gdt.base = env->gdt.base;
+memset(sregs.gdt.padding, 0, sizeof sregs.gdt.padding);
+
+sregs.cr0 = env->cr[0];
+sregs.cr2 = env->cr[2];
+sregs.cr3 = env->cr[3];
+sregs.cr4 = env->cr[4];
+
+sregs.cr8 = cpu_get_apic_tpr(cpu->apic_state);
+sregs.apic_base = cpu_get_apic_base(cpu->apic_state);
+
+sregs.efer = env->efer;
+
+if (env->pdptrs_valid) {
+for (i = 0; i < 4; i++) {
+sregs.pdptrs[i] = env->pdptrs[i];
+}
+sregs.flags |= KVM_SREGS2_FLAGS_PDPTRS_VALID;
+}
+
+return kvm_vcpu_ioctl(CPU(cpu), KVM_SET_SREGS2, );
+}
+
+
 static void kvm_msr_buf_reset(X86CPU *cpu)
 {
 memset(cpu->kvm_msr_buf, 0, MSR_BUF_SIZE);
@@ -3330,6 +3387,53 @@ static int kvm_get_sregs(X86CPU *cpu)
 return 0;
 }
 
+static int kvm_get_sregs2(X86CPU *cpu)
+{
+CPUX86State *env = >env;
+struct kvm_sregs2 sregs;
+int i, ret;
+
+ret = kvm_vcpu_ioctl(CPU(cpu), KVM_GET_SREGS2, );
+if (ret < 0) {
+return ret;
+}
+
+get_seg(>segs[R_CS], );
+get_seg(>segs[R_DS], );
+get_seg(>segs[R_ES], );
+get_seg(>segs[R_FS], );
+get_seg(>segs[R_GS], );
+get_seg(>segs[R_SS], );
+
+get_seg(>tr, );
+get_seg(>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;
+
+env->cr[0] = sregs.cr0;
+env->cr[2] = sregs.cr2;
+env->cr[3] = sregs.cr3;
+env->cr[4] = sregs.cr4;
+
+env->efer = sregs.efer;
+
+env->pdptrs_valid = sregs.flags & KVM_SREGS2_FLAGS_PDPTRS_VALID;
+
+if (env->pdptrs_valid) {
+for (i = 0; i < 4; i++) {
+env->pdptrs[i] = sregs.pdptrs[i];
+}
+}
+
+/* changes to apic base and cr8/tpr are read back via kvm_arch_post_run */
+x86_update_hflags(env);
+
+return 0;
+}
+
 static int kvm_get_msrs(X86CPU *cpu)
 {
 CPUX86State *env = >env;
@@ -4173,7 +4277,7 @@ int kvm_arch_put_registers(CPUState *cpu, int level)
 assert(cpu_is_stopped(cpu) || qemu_cpu_is_self(cpu));
 
 /* must be before kvm_put_nested_state so that EFER.SVME is set */
-ret = kvm_put_sregs(x86_cpu);
+

[PULL 00/15] Build system and KVM changes for 2021-12-23

2021-12-23 Thread Paolo Bonzini
The following changes since commit 2bf40d0841b942e7ba12953d515e62a436f0af84:

  Merge tag 'pull-user-20211220' of https://gitlab.com/rth7680/qemu into 
staging (2021-12-20 13:20:07 -0800)

are available in the Git repository at:

  https://gitlab.com/bonzini/qemu.git tags/for-upstream

for you to fetch changes up to c139f026aa685e6b27a5a8ecb3272d4ed1700312:

  KVM: x86: ignore interrupt_bitmap field of KVM_GET/SET_SREGS (2021-12-23 
10:05:28 +0100)


* configure and meson cleanups
* KVM_GET/SET_SREGS2 support for x86
* fix occasional container build failures for debian-tricore-cross


Maxim Levitsky (1):
  KVM: use KVM_{GET|SET}_SREGS2 when supported.

Paolo Bonzini (13):
  docker: include bison in debian-tricore-cross
  meson: reuse common_user_inc when building files specific to user-mode 
emulators
  user: move common-user includes to a subdirectory of {bsd,linux}-user/
  meson: cleanup common-user/ build
  configure: simplify creation of plugin symbol list
  configure: do not set bsd_user/linux_user early
  configure, makefile: remove traces of really old files
  configure: parse --enable/--disable-strip automatically, flip default
  configure: move non-command-line variables away from command-line parsing 
section
  meson: build contrib/ executables after generated headers
  configure, meson: move config-poison.h to meson
  meson: add comments in the target-specific flags section
  KVM: x86: ignore interrupt_bitmap field of KVM_GET/SET_SREGS

Thomas Huth (1):
  block/file-posix: Simplify the XFS_IOC_DIOINFO handling

 Makefile   |  11 +-
 block/file-posix.c |  37 ++---
 bsd-user/{ => include}/special-errno.h |   0
 bsd-user/meson.build   |   2 +-
 common-user/meson.build|   2 +-
 configure  | 182 +++--
 contrib/elf2dmp/meson.build|   2 +-
 contrib/ivshmem-client/meson.build |   2 +-
 contrib/ivshmem-server/meson.build |   2 +-
 contrib/rdmacm-mux/meson.build |   2 +-
 .../{ => include}/host/aarch64/host-signal.h   |   0
 linux-user/{ => include}/host/alpha/host-signal.h  |   0
 linux-user/{ => include}/host/arm/host-signal.h|   0
 linux-user/{ => include}/host/i386/host-signal.h   |   0
 linux-user/{ => include}/host/mips/host-signal.h   |   0
 linux-user/{ => include}/host/ppc/host-signal.h|   0
 linux-user/{ => include}/host/ppc64/host-signal.h  |   0
 linux-user/{ => include}/host/riscv/host-signal.h  |   0
 linux-user/{ => include}/host/s390/host-signal.h   |   0
 linux-user/{ => include}/host/s390x/host-signal.h  |   0
 linux-user/{ => include}/host/sparc/host-signal.h  |   0
 .../{ => include}/host/sparc64/host-signal.h   |   0
 linux-user/{ => include}/host/x32/host-signal.h|   0
 linux-user/{ => include}/host/x86_64/host-signal.h |   0
 linux-user/{ => include}/special-errno.h   |   0
 linux-user/meson.build |   4 +-
 meson.build|  33 ++--
 pc-bios/s390-ccw/Makefile  |   2 -
 plugins/meson.build|  11 +-
 scripts/make-config-poison.sh  |  16 ++
 scripts/meson-buildoptions.py  |  21 ++-
 scripts/meson-buildoptions.sh  |   3 +
 target/i386/cpu.h  |   3 +
 target/i386/kvm/kvm.c  | 130 +--
 target/i386/machine.c  |  29 
 .../docker/dockerfiles/debian-tricore-cross.docker |   1 +
 36 files changed, 259 insertions(+), 236 deletions(-)
 rename bsd-user/{ => include}/special-errno.h (100%)
 rename linux-user/{ => include}/host/aarch64/host-signal.h (100%)
 rename linux-user/{ => include}/host/alpha/host-signal.h (100%)
 rename linux-user/{ => include}/host/arm/host-signal.h (100%)
 rename linux-user/{ => include}/host/i386/host-signal.h (100%)
 rename linux-user/{ => include}/host/mips/host-signal.h (100%)
 rename linux-user/{ => include}/host/ppc/host-signal.h (100%)
 rename linux-user/{ => include}/host/ppc64/host-signal.h (100%)
 rename linux-user/{ => include}/host/riscv/host-signal.h (100%)
 rename linux-user/{ => include}/host/s390/host-signal.h (100%)
 rename linux-user/{ => include}/host/s390x/host-signal.h (100%)
 rename linux-user/{ => include}/host/sparc/host-signal.h (100%)
 rename linux-user/{ => include}/host/sparc64/host-signal.h (100%)
 rename linux-user/{ => include}/host/x32/host-signal.h (100%)
 rename linux-user/{ => include}/hos

[PULL 02/15] meson: reuse common_user_inc when building files specific to user-mode emulators

2021-12-23 Thread Paolo Bonzini
Reviewed-by: Richard Henderson 
Signed-off-by: Paolo Bonzini 
---
 meson.build | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/meson.build b/meson.build
index f45ecf31bd..b0af02b805 100644
--- a/meson.build
+++ b/meson.build
@@ -2897,6 +2897,7 @@ foreach target : target_dirs
   else
 abi = config_target['TARGET_ABI_DIR']
 target_type='user'
+target_inc += common_user_inc
 qemu_target_name = 'qemu-' + target_name
 if target_base_arch in target_user_arch
   t = target_user_arch[target_base_arch].apply(config_target, strict: 
false)
@@ -2905,7 +2906,6 @@ foreach target : target_dirs
 endif
 if 'CONFIG_LINUX_USER' in config_target
   base_dir = 'linux-user'
-  target_inc += include_directories('linux-user/host/' / host_arch)
 endif
 if 'CONFIG_BSD_USER' in config_target
   base_dir = 'bsd-user'
-- 
2.33.1





[PULL 1/1] build: use "meson test" as the test harness

2021-12-23 Thread Paolo Bonzini
"meson test" starting with version 0.57 is just as capable and easy to
use as QEMU's own TAP driver.  All existing options for "make check"
work.  The only required code change involves how to mark "slow" tests;
they need to belong to an additional "slow" suite.

The rules for .tap output are replaced by JUnit XML; GitLab is able
to parse that output and present it in the CI pipeline report.

Signed-off-by: Paolo Bonzini 
---
 Makefile  |   3 +-
 meson.build   |   5 +-
 scripts/mtest2make.py | 112 +
 scripts/tap-driver.pl | 379 --
 scripts/tap-merge.pl  | 111 -
 tests/fp/meson.build  |   2 +-
 6 files changed, 51 insertions(+), 561 deletions(-)
 delete mode 100755 scripts/tap-driver.pl
 delete mode 100755 scripts/tap-merge.pl

diff --git a/Makefile b/Makefile
index 74c5b46d38..5d66c35ea5 100644
--- a/Makefile
+++ b/Makefile
@@ -145,7 +145,8 @@ NINJAFLAGS = $(if $V,-v) $(if $(MAKE.n), -n) $(if 
$(MAKE.k), -k0) \
 $(filter-out -j, $(lastword -j1 $(filter -l% -j%, $(MAKEFLAGS \
 
 ninja-cmd-goals = $(or $(MAKECMDGOALS), all)
-ninja-cmd-goals += $(foreach t, $(.tests), $(.test.deps.$t))
+ninja-cmd-goals += $(foreach t, $(.check.build-suites), $(.check-$t.deps))
+ninja-cmd-goals += $(foreach t, $(.bench.build-suites), $(.bench-$t.deps))
 
 makefile-targets := build.ninja ctags TAGS cscope dist clean uninstall
 # "ninja -t targets" also lists all prerequisites.  If build system
diff --git a/meson.build b/meson.build
index f45ecf31bd..f0f1d5ba9d 100644
--- a/meson.build
+++ b/meson.build
@@ -1,8 +1,11 @@
 project('qemu', ['c'], meson_version: '>=0.58.2',
 default_options: ['warning_level=1', 'c_std=gnu11', 'cpp_std=gnu++11', 
'b_colorout=auto',
-  'b_staticpic=false'],
+  'b_staticpic=false', 'stdsplit=false'],
 version: files('VERSION'))
 
+add_test_setup('quick', exclude_suites: 'slow', is_default: true)
+add_test_setup('slow', env: ['G_TEST_SLOW=1', 'SPEED=slow'])
+
 not_found = dependency('', required: false)
 keyval = import('keyval')
 ss = import('sourceset')
diff --git a/scripts/mtest2make.py b/scripts/mtest2make.py
index 02c0453e67..7067bdadf5 100644
--- a/scripts/mtest2make.py
+++ b/scripts/mtest2make.py
@@ -13,101 +13,79 @@
 
 class Suite(object):
 def __init__(self):
-self.tests = list()
-self.slow_tests = list()
-self.executables = set()
+self.deps = set()
+self.speeds = ['quick']
+
+def names(self, base):
+return [base if speed == 'quick' else f'{base}-{speed}' for speed in 
self.speeds]
+
 
 print('''
 SPEED = quick
 
-# $1 = environment, $2 = test command, $3 = test name, $4 = dir
-.test-human-tap = $1 $(if $4,(cd $4 && $2),$2) -m $(SPEED) < /dev/null | 
./scripts/tap-driver.pl --test-name="$3" $(if $(V),,--show-failures-only)
-.test-human-exitcode = $1 $(PYTHON) scripts/test-driver.py $(if $4,-C$4) $(if 
$(V),--verbose) -- $2 < /dev/null
-.test-tap-tap = $1 $(if $4,(cd $4 && $2),$2) < /dev/null | sed "s/^[a-z][a-z]* 
[0-9]*/& $3/" || true
-.test-tap-exitcode = printf "%s\\n" 1..1 "`$1 $(if $4,(cd $4 && $2),$2) < 
/dev/null > /dev/null || echo "not "`ok 1 $3"
-.test.human-print = echo $(if $(V),'$1 $2','Running test $3') &&
-.test.env = MALLOC_PERTURB_=$${MALLOC_PERTURB_:-$$(( $${RANDOM:-0} % 255 + 1))}
+.speed.quick = $(foreach s,$(sort $(filter-out %-slow, $1)), --suite $s)
+.speed.slow = $(foreach s,$(sort $1), --suite $s)
 
-# $1 = test name, $2 = test target (human or tap)
-.test.run = $(call 
.test.$2-print,$(.test.env.$1),$(.test.cmd.$1),$(.test.name.$1)) $(call 
.test-$2-$(.test.driver.$1),$(.test.env.$1),$(.test.cmd.$1),$(.test.name.$1),$(.test.dir.$1))
+.mtestargs = --no-rebuild -t 0
+ifneq ($(SPEED), quick)
+.mtestargs += --setup $(SPEED)
+endif
+.mtestargs += $(subst -j,--num-processes , $(filter-out -j, $(lastword -j1 
$(filter -j%, $(MAKEFLAGS)
 
-.test.output-format = human
-''')
+.check.mtestargs = $(MTESTARGS) $(.mtestargs) $(if 
$(V),--verbose,--print-errorlogs)
+.bench.mtestargs = $(MTESTARGS) $(.mtestargs) --benchmark --verbose''')
 
 introspect = json.load(sys.stdin)
-i = 0
 
 def process_tests(test, targets, suites):
-global i
-env = ' '.join(('%s=%s' % (shlex.quote(k), shlex.quote(v))
-for k, v in test['env'].items()))
 executable = test['cmd'][0]
 try:
 executable = os.path.relpath(executable)
 except:
 pass
-if test['workdir'] is not None:
-try:
-test['cmd'][0] = os.path.relpath(executable, test['workdir'])
-except:
-test['cmd'][0] = executable
-else:
-test['cmd'][0] = executable
-cmd = ' '.join((shlex.quote(x) for x in test['cmd']))
-driver = test['protocol'] if 'protocol' in te

[PULL 0/1] "make check" switch to meson test harness

2021-12-23 Thread Paolo Bonzini
The following changes since commit 2bf40d0841b942e7ba12953d515e62a436f0af84:

  Merge tag 'pull-user-20211220' of https://gitlab.com/rth7680/qemu into 
staging (2021-12-20 13:20:07 -0800)

are available in the Git repository at:

  https://gitlab.com/bonzini/qemu.git tags/for-upstream-mtest

for you to fetch changes up to 3d2f73ef75e25ba850aff4fcccb36d50137afd0f:

  build: use "meson test" as the test harness (2021-12-23 10:06:19 +0100)


Replace tap-driver.pl with "meson test".

--------
Paolo Bonzini (1):
  build: use "meson test" as the test harness

 Makefile  |   3 +-
 meson.build   |   5 +-
 scripts/mtest2make.py | 112 ++-
 scripts/tap-driver.pl | 379 --
 scripts/tap-merge.pl  | 111 ---
 tests/fp/meson.build  |   2 +-
 6 files changed, 51 insertions(+), 561 deletions(-)
 delete mode 100755 scripts/tap-driver.pl
 delete mode 100755 scripts/tap-merge.pl
-- 
2.33.1




Re: [PATCH 3/3] meson: generate trace points for qmp commands

2021-12-22 Thread Paolo Bonzini
Il mar 21 dic 2021, 20:35 Vladimir Sementsov-Ogievskiy <
vsement...@virtuozzo.com> ha scritto:

--- a/trace/meson.build
+++ b/trace/meson.build
@@ -2,10 +2,14 @@
 specific_ss.add(files('control-target.c'))

 trace_events_files = []
-foreach dir : [ '.' ] + trace_events_subdirs
-  trace_events_file = meson.project_source_root() / dir / 'trace-events'
+foreach path : [ '.' ] + trace_events_subdirs + qapi_trace_events
+  if path.contains('trace-events')
+trace_events_file = meson.project_build_root() / 'qapi' / path



Just using "trace_events_file = 'qapi' / path" might work, since the build
is nonrecursive.

If it doesn't, use the custom target object, possibly indexing it as
ct[index]. You can use a dictionary to store the custom targets and find
them from the "path" variable.

Paolo


>
>


Re: [PATCH 3/3] meson: cleanup common-user/ build

2021-12-22 Thread Paolo Bonzini
Il mar 21 dic 2021, 21:32 Richard Henderson 
ha scritto:

> On 12/21/21 8:33 AM, Paolo Bonzini wrote:
> > Do not go through a static_library, which is only necessary in order to
> reuse
> > some source files between emulators and tests.
>
> That's not true, is it.  Anyway, you're moving the file to a different
> static_library.  I
> though I had tried this myself, but I don't remember the details now.
>

Right, I will change the commit message to "a static_library just for
common_user files, since the one that covers all of common_ss is enough".

Paolo


>
>
> Tested-by: Richard Henderson 
> Reviewed-by: Richard Henderson 
>
>
> r~
>
>


[PATCH 2/3] user: move common-user includes to a subdirectory of {bsd, linux}-user/

2021-12-21 Thread Paolo Bonzini
Avoid polluting the compilation of common-user/ with local include files;
making an include file available to common-user/ should be a deliberate
decision in order to keep a clear interface that can be used by both
bsd-user/ and linux-user/.

Signed-off-by: Paolo Bonzini 
---
 bsd-user/{ => include}/special-errno.h  | 0
 bsd-user/meson.build| 2 +-
 linux-user/{ => include}/host/aarch64/host-signal.h | 0
 linux-user/{ => include}/host/alpha/host-signal.h   | 0
 linux-user/{ => include}/host/arm/host-signal.h | 0
 linux-user/{ => include}/host/i386/host-signal.h| 0
 linux-user/{ => include}/host/mips/host-signal.h| 0
 linux-user/{ => include}/host/ppc/host-signal.h | 0
 linux-user/{ => include}/host/ppc64/host-signal.h   | 0
 linux-user/{ => include}/host/riscv/host-signal.h   | 0
 linux-user/{ => include}/host/s390/host-signal.h| 0
 linux-user/{ => include}/host/s390x/host-signal.h   | 0
 linux-user/{ => include}/host/sparc/host-signal.h   | 0
 linux-user/{ => include}/host/sparc64/host-signal.h | 0
 linux-user/{ => include}/host/x32/host-signal.h | 0
 linux-user/{ => include}/host/x86_64/host-signal.h  | 0
 linux-user/{ => include}/special-errno.h| 0
 linux-user/meson.build  | 4 ++--
 18 files changed, 3 insertions(+), 3 deletions(-)
 rename bsd-user/{ => include}/special-errno.h (100%)
 rename linux-user/{ => include}/host/aarch64/host-signal.h (100%)
 rename linux-user/{ => include}/host/alpha/host-signal.h (100%)
 rename linux-user/{ => include}/host/arm/host-signal.h (100%)
 rename linux-user/{ => include}/host/i386/host-signal.h (100%)
 rename linux-user/{ => include}/host/mips/host-signal.h (100%)
 rename linux-user/{ => include}/host/ppc/host-signal.h (100%)
 rename linux-user/{ => include}/host/ppc64/host-signal.h (100%)
 rename linux-user/{ => include}/host/riscv/host-signal.h (100%)
 rename linux-user/{ => include}/host/s390/host-signal.h (100%)
 rename linux-user/{ => include}/host/s390x/host-signal.h (100%)
 rename linux-user/{ => include}/host/sparc/host-signal.h (100%)
 rename linux-user/{ => include}/host/sparc64/host-signal.h (100%)
 rename linux-user/{ => include}/host/x32/host-signal.h (100%)
 rename linux-user/{ => include}/host/x86_64/host-signal.h (100%)
 rename linux-user/{ => include}/special-errno.h (100%)

diff --git a/bsd-user/special-errno.h b/bsd-user/include/special-errno.h
similarity index 100%
rename from bsd-user/special-errno.h
rename to bsd-user/include/special-errno.h
diff --git a/bsd-user/meson.build b/bsd-user/meson.build
index 9fcb80c3fa..8380fa44c2 100644
--- a/bsd-user/meson.build
+++ b/bsd-user/meson.build
@@ -4,7 +4,7 @@ endif
 
 bsd_user_ss = ss.source_set()
 
-common_user_inc += include_directories('.')
+common_user_inc += include_directories('include')
 
 bsd_user_ss.add(files(
   'bsdload.c',
diff --git a/linux-user/host/aarch64/host-signal.h 
b/linux-user/include/host/aarch64/host-signal.h
similarity index 100%
rename from linux-user/host/aarch64/host-signal.h
rename to linux-user/include/host/aarch64/host-signal.h
diff --git a/linux-user/host/alpha/host-signal.h 
b/linux-user/include/host/alpha/host-signal.h
similarity index 100%
rename from linux-user/host/alpha/host-signal.h
rename to linux-user/include/host/alpha/host-signal.h
diff --git a/linux-user/host/arm/host-signal.h 
b/linux-user/include/host/arm/host-signal.h
similarity index 100%
rename from linux-user/host/arm/host-signal.h
rename to linux-user/include/host/arm/host-signal.h
diff --git a/linux-user/host/i386/host-signal.h 
b/linux-user/include/host/i386/host-signal.h
similarity index 100%
rename from linux-user/host/i386/host-signal.h
rename to linux-user/include/host/i386/host-signal.h
diff --git a/linux-user/host/mips/host-signal.h 
b/linux-user/include/host/mips/host-signal.h
similarity index 100%
rename from linux-user/host/mips/host-signal.h
rename to linux-user/include/host/mips/host-signal.h
diff --git a/linux-user/host/ppc/host-signal.h 
b/linux-user/include/host/ppc/host-signal.h
similarity index 100%
rename from linux-user/host/ppc/host-signal.h
rename to linux-user/include/host/ppc/host-signal.h
diff --git a/linux-user/host/ppc64/host-signal.h 
b/linux-user/include/host/ppc64/host-signal.h
similarity index 100%
rename from linux-user/host/ppc64/host-signal.h
rename to linux-user/include/host/ppc64/host-signal.h
diff --git a/linux-user/host/riscv/host-signal.h 
b/linux-user/include/host/riscv/host-signal.h
similarity index 100%
rename from linux-user/host/riscv/host-signal.h
rename to linux-user/include/host/riscv/host-signal.h
diff --git a/linux-user/host/s390/host-signal.h 
b/linux-user/include/host/s390/host-signal.h
similarity index 100%
rename from linux-user/host/s390/host-signal.h
rename to linux-user/include/host/s390/host-signal.h
diff --git a/linux-user/host/s390x/host-sign

[PATCH 3/3] meson: cleanup common-user/ build

2021-12-21 Thread Paolo Bonzini
Do not go through a static_library, which is only necessary in order to reuse
some source files between emulators and tests.  Instead just place common files
for all user-mode emulators in common_ss, similar to what is already done for
softmmu_ss in full system emulators.

The only disadvantage is that the include_directories under bsd-user/include/
and linux-user/include/ are now enabled for all targets rather than only
user mode emulators.  This however is not different from how include/sysemu/
is available when building user mode emulators.

Signed-off-by: Paolo Bonzini 
---
 common-user/meson.build |  2 +-
 meson.build | 13 +
 2 files changed, 2 insertions(+), 13 deletions(-)

diff --git a/common-user/meson.build b/common-user/meson.build
index 5cb42bc664..26212dda5c 100644
--- a/common-user/meson.build
+++ b/common-user/meson.build
@@ -1,6 +1,6 @@
 common_user_inc += include_directories('host/' / host_arch)
 
-common_user_ss.add(files(
+user_ss.add(files(
   'safe-syscall.S',
   'safe-syscall-error.c',
 ))
diff --git a/meson.build b/meson.build
index b0af02b805..879628ab68 100644
--- a/meson.build
+++ b/meson.build
@@ -2377,7 +2377,6 @@ blockdev_ss = ss.source_set()
 block_ss = ss.source_set()
 chardev_ss = ss.source_set()
 common_ss = ss.source_set()
-common_user_ss = ss.source_set()
 crypto_ss = ss.source_set()
 hwcore_ss = ss.source_set()
 io_ss = ss.source_set()
@@ -2629,17 +2628,6 @@ subdir('common-user')
 subdir('bsd-user')
 subdir('linux-user')
 
-common_user_ss = common_user_ss.apply(config_all, strict: false)
-common_user = static_library('common-user',
- sources: common_user_ss.sources(),
- dependencies: common_user_ss.dependencies(),
- include_directories: common_user_inc,
- name_suffix: 'fa',
- build_by_default: false)
-common_user = declare_dependency(link_with: common_user)
-
-user_ss.add(common_user)
-
 # needed for fuzzing binaries
 subdir('tests/qtest/libqos')
 subdir('tests/qtest/fuzz')
@@ -2857,6 +2845,7 @@ common_all = common_ss.apply(config_all, strict: false)
 common_all = static_library('common',
 build_by_default: false,
 sources: common_all.sources() + genh,
+include_directories: common_user_inc,
 implicit_include_directories: false,
 dependencies: common_all.dependencies(),
 name_suffix: 'fa')
-- 
2.33.1




[PATCH 1/3] meson: reuse common_user_inc when building files specific to user-mode emulators

2021-12-21 Thread Paolo Bonzini
Signed-off-by: Paolo Bonzini 
---
 meson.build | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/meson.build b/meson.build
index f45ecf31bd..b0af02b805 100644
--- a/meson.build
+++ b/meson.build
@@ -2897,6 +2897,7 @@ foreach target : target_dirs
   else
 abi = config_target['TARGET_ABI_DIR']
 target_type='user'
+target_inc += common_user_inc
 qemu_target_name = 'qemu-' + target_name
 if target_base_arch in target_user_arch
   t = target_user_arch[target_base_arch].apply(config_target, strict: 
false)
@@ -2905,7 +2906,6 @@ foreach target : target_dirs
 endif
 if 'CONFIG_LINUX_USER' in config_target
   base_dir = 'linux-user'
-  target_inc += include_directories('linux-user/host/' / host_arch)
 endif
 if 'CONFIG_BSD_USER' in config_target
   base_dir = 'bsd-user'
-- 
2.33.1





[PATCH 0/3] build: some cleanups for common-user/ infrastructure

2021-12-21 Thread Paolo Bonzini
A belated review of the patches that introduced common-user/.
Limiting the interface that it expects from bsd-user/ and linux-user/
to an include/ subdirectory, and simplifying the mesonry that builds
the new directory.

Paolo Bonzini (3):
  meson: reuse common_user_inc when building files specific to user-mode
emulators
  user: move common-user includes to a subdirectory of {bsd,linux}-user/
  meson: cleanup common-user/ build

 bsd-user/{ => include}/special-errno.h|  0
 bsd-user/meson.build  |  2 +-
 common-user/meson.build   |  2 +-
 .../{ => include}/host/aarch64/host-signal.h  |  0
 linux-user/{ => include}/host/alpha/host-signal.h |  0
 linux-user/{ => include}/host/arm/host-signal.h   |  0
 linux-user/{ => include}/host/i386/host-signal.h  |  0
 linux-user/{ => include}/host/mips/host-signal.h  |  0
 linux-user/{ => include}/host/ppc/host-signal.h   |  0
 linux-user/{ => include}/host/ppc64/host-signal.h |  0
 linux-user/{ => include}/host/riscv/host-signal.h |  0
 linux-user/{ => include}/host/s390/host-signal.h  |  0
 linux-user/{ => include}/host/s390x/host-signal.h |  0
 linux-user/{ => include}/host/sparc/host-signal.h |  0
 .../{ => include}/host/sparc64/host-signal.h  |  0
 linux-user/{ => include}/host/x32/host-signal.h   |  0
 .../{ => include}/host/x86_64/host-signal.h   |  0
 linux-user/{ => include}/special-errno.h  |  0
 linux-user/meson.build|  4 ++--
 meson.build   | 15 ++-
 20 files changed, 6 insertions(+), 17 deletions(-)
 rename bsd-user/{ => include}/special-errno.h (100%)
 rename linux-user/{ => include}/host/aarch64/host-signal.h (100%)
 rename linux-user/{ => include}/host/alpha/host-signal.h (100%)
 rename linux-user/{ => include}/host/arm/host-signal.h (100%)
 rename linux-user/{ => include}/host/i386/host-signal.h (100%)
 rename linux-user/{ => include}/host/mips/host-signal.h (100%)
 rename linux-user/{ => include}/host/ppc/host-signal.h (100%)
 rename linux-user/{ => include}/host/ppc64/host-signal.h (100%)
 rename linux-user/{ => include}/host/riscv/host-signal.h (100%)
 rename linux-user/{ => include}/host/s390/host-signal.h (100%)
 rename linux-user/{ => include}/host/s390x/host-signal.h (100%)
 rename linux-user/{ => include}/host/sparc/host-signal.h (100%)
 rename linux-user/{ => include}/host/sparc64/host-signal.h (100%)
 rename linux-user/{ => include}/host/x32/host-signal.h (100%)
 rename linux-user/{ => include}/host/x86_64/host-signal.h (100%)
 rename linux-user/{ => include}/special-errno.h (100%)

-- 
2.33.1




Re: [PATCH] vl: Add -set options to device opts dict when using JSON syntax for -device

2021-12-21 Thread Paolo Bonzini

On 12/21/21 13:58, Markus Armbruster wrote:

Is this a regression?  I suspect commit 5dacda5167 "vl: Enable JSON
syntax for -device" (v6.2.0).

Obviously not a regression: everything that used to work still works.



FWIW I think -set should be deprecated.  I'm not aware of any 
particularly useful use of it.  There are a couple in the QEMU tests (in 
vhost-user-test and in qemu-iotests 068), but in both cases the code 
would be easier to follow without; patches can be dusted off if desired.


Paolo



[PATCH] docker: include bison in debian-tricore-cross

2021-12-21 Thread Paolo Bonzini
Binutils sometimes fail to build if bison is not installed:

  /bin/sh ./ylwrap `test -f arparse.y || echo ./`arparse.y y.tab.c arparse.c 
y.tab.h arparse.h y.output arparse.output --  -d
  ./ylwrap: 109: ./ylwrap: -d: not found

(the correct invocation of ylwrap would have "bison -d" after the double
dash).  Work around by installing it in the container.

Cc: Alex Bennée 
Signed-off-by: Paolo Bonzini 
---
 tests/docker/dockerfiles/debian-tricore-cross.docker | 1 +
 1 file changed, 1 insertion(+)

diff --git a/tests/docker/dockerfiles/debian-tricore-cross.docker 
b/tests/docker/dockerfiles/debian-tricore-cross.docker
index d8df2c6117..3f6b55562c 100644
--- a/tests/docker/dockerfiles/debian-tricore-cross.docker
+++ b/tests/docker/dockerfiles/debian-tricore-cross.docker
@@ -16,6 +16,7 @@ MAINTAINER Philippe Mathieu-Daudé 
 RUN apt update && \
 DEBIAN_FRONTEND=noninteractive apt install -yy eatmydata && \
 DEBIAN_FRONTEND=noninteractive eatmydata apt install -yy \
+   bison \
bzip2 \
ca-certificates \
ccache \
-- 
2.33.1




[PATCH 8/8] meson: add comments in the target-specific flags section

2021-12-21 Thread Paolo Bonzini
Signed-off-by: Paolo Bonzini 
---
 meson.build | 5 +
 1 file changed, 5 insertions(+)

diff --git a/meson.build b/meson.build
index 09ee427ca4..0a6d57125f 100644
--- a/meson.build
+++ b/meson.build
@@ -233,6 +233,7 @@ endif
 # Target-specific checks and dependencies #
 ###
 
+# Fuzzing
 if get_option('fuzzing') and get_option('fuzzing_engine') == '' and \
 not cc.links('''
   #include 
@@ -244,6 +245,7 @@ if get_option('fuzzing') and get_option('fuzzing_engine') 
== '' and \
   error('Your compiler does not support -fsanitize=fuzzer')
 endif
 
+# Tracing backends
 if 'ftrace' in get_option('trace_backends') and targetos != 'linux'
   error('ftrace is supported only on Linux')
 endif
@@ -257,6 +259,7 @@ if 'syslog' in get_option('trace_backends') and not 
cc.compiles('''
   error('syslog is not supported on this system')
 endif
 
+# Miscellaneous Linux-only features
 if targetos != 'linux' and get_option('mpath').enabled()
   error('Multipath is supported only on Linux')
 endif
@@ -266,6 +269,7 @@ if targetos != 'linux' and 
get_option('multiprocess').enabled()
 endif
 multiprocess_allowed = targetos == 'linux' and not 
get_option('multiprocess').disabled()
 
+# Target-specific libraries and flags
 libm = cc.find_library('m', required: false)
 threads = dependency('threads')
 util = cc.find_library('util', required: false)
@@ -306,6 +310,7 @@ elif targetos == 'openbsd'
   endif
 endif
 
+# Target-specific configuration of accelerators
 accelerators = []
 if not get_option('kvm').disabled() and targetos == 'linux'
   accelerators += 'CONFIG_KVM'
-- 
2.33.1




[PATCH 5/8] configure: move non-command-line variables away from command-line parsing section

2021-12-21 Thread Paolo Bonzini
This makes it easier to identify candidates for moving to Meson.

Signed-off-by: Paolo Bonzini 
---
 configure | 13 ++---
 1 file changed, 6 insertions(+), 7 deletions(-)

diff --git a/configure b/configure
index 40dd6e8d1b..810bc36490 100755
--- a/configure
+++ b/configure
@@ -308,16 +308,12 @@ debug="no"
 sanitizers="no"
 tsan="no"
 fortify_source="$default_feature"
-mingw32="no"
 gcov="no"
 EXESUF=""
 modules="no"
 module_upgrades="no"
 prefix="/usr/local"
 qemu_suffix="qemu"
-bsd="no"
-linux="no"
-solaris="no"
 profiler="no"
 softmmu="yes"
 linux_user=""
@@ -331,8 +327,6 @@ opengl="$default_feature"
 cpuid_h="no"
 avx2_opt="$default_feature"
 guest_agent="$default_feature"
-guest_agent_with_vss="no"
-guest_agent_ntddscsi="no"
 vss_win32_sdk="$default_feature"
 win_sdk="no"
 want_tools="$default_feature"
@@ -527,6 +521,10 @@ fi
 
 # OS specific
 
+mingw32="no"
+bsd="no"
+linux="no"
+solaris="no"
 case $targetos in
 windows)
   mingw32="yes"
@@ -2574,6 +2572,7 @@ fi
 ##
 # check if we have VSS SDK headers for win
 
+guest_agent_with_vss="no"
 if test "$mingw32" = "yes" && test "$guest_agent" != "no" && \
 test "$vss_win32_sdk" != "no" ; then
   case "$vss_win32_sdk" in
@@ -2604,7 +2603,6 @@ EOF
   echo "ERROR: The headers are extracted in the directory \`inc'."
   feature_not_found "VSS support"
 fi
-guest_agent_with_vss="no"
   fi
 fi
 
@@ -2631,6 +2629,7 @@ fi
 
 ##
 # check if mingw environment provides a recent ntddscsi.h
+guest_agent_ntddscsi="no"
 if test "$mingw32" = "yes" && test "$guest_agent" != "no"; then
   cat > $TMPC << EOF
 #include 
-- 
2.33.1





[PATCH 7/8] configure, meson: move config-poison.h to meson

2021-12-21 Thread Paolo Bonzini
This ensures that the file is regenerated properly whenever config-target.h
or config-devices.h files change.

Signed-off-by: Paolo Bonzini 
---
 Makefile  |  2 +-
 configure | 11 ---
 meson.build   | 12 
 scripts/make-config-poison.sh | 16 
 4 files changed, 29 insertions(+), 12 deletions(-)
 create mode 100755 scripts/make-config-poison.sh

diff --git a/Makefile b/Makefile
index 06ad8a61e1..2f80f56a4a 100644
--- a/Makefile
+++ b/Makefile
@@ -220,7 +220,7 @@ qemu-%.tar.bz2:
 
 distclean: clean
-$(quiet-@)test -f build.ninja && $(NINJA) $(NINJAFLAGS) -t clean -g || 
:
-   rm -f config-host.mak config-poison.h
+   rm -f config-host.mak
rm -f tests/tcg/config-*.mak
rm -f config.status
rm -f roms/seabios/config.mak
diff --git a/configure b/configure
index 810bc36490..aff371ca81 100755
--- a/configure
+++ b/configure
@@ -3858,17 +3858,6 @@ if test -n "${deprecated_features}"; then
 echo "  features: ${deprecated_features}"
 fi
 
-# Create list of config switches that should be poisoned in common code...
-# but filter out CONFIG_TCG and CONFIG_USER_ONLY which are special.
-target_configs_h=$(ls *-config-devices.h *-config-target.h 2>/dev/null)
-if test -n "$target_configs_h" ; then
-sed -n -e '/CONFIG_TCG/d' -e '/CONFIG_USER_ONLY/d' \
--e '/^#define / { s///; s/ .*//; s/^/#pragma GCC poison /p; }' \
-$target_configs_h | sort -u > config-poison.h
-else
-:> config-poison.h
-fi
-
 # Save the configure command line for later reuse.
 cat <config.status
 #!/bin/sh
diff --git a/meson.build b/meson.build
index 2495360fd0..09ee427ca4 100644
--- a/meson.build
+++ b/meson.build
@@ -2006,6 +2006,18 @@ config_all += {
   'CONFIG_ALL': true,
 }
 
+target_configs_h = []
+foreach target: target_dirs
+  target_configs_h += config_target_h[target]
+  target_configs_h += config_devices_h.get(target, [])
+endforeach
+genh += custom_target('config-poison.h',
+  input: [target_configs_h],
+  output: 'config-poison.h',
+  capture: true,
+  command: [find_program('scripts/make-config-poison.sh')] 
+
+   (target_configs_h.length() > 0 ? ['@INPUT@'] : 
[]))
+
 ##
 # Submodules #
 ##
diff --git a/scripts/make-config-poison.sh b/scripts/make-config-poison.sh
new file mode 100755
index 00..d222a04304
--- /dev/null
+++ b/scripts/make-config-poison.sh
@@ -0,0 +1,16 @@
+#! /bin/sh
+
+if test $# = 0; then
+  exit 0
+fi
+
+# Create list of config switches that should be poisoned in common code...
+# but filter out CONFIG_TCG and CONFIG_USER_ONLY which are special.
+exec sed -n \
+  -e' /CONFIG_TCG/d' \
+  -e '/CONFIG_USER_ONLY/d' \
+  -e '/^#define / {' \
+  -e's///' \
+  -e's/ .*//' \
+  -e's/^/#pragma GCC poison /p' \
+  -e '}' "$@"
-- 
2.33.1





[PATCH 3/8] configure, makefile: remove traces of really old files

2021-12-21 Thread Paolo Bonzini
These files have been removed for more than year in the best
case, or for more than ten years for some really old TCG files.
Remove any traces of it.

Signed-off-by: Paolo Bonzini 
---
 Makefile  | 11 ---
 configure |  9 -
 2 files changed, 4 insertions(+), 16 deletions(-)

diff --git a/Makefile b/Makefile
index 74c5b46d38..06ad8a61e1 100644
--- a/Makefile
+++ b/Makefile
@@ -205,14 +205,11 @@ recurse-clean: $(addsuffix /clean, $(ROM_DIRS))
 clean: recurse-clean
-$(quiet-@)test -f build.ninja && $(NINJA) $(NINJAFLAGS) -t clean || :
-$(quiet-@)test -f build.ninja && $(NINJA) $(NINJAFLAGS) clean-ctlist 
|| :
-# avoid old build problems by removing potentially incorrect old files
-   rm -f config.mak op-i386.h opc-i386.h gen-op-i386.h op-arm.h opc-arm.h 
gen-op-arm.h
find . \( -name '*.so' -o -name '*.dll' -o -name '*.[oda]' \) -type f \
! -path ./roms/edk2/ArmPkg/Library/GccLto/liblto-aarch64.a \
! -path ./roms/edk2/ArmPkg/Library/GccLto/liblto-arm.a \
-exec rm {} +
-   rm -f TAGS cscope.* *.pod *~ */*~
-   rm -f fsdev/*.pod scsi/*.pod
+   rm -f TAGS cscope.* *~ */*~
 
 VERSION = $(shell cat $(SRC_PATH)/VERSION)
 
@@ -223,10 +220,10 @@ qemu-%.tar.bz2:
 
 distclean: clean
-$(quiet-@)test -f build.ninja && $(NINJA) $(NINJAFLAGS) -t clean -g || 
:
-   rm -f config-host.mak config-host.h* config-poison.h
+   rm -f config-host.mak config-poison.h
rm -f tests/tcg/config-*.mak
-   rm -f config-all-disas.mak config.status
-   rm -f roms/seabios/config.mak roms/vgabios/config.mak
+   rm -f config.status
+   rm -f roms/seabios/config.mak
rm -f qemu-plugins-ld.symbols qemu-plugins-ld64.symbols
rm -f *-config-target.h *-config-devices.mak *-config-devices.h
rm -rf meson-private meson-logs meson-info compile_commands.json
diff --git a/configure b/configure
index 6dafbcd362..e09e5bb58f 100755
--- a/configure
+++ b/configure
@@ -3696,9 +3696,6 @@ fi
 # so the build tree will be missing the link back to the new file, and
 # tests might fail. Prefer to keep the relevant files in their own
 # directory and symlink the directory instead.
-# UNLINK is used to remove symlinks from older development versions
-# that might get into the way when doing "git update" without doing
-# a "make distclean" in between.
 LINKS="Makefile"
 LINKS="$LINKS tests/tcg/Makefile.target"
 LINKS="$LINKS pc-bios/optionrom/Makefile"
@@ -3710,7 +3707,6 @@ LINKS="$LINKS tests/avocado tests/data"
 LINKS="$LINKS tests/qemu-iotests/check"
 LINKS="$LINKS python"
 LINKS="$LINKS contrib/plugins/Makefile "
-UNLINK="pc-bios/keymaps"
 for bios_file in \
 $source_path/pc-bios/*.bin \
 $source_path/pc-bios/*.elf \
@@ -3732,11 +3728,6 @@ for f in $LINKS ; do
 symlink "$source_path/$f" "$f"
 fi
 done
-for f in $UNLINK ; do
-if [ -L "$f" ]; then
-rm -f "$f"
-fi
-done
 
 (for i in $cross_cc_vars; do
   export $i
-- 
2.33.1





[PATCH 6/8] meson: build contrib/ executables after generated headers

2021-12-21 Thread Paolo Bonzini
This will be needed as soon as config-poison.h moves from configure to
a meson custom_target (which is built at "ninja" time).

Signed-off-by: Paolo Bonzini 
---
 contrib/elf2dmp/meson.build| 2 +-
 contrib/ivshmem-client/meson.build | 2 +-
 contrib/ivshmem-server/meson.build | 2 +-
 contrib/rdmacm-mux/meson.build | 2 +-
 4 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/contrib/elf2dmp/meson.build b/contrib/elf2dmp/meson.build
index 4d86cb390a..6707d43c4f 100644
--- a/contrib/elf2dmp/meson.build
+++ b/contrib/elf2dmp/meson.build
@@ -1,5 +1,5 @@
 if curl.found()
-  executable('elf2dmp', files('main.c', 'addrspace.c', 'download.c', 'pdb.c', 
'qemu_elf.c'),
+  executable('elf2dmp', files('main.c', 'addrspace.c', 'download.c', 'pdb.c', 
'qemu_elf.c'), genh,
  dependencies: [glib, curl],
  install: true)
 endif
diff --git a/contrib/ivshmem-client/meson.build 
b/contrib/ivshmem-client/meson.build
index 1b171efb4f..ce8dcca84d 100644
--- a/contrib/ivshmem-client/meson.build
+++ b/contrib/ivshmem-client/meson.build
@@ -1,4 +1,4 @@
-executable('ivshmem-client', files('ivshmem-client.c', 'main.c'),
+executable('ivshmem-client', files('ivshmem-client.c', 'main.c'), genh,
dependencies: glib,
build_by_default: targetos == 'linux',
install: false)
diff --git a/contrib/ivshmem-server/meson.build 
b/contrib/ivshmem-server/meson.build
index 3a53942201..c6c3c82e89 100644
--- a/contrib/ivshmem-server/meson.build
+++ b/contrib/ivshmem-server/meson.build
@@ -1,4 +1,4 @@
-executable('ivshmem-server', files('ivshmem-server.c', 'main.c'),
+executable('ivshmem-server', files('ivshmem-server.c', 'main.c'), genh,
dependencies: [qemuutil, rt],
build_by_default: targetos == 'linux',
install: false)
diff --git a/contrib/rdmacm-mux/meson.build b/contrib/rdmacm-mux/meson.build
index 6cc5016747..7674f54cc5 100644
--- a/contrib/rdmacm-mux/meson.build
+++ b/contrib/rdmacm-mux/meson.build
@@ -2,7 +2,7 @@ if 'CONFIG_PVRDMA' in config_host
   # if not found, CONFIG_PVRDMA should not be set
   # FIXME: broken on big endian architectures
   libumad = cc.find_library('ibumad', required: true)
-  executable('rdmacm-mux', files('main.c'),
+  executable('rdmacm-mux', files('main.c'), genh,
  dependencies: [glib, libumad],
  build_by_default: false,
  install: false)
-- 
2.33.1





[PATCH 0/8] Next round of configure/meson cleanups

2021-12-21 Thread Paolo Bonzini
Includes v2 of patches from the previous round, and new patches 3-8.

Paolo

Paolo Bonzini (8):
  configure: simplify creation of plugin symbol list
  configure: do not set bsd_user/linux_user early
  configure, makefile: remove traces of really old files
  configure: parse --enable/--disable-strip automatically, flip default
  configure: move non-command-line variables away from command-line
parsing section
  meson: build contrib/ executables after generated headers
  configure, meson: move config-poison.h to meson
  meson: add comments in the target-specific flags section

 Makefile   |  11 +--
 configure  | 151 +
 contrib/elf2dmp/meson.build|   2 +-
 contrib/ivshmem-client/meson.build |   2 +-
 contrib/ivshmem-server/meson.build |   2 +-
 contrib/rdmacm-mux/meson.build |   2 +-
 meson.build|  17 
 pc-bios/s390-ccw/Makefile  |   2 -
 plugins/meson.build|  11 ++-
 scripts/make-config-poison.sh  |  16 +++
 scripts/meson-buildoptions.py  |  21 ++--
 scripts/meson-buildoptions.sh  |   3 +
 12 files changed, 90 insertions(+), 150 deletions(-)
 create mode 100755 scripts/make-config-poison.sh

-- 
2.33.1




[PATCH 4/8] configure: parse --enable/--disable-strip automatically, flip default

2021-12-21 Thread Paolo Bonzini
Always include the STRIP variable in config-host.mak (it's only used
by the s390-ccw firmware build, and it adds a default if configure
omitted it), and use meson-buildoptions.sh to turn
--enable/--disable-strip into -Dstrip.

The default is now not to strip the binaries like for almost every other
package that has a configure script.

Signed-off-by: Paolo Bonzini 
---
 configure | 10 +-
 pc-bios/s390-ccw/Makefile |  2 --
 scripts/meson-buildoptions.py | 21 ++---
 scripts/meson-buildoptions.sh |  3 +++
 4 files changed, 18 insertions(+), 18 deletions(-)

diff --git a/configure b/configure
index e09e5bb58f..40dd6e8d1b 100755
--- a/configure
+++ b/configure
@@ -308,7 +308,6 @@ debug="no"
 sanitizers="no"
 tsan="no"
 fortify_source="$default_feature"
-strip_opt="yes"
 mingw32="no"
 gcov="no"
 EXESUF=""
@@ -891,7 +890,6 @@ for opt do
   debug_tcg="yes"
   debug_mutex="yes"
   debug="yes"
-  strip_opt="no"
   fortify_source="no"
   ;;
   --enable-sanitizers) sanitizers="yes"
@@ -902,8 +900,6 @@ for opt do
   ;;
   --disable-tsan) tsan="no"
   ;;
-  --disable-strip) strip_opt="no"
-  ;;
   --disable-slirp) slirp="disabled"
   ;;
   --enable-slirp) slirp="enabled"
@@ -1370,7 +1366,6 @@ Advanced options (experts only):
   --enable-debug   enable common debug build options
   --enable-sanitizers  enable default sanitizers
   --enable-tsanenable thread sanitizer
-  --disable-strip  disable stripping binaries
   --disable-werror disable compilation abort on warning
   --disable-stack-protector disable compiler-provided stack protection
   --audio-drv-list=LISTset audio drivers to try if -audiodev is not used
@@ -3340,9 +3335,6 @@ echo "GIT_SUBMODULES_ACTION=$git_submodules_action" >> 
$config_host_mak
 if test "$debug_tcg" = "yes" ; then
   echo "CONFIG_DEBUG_TCG=y" >> $config_host_mak
 fi
-if test "$strip_opt" = "yes" ; then
-  echo "STRIP=${strip}" >> $config_host_mak
-fi
 if test "$mingw32" = "yes" ; then
   echo "CONFIG_WIN32=y" >> $config_host_mak
   if test "$guest_agent_with_vss" = "yes" ; then
@@ -3622,6 +3614,7 @@ echo "GLIB_CFLAGS=$glib_cflags" >> $config_host_mak
 echo "GLIB_LIBS=$glib_libs" >> $config_host_mak
 echo "QEMU_LDFLAGS=$QEMU_LDFLAGS" >> $config_host_mak
 echo "LD_I386_EMULATION=$ld_i386_emulation" >> $config_host_mak
+echo "STRIP=$strip" >> $config_host_mak
 echo "EXESUF=$EXESUF" >> $config_host_mak
 echo "LIBS_QGA=$libs_qga" >> $config_host_mak
 
@@ -3836,7 +3829,6 @@ if test "$skip_meson" = no; then
 -Doptimization=$(if test "$debug" = yes; then echo 0; else echo 2; fi) 
\
 -Ddebug=$(if test "$debug_info" = yes; then echo true; else echo 
false; fi) \
 -Dwerror=$(if test "$werror" = yes; then echo true; else echo false; 
fi) \
--Dstrip=$(if test "$strip_opt" = yes; then echo true; else echo false; 
fi) \
 -Db_pie=$(if test "$pie" = yes; then echo true; else echo false; fi) \
 -Db_coverage=$(if test "$gcov" = yes; then echo true; else echo false; 
fi) \
 -Db_lto=$lto -Dcfi=$cfi -Dtcg=$tcg -Dxen=$xen \
diff --git a/pc-bios/s390-ccw/Makefile b/pc-bios/s390-ccw/Makefile
index cee9d2c63b..0eb68efc7b 100644
--- a/pc-bios/s390-ccw/Makefile
+++ b/pc-bios/s390-ccw/Makefile
@@ -44,8 +44,6 @@ build-all: s390-ccw.img s390-netboot.img
 s390-ccw.elf: $(OBJECTS)
$(call quiet-command,$(CC) $(LDFLAGS) -o $@ 
$(OBJECTS),"BUILD","$(TARGET_DIR)$@")
 
-STRIP ?= strip
-
 s390-ccw.img: s390-ccw.elf
$(call quiet-command,$(STRIP) --strip-unneeded $< -o 
$@,"STRIP","$(TARGET_DIR)$@")
 
diff --git a/scripts/meson-buildoptions.py b/scripts/meson-buildoptions.py
index 96969d89ee..98ae944148 100755
--- a/scripts/meson-buildoptions.py
+++ b/scripts/meson-buildoptions.py
@@ -36,6 +36,10 @@
 "trace_file",
 }
 
+BUILTIN_OPTIONS = {
+"strip",
+}
+
 LINE_WIDTH = 76
 
 
@@ -90,14 +94,17 @@ def allow_arg(opt):
 return not (set(opt["choices"]) <= {"auto", "disabled", "enabled"})
 
 
+def filter_options(json):
+if ":" in json["name"]:
+return False
+if json["section"] == "user":
+return json["name"] not in SKIP_OPTIONS
+else:
+return json["name"] in BUILTIN_OPTIONS
+
+
 def load_options(json):
-json = [
-x
-for x in js

[PATCH 2/8] configure: do not set bsd_user/linux_user early

2021-12-21 Thread Paolo Bonzini
Similar to other optional features, leave the variables empty and compute
the actual value later.  Use the existence of include or source directories
to detect whether an OS or CPU supports respectively bsd-user and linux-user.

For now, BSD user-mode emulation is buildable even on TCI-only
architectures.  This probably will change once safe signals are
brought over from linux-user.

Signed-off-by: Paolo Bonzini 
---
 configure | 28 +---
 1 file changed, 17 insertions(+), 11 deletions(-)

diff --git a/configure b/configure
index 1bce9635d9..6dafbcd362 100755
--- a/configure
+++ b/configure
@@ -321,8 +321,8 @@ linux="no"
 solaris="no"
 profiler="no"
 softmmu="yes"
-linux_user="no"
-bsd_user="no"
+linux_user=""
+bsd_user=""
 pkgversion=""
 pie=""
 qom_cast_debug="yes"
@@ -539,7 +539,6 @@ gnu/kfreebsd)
 ;;
 freebsd)
   bsd="yes"
-  bsd_user="yes"
   make="${MAKE-gmake}"
   # needed for kinfo_getvmmap(3) in libutil.h
 ;;
@@ -584,7 +583,6 @@ haiku)
 ;;
 linux)
   linux="yes"
-  linux_user="yes"
   vhost_user=${default_feature:-yes}
 ;;
 esac
@@ -1262,18 +1260,26 @@ if eval test -z "\${cross_cc_$cpu}"; then
 cross_cc_vars="$cross_cc_vars cross_cc_${cpu}"
 fi
 
-# For user-mode emulation the host arch has to be one we explicitly
-# support, even if we're using TCI.
-if [ "$ARCH" = "unknown" ]; then
-  bsd_user="no"
-  linux_user="no"
-fi
-
 default_target_list=""
 deprecated_targets_list=ppc64abi32-linux-user
 deprecated_features=""
 mak_wilds=""
 
+if [ "$linux_user" != no ]; then
+if [ "$targetos" = linux ] && [ -d $source_path/linux-user/host/$cpu ]; 
then
+linux_user=yes
+elif [ "$linux_user" = yes ]; then
+error_exit "linux-user not supported on this architecture"
+fi
+fi
+if [ "$bsd_user" != no ]; then
+if [ "$bsd_user" = "" ]; then
+test $targetos = freebsd && bsd_user=yes
+fi
+if [ "$bsd_user" = yes ] && ! [ -d $source_path/bsd-user/$targetos ]; then
+error_exit "bsd-user not supported on this host OS"
+fi
+fi
 if [ "$softmmu" = "yes" ]; then
 mak_wilds="${mak_wilds} $source_path/configs/targets/*-softmmu.mak"
 fi
-- 
2.33.1





[PATCH 1/8] configure: simplify creation of plugin symbol list

2021-12-21 Thread Paolo Bonzini
--dynamic-list is present on all supported ELF (not Windows or Darwin)
platforms, since it dates back to 2006; -exported_symbols_list is
likewise present on all supported versions of macOS.  Do not bother
doing a functional test in configure.

Remove the file creation from configure as well: for Darwin, move the
the creation of the Darwin-formatted symbols to meson; for ELF, use the
file in the source path directly and switch from -Wl, to -Xlinker to
not break weird paths that include a comma.

Signed-off-by: Paolo Bonzini 
---
 configure   | 80 -
 plugins/meson.build | 11 +--
 2 files changed, 8 insertions(+), 83 deletions(-)

diff --git a/configure b/configure
index 8ccfe51673..1bce9635d9 100755
--- a/configure
+++ b/configure
@@ -78,7 +78,6 @@ TMPC="${TMPDIR1}/${TMPB}.c"
 TMPO="${TMPDIR1}/${TMPB}.o"
 TMPCXX="${TMPDIR1}/${TMPB}.cxx"
 TMPE="${TMPDIR1}/${TMPB}.exe"
-TMPTXT="${TMPDIR1}/${TMPB}.txt"
 
 rm -f config.log
 
@@ -2343,69 +2342,6 @@ EOF
   fi
 fi
 
-##
-# plugin linker support probe
-
-if test "$plugins" != "no"; then
-
-#
-# See if --dynamic-list is supported by the linker
-
-ld_dynamic_list="no"
-cat > $TMPTXT < $TMPC <
-void foo(void);
-
-void foo(void)
-{
-  printf("foo\n");
-}
-
-int main(void)
-{
-  foo();
-  return 0;
-}
-EOF
-
-if compile_prog "" "-Wl,--dynamic-list=$TMPTXT" ; then
-ld_dynamic_list="yes"
-fi
-
-#
-# See if -exported_symbols_list is supported by the linker
-
-ld_exported_symbols_list="no"
-cat > $TMPTXT <> $config_host_mak
-# Copy the export object list to the build dir
-if test "$ld_dynamic_list" = "yes" ; then
-   echo "CONFIG_HAS_LD_DYNAMIC_LIST=yes" >> $config_host_mak
-   ld_symbols=qemu-plugins-ld.symbols
-   cp "$source_path/plugins/qemu-plugins.symbols" $ld_symbols
-elif test "$ld_exported_symbols_list" = "yes" ; then
-   echo "CONFIG_HAS_LD_EXPORTED_SYMBOLS_LIST=yes" >> $config_host_mak
-   ld64_symbols=qemu-plugins-ld64.symbols
-   echo "# Automatically generated by configure - do not modify" > 
$ld64_symbols
-   grep 'qemu_' "$source_path/plugins/qemu-plugins.symbols" | sed 's/;//g' 
| \
-   sed -E 's/^[[:space:]]*(.*)/_\1/' >> $ld64_symbols
-else
-   error_exit \
-   "If \$plugins=yes, either \$ld_dynamic_list or " \
-   "\$ld_exported_symbols_list should have been set to 'yes'."
-fi
 fi
 
 if test -n "$gdb_bin"; then
diff --git a/plugins/meson.build b/plugins/meson.build
index b3de57853b..d0a2ee94cf 100644
--- a/plugins/meson.build
+++ b/plugins/meson.build
@@ -1,10 +1,15 @@
 plugin_ldflags = []
 # Modules need more symbols than just those in plugins/qemu-plugins.symbols
 if not enable_modules
-  if 'CONFIG_HAS_LD_DYNAMIC_LIST' in config_host
-plugin_ldflags = ['-Wl,--dynamic-list=qemu-plugins-ld.symbols']
-  elif 'CONFIG_HAS_LD_EXPORTED_SYMBOLS_LIST' in config_host
+  if targetos == 'darwin'
+qemu_plugins_symbols_list = configure_file(
+  input: files('qemu-plugins.symbols'),
+  output: 'qemu-plugins-ld64.symbols',
+  capture: true,
+  command: ['sed', '-ne', 's/^[[:space:]]*\\(qemu_.*\\);/_\\1/p', 
'@INPUT@'])
 plugin_ldflags = ['-Wl,-exported_symbols_list,qemu-plugins-ld64.symbols']
+  else
+plugin_ldflags = ['-Xlinker', '--dynamic-list=' + 
(meson.project_source_root() / 'plugins/qemu-plugins.symbols')]
   endif
 endif
 
-- 
2.33.1





[PATCH] KVM: x86: ignore interrupt_bitmap field of KVM_GET/SET_SREGS

2021-12-21 Thread Paolo Bonzini
This is unnecessary, because the interrupt would be retrieved and queued
anyway by KVM_GET_VCPU_EVENTS and KVM_SET_VCPU_EVENTS respectively,
and it makes the flow more similar to the one for KVM_GET/SET_SREGS2.

Signed-off-by: Paolo Bonzini 
---
 target/i386/kvm/kvm.c | 22 --
 1 file changed, 8 insertions(+), 14 deletions(-)

diff --git a/target/i386/kvm/kvm.c b/target/i386/kvm/kvm.c
index d81745620b..b42bcbc363 100644
--- a/target/i386/kvm/kvm.c
+++ b/target/i386/kvm/kvm.c
@@ -2607,11 +2607,11 @@ static int kvm_put_sregs(X86CPU *cpu)
 CPUX86State *env = >env;
 struct kvm_sregs sregs;
 
+/*
+ * The interrupt_bitmap is ignored because KVM_SET_SREGS is
+ * always followed by KVM_SET_VCPU_EVENTS.
+ */
 memset(sregs.interrupt_bitmap, 0, sizeof(sregs.interrupt_bitmap));
-if (env->interrupt_injected >= 0) {
-sregs.interrupt_bitmap[env->interrupt_injected / 64] |=
-(uint64_t)1 << (env->interrupt_injected % 64);
-}
 
 if ((env->eflags & VM_MASK)) {
 set_v8086_seg(, >segs[R_CS]);
@@ -3348,16 +3348,10 @@ static int kvm_get_sregs(X86CPU *cpu)
 return ret;
 }
 
-/* There can only be one pending IRQ set in the bitmap at a time, so try
-   to find it and save its number instead (-1 for none). */
-env->interrupt_injected = -1;
-for (i = 0; i < ARRAY_SIZE(sregs.interrupt_bitmap); i++) {
-if (sregs.interrupt_bitmap[i]) {
-bit = ctz64(sregs.interrupt_bitmap[i]);
-env->interrupt_injected = i * 64 + bit;
-break;
-}
-}
+/*
+ * The interrupt_bitmap is ignored because KVM_GET_SREGS is
+ * always preceded by KVM_GET_VCPU_EVENTS.
+ */
 
 get_seg(>segs[R_CS], );
 get_seg(>segs[R_DS], );
-- 
2.33.1




[PULL 15/16] tests/qtest/fuzz-megasas-test: Add test for GitLab issue #521

2021-12-19 Thread Paolo Bonzini
From: Philippe Mathieu-Daudé 

Without the previous commit, this test triggers:

  $ make check-qtest-x86_64
  [...]
  Running test qtest-x86_64/fuzz-megasas-test
  qemu-system-x86_64: softmmu/physmem.c:3229: address_space_unmap: Assertion 
`mr != NULL' failed.
  Broken pipe
  ERROR qtest-x86_64/fuzz-megasas-test - too few tests run (expected 2, got 1)

Suggested-by: Alexander Bulekov 
Signed-off-by: Philippe Mathieu-Daudé 
Reviewed-by: Darren Kenny 
Message-Id: <2029201141.532377-3-phi...@redhat.com>
Signed-off-by: Paolo Bonzini 
---
 tests/qtest/fuzz-megasas-test.c | 30 ++
 1 file changed, 30 insertions(+)

diff --git a/tests/qtest/fuzz-megasas-test.c b/tests/qtest/fuzz-megasas-test.c
index 940a76bf25..e1141c58a4 100644
--- a/tests/qtest/fuzz-megasas-test.c
+++ b/tests/qtest/fuzz-megasas-test.c
@@ -34,6 +34,34 @@ static void test_lp1878263_megasas_zero_iov_cnt(void)
 qtest_quit(s);
 }
 
+/*
+ * Overflow SGL buffer.
+ * https://gitlab.com/qemu-project/qemu/-/issues/521
+ */
+static void test_gitlab_issue521_megasas_sgl_ovf(void)
+{
+QTestState *s = qtest_init("-display none -m 32M -machine q35 "
+   "-nodefaults -device megasas "
+   "-device scsi-cd,drive=null0 "
+   "-blockdev "
+   
"driver=null-co,read-zeroes=on,node-name=null0");
+qtest_outl(s, 0xcf8, 0x8818);
+qtest_outl(s, 0xcfc, 0xc000);
+qtest_outl(s, 0xcf8, 0x8804);
+qtest_outw(s, 0xcfc, 0x05);
+qtest_bufwrite(s, 0x0, "\x01", 0x1);
+qtest_bufwrite(s, 0x7, "\x01", 0x1);
+qtest_bufwrite(s, 0x10, "\x02", 0x1);
+qtest_bufwrite(s, 0x16, "\x01", 0x1);
+qtest_bufwrite(s, 0x28, "\x01", 0x1);
+qtest_bufwrite(s, 0x33, "\x01", 0x1);
+qtest_outb(s, 0xc040, 0x0);
+qtest_outb(s, 0xc040, 0x20);
+qtest_outl(s, 0xc040, 0x2000);
+qtest_outb(s, 0xc040, 0x20);
+qtest_quit(s);
+}
+
 int main(int argc, char **argv)
 {
 const char *arch = qtest_get_arch();
@@ -43,6 +71,8 @@ int main(int argc, char **argv)
 if (strcmp(arch, "i386") == 0 || strcmp(arch, "x86_64") == 0) {
 qtest_add_func("fuzz/test_lp1878263_megasas_zero_iov_cnt",
test_lp1878263_megasas_zero_iov_cnt);
+qtest_add_func("fuzz/gitlab_issue521_megasas_sgl_ovf",
+   test_gitlab_issue521_megasas_sgl_ovf);
 }
 
 return g_test_run();
-- 
2.33.1





[PULL 13/16] hw/scsi: Fix scsi_bus_init_named() docstring

2021-12-19 Thread Paolo Bonzini
From: Philippe Mathieu-Daudé 

Commit 739e95f5741 ("scsi: Replace scsi_bus_new() with
scsi_bus_init(), scsi_bus_init_named()") forgot to rename
scsi_bus_init() in the function documentation string.

Signed-off-by: Philippe Mathieu-Daudé 
Message-Id: <20211122104744.1051554-1-f4...@amsat.org>
Reviewed-by: Peter Maydell 
Signed-off-by: Paolo Bonzini 
---
 include/hw/scsi/scsi.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/include/hw/scsi/scsi.h b/include/hw/scsi/scsi.h
index a567a5ed86..2ef80af6dc 100644
--- a/include/hw/scsi/scsi.h
+++ b/include/hw/scsi/scsi.h
@@ -158,7 +158,7 @@ struct SCSIBus {
  * provided by the caller. It is the caller's responsibility to make
  * sure that name does not clash with the name of any other bus in the
  * system. Unless you need the new bus to have a specific name, you
- * should use scsi_bus_new() instead.
+ * should use scsi_bus_init() instead.
  */
 void scsi_bus_init_named(SCSIBus *bus, size_t bus_size, DeviceState *host,
  const SCSIBusInfo *info, const char *bus_name);
-- 
2.33.1





[PULL 16/16] hw/i386/vmmouse: Require 'i8042' property to be set

2021-12-19 Thread Paolo Bonzini
From: Philippe Mathieu-Daudé 

If the 'i8042' property is not set, mouse events handled by
vmmouse_mouse_event() end calling i8042_isa_mouse_fake_event()
with a NULL argument, resulting in ps2_mouse_fake_event() being
called with invalid PS2MouseState pointer. Fix by requiring
the 'i8042' property to be always set:

  $ qemu-system-x86_64 -device vmmouse
  qemu-system-x86_64: -device vmmouse: 'i8042' link is not set

Fixes: 91c9e09147b ("vmmouse: convert to qdev")
Reported-by: Calvin Buckley 
Resolves: https://gitlab.com/qemu-project/qemu/-/issues/752
Signed-off-by: Philippe Mathieu-Daudé 
Message-Id: <20211201223253.36080-1-f4...@amsat.org>
Signed-off-by: Paolo Bonzini 
---
 hw/i386/vmmouse.c | 4 
 1 file changed, 4 insertions(+)

diff --git a/hw/i386/vmmouse.c b/hw/i386/vmmouse.c
index 3d66368286..a56c185f15 100644
--- a/hw/i386/vmmouse.c
+++ b/hw/i386/vmmouse.c
@@ -286,6 +286,10 @@ static void vmmouse_realizefn(DeviceState *dev, Error 
**errp)
 
 DPRINTF("vmmouse_init\n");
 
+if (!s->i8042) {
+error_setg(errp, "'i8042' link is not set");
+return;
+}
 if (!object_resolve_path_type("", TYPE_VMPORT, NULL)) {
 error_setg(errp, "vmmouse needs a machine with vmport");
 return;
-- 
2.33.1




[PULL 10/16] meson: reenable test-fdmon-epoll

2021-12-19 Thread Paolo Bonzini
The test was disabled when CONFIG_EPOLL_CREATE1 was moved out
of config-host.mak.  Fix the condition.

Signed-off-by: Paolo Bonzini 
---
 tests/unit/meson.build | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tests/unit/meson.build b/tests/unit/meson.build
index acac3622ed..90acf5b0da 100644
--- a/tests/unit/meson.build
+++ b/tests/unit/meson.build
@@ -112,7 +112,7 @@ if have_block
   if nettle.found() or gcrypt.found()
 tests += {'test-crypto-pbkdf': [io]}
   endif
-  if 'CONFIG_EPOLL_CREATE1' in config_host
+  if config_host_data.get('CONFIG_EPOLL_CREATE1')
 tests += {'test-fdmon-epoll': [testblock]}
   endif
 endif
-- 
2.33.1





[PULL 09/16] configure: remove DIRS

2021-12-19 Thread Paolo Bonzini
DIRS is used to create the directory in which the LINKS symbolic links
reside, or to create directories for object files.  The former can
be done directly in the symlinking loop, while the latter is done
by Meson already, so DIRS is not necessary.

Reviewed-by: Peter Maydell 
Reviewed-by: Alex Bennée 
Tested-by: Alex Bennée 
Signed-off-by: Paolo Bonzini 
---
 configure | 9 +
 1 file changed, 1 insertion(+), 8 deletions(-)

diff --git a/configure b/configure
index ba85bbb54b..8ccfe51673 100755
--- a/configure
+++ b/configure
@@ -3762,7 +3762,6 @@ if test "$safe_stack" = "yes"; then
 fi
 
 # If we're using a separate build tree, set it up now.
-# DIRS are directories which we simply mkdir in the build tree;
 # LINKS are things to symlink back into the source tree
 # (these can be both files and directories).
 # Caution: do not add files or directories here using wildcards. This
@@ -3774,12 +3773,6 @@ fi
 # UNLINK is used to remove symlinks from older development versions
 # that might get into the way when doing "git update" without doing
 # a "make distclean" in between.
-DIRS="tests tests/tcg tests/qapi-schema tests/qtest/libqos"
-DIRS="$DIRS tests/qtest tests/qemu-iotests tests/vm tests/fp tests/qgraph"
-DIRS="$DIRS docs docs/interop fsdev scsi"
-DIRS="$DIRS pc-bios/optionrom pc-bios/s390-ccw"
-DIRS="$DIRS roms/seabios"
-DIRS="$DIRS contrib/plugins/"
 LINKS="Makefile"
 LINKS="$LINKS tests/tcg/Makefile.target"
 LINKS="$LINKS pc-bios/optionrom/Makefile"
@@ -3807,9 +3800,9 @@ for bios_file in \
 do
 LINKS="$LINKS pc-bios/$(basename $bios_file)"
 done
-mkdir -p $DIRS
 for f in $LINKS ; do
 if [ -e "$source_path/$f" ]; then
+mkdir -p `dirname ./$f`
 symlink "$source_path/$f" "$f"
 fi
 done
-- 
2.33.1





[PULL 11/16] cpu: remove unnecessary #ifdef CONFIG_TCG

2021-12-19 Thread Paolo Bonzini
"if (tcg_enabled())" allows elision of the code inside it; we only need
the prototype to exist, so that the code compile even for the --disable-tcg
case.

Signed-off-by: Paolo Bonzini 
---
 cpu.c  | 5 -
 include/exec/cpu-all.h | 2 --
 2 files changed, 7 deletions(-)

diff --git a/cpu.c b/cpu.c
index 9bce67ef55..945dd3dded 100644
--- a/cpu.c
+++ b/cpu.c
@@ -137,12 +137,10 @@ void cpu_exec_realizefn(CPUState *cpu, Error **errp)
 if (!accel_cpu_realizefn(cpu, errp)) {
 return;
 }
-#ifdef CONFIG_TCG
 /* NB: errp parameter is unused currently */
 if (tcg_enabled()) {
 tcg_exec_realizefn(cpu, errp);
 }
-#endif /* CONFIG_TCG */
 
 #ifdef CONFIG_USER_ONLY
 assert(qdev_get_vmsd(DEVICE(cpu)) == NULL ||
@@ -169,12 +167,9 @@ void cpu_exec_unrealizefn(CPUState *cpu)
 vmstate_unregister(NULL, _cpu_common, cpu);
 }
 #endif
-#ifdef CONFIG_TCG
-/* NB: errp parameter is unused currently */
 if (tcg_enabled()) {
 tcg_exec_unrealizefn(cpu);
 }
-#endif /* CONFIG_TCG */
 
 cpu_list_remove(cpu);
 }
diff --git a/include/exec/cpu-all.h b/include/exec/cpu-all.h
index 3c8e24292b..bb37239efa 100644
--- a/include/exec/cpu-all.h
+++ b/include/exec/cpu-all.h
@@ -437,12 +437,10 @@ void dump_opcount_info(GString *buf);
 
 #endif /* !CONFIG_USER_ONLY */
 
-#ifdef CONFIG_TCG
 /* accel/tcg/cpu-exec.c */
 int cpu_exec(CPUState *cpu);
 void tcg_exec_realizefn(CPUState *cpu, Error **errp);
 void tcg_exec_unrealizefn(CPUState *cpu);
-#endif /* CONFIG_TCG */
 
 /* Returns: 0 on success, -1 on error */
 int cpu_memory_rw_debug(CPUState *cpu, target_ulong addr,
-- 
2.33.1





[PULL 14/16] hw/scsi/megasas: Fails command if SGL buffer overflows

2021-12-19 Thread Paolo Bonzini
From: Philippe Mathieu-Daudé 

If we detect an overflow on the SGL buffer, do not
keep processing the command: discard it. TARGET_FAILURE
sense code will be returned (MFI_STAT_SCSI_DONE_WITH_ERROR).

Reported-by: Alexander Bulekov 
Resolves: https://gitlab.com/qemu-project/qemu/-/issues/521
Signed-off-by: Philippe Mathieu-Daudé 
Reviewed-by: Darren Kenny 
Message-Id: <2029201141.532377-2-phi...@redhat.com>
Signed-off-by: Paolo Bonzini 
---
 hw/scsi/megasas.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/hw/scsi/megasas.c b/hw/scsi/megasas.c
index 4ff51221d4..8f35784100 100644
--- a/hw/scsi/megasas.c
+++ b/hw/scsi/megasas.c
@@ -303,6 +303,7 @@ static int megasas_map_sgl(MegasasState *s, MegasasCmd 
*cmd, union mfi_sgl *sgl)
 }
 if (cmd->iov_size > iov_size) {
 trace_megasas_iovec_overflow(cmd->index, iov_size, cmd->iov_size);
+goto unmap;
 } else if (cmd->iov_size < iov_size) {
 trace_megasas_iovec_underflow(cmd->index, iov_size, cmd->iov_size);
 }
-- 
2.33.1





[PULL 07/16] configure, meson: move ARCH to meson.build

2021-12-19 Thread Paolo Bonzini
$ARCH and the HOST_* symbols are only used by the QEMU build; configure
uses $cpu instead.  Remove it from config-host.mak.

Reviewed-by: Richard Henderson 
Signed-off-by: Paolo Bonzini 
---
 configure   | 21 -
 meson.build | 26 +-
 2 files changed, 21 insertions(+), 26 deletions(-)

diff --git a/configure b/configure
index 108b7621e2..6e06ac6161 100755
--- a/configure
+++ b/configure
@@ -635,11 +635,9 @@ else
   cpu=$(uname -m)
 fi
 
-ARCH=
-# Normalise host CPU name, set ARCH and multilib cflags
+# Normalise host CPU name, set multilib cflags
 # Note that this case should only have supported host CPUs, not guests.
 case "$cpu" in
-  aarch64|riscv) ;;
   armv*b|armv*l|arm)
 cpu="arm" ;;
 
@@ -668,8 +666,7 @@ case "$cpu" in
 CPU_CFLAGS="-m64 -mlittle" ;;
 
   s390)
-CPU_CFLAGS="-m31"
-ARCH=unknown ;;
+CPU_CFLAGS="-m31" ;;
   s390x)
 CPU_CFLAGS="-m64" ;;
 
@@ -678,15 +675,7 @@ case "$cpu" in
 CPU_CFLAGS="-m32 -mv8plus -mcpu=ultrasparc" ;;
   sparc64)
 CPU_CFLAGS="-m64 -mcpu=ultrasparc" ;;
-
-  *)
-# This will result in either an error or falling back to TCI later
-ARCH=unknown
-  ;;
 esac
-if test -z "$ARCH"; then
-  ARCH="$cpu"
-fi
 
 : ${make=${MAKE-make}}
 
@@ -3406,8 +3395,6 @@ echo "GIT=$git" >> $config_host_mak
 echo "GIT_SUBMODULES=$git_submodules" >> $config_host_mak
 echo "GIT_SUBMODULES_ACTION=$git_submodules_action" >> $config_host_mak
 
-echo "ARCH=$ARCH" >> $config_host_mak
-
 if test "$debug_tcg" = "yes" ; then
   echo "CONFIG_DEBUG_TCG=y" >> $config_host_mak
 fi
@@ -3898,12 +3885,12 @@ if test "$skip_meson" = no; then
 cross_arg="--cross-file config-meson.cross"
 echo "[host_machine]" >> $cross
 echo "system = '$targetos'" >> $cross
-case "$ARCH" in
+case "$cpu" in
 i386)
 echo "cpu_family = 'x86'" >> $cross
 ;;
 *)
-echo "cpu_family = '$ARCH'" >> $cross
+echo "cpu_family = '$cpu'" >> $cross
 ;;
 esac
 echo "cpu = '$cpu'" >> $cross
diff --git a/meson.build b/meson.build
index 4fdaa65b05..2495360fd0 100644
--- a/meson.build
+++ b/meson.build
@@ -67,6 +67,14 @@ endif
 
 targetos = host_machine.system()
 
+if cpu not in supported_cpus
+  host_arch = 'unknown'
+elif cpu == 'x86'
+  host_arch = 'i386'
+else
+  host_arch = cpu
+endif
+
 if cpu in ['x86', 'x86_64']
   kvm_targets = ['i386-softmmu', 'x86_64-softmmu']
 elif cpu == 'aarch64'
@@ -335,9 +343,9 @@ if targetos == 'netbsd'
   endif
 endif
 
-tcg_arch = config_host['ARCH']
+tcg_arch = host_arch
 if not get_option('tcg').disabled()
-  if cpu not in supported_cpus
+  if host_arch == 'unknown'
 if get_option('tcg_interpreter')
   warning('Unsupported CPU @0@, will use TCG with TCI (slow)'.format(cpu))
 else
@@ -353,11 +361,11 @@ if not get_option('tcg').disabled()
   endif
   if get_option('tcg_interpreter')
 tcg_arch = 'tci'
-  elif config_host['ARCH'] == 'sparc64'
+  elif host_arch == 'sparc64'
 tcg_arch = 'sparc'
-  elif config_host['ARCH'] == 'x86_64'
+  elif host_arch == 'x86_64'
 tcg_arch = 'i386'
-  elif config_host['ARCH'] == 'ppc64'
+  elif host_arch == 'ppc64'
 tcg_arch = 'ppc'
   endif
   add_project_arguments('-iquote', meson.current_source_dir() / 'tcg' / 
tcg_arch,
@@ -1426,6 +1434,8 @@ config_host_data.set_quoted('CONFIG_QEMU_LOCALSTATEDIR', 
get_option('prefix') /
 config_host_data.set_quoted('CONFIG_QEMU_MODDIR', get_option('prefix') / 
qemu_moddir)
 config_host_data.set_quoted('CONFIG_SYSCONFDIR', get_option('prefix') / 
get_option('sysconfdir'))
 
+config_host_data.set('HOST_' + host_arch.to_upper(), 1)
+
 config_host_data.set('CONFIG_ATTR', libattr.found())
 config_host_data.set('CONFIG_BRLAPI', brlapi.found())
 config_host_data.set('CONFIG_COCOA', cocoa.found())
@@ -1775,8 +1785,6 @@ foreach k, v: config_host
   v = '"' + '", "'.join(v.split()) + '", '
 endif
 config_host_data.set(k, v)
-  elif k == 'ARCH'
-config_host_data.set('HOST_' + v.to_upper(), 1)
   elif strings.contains(k)
 config_host_data.set_quoted(k, v)
   elif k.startswith('CONFIG_')
@@ -1919,7 +1927,7 @@ foreach target : target_dirs
   endif
 
   foreach k, v: disassemblers
-if config_host['ARCH'].startswith(k) or 
config_target['TARGET_BASE_ARCH'].startswith(k)
+if host_arch.startswith(k) or 
config_target['TARGET_BASE_ARCH'].startswith(k)
   foreach sym: v
 config_target += { sym: 'y' }
 config_all_disas += { sym: 'y' }
@@ -2888,7 +2896,7 @@ foreach target : target_dirs
 endif
 if 'CONFIG_LINUX_USER' in config_target
   base_dir = 'linux-user'
-  target_inc += include_directories('linux-user/host/' / 
config_host['ARCH'])
+  target_inc += include_directories('linux-user/host/' / host_arch)
 endif
 if 'CONFIG_BSD_USER' in config_target
   base_dir = 'bsd-user'
-- 
2.33.1





  1   2   3   4   5   6   7   8   9   10   >