1. 13 3月, 2019 13 次提交
    • A
      block: Allow freezing BdrvChild links · 2cad1ebe
      Alberto Garcia 提交于
      Our permission system is useful to define what operations are allowed
      on a certain block node and includes things like BLK_PERM_WRITE or
      BLK_PERM_RESIZE among others.
      
      One of the permissions is BLK_PERM_GRAPH_MOD which allows "changing
      the node that this BdrvChild points to". The exact meaning of this has
      never been very clear, but it can be understood as "change any of the
      links connected to the node". This can be used to prevent changing a
      backing link, but it's too coarse.
      
      This patch adds a new 'frozen' attribute to BdrvChild, which forbids
      detaching the link from the node it points to, and new API to freeze
      and unfreeze a backing chain.
      
      After this change a few functions can fail, so they need additional
      checks.
      Signed-off-by: NAlberto Garcia <berto@igalia.com>
      Signed-off-by: NKevin Wolf <kwolf@redhat.com>
      2cad1ebe
    • K
      nvme: fix write zeroes offset and count · 9d6459d2
      Keith Busch 提交于
      The implementation used blocks units rather than the expected bytes.
      
      Fixes: c03e7ef1 ("nvme: Implement Write Zeroes")
      Reported-by: NMing Lei <ming.lei@redhat.com>
      Signed-off-by: NKeith Busch <keith.busch@intel.com>
      Reviewed-by: NChristoph Hellwig <hch@lst.de>
      Signed-off-by: NKevin Wolf <kwolf@redhat.com>
      9d6459d2
    • K
      file-posix: Make auto-read-only dynamic · 23dece19
      Kevin Wolf 提交于
      Until now, with auto-read-only=on we tried to open the file read-write
      first and if that failed, read-only was tried. This is actually not good
      enough for libvirt, which gives QEMU SELinux permissions for read-write
      only as soon as it actually intends to write to the image. So we need to
      be able to switch between read-only and read-write at runtime.
      
      This patch makes auto-read-only dynamic, i.e. the file is opened
      read-only as long as no user of the node has requested write
      permissions, but it is automatically reopened read-write as soon as the
      first writer is attached. Conversely, if the last writer goes away, the
      file is reopened read-only again.
      
      bs->read_only is no longer set for auto-read-only=on files even if the
      file descriptor is opened read-only because it will be transparently
      upgraded as soon as a writer is attached. This changes the output of
      qemu-iotests 232.
      Signed-off-by: NKevin Wolf <kwolf@redhat.com>
      23dece19
    • K
      file-posix: Prepare permission code for fd switching · 6ceabe6f
      Kevin Wolf 提交于
      In order to be able to dynamically reopen the file read-only or
      read-write, depending on the users that are attached, we need to be able
      to switch to a different file descriptor during the permission change.
      
      This interacts with reopen, which also creates a new file descriptor and
      performs permission changes internally. In this case, the permission
      change code must reuse the reopen file descriptor instead of creating a
      third one.
      
      In turn, reopen can drop its code to copy file locks to the new file
      descriptor because that is now done when applying the new permissions.
      Signed-off-by: NKevin Wolf <kwolf@redhat.com>
      6ceabe6f
    • K
      file-posix: Lock new fd in raw_reopen_prepare() · a6aeca0c
      Kevin Wolf 提交于
      There is no reason why we can take locks on the new file descriptor only
      in raw_reopen_commit() where error handling isn't possible any more.
      Instead, we can already do this in raw_reopen_prepare().
      Signed-off-by: NKevin Wolf <kwolf@redhat.com>
      a6aeca0c
    • K
      file-posix: Store BDRVRawState.reopen_state during reopen · e0c9cf3a
      Kevin Wolf 提交于
      We'll want to access the file descriptor in the reopen_state while
      processing permission changes in the context of the repoen.
      Signed-off-by: NKevin Wolf <kwolf@redhat.com>
      e0c9cf3a
    • K
      file-posix: Factor out raw_reconfigure_getfd() · 5cec2870
      Kevin Wolf 提交于
      Signed-off-by: NKevin Wolf <kwolf@redhat.com>
      5cec2870
    • K
      file-posix: Fix bdrv_open_flags() for snapshot=on · 30855137
      Kevin Wolf 提交于
      Using a different read-only setting for bs->open_flags than for the
      flags to the driver's open function is just inconsistent and a bad idea.
      After this patch, the temporary snapshot keeps being opened read-only if
      read-only=on,snapshot=on is passed.
      
      If we wanted to change this behaviour to make only the orginal image
      file read-only, but the temporary overlay read-write (as the comment in
      the removed code suggests), that change would have to be made in
      bdrv_temp_snapshot_options() (where the comment suggests otherwise).
      
      Addressing this inconsistency before introducing dynamic auto-read-only
      is important because otherwise we would immediately try to reopen the
      temporary overlay even though the file is already unlinked.
      Signed-off-by: NKevin Wolf <kwolf@redhat.com>
      30855137
    • K
      block: Make permission changes in reopen less wrong · 69b736e7
      Kevin Wolf 提交于
      The way that reopen interacts with permission changes has one big
      problem: Both operations are recursive, and the permissions are changes
      for each node in the reopen queue.
      
      For a simple graph that consists just of parent and child,
      .bdrv_check_perm will be called twice for the child, once recursively
      when adjusting the permissions of parent, and once again when the child
      itself is reopened.
      
      Even worse, the first .bdrv_check_perm call happens before
      .bdrv_reopen_prepare was called for the child and the second one is
      called afterwards.
      
      Making sure that .bdrv_check_perm (and the other permission callbacks)
      are called only once is hard. We can cope with multiple calls right now,
      but as soon as file-posix gets a dynamic auto-read-only that may need to
      open a new file descriptor, we get the additional requirement that all
      of them are after the .bdrv_reopen_prepare call.
      
      So reorder things in bdrv_reopen_multiple() to first call
      .bdrv_reopen_prepare for all involved nodes and only then adjust
      permissions.
      Signed-off-by: NKevin Wolf <kwolf@redhat.com>
      69b736e7
    • K
      block: Avoid useless local_err · a4615ab3
      Kevin Wolf 提交于
      Signed-off-by: NKevin Wolf <kwolf@redhat.com>
      Reviewed-by: NAlberto Garcia <berto@igalia.com>
      Reviewed-by: NEric Blake <eblake@redhat.com>
      a4615ab3
    • K
      12efe428
    • K
      tests/virtio-blk-test: Disable auto-read-only · 70304118
      Kevin Wolf 提交于
      tests/virtio-blk-test uses a temporary image file that it deletes while
      QEMU is still running, so it can't be reopened when writers are
      attached or detached. Disable auto-read-only to keep it always writable.
      Signed-off-by: NKevin Wolf <kwolf@redhat.com>
      Reviewed-by: NEric Blake <eblake@redhat.com>
      70304118
    • V
      qapi: drop x- from x-block-latency-histogram-set · cb8aac37
      Vladimir Sementsov-Ogievskiy 提交于
      Drop x- and x_ prefixes for latency histograms and update version to
      4.0
      Signed-off-by: NVladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
      Signed-off-by: NKevin Wolf <kwolf@redhat.com>
      cb8aac37
  2. 12 3月, 2019 27 次提交