1. 02 11月, 2016 2 次提交
  2. 28 10月, 2016 7 次提交
  3. 27 10月, 2016 1 次提交
  4. 15 8月, 2016 2 次提交
  5. 20 7月, 2016 3 次提交
  6. 05 7月, 2016 3 次提交
    • E
      block: Switch discard length bounds to byte-based · b9f7855a
      Eric Blake 提交于
      Sector-based limits are awkward to think about; in our on-going
      quest to move to byte-based interfaces, convert max_discard and
      discard_alignment.  Rename them, using 'pdiscard' as an aid to
      track which remaining discard interfaces need conversion, and so
      that the compiler will help us catch the change in semantics
      across any rebased code.  The BlockLimits type is now completely
      byte-based; and in iscsi.c, sector_limits_lun2qemu() is no
      longer needed.
      
      pdiscard_alignment is made unsigned (we use power-of-2 alignments
      as bitmasks, where unsigned is easier to think about) while
      leaving max_pdiscard signed (since we still have an 'int'
      interface); this is comparable to what commit cf081fca did for
      write zeroes limits.  We may later want to make everything an
      unsigned 64-bit limit - but that requires a bigger code audit.
      Signed-off-by: NEric Blake <eblake@redhat.com>
      Reviewed-by: NFam Zheng <famz@redhat.com>
      Signed-off-by: NKevin Wolf <kwolf@redhat.com>
      b9f7855a
    • E
      block: Switch transfer length bounds to byte-based · 5def6b80
      Eric Blake 提交于
      Sector-based limits are awkward to think about; in our on-going
      quest to move to byte-based interfaces, convert max_transfer_length
      and opt_transfer_length.  Rename them (dropping the _length suffix)
      so that the compiler will help us catch the change in semantics
      across any rebased code, and improve the documentation.  Use unsigned
      values, so that we don't have to worry about negative values and
      so that bit-twiddling is easier; however, we are still constrained
      by 2^31 of signed int in most APIs.
      
      When a value comes from an external source (iscsi and raw-posix),
      sanitize the results to ensure that opt_transfer is a power of 2.
      Signed-off-by: NEric Blake <eblake@redhat.com>
      Reviewed-by: NFam Zheng <famz@redhat.com>
      Signed-off-by: NKevin Wolf <kwolf@redhat.com>
      5def6b80
    • E
      nbd: Advertise realistic limits to block layer · 20220471
      Eric Blake 提交于
      We were basing the advertisement of maximum discard and transfer
      length off of UINT32_MAX, but since the rest of the block layer
      has signed int limits on a transaction, nothing could ever reach
      that maximum, and we risk overflowing an int once things are
      converted to byte-based rather than sector-based limits.  What's
      more, we DO have a much smaller limit: both the current kernel
      and qemu-nbd have a hard limit of 32M on a read or write
      transaction, and while they may also permit up to a full 32 bits
      on a discard transaction, the upstream NBD protocol is proposing
      wording that without any explicit advertisement otherwise,
      clients should limit ALL requests to the same limits as read and
      write, even though the other requests do not actually require as
      many bytes across the wire.  So the better limit to tell the
      block layer is 32M for both values.
      
      Behavior doesn't actually change with this patch (the block layer
      is currently ignoring the max_transfer advertisements); but when
      that problem is fixed in a later series, this patch will prevent
      the exposure of a latent bug.
      Signed-off-by: NEric Blake <eblake@redhat.com>
      Reviewed-by: NKevin Wolf <kwolf@redhat.com>
      Acked-by: NPaolo Bonzini <pbonzini@redhat.com>
      Reviewed-by: NFam Zheng <famz@redhat.com>
      Reviewed-by: NStefan Hajnoczi <stefanha@redhat.com>
      Signed-off-by: NKevin Wolf <kwolf@redhat.com>
      20220471
  7. 12 5月, 2016 3 次提交
    • E
      nbd: Simplify client FUA handling · 52a46505
      Eric Blake 提交于
      Now that the block layer honors per-bds FUA support, we don't
      have to duplicate the fallback flush at the NBD layer.  The
      static function nbd_co_writev_flags() is no longer needed, and
      the driver can just directly use nbd_client_co_writev().
      Signed-off-by: NEric Blake <eblake@redhat.com>
      Reviewed-by: NFam Zheng <famz@redhat.com>
      Acked-by: NStefan Hajnoczi <stefanha@redhat.com>
      Signed-off-by: NKevin Wolf <kwolf@redhat.com>
      52a46505
    • E
      block: Make supported_write_flags a per-bds property · 4df863f3
      Eric Blake 提交于
      Pre-patch, .supported_write_flags lives at the driver level, which
      means we are blindly declaring that all block devices using a
      given driver will either equally support FUA, or that we need a
      fallback at the block layer.  But there are drivers where FUA
      support is a per-block decision: the NBD block driver is dependent
      on the remote server advertising NBD_FLAG_SEND_FUA (and has
      fallback code to duplicate the flush that the block layer would do
      if NBD had not set .supported_write_flags); and the iscsi block
      driver is dependent on the mode sense bits advertised by the
      underlying device (and is currently silently ignoring FUA requests
      if the underlying device does not support FUA).
      
      The fix is to make supported flags as a per-BDS option, set during
      .bdrv_open().  This patch moves the variable and fixes NBD and iscsi
      to set it only conditionally; later patches will then further
      simplify the NBD driver to quit duplicating work done at the block
      layer, as well as tackle the fact that SCSI does not support FUA
      semantics on WRITESAME(10/16) but only on WRITE(10/16).
      Signed-off-by: NEric Blake <eblake@redhat.com>
      Reviewed-by: NFam Zheng <famz@redhat.com>
      Acked-by: NStefan Hajnoczi <stefanha@redhat.com>
      Signed-off-by: NKevin Wolf <kwolf@redhat.com>
      4df863f3
    • K
      block: Introduce bdrv_driver_pwritev() · 78a07294
      Kevin Wolf 提交于
      This is a function that simply calls into the block driver for doing a
      write, providing the byte granularity interface we want to eventually
      have everywhere, and using whatever interface that driver supports.
      
      This one is a bit more interesting than the version for reads: It adds
      support for .bdrv_co_writev_flags() everywhere, so that drivers
      implementing this function can drop .bdrv_co_writev() now.
      Signed-off-by: NKevin Wolf <kwolf@redhat.com>
      Reviewed-by: NEric Blake <eblake@redhat.com>
      Reviewed-by: NFam Zheng <famz@redhat.com>
      78a07294
  8. 30 3月, 2016 1 次提交
    • K
      nbd: Support BDRV_REQ_FUA · 2b556518
      Kevin Wolf 提交于
      The NBD server already used to send a FUA flag when the writethrough
      mode was set. This code was a remnant from the times where protocol
      drivers actually had to implement writethrough modes. Since nowadays the
      block layer sends flushes in writethrough mode and non-root nodes are
      always writeback, this was mostly dead code - only mostly because if NBD
      was configured to be used without a format, we sent _both_ FUA and an
      explicit flush afterwards, which makes the code not technically dead,
      but useless overhead.
      
      This patch changes the code so that the block layer's FUA flag is
      recognised and translated into a NBD FUA flag. The additional flush is
      avoided now.
      Signed-off-by: NKevin Wolf <kwolf@redhat.com>
      Reviewed-by: NMax Reitz <mreitz@redhat.com>
      2b556518
  9. 23 3月, 2016 2 次提交
    • V
      util: move declarations out of qemu-common.h · f348b6d1
      Veronia Bahaa 提交于
      Move declarations out of qemu-common.h for functions declared in
      utils/ files: e.g. include/qemu/path.h for utils/path.c.
      Move inline functions out of qemu-common.h and into new files (e.g.
      include/qemu/bcd.h)
      Signed-off-by: NVeronia Bahaa <veroniabahaa@gmail.com>
      Signed-off-by: NPaolo Bonzini <pbonzini@redhat.com>
      f348b6d1
    • M
      include/qemu/osdep.h: Don't include qapi/error.h · da34e65c
      Markus Armbruster 提交于
      Commit 57cb38b3 included qapi/error.h into qemu/osdep.h to get the
      Error typedef.  Since then, we've moved to include qemu/osdep.h
      everywhere.  Its file comment explains: "To avoid getting into
      possible circular include dependencies, this file should not include
      any other QEMU headers, with the exceptions of config-host.h,
      compiler.h, os-posix.h and os-win32.h, all of which are doing a
      similar job to this file and are under similar constraints."
      qapi/error.h doesn't do a similar job, and it doesn't adhere to
      similar constraints: it includes qapi-types.h.  That's in excess of
      100KiB of crap most .c files don't actually need.
      
      Add the typedef to qemu/typedefs.h, and include that instead of
      qapi/error.h.  Include qapi/error.h in .c files that need it and don't
      get it now.  Include qapi-types.h in qom/object.h for uint16List.
      
      Update scripts/clean-includes accordingly.  Update it further to match
      reality: replace config.h by config-target.h, add sysemu/os-posix.h,
      sysemu/os-win32.h.  Update the list of includes in the qemu/osdep.h
      comment quoted above similarly.
      
      This reduces the number of objects depending on qapi/error.h from "all
      of them" to less than a third.  Unfortunately, the number depending on
      qapi-types.h shrinks only a little.  More work is needed for that one.
      Signed-off-by: NMarkus Armbruster <armbru@redhat.com>
      [Fix compilation without the spice devel packages. - Paolo]
      Signed-off-by: NPaolo Bonzini <pbonzini@redhat.com>
      da34e65c
  10. 18 3月, 2016 1 次提交
    • E
      qapi: Don't special-case simple union wrappers · 32bafa8f
      Eric Blake 提交于
      Simple unions were carrying a special case that hid their 'data'
      QMP member from the resulting C struct, via the hack method
      QAPISchemaObjectTypeVariant.simple_union_type().  But by using
      the work we started by unboxing flat union and alternate
      branches, coupled with the ability to visit the members of an
      implicit type, we can now expose the simple union's implicit
      type in qapi-types.h:
      
      | struct q_obj_ImageInfoSpecificQCow2_wrapper {
      |     ImageInfoSpecificQCow2 *data;
      | };
      |
      | struct q_obj_ImageInfoSpecificVmdk_wrapper {
      |     ImageInfoSpecificVmdk *data;
      | };
      ...
      | struct ImageInfoSpecific {
      |     ImageInfoSpecificKind type;
      |     union { /* union tag is @type */
      |         void *data;
      |-        ImageInfoSpecificQCow2 *qcow2;
      |-        ImageInfoSpecificVmdk *vmdk;
      |+        q_obj_ImageInfoSpecificQCow2_wrapper qcow2;
      |+        q_obj_ImageInfoSpecificVmdk_wrapper vmdk;
      |     } u;
      | };
      
      Doing this removes asymmetry between QAPI's QMP side and its
      C side (both sides now expose 'data'), and means that the
      treatment of a simple union as sugar for a flat union is now
      equivalent in both languages (previously the two approaches used
      a different layer of dereferencing, where the simple union could
      be converted to a flat union with equivalent C layout but
      different {} on the wire, or to an equivalent QMP wire form
      but with different C representation).  Using the implicit type
      also lets us get rid of the simple_union_type() hack.
      
      Of course, now all clients of simple unions have to adjust from
      using su->u.member to using su->u.member.data; while this touches
      a number of files in the tree, some earlier cleanup patches
      helped minimize the change to the initialization of a temporary
      variable rather than every single member access.  The generated
      qapi-visit.c code is also affected by the layout change:
      
      |@@ -7393,10 +7393,10 @@ void visit_type_ImageInfoSpecific_member
      |     }
      |     switch (obj->type) {
      |     case IMAGE_INFO_SPECIFIC_KIND_QCOW2:
      |-        visit_type_ImageInfoSpecificQCow2(v, "data", &obj->u.qcow2, &err);
      |+        visit_type_q_obj_ImageInfoSpecificQCow2_wrapper_members(v, &obj->u.qcow2, &err);
      |         break;
      |     case IMAGE_INFO_SPECIFIC_KIND_VMDK:
      |-        visit_type_ImageInfoSpecificVmdk(v, "data", &obj->u.vmdk, &err);
      |+        visit_type_q_obj_ImageInfoSpecificVmdk_wrapper_members(v, &obj->u.vmdk, &err);
      |         break;
      |     default:
      |         abort();
      Signed-off-by: NEric Blake <eblake@redhat.com>
      Message-Id: <1458254921-17042-13-git-send-email-eblake@redhat.com>
      Signed-off-by: NMarkus Armbruster <armbru@redhat.com>
      32bafa8f
  11. 05 3月, 2016 1 次提交
    • E
      util: Shorten references into SocketAddress · 0399293e
      Eric Blake 提交于
      An upcoming patch will alter how simple unions, like SocketAddress,
      are laid out, which will impact all lines of the form 'addr->u.XXX'
      (expanding it to the longer 'addr->u.XXX.data').  For better
      legibility in that patch, and less need for line wrapping, it's better
      to use a temporary variable to reduce the effect of a layout change to
      just the variable initializations, rather than every reference within
      a SocketAddress.  Also, take advantage of some C99 initialization where
      it makes sense (simplifying g_new0() to g_new()).
      Signed-off-by: NEric Blake <eblake@redhat.com>
      Message-Id: <1457021813-10704-7-git-send-email-eblake@redhat.com>
      Signed-off-by: NMarkus Armbruster <armbru@redhat.com>
      0399293e
  12. 17 2月, 2016 2 次提交
    • D
      nbd: enable use of TLS with NBD block driver · 75822a12
      Daniel P. Berrange 提交于
      This modifies the NBD driver so that it is possible to request
      use of TLS. This is done by providing the 'tls-creds' parameter
      with the ID of a previously created QCryptoTLSCreds object.
      
      For example
      
        $QEMU -object tls-creds-x509,id=tls0,endpoint=client,\
                      dir=/home/berrange/security/qemutls \
              -drive driver=nbd,host=localhost,port=9000,tls-creds=tls0
      
      The client will drop the connection if the NBD server does not
      provide TLS.
      Signed-off-by: NDaniel P. Berrange <berrange@redhat.com>
      Message-Id: <1455129674-17255-15-git-send-email-berrange@redhat.com>
      Signed-off-by: NPaolo Bonzini <pbonzini@redhat.com>
      75822a12
    • D
      nbd: convert block client to use I/O channels for connection setup · 064097d9
      Daniel P. Berrange 提交于
      This converts the NBD block driver client to use the QIOChannelSocket
      class for initial connection setup. The NbdClientSession struct has
      two pointers, one to the master QIOChannelSocket providing the raw
      data channel, and one to a QIOChannel which is the current channel
      used for I/O. Initially the two point to the same object, but when
      TLS support is added, they will point to different objects.
      
      The qemu-img & qemu-io tools now need to use MODULE_INIT_QOM to
      ensure the QIOChannel object classes are registered. The qemu-nbd
      tool already did this.
      
      In this initial conversion though, all I/O is still actually done
      using the raw POSIX sockets APIs.
      Signed-off-by: NDaniel P. Berrange <berrange@redhat.com>
      Message-Id: <1455129674-17255-4-git-send-email-berrange@redhat.com>
      Signed-off-by: NPaolo Bonzini <pbonzini@redhat.com>
      064097d9
  13. 20 1月, 2016 1 次提交
  14. 18 12月, 2015 1 次提交
  15. 02 11月, 2015 1 次提交
    • E
      block: Convert to new qapi union layout · 6a8f9661
      Eric Blake 提交于
      We have two issues with our qapi union layout:
      1) Even though the QMP wire format spells the tag 'type', the
      C code spells it 'kind', requiring some hacks in the generator.
      2) The C struct uses an anonymous union, which places all tag
      values in the same namespace as all non-variant members. This
      leads to spurious collisions if a tag value matches a non-variant
      member's name.
      
      Make the conversion to the new layout for block-related code.
      Signed-off-by: NEric Blake <eblake@redhat.com>
      Message-Id: <1445898903-12082-16-git-send-email-eblake@redhat.com>
      [Commit message tweaked slightly]
      Signed-off-by: NMarkus Armbruster <armbru@redhat.com>
      6a8f9661
  16. 25 9月, 2015 1 次提交
  17. 18 3月, 2015 1 次提交
  18. 10 3月, 2015 1 次提交
  19. 26 2月, 2015 1 次提交
  20. 16 2月, 2015 1 次提交
    • M
      nbd: Drop BDS backpointer · f53a829b
      Max Reitz 提交于
      Before this patch, the "opaque" pointer in an NBD BDS points to a
      BDRVNBDState, which contains an NbdClientSession object, which in turn
      contains a pointer to the BDS. This pointer may become invalid due to
      bdrv_swap(), so drop it, and instead pass the BDS directly to the
      nbd-client.c functions which then retrieve the NbdClientSession object
      from there.
      Signed-off-by: NMax Reitz <mreitz@redhat.com>
      Reviewed-by: NPaolo Bonzini <pbonzini@redhat.com>
      Message-id: 1423256778-3340-2-git-send-email-mreitz@redhat.com
      Signed-off-by: NStefan Hajnoczi <stefanha@redhat.com>
      f53a829b
  21. 07 2月, 2015 2 次提交
    • D
      nbd: fix max_discard/max_transfer_length · fa21e6fa
      Denis V. Lunev 提交于
      nbd_co_discard calls nbd_client_session_co_discard which uses uint32_t
      as the length in bytes of the data to discard due to the following
      definition:
      
      struct nbd_request {
          uint32_t magic;
          uint32_t type;
          uint64_t handle;
          uint64_t from;
          uint32_t len; <-- the length of data to be discarded, in bytes
      } QEMU_PACKED;
      
      Thus we should limit bl_max_discard to UINT32_MAX >> BDRV_SECTOR_BITS to
      avoid overflow.
      
      NBD read/write code uses the same structure for transfers. Fix
      max_transfer_length accordingly.
      Signed-off-by: NDenis V. Lunev <den@openvz.org>
      CC: Peter Lieven <pl@kamp.de>
      CC: Kevin Wolf <kwolf@redhat.com>
      Signed-off-by: NKevin Wolf <kwolf@redhat.com>
      fa21e6fa
    • M
      nbd: Improve error messages · 1ce52846
      Max Reitz 提交于
      This patch makes use of the Error object for nbd_receive_negotiate() so
      that errors during negotiation look nicer.
      
      Furthermore, this patch adds an additional error message if the received
      magic was wrong, but would be correct for the other protocol version,
      respectively: So if an export name was specified, but the NBD server
      magic corresponds to an old handshake, this condition is explicitly
      signaled to the user, and vice versa.
      
      As these messages are now part of the "Could not open image" error
      message, additional filtering has to be employed in iotest 083, which
      this patch does as well.
      Signed-off-by: NMax Reitz <mreitz@redhat.com>
      Reviewed-by: NPaolo Bonzini <pbonzini@redhat.com>
      Signed-off-by: NKevin Wolf <kwolf@redhat.com>
      1ce52846
  22. 20 10月, 2014 1 次提交
    • M
      nbd: Fix filename generation · ec0de768
      Max Reitz 提交于
      Export names may be used with nbd+unix, too, fix nbd_refresh_filename()
      accordingly. Also, for nbd+tcp, the documented path schema is
      "nbd://host[:port]/export", so use it. Furthermore, as can be seen from
      that schema, the port is optional.
      
      That makes six single cases for how the filename can be formatted; it is
      not easy to generalize these cases without the resulting statement being
      completely unreadable, thus there is simply one snprintf() per case.
      
      Finally, taking the options from BDRVNBDState::socket_opts is wrong,
      because those will not contain the export name. Just use
      BlockDriverState::options instead.
      Reported-by: NStefan Hajnoczi <stefanha@redhat.com>
      Signed-off-by: NMax Reitz <mreitz@redhat.com>
      Reviewed-by: NPaolo Bonzini <pbonzini@redhat.com>
      Signed-off-by: NKevin Wolf <kwolf@redhat.com>
      ec0de768
  23. 20 8月, 2014 1 次提交