Compare commits

...

46 Commits

Author SHA1 Message Date
Marc-André Lureau
79883c9302 seccomp: check TSYNC host capability
Remove -sandbox option if the host is not capable of TSYNC, since the
sandbox will fail at setup time otherwise. This will help libvirt, for
ex, to figure out if -sandbox will work.

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Signed-off-by: Eduardo Otubo <otubo@redhat.com>
Acked-by: Eduardo Otubo <otubo@redhat.com>
(cherry picked from commit 5780760f5e)
[LD: BSC#1106222 CVE-2018-15746]
Signed-off-by: Larry Dewey <ldewey@suse.com>
2018-10-05 10:48:24 -06:00
Yi Min Zhao
b481a5487b sandbox: disable -sandbox if CONFIG_SECCOMP undefined
If CONFIG_SECCOMP is undefined, the option 'elevatedprivileges' remains
compiled. This would make libvirt set the corresponding capability and
then trigger failure during guest startup. This patch moves the code
regarding seccomp command line options to qemu-seccomp.c file and
wraps qemu_opts_foreach finding sandbox option with CONFIG_SECCOMP.
Because parse_sandbox() is moved into qemu-seccomp.c file, change
seccomp_start() to static function.

Signed-off-by: Yi Min Zhao <zyimin@linux.ibm.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Tested-by: Ján Tomko <jtomko@redhat.com>
Acked-by: Eduardo Otubo <otubo@redhat.com>
(cherry picked from commit 9d0fdecbad)
[LD: BSC#1106222 CVE-2018-15746]
Signed-off-by: Larry Dewey <ldewey@suse.com>
2018-10-05 10:48:07 -06:00
Marc-André Lureau
e31313eaca seccomp: set the seccomp filter to all threads
When using "-seccomp on", the seccomp policy is only applied to the
main thread, the vcpu worker thread and other worker threads created
after seccomp policy is applied; the seccomp policy is not applied to
e.g. the RCU thread because it is created before the seccomp policy is
applied and SECCOMP_FILTER_FLAG_TSYNC isn't used.

This can be verified with
for task in /proc/`pidof qemu`/task/*; do cat $task/status | grep Secc ; done
Seccomp:	2
Seccomp:	0
Seccomp:	0
Seccomp:	2
Seccomp:	2
Seccomp:	2

Starting with libseccomp 2.2.0 and kernel >= 3.17, we can use
seccomp_attr_set(ctx, > SCMP_FLTATR_CTL_TSYNC, 1) to update the policy
on all threads.

libseccomp requirement was bumped to 2.2.0 in previous patch.
libseccomp should fail to set the filter if it can't honour
SCMP_FLTATR_CTL_TSYNC (untested), and thus -sandbox will now fail on
kernel < 3.17.

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Acked-by: Eduardo Otubo <otubo@redhat.com>
(cherry picked from commit 70dfabeaa7)
[LD: BSC#1106222 CVE-2018-15746]
Signed-off-by: Larry Dewey <ldewey@suse.com>
2018-10-05 10:47:12 -06:00
Marc-André Lureau
a9794287e8 configure: require libseccomp 2.2.0
The following patch is going to require TSYNC, which is only available
since libseccomp 2.2.0.

libseccomp 2.2.0 was released February 12, 2015.

According to repology, libseccomp version in different distros:

  RHEL-7: 2.3.1
  Debian (Stretch): 2.3.1
  OpenSUSE Leap 15: 2.3.2
  Ubuntu (Xenial):  2.3.1

This will drop support for -sandbox on:

  Debian (Jessie): 2.1.1 (but 2.2.3 in backports)

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Acked-by: Eduardo Otubo <otubo@redhat.com>
(cherry picked from commit d0699bd37c)
[LD: BSC#1106222 CVE-2018-15746]
Signed-off-by: Larry Dewey <ldewey@suse.com>
2018-10-05 10:46:57 -06:00
Marc-André Lureau
6edbf80f95 seccomp: prefer SCMP_ACT_KILL_PROCESS if available
The upcoming libseccomp release should have SCMP_ACT_KILL_PROCESS
action (https://github.com/seccomp/libseccomp/issues/96).

SCMP_ACT_KILL_PROCESS is preferable to immediately terminate the
offending process, rather than having the SIGSYS handler running.

Use SECCOMP_GET_ACTION_AVAIL to check availability of kernel support,
as libseccomp will fallback on SCMP_ACT_KILL otherwise, and we still
prefer SCMP_ACT_TRAP.

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
Acked-by: Eduardo Otubo <otubo@redhat.com>
(cherry picked from commit bda08a5764)
[LD: BSC#1106222 CVE-2018-15746]
Signed-off-by: Larry Dewey <ldewey@suse.com>
2018-10-05 10:46:38 -06:00
Christian Borntraeger
3ff69067e3 s390x/kvm: add etoken facility
Provide the etoken facility. We need to handle cpu model, migration and
clear reset.

Signed-off-by: Christian Borntraeger <borntraeger@de.ibm.com>
Acked-by: Janosch Frank <frankja@linux.ibm.com>
Message-Id: <20180731090448.36662-3-borntraeger@de.ibm.com>
Reviewed-by: David Hildenbrand <david@redhat.com>
Signed-off-by: Cornelia Huck <cohuck@redhat.com>
(cherry picked from commit 27e84d4ebd)
[FL: bsc#1107489]
Signed-off-by: Fei Li <fli@suse.com>
2018-09-14 15:13:50 -06:00
Fei Li
8194d18811 linux-headers: update
Update to Linux upstream commit 2ad0d5269970
("Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net")

Signed-off-by: Cornelia Huck <cohuck@redhat.com>
(cherry picked from commit d36f7de829)
[FL: bsc#1107489 - actually only backport the linux-header's update
for the etoken cpu feature used on the s390x platform)
Signed-off-by: Fei Li <fli@suse.com>
2018-09-14 15:12:58 -06:00
Peter Maydell
eb6fab8ccd tests/boot-serial-test: Bump timeout to 6 minutes
On a SPARC host that I'm using as a build test machine, the
boot-serial-test for the SPARC guest machines takes about 65
seconds to execute. This means that it hits the current
60 second timer on these tests. Push the timeout up so
that it doesn't trigger spuriously on slow hosts like this one.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Thomas Huth <thuth@redhat.com>
Acked-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
Message-id: 20180817161404.9420-1-peter.maydell@linaro.org
(cherry picked from commit 627fce6178)
[BR: We have seen this issue occasionally for qemu-testsuite on armv7l]
Signed-off-by: Bruce Rogers <brogers@suse.com>
2018-08-20 15:14:22 -06:00
Bruce Rogers
780702171c xen: add block resize support for xen disks
Provide monitor naming of xen disks, and plumb guest driver
notification through xenstore of resizing instigated via the
monitor.

Signed-off-by: Bruce Rogers <brogers@suse.com>
2018-08-14 10:39:10 -06:00
Bruce Rogers
0903be7746 tests: test-thread-pool is racy - add some barriers
I imagine there is more to be done to fix the memory consistency
races here, but these added barriers at least let it pass on ppc64le,
whereas before it would fail regularly there.

Signed-off-by: Bruce Rogers <brogers@suse.com>
2018-08-14 10:39:10 -06:00
Bruce Rogers
cf1f315805 qemu-io tests: comment out problematic block io tests issues
The following issue is seen:
130 - timeout resulting from failed to get shared "write" lock
153 - error resulting from failed to get "write" lock
162 - sometimes we see different error code / message

Signed-off-by: Bruce Rogers <brogers@suse.com>
2018-08-14 10:39:10 -06:00
Bruce Rogers
ce30b89aa8 configure: Modify python used for io tests
Because the block io tests are not yet ported to python3, change
the python env var to explicitly reference python2.

Signed-off-by: Bruce Rogers <brogers@suse.com>
2018-08-14 10:39:10 -06:00
a0170ac311 smbios: Add 1 terminator if any string fields defined in given table.
If user specifies smbios table files through qemu command line, Then will
get error messages while decoding those table content in guest.

Reproducer:
1. dump a smbios table(say table 1) to a binary file from a pc.
2. load the binary file through command line: 'qemu -smbios file=...'.
3. perform 'dmidecode' or 'dmidecode -t 1' in guest.

It reports 'Invalid entry length...' because qemu doesn't add terminator(s)
correctly for the table.

This patch fixed the issue by:

For smbios tables which have string fields provided, qemu should add 1 terminator.
For smbios tables which dont have string fields provided, qemu should add 2.

[LM: BSC#994082]
[LM: BSC#1084316]
Signed-off-by: Lin Ma <lma@suse.com>
2018-08-14 10:39:10 -06:00
Bruce Rogers
579a6f80e0 migration: warn about inconsistent spec_ctrl state
As an attempt to help the user do the right thing, warn if we
detect spec_ctrl data in the migration stream, but where the
cpu defined doesn't have the feature. This would indicate the
migration is from the quick and dirty qemu produced in January
2018 to handle Spectre v2. That qemu version exposed the IBRS
cpu feature to all vcpu types, which helped in the short term
but wasn't a well designed approach.
Warn the user that the now migrated guest needs to be restarted
as soon as possible, using the spec_ctrl cpu feature flag or a
*-IBRS vcpu model specified as appropriate.

Signed-off-by: Bruce Rogers <brogers@suse.com>
2018-08-14 10:39:10 -06:00
Bruce Rogers
6d5e50164b Make installed scripts explicitly python3
We want to expliitly reference python3 in the scripts we install.

[BR: BSC#1077564]
Signed-off-by: Bruce Rogers <brogers@suse.com>
2018-08-14 10:39:10 -06:00
Bruce Rogers
f813f4f807 Switch order of libraries for mpath support
Signed-off-by: Bruce Rogers <brogers@suse.com>
2018-08-14 10:39:10 -06:00
Andreas Färber
874f90da7d tests: Add scsi-disk test
Test scsi-{disk,hd,cd} wwn properties for correct 64-bit parsing.

For now piggyback on virtio-scsi.

Cc: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Andreas Färber <afaerber@suse.de>
2018-08-14 10:39:10 -06:00
Andreas Färber
d6d65620fc tests: Add QOM property unit tests
Add a test for parsing and setting a uint64 property.

Signed-off-by: Andreas Färber <afaerber@suse.de>
2018-08-14 10:39:10 -06:00
Andreas Färber
ec5cf6d449 test-string-input-visitor: Add uint64 test
Test parsing of decimal and hexadecimal uint64 numbers with most
significant bit set.

Signed-off-by: Andreas Färber <afaerber@suse.de>
2018-08-14 10:39:10 -06:00
Andreas Färber
bc42c484c1 test-string-input-visitor: Add int test case
In addition to -42 also parse the maximum int64.

Signed-off-by: Andreas Färber <afaerber@suse.de>
2018-08-14 10:39:10 -06:00
Andreas Färber
ad93dd9db3 string-input-visitor: Fix uint64 parsing
All integers would get parsed by strtoll(), not handling the case of
UINT64 properties with the most significient bit set.

Implement a .type_uint64 visitor callback, reusing the existing
parse_str() code through a new argument, using strtoull().

As this is a bug fix, it intentionally ignores checkpatch warnings to
prefer the use of qemu_strto[u]ll() over strto[u]ll().

Cc: qemu-stable@nongnu.org
Signed-off-by: Andreas Färber <afaerber@suse.de>
2018-08-14 10:39:10 -06:00
Chunyan Liu
613a8ec441 Fix tigervnc long press issue
Using xen tools 'xl vncviewer' with tigervnc (default on SLE-12),
found that: the display of the guest is unexpected while keep
pressing a key. We expect the same character multiple times, but
it prints only one time. This happens on a PV guest in text mode.

After debugging, found that tigervnc sends repeated key down events
in this case, to differentiate from user pressing the same key many
times. Vnc server only prints the character when it finally receives
key up event.

To solve this issue, this patch tries to add additional key up event
before the next repeated key down event (if the key is not a control
key).

[CYL: BSC#882405]
Signed-off-by: Chunyan Liu <cyliu@suse.com>
2018-08-14 10:39:10 -06:00
Andreas Färber
ff50be5b0f acpi_piix4: Fix migration from SLE11 SP2
qemu-kvm 0.15 uses the same GPE format as qemu 1.4, but as version 2
rather than 3.

Addresses part of BNC#812836.

Signed-off-by: Andreas Färber <afaerber@suse.de>
2018-08-14 10:39:10 -06:00
Andreas Färber
83a2c6af42 i8254: Fix migration from SLE11 SP2
qemu-kvm 0.15 had a VMSTATE_UINT32(flags, PITState) field that
qemu 1.4 does not have.

Addresses part of BNC#812836.

Signed-off-by: Andreas Färber <afaerber@suse.de>
2018-08-14 10:39:10 -06:00
Andreas Färber
edd9909ef3 vga: Raise VRAM to 16 MiB for pc-0.15 and below
qemu-kvm.git commit a7fe0297840908a4fd65a1cf742481ccd45960eb
(Extend vram size to 16MB) deviated from qemu.git since kvm-61, and only
in commit 9e56edcf8d (vga: raise default
vgamem size) did qemu.git adjust the VRAM size for v1.2.

Add compatibility properties so that up to and including pc-0.15 we
maintain migration compatibility with qemu-kvm rather than QEMU and
from pc-1.0 on with QEMU (last qemu-kvm release was 1.2).

Addresses part of BNC#812836.

Signed-off-by: Andreas Färber <afaerber@suse.de>
[BR: adjust comma position in list in macro for v2.5.0 compat]
Signed-off-by: Bruce Rogers <brogers@suse.com>
2018-08-14 10:39:10 -06:00
Bruce Rogers
3efe84f921 increase x86_64 physical bits to 42
Allow for guests with higher amounts of ram. The current thought
is that 2TB specified on qemu commandline would be an appropriate
limit. Note that this requires the next higher bit value since
the highest address is actually more than 2TB due to the pci
memory hole.

Signed-off-by: Bruce Rogers <brogers@suse.com>
Signed-off-by: Andreas Färber <afaerber@suse.de>
2018-08-14 10:39:10 -06:00
Andreas Färber
a6216a05ef Raise soft address space limit to hard limit
For SLES we want users to be able to use large memory configurations
with KVM without fiddling with ulimit -Sv.

Signed-off-by: Andreas Färber <afaerber@suse.de>
[BR: add include for sys/resource.h]
Signed-off-by: Bruce Rogers <brogers@suse.com>
2018-08-14 10:39:09 -06:00
Bruce Rogers
d952859543 roms/Makefile: pass a packaging timestamp to subpackages with date info
Certain rom subpackages build from qemu git-submodules call the date
program to include date information in the packaged binaries. This
causes repeated builds of the package to be different, wkere the only
real difference is due to the fact that time build timestamp has
changed. To promote reproducible builds and avoid customers being
prompted to update packages needlessly, we'll use the timestamp of the
VERSION file as the packaging timestamp for all packages that build in a
timestamp for whatever reason.

[BR: BSC#1011213]
Signed-off-by: Bruce Rogers <brogers@suse.com>
2018-08-14 10:39:09 -06:00
94c36b397d linux-user: properly test for infinite timeout in poll (#8)
After "linux-user: use target_ulong" the poll syscall was no longer
handling infinite timeout.

/home/abuild/rpmbuild/BUILD/qemu-2.7.0-rc5/linux-user/syscall.c:9773:26: warning: comparison of unsigned expression >= 0 is always true [-Wtype-limits]
                 if (arg3 >= 0) {
                          ^~

Signed-off-by: Andreas Schwab <schwab@suse.de>
2018-08-14 10:39:09 -06:00
1247ffeb8b qemu-binfmt-conf: use qemu-ARCH-binfmt
Signed-off-by: Andreas Schwab <schwab@suse.de>
Signed-off-by: Andreas Färber <afaerber@suse.de>
2018-08-14 10:39:09 -06:00
Bruce Rogers
960e9697ab qemu-bridge-helper: reduce security profile
Change from using glib alloc and free routines to those
from libc. Also perform safety measure of dropping privs
to user if configured no-caps.

[BR: BOO#988279]
Signed-off-by: Bruce Rogers <brogers@suse.com>
[AF: Rebased for v2.7.0-rc2]
Signed-off-by: Andreas Färber <afaerber@suse.de>
2018-08-14 10:39:09 -06:00
Bruce Rogers
6ed042659b xen_disk: Add suse specific flush disable handling and map to QEMU equiv
Add code to read the suse specific suse-diskcache-disable-flush flag out
of xenstore, and set the equivalent flag within QEMU.

Patch taken from Xen's patch queue, Olaf Hering being the original author.
[bsc#879425]

Signed-off-by: Bruce Rogers <brogers@suse.com>
Signed-off-by: Olaf Hering <olaf@aepfle.de>
2018-08-14 10:39:09 -06:00
Alexander Graf
c82a9a0340 AIO: Reduce number of threads for 32bit hosts
On hosts with limited virtual address space (32bit pointers), we can very
easily run out of virtual memory with big thread pools.

Instead, we should limit ourselves to small pools to keep memory footprint
low on those systems.

This patch fixes random VM stalls like

  (process:25114): GLib-ERROR **: gmem.c:103: failed to allocate 1048576 bytes

on 32bit ARM systems for me.

Signed-off-by: Alexander Graf <agraf@suse.de>
2018-08-14 10:39:09 -06:00
Alexander Graf
8c551cc70f linux-user: lseek: explicitly cast non-set offsets to signed
When doing lseek, SEEK_SET indicates that the offset is an unsigned variable.
Other seek types have parameters that can be negative.

When converting from 32bit to 64bit parameters, we need to take this into
account and enable SEEK_END and SEEK_CUR to be negative, while SEEK_SET stays
absolute positioned which we need to maintain as unsigned.

Signed-off-by: Alexander Graf <agraf@suse.de>
2018-08-14 10:39:09 -06:00
Alexander Graf
b45f8e8056 Make char muxer more robust wrt small FIFOs
Virtio-Console can only process one character at a time. Using it on S390
gave me strage "lags" where I got the character I pressed before when
pressing one. So I typed in "abc" and only received "a", then pressed "d"
but the guest received "b" and so on.

While the stdio driver calls a poll function that just processes on its
queue in case virtio-console can't take multiple characters at once, the
muxer does not have such callbacks, so it can't empty its queue.

To work around that limitation, I introduced a new timer that only gets
active when the guest can not receive any more characters. In that case
it polls again after a while to check if the guest is now receiving input.

This patch fixes input when using -nographic on s390 for me.

[AF: Rebased for v2.7.0-rc2]
2018-08-14 10:39:09 -06:00
Alexander Graf
4aecd955fd linux-user: use target_ulong
Linux syscalls pass pointers or data length or other information of that sort
to the kernel. This is all stuff you don't want to have sign extended.
Otherwise a host 64bit variable parameter with a size parameter will extend
it to a negative number, breaking lseek for example.

Pass syscall arguments as ulong always.

Signed-off-by: Alexander Graf <agraf@suse.de>
2018-08-14 10:39:09 -06:00
Adam Williamson
e13afd152f Remove problematic 'evdev 86' key from en-us keymap
This causes LP#1738283. Gerd will have to come up with a better
fix, but just hacking out the problematic key definition should
work for now.

[BR: We see this issue as well, eg via vnc]
Signed-off-by: Bruce Rogers <brogers@suse.com>
2018-08-14 10:39:09 -06:00
Alexander Graf
7511bbd3bc linux-user: Fake /proc/cpuinfo
Fedora 17 for ARM reads /proc/cpuinfo and fails if it doesn't contain
ARM related contents. This patch implements a quick hack to expose real
/proc/cpuinfo data taken from a real world machine.

The real fix would be to generate at least the flags automatically based
on the selected CPU. Please do not submit this patch upstream until this
has happened.

Signed-off-by: Alexander Graf <agraf@suse.de>
[AF: Rebased for v1.6 and v1.7]
Signed-off-by: Andreas Färber <afaerber@suse.de>
2018-08-14 10:39:09 -06:00
Alexander Graf
40b72c9a18 linux-user: binfmt: support host binaries
When we have a working host binary equivalent for the guest binary we're
trying to run, let's just use that instead as it will be a lot faster.

Signed-off-by: Alexander Graf <agraf@suse.de>
2018-08-14 10:39:09 -06:00
Alexander Graf
a98cb00cf6 PPC: KVM: Disable mmu notifier check
When using hugetlbfs (which is required for HV mode KVM on 970), we
check for MMU notifiers that on 970 can not be implemented properly.

So disable the check for mmu notifiers on PowerPC guests, making
KVM guests work there, even if possibly racy in some odd circumstances.
2018-08-14 10:39:09 -06:00
Alexander Graf
8d952c63e4 linux-user: add binfmt wrapper for argv[0] handling
When using qemu's linux-user binaries through binfmt, argv[0] gets lost
along the execution because qemu only gets passed in the full file name
to the executable while argv[0] can be something completely different.

This breaks in some subtile situations, such as the grep and make test
suites.

This patch adds a wrapper binary called qemu-$TARGET-binfmt that can be
used with binfmt's P flag which passes the full path _and_ argv[0] to
the binfmt handler.

The binary would be smart enough to be versatile and only exist in the
system once, creating the qemu binary path names from its own argv[0].
However, this seemed like it didn't fit the make system too well, so
we're currently creating a new binary for each target archictecture.

CC: Reinhard Max <max@suse.de>
Signed-off-by: Alexander Graf <agraf@suse.de>
[AF: Rebased onto new Makefile infrastructure, twice]
[AF: Updated for aarch64 for v2.0.0-rc1]
[AF: Rebased onto Makefile changes for v2.1.0-rc0]
[AF: Rebased onto script rewrite for v2.7.0-rc2 - to be fixed]
Signed-off-by: Andreas Färber <afaerber@suse.de>
2018-08-14 10:39:09 -06:00
Alexander Graf
a82a766a9e qemu-cvs-ioctl_nodirection
the direction given in the ioctl should be correct so we can assume the
communication is uni-directional. The alsa developers did not like this
concept though and declared ioctls IOC_R and IOC_W even though they were
IOC_RW.

Signed-off-by: Alexander Graf <agraf@suse.de>
Signed-off-by: Ulrich Hecht <uli@suse.de>
2018-08-14 10:39:09 -06:00
Alexander Graf
252fd85362 qemu-cvs-ioctl_debug
Extends unsupported ioctl debug output.

Signed-off-by: Alexander Graf <agraf@suse.de>
Signed-off-by: Ulrich Hecht <uli@suse.de>
2018-08-14 10:39:09 -06:00
Ulrich Hecht
6d0df1baba qemu-cvs-gettimeofday
No clue what this is for.
2018-08-14 10:39:09 -06:00
Andreas Färber
e7c65bc554 qemu-binfmt-conf: Modify default path
Change QEMU_PATH from /usr/local/bin to /usr/bin prefix.

Signed-off-by: Andreas Färber <afaerber@suse.de>
2018-08-14 10:39:09 -06:00
Alexander Graf
fc0c190670 XXX dont dump core on sigabort 2018-08-14 10:39:09 -06:00
55 changed files with 907 additions and 69 deletions

View File

@@ -1125,6 +1125,7 @@ R: Fam Zheng <famz@redhat.com>
S: Supported
F: include/hw/scsi/*
F: hw/scsi/*
F: tests/scsi-disk-test.c
F: tests/virtio-scsi-test.c
T: git git://github.com/bonzini/qemu.git scsi-next
@@ -1685,6 +1686,7 @@ F: qom/
X: qom/cpu.c
F: tests/check-qom-interface.c
F: tests/check-qom-proplist.c
F: tests/check-qom-props.c
F: tests/qom-test.c
QMP

View File

@@ -547,7 +547,7 @@ fsdev/virtfs-proxy-helper$(EXESUF): LIBS += -lcap
scsi/qemu-pr-helper$(EXESUF): scsi/qemu-pr-helper.o scsi/utils.o $(crypto-obj-y) $(io-obj-y) $(qom-obj-y) $(COMMON_LDADDS)
ifdef CONFIG_MPATH
scsi/qemu-pr-helper$(EXESUF): LIBS += -ludev -lmultipath -lmpathpersist
scsi/qemu-pr-helper$(EXESUF): LIBS += -ludev -lmpathpersist -lmultipath
endif
qemu-img-cmds.h: $(SRC_PATH)/qemu-img-cmds.hx $(SRC_PATH)/scripts/hxtool

View File

@@ -41,6 +41,10 @@ ifdef CONFIG_USER_ONLY
include $(SRC_PATH)/tests/tcg/Makefile.include
endif
ifdef CONFIG_LINUX_USER
PROGS+=$(QEMU_PROG)-binfmt
endif
config-target.h: config-target.h-timestamp
config-target.h-timestamp: config-target.mak
@@ -119,6 +123,8 @@ QEMU_CFLAGS+=-I$(SRC_PATH)/linux-user/$(TARGET_ABI_DIR) \
obj-y += linux-user/
obj-y += gdbstub.o thunk.o
obj-binfmt-y += linux-user/
endif #CONFIG_LINUX_USER
#########################################################
@@ -161,7 +167,11 @@ endif # CONFIG_SOFTMMU
# Workaround for http://gcc.gnu.org/PR55489, see configure.
%/translate.o: QEMU_CFLAGS += $(TRANSLATE_OPT_CFLAGS)
ifdef CONFIG_LINUX_USER
dummy := $(call unnest-vars,,obj-y obj-binfmt-y)
else
dummy := $(call unnest-vars,,obj-y)
endif
all-obj-y := $(obj-y)
target-obj-y :=
@@ -202,6 +212,9 @@ ifdef CONFIG_DARWIN
$(call quiet-command,SetFile -a C $@,"SETFILE","$(TARGET_DIR)$@")
endif
$(QEMU_PROG)-binfmt: $(obj-binfmt-y)
$(call LINK,$^)
gdbstub-xml.c: $(TARGET_XML_FILES) $(SRC_PATH)/scripts/feature_to_c.sh
$(call quiet-command,rm -f $@ && $(SHELL) $(SRC_PATH)/scripts/feature_to_c.sh $@ $(TARGET_XML_FILES),"GEN","$(TARGET_DIR)$@")

View File

@@ -23,6 +23,7 @@
#include "qemu/option.h"
#include "trace.h"
#include "migration/misc.h"
#include "hw/xen/xen.h"
/* Number of coroutines to reserve per attached device model */
#define COROUTINE_POOL_RESERVATION 64
@@ -900,7 +901,9 @@ char *blk_get_attached_dev_id(BlockBackend *blk)
{
DeviceState *dev;
assert(!blk->legacy_dev);
if (blk->legacy_dev) {
return xen_blk_get_attached_dev_id(blk->dev);
}
dev = blk->dev;
if (!dev) {
@@ -2005,6 +2008,13 @@ int blk_truncate(BlockBackend *blk, int64_t offset, PreallocMode prealloc,
return bdrv_truncate(blk->root, offset, prealloc, errp);
}
void blk_legacy_resize_cb(BlockBackend *blk)
{
if (blk->legacy_dev) {
xen_blk_resize_cb(blk->dev);
}
}
static void blk_pdiscard_entry(void *opaque)
{
BlkRwCo *rwco = opaque;

View File

@@ -3175,6 +3175,7 @@ void qmp_block_resize(bool has_device, const char *device,
{
Error *local_err = NULL;
BlockBackend *blk = NULL;
BlockBackend *cb_blk = NULL;
BlockDriverState *bs;
AioContext *aio_context;
int ret;
@@ -3187,6 +3188,10 @@ void qmp_block_resize(bool has_device, const char *device,
return;
}
if (has_device) {
cb_blk = blk_by_name(device);
}
aio_context = bdrv_get_aio_context(bs);
aio_context_acquire(aio_context);
@@ -3213,6 +3218,9 @@ void qmp_block_resize(bool has_device, const char *device,
bdrv_drained_begin(bs);
ret = blk_truncate(blk, size, PREALLOC_MODE_OFF, errp);
if (!ret && cb_blk) {
blk_legacy_resize_cb(cb_blk);
}
bdrv_drained_end(bs);
out:

View File

@@ -21,6 +21,7 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
#define HW_POISON_H // avoid poison since we patch against rules it "enforces"
#include "qemu/osdep.h"
#include "qemu/error-report.h"
#include "qapi/error.h"

View File

@@ -22,6 +22,7 @@
* THE SOFTWARE.
*/
#define HW_POISON_H // avoid poison since we patch against rules it "enforces"
#include "qemu/osdep.h"
#include "qapi/error.h"
#include "qemu/option.h"
@@ -190,6 +191,15 @@ static void mux_chr_accept_input(Chardev *chr)
be->chr_read(be->opaque,
&d->buffer[m][d->cons[m]++ & MUX_BUFFER_MASK], 1);
}
#if defined(TARGET_S390X)
/* We're still not able to sync producer and consumer, so let's wait a bit
and try again by then. */
if (d->prod[m] != d->cons[m]) {
qemu_mod_timer(d->accept_timer, qemu_get_clock_ns(vm_clock)
+ (int64_t)100000);
}
#endif
}
static int mux_chr_can_read(void *opaque)
@@ -324,6 +334,10 @@ static void qemu_chr_open_mux(Chardev *chr,
}
d->focus = -1;
#if defined(TARGET_S390X)
d->accept_timer = qemu_new_timer_ns(vm_clock,
(QEMUTimerCB*)mux_chr_accept_input, chr);
#endif
/* only default to opened state if we've realized the initial
* set of muxes
*/

View File

@@ -22,6 +22,7 @@
* THE SOFTWARE.
*/
#define HW_POISON_H // avoid poison since we patch against rules it "enforces"
#include "qemu/osdep.h"
#include "qemu/cutils.h"
#include "monitor/monitor.h"

11
configure vendored
View File

@@ -2216,13 +2216,10 @@ fi
##########################################
# libseccomp check
libseccomp_minver="2.2.0"
if test "$seccomp" != "no" ; then
case "$cpu" in
i386|x86_64)
libseccomp_minver="2.1.0"
;;
mips)
libseccomp_minver="2.2.0"
i386|x86_64|mips)
;;
arm|aarch64)
libseccomp_minver="2.2.3"
@@ -3577,7 +3574,7 @@ int main(void) {
return 0;
}
EOF
if compile_prog "" "-ludev -lmultipath -lmpathpersist" ; then
if compile_prog "" "-ludev -lmpathpersist -lmultipath" ; then
mpathpersist=yes
else
mpathpersist=no
@@ -7418,7 +7415,7 @@ iotests_check="tests/qemu-iotests/check"
echo "# Automatically generated by configure - do not modify" > "$iotests_common_env"
echo >> "$iotests_common_env"
echo "export PYTHON='$python'" >> "$iotests_common_env"
echo "export PYTHON='/usr/bin/python2 -B'" >> "$iotests_common_env"
if [ ! -e "$iotests_check" ]; then
symlink "$source_path/$iotests_check" "$iotests_check"

12
cpus.c
View File

@@ -2367,6 +2367,18 @@ exit:
fclose(f);
}
bool spec_ctrl_is_inconsistent(void)
{
#if defined(TARGET_I386)
X86CPU *x86_cpu = X86_CPU(current_cpu);
CPUX86State *env = x86_cpu != NULL ? &x86_cpu->env : NULL;
if (env && !(env->features[FEAT_7_0_EDX] & CPUID_7_0_EDX_SPEC_CTRL) &&
env->spec_ctrl)
return true;
#endif
return false;
}
void qmp_inject_nmi(Error **errp)
{
nmi_monitor_handle(monitor_get_cpu_index(), errp);

2
exec.c
View File

@@ -2270,11 +2270,13 @@ RAMBlock *qemu_ram_alloc_from_fd(ram_addr_t size, MemoryRegion *mr,
return NULL;
}
#ifndef TARGET_PPC
if (kvm_enabled() && !kvm_has_sync_mmu()) {
error_setg(errp,
"host lacks kvm mmu notifiers, -mem-path unsupported");
return NULL;
}
#endif
if (phys_mem_alloc != qemu_anon_ram_alloc) {
/*

View File

@@ -310,7 +310,7 @@ static const VMStateDescription vmstate_cpuhp_state = {
static const VMStateDescription vmstate_acpi = {
.name = "piix4_pm",
.version_id = 3,
.minimum_version_id = 3,
.minimum_version_id = 2, /* qemu-kvm */
.minimum_version_id_old = 1,
.load_state_old = acpi_load_old,
.post_load = vmstate_acpi_post_load,

View File

@@ -90,6 +90,8 @@ struct XenBlkDev {
int requests_finished;
unsigned int max_requests;
gboolean cache_unsafe;
/* Persistent grants extension */
gboolean feature_discard;
/* qemu block driver */
@@ -642,6 +644,16 @@ static void blk_parse_discard(struct XenBlkDev *blkdev)
}
}
static void blk_parse_cache_unsafe(struct XenBlkDev *blkdev)
{
int enable;
blkdev->cache_unsafe = false;
if (xenstore_read_be_int(&blkdev->xendev, "suse-diskcache-disable-flush", &enable) == 0)
blkdev->cache_unsafe = !!enable;
}
static int blk_init(struct XenDevice *xendev)
{
struct XenBlkDev *blkdev = container_of(xendev, struct XenBlkDev, xendev);
@@ -717,6 +729,7 @@ static int blk_init(struct XenDevice *xendev)
MAX_RING_PAGE_ORDER);
blk_parse_discard(blkdev);
blk_parse_cache_unsafe(blkdev);
g_free(directiosafe);
return 0;
@@ -746,6 +759,7 @@ static int blk_connect(struct XenDevice *xendev)
int order, ring_ref;
unsigned int ring_size, max_grants;
unsigned int i;
Error *errp = NULL;
trace_xen_disk_connect(xendev->name);
@@ -764,6 +778,9 @@ static int blk_connect(struct XenDevice *xendev)
qflags |= BDRV_O_UNMAP;
}
if (blkdev->cache_unsafe)
qflags |= BDRV_O_NO_FLUSH;
/* init qemu block driver */
index = (xendev->dev - 202 * 256) / 16;
blkdev->dinfo = drive_get(IF_XEN, 0, index);
@@ -802,6 +819,13 @@ static int blk_connect(struct XenDevice *xendev)
blk_ref(blkdev->blk);
}
blk_attach_dev_legacy(blkdev->blk, blkdev);
if (!monitor_add_blk(blkdev->blk, g_strdup(blkdev->dev), &errp)) {
xen_pv_printf(&blkdev->xendev, 0, "error: %s\n",
error_get_pretty(errp));
error_free(errp);
return -1;
}
blkdev->file_size = blk_getlength(blkdev->blk);
if (blkdev->file_size < 0) {
BlockDriverState *bs = blk_bs(blkdev->blk);
@@ -952,6 +976,7 @@ static void blk_disconnect(struct XenDevice *xendev)
if (blkdev->blk) {
blk_set_aio_context(blkdev->blk, qemu_get_aio_context());
blk_detach_dev(blkdev->blk, blkdev);
monitor_remove_blk(blkdev->blk);
blk_unref(blkdev->blk);
blkdev->blk = NULL;
}
@@ -999,6 +1024,21 @@ static void blk_event(struct XenDevice *xendev)
qemu_bh_schedule(blkdev->bh);
}
void xen_blk_resize_cb(void *dev)
{
struct XenBlkDev *blkdev = dev;
blkdev->file_size = blk_getlength(blkdev->blk);
xenstore_write_be_int64(&blkdev->xendev, "sectors",
blkdev->file_size / blkdev->file_blk);
xen_be_set_state(&blkdev->xendev, blkdev->xendev.be_state);
}
char *xen_blk_get_attached_dev_id(void *dev)
{
struct XenBlkDev *blkdev = dev;
return g_strdup_printf("xen-qdisk-%i", blkdev->xendev.dev);
}
struct XenDevOps xen_blkdev_ops = {
.flags = DEVOPS_FLAG_NEED_GNTDEV,
.size = sizeof(struct XenBlkDev),

View File

@@ -809,7 +809,32 @@ DEFINE_I440FX_MACHINE(v1_0, "pc-1.0", pc_compat_1_2,
#define PC_COMPAT_0_15 \
PC_CPU_MODEL_IDS("0.15")
PC_CPU_MODEL_IDS("0.15")\
{\
.driver = "VGA",\
.property = "vgamem_mb",\
.value = stringify(16),\
},{\
.driver = "vmware-svga",\
.property = "vgamem_mb",\
.value = stringify(16),\
},{\
.driver = "qxl-vga",\
.property = "vgamem_mb",\
.value = stringify(16),\
},{\
.driver = "qxl",\
.property = "vgamem_mb",\
.value = stringify(16),\
},{\
.driver = "isa-cirrus-vga",\
.property = "vgamem_mb",\
.value = stringify(16),\
},{\
.driver = "cirrus-vga",\
.property = "vgamem_mb",\
.value = stringify(16),\
},
static void pc_i440fx_0_15_machine_options(MachineClass *m)
{

View File

@@ -952,6 +952,9 @@ void smbios_entry_add(QemuOpts *opts, Error **errp)
{
const char *val;
int i, terminator_count = 2, table_str_field_count = 0;
int *tables_str_field_offset = NULL;
assert(!smbios_immutable);
val = qemu_opt_get(opts, "file");
@@ -993,7 +996,94 @@ void smbios_entry_add(QemuOpts *opts, Error **errp)
smbios_type4_count++;
}
switch (header->type) {
case 0:
tables_str_field_offset = g_malloc0(sizeof(int) * \
TYPE_0_STR_FIELD_COUNT);
tables_str_field_offset = (int []){\
TYPE_0_STR_FIELD_OFFSET_VENDOR, \
TYPE_0_STR_FIELD_OFFSET_BIOS_VERSION, \
TYPE_0_STR_FIELD_OFFSET_BIOS_RELEASE_DATE};
table_str_field_count = sizeof(tables_str_field_offset) / \
sizeof(tables_str_field_offset[0]);
break;
case 1:
tables_str_field_offset = g_malloc0(sizeof(int) * \
TYPE_1_STR_FIELD_COUNT);
tables_str_field_offset = (int []){
TYPE_1_STR_FIELD_OFFSET_MANUFACTURER, \
TYPE_1_STR_FIELD_OFFSET_PRODUCT, \
TYPE_1_STR_FIELD_OFFSET_VERSION, \
TYPE_1_STR_FIELD_OFFSET_SERIAL, \
TYPE_1_STR_FIELD_OFFSET_SKU, \
TYPE_1_STR_FIELD_OFFSET_FAMILY};
table_str_field_count = sizeof(tables_str_field_offset) / \
sizeof(tables_str_field_offset[0]);
break;
case 2:
tables_str_field_offset = g_malloc0(sizeof(int) * \
TYPE_2_STR_FIELD_COUNT);
tables_str_field_offset = (int []){\
TYPE_2_STR_FIELD_OFFSET_MANUFACTURER, \
TYPE_2_STR_FIELD_OFFSET_PRODUCT, \
TYPE_2_STR_FIELD_OFFSET_VERSION, \
TYPE_2_STR_FIELD_OFFSET_SERIAL, \
TYPE_2_STR_FIELD_OFFSET_ASSET, \
TYPE_2_STR_FIELD_OFFSET_LOCATION};
table_str_field_count = sizeof(tables_str_field_offset) / \
sizeof(tables_str_field_offset[0]);
break;
case 3:
tables_str_field_offset = g_malloc0(sizeof(int) * \
TYPE_3_STR_FIELD_COUNT);
tables_str_field_offset = (int []){\
TYPE_3_STR_FIELD_OFFSET_MANUFACTURER, \
TYPE_3_STR_FIELD_OFFSET_VERSION, \
TYPE_3_STR_FIELD_OFFSET_SERIAL, \
TYPE_3_STR_FIELD_OFFSET_ASSET, \
TYPE_3_STR_FIELD_OFFSET_SKU};
table_str_field_count = sizeof(tables_str_field_offset) / \
sizeof(tables_str_field_offset[0]);
break;
case 4:
tables_str_field_offset = g_malloc0(sizeof(int) * \
TYPE_4_STR_FIELD_COUNT);
tables_str_field_offset = (int []){\
TYPE_4_STR_FIELD_OFFSET_SOCKET, \
TYPE_4_STR_FIELD_OFFSET_PROCESSOR_MANUFACTURER, \
TYPE_4_STR_FIELD_OFFSET_PROCESSOR_VERSION, \
TYPE_4_STR_FIELD_OFFSET_SERIAL, \
TYPE_4_STR_FIELD_OFFSET_ASSET, \
TYPE_4_STR_FIELD_OFFSET_PART};
table_str_field_count = sizeof(tables_str_field_offset) / \
sizeof(tables_str_field_offset[0]);
break;
case 17:
tables_str_field_offset = g_malloc0(sizeof(int) * \
TYPE_17_STR_FIELD_COUNT);
tables_str_field_offset = (int []){\
TYPE_17_STR_FIELD_OFFSET_DEVICE_LOCATOR, \
TYPE_17_STR_FIELD_OFFSET_BANK_LOCATOR, \
TYPE_17_STR_FIELD_OFFSET_MANUFACTURER, \
TYPE_17_STR_FIELD_OFFSET_SERIAL, \
TYPE_17_STR_FIELD_OFFSET_ASSET, \
TYPE_17_STR_FIELD_OFFSET_PART};
table_str_field_count = sizeof(tables_str_field_offset) / \
sizeof(tables_str_field_offset[0]);
break;
default:
break;
}
for (i = 0; i < table_str_field_count; i++) {
if (*(uint8_t *)(smbios_tables + tables_str_field_offset[i]) > 0) {
terminator_count = 1;
break;
}
}
smbios_tables_len += size;
smbios_tables_len += terminator_count;
if (size > smbios_table_max) {
smbios_table_max = size;
}

View File

@@ -259,6 +259,12 @@ static int pit_dispatch_post_load(void *opaque, int version_id)
return 0;
}
static bool is_qemu_kvm(void *opaque, int version_id)
{
/* HACK: We ignore incoming migration from upstream qemu */
return version_id < 3;
}
static const VMStateDescription vmstate_pit_common = {
.name = "i8254",
.version_id = 3,
@@ -268,6 +274,7 @@ static const VMStateDescription vmstate_pit_common = {
.pre_save = pit_dispatch_pre_save,
.post_load = pit_dispatch_post_load,
.fields = (VMStateField[]) {
VMSTATE_UNUSED_TEST(is_qemu_kvm, 4),
VMSTATE_UINT32_V(channels[0].irq_disabled, PITCommonState, 3),
VMSTATE_STRUCT_ARRAY(channels, PITCommonState, 3, 2,
vmstate_pit_channel, PITChannelState),

View File

@@ -34,6 +34,9 @@ typedef struct MuxChardev {
Chardev parent;
CharBackend *backends[MAX_MUX];
CharBackend chr;
#if defined(TARGET_S390X)
QEMUTimer *accept_timer;
#endif
int focus;
int mux_cnt;
int term_got_escape;

View File

@@ -272,4 +272,48 @@ void smbios_get_tables(const struct smbios_phys_mem_area *mem_array,
const unsigned int mem_array_size,
uint8_t **tables, size_t *tables_len,
uint8_t **anchor, size_t *anchor_len);
#define TYPE_0_STR_FIELD_OFFSET_VENDOR 0x4
#define TYPE_0_STR_FIELD_OFFSET_BIOS_VERSION 0x5
#define TYPE_0_STR_FIELD_OFFSET_BIOS_RELEASE_DATE 0x8
#define TYPE_0_STR_FIELD_COUNT 3
#define TYPE_1_STR_FIELD_OFFSET_MANUFACTURER 0x4
#define TYPE_1_STR_FIELD_OFFSET_PRODUCT 0x5
#define TYPE_1_STR_FIELD_OFFSET_VERSION 0x6
#define TYPE_1_STR_FIELD_OFFSET_SERIAL 0x7
#define TYPE_1_STR_FIELD_OFFSET_SKU 0x19
#define TYPE_1_STR_FIELD_OFFSET_FAMILY 0x1a
#define TYPE_1_STR_FIELD_COUNT 6
#define TYPE_2_STR_FIELD_OFFSET_MANUFACTURER 0x4
#define TYPE_2_STR_FIELD_OFFSET_PRODUCT 0x5
#define TYPE_2_STR_FIELD_OFFSET_VERSION 0x6
#define TYPE_2_STR_FIELD_OFFSET_SERIAL 0x7
#define TYPE_2_STR_FIELD_OFFSET_ASSET 0x8
#define TYPE_2_STR_FIELD_OFFSET_LOCATION 0xa
#define TYPE_2_STR_FIELD_COUNT 6
#define TYPE_3_STR_FIELD_OFFSET_MANUFACTURER 0x4
#define TYPE_3_STR_FIELD_OFFSET_VERSION 0x6
#define TYPE_3_STR_FIELD_OFFSET_SERIAL 0x7
#define TYPE_3_STR_FIELD_OFFSET_ASSET 0x8
#define TYPE_3_STR_FIELD_OFFSET_SKU 0x14
#define TYPE_3_STR_FIELD_COUNT 5
#define TYPE_4_STR_FIELD_OFFSET_SOCKET 0x4
#define TYPE_4_STR_FIELD_OFFSET_PROCESSOR_MANUFACTURER 0x7
#define TYPE_4_STR_FIELD_OFFSET_PROCESSOR_VERSION 0x10
#define TYPE_4_STR_FIELD_OFFSET_SERIAL 0x20
#define TYPE_4_STR_FIELD_OFFSET_ASSET 0x21
#define TYPE_4_STR_FIELD_OFFSET_PART 0x22
#define TYPE_4_STR_FIELD_COUNT 6
#define TYPE_17_STR_FIELD_OFFSET_DEVICE_LOCATOR 0x10
#define TYPE_17_STR_FIELD_OFFSET_BANK_LOCATOR 0x11
#define TYPE_17_STR_FIELD_OFFSET_MANUFACTURER 0x17
#define TYPE_17_STR_FIELD_OFFSET_SERIAL 0x18
#define TYPE_17_STR_FIELD_OFFSET_ASSET 0x19
#define TYPE_17_STR_FIELD_OFFSET_PART 0x1a
#define TYPE_17_STR_FIELD_COUNT 6
#endif /* QEMU_SMBIOS_H */

View File

@@ -48,4 +48,8 @@ void xen_hvm_modified_memory(ram_addr_t start, ram_addr_t length);
void xen_register_framebuffer(struct MemoryRegion *mr);
void xen_blk_resize_cb(void *dev);
char *xen_blk_get_attached_dev_id(void *dev);
#endif /* QEMU_HW_XEN_H */

View File

@@ -240,4 +240,5 @@ void qemu_lockcnt_inc_and_unlock(QemuLockCnt *lockcnt);
*/
unsigned qemu_lockcnt_count(QemuLockCnt *lockcnt);
bool spec_ctrl_is_inconsistent(void);
#endif

View File

@@ -236,5 +236,6 @@ int coroutine_fn blk_co_copy_range(BlockBackend *blk_in, int64_t off_in,
BlockBackend *blk_out, int64_t off_out,
int bytes, BdrvRequestFlags read_flags,
BdrvRequestFlags write_flags);
void blk_legacy_resize_cb(BlockBackend *blk);
#endif

View File

@@ -4,7 +4,7 @@
/*
* KVM s390 specific structures and definitions
*
* Copyright IBM Corp. 2008
* Copyright IBM Corp. 2008, 2018
*
* Author(s): Carsten Otte <cotte@de.ibm.com>
* Christian Borntraeger <borntraeger@de.ibm.com>
@@ -225,6 +225,7 @@ struct kvm_guest_debug_arch {
#define KVM_SYNC_FPRS (1UL << 8)
#define KVM_SYNC_GSCB (1UL << 9)
#define KVM_SYNC_BPBC (1UL << 10)
#define KVM_SYNC_ETOKEN (1UL << 11)
/* length and alignment of the sdnx as a power of two */
#define SDNXC 8
#define SDNXL (1UL << SDNXC)
@@ -258,6 +259,8 @@ struct kvm_sync_regs {
struct {
__u64 reserved1[2];
__u64 gscb[4];
__u64 etoken;
__u64 etoken_extension;
};
};
};

View File

@@ -7,3 +7,5 @@ obj-$(TARGET_HAS_BFLT) += flatload.o
obj-$(TARGET_I386) += vm86.o
obj-$(TARGET_ARM) += arm/nwfpe/
obj-$(TARGET_M68K) += m68k-sim.o
obj-binfmt-y = binfmt.o

68
linux-user/binfmt.c Normal file
View File

@@ -0,0 +1,68 @@
#include <stdio.h>
#include <stdarg.h>
#include <unistd.h>
#include <libgen.h>
#include <string.h>
#include <stdlib.h>
#ifdef __x86_64__
#define ARCH_NAME "x86_64"
#endif
int main(int argc, char **argv, char **envp)
{
char *binfmt;
char **new_argv;
/*
* Check if our file name ends with -binfmt
*/
binfmt = argv[0] + strlen(argv[0]) - strlen("-binfmt");
if (strcmp(binfmt, "-binfmt")) {
fprintf(stderr, "%s: Invalid executable name\n", argv[0]);
exit(1);
}
if (argc < 3) {
fprintf(stderr, "%s: Please use me through binfmt with P flag\n",
argv[0]);
exit(1);
}
binfmt[0] = '\0';
/* Now argv[0] is the real qemu binary name */
#ifdef ARCH_NAME
{
char *hostbin;
char *guestarch;
int r;
guestarch = strrchr(argv[0], '-') ;
if (!guestarch) {
goto skip;
}
guestarch++;
r = asprintf(&hostbin, "/emul/" ARCH_NAME "-for-%s/%s", guestarch, argv[1]);
if ((r > 0) && !access(hostbin, X_OK)) {
/*
* We found a host binary replacement for the non-host binary. Let's
* use that instead!
*/
return execve(hostbin, &argv[2], envp);
}
}
skip:
#endif
new_argv = (char **)malloc((argc + 2) * sizeof(*new_argv));
if (argc > 3) {
memcpy(&new_argv[4], &argv[3], (argc - 3) * sizeof(*new_argv));
}
new_argv[0] = argv[0];
new_argv[1] = (char *)"-0";
new_argv[2] = argv[2];
new_argv[3] = argv[1];
new_argv[argc + 1] = NULL;
return execve(new_argv[0], new_argv, envp);
}

View File

@@ -202,10 +202,10 @@ abi_long memcpy_to_target(abi_ulong dest, const void *src,
void target_set_brk(abi_ulong new_brk);
abi_long do_brk(abi_ulong new_brk);
void syscall_init(void);
abi_long do_syscall(void *cpu_env, int num, abi_long arg1,
abi_long arg2, abi_long arg3, abi_long arg4,
abi_long arg5, abi_long arg6, abi_long arg7,
abi_long arg8);
abi_long do_syscall(void *cpu_env, int num, abi_ulong arg1,
abi_ulong arg2, abi_ulong arg3, abi_ulong arg4,
abi_ulong arg5, abi_ulong arg6, abi_ulong arg7,
abi_ulong arg8);
void gemu_log(const char *fmt, ...) GCC_FMT_ATTR(1, 2);
extern __thread CPUState *thread_cpu;
void cpu_loop(CPUArchState *env);

View File

@@ -575,6 +575,10 @@ static void QEMU_NORETURN dump_core_and_abort(int target_sig)
trace_user_force_sig(env, target_sig, host_sig);
gdb_signalled(env, target_sig);
if (target_sig == 6) {
goto no_core;
}
/* dump core if supported by target binary format */
if (core_dump_signal(target_sig) && (ts->bprm->core_dump != NULL)) {
stop_all_tasks();
@@ -592,6 +596,8 @@ static void QEMU_NORETURN dump_core_and_abort(int target_sig)
target_sig, strsignal(host_sig), "core dumped" );
}
no_core:
/* The proper exit code for dying from an uncaught signal is
* -<signal>. The kernel doesn't allow exit() or _exit() to pass
* a negative value. To get the proper exit code we need to

View File

@@ -5770,7 +5770,12 @@ static abi_long do_ioctl(int fd, int cmd, abi_long arg)
ie = ioctl_entries;
for(;;) {
if (ie->target_cmd == 0) {
gemu_log("Unsupported ioctl: cmd=0x%04lx\n", (long)cmd);
int i;
gemu_log("Unsupported ioctl: cmd=0x%04lx (%x)\n", (unsigned long)cmd, (unsigned int)(cmd & (TARGET_IOC_SIZEMASK << TARGET_IOC_SIZESHIFT)) >> TARGET_IOC_SIZESHIFT);
for (i = 0; ioctl_entries[i].target_cmd; i++) {
if ((ioctl_entries[i].target_cmd & ~(TARGET_IOC_SIZEMASK << TARGET_IOC_SIZESHIFT)) == (cmd & ~(TARGET_IOC_SIZEMASK << TARGET_IOC_SIZESHIFT)))
gemu_log("%p\t->\t%s (%x)\n", (void *)(unsigned long)ioctl_entries[i].host_cmd, ioctl_entries[i].name, (ioctl_entries[i].target_cmd & (TARGET_IOC_SIZEMASK << TARGET_IOC_SIZESHIFT)) >> TARGET_IOC_SIZESHIFT);
}
return -TARGET_ENOSYS;
}
if (ie->target_cmd == cmd)
@@ -5802,6 +5807,11 @@ static abi_long do_ioctl(int fd, int cmd, abi_long arg)
arg_type++;
target_size = thunk_type_size(arg_type, 0);
switch(ie->access) {
/* FIXME: actually the direction given in the ioctl should be
* correct so we can assume the communication is uni-directional.
* The alsa developers did not like this concept though and
* declared ioctls IOC_R and IOC_W even though they were IOC_RW.*/
/*
case IOC_R:
ret = get_errno(safe_ioctl(fd, ie->host_cmd, buf_temp));
if (!is_error(ret)) {
@@ -5820,6 +5830,7 @@ static abi_long do_ioctl(int fd, int cmd, abi_long arg)
unlock_user(argptr, arg, 0);
ret = get_errno(safe_ioctl(fd, ie->host_cmd, buf_temp));
break;
*/
default:
case IOC_RW:
argptr = lock_user(VERIFY_READ, arg, target_size, 1);
@@ -7691,6 +7702,25 @@ static int open_self_stat(void *cpu_env, int fd)
return 0;
}
static int open_cpuinfo(void *cpu_env, int fd)
{
dprintf(fd,
"Processor : ARMv7 Processor rev 5 (v7l)\n"
"BogoMIPS : 799.53\n"
"Features : swp half thumb fastmult vfp edsp thumbee neon vfpv3\n"
"CPU implementer : 0x41\n"
"CPU architecture: 7\n"
"CPU variant : 0x2\n"
"CPU part : 0xc08\n"
"CPU revision : 5\n"
"\n"
"Hardware : Genesi Efika MX (Smarttop)\n"
"Revision : 51030\n"
"Serial : 0000000000000000\n");
return 0;
}
static int open_self_auxv(void *cpu_env, int fd)
{
CPUState *cpu = ENV_GET_CPU((CPUArchState *)cpu_env);
@@ -7805,6 +7835,7 @@ static int do_openat(void *cpu_env, int dirfd, const char *pathname, int flags,
#if defined(HOST_WORDS_BIGENDIAN) != defined(TARGET_WORDS_BIGENDIAN)
{ "/proc/net/route", open_net_route, is_proc },
#endif
{ "cpuinfo", open_cpuinfo, is_proc_myself },
{ NULL, NULL, NULL }
};
@@ -7989,10 +8020,10 @@ static int host_to_target_cpu_mask(const unsigned long *host_mask,
/* do_syscall() should always have a single exit point at the end so
that actions, such as logging of syscall results, can be performed.
All errnos that do_syscall() returns must be -TARGET_<errcode>. */
abi_long do_syscall(void *cpu_env, int num, abi_long arg1,
abi_long arg2, abi_long arg3, abi_long arg4,
abi_long arg5, abi_long arg6, abi_long arg7,
abi_long arg8)
abi_long do_syscall(void *cpu_env, int num, abi_ulong arg1,
abi_ulong arg2, abi_ulong arg3, abi_ulong arg4,
abi_ulong arg5, abi_ulong arg6, abi_ulong arg7,
abi_ulong arg8)
{
CPUState *cpu = ENV_GET_CPU(cpu_env);
abi_long ret;
@@ -8365,9 +8396,14 @@ abi_long do_syscall(void *cpu_env, int num, abi_long arg1,
case TARGET_NR_oldstat:
goto unimplemented;
#endif
case TARGET_NR_lseek:
ret = get_errno(lseek(arg1, arg2, arg3));
case TARGET_NR_lseek: {
off_t off = arg2;
if (arg3 != SEEK_SET) {
off = (abi_long)arg2;
}
ret = get_errno(lseek(arg1, off, arg3));
break;
}
#if defined(TARGET_NR_getxpid) && defined(TARGET_ALPHA)
/* Alpha specific */
case TARGET_NR_getxpid:
@@ -9292,6 +9328,8 @@ abi_long do_syscall(void *cpu_env, int num, abi_long arg1,
case TARGET_NR_gettimeofday:
{
struct timeval tv;
if(copy_from_user_timeval(&tv, arg1))
goto efault;
ret = get_errno(gettimeofday(&tv, NULL));
if (!is_error(ret)) {
if (copy_to_user_timeval(arg1, &tv))
@@ -10542,7 +10580,7 @@ abi_long do_syscall(void *cpu_env, int num, abi_long arg1,
{
struct timespec ts, *pts;
if (arg3 >= 0) {
if ((abi_long)arg3 >= 0) {
/* Convert ms to secs, ns */
ts.tv_sec = arg3 / 1000;
ts.tv_nsec = (arg3 % 1000) * 1000000LL;

View File

@@ -2575,6 +2575,14 @@ static void migration_completion(MigrationState *s)
migrate_set_state(&s->state, current_active_state,
MIGRATION_STATUS_COMPLETED);
}
if (spec_ctrl_is_inconsistent()) {
fprintf(stderr, "WARNING! Migration from qemu with rudimentary "
"Spectre v2 support to newer qemu\ndetected! To "
"maintain proper protection, restart the guest as "
"soon as possible\nusing the spec_ctrl cpu feature "
"flag or a *-IBRS vcpu model specified\nas appropriate."
"\n");
}
return;

View File

@@ -343,12 +343,6 @@ KP_Decimal 0x53 numlock
# evdev 85 (0x55): no evdev -> QKeyCode mapping (xkb keysym NoSymbol)
# evdev 86 (0x56), QKeyCode "less", number 0x56
less 0x56
greater 0x56 shift
bar 0x56 altgr
brokenbar 0x56 shift altgr
# evdev 87 (0x57), QKeyCode "f11", number 0x57
F11 0x57

View File

@@ -44,7 +44,8 @@ static void free_range(void *range, void *dummy)
g_free(range);
}
static int parse_str(StringInputVisitor *siv, const char *name, Error **errp)
static int parse_str(StringInputVisitor *siv, const char *name, bool u64,
Error **errp)
{
char *str = (char *) siv->string;
long long start, end;
@@ -61,7 +62,11 @@ static int parse_str(StringInputVisitor *siv, const char *name, Error **errp)
do {
errno = 0;
start = strtoll(str, &endptr, 0);
if (u64) {
start = strtoull(str, &endptr, 0);
} else {
start = strtoll(str, &endptr, 0);
}
if (errno == 0 && endptr > str) {
if (*endptr == '\0') {
cur = g_malloc0(sizeof(*cur));
@@ -72,7 +77,11 @@ static int parse_str(StringInputVisitor *siv, const char *name, Error **errp)
} else if (*endptr == '-') {
str = endptr + 1;
errno = 0;
end = strtoll(str, &endptr, 0);
if (u64) {
end = strtoull(str, &endptr, 0);
} else {
end = strtoll(str, &endptr, 0);
}
if (errno == 0 && endptr > str && start <= end &&
(start > INT64_MAX - 65536 ||
end < start + 65536)) {
@@ -128,7 +137,7 @@ start_list(Visitor *v, const char *name, GenericList **list, size_t size,
assert(list);
siv->list = list;
if (parse_str(siv, name, errp) < 0) {
if (parse_str(siv, name, false, errp) < 0) {
*list = NULL;
return;
}
@@ -216,7 +225,7 @@ static void parse_type_int64(Visitor *v, const char *name, int64_t *obj,
{
StringInputVisitor *siv = to_siv(v);
if (parse_str(siv, name, errp) < 0) {
if (parse_str(siv, name, false, errp) < 0) {
return;
}
@@ -252,15 +261,43 @@ error:
static void parse_type_uint64(Visitor *v, const char *name, uint64_t *obj,
Error **errp)
{
/* FIXME: parse_type_int64 mishandles values over INT64_MAX */
int64_t i;
Error *err = NULL;
parse_type_int64(v, name, &i, &err);
if (err) {
error_propagate(errp, err);
} else {
*obj = i;
StringInputVisitor *siv = to_siv(v);
if (!siv->string) {
error_setg(errp, QERR_INVALID_PARAMETER_TYPE, name ? name : "null",
"integer");
return;
}
parse_str(siv, name, true, errp);
if (!siv->ranges) {
goto error;
}
if (!siv->cur_range) {
Range *r;
siv->cur_range = g_list_first(siv->ranges);
if (!siv->cur_range) {
goto error;
}
r = siv->cur_range->data;
if (!r) {
goto error;
}
siv->cur = range_lob(r);
}
*obj = siv->cur;
siv->cur++;
return;
error:
error_setg(errp, QERR_INVALID_PARAMETER_VALUE, name,
"a uint64 value or range");
}
static void parse_type_size(Visitor *v, const char *name, uint64_t *obj,

View File

@@ -110,7 +110,12 @@ static int parse_acl_file(const char *filename, ACLList *acl_list)
*argend = 0;
if (strcmp(cmd, "deny") == 0) {
acl_rule = g_malloc(sizeof(*acl_rule));
acl_rule = calloc(1, sizeof(*acl_rule));
if (!acl_rule) {
fclose(f);
errno = ENOMEM;
return -1;
}
if (strcmp(arg, "all") == 0) {
acl_rule->type = ACL_DENY_ALL;
} else {
@@ -119,7 +124,12 @@ static int parse_acl_file(const char *filename, ACLList *acl_list)
}
QSIMPLEQ_INSERT_TAIL(acl_list, acl_rule, entry);
} else if (strcmp(cmd, "allow") == 0) {
acl_rule = g_malloc(sizeof(*acl_rule));
acl_rule = calloc(1, sizeof(*acl_rule));
if (!acl_rule) {
fclose(f);
errno = ENOMEM;
return -1;
}
if (strcmp(arg, "all") == 0) {
acl_rule->type = ACL_ALLOW_ALL;
} else {
@@ -413,6 +423,17 @@ int main(int argc, char **argv)
goto cleanup;
}
#ifndef CONFIG_LIBCAP
/* avoid sending the fd as root user if running suid to not fool
* peer credentials to daemons that dont expect that
*/
if (setuid(getuid()) < 0) {
fprintf(stderr, "Failed to drop privileges.\n");
ret = EXIT_FAILURE;
goto cleanup;
}
#endif
/* write fd to the domain socket */
if (send_fd(unixfd, fd) == -1) {
fprintf(stderr, "failed to write fd to unix socket: %s\n",
@@ -434,7 +455,7 @@ cleanup:
}
while ((acl_rule = QSIMPLEQ_FIRST(&acl_list)) != NULL) {
QSIMPLEQ_REMOVE_HEAD(&acl_list, entry);
g_free(acl_rule);
free(acl_rule);
}
return ret;

View File

@@ -20,6 +20,7 @@
#include <sys/prctl.h>
#include <seccomp.h>
#include "sysemu/seccomp.h"
#include <linux/seccomp.h>
/* For some architectures (notably ARM) cacheflush is not supported until
* libseccomp 2.2.3, but configure enforces that we are using a more recent
@@ -107,12 +108,39 @@ static const struct QemuSeccompSyscall blacklist[] = {
{ SCMP_SYS(sched_get_priority_min), QEMU_SECCOMP_SET_RESOURCECTL },
};
static inline __attribute__((unused)) int
qemu_seccomp(unsigned int operation, unsigned int flags, void *args)
{
#ifdef __NR_seccomp
return syscall(__NR_seccomp, operation, flags, args);
#else
errno = ENOSYS;
return -1;
#endif
}
static uint32_t qemu_seccomp_get_kill_action(void)
{
#if defined(SECCOMP_GET_ACTION_AVAIL) && defined(SCMP_ACT_KILL_PROCESS) && \
defined(SECCOMP_RET_KILL_PROCESS)
{
uint32_t action = SECCOMP_RET_KILL_PROCESS;
if (qemu_seccomp(SECCOMP_GET_ACTION_AVAIL, 0, &action) == 0) {
return SCMP_ACT_KILL_PROCESS;
}
}
#endif
return SCMP_ACT_TRAP;
}
static int seccomp_start(uint32_t seccomp_opts)
{
int rc = 0;
unsigned int i = 0;
scmp_filter_ctx ctx;
uint32_t action = qemu_seccomp_get_kill_action();
ctx = seccomp_init(SCMP_ACT_ALLOW);
if (ctx == NULL) {
@@ -120,12 +148,17 @@ static int seccomp_start(uint32_t seccomp_opts)
goto seccomp_return;
}
rc = seccomp_attr_set(ctx, SCMP_FLTATR_CTL_TSYNC, 1);
if (rc != 0) {
goto seccomp_return;
}
for (i = 0; i < ARRAY_SIZE(blacklist); i++) {
if (!(seccomp_opts & blacklist[i].set)) {
continue;
}
rc = seccomp_rule_add_array(ctx, SCMP_ACT_KILL, blacklist[i].num,
rc = seccomp_rule_add_array(ctx, action, blacklist[i].num,
blacklist[i].narg, blacklist[i].arg_cmp);
if (rc < 0) {
goto seccomp_return;
@@ -248,7 +281,24 @@ static QemuOptsList qemu_sandbox_opts = {
static void seccomp_register(void)
{
qemu_add_opts(&qemu_sandbox_opts);
bool add = false;
/* FIXME: use seccomp_api_get() >= 2 check when released */
#if defined(SECCOMP_FILTER_FLAG_TSYNC)
int check;
/* check host TSYNC capability, it returns errno == ENOSYS if unavailable */
check = qemu_seccomp(SECCOMP_SET_MODE_FILTER,
SECCOMP_FILTER_FLAG_TSYNC, NULL);
if (check < 0 && errno == EFAULT) {
add = true;
}
#endif
if (add) {
qemu_add_opts(&qemu_sandbox_opts);
}
}
opts_init(seccomp_register);
#endif

View File

@@ -52,6 +52,12 @@ SEABIOS_EXTRAVERSION="-prebuilt.qemu-project.org"
#
EFIROM ?= $(shell which EfiRom 2>/dev/null)
# NB: Certain SUSE qemu subpackages use date information, but we want
# reproducible builds, so we use a pre-determined timestamp, rather
# than the current timestamp to acheive consistent results build to
# build.
PACKAGING_TIMESTAMP = $(shell date -r ../VERSION +%s)
default:
@echo "nothing is build by default"
@echo "available build targets:"
@@ -95,7 +101,7 @@ build-seabios-config-%: config.%
.PHONY: sgabios skiboot
sgabios:
$(MAKE) -C sgabios
$(MAKE) -C sgabios PACKAGING_TIMESTAMP=$(PACKAGING_TIMESTAMP)
cp sgabios/sgabios.bin ../pc-bios
@@ -115,18 +121,22 @@ efi-rom-%: build-pxe-roms build-efi-roms
build-pxe-roms:
$(MAKE) -C ipxe/src CONFIG=qemu \
PACKAGING_TIMESTAMP=$(PACKAGING_TIMESTAMP) \
CROSS_COMPILE=$(x86_64_cross_prefix) \
$(patsubst %,bin/%.rom,$(pxerom_targets))
build-efi-roms: build-pxe-roms
$(MAKE) -C ipxe/src CONFIG=qemu \
PACKAGING_TIMESTAMP=$(PACKAGING_TIMESTAMP) \
CROSS_COMPILE=$(x86_64_cross_prefix) \
$(patsubst %,bin-i386-efi/%.efidrv,$(pxerom_targets)) \
$(patsubst %,bin-x86_64-efi/%.efidrv,$(pxerom_targets))
slof:
$(MAKE) -C SLOF CROSS=$(powerpc64_cross_prefix) qemu
$(MAKE) -C SLOF CROSS=$(powerpc64_cross_prefix) \
PACKAGING_TIMESTAMP=$(PACKAGING_TIMESTAMP) \
qemu
cp SLOF/boot_rom.bin ../pc-bios/slof.bin
u-boot.e500:

View File

@@ -1,4 +1,4 @@
#!/usr/bin/env python
#!/usr/bin/python3
#
# Migration Stream Analyzer
#

View File

@@ -258,7 +258,7 @@ qemu_generate_register() {
flags="${flags}F"
fi
echo ":qemu-$cpu:M::$magic:$mask:$qemu:$flags"
echo ":qemu-$cpu:M::$magic:$mask:$qemu:P$flags"
}
qemu_register_interpreter() {
@@ -297,9 +297,9 @@ qemu_set_binfmts() {
continue
fi
qemu="$QEMU_PATH/qemu-$cpu"
qemu="$QEMU_PATH/qemu-$cpu-binfmt"
if [ "$cpu" = "i486" ] ; then
qemu="$QEMU_PATH/qemu-i386"
qemu="$QEMU_PATH/qemu-i386-binfmt"
fi
qemu="$qemu$QEMU_SUFFIX"
@@ -315,7 +315,7 @@ BINFMT_SET=qemu_register_interpreter
SYSTEMDDIR="/etc/binfmt.d"
DEBIANDIR="/usr/share/binfmts"
QEMU_PATH=/usr/local/bin
QEMU_PATH=/usr/bin
CREDENTIAL=no
PERSISTENT=no
QEMU_SUFFIX=""

View File

@@ -1,4 +1,4 @@
#!/usr/bin/python
#!/usr/bin/python3
#
# Compares vmstate information stored in JSON format, obtained from
# the -dump-vmstate QEMU command.

View File

@@ -12,3 +12,12 @@
void xenstore_store_pv_console_info(int i, Chardev *chr)
{
}
void xen_blk_resize_cb(void *dev)
{
}
char *xen_blk_get_attached_dev_id(void *dev)
{
return g_strdup("");
}

View File

@@ -1675,7 +1675,7 @@ uint64_t cpu_get_tsc(CPUX86State *env);
/* XXX: This value should match the one returned by CPUID
* and in exec.c */
# if defined(TARGET_X86_64)
# define TCG_PHYS_ADDR_BITS 40
# define TCG_PHYS_ADDR_BITS 42
# else
# define TCG_PHYS_ADDR_BITS 36
# endif

View File

@@ -2,6 +2,7 @@
* S/390 virtual CPU header
*
* Copyright (c) 2009 Ulrich Hecht
* Copyright IBM Corp. 2012, 2018
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@@ -68,6 +69,8 @@ struct CPUS390XState {
uint32_t aregs[16]; /* access registers */
uint8_t riccb[64]; /* runtime instrumentation control */
uint64_t gscb[4]; /* guarded storage control */
uint64_t etoken; /* etoken */
uint64_t etoken_extension; /* etoken extension */
/* Fields up to this point are not cleared by initial CPU reset */
struct {} start_initial_reset_fields;

View File

@@ -1,7 +1,7 @@
/*
* CPU features/facilities for s390x
*
* Copyright 2016 IBM Corp.
* Copyright IBM Corp. 2016, 2018
*
* Author(s): David Hildenbrand <dahi@linux.vnet.ibm.com>
*
@@ -106,6 +106,7 @@ static const S390FeatDef s390_features[] = {
FEAT_INIT("irbm", S390_FEAT_TYPE_STFL, 145, "Insert-reference-bits-multiple facility"),
FEAT_INIT("msa8-base", S390_FEAT_TYPE_STFL, 146, "Message-security-assist-extension-8 facility (excluding subfunctions)"),
FEAT_INIT("cmmnt", S390_FEAT_TYPE_STFL, 147, "CMM: ESSA-enhancement (no translate) facility"),
FEAT_INIT("etoken", S390_FEAT_TYPE_STFL, 156, "Etoken facility"),
/* SCLP SCCB Byte 80 - 98 (bit numbers relative to byte-80) */
FEAT_INIT("gsls", S390_FEAT_TYPE_SCLP_CONF_CHAR, 40, "SIE: Guest-storage-limit-suppression facility"),

View File

@@ -1,7 +1,7 @@
/*
* CPU features/facilities for s390
*
* Copyright 2016 IBM Corp.
* Copyright IBM Corp. 2016, 2018
*
* Author(s): Michael Mueller <mimu@linux.vnet.ibm.com>
* David Hildenbrand <dahi@linux.vnet.ibm.com>
@@ -93,6 +93,7 @@ typedef enum {
S390_FEAT_INSERT_REFERENCE_BITS_MULT,
S390_FEAT_MSA_EXT_8,
S390_FEAT_CMM_NT,
S390_FEAT_ETOKEN,
/* Sclp Conf Char */
S390_FEAT_SIE_GSLS,

View File

@@ -1,7 +1,7 @@
/*
* S390 feature list generator
*
* Copyright 2016 IBM Corp.
* Copyright IBM Corp. 2016, 2018
*
* Author(s): Michael Mueller <mimu@linux.vnet.ibm.com>
* David Hildenbrand <dahi@linux.vnet.ibm.com>
@@ -471,6 +471,7 @@ static uint16_t full_GEN14_GA1[] = {
S390_FEAT_GROUP_MSA_EXT_7,
S390_FEAT_GROUP_MSA_EXT_8,
S390_FEAT_CMM_NT,
S390_FEAT_ETOKEN,
S390_FEAT_HPMA2,
S390_FEAT_SIE_KSS,
S390_FEAT_GROUP_MULTIPLE_EPOCH_PTFF,

View File

@@ -493,6 +493,12 @@ int kvm_arch_put_registers(CPUState *cs, int level)
cs->kvm_run->kvm_dirty_regs |= KVM_SYNC_BPBC;
}
if (can_sync_regs(cs, KVM_SYNC_ETOKEN)) {
cs->kvm_run->s.regs.etoken = env->etoken;
cs->kvm_run->s.regs.etoken_extension = env->etoken_extension;
cs->kvm_run->kvm_dirty_regs |= KVM_SYNC_ETOKEN;
}
/* Finally the prefix */
if (can_sync_regs(cs, KVM_SYNC_PREFIX)) {
cs->kvm_run->s.regs.prefix = env->psa;
@@ -607,6 +613,11 @@ int kvm_arch_get_registers(CPUState *cs)
env->bpbc = cs->kvm_run->s.regs.bpbc;
}
if (can_sync_regs(cs, KVM_SYNC_ETOKEN)) {
env->etoken = cs->kvm_run->s.regs.etoken;
env->etoken_extension = cs->kvm_run->s.regs.etoken_extension;
}
/* pfault parameters */
if (can_sync_regs(cs, KVM_SYNC_PFAULT)) {
env->pfault_token = cs->kvm_run->s.regs.pft;

View File

@@ -1,7 +1,7 @@
/*
* S390x machine definitions and functions
*
* Copyright IBM Corp. 2014
* Copyright IBM Corp. 2014, 2018
*
* Authors:
* Thomas Huth <thuth@linux.vnet.ibm.com>
@@ -216,6 +216,23 @@ const VMStateDescription vmstate_bpbc = {
}
};
static bool etoken_needed(void *opaque)
{
return s390_has_feat(S390_FEAT_ETOKEN);
}
const VMStateDescription vmstate_etoken = {
.name = "cpu/etoken",
.version_id = 1,
.minimum_version_id = 1,
.needed = etoken_needed,
.fields = (VMStateField[]) {
VMSTATE_UINT64(env.etoken, S390CPU),
VMSTATE_UINT64(env.etoken_extension, S390CPU),
VMSTATE_END_OF_LIST()
}
};
const VMStateDescription vmstate_s390_cpu = {
.name = "cpu",
.post_load = cpu_post_load,
@@ -251,6 +268,7 @@ const VMStateDescription vmstate_s390_cpu = {
&vmstate_exval,
&vmstate_gscb,
&vmstate_bpbc,
&vmstate_etoken,
NULL
},
};

View File

@@ -129,6 +129,8 @@ check-unit-y += tests/check-qom-interface$(EXESUF)
gcov-files-check-qom-interface-y = qom/object.c
check-unit-y += tests/check-qom-proplist$(EXESUF)
gcov-files-check-qom-proplist-y = qom/object.c
check-unit-y += tests/check-qom-props$(EXESUF)
gcov-files-check-qom-props-y = qom/object.c
check-unit-y += tests/test-qemu-opts$(EXESUF)
gcov-files-test-qemu-opts-y = util/qemu-option.c
check-unit-y += tests/test-keyval$(EXESUF)
@@ -201,6 +203,8 @@ check-qtest-virtio-y += tests/virtio-rng-test$(EXESUF)
gcov-files-virtio-y += hw/virtio/virtio-rng.c
check-qtest-virtio-y += tests/virtio-scsi-test$(EXESUF)
gcov-files-virtio-y += i386-softmmu/hw/scsi/virtio-scsi.c
check-qtest-virtio-y += tests/scsi-disk-test$(EXESUF)
gcov-files-virtio-y += i386-softmmu/hw/scsi/scsi-disk.c
ifeq ($(CONFIG_VIRTIO)$(CONFIG_VIRTFS)$(CONFIG_PCI),yyy)
check-qtest-virtio-y += tests/virtio-9p-test$(EXESUF)
gcov-files-virtio-y += hw/9pfs/virtio-9p.c
@@ -629,6 +633,7 @@ tests/check-qjson$(EXESUF): tests/check-qjson.o $(test-util-obj-y)
tests/check-qlit$(EXESUF): tests/check-qlit.o $(test-util-obj-y)
tests/check-qom-interface$(EXESUF): tests/check-qom-interface.o $(test-qom-obj-y)
tests/check-qom-proplist$(EXESUF): tests/check-qom-proplist.o $(test-qom-obj-y)
tests/check-qom-props$(EXESUF): tests/check-qom-props.o $(test-qom-obj-y)
tests/test-char$(EXESUF): tests/test-char.o $(test-util-obj-y) $(qtest-obj-y) $(test-io-obj-y) $(chardev-obj-y)
tests/test-coroutine$(EXESUF): tests/test-coroutine.o $(test-block-obj-y)
@@ -837,6 +842,7 @@ tests/migration-test$(EXESUF): tests/migration-test.o
tests/vhost-user-test$(EXESUF): tests/vhost-user-test.o $(test-util-obj-y) \
$(qtest-obj-y) $(test-io-obj-y) $(libqos-virtio-obj-y) $(libqos-pc-obj-y) \
$(chardev-obj-y)
tests/scsi-disk-test$(EXESUF): tests/scsi-disk-test.o
tests/qemu-iotests/socket_scm_helper$(EXESUF): tests/qemu-iotests/socket_scm_helper.o
tests/test-qemu-opts$(EXESUF): tests/test-qemu-opts.o $(test-util-obj-y)
tests/test-keyval$(EXESUF): tests/test-keyval.o $(test-util-obj-y) $(test-qapi-obj-y)

View File

@@ -116,8 +116,8 @@ static bool check_guest_output(const testdef_t *test, int fd)
int i, nbr = 0, pos = 0, ccnt;
char ch;
/* Poll serial output... Wait at most 60 seconds */
for (i = 0; i < 6000; ++i) {
/* Poll serial output... Wait at most 360 seconds */
for (i = 0; i < 36000; ++i) {
ccnt = 0;
while (ccnt++ < 512 && (nbr = read(fd, &ch, 1)) == 1) {
if (ch == test->expect[pos]) {

122
tests/check-qom-props.c Normal file
View File

@@ -0,0 +1,122 @@
/*
* Copyright (C) 2015 Red Hat, Inc.
* Copyright (c) 2015 SUSE Linux GmbH
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library. If not, see
* <http://www.gnu.org/licenses/>.
*
* Author: Daniel P. Berrange <berrange@redhat.com>
* Andreas Färber <afaerber@suse.com>
*/
#include "qemu/osdep.h"
#include <glib.h>
#include "qapi/visitor.h"
#include "qom/object.h"
#include "qemu/module.h"
#define TYPE_DUMMY "qemu-dummy"
typedef struct DummyObject DummyObject;
typedef struct DummyObjectClass DummyObjectClass;
#define DUMMY_OBJECT(obj) \
OBJECT_CHECK(DummyObject, (obj), TYPE_DUMMY)
struct DummyObject {
Object parent_obj;
uint64_t u64val;
};
struct DummyObjectClass {
ObjectClass parent_class;
};
static void dummy_set_uint64(Object *obj, Visitor *v,
const char *name, void *opaque,
Error **errp)
{
uint64_t *ptr = (uint64_t *)opaque;
visit_type_uint64(v, name, ptr, errp);
}
static void dummy_get_uint64(Object *obj, Visitor *v,
const char *name, void *opaque,
Error **errp)
{
uint64_t value = *(uint64_t *)opaque;
visit_type_uint64(v, name, &value, errp);
}
static void dummy_init(Object *obj)
{
DummyObject *dobj = DUMMY_OBJECT(obj);
object_property_add(obj, "u64val", "uint64",
dummy_get_uint64,
dummy_set_uint64,
NULL, &dobj->u64val, NULL);
}
static const TypeInfo dummy_info = {
.name = TYPE_DUMMY,
.parent = TYPE_OBJECT,
.instance_size = sizeof(DummyObject),
.instance_init = dummy_init,
.class_size = sizeof(DummyObjectClass),
};
static void test_dummy_uint64(void)
{
Error *err = NULL;
char *str;
DummyObject *dobj = DUMMY_OBJECT(object_new(TYPE_DUMMY));
g_assert(dobj->u64val == 0);
str = g_strdup_printf("%" PRIu64, UINT64_MAX);
object_property_parse(OBJECT(dobj), str, "u64val", &err);
g_free(str);
g_assert(!err);
g_assert_cmpint(dobj->u64val, ==, UINT64_MAX);
dobj->u64val = 0;
str = g_strdup_printf("0x%" PRIx64, UINT64_MAX);
object_property_parse(OBJECT(dobj), str, "u64val", &err);
g_free(str);
g_assert(!err);
g_assert_cmpint(dobj->u64val, ==, UINT64_MAX);
object_unref(OBJECT(dobj));
}
int main(int argc, char **argv)
{
g_test_init(&argc, &argv, NULL);
module_call_init(MODULE_INIT_QOM);
type_register_static(&dummy_info);
g_test_add_func("/qom/props/uint64", test_dummy_uint64);
return g_test_run();
}

View File

@@ -136,7 +136,7 @@
127 rw auto backing quick
128 rw auto quick
129 rw auto quick
130 rw auto quick
#ISSUES 130 rw auto quick
131 rw auto quick
132 rw auto quick
133 auto quick
@@ -159,7 +159,7 @@
150 rw auto quick
151 rw auto
152 rw auto quick
153 rw auto quick
#ISSUES 153 rw auto quick
154 rw auto backing quick
155 rw auto
156 rw auto quick
@@ -167,7 +167,7 @@
158 rw auto quick
159 rw auto quick
160 rw auto quick
162 auto quick
#ISSUES 162 auto quick
163 rw auto
165 rw auto quick
169 rw auto quick migration

83
tests/scsi-disk-test.c Normal file
View File

@@ -0,0 +1,83 @@
/*
* QTest testcase for SCSI disks
* See virtio-scsi-test for more integrated tests.
*
* Copyright (c) 2015 SUSE Linux GmbH
*
* This work is licensed under the terms of the GNU GPL, version 2 or later.
* See the COPYING file in the top-level directory.
*/
#include "qemu/osdep.h"
#include <glib.h>
#include "libqtest.h"
#include "qapi/qmp/qnum.h"
#include "qapi/qmp/qdict.h"
static void test_scsi_disk_common(const char *type, const char *id)
{
char *cmdline, *path;
QDict *response;
QNum *value;
cmdline = g_strdup_printf(
"-drive id=drv0,if=none,file=/dev/null,format=raw "
"-device virtio-scsi-pci,id=scsi0 "
"-device %s,id=%s,bus=scsi0.0,drive=drv0"
",wwn=0x%" PRIx64 ",port_wwn=0x%" PRIx64,
type, id, UINT64_MAX, UINT64_C(1) << 63);
qtest_start(cmdline);
g_free(cmdline);
path = g_strdup_printf("/machine/peripheral/%s", id);
response = qmp("{ 'execute': 'qom-get',"
" 'arguments': { 'path': %s,"
" 'property': 'wwn' } }",
path);
g_assert(response);
g_assert(qdict_haskey(response, "return"));
value = qobject_to(QNum, qdict_get(response, "return"));
g_assert_cmpint(qnum_get_uint(value), ==, UINT64_MAX);
response = qmp("{ 'execute': 'qom-get',"
" 'arguments': { 'path': %s,"
" 'property': 'port_wwn' } }",
path);
g_assert(response);
g_assert(qdict_haskey(response, "return"));
value = qobject_to(QNum, qdict_get(response, "return"));
g_assert_cmpint(qnum_get_uint(value), ==, UINT64_C(1) << 63);
g_free(path);
qtest_end();
}
static void test_scsi_disk(void)
{
test_scsi_disk_common("scsi-disk", "disk0");
}
static void test_scsi_hd(void)
{
test_scsi_disk_common("scsi-hd", "hd0");
}
static void test_scsi_cd(void)
{
test_scsi_disk_common("scsi-cd", "cd0");
}
int main(int argc, char **argv)
{
int ret;
g_test_init(&argc, &argv, NULL);
qtest_add_func("/scsi-disk/props", test_scsi_disk);
qtest_add_func("/scsi-hd/props", test_scsi_hd);
qtest_add_func("/scsi-cd/props", test_scsi_cd);
ret = g_test_run();
return ret;
}

View File

@@ -1,3 +1,4 @@
#define HW_POISON_H // avoid poison since we patch against rules it "enforces"
#include "qemu/osdep.h"
#include <glib/gstdio.h>

View File

@@ -53,6 +53,14 @@ static void test_visitor_in_int(TestInputVisitorData *data,
v = visitor_input_test_init(data, "-42");
visit_type_int(v, NULL, &res, &err);
g_assert(!err);
g_assert_cmpint(res, ==, value);
visitor_input_teardown(data, unused);
value = INT64_MAX;
v = visitor_input_test_init(data, g_strdup_printf("%" PRId64, value));
visit_type_int(v, NULL, &res, &err);
g_assert(!err);
g_assert_cmpint(res, ==, value);
@@ -68,6 +76,27 @@ static void test_visitor_in_int(TestInputVisitorData *data,
error_free_or_abort(&err);
}
static void test_visitor_in_uint64(TestInputVisitorData *data,
const void *unused)
{
uint64_t res = 0, value = UINT64_MAX;
Error *err = NULL;
Visitor *v;
v = visitor_input_test_init(data, g_strdup_printf("%" PRIu64, value));
visit_type_uint64(v, NULL, &res, &err);
g_assert(!err);
g_assert_cmpint(res, ==, value);
visitor_input_teardown(data, unused);
v = visitor_input_test_init(data, g_strdup_printf("0x%" PRIx64, value));
visit_type_uint64(v, NULL, &res, &err);
g_assert(!err);
g_assert_cmpint(res, ==, value);
}
static void check_ilist(Visitor *v, int64_t *expected, size_t n)
{
int64List *res = NULL;
@@ -354,6 +383,8 @@ int main(int argc, char **argv)
input_visitor_test_add("/string-visitor/input/int",
&in_visitor_data, test_visitor_in_int);
input_visitor_test_add("/string-visitor/input/uint64",
&in_visitor_data, test_visitor_in_uint64);
input_visitor_test_add("/string-visitor/input/intList",
&in_visitor_data, test_visitor_in_intList);
input_visitor_test_add("/string-visitor/input/bool",

View File

@@ -171,6 +171,7 @@ static void do_test_cancel(bool sync)
/* Cancel the jobs that haven't been started yet. */
num_canceled = 0;
for (i = 0; i < 100; i++) {
smp_mb();
if (atomic_cmpxchg(&data[i].n, 0, 3) == 0) {
data[i].ret = -ECANCELED;
if (sync) {
@@ -185,6 +186,7 @@ static void do_test_cancel(bool sync)
g_assert_cmpint(num_canceled, <, 100);
for (i = 0; i < 100; i++) {
smp_mb();
if (data[i].aiocb && data[i].n != 3) {
if (sync) {
/* Canceling the others will be a blocking operation. */
@@ -201,6 +203,7 @@ static void do_test_cancel(bool sync)
}
g_assert_cmpint(active, ==, 0);
for (i = 0; i < 100; i++) {
smp_mb();
if (data[i].n == 3) {
g_assert_cmpint(data[i].ret, ==, -ECANCELED);
g_assert(data[i].aiocb == NULL);

View File

@@ -1825,6 +1825,25 @@ static void do_key_event(VncState *vs, int down, int keycode, int sym)
if (down)
vs->modifiers_state[keycode] ^= 1;
break;
default:
if (qemu_console_is_graphic(NULL)) {
/* record key 'down' info. Some client like tigervnc
* will send key down repeatedly if user pressing a
* a key for long time. In this case, we should add
* additional key up event before repeated key down,
* so that it can display the key multiple times.
*/
if (down) {
if (vs->modifiers_state[keycode]) {
/* add a key up event */
do_key_event(vs, 0, keycode, sym);
}
vs->modifiers_state[keycode] = 1;
} else {
vs->modifiers_state[keycode] = 0;
}
}
break;
}
/* Turn off the lock state sync logic if the client support the led

View File

@@ -308,7 +308,12 @@ static void thread_pool_init_one(ThreadPool *pool, AioContext *ctx)
qemu_mutex_init(&pool->lock);
qemu_cond_init(&pool->worker_stopped);
qemu_sem_init(&pool->sem, 0);
pool->max_threads = 64;
if (sizeof(pool) == 4) {
/* 32bit systems run out of virtual memory quickly */
pool->max_threads = 4;
} else {
pool->max_threads = 64;
}
pool->new_thread_bh = aio_bh_new(ctx, spawn_thread_bh_fn, pool);
QLIST_INIT(&pool->head);

16
vl.c
View File

@@ -29,6 +29,7 @@
#include "qemu/cutils.h"
#include "qemu/help_option.h"
#include "qemu/uuid.h"
#include <sys/resource.h>
#include "sysemu/seccomp.h"
#ifdef CONFIG_SDL
@@ -2949,6 +2950,7 @@ int main(int argc, char **argv, char **envp)
} BlockdevOptions_queue;
QSIMPLEQ_HEAD(, BlockdevOptions_queue) bdo_queue
= QSIMPLEQ_HEAD_INITIALIZER(bdo_queue);
struct rlimit rlimit_as;
module_call_init(MODULE_INIT_TRACE);
@@ -2957,6 +2959,16 @@ int main(int argc, char **argv, char **envp)
qemu_mutex_lock_iothread();
/*
* Try to raise the soft address space limit.
* Default on SLES 11 SP2 is 80% of physical+swap memory.
*/
getrlimit(RLIMIT_AS, &rlimit_as);
if (rlimit_as.rlim_cur < rlimit_as.rlim_max) {
rlimit_as.rlim_cur = rlimit_as.rlim_max;
setrlimit(RLIMIT_AS, &rlimit_as);
}
atexit(qemu_run_exit_notifiers);
error_set_progname(argv[0]);
qemu_init_exec_dir(argv[0]);
@@ -4003,8 +4015,8 @@ int main(int argc, char **argv, char **envp)
}
#ifdef CONFIG_SECCOMP
if (qemu_opts_foreach(qemu_find_opts("sandbox"),
parse_sandbox, NULL, NULL)) {
olist = qemu_find_opts_err("sandbox", NULL);
if (olist && qemu_opts_foreach(olist, parse_sandbox, NULL, NULL)) {
exit(1);
}
#endif