Skip to content
Snippets Groups Projects
  1. Sep 21, 2017
    • Paolo Bonzini's avatar
      scsi, file-posix: add support for persistent reservation management · 7c9e5276
      Paolo Bonzini authored
      
      It is a common requirement for virtual machine to send persistent
      reservations, but this currently requires either running QEMU with
      CAP_SYS_RAWIO, or using out-of-tree patches that let an unprivileged
      QEMU bypass Linux's filter on SG_IO commands.
      
      As an alternative mechanism, the next patches will introduce a
      privileged helper to run persistent reservation commands without
      expanding QEMU's attack surface unnecessarily.
      
      The helper is invoked through a "pr-manager" QOM object, to which
      file-posix.c passes SG_IO requests for PERSISTENT RESERVE OUT and
      PERSISTENT RESERVE IN commands.  For example:
      
        $ qemu-system-x86_64
            -device virtio-scsi \
            -object pr-manager-helper,id=helper0,path=/var/run/qemu-pr-helper.sock
            -drive if=none,id=hd,driver=raw,file.filename=/dev/sdb,file.pr-manager=helper0
            -device scsi-block,drive=hd
      
      or:
      
        $ qemu-system-x86_64
            -device virtio-scsi \
            -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
      
      Multiple pr-manager implementations are conceivable and possible, though
      only one is implemented right now.  For example, a pr-manager could:
      
      - talk directly to the multipath daemon from a privileged QEMU
        (i.e. QEMU links to libmpathpersist); this makes reservation work
        properly with multipath, but still requires CAP_SYS_RAWIO
      
      - use the Linux IOC_PR_* ioctls (they require CAP_SYS_ADMIN though)
      
      - more interestingly, implement reservations directly in QEMU
        through file system locks or a shared database (e.g. sqlite)
      
      Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
      7c9e5276
  2. Sep 19, 2017
    • Alistair Francis's avatar
      General warn report fixups · b62e39b4
      Alistair Francis authored
      
      Tidy up some of the warn_report() messages after having converted them
      to use warn_report().
      
      Signed-off-by: default avatarAlistair Francis <alistair.francis@xilinx.com>
      Reviewed-by: default avatarMarkus Armbruster <armbru@redhat.com>
      Message-Id: <9cb1d23551898c9c9a5f84da6773e99871285120.1505158760.git.alistair.francis@xilinx.com>
      Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
      b62e39b4
    • Alistair Francis's avatar
      Convert multi-line fprintf() to warn_report() · 8297be80
      Alistair Francis authored
      
      Convert all the multi-line uses of fprintf(stderr, "warning:"..."\n"...
      to use warn_report() instead. This helps standardise on a single
      method of printing warnings to the user.
      
      All of the warnings were changed using these commands:
        find ./* -type f -exec sed -i \
          'N; {s|fprintf(.*".*warning[,:] \(.*\)\\n"\(.*\));|warn_report("\1"\2);|Ig}' \
          {} +
        find ./* -type f -exec sed -i \
          'N;N; {s|fprintf(.*".*warning[,:] \(.*\)\\n"\(.*\));|warn_report("\1"\2);|Ig}' \
          {} +
        find ./* -type f -exec sed -i \
          'N;N;N; {s|fprintf(.*".*warning[,:] \(.*\)\\n"\(.*\));|warn_report("\1"\2);|Ig}' \
          {} +
        find ./* -type f -exec sed -i \
          'N;N;N;N {s|fprintf(.*".*warning[,:] \(.*\)\\n"\(.*\));|warn_report("\1"\2);|Ig}' \
          {} +
        find ./* -type f -exec sed -i \
          'N;N;N;N;N {s|fprintf(.*".*warning[,:] \(.*\)\\n"\(.*\));|warn_report("\1"\2);|Ig}' \
          {} +
        find ./* -type f -exec sed -i \
          'N;N;N;N;N;N {s|fprintf(.*".*warning[,:] \(.*\)\\n"\(.*\));|warn_report("\1"\2);|Ig}' \
          {} +
        find ./* -type f -exec sed -i \
          'N;N;N;N;N;N;N; {s|fprintf(.*".*warning[,:] \(.*\)\\n"\(.*\));|warn_report("\1"\2);|Ig}' \
          {} +
      
      Indentation fixed up manually afterwards.
      
      Some of the lines were manually edited to reduce the line length to below
      80 charecters. Some of the lines with newlines in the middle of the
      string were also manually edit to avoid checkpatch errrors.
      
      The #include lines were manually updated to allow the code to compile.
      
      Several of the warning messages can be improved after this patch, to
      keep this patch mechanical this has been moved into a later patch.
      
      Signed-off-by: default avatarAlistair Francis <alistair.francis@xilinx.com>
      Cc: Paolo Bonzini <pbonzini@redhat.com>
      Cc: Kevin Wolf <kwolf@redhat.com>
      Cc: Max Reitz <mreitz@redhat.com>
      Cc: "Michael S. Tsirkin" <mst@redhat.com>
      Cc: Igor Mammedov <imammedo@redhat.com>
      Cc: Peter Maydell <peter.maydell@linaro.org>
      Cc: Stefano Stabellini <sstabellini@kernel.org>
      Cc: Anthony Perard <anthony.perard@citrix.com>
      Cc: Richard Henderson <rth@twiddle.net>
      Cc: Eduardo Habkost <ehabkost@redhat.com>
      Cc: Aurelien Jarno <aurelien@aurel32.net>
      Cc: Yongbok Kim <yongbok.kim@imgtec.com>
      Cc: Cornelia Huck <cohuck@redhat.com>
      Cc: Christian Borntraeger <borntraeger@de.ibm.com>
      Cc: Alexander Graf <agraf@suse.de>
      Cc: Jason Wang <jasowang@redhat.com>
      Cc: David Gibson <david@gibson.dropbear.id.au>
      Cc: Gerd Hoffmann <kraxel@redhat.com>
      Acked-by: default avatarCornelia Huck <cohuck@redhat.com>
      Reviewed-by: default avatarMarkus Armbruster <armbru@redhat.com>
      Message-Id: <5def63849ca8f551630c6f2b45bcb1c482f765a6.1505158760.git.alistair.francis@xilinx.com>
      Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
      8297be80
    • Alistair Francis's avatar
      Convert single line fprintf(.../n) to warn_report() · 2ab4b135
      Alistair Francis authored
      
      Convert all the single line uses of fprintf(stderr, "warning:"..."\n"...
      to use warn_report() instead. This helps standardise on a single
      method of printing warnings to the user.
      
      All of the warnings were changed using this command:
        find ./* -type f -exec sed -i \
          's|fprintf(.*".*warning[,:] \(.*\)\\n"\(.*\));|warn_report("\1"\2);|Ig' \
          {} +
      
      Some of the lines were manually edited to reduce the line length to below
      80 charecters.
      
      The #include lines were manually updated to allow the code to compile.
      
      Signed-off-by: default avatarAlistair Francis <alistair.francis@xilinx.com>
      Cc: Kevin Wolf <kwolf@redhat.com>
      Cc: Max Reitz <mreitz@redhat.com>
      Cc: "Michael S. Tsirkin" <mst@redhat.com>
      Cc: Igor Mammedov <imammedo@redhat.com>
      Cc: Paolo Bonzini <pbonzini@redhat.com>
      Cc: Richard Henderson <rth@twiddle.net>
      Cc: Eduardo Habkost <ehabkost@redhat.com>
      Cc: Gerd Hoffmann <kraxel@redhat.com>
      Cc: Jason Wang <jasowang@redhat.com>
      Cc: Michael Roth <mdroth@linux.vnet.ibm.com>
      Cc: James Hogan <james.hogan@imgtec.com>
      Cc: Aurelien Jarno <aurelien@aurel32.net>
      Cc: Yongbok Kim <yongbok.kim@imgtec.com>
      Cc: Stefan Hajnoczi <stefanha@redhat.com>
      Reviewed-by: default avatarMarkus Armbruster <armbru@redhat.com>
      Reviewed-by: James Hogan <james.hogan@imgtec.com> [mips]
      Message-Id: <ae8f8a7f0a88ded61743dff2adade21f8122a9e7.1505158760.git.alistair.francis@xilinx.com>
      Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
      2ab4b135
    • Alistair Francis's avatar
      Convert remaining error_report() to warn_report() · 55d527a9
      Alistair Francis authored
      
      In a previous patch (3dc6f869) we
      converted uses of error_report("warning:"... to use warn_report()
      instead. This was to help standardise on a single method of printing
      warnings to the user.
      
      There appears to have been some cases that slipped through in patch sets
      applied around the same time, this patch catches the few remaining
      cases.
      
      All of the warnings were changed using this command:
        find ./* -type f -exec sed -i \
          's|error_report(".*warning[,:] |warn_report("|Ig' {} +
      
      Indentation fixed up manually afterwards.
      
      Two messages were manually fixed up as well.
      
      Signed-off-by: default avatarAlistair Francis <alistair.francis@xilinx.com>
      Cc: Kevin Wolf <kwolf@redhat.com>
      Cc: Max Reitz <mreitz@redhat.com>
      Cc: Christian Borntraeger <borntraeger@de.ibm.com>
      Cc: Cornelia Huck <cohuck@redhat.com>
      Cc: Alexander Graf <agraf@suse.de>
      Cc: Richard Henderson <rth@twiddle.net>
      Cc: Stefan Hajnoczi <stefanha@redhat.com>
      Acked-by: default avatarCornelia Huck <cohuck@redhat.com>
      Reviewed-by: default avatarMarkus Armbruster <armbru@redhat.com>
      Message-Id: <eec8cba0d5434bd828639e5e45f12182490ff47d.1505158760.git.alistair.francis@xilinx.com>
      Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
      55d527a9
    • Paolo Bonzini's avatar
      scsi: move block/scsi.h to include/scsi/constants.h · 08e2c9f1
      Paolo Bonzini authored
      
      Complete the transition by renaming this header, which was
      shared by block/iscsi.c and the SCSI emulation code.
      
      Reviewed-by: default avatarPhilippe Mathieu-Daudé <f4bug@amsat.org>
      Reviewed-by: default avatarStefan Hajnoczi <stefanha@redhat.com>
      Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
      08e2c9f1
    • Paolo Bonzini's avatar
      scsi: move non-emulation specific code to scsi/ · e5b5728c
      Paolo Bonzini authored
      
      util/scsi.c includes some SCSI code that is shared by block/iscsi.c and
      hw/scsi, but the introduction of the persistent reservation helper
      will add many more instances of this.  There is also include/block/scsi.h,
      which actually is not part of the core block layer.
      
      The persistent reservation manager will also need a home.  A scsi/
      directory provides one for both the aforementioned shared code and
      the PR manager code.
      
      Reviewed-by: default avatarPhilippe Mathieu-Daudé <f4bug@amsat.org>
      Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
      e5b5728c
    • Fam Zheng's avatar
      scsi: Refactor scsi sense interpreting code · 28751358
      Fam Zheng authored
      
      So that it can be reused outside of iscsi.c.
      
      Also update MAINTAINERS to include the new files in SCSI section.
      
      Signed-off-by: default avatarFam Zheng <famz@redhat.com>
      Message-Id: <20170821141008.19383-2-famz@redhat.com>
      Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
      28751358
  3. Sep 06, 2017
  4. Sep 05, 2017
  5. Sep 04, 2017
  6. Aug 31, 2017
  7. Aug 30, 2017
    • Vladimir Sementsov-Ogievskiy's avatar
      block/nbd-client: refactor request send/receive · f35dff7e
      Vladimir Sementsov-Ogievskiy authored
      
      Add nbd_co_request, to remove code duplications in
      nbd_client_co_{pwrite,pread,...} functions. Also this is
      needed for further refactoring.
      
      Signed-off-by: default avatarVladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
      Message-Id: <20170804151440.320927-8-vsementsov@virtuozzo.com>
      [eblake: make nbd_co_request a wrapper, rather than merging two
      existing functions]
      Signed-off-by: default avatarEric Blake <eblake@redhat.com>
      f35dff7e
    • Vladimir Sementsov-Ogievskiy's avatar
      block/nbd-client: rename nbd_recv_coroutines_enter_all · 07b1b99c
      Vladimir Sementsov-Ogievskiy authored
      
      Rename nbd_recv_coroutines_enter_all to nbd_recv_coroutines_wake_all,
      as it most probably just adds all recv coroutines into co_queue_wakeup,
      rather than directly enter them.
      
      Signed-off-by: default avatarVladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
      Message-Id: <20170804151440.320927-9-vsementsov@virtuozzo.com>
      [eblake: tweak commit message]
      Signed-off-by: default avatarEric Blake <eblake@redhat.com>
      07b1b99c
    • Vladimir Sementsov-Ogievskiy's avatar
      block/nbd-client: get rid of ssize_t · 6faa0777
      Vladimir Sementsov-Ogievskiy authored
      
      Use int variable for nbd_co_send_request return value (as
      nbd_co_send_request returns int).
      
      Signed-off-by: default avatarVladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
      Message-Id: <20170804151440.320927-6-vsementsov@virtuozzo.com>
      Signed-off-by: default avatarEric Blake <eblake@redhat.com>
      6faa0777
    • Stefan Hajnoczi's avatar
      nbd-client: avoid read_reply_co entry if send failed · 3c2d5183
      Stefan Hajnoczi authored
      
      The following segfault is encountered if the NBD server closes the UNIX
      domain socket immediately after negotiation:
      
        Program terminated with signal SIGSEGV, Segmentation fault.
        #0  aio_co_schedule (ctx=0x0, co=0xd3c0ff2ef0) at util/async.c:441
        441       QSLIST_INSERT_HEAD_ATOMIC(&ctx->scheduled_coroutines,
        (gdb) bt
        #0  0x000000d3c01a50f8 in aio_co_schedule (ctx=0x0, co=0xd3c0ff2ef0) at util/async.c:441
        #1  0x000000d3c012fa90 in nbd_coroutine_end (bs=bs@entry=0xd3c0fec650, request=<optimized out>) at block/nbd-client.c:207
        #2  0x000000d3c012fb58 in nbd_client_co_preadv (bs=0xd3c0fec650, offset=0, bytes=<optimized out>, qiov=0x7ffc10a91b20, flags=0) at block/nbd-client.c:237
        #3  0x000000d3c0128e63 in bdrv_driver_preadv (bs=bs@entry=0xd3c0fec650, offset=offset@entry=0, bytes=bytes@entry=512, qiov=qiov@entry=0x7ffc10a91b20, flags=0) at block/io.c:836
        #4  0x000000d3c012c3e0 in bdrv_aligned_preadv (child=child@entry=0xd3c0ff51d0, req=req@entry=0x7f31885d6e90, offset=offset@entry=0, bytes=bytes@entry=512, align=align@entry=1, qiov=qiov@entry=0x7ffc10a91b20, f
      +lags=0) at block/io.c:1086
        #5  0x000000d3c012c6b8 in bdrv_co_preadv (child=0xd3c0ff51d0, offset=offset@entry=0, bytes=bytes@entry=512, qiov=qiov@entry=0x7ffc10a91b20, flags=flags@entry=0) at block/io.c:1182
        #6  0x000000d3c011cc17 in blk_co_preadv (blk=0xd3c0ff4f80, offset=0, bytes=512, qiov=0x7ffc10a91b20, flags=0) at block/block-backend.c:1032
        #7  0x000000d3c011ccec in blk_read_entry (opaque=0x7ffc10a91b40) at block/block-backend.c:1079
        #8  0x000000d3c01bbb96 in coroutine_trampoline (i0=<optimized out>, i1=<optimized out>) at util/coroutine-ucontext.c:79
        #9  0x00007f3196cb8600 in __start_context () at /lib64/libc.so.6
      
      The problem is that nbd_client_init() uses
      nbd_client_attach_aio_context() -> aio_co_schedule(new_context,
      client->read_reply_co).  Execution of read_reply_co is deferred to a BH
      which doesn't run until later.
      
      In the mean time blk_co_preadv() can be called and nbd_coroutine_end()
      calls aio_wake() on read_reply_co.  At this point in time
      read_reply_co's ctx isn't set because it has never been entered yet.
      
      This patch simplifies the nbd_co_send_request() ->
      nbd_co_receive_reply() -> nbd_coroutine_end() lifecycle to just
      nbd_co_send_request() -> nbd_co_receive_reply().  The request is "ended"
      if an error occurs at any point.  Callers no longer have to invoke
      nbd_coroutine_end().
      
      This cleanup also eliminates the segfault because we don't call
      aio_co_schedule() to wake up s->read_reply_co if sending the request
      failed.  It is only necessary to wake up s->read_reply_co if a reply was
      received.
      
      Note this only happens with UNIX domain sockets on Linux.  It doesn't
      seem possible to reproduce this with TCP sockets.
      
      Suggested-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
      Signed-off-by: default avatarStefan Hajnoczi <stefanha@redhat.com>
      Message-Id: <20170829122745.14309-2-stefanha@redhat.com>
      Signed-off-by: default avatarEric Blake <eblake@redhat.com>
      3c2d5183
    • Stefan Hajnoczi's avatar
      qcow2: allocate cluster_cache/cluster_data on demand · 3e4c7052
      Stefan Hajnoczi authored
      
      Most qcow2 files are uncompressed so it is wasteful to allocate (32 + 1)
      * cluster_size + 512 bytes upfront.  Allocate s->cluster_cache and
      s->cluster_data when the first read operation is performance on a
      compressed cluster.
      
      The buffers are freed in .bdrv_close().  .bdrv_open() no longer has any
      code paths that can allocate these buffers, so remove the free functions
      in the error code path.
      
      This patch can result in significant memory savings when many qcow2
      disks are attached or backing file chains are long:
      
      Before 12.81% (1,023,193,088B)
      After   5.36% (393,893,888B)
      
      Reported-by: default avatarAlexey Kardashevskiy <aik@ozlabs.ru>
      Tested-by: default avatarAlexey Kardashevskiy <aik@ozlabs.ru>
      Reviewed-by: default avatarEric Blake <eblake@redhat.com>
      Signed-off-by: default avatarStefan Hajnoczi <stefanha@redhat.com>
      Message-id: 20170821135530.32344-1-stefanha@redhat.com
      Cc: Kevin Wolf <kwolf@redhat.com>
      Signed-off-by: default avatarStefan Hajnoczi <stefanha@redhat.com>
      3e4c7052
    • Alberto Garcia's avatar
      misc: Remove unused Error variables · c3a8fe33
      Alberto Garcia authored
      
      There's a few cases which we're passing an Error pointer to a function
      only to discard it immediately afterwards without checking it. In
      these cases we can simply remove the variable and pass NULL instead.
      
      Signed-off-by: default avatarAlberto Garcia <berto@igalia.com>
      Reviewed-by: default avatarPhilippe Mathieu-Daudé <f4bug@amsat.org>
      Reviewed-by: default avatarEric Blake <eblake@redhat.com>
      Message-id: 20170829120836.16091-1-berto@igalia.com
      Signed-off-by: default avatarStefan Hajnoczi <stefanha@redhat.com>
      c3a8fe33
  8. Aug 23, 2017
Loading