]> git.maquefel.me Git - qemu.git/log
qemu.git
5 years agos390x/tcg: Implement 32/128 bit for VECTOR FP COMPARE (AND SIGNAL) SCALAR
David Hildenbrand [Tue, 8 Jun 2021 09:23:27 +0000 (11:23 +0200)]
s390x/tcg: Implement 32/128 bit for VECTOR FP COMPARE (AND SIGNAL) SCALAR

Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Signed-off-by: David Hildenbrand <david@redhat.com>
Message-Id: <20210608092337.12221-17-david@redhat.com>
Signed-off-by: Cornelia Huck <cohuck@redhat.com>
5 years agos390x/tcg: Implement 32/128 bit for VECTOR FP COMPARE *
David Hildenbrand [Tue, 8 Jun 2021 09:23:26 +0000 (11:23 +0200)]
s390x/tcg: Implement 32/128 bit for VECTOR FP COMPARE *

In addition to 32/128bit variants, we also have to support the
"Signal-on-QNaN (SQ)" bit.

Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Signed-off-by: David Hildenbrand <david@redhat.com>
Message-Id: <20210608092337.12221-16-david@redhat.com>
Signed-off-by: Cornelia Huck <cohuck@redhat.com>
5 years agos390x/tcg: Implement 32/128 bit for VECTOR (LOAD FP INTEGER|FP SQUARE ROOT)
David Hildenbrand [Tue, 8 Jun 2021 09:23:25 +0000 (11:23 +0200)]
s390x/tcg: Implement 32/128 bit for VECTOR (LOAD FP INTEGER|FP SQUARE ROOT)

Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Signed-off-by: David Hildenbrand <david@redhat.com>
Message-Id: <20210608092337.12221-15-david@redhat.com>
Signed-off-by: Cornelia Huck <cohuck@redhat.com>
5 years agos390x/tcg: Implement 32/128 bit for VECTOR FP (ADD|DIVIDE|MULTIPLY|SUBTRACT)
David Hildenbrand [Tue, 8 Jun 2021 09:23:24 +0000 (11:23 +0200)]
s390x/tcg: Implement 32/128 bit for VECTOR FP (ADD|DIVIDE|MULTIPLY|SUBTRACT)

In case of 128bit, we always have a single element. Add new helpers for
reading/writing 32/128 bit floats.

Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Signed-off-by: David Hildenbrand <david@redhat.com>
Message-Id: <20210608092337.12221-14-david@redhat.com>
Signed-off-by: Cornelia Huck <cohuck@redhat.com>
5 years agos390x/tcg: Implement VECTOR MULTIPLY SUM LOGICAL
David Hildenbrand [Tue, 8 Jun 2021 09:23:23 +0000 (11:23 +0200)]
s390x/tcg: Implement VECTOR MULTIPLY SUM LOGICAL

Fortunately, we only need the Doubleword implementation.

Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Signed-off-by: David Hildenbrand <david@redhat.com>
Message-Id: <20210608092337.12221-13-david@redhat.com>
Signed-off-by: Cornelia Huck <cohuck@redhat.com>
5 years agos390x/tcg: Implement VECTOR BIT PERMUTE
David Hildenbrand [Tue, 8 Jun 2021 09:23:22 +0000 (11:23 +0200)]
s390x/tcg: Implement VECTOR BIT PERMUTE

Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Signed-off-by: David Hildenbrand <david@redhat.com>
Message-Id: <20210608092337.12221-12-david@redhat.com>
Signed-off-by: Cornelia Huck <cohuck@redhat.com>
5 years agos390x/tcg: Simplify wfc64() handling
David Hildenbrand [Tue, 8 Jun 2021 09:23:21 +0000 (11:23 +0200)]
s390x/tcg: Simplify wfc64() handling

... and prepare for 32/128 bit support.

Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Signed-off-by: David Hildenbrand <david@redhat.com>
Message-Id: <20210608092337.12221-11-david@redhat.com>
Signed-off-by: Cornelia Huck <cohuck@redhat.com>
5 years agos390x/tcg: Simplify vflr64() handling
David Hildenbrand [Tue, 8 Jun 2021 09:23:20 +0000 (11:23 +0200)]
s390x/tcg: Simplify vflr64() handling

Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Signed-off-by: David Hildenbrand <david@redhat.com>
Message-Id: <20210608092337.12221-10-david@redhat.com>
Signed-off-by: Cornelia Huck <cohuck@redhat.com>
5 years agos390x/tcg: Simplify vfll32() handling
David Hildenbrand [Tue, 8 Jun 2021 09:23:19 +0000 (11:23 +0200)]
s390x/tcg: Simplify vfll32() handling

Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Signed-off-by: David Hildenbrand <david@redhat.com>
Message-Id: <20210608092337.12221-9-david@redhat.com>
Signed-off-by: Cornelia Huck <cohuck@redhat.com>
5 years agos390x/tcg: Simplify vfma64() handling
David Hildenbrand [Tue, 8 Jun 2021 09:23:18 +0000 (11:23 +0200)]
s390x/tcg: Simplify vfma64() handling

Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Signed-off-by: David Hildenbrand <david@redhat.com>
Message-Id: <20210608092337.12221-8-david@redhat.com>
Signed-off-by: Cornelia Huck <cohuck@redhat.com>
5 years agos390x/tcg: Simplify vftci64() handling
David Hildenbrand [Tue, 8 Jun 2021 09:23:17 +0000 (11:23 +0200)]
s390x/tcg: Simplify vftci64() handling

Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Signed-off-by: David Hildenbrand <david@redhat.com>
Message-Id: <20210608092337.12221-7-david@redhat.com>
Signed-off-by: Cornelia Huck <cohuck@redhat.com>
5 years agos390x/tcg: Simplify vfc64() handling
David Hildenbrand [Tue, 8 Jun 2021 09:23:16 +0000 (11:23 +0200)]
s390x/tcg: Simplify vfc64() handling

Pass the m5 field via simd_data() and don't provide specialized handlers
for single-element variants.

Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Signed-off-by: David Hildenbrand <david@redhat.com>
Message-Id: <20210608092337.12221-6-david@redhat.com>
Signed-off-by: Cornelia Huck <cohuck@redhat.com>
5 years agos390x/tcg: Simplify vop64_2() handling
David Hildenbrand [Tue, 8 Jun 2021 09:23:15 +0000 (11:23 +0200)]
s390x/tcg: Simplify vop64_2() handling

Let's rework our macros and simplify. We still need helper functions in
most cases due to the different parameters types.

Next, we'll only have 32/128bit variants for vfi and vfsq, so special
case the others.

