1. 20 2月, 2020 1 次提交
  2. 18 2月, 2020 5 次提交
  3. 06 2月, 2020 2 次提交
    • P
      block: fix memleaks in bdrv_refresh_filename · cb895614
      Pan Nengyuan 提交于
      If we call the qmp 'query-block' while qemu is working on
      'block-commit', it will cause memleaks, the memory leak stack is as
      follow:
      
      Indirect leak of 12360 byte(s) in 3 object(s) allocated from:
          #0 0x7f80f0b6d970 in __interceptor_calloc (/lib64/libasan.so.5+0xef970)
          #1 0x7f80ee86049d in g_malloc0 (/lib64/libglib-2.0.so.0+0x5249d)
          #2 0x55ea95b5bb67 in qdict_new /mnt/sdb/qemu-4.2.0-rc0/qobject/qdict.c:29
          #3 0x55ea956cd043 in bdrv_refresh_filename /mnt/sdb/qemu-4.2.0-rc0/block.c:6427
          #4 0x55ea956cc950 in bdrv_refresh_filename /mnt/sdb/qemu-4.2.0-rc0/block.c:6399
          #5 0x55ea956cc950 in bdrv_refresh_filename /mnt/sdb/qemu-4.2.0-rc0/block.c:6399
          #6 0x55ea956cc950 in bdrv_refresh_filename /mnt/sdb/qemu-4.2.0-rc0/block.c:6399
          #7 0x55ea958818ea in bdrv_block_device_info /mnt/sdb/qemu-4.2.0-rc0/block/qapi.c:56
          #8 0x55ea958879de in bdrv_query_info /mnt/sdb/qemu-4.2.0-rc0/block/qapi.c:392
          #9 0x55ea9588b58f in qmp_query_block /mnt/sdb/qemu-4.2.0-rc0/block/qapi.c:578
          #10 0x55ea95567392 in qmp_marshal_query_block qapi/qapi-commands-block-core.c:95
      
      Indirect leak of 4120 byte(s) in 1 object(s) allocated from:
          #0 0x7f80f0b6d970 in __interceptor_calloc (/lib64/libasan.so.5+0xef970)
          #1 0x7f80ee86049d in g_malloc0 (/lib64/libglib-2.0.so.0+0x5249d)
          #2 0x55ea95b5bb67 in qdict_new /mnt/sdb/qemu-4.2.0-rc0/qobject/qdict.c:29
          #3 0x55ea956cd043 in bdrv_refresh_filename /mnt/sdb/qemu-4.2.0-rc0/block.c:6427
          #4 0x55ea956cc950 in bdrv_refresh_filename /mnt/sdb/qemu-4.2.0-rc0/block.c:6399
          #5 0x55ea956cc950 in bdrv_refresh_filename /mnt/sdb/qemu-4.2.0-rc0/block.c:6399
          #6 0x55ea9569f301 in bdrv_backing_attach /mnt/sdb/qemu-4.2.0-rc0/block.c:1064
          #7 0x55ea956a99dd in bdrv_replace_child_noperm /mnt/sdb/qemu-4.2.0-rc0/block.c:2283
          #8 0x55ea956b9b53 in bdrv_replace_node /mnt/sdb/qemu-4.2.0-rc0/block.c:4196
          #9 0x55ea956b9e49 in bdrv_append /mnt/sdb/qemu-4.2.0-rc0/block.c:4236
          #10 0x55ea958c3472 in commit_start /mnt/sdb/qemu-4.2.0-rc0/block/commit.c:306
          #11 0x55ea94b68ab0 in qmp_block_commit /mnt/sdb/qemu-4.2.0-rc0/blockdev.c:3459
          #12 0x55ea9556a7a7 in qmp_marshal_block_commit qapi/qapi-commands-block-core.c:407
      
      Fixes: bb808d5fReported-by: NEuler Robot <euler.robot@huawei.com>
      Signed-off-by: NPan Nengyuan <pannengyuan@huawei.com>
      Message-id: 20200116085600.24056-1-pannengyuan@huawei.com
      Signed-off-by: NMax Reitz <mreitz@redhat.com>
      cb895614
    • A
      block: Use a GString in bdrv_perm_names() · e2a7423a
      Alberto Garcia 提交于
      This is a bit more efficient than having to allocate and free memory
      for each new permission.
      
      The default size (30) is enough for "consistent read, write, resize".
      Signed-off-by: NAlberto Garcia <berto@igalia.com>
      Message-id: 20200110171518.22168-1-berto@igalia.com
      Reviewed-by: NEric Blake <eblake@redhat.com>
      Signed-off-by: NMax Reitz <mreitz@redhat.com>
      e2a7423a
  4. 31 1月, 2020 1 次提交
  5. 06 1月, 2020 2 次提交
    • M
      block: Use bdrv_qapi_perm_to_blk_perm() · cdb1cec8
      Max Reitz 提交于
      We can save some LoC in xdbg_graph_add_edge() by using
      bdrv_qapi_perm_to_blk_perm().
      Signed-off-by: NMax Reitz <mreitz@redhat.com>
      Message-id: 20191108123455.39445-3-mreitz@redhat.com
      Reviewed-by: NVladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
      Signed-off-by: NMax Reitz <mreitz@redhat.com>
      cdb1cec8
    • M
      block: Add bdrv_qapi_perm_to_blk_perm() · 7b1d9c4d
      Max Reitz 提交于
      We need some way to correlate QAPI BlockPermission values with
      BLK_PERM_* flags.  We could:
      
      (1) have the same order in the QAPI definition as the the BLK_PERM_*
          flags are in LSb-first order.  However, then there is no guarantee
          that they actually match (e.g. when someone modifies the QAPI schema
          without thinking of the BLK_PERM_* definitions).
          We could add static assertions, but these would break what’s good
          about this solution, namely its simplicity.
      
      (2) define the BLK_PERM_* flags based on the BlockPermission values.
          But this way whenever someone were to modify the QAPI order
          (perfectly sensible in theory), the BLK_PERM_* values would change.
          Because these values are used for file locking, this might break
          file locking between different qemu versions.
      
      Therefore, go the slightly more cumbersome way: Add a function to
      translate from the QAPI constants to the BLK_PERM_* flags.
      Signed-off-by: NMax Reitz <mreitz@redhat.com>
      Message-id: 20191108123455.39445-2-mreitz@redhat.com
      Reviewed-by: NVladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
      Signed-off-by: NMax Reitz <mreitz@redhat.com>
      7b1d9c4d
  6. 20 12月, 2019 1 次提交
    • K
      block: Activate recursively even for already active nodes · 7bb4941a
      Kevin Wolf 提交于
      bdrv_invalidate_cache_all() assumes that all nodes in a given subtree
      are either active or inactive when it starts. Therefore, as soon as it
      arrives at an already active node, it stops.
      
      However, this assumption is wrong. For example, it's possible to take a
      snapshot of an inactive node, which results in an active overlay over an
      inactive backing file. The active overlay is probably also the root node
      of an inactive BlockBackend (blk->disable_perm == true).
      
      In this case, bdrv_invalidate_cache_all() does not need to do anything
      to activate the overlay node, but it still needs to recurse into the
      children and the parents to make sure that after returning success,
      really everything is activated.
      
      Cc: qemu-stable@nongnu.org
      Signed-off-by: NKevin Wolf <kwolf@redhat.com>
      Reviewed-by: NMax Reitz <mreitz@redhat.com>
      7bb4941a
  7. 18 12月, 2019 1 次提交
  8. 19 11月, 2019 1 次提交
    • K
      block: Remove 'backing': null from bs->{explicit_,}options · ae0f57f0
      Kevin Wolf 提交于
      bs->options and bs->explicit_options shouldn't contain any options for
      child nodes. bdrv_open_inherited() takes care to remove any options that
      match a child name after opening the image and the same is done when
      reopening.
      
      However, we miss the case of 'backing': null, which is a child option,
      but results in no child being created. This means that a 'backing': null
      remains in bs->options and bs->explicit_options.
      
      A typical use for 'backing': null is in live snapshots: blockdev-add for
      the qcow2 overlay makes sure not to open the backing file (because it is
      already opened and blockdev-snapshot will attach it). After doing a
      blockdev-snapshot, bs->options and bs->explicit_options become
      inconsistent with the actual state (bs has a backing file now, but the
      options still say null). On the next occasion that the image is
      reopened, e.g. switching it from read-write to read-only when another
      snapshot is taken, the option will take effect again and the node
      incorrectly loses its backing file.
      
      Fix bdrv_open_inherited() to remove the 'backing' option from
      bs->options and bs->explicit_options even for the case where it
      specifies that no backing file is wanted.
      Reported-by: NPeter Krempa <pkrempa@redhat.com>
      Signed-off-by: NKevin Wolf <kwolf@redhat.com>
      Reviewed-by: NAlberto Garcia <berto@igalia.com>
      Tested-by: NPeter Krempa <pkrempa@redhat.com>
      ae0f57f0
  9. 26 10月, 2019 1 次提交
    • W
      core: replace getpagesize() with qemu_real_host_page_size · 038adc2f
      Wei Yang 提交于
      There are three page size in qemu:
      
        real host page size
        host page size
        target page size
      
      All of them have dedicate variable to represent. For the last two, we
      use the same form in the whole qemu project, while for the first one we
      use two forms: qemu_real_host_page_size and getpagesize().
      
      qemu_real_host_page_size is defined to be a replacement of
      getpagesize(), so let it serve the role.
      
      [Note] Not fully tested for some arch or device.
      Signed-off-by: NWei Yang <richardw.yang@linux.intel.com>
      Message-Id: <20191013021145.16011-3-richardw.yang@linux.intel.com>
      Signed-off-by: NPaolo Bonzini <pbonzini@redhat.com>
      038adc2f
  10. 18 10月, 2019 5 次提交
  11. 10 10月, 2019 2 次提交
  12. 03 9月, 2019 1 次提交
  13. 19 8月, 2019 1 次提交
    • M
      block: Add bdrv_has_zero_init_truncate() · ceaca56f
      Max Reitz 提交于
      No .bdrv_has_zero_init() implementation returns 1 if growing the file
      would add non-zero areas (at least with PREALLOC_MODE_OFF), so using it
      in lieu of this new function was always safe.
      
      But on the other hand, it is possible that growing an image that is not
      zero-initialized would still add a zero-initialized area, like when
      using nonpreallocating truncation on a preallocated image.  For callers
      that care only about truncation, not about creation with potential
      preallocation, this new function is useful.
      
      Alternatively, we could have added a PreallocMode parameter to
      bdrv_has_zero_init().  But the only user would have been qemu-img
      convert, which does not have a plain PreallocMode value right now -- it
      would have to parse the creation option to obtain it.  Therefore, the
      simpler solution is to let bdrv_has_zero_init() inquire the
      preallocation status and add the new bdrv_has_zero_init_truncate() that
      presupposes PREALLOC_MODE_OFF.
      Signed-off-by: NMax Reitz <mreitz@redhat.com>
      Message-id: 20190724171239.8764-4-mreitz@redhat.com
      Reviewed-by: NMaxim Levitsky <mlevitsk@redhat.com>
      Reviewed-by: NStefano Garzarella <sgarzare@redhat.com>
      Signed-off-by: NMax Reitz <mreitz@redhat.com>
      ceaca56f
  14. 17 8月, 2019 1 次提交
  15. 16 8月, 2019 4 次提交
    • M
      Include qemu/main-loop.h less · db725815
      Markus Armbruster 提交于
      In my "build everything" tree, changing qemu/main-loop.h triggers a
      recompile of some 5600 out of 6600 objects (not counting tests and
      objects that don't depend on qemu/osdep.h).  It includes block/aio.h,
      which in turn includes qemu/event_notifier.h, qemu/notify.h,
      qemu/processor.h, qemu/qsp.h, qemu/queue.h, qemu/thread-posix.h,
      qemu/thread.h, qemu/timer.h, and a few more.
      
      Include qemu/main-loop.h only where it's needed.  Touching it now
      recompiles only some 1700 objects.  For block/aio.h and
      qemu/event_notifier.h, these numbers drop from 5600 to 2800.  For the
      others, they shrink only slightly.
      Signed-off-by: NMarkus Armbruster <armbru@redhat.com>
      Message-Id: <20190812052359.30071-21-armbru@redhat.com>
      Reviewed-by: NAlex Bennée <alex.bennee@linaro.org>
      Reviewed-by: NPhilippe Mathieu-Daudé <philmd@redhat.com>
      Tested-by: NPhilippe Mathieu-Daudé <philmd@redhat.com>
      db725815
    • M
      block: Reduce (un)drains when replacing a child · debc2927
      Max Reitz 提交于
      Currently, bdrv_replace_child_noperm() undrains the parent until it is
      completely undrained, then re-drains it after attaching the new child
      node.
      
      This is a problem with bdrv_drop_intermediate(): We want to keep the
      whole subtree drained, including parents, while the operation is
      under way.  bdrv_replace_child_noperm() breaks this by allowing every
      parent to become unquiesced briefly, and then redraining it.
      
      In fact, there is no reason why the parent should become unquiesced and
      be allowed to submit requests to the new child node if that new node is
      supposed to be kept drained.  So if anything, we have to drain the
      parent before detaching the old child node.  Conversely, we have to
      undrain it only after attaching the new child node.
      
      Thus, change the whole drain algorithm here: Calculate the number of
      times we have to drain/undrain the parent before replacing the child
      node then drain it (if necessary), replace the child node, and then
      undrain it.
      Signed-off-by: NMax Reitz <mreitz@redhat.com>
      Signed-off-by: NKevin Wolf <kwolf@redhat.com>
      debc2927
    • M
      block: Keep subtree drained in drop_intermediate · 637d54a5
      Max Reitz 提交于
      bdrv_drop_intermediate() calls BdrvChildRole.update_filename().  That
      may poll, thus changing the graph, which potentially breaks the
      QLIST_FOREACH_SAFE() loop.
      
      Just keep the whole subtree drained.  This is probably the right thing
      to do anyway (dropping nodes while the subtree is not drained seems
      wrong).
      Signed-off-by: NMax Reitz <mreitz@redhat.com>
      Reviewed-by: NKevin Wolf <kwolf@redhat.com>
      Signed-off-by: NKevin Wolf <kwolf@redhat.com>
      637d54a5
    • K
      block: Simplify bdrv_filter_default_perms() · e444fa83
      Kevin Wolf 提交于
      The same change as commit 2b23f286 ('block/copy-on-read: Fix
      permissions for inactive node') made for the copy-on-read driver can be
      made for bdrv_filter_default_perms(): Retaining the old permissions from
      the BdrvChild if it is given complicates things unnecessarily when in
      the end this only means that the options set in the c == NULL case (i.e.
      during child creation) are retained.
      Signed-off-by: NKevin Wolf <kwolf@redhat.com>
      Reviewed-by: NEric Blake <eblake@redhat.com>
      Reviewed-by: NMax Reitz <mreitz@redhat.com>
      e444fa83
  16. 23 7月, 2019 1 次提交
    • M
      block: Only the main loop can change AioContexts · 43eaaaef
      Max Reitz 提交于
      bdrv_set_aio_context_ignore() can only work in the main loop:
      bdrv_drained_begin() only works in the main loop and the node's (old)
      AioContext; and bdrv_drained_end() really only works in the main loop
      and the node's (new) AioContext (contrary to its current comment, which
      is just wrong).
      
      Consequentially, bdrv_set_aio_context_ignore() must be called from the
      main loop.  Luckily, assuming that we can make block graph changes only
      from the main loop as well, all its callers do that already.
      
      Note that changing a node's context in a sense is an operation that
      changes the block graph, so it actually makes sense to require this
      function to be called from the main loop.
      
      Also, fix bdrv_drained_end()'s description.  You can only use it from
      the main loop or the node's AioContext, and in the latter case, the
      whole subtree must be in the same context.
      
      Fixes: e037c09cSigned-off-by: NMax Reitz <mreitz@redhat.com>
      Message-id: 20190722133054.21781-3-mreitz@redhat.com
      Signed-off-by: NMax Reitz <mreitz@redhat.com>
      43eaaaef
  17. 19 7月, 2019 2 次提交
    • M
      block: Do not poll in bdrv_do_drained_end() · e037c09c
      Max Reitz 提交于
      We should never poll anywhere in bdrv_do_drained_end() (including its
      recursive callees like bdrv_drain_invoke()), because it does not cope
      well with graph changes.  In fact, it has been written based on the
      postulation that no graph changes will happen in it.
      
      Instead, the callers that want to poll must poll, i.e. all currently
      globally available wrappers: bdrv_drained_end(),
      bdrv_subtree_drained_end(), bdrv_unapply_subtree_drain(), and
      bdrv_drain_all_end().  Graph changes there do not matter.
      
      They can poll simply by passing a pointer to a drained_end_counter and
      wait until it reaches 0.
      
      This patch also adds a non-polling global wrapper for
      bdrv_do_drained_end() that takes a drained_end_counter pointer.  We need
      such a variant because now no function called anywhere from
      bdrv_do_drained_end() must poll.  This includes
      BdrvChildRole.drained_end(), which already must not poll according to
      its interface documentation, but bdrv_child_cb_drained_end() just
      violates that by invoking bdrv_drained_end() (which does poll).
      Therefore, BdrvChildRole.drained_end() must take a *drained_end_counter
      parameter, which bdrv_child_cb_drained_end() can pass on to the new
      bdrv_drained_end_no_poll() function.
      
      Note that we now have a pattern of all drained_end-related functions
      either polling or receiving a *drained_end_counter to let the caller
      poll based on that.
      
      A problem with a single poll loop is that when the drained section in
      bdrv_set_aio_context_ignore() ends, some nodes in the subgraph may be in
      the old contexts, while others are in the new context already.  To let
      the collective poll in bdrv_drained_end() work correctly, we must not
      hold a lock to the old context, so that the old context can make
      progress in case it is different from the current context.
      
      (In the process, remove the comment saying that the current context is
      always the old context, because it is wrong.)
      
      In all other places, all nodes in a subtree must be in the same context,
      so we can just poll that.  The exception of course is
      bdrv_drain_all_end(), but that always runs in the main context, so we
      can just poll NULL (like bdrv_drain_all_begin() does).
      Signed-off-by: NMax Reitz <mreitz@redhat.com>
      Signed-off-by: NKevin Wolf <kwolf@redhat.com>
      e037c09c
    • M
      block: Introduce BdrvChild.parent_quiesce_counter · 804db8ea
      Max Reitz 提交于
      Commit 5cb2737e laid out why
      bdrv_do_drained_end() must decrement the quiesce_counter after
      bdrv_drain_invoke().  It did not give a very good reason why it has to
      happen after bdrv_parent_drained_end(), instead only claiming symmetry
      to bdrv_do_drained_begin().
      
      It turns out that delaying it for so long is wrong.
      
      Situation: We have an active commit job (i.e. a mirror job) from top to
      base for the following graph:
      
                        filter
                          |
                        [file]
                          |
                          v
      top --[backing]--> base
      
      Now the VM is closed, which results in the job being cancelled and a
      bdrv_drain_all() happening pretty much simultaneously.
      
      Beginning the drain means the job is paused once whenever one of its
      nodes is quiesced.  This is reversed when the drain ends.
      
      With how the code currently is, after base's drain ends (which means
      that it will have unpaused the job once), its quiesce_counter remains at
      1 while it goes to undrain its parents (bdrv_parent_drained_end()).  For
      some reason or another, undraining filter causes the job to be kicked
      and enter mirror_exit_common(), where it proceeds to invoke
      block_job_remove_all_bdrv().
      
      Now base will be detached from the job.  Because its quiesce_counter is
      still 1, it will unpause the job once more.  So in total, undraining
      base will unpause the job twice.  Eventually, this will lead to the
      job's pause_count going negative -- well, it would, were there not an
      assertion against this, which crashes qemu.
      
      The general problem is that if in bdrv_parent_drained_end() we undrain
      parent A, and then undrain parent B, which then leads to A detaching the
      child, bdrv_replace_child_noperm() will undrain A as if we had not done
      so yet; that is, one time too many.
      
      It follows that we cannot decrement the quiesce_counter after invoking
      bdrv_parent_drained_end().
      
      Unfortunately, decrementing it before bdrv_parent_drained_end() would be
      wrong, too.  Imagine the above situation in reverse: Undraining A leads
      to B detaching the child.  If we had already decremented the
      quiesce_counter by that point, bdrv_replace_child_noperm() would undrain
      B one time too little; because it expects bdrv_parent_drained_end() to
      issue this undrain.  But bdrv_parent_drained_end() won't do that,
      because B is no longer a parent.
      
      Therefore, we have to do something else.  This patch opts for
      introducing a second quiesce_counter that counts how many times a
      child's parent has been quiesced (though c->role->drained_*).  With
      that, bdrv_replace_child_noperm() just has to undrain the parent exactly
      that many times when removing a child, and it will always be right.
      Signed-off-by: NMax Reitz <mreitz@redhat.com>
      Signed-off-by: NKevin Wolf <kwolf@redhat.com>
      804db8ea
  18. 15 7月, 2019 2 次提交
    • M
      block: Deep-clear inherits_from · 3cf746b3
      Max Reitz 提交于
      BDS.inherits_from does not always point to an immediate parent node.
      When launching a block job with a filter node, for example, the node
      directly below the filter will not point to the filter, but keep its old
      pointee (above the filter).
      
      If that pointee goes away while the job is still running, the node's
      inherits_from will not be updated and thus point to garbage.  To fix
      this, bdrv_unref_child() has to check not only the parent node's
      immediate children for nodes whose inherits_from needs to be cleared,
      but its whole subtree.
      Signed-off-by: NMax Reitz <mreitz@redhat.com>
      Message-id: 20190703172813.6868-7-mreitz@redhat.com
      Signed-off-by: NMax Reitz <mreitz@redhat.com>
      3cf746b3
    • M
      block: Add BDS.never_freeze · e5182c1c
      Max Reitz 提交于
      The commit and the mirror block job must be able to drop their filter
      node at any point.  However, this will not be possible if any of the
      BdrvChild links to them is frozen.  Therefore, we need to prevent them
      from ever becoming frozen.
      Signed-off-by: NMax Reitz <mreitz@redhat.com>
      Reviewed-by: NAndrey Shinkevich <andrey.shinkevich@virtuozzo.com>
      Reviewed-by: NAlberto Garcia <berto@igalia.com>
      Message-id: 20190703172813.6868-2-mreitz@redhat.com
      Signed-off-by: NMax Reitz <mreitz@redhat.com>
      e5182c1c
  19. 18 6月, 2019 5 次提交
    • M
      block: Ignore loosening perm restrictions failures · 1046779e
      Max Reitz 提交于
      We generally assume that loosening permission restrictions can never
      fail.  We have seen in the past that this assumption is wrong.  This has
      led to crashes because we generally pass &error_abort when loosening
      permissions.
      
      However, a failure in such a case should actually be handled in quite
      the opposite way: It is very much not fatal, so qemu may report it, but
      still consider the operation successful.  The only realistic problem is
      that qemu may then retain permissions and thus locks on images it
      actually does not require.  But again, that is not fatal.
      
      To implement this behavior, we make all functions that change
      permissions and that pass &error_abort to the initiating function
      (bdrv_check_perm() or bdrv_child_check_perm()) evaluate the
      @loosen_restrictions value introduced in the previous patch.  If it is
      true and an error did occur, we abort the permission update, discard the
      error, and instead report success to the caller.
      
      bdrv_child_try_set_perm() itself does not pass &error_abort, but it is
      the only public function to change permissions.  As such, callers may
      pass &error_abort to it, expecting dropping permission restrictions to
      never fail.
      Signed-off-by: NMax Reitz <mreitz@redhat.com>
      Signed-off-by: NKevin Wolf <kwolf@redhat.com>
      1046779e
    • M
      block: Add *tighten_restrictions to *check*_perm() · 9eab1544
      Max Reitz 提交于
      This patch makes three functions report whether the necessary permission
      change tightens restrictions or not.  These functions are:
      - bdrv_check_perm()
      - bdrv_check_update_perm()
      - bdrv_child_check_perm()
      
      Callers can use this result to decide whether a failure is fatal or not
      (see the next patch).
      Signed-off-by: NMax Reitz <mreitz@redhat.com>
      Signed-off-by: NKevin Wolf <kwolf@redhat.com>
      9eab1544
    • M
      block: Fix order in bdrv_replace_child() · 87ace5f8
      Max Reitz 提交于
      We have to start by applying the permission restrictions to new_bs
      before we can loosen them on old_bs.  See the comment for the
      explanation.
      Signed-off-by: NMax Reitz <mreitz@redhat.com>
      Reviewed-by: NKevin Wolf <kwolf@redhat.com>
      Signed-off-by: NKevin Wolf <kwolf@redhat.com>
      87ace5f8
    • M
      block: Add bdrv_child_refresh_perms() · c1087f12
      Max Reitz 提交于
      If a block node uses bdrv_child_try_set_perm() to change the permission
      it takes on its child, the result may be very short-lived.  If anything
      makes the block layer recalculate the permissions internally, it will
      invoke the node driver's .bdrv_child_perm() implementation.  The
      permission/shared permissions masks that returns will then override the
      values previously passed to bdrv_child_try_set_perm().
      
      If drivers want a child edge to have specific values for the
      permissions/shared permissions mask, it must return them in
      .bdrv_child_perm().  Consequentially, there is no need for them to pass
      the same values to bdrv_child_try_set_perm() then: It is better to have
      a function that invokes .bdrv_child_perm() and calls
      bdrv_child_try_set_perm() with the result.  This patch adds such a
      function under the name of bdrv_child_refresh_perms().
      Signed-off-by: NMax Reitz <mreitz@redhat.com>
      Reviewed-by: NKevin Wolf <kwolf@redhat.com>
      Signed-off-by: NKevin Wolf <kwolf@redhat.com>
      c1087f12
    • V
      block: drop bs->job · b23c580c
      Vladimir Sementsov-Ogievskiy 提交于
      Drop remaining users of bs->job:
      1. assertions actually duplicated by assert(!bs->refcnt)
      2. trace-point seems not enough reason to change stream_start to return
         BlockJob pointer
      3. Restricting creation of two jobs based on same bs is bad idea, as
         3.1 Some jobs creates filters to be their main node, so, this check
         don't actually prevent creating second job on same real node (which
         will create another filter node) (but I hope it is restricted by
         other mechanisms)
         3.2 Even without bs->job we have two systems of permissions:
         op-blockers and BLK_PERM
         3.3 We may want to run several jobs on one node one day
      
      And finally, drop bs->job pointer itself. Hurrah!
      Suggested-by: NKevin Wolf <kwolf@redhat.com>
      Signed-off-by: NVladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
      Signed-off-by: NKevin Wolf <kwolf@redhat.com>
      b23c580c
  20. 04 6月, 2019 1 次提交
    • K
      block: Remove bdrv_set_aio_context() · 42a65f02
      Kevin Wolf 提交于
      All callers of bdrv_set_aio_context() are eliminated now, they have
      moved to bdrv_try_set_aio_context() and related safe functions. Remove
      bdrv_set_aio_context().
      
      With this, we can now know that the .set_aio_ctx callback must be
      present in bdrv_set_aio_context_ignore() because
      bdrv_can_set_aio_context() would have returned false previously, so
      instead of checking the condition, we can assert it.
      Signed-off-by: NKevin Wolf <kwolf@redhat.com>
      42a65f02