Skip to content
Snippets Groups Projects
  1. Jan 13, 2021
  2. Jan 12, 2021
  3. Jan 08, 2021
  4. Jan 02, 2021
  5. Dec 19, 2020
    • Markus Armbruster's avatar
      qobject: Change qobject_to_json()'s value to GString · eab3a467
      Markus Armbruster authored
      
      qobject_to_json() and qobject_to_json_pretty() build a GString, then
      covert it to QString.  Just one of the callers actually needs a
      QString: qemu_rbd_parse_filename().  A few others need a string they
      can modify: qmp_send_response(), qga's send_response(), to_json_str(),
      and qmp_fd_vsend_fds().  The remainder just need a string.
      
      Change qobject_to_json() and qobject_to_json_pretty() to return the
      GString.
      
      qemu_rbd_parse_filename() now has to convert to QString.  All others
      save a QString temporary.  to_json_str() actually becomes a bit
      simpler, because GString provides more convenient modification
      functions.
      
      Signed-off-by: default avatarMarkus Armbruster <armbru@redhat.com>
      Message-Id: <20201211171152.146877-6-armbru@redhat.com>
      eab3a467
    • Eric Blake's avatar
      qapi: Use QAPI_LIST_PREPEND() where possible · 54aa3de7
      Eric Blake authored
      
      Anywhere we create a list of just one item or by prepending items
      (typically because order doesn't matter), we can use
      QAPI_LIST_PREPEND().  But places where we must keep the list in order
      by appending remain open-coded until later patches.
      
      Note that as a side effect, this also performs a cleanup of two minor
      issues in qga/commands-posix.c: the old code was performing
       new = g_malloc0(sizeof(*ret));
      which 1) is confusing because you have to verify whether 'new' and
      'ret' are variables with the same type, and 2) would conflict with C++
      compilation (not an actual problem for this file, but makes
      copy-and-paste harder).
      
      Signed-off-by: default avatarEric Blake <eblake@redhat.com>
      Message-Id: <20201113011340.463563-5-eblake@redhat.com>
      Reviewed-by: default avatarMarkus Armbruster <armbru@redhat.com>
      Acked-by: default avatarStefan Hajnoczi <stefanha@redhat.com>
      [Straightforward conflicts due to commit a8aa94b5 "qga: update
      schema for guest-get-disks 'dependents' field" and commit a10b453a
      "target/mips: Move mips_cpu_add_definition() from helper.c to cpu.c"
      resolved.  Commit message tweaked.]
      Signed-off-by: default avatarMarkus Armbruster <armbru@redhat.com>
      54aa3de7
  6. Dec 18, 2020
  7. Dec 13, 2020
  8. Dec 11, 2020
    • Kevin Wolf's avatar
      block: Fix deadlock in bdrv_co_yield_to_drain() · 960d5fb3
      Kevin Wolf authored
      If bdrv_co_yield_to_drain() is called for draining a block node that
      runs in a different AioContext, it keeps that AioContext locked while it
      yields and schedules a BH in the AioContext to do the actual drain.
      
      As long as executing the BH is the very next thing that the event loop
      of the node's AioContext does, this actually happens to work, but when
      it tries to execute something else that wants to take the AioContext
      lock, it will deadlock. (In the bug report, this other thing is a
      virtio-scsi device running virtio_scsi_data_plane_handle_cmd().)
      
      Instead, always drop the AioContext lock across the yield and reacquire
      it only when the coroutine is reentered. The BH needs to unconditionally
      take the lock for itself now.
      
      This fixes the 'block_resize' QMP command on a block node that runs in
      an iothread.
      
      Cc: qemu-stable@nongnu.org
      Fixes: eb94b81a
      Fixes: https://bugzilla.redhat.com/show_bug.cgi?id=1903511
      
      
      Signed-off-by: default avatarKevin Wolf <kwolf@redhat.com>
      Message-Id: <20201203172311.68232-4-kwolf@redhat.com>
      Reviewed-by: default avatarVladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
      Signed-off-by: default avatarKevin Wolf <kwolf@redhat.com>
      960d5fb3
    • Vladimir Sementsov-Ogievskiy's avatar
      block: introduce BDRV_MAX_LENGTH · 8b117001
      Vladimir Sementsov-Ogievskiy authored
      
      We are going to modify block layer to work with 64bit requests. And
      first step is moving to int64_t type for both offset and bytes
      arguments in all block request related functions.
      
      It's mostly safe (when widening signed or unsigned int to int64_t), but
      switching from uint64_t is questionable.
      
      So, let's first establish the set of requests we want to work with.
      First signed int64_t should be enough, as off_t is signed anyway. Then,
      obviously offset + bytes should not overflow.
      
      And most interesting: (offset + bytes) being aligned up should not
      overflow as well. Aligned to what alignment? First thing that comes in
      mind is bs->bl.request_alignment, as we align up request to this
      alignment. But there is another thing: look at
      bdrv_mark_request_serialising(). It aligns request up to some given
      alignment. And this parameter may be bdrv_get_cluster_size(), which is
      often a lot greater than bs->bl.request_alignment.
      Note also, that bdrv_mark_request_serialising() uses signed int64_t for
      calculations. So, actually, we already depend on some restrictions.
      
      Happily, bdrv_get_cluster_size() returns int and
      bs->bl.request_alignment has 32bit unsigned type, but defined to be a
      power of 2 less than INT_MAX. So, we may establish, that INT_MAX is
      absolute maximum for any kind of alignment that may occur with the
      request.
      
      Note, that bdrv_get_cluster_size() is not documented to return power
      of 2, still bdrv_mark_request_serialising() behaves like it is.
      Also, backup uses bdi.cluster_size and is not prepared to it not being
      power of 2.
      So, let's establish that Qemu supports only power-of-2 clusters and
      alignments.
      
      So, alignment can't be greater than 2^30.
      
      Finally to be safe with calculations, to not calculate different
      maximums for different nodes (depending on cluster size and
      request_alignment), let's simply set QEMU_ALIGN_DOWN(INT64_MAX, 2^30)
      as absolute maximum bytes length for Qemu. Actually, it's not much less
      than INT64_MAX.
      
      OK, then, let's apply it to block/io.
      
      Let's consider all block/io entry points of offset/bytes:
      
      4 bytes/offset interface functions: bdrv_co_preadv_part(),
      bdrv_co_pwritev_part(), bdrv_co_copy_range_internal() and
      bdrv_co_pdiscard() and we check them all with bdrv_check_request().
      
      We also have one entry point with only offset: bdrv_co_truncate().
      Check the offset.
      
      And one public structure: BdrvTrackedRequest. Happily, it has only
      three external users:
      
       file-posix.c: adopted by this patch
       write-threshold.c: only read fields
       test-write-threshold.c: sets obviously small constant values
      
      Better is to make the structure private and add corresponding
      interfaces.. Still it's not obvious what kind of interface is needed
      for file-posix.c. Let's keep it public but add corresponding
      assertions.
      
      After this patch we'll convert functions in block/io.c to int64_t bytes
      and offset parameters. We can assume that offset/bytes pair always
      satisfy new restrictions, and make
      corresponding assertions where needed. If we reach some offset/bytes
      point in block/io.c missing bdrv_check_request() it is considered a
      bug. As well, if block/io.c modifies a offset/bytes request, expanding
      it more then aligning up to request_alignment, it's a bug too.
      
      For all io requests except for discard we keep for now old restriction
      of 32bit request length.
      
      iotest 206 output error message changed, as now test disk size is
      larger than new limit. Add one more test case with new maximum disk
      size to cover too-big-L1 case.
      
      Signed-off-by: default avatarVladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
      Message-Id: <20201203222713.13507-5-vsementsov@virtuozzo.com>
      Signed-off-by: default avatarKevin Wolf <kwolf@redhat.com>
      8b117001
    • Vladimir Sementsov-Ogievskiy's avatar
      block/io: bdrv_check_byte_request(): drop bdrv_is_inserted() · f4dad307
      Vladimir Sementsov-Ogievskiy authored
      
      Move bdrv_is_inserted() calls into callers.
      
      We are going to make bdrv_check_byte_request() a clean thing.
      bdrv_is_inserted() is not about checking the request, it's about
      checking the bs. So, it should be separate.
      
      With this patch we probably change error path for some failure
      scenarios. But depending on the fact that querying too big request on
      empty cdrom (or corrupted qcow2 node with no drv) will result in EIO
      and not ENOMEDIUM would be very strange. More over, we are going to
      move to 64bit requests, so larger requests will be allowed anyway.
      
      More over, keeping in mind that cdrom is the only driver that has
      .bdrv_is_inserted() handler it's strange that we should care so much
      about it in generic block layer, intuitively we should just do read and
      write, and cdrom driver should return correct errors if it is not
      inserted. But it's a work for another series.
      
      Signed-off-by: default avatarVladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
      Message-Id: <20201203222713.13507-4-vsementsov@virtuozzo.com>
      Reviewed-by: default avatarAlberto Garcia <berto@igalia.com>
      Signed-off-by: default avatarKevin Wolf <kwolf@redhat.com>
      f4dad307
    • Vladimir Sementsov-Ogievskiy's avatar
      block/io: bdrv_refresh_limits(): use ERRP_GUARD · 33985614
      Vladimir Sementsov-Ogievskiy authored
      
      This simplifies following commit.
      
      Signed-off-by: default avatarVladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
      Message-Id: <20201203222713.13507-3-vsementsov@virtuozzo.com>
      Reviewed-by: default avatarAlberto Garcia <berto@igalia.com>
      Signed-off-by: default avatarKevin Wolf <kwolf@redhat.com>
      33985614
    • Vladimir Sementsov-Ogievskiy's avatar
      block/file-posix: fix workaround in raw_do_pwrite_zeroes() · 9b100af3
      Vladimir Sementsov-Ogievskiy authored
      
      We should not set overlap_bytes:
      
      1. Don't worry: it is calculated by bdrv_mark_request_serialising() and
         will be equal to or greater than bytes anyway.
      
      2. If the request was already aligned up to some greater alignment,
         than we may break things: we reduce overlap_bytes, and further
         bdrv_mark_request_serialising() may not help, as it will not restore
         old bigger alignment.
      
      Signed-off-by: default avatarVladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
      Message-Id: <20201203222713.13507-2-vsementsov@virtuozzo.com>
      Signed-off-by: default avatarKevin Wolf <kwolf@redhat.com>
      9b100af3
    • Li Feng's avatar
      file-posix: check the use_lock before setting the file lock · eb43ea16
      Li Feng authored
      
      The scenario is that when accessing a volume on an NFS filesystem
      without supporting the file lock,  Qemu will complain "Failed to lock
      byte 100", even when setting the file.locking = off.
      
      We should do file lock related operations only when the file.locking is
      enabled, otherwise, the syscall of 'fcntl' will return non-zero.
      
      Signed-off-by: default avatarLi Feng <fengli@smartx.com>
      Message-Id: <1607341446-85506-1-git-send-email-fengli@smartx.com>
      Signed-off-by: default avatarKevin Wolf <kwolf@redhat.com>
      eb43ea16
    • Hanna Reitz's avatar
      fuse: Implement hole detection through lseek · df4ea709
      Hanna Reitz authored
      
      This is a relatively new feature in libfuse (available since 3.8.0,
      which was released in November 2019), so we have to add a dedicated
      check whether it is available before making use of it.
      
      Signed-off-by: default avatarMax Reitz <mreitz@redhat.com>
      Message-Id: <20201027190600.192171-7-mreitz@redhat.com>
      Signed-off-by: default avatarKevin Wolf <kwolf@redhat.com>
      df4ea709
    • Hanna Reitz's avatar
      fuse: (Partially) implement fallocate() · 4ca37a96
      Hanna Reitz authored
      
      This allows allocating areas after the (old) EOF as part of a growing
      resize, writing zeroes, and discarding.
      
      Signed-off-by: default avatarMax Reitz <mreitz@redhat.com>
      Message-Id: <20201027190600.192171-6-mreitz@redhat.com>
      Signed-off-by: default avatarKevin Wolf <kwolf@redhat.com>
      4ca37a96
    • Hanna Reitz's avatar
      fuse: Allow growable exports · 4fba06d5
      Hanna Reitz authored
      
      These will behave more like normal files in that writes beyond the EOF
      will automatically grow the export size.
      
      As an optimization, keep the RESIZE permission for growable exports so
      we do not have to take it for every post-EOF write.  (This permission is
      not released when the export is destroyed, because at that point the
      BlockBackend is destroyed altogether anyway.)
      
      Signed-off-by: default avatarMax Reitz <mreitz@redhat.com>
      Message-Id: <20201027190600.192171-5-mreitz@redhat.com>
      Signed-off-by: default avatarKevin Wolf <kwolf@redhat.com>
      4fba06d5
    • Hanna Reitz's avatar
      fuse: Implement standard FUSE operations · 41429e3d
      Hanna Reitz authored
      
      This makes the export actually useful instead of only producing errors
      whenever it is accessed.
      
      Signed-off-by: default avatarMax Reitz <mreitz@redhat.com>
      Message-Id: <20201027190600.192171-4-mreitz@redhat.com>
      Signed-off-by: default avatarKevin Wolf <kwolf@redhat.com>
      41429e3d
    • Hanna Reitz's avatar
      fuse: Allow exporting BDSs via FUSE · 0c9b70d5
      Hanna Reitz authored
      
      block-export-add type=fuse allows mounting block graph nodes via FUSE on
      some existing regular file.  That file should then appears like a raw
      disk image, and accesses to it result in accesses to the exported BDS.
      
      Right now, we only implement the necessary block export functions to set
      it up and shut it down.  We do not implement any access functions, so
      accessing the mount point only results in errors.  This will be
      addressed by a followup patch.
      
      We keep a hash table of exported mount points, because we want to be
      able to detect when users try to use a mount point twice.  This is
      because we invoke stat() to check whether the given mount point is a
      regular file, but if that file is served by ourselves (because it is
      already used as a mount point), then this stat() would have to be served
      by ourselves, too, which is impossible to do while we (as the caller)
      are waiting for it to settle.  Therefore, keep track of mount point
      paths to at least catch the most obvious instances of that problem.
      
      Signed-off-by: default avatarMax Reitz <mreitz@redhat.com>
      Message-Id: <20201027190600.192171-3-mreitz@redhat.com>
      Signed-off-by: default avatarKevin Wolf <kwolf@redhat.com>
      0c9b70d5
    • Gan Qixin's avatar
      block/iscsi: Use lock guard macros · c208b0ef
      Gan Qixin authored
      
      Replace manual lock()/unlock() calls with lock guard macros
      (QEMU_LOCK_GUARD/WITH_QEMU_LOCK_GUARD) in block/iscsi.
      
      Signed-off-by: default avatarGan Qixin <ganqixin@huawei.com>
      Message-Id: <20201203075055.127773-5-ganqixin@huawei.com>
      Signed-off-by: default avatarKevin Wolf <kwolf@redhat.com>
      c208b0ef
Loading