1. 02 Jun, 2017 1 commit
  2. 23 May, 2017 1 commit
    • Eric Blake's avatar
      shutdown: Add source information to SHUTDOWN and RESET · cf83f140
      Eric Blake authored
      Time to wire up all the call sites that request a shutdown or
      reset to use the enum added in the previous patch.
      
      It would have been less churn to keep the common case with no
      arguments as meaning guest-triggered, and only modified the
      host-triggered code paths, via a wrapper function, but then we'd
      still have to audit that I didn't miss any host-triggered spots;
      changing the signature forces us to double-check that I correctly
      categorized all callers.
      
      Since command line options can change whether a guest reset request
      causes an actual reset vs. a shutdown, it's easy to also add the
      information to reset requests.
      Signed-off-by: 's avatarEric Blake <eblake@redhat.com>
      Acked-by: David Gibson <david@gibson.dropbear.id.au> [ppc parts]
      Reviewed-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk> [SPARC part]
      Reviewed-by: Cornelia Huck <cornelia.huck@de.ibm.com> [s390x parts]
      Message-Id: <20170515214114.15442-5-eblake@redhat.com>
      Reviewed-by: 's avatarMarkus Armbruster <armbru@redhat.com>
      Signed-off-by: 's avatarMarkus Armbruster <armbru@redhat.com>
      cf83f140
  3. 11 May, 2017 2 commits
    • Kevin Wolf's avatar
      block: New BdrvChildRole.activate() for blk_resume_after_migration() · 4417ab7a
      Kevin Wolf authored
      Instead of manually calling blk_resume_after_migration() in migration
      code after doing bdrv_invalidate_cache_all(), integrate the BlockBackend
      activation with cache invalidation into a single function. This is
      achieved with a new callback in BdrvChildRole that is called by
      bdrv_invalidate_cache_all().
      Signed-off-by: 's avatarKevin Wolf <kwolf@redhat.com>
      Reviewed-by: 's avatarEric Blake <eblake@redhat.com>
      4417ab7a
    • Kevin Wolf's avatar
      migration: Unify block node activation error handling · ace21a58
      Kevin Wolf authored
      Migration code activates all block driver nodes on the destination when
      the migration completes. It does so by calling
      bdrv_invalidate_cache_all() and blk_resume_after_migration(). There is
      one code path for precopy and one for postcopy migration, resulting in
      four function calls, which used to have three different failure modes.
      
      This patch unifies the behaviour so that failure to activate all block
      nodes is non-fatal, but the error message is logged and the VM isn't
      automatically started. 'cont' will retry activating the block nodes.
      Signed-off-by: 's avatarKevin Wolf <kwolf@redhat.com>
      Reviewed-by: 's avatarEric Blake <eblake@redhat.com>
      ace21a58
  4. 21 Apr, 2017 1 commit
  5. 07 Apr, 2017 1 commit
    • Kevin Wolf's avatar
      block: Ignore guest dev permissions during incoming migration · d35ff5e6
      Kevin Wolf authored
      Usually guest devices don't like other writers to the same image, so
      they use blk_set_perm() to prevent this from happening. In the migration
      phase before the VM is actually running, though, they don't have a
      problem with writes to the image. On the other hand, storage migration
      needs to be able to write to the image in this phase, so the restrictive
      blk_set_perm() call of qdev devices breaks it.
      
      This patch flags all BlockBackends with a qdev device as
      blk->disable_perm during incoming migration, which means that the
      requested permissions are stored in the BlockBackend, but not actually
      applied to its root node yet.
      
      Once migration has finished and the VM should be resumed, the
      permissions are applied. If they cannot be applied (e.g. because the NBD
      server used for block migration hasn't been shut down), resuming the VM
      fails.
      Signed-off-by: 's avatarKevin Wolf <kwolf@redhat.com>
      Tested-by: 's avatarKashyap Chamarthy <kchamart@redhat.com>
      d35ff5e6
  6. 05 Mar, 2017 1 commit
  7. 31 Jan, 2017 1 commit
  8. 27 Jan, 2017 2 commits
  9. 28 Oct, 2016 1 commit
  10. 25 Oct, 2016 2 commits
  11. 06 Oct, 2016 1 commit
  12. 23 Sep, 2016 3 commits
    • Kevin Wolf's avatar
      block: Accept device model name for blockdev-change-medium · 70e2cb3b
      Kevin Wolf authored
      In order to remove the need for BlockBackend names in the external API,
      we want to allow qdev device names in all device related commands.
      
      This converts blockdev-change-medium to accept a qdev device name.
      Signed-off-by: 's avatarKevin Wolf <kwolf@redhat.com>
      70e2cb3b
    • Fam Zheng's avatar
      vl: Switch qemu_uuid to QemuUUID · 9c5ce8db
      Fam Zheng authored
      Update all qemu_uuid users as well, especially get rid of the duplicated
      low level g_strdup_printf, sscanf and snprintf calls with QEMU UUID API.
      
      Since qemu_uuid_parse is quite tangled with qemu_uuid, its switching to
      QemuUUID is done here too to keep everything in sync and avoid code
      churn.
      Signed-off-by: 's avatarFam Zheng <famz@redhat.com>
      Reviewed-by: 's avatarEric Blake <eblake@redhat.com>
      Reviewed-by: 's avatarJeff Cody <jcody@redhat.com>
      Message-Id: <1474432046-325-10-git-send-email-famz@redhat.com>
      9c5ce8db
    • Fam Zheng's avatar
      util: Add UUID API · cea25275
      Fam Zheng authored
      A number of different places across the code base use CONFIG_UUID. Some
      of them are soft dependency, some are not built if libuuid is not
      available, some come with dummy fallback, some throws runtime error.
      
      It is hard to maintain, and hard to reason for users.
      
      Since UUID is a simple standard with only a small number of operations,
      it is cleaner to have a central support in libqemuutil. This patch adds
      qemu_uuid_* functions that all uuid users in the code base can
      rely on. Except for qemu_uuid_generate which is new code, all other
      functions are just copy from existing fallbacks from other files.
      
      Note that qemu_uuid_parse is moved without updating the function
      signature to use QemuUUID, to keep this patch simple.
      Signed-off-by: 's avatarFam Zheng <famz@redhat.com>
      Reviewed-by: 's avatarEric Blake <eblake@redhat.com>
      Reviewed-by: 's avatarJeff Cody <jcody@redhat.com>
      Message-Id: <1474432046-325-2-git-send-email-famz@redhat.com>
      cea25275
  13. 19 Sep, 2016 1 commit
  14. 06 Sep, 2016 3 commits
  15. 06 Jul, 2016 1 commit
    • Eric Blake's avatar
      qmp-input-visitor: Favor new visit_free() function · b70ce101
      Eric Blake authored
      Now that we have a polymorphic visit_free(), we no longer need
      qmp_input_visitor_cleanup(); which in turn means we no longer
      need to return a subtype from qmp_input_visitor_new() nor a
      public upcast function.
      
      Generated code changes to qmp-marshal.c look like:
      
      |@@ -52,11 +52,10 @@ void qmp_marshal_add_fd(QDict *args, QOb
      | {
      |     Error *err = NULL;
      |     AddfdInfo *retval;
      |-    QmpInputVisitor *qiv = qmp_input_visitor_new(QOBJECT(args), true);
      |     Visitor *v;
      |     q_obj_add_fd_arg arg = {0};
      |
      |-    v = qmp_input_get_visitor(qiv);
      |+    v = qmp_input_visitor_new(QOBJECT(args), true);
      |     visit_start_struct(v, NULL, NULL, 0, &err);
      |     if (err) {
      |         goto out;
      Signed-off-by: 's avatarEric Blake <eblake@redhat.com>
      Message-Id: <1465490926-28625-8-git-send-email-eblake@redhat.com>
      Reviewed-by: 's avatarMarkus Armbruster <armbru@redhat.com>
      Signed-off-by: 's avatarMarkus Armbruster <armbru@redhat.com>
      b70ce101
  16. 07 Jun, 2016 1 commit
    • Fam Zheng's avatar
      Makefile: Derive "PKGVERSION" from "git describe" by default · 67a1de0d
      Fam Zheng authored
      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: 's avatarFam Zheng <famz@redhat.com>
      Message-Id: <1464774261-648-3-git-send-email-famz@redhat.com>
      Signed-off-by: 's avatarPaolo Bonzini <pbonzini@redhat.com>
      67a1de0d
  17. 25 May, 2016 1 commit
    • Kevin Wolf's avatar
      block: Fix bdrv_next() memory leak · 88be7b4b
      Kevin Wolf authored
      The bdrv_next() users all leaked the BdrvNextIterator after completing
      the iteration. Simply changing bdrv_next() to free the iterator before
      returning NULL at the end of list doesn't work because some callers exit
      the loop before looking at all BDSes.
      
      This patch moves the BdrvNextIterator from the heap to the stack of
      the caller and switches to a bdrv_first()/bdrv_next() interface for
      initialising the iterator.
      Signed-off-by: 's avatarKevin Wolf <kwolf@redhat.com>
      Reviewed-by: 's avatarFam Zheng <famz@redhat.com>
      88be7b4b
  18. 19 May, 2016 1 commit
  19. 12 May, 2016 2 commits
    • Eric Blake's avatar
      qapi: Use strict QMP input visitor in more places · 240f64b6
      Eric Blake authored
      The following uses of a QMP input visitor should be strict
      (that is, excess keys in QDict input should be flagged if not
      converted to QAPI):
      
      - Testsuite code unrelated to explicitly testing non-strict
      mode (test-qmp-commands, test-visitor-serialization); since
      we want more code to be strict by default, having more tests
      of strict mode doesn't hurt
      
      - Code used for cloning QAPI objects (replay-input.c,
      qemu-sockets.c); we are reparsing a QObject just barely
      produced by the qmp output visitor and which therefore should
      not have any garbage, so while it is extra work to be strict,
      it validates that our clone is correct [note that a later patch
      series will simplify these two uses by creating an actual
      clone visitor that is much more efficient than a
      generate/reparse cycle]
      
      - qmp_object_add(), which calls into user_creatable_add_type().
      Since command line parsing for '-object' uses the same
      user_creatable_add_type() through the OptsVisitor, and that is
      always strict, we want to ensure that any nested dictionaries
      would be treated the same in QMP and from the command line (I
      don't actually know if such nested dictionaries exist).  Note
      that on this code change, strictness only matters for nested
      dictionaries (if even possible), since we already flag excess
      input at the top level during an earlier object_property_set()
      on an unknown key, whether from QemuOpts:
      
      $ ./x86_64-softmmu/qemu-system-x86_64 -nographic -nodefaults -qmp stdio -object secret,id=sec0,data=letmein,format=raw,foo=bar
      qemu-system-x86_64: -object secret,id=sec0,data=letmein,format=raw,foo=bar: Property '.foo' not found
      
      or from QMP:
      
      $ ./x86_64-softmmu/qemu-system-x86_64 -nographic -nodefaults -qmp stdio
      {"QMP": {"version": {"qemu": {"micro": 93, "minor": 5, "major": 2}, "package": ""}, "capabilities": []}}
      {"execute":"qmp_capabilities"}
      {"return": {}}
      {"execute":"object-add","arguments":{"qom-type":"secret","id":"sec0","props":{"format":"raw","data":"letmein","foo":"bar"}}}
      {"error": {"class": "GenericError", "desc": "Property '.foo' not found"}}
      
      The only remaining uses of non-strict input visits are:
      
      - QMP 'qom-set' (which eventually executes
      object_property_set_qobject()) - mark it as something to revisit
      in the future (I didn't want to spend any more time on this patch
      auditing if we have any QOM dictionary properties that might be
      impacted, and couldn't easily prove whether this code path is
      shared with anything else).
      
      - test-qmp-input-visitor: explicit tests of non-strict mode. If
      we later get rid of users that don't need strictness, then this
      test should be merged with test-qmp-input-strict
      Signed-off-by: 's avatarEric Blake <eblake@redhat.com>
      Message-Id: <1461879932-9020-7-git-send-email-eblake@redhat.com>
      Signed-off-by: 's avatarMarkus Armbruster <armbru@redhat.com>
      240f64b6
    • Eric Blake's avatar
      qapi: Consolidate QMP input visitor creation · fc471c18
      Eric Blake authored
      Rather than having two separate ways to create a QMP input
      visitor, where the safer approach has the more verbose name,
      it is better to consolidate things into a single function
      where the caller must explicitly choose whether to be strict
      or to ignore excess input.  This patch is the strictly
      mechanical conversion; the next patch will then audit which
      uses can be made stricter.
      Signed-off-by: 's avatarEric Blake <eblake@redhat.com>
      Message-Id: <1461879932-9020-6-git-send-email-eblake@redhat.com>
      Signed-off-by: 's avatarMarkus Armbruster <armbru@redhat.com>
      fc471c18
  20. 22 Mar, 2016 1 commit
  21. 22 Feb, 2016 1 commit
  22. 16 Feb, 2016 1 commit
    • Daniel P. Berrange's avatar
      qom: add helpers for UserCreatable object types · 90998d58
      Daniel P. Berrange authored
      The QMP monitor code has two helper methods object_add
      and qmp_object_del that are called from several places
      in the code (QMP, HMP and main emulator startup).
      
      The HMP and main emulator startup code also share
      further logic that extracts the qom-type & id
      values from a qdict.
      
      We soon need to use this logic from qemu-img, qemu-io
      and qemu-nbd too, but don't want those to depend on
      the monitor, nor do we want to duplicate the code.
      
      To avoid this, move some code out of qmp.c and hmp.c
      adding new methods to qom/object_interfaces.c
      
       - user_creatable_add - takes a QDict holding a full
         object definition & instantiates it
       - user_creatable_add_type - takes an ID, type name,
         and QDict holding object properties & instantiates
         it
       - user_creatable_add_opts - takes a QemuOpts holding
         a full object definition & instantiates it
       - user_creatable_add_opts_foreach - variant on
         user_creatable_add_opts which can be directly used
         in conjunction with qemu_opts_foreach.
       - user_creatable_del - takes an ID and deletes the
         corresponding object
      
      The existing code is updated to use these new methods.
      Signed-off-by: 's avatarDaniel P. Berrange <berrange@redhat.com>
      Message-Id: <1455129674-17255-2-git-send-email-berrange@redhat.com>
      Signed-off-by: 's avatarPaolo Bonzini <pbonzini@redhat.com>
      90998d58
  23. 04 Feb, 2016 1 commit
    • Peter Maydell's avatar
      all: Clean up includes · d38ea87a
      Peter Maydell authored
      Clean up includes so that osdep.h is included first and headers
      which it implies are not included manually.
      
      This commit was created with scripts/clean-includes.
      Signed-off-by: 's avatarPeter Maydell <peter.maydell@linaro.org>
      Message-id: 1454089805-5470-16-git-send-email-peter.maydell@linaro.org
      d38ea87a
  24. 20 Jan, 2016 1 commit
    • Kevin Wolf's avatar
      block: Inactivate BDS when migration completes · 76b1c7fe
      Kevin Wolf authored
      So far, live migration with shared storage meant that the image is in a
      not-really-ready don't-touch-me state on the destination while the
      source is still actively using it, but after completing the migration,
      the image was fully opened on both sides. This is bad.
      
      This patch adds a block driver callback to inactivate images on the
      source before completing the migration. Inactivation means that it goes
      to a state as if it was just live migrated to the qemu instance on the
      source (i.e. BDRV_O_INACTIVE is set). You're then supposed to continue
      either on the source or on the destination, which takes ownership of the
      image.
      
      A typical migration looks like this now with respect to disk images:
      
      1. Destination qemu is started, the image is opened with
         BDRV_O_INACTIVE. The image is fully opened on the source.
      
      2. Migration is about to complete. The source flushes the image and
         inactivates it. Now both sides have the image opened with
         BDRV_O_INACTIVE and are expecting the other side to still modify it.
      
      3. One side (the destination on success) continues and calls
         bdrv_invalidate_all() in order to take ownership of the image again.
         This removes BDRV_O_INACTIVE on the resuming side; the flag remains
         set on the other side.
      
      This ensures that the same image isn't written to by both instances
      (unless both are resumed, but then you get what you deserve). This is
      important because .bdrv_close for non-BDRV_O_INACTIVE images could write
      to the image file, which is definitely forbidden while another host is
      using the image.
      Signed-off-by: 's avatarKevin Wolf <kwolf@redhat.com>
      Reviewed-by: 's avatarEric Blake <eblake@redhat.com>
      Reviewed-by: 's avatarJohn Snow <jsnow@redhat.com>
      76b1c7fe
  25. 18 Jan, 2016 1 commit
    • Daniel P. Berrange's avatar
      qom: Change object property iterator API contract · 7746abd8
      Daniel P. Berrange authored
      Currently the ObjectProperty iterator API works as follows:
      
        ObjectPropertyIterator *iter;
      
        iter = object_property_iter_init(obj);
        while ((prop = object_property_iter_next(iter))) {
           ...
        }
        object_property_iter_free(iter);
      
      This has the benefit that the ObjectPropertyIterator struct
      can be opaque, but has the downside that callers need to
      explicitly call a free function. It is also not in keeping
      with iterator style used elsewhere in QEMU/GLib2.
      
      This patch changes the API to use stack allocation instead:
      
        ObjectPropertyIterator iter;
      
        object_property_iter_init(&iter, obj);
        while ((prop = object_property_iter_next(&iter))) {
           ...
        }
      Reviewed-by: 's avatarEric Blake <eblake@redhat.com>
      Signed-off-by: 's avatarDaniel P. Berrange <berrange@redhat.com>
      Reviewed-by: 's avatarMarkus Armbruster <armbru@redhat.com>
      [AF: Fused ObjectPropertyIterator struct with typedef]
      Signed-off-by: 's avatarAndreas Färber <afaerber@suse.de>
      7746abd8
  26. 18 Nov, 2015 1 commit
  27. 11 Nov, 2015 2 commits
  28. 23 Oct, 2015 1 commit
  29. 09 Oct, 2015 2 commits
    • Markus Armbruster's avatar
      qdev: Protect device-list-properties against broken devices · 4c315c27
      Markus Armbruster authored
      Several devices don't survive object_unref(object_new(T)): they crash
      or hang during cleanup, or they leave dangling pointers behind.
      
      This breaks at least device-list-properties, because
      qmp_device_list_properties() needs to create a device to find its
      properties.  Broken in commit f4eb32b5 "qmp: show QOM properties in
      device-list-properties", v2.1.  Example reproducer:
      
          $ qemu-system-aarch64 -nodefaults -display none -machine none -S -qmp stdio
          {"QMP": {"version": {"qemu": {"micro": 50, "minor": 4, "major": 2}, "package": ""}, "capabilities": []}}
          { "execute": "qmp_capabilities" }
          {"return": {}}
          { "execute": "device-list-properties", "arguments": { "typename": "pxa2xx-pcmcia" } }
          qemu-system-aarch64: /home/armbru/work/qemu/memory.c:1307: memory_region_finalize: Assertion `((&mr->subregions)->tqh_first == ((void *)0))' failed.
          Aborted (core dumped)
          [Exit 134 (SIGABRT)]
      
      Unfortunately, I can't fix the problems in these devices right now.
      Instead, add DeviceClass member cannot_destroy_with_object_finalize_yet
      to mark them:
      
      * Hang during cleanup (didn't debug, so I can't say why):
        "realview_pci", "versatile_pci".
      
      * Dangling pointer in cpus: most CPUs, plus "allwinner-a10", "digic",
        "fsl,imx25", "fsl,imx31", "xlnx,zynqmp", because they create such
        CPUs
      
      * Assert kvm_enabled(): "host-x86_64-cpu", host-i386-cpu",
        "host-powerpc64-cpu", "host-embedded-powerpc-cpu",
        "host-powerpc-cpu" (the powerpc ones can't currently reach the
        assertion, because the CPUs are only registered when KVM is enabled,
        but the assertion is arguably in the wrong place all the same)
      
      Make qmp_device_list_properties() fail cleanly when the device is so
      marked.  This improves device-list-properties from "crashes, hangs or
      leaves dangling pointers behind" to "fails".  Not a complete fix, just
      a better-than-nothing work-around.  In the above reproducer,
      device-list-properties now fails with "Can't list properties of device
      'pxa2xx-pcmcia'".
      
      This also protects -device FOO,help, which uses the same machinery
      since commit ef523587 "qdev-monitor: include QOM properties in -device
      FOO, help output", v2.2.  Example reproducer:
      
          $ qemu-system-aarch64 -machine none -device pxa2xx-pcmcia,help
      
      Before:
      
          qemu-system-aarch64: .../memory.c:1307: memory_region_finalize: Assertion `((&mr->subregions)->tqh_first == ((void *)0))' failed.
      
      After:
      
          Can't list properties of device 'pxa2xx-pcmcia'
      
      Cc: "Andreas Färber" <afaerber@suse.de>
      Cc: "Edgar E. Iglesias" <edgar.iglesias@gmail.com>
      Cc: Alexander Graf <agraf@suse.de>
      Cc: Anthony Green <green@moxielogic.com>
      Cc: Aurelien Jarno <aurelien@aurel32.net>
      Cc: Bastian Koppelmann <kbastian@mail.uni-paderborn.de>
      Cc: Blue Swirl <blauwirbel@gmail.com>
      Cc: Eduardo Habkost <ehabkost@redhat.com>
      Cc: Guan Xuetao <gxt@mprc.pku.edu.cn>
      Cc: Jia Liu <proljc@gmail.com>
      Cc: Leon Alrae <leon.alrae@imgtec.com>
      Cc: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
      Cc: Max Filippov <jcmvbkbc@gmail.com>
      Cc: Michael Walle <michael@walle.cc>
      Cc: Paolo Bonzini <pbonzini@redhat.com>
      Cc: Peter Maydell <peter.maydell@linaro.org>
      Cc: Richard Henderson <rth@twiddle.net>
      Cc: qemu-ppc@nongnu.org
      Cc: qemu-stable@nongnu.org
      Signed-off-by: 's avatarMarkus Armbruster <armbru@redhat.com>
      Reviewed-by: 's avatarEduardo Habkost <ehabkost@redhat.com>
      Message-Id: <1443689999-12182-10-git-send-email-armbru@redhat.com>
      4c315c27
    • Markus Armbruster's avatar
      qmp: Fix device-list-properties not to crash for abstract device · edb1523d
      Markus Armbruster authored
      Broken in commit f4eb32b5 "qmp: show QOM properties in
      device-list-properties", v2.1.
      
      Cc: qemu-stable@nongnu.org
      Signed-off-by: 's avatarMarkus Armbruster <armbru@redhat.com>
      Reviewed-by: 's avatarEric Blake <eblake@redhat.com>
      Reviewed-by: 's avatarAndreas Färber <afaerber@suse.de>
      Message-Id: <1443689999-12182-9-git-send-email-armbru@redhat.com>
      edb1523d
  30. 21 Sep, 2015 1 commit