sdk/emulator/qemu.git
10 years agoqmp: clean out whitespace
Michael S. Tsirkin [Mon, 16 Jun 2014 12:20:18 +0000 (15:20 +0300)]
qmp: clean out whitespace

Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
10 years agoqdev: recursively unrealize devices when unrealizing bus
Paolo Bonzini [Wed, 11 Jun 2014 12:52:09 +0000 (14:52 +0200)]
qdev: recursively unrealize devices when unrealizing bus

When the patch was posted that became 5c21ce7 (qdev: Realize buses
on device realization, 2014-03-12), it included recursive realization
and unrealization of devices when the bus's "realized" property
was toggled.

However, due to the same old worries about recursive realization
and prerequisites not being realized yet, those hunks were dropped when
committing the patch.  Unfortunately, this causes a use-after-free bug
(easily reproduced by a PCI hot-unplug action).

Before the patch, device_unparent behaved as follows:

   for each child bus
     unparent bus ----------------------------.
     | for each child device                  |
     |   unparent device ---------------.     |
     |   | unrealize device             |     |
     |   | call dc->unparent            |     |
     |   '-------------------------------     |
     '----------------------------------------'
   unrealize device

After the patch, it behaves as follows instead:

   unrealize device --------------------.
   | for each child bus                 |
   |   unrealize bus               (A)  |
   '------------------------------------'
   for each child bus
     unparent bus ----------------------.
     | for each child device            |
     |   unrealize device          (B)  |
     |   call dc->unparent              |
     '----------------------------------'

At the step marked (B) the device might use data from the bus that is
not available anymore due to step (A).

To fix this, we need to unrealize devices before step (A).  To sidestep
concerns about recursive realization, only do recursive unrealization
and leave the "value && !bus->realized" case as it is.

The resulting flow is:

   for each child bus
     unrealize bus ---------------------.
     | for each child device            |
     |   unrealize device          (B)  |
     | call bc->unrealize          (A)  |
     '----------------------------------'
   unrealize device
   for each child bus
     unparent bus ----------------------.
     | for each child device            |
     |   unparent device                |
     '----------------------------------'

where everything is "powered down" before it is unassembled.

Cc: qemu-stable@nongnu.org
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Tested-by: Michael S. Tsirkin <mst@redhat.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Reviewed-by: Andreas Färber <afaerber@suse.de>
10 years agoqdev: reorganize error reporting in bus_set_realized
Paolo Bonzini [Wed, 11 Jun 2014 12:52:08 +0000 (14:52 +0200)]
qdev: reorganize error reporting in bus_set_realized

No semantic change.

Cc: qemu-stable@nongnu.org
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Tested-by: Michael S. Tsirkin <mst@redhat.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Reviewed-by: Andreas Färber <afaerber@suse.de>
10 years agoqapi: fix build on glib < 2.28
Michael S. Tsirkin [Mon, 16 Jun 2014 15:07:03 +0000 (18:07 +0300)]
qapi: fix build on glib < 2.28

The following commits:
    qapi: make string output visitor parse int list
    qapi: make string input visitor parse int list
break with glib < 2.28 since they use the
new g_list_free_full function.

Open-code that to fix build on old systems.

Cc: Hu Tao <hutao@cn.fujitsu.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
10 years agoqapi: make string output visitor parse int list
Hu Tao [Tue, 10 Jun 2014 11:15:28 +0000 (19:15 +0800)]
qapi: make string output visitor parse int list

Signed-off-by: Hu Tao <hutao@cn.fujitsu.com>
Acked-by: Michael S. Tsirkin <mst@redhat.com>
Tested-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
MST: split up patch

10 years agoqapi: make string input visitor parse int list
Hu Tao [Tue, 10 Jun 2014 11:15:27 +0000 (19:15 +0800)]
qapi: make string input visitor parse int list

Signed-off-by: Hu Tao <hutao@cn.fujitsu.com>
Acked-by: Michael S. Tsirkin <mst@redhat.com>
Tested-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
MST: split up patch

10 years agotests: fix memory leak in test of string input visitor
Hu Tao [Tue, 10 Jun 2014 11:15:26 +0000 (19:15 +0800)]
tests: fix memory leak in test of string input visitor

Signed-off-by: Hu Tao <hutao@cn.fujitsu.com>
Acked-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
10 years agohmp: add info memdev
Hu Tao [Wed, 14 May 2014 09:43:35 +0000 (17:43 +0800)]
hmp: add info memdev

This is the hmp counterpart of qmp query-memdev.

Signed-off-by: Hu Tao <hutao@cn.fujitsu.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Acked-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
MST: fix build on 32 bit

10 years agoqmp: add query-memdev
Hu Tao [Mon, 16 Jun 2014 10:05:41 +0000 (18:05 +0800)]
qmp: add query-memdev

Add qmp command query-memdev to query for information
of memory devices

Signed-off-by: Hu Tao <hutao@cn.fujitsu.com>
Acked-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
10 years agohostmem: add properties for NUMA memory policy
Hu Tao [Tue, 10 Jun 2014 11:15:25 +0000 (19:15 +0800)]
hostmem: add properties for NUMA memory policy

Signed-off-by: Hu Tao <hutao@cn.fujitsu.com>
[Raise errors on setting properties if !CONFIG_NUMA.  Add BUILD_BUG_ON
 checks. - Paolo]
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
Signed-off-by: Hu Tao <hutao@cn.fujitsu.com>
Acked-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
10 years agohostmem: add property to map memory with MAP_SHARED
Paolo Bonzini [Tue, 10 Jun 2014 11:15:24 +0000 (19:15 +0800)]
hostmem: add property to map memory with MAP_SHARED

A new "share" property can be used with the "memory-file" backend to
map memory with MAP_SHARED instead of MAP_PRIVATE.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Hu Tao <hutao@cn.fujitsu.com>
Acked-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
10 years agohostmem: allow preallocation of any memory region
Paolo Bonzini [Tue, 10 Jun 2014 11:15:23 +0000 (19:15 +0800)]
hostmem: allow preallocation of any memory region