Note that for vfsq, the XxC and erm passed in the simd_data() will never be
set, resulting in the same behavior.

Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Signed-off-by: David Hildenbrand <david@redhat.com>
Message-Id: <20210608092337.12221-5-david@redhat.com>
Signed-off-by: Cornelia Huck <cohuck@redhat.com>
5 years agos390x/tcg: Simplify vop64_3() handling
David Hildenbrand [Tue, 8 Jun 2021 09:23:14 +0000 (11:23 +0200)]
s390x/tcg: Simplify vop64_3() handling

Let's simplify, reworking our handler generation, passing the whole "m5"
register content and not providing specialized handlers for "se", and
reading/writing proper float64 values using new helpers.

Suggested-by: Richard Henderson <richard.henderson@linaro.org>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Signed-off-by: David Hildenbrand <david@redhat.com>
Message-Id: <20210608092337.12221-4-david@redhat.com>
Signed-off-by: Cornelia Huck <cohuck@redhat.com>
5 years agos390x/tcg: Fix instruction name for VECTOR FP LOAD (LENGTHENED|ROUNDED)
David Hildenbrand [Tue, 8 Jun 2021 09:23:13 +0000 (11:23 +0200)]
s390x/tcg: Fix instruction name for VECTOR FP LOAD (LENGTHENED|ROUNDED)

Let's use the correct name.

Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Signed-off-by: David Hildenbrand <david@redhat.com>
Message-Id: <20210608092337.12221-3-david@redhat.com>
Signed-off-by: Cornelia Huck <cohuck@redhat.com>
5 years agos390x/tcg: Fix FP CONVERT TO (LOGICAL) FIXED NaN handling
David Hildenbrand [Tue, 8 Jun 2021 09:23:12 +0000 (11:23 +0200)]
s390x/tcg: Fix FP CONVERT TO (LOGICAL) FIXED NaN handling

In case we encounter a NaN, we have to return the smallest possible
number, corresponding to either 0 or the maximum negative number. This
seems to differ from IEEE handling as implemented in softfloat, whereby
we return the biggest possible number.

While at it, use float32_to_uint64() in the CLGEB handler.

Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Signed-off-by: David Hildenbrand <david@redhat.com>
Message-Id: <20210608092337.12221-2-david@redhat.com>
Signed-off-by: Cornelia Huck <cohuck@redhat.com>
5 years agos390x/kvm: remove unused gs handling
Cornelia Huck [Wed, 2 Jun 2021 12:50:50 +0000 (14:50 +0200)]
s390x/kvm: remove unused gs handling

