Go to file
Philippe Mathieu-Daudé d90d5cae2b block/create: Do not abort if a block driver is not available
The 'blockdev-create' QMP command was introduced as experimental
feature in commit b0292b851b, using the assert() debug call.
It got promoted to 'stable' command in 3fb588a0f2, but the
assert call was not removed.

Some block drivers are optional, and bdrv_find_format() might
return a NULL value, triggering the assertion.

Stable code is not expected to abort, so return an error instead.

This is easily reproducible when libnfs is not installed:

  ./configure
  [...]
  module support    no
  Block whitelist (rw)
  Block whitelist (ro)
  libiscsi support  yes
  libnfs support    no
  [...]

Start QEMU:

  $ qemu-system-x86_64 -S -qmp unix:/tmp/qemu.qmp,server,nowait

Send the 'blockdev-create' with the 'nfs' driver:

  $ ( cat << 'EOF'
  {'execute': 'qmp_capabilities'}
  {'execute': 'blockdev-create', 'arguments': {'job-id': 'x', 'options': {'size': 0, 'driver': 'nfs', 'location': {'path': '/', 'server': {'host': '::1', 'type': 'inet'}}}}, 'id': 'x'}
  EOF
  ) | socat STDIO UNIX:/tmp/qemu.qmp
  {"QMP": {"version": {"qemu": {"micro": 50, "minor": 1, "major": 4}, "package": "v4.1.0-733-g89ea03a7dc"}, "capabilities": ["oob"]}}
  {"return": {}}

QEMU crashes:

  $ gdb qemu-system-x86_64 core
  Program received signal SIGSEGV, Segmentation fault.
  (gdb) bt
  #0  0x00007ffff510957f in raise () at /lib64/libc.so.6
  #1  0x00007ffff50f3895 in abort () at /lib64/libc.so.6
  #2  0x00007ffff50f3769 in _nl_load_domain.cold.0 () at /lib64/libc.so.6
  #3  0x00007ffff5101a26 in .annobin_assert.c_end () at /lib64/libc.so.6
  #4  0x0000555555d7e1f1 in qmp_blockdev_create (job_id=0x555556baee40 "x", options=0x555557666610, errp=0x7fffffffc770) at block/create.c:69
  #5  0x0000555555c96b52 in qmp_marshal_blockdev_create (args=0x7fffdc003830, ret=0x7fffffffc7f8, errp=0x7fffffffc7f0) at qapi/qapi-commands-block-core.c:1314
  #6  0x0000555555deb0a0 in do_qmp_dispatch (cmds=0x55555645de70 <qmp_commands>, request=0x7fffdc005c70, allow_oob=false, errp=0x7fffffffc898) at qapi/qmp-dispatch.c:131
  #7  0x0000555555deb2a1 in qmp_dispatch (cmds=0x55555645de70 <qmp_commands>, request=0x7fffdc005c70, allow_oob=false) at qapi/qmp-dispatch.c:174

With this patch applied, QEMU returns a QMP error:

  {'execute': 'blockdev-create', 'arguments': {'job-id': 'x', 'options': {'size': 0, 'driver': 'nfs', 'location': {'path': '/', 'server': {'host': '::1', 'type': 'inet'}}}}, 'id': 'x'}
  {"id": "x", "error": {"class": "GenericError", "desc": "Block driver 'nfs' not found or not supported"}}