And allow preallocation of file-based memory even without -mem-prealloc.
Some care is necessary because -mem-prealloc does not allow disabling
preallocation for hostmem-file.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Hu Tao <hutao@cn.fujitsu.com>
Acked-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
10 years agohostmem: add merge and dump properties
Paolo Bonzini [Tue, 10 Jun 2014 11:15:22 +0000 (19:15 +0800)]
hostmem: add merge and dump properties

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Hu Tao <hutao@cn.fujitsu.com>
Acked-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
10 years agoosdep: add merge and dump flags
Michael S. Tsirkin [Wed, 18 Jun 2014 18:48:19 +0000 (21:48 +0300)]
osdep: add merge and dump flags

will be used by follow up patch

Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
10 years agohostmem: add file-based HostMemoryBackend
Paolo Bonzini [Tue, 10 Jun 2014 11:15:21 +0000 (19:15 +0800)]
hostmem: add file-based HostMemoryBackend

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Hu Tao <hutao@cn.fujitsu.com>
Acked-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
MST: comment tweak

10 years agohostmem: separate allocation from UserCreatable complete method
Hu Tao [Tue, 10 Jun 2014 11:15:19 +0000 (19:15 +0800)]
hostmem: separate allocation from UserCreatable complete method

This allows the superclass to set various policies on the memory
region that the subclass creates. Drops hostmem-ram's complete method
accordingly.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Hu Tao <hutao@cn.fujitsu.com>
Acked-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
10 years agobackend:hostmem: replace hostmemory with host_memory
Hu Tao [Tue, 10 Jun 2014 11:15:18 +0000 (19:15 +0800)]
backend:hostmem: replace hostmemory with host_memory

..to keep names consistant.

Signed-off-by: Hu Tao <hutao@cn.fujitsu.com>
Acked-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
10 years agopc: pass MachineState to pc_memory_init
Paolo Bonzini [Tue, 10 Jun 2014 11:15:17 +0000 (19:15 +0800)]
pc: pass MachineState to pc_memory_init

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Hu Tao <hutao@cn.fujitsu.com>
Reviewed-By: Igor Mammedov <imammedo@redhat.com>
Acked-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
10 years agovl: redo -object parsing
Paolo Bonzini [Tue, 10 Jun 2014 11:15:15 +0000 (19:15 +0800)]
vl: redo -object parsing

Follow the lines of the HMP implementation, using OptsVisitor
to parse the options.  This gives access to OptsVisitor's
rich parsing of integer lists.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Hu Tao <hutao@cn.fujitsu.com>
Acked-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
10 years agomemory: add error propagation to file-based RAM allocation
Paolo Bonzini [Wed, 14 May 2014 09:43:20 +0000 (17:43 +0800)]
memory: add error propagation to file-based RAM allocation

Right now, -mem-path will fall back to RAM-based allocation in some
cases.  This should never happen with "-object memory-file", prepare
the code by adding correct error propagation.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Hu Tao <hutao@cn.fujitsu.com>
Acked-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
MST: drop \n at end of error messages

10 years agomemory: move mem_path handling to memory_region_allocate_system_memory
Paolo Bonzini [Wed, 14 May 2014 09:43:19 +0000 (17:43 +0800)]
memory: move mem_path handling to memory_region_allocate_system_memory

Like the previous patch did in exec.c, split memory_region_init_ram and
memory_region_init_ram_from_file, and push mem_path one step further up.
Other RAM regions than system memory will now be backed by regular RAM.

Also, boards that do not use memory_region_allocate_system_memory will
not support -mem-path anymore.  This can be changed before the patches
are merged by migrating boards to use the function.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Hu Tao <hutao@cn.fujitsu.com>
Acked-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
10 years agonuma: add -numa node,memdev= option
Paolo Bonzini [Wed, 14 May 2014 09:43:17 +0000 (17:43 +0800)]
numa: add -numa node,memdev= option

This option provides the infrastructure for binding guest NUMA nodes
to host NUMA nodes.  For example:

 -object memory-ram,size=1024M,policy=bind,host-nodes=0,id=ram-node0 \
 -numa node,nodeid=0,cpus=0,memdev=ram-node0 \
 -object memory-ram,size=1024M,policy=interleave,host-nodes=1-3,id=ram-node1 \
 -numa node,nodeid=1,cpus=1,memdev=ram-node1

The option replaces "-numa node,mem=".

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Hu Tao <hutao@cn.fujitsu.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Acked-by: Michael S. Tsirkin <mst@redhat.com>
MST: conflict resolution

10 years agoqom: introduce object_property_get_enum and object_property_get_uint16List
Hu Tao [Wed, 14 May 2014 09:43:33 +0000 (17:43 +0800)]
qom: introduce object_property_get_enum and object_property_get_uint16List

Signed-off-by: Hu Tao <hutao@cn.fujitsu.com>
Acked-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
10 years agoIntroduce signed range.
Hu Tao [Wed, 14 May 2014 09:43:30 +0000 (17:43 +0800)]
Introduce signed range.

Signed-off-by: Hu Tao <hutao@cn.fujitsu.com>
Acked-by: Michael S. Tsirkin <mst@redhat.com>
Tested-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
MST: split up patch

10 years agoconfigure: add Linux libnuma detection
Wanlong Gao [Wed, 14 May 2014 09:43:28 +0000 (17:43 +0800)]
configure: add Linux libnuma detection

Add detection of libnuma (mostly contained in the numactl package)
to the configure script. Can be enabled or disabled on the command
line, default is use if available.

Signed-off-by: Andre Przywara <andre.przywara@amd.com>
Signed-off-by: Wanlong Gao <gaowanlong@cn.fujitsu.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Hu Tao <hutao@cn.fujitsu.com>
Acked-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
10 years agomemory: move RAM_PREALLOC_MASK to exec.c, rename
Paolo Bonzini [Wed, 14 May 2014 09:43:22 +0000 (17:43 +0800)]
memory: move RAM_PREALLOC_MASK to exec.c, rename

Prepare for adding more flags.  The "_MASK" suffix is unique, kill it.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Hu Tao <hutao@cn.fujitsu.com>
Acked-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
10 years agomemory: move preallocation code out of exec.c
Paolo Bonzini [Wed, 14 May 2014 09:43:21 +0000 (17:43 +0800)]
memory: move preallocation code out of exec.c

So that backends can use it.

Since we need the page size for efficiency, move code to compute it
out of translate-all.c and into util/oslib-win32.c.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Hu Tao <hutao@cn.fujitsu.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
10 years agomemory: reorganize file-based allocation
Paolo Bonzini [Wed, 14 May 2014 09:43:18 +0000 (17:43 +0800)]
memory: reorganize file-based allocation