With commit 0280b3eb7c05 ("s390x/kvm: use cpu model for gscb on
compat machines"), we removed any calls to kvm_s390_get_gs()
in favour of a different mechanism.

Let's remove the unused kvm_s390_get_gs(), and with it the now
unneeded cap_gs as well.

Signed-off-by: Cornelia Huck <cohuck@redhat.com>
Reviewed-by: Christian Borntraeger <borntraeger@de.ibm.com>
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Reviewed-by: Thomas Huth <thuth@redhat.com>
Message-Id: <20210602125050.492500-1-cohuck@redhat.com>

5 years agofuzz: Display hexadecimal value with '0x' prefix
Philippe Mathieu-Daudé [Sat, 12 Jun 2021 19:58:42 +0000 (21:58 +0200)]
fuzz: Display hexadecimal value with '0x' prefix

Use memory_region_size() to get the MemoryRegion size,
and display it with the '0x' prefix.

Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Reviewed-by: Alexander Bulekov <alxndr@bu.edu>
Reviewed-by: Laurent Vivier <laurent@vivier.eu>
Reviewed-by: Thomas Huth <thuth@redhat.com>
Message-Id: <20210612195842.1595999-1-f4bug@amsat.org>
Signed-off-by: Thomas Huth <thuth@redhat.com>
5 years agoRemove leading underscores from QEMU defines
Ahmed Abouzied [Sat, 5 Jun 2021 17:49:38 +0000 (19:49 +0200)]
Remove leading underscores from QEMU defines

Leading underscores followed by a capital letter or underscore are
reserved by the C standard.

Resolves: https://gitlab.com/qemu-project/qemu/-/issues/369

Signed-off-by: Ahmed Abouzied <email@aabouzied.com>
Message-Id: <20210605174938.13782-1-email@aabouzied.com>
Signed-off-by: Thomas Huth <thuth@redhat.com>
5 years agoUpdate documentation to refer to new location for issues
Stefan Weil [Sat, 19 Jun 2021 15:42:53 +0000 (17:42 +0200)]
Update documentation to refer to new location for issues

Signed-off-by: Stefan Weil <sw@weilnetz.de>
Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
Reviewed-by: Thomas Huth <thuth@redhat.com>
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Message-Id: <20210619154253.553446-1-sw@weilnetz.de>
Signed-off-by: Thomas Huth <thuth@redhat.com>
5 years agodocs/tools/virtiofsd: Fix bad rst syntax
Thomas Huth [Mon, 7 Jun 2021 18:00:15 +0000 (20:00 +0200)]
docs/tools/virtiofsd: Fix bad rst syntax

For literal blocks, there has to be an empty line after the two colons,
and the block itself should be indented.

Signed-off-by: Thomas Huth <thuth@redhat.com>
Reviewed-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
Message-Id: <20210607180015.924571-1-thuth@redhat.com>
Signed-off-by: Thomas Huth <thuth@redhat.com>
5 years agodocs/tools/virtiofsd.rst: Do not hard-code the QEMU binary name
Thomas Huth [Mon, 7 Jun 2021 17:42:50 +0000 (19:42 +0200)]
docs/tools/virtiofsd.rst: Do not hard-code the QEMU binary name

In downstream, we want to use a different name for the QEMU binary,
and some people might also use the docs for non-x86 binaries, that's
why we already created the |qemu_system| placeholder in the past.
Use it now in the virtiofsd doc, too.

Signed-off-by: Thomas Huth <thuth@redhat.com>
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
Reviewed-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
Message-Id: <20210607174250.920226-1-thuth@redhat.com>
Signed-off-by: Thomas Huth <thuth@redhat.com>
5 years agodocs/interop/live-block-operations: Do not hard-code the QEMU binary name
Thomas Huth [Mon, 7 Jun 2021 17:23:11 +0000 (19:23 +0200)]
docs/interop/live-block-operations: Do not hard-code the QEMU binary name

In downstream, we want to use a different name for the QEMU binary,
and some people might also use the docs for non-x86 binaries, that's
why we already created the |qemu_system| placeholder in the past.
Use it now in the live-block-operations doc, too.

Signed-off-by: Thomas Huth <thuth@redhat.com>
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Message-Id: <20210607172311.915385-1-thuth@redhat.com>
Signed-off-by: Thomas Huth <thuth@redhat.com>
5 years agoMerge remote-tracking branch 'remotes/ericb/tags/pull-nbd-2021-06-15-v2' into staging
Peter Maydell [Sun, 20 Jun 2021 20:20:13 +0000 (21:20 +0100)]
Merge remote-tracking branch 'remotes/ericb/tags/pull-nbd-2021-06-15-v2' into staging

nbd patches for 2021-06-15

- bug fixes in coroutine aio context handling
- rework NBD client connection logic to perform more work in coroutine

# gpg: Signature made Fri 18 Jun 2021 18:29:39 BST
# gpg:                using RSA key 71C2CC22B1C4602927D2F3AAA7A16B4A2527436A
# gpg: Good signature from "Eric Blake <eblake@redhat.com>" [full]
# gpg:                 aka "Eric Blake (Free Software Programmer) <ebb9@byu.net>" [full]
# gpg:                 aka "[jpeg image of size 6874]" [full]
# Primary key fingerprint: 71C2 CC22 B1C4 6029 27D2  F3AA A7A1 6B4A 2527 436A

* remotes/ericb/tags/pull-nbd-2021-06-15-v2: (34 commits)
  block/nbd: safer transition to receiving request
  block/nbd: add nbd_client_connected() helper
  block/nbd: reuse nbd_co_do_establish_connection() in nbd_open()
  nbd/client-connection: add option for non-blocking connection attempt
  block/nbd: split nbd_co_do_establish_connection out of nbd_reconnect_attempt
  block-coroutine-wrapper: allow non bdrv_ prefix
  nbd/client-connection: return only one io channel
  block/nbd: drop BDRVNBDState::sioc
  block/nbd: don't touch s->sioc in nbd_teardown_connection()
  block/nbd: use negotiation of NBDClientConnection
  block/nbd: split nbd_handle_updated_info out of nbd_client_handshake()
  nbd/client-connection: shutdown connection on release
  nbd/client-connection: implement connection retry
  nbd/client-connection: add possibility of negotiation
  nbd/client-connection: use QEMU_LOCK_GUARD
  nbd: move connection code from block/nbd to nbd/client-connection
  block/nbd: introduce nbd_client_connection_release()
  block/nbd: introduce nbd_client_connection_new()
  block/nbd: rename NBDConnectThread to NBDClientConnection
  block/nbd: make nbd_co_establish_connection_cancel() bs-independent
  ...

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
5 years agolinux-user: Use public sigev_notify_thread_id member if available
Michael Forney [Wed, 26 May 2021 03:55:56 +0000 (20:55 -0700)]
linux-user: Use public sigev_notify_thread_id member if available

_sigev_un._tid is an internal glibc field and is not available on
musl libc. The sigevent(7) man page and Linux UAPI headers both use
sigev_notify_thread_id as a public way to access this field.

musl libc supports this field since 1.2.2[0], and glibc plans to
add support as well[1][2].

If sigev_notify_thread_id is not available, fall back to _sigev_un._tid
as before.

[0] http://git.musl-libc.org/cgit/musl/commit/?id=7c71792e87691451f2a6b76348e83ad1889f1dcb
[1] https://www.openwall.com/lists/musl/2019/08/01/5
[2] https://sourceware.org/bugzilla/show_bug.cgi?id=27417

Signed-off-by: Michael Forney <mforney@mforney.org>
Reviewed-by: Laurent Vivier <laurent@vivier.eu>
Message-Id: <20210526035556.7931-1-mforney@mforney.org>
Signed-off-by: Laurent Vivier <laurent@vivier.eu>
5 years agolinux-user: Fix incorrect use of feature-test-macros
Michael Forney [Wed, 26 May 2021 03:55:31 +0000 (20:55 -0700)]
linux-user: Fix incorrect use of feature-test-macros

The _POSIX_C_SOURCE and _XOPEN_SOURCE macros are used by the
application to indicate to libc which declarations it should expose.
Since qemu does not define them anywhere, it does not make sense
to check their value.

Instead, since the intent is to determine whether the host struct
stat supports the st_*tim fields, use the configure test result
which does exactly that.

Signed-off-by: Michael Forney <mforney@mforney.org>
Reviewed-by: Laurent Vivier <laurent@vivier.eu>
Message-Id: <20210526035531.7871-1-mforney@mforney.org>
Signed-off-by: Laurent Vivier <laurent@vivier.eu>
5 years agolinux-user: Check for ieee128 fpbits in PPC64 HWCAP2 feature list
Khem Raj [Mon, 14 Jun 2021 19:17:29 +0000 (12:17 -0700)]
linux-user: Check for ieee128 fpbits in PPC64 HWCAP2 feature list

glibc 2.34 is now checking for this in hwcaps at
runtime [1] and failing to run the binary if machine
does not support 128bit IEEE fp

Fixes
Fatal glibc error: CPU lacks float128 support (POWER 9 or later required)

[1] https://sourceware.org/git/?p=glibc.git;a=commitdiff;h=d337345ce145e23c5f3a956f349d924fdf54ce2d;hp=eb24865637a271ab7dad13190330105eab0d478d

Signed-off-by: Khem Raj <raj.khem@gmail.com>
Cc: Florian Weimer <fweimer@redhat.com>
Reviewed-by: Laurent Vivier <laurent@vivier.eu>
Message-Id: <20210614191729.2981488-1-raj.khem@gmail.com>
Signed-off-by: Laurent Vivier <laurent@vivier.eu>
5 years agotests/tcg/linux-test: Check that sigaction can query SIGKILL/SIGSTOP
Ilya Leoshkevich [Tue, 1 Jun 2021 14:56:00 +0000 (16:56 +0200)]
tests/tcg/linux-test: Check that sigaction can query SIGKILL/SIGSTOP

Verify that querying is allowed, but making changes isn't.

Signed-off-by: Ilya Leoshkevich <iii@linux.ibm.com>
Reviewed-by: Laurent Vivier <laurent@vivier.eu>
Message-Id: <20210601145600.3131040-3-iii@linux.ibm.com>
Signed-off-by: Laurent Vivier <laurent@vivier.eu>
5 years agolinux-user: Let sigaction query SIGKILL/SIGSTOP
Ilya Leoshkevich [Tue, 1 Jun 2021 14:55:59 +0000 (16:55 +0200)]
linux-user: Let sigaction query SIGKILL/SIGSTOP

The kernel allows doing this, so let's allow this in qemu as well.
Valgrind relies on this.

Signed-off-by: Ilya Leoshkevich <iii@linux.ibm.com>
Reviewed-by: Laurent Vivier <laurent@vivier.eu>
Message-Id: <20210601145600.3131040-2-iii@linux.ibm.com>
Signed-off-by: Laurent Vivier <laurent@vivier.eu>
5 years agolinux-user: Implement pivot_root
YAMAMOTO Takashi [Mon, 31 May 2021 05:50:12 +0000 (14:50 +0900)]
linux-user: Implement pivot_root

Used by runc.

Signed-off-by: YAMAMOTO Takashi <yamamoto@midokura.com>
Reviewed-by: Laurent Vivier <laurent@vivier.eu>
Message-Id: <20210531055019.10149-6-yamamoto@midokura.com>
Signed-off-by: Laurent Vivier <laurent@vivier.eu>
5 years agoutil/oslib-win32: Fix fatal assertion in qemu_try_memalign
Stefan Weil [Fri, 11 Jun 2021 10:58:46 +0000 (12:58 +0200)]
util/oslib-win32: Fix fatal assertion in qemu_try_memalign

The function is called with alignment == 0 which caused an assertion.
Use the code from oslib-posix.c to fix that regression.

Fixes: ed6f53f9ca9
Signed-off-by: Stefan Weil <sw@weilnetz.de>
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Message-Id: <20210611105846.347954-1-sw@weilnetz.de>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
5 years agotcg: expose TCGCond manipulation routines
Alessandro Di Federico [Sat, 19 Jun 2021 09:37:00 +0000 (11:37 +0200)]
tcg: expose TCGCond manipulation routines

This commit moves into a separate file routines used to manipulate
TCGCond. These will be employed by the idef-parser.

Signed-off-by: Alessandro Di Federico <ale@rev.ng>
Signed-off-by: Paolo Montesel <babush@rev.ng>
Message-Id: <20210619093713.1845446-2-ale.qemu@rev.ng>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
5 years agotcg: Restart when exhausting the stack frame
Richard Henderson [Sat, 19 Jun 2021 13:32:03 +0000 (06:32 -0700)]
tcg: Restart when exhausting the stack frame

Assume that we'll have fewer temps allocated after
restarting with a fewer number of instructions.

Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
5 years agotcg: Allocate sufficient storage in temp_allocate_frame
Richard Henderson [Sat, 19 Jun 2021 04:53:27 +0000 (21:53 -0700)]
tcg: Allocate sufficient storage in temp_allocate_frame

This function should have been updated for vector types
when they were introduced.

Fixes: d2fd745fe8b
Resolves: https://gitlab.com/qemu-project/qemu/-/issues/367
Cc: qemu-stable@nongnu.org
Tested-by: Stefan Weil <sw@weilnetz.de>
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
5 years agotcg/sparc: Fix temp_allocate_frame vs sparc stack bias
Richard Henderson [Fri, 18 Jun 2021 23:49:26 +0000 (16:49 -0700)]
tcg/sparc: Fix temp_allocate_frame vs sparc stack bias

We should not be aligning the offset in temp_allocate_frame,
because the odd offset produces an aligned address in the end.
Instead, pass the logical offset into tcg_set_frame and add
the stack bias last.

Cc: qemu-stable@nongnu.org
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
5 years agoaccel/tcg: Probe the proper permissions for atomic ops
Richard Henderson [Sun, 13 Jun 2021 00:21:06 +0000 (17:21 -0700)]
accel/tcg: Probe the proper permissions for atomic ops

We had a single ATOMIC_MMU_LOOKUP macro that probed for
read+write on all atomic ops.  This is incorrect for
plain atomic load and atomic store.

For user-only, we rely on the host page permissions.

Resolves: https://gitlab.com/qemu-project/qemu/-/issues/390
Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
5 years agotests/tcg: Increase timeout for TCI
Richard Henderson [Mon, 8 Feb 2021 02:15:04 +0000 (18:15 -0800)]
tests/tcg: Increase timeout for TCI

The longest test at the moment seems to be a (slower)
aarch64 host, for which test-mmap takes 64 seconds.

Tested-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Acked-by: Alex Bennée <alex.bennee@linaro.org>
Reviewed-by: Thomas Huth <thuth@redhat.com>
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
5 years agotcg/tci: Use {set,clear}_helper_retaddr
Richard Henderson [Thu, 27 May 2021 19:41:07 +0000 (12:41 -0700)]
tcg/tci: Use {set,clear}_helper_retaddr

Wrap guest memory operations for tci like we do for cpu_ld*_data.

We cannot actually use the cpu_ldst.h interface without duplicating
the memory trace operations performed within, which will already
have been expanded into the tcg opcode stream.

Tested-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
5 years agotcg/tci: Remove the qemu_ld/st_type macros
Richard Henderson [Thu, 27 May 2021 19:37:57 +0000 (12:37 -0700)]
tcg/tci: Remove the qemu_ld/st_type macros

These macros are only used in one place.  By expanding,
we get to apply some common-subexpression elimination
and create some local variables.

Tested-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
5 years agoRevert "tcg/tci: Use exec/cpu_ldst.h interfaces"
Richard Henderson [Thu, 27 May 2021 19:24:25 +0000 (12:24 -0700)]
Revert "tcg/tci: Use exec/cpu_ldst.h interfaces"

This reverts commit dc09f047eddec8f4a1991c4f5f4a428d7aa3f2c0.

For tcg, tracepoints are expanded inline in tcg opcodes.
Using a helper which generates a second tracepoint is incorrect.

For system mode, the extraction and re-packing of MemOp and mmu_idx
lost the alignment information from MemOp.  So we were no longer
raising alignment exceptions for !TARGET_ALIGNED_ONLY guests.
This can be seen in tests/tcg/xtensa/test_load_store.S.

For user mode, we must update to the new signature of g2h() so that
the revert compiles.  We can leave set_helper_retaddr for later.

Tested-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
5 years agotcg/tci: Split out tci_qemu_ld, tci_qemu_st
Richard Henderson [Thu, 27 May 2021 19:21:59 +0000 (12:21 -0700)]
tcg/tci: Split out tci_qemu_ld, tci_qemu_st

We can share this code between 32-bit and 64-bit loads and stores.

Tested-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
5 years agotcg/tci: Implement add2, sub2
Richard Henderson [Wed, 3 Feb 2021 01:40:12 +0000 (17:40 -0800)]
tcg/tci: Implement add2, sub2

We already had the 32-bit versions for a 32-bit host; expand this
to 64-bit hosts as well.  The 64-bit opcodes are new.

Tested-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
5 years agotcg/tci: Implement mulu2, muls2
Richard Henderson [Wed, 3 Feb 2021 01:21:27 +0000 (17:21 -0800)]
tcg/tci: Implement mulu2, muls2

We already had mulu2_i32 for a 32-bit host; expand this to 64-bit
hosts as well.  The muls2_i32 and the 64-bit opcodes are new.

Tested-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
5 years agotcg/tci: Implement clz, ctz, ctpop
Richard Henderson [Wed, 3 Feb 2021 01:01:57 +0000 (17:01 -0800)]
tcg/tci: Implement clz, ctz, ctpop

Tested-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
5 years agotcg/tci: Implement extract, sextract
Richard Henderson [Wed, 3 Feb 2021 00:48:48 +0000 (16:48 -0800)]
tcg/tci: Implement extract, sextract

Tested-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
5 years agotcg/tci: Implement andc, orc, eqv, nand, nor
Richard Henderson [Wed, 3 Feb 2021 00:29:18 +0000 (16:29 -0800)]
tcg/tci: Implement andc, orc, eqv, nand, nor

These were already present in tcg-target.c.inc,
but not in the interpreter.

Tested-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
5 years agotcg/tci: Implement movcond
Richard Henderson [Wed, 3 Feb 2021 00:15:45 +0000 (16:15 -0800)]
tcg/tci: Implement movcond

When this opcode is not available in the backend, tcg middle-end
will expand this as a series of 5 opcodes.  So implementing this
saves bytecode space.

Tested-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
5 years agotcg/tci: Implement goto_ptr
Richard Henderson [Tue, 2 Feb 2021 19:40:22 +0000 (09:40 -1000)]
tcg/tci: Implement goto_ptr

This operation is critical to staying within the interpretation
loop longer, which avoids the overhead of setup and teardown for
many TBs.

The check in tcg_prologue_init is disabled because TCI does
want to use NULL to indicate exit, as opposed to branching to
a real epilogue.

Tested-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
5 years agotcg/tci: Change encoding to uint32_t units
Richard Henderson [Tue, 2 Feb 2021 07:27:41 +0000 (21:27 -1000)]
tcg/tci: Change encoding to uint32_t units

This removes all of the problems with unaligned accesses
to the bytecode stream.

With an 8-bit opcode at the bottom, we have 24 bits remaining,
which are generally split into 6 4-bit slots.  This fits well
with the maximum length opcodes, e.g. INDEX_op_add2_i32, which
have 6 register operands.

We have, in previous patches, rearranged things such that there
are no operations with a label which have more than one other
operand.  Which leaves us with a 20-bit field in which to encode
a label, giving us a maximum TB size of 512k -- easily large.

Change the INDEX_op_tci_movi_{i32,i64} opcodes to tci_mov[il].
The former puts the immediate in the upper 20 bits of the insn,
like we do for the label displacement.  The later uses a label
to reference an entry in the constant pool.  Thus, in the worst
case we still have a single memory reference for any constant,
but now the constants are out-of-line of the bytecode and can
be shared between different moves saving space.

Change INDEX_op_call to use a label to reference a pair of
pointers in the constant pool.  This removes the only slightly
dodgy link with the layout of struct TCGHelperInfo.

The re-encode cannot be done in pieces.

Tested-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
5 years agotcg/tci: Remove tci_write_reg
Richard Henderson [Mon, 1 Feb 2021 21:30:30 +0000 (11:30 -1000)]
tcg/tci: Remove tci_write_reg

Inline it into its one caller, tci_write_reg64.
Drop the asserts that are redundant with tcg_read_r.

Tested-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
5 years agotcg/tci: Emit setcond before brcond
Richard Henderson [Mon, 1 Feb 2021 19:41:20 +0000 (09:41 -1000)]
tcg/tci: Emit setcond before brcond

The encoding planned for tci does not have enough room for
brcond2, with 4 registers and a condition as input as well
as the label.  Resolve the condition into TCG_REG_TMP, and
relax brcond to one register plus a label, considering the
condition to always be reg != 0.

Tested-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
5 years agotcg/tci: Reserve r13 for a temporary
Richard Henderson [Mon, 1 Feb 2021 09:26:14 +0000 (23:26 -1000)]
tcg/tci: Reserve r13 for a temporary

We're about to adjust the offset range on host memory ops,
and the format of branches.  Both will require a temporary.

Tested-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
5 years agotcg/tci: Use ffi for calls
Richard Henderson [Sat, 30 Jan 2021 22:24:25 +0000 (14:24 -0800)]
tcg/tci: Use ffi for calls

This requires adjusting where arguments are stored.
Place them on the stack at left-aligned positions.
Adjust the stack frame to be at entirely positive offsets.

Tested-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
5 years agotcg/tci: Move call-return regs to end of tcg_target_reg_alloc_order
Richard Henderson [Mon, 1 Feb 2021 09:23:07 +0000 (23:23 -1000)]
tcg/tci: Move call-return regs to end of tcg_target_reg_alloc_order

As the only call-clobbered regs for TCI, these should
receive the least priority.

Tested-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
5 years agotcg/tci: Improve tcg_target_call_clobber_regs
Richard Henderson [Fri, 29 Jan 2021 20:00:42 +0000 (10:00 -1000)]
tcg/tci: Improve tcg_target_call_clobber_regs

The current setting is much too pessimistic.  Indicating only
the one or two registers that are actually assigned after a
call should avoid unnecessary movement between the register
array and the stack array.

Tested-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
5 years agotcg: Build ffi data structures for helpers
Richard Henderson [Thu, 18 Mar 2021 18:46:44 +0000 (12:46 -0600)]
tcg: Build ffi data structures for helpers

Add libffi as a build requirement for TCI.
Add libffi to the dockerfiles to satisfy that requirement.

Construct an ffi_cif structure for each unique typemask.
Record the result in a separate hash table for later lookup;
this allows helper_table to stay const.

Tested-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
5 years agotcg: Add tcg_call_func
Richard Henderson [Thu, 18 Mar 2021 22:40:07 +0000 (16:40 -0600)]
tcg: Add tcg_call_func

Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Tested-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
5 years agotcg: Store the TCGHelperInfo in the TCGOp for call
Richard Henderson [Thu, 18 Mar 2021 17:29:50 +0000 (11:29 -0600)]
tcg: Store the TCGHelperInfo in the TCGOp for call

This will give us both flags and typemask for use later.

We also fix a dumping bug, wherein calls generated for plugins
fail tcg_find_helper and print (null) instead of either a name
or the raw function pointer.

Tested-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
5 years agoaccel/tcg: Add tcg call flags to plugins helpers
Richard Henderson [Fri, 19 Mar 2021 20:28:17 +0000 (14:28 -0600)]
accel/tcg: Add tcg call flags to plugins helpers

As noted by qemu-plugins.h, plugins can neither read nor write
guest registers.

Tested-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
5 years agoplugins: Drop tcg_flags from struct qemu_plugin_dyn_cb
Richard Henderson [Fri, 19 Mar 2021 20:18:30 +0000 (14:18 -0600)]
plugins: Drop tcg_flags from struct qemu_plugin_dyn_cb

As noted by qemu-plugins.h, enum qemu_plugin_cb_flags is
currently unused -- plugins can neither read nor write
guest registers.

Tested-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
5 years agoaccel/tcg/plugin-gen: Drop inline markers
Richard Henderson [Fri, 19 Mar 2021 19:01:32 +0000 (13:01 -0600)]
accel/tcg/plugin-gen: Drop inline markers

Let the compiler decide on inlining.

Tested-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
5 years agotcg: Add tcg_call_flags
Richard Henderson [Thu, 18 Mar 2021 16:21:45 +0000 (10:21 -0600)]
tcg: Add tcg_call_flags

We're going to change how to look up the call flags from a TCGop,
so extract it as a helper.

Tested-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
5 years agotcg: Combine dh_is_64bit and dh_is_signed to dh_typecode
Richard Henderson [Thu, 18 Mar 2021 16:01:01 +0000 (10:01 -0600)]
tcg: Combine dh_is_64bit and dh_is_signed to dh_typecode

We will shortly be interested in distinguishing pointers
from integers in the helper's declaration, as well as a
true void return.  We currently have two parallel 1 bit
fields; merge them and expand to a 3 bit field.

Our current maximum is 7 helper arguments, plus the return
makes 8 * 3 = 24 bits used within the uint32_t typemask.

Tested-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
5 years agoscripts/qmp-shell: add redirection shim
John Snow [Mon, 7 Jun 2021 20:06:49 +0000 (16:06 -0400)]
scripts/qmp-shell: add redirection shim

qmp-shell has a new home, add a redirect for a little while as the dust
settles.

Signed-off-by: John Snow <jsnow@redhat.com>
Message-id: 20210607200649.1840382-43-jsnow@redhat.com
Signed-off-by: John Snow <jsnow@redhat.com>
5 years agopython: add qmp-shell entry point
John Snow [Mon, 7 Jun 2021 20:06:48 +0000 (16:06 -0400)]
python: add qmp-shell entry point

now 'qmp-shell' should be available from the command line when
installing the python package.

Signed-off-by: John Snow <jsnow@redhat.com>
Message-id: 20210607200649.1840382-42-jsnow@redhat.com
Signed-off-by: John Snow <jsnow@redhat.com>
5 years agoscripts/qmp-shell: move to python/qemu/qmp/qmp_shell.py
John Snow [Mon, 7 Jun 2021 20:06:47 +0000 (16:06 -0400)]
scripts/qmp-shell: move to python/qemu/qmp/qmp_shell.py

The script will be unavailable for a commit or two, which will help
preserve development history attached to the new file. A forwarder will
be added shortly afterwards.

With qmp_shell in the python qemu.qmp package, now it is fully type
checked, linted, etc. via the Python CI. It will be quite a bit harder
to accidentally break it again in the future.

Signed-off-by: John Snow <jsnow@redhat.com>
Message-id: 20210607200649.1840382-41-jsnow@redhat.com
Signed-off-by: John Snow <jsnow@redhat.com>
5 years agoscripts/qmp-shell: add docstrings
John Snow [Mon, 7 Jun 2021 20:06:46 +0000 (16:06 -0400)]
scripts/qmp-shell: add docstrings

Signed-off-by: John Snow <jsnow@redhat.com>
Message-id: 20210607200649.1840382-40-jsnow@redhat.com
Signed-off-by: John Snow <jsnow@redhat.com>
5 years agoscripts/qmp-shell: make QMPShellError inherit QMPError
John Snow [Mon, 7 Jun 2021 20:06:45 +0000 (16:06 -0400)]
scripts/qmp-shell: make QMPShellError inherit QMPError

In preparation for moving qmp-shell into the qemu.qmp package, make
QMPShellError inherit from QMPError so that all custom errors in this
package all derive from QMPError.

Signed-off-by: John Snow <jsnow@redhat.com>
Message-id: 20210607200649.1840382-39-jsnow@redhat.com
Signed-off-by: John Snow <jsnow@redhat.com>
5 years agoscripts/qmp-shell: remove double-underscores
John Snow [Mon, 7 Jun 2021 20:06:44 +0000 (16:06 -0400)]
scripts/qmp-shell: remove double-underscores

They're not needed; single underscore is enough to express intent that
these methods are "internal". double underscore is used as a weak name
mangling, but that isn't beneficial for us here.

Signed-off-by: John Snow <jsnow@redhat.com>
Message-id: 20210607200649.1840382-38-jsnow@redhat.com
Signed-off-by: John Snow <jsnow@redhat.com>
5 years agoscripts/qmp-shell: convert usage comment to docstring
John Snow [Mon, 7 Jun 2021 20:06:43 +0000 (16:06 -0400)]
scripts/qmp-shell: convert usage comment to docstring

The nice usage comment should be a docstring instead of a comment, so
that it's visible from other python tooling.

Signed-off-by: John Snow <jsnow@redhat.com>
Message-id: 20210607200649.1840382-37-jsnow@redhat.com
Signed-off-by: John Snow <jsnow@redhat.com>
5 years agoscripts/qmp-shell: Remove too-broad-exception
John Snow [Mon, 7 Jun 2021 20:06:42 +0000 (16:06 -0400)]
scripts/qmp-shell: Remove too-broad-exception

We are only anticipating QMPShellErrors here, for syntax we weren't able
to understand. Other errors, if any, should be allowed to percolate
upwards.

Signed-off-by: John Snow <jsnow@redhat.com>
Message-id: 20210607200649.1840382-36-jsnow@redhat.com
Signed-off-by: John Snow <jsnow@redhat.com>
5 years agoscripts/qmp-shell: Fix empty-transaction invocation
John Snow [Mon, 7 Jun 2021 20:06:41 +0000 (16:06 -0400)]
scripts/qmp-shell: Fix empty-transaction invocation

calling "transaction( )" is pointless, but valid. Rework the parser to
allow this kind of invocation. This helps clean up exception handling
later by removing accidental breakages of the parser that aren't
explicitly forbidden.

Signed-off-by: John Snow <jsnow@redhat.com>
Message-id: 20210607200649.1840382-35-jsnow@redhat.com
Signed-off-by: John Snow <jsnow@redhat.com>
5 years agoscripts/qmp-shell: remove TODO
John Snow [Mon, 7 Jun 2021 20:06:40 +0000 (16:06 -0400)]
scripts/qmp-shell: remove TODO

We still want to revamp qmp-shell again, but there's much more to the
idea than the comment now intuits. Remove it.

Signed-off-by: John Snow <jsnow@redhat.com>
Message-id: 20210607200649.1840382-34-jsnow@redhat.com
Signed-off-by: John Snow <jsnow@redhat.com>
5 years agoscripts/qmp-shell: use logging to show warnings
John Snow [Mon, 7 Jun 2021 20:06:39 +0000 (16:06 -0400)]
scripts/qmp-shell: use logging to show warnings

A perfect candidate is non-fatal shell history messages.

Signed-off-by: John Snow <jsnow@redhat.com>
Message-id: 20210607200649.1840382-33-jsnow@redhat.com
Signed-off-by: John Snow <jsnow@redhat.com>
5 years agoscripts/qmp-shell: Use context manager instead of atexit
John Snow [Mon, 7 Jun 2021 20:06:38 +0000 (16:06 -0400)]
scripts/qmp-shell: Use context manager instead of atexit

We can invoke the shell history writing when we leave the QMPShell scope
instead of relying on atexit. Doing so may be preferable to avoid global
state being registered from within a class instead of from the
application logic directly.

Use QMP's context manager to hook this history saving at close time,
which gets invoked when we leave the context block.

Signed-off-by: John Snow <jsnow@redhat.com>
Message-id: 20210607200649.1840382-32-jsnow@redhat.com
Signed-off-by: John Snow <jsnow@redhat.com>
5 years agopython/qmp: return generic type from context manager
John Snow [Mon, 7 Jun 2021 20:06:37 +0000 (16:06 -0400)]
python/qmp: return generic type from context manager

__enter__ can be invoked from a subclass, so it needs a more flexible
type.

Signed-off-by: John Snow <jsnow@redhat.com>
Message-id: 20210607200649.1840382-31-jsnow@redhat.com
Signed-off-by: John Snow <jsnow@redhat.com>
5 years agoscripts/qmp-shell: unprivatize 'pretty' property
John Snow [Mon, 7 Jun 2021 20:06:36 +0000 (16:06 -0400)]
scripts/qmp-shell: unprivatize 'pretty' property

Similar to verbose, there's no reason this needs to be hidden.

Signed-off-by: John Snow <jsnow@redhat.com>
Message-id: 20210607200649.1840382-30-jsnow@redhat.com
Signed-off-by: John Snow <jsnow@redhat.com>
5 years agoscripts/qmp-shell: Accept SocketAddrT instead of string
John Snow [Mon, 7 Jun 2021 20:06:35 +0000 (16:06 -0400)]
scripts/qmp-shell: Accept SocketAddrT instead of string

Don't "extend" QEMUMonitorProtocol by changing the argument types. Move
the string parsing just outside of the class instead.

Signed-off-by: John Snow <jsnow@redhat.com>
Message-id: 20210607200649.1840382-29-jsnow@redhat.com
Signed-off-by: John Snow <jsnow@redhat.com>
5 years agoscripts/qmp-shell: add mypy types
John Snow [Mon, 7 Jun 2021 20:06:34 +0000 (16:06 -0400)]
scripts/qmp-shell: add mypy types

As per my usual, this patch is annotations only. Any changes with side
effects are done elsewhere.

Note: pylint does not understand the subscripts for Collection in Python 3.6,
so use the stronger Sequence type as a workaround.
Signed-off-by: John Snow <jsnow@redhat.com>
Message-id: 20210607200649.1840382-28-jsnow@redhat.com
Signed-off-by: John Snow <jsnow@redhat.com>
5 years agopython/qmp: add QMPObject type alias
John Snow [Mon, 7 Jun 2021 20:06:33 +0000 (16:06 -0400)]
python/qmp: add QMPObject type alias

This is meant to represent any generic object seen in a QMPMessage, not
just the root object itself.

Signed-off-by: John Snow <jsnow@redhat.com>
Message-id: 20210607200649.1840382-27-jsnow@redhat.com
Signed-off-by: John Snow <jsnow@redhat.com>
5 years agoscripts/qmp-shell: initialize completer early
John Snow [Mon, 7 Jun 2021 20:06:32 +0000 (16:06 -0400)]
scripts/qmp-shell: initialize completer early

Add an empty completer as a more type-safe placeholder instead of
'None'.

Signed-off-by: John Snow <jsnow@redhat.com>
Message-id: 20210607200649.1840382-26-jsnow@redhat.com
Signed-off-by: John Snow <jsnow@redhat.com>
5 years agoscripts/qmp-shell: refactor QMPCompleter
John Snow [Mon, 7 Jun 2021 20:06:31 +0000 (16:06 -0400)]
scripts/qmp-shell: refactor QMPCompleter

list is a generic type, but we expect to use strings directly. We could
subclass list[str], but pylint does not presently understand that
invocation.

Change this class to envelop a list instead of *being* a list, for
simpler mypy typing.

Signed-off-by: John Snow <jsnow@redhat.com>
Message-id: 20210607200649.1840382-25-jsnow@redhat.com
Signed-off-by: John Snow <jsnow@redhat.com>
5 years agoscripts/qmp-shell: Fix "FuzzyJSON" parser
John Snow [Mon, 7 Jun 2021 20:06:30 +0000 (16:06 -0400)]
scripts/qmp-shell: Fix "FuzzyJSON" parser

I'm not sure when this regressed (Or maybe if it was ever working right
to begin with?), but the Python AST requires you to change "Names" to
"Constants" in order to truly convert `false` to `False`.

