Skip to content
Snippets Groups Projects
  1. Jun 29, 2021
  2. Mar 19, 2021
  3. Feb 12, 2021
    • Eric Blake's avatar
      qemu-nbd: Permit --shared=0 for unlimited clients · 3dcf56e6
      Eric Blake authored
      
      This gives us better feature parity with QMP nbd-server-start, where
      max-connections defaults to 0 for unlimited.
      
      Signed-off-by: default avatarEric Blake <eblake@redhat.com>
      Message-Id: <20210209152759.209074-3-eblake@redhat.com>
      Reviewed-by: default avatarDaniel P. Berrangé <berrange@redhat.com>
      3dcf56e6
    • Eric Blake's avatar
      qemu-nbd: Use SOMAXCONN for socket listen() backlog · 582d4210
      Eric Blake authored
      Our default of a backlog of 1 connection is rather puny; it gets in
      the way when we are explicitly allowing multiple clients (such as
      qemu-nbd -e N [--shared], or nbd-server-start with its default
      "max-connections":0 for unlimited), but is even a problem when we
      stick to qemu-nbd's default of only 1 active client but use -t
      [--persistent] where a second client can start using the server once
      the first finishes.  While the effects are less noticeable on TCP
      sockets (since the client can poll() to learn when the server is ready
      again), it is definitely observable on Unix sockets, where on Linux, a
      client will fail with EAGAIN and no recourse but to sleep an arbitrary
      amount of time before retrying if the server backlog is already full.
      
      Since QMP nbd-server-start is always persistent, it now always
      requests a backlog of SOMAXCONN; meanwhile, qemu-nbd will request
      SOMAXCONN if persistent, otherwise its backlog should be based on the
      expected number of clients.
      
      See https://bugzilla.redhat.com/1925045
      
       for a demonstration of where
      our low backlog prevents libnbd from connecting as many parallel
      clients as it wants.
      
      Reported-by: default avatarRichard W.M. Jones <rjones@redhat.com>
      Signed-off-by: default avatarEric Blake <eblake@redhat.com>
      CC: qemu-stable@nongnu.org
      Message-Id: <20210209152759.209074-2-eblake@redhat.com>
      Tested-by: default avatarRichard W.M. Jones <rjones@redhat.com>
      Reviewed-by: default avatarDaniel P. Berrangé <berrange@redhat.com>
      Signed-off-by: default avatarEric Blake <eblake@redhat.com>
      582d4210
  4. Feb 02, 2021
  5. Jan 20, 2021
  6. Nov 11, 2020
  7. Oct 30, 2020
    • Eric Blake's avatar
      nbd: Add 'qemu-nbd -A' to expose allocation depth · dbc7b014
      Eric Blake authored
      
      Allow the server to expose an additional metacontext to be requested
      by savvy clients.  qemu-nbd adds a new option -A to expose the
      qemu:allocation-depth metacontext through NBD_CMD_BLOCK_STATUS; this
      can also be set via QMP when using block-export-add.
      
      qemu as client is hacked into viewing the key aspects of this new
      context by abusing the already-experimental x-dirty-bitmap option to
      collapse all depths greater than 2, which results in a tri-state value
      visible in the output of 'qemu-img map --output=json' (yes, that means
      x-dirty-bitmap is now a bit of a misnomer, but I didn't feel like
      renaming it as it would introduce a needless break of back-compat,
      even though we make no compat guarantees with x- members):
      
      unallocated (depth 0) => "zero":false, "data":true
      local (depth 1)       => "zero":false, "data":false
      backing (depth 2+)    => "zero":true,  "data":true
      
      libnbd as client is probably a nicer way to get at the information
      without having to decipher such hacks in qemu as client. ;)
      
      Signed-off-by: default avatarEric Blake <eblake@redhat.com>
      Message-Id: <20201027050556.269064-11-eblake@redhat.com>
      Reviewed-by: default avatarVladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
      dbc7b014
    • Eric Blake's avatar
      nbd: Update qapi to support exporting multiple bitmaps · cbad81ce
      Eric Blake authored
      
      Since 'block-export-add' is new to 5.2, we can still tweak the
      interface; there, allowing 'bitmaps':['str'] is nicer than
      'bitmap':'str'.  This wires up the qapi and qemu-nbd changes to permit
      passing multiple bitmaps as distinct metadata contexts that the NBD
      client may request, but the actual support for more than one will
      require a further patch to the server.
      
      Note that there are no changes made to the existing deprecated
      'nbd-server-add' command; this required splitting the QAPI type
      BlockExportOptionsNbd, which fortunately does not affect QMP
      introspection.
      
      Signed-off-by: default avatarEric Blake <eblake@redhat.com>
      Message-Id: <20201027050556.269064-5-eblake@redhat.com>
      Reviewed-by: default avatarVladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
      Reviewed-by: default avatarPeter Krempa <pkrempa@redhat.com>
      cbad81ce
  8. Oct 23, 2020
    • Stefan Hajnoczi's avatar
      block: move block exports to libblockdev · cbc20bfb
      Stefan Hajnoczi authored
      
      Block exports are used by softmmu, qemu-storage-daemon, and qemu-nbd.
      They are not used by other programs and are not otherwise needed in
      libblock.
      
      Undo the recent move of blockdev-nbd.c from blockdev_ss into block_ss.
      Since bdrv_close_all() (libblock) calls blk_exp_close_all()
      (libblockdev) a stub function is required..
      
      Make qemu-nbd.c use signal handling utility functions instead of
      duplicating the code. This helps because os-posix.c is in libblockdev
      and it depends on a qemu_system_killed() symbol that qemu-nbd.c lacks.
      Once we use the signal handling utility functions we also end up
      providing the necessary symbol.
      
      Signed-off-by: default avatarStefan Hajnoczi <stefanha@redhat.com>
      Reviewed-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
      Reviewed-by: default avatarEric Blake <eblake@redhat.com>
      Message-id: 20200929125516.186715-4-stefanha@redhat.com
      [Fixed s/ndb/nbd/ typo in commit description as suggested by Eric Blake
      --Stefan]
      Signed-off-by: default avatarStefan Hajnoczi <stefanha@redhat.com>
      cbc20bfb
  9. Oct 09, 2020
  10. Oct 02, 2020
  11. Sep 23, 2020
    • Stefan Hajnoczi's avatar
      qemu/atomic.h: rename atomic_ to qatomic_ · d73415a3
      Stefan Hajnoczi authored
      
      clang's C11 atomic_fetch_*() functions only take a C11 atomic type
      pointer argument. QEMU uses direct types (int, etc) and this causes a
      compiler error when a QEMU code calls these functions in a source file
      that also included <stdatomic.h> via a system header file:
      
        $ CC=clang CXX=clang++ ./configure ... && make
        ../util/async.c:79:17: error: address argument to atomic operation must be a pointer to _Atomic type ('unsigned int *' invalid)
      
      Avoid using atomic_*() names in QEMU's atomic.h since that namespace is
      used by <stdatomic.h>. Prefix QEMU's APIs with 'q' so that atomic.h
      and <stdatomic.h> can co-exist. I checked /usr/include on my machine and
      searched GitHub for existing "qatomic_" users but there seem to be none.
      
      This patch was generated using:
      
        $ git grep -h -o '\<atomic\(64\)\?_[a-z0-9_]\+' include/qemu/atomic.h | \
          sort -u >/tmp/changed_identifiers
        $ for identifier in $(</tmp/changed_identifiers); do
              sed -i "s%\<$identifier\>%q$identifier%g" \
                  $(git grep -I -l "\<$identifier\>")
          done
      
      I manually fixed line-wrap issues and misaligned rST tables.
      
      Signed-off-by: default avatarStefan Hajnoczi <stefanha@redhat.com>
      Reviewed-by: default avatarPhilippe Mathieu-Daudé <philmd@redhat.com>
      Acked-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
      Message-Id: <20200923105646.47864-1-stefanha@redhat.com>
      d73415a3
  12. Sep 02, 2020
  13. May 27, 2020
  14. May 18, 2020
  15. Feb 05, 2020
  16. Jan 30, 2020
  17. Nov 18, 2019
    • Eric Blake's avatar
      nbd: Don't send oversize strings · 93676c88
      Eric Blake authored
      
      Qemu as server currently won't accept export names larger than 256
      bytes, nor create dirty bitmap names longer than 1023 bytes, so most
      uses of qemu as client or server have no reason to get anywhere near
      the NBD spec maximum of a 4k limit per string.
      
      However, we weren't actually enforcing things, ignoring when the
      remote side violates the protocol on input, and also having several
      code paths where we send oversize strings on output (for example,
      qemu-nbd --description could easily send more than 4k).  Tighten
      things up as follows:
      
      client:
      - Perform bounds check on export name and dirty bitmap request prior
        to handing it to server
      - Validate that copied server replies are not too long (ignoring
        NBD_INFO_* replies that are not copied is not too bad)
      server:
      - Perform bounds check on export name and description prior to
        advertising it to client
      - Reject client name or metadata query that is too long
      - Adjust things to allow full 4k name limit rather than previous
        256 byte limit
      
      Signed-off-by: default avatarEric Blake <eblake@redhat.com>
      Message-Id: <20191114024635.11363-4-eblake@redhat.com>
      Reviewed-by: default avatarMaxim Levitsky <mlevitsk@redhat.com>
      Reviewed-by: default avatarVladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
      93676c88
  18. Oct 14, 2019
  19. Sep 05, 2019
    • Eric Blake's avatar
      nbd: Prepare for NBD_CMD_FLAG_FAST_ZERO · 0a479545
      Eric Blake authored
      
      Commit fe0480d6 and friends added BDRV_REQ_NO_FALLBACK as a way to
      avoid wasting time on a preliminary write-zero request that will later
      be rewritten by actual data, if it is known that the write-zero
      request will use a slow fallback; but in doing so, could not optimize
      for NBD.  The NBD specification is now considering an extension that
      will allow passing on those semantics; this patch updates the new
      protocol bits and 'qemu-nbd --list' output to recognize the bit, as
      well as the new errno value possible when using the new flag; while
      upcoming patches will improve the client to use the feature when
      present, and the server to advertise support for it.
      
      The NBD spec recommends (but not requires) that ENOTSUP be avoided for
      all but failures of a fast zero (the only time it is mandatory to
      avoid an ENOTSUP failure is when fast zero is supported but not
      requested during write zeroes; the questionable use is for ENOTSUP to
      other actions like a normal write request).  However, clients that get
      an unexpected ENOTSUP will either already be treating it the same as
      EINVAL, or may appreciate the extra bit of information.  We were
      equally loose for returning EOVERFLOW in more situations than
      recommended by the spec, so if it turns out to be a problem in
      practice, a later patch can tighten handling for both error codes.
      
      Signed-off-by: default avatarEric Blake <eblake@redhat.com>
      Message-Id: <20190823143726.27062-3-eblake@redhat.com>
      Reviewed-by: default avatarVladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
      [eblake: tweak commit message, also handle EOPNOTSUPP]
      0a479545
    • Eric Blake's avatar
      nbd: Improve per-export flag handling in server · dbb38caa
      Eric Blake authored
      
      When creating a read-only image, we are still advertising support for
      TRIM and WRITE_ZEROES to the client, even though the client should not
      be issuing those commands.  But seeing this requires looking across
      multiple functions:
      
      All callers to nbd_export_new() passed a single flag based solely on
      whether the export allows writes.  Later, we then pass a constant set
      of flags to nbd_negotiate_options() (namely, the set of flags which we
      always support, at least for writable images), which is then further
      dynamically modified with NBD_FLAG_SEND_DF based on client requests
      for structured options.  Finally, when processing NBD_OPT_EXPORT_NAME
      or NBD_OPT_EXPORT_GO we bitwise-or the original caller's flag with the
      runtime set of flags we've built up over several functions.
      
      Let's refactor things to instead compute a baseline of flags as soon
      as possible which gets shared between multiple clients, in
      nbd_export_new(), and changing the signature for the callers to pass
      in a simpler bool rather than having to figure out flags.  We can then
      get rid of the 'myflags' parameter to various functions, and instead
      refer to client for everything we need (we still have to perform a
      bitwise-OR for NBD_FLAG_SEND_DF during NBD_OPT_EXPORT_NAME and
      NBD_OPT_EXPORT_GO, but it's easier to see what is being computed).
      This lets us quit advertising senseless flags for read-only images, as
      well as making the next patch for exposing FAST_ZERO support easier to
      write.
      
      Signed-off-by: default avatarEric Blake <eblake@redhat.com>
      Message-Id: <20190823143726.27062-2-eblake@redhat.com>
      Reviewed-by: default avatarVladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
      [eblake: improve commit message, update iotest 223]
      dbb38caa
    • Eric Blake's avatar
      nbd: Advertise multi-conn for shared read-only connections · 61cc8724
      Eric Blake authored
      The NBD specification defines NBD_FLAG_CAN_MULTI_CONN, which can be
      advertised when the server promises cache consistency between
      simultaneous clients (basically, rules that determine what FUA and
      flush from one client are able to guarantee for reads from another
      client).  When we don't permit simultaneous clients (such as qemu-nbd
      without -e), the bit makes no sense; and for writable images, we
      probably have a lot more work before we can declare that actions from
      one client are cache-consistent with actions from another.  But for
      read-only images, where flush isn't changing any data, we might as
      well advertise multi-conn support.  What's more, advertisement of the
      bit makes it easier for clients to determine if 'qemu-nbd -e' was in
      use, where a second connection will succeed rather than hang until the
      first client goes away.
      
      This patch affects qemu as server in advertising the bit.  We may want
      to consider patches to qemu as client to attempt parallel connections
      for higher throughput by spreading the load over those connections
      when a server advertises multi-conn, but for now sticking to one
      connection per nbd:// BDS is okay.
      
      See also: https://bugzilla.redhat.com/1708300
      
      
      Signed-off-by: default avatarEric Blake <eblake@redhat.com>
      Message-Id: <20190815185024.7010-1-eblake@redhat.com>
      [eblake: tweak blockdev-nbd.c to not request shared when writable,
      fix iotest 233]
      Reviewed-by: default avatarJohn Snow <jsnow@redhat.com>
      61cc8724
  20. Sep 03, 2019
  21. Aug 15, 2019
  22. Jun 13, 2019
  23. Jun 12, 2019
    • Markus Armbruster's avatar
      Include qemu-common.h exactly where needed · a8d25326
      Markus Armbruster authored
      
      No header includes qemu-common.h after this commit, as prescribed by
      qemu-common.h's file comment.
      
      Signed-off-by: default avatarMarkus Armbruster <armbru@redhat.com>
      Message-Id: <20190523143508.25387-5-armbru@redhat.com>
      [Rebased with conflicts resolved automatically, except for
      include/hw/arm/xlnx-zynqmp.h hw/arm/nrf51_soc.c hw/arm/msf2-soc.c
      block/qcow2-refcount.c block/qcow2-cluster.c block/qcow2-cache.c
      target/arm/cpu.h target/lm32/cpu.h target/m68k/cpu.h target/mips/cpu.h
      target/moxie/cpu.h target/nios2/cpu.h target/openrisc/cpu.h
      target/riscv/cpu.h target/tilegx/cpu.h target/tricore/cpu.h
      target/unicore32/cpu.h target/xtensa/cpu.h; bsd-user/main.c and
      net/tap-bsd.c fixed up]
      a8d25326
    • Markus Armbruster's avatar
      Include qemu/module.h where needed, drop it from qemu-common.h · 0b8fa32f
      Markus Armbruster authored
      
      Signed-off-by: default avatarMarkus Armbruster <armbru@redhat.com>
      Message-Id: <20190523143508.25387-4-armbru@redhat.com>
      [Rebased with conflicts resolved automatically, except for
      hw/usb/dev-hub.c hw/misc/exynos4210_rng.c hw/misc/bcm2835_rng.c
      hw/misc/aspeed_scu.c hw/display/virtio-vga.c hw/arm/stm32f205_soc.c;
      ui/cocoa.m fixed up]
      0b8fa32f
  24. Jun 11, 2019
    • Markus Armbruster's avatar
      qemu-common: Move tcg_enabled() etc. to sysemu/tcg.h · 14a48c1d
      Markus Armbruster authored
      
      Other accelerators have their own headers: sysemu/hax.h, sysemu/hvf.h,
      sysemu/kvm.h, sysemu/whpx.h.  Only tcg_enabled() & friends sit in
      qemu-common.h.  This necessitates inclusion of qemu-common.h into
      headers, which is against the rules spelled out in qemu-common.h's
      file comment.
      
      Move tcg_enabled() & friends into their own header sysemu/tcg.h, and
      adjust #include directives.
      
      Cc: Richard Henderson <rth@twiddle.net>
      Cc: Paolo Bonzini <pbonzini@redhat.com>
      Signed-off-by: default avatarMarkus Armbruster <armbru@redhat.com>
      Message-Id: <20190523143508.25387-2-armbru@redhat.com>
      Reviewed-by: default avatarRichard Henderson <richard.henderson@linaro.org>
      [Rebased with conflicts resolved automatically, except for
      accel/tcg/tcg-all.c]
      14a48c1d
Loading