1. 13 7月, 2016 3 次提交
  2. 06 7月, 2016 3 次提交
    • E
      qapi: Add new visit_complete() function · 3b098d56
      Eric Blake 提交于
      Making each output visitor provide its own output collection
      function was the only remaining reason for exposing visitor
      sub-types to the rest of the code base.  Add a polymorphic
      visit_complete() function which is a no-op for input visitors,
      and which populates an opaque pointer for output visitors.  For
      maximum type-safety, also add a parameter to the output visitor
      constructors with a type-correct version of the output pointer,
      and assert that the two uses match.
      
      This approach was considered superior to either passing the
      output parameter only during construction (action at a distance
      during visit_free() feels awkward) or only during visit_complete()
      (defeating type safety makes it easier to use incorrectly).
      
      Most callers were function-local, and therefore a mechanical
      conversion; the testsuite was a bit trickier, but the previous
      cleanup patch minimized the churn here.
      
      The visit_complete() function may be called at most once; doing
      so lets us use transfer semantics rather than duplication or
      ref-count semantics to get the just-built output back to the
      caller, even though it means our behavior is not idempotent.
      
      Generated code is simplified as follows for events:
      
      |@@ -26,7 +26,7 @@ void qapi_event_send_acpi_device_ost(ACP
      |     QDict *qmp;
      |     Error *err = NULL;
      |     QMPEventFuncEmit emit;
      |-    QmpOutputVisitor *qov;
      |+    QObject *obj;
      |     Visitor *v;
      |     q_obj_ACPI_DEVICE_OST_arg param = {
      |         info
      |@@ -39,8 +39,7 @@ void qapi_event_send_acpi_device_ost(ACP
      |
      |     qmp = qmp_event_build_dict("ACPI_DEVICE_OST");
      |
      |-    qov = qmp_output_visitor_new();
      |-    v = qmp_output_get_visitor(qov);
      |+    v = qmp_output_visitor_new(&obj);
      |
      |     visit_start_struct(v, "ACPI_DEVICE_OST", NULL, 0, &err);
      |     if (err) {
      |@@ -55,7 +54,8 @@ void qapi_event_send_acpi_device_ost(ACP
      |         goto out;
      |     }
      |
      |-    qdict_put_obj(qmp, "data", qmp_output_get_qobject(qov));
      |+    visit_complete(v, &obj);
      |+    qdict_put_obj(qmp, "data", obj);
      |     emit(QAPI_EVENT_ACPI_DEVICE_OST, qmp, &err);
      
      and for commands:
      
      | {
      |     Error *err = NULL;
      |-    QmpOutputVisitor *qov = qmp_output_visitor_new();
      |     Visitor *v;
      |
      |-    v = qmp_output_get_visitor(qov);
      |+    v = qmp_output_visitor_new(ret_out);
      |     visit_type_AddfdInfo(v, "unused", &ret_in, &err);
      |-    if (err) {
      |-        goto out;
      |+    if (!err) {
      |+        visit_complete(v, ret_out);
      |     }
      |-    *ret_out = qmp_output_get_qobject(qov);
      |-
      |-out:
      |     error_propagate(errp, err);
      Signed-off-by: NEric Blake <eblake@redhat.com>
      Message-Id: <1465490926-28625-13-git-send-email-eblake@redhat.com>
      Reviewed-by: NMarkus Armbruster <armbru@redhat.com>
      Signed-off-by: NMarkus Armbruster <armbru@redhat.com>
      3b098d56
    • E
      qmp-output-visitor: Favor new visit_free() function · 1830f22a
      Eric Blake 提交于
      Now that we have a polymorphic visit_free(), we no longer need
      qmp_output_visitor_cleanup(); however, we still need to
      expose the subtype for qmp_output_get_qobject().
      Signed-off-by: NEric Blake <eblake@redhat.com>
      Message-Id: <1465490926-28625-10-git-send-email-eblake@redhat.com>
      Reviewed-by: NMarkus Armbruster <armbru@redhat.com>
      Signed-off-by: NMarkus Armbruster <armbru@redhat.com>
      1830f22a
    • E
      qemu-img: Don't leak errors when outputting JSON · 911ee36d
      Eric Blake 提交于
      If our JSON output ever encounters an error, we would just silently
      leak the error object.  Instead, assert that our usage won't fail.
      Signed-off-by: NEric Blake <eblake@redhat.com>
      Message-Id: <1465490926-28625-3-git-send-email-eblake@redhat.com>
      Reviewed-by: NMarkus Armbruster <armbru@redhat.com>
      Signed-off-by: NMarkus Armbruster <armbru@redhat.com>
      911ee36d
  3. 05 7月, 2016 4 次提交
    • K
      720ff280
    • 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
    • D
      qemu-img: fix failed autotests · cfef6a45
      Denis V. Lunev 提交于
      There are 9 iotests failed on Ubuntu 15.10 at the moment.
      The problem is that options parsing in qemu-img is broken by the
      following commit:
          commit 10985131
          Author: Denis V. Lunev <den@openvz.org>
          Date:   Fri Jun 17 17:44:13 2016 +0300
          qemu-img: move common options parsing before commands processing
      
      This strange command line reports error
        ./qemu-img create -f qcow2 TEST_DIR/t.qcow2 -- 1024
        qemu-img: Invalid image size specified!
      while original code parses it successfully.
      
      The problem is that getopt_long state should be reset. This could be done
      using this assignment according to the manual:
          optind = 0
      Signed-off-by: NDenis V. Lunev <den@openvz.org>
      CC: Eric Blake <eblake@redhat.com>
      CC: Kevin Wolf <kwolf@redhat.com>
      CC: Max Reitz <mreitz@redhat.com>
      Signed-off-by: NKevin Wolf <kwolf@redhat.com>
      cfef6a45
  4. 29 6月, 2016 2 次提交
  5. 16 6月, 2016 1 次提交
  6. 08 6月, 2016 5 次提交
  7. 07 6月, 2016 1 次提交
    • F
      Makefile: Derive "PKGVERSION" from "git describe" by default · 67a1de0d
      Fam Zheng 提交于
      Currently, if not specified in "./configure", QEMU_PKGVERSION will be
      empty. Write a rule in Makefile to generate a value from "git describe"
      combined with a possible git tree cleanness suffix, and write into a new
      header.
      
          $ cat qemu-version.h
          #define QEMU_PKGVERSION "-v2.6.0-557-gd6550e9e-dirty"
      
      Include the header in .c files where the macro is referenced. It's not
      necessary to include it in all files, otherwise each time the content of
      the file changes, all sources have to be recompiled.
      Signed-off-by: NFam Zheng <famz@redhat.com>
      Message-Id: <1464774261-648-3-git-send-email-famz@redhat.com>
      Signed-off-by: NPaolo Bonzini <pbonzini@redhat.com>
      67a1de0d
  8. 26 5月, 2016 2 次提交
  9. 21 5月, 2016 1 次提交
  10. 12 5月, 2016 3 次提交
  11. 28 4月, 2016 1 次提交
    • M
      qom: -object error messages lost location, restore it · 51b9b478
      Markus Armbruster 提交于
      qemu_opts_foreach() runs its callback with the error location set to
      the option's location.  Any errors the callback reports use the
      option's location automatically.
      
      Commit 90998d58 moved the actual error reporting from "inside"
      qemu_opts_foreach() to after it.  Here's a typical hunk:
      
      	 if (qemu_opts_foreach(qemu_find_opts("object"),
          -                          object_create,
          -                          object_create_initial, NULL)) {
          +                          user_creatable_add_opts_foreach,
          +                          object_create_initial, &err)) {
          +        error_report_err(err);
      	     exit(1);
      	 }
      
      Before, object_create() reports from within qemu_opts_foreach(), using
      the option's location.  Afterwards, we do it after
      qemu_opts_foreach(), using whatever location happens to be current
      there.  Commonly a "none" location.
      
      This is because Error objects don't have location information.
      Problematic.
      
      Reproducer:
      
          $ qemu-system-x86_64 -nodefaults -display none -object secret,id=foo,foo=bar
          qemu-system-x86_64: Property '.foo' not found
      
      Note no location.  This commit restores it:
      
          qemu-system-x86_64: -object secret,id=foo,foo=bar: Property '.foo' not found
      
      Note that the qemu_opts_foreach() bug just fixed could mask the bug
      here: if the location it leaves dangling hasn't been clobbered, yet,
      it's the correct one.
      Reported-by: NEric Blake <eblake@redhat.com>
      Cc: Daniel P. Berrange <berrange@redhat.com>
      Signed-off-by: NMarkus Armbruster <armbru@redhat.com>
      Message-Id: <1461767349-15329-4-git-send-email-armbru@redhat.com>
      Reviewed-by: NDaniel P. Berrange <berrange@redhat.com>
      Reviewed-by: NEric Blake <eblake@redhat.com>
      [Paragraph on Error added to commit message]
      51b9b478
  12. 13 4月, 2016 2 次提交
  13. 30 3月, 2016 6 次提交
    • M
      qemu-img: Fix preallocation with -S 0 for convert · aad15de4
      Max Reitz 提交于
      When passing -S 0 to qemu-img convert, the target image is supposed to
      be fully allocated. Right now, this is not the case if the source image
      contains areas which bdrv_get_block_status() reports as being zero.
      
      This patch changes a zeroed area's status from BLK_ZERO to BLK_DATA
      before invoking convert_write() if -S 0 has been specified. In addition,
      the check whether convert_read() actually needs to do anything
      (basically only if the current area is a BLK_DATA area) is pulled out of
      that function to the caller.
      
      If -S 0 has been specified, zeroed areas need to be written as data to
      the output, thus they then have to be accounted when calculating the
      progress made.
      
      This patch changes the reference output for iotest 122; contrary to what
      it assumed, -S 0 really should allocate everything in the output, not
      just areas that are filled with zeros (as opposed to being zeroed).
      Signed-off-by: NMax Reitz <mreitz@redhat.com>
      Reviewed-by: NFam Zheng <famz@redhat.com>
      Signed-off-by: NKevin Wolf <kwolf@redhat.com>
      aad15de4
    • K
      block: Remove BDRV_O_CACHE_WB · 61de4c68
      Kevin Wolf 提交于
      The previous patches have successively made blk->enable_write_cache the
      true source for the information whether a writethrough mode must be
      implemented. The corresponding BDRV_O_CACHE_WB is only useless baggage
      we're carrying around, so now's the time to remove it.
      
      At the same time, we remove the 'cache.writeback' option parsing on the
      BDS level as the only effect was setting the BDRV_O_CACHE_WB flag.
      
      This change requires test cases that explicitly enabled the option to
      drop it. Other than that and the change of the error message when
      writethrough is enabled on the BDS level (from "Can't set writethrough
      mode" to "doesn't support the option"), there should be no change in
      behaviour.
      Signed-off-by: NKevin Wolf <kwolf@redhat.com>
      Reviewed-by: NMax Reitz <mreitz@redhat.com>
      61de4c68
    • K
      qemu-img: Call blk_set_enable_write_cache() explicitly · ce099547
      Kevin Wolf 提交于
      Signed-off-by: NKevin Wolf <kwolf@redhat.com>
      Reviewed-by: NMax Reitz <mreitz@redhat.com>
      ce099547
    • K
      qemu-img: Expand all BDRV_O_FLAGS uses · e6996143
      Kevin Wolf 提交于
      It always only set the BDRV_O_CACHE_WB flag, which is going to go away.
      In order to make the next changes more local for better reviewability
      this patches expands the macro.
      Signed-off-by: NKevin Wolf <kwolf@redhat.com>
      Reviewed-by: NMax Reitz <mreitz@redhat.com>
      e6996143
    • D
      qemu-img/qemu-io: don't prompt for passwords if not required · 4ef130fc
      Daniel P. Berrange 提交于
      The qemu-img/qemu-io tools prompt for disk encryption passwords
      regardless of whether any are actually required. Adding a check
      on bdrv_key_required() avoids this prompt for disk formats which
      have been converted to the QCryptoSecret APIs.
      
      This is just a temporary hack to ensure the block I/O tests
      continue to work after each patch, since the last patch will
      completely delete all the password prompting code.
      Reviewed-by: NEric Blake <eblake@redhat.com>
      Signed-off-by: NDaniel P. Berrange <berrange@redhat.com>
      Signed-off-by: NKevin Wolf <kwolf@redhat.com>
      4ef130fc
    • D
      block: add flag to indicate that no I/O will be performed · abb06c5a
      Daniel P. Berrange 提交于
      When opening an image it is useful to know whether the caller
      intends to perform I/O on the image or not. In the case of
      encrypted images this will allow the block driver to avoid
      having to prompt for decryption keys when we merely want to
      query header metadata about the image. eg qemu-img info
      
      This flag is enforced at the top level only, since even if
      we don't want todo I/O on the 'qcow2' file payload, the
      underlying 'file' driver will still need todo I/O to read
      the qcow2 header, for example.
      Reviewed-by: NEric Blake <eblake@redhat.com>
      Signed-off-by: NDaniel P. Berrange <berrange@redhat.com>
      Signed-off-by: NKevin Wolf <kwolf@redhat.com>
      abb06c5a
  14. 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
  15. 17 3月, 2016 1 次提交
    • M
      blockdev: Split monitor reference from BB creation · efaa7c4e
      Max Reitz 提交于
      Before this patch, blk_new() automatically assigned a name to the new
      BlockBackend and considered it referenced by the monitor. This patch
      removes the implicit monitor_add_blk() call from blk_new() (and
      consequently the monitor_remove_blk() call from blk_delete(), too) and
      thus blk_new() (and related functions) no longer take a BB name
      argument.
      
      In fact, there is only a single point where blk_new()/blk_new_open() is
      called and the new BB is monitor-owned, and that is in blockdev_init().
      Besides thus relieving us from having to invent names for all of the BBs
      we use in qemu-img, this fixes a bug where qemu cannot create a new
      image if there already is a monitor-owned BB named "image".
      
      If a BB and its BDS tree are created in a single operation, as of this
      patch the BDS tree will be created before the BB is given a name
      (whereas it was the other way around before). This results in minor
      change to the output of iotest 087, whose reference output is amended
      accordingly.
      Signed-off-by: NMax Reitz <mreitz@redhat.com>
      Signed-off-by: NKevin Wolf <kwolf@redhat.com>
      efaa7c4e
  16. 14 3月, 2016 1 次提交
  17. 22 2月, 2016 2 次提交