Skip to content
Snippets Groups Projects
  1. Oct 13, 2021
  2. Oct 02, 2021
    • David Hildenbrand's avatar
      softmmu/memory_mapping: optimize for RamDiscardManager sections · cb83ba8c
      David Hildenbrand authored
      
      virtio-mem logically plugs/unplugs memory within a sparse memory region
      and notifies via the RamDiscardManager interface when parts become
      plugged (populated) or unplugged (discarded).
      
      Currently, we end up (via the two users)
      1) zeroing all logically unplugged/discarded memory during TPM resets.
      2) reading all logically unplugged/discarded memory when dumping, to
         figure out the content is zero.
      
      1) is always bad, because we assume unplugged memory stays discarded
         (and is already implicitly zero).
      2) isn't that bad with anonymous memory, we end up reading the zero
         page (slow and unnecessary, though). However, once we use some
         file-backed memory (future use case), even reading will populate memory.
      
      Let's cut out all parts marked as not-populated (discarded) via the
      RamDiscardManager. As virtio-mem is the single user, this now means that
      logically unplugged memory ranges will no longer be included in the
      dump, which results in smaller dump files and faster dumping.
      
      virtio-mem has a minimum granularity of 1 MiB (and the default is usually
      2 MiB). Theoretically, we can see quite some fragmentation, in practice
      we won't have it completely fragmented in 1 MiB pieces. Still, we might
      end up with many physical ranges.
      
      Both, the ELF format and kdump seem to be ready to support many
      individual ranges (e.g., for ELF it seems to be UINT32_MAX, kdump has a
      linear bitmap).
      
      Reviewed-by: default avatarPeter Xu <peterx@redhat.com>
      Cc: Marc-André Lureau <marcandre.lureau@redhat.com>
      Cc: Paolo Bonzini <pbonzini@redhat.com>
      Cc: "Michael S. Tsirkin" <mst@redhat.com>
      Cc: Eduardo Habkost <ehabkost@redhat.com>
      Cc: Alex Williamson <alex.williamson@redhat.com>
      Cc: Dr. David Alan Gilbert <dgilbert@redhat.com>
      Cc: Igor Mammedov <imammedo@redhat.com>
      Cc: Claudio Fontana <cfontana@suse.de>
      Cc: Thomas Huth <thuth@redhat.com>
      Cc: "Alex Bennée" <alex.bennee@linaro.org>
      Cc: Peter Xu <peterx@redhat.com>
      Cc: Laurent Vivier <lvivier@redhat.com>
      Cc: Stefan Berger <stefanb@linux.ibm.com>
      Signed-off-by: default avatarDavid Hildenbrand <david@redhat.com>
      Message-Id: <20210727082545.17934-5-david@redhat.com>
      Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
      cb83ba8c
    • David Hildenbrand's avatar
      softmmu/memory_mapping: factor out adding physical memory ranges · 3513bb1b
      David Hildenbrand authored
      
      Let's factor out adding a MemoryRegionSection to the list, to be reused in
      RamDiscardManager context next.
      
      Reviewed-by: default avatarStefan Berger <stefanb@linux.ibm.com>
      Reviewed-by: default avatarPeter Xu <peterx@redhat.com>
      Cc: Marc-André Lureau <marcandre.lureau@redhat.com>
      Cc: Paolo Bonzini <pbonzini@redhat.com>
      Cc: "Michael S. Tsirkin" <mst@redhat.com>
      Cc: Eduardo Habkost <ehabkost@redhat.com>
      Cc: Alex Williamson <alex.williamson@redhat.com>
      Cc: Dr. David Alan Gilbert <dgilbert@redhat.com>
      Cc: Igor Mammedov <imammedo@redhat.com>
      Cc: Claudio Fontana <cfontana@suse.de>
      Cc: Thomas Huth <thuth@redhat.com>
      Cc: "Alex Bennée" <alex.bennee@linaro.org>
      Cc: Peter Xu <peterx@redhat.com>
      Cc: Laurent Vivier <lvivier@redhat.com>
      Cc: Stefan Berger <stefanb@linux.ibm.com>
      Signed-off-by: default avatarDavid Hildenbrand <david@redhat.com>
      Message-Id: <20210727082545.17934-4-david@redhat.com>
      Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
      3513bb1b
    • David Hildenbrand's avatar
      softmmu/memory_mapping: never merge ranges accross memory regions · 602f8ea7
      David Hildenbrand authored
      
      Let's make sure to not merge when different memory regions are involved.
      Unlikely, but theoretically possible.
      
      Acked-by: default avatarStefan Berger <stefanb@linux.ibm.com>
      Reviewed-by: default avatarPeter Xu <peterx@redhat.com>
      Cc: Marc-André Lureau <marcandre.lureau@redhat.com>
      Cc: Paolo Bonzini <pbonzini@redhat.com>
      Cc: "Michael S. Tsirkin" <mst@redhat.com>
      Cc: Eduardo Habkost <ehabkost@redhat.com>
      Cc: Alex Williamson <alex.williamson@redhat.com>
      Cc: Dr. David Alan Gilbert <dgilbert@redhat.com>
      Cc: Igor Mammedov <imammedo@redhat.com>
      Cc: Claudio Fontana <cfontana@suse.de>
      Cc: Thomas Huth <thuth@redhat.com>
      Cc: "Alex Bennée" <alex.bennee@linaro.org>
      Cc: Peter Xu <peterx@redhat.com>
      Cc: Laurent Vivier <lvivier@redhat.com>
      Cc: Stefan Berger <stefanb@linux.ibm.com>
      Signed-off-by: default avatarDavid Hildenbrand <david@redhat.com>
      Message-Id: <20210727082545.17934-3-david@redhat.com>
      Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
      602f8ea7
  3. Sep 30, 2021
  4. Sep 13, 2021
    • Peter Maydell's avatar
      qdev: Support marking individual buses as 'full' · 1518562b
      Peter Maydell authored
      
      By default, QEMU will allow devices to be plugged into a bus up to
      the bus class's device count limit.  If the user creates a device on
      the command line or via the monitor and doesn't explicitly specify
      the bus to plug it in, QEMU will plug it into the first non-full bus
      that it finds.
      
      This is fine in most cases, but some machines have multiple buses of
      a given type, some of which are dedicated to on-board devices and
      some of which have an externally exposed connector for user-pluggable
      devices. One example is I2C buses.
      
      Provide a new function qbus_mark_full() so that a machine model can
      mark this kind of "internal only" bus as 'full' after it has created
      all the devices that should be plugged into that bus. The "find a
      non-full bus" algorithm will then skip the internal-only bus when
      looking for a place to plug in user-created devices.
      
      Signed-off-by: default avatarPeter Maydell <peter.maydell@linaro.org>
      Reviewed-by: default avatarRichard Henderson <richard.henderson@linaro.org>
      Message-id: 20210903151435.22379-2-peter.maydell@linaro.org
      1518562b
  5. Sep 06, 2021
    • Thomas Huth's avatar
      softmmu/vl: Deprecate the -sdl and -curses option · 6695e4c0
      Thomas Huth authored
      
      It's not that much complicated to type "-display sdl" or "-display curses",
      so we should not clutter our main option name space with such simple
      wrapper options and rather present the users with a concise interface
      instead. Thus let's deprecate the "-sdl" and "-curses" wrapper options now.
      
      Message-Id: <20210825092023.81396-4-thuth@redhat.com>
      Reviewed-by: default avatarGerd Hoffmann <kraxel@redhat.com>
      Acked-by: default avatarPeter Krempa <pkrempa@redhat.com>
      Signed-off-by: default avatarThomas Huth <thuth@redhat.com>
      6695e4c0
    • Thomas Huth's avatar
      softmmu/vl: Deprecate the old grab options · d46156fd
      Thomas Huth authored
      
      The alt_grab and ctrl_grab parameter of the -display sdl option prevent
      the QAPIfication of the "sdl" part of the -display option, so we should
      eventually remove them. And since this feature is also rather niche anyway,
      we should not clutter the top-level option list with these, so let's
      also deprecate the "-alt-grab" and the "-ctrl-grab" options while we're
      at it.
      
      Once the deprecation period of "alt_grab" and "ctrl_grab" is over, we
      then can finally switch the -display sdl option to use QAPI internally,
      too.
      
      Message-Id: <20210825092023.81396-3-thuth@redhat.com>
      Reviewed-by: default avatarGerd Hoffmann <kraxel@redhat.com>
      Acked-by: default avatarPeter Krempa <pkrempa@redhat.com>
      Signed-off-by: default avatarThomas Huth <thuth@redhat.com>
      d46156fd
    • Thomas Huth's avatar
      softmmu/vl: Add a "grab-mod" parameter to the -display sdl option · 8e8e844b
      Thomas Huth authored
      
      The -display sdl option is not using QAPI internally yet, and uses hand-
      crafted parsing instead (see parse_display() in vl.c), which is quite
      ugly, since most of the other code is using the QAPIfied DisplayOption
      already. Unfortunately, the "alt_grab" and "ctrl_grab" use underscores in
      their names which has recently been forbidden in new QAPI code, so
      a straight conversion is not possible. While we could add some exceptions
      to the QAPI schema parser for this, the way these parameters have been
      designed was maybe a bad idea anyway: First, it's not possible to enable
      both parameters at the same time, thus instead of two boolean parameters
      it would be better to have only one multi-choice parameter instead.
      Second, the naming is also somewhat unfortunate since the "alt_grab"
      parameter is not about the ALT key, but rather about the left SHIFT key
      that has to be used additionally when the parameter is enabled.
      
      So instead of trying to QAPIfy "alt_grab" and "ctrl_grab", let's rather
      introduce an alternative to these parameters instead, a new parameter
      called "grab-mod" which can either be set to "lshift-lctrl-lalt" or to
      "rctrl". In case we ever want to support additional modes later, we can
      then also simply extend the list of supported strings here.
      
      Message-Id: <20210825092023.81396-2-thuth@redhat.com>
      Reviewed-by: default avatarGerd Hoffmann <kraxel@redhat.com>
      Signed-off-by: default avatarThomas Huth <thuth@redhat.com>
      8e8e844b
  6. Aug 26, 2021
  7. Aug 17, 2021
  8. Jul 30, 2021
    • Paolo Bonzini's avatar
      vl: stop recording -smp in QemuOpts · e4383ca2
      Paolo Bonzini authored
      
      -readconfig is still recording SMP options in QemuOpts instead of
      using machine_opts_dict.  This means that SMP options from -readconfig
      are ignored.
      
      Just stop using QemuOpts for -smp, making it return false for
      is_qemuopts_group.  Configuration files will merge the values in
      machine_opts_dict using the new function machine_merge_property.
      
      At the same time, fix -mem-prealloc which looked at QemuOpts to find the
      number of guest CPUs, which it used as the default number of preallocation
      threads.
      
      Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
      e4383ca2
    • Paolo Bonzini's avatar
      vl: introduce machine_merge_property · a3c2f128
      Paolo Bonzini authored
      
      It will be used to parse smp-opts config groups from configuration
      files.  The point to note is that it does not steal a reference
      from the caller.  This is better because this function will be called
      from qemu_config_foreach's callback; qemu_config_foreach does not cede
      its reference to the qdict to the callback, and wants to free it.  To
      balance that extra reference, machine_parse_property_opt now needs
      a qobject_unref.
      
      Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
      a3c2f128
  9. Jul 27, 2021
  10. Jul 22, 2021
  11. Jul 21, 2021
  12. Jul 20, 2021
    • Jason Andryuk's avatar
      vl: Parse legacy default_machine_opts · dadafe67
      Jason Andryuk authored
      
      qemu can't start a xen vm after commit d8fb7d09
      "vl: switch -M parsing to keyval" with:
      
      $ ./qemu-system-i386 -M xenfv
      Unexpected error in object_property_find_err() at ../qom/object.c:1298:
      qemu-system-i386: Property 'xenfv-3.1-machine.accel' not found
      Aborted (core dumped)
      
      The default_machine_opts handling doesn't process the legacy machine
      options like "accel".  Call qemu_apply_legacy_machine_options to provide
      the legacy handling.
      
      Signed-off-by: default avatarJason Andryuk <jandryuk@gmail.com>
      Message-Id: <20210713021552.19110-1-jandryuk@gmail.com>
      Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
      dadafe67
  13. Jul 14, 2021
  14. Jul 09, 2021
  15. Jul 08, 2021
    • David Hildenbrand's avatar
      softmmu/physmem: Extend ram_block_discard_(require|disable) by two discard types · 7e6d32eb
      David Hildenbrand authored
      
      We want to separate the two cases whereby we discard ram
      - uncoordinated: e.g., virito-balloon
      - coordinated: e.g., virtio-mem coordinated via the RamDiscardManager
      
      Reviewed-by: default avatarPankaj Gupta <pankaj.gupta@cloud.ionos.com>
      Acked-by: default avatarMichael S. Tsirkin <mst@redhat.com>
      Cc: Paolo Bonzini <pbonzini@redhat.com>
      Cc: "Michael S. Tsirkin" <mst@redhat.com>
      Cc: Alex Williamson <alex.williamson@redhat.com>
      Cc: Dr. David Alan Gilbert <dgilbert@redhat.com>
      Cc: Igor Mammedov <imammedo@redhat.com>
      Cc: Pankaj Gupta <pankaj.gupta.linux@gmail.com>
      Cc: Peter Xu <peterx@redhat.com>
      Cc: Auger Eric <eric.auger@redhat.com>
      Cc: Wei Yang <richard.weiyang@linux.alibaba.com>
      Cc: teawater <teawaterz@linux.alibaba.com>
      Cc: Marek Kedzierski <mkedzier@redhat.com>
      Signed-off-by: default avatarDavid Hildenbrand <david@redhat.com>
      Message-Id: <20210413095531.25603-12-david@redhat.com>
      Signed-off-by: default avatarEduardo Habkost <ehabkost@redhat.com>
      7e6d32eb
    • David Hildenbrand's avatar
      softmmu/physmem: Don't use atomic operations in ram_block_discard_(disable|require) · 98da491d
      David Hildenbrand authored
      
      We have users in migration context that don't hold the BQL (when
      finishing migration). To prepare for further changes, use a dedicated mutex
      instead of atomic operations. Keep using qatomic_read ("READ_ONCE") for the
      functions that only extract the current state (e.g., used by
      virtio-balloon), locking isn't necessary.
      
      While at it, split up the counter into two variables to make it easier
      to understand.
      
      Suggested-by: default avatarPeter Xu <peterx@redhat.com>
      Reviewed-by: default avatarPeter Xu <peterx@redhat.com>
      Reviewed-by: default avatarPankaj Gupta <pankaj.gupta@cloud.ionos.com>
      Acked-by: default avatarMichael S. Tsirkin <mst@redhat.com>
      Cc: Paolo Bonzini <pbonzini@redhat.com>
      Cc: "Michael S. Tsirkin" <mst@redhat.com>
      Cc: Alex Williamson <alex.williamson@redhat.com>
      Cc: Dr. David Alan Gilbert <dgilbert@redhat.com>
      Cc: Igor Mammedov <imammedo@redhat.com>
      Cc: Pankaj Gupta <pankaj.gupta.linux@gmail.com>
      Cc: Peter Xu <peterx@redhat.com>
      Cc: Auger Eric <eric.auger@redhat.com>
      Cc: Wei Yang <richard.weiyang@linux.alibaba.com>
      Cc: teawater <teawaterz@linux.alibaba.com>
      Cc: Marek Kedzierski <mkedzier@redhat.com>
      Signed-off-by: default avatarDavid Hildenbrand <david@redhat.com>
      Message-Id: <20210413095531.25603-11-david@redhat.com>
      Signed-off-by: default avatarEduardo Habkost <ehabkost@redhat.com>
      98da491d
    • David Hildenbrand's avatar
      memory: Helpers to copy/free a MemoryRegionSection · 22843838
      David Hildenbrand authored
      
      In case one wants to create a permanent copy of a MemoryRegionSections,
      one needs access to flatview_ref()/flatview_unref(). Instead of exposing
      these, let's just add helpers to copy/free a MemoryRegionSection and
      properly adjust references.
      
      Cc: Paolo Bonzini <pbonzini@redhat.com>
      Cc: "Michael S. Tsirkin" <mst@redhat.com>
      Cc: Alex Williamson <alex.williamson@redhat.com>
      Cc: Dr. David Alan Gilbert <dgilbert@redhat.com>
      Cc: Igor Mammedov <imammedo@redhat.com>
      Cc: Pankaj Gupta <pankaj.gupta.linux@gmail.com>
      Cc: Peter Xu <peterx@redhat.com>
      Cc: Auger Eric <eric.auger@redhat.com>
      Cc: Wei Yang <richard.weiyang@linux.alibaba.com>
      Cc: teawater <teawaterz@linux.alibaba.com>
      Cc: Marek Kedzierski <mkedzier@redhat.com>
      Signed-off-by: default avatarDavid Hildenbrand <david@redhat.com>
      Message-Id: <20210413095531.25603-3-david@redhat.com>
      Signed-off-by: default avatarEduardo Habkost <ehabkost@redhat.com>
      22843838
    • David Hildenbrand's avatar
      memory: Introduce RamDiscardManager for RAM memory regions · 8947d7fc
      David Hildenbrand authored
      We have some special RAM memory regions (managed by virtio-mem), whereby
      the guest agreed to only use selected memory ranges. "unused" parts are
      discarded so they won't consume memory - to logically unplug these memory
      ranges. Before the VM is allowed to use such logically unplugged memory
      again, coordination with the hypervisor is required.
      
      This results in "sparse" mmaps/RAMBlocks/memory regions, whereby only
      coordinated parts are valid to be used/accessed by the VM.
      
      In most cases, we don't care about that - e.g., in KVM, we simply have a
      single KVM memory slot. However, in case of vfio, registering the
      whole region with the kernel results in all pages getting pinned, and
      therefore an unexpected high memory consumption - discarding of RAM in
      that context is broken.
      
      Let's introduce a way to coordinate discarding/populating memory within a
      RAM memory region with such special consumers of RAM memory regions: they
      can register as listeners and get updates on memory getting discarded and
      populated. Using this machinery, vfio will be able to map only the
      currently populated parts, resulting in discarded parts not getting pinned
      and not consuming memory.
      
      A RamDiscardManager has to be set for a memory region before it is getting
      mapped, and cannot change while the memory region is mapped.
      
      Note: At some point, we might want to let RAMBlock users (esp. vfio used
      for nvme://
      
      ) consume this interface as well. We'll need RAMBlock notifier
      calls when a RAMBlock is getting mapped/unmapped (via the corresponding
      memory region), so we can properly register a listener there as well.
      
      Reviewed-by: default avatarPankaj Gupta <pankaj.gupta@cloud.ionos.com>
      Acked-by: default avatarMichael S. Tsirkin <mst@redhat.com>
      Cc: Paolo Bonzini <pbonzini@redhat.com>
      Cc: "Michael S. Tsirkin" <mst@redhat.com>
      Cc: Alex Williamson <alex.williamson@redhat.com>
      Cc: Dr. David Alan Gilbert <dgilbert@redhat.com>
      Cc: Igor Mammedov <imammedo@redhat.com>
      Cc: Pankaj Gupta <pankaj.gupta.linux@gmail.com>
      Cc: Peter Xu <peterx@redhat.com>
      Cc: Auger Eric <eric.auger@redhat.com>
      Cc: Wei Yang <richard.weiyang@linux.alibaba.com>
      Cc: teawater <teawaterz@linux.alibaba.com>
      Cc: Marek Kedzierski <mkedzier@redhat.com>
      Signed-off-by: default avatarDavid Hildenbrand <david@redhat.com>
      Message-Id: <20210413095531.25603-2-david@redhat.com>
      Signed-off-by: default avatarEduardo Habkost <ehabkost@redhat.com>
      8947d7fc
  16. Jul 06, 2021
    • Paolo Bonzini's avatar
      machine: add smp compound property · fe68090e
      Paolo Bonzini authored
      
      Make -smp syntactic sugar for a compound property "-machine
      smp.{cores,threads,cpu,...}".  machine_smp_parse is replaced by the
      setter for the property.
      
      numa-test will now cover the new syntax, while other tests
      still use -smp.
      
      Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
      fe68090e
    • Paolo Bonzini's avatar
      vl: switch -M parsing to keyval · d8fb7d09
      Paolo Bonzini authored
      
      Switch from QemuOpts to keyval.  This enables the introduction
      of non-scalar machine properties, and JSON syntax in the future.
      
      For JSON syntax to be supported right now, we would have to
      consider what would happen if string-based dictionaries (produced by
      -M key=val) were to be merged with strongly-typed dictionaries
      (produced by -M {'key': 123}).
      
      The simplest way out is to never enter the situation, and only allow one
      -M option when JSON syntax is in use.  However, we want options such as
      -smp to become syntactic sugar for -M, and this is a problem; as soon
      as -smp becomes a shortcut for -M, QEMU would forbid using -M '{....}'
      together with -smp.  Therefore, allowing JSON syntax right now for -M
      would be a forward-compatibility nightmare and it would be impossible
      anyway to introduce -M incrementally in tools.
      
      Instead, support for JSON syntax is delayed until after the main
      options are converted to QOM compound properties.  These include -boot,
      -acpitable, -smbios, -m, -semihosting-config, -rtc and -fw_cfg.  Once JSON
      syntax is introduced, these options will _also_ be forbidden together
      with -M '{...}'.
      
      Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
      d8fb7d09
Loading