qapi: add SIZE type parser to string_input_visitor

Signed-off-by: Igor Mammedov <imammedo@redhat.com>
get reference to /backend container via qemu_get_backend()

... API, so it could be reused later using qemu_get_backend()
without duplicating "/backend" everywhere.

Signed-off-by: Igor Mammedov <imammedo@redhat.com>
add memdev backend infrastructure

Provides framework for splitting host RAM allocation/
policies into a separate backend that could be used
by devices. It would allow to separate host specific
options from device model like it's done for netdev & co.

It adds new:
   -memdev CLI option and corresponding memdev-add
    QMP/HMP commands.

Upon successful command execution an new memdev object
is added to QOM tree into "/backend" container.

Initially only legacy RAM backend is provided which
uses memory_region_init_ram() allocator and compatible
every CLI option that affects memory_region_init_ram().

memdev object is intendend for usage with Dimm device,
example:
 -memdev id=m1,size=1G -device dimm,id=dimm1,backend=m1

Signed-off-by: Igor Mammedov <imammedo@redhat.com>
vl: set default ram_size during variable initialization

Signed-off-by: Igor Mammedov <imammedo@redhat.com>
---
v2:
  - keep legacy behaviour "-m 0" resulting in default ram_size value
dimm: implement dimm device abstraction

Each hotplug-able memory slot is a DimmDevice. All DimmDevices are
attached to a new bus called DimmBus.

A hot-add operation for a DIMM:
- creates a new DimmDevice and attaches it to the DimmBus

Hotplug operations are done through normal device_add commands.
For migration case, all hotplugged DIMMs on source should be specified
on target's command line using '-device' option with properties set to
the same values as on target.

To simplify review, patch introduces only DimmDevice and DimmBus basic
QOM skeleton that will be extended by following patches to implement
actual memory hotplug and related functions.

Signed-off-by: Vasilis Liaskovitis <vasilis.liaskovitis@profitbricks.com>
Signed-off-by: Igor Mammedov <imammedo@redhat.com>
---
v3:
  pc: compile memhotplug on i386 target too
v2:
  fix typo s/DimmBus/DimmDevice/ in doc comment
  s/klass/oc/;s/*/parent_obj/;a/gtk-doc markup/
dimm: map DimmDevice into DimBus provided address space

Signed-off-by: Igor Mammedov <imammedo@redhat.com>
dimm: add busy slot check and slot auto-allocation

- if slot property is not specified on -device/device_add command,
treat default value as request for assigning DimmDevice to
the first free slot.

- if slot is provided with -device/device_add command, attempt to
use it or fail command if it's already occupied.

Signed-off-by: Igor Mammedov <imammedo@redhat.com>
---
v2:
  s/dc/dbc/
dimm: add busy address check and address auto-allocation

- if 'start' property is not specified on -device/device_add command,
treat default value as request for assigning DimmDevice to
the first free memory region.

- if 'start' is provided with -device/device_add command, attempt to
use it or fail command if it's already occupied or falls inside
of an existing DimmDevice memory region.

Signed-off-by: Igor Mammedov <imammedo@redhat.com>
---
v2:
  s/dc/dbc/
dimm: add hotplug callback to DimmBus

Signed-off-by: Igor Mammedov <imammedo@redhat.com>
acpi/piix4: introduce memory hot-plug interface QEMU<->ACPI BIOS

- implements QEMU part of memory hotplug protocol described at
  docs/specs/acpi_mem_hotplug.txt
- handles memory add notification event.

Signed-off-by: Igor Mammedov <imammedo@redhat.com>
---
v2:
  * acpi/piix: impl hotplug callback
pc: ACPI BIOS: implement memory hotplug interface

- provides static DSDT object for memory hotplug
- SSDT template for memory devices and runtime generator
  of them in SSDT table.

Signed-off-by: Vasilis Liaskovitis <vasilis.liaskovitis@profitbricks.com>
Signed-off-by: Igor Mammedov <imammedo@redhat.com>
pc: update acpi-dsdt.hex.generated and add ssdt-mem.hex.generated

Signed-off-by: Igor Mammedov <imammedo@redhat.com>
acpi: use enum for defining memory affinity flags

replace magic numbers with enum describing Flags field of
memory affinity in SRAT table.

MemoryAffinityFlags enum will define flags decribed by:
 ACPI spec 5.0, "5.2.16.2 Memory Affinity Structure",
 "Table 5-69 Flags - Memory Affinity Structure"

Signed-off-by: Igor Mammedov <imammedo@redhat.com>
acpi: return PIIX4_PM from piix4_pm_init()

it will be used by pc_piix to set PIIX4_PM as
hotplug device for memory hotplug notification
to guest.

Signed-off-by: Igor Mammedov <imammedo@redhat.com>
pc: piix: make PCII440FXState type public

Signed-off-by: Igor Mammedov <imammedo@redhat.com>
pc: piix: add memory hotplug to 440fx machine

Add 2 DimmBus-es, one for memory hotplug below 4Gb and
second above 4Gb.

* if ram_size is less tha 32-bit PCI hole start, reserve
  hotplug memory region as [ram_size,32bit-PCIhole-start)
  and for the rest of hotplug memory reserve hotplug
  memory region above "0x100000000ULL + above_4g_mem_size"

* setup memory hotplug callback to use PIIX4_PM as hotplug
  notification device

Signed-off-by: Igor Mammedov <imammedo@redhat.com>