Split the internal interface in exec.c to a separate function, and
push the check on mem_path up to memory_region_init_ram.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Hu Tao <hutao@cn.fujitsu.com>
Acked-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
10 years agonuma: introduce memory_region_allocate_system_memory
Paolo Bonzini [Wed, 14 May 2014 09:43:15 +0000 (17:43 +0800)]
numa: introduce memory_region_allocate_system_memory

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Hu Tao <hutao@cn.fujitsu.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Acked-by: Michael S. Tsirkin <mst@redhat.com>
Reviewed-by: Eduardo Habkost <ehabkost@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
MST: resolve conflicts

10 years agoqmp: improve error reporting for -object and object-add
Paolo Bonzini [Wed, 14 May 2014 09:43:13 +0000 (17:43 +0800)]
qmp: improve error reporting for -object and object-add

Use QERR_INVALID_PARAMETER_VALUE for consistency.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Hu Tao <hutao@cn.fujitsu.com>
Acked-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
10 years agoman: improve -numa doc
Luiz Capitulino [Wed, 14 May 2014 09:43:10 +0000 (17:43 +0800)]
man: improve -numa doc

The -numa option documentation in qemu's manpage lacks the command-line
options and some information regarding how it relates to options -m and
-smp. This commit fills in the missing text.

Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Hu Tao <hutao@cn.fujitsu.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Reviewed-by: Eduardo Habkost <ehabkost@redhat.com>
Acked-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
10 years agoNUMA: expand MAX_NODES from 64 to 128
Wanlong Gao [Wed, 14 May 2014 09:43:09 +0000 (17:43 +0800)]
NUMA: expand MAX_NODES from 64 to 128

libnuma choosed 128 for MAX_NODES, so we follow libnuma here.

Signed-off-by: Wanlong Gao <gaowanlong@cn.fujitsu.com>
Reviewed-by: Eduardo Habkost <ehabkost@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Hu Tao <hutao@cn.fujitsu.com>
Acked-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
10 years agoNUMA: convert -numa option to use OptsVisitor
Wanlong Gao [Wed, 14 May 2014 09:43:08 +0000 (17:43 +0800)]
NUMA: convert -numa option to use OptsVisitor

Signed-off-by: Wanlong Gao <gaowanlong@cn.fujitsu.com>
Signed-off-by: Igor Mammedov <imammedo@redhat.com>
Tested-by: Eduardo Habkost <ehabkost@redhat.com>
Reviewed-by: Eduardo Habkost <ehabkost@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Hu Tao <hutao@cn.fujitsu.com>
Acked-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
10 years agoNUMA: Add numa_info structure to contain numa nodes info
Wanlong Gao [Wed, 14 May 2014 09:43:07 +0000 (17:43 +0800)]
NUMA: Add numa_info structure to contain numa nodes info

Add the numa_info structure to contain the numa nodes memory,
VCPUs information and the future added numa nodes host memory
policies.

Reviewed-by: Eduardo Habkost <ehabkost@redhat.com>
Signed-off-by: Andre Przywara <andre.przywara@amd.com>
Signed-off-by: Wanlong Gao <gaowanlong@cn.fujitsu.com>
[Fix hw/ppc/spapr.c - Paolo]
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Hu Tao <hutao@cn.fujitsu.com>
Acked-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
10 years agoNUMA: check if the total numa memory size is equal to ram_size
Wanlong Gao [Wed, 14 May 2014 09:43:06 +0000 (17:43 +0800)]
NUMA: check if the total numa memory size is equal to ram_size

If the total number of the assigned numa nodes memory is not
equal to the assigned ram size, it will write the wrong data
to ACPI table, then the guest will ignore the wrong ACPI table
and recognize all memory to one node. It's buggy, we should
check it to ensure that we write the right data to ACPI table.

Signed-off-by: Wanlong Gao <gaowanlong@cn.fujitsu.com>
Reviewed-by: Eduardo Habkost <ehabkost@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Hu Tao <hutao@cn.fujitsu.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Acked-by: Michael S. Tsirkin <mst@redhat.com>
MST: error message reworded

10 years agoNUMA: move numa related code to new file numa.c
Wanlong Gao [Wed, 14 May 2014 09:43:05 +0000 (17:43 +0800)]
NUMA: move numa related code to new file numa.c

Signed-off-by: Wanlong Gao <gaowanlong@cn.fujitsu.com>
Reviewed-by: Eduardo Habkost <ehabkost@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Hu Tao <hutao@cn.fujitsu.com>
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
Signed-off-by: Andre Przywara <andre.przywara@amd.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Acked-by: Michael S. Tsirkin <mst@redhat.com>
MST: comment tweaks

10 years agotests: disable vhost test temporarily
Michael S. Tsirkin [Wed, 18 Jun 2014 09:23:36 +0000 (12:23 +0300)]
tests: disable vhost test temporarily

This test needs a bit more work: issues have been
found on legacy systems, disable it for now to
avoid false positives for people.
Will re-enable after issues are addressed.

Reported-by: Igor Mammedov <imammedo@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
10 years agoAdd qtest for vhost-user
Nikolay Nikolaev [Tue, 10 Jun 2014 10:03:23 +0000 (13:03 +0300)]
Add qtest for vhost-user

This test creates a 'server' chardev to listen for vhost-user messages.
Once VHOST_USER_SET_MEM_TABLE is received it mmaps each received region,
and read 1k bytes from it. The read data is compared to data from readl.

The test requires hugetlbfs to be already mounted and writable. The mount
point defaults to '/hugetlbfs' and can be specified via the environment
variable QTEST_HUGETLBFS_PATH.

The rom pc-bios/pxe-virtio.rom is used to instantiate a virtio pcicontroller.

Signed-off-by: Antonios Motakis <a.motakis@virtualopensystems.com>
Signed-off-by: Nikolay Nikolaev <n.nikolaev@virtualopensystems.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
MST: fix up coding style
MST: disable vhost test temporarily

This test needs a bit more work: issues have been
found on legacy systems, disable it for now to
avoid false positives for people.
Will re-enable after issues are addressed.

