Misc patches for 2017-09-22 (v2)
The following changes since commit b62b7ed0fc9c58e373b8946c9bd2e193be98dae6:
Merge remote-tracking branch 'remotes/gkurz/tags/for-upstream' into staging (2017-09-20 20:33:48 +0100)
are available in the git repository at:
git://github.com/bonzini/qemu.git tags/for-upstream
for you to fetch changes up to 8acf7b48e0098198057db048340606c7fbfc6518:
chardev: remove context in chr_update_read_handler (2017-09-22 14:03:27 +0200)
v2 fixes some issues with the new qemu-pr-helper. make install and systemd socket activation were broken. I have now backported it to the Fedora QEMU packages to shake out any distro-level issues.
----------------------------------------------------------------
* Speed up AddressSpaceDispatch creation (Alexey)
* Fix kvm.c assert (David)
* Memory fixes and further speedup (me)
* Persistent reservation manager infrastructure (me)
* virtio-serial: add enable_backend callback (Pavel)
* chardev GMainContext fixes (Peter)
----------------------------------------------------------------
Alexey Kardashevskiy (17):
exec: Explicitly export target AS from address_space_translate_internal
memory: Open code FlatView rendering
memory: Move FlatView allocation to a helper
memory: Move AddressSpaceDispatch from AddressSpace to FlatView
memory: Remove AddressSpace pointer from AddressSpaceDispatch
memory: Switch memory from using AddressSpace to FlatView
memory: Cleanup after switching to FlatView
memory: Rename mem_begin/mem_commit/mem_add helpers
memory: Store physical root MR in FlatView
memory: Alloc dispatch tree where topology is generared
memory: Move address_space_update_ioeventfds
memory: Share FlatView's and dispatch trees between address spaces
memory: Do not allocate FlatView in address_space_init
memory: Rework "info mtree" to print flat views and dispatch trees
memory: Get rid of address_space_init_shareable
memory: Create FlatView directly
memory: Share special empty FlatView
David Hildenbrand (1):
kvm: drop wrong assertion creating problems with pflash
KONRAD Frederic (1):
memory: avoid a name clash with access macro
Paolo Bonzini (8):
atomic: update documentation
memory: avoid "resurrection" of dead FlatViews
memory: trace FlatView creation and destruction
memory: seek FlatView sharing candidates among children subregions scsi, file-posix: add support for persistent reservation management
scsi: build qemu-pr-helper
scsi: add multipath support to qemu-pr-helper
scsi: add persistent reservation manager using qemu-pr-helper
Pavel Butsykin (1):
virtio-serial: add enable_backend callback
Peter Xu (4):
chardev: new qemu_chr_be_update_read_handlers()
chardev: add Chardev.gcontext field
chardev: use per-dev context for io_add_watch_poll
chardev: remove context in chr_update_read_handler
Makefile | 7 +- Makefile.objs | 1 + accel/kvm/kvm-all.c | 1 - block/file-posix.c | 30 ++ chardev/char-fd.c | 5 +- chardev/char-fe.c | 7 +- chardev/char-pty.c | 5 +- chardev/char-socket.c | 7 +- chardev/char-udp.c | 5 +- chardev/char.c | 11 + configure | 60 ++- cpus.c | 5 +- docs/devel/atomics.txt | 14 +- docs/interop/pr-helper.rst | 83 +++ docs/pr-manager.rst | 111 ++++ exec.c | 330 +++++++----- hmp-commands-info.hx | 7 +- hw/arm/armv7m.c | 9 +- hw/char/virtio-console.c | 21 + hw/char/virtio-serial-bus.c | 7 + hw/intc/openpic_kvm.c | 2 +- include/chardev/char.h | 13 +- include/exec/memory-internal.h | 16 +- include/exec/memory.h | 75 ++- include/hw/arm/armv7m.h | 2 +- include/hw/virtio/virtio-serial.h | 3 + include/qemu/atomic.h | 8 + include/qemu/typedefs.h | 1 + include/scsi/pr-manager.h | 56 ++ include/scsi/utils.h | 4 + memory.c | 378 ++++++++++--- monitor.c | 3 +- qapi/block-core.json | 4 + scsi/Makefile.objs | 2 + scsi/pr-helper.h | 41 ++ scsi/pr-manager-helper.c | 302 +++++++++++ scsi/pr-manager.c | 109 ++++ scsi/qemu-pr-helper.c | 1075 +++++++++++++++++++++++++++++++++++++ scsi/trace-events | 3 + scsi/utils.c | 10 + target/arm/cpu.c | 16 +- target/i386/cpu.c | 5 +- trace-events | 3 + vl.c | 3 +- 44 files changed, 2550 insertions(+), 310 deletions(-) create mode 100644 docs/interop/pr-helper.rst create mode 100644 docs/pr-manager.rst create mode 100644 include/scsi/pr-manager.h create mode 100644 scsi/pr-helper.h create mode 100644 scsi/pr-manager-helper.c create mode 100644 scsi/pr-manager.c create mode 100644 scsi/qemu-pr-helper.c create mode 100644 scsi/trace-events
Signature · 1 line
2.13.5
[Qemu-devel] [PULL 27/32] scsi: add multipath support to qemu-pr-helper
Proper support of persistent reservation for multipath devices requires communication with the multipath daemon, so that the reservation is registered and applied when a path comes up. The device mapper utilities provide a library to do so; this patch makes qemu-pr-helper.c detect multipath devices and, when one is found, delegate the operation to libmpathpersist.
--- Makefile | 3 + configure | 46 +++++++ docs/pr-manager.rst | 27 ++++ include/scsi/utils.h | 4 + scsi/qemu-pr-helper.c | 346 +++++++++++++++++++++++++++++++++++++++++++++++++- scsi/utils.c | 10 ++ 6 files changed, 433 insertions(+), 3 deletions(-)
Makefile +3 -0
@@ -373,6 +373,9 @@ fsdev/virtfs-proxy-helper$(EXESUF): fsdev/virtfs-proxy-helper.o fsdev/9p-marshal fsdev/virtfs-proxy-helper$(EXESUF): LIBS += -lcap scsi/qemu-pr-helper$(EXESUF): scsi/qemu-pr-helper.o scsi/utils.o $(crypto-obj-y) $(io-obj-y) $(qom-obj-y) $(COMMON_LDADDS) +ifdef CONFIG_MPATH +scsi/qemu-pr-helper$(EXESUF): LIBS += -ludev -lmultipath -lmpathpersist +endif qemu-img-cmds.h: $(SRC_PATH)/qemu-img-cmds.hx $(SRC_PATH)/scripts/hxtool $(call quiet-command,sh $(SRC_PATH)/scripts/hxtool -h < $< > $@,"GEN","$@")
configure +46 -0
94 lines not on this page · raw message
docs/pr-manager.rst +27 -0
@@ -60,6 +60,7 @@ system service and supports the following option: -d, --daemon run in the background -q, --quiet decrease verbosity +-v, --verbose increase verbosity -f, --pidfile=path PID file when running as a daemon -k, --socket=path path to the socket -T, --trace=trace-opts tracing options
@@ -82,3 +83,29 @@ its operation. To do this, add the following options: -u, --user=user user to drop privileges to -g, --group=group group to drop privileges to + +--------------------------------------------- +Multipath devices and persistent reservations +--------------------------------------------- + +Proper support of persistent reservation for multipath devices requires +communication with the multipath daemon, so that the reservation is +registered and applied when a path is newly discovered or becomes online +again. :command:`qemu-pr-helper` can do this if the ``libmpathpersist`` +library was available on the system at build time. + +As of August 2017, a reservation key must be specified in ``multipath.conf`` +for ``multipathd`` to check for persistent reservation for newly +discovered paths or reinstated paths. The attribute can be added +to the ``defaults`` section or the ``multipaths`` section; for example:: + + multipaths { + multipath { + wwid XXXXXXXXXXXXXXXX + alias yellow + reservation_key 0x123abc + } + } + +Linking :program:`qemu-pr-helper` to ``libmpathpersist`` does not impede +its usage on regular SCSI devices.
include/scsi/utils.h +4 -0
@@ -72,10 +72,14 @@ extern const struct SCSISense sense_code_IO_ERROR;extern const struct SCSISense sense_code_I_T_NEXUS_LOSS;/* Command aborted, Logical Unit failure */ extern const struct SCSISense sense_code_LUN_FAILURE; +/* Command aborted, LUN Communication failure */ +extern const struct SCSISense sense_code_LUN_COMM_FAILURE;/* Command aborted, Overlapped Commands Attempted */ extern const struct SCSISense sense_code_OVERLAPPED_COMMANDS;/* LUN not ready, Capacity data has changed */ extern const struct SCSISense sense_code_CAPACITY_CHANGED; +/* Unit attention, SCSI bus reset */ +extern const struct SCSISense sense_code_SCSI_BUS_RESET;/* LUN not ready, Medium not present */ extern const struct SCSISense sense_code_UNIT_ATTENTION_NO_MEDIUM;/* Unit attention, Power on, reset or bus device reset occurred */
scsi/qemu-pr-helper.c +343 -3
413 lines not on this page · raw message
scsi/utils.c +10 -0
@@ -206,6 +206,11 @@ const struct SCSISense sense_code_OVERLAPPED_COMMANDS = { .key = ABORTED_COMMAND, .asc = 0x4e, .ascq = 0x00 }; +/* Command aborted, LUN Communication Failure */ +const struct SCSISense sense_code_LUN_COMM_FAILURE = { + .key =ABORTED_COMMAND , .asc =0x08 , .ascq =0x00 +}; +/* Unit attention, Capacity data has changed */ const struct SCSISense sense_code_CAPACITY_CHANGED = { .key =UNIT_ATTENTION , .asc =0x2a , .ascq =0x09
@@ -216,6 +221,11 @@ const struct SCSISense sense_code_RESET = { .key = UNIT_ATTENTION, .asc = 0x29, .ascq = 0x00 }; +/* Unit attention, SCSI bus reset */ +const struct SCSISense sense_code_SCSI_BUS_RESET = { + .key =UNIT_ATTENTION , .asc =0x29 , .ascq =0x02 +}; +/* Unit attention, No medium */ const struct SCSISense sense_code_UNIT_ATTENTION_NO_MEDIUM = { .key =UNIT_ATTENTION , .asc =0x3a , .ascq =0x00
Signature · 1 line
2.13.5
[Qemu-devel] [PULL 26/32] scsi: build qemu-pr-helper
In reply to Paolo BonziniIntroduce a privileged helper to run persistent reservation commands. This lets virtual machines send persistent reservations without using CAP_SYS_RAWIO or out-of-tree patches. The helper uses Unix permissions and SCM_RIGHTS to restrict access to processes that can access its socket and prove that they have an open file descriptor for a raw SCSI device.
The next patch will also correct the usage of persistent reservations with multipath devices.
It would also be possible to support for Linux's IOC_PR_* ioctls in the future, to support NVMe devices. For now, however, only SCSI is supported.
--- Makefile | 4 +- configure | 14 +- docs/interop/pr-helper.rst | 83 +++++ docs/pr-manager.rst | 33 ++ scsi/pr-helper.h | 41 +++ scsi/qemu-pr-helper.c | 735 +++++++++++++++++++++++++++++++++++++++++++++ 6 files changed, 905 insertions(+), 5 deletions(-) create mode 100644 docs/interop/pr-helper.rst create mode 100644 scsi/pr-helper.h create mode 100644 scsi/qemu-pr-helper.c
Makefile +3 -1
@@ -372,6 +372,8 @@ qemu-bridge-helper$(EXESUF): qemu-bridge-helper.o $(COMMON_LDADDS) fsdev/virtfs-proxy-helper$(EXESUF): fsdev/virtfs-proxy-helper.o fsdev/9p-marshal.o fsdev/9p-iov-marshal.o $(COMMON_LDADDS) fsdev/virtfs-proxy-helper$(EXESUF): LIBS += -lcap +scsi/qemu-pr-helper$(EXESUF): scsi/qemu-pr-helper.o scsi/utils.o $(crypto-obj-y) $(io-obj-y) $(qom-obj-y) $(COMMON_LDADDS) + qemu-img-cmds.h: $(SRC_PATH)/qemu-img-cmds.hx $(SRC_PATH)/scripts/hxtool $(call quiet-command,sh $(SRC_PATH)/scripts/hxtool -h < $< > $@,"GEN","$@")
@@ -488,7 +490,7 @@ clean: rm -f *.msi find . \( -name '*.so' -o -name '*.dll' -o -name '*.mo' -o -name '*.[oda]' \) -type f -exec rm {} + rm -f $(filter-out %.tlb,$(TOOLS)) $(HELPERS-y) qemu-ga TAGS cscope.* *.pod *~ */*~ - rm -f fsdev/*.pod + rm -f fsdev/*.pod scsi/*.pod rm -f qemu-img-cmds.h rm -f ui/shader/*-vert.h ui/shader/*-frag.h @# May not be present in GENERATED_FILES
configure +10 -4
@@ -5034,16 +5034,22 @@ if test "$want_tools" = "yes" ; then fi fi if test "$softmmu" = yes ; then - if test "$virtfs" != no ; then - if test "$cap" = yes && test "$linux" = yes && test "$attr" = yes ; then + if test "$linux" = yes; then + if test "$virtfs" != no && test "$cap" = yes && test "$attr" = yes ; then virtfs=yes tools="$tools fsdev/virtfs-proxy-helper\$(EXESUF)" else if test "$virtfs" = yes; then - error_exit "VirtFS is supported only on Linux and requires libcap devel and libattr devel" + error_exit "VirtFS requires libcap devel and libattr devel" fi virtfs=no fi + tools="$tools scsi/qemu-pr-helper\$(EXESUF)" + else + if test "$virtfs" = yes; then + error_exit "VirtFS is supported only on Linux" + fi + virtfs=no fi fi
@@ -6506,7 +6512,7 @@ fi # build tree in object directory in case the source is not in the current directory DIRS="tests tests/tcg tests/tcg/cris tests/tcg/lm32 tests/libqos tests/qapi-schema tests/tcg/xtensa tests/qemu-iotests" -DIRS="$DIRS docs docs/interop fsdev" +DIRS="$DIRS docs docs/interop fsdev scsi" DIRS="$DIRS pc-bios/optionrom pc-bios/spapr-rtas pc-bios/s390-ccw" DIRS="$DIRS roms/seabios roms/vgabios" DIRS="$DIRS qapi-generated"
docs/interop/pr-helper.rst new file +83 -0
83 lines not on this page · raw message
docs/pr-manager.rst +33 -0
@@ -49,3 +49,36 @@ Alternatively, using ``-blockdev``:: -object pr-manager-helper,id=helper0,path=/var/run/qemu-pr-helper.sock -blockdev node-name=hd,driver=raw,file.driver=host_device,file.filename=/dev/sdb,file.pr-manager=helper0 -device scsi-block,drive=hd + +---------------------------------- +Invoking :program:`qemu-pr-helper` +---------------------------------- + +QEMU provides an implementation of the persistent reservation helper, +called :program:`qemu-pr-helper`. The helper should be started as a +system service and supports the following option: + +-d, --daemon run in the background +-q, --quiet decrease verbosity +-f, --pidfile=path PID file when running as a daemon +-k, --socket=path path to the socket +-T, --trace=trace-opts tracing options + +By default, the socket and PID file are placed in the runtime state +directory, for example :file:`/var/run/qemu-pr-helper.sock` and +:file:`/var/run/qemu-pr-helper.pid`. The PID file is not created +unless :option:`-d` is passed too. + +:program:`qemu-pr-helper` can also use the systemd socket activation +protocol. In this case, the systemd socket unit should specify a +Unix stream socket, like this:: + + [Socket] + ListenStream=/var/run/qemu-pr-helper.sock + +After connecting to the socket, :program:`qemu-pr-helper`` can optionally drop +root privileges, except for those capabilities that are needed for +its operation. To do this, add the following options: + +-u, --user=user user to drop privileges to +-g, --group=group group to drop privileges to
scsi/pr-helper.h new file +41 -0
41 lines not on this page · raw message
scsi/qemu-pr-helper.c new file +735 -0
735 lines not on this page · raw message
Signature · 1 line
2.13.5
Quoted 16 lines · Paolo Bonzini
The following changes since commit
b62b7ed0fc9c58e373b8946c9bd2e193be98dae6:Merge remote-tracking branch 'remotes/gkurz/tags/for-upstream' into staging (2017-09-20 20:33:48 +0100)
are available in the git repository at:
git://github.com/bonzini/qemu.gittags/for-upstreamfor you to fetch changes up to
8acf7b48e0098198057db048340606c7fbfc6518:chardev: remove context in
chr_update_read_handler(2017-09-22 14:03:27 +0200)v2 fixes some issues with the new qemu-pr-helper. make install and systemd socket activation were broken. I have now backported it to the Fedora QEMU packages to shake out any distro-level issues.
Quoted 7 lines
----------------------------------------------------------------
* Speed up AddressSpaceDispatch creation (Alexey)
* Fixkvm.cassert (David)
* Memory fixes and further speedup (me)
* Persistent reservation manager infrastructure (me)
* virtio-serial: addenable_backendcallback (Pavel)
* chardev GMainContext fixes (Peter)
In today's episode of "compiler whinges" we have
/home/pm215/qemu/scsi/qemu-pr-helper.c: In function ‘main’:/home/pm215/qemu/scsi/qemu-pr-helper.c:912:5: error: comparison is always true due to limited range of data type [-Werror=type-limits]
while ((ch = getopt_long(argc, argv, sopt, lopt, &opt_ind)) != -1) {
^(reported by the gcc on my ppc64, s390x, aarch64, aarch32 setups).
This one's a genuine bug, I think: ch is a char, which is unsigned on these systems, and so the loop would never terminate.
thanks
-- PMM
Quoted 30 lines · Peter Maydell
Quoted 16 lines · Paolo Bonzini
The following changes since commit
b62b7ed0fc9c58e373b8946c9bd2e193be98dae6:Merge remote-tracking branch 'remotes/gkurz/tags/for-upstream' into staging (2017-09-20 20:33:48 +0100)
are available in the git repository at:
git://github.com/bonzini/qemu.gittags/for-upstreamfor you to fetch changes up to
8acf7b48e0098198057db048340606c7fbfc6518:chardev: remove context in
chr_update_read_handler(2017-09-22 14:03:27 +0200)v2 fixes some issues with the new qemu-pr-helper. make install and systemd socket activation were broken. I have now backported it to the Fedora QEMU packages to shake out any distro-level issues.
Quoted 7 lines
----------------------------------------------------------------
* Speed up AddressSpaceDispatch creation (Alexey)
* Fixkvm.cassert (David)
* Memory fixes and further speedup (me)
* Persistent reservation manager infrastructure (me)
* virtio-serial: addenable_backendcallback (Pavel)
* chardev GMainContext fixes (Peter)In today's episode of "compiler whinges" we have
/home/pm215/qemu/scsi/qemu-pr-helper.c: In function ‘main’:/home/pm215/qemu/scsi/qemu-pr-helper.c:912:5: error: comparison is always true due to limited range of data type [-Werror=type-limits]
Quoted 7 lines
while ((ch = getopt_long(argc, argv, sopt, lopt, &opt_ind)) != -1) { ^(reported by the gcc on my ppc64, s390x, aarch64, aarch32 setups).
This one's a genuine bug, I think: ch is a char, which is unsigned on these systems, and so the loop would never terminate.
Yes, it is a bug. I copied the line from qemu-nbd, but qemu-nbd has "int ch".
Paolo