Cc: qemu-stable@nongnu.org
Reported-by: Xu Tian <xutian@redhat.com>
Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Reviewed-by: John Snow <jsnow@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2019-09-13 12:18:37 +02:00
accel Allow page table bit to swap endianness. 2019-09-04 16:29:18 +01:00
audio audio: omitting audiodev= parameter is only deprecated 2019-08-28 11:57:45 +02:00
authz Include qemu/module.h where needed, drop it from qemu-common.h 2019-06-12 13:18:33 +02:00
backends virtio,vhost: fixes, features, cleanups. 2019-09-04 17:22:34 +01:00
block block/create: Do not abort if a block driver is not available 2019-09-13 12:18:37 +02:00
bsd-user Include qemu-common.h exactly where needed 2019-06-12 13:20:20 +02:00
capstone@22ead3e0bf disas: Add capstone as submodule 2017-10-26 11:56:20 +02:00
chardev socket: Add num connections to qio_net_listener_open_sync() 2019-09-03 23:24:42 +02:00
contrib virtio,vhost: fixes, features, cleanups. 2019-09-04 17:22:34 +01:00
crypto crypto: use auto cleanup for many stack variables 2019-08-22 10:56:57 +01:00
default-configs m68k: Add NeXTcube framebuffer device emulation 2019-09-07 08:30:34 +02:00
disas ppc: Add support for 'mffsl' instruction 2019-08-21 17:17:39 +10:00
docs nbd patches for 2019-09-05 2019-09-06 09:28:31 +01:00
dtc@88f18909db Update dtc/libfdt submodule to v1.4.7 2018-10-02 13:53:26 +10:00
dump sysemu: Split sysemu/runstate.h off sysemu/sysemu.h 2019-08-16 13:37:36 +02:00
fpu fpu: rename softfloat-specialize.h -> .inc.c 2019-08-19 12:07:13 +01:00
fsdev 9p: simplify source file selection 2019-08-20 17:26:19 +02:00
gdb-xml RISC-V: Add 64-bit gdb xml files. 2019-03-19 05:13:24 -07:00
hw m68k: Add serial controller to the NeXTcube machine 2019-09-07 08:32:34 +02:00
include job: drop job_drain 2019-09-10 08:58:43 +02:00
io socket: Add num connections to qio_net_listener_open_sync() 2019-09-03 23:24:42 +02:00
libdecnumber build: remove CONFIG_LIBDECNUMBER 2017-10-16 18:03:52 +02:00
linux-headers linux-headers: sync with latest KVM headers from Linux 5.2 2019-06-21 13:23:47 +02:00
linux-user target/openrisc: Add support for ORFPX64A32 2019-09-04 12:53:33 -07:00
migration multifd: Use number of channels as listen backlog 2019-09-03 23:24:42 +02:00
monitor Monitor patches for 2019-08-21 2019-08-22 10:31:21 +01:00
nbd nbd: Implement server use of NBD FAST_ZERO 2019-09-05 16:04:53 -05:00
net sysemu: Split sysemu/runstate.h off sysemu/sysemu.h 2019-08-16 13:37:36 +02:00
pc-bios pseries: Update SLOF firmware image 2019-08-29 09:46:07 +10:00
po po/Makefile: Modern shell scripting (use $() instead of ``) 2018-10-24 07:39:10 +01:00
python/qemu iotests: Add @has_quit to vm.shutdown() 2019-07-19 13:19:17 +02:00
qapi qapi: report the default CPU type for each machine 2019-09-03 14:39:46 -03:00
qga socket: Add backlog parameter to socket_listen 2019-09-03 23:24:42 +02:00
qobject json: Move switch 'fall through' comment to correct place 2019-08-21 10:54:31 +02:00
qom hw/core: Move cpu.c, cpu.h from qom/ to hw/core/ 2019-08-21 13:24:01 +02:00
replay audio: second batch of -audiodev support, adding support for multiple backends. 2019-08-21 15:18:50 +01:00
roms pseries: Update SLOF firmware image 2019-08-29 09:46:07 +10:00
scripts docs: convert README, CODING_STYLE and HACKING to RST syntax 2019-09-05 14:27:06 +01:00
scsi pr-manager: Fix invalid g_free() crash bug 2019-09-10 08:58:43 +02:00
slirp@126c04acba slirp: update with CVE-2019-14378 fix 2019-08-02 15:14:56 +04:00
stubs sysemu: Split sysemu/runstate.h off sysemu/sysemu.h 2019-08-16 13:37:36 +02:00
target target/arm: Inline gen_bx_im into callers 2019-09-05 13:23:04 +01:00
tcg Allow page table bit to swap endianness. 2019-09-04 16:29:18 +01:00
tests iotests: extend sleeping time under Valgrind 2019-09-13 12:18:37 +02:00
trace tcg: TCGMemOp is now accelerator independent MemOp 2019-09-03 08:30:38 -07:00
ui socket: Add num connections to qio_net_listener_open_sync() 2019-09-03 23:24:42 +02:00
util socket: Add backlog parameter to socket_listen 2019-09-03 23:24:42 +02:00
.cirrus.yml cirrus / travis: Add gnu-sed and bash for macOS and FreeBSD 2019-05-21 10:12:47 +02:00
.dir-locals.el Add .dir-locals.el file to configure emacs coding style 2015-10-08 19:46:01 +03:00
.editorconfig editorconfig: add setting for shell scripts 2019-06-12 17:53:22 +01:00
.exrc qemu: add .exrc 2012-09-07 09:02:44 +03:00
.gdbinit .gdbinit: load QEMU sub-commands when gdb starts 2017-06-07 14:38:45 +01:00
.gitignore .gitignore: ignore some vhost-user* related files 2019-08-21 10:40:41 +02:00
.gitlab-ci.yml gitlab-ci.yml: Install libattr-devel and libcap-devel to test virtio-9p 2019-09-05 16:00:01 +02:00
.gitmodules roms: Add OpenSBI version 0.4 2019-07-18 14:18:43 -07:00
.gitpublish Add a git-publish configuration file 2018-03-05 09:03:17 +00:00
.mailmap .mailmap/aliases: add some further commentary 2019-09-02 10:52:22 +01:00
.patchew.yml ci: store Patchew configuration in the tree 2019-06-03 14:03:02 +02:00
.shippable.yml shippable: re-enable the windows cross builds 2019-07-23 15:53:25 +01:00
.travis.yml .travis.yml: Let the avocado job run the NeXTcube tests 2019-09-07 08:35:41 +02:00
arch_init.c qapi: Move query-target from misc.json to machine.json 2019-08-21 13:24:01 +02:00
balloon.c Clean up inclusion of exec/cpu-common.h 2019-08-16 13:31:52 +02:00
block.c block: fix permission update in bdrv_replace_node 2019-09-03 14:55:35 +02:00
blockdev-nbd.c nbd: Improve per-export flag handling in server 2019-09-05 16:02:54 -05:00
blockdev.c mirror: Fix bdrv_has_zero_init() use 2019-08-19 17:13:26 +02:00
blockjob.c job: drop job_drain 2019-09-10 08:58:43 +02:00
bootdevice.c fw_cfg: ignore suffixes in the bootdevice list dependent on machine class 2018-08-16 22:27:43 -03:00
bt-host.c all: Clean up includes 2016-02-04 17:41:30 +00:00
bt-vhci.c Include qemu-common.h exactly where needed 2019-06-12 13:20:20 +02:00
Changelog Use HTTPS for qemu.org and other domains 2017-11-21 13:34:13 +00:00
CODING_STYLE.rst docs: split the CODING_STYLE doc into distinct groups 2019-09-05 14:41:00 +01:00
configure configure: more resilient Python version capture 2019-08-27 16:57:24 -03:00
COPYING COPYING: update from FSF 2008-10-12 17:54:42 +00:00
COPYING.LIB COPYING.LIB: Synchronize the LGPL 2.1 with the version from gnu.org 2019-01-30 11:01:22 +01:00
cpus-common.c Monitor patches for 2019-08-21 2019-08-22 10:31:21 +01:00
cpus.c util/qemu-timer: refactor deadline calculation for external timers 2019-08-20 17:26:21 +02:00
device_tree.c device_tree: Fix integer overflowing in load_device_tree() 2019-04-09 16:35:40 -07:00
device-hotplug.c Include hw/hw.h exactly where needed 2019-08-16 13:31:52 +02:00
disas.c Include qemu-common.h exactly where needed 2019-06-12 13:20:20 +02:00
dma-helpers.c dma-helpers: ensure AIO callback is invoked after cancellation 2019-08-16 19:14:04 -04:00
exec.c Allow page table bit to swap endianness. 2019-09-04 16:29:18 +01:00
gdbstub.c gdbstub: Fix handler for 'F' packet 2019-08-28 10:11:15 +01:00
gitdm.config contrib: gitdm: add a mapping for Janus Technologies 2019-03-12 19:31:29 +00:00
hmp-commands-info.hx {hmp, hw/pvrdma}: Expose device internals via monitor interface 2019-03-16 15:52:44 +02:00
hmp-commands.hx audio: add audiodev property to vnc and wav_capture 2019-08-21 09:13:37 +02:00
ioport.c Include qemu-common.h exactly where needed 2019-06-12 13:20:20 +02:00
iothread.c iothread: document about why we need explicit aio_poll() 2019-03-08 10:20:57 +00:00
job-qmp.c Include qemu-common.h exactly where needed 2019-06-12 13:20:20 +02:00
job.c job: drop job_drain 2019-09-10 08:58:43 +02:00
Kconfig.host 9p: simplify source file selection 2019-08-20 17:26:19 +02:00
LICENSE roms: Add OpenSBI version 0.4 2019-07-18 14:18:43 -07:00
MAINTAINERS m68k: Add an entry for the NeXTcube machine to the MAINTAINERS file 2019-09-07 08:32:52 +02:00
Makefile tests/docker: add podman support 2019-08-22 17:30:25 +04:00
Makefile.objs dump: Move HMP command handlers to dump/ 2019-07-02 13:37:00 +02:00
Makefile.target configure: only link capstone to emulation targets 2019-07-19 12:52:04 +01:00
memory_ldst.inc.c memory: Single byte swap along the I/O path 2019-09-03 08:30:39 -07:00
memory_mapping.c Include qemu-common.h exactly where needed 2019-06-12 13:20:20 +02:00
memory.c Allow page table bit to swap endianness. 2019-09-04 16:29:18 +01:00
module-common.c all: Clean up includes 2016-02-04 17:41:30 +00:00
os-posix.c sysemu: Split sysemu/runstate.h off sysemu/sysemu.h 2019-08-16 13:37:36 +02:00
os-win32.c sysemu: Split sysemu/runstate.h off sysemu/sysemu.h 2019-08-16 13:37:36 +02:00
qdev-monitor.c qdev: Collect HMP handlers command handlers in qdev-monitor.c 2019-08-21 13:24:01 +02:00
qemu-bridge-helper.c qemu-bridge-helper: move repeating code in parse_acl_file 2019-07-29 16:29:30 +08:00
qemu-deprecated.texi audio: omitting audiodev= parameter is only deprecated 2019-08-28 11:57:45 +02:00
qemu-doc.texi nbd patches for 2019-09-05 2019-09-06 09:28:31 +01:00
qemu-edid.c Include qemu-common.h exactly where needed 2019-06-12 13:20:20 +02:00
qemu-ga.texi doc: fix the configuration path 2019-05-03 13:03:04 +02:00
qemu-img-cmds.hx qemu-img: Add salvaging mode to convert 2019-06-14 14:16:57 +02:00
qemu-img.c block: define .*_part io handlers in BlockDriver 2019-08-27 14:58:42 +01:00
qemu-img.texi doc: Preallocation does not require writing zeroes 2019-08-19 17:13:26 +02:00
qemu-io-cmds.c qemu-io: Don't leak pattern file in error path 2019-09-13 12:18:37 +02:00
qemu-io.c Include qemu-common.h exactly where needed 2019-06-12 13:20:20 +02:00
qemu-keymap.c Include qemu-common.h exactly where needed 2019-06-12 13:20:20 +02:00
qemu-nbd.c nbd: Prepare for NBD_CMD_FLAG_FAST_ZERO 2019-09-05 16:03:13 -05:00
qemu-nbd.texi qemu-nbd: Add --pid-file option 2019-06-13 08:50:47 -05:00
qemu-option-trace.texi qemu-option-trace: -trace enable= is a pattern, not a file 2018-05-20 08:29:01 +03:00
qemu-options-wrapper.h qemu-img: remove references to GEN_DOCS 2018-05-20 08:35:54 +03:00
qemu-options.h Clean up ill-advised or unusual header guards 2016-07-12 16:20:46 +02:00
qemu-options.hx qemu-doc: Do not hard-code the name of the QEMU binary 2019-09-05 13:18:52 +02:00
qemu-seccomp.c seccomp: report more useful errors from seccomp 2019-03-27 13:11:38 +01:00
qemu-tech.texi qemu-tech: Fix dangling @menu entries 2019-07-15 21:10:29 +02:00
qemu.nsi NSIS: Add missing firmware blobs 2019-07-23 15:53:25 +01:00
qemu.sasl Default to GSSAPI (Kerberos) instead of DIGEST-MD5 for SASL 2017-05-09 14:41:47 +01:00
qtest.c tests: add module loading test 2019-08-21 16:29:57 +02:00
README.rst docs: merge HACKING.rst contents into CODING_STYLE.rst 2019-09-05 14:27:06 +01:00
replication.c replication: Introduce new APIs to do replication operation 2016-09-13 11:00:56 +01:00
replication.h Include qemu/module.h where needed, drop it from qemu-common.h 2019-06-12 13:18:33 +02:00
rules.mak contrib: add vhost-user-gpu 2019-05-29 06:30:45 +02:00
thunk.c thunk: improve readability of allocation loop 2019-03-11 18:48:20 +01:00
tpm.c tpm: Clean up error reporting in tpm_init_tpmdev() 2018-10-19 14:51:34 +02:00
trace-events hw/core: Move cpu.c, cpu.h from qom/ to hw/core/ 2019-08-21 13:24:01 +02:00
VERSION Open 4.2 development tree 2019-08-15 17:20:55 +01:00
version.rc Use HTTPS for qemu.org and other domains 2017-11-21 13:34:13 +00:00
vl.c Various trivial fixes 2019-08-21 16:59:22 +01:00