Signed-off-by: John Snow <jsnow@redhat.com>
Message-id: 20210607200649.1840382-24-jsnow@redhat.com
Signed-off-by: John Snow <jsnow@redhat.com>
5 years agoscripts/qmp-shell: move the REPL functionality into QMPShell
John Snow [Mon, 7 Jun 2021 20:06:29 +0000 (16:06 -0400)]
scripts/qmp-shell: move the REPL functionality into QMPShell

Instead of doing this in main, move it into the class itself. (This
makes it easier to put into the qemu.qmp package later by removing as
much as we can from the main() function.)

Signed-off-by: John Snow <jsnow@redhat.com>
Message-id: 20210607200649.1840382-23-jsnow@redhat.com
Signed-off-by: John Snow <jsnow@redhat.com>
5 years agoscripts/qmp-shell: remove prompt argument from read_exec_command
John Snow [Mon, 7 Jun 2021 20:06:28 +0000 (16:06 -0400)]
scripts/qmp-shell: remove prompt argument from read_exec_command

It's only ever used by one caller, we can just absorb that logic.

Signed-off-by: John Snow <jsnow@redhat.com>
Message-id: 20210607200649.1840382-22-jsnow@redhat.com
Signed-off-by: John Snow <jsnow@redhat.com>
5 years agoscripts/qmp-shell: move get_prompt() to prompt property
John Snow [Mon, 7 Jun 2021 20:06:27 +0000 (16:06 -0400)]
scripts/qmp-shell: move get_prompt() to prompt property

