1. 27 2月, 2019 2 次提交
  2. 20 2月, 2019 1 次提交
  3. 12 2月, 2019 1 次提交
  4. 01 2月, 2019 11 次提交
  5. 31 1月, 2019 3 次提交
    • M
      iotests: Allow 147 to be run concurrently · 908b3016
      Max Reitz 提交于
      To do this, we need to allow creating the NBD server on various ports
      instead of a single one (which may not even work if you run just one
      instance, because something entirely else might be using that port).
      
      So we just pick a random port in [32768, 32768 + 1024) and try to create
      a server there.  If that fails, we just retry until something sticks.
      
      For the IPv6 test, we need a different range, though (just above that
      one).  This is because "localhost" resolves to both 127.0.0.1 and ::1.
      This means that if you bind to it, it will bind to both, if possible, or
      just one if the other is already in use.  Therefore, if the IPv6 test
      has already taken [::1]:some_port and we then try to take
      localhost:some_port, that will work -- only the second server will be
      bound to 127.0.0.1:some_port alone and not [::1]:some_port in addition.
      So we have two different servers on the same port, one for IPv4 and one
      for IPv6.
      
      But when we then try to connect to the server through
      localhost:some_port, we will always end up at the IPv6 one (as long as
      it is up), and this may not be the one we want.
      
      Thus, we must make sure not to create an IPv6-only NBD server on the
      same port as a normal "dual-stack" NBD server -- which is done by using
      distinct port ranges, as explained above.
      Signed-off-by: NMax Reitz <mreitz@redhat.com>
      Message-id: 20181221234750.23577-4-mreitz@redhat.com
      Reviewed-by: NJohn Snow <jsnow@redhat.com>
      Signed-off-by: NMax Reitz <mreitz@redhat.com>
      908b3016
    • M
      iotests: Bind qemu-nbd to localhost in 147 · dfadac9a
      Max Reitz 提交于
      By default, qemu-nbd binds to 0.0.0.0.  However, we then proceed to
      connect to "localhost".  Usually, this works out fine; but if this test
      is run concurrently, some other test function may have bound a different
      server to ::1 (on the same port -- you can bind different serves to the
      same port, as long as one is on IPv4 and the other on IPv6).
      
      So running qemu-nbd works, it can bind to 0.0.0.0:NBD_PORT.  But
      potentially a concurrent test has successfully taken [::1]:NBD_PORT.  In
      this case, trying to connect to "localhost" will lead us to the IPv6
      instance, where we do not want to end up.
      
      Fix this by just binding to "localhost".  This will make qemu-nbd error
      out immediately and not give us cryptic errors later.
      
      (Also, it will allow us to just try a different port as of a future
      patch.)
      Signed-off-by: NMax Reitz <mreitz@redhat.com>
      Message-id: 20181221234750.23577-3-mreitz@redhat.com
      Reviewed-by: NJohn Snow <jsnow@redhat.com>
      Reviewed-by: NEric Blake <eblake@redhat.com>
      Signed-off-by: NMax Reitz <mreitz@redhat.com>
      dfadac9a
    • M
      iotests.py: Add qemu_nbd_pipe() · e1e6eccd
      Max Reitz 提交于
      In some cases, we may want to deal with qemu-nbd errors (e.g. by
      launching it in a different configuration until it no longer throws
      any).  In that case, we do not want its output ending up in the test
      output.
      
      It may still be useful for handling the error, though, so add a new
      function that works basically like qemu_nbd(), only that it returns the
      qemu-nbd output instead of making it end up in the log.  In contrast to
      qemu_img_pipe(), it does still return the exit code as well, though,
      because that is even more important for error handling.
      Signed-off-by: NMax Reitz <mreitz@redhat.com>
      Message-id: 20181221234750.23577-2-mreitz@redhat.com
      Reviewed-by: NJohn Snow <jsnow@redhat.com>
      Reviewed-by: NEric Blake <eblake@redhat.com>
      Signed-off-by: NMax Reitz <mreitz@redhat.com>
      e1e6eccd
  6. 24 1月, 2019 1 次提交
  7. 22 1月, 2019 2 次提交
  8. 15 1月, 2019 13 次提交
    • E
      qemu-nbd: Add --bitmap=NAME option · 636192c4
      Eric Blake 提交于
      Having to fire up qemu, then use QMP commands for nbd-server-start
      and nbd-server-add, just to expose a persistent dirty bitmap, is
      rather tedious.  Make it possible to expose a dirty bitmap using
      just qemu-nbd (of course, for now this only works when qemu-nbd is
      visiting a BDS formatted as qcow2).
      
      Of course, any good feature also needs unit testing, so expand
      iotest 223 to cover it.
      Signed-off-by: NEric Blake <eblake@redhat.com>
      Message-Id: <20190111194720.15671-9-eblake@redhat.com>
      636192c4
    • E
      nbd: Allow bitmap export during QMP nbd-server-add · 5fcbeb06
      Eric Blake 提交于
      With the experimental x-nbd-server-add-bitmap command, there was
      a window of time where an NBD client could see the export but not
      the associated dirty bitmap, which can cause a client that planned
      on using the dirty bitmap to be forced to treat the entire image
      as dirty as a safety fallback.  Furthermore, if the QMP client
      successfully exports a disk but then fails to add the bitmap, it
      has to take on the burden of removing the export.  Since we don't
      allow changing the exposed dirty bitmap (whether to a different
      bitmap, or removing advertisement of the bitmap), it is nicer to
      make the bitmap tied to the export at the time the export is
      created, with automatic failure to export if the bitmap is not
      available.
      
      The experimental command included an optional 'bitmap-export-name'
      field for remapping the name exposed over NBD to be different from
      the bitmap name stored on disk.  However, my libvirt demo code
      for implementing differential backups on top of persistent bitmaps
      did not need to take advantage of that feature (it is instead
      possible to create a new temporary bitmap with the desired name,
      use block-dirty-bitmap-merge to merge one or more persistent
      bitmaps into the temporary, then associate the temporary with the
      NBD export, if control is needed over the exported bitmap name).
      Hence, I'm not copying that part of the experiment over to the
      stable addition. For more details on the libvirt demo, see
      https://www.redhat.com/archives/libvir-list/2018-October/msg01254.html,
      https://kvmforum2018.sched.com/event/FzuB/facilitating-incremental-backup-eric-blake-red-hat
      
      This patch focuses on the user interface, and reduces (but does
      not completely eliminate) the window where an NBD client can see
      the export but not the dirty bitmap, with less work to clean up
      after errors.  Later patches will add further cleanups now that
      this interface is declared stable via a single QMP command,
      including removing the race window.
      
      Update test 223 to use the new interface.
      Signed-off-by: NEric Blake <eblake@redhat.com>
      Reviewed-by: NVladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
      Message-Id: <20190111194720.15671-6-eblake@redhat.com>
      5fcbeb06
    • E
      nbd: Only require disabled bitmap for read-only exports · 702aa50d
      Eric Blake 提交于
      Our initial implementation of x-nbd-server-add-bitmap put
      in a restriction because of incremental backups: in that
      usage, we are exporting one qcow2 file (the temporary overlay
      target of a blockdev-backup sync:none job) and a dirty bitmap
      owned by a second qcow2 file (the source of the
      blockdev-backup, which is the backing file of the temporary).
      While both qcow2 files are still writable (the target in
      order to capture copy-on-write of old contents, and the
      source in order to track live guest writes in the meantime),
      the NBD client expects to see constant data, including the
      dirty bitmap.  An enabled bitmap in the source would be
      modified by guest writes, which is at odds with the NBD
      export being a read-only constant view, hence the initial
      code choice of enforcing a disabled bitmap (the intent is
      that the exposed bitmap was disabled in the same transaction
      that started the blockdev-backup job, although we don't want
      to track enough state to actually enforce that).
      
      However, consider the case of a bitmap contained in a read-only
      node (including when the bitmap is found in a backing layer of
      the active image).  Because the node can't be modified, the
      bitmap won't change due to writes, regardless of whether it is
      still enabled.  Forbidding the export unless the bitmap is
      disabled is awkward, paritcularly since we can't change the
      bitmap to be disabled (because the node is read-only).
      
      Alternatively, consider the case of live storage migration,
      where management directs the destination to create a writable
      NBD server, then performs a drive-mirror from the source to
      the target, prior to doing the rest of the live migration.
      Since storage migration can be time-consuming, it may be wise
      to let the destination include a dirty bitmap to track which
      portions it has already received, where even if the migration
      is interrupted and restarted, the source can query the
      destination block status in order to potentially minimize
      re-sending data that has not changed in the meantime on a
      second attempt. Such code has not been written, and might not
      be trivial (after all, a cluster being marked dirty in the
      bitmap does not necessarily guarantee it has the desired
      contents), but it makes sense that letting an active dirty
      bitmap be exposed and changing alongside writes may prove
      useful in the future.
      
      Solve both issues by gating the restriction against a
      disabled bitmap to only happen when the caller has requested
      a read-only export, and where the BDS that owns the bitmap
      (whether or not it is the BDS handed to nbd_export_new() or
      from its backing chain) is still writable.  We could drop
      the check altogether (if management apps are prepared to
      deal with a changing bitmap even on a read-only image), but
      for now keeping a check for the read-only case still stands
      a chance of preventing management errors.
      
      Update iotest 223 to show the looser behavior by leaving
      a bitmap enabled the whole run; note that we have to tear
      down and re-export a node when handling an error.
      Signed-off-by: NEric Blake <eblake@redhat.com>
      Message-Id: <20190111194720.15671-4-eblake@redhat.com>
      Reviewed-by: NVladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
      702aa50d
    • E
      nbd: Forbid nbd-server-stop when server is not running · 7801c3a7
      Eric Blake 提交于
      Since we already forbid other nbd-server commands when not
      in the right state, it is unlikely that any caller was relying
      on a second stop to behave as a silent no-op.  Update iotest
      223 to show the improved behavior.
      Signed-off-by: NEric Blake <eblake@redhat.com>
      Message-Id: <20190111194720.15671-3-eblake@redhat.com>
      Reviewed-by: NVladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
      7801c3a7
    • E
      nbd: Add some error case testing to iotests 223 · 2d2fd674
      Eric Blake 提交于
      Testing success paths is important, but it's also nice to highlight
      expected failure handling, to show that we don't crash, and so that
      upcoming tests that change behavior can demonstrate the resulting
      effects on error paths.
      
      Add the following errors:
      Attempting to export without a running server
      Attempting to start a second server
      Attempting to export a bad node name
      Attempting to export a name that is already exported
      Attempting to export an enabled bitmap
      Attempting to remove an already removed export
      Attempting to quit server a second time
      
      All of these properly complain except for a second server-stop,
      which will be fixed next.
      Signed-off-by: NEric Blake <eblake@redhat.com>
      Message-Id: <20190111194720.15671-2-eblake@redhat.com>
      Reviewed-by: NVladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
      2d2fd674
    • J
      iotests: add iotest 236 for testing bitmap merge · 14da540f
      John Snow 提交于
      New interface, new smoke test.
      Signed-off-by: NJohn Snow <jsnow@redhat.com>
      Reviewed-by: NVladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
      Reviewed-by: NEric Blake <eblake@redhat.com>
      Message-Id: <20181221093529.23855-12-jsnow@redhat.com>
      [eblake: fix last-minute change to echo text]
      Signed-off-by: NEric Blake <eblake@redhat.com>
      14da540f
    • J
      iotests: implement pretty-print for log and qmp_log · 55cd64ea
      John Snow 提交于
      If iotests have lines exceeding >998 characters long, git doesn't
      want to send it plaintext to the list. We can solve this by allowing
      the iotests to use pretty printed QMP output that we can match against
      instead.
      
      As a bonus, it's much nicer for human eyes too.
      Signed-off-by: NJohn Snow <jsnow@redhat.com>
      Reviewed-by: NEric Blake <eblake@redhat.com>
      Reviewed-by: NVladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
      Message-Id: <20181221093529.23855-11-jsnow@redhat.com>
      Signed-off-by: NEric Blake <eblake@redhat.com>
      55cd64ea
    • J
      iotests: change qmp_log filters to expect QMP objects only · 08fcd611
      John Snow 提交于
      As laid out in the previous commit's message:
      
      ```
      Several places in iotests deal with serializing objects into JSON
      strings, but to add pretty-printing it seems desirable to localize
      all of those cases.
      
      log() seems like a good candidate for that centralized behavior.
      log() can already serialize json objects, but when it does so,
      it assumes filters=[] operates on QMP objects, not strings.
      
      qmp_log currently operates by dumping outgoing and incoming QMP
      objects into strings and filtering them assuming that filters=[]
      are string filters.
      ```
      
      Therefore:
      
      Change qmp_log to treat filters as if they're always qmp object filters,
      then change the logging call to rely on log()'s ability to serialize QMP
      objects, so we're not duplicating that effort.
      
      Add a qmp version of filter_testfiles and adjust the only caller using
      it for qmp_log to use the qmp version.
      Signed-off-by: NJohn Snow <jsnow@redhat.com>
      Message-Id: <20181221093529.23855-10-jsnow@redhat.com>
      Reviewed-by: NVladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
      Signed-off-by: NEric Blake <eblake@redhat.com>
      08fcd611
    • J
      iotests: remove default filters from qmp_log · f8ca8609
      John Snow 提交于
      Several places in iotests deal with serializing objects into JSON
      strings, but to add pretty-printing it seems desirable to localize
      all of those cases.
      
      log() seems like a good candidate for that centralized behavior.
      log() can already serialize json objects, but when it does so,
      it assumes filters=[] operates on QMP objects, not strings.
      
      qmp_log currently operates by dumping outgoing and incoming QMP
      objects into strings and filtering them assuming that filters=[]
      are string filters.
      
      To have qmp_log use log's serialization, qmp_log will need to
      accept only qmp filters, not text filters.
      
      However, only a single caller of qmp_log actually requires any
      filters at all. I remove the default filter and add it explicitly
      to the caller in preparation for refactoring qmp_log to use rich
      filters instead.
      
      test 206 is amended to name the filter explicitly and the default
      is removed.
      Signed-off-by: NJohn Snow <jsnow@redhat.com>
      Reviewed-by: NEric Blake <eblake@redhat.com>
      Reviewed-by: NVladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
      Message-Id: <20181221093529.23855-9-jsnow@redhat.com>
      Signed-off-by: NEric Blake <eblake@redhat.com>
      f8ca8609
    • J
      iotests: add qmp recursive sorting function · 0706e87d
      John Snow 提交于
      Python before 3.6 does not sort dictionaries (including kwargs).
      Therefore, printing QMP objects involves sorting the keys to have
      a predictable ordering in the iotests output. This means that
      iotests output will sometimes show arguments in an order not
      specified by the test author.
      
      Presently, we accomplish this by using json.dumps' sort_keys argument,
      where we only serialize the arguments dictionary, but not the command.
      
      However, if we want to pretty-print QMP objects being sent to the
      QEMU process, we need to build the entire command before logging it.
      Ordinarily, this would then involve "arguments" being sorted above
      "execute", which would necessitate a rather ugly and harder-to-read
      change to many iotests outputs.
      
      To facilitate pretty-printing AND maintaining predictable output AND
      having "arguments" sort after "execute", add a custom sort function
      that takes a dictionary and recursively builds an OrderedDict that
      maintains the specific key order we wish to see in iotests output.
      
      The qmp_log function uses this to build a QMP object that keeps
      "execute" above "arguments", but sorts all keys and keys in any
      subdicts in "arguments" lexicographically to maintain consistent
      iotests output, with no incompatible changes to any current test.
      Signed-off-by: NJohn Snow <jsnow@redhat.com>
      Reviewed-by: NEric Blake <eblake@redhat.com>
      Reviewed-by: NVladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
      Message-Id: <20181221093529.23855-8-jsnow@redhat.com>
      Signed-off-by: NEric Blake <eblake@redhat.com>
      0706e87d
    • J
      iotests: add filter_generated_node_ids · fa1151f8
      John Snow 提交于
      To mimic the common filter of the same name, but for the python tests.
      Signed-off-by: NJohn Snow <jsnow@redhat.com>
      Reviewed-by: NEric Blake <eblake@redhat.com>
      Reviewed-by: NVladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
      Message-Id: <20181221093529.23855-7-jsnow@redhat.com>
      Signed-off-by: NEric Blake <eblake@redhat.com>
      fa1151f8
    • J
      iotests.py: don't abort if IMGKEYSECRET is undefined · 58ebcb65
      John Snow 提交于
      Instead of using os.environ[], use .get with a default of empty string
      to match the setup in check to allow us to import the iotests module
      (for debugging, say) without needing a crafted environment just to
      import the module.
      Signed-off-by: NJohn Snow <jsnow@redhat.com>
      Reviewed-by: NEric Blake <eblake@redhat.com>
      Reviewed-by: NVladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
      Message-Id: <20181221093529.23855-6-jsnow@redhat.com>
      Signed-off-by: NEric Blake <eblake@redhat.com>
      58ebcb65
    • J
      block: remove 'x' prefix from experimental bitmap APIs · 0e2b7f09
      John Snow 提交于
      The 'x' prefix was added because I was uncertain of the direction we'd
      take for the libvirt API. With the general approach solidified, I feel
      comfortable committing to this API for 4.0.
      Signed-off-by: NJohn Snow <jsnow@redhat.com>
      Reviewed-by: NEric Blake <eblake@redhat.com>
      Reviewed-by: NVladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
      Message-Id: <20181221093529.23855-5-jsnow@redhat.com>
      Signed-off-by: NEric Blake <eblake@redhat.com>
      0e2b7f09
  9. 05 1月, 2019 2 次提交
    • E
      qemu-nbd: Use program name in error messages · 3ba1b7ba
      Eric Blake 提交于
      This changes output from:
      
      $ qemu-nbd nosuch
      Failed to blk_new_open 'nosuch': Could not open 'nosuch': No such file or directory
      
      to something more consistent with qemu-img and qemu:
      
      $ qemu-nbd nosuch
      qemu-nbd: Failed to blk_new_open 'nosuch': Could not open 'nosuch': No such file or directory
      
      Update the lone affected test to match.  (Hmm - is it sad that we don't
      do much testing of expected failures?)
      Signed-off-by: NEric Blake <eblake@redhat.com>
      Reviewed-by: NRichard W.M. Jones <rjones@redhat.com>
      Reviewed-by: NVladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
      Message-Id: <20181215135324.152629-2-eblake@redhat.com>
      3ba1b7ba
    • V
      block/nbd-client: use traces instead of noisy error_report_err · d8b4bad8
      Vladimir Sementsov-Ogievskiy 提交于
      Reduce extra noise of nbd-client, change 083 correspondingly.
      
      In various commits (be41c100 in 2.10, f140e300 in 2.11, 78a33ab5
      in 2.12), we added spots where qemu as an NBD client would report
      problems communicating with the server to stderr, because there
      was no where else to send the error to.  However, this is racy,
      particularly since the most common source of these errors is when
      either the client or the server abruptly hangs up, leaving one
      coroutine to report the error only if it wins (or loses) the
      race in attempting the read from the server before another
      thread completes its cleanup of a protocol error that caused the
      disconnect in the first place.  The race is also apparent in the
      fact that differences in the flush behavior of the server can
      alter the frequency of encountering the race in the client (see
      commit 6d39db96).
      
      Rather than polluting stderr, it's better to just trace these
      situations, for use by developers debugging a flaky connection,
      particularly since the real error that either triggers the abrupt
      disconnection in the first place, or that results from the EIO
      when a request can't receive a reply, DOES make it back to the
      user in the normal Error propagation channels.
      Signed-off-by: NVladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
      Message-Id: <20181102151152.288399-4-vsementsov@virtuozzo.com>
      [eblake: drop depedence on error hint, enhance commit message]
      Signed-off-by: NEric Blake <eblake@redhat.com>
      d8b4bad8
  10. 18 12月, 2018 2 次提交
  11. 14 12月, 2018 2 次提交
    • C
      iotests: make 235 work on s390 (and others) · 2c26e648
      Christian Borntraeger 提交于
      "-machine pc" will not work all architectures. Lets fall back to the
      default machine by not specifying it.
      
      In addition we also need to specify -no-shutdown on s390 as qemu will
      exit otherwise.
      
      Cc: qemu-stable@nongnu.org
      Signed-off-by: NChristian Borntraeger <borntraeger@de.ibm.com>
      Reviewed-by: NEric Blake <eblake@redhat.com>
      Signed-off-by: NKevin Wolf <kwolf@redhat.com>
      2c26e648
    • A
      block: Remove assertions from update_flags_from_options() · 8eb4b07b
      Alberto Garcia 提交于
      This function takes four options (cache.direct, cache.no-flush,
      read-only and auto-read-only) from a QemuOpts object and updates the
      flags accordingly.
      
      If any of those options is not set (because it was missing from the
      original QDict or because it had an invalid value) then the function
      aborts with a failed assertion:
      
         $ qemu-io -c 'reopen -o read-only=foo' hd.qcow2
         block.c:1126: update_flags_from_options: Assertion `qemu_opt_find(opts, BDRV_OPT_CACHE_DIRECT)' failed.
         Aborted
      
      This assertion is unnecessary, and it forces any caller of
      bdrv_reopen() to pass all the aforementioned four options. This may
      have made sense in order to remove ambiguity when bdrv_reopen() was
      taking both flags and options, but that's not the case anymore.
      
      It's also unnecessary if we want to validate the option values,
      because bdrv_reopen_prepare() already takes care of that, as we can
      see if we remove the assertions:
      
         $ qemu-io -c 'reopen -o read-only=foo' hd.qcow2
         Parameter 'read-only' expects 'on' or 'off'
      Signed-off-by: NAlberto Garcia <berto@igalia.com>
      Reviewed-by: NMax Reitz <mreitz@redhat.com>
      Signed-off-by: NKevin Wolf <kwolf@redhat.com>
      8eb4b07b