1. 22 2月, 2016 2 次提交
  2. 17 2月, 2016 1 次提交
    • 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
  3. 09 2月, 2016 1 次提交
    • E
      qapi: Swap visit_* arguments for consistent 'name' placement · 51e72bc1
      Eric Blake 提交于
      JSON uses "name":value, but many of our visitor interfaces were
      called with visit_type_FOO(v, &value, name, errp).  This can be
      a bit confusing to have to mentally swap the parameter order to
      match JSON order.  It's particularly bad for visit_start_struct(),
      where the 'name' parameter is smack in the middle of the
      otherwise-related group of 'obj, kind, size' parameters! It's
      time to do a global swap of the parameter ordering, so that the
      'name' parameter is always immediately after the Visitor argument.
      
      Additional reason in favor of the swap: the existing include/qjson.h
      prefers listing 'name' first in json_prop_*(), and I have plans to
      unify that file with the qapi visitors; listing 'name' first in
      qapi will minimize churn to the (admittedly few) qjson.h clients.
      
      Later patches will then fix docs, object.h, visitor-impl.h, and
      those clients to match.
      
      Done by first patching scripts/qapi*.py by hand to make generated
      files do what I want, then by running the following Coccinelle
      script to affect the rest of the code base:
       $ spatch --sp-file script `git grep -l '\bvisit_' -- '**/*.[ch]'`
      I then had to apply some touchups (Coccinelle insisted on TAB
      indentation in visitor.h, and botched the signature of
      visit_type_enum() by rewriting 'const char *const strings[]' to
      the syntactically invalid 'const char*const[] strings').  The
      movement of parameters is sufficient to provoke compiler errors
      if any callers were missed.
      
          // Part 1: Swap declaration order
          @@
          type TV, TErr, TObj, T1, T2;
          identifier OBJ, ARG1, ARG2;
          @@
           void visit_start_struct
          -(TV v, TObj OBJ, T1 ARG1, const char *name, T2 ARG2, TErr errp)
          +(TV v, const char *name, TObj OBJ, T1 ARG1, T2 ARG2, TErr errp)
           { ... }
      
          @@
          type bool, TV, T1;
          identifier ARG1;
          @@
           bool visit_optional
          -(TV v, T1 ARG1, const char *name)
          +(TV v, const char *name, T1 ARG1)
           { ... }
      
          @@
          type TV, TErr, TObj, T1;
          identifier OBJ, ARG1;
          @@
           void visit_get_next_type
          -(TV v, TObj OBJ, T1 ARG1, const char *name, TErr errp)
          +(TV v, const char *name, TObj OBJ, T1 ARG1, TErr errp)
           { ... }
      
          @@
          type TV, TErr, TObj, T1, T2;
          identifier OBJ, ARG1, ARG2;
          @@
           void visit_type_enum
          -(TV v, TObj OBJ, T1 ARG1, T2 ARG2, const char *name, TErr errp)
          +(TV v, const char *name, TObj OBJ, T1 ARG1, T2 ARG2, TErr errp)
           { ... }
      
          @@
          type TV, TErr, TObj;
          identifier OBJ;
          identifier VISIT_TYPE =~ "^visit_type_";
          @@
           void VISIT_TYPE
          -(TV v, TObj OBJ, const char *name, TErr errp)
          +(TV v, const char *name, TObj OBJ, TErr errp)
           { ... }
      
          // Part 2: swap caller order
          @@
          expression V, NAME, OBJ, ARG1, ARG2, ERR;
          identifier VISIT_TYPE =~ "^visit_type_";
          @@
          (
          -visit_start_struct(V, OBJ, ARG1, NAME, ARG2, ERR)
          +visit_start_struct(V, NAME, OBJ, ARG1, ARG2, ERR)
          |
          -visit_optional(V, ARG1, NAME)
          +visit_optional(V, NAME, ARG1)
          |
          -visit_get_next_type(V, OBJ, ARG1, NAME, ERR)
          +visit_get_next_type(V, NAME, OBJ, ARG1, ERR)
          |
          -visit_type_enum(V, OBJ, ARG1, ARG2, NAME, ERR)
          +visit_type_enum(V, NAME, OBJ, ARG1, ARG2, ERR)
          |
          -VISIT_TYPE(V, OBJ, NAME, ERR)
          +VISIT_TYPE(V, NAME, OBJ, ERR)
          )
      Signed-off-by: NEric Blake <eblake@redhat.com>
      Reviewed-by: NMarc-André Lureau <marcandre.lureau@redhat.com>
      Message-Id: <1454075341-13658-19-git-send-email-eblake@redhat.com>
      Signed-off-by: NMarkus Armbruster <armbru@redhat.com>
      51e72bc1
  4. 03 2月, 2016 3 次提交
  5. 20 1月, 2016 2 次提交
  6. 13 1月, 2016 2 次提交
  7. 18 12月, 2015 2 次提交
  8. 12 11月, 2015 1 次提交
  9. 11 11月, 2015 1 次提交
  10. 16 10月, 2015 2 次提交
  11. 25 9月, 2015 1 次提交
  12. 05 9月, 2015 1 次提交
  13. 23 6月, 2015 3 次提交
  14. 22 5月, 2015 1 次提交
  15. 28 4月, 2015 1 次提交
    • K
      qemu-img convert: Rewrite copying logic · 690c7301
      Kevin Wolf 提交于
      The implementation of qemu-img convert is (a) messy, (b) buggy, and
      (c) less efficient than possible. The changes required to beat some
      sense into it are massive enough that incremental changes would only
      make my and the reviewers' life harder. So throw it away and reimplement
      it from scratch.
      
      Let me give some examples what I mean by messy, buggy and inefficient:
      
      (a) The copying logic of qemu-img convert has two separate branches for
          compressed and normal target images, which roughly do the same -
          except for a little code that handles actual differences between
          compressed and uncompressed images, and much more code that
          implements just a different set of optimisations and bugs. This is
          unnecessary code duplication, and makes the code for compressed
          output (unsurprisingly) suffer from bitrot.
      
          The code for uncompressed ouput is run twice to count the the total
          length for the progress bar. In the first run it just takes a
          shortcut and runs only half the loop, and when it's done, it toggles
          a boolean, jumps out of the loop with a backwards goto and starts
          over. Works, but pretty is something different.
      
      (b) Converting while keeping a backing file (-B option) is broken in
          several ways. This includes not writing to the image file if the
          input has zero clusters or data filled with zeros (ignoring that the
          backing file will be visible instead).
      
          It also doesn't correctly limit every iteration of the copy loop to
          sectors of the same status so that too many sectors may be copied to
          in the target image. For -B this gives an unexpected result, for
          other images it just does more work than necessary.
      
          Conversion with a compressed target completely ignores any target
          backing file.
      
      (c) qemu-img convert skips reading and writing an area if it knows from
          metadata that copying isn't needed (except for the bug mentioned
          above that ignores a status change in some cases). It does, however,
          read from the source even if it knows that it will read zeros, and
          then search for non-zero bytes in the read buffer, if it's possible
          that a write might be needed.
      
      This reimplementation of the copying core reorganises the code to remove
      the duplication and have a much more obvious code flow, by essentially
      splitting the copy iteration loop into three parts:
      
      1. Find the number of contiguous sectors of the same status at the
         current offset (This can also be called in a separate loop before the
         copying loop in order to determine the total sectors for the progress
         bar.)
      
      2. Read sectors. If the status implies that there is no data there to
         read (zero or unallocated cluster), don't do anything.
      
      3. Write sectors depending on the status. If it's data, write it. If
         we want the backing file to be visible (with -B), don't write it. If
         it's zeroed, skip it if you can, otherwise use bdrv_write_zeroes() to
         optimise the write at least where possible.
      Signed-off-by: NKevin Wolf <kwolf@redhat.com>
      Reviewed-by: NMax Reitz <mreitz@redhat.com>
      690c7301
  16. 17 3月, 2015 2 次提交
  17. 10 3月, 2015 2 次提交
  18. 26 2月, 2015 4 次提交
  19. 18 2月, 2015 2 次提交
  20. 16 2月, 2015 5 次提交
  21. 07 2月, 2015 1 次提交