Small tidying; treat "prompt" like an immutable property instead of
function/method/routine.

Signed-off-by: John Snow <jsnow@redhat.com>
Message-id: 20210607200649.1840382-21-jsnow@redhat.com
Signed-off-by: John Snow <jsnow@redhat.com>
5 years agoscripts/qmp-shell: Make verbose a public attribute
John Snow [Mon, 7 Jun 2021 20:06:26 +0000 (16:06 -0400)]
scripts/qmp-shell: Make verbose a public attribute

No real reason to hide this behind an underscore; make it part of the
initializer and make it a regular RW attribute.
Signed-off-by: John Snow <jsnow@redhat.com>
Message-id: 20210607200649.1840382-20-jsnow@redhat.com
Signed-off-by: John Snow <jsnow@redhat.com>
5 years agoscripts/qmp-shell: Add pretty attribute to HMP shell
John Snow [Mon, 7 Jun 2021 20:06:25 +0000 (16:06 -0400)]
scripts/qmp-shell: Add pretty attribute to HMP shell

It's less useful, but it makes the initialization methods LSP
consistent, which quiets a mypy complaint.

Signed-off-by: John Snow <jsnow@redhat.com>
Message-id: 20210607200649.1840382-19-jsnow@redhat.com
Signed-off-by: John Snow <jsnow@redhat.com>
5 years agoscripts/qmp-shell: use argparse
John Snow [Mon, 7 Jun 2021 20:06:24 +0000 (16:06 -0400)]
scripts/qmp-shell: use argparse