===========
QEMU README
===========

QEMU is a generic and open source machine & userspace emulator and
virtualizer.

QEMU is capable of emulating a complete machine in software without any
need for hardware virtualization support. By using dynamic translation,
it achieves very good performance. QEMU can also integrate with the Xen
and KVM hypervisors to provide emulated hardware while allowing the
hypervisor to manage the CPU. With hypervisor support, QEMU can achieve
near native performance for CPUs. When QEMU emulates CPUs directly it is
capable of running operating systems made for one machine (e.g. an ARMv7
board) on a different machine (e.g. an x86_64 PC board).

QEMU is also capable of providing userspace API virtualization for Linux
and BSD kernel interfaces. This allows binaries compiled against one
architecture ABI (e.g. the Linux PPC64 ABI) to be run on a host using a
different architecture ABI (e.g. the Linux x86_64 ABI). This does not
involve any hardware emulation, simply CPU and syscall emulation.

QEMU aims to fit into a variety of use cases. It can be invoked directly
by users wishing to have full control over its behaviour and settings.
It also aims to facilitate integration into higher level management
layers, by providing a stable command line interface and monitor API.
It is commonly invoked indirectly via the libvirt library when using
open source applications such as oVirt, OpenStack and virt-manager.

QEMU as a whole is released under the GNU General Public License,
version 2. For full licensing details, consult the LICENSE file.


