Skip to content
Snippets Groups Projects
  1. Apr 28, 2022
  2. Apr 27, 2022
  3. Apr 26, 2022
    • Richard Henderson's avatar
      Merge tag 'pull-nbd-2022-04-26' of https://repo.or.cz/qemu/ericb into staging · a72d9008
      Richard Henderson authored
      nbd patches for 2022-04-26
      
      - Paolo Bonzini: thread-safety improvements to NBD client
      - Vladimir Sementsov-Ogievsky: finer-grained selection of bitmaps during
        nbd-export
      
      # -----BEGIN PGP SIGNATURE-----
      #
      # iQEzBAABCAAdFiEEccLMIrHEYCkn0vOqp6FrSiUnQ2oFAmJoUhAACgkQp6FrSiUn
      # Q2qnpgf/YCuONdwAndjEo7he5c1BfB/F2sujQJJ00CebUqnz5OFKQ85RwLC8DCGB
      # rXnxqC/NF4yyYM+6uYWDpggDd0bJVKbfG7NE/AZsEZrK+n9xMkvGLRwGqMugUii+
      # Px4Ba98++0giqGoAI8pU/wQZNh1I6uGabv/DPRTpwzBjbfAcATqV09OzaGiK3SRC
      # Zm/55zmXm1zM4XSUtUzN1gILPG09P+51m6NVkANZbzps9e2PtfFy8EsWc5+YhuBM
      # 5K7sN+5g8GpRhz6j8RkrhrbNpvg3bGvgRJRMcW7Bo8KVUdvT1Jng6xs8CIRv39AF
      # jDJwGe+cq5p5PNuyqOrVSA/ynBZxBw==
      # =I1yM
      # -----END PGP SIGNATURE-----
      # gpg: Signature made Tue 26 Apr 2022 01:12:00 PM PDT
      # gpg:                using RSA key 71C2CC22B1C4602927D2F3AAA7A16B4A2527436A
      # gpg: Good signature from "Eric Blake <eblake@redhat.com>" [full]
      # gpg:                 aka "Eric Blake (Free Software Programmer) <ebb9@byu.net>" [full]
      # gpg:                 aka "[jpeg image of size 6874]" [full]
      
      * tag 'pull-nbd-2022-04-26' of https://repo.or.cz/qemu/ericb
      
      :
        nbd: document what is protected by the CoMutexes
        nbd: take receive_mutex when reading requests[].receiving
        nbd: move s->state under requests_lock
        nbd: code motion and function renaming
        nbd: use a QemuMutex to synchronize yanking, reconnection and coroutines
        nbd: keep send_mutex/free_sema handling outside nbd_co_do_establish_connection
        nbd: remove peppering of nbd_client_connected
        nbd: mark more coroutine_fns
        nbd: safeguard against waking up invalid coroutine
        iotests/223: check new possibility of exporting bitmaps by node/name
        qapi: nbd-export: allow select bitmaps by node/name pair
        qapi: rename BlockDirtyBitmapMergeSource to BlockDirtyBitmapOrStr
      
      Signed-off-by: default avatarRichard Henderson <richard.henderson@linaro.org>
      a72d9008
    • Richard Henderson's avatar
      Merge tag 'pull-nios2-20220426' of https://gitlab.com/rth7680/qemu into staging · 88d5814e
      Richard Henderson authored
      Fix nios2-linux-user syscalls.
      Fix nios2-linux-user sigreturn.
      Enable tests for nios2-linux-user.
      Remove special handling of SIGSEGV.
      Check supervisor for eret, bret.
      Split special registers out of env->regs[].
      Clean up interrupt processing.
      Raise unaligned data and destination exceptions.
      Set TLBMISC fields correctly on exceptions.
      Prevent writes to read-only or reserved control fields.
      Use tcg_constant_tl().
      Implement shadow register sets.
      Implement external interrupt controller interface.
      Implement vectored interrupt controller.
      Enable semihosting tests for nios2-softmmu.
      
      # -----BEGIN PGP SIGNATURE-----
      #
      # iQFRBAABCgA7FiEEekgeeIaLTbaoWgXAZN846K9+IV8FAmJoNuQdHHJpY2hhcmQu
      # aGVuZGVyc29uQGxpbmFyby5vcmcACgkQZN846K9+IV+a0ggAhawc3tod4OTHRlRq
      # rvZrJK740bNMo8rtidDnh71+IGjBiz8pXahqkE78cADtMzNmQoScwWbjht3cuMN2
      # TMV0sbNDeA2OB98QzX6JTbCRtEfQAB7pyjpFvg6oXhYYSfwwhWbTR9QsYTHjq157
      # ZKOprafoSlmDlgWJhlAikLdvJb07/5jgmvsLbBzu8/G/HiJ4HhHyjZxL1wNz1t/+
      # 0KTAbnn3SWGDAhLGS/P6BMZKeU1EAExAwo7CtZeUbs+9QCfeM3cBAurG3WB1Vw14
      # ERPoGPPrARtoNPtgQFMHu0am3HH5HtneuzJfWaLT96rrwNyTrYY0EYti1NtFDW8O
      # CCz42Q==
      # =MHar
      # -----END PGP SIGNATURE-----
      # gpg: Signature made Tue 26 Apr 2022 11:16:04 AM PDT
      # gpg:                using RSA key 7A481E78868B4DB6A85A05C064DF38E8AF7E215F
      # gpg:                issuer "richard.henderson@linaro.org"
      # gpg: Good signature from "Richard Henderson <richard.henderson@linaro.org>" [ultimate]
      
      * tag 'pull-nios2-20220426' of https://gitlab.com/rth7680/qemu
      
      : (68 commits)
        tests/tcg/nios2: Add test-shadow-1
        tests/tcg/nios2: Add semihosting multiarch tests
        hw/nios2: Machine with a Vectored Interrupt Controller
        hw/nios2: Move memory regions into Nios2Machine
        hw/nios2: Introduce Nios2MachineState
        hw/intc: Vectored Interrupt Controller (VIC)
        linux-user/nios2: Handle various SIGILL exceptions
        target/nios2: Advance pc when raising exceptions
        target/nios2: Implement EIC interrupt processing
        target/nios2: Update helper_eret for shadow registers
        target/nios2: Implement rdprs, wrprs
        target/nios2: Introduce shadow register sets
        target/nios2: Implement Misaligned destination exception
        target/nios2: Use tcg_gen_lookup_and_goto_ptr
        target/nios2: Use gen_goto_tb for DISAS_TOO_MANY
        target/nios2: Hoist set of is_jmp into gen_goto_tb
        target/nios2: Create gen_jumpr
        target/nios2: Enable unaligned traps for system mode
        target/nios2: Drop CR_STATUS_EH from tb->flags
        target/nios2: Introduce dest_gpr
        ...
      
      Signed-off-by: default avatarRichard Henderson <richard.henderson@linaro.org>
      88d5814e
    • Paolo Bonzini's avatar
      nbd: document what is protected by the CoMutexes · 620c5cb5
      Paolo Bonzini authored
      
      Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
      Message-Id: <20220414175756.671165-10-pbonzini@redhat.com>
      Reviewed-by: default avatarEric Blake <eblake@redhat.com>
      Reviewed-by: default avatarLukas Straub <lukasstraub2@web.de>
      Signed-off-by: default avatarEric Blake <eblake@redhat.com>
      620c5cb5
    • Paolo Bonzini's avatar
      nbd: take receive_mutex when reading requests[].receiving · a80a9a1c
      Paolo Bonzini authored
      
      requests[].receiving is set by nbd_receive_replies() under the receive_mutex;
      Read it under the same mutex as well.  Waking up receivers on errors happens
      after each reply finishes processing, in nbd_co_receive_one_chunk().
      If there is no currently-active reply, there are two cases:
      
      * either there is no active request at all, in which case no
      element of request[] can have .receiving = true
      
      * or nbd_receive_replies() must be running and owns receive_mutex;
      in that case it will get back to nbd_co_receive_one_chunk() because
      the socket has been shutdown, and all waiting coroutines will wake up
      in turn.
      
      Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
      Message-Id: <20220414175756.671165-9-pbonzini@redhat.com>
      Reviewed-by: default avatarEric Blake <eblake@redhat.com>
      Reviewed-by: default avatarVladimir Sementsov-Ogievskiy <vsementsov@openvz.org>
      Reviewed-by: default avatarLukas Straub <lukasstraub2@web.de>
      Signed-off-by: default avatarEric Blake <eblake@redhat.com>
      a80a9a1c
    • Paolo Bonzini's avatar
      nbd: move s->state under requests_lock · dba5156c
      Paolo Bonzini authored
      
      Remove the confusing, and most likely wrong, atomics.  The only function
      that used to be somewhat in a hot path was nbd_client_connected(),
      but it is not anymore after the previous patches.
      
      The same logic is used both to check if a request had to be reissued
      and also in nbd_reconnecting_attempt().  The former cases are outside
      requests_lock, while nbd_reconnecting_attempt() does have the lock,
      therefore the two have been separated in the previous commit.
      nbd_client_will_reconnect() can simply take s->requests_lock, while
      nbd_reconnecting_attempt() can inline the access now that no
      complicated atomics are involved.
      
      Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
      Message-Id: <20220414175756.671165-8-pbonzini@redhat.com>
      Reviewed-by: default avatarEric Blake <eblake@redhat.com>
      Reviewed-by: default avatarVladimir Sementsov-Ogievskiy <vsementsov@openvz.org>
      Reviewed-by: default avatarLukas Straub <lukasstraub2@web.de>
      Signed-off-by: default avatarEric Blake <eblake@redhat.com>
      dba5156c
    • Paolo Bonzini's avatar
      nbd: code motion and function renaming · 8d45185c
      Paolo Bonzini authored
      
      Prepare for the next patch, so that the diff is less confusing.
      
      nbd_client_connecting is moved closer to the definition point.
      
      nbd_client_connecting_wait() is kept only for the reconnection
      logic; when it is used to check if a request has to be reissued,
      use the renamed function nbd_client_will_reconnect().  In the
      next patch, the two cases will have different locking requirements.
      
      Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
      Message-Id: <20220414175756.671165-7-pbonzini@redhat.com>
      Reviewed-by: default avatarEric Blake <eblake@redhat.com>
      Reviewed-by: default avatarVladimir Sementsov-Ogievskiy <vsementsov@openvz.org>
      Reviewed-by: default avatarLukas Straub <lukasstraub2@web.de>
      Signed-off-by: default avatarEric Blake <eblake@redhat.com>
      8d45185c
    • Paolo Bonzini's avatar
      nbd: use a QemuMutex to synchronize yanking, reconnection and coroutines · ee19d953
      Paolo Bonzini authored
      
      The condition for waiting on the s->free_sema queue depends on
      both s->in_flight and s->state.  The latter is currently using
      atomics, but this is quite dubious and probably wrong.
      
      Because s->state is written in the main thread too, for example by
      the yank callback, it cannot be protected by a CoMutex.  Introduce a
      separate lock that can be used by nbd_co_send_request(); later on this
      lock will also be used for s->state.  There will not be any contention
      on the lock unless there is a yank or reconnect, so this is not
      performance sensitive.
      
      Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
      Message-Id: <20220414175756.671165-6-pbonzini@redhat.com>
      Reviewed-by: default avatarEric Blake <eblake@redhat.com>
      Reviewed-by: default avatarLukas Straub <lukasstraub2@web.de>
      Signed-off-by: default avatarEric Blake <eblake@redhat.com>
      ee19d953
    • Paolo Bonzini's avatar
      nbd: keep send_mutex/free_sema handling outside nbd_co_do_establish_connection · 8610b449
      Paolo Bonzini authored
      
      Elevate s->in_flight early so that other incoming requests will wait
      on the CoQueue in nbd_co_send_request; restart them after getting back
      from nbd_reconnect_attempt.  This could be after the reconnect timer or
      nbd_cancel_in_flight have cancelled the attempt, so there is no
      need anymore to cancel the requests there.
      
      nbd_co_send_request now handles both stopping and restarting pending
      requests after a successful connection, and there is no need to
      hold send_mutex in nbd_co_do_establish_connection.  The current setup
      is confusing because nbd_co_do_establish_connection is called both with
      send_mutex taken and without it.  Before the patch it uses free_sema which
      (at least in theory...) is protected by send_mutex, after the patch it
      does not anymore.
      
      Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
      Message-Id: <20220414175756.671165-5-pbonzini@redhat.com>
      Reviewed-by: default avatarEric Blake <eblake@redhat.com>
      [eblake: wrap long line]
      Reviewed-by: default avatarVladimir Sementsov-Ogievskiy <vsementsov@openvz.org>
      Reviewed-by: default avatarLukas Straub <lukasstraub2@web.de>
      Signed-off-by: default avatarEric Blake <eblake@redhat.com>
      8610b449
    • Paolo Bonzini's avatar
      nbd: remove peppering of nbd_client_connected · 172f5f1a
      Paolo Bonzini authored
      
      It is unnecessary to check nbd_client_connected() because every time
      s->state is moved out of NBD_CLIENT_CONNECTED the socket is shut down
      and all coroutines are resumed.
      
      The only case where it was actually needed is when the NBD
      server disconnects and there is no reconnect-delay.  In that
      case, nbd_receive_replies() does not set s->reply.handle and
      nbd_co_do_receive_one_chunk() cannot continue.  For that one case,
      check the return value of nbd_receive_replies().
      
      As to the others:
      
      * nbd_receive_replies() can put the current coroutine to sleep if another
      reply is ongoing; then it will be woken by nbd_channel_error(), called
      by the ongoing reply.  Or it can try itself to read a reply header and
      fail, thus calling nbd_channel_error() itself.
      
      * nbd_co_send_request() will write the body of the request and fail
      
      * nbd_reply_chunk_iter_receive() will call nbd_co_receive_one_chunk()
      and then nbd_co_do_receive_one_chunk(), which will handle the failure as
      above; or it will just detect a previous call to nbd_iter_channel_error()
      via iter->ret < 0.
      
      Reviewed-by: default avatarEric Blake <eblake@redhat.com>
      Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
      Message-Id: <20220414175756.671165-4-pbonzini@redhat.com>
      Reviewed-by: default avatarVladimir Sementsov-Ogievskiy <vsementsov@openvz.org>
      Reviewed-by: default avatarLukas Straub <lukasstraub2@web.de>
      Signed-off-by: default avatarEric Blake <eblake@redhat.com>
      172f5f1a
    • Paolo Bonzini's avatar
      nbd: mark more coroutine_fns · 0c43c6fc
      Paolo Bonzini authored
      
      Several coroutine functions in block/nbd.c are not marked as such.  This
      patch adds a few more markers; it is not exhaustive, but it focuses
      especially on:
      
      - places that wake other coroutines, because aio_co_wake() has very
      different semantics inside a coroutine (queuing after yield vs. entering
      immediately);
      
      - functions with _co_ in their names, to avoid confusion
      
      Reviewed-by: default avatarEric Blake <eblake@redhat.com>
      Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
      Message-Id: <20220414175756.671165-3-pbonzini@redhat.com>
      Reviewed-by: default avatarVladimir Sementsov-Ogievskiy <vsementsov@openvz.org>
      Reviewed-by: default avatarLukas Straub <lukasstraub2@web.de>
      Signed-off-by: default avatarEric Blake <eblake@redhat.com>
      0c43c6fc
    • Paolo Bonzini's avatar
      nbd: safeguard against waking up invalid coroutine · 8846b7d1
      Paolo Bonzini authored
      
      The .reply_possible field of s->requests is never set to false.  This is
      not a problem as it is only a safeguard to detect protocol errors,
      but it's sloppy.  In fact, the field is actually not necessary at all,
      because .coroutine is set to NULL in NBD_FOREACH_REPLY_CHUNK after
      receiving the last chunk.  Thus, replace .reply_possible with .coroutine
      and move the check before deciding the fate of this request.
      
      Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
      Message-Id: <20220414175756.671165-2-pbonzini@redhat.com>
      Reviewed-by: default avatarEric Blake <eblake@redhat.com>
      Reviewed-by: default avatarVladimir Sementsov-Ogievskiy <vsementsov@openvz.org>
      Reviewed-by: default avatarLukas Straub <lukasstraub2@web.de>
      Signed-off-by: default avatarEric Blake <eblake@redhat.com>
      8846b7d1
Loading