1. 08 3月, 2019 2 次提交
  2. 07 3月, 2019 19 次提交
  3. 06 3月, 2019 19 次提交
    • D
      qdev: Provide qdev_get_bus_hotplug_handler() · 14405c27
      David Hildenbrand 提交于
      Let's use a wrapper instead of looking it up manually. This function can
      than be reused when we explicitly want to have the bus hotplug handler
      (e.g. when the bus hotplug handler was overwritten by the machine
      hotplug handler).
      Reviewed-by: NIgor Mammedov <imammedo@redhat.com>
      Signed-off-by: NDavid Hildenbrand <david@redhat.com>
      Message-Id: <20190228122849.4296-4-david@redhat.com>
      Signed-off-by: NEduardo Habkost <ehabkost@redhat.com>
      14405c27
    • I
      qdev: Let machine hotplug handler to override bus hotplug handler · 17cc0128
      Igor Mammedov 提交于
      it will allow to return another hotplug handler than the default
      one for a specific bus based device type. Which is needed to handle
      non trivial plug/unplug sequences that need the access to resources
      configured outside of bus where device is attached.
      
      That will allow for returned hotplug handler to orchestrate wiring
      in arbitrary order, by chaining other hotplug handlers when
      it's needed.
      
      PS:
      It could be used for hybrid virtio-mem and virtio-pmem devices
      where it will return machine as hotplug handler which will do
      necessary wiring at machine level and then pass control down
      the chain to bus specific hotplug handler.
      
      Example of top level hotplug handler override and custom plug sequence:
      
        some_machine_get_hotplug_handler(machine){
            if (object_dynamic_cast(OBJECT(dev), TYPE_SOME_BUS_DEVICE)) {
                return HOTPLUG_HANDLER(machine);
            }
            return NULL;
        }
      
        some_machine_device_plug(hotplug_dev, dev) {
            if (object_dynamic_cast(OBJECT(dev), TYPE_SOME_BUS_DEVICE)) {
                /* do machine specific initialization */
                some_machine_init_special_device(dev)
      
                /* pass control to bus specific handler */
                hotplug_handler_plug(dev->parent_bus->hotplug_handler, dev)
            }
        }
      Reviewed-by: NDavid Gibson <david@gibson.dropbear.id.au>
      Signed-off-by: NIgor Mammedov <imammedo@redhat.com>
      Signed-off-by: NDavid Hildenbrand <david@redhat.com>
      Message-Id: <20190228122849.4296-3-david@redhat.com>
      Signed-off-by: NEduardo Habkost <ehabkost@redhat.com>
      17cc0128
    • D
      qdev: Let the hotplug_handler_unplug() caller delete the device · 07578b0a
      David Hildenbrand 提交于
      When unplugging a device, at one point the device will be destroyed
      via object_unparent(). This will, one the one hand, unrealize the
      removed device hierarchy, and on the other hand, destroy/free the
      device hierarchy.
      
      When chaining hotplug handlers, we want to overwrite a bus hotplug
      handler by the machine hotplug handler, to be able to perform
      some part of the plug/unplug and to forward the calls to the bus hotplug
      handler.
      
      For now, the bus hotplug handler would trigger an object_unparent(), not
      allowing us to perform some unplug action on a device after we forwarded
      the call to the bus hotplug handler. The device would be gone at that
      point.
      
      machine_unplug_handler(dev)
          /* eventually do unplug stuff */
          bus_unplug_handler(dev)
          /* dev is gone, we can't do more unplug stuff */
      
      So move the object_unparent() to the original caller of the unplug. For
      now, keep the unrealize() at the original places of the
      object_unparent(). For implicitly chained hotplug handlers (e.g. pc
      code calling acpi hotplug handlers), the object_unparent() has to be
      done by the outermost caller. So when calling hotplug_handler_unplug()
      from inside an unplug handler, nothing is to be done.
      
      hotplug_handler_unplug(dev) -> calls machine_unplug_handler()
          machine_unplug_handler(dev) {
              /* eventually do unplug stuff */
              bus_unplug_handler(dev) -> calls unrealize(dev)
              /* we can do more unplug stuff but device already unrealized */
          }
      object_unparent(dev)
      
      In the long run, every unplug action should be factored out of the
      unrealize() function into the unplug handler (especially for PCI). Then
      we can get rid of the additonal unrealize() calls and object_unparent()
      will properly unrealize the device hierarchy after the device has been
      unplugged.
      
      hotplug_handler_unplug(dev) -> calls machine_unplug_handler()
          machine_unplug_handler(dev) {
              /* eventually do unplug stuff */
              bus_unplug_handler(dev) -> only unplugs, does not unrealize
              /* we can do more unplug stuff */
          }
      object_unparent(dev) -> will unrealize
      
      The original approach was suggested by Igor Mammedov for the PCI
      part, but I extended it to all hotplug handlers. I consider this one
      step into the right direction.
      
      To summarize:
      - object_unparent() on synchronous unplugs is done by common code
      -- "Caller of hotplug_handler_unplug"
      - object_unparent() on asynchronous unplugs ("unplug requests") has to
        be done manually
      -- "Caller of hotplug_handler_unplug"
      Reviewed-by: NIgor Mammedov <imammedo@redhat.com>
      Acked-by: NCornelia Huck <cohuck@redhat.com>
      Signed-off-by: NDavid Hildenbrand <david@redhat.com>
      Message-Id: <20190228122849.4296-2-david@redhat.com>
      Reviewed-by: NGreg Kurz <groug@kaod.org>
      Signed-off-by: NEduardo Habkost <ehabkost@redhat.com>
      07578b0a
    • I
      hostmem: fix crash when querying empty host-nodes property via QMP · 15160ab7
      Igor Mammedov 提交于
      QEMU will crashes with
       qapi/qobject-output-visitor.c:210: qobject_output_complete: Assertion `qov->root && ((&qov->stack)->slh_first == ((void *)0))' failed
      when trying to get value of not set hostmem's "host-nodes"
      property, HostMemoryBackend::host_nodes bitmap doesn't have
      any bits set in it, which leads to find_first_bit() returning
      MAX_NODES and consequently to an early return from
      host_memory_backend_get_host_nodes() without calling visitor.
      
      Fix it by calling visitor even if "host-nodes" property wasn't
      set before exiting from property getter to return valid empty
      list.
      Signed-off-by: NIgor Mammedov <imammedo@redhat.com>
      Message-Id: <20190214105733.25643-1-imammedo@redhat.com>
      Reviewed-by: NEric Blake <eblake@redhat.com>
      Reviewed-by: NStefano Garzarella <sgarzare@redhat.com>
      Signed-off-by: NEduardo Habkost <ehabkost@redhat.com>
      15160ab7
    • T
      qdev/core: fix qbus_is_full() · 12b2e9f3
      Tony Krowiak 提交于
      The qbus_is_full(BusState *bus) function (qdev_monitor.c) compares the max_index
      value of the BusState structure with the max_dev value of the BusClass structure
      to determine whether the maximum number of children has been reached for the
      bus. The problem is, the max_index field of the BusState structure does not
      necessarily reflect the number of devices that have been plugged into
      the bus.
      
      Whenever a child device is plugged into the bus, the bus's max_index value is
      assigned to the child device and then incremented. If the child is subsequently
      unplugged, the value of the max_index does not change and no longer reflects the
      number of children.
      
      When the bus's max_index value reaches the maximum number of devices
      allowed for the bus (i.e., the max_dev field in the BusClass structure),
      attempts to plug another device will be rejected claiming that the bus is
      full -- even if the bus is actually empty.
      
      To resolve the problem, a new 'num_children' field is being added to the
      BusState structure to keep track of the number of children plugged into the
      bus. It will be incremented when a child is plugged, and decremented when a
      child is unplugged.
      Signed-off-by: NTony Krowiak <akrowiak@linux.ibm.com>
      Reviewed-by: Pierre Morel<pmorel@linux.ibm.com>
      Reviewed-by: NHalil Pasic <pasic@linux.ibm.com>
      Message-Id: <1545062250-7573-1-git-send-email-akrowiak@linux.ibm.com>
      Reviewed-by: NIgor Mammedov <imammedo@redhat.com>
      Signed-off-by: NEduardo Habkost <ehabkost@redhat.com>
      12b2e9f3
    • P
      Merge remote-tracking branch 'remotes/dgilbert/tags/pull-migration-20190306a' into staging · c557a8c7
      Peter Maydell 提交于
      Migation pull 2019-03-06
      
      (This replaces the pull sent yesterday)
      
         a) 4 small fixes including the cancel problem
           that caused the ahci migration test to fail
           intermittently
         b) Yury's ignore-shared feature
         c) Juan's extra tests
         d) Wei Wang's free page hinting
         e) Some Colo fixes from Zhang Chen
      
      Diff from yesterdays pull:
        1) A missing fix of mine (cleanup during exit)
        2) Changes from Eric/Markus on 'Create socket-address parameter'
      
      # gpg: Signature made Wed 06 Mar 2019 11:39:53 GMT
      # gpg:                using RSA key 0516331EBC5BFDE7
      # gpg: Good signature from "Dr. David Alan Gilbert (RH2) <dgilbert@redhat.com>" [full]
      # Primary key fingerprint: 45F5 C71B 4A0C B7FB 977A  9FA9 0516 331E BC5B FDE7
      
      * remotes/dgilbert/tags/pull-migration-20190306a: (22 commits)
        qapi/migration.json: Remove a variable that doesn't exist in example
        Migration/colo.c: Make COLO node running after failover
        Migration/colo.c: Fix double close bug when occur COLO failover
        virtio-balloon: VIRTIO_BALLOON_F_FREE_PAGE_HINT
        migration/ram.c: add the free page optimization enable flag
        migration/ram.c: add a notifier chain for precopy
        migration: API to clear bits of guest free pages from the dirty bitmap
        migration: use bitmap_mutex in migration_bitmap_clear_dirty
        bitmap: bitmap_count_one_with_offset
        bitmap: fix bitmap_count_one
        tests: Add basic migration precopy tcp test
        migration: Create socket-address parameter
        tests: Add migration xbzrle test
        migration: Add capabilities validation
        tests/migration-test: Add a test for ignore-shared capability
        migration: Add an ability to ignore shared RAM blocks
        migration: Introduce ignore-shared capability
        exec: Change RAMBlockIterFunc definition
        migration/rdma: clang compilation fix
        migration: Cleanup during exit
        ...
      Signed-off-by: NPeter Maydell <peter.maydell@linaro.org>
      c557a8c7
    • P
      Merge remote-tracking branch 'remotes/vivier2/tags/trivial-branch-pull-request' into staging · 9b748c5e
      Peter Maydell 提交于
      trivial patches pull request (20190206)
      
      - acpi: remove unused functions/variables
      - tests: remove useless architecture checks
      - some typo fixes and documentation update
      - flash_cfi02: fix memory leak
      
      # gpg: Signature made Wed 06 Mar 2019 11:05:12 GMT
      # gpg:                using RSA key F30C38BD3F2FBE3C
      # gpg: Good signature from "Laurent Vivier <lvivier@redhat.com>" [full]
      # gpg:                 aka "Laurent Vivier <laurent@vivier.eu>" [full]
      # gpg:                 aka "Laurent Vivier (Red Hat) <lvivier@redhat.com>" [full]
      # Primary key fingerprint: CD2F 75DD C8E3 A4DC 2E4F  5173 F30C 38BD 3F2F BE3C
      
      * remotes/vivier2/tags/trivial-branch-pull-request:
        thunk: fix of malloc to g_new
        hostmem-file: simplify ifdef-s in file_backend_memory_alloc()
        build: Correct explanation of unnest-vars example
        bswap: Fix accessors syntax in comment
        doc: fix typos for documents in tree
        block/pflash_cfi02: Fix memory leak and potential use-after-free
        hw/acpi: remove unnecessary variable acpi_table_builtin
        hw/acpi: remove unused function acpi_table_add_builtin()
        hw/i386/pc.c: remove unused function pc_acpi_init()
        tests: Remove (mostly) useless architecture checks
      Signed-off-by: NPeter Maydell <peter.maydell@linaro.org>
      9b748c5e
    • Z
      qapi/migration.json: Remove a variable that doesn't exist in example · b5922fc5
      Zhang Chen 提交于
      Remove the "active" variable in example for query-colo-status.
      It is a doc bug from commit f56c0065Signed-off-by: NZhang Chen <chen.zhang@intel.com>
      Reviewed-by: NEric Blake <eblake@redhat.com>
      Message-Id: <20190303145021.2962-6-chen.zhang@intel.com>
      Signed-off-by: NDr. David Alan Gilbert <dgilbert@redhat.com>
      b5922fc5
    • Z
      Migration/colo.c: Make COLO node running after failover · db009729
      Zhang Chen 提交于
      Delay to close COLO for auto start VM after failover.
      Signed-off-by: NZhang Chen <chen.zhang@intel.com>
      Reviewed-by: NDr. David Alan Gilbert <dgilbert@redhat.com>
      Message-Id: <20190303145021.2962-4-chen.zhang@intel.com>
      Signed-off-by: NDr. David Alan Gilbert <dgilbert@redhat.com>
      db009729
    • Z
      Migration/colo.c: Fix double close bug when occur COLO failover · b8b5734b
      Zhang Chen 提交于
      In migration_incoming_state_destroy(void) will check the mis->to_src_file
      to double close the mis->to_src_file when occur COLO failover.
      Signed-off-by: NZhang Chen <chen.zhang@intel.com>
      Reviewed-by: NDr. David Alan Gilbert <dgilbert@redhat.com>
      Message-Id: <20190303145021.2962-2-chen.zhang@intel.com>
      Signed-off-by: NDr. David Alan Gilbert <dgilbert@redhat.com>
      b8b5734b
    • W
      virtio-balloon: VIRTIO_BALLOON_F_FREE_PAGE_HINT · c13c4153
      Wei Wang 提交于
      The new feature enables the virtio-balloon device to receive hints of
      guest free pages from the free page vq.
      
      A notifier is registered to the migration precopy notifier chain. The
      notifier calls free_page_start after the migration thread syncs the dirty
      bitmap, so that the free page optimization starts to clear bits of free
      pages from the bitmap. It calls the free_page_stop before the migration
      thread syncs the bitmap, which is the end of the current round of ram
      save. The free_page_stop is also called to stop the optimization in the
      case when there is an error occurred in the process of ram saving.
      
      Note: balloon will report pages which were free at the time of this call.
      As the reporting happens asynchronously, dirty bit logging must be
      enabled before this free_page_start call is made. Guest reporting must be
      disabled before the migration dirty bitmap is synchronized.
      Signed-off-by: NWei Wang <wei.w.wang@intel.com>
      CC: Michael S. Tsirkin <mst@redhat.com>
      CC: Dr. David Alan Gilbert <dgilbert@redhat.com>
      CC: Juan Quintela <quintela@redhat.com>
      CC: Peter Xu <peterx@redhat.com>
      Message-Id: <1544516693-5395-8-git-send-email-wei.w.wang@intel.com>
      Reviewed-by: NMichael S. Tsirkin <mst@redhat.com>
      Signed-off-by: NDr. David Alan Gilbert <dgilbert@redhat.com>
        dgilbert: Dropped kernel header update, fixed up CMD_ID_* name change
      c13c4153
    • W
      migration/ram.c: add the free page optimization enable flag · 6eeb63f7
      Wei Wang 提交于
      This patch adds the free page optimization enable flag, and a function
      to set this flag. When the free page optimization is enabled, not all
      the pages are needed to be sent in the bulk stage.
      
      Why using a new flag, instead of directly disabling ram_bulk_stage when
      the optimization is running?
      Thanks for Peter Xu's reminder that disabling ram_bulk_stage will affect
      the use of compression. Please see save_page_use_compression. When
      xbzrle and compression are used, if free page optimizaion causes the
      ram_bulk_stage to be disabled, save_page_use_compression will return
      false, which disables the use of compression. That is, if free page
      optimization avoids the sending of half of the guest pages, the other
      half of pages loses the benefits of compression in the meantime. Using a
      new flag to let migration_bitmap_find_dirty skip the free pages in the
      bulk stage will avoid the above issue.
      Signed-off-by: NWei Wang <wei.w.wang@intel.com>
      CC: Dr. David Alan Gilbert <dgilbert@redhat.com>
      CC: Juan Quintela <quintela@redhat.com>
      CC: Michael S. Tsirkin <mst@redhat.com>
      CC: Peter Xu <peterx@redhat.com>
      Message-Id: <1544516693-5395-7-git-send-email-wei.w.wang@intel.com>
      Reviewed-by: NDr. David Alan Gilbert <dgilbert@redhat.com>
      Signed-off-by: NDr. David Alan Gilbert <dgilbert@redhat.com>
      6eeb63f7
    • W
      migration/ram.c: add a notifier chain for precopy · bd227060
      Wei Wang 提交于
      This patch adds a notifier chain for the memory precopy. This enables various
      precopy optimizations to be invoked at specific places.
      Signed-off-by: NWei Wang <wei.w.wang@intel.com>
      CC: Dr. David Alan Gilbert <dgilbert@redhat.com>
      CC: Juan Quintela <quintela@redhat.com>
      CC: Michael S. Tsirkin <mst@redhat.com>
      CC: Peter Xu <peterx@redhat.com>
      Reviewed-by: NPeter Xu <peterx@redhat.com>
      Message-Id: <1544516693-5395-6-git-send-email-wei.w.wang@intel.com>
      Signed-off-by: NDr. David Alan Gilbert <dgilbert@redhat.com>
      bd227060
    • W
      migration: API to clear bits of guest free pages from the dirty bitmap · 6bcb05fc
      Wei Wang 提交于
      This patch adds an API to clear bits corresponding to guest free pages
      from the dirty bitmap. Spilt the free page block if it crosses the QEMU
      RAMBlock boundary.
      Signed-off-by: NWei Wang <wei.w.wang@intel.com>
      CC: Dr. David Alan Gilbert <dgilbert@redhat.com>
      CC: Juan Quintela <quintela@redhat.com>
      CC: Michael S. Tsirkin <mst@redhat.com>
      CC: Peter Xu <peterx@redhat.com>
      Reviewed-by: NPeter Xu <peterx@redhat.com>
      Message-Id: <1544516693-5395-5-git-send-email-wei.w.wang@intel.com>
      Signed-off-by: NDr. David Alan Gilbert <dgilbert@redhat.com>
      6bcb05fc
    • W
      migration: use bitmap_mutex in migration_bitmap_clear_dirty · 386a907b
      Wei Wang 提交于
      The bitmap mutex is used to synchronize threads to update the dirty
      bitmap and the migration_dirty_pages counter. For example, the free
      page optimization clears bits of free pages from the bitmap in an
      iothread context. This patch makes migration_bitmap_clear_dirty update
      the bitmap and counter under the mutex.
      Signed-off-by: NWei Wang <wei.w.wang@intel.com>
      CC: Dr. David Alan Gilbert <dgilbert@redhat.com>
      CC: Juan Quintela <quintela@redhat.com>
      CC: Michael S. Tsirkin <mst@redhat.com>
      CC: Peter Xu <peterx@redhat.com>
      Reviewed-by: NPeter Xu <peterx@redhat.com>
      Message-Id: <1544516693-5395-4-git-send-email-wei.w.wang@intel.com>
      Signed-off-by: NDr. David Alan Gilbert <dgilbert@redhat.com>
      386a907b
    • W
      bitmap: bitmap_count_one_with_offset · 94960256
      Wei Wang 提交于
      Count the number of 1s in a bitmap starting from an offset.
      Signed-off-by: NWei Wang <wei.w.wang@intel.com>
      CC: Dr. David Alan Gilbert <dgilbert@redhat.com>
      CC: Juan Quintela <quintela@redhat.com>
      CC: Michael S. Tsirkin <mst@redhat.com>
      Reviewed-by: NDr. David Alan Gilbert <dgilbert@redhat.com>
      Message-Id: <1544516693-5395-3-git-send-email-wei.w.wang@intel.com>
      Signed-off-by: NDr. David Alan Gilbert <dgilbert@redhat.com>
      94960256
    • W
      bitmap: fix bitmap_count_one · e7c91368
      Wei Wang 提交于
      BITMAP_LAST_WORD_MASK(nbits) returns 0xffffffff when "nbits=0", which
      makes bitmap_count_one fail to handle the "nbits=0" case. It appears to be
      preferred to remain BITMAP_LAST_WORD_MASK identical to the kernel
      implementation that it is ported from.
      
      So this patch fixes bitmap_count_one to handle the nbits=0 case.
      
      Inital Discussion Link:
      https://www.mail-archive.com/qemu-devel@nongnu.org/msg554316.htmlSigned-off-by: NWei Wang <wei.w.wang@intel.com>
      CC: Juan Quintela <quintela@redhat.com>
      CC: Dr. David Alan Gilbert <dgilbert@redhat.com>
      CC: Peter Xu <peterx@redhat.com>
      Message-Id: <1544516693-5395-2-git-send-email-wei.w.wang@intel.com>
      Reviewed-by: NDr. David Alan Gilbert <dgilbert@redhat.com>
      Signed-off-by: NDr. David Alan Gilbert <dgilbert@redhat.com>
      e7c91368
    • J
      tests: Add basic migration precopy tcp test · 609d3844
      Juan Quintela 提交于
      Not sharing code from precopy/unix because we have to read back the
      tcp parameter.
      Signed-off-by: NJuan Quintela <quintela@redhat.com>
      Reviewed-by: NDr. David Alan Gilbert <dgilbert@redhat.com>
      Reviewed-by: NPeter Xu <peterx@redhat.com>
      Reviewed-by: NThomas Huth <thuth@redhat.com>
      
      Message-Id: <20190227105128.1655-4-quintela@redhat.com>
      Signed-off-by: NDr. David Alan Gilbert <dgilbert@redhat.com>
        dgilbert:  Fixup for clash with Yury's
      609d3844
    • J
      migration: Create socket-address parameter · 9aca82ba
      Juan Quintela 提交于
      It will be used to store the uri parameters. We want this only for
      tcp, so we don't set it for other uris.  We need it to know what port
      is migration running.
      Reviewed-by: NDr. David Alan Gilbert <dgilbert@redhat.com>
      Signed-off-by: NJuan Quintela <quintela@redhat.com>
      Signed-off-by: NDr. David Alan Gilbert <dgilbert@redhat.com>
        dgilbert: Removed DummyStruct as suggested by Eric & Markus
      
      --
      9aca82ba