Skip to content
Snippets Groups Projects
  1. Mar 06, 2020
  2. Feb 22, 2020
  3. Feb 20, 2020
  4. Feb 18, 2020
  5. Feb 06, 2020
    • Pan Nengyuan's avatar
      block: fix memleaks in bdrv_refresh_filename · cb895614
      Pan Nengyuan authored
      
      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: bb808d5f
      Reported-by: default avatarEuler Robot <euler.robot@huawei.com>
      Signed-off-by: default avatarPan Nengyuan <pannengyuan@huawei.com>
      Message-id: 20200116085600.24056-1-pannengyuan@huawei.com
      Signed-off-by: default avatarMax Reitz <mreitz@redhat.com>
      cb895614
    • Alberto Garcia's avatar
      block: Use a GString in bdrv_perm_names() · e2a7423a
      Alberto Garcia authored
      
      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: default avatarAlberto Garcia <berto@igalia.com>
      Message-id: 20200110171518.22168-1-berto@igalia.com
      Reviewed-by: default avatarEric Blake <eblake@redhat.com>
      Signed-off-by: default avatarMax Reitz <mreitz@redhat.com>
      e2a7423a
  6. Jan 30, 2020
  7. Jan 06, 2020
    • Hanna Reitz's avatar
      block: Use bdrv_qapi_perm_to_blk_perm() · cdb1cec8
      Hanna Reitz authored
      
      We can save some LoC in xdbg_graph_add_edge() by using
      bdrv_qapi_perm_to_blk_perm().
      
      Signed-off-by: default avatarMax Reitz <mreitz@redhat.com>
      Message-id: 20191108123455.39445-3-mreitz@redhat.com
      Reviewed-by: default avatarVladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
      Signed-off-by: default avatarMax Reitz <mreitz@redhat.com>
      cdb1cec8
    • Hanna Reitz's avatar
      block: Add bdrv_qapi_perm_to_blk_perm() · 7b1d9c4d
      Hanna Reitz authored
      
      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: default avatarMax Reitz <mreitz@redhat.com>
      Message-id: 20191108123455.39445-2-mreitz@redhat.com
      Reviewed-by: default avatarVladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
      Signed-off-by: default avatarMax Reitz <mreitz@redhat.com>
      7b1d9c4d
  8. Dec 19, 2019
    • Kevin Wolf's avatar
      block: Activate recursively even for already active nodes · 7bb4941a
      Kevin Wolf authored
      
      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: default avatarKevin Wolf <kwolf@redhat.com>
      Reviewed-by: default avatarMax Reitz <mreitz@redhat.com>
      7bb4941a
  9. Dec 18, 2019
  10. Nov 18, 2019
    • Kevin Wolf's avatar
      block: Remove 'backing': null from bs->{explicit_,}options · ae0f57f0
      Kevin Wolf authored
      
      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: default avatarPeter Krempa <pkrempa@redhat.com>
      Signed-off-by: default avatarKevin Wolf <kwolf@redhat.com>
      Reviewed-by: default avatarAlberto Garcia <berto@igalia.com>
      Tested-by: default avatarPeter Krempa <pkrempa@redhat.com>
      ae0f57f0
  11. Oct 26, 2019
    • Wei Yang's avatar
      core: replace getpagesize() with qemu_real_host_page_size · 038adc2f
      Wei Yang authored
      
      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: default avatarWei Yang <richardw.yang@linux.intel.com>
      Message-Id: <20191013021145.16011-3-richardw.yang@linux.intel.com>
      Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
      038adc2f
  12. Oct 17, 2019
  13. Oct 10, 2019
  14. Sep 03, 2019
  15. Aug 19, 2019
    • Hanna Reitz's avatar
      block: Add bdrv_has_zero_init_truncate() · ceaca56f
      Hanna Reitz authored
      
      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: default avatarMax Reitz <mreitz@redhat.com>
      Message-id: 20190724171239.8764-4-mreitz@redhat.com
      Reviewed-by: default avatarMaxim Levitsky <mlevitsk@redhat.com>
      Reviewed-by: default avatarStefano Garzarella <sgarzare@redhat.com>
      Signed-off-by: default avatarMax Reitz <mreitz@redhat.com>
      ceaca56f
  16. Aug 16, 2019
    • John Snow's avatar
      qapi: implement block-dirty-bitmap-remove transaction action · c4e4b0fa
      John Snow authored
      
      It is used to do transactional movement of the bitmap (which is
      possible in conjunction with merge command). Transactional bitmap
      movement is needed in scenarios with external snapshot, when we don't
      want to leave copy of the bitmap in the base image.
      
      Signed-off-by: default avatarVladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
      Signed-off-by: default avatarJohn Snow <jsnow@redhat.com>
      Reviewed-by: default avatarMax Reitz <mreitz@redhat.com>
      Message-id: 20190708220502.12977-3-jsnow@redhat.com
      [Edited "since" version to 4.2 --js]
      Signed-off-by: default avatarJohn Snow <jsnow@redhat.com>
      c4e4b0fa
    • Markus Armbruster's avatar
      Include qemu/main-loop.h less · db725815
      Markus Armbruster authored
      
      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: default avatarMarkus Armbruster <armbru@redhat.com>
      Message-Id: <20190812052359.30071-21-armbru@redhat.com>
      Reviewed-by: default avatarAlex Bennée <alex.bennee@linaro.org>
      Reviewed-by: default avatarPhilippe Mathieu-Daudé <philmd@redhat.com>
      Tested-by: default avatarPhilippe Mathieu-Daudé <philmd@redhat.com>
      db725815
    • Hanna Reitz's avatar
      block: Reduce (un)drains when replacing a child · debc2927
      Hanna Reitz authored
      
      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: default avatarMax Reitz <mreitz@redhat.com>
      Signed-off-by: default avatarKevin Wolf <kwolf@redhat.com>
      debc2927
    • Hanna Reitz's avatar
      block: Keep subtree drained in drop_intermediate · 637d54a5
      Hanna Reitz authored
      
      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: default avatarMax Reitz <mreitz@redhat.com>
      Reviewed-by: default avatarKevin Wolf <kwolf@redhat.com>
      Signed-off-by: default avatarKevin Wolf <kwolf@redhat.com>
      637d54a5
    • Kevin Wolf's avatar
      block: Simplify bdrv_filter_default_perms() · e444fa83
      Kevin Wolf authored
      
      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: default avatarKevin Wolf <kwolf@redhat.com>
      Reviewed-by: default avatarEric Blake <eblake@redhat.com>
      Reviewed-by: default avatarMax Reitz <mreitz@redhat.com>
      e444fa83
  17. Jul 22, 2019
    • Hanna Reitz's avatar
      block: Only the main loop can change AioContexts · 43eaaaef
      Hanna Reitz authored
      
      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: e037c09c
      Signed-off-by: default avatarMax Reitz <mreitz@redhat.com>
      Message-id: 20190722133054.21781-3-mreitz@redhat.com
      Signed-off-by: default avatarMax Reitz <mreitz@redhat.com>
      43eaaaef
  18. Jul 19, 2019
    • Hanna Reitz's avatar
      block: Do not poll in bdrv_do_drained_end() · e037c09c
      Hanna Reitz authored
      
      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: default avatarMax Reitz <mreitz@redhat.com>
      Signed-off-by: default avatarKevin Wolf <kwolf@redhat.com>
      e037c09c
    • Hanna Reitz's avatar
      block: Introduce BdrvChild.parent_quiesce_counter · 804db8ea
      Hanna Reitz authored
      
      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: default avatarMax Reitz <mreitz@redhat.com>
      Signed-off-by: default avatarKevin Wolf <kwolf@redhat.com>
      804db8ea
  19. Jul 15, 2019
    • Hanna Reitz's avatar
      block: Deep-clear inherits_from · 3cf746b3
      Hanna Reitz authored
      
      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: default avatarMax Reitz <mreitz@redhat.com>
      Message-id: 20190703172813.6868-7-mreitz@redhat.com
      Signed-off-by: default avatarMax Reitz <mreitz@redhat.com>
      3cf746b3
    • Hanna Reitz's avatar
      block: Add BDS.never_freeze · e5182c1c
      Hanna Reitz authored
      
      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: default avatarMax Reitz <mreitz@redhat.com>
      Reviewed-by: default avatarAndrey Shinkevich <andrey.shinkevich@virtuozzo.com>
      Reviewed-by: default avatarAlberto Garcia <berto@igalia.com>
      Message-id: 20190703172813.6868-2-mreitz@redhat.com
      Signed-off-by: default avatarMax Reitz <mreitz@redhat.com>
      e5182c1c
  20. Jun 18, 2019
    • Hanna Reitz's avatar
      block: Ignore loosening perm restrictions failures · 1046779e
      Hanna Reitz authored
      
      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: default avatarMax Reitz <mreitz@redhat.com>
      Signed-off-by: default avatarKevin Wolf <kwolf@redhat.com>
      1046779e
    • Hanna Reitz's avatar
      block: Add *tighten_restrictions to *check*_perm() · 9eab1544
      Hanna Reitz authored
      
      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: default avatarMax Reitz <mreitz@redhat.com>
      Signed-off-by: default avatarKevin Wolf <kwolf@redhat.com>
      9eab1544
Loading