Use argparse instead of an open-coded CLI parser, for consistency with
everything else.

Signed-off-by: John Snow <jsnow@redhat.com>
Message-id: 20210607200649.1840382-18-jsnow@redhat.com
Signed-off-by: John Snow <jsnow@redhat.com>
5 years agoscripts/qmp-shell: use isinstance() instead of type()
John Snow [Mon, 7 Jun 2021 20:06:23 +0000 (16:06 -0400)]
scripts/qmp-shell: use isinstance() instead of type()

A bit more idiomatic, and quiets some linter warnings.

Signed-off-by: John Snow <jsnow@redhat.com>
Message-id: 20210607200649.1840382-17-jsnow@redhat.com
Signed-off-by: John Snow <jsnow@redhat.com>
5 years agoscripts/qmp-shell: remove if-raise-else patterns
John Snow [Mon, 7 Jun 2021 20:06:22 +0000 (16:06 -0400)]
scripts/qmp-shell: remove if-raise-else patterns

Shushes pylint. I don't always mind these patterns personally, but I'm
not as sure that I want to remove the warning from pylint's repertoire
entirely. Oh well.

Signed-off-by: John Snow <jsnow@redhat.com>
Message-id: 20210607200649.1840382-16-jsnow@redhat.com
Signed-off-by: John Snow <jsnow@redhat.com>
5 years agoscripts/qmp-shell: fix shell history exception handling
John Snow [Mon, 7 Jun 2021 20:06:21 +0000 (16:06 -0400)]
scripts/qmp-shell: fix shell history exception handling