Building
========

QEMU is multi-platform software intended to be buildable on all modern
Linux platforms, OS-X, Win32 (via the Mingw64 toolchain) and a variety
of other UNIX targets. The simple steps to build QEMU are:


.. code-block:: shell

  mkdir build
  cd build
  ../configure
  make

Additional information can also be found online via the QEMU website:

* `<https://qemu.org/Hosts/Linux>`_
* `<https://qemu.org/Hosts/Mac>`_
* `<https://qemu.org/Hosts/W32>`_


Submitting patches
==================

The QEMU source code is maintained under the GIT version control system.

.. code-block:: shell

   git clone https://git.qemu.org/git/qemu.git

When submitting patches, one common approach is to use 'git
format-patch' and/or 'git send-email' to format & send the mail to the
qemu-devel@nongnu.org mailing list. All patches submitted must contain
a 'Signed-off-by' line from the author. Patches should follow the
guidelines set out in the CODING_STYLE.rst file.

Additional information on submitting patches can be found online via
the QEMU website

* `<https://qemu.org/Contribute/SubmitAPatch>`_
* `<https://qemu.org/Contribute/TrivialPatches>`_

The QEMU website is also maintained under source control.

.. code-block:: shell

  git clone https://git.qemu.org/git/qemu-web.git

* `<https://www.qemu.org/2017/02/04/the-new-qemu-website-is-up/>`_

