]> Git Repo - qemu.git/log
qemu.git
4 years agodocs/system/deprecated: Mark the 'moxie' CPU as deprecated
Thomas Huth [Wed, 23 Sep 2020 14:05:34 +0000 (16:05 +0200)]
docs/system/deprecated: Mark the 'moxie' CPU as deprecated

It is currently unclear whether anybody is still using the 'moxie' CPU,
and there are no images for testing available this CPU, so the code has
likely bit-rotten in the course of time. When I asked the maintainer
for information, I did not get a reply within four weeks yet (see
https://lists.gnu.org/archive/html/qemu-devel/2020-08/msg07201.html).
The last Signed-off-by line from Anthony in our repo is from 2013,
so it seems like this code is rather unmaintained. Time to put it onto
the deprecation list to see whether somebody is still interested in this
code or whether we could remove it in a couple of releases.

Message-Id: <20200923171815[email protected]>
Reviewed-by: Richard Henderson <[email protected]>
Signed-off-by: Thomas Huth <[email protected]>
4 years agoRemove superfluous .gitignore files
Thomas Huth [Sat, 19 Sep 2020 10:27:20 +0000 (12:27 +0200)]
Remove superfluous .gitignore files

Since we are now always doing out-of-tree builds, these gitignore
files should not be necessary anymore.

Message-Id: <20200919133637[email protected]>
Signed-off-by: Thomas Huth <[email protected]>
4 years agoMAINTAINERS: Ignore bios-tables-test in the qtest section
Thomas Huth [Thu, 1 Oct 2020 04:27:17 +0000 (06:27 +0200)]
MAINTAINERS: Ignore bios-tables-test in the qtest section

I'm very often getting CC: on rather large patch series that
modify the ACPI stuff of either ARM or x86, just because the
bios-table-test is often slightly involved here. I can't say
much about ACPI, and the bios-table-test is already covered
by the ACPI section in MAINTAINERS, so I'd rather prefer to
not getting automatically CC-ed on such patch series anymore.
If people want my opinion about qtest-related changes, they
can still put me on CC manually.

Message-Id: <20201001042717[email protected]>
Acked-by: Laszlo Ersek <[email protected]>
Signed-off-by: Thomas Huth <[email protected]>
4 years agoAdd a comment in bios-tables-test.c to clarify the reason behind approach
Ani Sinha [Tue, 29 Sep 2020 14:25:01 +0000 (19:55 +0530)]
Add a comment in bios-tables-test.c to clarify the reason behind approach

A comment is added in bios-tables-test.c that explains the reasoning
behind the process of updating the ACPI table blobs when new tests are added
or old tests are modified or code is committed that affect tests. The
explanation would help future contributors follow the correct process when
making code changes that affect ACPI tables.

Signed-off-by: Ani Sinha <[email protected]>
Acked-by: Igor Mammedov <[email protected]>
Message-Id: <20200929142501[email protected]>
Signed-off-by: Thomas Huth <[email protected]>
4 years agosoftmmu/vl: Be less verbose about missing KVM when running the qtests
Thomas Huth [Fri, 10 Jul 2020 08:50:20 +0000 (10:50 +0200)]
softmmu/vl: Be less verbose about missing KVM when running the qtests

Some of the qtests use "-accel kvm -accel tcg" to run real guest code.
This causes some error messages when kvm is not available. We do not
really care about these messages since the fallback to tcg is expected
here. So let's silence them to avoid that they spoil the output of
the tests.

Unfortunately, we can not use the qtest_enabled() wrapper in this case,
since the qtest accelerator itself is not initialized. Thus we have to
test for the qtest_chrdev variable instead.

Message-Id: <20200710085020[email protected]>
Reviewed-by: Alexander Bulekov <[email protected]>
Signed-off-by: Thomas Huth <[email protected]>
4 years agotests/migration: Allow longer timeouts
Dr. David Alan Gilbert [Thu, 8 Oct 2020 16:03:30 +0000 (17:03 +0100)]
tests/migration: Allow longer timeouts

In travis, with gcov and gprof we're seeing timeouts; hopefully fix
this by increasing the test timeouts a bit, but for xbzrle ensure it
really does get a couple of cycles through to test the cache.

I think the problem in travis is we have about 2 host CPU threads,
in the test we have at least 3:
   a) The vCPU thread (100% flat out)
   b) The source migration thread
   c) The destination migration thread

if (b) & (c) are slow for any reason - gcov+gperf or a slow host -
then they're sharing one host CPU thread so limit the migration
bandwidth.

Tested on my laptop with:
   taskset -c 0,1 ./tests/qtest/migration-test -p /x86_64/migration