We want to remove exceptions that are too broad here; we only want to
catch IOErrors that get raised as a direct result of the open call.

Signed-off-by: John Snow <jsnow@redhat.com>
Message-id: 20210607200649.1840382-15-jsnow@redhat.com
Signed-off-by: John Snow <jsnow@redhat.com>
5 years agoscripts/qmp-shell: rename one and two-letter variables
John Snow [Mon, 7 Jun 2021 20:06:20 +0000 (16:06 -0400)]
scripts/qmp-shell: rename one and two-letter variables

A bit of churn and housekeeping for pylint, flake8 et al.

Signed-off-by: John Snow <jsnow@redhat.com>
Message-id: 20210607200649.1840382-14-jsnow@redhat.com
Signed-off-by: John Snow <jsnow@redhat.com>
5 years agoscripts/qmp-shell: make QMPCompleter returns explicit
John Snow [Mon, 7 Jun 2021 20:06:19 +0000 (16:06 -0400)]
scripts/qmp-shell: make QMPCompleter returns explicit

This function returns None when it doesn't find a match; do that
explicitly.

Signed-off-by: John Snow <jsnow@redhat.com>
Message-id: 20210607200649.1840382-13-jsnow@redhat.com
Signed-off-by: John Snow <jsnow@redhat.com>
5 years agoscripts/qmp-shell: ignore visit_Name name
John Snow [Mon, 7 Jun 2021 20:06:18 +0000 (16:06 -0400)]
scripts/qmp-shell: ignore visit_Name name