Reported-by: Igor Mammedov <imammedo@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
10 years agolibqemustub: add stubs to be able to use qemu-char.c
Nikolay Nikolaev [Tue, 27 May 2014 12:07:10 +0000 (15:07 +0300)]
libqemustub: add stubs to be able to use qemu-char.c

chardev depends on lots of external symbols that are not necessarily
needed to be able to use, for example, 'socket chardev'. So add stubs
for these functions:

 - bdrv_commit_all
 - qemu_chr_open_msmouse
 - is_daemonized
 - qemu_add_machine_init_done_notifier
 - monitor_init
 - qemu_notify_event
 - vc_init

and this array:

 - serial_hds

Signed-off-by: Antonios Motakis <a.motakis@virtualopensystems.com>
Signed-off-by: Nikolay Nikolaev <n.nikolaev@virtualopensystems.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
10 years agoAdd vhost-user protocol documentation
Nikolay Nikolaev [Tue, 10 Jun 2014 10:02:57 +0000 (13:02 +0300)]
Add vhost-user protocol documentation

This document describes the basic message format used by vhost-user
for communication over a unix domain socket. The protocol is based
on the existing ioctl interface used for the kernel version of vhost.

Signed-off-by: Antonios Motakis <a.motakis@virtualopensystems.com>
Signed-off-by: Nikolay Nikolaev <n.nikolaev@virtualopensystems.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
10 years agoAdd the vhost-user netdev backend to the command line
Nikolay Nikolaev [Tue, 10 Jun 2014 10:02:16 +0000 (13:02 +0300)]
Add the vhost-user netdev backend to the command line

The supplied chardev id will be inspected for supported options. Only
a socket backend, with a set path (i.e. a Unix socket) and optionally
the server parameter set, will be allowed. Other options (nowait, telnet)
will make the chardev unusable and the netdev will not be initialised.

Additional checks for validity:
  - requires `-numa node,memdev=..`
  - requires `-device virtio-net-*`

The `vhostforce` option is used to force vhost-net when we deal with
non-MSIX guests.

Signed-off-by: Antonios Motakis <a.motakis@virtualopensystems.com>
Signed-off-by: Nikolay Nikolaev <n.nikolaev@virtualopensystems.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Acked-by: Luiz Capitulino <lcapitulino@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
10 years agoAdd new vhost-user netdev backend
Nikolay Nikolaev [Tue, 27 May 2014 12:06:29 +0000 (15:06 +0300)]
Add new vhost-user netdev backend

Add a new QEMU netdev backend that is intended to invoke vhost_net with the
vhost-user backend. It uses an Unix socket chardev to establish a
communication with the 'slave' (client and server mode supported).

At runtime the netdev will handle OPEN/CLOSE events from the chardev. Upon
disconnection it will set link_down accordingly and notify virtio-net; the
virtio-net interface will go down.

Signed-off-by: Antonios Motakis <a.motakis@virtualopensystems.com>
Signed-off-by: Nikolay Nikolaev <n.nikolaev@virtualopensystems.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
10 years agovhost-net: vhost-user feature bits support
Nikolay Nikolaev [Tue, 27 May 2014 12:06:16 +0000 (15:06 +0300)]
vhost-net: vhost-user feature bits support

Handle the feature bits negotiation when using vhost-user. Allow
the underlying implementation to have a finer control over all the
bits except the VIRTIO_NET_F_MAC.

Signed-off-by: Nikolay Nikolaev <n.nikolaev@virtualopensystems.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
10 years agoAdd vhost-user as a vhost backend.
Nikolay Nikolaev [Tue, 27 May 2014 12:06:02 +0000 (15:06 +0300)]
Add vhost-user as a vhost backend.

The initialization takes a chardev backed by a unix domain socket.
It should implement qemu_fe_set_msgfds in order to be able to pass
file descriptors to the remote process.

Each ioctl request of vhost-kernel has a vhost-user message equivalent,
which is sent over the control socket.

The general approach is to copy the data from the supplied argument
pointer to a designated field in the message. If a file descriptor is
to be passed it will be placed in the fds array for inclusion in
the sendmsg control header.

VHOST_SET_MEM_TABLE ignores the supplied vhost_memory structure and scans
the global ram_list for ram blocks with a valid fd field set. This would
be set when the '-object memory-file' option with share=on property is used.

Signed-off-by: Antonios Motakis <a.motakis@virtualopensystems.com>
Signed-off-by: Nikolay Nikolaev <n.nikolaev@virtualopensystems.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
10 years agoAdd vhost-backend and VhostBackendType
Nikolay Nikolaev [Tue, 27 May 2014 12:05:49 +0000 (15:05 +0300)]
Add vhost-backend and VhostBackendType

Use vhost_set_backend_type to initialise a proper vhost_ops structure.
In vhost_net_init and vhost_net_start_one call conditionally TAP related
initialisation depending on the vhost backend type.

Signed-off-by: Antonios Motakis <a.motakis@virtualopensystems.com>
Signed-off-by: Nikolay Nikolaev <n.nikolaev@virtualopensystems.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
10 years agoAdd vhost_ops to vhost_dev struct and replace all relevant ioctls
Nikolay Nikolaev [Tue, 27 May 2014 12:05:35 +0000 (15:05 +0300)]
Add vhost_ops to vhost_dev struct and replace all relevant ioctls

Decouple vhost from the Linux kernel by introducing vhost_ops. The
intention is to provide different backends - a 'kernel' backend based on
the ioctl interface, and an 'user' backend based on a UNIX domain socket
and shared memory interface.

Signed-off-by: Antonios Motakis <a.motakis@virtualopensystems.com>
Signed-off-by: Nikolay Nikolaev <n.nikolaev@virtualopensystems.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
10 years agovhost_net_init will use VhostNetOptions to get all its arguments
Nikolay Nikolaev [Tue, 27 May 2014 12:05:22 +0000 (15:05 +0300)]
vhost_net_init will use VhostNetOptions to get all its arguments

vhost_dev_init will replace devfd and devpath with a single opaque argument.
This is initialised with a file descriptor. When TAP is used (through
vhost_net), open /dev/vhost-net and pass the fd as an opaque parameter in
VhostNetOptions. The same applies to vhost-scsi - open /dev/vhost-scsi and
pass the fd.

