1. 30 4月, 2014 17 次提交
    • M
      curl: Remove erroneous sleep waiting for curl completion · e4661837
      Matthew Booth 提交于
      The driver will not start more than a fixed number of curl sessions.
      If it needs more, it must wait for the completion of an existing one.
      The driver was sleeping, which will prevent the main loop from
      running, and therefore the event it's waiting on. It was also directly
      calling its internal handler rather than waiting on existing
      registered handlers to be called from the main loop.
      
      This change causes it simply to wait for a period of time whilst
      allowing the main loop to execute.
      Signed-off-by: NMatthew Booth <mbooth@redhat.com>
      Tested-by: NRichard W.M. Jones <rjones@redhat.com>
      Signed-off-by: NKevin Wolf <kwolf@redhat.com>
      e4661837
    • M
      curl: Fix return from curl_read_cb with invalid state · 38bbc0a5
      Matthew Booth 提交于
      A curl write callback is supposed to return the number of bytes it
      handled.  curl_read_cb would have erroneously reported it had handled
      all bytes in the event that the internal curl state was invalid.
      Signed-off-by: NMatthew Booth <mbooth@redhat.com>
      Tested-by: NRichard W.M. Jones <rjones@redhat.com>
      Signed-off-by: NKevin Wolf <kwolf@redhat.com>
      38bbc0a5
    • M
      curl: Remove unnecessary use of goto · 9e550b32
      Matthew Booth 提交于
      This isn't any of the usually acceptable uses of goto.
      Signed-off-by: NMatthew Booth <mbooth@redhat.com>
      Tested-by: NRichard W.M. Jones <rjones@redhat.com>
      Signed-off-by: NKevin Wolf <kwolf@redhat.com>
      9e550b32
    • M
      curl: Fix long line · f6246509
      Matthew Booth 提交于
      Signed-off-by: NMatthew Booth <mbooth@redhat.com>
      Tested-by: NRichard W.M. Jones <rjones@redhat.com>
      Signed-off-by: NKevin Wolf <kwolf@redhat.com>
      f6246509
    • M
      block/vdi: Error out immediately in vdi_create() · 0549ea8b
      Max Reitz 提交于
      Currently, if an error occurs during the part of vdi_create() which
      actually writes the image, the function stores -errno, but continues
      anyway.
      
      Instead of trying to write data which (if it can be written at all) does
      not make any sense without the operations before succeeding (e.g.,
      writing the image header), just error out immediately.
      Signed-off-by: NMax Reitz <mreitz@redhat.com>
      Reviewed-by: NStefan Weil <sw@weilnetz.de>
      Signed-off-by: NKevin Wolf <kwolf@redhat.com>
      0549ea8b
    • M
      block/bochs: Fix error handling for seek_to_sector() · e1b42f45
      Max Reitz 提交于
      Currently, seek_to_sector() returns -1 both for errors and unallocated
      sectors, resulting in silent errors. As 0 is an invalid offset of data
      clusters (bitmap_offset is greater than 0 because s->data_offset is
      greater than 0), just return 0 for unallocated sectors and -errno in
      case of error. This should then be propagated by bochs_read(), the sole
      user of seek_to_sector().
      
      That function also has a case of "return -1 in case of error", which is
      fixed by this patch as well.
      
      bochs_read() is called by bochs_co_read() which passes the return value
      through, therefore it is indeed correct for bochs_read() to return
      -errno.
      Signed-off-by: NMax Reitz <mreitz@redhat.com>
      Signed-off-by: NKevin Wolf <kwolf@redhat.com>
      e1b42f45
    • M
      qcow2: Check min_size in qcow2_grow_l1_table() · b93f9950
      Max Reitz 提交于
      First, new_l1_size is an int64_t, whereas min_size is a uint64_t.
      Therefore, during the loop which adjusts new_l1_size until it equals or
      exceeds min_size, new_l1_size might overflow and become negative. The
      comparison in the loop condition however will take it as an unsigned
      value (because min_size is unsigned) and therefore recognize it as
      exceeding min_size. Therefore, the loop is left with a negative
      new_l1_size, which is not correct. This could be fixed by making
      new_l1_size uint64_t.
      
      On the other hand, however, by doing this, the while loop may take
      forever. If min_size is e.g. UINT64_MAX, it will take new_l1_size
      probably multiple overflows to reach the exact same value (if it reaches
      it at all). Then, right after the loop, new_l1_size will be recognized
      as being too big anyway.
      
      Both problems require a ridiculously high min_size value, which is very
      unlikely to occur; but both problems are also simply avoided by checking
      whether min_size is sane before calculating new_l1_size (which should
      still be checked separately, though).
      Signed-off-by: NMax Reitz <mreitz@redhat.com>
      Signed-off-by: NKevin Wolf <kwolf@redhat.com>
      b93f9950
    • M
      qcow2: Catch bdrv_getlength() error · a49139af
      Max Reitz 提交于
      The call to bdrv_getlength() from qcow2_check_refcounts() may result in
      an error. Check this and abort if necessary.
      Signed-off-by: NMax Reitz <mreitz@redhat.com>
      Signed-off-by: NKevin Wolf <kwolf@redhat.com>
      a49139af
    • M
      block: Use correct width in format strings · 521b2b5d
      Max Reitz 提交于
      Instead of blindly relying on a normal integer having a width of 32 bits
      (which is a pretty good assumption, but we should not rely on it if
      there is no need), use the correct format string macros.
      
      This does not touch DEBUG output.
      Signed-off-by: NMax Reitz <mreitz@redhat.com>
      Signed-off-by: NKevin Wolf <kwolf@redhat.com>
      521b2b5d
    • M
      qcow2: Avoid overflow in alloc_clusters_noref() · 91f827dc
      Max Reitz 提交于
      alloc_clusters_noref() stores the cluster index in a uint64_t. However,
      offsets are often represented as int64_t (as for example the return
      value of alloc_clusters_noref() itself demonstrates). Therefore, we
      should make sure all offsets in the allocated range of clusters are
      representable using int64_t without overflows.
      Signed-off-by: NMax Reitz <mreitz@redhat.com>
      Signed-off-by: NKevin Wolf <kwolf@redhat.com>
      91f827dc
    • M
      block: Use error_abort in bdrv_image_info_specific_dump() · 35d0d40a
      Max Reitz 提交于
      Currently, bdrv_image_info_specific_dump() uses an error variable for
      visit_type_ImageInfoSpecific, but ignores the result. As this function
      is used here with an output visitor to transform the ImageInfoSpecific
      object to a generic QDict, an error should actually be impossible. It is
      however better to assert that this is indeed the case. This is done by
      this patch using error_abort instead of an unused local Error variable.
      Signed-off-by: NMax Reitz <mreitz@redhat.com>
      Reported-by: NMarkus Armbruster <armbru@redhat.com>
      Signed-off-by: NKevin Wolf <kwolf@redhat.com>
      35d0d40a
    • K
      block: Fix open_flags in bdrv_reopen() · f1f25a2e
      Kevin Wolf 提交于
      Use the same function as bdrv_open() for determining what the right
      flags for bs->file are. Without doing this, a reopen means that
      bs->file loses BDRV_O_CACHE_WB or BDRV_O_UNMAP if bs doesn't have it as
      well.
      Signed-off-by: NKevin Wolf <kwolf@redhat.com>
      Reviewed-by: NMax Reitz <mreitz@redhat.com>
      f1f25a2e
    • K
      Revert "block: another bdrv_append fix" · 7e3d98dd
      Kevin Wolf 提交于
      This reverts commit 3a389e79. The commit
      was wrong and what it tried to fix just works today without any change.
      
      What the commit tried to fix:
      
          When creating live snapshots, the new image file is opened with
          BDRV_O_NO_BACKING because the whole backing chain is already opened.
          It is then appended to the chain using bdrv_append(). The result of
          this was that the image had a backing file, but BDRV_O_NO_BACKING
          was still set. This is obviously inconsistent.
      
          There used to be some places in qemu that closed and image and then
          opened it again, with its old flags (a bdrv_open()/close() sequence
          involves reopening the whole backing file chain, too). In this case
          the BDRV_O_NO_BACKING flag meant that the backing chain wasn't
          reopened and only the top layer was left.
      
          (Most, but not all of these places are replaced by bdrv_reopen()
          today, which doesn't touch the backing files at all.)
      
          Other places that looked at bs->open_flags weren't interested in
          BDRV_O_NO_BACKING, so no breakage there.
      
      What it actually did:
      
          The commit moved the BDRV_O_NO_BACKING away to the backing file.
          Because the bdrv_open()/close() sequences only looked at the flags
          of the top level BlockDriverState and used it for the whole chain,
          the flag didn't hurt there any more. Obviously, it is still
          inconsistent because the backing file may have another backing file,
          but without practical impact.
      
          At the same time, it swapped all other flags. This is practically
          irrelevant as long as live snapshots only allow opening the new
          layer with the same flags as the old top layer. It still doesn't
          make any sense, and it is a time bomb that explodes as soon as the
          flags can differ.
      
          bdrv_append_temp_snapshot() is such a case: It adds the new flag
          BDRV_O_TEMPORARY for the temporary snapshot. The swapping of commit
          3a389e79 results in the following nonsensical configuration:
      
          bs->open_flags:                     BDRV_O_TEMPORARY cleared
          bs->file->open_flags:               BDRV_O_TEMPORARY set
          bs->backing_hd->open_flags:         BDRV_O_TEMPORARY set
          bs->backing_hd->file->open_flags:   BDRV_O_TEMPORARY cleared
      
          We're still lucky because the format layer ignores the flag and the
          protocol layer happens to get the right value, but sooner or later
          this is bound to go wrong...
      
      What the right fix would have been:
      
          Simply clear the BDRV_O_NO_BACKING flag when the BlockDriverState is
          appended to an existing backing file chain, because now it does have
          a backing file.
      
          Commit 4ddc07ca already implemented this silently in bdrv_append(),
          so we don't have to come up with a new fix.
      Signed-off-by: NKevin Wolf <kwolf@redhat.com>
      Reviewed-by: NMax Reitz <mreitz@redhat.com>
      7e3d98dd
    • K
      block: Unlink temporary files in raw-posix/win32 · 8bfea15d
      Kevin Wolf 提交于
      Instead of having unlink() calls in the generic block layer, where we
      aren't even guarateed to have a file name, move them to those block
      drivers that are actually used and that always have a filename. Gets us
      rid of some #ifdefs as well.
      
      The patch also converts bs->is_temporary to a new BDRV_O_TEMPORARY open
      flag so that it is inherited in the protocol layer and the raw-posix and
      raw-win32 drivers can unlink the file.
      Signed-off-by: NKevin Wolf <kwolf@redhat.com>
      Reviewed-by: NMax Reitz <mreitz@redhat.com>
      8bfea15d
    • K
      block: Remove BDRV_O_COPY_ON_READ for bs->file · 5669b44d
      Kevin Wolf 提交于
      Copy on Read makes sense on the format level where backing files are
      implemented, but it's not required on the protocol level. While it
      shouldn't actively break anything to have COR enabled on both layers,
      needless serialisation and allocation checks may impact performance.
      Signed-off-by: NKevin Wolf <kwolf@redhat.com>
      Reviewed-by: NMax Reitz <mreitz@redhat.com>
      5669b44d
    • K
      block: Create bdrv_backing_flags() · 317fc44e
      Kevin Wolf 提交于
      Instead of manipulation flags inline, move the derivation of the flags
      of a backing file into a new function next to the existing functions
      that derive flags for bs->file and for the block driver open function.
      Signed-off-by: NKevin Wolf <kwolf@redhat.com>
      Reviewed-by: NMax Reitz <mreitz@redhat.com>
      317fc44e
    • K
      block: Create bdrv_inherited_flags() · 0b50cc88
      Kevin Wolf 提交于
      Instead of having bdrv_open_flags() as a function that creates flags for
      several unrelated places and then adding open-coded flags on top, create
      a new function that derives the flags for bs->file from the flags for bs.
      Signed-off-by: NKevin Wolf <kwolf@redhat.com>
      Reviewed-by: NMax Reitz <mreitz@redhat.com>
      0b50cc88
  2. 29 4月, 2014 8 次提交
  3. 28 4月, 2014 15 次提交