Reported-by: Alex Bennée <[email protected]>
Signed-off-by: Dr. David Alan Gilbert <[email protected]>
Message-Id: <20201008160330[email protected]>
[thuth: Move the #define to the right location]
Signed-off-by: Thomas Huth <[email protected]>
4 years agoqtest: add fuzz test case
Li Qiang [Mon, 21 Sep 2020 16:06:05 +0000 (09:06 -0700)]
qtest: add fuzz test case

Currently the device fuzzer finds more and more issues.
For every fuzz case, we need not only the fixes but also
the corresponding test case. We can analysis the reproducer
for every case and find what happened in where and write
a beautiful test case. However the raw data of reproducer is not
friendly to analysis. It will take a very long time, even far more
than the fixes itself. So let's create a new file to hold all of
the fuzz test cases and just use the raw data to act as the test
case. This way nobody will be afraid of writing a test case for
the fuzz reproducer.

This patch adds the issue LP#1878263 test case.

Signed-off-by: Li Qiang <[email protected]>
Message-Id: <20200921160605[email protected]>
Reviewed-by: Philippe Mathieu-Daudé <[email protected]>
Reviewed-by: Alexander Bulekov <[email protected]>
[thuth: Slightly adjusted commit message, removed empty lines]
Signed-off-by: Thomas Huth <[email protected]>
4 years agoAcceptance tests: show test report on GitLab CI
Cleber Rosa [Fri, 9 Oct 2020 20:55:13 +0000 (16:55 -0400)]
Acceptance tests: show test report on GitLab CI

Avocado will, by default, produce JUnit files.  Let's ask GitLab
to present those in the web UI.

Signed-off-by: Cleber Rosa <[email protected]>
Message-Id: <20201009205513[email protected]>
Reviewed-by: Philippe Mathieu-Daudé <[email protected]>
Tested-by: Philippe Mathieu-Daudé <[email protected]>
Signed-off-by: Thomas Huth <[email protected]>
4 years agoAcceptance tests: do not show canceled test logs on GitLab CI
Cleber Rosa [Fri, 9 Oct 2020 20:55:12 +0000 (16:55 -0400)]
Acceptance tests: do not show canceled test logs on GitLab CI

Tests resulting in "CANCEL" in Avocado are usually canceled on
purpose, and are almost identical to "SKIP".  The logs for canceled
tests are adding a lot of noise to the logs being shown on GitLab CI,
and causing distraction from real failures.

As a side note, this "after script" is scheduled for removal once the
feature is implemented within Avocado itself.

Reference: https://github.com/avocado-framework/avocado/issues/4266
Signed-off-by: Cleber Rosa <[email protected]>
Message-Id: <20201009205513[email protected]>
Reviewed-by: Philippe Mathieu-Daudé <[email protected]>
Tested-by: Philippe Mathieu-Daudé <[email protected]>
Signed-off-by: Thomas Huth <[email protected]>
4 years agoAcceptance tests: bump pycdlib version for easier installation
Cleber Rosa [Fri, 9 Oct 2020 20:55:11 +0000 (16:55 -0400)]
Acceptance tests: bump pycdlib version for easier installation

On with certain versions of "pip", package installations will attempt
to create wheels.  And, on environments without a "complete" Python
installation (as described in the acceptance tests requirements docs),
that will fail.

pycdlib, starting with version 1.11.0, is now being made available
as wheels, so its instalation on those constrained environments is
now possible.

Buglink: https://bugs.launchpad.net/qemu/+bug/1897783
Reported-by: Philippe Mathieu-Daudé <[email protected]>
Signed-off-by: Cleber Rosa <[email protected]>
Message-Id: <20201009205513[email protected]>
Reviewed-by: Philippe Mathieu-Daudé <[email protected]>
Tested-by: Philippe Mathieu-Daudé <[email protected]>
Signed-off-by: Thomas Huth <[email protected]>
4 years agogitlab-ci.yml: Only run one test-case per fuzzer
Alexander Bulekov [Fri, 2 Oct 2020 14:35:24 +0000 (10:35 -0400)]
gitlab-ci.yml: Only run one test-case per fuzzer

With 1000 runs, there is a non-negligible chance that the fuzzer can
trigger a crash. With this CI job, we care about catching build/runtime
issues in the core fuzzing code. Actual device fuzzing takes place on
oss-fuzz. For these purposes, only running one input should be
sufficient.

Signed-off-by: Alexander Bulekov <[email protected]>
Suggested-by: Philippe Mathieu-Daudé <[email protected]>
Message-Id: <20201002143524[email protected]>
Reviewed-by: Philippe Mathieu-Daudé <[email protected]>
Reviewed-by: Darren Kenny <[email protected]>
Signed-off-by: Thomas Huth <[email protected]>
4 years agotests/qtest: Replace magic value by NANOSECONDS_PER_SECOND definition
Philippe Mathieu-Daudé [Sun, 11 Oct 2020 19:49:18 +0000 (21:49 +0200)]
tests/qtest: Replace magic value by NANOSECONDS_PER_SECOND definition

Use self-explicit NANOSECONDS_PER_SECOND definition instead
of a magic value.

Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
Message-Id: <20201011194918.3219195[email protected]>
Reviewed-by: Thomas Huth <[email protected]>
Signed-off-by: Thomas Huth <[email protected]>
4 years agoMerge remote-tracking branch 'remotes/bonzini-gitlab/tags/for-upstream' into staging
Peter Maydell [Mon, 12 Oct 2020 21:48:45 +0000 (22:48 +0100)]
Merge remote-tracking branch 'remotes/bonzini-gitlab/tags/for-upstream' into staging

* qtest documentation improvements (Eduardo, myself)
* libqtest event buffering (Maxim)
* use RCU for list of children of a bus (Maxim)
* move more files to softmmu/ (myself)
* meson.build cleanups, qemu-storage-daemon fix (Philippe)

# gpg: Signature made Mon 12 Oct 2020 16:55:19 BST
# gpg:                using RSA key F13338574B662389866C7682BFFBD25F78C7AE83
# gpg:                issuer "[email protected]"
# gpg: Good signature from "Paolo Bonzini <[email protected]>" [full]
# gpg:                 aka "Paolo Bonzini <[email protected]>" [full]
# Primary key fingerprint: 46F5 9FBD 57D6 12E7 BFD4  E2F7 7E15 100C CD36 69B1
#      Subkey fingerprint: F133 3857 4B66 2389 866C  7682 BFFB D25F 78C7 AE83

* remotes/bonzini-gitlab/tags/for-upstream: (38 commits)
  meson: identify more sections of meson.build
  scsi/scsi_bus: fix races in REPORT LUNS
  virtio-scsi: use scsi_device_get
  scsi/scsi_bus: Add scsi_device_get
  scsi/scsi-bus: scsi_device_find: don't return unrealized devices
  device-core: use atomic_set on .realized property
  scsi: switch to bus->check_address
  device-core: use RCU for list of children of a bus
  device_core: use drain_call_rcu in in qmp_device_add
  scsi/scsi_bus: switch search direction in scsi_device_find
  qdev: add "check if address free" callback for buses
  qemu-iotests, qtest: rewrite test 067 as a qtest
  qtest: check that drives are really appearing and disappearing
  qtest: switch users back to qtest_qmp_receive
  device-plug-test: use qtest_qmp to send the device_del command
  qtest: remove qtest_qmp_receive_success
  qtest: Reintroduce qtest_qmp_receive with QMP event buffering
  qtest: rename qtest_qmp_receive to qtest_qmp_receive_dict
  meson.build: Re-enable KVM support for MIPS
  build-sys: fix git version from -version
  ...

Signed-off-by: Peter Maydell <[email protected]>
4 years agotarget/i386/cpu: Update comment that mentions Texinfo
Markus Armbruster [Tue, 29 Sep 2020 07:58:24 +0000 (09:58 +0200)]
target/i386/cpu: Update comment that mentions Texinfo

Missed in commit 41fba1618b "docs/system: convert the documentation of
deprecated features to rST."

Signed-off-by: Markus Armbruster <[email protected]>
Reviewed-by: Philippe Mathieu-Daudé <[email protected]>
Message-Id: <20200929075824.1517969[email protected]>
Signed-off-by: Laurent Vivier <[email protected]>
4 years agoqemu-img-cmds.hx: Update comment that mentions Texinfo
Markus Armbruster [Tue, 29 Sep 2020 07:58:23 +0000 (09:58 +0200)]
qemu-img-cmds.hx: Update comment that mentions Texinfo

Missed in 3c95fdef94 "Update comments in .hx files that mention
Texinfo".

Signed-off-by: Markus Armbruster <[email protected]>
Reviewed-by: Philippe Mathieu-Daudé <[email protected]>
Message-Id: <20200929075824.1517969[email protected]>
Signed-off-by: Laurent Vivier <[email protected]>
4 years agomeson: identify more sections of meson.build
Paolo Bonzini [Wed, 7 Oct 2020 15:01:51 +0000 (11:01 -0400)]
meson: identify more sections of meson.build

Add more headers that clarify code organization.

Signed-off-by: Paolo Bonzini <[email protected]>
4 years agoscsi/scsi_bus: fix races in REPORT LUNS
Maxim Levitsky [Tue, 6 Oct 2020 12:39:04 +0000 (15:39 +0300)]
scsi/scsi_bus: fix races in REPORT LUNS

Currently scsi_target_emulate_report_luns iterates over the child device list
twice, and there is no guarantee that this list is the same in both iterations.

The reason for iterating twice is that the first iteration calculates
how much memory to allocate.  However if we use a dynamic array we can
avoid iterating twice, and therefore we avoid this race.

Buglink: https://bugzilla.redhat.com/show_bug.cgi?id=1866707
Signed-off-by: Maxim Levitsky <[email protected]>
Reviewed-by: Stefan Hajnoczi <[email protected]>
Message-Id: <20200913160259[email protected]>
Signed-off-by: Paolo Bonzini <[email protected]>
Message-Id: <20201006123904[email protected]>
Signed-off-by: Paolo Bonzini <[email protected]>
4 years agovirtio-scsi: use scsi_device_get
Maxim Levitsky [Tue, 6 Oct 2020 12:39:03 +0000 (15:39 +0300)]
virtio-scsi: use scsi_device_get

This will help us to avoid the scsi device disappearing
after we took a reference to it.

It doesn't by itself forbid case when we try to access
an unrealized device

Suggested-by: Stefan Hajnoczi <[email protected]>
Signed-off-by: Maxim Levitsky <[email protected]>
Reviewed-by: Stefan Hajnoczi <[email protected]>
Message-Id: <20200913160259[email protected]>
Signed-off-by: Paolo Bonzini <[email protected]>
Message-Id: <20201006123904[email protected]>
Signed-off-by: Paolo Bonzini <[email protected]>
4 years agoscsi/scsi_bus: Add scsi_device_get
Maxim Levitsky [Tue, 6 Oct 2020 12:39:02 +0000 (15:39 +0300)]
scsi/scsi_bus: Add scsi_device_get

Add scsi_device_get which finds the scsi device
and takes a reference to it.

Suggested-by: Stefan Hajnoczi <[email protected]>
Signed-off-by: Maxim Levitsky <[email protected]>
Message-Id: <20200913160259[email protected]>
Signed-off-by: Paolo Bonzini <[email protected]>
Message-Id: <20201006123904[email protected]>
Signed-off-by: Paolo Bonzini <[email protected]>
4 years agoscsi/scsi-bus: scsi_device_find: don't return unrealized devices
Paolo Bonzini [Tue, 6 Oct 2020 12:39:01 +0000 (15:39 +0300)]
scsi/scsi-bus: scsi_device_find: don't return unrealized devices

The device core first places a device on the bus and then realizes it.
Make scsi_device_find avoid returing such devices to avoid
races in drivers that use an iothread (currently virtio-scsi)

Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=1812399

Suggested-by: Paolo Bonzini <[email protected]>
Signed-off-by: Maxim Levitsky <[email protected]>
Reviewed-by: Stefan Hajnoczi <[email protected]>
Message-Id: <20200913160259[email protected]>
Signed-off-by: Paolo Bonzini <[email protected]>
Message-Id: <20201006123904[email protected]>
Signed-off-by: Paolo Bonzini <[email protected]>
4 years agodevice-core: use atomic_set on .realized property
Maxim Levitsky [Tue, 6 Oct 2020 12:39:00 +0000 (15:39 +0300)]
device-core: use atomic_set on .realized property

Some code might race with placement of new devices on a bus.
We currently first place a (unrealized) device on the bus
and then realize it.

As a workaround, users that scan the child device list, can
check the realized property to see if it is safe to access such a device.
Use an atomic write here too to aid with this.

A separate discussion is what to do with devices that are unrealized:
It looks like for this case we only call the hotplug handler's unplug
callback and its up to it to unrealize the device.
An atomic operation doesn't cause harm for this code path though.

Signed-off-by: Maxim Levitsky <[email protected]>
Reviewed-by: Stefan Hajnoczi <[email protected]>
Message-Id: <20200913160259[email protected]>
Signed-off-by: Paolo Bonzini <[email protected]>
Message-Id: <20201006123904[email protected]>
Signed-off-by: Paolo Bonzini <[email protected]>
4 years agoscsi: switch to bus->check_address
Paolo Bonzini [Tue, 6 Oct 2020 12:38:56 +0000 (15:38 +0300)]
scsi: switch to bus->check_address

Signed-off-by: Paolo Bonzini <[email protected]>
Message-Id: <20201006123904[email protected]>
Signed-off-by: Paolo Bonzini <[email protected]>
4 years agodevice-core: use RCU for list of children of a bus
Maxim Levitsky [Tue, 6 Oct 2020 12:38:59 +0000 (15:38 +0300)]
device-core: use RCU for list of children of a bus

This fixes the race between device emulation code that tries to find
a child device to dispatch the request to (e.g a scsi disk),
and hotplug of a new device to that bus.

Note that this doesn't convert all the readers of the list
but only these that might go over that list without BQL held.

This is a very small first step to make this code thread safe.

Suggested-by: Paolo Bonzini <[email protected]>
Signed-off-by: Maxim Levitsky <[email protected]>
Reviewed-by: Stefan Hajnoczi <[email protected]>
Message-Id: <20200913160259[email protected]>
[Use RCU_READ_LOCK_GUARD in more places, adjust testcase now that
 the delay in DEVICE_DELETED due to RCU is more consistent. - Paolo]
Signed-off-by: Paolo Bonzini <[email protected]>
Message-Id: <20201006123904[email protected]>
Signed-off-by: Paolo Bonzini <[email protected]>
4 years agodevice_core: use drain_call_rcu in in qmp_device_add
Maxim Levitsky [Tue, 6 Oct 2020 12:38:58 +0000 (14:38 +0200)]
device_core: use drain_call_rcu in in qmp_device_add

Soon, a device removal might only happen on RCU callback execution.
This is okay for device-del which provides a DEVICE_DELETED event,
but not for the failure case of device-add.  To avoid changing
monitor semantics, just drain all pending RCU callbacks on error.

Signed-off-by: Maxim Levitsky <[email protected]>
Suggested-by: Stefan Hajnoczi <[email protected]>
Reviewed-by: Stefan Hajnoczi <[email protected]>
Message-Id: <20200913160259[email protected]>
[Don't use it in qmp_device_del. - Paolo]
Signed-off-by: Paolo Bonzini <[email protected]>
4 years agoscsi/scsi_bus: switch search direction in scsi_device_find
Maxim Levitsky [Tue, 6 Oct 2020 12:38:57 +0000 (14:38 +0200)]
scsi/scsi_bus: switch search direction in scsi_device_find

This change will allow us to convert the bus children list to RCU,
while not changing the logic of this function

Signed-off-by: Maxim Levitsky <[email protected]>
Reviewed-by: Stefan Hajnoczi <[email protected]>
Message-Id: <20200913160259[email protected]>
Signed-off-by: Paolo Bonzini <[email protected]>
4 years agoqdev: add "check if address free" callback for buses
Paolo Bonzini [Tue, 6 Oct 2020 12:38:55 +0000 (15:38 +0300)]
qdev: add "check if address free" callback for buses

Check if an address is free on the bus before plugging in the
device.  This makes it possible to do the check without any
side effects, and to detect the problem early without having
to do it in the realize callback.

Signed-off-by: Paolo Bonzini <[email protected]>
Message-Id: <20201006123904[email protected]>
Signed-off-by: Paolo Bonzini <[email protected]>
4 years agoqemu-iotests, qtest: rewrite test 067 as a qtest
Paolo Bonzini [Wed, 7 Oct 2020 10:43:03 +0000 (06:43 -0400)]
qemu-iotests, qtest: rewrite test 067 as a qtest

Test 067 from qemu-iotests is executing QMP commands to hotplug
and hot-unplug disks, devices and blockdevs.  Because the power
of the text-based test harness is limited, it is actually limiting
the checks that it does, for example by skipping DEVICE_DELETED
events.

tests/qtest already has a similar test, drive_del-test.c.
We can merge them, and even reuse some of the existing code in
drive_del-test.c.  This will improve the quality of the test by
covering DEVICE_DELETED events and testing multiple architectures
(therefore covering multiple PCI hotplug mechanisms as well as s390x
virtio-ccw).

The only difference is that the new test will always use null-co:// for
the medium rather than qcow2 or raw, but this should be irrelevant for
what the test is covering.  For example there are no "qemu-img check"
runs in 067 that would check that the file is properly closed.

The new tests requires PCI hot-plug support, so drive_del-test
is moved from qemu-system-ppc to qemu-system-ppc64.

Reviewed-by: Kevin Wolf <[email protected]>
Signed-off-by: Paolo Bonzini <[email protected]>
4 years agoqtest: check that drives are really appearing and disappearing
Paolo Bonzini [Wed, 7 Oct 2020 09:50:22 +0000 (05:50 -0400)]
qtest: check that drives are really appearing and disappearing

Do not just trust the HMP commands to create and delete the drive, use
query-block to check that this is actually the case.

Reviewed-by: Kevin Wolf <[email protected]>
Signed-off-by: Paolo Bonzini <[email protected]>
4 years agoqtest: switch users back to qtest_qmp_receive
Maxim Levitsky [Tue, 6 Oct 2020 12:38:53 +0000 (15:38 +0300)]
qtest: switch users back to qtest_qmp_receive

Let test use the new functionality for buffering events.
The only remaining users of qtest_qmp_receive_dict are tests
that fuzz the QMP protocol.

Tested with 'make check-qtest'.

Signed-off-by: Maxim Levitsky <[email protected]>
Message-Id: <20201006123904[email protected]>
Signed-off-by: Paolo Bonzini <[email protected]>
4 years agodevice-plug-test: use qtest_qmp to send the device_del command
Paolo Bonzini [Wed, 7 Oct 2020 11:37:41 +0000 (07:37 -0400)]
device-plug-test: use qtest_qmp to send the device_del command

Simplify the code now that events are buffered.  There is no need
anymore to separate sending the command and retrieving the response.

Signed-off-by: Paolo Bonzini <[email protected]>
4 years agoqtest: remove qtest_qmp_receive_success
Maxim Levitsky [Tue, 6 Oct 2020 12:59:32 +0000 (08:59 -0400)]
qtest: remove qtest_qmp_receive_success

The purpose of qtest_qmp_receive_success was mostly to process events
that arrived between the issueing of a command and the "return"
line from QMP.  This is now handled by the buffering of events
that libqtest performs automatically.

Signed-off-by: Paolo Bonzini <[email protected]>
Signed-off-by: Maxim Levitsky <[email protected]>
4 years agoqtest: Reintroduce qtest_qmp_receive with QMP event buffering
Maxim Levitsky [Tue, 6 Oct 2020 12:38:53 +0000 (15:38 +0300)]
qtest: Reintroduce qtest_qmp_receive with QMP event buffering

The new qtest_qmp_receive buffers all the received qmp events, allowing
qtest_qmp_eventwait_ref to return them.

This is intended to solve the race in regard to ordering of qmp events
vs qmp responses, as soon as the callers start using the new interface.

In addition to that, define qtest_qmp_event_ref a function which only scans
the buffer that qtest_qmp_receive stores the events to.  This is intended
for callers that are only interested in events that were received during
the last call to the qtest_qmp_receive.

Suggested-by: Paolo Bonzini <[email protected]>
Signed-off-by: Maxim Levitsky <[email protected]>
Message-Id: <20201006123904[email protected]>
Signed-off-by: Paolo Bonzini <[email protected]>
4 years agoqtest: rename qtest_qmp_receive to qtest_qmp_receive_dict
Maxim Levitsky [Tue, 6 Oct 2020 12:38:52 +0000 (14:38 +0200)]
qtest: rename qtest_qmp_receive to qtest_qmp_receive_dict

In the next patch a new version of qtest_qmp_receive will be
reintroduced that will buffer received qmp events for later
consumption in qtest_qmp_eventwait_ref

No functional change intended.

Suggested-by: Paolo Bonzini <[email protected]>
Signed-off-by: Maxim Levitsky <[email protected]>
Signed-off-by: Paolo Bonzini <[email protected]>
4 years agomeson.build: Re-enable KVM support for MIPS
Huacai Chen [Wed, 7 Oct 2020 08:39:28 +0000 (16:39 +0800)]
meson.build: Re-enable KVM support for MIPS

After converting from configure to meson, KVM support is lost for MIPS,
so re-enable it in meson.build.

Fixes: fdb75aeff7c212e1afaaa3a43 ("configure: remove target configuration")
Fixes: 8a19980e3fc42239aae054bc9 ("configure: move accelerator logic to meson")
Cc: aolo Bonzini <[email protected]>
Signed-off-by: Huacai Chen <[email protected]>
Message-Id: <1602059975[email protected]>
Signed-off-by: Paolo Bonzini <[email protected]>
4 years agobuild-sys: fix git version from -version
Marc-André Lureau [Tue, 29 Sep 2020 14:36:54 +0000 (18:36 +0400)]
build-sys: fix git version from -version

Typo introduced with the script.

Fixes: 2c273f32d3 ("meson: generate qemu-version.h")
Signed-off-by: Marc-André Lureau <[email protected]>
Reported-by: Laszlo Ersek <[email protected]>
Reviewed-by: Eric Blake <[email protected]>
Tested-by: Laszlo Ersek <[email protected]>
Message-Id: <20200929143654[email protected]>
Signed-off-by: Paolo Bonzini <[email protected]>
4 years agodocs/devel: update instruction on how to add new unit tests
Paolo Bonzini [Tue, 6 Oct 2020 12:49:55 +0000 (08:49 -0400)]
docs/devel: update instruction on how to add new unit tests

Signed-off-by: Paolo Bonzini <[email protected]>
4 years agoqtest: unify extra_qtest_srcs and extra_qtest_deps
Paolo Bonzini [Tue, 6 Oct 2020 12:44:00 +0000 (08:44 -0400)]
qtest: unify extra_qtest_srcs and extra_qtest_deps

Currently the extra sources and extra dependencies of qtests are held
in two separate dictionaries.  Use the same trick as tests/meson.build
to combine them into one.  This will make it easier to update the
documentation for unit tests and qtests.

Signed-off-by: Paolo Bonzini <[email protected]>
4 years agodocs/devel/qtest: Include libqtest API reference
Eduardo Habkost [Mon, 5 Oct 2020 20:52:28 +0000 (16:52 -0400)]
docs/devel/qtest: Include libqtest API reference

Signed-off-by: Eduardo Habkost <[email protected]>
Acked-by: Thomas Huth <[email protected]>
Message-Id: <20201005205228[email protected]>
Signed-off-by: Paolo Bonzini <[email protected]>
4 years agodocs/devel/qtest: Include protocol spec in document
Eduardo Habkost [Mon, 5 Oct 2020 20:52:27 +0000 (16:52 -0400)]
docs/devel/qtest: Include protocol spec in document

Include the QTest Protocol doc string in docs/devel/qtest.rst,
after converting it to use Sphinx syntax.

Signed-off-by: Eduardo Habkost <[email protected]>
Acked-by: Thomas Huth <[email protected]>
Message-Id: <20201005205228[email protected]>
Signed-off-by: Paolo Bonzini <[email protected]>
4 years agodocs: Move QTest documentation to its own document
Eduardo Habkost [Mon, 5 Oct 2020 20:52:26 +0000 (16:52 -0400)]
docs: Move QTest documentation to its own document

The qtest and libqtest doc comments will be parsed to generate
API documentation, so move QTest documentation to its own
document where the API and format documentation and will be
included.

Signed-off-by: Eduardo Habkost <[email protected]>
Acked-by: Thomas Huth <[email protected]>
Message-Id: <20201005205228[email protected]>
Signed-off-by: Paolo Bonzini <[email protected]>
4 years agoqom: fix objects with improper parent type
Paolo Bonzini [Wed, 7 Oct 2020 16:23:56 +0000 (12:23 -0400)]
qom: fix objects with improper parent type

Some objects accidentally inherit ObjectClass instead of Object.
They compile silently but may crash after downcasting.

In this patch, we introduce a coccinelle script to find broken
declarations and fix them manually with proper base type.

Signed-off-by: Sergey Nizovtsev <[email protected]>
Signed-off-by: Paolo Bonzini <[email protected]>
4 years agoexec: split out non-softmmu-specific parts
Paolo Bonzini [Tue, 6 Oct 2020 07:05:29 +0000 (09:05 +0200)]
exec: split out non-softmmu-specific parts

Over the years, most parts of exec.c that were not specific to softmmu
have been moved to accel/tcg; what's left is mostly the low-level part
of the memory API, which includes RAMBlock and AddressSpaceDispatch.
However exec.c also hosts 4-500 lines of code for the target specific
parts of the CPU QOM object, plus a few functions for user-mode
emulation that do not have a better place (they are not TCG-specific so
accel/tcg/user-exec.c is not a good place either).

Move these parts to a new file, so that exec.c can be moved to
softmmu/physmem.c.

Signed-off-by: Paolo Bonzini <[email protected]>
4 years agosoftmmu: move more files to softmmu/
Paolo Bonzini [Tue, 6 Oct 2020 07:01:22 +0000 (09:01 +0200)]
softmmu: move more files to softmmu/

Keep most softmmu_ss files into the system-emulation-specific
directory.

Signed-off-by: Paolo Bonzini <[email protected]>
4 years agohw/nvram: Always register FW_CFG_DATA_GENERATOR_INTERFACE
Philippe Mathieu-Daudé [Tue, 6 Oct 2020 11:19:09 +0000 (13:19 +0200)]
hw/nvram: Always register FW_CFG_DATA_GENERATOR_INTERFACE

While the FW_CFG_DATA_GENERATOR_INTERFACE is only consumed
by a device only available using system-mode (fw_cfg), it is
implemented by a crypto component (tls-cipher-suites) which
is always available when crypto is used.

Commit 69699f3055 introduced the following error in the
qemu-storage-daemon binary:

  $ echo -e \
    '{"execute": "qmp_capabilities"}\r\n{"execute": "qom-list-types"}\r\n{"execute": "quit"}\r\n' \
    | storage-daemon/qemu-storage-daemon --chardev stdio,id=qmp0  --monitor qmp0
  {"QMP": {"version": {"qemu": {"micro": 50, "minor": 1, "major": 5}, "package": ""}, "capabilities": ["oob"]}}
  {"return": {}}
  missing interface 'fw_cfg-data-generator' for object 'tls-creds'
  Aborted (core dumped)

Since QOM dependencies are resolved at runtime, this issue
could not be triggered at linktime, and we don't have test
running the qemu-storage-daemon binary.

Fix by always registering the QOM interface.

Reported-by: Kevin Wolf <[email protected]>
Fixes: 69699f3055 ("crypto/tls-cipher-suites: Produce fw_cfg consumable blob")
Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
Reviewed-by: Laszlo Ersek <[email protected]>
Reviewed-by: Paolo Bonzini <[email protected]>
Message-Id: <20201006111909.2302081[email protected]>
Signed-off-by: Paolo Bonzini <[email protected]>
4 years agoqom: Move the creation of the library to the main meson.build
Philippe Mathieu-Daudé [Tue, 6 Oct 2020 12:56:02 +0000 (14:56 +0200)]
qom: Move the creation of the library to the main meson.build

Be consistent creating all the libraries in the main meson.build file.

Suggested-by: Paolo Bonzini <[email protected]>
Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
Message-Id: <20201006125602.2311423[email protected]>
Signed-off-by: Paolo Bonzini <[email protected]>
4 years agoauthz: Move the creation of the library to the main meson.build
Philippe Mathieu-Daudé [Tue, 6 Oct 2020 12:56:01 +0000 (14:56 +0200)]
authz: Move the creation of the library to the main meson.build

Be consistent creating all the libraries in the main meson.build file.

Suggested-by: Paolo Bonzini <[email protected]>
Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
Message-Id: <20201006125602.2311423[email protected]>
Signed-off-by: Paolo Bonzini <[email protected]>
4 years agocrypto: Move the creation of the library to the main meson.build
Philippe Mathieu-Daudé [Tue, 6 Oct 2020 12:56:00 +0000 (14:56 +0200)]
crypto: Move the creation of the library to the main meson.build

Be consistent creating all the libraries in the main meson.build file.

Suggested-by: Paolo Bonzini <[email protected]>
Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
Message-Id: <20201006125602.2311423[email protected]>
Signed-off-by: Paolo Bonzini <[email protected]>
4 years agoio: Move the creation of the library to the main meson.build
Philippe Mathieu-Daudé [Tue, 6 Oct 2020 12:55:59 +0000 (14:55 +0200)]
io: Move the creation of the library to the main meson.build

Be consistent creating all the libraries in the main meson.build file.

Suggested-by: Paolo Bonzini <[email protected]>
Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
Message-Id: <20201006125602.2311423[email protected]>
Signed-off-by: Paolo Bonzini <[email protected]>
4 years agomigration: Move the creation of the library to the main meson.build
Philippe Mathieu-Daudé [Tue, 6 Oct 2020 12:55:58 +0000 (14:55 +0200)]
migration: Move the creation of the library to the main meson.build

Be consistent creating all the libraries in the main meson.build file.

Suggested-by: Paolo Bonzini <[email protected]>
Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
Message-Id: <20201006125602.2311423[email protected]>
Signed-off-by: Paolo Bonzini <[email protected]>
4 years agochardev: Move the creation of the library to the main meson.build
Philippe Mathieu-Daudé [Tue, 6 Oct 2020 12:55:57 +0000 (14:55 +0200)]
chardev: Move the creation of the library to the main meson.build

Be consistent creating all the libraries in the main meson.build file.

Suggested-by: Paolo Bonzini <[email protected]>
Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
Message-Id: <20201006125602.2311423[email protected]>
Signed-off-by: Paolo Bonzini <[email protected]>
4 years agohw/core: Move the creation of the library to the main meson.build
Philippe Mathieu-Daudé [Tue, 6 Oct 2020 12:55:56 +0000 (14:55 +0200)]
hw/core: Move the creation of the library to the main meson.build

Be consistent creating all the libraries in the main meson.build file.

Suggested-by: Paolo Bonzini <[email protected]>
Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
Message-Id: <20201006125602.2311423[email protected]>
Signed-off-by: Paolo Bonzini <[email protected]>
4 years agomeson.build: Sort sourcesets alphabetically
Philippe Mathieu-Daudé [Tue, 6 Oct 2020 12:55:55 +0000 (14:55 +0200)]
meson.build: Sort sourcesets alphabetically

Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
Message-Id: <20201006125602.2311423[email protected]>
Signed-off-by: Paolo Bonzini <[email protected]>
4 years agomeson.build: Add comments to clarify code organization
Philippe Mathieu-Daudé [Tue, 6 Oct 2020 12:55:54 +0000 (14:55 +0200)]
meson.build: Add comments to clarify code organization

Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
Message-Id: <20201006125602.2311423[email protected]>
Signed-off-by: Paolo Bonzini <[email protected]>
4 years agoMerge remote-tracking branch 'remotes/dgilbert/tags/pull-migration-20201012a' into...
Peter Maydell [Mon, 12 Oct 2020 12:12:04 +0000 (13:12 +0100)]
Merge remote-tracking branch 'remotes/dgilbert/tags/pull-migration-20201012a' into staging

v3 Migration+ virtiofsd pull 2020-10-12

V3
  Remove the postcopy recovery changes

Migration:
  Dirtyrate measurement API cleanup

Virtiofsd:
  Missing qemu_init_exec_dir call
  Support for setting the group on socket creation
  Stop a gcc warning
  Avoid tempdir in sandboxing

# gpg: Signature made Mon 12 Oct 2020 12:43:30 BST
# gpg:                using RSA key 45F5C71B4A0CB7FB977A9FA90516331EBC5BFDE7
# gpg: Good signature from "Dr. David Alan Gilbert (RH2) <[email protected]>" [full]
# Primary key fingerprint: 45F5 C71B 4A0C B7FB 977A  9FA9 0516 331E BC5B FDE7

* remotes/dgilbert/tags/pull-migration-20201012a:
  migration/dirtyrate: present dirty rate only when querying the rate has completed
  migration/dirtyrate: record start_time and calc_time while at the measuring state
  virtiofsd: avoid /proc/self/fd tempdir
  virtiofsd: Call qemu_init_exec_dir
  tools/virtiofsd: add support for --socket-group
  virtiofsd: Silence gcc warning

Signed-off-by: Peter Maydell <[email protected]>
4 years agomigration/dirtyrate: present dirty rate only when querying the rate has completed
Chuan Zheng [Tue, 29 Sep 2020 03:42:18 +0000 (11:42 +0800)]
migration/dirtyrate: present dirty rate only when querying the rate has completed

Make dirty_rate field optional, present dirty rate only when querying
the rate has completed.
The qmp results is shown as follow:
@unstarted:
{"return":{"status":"unstarted","start-time":0,"calc-time":0},"id":"libvirt-12"}
@measuring:
{"return":{"status":"measuring","start-time":102931,"calc-time":1},"id":"libvirt-85"}
@measured:
{"return":{"status":"measured","dirty-rate":4,"start-time":150146,"calc-time":1},"id":"libvirt-15"}

Signed-off-by: Chuan Zheng <[email protected]>
Reviewed-by: David Edmondson <[email protected]>
Message-Id: <1601350938[email protected]>
Signed-off-by: Dr. David Alan Gilbert <[email protected]>
4 years agomigration/dirtyrate: record start_time and calc_time while at the measuring state
Chuan Zheng [Tue, 29 Sep 2020 03:42:17 +0000 (11:42 +0800)]
migration/dirtyrate: record start_time and calc_time while at the measuring state

Querying could include both the start-time and the calc-time while at the measuring
state, allowing a caller to determine when they should expect to come back looking
for a result.

Signed-off-by: Chuan Zheng <[email protected]>
Message-Id: <1601350938[email protected]>
Reviewed-by: David Edmondson <[email protected]>
Signed-off-by: Dr. David Alan Gilbert <[email protected]>
4 years agovirtiofsd: avoid /proc/self/fd tempdir
Stefan Hajnoczi [Tue, 6 Oct 2020 09:58:26 +0000 (10:58 +0100)]
virtiofsd: avoid /proc/self/fd tempdir

In order to prevent /proc/self/fd escapes a temporary directory is
created where /proc/self/fd is bind-mounted. This doesn't work on
read-only file systems.

Avoid the temporary directory by bind-mounting /proc/self/fd over /proc.
This does not affect other processes since we remounted / with MS_REC |
MS_SLAVE. /proc must exist and virtiofsd does not use it so it's safe to
do this.

Path traversal can be tested with the following function:

  static void test_proc_fd_escape(struct lo_data *lo)
  {
      int fd;
      int level = 0;
      ino_t last_ino = 0;

      fd = lo->proc_self_fd;
      for (;;) {
          struct stat st;

          if (fstat(fd, &st) != 0) {
              perror("fstat");
              return;
          }
          if (last_ino && st.st_ino == last_ino) {
              fprintf(stderr, "inode number unchanged, stopping\n");
              return;
          }
          last_ino = st.st_ino;

          fprintf(stderr, "Level %d dev %lu ino %lu\n", level,
                  (unsigned long)st.st_dev,
                  (unsigned long)last_ino);
          fd = openat(fd, "..", O_PATH | O_DIRECTORY | O_NOFOLLOW);
          level++;
      }
  }

Before and after this patch only Level 0 is displayed. Without
/proc/self/fd bind-mount protection it is possible to traverse parent
directories.

Fixes: 397ae982f4df4 ("virtiofsd: jail lo->proc_self_fd")
Cc: Miklos Szeredi <[email protected]>
Cc: Jens Freimann <[email protected]>
Signed-off-by: Stefan Hajnoczi <[email protected]>
Message-Id: <20201006095826[email protected]>
Reviewed-by: Dr. David Alan Gilbert <[email protected]>
Tested-by: Jens Freimann <[email protected]>
Reviewed-by: Jens Freimann <[email protected]>
Signed-off-by: Dr. David Alan Gilbert <[email protected]>
4 years agovirtiofsd: Call qemu_init_exec_dir
Dr. David Alan Gilbert [Fri, 2 Oct 2020 12:40:15 +0000 (13:40 +0100)]
virtiofsd: Call qemu_init_exec_dir

Since fcb4f59c879 qemu_get_local_state_pathname relies on the
init_exec_dir, and virtiofsd asserts because we never set it.
Set it.

Reported-by: Alex Bennée <[email protected]>
Signed-off-by: Dr. David Alan Gilbert <[email protected]>
Message-Id: <20201002124015[email protected]>
Tested-by: Alex Bennée <[email protected]>
Reviewed-by: Alex Bennée <[email protected]>
Reviewed-by: Stefan Hajnoczi <[email protected]>
Signed-off-by: Dr. David Alan Gilbert <[email protected]>
4 years agotools/virtiofsd: add support for --socket-group
Alex Bennée [Fri, 25 Sep 2020 12:51:29 +0000 (13:51 +0100)]
tools/virtiofsd: add support for --socket-group

If you like running QEMU as a normal user (very common for TCG runs)
but you have to run virtiofsd as a root user you run into connection
problems. Adding support for an optional --socket-group allows the
users to keep using the command line.

Signed-off-by: Alex Bennée <[email protected]>
Reviewed-by: Stefan Hajnoczi <[email protected]>
Message-Id: <20200925125147[email protected]>
Signed-off-by: Dr. David Alan Gilbert <[email protected]>
  dgilbert: Split long line

4 years agovirtiofsd: Silence gcc warning
Dr. David Alan Gilbert [Thu, 27 Aug 2020 15:36:52 +0000 (16:36 +0100)]
virtiofsd: Silence gcc warning

Gcc worries fd might be used unset, in reality it's always set if
fi is set, and only used if fi is set so it's safe.  Initialise it to -1
just to keep gcc happy for now.

Signed-off-by: Dr. David Alan Gilbert <[email protected]>
Message-Id: <20200827153657[email protected]>
Reviewed-by: Ján Tomko <[email protected]>
Signed-off-by: Dr. David Alan Gilbert <[email protected]>
4 years agoMerge remote-tracking branch 'remotes/armbru/tags/pull-qapi-2020-10-10' into staging
Peter Maydell [Mon, 12 Oct 2020 10:29:41 +0000 (11:29 +0100)]
Merge remote-tracking branch 'remotes/armbru/tags/pull-qapi-2020-10-10' into staging

QAPI patches patches for 2020-10-10

# gpg: Signature made Sat 10 Oct 2020 10:43:14 BST
# gpg:                using RSA key 354BC8B3D7EB2A6B68674E5F3870B400EB918653
# gpg:                issuer "[email protected]"
# gpg: Good signature from "Markus Armbruster <[email protected]>" [full]
# gpg:                 aka "Markus Armbruster <[email protected]>" [full]
# Primary key fingerprint: 354B C8B3 D7EB 2A6B 6867  4E5F 3870 B400 EB91 8653

* remotes/armbru/tags/pull-qapi-2020-10-10: (34 commits)
  qapi/visit.py: add type hint annotations
  qapi/visit.py: remove unused parameters from gen_visit_object
  qapi/visit.py: assert tag_member contains a QAPISchemaEnumType
  qapi/types.py: remove one-letter variables
  qapi/types.py: add type hint annotations
  qapi/gen.py: delint with pylint
  qapi/gen.py: update write() to be more idiomatic
  qapi/gen.py: Remove unused parameter
  qapi/gen.py: add type hint annotations
  qapi/gen: Make _is_user_module() return bool
  qapi/source.py: delint with pylint
  qapi/source.py: add type hint annotations
  qapi/commands.py: add type hint annotations
  qapi/commands.py: Don't re-bind to variable of different type
  qapi/events.py: Move comments into docstrings
  qapi/events.py: add type hint annotations
  qapi: establish mypy type-checking baseline
  qapi/common.py: move build_params into gen.py
  qapi/common.py: Convert comments into docstrings, and elaborate
  qapi/common.py: add type hint annotations
  ...

Signed-off-by: Peter Maydell <[email protected]>
4 years agoMerge remote-tracking branch 'remotes/stsquad/tags/pull-various-091020-1' into staging
Peter Maydell [Sun, 11 Oct 2020 13:34:07 +0000 (14:34 +0100)]
Merge remote-tracking branch 'remotes/stsquad/tags/pull-various-091020-1' into staging

Testing, gitdm and plugin fixes:

  - fix acceptance regressions in MIPS and IDE
  - speed up cirrus msys2/mingw builds
  - add genisoimage to more docker images
  - slew of gitdb updates
  - fix some windows compile issues for plugins
  - add V=1 to cirrus output
  - disable rxsim in gitlab CI

# gpg: Signature made Fri 09 Oct 2020 17:30:29 BST
# gpg:                using RSA key 6685AE99E75167BCAFC8DF35FBD0DB095A9E2A44
# gpg: Good signature from "Alex Bennée (Master Work Key) <[email protected]>" [full]
# Primary key fingerprint: 6685 AE99 E751 67BC AFC8  DF35 FBD0 DB09 5A9E 2A44

* remotes/stsquad/tags/pull-various-091020-1: (22 commits)
  tests/acceptance: disable machine_rx_gdbsim on GitLab
  cirrus: use V=1 when running tests on FreeBSD and macOS
  plugin: Fixes compiling errors on msys2/mingw
  plugins: Fixes a issue when dlsym failed, the handle not closed
  .mailmap: Fix more contributor entries
  contrib/gitdm: Add Yandex to the domain map
  contrib/gitdm: Add Yadro to the domain map
  contrib/gitdm: Add SUSE to the domain map
  contrib/gitdm: Add Nir Soffer to Red Hat domain
  contrib/gitdm: Add Qualcomm to the domain map
  contrib/gitdm: Add Nuvia to the domain map
  contrib/gitdm: Add Google to the domain map
  contrib/gitdm: Add ByteDance to the domain map
  contrib/gitdm: Add Baidu to the domain map
  contrib/gitdm: Add more individual contributors
  contrib/gitdm: Add more academic domains
  tests/docker: Add genisoimage to the docker file
  cirrus: msys2/mingw speed is up, add excluded target back
  cirrus: Fixing and speedup the msys2/mingw CI
  hw/ide: restore replay support of IDE
  ...

Signed-off-by: Peter Maydell <[email protected]>
4 years agoqapi/visit.py: add type hint annotations
John Snow [Fri, 9 Oct 2020 16:15:58 +0000 (12:15 -0400)]
qapi/visit.py: add type hint annotations

Annotations do not change runtime behavior.
This commit *only* adds annotations.

Signed-off-by: John Snow <[email protected]>
Reviewed-by: Eduardo Habkost <[email protected]>
Reviewed-by: Cleber Rosa <[email protected]>
Tested-by: Cleber Rosa <[email protected]>
Message-Id: <20201009161558[email protected]>
Reviewed-by: Markus Armbruster <[email protected]>
Signed-off-by: Markus Armbruster <[email protected]>
4 years agoqapi/visit.py: remove unused parameters from gen_visit_object
John Snow [Fri, 9 Oct 2020 16:15:57 +0000 (12:15 -0400)]
qapi/visit.py: remove unused parameters from gen_visit_object

And this fixes the pylint report for this file, so make sure we check
this in the future, too.

Signed-off-by: John Snow <[email protected]>
Reviewed-by: Eduardo Habkost <[email protected]>
Reviewed-by: Cleber Rosa <[email protected]>
Tested-by: Cleber Rosa <[email protected]>
Reviewed-by: Philippe Mathieu-Daudé <[email protected]>
Message-Id: <20201009161558[email protected]>
Reviewed-by: Markus Armbruster <[email protected]>
Signed-off-by: Markus Armbruster <[email protected]>
4 years agoqapi/visit.py: assert tag_member contains a QAPISchemaEnumType
John Snow [Fri, 9 Oct 2020 16:15:56 +0000 (12:15 -0400)]
qapi/visit.py: assert tag_member contains a QAPISchemaEnumType

This is true by design, but not presently able to be expressed in the
type system. An assertion helps mypy understand our constraints.

Signed-off-by: John Snow <[email protected]>
Reviewed-by: Eduardo Habkost <[email protected]>
Reviewed-by: Cleber Rosa <[email protected]>
Message-Id: <20201009161558[email protected]>
Reviewed-by: Markus Armbruster <[email protected]>
Signed-off-by: Markus Armbruster <[email protected]>
4 years agoqapi/types.py: remove one-letter variables
John Snow [Fri, 9 Oct 2020 16:15:55 +0000 (12:15 -0400)]
qapi/types.py: remove one-letter variables

"John, if pylint told you to jump off a bridge, would you?"
Hey, if it looked like fun, I might.

Now that this file is clean, enable pylint checks on this file.

Signed-off-by: John Snow <[email protected]>
Reviewed-by: Eduardo Habkost <[email protected]>
Reviewed-by: Cleber Rosa <[email protected]>
Message-Id: <20201009161558[email protected]>
Reviewed-by: Markus Armbruster <[email protected]>
Signed-off-by: Markus Armbruster <[email protected]>
4 years agoqapi/types.py: add type hint annotations
John Snow [Fri, 9 Oct 2020 16:15:54 +0000 (12:15 -0400)]
qapi/types.py: add type hint annotations

Annotations do not change runtime behavior.
This commit *only* adds annotations.

Signed-off-by: John Snow <[email protected]>
Reviewed-by: Eduardo Habkost <[email protected]>
Reviewed-by: Cleber Rosa <[email protected]>
Message-Id: <20201009161558[email protected]>
Reviewed-by: Markus Armbruster <[email protected]>
Signed-off-by: Markus Armbruster <[email protected]>
4 years agoqapi/gen.py: delint with pylint
John Snow [Fri, 9 Oct 2020 16:15:53 +0000 (12:15 -0400)]
qapi/gen.py: delint with pylint

'fp' and 'fd' are self-evident in context, add them to the list of OK
names.

_top and _bottom also need to stay standard methods because some users
override the method and need to use `self`. Tell pylint to shush.

Signed-off-by: John Snow <[email protected]>
Reviewed-by: Eduardo Habkost <[email protected]>
Reviewed-by: Cleber Rosa <[email protected]>
Message-Id: <20201009161558[email protected]>
Reviewed-by: Markus Armbruster <[email protected]>
Signed-off-by: Markus Armbruster <[email protected]>
4 years agoqapi/gen.py: update write() to be more idiomatic
John Snow [Fri, 9 Oct 2020 16:15:52 +0000 (12:15 -0400)]
qapi/gen.py: update write() to be more idiomatic

Make the file handling here just a tiny bit more idiomatic.
(I realize this is heavily subjective.)

Use exist_ok=True for os.makedirs and remove the exception,
use fdopen() to wrap the file descriptor in a File-like object,
and use a context manager for managing the file pointer.

Signed-off-by: John Snow <[email protected]>
Reviewed-by: Eduardo Habkost <[email protected]>
Reviewed-by: Cleber Rosa <[email protected]>
Reviewed-by: Markus Armbruster <[email protected]>
Message-Id: <20201009161558[email protected]>
Signed-off-by: Markus Armbruster <[email protected]>
4 years agoqapi/gen.py: Remove unused parameter
John Snow [Fri, 9 Oct 2020 16:15:51 +0000 (12:15 -0400)]
qapi/gen.py: Remove unused parameter

_module_dirname doesn't use the 'what' argument, so remove it.

Signed-off-by: John Snow <[email protected]>
Reviewed-by: Eduardo Habkost <[email protected]>
Reviewed-by: Cleber Rosa <[email protected]>
Message-Id: <20201009161558[email protected]>
Reviewed-by: Markus Armbruster <[email protected]>
Signed-off-by: Markus Armbruster <[email protected]>
4 years agoqapi/gen.py: add type hint annotations
John Snow [Fri, 9 Oct 2020 16:15:49 +0000 (12:15 -0400)]
qapi/gen.py: add type hint annotations

Annotations do not change runtime behavior.
This commit *only* adds annotations.

Signed-off-by: John Snow <[email protected]>
Reviewed-by: Eduardo Habkost <[email protected]>
Reviewed-by: Cleber Rosa <[email protected]>
Message-Id: <20201009161558[email protected]>
Message-Id: <20201009161558[email protected]>
[mypy.ini update squashed in]
Reviewed-by: Markus Armbruster <[email protected]>
Signed-off-by: Markus Armbruster <[email protected]>
4 years agoqapi/gen: Make _is_user_module() return bool
John Snow [Fri, 9 Oct 2020 16:15:48 +0000 (12:15 -0400)]
qapi/gen: Make _is_user_module() return bool

_is_user_module() returns thruth values.  The next commit wants it to
return bool.  Make it so.

Signed-off-by: John Snow <[email protected]>
Reviewed-by: Cleber Rosa <[email protected]>
Reviewed-by: Eduardo Habkost <[email protected]>
Reviewed-by: Philippe Mathieu-Daudé <[email protected]>
Message-Id: <20201009161558[email protected]>
Reviewed-by: Markus Armbruster <[email protected]>
[Commit message rewritten]
Signed-off-by: Markus Armbruster <[email protected]>
4 years agoqapi/source.py: delint with pylint
John Snow [Fri, 9 Oct 2020 16:15:47 +0000 (12:15 -0400)]
qapi/source.py: delint with pylint

Shush an error and leave a hint for future cleanups when we're allowed
to use Python 3.7+.

Signed-off-by: John Snow <[email protected]>
Reviewed-by: Eduardo Habkost <[email protected]>
Reviewed-by: Cleber Rosa <[email protected]>
Tested-by: Cleber Rosa <[email protected]>
Message-Id: <20201009161558[email protected]>
Reviewed-by: Markus Armbruster <[email protected]>
Signed-off-by: Markus Armbruster <[email protected]>
4 years agoqapi/source.py: add type hint annotations
John Snow [Fri, 9 Oct 2020 16:15:46 +0000 (12:15 -0400)]
qapi/source.py: add type hint annotations

Annotations do not change runtime behavior.
This commit *only* adds annotations.

A note on typing of __init__: mypy requires init functions with no
parameters to document a return type of None to be considered fully
typed. In the case when there are input parameters, None may be omitted.

Since __init__ may never return any value, it is preferred to omit the
return annotation whenever possible.

Signed-off-by: John Snow <[email protected]>
Reviewed-by: Eduardo Habkost <[email protected]>
Reviewed-by: Cleber Rosa <[email protected]>
Tested-by: Cleber Rosa <[email protected]>
Message-Id: <20201009161558[email protected]>
Reviewed-by: Markus Armbruster <[email protected]>
Signed-off-by: Markus Armbruster <[email protected]>
4 years agoqapi/commands.py: add type hint annotations
John Snow [Fri, 9 Oct 2020 16:15:44 +0000 (12:15 -0400)]
qapi/commands.py: add type hint annotations

Annotations do not change runtime behavior.
This commit *only* adds annotations.

Signed-off-by: John Snow <[email protected]>
Reviewed-by: Eduardo Habkost <[email protected]>
Reviewed-by: Cleber Rosa <[email protected]>
Message-Id: <20201009161558[email protected]>
Message-Id: <20201009161558[email protected]>
[mypy.ini update squashed in]
Reviewed-by: Markus Armbruster <[email protected]>
Signed-off-by: Markus Armbruster <[email protected]>
4 years agoqapi/commands.py: Don't re-bind to variable of different type
John Snow [Fri, 9 Oct 2020 16:15:43 +0000 (12:15 -0400)]
qapi/commands.py: Don't re-bind to variable of different type

Mypy isn't a fan of rebinding a variable with a new data type.
It's easy enough to avoid.

Signed-off-by: John Snow <[email protected]>
Reviewed-by: Eduardo Habkost <[email protected]>
Reviewed-by: Cleber Rosa <[email protected]>
Reviewed-by: Markus Armbruster <[email protected]>
Message-Id: <20201009161558[email protected]>
Signed-off-by: Markus Armbruster <[email protected]>
4 years agoqapi/events.py: Move comments into docstrings
John Snow [Fri, 9 Oct 2020 16:15:42 +0000 (12:15 -0400)]
qapi/events.py: Move comments into docstrings

Clarify them while we're here.

Signed-off-by: John Snow <[email protected]>
Reviewed-by: Eduardo Habkost <[email protected]>
Reviewed-by: Cleber Rosa <[email protected]>
Message-Id: <20201009161558[email protected]>
Reviewed-by: Markus Armbruster <[email protected]>
Signed-off-by: Markus Armbruster <[email protected]>
4 years agoqapi/events.py: add type hint annotations
John Snow [Fri, 9 Oct 2020 16:15:41 +0000 (12:15 -0400)]
qapi/events.py: add type hint annotations

Annotations do not change runtime behavior.
This commit *only* adds annotations.

Note: __init__ does not need its return type annotated, as it is special.
https://mypy.readthedocs.io/en/stable/class_basics.html#annotating-init-methods

Signed-off-by: John Snow <[email protected]>
Reviewed-by: Eduardo Habkost <[email protected]>
Reviewed-by: Cleber Rosa <[email protected]>
Message-Id: <20201009161558[email protected]>
Reviewed-by: Markus Armbruster <[email protected]>
Signed-off-by: Markus Armbruster <[email protected]>
4 years agoqapi: establish mypy type-checking baseline
John Snow [Fri, 9 Oct 2020 16:15:40 +0000 (12:15 -0400)]
qapi: establish mypy type-checking baseline

Fix a minor typing issue, and then establish a mypy type-checking
baseline.

Like pylint, this should be run from the folder above:

 > mypy --config-file=qapi/mypy.ini qapi/

This is designed and tested for mypy 0.770 or greater.

Signed-off-by: John Snow <[email protected]>
Tested-by: Eduardo Habkost <[email protected]>
Reviewed-by: Cleber Rosa <[email protected]>
Tested-by: Cleber Rosa <[email protected]>
Message-Id: <20201009161558[email protected]>
Reviewed-by: Markus Armbruster <[email protected]>
Signed-off-by: Markus Armbruster <[email protected]>
4 years agoqapi/common.py: move build_params into gen.py
John Snow [Fri, 9 Oct 2020 16:15:39 +0000 (12:15 -0400)]
qapi/common.py: move build_params into gen.py

Including it in common.py creates a circular import dependency; schema
relies on common, but common.build_params requires a type annotation
from schema. To type this properly, it needs to be moved outside the
cycle.

Signed-off-by: John Snow <[email protected]>
Reviewed-by: Eduardo Habkost <[email protected]>
Reviewed-by: Cleber Rosa <[email protected]>
Message-Id: <20201009161558[email protected]>
Reviewed-by: Markus Armbruster <[email protected]>
Signed-off-by: Markus Armbruster <[email protected]>
4 years agoqapi/common.py: Convert comments into docstrings, and elaborate
John Snow [Fri, 9 Oct 2020 16:15:38 +0000 (12:15 -0400)]
qapi/common.py: Convert comments into docstrings, and elaborate

As docstrings, they'll show up in documentation and IDE help.

The docstring style being targeted is the Sphinx documentation
style. Sphinx uses an extension of ReST with "domains". We use the
(implicit) Python domain, which supports a number of custom "info
fields". Those info fields are documented here:
https://www.sphinx-doc.org/en/master/usage/restructuredtext/domains.html#info-field-lists

Primarily, we use `:param X: descr`, `:return[s]: descr`, and `:raise[s]
Z: when`. Everything else is the Sphinx dialect of ReST.

(No, nothing checks or enforces this style that I am aware of. Sphinx
either chokes or succeeds, but does not enforce a standard of what is
otherwise inside the docstring. Pycharm does highlight when your param
fields are not aligned with the actual fields present. It does not
highlight missing return or exception statements. There is no existing
style guide I am aware of that covers a standard for a minimally
acceptable docstring. I am debating writing one.)

Signed-off-by: John Snow <[email protected]>
Reviewed-by: Eduardo Habkost <[email protected]>
Reviewed-by: Cleber Rosa <[email protected]>
Message-Id: <20201009161558[email protected]>
Reviewed-by: Markus Armbruster <[email protected]>
Signed-off-by: Markus Armbruster <[email protected]>
4 years agoqapi/common.py: add type hint annotations
John Snow [Fri, 9 Oct 2020 16:15:37 +0000 (12:15 -0400)]
qapi/common.py: add type hint annotations

Annotations do not change runtime behavior.
This commit *only* adds annotations.

Note that build_params() cannot be fully annotated due to import
dependency issues.  The commit after next will take care of it.

Signed-off-by: John Snow <[email protected]>
Reviewed-by: Eduardo Habkost <[email protected]>
Reviewed-by: Cleber Rosa <[email protected]>
Message-Id: <20201009161558[email protected]>
Reviewed-by: Markus Armbruster <[email protected]>
Signed-off-by: Markus Armbruster <[email protected]>
4 years agoqapi/common.py: check with pylint
John Snow [Fri, 9 Oct 2020 16:15:36 +0000 (12:15 -0400)]
qapi/common.py: check with pylint

Remove qapi/common.py from the pylintrc ignore list.

Signed-off-by: John Snow <[email protected]>
Reviewed-by: Cleber Rosa <[email protected]>
Tested-by: Cleber Rosa <[email protected]>
Tested-by: Eduardo Habkost <[email protected]>
Message-Id: <20201009161558[email protected]>
Reviewed-by: Markus Armbruster <[email protected]>
Signed-off-by: Markus Armbruster <[email protected]>
4 years agoqapi/common.py: Replace one-letter 'c' variable
John Snow [Fri, 9 Oct 2020 16:15:35 +0000 (12:15 -0400)]
qapi/common.py: Replace one-letter 'c' variable

Signed-off-by: John Snow <[email protected]>
Reviewed-by: Cleber Rosa <[email protected]>
Reviewed-by: Eduardo Habkost <[email protected]>
Reviewed-by: Philippe Mathieu-Daudé <[email protected]>
Message-Id: <20201009161558[email protected]>
Reviewed-by: Markus Armbruster <[email protected]>
Signed-off-by: Markus Armbruster <[email protected]>
4 years agoqapi/common.py: delint with pylint
John Snow [Fri, 9 Oct 2020 16:15:34 +0000 (12:15 -0400)]
qapi/common.py: delint with pylint

At this point, that just means using a consistent strategy for constant names.
constants get UPPER_CASE and names not used externally get a leading underscore.

As a preference, while renaming constants to be UPPERCASE, move them to
the head of the file. Generally, it's nice to be able to audit the code
that runs on import in one central place.

Signed-off-by: John Snow <[email protected]>
Reviewed-by: Eduardo Habkost <[email protected]>
Reviewed-by: Cleber Rosa <[email protected]>
Message-Id: <20201009161558[email protected]>
Reviewed-by: Markus Armbruster <[email protected]>
Signed-off-by: Markus Armbruster <[email protected]>
4 years agoqapi/common.py: Add indent manager
John Snow [Fri, 9 Oct 2020 16:15:33 +0000 (12:15 -0400)]
qapi/common.py: Add indent manager

Code style tools really dislike the use of global keywords, because it
generally involves re-binding the name at runtime which can have strange
effects depending on when and how that global name is referenced in
other modules.

Make a little indent level manager instead.

Signed-off-by: John Snow <[email protected]>
Reviewed-by: Eduardo Habkost <[email protected]>
Reviewed-by: Cleber Rosa <[email protected]>
Message-Id: <20201009161558[email protected]>
Reviewed-by: Markus Armbruster <[email protected]>
Signed-off-by: Markus Armbruster <[email protected]>
4 years agoqapi/common.py: Remove python compatibility workaround
John Snow [Fri, 9 Oct 2020 16:15:32 +0000 (12:15 -0400)]
qapi/common.py: Remove python compatibility workaround

Signed-off-by: John Snow <[email protected]>
Reviewed-by: Eduardo Habkost <[email protected]>
Reviewed-by: Cleber Rosa <[email protected]>
Message-Id: <20201009161558[email protected]>
Reviewed-by: Markus Armbruster <[email protected]>
Signed-off-by: Markus Armbruster <[email protected]>
4 years agoqapi: add pylintrc
John Snow [Fri, 9 Oct 2020 16:15:31 +0000 (12:15 -0400)]
qapi: add pylintrc

Using `pylint --generate-rcfile > pylintrc`, generate a skeleton
pylintrc file. Sections that are not presently relevant (by the end of
this series) are removed leaving just the empty section as a search
engine / documentation hint to future authors.

I am targeting pylint 2.6.0. In the future (and hopefully before 5.2 is
released), I aim to have gitlab CI running the specific targeted
versions of pylint, mypy, flake8, etc in a job.

2.5.x will work if you additionally pass --disable=bad-whitespace.
This warning was removed from 2.6.x, for lack of consistent support.

Right now, quite a few modules are ignored as they are known to fail as
of this commit. modules will be removed from the known-bad list
throughout this and following series as they are repaired.

Note: Normally, pylintrc would go in the folder above the module, but as
that folder is shared by many things, it is going inside the module
folder (for now). Due to a bug in pylint 2.5+, pylint does not
correctly recognize when it is being run from "inside" a package, and
must be run *outside* of the package.

Therefore, to run it, you must:

 > pylint scripts/qapi/ --rcfile=scripts/qapi/pylintrc

Signed-off-by: John Snow <[email protected]>
Tested-by: Eduardo Habkost <[email protected]>
Reviewed-by: Cleber Rosa <[email protected]>
Tested-by: Cleber Rosa <[email protected]>
Message-Id: <20201009161558[email protected]>
Reviewed-by: Markus Armbruster <[email protected]>
Signed-off-by: Markus Armbruster <[email protected]>
4 years agoqapi: delint using flake8
John Snow [Fri, 9 Oct 2020 16:15:30 +0000 (12:15 -0400)]
qapi: delint using flake8

Petty style guide fixes and line length enforcement.  Not a big win, not
a big loss, but flake8 passes 100% on the qapi module, which gives us an
easy baseline to enforce hereafter.

A note on the flake8 exception: flake8 will warn on *any* bare except,
but pylint's is context-aware and will suppress the warning if you
re-raise the exception.

Signed-off-by: John Snow <[email protected]>
Reviewed-by: Eduardo Habkost <[email protected]>
Reviewed-by: Cleber Rosa <[email protected]>
Message-Id: <20201009161558[email protected]>
Reviewed-by: Markus Armbruster <[email protected]>
Signed-off-by: Markus Armbruster <[email protected]>
4 years agoqapi: enforce import order/styling with isort
John Snow [Fri, 9 Oct 2020 16:15:29 +0000 (12:15 -0400)]
qapi: enforce import order/styling with isort

While we're mucking around with imports, we might as well formalize the
style we use. Let's use isort to do it for us.

lines_after_imports=2: Use two lines after imports, to match PEP8's
desire to have "two lines before and after" class definitions, which are
likely to start immediately after imports.

force_sort_within_sections: Intermingles "from x" and "import x" style
statements, such that sorting is always performed strictly on the module
name itself.

force_grid_wrap=4: Four or more imports from a single module will force
the one-per-line style that's more git-friendly. This will generally
happen for 'typing' imports.

multi_line_output=3: Uses the one-per-line indented style for long
imports.

include_trailing_comma: Adds a comma to the last import in a group,
which makes git conflicts nicer to deal with, generally.

line_length: 72 is chosen to match PEP8's "docstrings and comments" line
length limit. If you have a single line import that exceeds 72
characters, your names are too long!

Suggested-by: Cleber Rosa <[email protected]>
Signed-off-by: John Snow <[email protected]>
Reviewed-by: Cleber Rosa <[email protected]>
Tested-by: Cleber Rosa <[email protected]>
Reviewed-by: Markus Armbruster <[email protected]>
Message-Id: <20201009161558[email protected]>
Signed-off-by: Markus Armbruster <[email protected]>
4 years agoqapi: Remove wildcard includes
John Snow [Fri, 9 Oct 2020 16:15:28 +0000 (12:15 -0400)]
qapi: Remove wildcard includes

Wildcard includes become hard to manage when refactoring and dealing
with circular dependencies with strictly typed mypy.

flake8 also flags each one as a warning, as it is not smart enough to
know which names exist in the imported file.

Remove them and include things explicitly by name instead.

Signed-off-by: John Snow <[email protected]>
Reviewed-by: Eduardo Habkost <[email protected]>
Reviewed-by: Cleber Rosa <[email protected]>
Reviewed-by: Philippe Mathieu-Daudé <[email protected]>
Message-Id: <20201009161558[email protected]>
Reviewed-by: Markus Armbruster <[email protected]>
Signed-off-by: Markus Armbruster <[email protected]>
4 years agoqapi: Prefer explicit relative imports
John Snow [Fri, 9 Oct 2020 16:15:27 +0000 (12:15 -0400)]
qapi: Prefer explicit relative imports

All of the QAPI include statements are changed to be package-aware, as
explicit relative imports.

A quirk of Python packages is that the name of the package exists only
*outside* of the package. This means that to a module inside of the qapi
folder, there is inherently no such thing as the "qapi" package. The
reason these imports work is because the "qapi" package exists in the
context of the caller -- the execution shim, where sys.path includes a
directory that has a 'qapi' folder in it.

When we write "from qapi import sibling", we are NOT referencing the folder
'qapi', but rather "any package named qapi in sys.path". If you should
so happen to have a 'qapi' package in your path, it will use *that*
package.

When we write "from .sibling import foo", we always reference explicitly
our sibling module; guaranteeing consistency in *where* we are importing
these modules from.

This can be useful when working with virtual environments and packages
in development mode. In development mode, a package is installed as a
series of symlinks that forwards to your same source files. The problem
arises because code quality checkers will follow "import qapi.x" to the
"installed" version instead of the sibling file and -- even though they
are the same file -- they have different module paths, and this causes
cyclic import problems, false positive type mismatch errors, and more.

It can also be useful when dealing with hierarchical packages, e.g. if
we allow qemu.core.qmp, qemu.qapi.parser, etc.

Signed-off-by: John Snow <[email protected]>
Reviewed-by: Eduardo Habkost <[email protected]>
Reviewed-by: Cleber Rosa <[email protected]>
Reviewed-by: Philippe Mathieu-Daudé <[email protected]>
Message-Id: <20201009161558[email protected]>
Reviewed-by: Markus Armbruster <[email protected]>
Signed-off-by: Markus Armbruster <[email protected]>
4 years agoqapi: move generator entrypoint into package
John Snow [Fri, 9 Oct 2020 16:15:26 +0000 (12:15 -0400)]
qapi: move generator entrypoint into package

As part of delinting and adding type hints to the QAPI generator, it's
helpful for the entrypoint to be part of the package, only leaving a
very tiny entrypoint shim outside of the package.

Signed-off-by: John Snow <[email protected]>
Reviewed-by: Eduardo Habkost <[email protected]>
Reviewed-by: Cleber Rosa <[email protected]>
Tested-by: Cleber Rosa <[email protected]>
Message-Id: <20201009161558[email protected]>
Reviewed-by: Markus Armbruster <[email protected]>
[invalid_char() renamed to invalid_prefix_char()]
Signed-off-by: Markus Armbruster <[email protected]>
4 years agoqapi-gen: Separate arg-parsing from generation
John Snow [Fri, 9 Oct 2020 16:15:25 +0000 (12:15 -0400)]
qapi-gen: Separate arg-parsing from generation

This is a minor re-work of the entrypoint script. It isolates a
generate() method from the actual command-line mechanism.

Signed-off-by: John Snow <[email protected]>
Reviewed-by: Eduardo Habkost <[email protected]>
Reviewed-by: Cleber Rosa <[email protected]>
Tested-by: Cleber Rosa <[email protected]>
Message-Id: <20201009161558[email protected]>
Reviewed-by: Markus Armbruster <[email protected]>
[invalid_char() renamed to invalid_prefix_char()]
Signed-off-by: Markus Armbruster <[email protected]>
4 years agoqapi: modify docstrings to be sphinx-compatible
John Snow [Fri, 9 Oct 2020 16:15:24 +0000 (12:15 -0400)]
qapi: modify docstrings to be sphinx-compatible

A precise style guide and a package-wide overhaul is forthcoming pending
further discussion and consensus. For now, merely avoid obvious errors
that cause Sphinx documentation build problems, using a style loosely
based on PEP 257 and Sphinx Autodoc. It is chosen for interoperability
with our existing Sphinx framework, and because it has loose recognition
in the Pycharm IDE.

See also:

https://www.python.org/dev/peps/pep-0257/
https://www.sphinx-doc.org/en/master/usage/restructuredtext/domains.html#info-field-lists
Signed-off-by: John Snow <[email protected]>
Message-Id: <20201009161558[email protected]>
Reviewed-by: Markus Armbruster <[email protected]>
Signed-off-by: Markus Armbruster <[email protected]>
4 years agodocs: repair broken references
John Snow [Fri, 9 Oct 2020 16:15:23 +0000 (12:15 -0400)]
docs: repair broken references

In two different places, we are not making a cross-reference to some
resource correctly.

Signed-off-by: John Snow <[email protected]>
Message-Id: <20201009161558[email protected]>
Reviewed-by: Markus Armbruster <[email protected]>
Signed-off-by: Markus Armbruster <[email protected]>
4 years agoMerge remote-tracking branch 'remotes/ericb/tags/pull-nbd-2020-10-08-v3' into staging
Peter Maydell [Fri, 9 Oct 2020 21:55:46 +0000 (22:55 +0100)]
Merge remote-tracking branch 'remotes/ericb/tags/pull-nbd-2020-10-08-v3' into staging

nbd patches for 2020-10-08

- silence compilation warnings
- more fixes to prevent reconnect hangs
- improve 'qemu-nbd' termination behavior
- cleaner NBD protocol compliance on string handling

# gpg: Signature made Fri 09 Oct 2020 21:05:30 BST
# gpg:                using RSA key 71C2CC22B1C4602927D2F3AAA7A16B4A2527436A
# gpg: Good signature from "Eric Blake <[email protected]>" [full]
# gpg:                 aka "Eric Blake (Free Software Programmer) <[email protected]>" [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-2020-10-08-v3:
  nbd: Simplify meta-context parsing
  nbd/server: Reject embedded NUL in NBD strings
  qemu-nbd: Honor SIGINT and SIGHUP
  block/nbd: nbd_co_reconnect_loop(): don't connect if drained
  block/nbd: fix reconnect-delay
  block/nbd: correctly use qio_channel_detach_aio_context when needed
  block/nbd: fix drain dead-lock because of nbd reconnect-delay
  nbd: silence maybe-uninitialized warnings

Signed-off-by: Peter Maydell <[email protected]>
4 years agonbd: Simplify meta-context parsing
Eric Blake [Wed, 30 Sep 2020 12:11:03 +0000 (07:11 -0500)]
nbd: Simplify meta-context parsing

We had a premature optimization of trying to read as little from the
wire as possible while handling NBD_OPT_SET_META_CONTEXT in phases.
But in reality, we HAVE to read the entire string from the client
before we can get to the next command, and it is easier to just read
it all at once than it is to read it in pieces.  And once we do that,
several functions end up no longer performing I/O, so they can drop
length and errp parameters, and just return a bool instead of
modifying through a pointer.

Our iotests still pass; I also checked that libnbd's testsuite (which
covers more corner cases of odd meta context requests) still passes.
There are cases where the sequence of trace messages produced differs
(for example, when no bitmap is exported, a query for "qemu:" now
produces two trace lines instead of one), but trace points are for
debug and have no effect on what the client sees.

Signed-off-by: Eric Blake <[email protected]>
Message-Id: <20200930121105[email protected]>
Reviewed-by: Vladimir Sementsov-Ogievskiy <[email protected]>
[eblake: enhance commit message]
Signed-off-by: Eric Blake <[email protected]>
4 years agonbd/server: Reject embedded NUL in NBD strings
Eric Blake [Wed, 30 Sep 2020 12:11:02 +0000 (07:11 -0500)]
nbd/server: Reject embedded NUL in NBD strings

The NBD spec is clear that any string sent from the client must not
contain embedded NUL characters.  If the client passes "a\0", we
should reject that option request rather than act on "a".

Testing this is not possible with a compliant client, but I was able
to use gdb to coerce libnbd into temporarily behaving as such a
client.

Signed-off-by: Eric Blake <[email protected]>
Message-Id: <20200930121105[email protected]>
Reviewed-by: Vladimir Sementsov-Ogievskiy <[email protected]>
Signed-off-by: Eric Blake <[email protected]>
4 years agoqemu-nbd: Honor SIGINT and SIGHUP
Eric Blake [Wed, 30 Sep 2020 12:11:01 +0000 (07:11 -0500)]
qemu-nbd: Honor SIGINT and SIGHUP

Honoring just SIGTERM on Linux is too weak; we also want to handle
other common signals, and do so even on BSD.  Why?  Because at least
'qemu-nbd -B bitmap' needs a chance to clean up the in-use bit on
bitmaps when the server is shut down via a signal.

See also: http://bugzilla.redhat.com/1883608

Signed-off-by: Eric Blake <[email protected]>
Message-Id: <20200930121105[email protected]>
Reviewed-by: Vladimir Sementsov-Ogievskiy <[email protected]>
[eblake: apply comment tweak suggested by Vladimir; fix ifdef around
termsig_handler]
Signed-off-by: Eric Blake <[email protected]>
This page took 0.110068 seconds and 4 git commands to generate.