Signed-off-by: Antonios Motakis <a.motakis@virtualopensystems.com>
Signed-off-by: Nikolay Nikolaev <n.nikolaev@virtualopensystems.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
10 years agoRefactor virtio-net to use generic get_vhost_net
Nikolay Nikolaev [Tue, 27 May 2014 12:05:08 +0000 (15:05 +0300)]
Refactor virtio-net to use generic get_vhost_net

This decouples virtio-net from the TAP netdev backend and allows support
for other backends to be implemented.

Signed-off-by: Antonios Motakis <a.motakis@virtualopensystems.com>
Signed-off-by: Nikolay Nikolaev <n.nikolaev@virtualopensystems.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
10 years agovhost_net should call the poll callback only when it is set
Nikolay Nikolaev [Tue, 27 May 2014 12:04:55 +0000 (15:04 +0300)]
vhost_net should call the poll callback only when it is set

The poll callback needs to be called when bringing up or down
the vhost_net instance. As it is not mandatory for an NetClient
to implement it, invoke it only when it is set.

Signed-off-by: Antonios Motakis <a.motakis@virtualopensystems.com>
Signed-off-by: Nikolay Nikolaev <n.nikolaev@virtualopensystems.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
10 years agovhost: add vhost_get_features and vhost_ack_features
Nikolay Nikolaev [Tue, 27 May 2014 12:04:42 +0000 (15:04 +0300)]
vhost: add vhost_get_features and vhost_ack_features

Generalize the features get/ack to be used for both vhost-net and vhost-scsi.
In vhost-net add vhost_net_get_feature_bits to select the feature bit set
depending on the NetClient kind.

Signed-off-by: Nikolay Nikolaev <n.nikolaev@virtualopensystems.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
10 years agoAdd G_IO_HUP handler for socket chardev
Nikolay Nikolaev [Tue, 27 May 2014 12:04:28 +0000 (15:04 +0300)]
Add G_IO_HUP handler for socket chardev

This is used to detect that the remote end has disconnected. Just call
tcp_char_disconnect on receiving this event.

Signed-off-by: Antonios Motakis <a.motakis@virtualopensystems.com>
Signed-off-by: Nikolay Nikolaev <n.nikolaev@virtualopensystems.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
10 years agoAdd chardev API qemu_chr_fe_get_msgfds
Nikolay Nikolaev [Tue, 27 May 2014 12:04:15 +0000 (15:04 +0300)]
Add chardev API qemu_chr_fe_get_msgfds

This extends the existing qemu_chr_fe_get_msgfd by allowing to read a set
of fds. The function for receiving the fds - unix_process_msgfd is extended
to allocate the needed array size.

Signed-off-by: Antonios Motakis <a.motakis@virtualopensystems.com>
Signed-off-by: Nikolay Nikolaev <n.nikolaev@virtualopensystems.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
10 years agoAdd chardev API qemu_chr_fe_set_msgfds
Nikolay Nikolaev [Tue, 27 May 2014 12:04:02 +0000 (15:04 +0300)]
Add chardev API qemu_chr_fe_set_msgfds

This will set an array of file descriptors to the internal structures.
The next time a message is send the array will be send as ancillary
data. This feature works on the UNIX domain socket backend only.

Signed-off-by: Antonios Motakis <a.motakis@virtualopensystems.com>
Signed-off-by: Nikolay Nikolaev <n.nikolaev@virtualopensystems.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
10 years agoAdd chardev API qemu_chr_fe_read_all
Nikolay Nikolaev [Tue, 27 May 2014 12:03:48 +0000 (15:03 +0300)]
Add chardev API qemu_chr_fe_read_all

This function will attempt to read data from the chardev trying
to fill the buffer up to the given length.
Add tcp_chr_disconnect to reuse disconnection code where needed.

Signed-off-by: Antonios Motakis <a.motakis@virtualopensystems.com>
Signed-off-by: Nikolay Nikolaev <n.nikolaev@virtualopensystems.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
10 years agoAdd kvm_eventfds_enabled function
Nikolay Nikolaev [Tue, 27 May 2014 12:03:35 +0000 (15:03 +0300)]
Add kvm_eventfds_enabled function

Add a function to check if the eventfd capability is present in KVM in
the host kernel.

Signed-off-by: Antonios Motakis <a.motakis@virtualopensystems.com>
Signed-off-by: Nikolay Nikolaev <n.nikolaev@virtualopensystems.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Acked-by: Paolo Bonzini <pbonzini@redhat.com>
10 years agovirtio-net: announce self by guest
Jason Wang [Tue, 20 May 2014 06:01:44 +0000 (14:01 +0800)]
virtio-net: announce self by guest

It's hard to track all mac addresses and their configurations (e.g
vlan or ipv6) in qemu. Without this information, it's impossible to
build proper garp packet after migration. The only possible solution
to this is let guest (who knows all configurations) to do this.

So, this patch introduces a new readonly config status bit of virtio-net,
VIRTIO_NET_S_ANNOUNCE which is used to notify guest to announce
presence of its link through config update interrupt.When guest has
done the announcement, it should ack the notification through
VIRTIO_NET_CTRL_ANNOUNCE_ACK cmd. This feature is negotiated by a new
feature bit VIRTIO_NET_F_ANNOUNCE (which has already been supported by
Linux guest).

During load, a counter of announcing rounds is set so that after the vm is
running it can trigger rounds of config interrupts to notify the guest to build
and send the correct garps.

Cc: Liuyongan <liuyongan@huawei.com>
Cc: Amos Kong <akong@redhat.com>
Signed-off-by: Jason Wang <jasowang@redhat.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
10 years agomigration: introduce self_announce_delay()
Jason Wang [Tue, 20 May 2014 06:01:43 +0000 (14:01 +0800)]
migration: introduce self_announce_delay()

This patch introduces self_announce_delay() to calculate the delay for
the next announce round. This could be used by other device e.g
virtio-net who wants to do announcing by itself.

Signed-off-by: Jason Wang <jasowang@redhat.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
10 years agomigration: export SELF_ANNOUNCE_ROUNDS
Jason Wang [Tue, 20 May 2014 06:01:42 +0000 (14:01 +0800)]
migration: export SELF_ANNOUNCE_ROUNDS

Export it for other users.