Not something I control, sorry, pylint.

Signed-off-by: John Snow <jsnow@redhat.com>
Message-id: 20210607200649.1840382-12-jsnow@redhat.com
Signed-off-by: John Snow <jsnow@redhat.com>
5 years agoscripts/qmp-shell: use triple-double-quote docstring style
John Snow [Mon, 7 Jun 2021 20:06:17 +0000 (16:06 -0400)]
scripts/qmp-shell: use triple-double-quote docstring style

(2014 me had never written python before.)

Signed-off-by: John Snow <jsnow@redhat.com>
Message-id: 20210607200649.1840382-11-jsnow@redhat.com
Signed-off-by: John Snow <jsnow@redhat.com>
5 years agoscripts/qmp-shell: declare verbose in __init__
John Snow [Mon, 7 Jun 2021 20:06:16 +0000 (16:06 -0400)]
scripts/qmp-shell: declare verbose in __init__

Linters get angry when we don't define state at init time.

Signed-off-by: John Snow <jsnow@redhat.com>
Message-id: 20210607200649.1840382-10-jsnow@redhat.com
Signed-off-by: John Snow <jsnow@redhat.com>
5 years agoscripts/qmp-shell: Use python3-style super()
John Snow [Mon, 7 Jun 2021 20:06:15 +0000 (16:06 -0400)]
scripts/qmp-shell: Use python3-style super()

Signed-off-by: John Snow <jsnow@redhat.com>
Message-id: 20210607200649.1840382-9-jsnow@redhat.com
Signed-off-by: John Snow <jsnow@redhat.com>
5 years agoscripts/qmp-shell: use @classmethod where appropriate
John Snow [Mon, 7 Jun 2021 20:06:14 +0000 (16:06 -0400)]
scripts/qmp-shell: use @classmethod where appropriate

Methods with no self-use should belong to the class.

Signed-off-by: John Snow <jsnow@redhat.com>
Message-id: 20210607200649.1840382-8-jsnow@redhat.com
Signed-off-by: John Snow <jsnow@redhat.com>
5 years agoscripts/qmp-shell: remove shadowed variable from _print()
John Snow [Mon, 7 Jun 2021 20:06:13 +0000 (16:06 -0400)]
scripts/qmp-shell: remove shadowed variable from _print()

Don't use 'qmp' here, which shadows the qmp module.

Signed-off-by: John Snow <jsnow@redhat.com>
Message-id: 20210607200649.1840382-7-jsnow@redhat.com
Signed-off-by: John Snow <jsnow@redhat.com>