1. 19 1月, 2018 3 次提交
    • I
      possible_cpus: add CPUArchId::type field · d342eb76
      Igor Mammedov 提交于
      Remove dependency of possible_cpus on 1st CPU instance,
      which decouples configuration data from CPU instances that
      are created using that data.
      
      Also later it would be used for enabling early cpu to numa node
      configuration at runtime qmp_query_hotpluggable_cpus() should
      provide a list of available cpu slots at early stage,
      before machine_init() is called and the 1st cpu is created,
      so that mgmt might be able to call it and use output to set
      numa mapping.
      
      Use MachineClass::possible_cpu_arch_ids() callback to set
      cpu type info, along with the rest of possible cpu properties,
      to let machine define which cpu type* will be used.
      
      * for SPAPR it will be a spapr core type and for ARM/s390x/x86
        a respective descendant of CPUClass.
      
      Move parse_numa_opts() in vl.c after cpu_model is parsed into
      cpu_type so that possible_cpu_arch_ids() would know which
      cpu_type to use during layout initialization.
      Signed-off-by: NIgor Mammedov <imammedo@redhat.com>
      Reviewed-by: NDavid Gibson <david@gibson.dropbear.id.au>
      Message-Id: <1515597770-268979-1-git-send-email-imammedo@redhat.com>
      Signed-off-by: NEduardo Habkost <ehabkost@redhat.com>
      d342eb76
    • T
      qdev: Check for the availability of a hotplug controller before adding a device · 03fcbd9d
      Thomas Huth 提交于
      The qdev_unplug() function contains a g_assert(hotplug_ctrl) statement,
      so QEMU crashes when the user tries to device_add + device_del a device
      that does not have a corresponding hotplug controller. This could be
      provoked for a couple of devices in the past (see commit 4c939506
      or 84ebd3e8 for example), and can currently for example also be
      triggered like this:
      
      $ s390x-softmmu/qemu-system-s390x -M none -nographic
      QEMU 2.10.50 monitor - type 'help' for more information
      (qemu) device_add qemu-s390x-cpu,id=x
      (qemu) device_del x
      **
      ERROR:qemu/qdev-monitor.c:872:qdev_unplug: assertion failed: (hotplug_ctrl)
      Aborted (core dumped)
      
      So devices clearly need a hotplug controller when they should be usable
      with device_add.
      The code in qdev_device_add() already checks whether the bus has a proper
      hotplug controller, but for devices that do not have a corresponding bus,
      there is no appropriate check available yet. In that case we should check
      whether the machine itself provides a suitable hotplug controller and
      refuse to plug the device if none is available.
      Reviewed-by: NIgor Mammedov <imammedo@redhat.com>
      Signed-off-by: NThomas Huth <thuth@redhat.com>
      Message-Id: <1509617407-21191-3-git-send-email-thuth@redhat.com>
      Reviewed-by: NCornelia Huck <cohuck@redhat.com>
      Signed-off-by: NEduardo Habkost <ehabkost@redhat.com>
      03fcbd9d
    • E
      machine: Replace has_dynamic_sysbus with list of allowed devices · 0bd1909d
      Eduardo Habkost 提交于
      The existing has_dynamic_sysbus flag makes the machine accept
      every user-creatable sysbus device type on the command-line.
      Replace it with a list of allowed device types, so machines can
      easily accept some sysbus devices while rejecting others.
      
      To keep exactly the same behavior as before, the existing
      has_dynamic_sysbus=true assignments are replaced with a
      TYPE_SYS_BUS_DEVICE entry on the allowed list.  Other patches
      will replace the TYPE_SYS_BUS_DEVICE entries with more specific
      lists of devices.
      
      Cc: Peter Maydell <peter.maydell@linaro.org>
      Cc: Marcel Apfelbaum <marcel@redhat.com>
      Cc: "Michael S. Tsirkin" <mst@redhat.com>
      Cc: Alexander Graf <agraf@suse.de>
      Cc: David Gibson <david@gibson.dropbear.id.au>
      Cc: Stefano Stabellini <sstabellini@kernel.org>
      Cc: Anthony Perard <anthony.perard@citrix.com>
      Cc: qemu-arm@nongnu.org
      Cc: qemu-ppc@nongnu.org
      Cc: xen-devel@lists.xenproject.org
      Signed-off-by: NEduardo Habkost <ehabkost@redhat.com>
      Message-Id: <20171125151610.20547-2-ehabkost@redhat.com>
      Reviewed-by: NGreg Kurz <groug@kaod.org>
      Reviewed-by: NDavid Gibson <david@gibson.dropbear.id.au>
      Reviewed-by: NMarc-André Lureau <marcandre.lureau@redhat.com>
      Reviewed-by: NMarcel Apfelbaum <marcel@redhat.com>
      Signed-off-by: NEduardo Habkost <ehabkost@redhat.com>
      0bd1909d
  2. 19 12月, 2017 2 次提交
  3. 18 12月, 2017 1 次提交
  4. 15 12月, 2017 1 次提交
  5. 06 12月, 2017 1 次提交
  6. 18 10月, 2017 3 次提交
    • M
      qdev: defer DEVICE_DEL event until instance_finalize() · f7b879e0
      Michael Roth 提交于
      DEVICE_DEL is currently emitted when a Device is unparented, as
      opposed to when it is finalized. The main design motivation for this
      seems to be that after unparent()/unrealize(), the Device is no
      longer visible to the guest, and thus the operation is complete
      from the perspective of management.
      
      However, there are cases where remaining host-side cleanup is also
      pertinent to management. The is generally handled by treating these
      resources as aspects of the "backend", which can be managed via
      separate interfaces/events, such as blockdev_add/del, netdev_add/del,
      object_add/del, etc, but some devices do not have this level of
      compartmentalization, namely vfio-pci, and possibly to lend themselves
      well to it.
      
      In the case of vfio-pci, the "backend" cleanup happens as part of
      the finalization of the vfio-pci device itself, in particular the
      cleanup of the VFIO group FD. Failing to wait for this cleanup can
      result in tools like libvirt attempting to rebind the device to
      the host while it's still being used by VFIO, which can result in
      host crashes or other misbehavior depending on the host driver.
      
      Deferring DEVICE_DEL still affords us the ability to manage backends
      explicitly, while also addressing cases like vfio-pci's, so we
      implement that approach here.
      
      An alternative proposal involving having VFIO emit a separate event
      to denote completion of host-side cleanup was discussed, but the
      prevailing opinion seems to be that it is not worth the added
      complexity, and leaves the issue open for other Device implementations
      to solve in the future.
      Signed-off-by: NMichael Roth <mdroth@linux.vnet.ibm.com>
      Reviewed-by: NGreg Kurz <groug@kaod.org>
      Tested-by: NEric Auger <eric.auger@redhat.com>
      Reviewed-by: NDavid Gibson <david@gibson.dropbear.id.au>
      Message-Id: <20171016222315.407-4-mdroth@linux.vnet.ibm.com>
      Signed-off-by: NPaolo Bonzini <pbonzini@redhat.com>
      f7b879e0
    • M
      Revert "qdev: Free QemuOpts when the QOM path goes away" · 2fc06c4a
      Michael Roth 提交于
      This reverts commit abed886e.
      
      This patch originally addressed an issue where a DEVICE_DELETED
      event could be emitted (in device_unparent()) before a Device's
      QemuOpts were cleaned up (in device_finalize()), leading to a
      "duplicate ID" error if management attempted to immediately add
      a device with the same ID in response to the DEVICE_DELETED event.
      
      An alternative will be implemented in a subsequent patch where we
      defer the DEVICE_DELETED event until device_finalize(), which would
      also prevent the race, so we revert the original fix in preparation.
      Signed-off-by: NMichael Roth <mdroth@linux.vnet.ibm.com>
      Reviewed-by: NGreg Kurz <groug@kaod.org>
      Tested-by: NEric Auger <eric.auger@redhat.com>
      Reviewed-by: NDavid Gibson <david@gibson.dropbear.id.au>
      Message-Id: <20171016222315.407-3-mdroth@linux.vnet.ibm.com>
      Signed-off-by: NPaolo Bonzini <pbonzini@redhat.com>
      2fc06c4a
    • M
      qdev: store DeviceState's canonical path to use when unparenting · 04162f8f
      Michael Roth 提交于
      device_unparent(dev, ...) is called when a device is unparented,
      either directly, or as a result of a parent device being
      finalized, and handles some final cleanup for the device. Part
      of this includes emiting a DEVICE_DELETED QMP event to notify
      management, which includes the device's path in the composition
      tree as provided by object_get_canonical_path().
      
      object_get_canonical_path() assumes the device is still connected
      to the machine/root container, and will assert otherwise, but
      in some situations this isn't the case:
      
      If the parent is finalized as a result of object_unparent(), it
      will still be attached to the composition tree at the time any
      children are unparented as a result of that same call to
      object_unparent(). However, in some cases, object_unparent()
      will complete without finalizing the parent device, due to
      lingering references that won't be released till some time later.
      One such example is if the parent has MemoryRegion children (which
      take a ref on their parent), who in turn have AddressSpace's (which
      take a ref on their regions), since those AddressSpaces get cleaned
      up asynchronously by the RCU thread.
      
      In this case qdev:device_unparent() may be called for a child Device
      that no longer has a path to the root/machine container, causing
      object_get_canonical_path() to assert.
      
      Fix this by storing the canonical path during realize() so the
      information will still be available for device_unparent() in such
      cases.
      
      Cc: Michael S. Tsirkin <mst@redhat.com>
      Cc: Paolo Bonzini <pbonzini@redhat.com>
      Signed-off-by: NMichael Roth <mdroth@linux.vnet.ibm.com>
      Signed-off-by: NGreg Kurz <groug@kaod.org>
      Signed-off-by: NMichael Roth <mdroth@linux.vnet.ibm.com>
      Tested-by: NEric Auger <eric.auger@redhat.com>
      Reviewed-by: NDavid Gibson <david@gibson.dropbear.id.au>
      Message-Id: <20171016222315.407-2-mdroth@linux.vnet.ibm.com>
      [Clear dev->canonical_path at the post_realize_fail label, which is
       cleaner.  Suggested by David Gibson. - Paolo]
      Signed-off-by: NPaolo Bonzini <pbonzini@redhat.com>
      04162f8f
  7. 15 10月, 2017 1 次提交
  8. 10 10月, 2017 1 次提交
  9. 20 9月, 2017 1 次提交
    • I
      numa: cpu: calculate/set default node-ids after all -numa CLI options are parsed · 79e07936
      Igor Mammedov 提交于
      Calculating default node-ids for CPUs in possible_cpu_arch_ids()
      is rather fragile since defaults calculation uses nb_numa_nodes but
      callback might be potentially called early before all -numa CLI
      options are parsed, which would lead to cpus assigned only upto
      nb_numa_nodes at the time possible_cpu_arch_ids() is called.
      
      Issue was introduced by
      (7c88e65d numa: mirror cpu to node mapping in MachineState::possible_cpus)
      and for example CLI:
        -smp 4 -numa node,cpus=0 -numa node
      would set props.node-id in possible_cpus array for every non
      explicitly mapped CPU to the first node.
      
      Issue is not visible to guest nor to mgmt interface due to
        1) implictly mapped cpus are forced to the first node in
           case of partial mapping
        2) in case of default mapping possible_cpu_arch_ids() is
           called after all -numa options are parsed (resulting
           in correct mapping).
      
      However it's fragile to rely on late execution of
      possible_cpu_arch_ids(), therefore add machine specific
      callback that returns node-id for CPU and use it to calculate/
      set defaults at machine_numa_finish_init() time when all -numa
      options are parsed.
      Reported-by: NEduardo Habkost <ehabkost@redhat.com>
      Signed-off-by: NIgor Mammedov <imammedo@redhat.com>
      Message-Id: <1496314408-163972-1-git-send-email-imammedo@redhat.com>
      Reviewed-by: NEduardo Habkost <ehabkost@redhat.com>
      Signed-off-by: NEduardo Habkost <ehabkost@redhat.com>
      79e07936
  10. 08 9月, 2017 1 次提交
  11. 04 9月, 2017 2 次提交
  12. 31 7月, 2017 1 次提交
  13. 28 7月, 2017 1 次提交
  14. 18 7月, 2017 3 次提交
  15. 17 7月, 2017 1 次提交
    • P
      qdev: support properties which don't set a default value · 5cc56cc6
      Peter Maydell 提交于
      In some situations it's useful to have a qdev property which doesn't
      automatically set its default value when qdev_property_add_static is
      called (for instance when the default value is not constant).
      
      Support this by adding a flag to the Property struct indicating
      whether to set the default value.  This replaces the existing test
      for whether the PropertyInfo set_default_value function pointer is
      NULL, and we set the .set_default field to true for all those cases
      of struct Property which use a PropertyInfo with a non-NULL
      set_default_value, so behaviour remains the same as before.
      
      This gives us the semantics of:
       * if .set_default is true, then .info->set_default_value must
         be not NULL, and .defval is used as the the default value of
         the property
       * otherwise, the property system does not set any default, and
         the field will retain whatever initial value it was given by
         the device's .instance_init method
      
      We define two new macros DEFINE_PROP_SIGNED_NODEFAULT and
      DEFINE_PROP_UNSIGNED_NODEFAULT, to cover the most plausible use cases
      of wanting to set an integer property with no default value.
      Suggested-by: NMarkus Armbruster <armbru@redhat.com>
      Signed-off-by: NPeter Maydell <peter.maydell@linaro.org>
      Reviewed-by: NMarc-André Lureau <marcandre.lureau@redhat.com>
      Reviewed-by: NMarkus Armbruster <armbru@redhat.com>
      Message-id: 1499788408-10096-3-git-send-email-peter.maydell@linaro.org
      5cc56cc6
  16. 14 7月, 2017 4 次提交
  17. 13 7月, 2017 2 次提交
  18. 11 7月, 2017 2 次提交
  19. 28 6月, 2017 2 次提交
  20. 20 6月, 2017 3 次提交
  21. 19 6月, 2017 1 次提交
  22. 06 6月, 2017 2 次提交
    • I
      numa: make sure that all cpus have has_node_id set if numa is enabled · d41f3e75
      Igor Mammedov 提交于
      It fixes/add missing _PXM object for non mapped CPU (x86)
      and missing fdt node (virt-arm).
      
      It ensures that possible_cpus contains complete mapping if
      numa is enabled by the time machine_init() is executed.
      
      As result non completely mapped CPUs:
       1) appear in ACPI/fdt blobs
       2) QMP query-hotpluggable-cpus command shows bound nodes for such CPUs
       3) allows to drop checks for has_node_id in numa only code,
         reducing number of invariants incomplete mapping could produce
       4) moves fixup/implicit node init from runtime numa_cpu_pre_plug()
         (when CPU object is created) to machine_numa_finish_init() which
         helps to fix [1, 2] and make possible_cpus complete source
         of numa mapping available even before CPUs are created.
      Signed-off-by: NIgor Mammedov <imammedo@redhat.com>
      Message-Id: <1496161442-96665-4-git-send-email-imammedo@redhat.com>
      Signed-off-by: NEduardo Habkost <ehabkost@redhat.com>
      d41f3e75
    • I
      numa: move default mapping init to machine · 60bed6a3
      Igor Mammedov 提交于
      there is no need use cpu_index_to_instance_props() for setting
      default cpu -> node mapping. Generic machine code can do it
      without cpu_index by just enabling already preset defaults
      in possible_cpus.
      
      PS:
      as bonus it makes one less user of cpu_index_to_instance_props()
      Signed-off-by: NIgor Mammedov <imammedo@redhat.com>
      Message-Id: <1496161442-96665-3-git-send-email-imammedo@redhat.com>
      Signed-off-by: NEduardo Habkost <ehabkost@redhat.com>
      60bed6a3
  23. 05 6月, 2017 1 次提交