Signed-off-by: Jason Wang <jasowang@redhat.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
10 years agopc: q35: acpi: report error to user on unsupported unplug request
Igor Mammedov [Mon, 9 Jun 2014 17:28:00 +0000 (19:28 +0200)]
pc: q35: acpi: report error to user on unsupported unplug request

Signed-off-by: Igor Mammedov <imammedo@redhat.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
10 years agoich: get rid of spaces in type name
Michael S. Tsirkin [Sun, 8 Jun 2014 15:45:25 +0000 (18:45 +0300)]
ich: get rid of spaces in type name

Names with spaces in them are nasty, let's not go there.

Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
10 years agovirtio: Drop superfluous conditionals around g_strdup()
Markus Armbruster [Fri, 6 Jun 2014 16:43:30 +0000 (18:43 +0200)]
virtio: Drop superfluous conditionals around g_strdup()

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
10 years agovirtio: Drop superfluous conditionals around g_free()
Markus Armbruster [Fri, 6 Jun 2014 16:43:29 +0000 (18:43 +0200)]
virtio: Drop superfluous conditionals around g_free()

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
10 years agoacpi-test: update expected tables
Michael S. Tsirkin [Sun, 8 Jun 2014 12:59:58 +0000 (15:59 +0300)]
acpi-test: update expected tables

Update ACPI tables test to match new ACPI tables
after adding the memory hotplug feature.

Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
10 years agoacpi: update generated files
Michael S. Tsirkin [Sun, 8 Jun 2014 12:58:59 +0000 (15:58 +0300)]
acpi: update generated files

pdate precompiled ACPI hex files for iasl-less hosts
after adding the memory hotplug feature

Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
10 years agopc: ACPI BIOS: make GPE.3 handle memory hotplug event on PIIX and Q35 machines
Igor Mammedov [Mon, 2 Jun 2014 13:25:29 +0000 (15:25 +0200)]
pc: ACPI BIOS: make GPE.3 handle memory hotplug event on PIIX and Q35 machines

also make handler edge based to avoid losing events, the same as
it has been done for PCI and CPU hotplug handlers.

Signed-off-by: Igor Mammedov <imammedo@redhat.com>
Acked-by: Peter Crosthwaite <peter.crosthwaite@xilinx.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
10 years agopc: ACPI BIOS: reserve SRAT entry for hotplug mem hole
Igor Mammedov [Mon, 2 Jun 2014 13:25:28 +0000 (15:25 +0200)]
pc: ACPI BIOS: reserve SRAT entry for hotplug mem hole

Needed for Windows to use hotplugged memory device, otherwise
it complains that server is not configured for memory hotplug.
Tests shows that aftewards it uses dynamically provided
proximity value from _PXM() method if available.

Signed-off-by: Igor Mammedov <imammedo@redhat.com>
Acked-by: Peter Crosthwaite <peter.crosthwaite@xilinx.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
10 years agopc: add "hotplug-memory-region-size" property to PC_MACHINE
Igor Mammedov [Mon, 2 Jun 2014 13:25:27 +0000 (15:25 +0200)]
pc: add "hotplug-memory-region-size" property to PC_MACHINE

... it will be used by acpi-build code and by unit tests

Signed-off-by: Igor Mammedov <imammedo@redhat.com>
Acked-by: Peter Crosthwaite <peter.crosthwaite@xilinx.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
10 years agopc: ACPI BIOS: implement memory hotplug interface
Igor Mammedov [Mon, 2 Jun 2014 13:25:26 +0000 (15:25 +0200)]
pc: ACPI BIOS: implement memory hotplug interface

- provides static SSDT object for memory hotplug that can handle
  upto 256 hotplugable memory slots
- 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>
Acked-by: Peter Crosthwaite <peter.crosthwaite@xilinx.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
10 years agopc: propagate memory hotplug event to ACPI device
Igor Mammedov [Mon, 2 Jun 2014 13:25:25 +0000 (15:25 +0200)]
pc: propagate memory hotplug event to ACPI device

Notify PIIX4_PM/ICH9LPC device about hotplug event,
so that it would send SCI to guest notifying about
newly added memory.

Signed-off-by: Igor Mammedov <imammedo@redhat.com>
Acked-by: Peter Crosthwaite <peter.crosthwaite@xilinx.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
10 years agopc: add acpi-device link to PCMachineState
Igor Mammedov [Mon, 2 Jun 2014 13:25:24 +0000 (15:25 +0200)]
pc: add acpi-device link to PCMachineState

the link will used later to access device implementing
ACPI functions instead of adhoc lookup in QOM tree.

Signed-off-by: Igor Mammedov <imammedo@redhat.com>
Acked-by: Peter Crosthwaite <peter.crosthwaite@xilinx.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
10 years agopc: migrate piix4 & ich9 MemHotplugState
Igor Mammedov [Mon, 2 Jun 2014 13:25:23 +0000 (15:25 +0200)]
pc: migrate piix4 & ich9 MemHotplugState

Adds an optional subsection that allows to migrate current
state of acpi_memory_hotplug of ACPI PM device.

Signed-off-by: Igor Mammedov <imammedo@redhat.com>
Acked-by: Peter Crosthwaite <peter.crosthwaite@xilinx.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
10 years agoacpi:ich9: add memory hotplug handling
Igor Mammedov [Mon, 2 Jun 2014 13:25:22 +0000 (15:25 +0200)]
acpi:ich9: add memory hotplug handling

Add memory hotplug initialization/handling to ICH9 LPC device
and enable it by default for post 2.0 machine types

Signed-off-by: Igor Mammedov <imammedo@redhat.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
10 years agopc: ich9 lpc: make it work with global/compat properties
Igor Mammedov [Mon, 2 Jun 2014 13:25:21 +0000 (15:25 +0200)]
pc: ich9 lpc: make it work with global/compat properties

Propeties of object should be available after its instances_init()
callback is finished and not added in PCIDeviceClass.init which is
roughly corresponds to realize() method.
Moving properties adding into instances_init will fix missing
property error when global/compat property mechanism is used.

Signed-off-by: Igor Mammedov <imammedo@redhat.com>
Acked-by: Peter Crosthwaite <peter.crosthwaite@xilinx.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
10 years agoacpi:piix4: add memory hotplug handling
Igor Mammedov [Mon, 2 Jun 2014 13:25:20 +0000 (15:25 +0200)]
acpi:piix4: add memory hotplug handling

