1. 31 1月, 2019 1 次提交
  2. 18 1月, 2019 1 次提交
    • P
      block/sheepdog: Use QEMU_NONSTRING for non NUL-terminated arrays · 97b583f4
      Philippe Mathieu-Daudé 提交于
      GCC 8 added a -Wstringop-truncation warning:
      
        The -Wstringop-truncation warning added in GCC 8.0 via r254630 for
        bug 81117 is specifically intended to highlight likely unintended
        uses of the strncpy function that truncate the terminating NUL
        character from the source string.
      
      This new warning leads to compilation failures:
      
          CC      block/sheepdog.o
        qemu/block/sheepdog.c: In function 'find_vdi_name':
        qemu/block/sheepdog.c:1239:5: error: 'strncpy' specified bound 256 equals destination size [-Werror=stringop-truncation]
             strncpy(buf + SD_MAX_VDI_LEN, tag, SD_MAX_VDI_TAG_LEN);
             ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
        make: *** [qemu/rules.mak:69: block/sheepdog.o] Error 1
      
      As described previous to the strncpy() calls, the use of strncpy() is
      correct here:
      
          /* This pair of strncpy calls ensures that the buffer is zero-filled,
           * which is desirable since we'll soon be sending those bytes, and
           * don't want the send_req to read uninitialized data.
           */
          strncpy(buf, filename, SD_MAX_VDI_LEN);
          strncpy(buf + SD_MAX_VDI_LEN, tag, SD_MAX_VDI_TAG_LEN);
      
      Use the QEMU_NONSTRING attribute, since this array is intended to store
      character arrays that do not necessarily contain a terminating NUL.
      Suggested-by: NMichael S. Tsirkin <mst@redhat.com>
      Reviewed-by: NEric Blake <eblake@redhat.com>
      Reviewed-by: NMichael S. Tsirkin <mst@redhat.com>
      Signed-off-by: NPhilippe Mathieu-Daudé <philmd@redhat.com>
      97b583f4
  3. 11 1月, 2019 1 次提交
    • P
      qemu/queue.h: leave head structs anonymous unless necessary · b58deb34
      Paolo Bonzini 提交于
      Most list head structs need not be given a name.  In most cases the
      name is given just in case one is going to use QTAILQ_LAST, QTAILQ_PREV
      or reverse iteration, but this does not apply to lists of other kinds,
      and even for QTAILQ in practice this is only rarely needed.  In addition,
      we will soon reimplement those macros completely so that they do not
      need a name for the head struct.  So clean up everything, not giving a
      name except in the rare case where it is necessary.
      Signed-off-by: NPaolo Bonzini <pbonzini@redhat.com>
      b58deb34
  4. 19 10月, 2018 1 次提交
    • M
      block: Use warn_report() & friends to report warnings · 5197f445
      Markus Armbruster 提交于
      Calling error_report() in a function that takes an Error ** argument
      is suspicious.  Convert a few that are actually warnings to
      warn_report().
      
      While there, split warnings consisting of multiple sentences to
      conform to conventions spelled out in warn_report()'s contract, and
      improve a rather useless warning in sheepdog.c.
      
      Cc: Kevin Wolf <kwolf@redhat.com>
      Cc: Ronnie Sahlberg <ronniesahlberg@gmail.com>
      Cc: Paolo Bonzini <pbonzini@redhat.com>
      Cc: Peter Lieven <pl@kamp.de>
      Cc: Liu Yuan <namei.unix@gmail.com>
      Signed-off-by: NMarkus Armbruster <armbru@redhat.com>
      Reviewed-by: NEric Blake <eblake@redhat.com>
      Message-Id: <20181017082702.5581-4-armbru@redhat.com>
      
      Drop changes to "without an explicit read-only=on" warnings, because
      there's a series removing them pending.  Also drop a cc: to a former
      Sheepdog maintainer.
      Reviewed-by: NKevin Wolf <kwolf@redhat.com>
      5197f445
  5. 29 6月, 2018 1 次提交
    • K
      block: Convert .bdrv_truncate callback to coroutine_fn · 061ca8a3
      Kevin Wolf 提交于
      bdrv_truncate() is an operation that can block (even for a quite long
      time, depending on the PreallocMode) in I/O paths that shouldn't block.
      Convert it to a coroutine_fn so that we have the infrastructure for
      drivers to make their .bdrv_co_truncate implementation asynchronous.
      
      This change could potentially introduce new race conditions because
      bdrv_truncate() isn't necessarily executed atomically any more. Whether
      this is a problem needs to be evaluated for each block driver that
      supports truncate:
      
      * file-posix/win32, gluster, iscsi, nfs, rbd, ssh, sheepdog: The
        protocol drivers are trivially safe because they don't actually yield
        yet, so there is no change in behaviour.
      
      * copy-on-read, crypto, raw-format: Essentially just filter drivers that
        pass the request to a child node, no problem.
      
      * qcow2: The implementation modifies metadata, so it needs to hold
        s->lock to be safe with concurrent I/O requests. In order to avoid
        double locking, this requires pulling the locking out into
        preallocate_co() and using qcow2_write_caches() instead of
        bdrv_flush().
      
      * qed: Does a single header update, this is fine without locking.
      Signed-off-by: NKevin Wolf <kwolf@redhat.com>
      Reviewed-by: NStefan Hajnoczi <stefanha@redhat.com>
      061ca8a3
  6. 15 6月, 2018 4 次提交
    • M
    • M
      block: Fix -drive for certain non-string scalars · 374c5246
      Markus Armbruster 提交于
      The previous commit fixed -blockdev breakage due to misuse of the
      qobject input visitor's keyval flavor in bdrv_file_open().  The commit
      message explain why using the plain flavor would be just as wrong; it
      would break -drive.  Turns out we break it in three places:
      nbd_open(), sd_open() and ssh_file_open().  They are even marked
      FIXME.  Example breakage:
      
          $ qemu-system-x86 -drive node-name=n1,driver=nbd,server.type=inet,server.host=localhost,server.port=1234,server.numeric=off
          qemu-system-x86: -drive node-name=n1,driver=nbd,server.type=inet,server.host=localhost,server.port=1234,server.numeric=off: Invalid parameter type for 'numeric', expected: boolean
      
      Fix it the same way: replace qdict_crumple() by
      qdict_crumple_for_keyval_qiv(), and switch from plain to the keyval
      flavor.
      Signed-off-by: NMarkus Armbruster <armbru@redhat.com>
      Reviewed-by: NKevin Wolf <kwolf@redhat.com>
      Signed-off-by: NKevin Wolf <kwolf@redhat.com>
      374c5246
    • M
      block: Fix -blockdev for certain non-string scalars · e5af0da1
      Markus Armbruster 提交于
      Configuration flows through the block subsystem in a rather peculiar
      way.  Configuration made with -drive enters it as QemuOpts.
      Configuration made with -blockdev / blockdev-add enters it as QAPI
      type BlockdevOptions.  The block subsystem uses QDict, QemuOpts and
      QAPI types internally.  The precise flow is next to impossible to
      explain (I tried for this commit message, but gave up after wasting
      several hours).  What I can explain is a flaw in the BlockDriver
      interface that leads to this bug:
      
          $ qemu-system-x86_64 -blockdev node-name=n1,driver=nfs,server.type=inet,server.host=localhost,path=/foo/bar,user=1234
          qemu-system-x86_64: -blockdev node-name=n1,driver=nfs,server.type=inet,server.host=localhost,path=/foo/bar,user=1234: Internal error: parameter user invalid
      
      QMP blockdev-add is broken the same way.
      
      Here's what happens.  The block layer passes configuration represented
      as flat QDict (with dotted keys) to BlockDriver methods
      .bdrv_file_open().  The QDict's members are typed according to the
      QAPI schema.
      
      nfs_file_open() converts it to QAPI type BlockdevOptionsNfs, with
      qdict_crumple() and a qobject input visitor.
      
      This visitor comes in two flavors.  The plain flavor requires scalars
      to be typed according to the QAPI schema.  That's the case here.  The
      keyval flavor requires string scalars.  That's not the case here.
      nfs_file_open() uses the latter, and promptly falls apart for members
      @user, @group, @tcp-syn-count, @readahead-size, @page-cache-size,
      @debug.
      
      Switching to the plain flavor would fix -blockdev, but break -drive,
      because there the scalars arrive in nfs_file_open() as strings.
      
      The proper fix would be to replace the QDict by QAPI type
      BlockdevOptions in the BlockDriver interface.  Sadly, that's beyond my
      reach right now.
      
      Next best would be to fix the block layer to always pass correctly
      typed QDicts to the BlockDriver methods.  Also beyond my reach.
      
      What I can do is throw another hack onto the pile: have
      nfs_file_open() convert all members to string, so use of the keyval
      flavor actually works, by replacing qdict_crumple() by new function
      qdict_crumple_for_keyval_qiv().
      
      The pattern "pass result of qdict_crumple() to
      qobject_input_visitor_new_keyval()" occurs several times more:
      
      * qemu_rbd_open()
      
        Same issue as nfs_file_open(), but since BlockdevOptionsRbd has only
        string members, its only a latent bug.  Fix it anyway.
      
      * parallels_co_create_opts(), qcow_co_create_opts(),
        qcow2_co_create_opts(), bdrv_qed_co_create_opts(),
        sd_co_create_opts(), vhdx_co_create_opts(), vpc_co_create_opts()
      
        These work, because they create the QDict with
        qemu_opts_to_qdict_filtered(), which creates only string scalars.
        The function sports a TODO comment asking for better typing; that's
        going to be fun.  Use qdict_crumple_for_keyval_qiv() to be safe.
      Signed-off-by: NMarkus Armbruster <armbru@redhat.com>
      Reviewed-by: NKevin Wolf <kwolf@redhat.com>
      Signed-off-by: NKevin Wolf <kwolf@redhat.com>
      e5af0da1
    • M
      block: Add block-specific QDict header · 609f45ea
      Max Reitz 提交于
      There are numerous QDict functions that have been introduced for and are
      used only by the block layer.  Move their declarations into an own
      header file to reflect that.
      
      While qdict_extract_subqdict() is in fact used outside of the block
      layer (in util/qemu-config.c), it is still a function related very
      closely to how the block layer works with nested QDicts, namely by
      sometimes flattening them.  Therefore, its declaration is put into this
      header as well and util/qemu-config.c includes it with a comment stating
      exactly which function it needs.
      Suggested-by: NMarkus Armbruster <armbru@redhat.com>
      Signed-off-by: NMax Reitz <mreitz@redhat.com>
      Message-Id: <20180509165530.29561-7-mreitz@redhat.com>
      [Copyright note tweaked, superfluous includes dropped]
      Signed-off-by: NMarkus Armbruster <armbru@redhat.com>
      Reviewed-by: NKevin Wolf <kwolf@redhat.com>
      Signed-off-by: NKevin Wolf <kwolf@redhat.com>
      609f45ea
  7. 05 6月, 2018 2 次提交
  8. 23 5月, 2018 1 次提交
  9. 15 5月, 2018 1 次提交
    • E
      block: Merge .bdrv_co_writev{,_flags} in drivers · e18a58b4
      Eric Blake 提交于
      We have too many driver callback interfaces; simplify the mess
      somewhat by merging the flags parameter of .bdrv_co_writev_flags()
      into .bdrv_co_writev().  Note that as long as a driver doesn't set
      .supported_write_flags, the flags argument will be 0 and behavior is
      identical.  Also note that the public function bdrv_co_writev() still
      lacks a flags argument; so the driver signature is thus intentionally
      slightly different.  But that's not the end of the world, nor the first
      time that the driver interface differs slightly from the public
      interface.
      
      Ideally, we should be rewriting all of these drivers to use modern
      byte-based interfaces.  But that's a more invasive patch to write
      and audit, compared to the simplification done here.
      Signed-off-by: NEric Blake <eblake@redhat.com>
      Reviewed-by: NDaniel P. Berrangé <berrange@redhat.com>
      Signed-off-by: NKevin Wolf <kwolf@redhat.com>
      e18a58b4
  10. 08 5月, 2018 1 次提交
  11. 04 5月, 2018 1 次提交
  12. 20 3月, 2018 1 次提交
    • M
      qapi: Replace qobject_to_X(o) by qobject_to(X, o) · 7dc847eb
      Max Reitz 提交于
      This patch was generated using the following Coccinelle script:
      
      @@
      expression Obj;
      @@
      (
      - qobject_to_qnum(Obj)
      + qobject_to(QNum, Obj)
      |
      - qobject_to_qstring(Obj)
      + qobject_to(QString, Obj)
      |
      - qobject_to_qdict(Obj)
      + qobject_to(QDict, Obj)
      |
      - qobject_to_qlist(Obj)
      + qobject_to(QList, Obj)
      |
      - qobject_to_qbool(Obj)
      + qobject_to(QBool, Obj)
      )
      
      and a bit of manual fix-up for overly long lines and three places in
      tests/check-qjson.c that Coccinelle did not find.
      Signed-off-by: NMax Reitz <mreitz@redhat.com>
      Reviewed-by: NAlberto Garcia <berto@igalia.com>
      Message-Id: <20180224154033.29559-4-mreitz@redhat.com>
      Reviewed-by: NEric Blake <eblake@redhat.com>
      [eblake: swap order from qobject_to(o, X), rebase to master, also a fix
      to latent false-positive compiler complaint about hw/i386/acpi-build.c]
      Signed-off-by: NEric Blake <eblake@redhat.com>
      7dc847eb
  13. 13 3月, 2018 1 次提交
    • D
      block: include original filename when reporting invalid URIs · 44acd46f
      Daniel P. Berrangé 提交于
      Consider passing a JSON based block driver to "qemu-img commit"
      
      $ qemu-img commit 'json:{"driver":"qcow2","file":{"driver":"gluster",\
                        "volume":"gv0","path":"sn1.qcow2",
                        "server":[{"type":\
      		  "tcp","host":"10.73.199.197","port":"24007"}]},}'
      
      Currently it will commit the content and then report an incredibly
      useless error message when trying to re-open the committed image:
      
        qemu-img: invalid URI
        Usage: file=gluster[+transport]://[host[:port]]volume/path[?socket=...][,file.debug=N][,file.logfile=/path/filename.log]
      
      With this fix we get:
      
        qemu-img: invalid URI json:{"server.0.host": "10.73.199.197",
            "driver": "gluster", "path": "luks.qcow2", "server.0.type":
            "tcp", "server.0.port": "24007", "volume": "gv0"}
      
      Of course the root cause problem still exists, but now we know
      what actually needs fixing.
      Signed-off-by: NDaniel P. Berrangé <berrange@redhat.com>
      Reviewed-by: NEric Blake <eblake@redhat.com>
      Message-id: 20180206105204.14817-1-berrange@redhat.com
      Signed-off-by: NJeff Cody <jcody@redhat.com>
      44acd46f
  14. 09 3月, 2018 2 次提交
  15. 03 3月, 2018 3 次提交
  16. 13 2月, 2018 3 次提交
  17. 09 2月, 2018 1 次提交
  18. 19 12月, 2017 3 次提交
  19. 05 9月, 2017 1 次提交
  20. 04 9月, 2017 1 次提交
  21. 17 7月, 2017 1 次提交
  22. 11 7月, 2017 1 次提交
  23. 26 6月, 2017 2 次提交
  24. 20 6月, 2017 1 次提交
  25. 16 6月, 2017 1 次提交
  26. 09 5月, 2017 3 次提交