A 'git-publish' utility was created to make above process less
cumbersome, and is highly recommended for making regular contributions,
or even just for sending consecutive patch series revisions. It also
requires a working 'git send-email' setup, and by default doesn't
automate everything, so you may want to go through the above steps
manually for once.

For installation instructions, please go to

*  `<https://github.com/stefanha/git-publish>`_

The workflow with 'git-publish' is:

.. code-block:: shell

  $ git checkout master -b my-feature
  $ # work on new commits, add your 'Signed-off-by' lines to each
  $ git publish

Your patch series will be sent and tagged as my-feature-v1 if you need to refer
back to it in the future.

Sending v2:

.. code-block:: shell

  $ git checkout my-feature # same topic branch
  $ # making changes to the commits (using 'git rebase', for example)
  $ git publish

Your patch series will be sent with 'v2' tag in the subject and the git tip
will be tagged as my-feature-v2.

Bug reporting
=============

The QEMU project uses Launchpad as its primary upstream bug tracker. Bugs
found when running code built from QEMU git or upstream released sources
should be reported via:

* `<https://bugs.launchpad.net/qemu/>`_

If using QEMU via an operating system vendor pre-built binary package, it
is preferable to report bugs to the vendor's own bug tracker first. If
the bug is also known to affect latest upstream code, it can also be
reported via launchpad.

For additional information on bug reporting consult:

* `<https://qemu.org/Contribute/ReportABug>`_


Contact
=======

The QEMU community can be contacted in a number of ways, with the two
main methods being email and IRC

* `<mailto:qemu-devel@nongnu.org>`_
* `<https://lists.nongnu.org/mailman/listinfo/qemu-devel>`_
* #qemu on irc.oftc.net

Information on additional methods of contacting the community can be
found online via the QEMU website:

* `<https://qemu.org/Contribute/StartHere>`_