Add memory hotplug initialization/handling to PIIX4_PM device
and enable it by default for post 2.0 machine types

Signed-off-by: Igor Mammedov <imammedo@redhat.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
MST: resolve conflict in pc.h

10 years agoacpi:piix4: allow plug/unlug callbacks handle not only PCI devices
Igor Mammedov [Mon, 2 Jun 2014 13:25:19 +0000 (15:25 +0200)]
acpi:piix4: allow plug/unlug callbacks handle not only PCI devices

... and report error if plugged in device is not supported.
Later these callbacks will be used by memory hotplug.

Signed-off-by: Igor Mammedov <imammedo@redhat.com>
Acked-by: Peter Crosthwaite <peter.crosthwaite@xilinx.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
10 years agotrace: pc: add PC_DIMM slot & address allocation
Igor Mammedov [Mon, 2 Jun 2014 13:25:18 +0000 (15:25 +0200)]
trace: pc: add PC_DIMM slot & address allocation

Add mhp_pc_dimm_assigned_slot & mhp_pc_dimm_assigned_address
events to trace which address and slot where assigned to
plugged in PC_DIMM device on target-i386 machine.

Signed-off-by: Igor Mammedov <imammedo@redhat.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
10 years agotrace: add acpi memory hotplug IO region events
Igor Mammedov [Mon, 2 Jun 2014 13:25:17 +0000 (15:25 +0200)]
trace: add acpi memory hotplug IO region events

Add events for tracing accesses to memory hotplug IO ports.

Signed-off-by: Igor Mammedov <imammedo@redhat.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
10 years agoacpi: memory hotplug ACPI hardware implementation
Igor Mammedov [Mon, 2 Jun 2014 13:25:16 +0000 (15:25 +0200)]
acpi: memory hotplug ACPI hardware implementation

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

Signed-off-by: Igor Mammedov <imammedo@redhat.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
10 years agoacpi: rename cpu_hotplug_defs.h to pc-hotplug.h
Igor Mammedov [Mon, 2 Jun 2014 13:25:15 +0000 (15:25 +0200)]
acpi: rename cpu_hotplug_defs.h to pc-hotplug.h

to make it more generic, so it could be used for memory hotplug
as well.

Signed-off-by: Igor Mammedov <imammedo@redhat.com>
Acked-by: Peter Crosthwaite <peter.crosthwaite@xilinx.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
10 years agopc-dimm: add busy slot check and slot auto-allocation
Igor Mammedov [Mon, 2 Jun 2014 13:25:14 +0000 (15:25 +0200)]
pc-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 PCDIMMDevice 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>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
10 years agopc-dimm: add busy address check and address auto-allocation
Igor Mammedov [Mon, 2 Jun 2014 13:25:13 +0000 (15:25 +0200)]
pc-dimm: add busy address check and address auto-allocation

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

- if 'addr' 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 PCDIMMDevice memory region.

Note:
GCompareFunc(a, b) used by g_slist_insert_sorted() returns 'gint',
however it might be too small to fit difference between
2 addresses. So use 128bit to calculate the difference and normalize
result to -1/0/1 return values.

Signed-off-by: Igor Mammedov <imammedo@redhat.com>
Signed-off-by: Tang Chen <tangchen@cn.fujitsu.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Tested-by: Andrey Korolyov <andrey@xdel.ru>
MST: commit log tweaks

10 years agopc: add memory hotplug handler to PC_MACHINE
Igor Mammedov [Mon, 2 Jun 2014 13:25:12 +0000 (15:25 +0200)]
pc: add memory hotplug handler to PC_MACHINE

that will perform mapping of PC_DIMM device into guest's RAM address space

Signed-off-by: Igor Mammedov <imammedo@redhat.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
10 years agopc: exit QEMU if compat machine doesn't support memory hotlpug
Igor Mammedov [Mon, 2 Jun 2014 13:25:11 +0000 (15:25 +0200)]
pc: exit QEMU if compat machine doesn't support memory hotlpug

... if user attempts to start it with memory hotplug enabled.

Signed-off-by: Igor Mammedov <imammedo@redhat.com>
Acked-by: Peter Crosthwaite <peter.crosthwaite@xilinx.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
10 years agopc: add 'etc/reserved-memory-end' fw_cfg interface for SeaBIOS
Igor Mammedov [Mon, 2 Jun 2014 13:25:10 +0000 (15:25 +0200)]
pc: add 'etc/reserved-memory-end' fw_cfg interface for SeaBIOS

'etc/reserved-memory-end' will allow QEMU to tell BIOS where PCI
BARs mapping could safely start in high memory.

Allowing BIOS to start mapping 64-bit PCI BARs at address where it
wouldn't conflict with other mappings QEMU might place before it.

That permits QEMU to reserve extra address space before
64-bit PCI hole for memory hotplug.

Signed-off-by: Igor Mammedov <imammedo@redhat.com>
Acked-by: Peter Crosthwaite <peter.crosthwaite@xilinx.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
10 years agopc: exit QEMU if number of slots more than supported 256
Igor Mammedov [Mon, 2 Jun 2014 13:25:09 +0000 (15:25 +0200)]
pc: exit QEMU if number of slots more than supported 256

... which is imposed by current naming scheme of ACPI memory devices.

Signed-off-by: Igor Mammedov <imammedo@redhat.com>
Acked-by: Peter Crosthwaite <peter.crosthwaite@xilinx.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
10 years agopc: initialize memory hotplug address space
Igor Mammedov [Mon, 2 Jun 2014 13:25:08 +0000 (15:25 +0200)]
pc: initialize memory hotplug address space

initialize and map hotplug memory address space container
into guest's RAM address space.

Signed-off-by: Igor Mammedov <imammedo@redhat.com>
Acked-by: Peter Crosthwaite <peter.crosthwaite@xilinx.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
10 years agopc-dimm: do not allow setting an in-use memdev
Igor Mammedov [Mon, 2 Jun 2014 13:25:07 +0000 (15:25 +0200)]
pc-dimm: do not allow setting an in-use memdev

using the same memdev backend more than once will cause
assertion at MemoryRegion mapping time because it's already
mapped. Prevent it by checking that the associated MemoryRegion
is not mapped.

Signed-off-by: Igor Mammedov <imammedo@redhat.com>
Acked-by: Peter Crosthwaite <peter.crosthwaite@xilinx.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
MST: tweak commit log

10 years agomemory: add memory_region_is_mapped() API
Igor Mammedov [Mon, 2 Jun 2014 13:25:06 +0000 (15:25 +0200)]
memory: add memory_region_is_mapped() API

which allows to check if MemoryRegion is already mapped.

Signed-off-by: Igor Mammedov <imammedo@redhat.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
10 years agopc: implement pc-dimm device abstraction
Vasilis Liaskovitis [Mon, 2 Jun 2014 13:25:05 +0000 (15:25 +0200)]
pc: implement pc-dimm device abstraction

Each hotplug-able memory slot is a PCDIMMDevice.
A hot-add operation for a memory device:
- creates a new PCDIMMDevice and makes hotplug controller to map it into
  guest address space

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

To simplify review, patch introduces only PCDIMMDevice 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>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
10 years agoqdev: expose DeviceState.hotplugged field as a property
Igor Mammedov [Mon, 2 Jun 2014 13:25:04 +0000 (15:25 +0200)]
qdev: expose DeviceState.hotplugged field as a property

so that management could detect via QOM interface if device was
hotplugged

Signed-off-by: Igor Mammedov <imammedo@redhat.com>
Acked-by: Peter Crosthwaite <peter.crosthwaite@xilinx.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
10 years agoqdev: hotplug for bus-less devices
Igor Mammedov [Mon, 2 Jun 2014 13:25:03 +0000 (15:25 +0200)]
qdev: hotplug for bus-less devices

Add get_hotplug_handler() method to machine, and
make bus-less device use it during hotplug
as a means to discover a hotplug handler controller.
The returned controller is used to perform hotplug
actions.

Signed-off-by: Igor Mammedov <imammedo@redhat.com>
Acked-by: Peter Crosthwaite <peter.crosthwaite@xilinx.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
10 years agovl.c: extend -m option to support options for memory hotplug
Igor Mammedov [Mon, 2 Jun 2014 13:25:02 +0000 (15:25 +0200)]
vl.c: extend -m option to support options for memory hotplug

Add following parameters:
  "slots" - total number of hotplug memory slots
  "maxmem" - maximum possible memory

"slots" and "maxmem" should go in pair and "maxmem" should be greater
than "mem" for memory hotplug to be enabled.

Signed-off-by: Igor Mammedov <imammedo@redhat.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
MST: fix build on 32 bit

10 years agoadd memdev backend infrastructure
Igor Mammedov [Fri, 6 Jun 2014 15:54:29 +0000 (17:54 +0200)]
add memdev backend infrastructure

Provides framework for splitting host RAM allocation/
policies into a separate backend that could be used
by devices.

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

Signed-off-by: Igor Mammedov <imammedo@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
10 years agovl.c: daemonize before guest memory allocation
Igor Mammedov [Mon, 2 Jun 2014 13:25:00 +0000 (15:25 +0200)]
vl.c: daemonize before guest memory allocation

memory allocated for guest before QEMU is daemonized and then mapped
later in guest's address space after it is daemonized, leads to EPT
violation and QEMU aborts.

To avoid this and similar issues switch to daemonized mode early
before applying/processing other options.

Signed-off-by: Igor Mammedov <imammedo@redhat.com>
Acked-by: Peter Crosthwaite <peter.crosthwaite@xilinx.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
10 years agoobject_add: allow completion handler to get canonical path
Igor Mammedov [Mon, 2 Jun 2014 13:24:59 +0000 (15:24 +0200)]
object_add: allow completion handler to get canonical path

Add object to /objects before calling user_creatable_complete()
handler, so that object might be able to call
object_get_canonical_path() in its completion handler.

Signed-off-by: Igor Mammedov <imammedo@redhat.com>
Acked-by: Peter Crosthwaite <peter.crosthwaite@xilinx.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
10 years agopc: ACPI BIOS: use enum for defining memory affinity flags
Igor Mammedov [Mon, 2 Jun 2014 13:24:58 +0000 (15:24 +0200)]
pc: ACPI BIOS: 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>
Acked-by: Peter Crosthwaite <peter.crosthwaite@xilinx.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
10 years agopc: create custom generic PC machine type
Igor Mammedov [Mon, 2 Jun 2014 13:24:57 +0000 (15:24 +0200)]
pc: create custom generic PC machine type

it will be used for PC specific options/variables

Signed-off-by: Igor Mammedov <imammedo@redhat.com>
Acked-by: Peter Crosthwaite <peter.crosthwaite@xilinx.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
10 years agoMerge remote-tracking branch 'remotes/bonzini/memory' into staging
Peter Maydell [Wed, 18 Jun 2014 14:08:38 +0000 (15:08 +0100)]
Merge remote-tracking branch 'remotes/bonzini/memory' into staging

* remotes/bonzini/memory:
  memory: Don't call memory_region_update_coalesced_range if nothing changed
  memory: MemoryRegion: rename parent to container
  memory: MemoryRegion: factor out memory region re-adder
  memory: MemoryRegion: factor out subregion add functionality
  qtest: fix qtest_clock_warp() for no deadline case
  exec: dummy_section: Pass address space through.
  memory: Simplify mr_add_subregion() if-else
  memory: Don't update all memory region when ioeventfd changed
  unset RAMBlock idstr when unregister MemoryRegion
  exec: introduce qemu_ram_unset_idstr() to unset RAMBlock idstr
  MAINTAINERS: Add myself as Memory API maintainer

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
10 years agomemory: Don't call memory_region_update_coalesced_range if nothing changed
Fam Zheng [Fri, 13 Jun 2014 06:34:41 +0000 (14:34 +0800)]
memory: Don't call memory_region_update_coalesced_range if nothing changed

With huge number of PCI devices in the system (for example, 200
virtio-blk-pci), this unconditional call can slow down emulation of
irrelevant PCI operations drastically, such as a BAR update on a device
that has no coalescing region. So avoid it.

Signed-off-by: Fam Zheng <famz@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
10 years agomemory: MemoryRegion: rename parent to container
Paolo Bonzini [Wed, 11 Jun 2014 09:18:09 +0000 (11:18 +0200)]
memory: MemoryRegion: rename parent to container

Avoid confusion with the QOM parent.

Reviewed-by: Peter Crosthwaite <peter.crosthwaite@xilinx.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>