OSDN Git Service

qmiga/qemu.git
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>
10 years agomemory: MemoryRegion: factor out memory region re-adder
Peter Crosthwaite [Fri, 6 Jun 2014 06:15:18 +0000 (23:15 -0700)]
memory: MemoryRegion: factor out memory region re-adder

memory_region_set_address is mostly just a function that deletes and
re-adds a memory region. Factor this generic functionality out into a
re-usable function. This prepares support for further QOMification
of MemoryRegion.

Signed-off-by: Peter Crosthwaite <peter.crosthwaite@xilinx.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
10 years agomemory: MemoryRegion: factor out subregion add functionality
Peter Crosthwaite [Fri, 6 Jun 2014 06:14:44 +0000 (23:14 -0700)]
memory: MemoryRegion: factor out subregion add functionality

Split off the core looping code that actually adds subregions into
it's own fn. This prepares support for Memory Region qomification
where setting the MR address or parent via QOM will back onto this more
minimal function.

Signed-off-by: Peter Crosthwaite <peter.crosthwaite@xilinx.com>
[Rename new function. - Paolo]
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
10 years agoMerge remote-tracking branch 'remotes/riku/linux-user-for-upstream' into staging
Peter Maydell [Tue, 17 Jun 2014 15:08:06 +0000 (16:08 +0100)]
Merge remote-tracking branch 'remotes/riku/linux-user-for-upstream' into staging

* remotes/riku/linux-user-for-upstream:
  User mode support for Linux ELF files with no section header
  linux-user: Return correct errno for unsupported netlink socket
  linux-user: Don't overrun guest buffer in sched_getaffinity
  linux-user/uname: Return correct uname string for x86_64
  linux-user: fix gcc-4.9 compiler error on __{get,put]}_user
  signal/ppc/do_setcontext remove __get_user return check
  signal/sparc64_set_context: remove __get_user checks
  signal/ppc/{save,restore}_user_regs remove __put/get error checks
  signal/all/setup_frame remove __put_user checks
  signal/all/do_sigreturn - remove __get_user checks
  signal/all/do_sigaltstack remove __get_user value check
  signal/sparc/restore_fpu_state: remove
  signal/all: remove return value from restore_sigcontext
  signal/all: remove return value from setup_sigcontext
  signal/all: remove return value from copy_siginfo_to_user
  signal/x86/setup_frame: __put_user cleanup
  signal/all: remove __get/__put_user return value reading

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
10 years agoqtest: fix qtest_clock_warp() for no deadline case
Sergey Fedorov [Tue, 10 Jun 2014 09:10:28 +0000 (13:10 +0400)]
qtest: fix qtest_clock_warp() for no deadline case

Use dedicated qemu_soonest_timeout() instead of MIN().

Signed-off-by: Sergey Fedorov <serge.fdrv@gmail.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
10 years agoexec: dummy_section: Pass address space through.
Peter Crosthwaite [Tue, 3 Jun 2014 02:08:44 +0000 (19:08 -0700)]
exec: dummy_section: Pass address space through.

Rather than use the global singleton.

Signed-off-by: Peter Crosthwaite <peter.crosthwaite@xilinx.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
10 years agomemory: Simplify mr_add_subregion() if-else
Peter Crosthwaite [Mon, 12 May 2014 08:13:47 +0000 (01:13 -0700)]
memory: Simplify mr_add_subregion() if-else

This if else is not needed. The previous call to memory_region_add
(whether _overlap or not) will always set priority and may_overlap
to desired values. And its not possible to get here without having
called memory_region_add_subregion due to the null guard on parent.
So we can just directly call memory_region_add_subregion_common.

Signed-off-by: Peter Crosthwaite <peter.crosthwaite@xilinx.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
10 years agomemory: Don't update all memory region when ioeventfd changed
Gonglei [Thu, 8 May 2014 03:47:32 +0000 (11:47 +0800)]
memory: Don't update all memory region when ioeventfd changed

memory mappings don't rely on ioeventfds, there is no need
to destroy and rebuild them when manipulating ioeventfds,
otherwise it scarifies performance.

according to testing result, each ioeventfd deleing needs
about 5ms, within which memory mapping rebuilding needs
about 4ms. With many Nics and vmchannel in a VM doing migrating,
there can be many ioeventfds deleting which increasing
downtime remarkably.

Signed-off-by: Gonglei <arei.gonglei@huawei.com>
Signed-off-by: Herongguang <herongguang.he@huawei.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
10 years agounset RAMBlock idstr when unregister MemoryRegion
Hu Tao [Wed, 2 Apr 2014 07:13:27 +0000 (15:13 +0800)]
unset RAMBlock idstr when unregister MemoryRegion

Signed-off-by: Hu Tao <hutao@cn.fujitsu.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
10 years agoexec: introduce qemu_ram_unset_idstr() to unset RAMBlock idstr
Hu Tao [Wed, 2 Apr 2014 07:13:26 +0000 (15:13 +0800)]
exec: introduce qemu_ram_unset_idstr() to unset RAMBlock idstr

Signed-off-by: Hu Tao <hutao@cn.fujitsu.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
10 years agoMAINTAINERS: Add myself as Memory API maintainer
Paolo Bonzini [Tue, 29 Apr 2014 14:05:53 +0000 (16:05 +0200)]
MAINTAINERS: Add myself as Memory API maintainer

I'm not including Avi since he has already removed himself from the
KVM entry.  I'm not going to commit my patches without review.

Acked-by: Edgar E. Iglesias <edgar.iglesias@gmail.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
10 years agoUser mode support for Linux ELF files with no section header
Craig Heffner [Mon, 5 Dec 2011 19:14:27 +0000 (14:14 -0500)]
User mode support for Linux ELF files with no section header

In user mode Linux, Qemu currently refuses to load ELF files that do not
contain section headers (ehdr->e_shentsize == 0). Since section headers are not
required in order to load an ELF file, simply removing the e_shentsize check in
elf_check_ehdr() allows ELF binaries with no section headers to be run properly
in user mode:

Signed-off-by: Craig Heffner <cheffner@tacnetsol.com>
Signed-off-by: Riku Voipio <riku.voipio@linaro.org>
10 years agolinux-user: Return correct errno for unsupported netlink socket
Ed Swierk [Tue, 6 May 2014 03:04:45 +0000 (20:04 -0700)]
linux-user: Return correct errno for unsupported netlink socket

This fixes "Cannot open audit interface - aborting." when the
EAFNOSUPPORT errno differs between the target and host
architectures (e.g. mips target and x86_64 host).

Signed-off-by: Ed Swierk <eswierk@skyportsystems.com>
Signed-off-by: Riku Voipio <riku.voipio@linaro.org>
10 years agolinux-user: Don't overrun guest buffer in sched_getaffinity
Peter Maydell [Thu, 15 May 2014 13:40:23 +0000 (14:40 +0100)]
linux-user: Don't overrun guest buffer in sched_getaffinity

If the guest's "long" type is smaller than the host's, then
our sched_getaffinity wrapper needs to round the buffer size
up to a multiple of the host sizeof(long). This means that when
we copy the data back from the host buffer to the guest's
buffer there might be more than we can fit. Rather than
overflowing the guest's buffer, handle this case by returning
EINVAL or ignoring the unused extra space, as appropriate.

Note that only guests using the syscall interface directly might
run into this bug -- the glibc wrappers around it will always
use a buffer whose size is a multiple of 8 regardless of guest
architecture.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Riku Voipio <riku.voipio@linaro.org>
10 years agolinux-user/uname: Return correct uname string for x86_64
Peter Maydell [Sat, 10 May 2014 11:25:53 +0000 (12:25 +0100)]
linux-user/uname: Return correct uname string for x86_64

We were returning the incorrect uname string (with a hyphen, not
an underscore) for x86_64. Fix this by removing the x86_64 special
case, since the default "just use UNAME_MACHINE" behaviour suffices.
This leaves cpu_to_uname_machine() special cases for only those
architectures which need to vary the string based on runtime CPU
features.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Riku Voipio <riku.voipio@linaro.org>
10 years agolinux-user: fix gcc-4.9 compiler error on __{get,put]}_user
Riku Voipio [Tue, 22 Apr 2014 12:40:50 +0000 (15:40 +0300)]
linux-user: fix gcc-4.9 compiler error on __{get,put]}_user

gcc-4.9 finds unused operand:

linux-user/syscall.c: In function ‘host_to_target_stat64’:
linux-user/qemu.h:301:19: error: right-hand operand of comma expression
has no effect [-Werror=unused-value]
      ((hptr), (x)), 0)

Just removing the rh operand is no good, it will error in later:

linux-user/main.c: In function ‘arm_kernel_cmpxchg64_helper’:
linux-user/qemu.h:330:15: error: void value not ignored as it ought to be
         __ret = __put_user((x), __hptr);    \

Thus, remove setting __ret from __get_user and __put_user, as and
set the right hand operand to (void)0 to make it clear that these
return never nothing.

This commit depends on the signal.c cleanup, to ensure bisectable
version history.

Signed-off-by: Riku Voipio <riku.voipio@linaro.org>
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Cc: Richard Henderson <rth@twiddle.net>
10 years agosignal/ppc/do_setcontext remove __get_user return check
Riku Voipio [Wed, 23 Apr 2014 11:05:09 +0000 (14:05 +0300)]
signal/ppc/do_setcontext remove __get_user return check

The last remaining check for return value of __get_user.

Signed-off-by: Riku Voipio <riku.voipio@linaro.org>
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Cc: Alexander Graf <agraf@suse.de>
10 years agosignal/sparc64_set_context: remove __get_user checks
Riku Voipio [Wed, 23 Apr 2014 11:02:36 +0000 (14:02 +0300)]
signal/sparc64_set_context: remove __get_user checks

Remove checks of __get_user and the err variable
used to control flow with it.

Signed-off-by: Riku Voipio <riku.voipio@linaro.org>
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
10 years agosignal/ppc/{save,restore}_user_regs remove __put/get error checks
Riku Voipio [Wed, 23 Apr 2014 10:53:45 +0000 (13:53 +0300)]
signal/ppc/{save,restore}_user_regs remove __put/get error checks

As __get_user and __put_user do not return errors, remove the
if checks from around them. This allows making the save/restore
functions void.

Signed-off-by: Riku Voipio <riku.voipio@linaro.org>
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Cc: Alexander Graf <agraf@suse.de>
10 years agosignal/all/setup_frame remove __put_user checks
Riku Voipio [Wed, 23 Apr 2014 10:34:15 +0000 (13:34 +0300)]
signal/all/setup_frame remove __put_user checks

Remove "if(__put_user" checks and their related error paths
for all architecture's setup_frame, setup_rt_frame and similar.

Remove the unlock_user_struct when the only way to end up there is
from failed lock_user_struct.

Remove err variable if there are no users for it in the function
anymore.

Signed-off-by: Riku Voipio <riku.voipio@linaro.org>
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
10 years agosignal/all/do_sigreturn - remove __get_user checks
Riku Voipio [Wed, 23 Apr 2014 10:00:17 +0000 (13:00 +0300)]
signal/all/do_sigreturn - remove __get_user checks

Remove "if(__get_user" checks and their related error paths
for all architecture's do_sigreturn. Remove the unlock_user_struct
when the only way to end up there is from failed lock_user_struct.

v3: remove unneccesary sigsegv label as suggested by Peter

Signed-off-by: Riku Voipio <riku.voipio@linaro.org>
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
10 years agosignal/all/do_sigaltstack remove __get_user value check
Riku Voipio [Wed, 23 Apr 2014 08:26:34 +0000 (11:26 +0300)]
signal/all/do_sigaltstack remove __get_user value check

Access is already checked in the lock_user_struct
call before.

Signed-off-by: Riku Voipio <riku.voipio@linaro.org>
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
10 years agosignal/sparc/restore_fpu_state: remove
Riku Voipio [Wed, 23 Apr 2014 08:22:38 +0000 (11:22 +0300)]
signal/sparc/restore_fpu_state: remove

A function never called from anywhere, obviously half-complete.
Remove function and if someone wants to complete this, please
check the old version out of git history.

Signed-off-by: Riku Voipio <riku.voipio@linaro.org>
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
10 years agosignal/all: remove return value from restore_sigcontext
Riku Voipio [Wed, 23 Apr 2014 08:19:48 +0000 (11:19 +0300)]
signal/all: remove return value from restore_sigcontext

make most implementations of restore_sigcontext void and
remove checking it's return value from functions calling
restore_sigcontext.

The exception is the X86 version of the function that is
too different from others to deal in this way, and arm
version, to keep possibility of erroring out from failed
valid_user_regs.

v3: keep arm valid_user_regs for filling in near future.

Signed-off-by: Riku Voipio <riku.voipio@linaro.org>
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
10 years agosignal/all: remove return value from setup_sigcontext
Riku Voipio [Wed, 23 Apr 2014 08:01:00 +0000 (11:01 +0300)]
signal/all: remove return value from setup_sigcontext

Make all implementations of setup_sigcontext void and
remove checking it's return value from functions calling
setup_sigcontext.

Signed-off-by: Riku Voipio <riku.voipio@linaro.org>
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
10 years agosignal/all: remove return value from copy_siginfo_to_user
Riku Voipio [Wed, 23 Apr 2014 07:46:13 +0000 (10:46 +0300)]
signal/all: remove return value from copy_siginfo_to_user

Since copy_siginfo_to_user always returns 0, make it void
and remove any checks for return value from calling functions.

Signed-off-by: Riku Voipio <riku.voipio@linaro.org>
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
10 years agosignal/x86/setup_frame: __put_user cleanup
Riku Voipio [Wed, 23 Apr 2014 07:34:53 +0000 (10:34 +0300)]
signal/x86/setup_frame: __put_user cleanup

Remove the remaining check for __put_user return
value, and all the checks for err variable which
isn't set anywhere anymore.

No we can only end up in give_sigsegv due to failed
lock_user_struct - thus we remove the unlock_user_struct
to avoid unlocking a region never locked.

Signed-off-by: Riku Voipio <riku.voipio@linaro.org>
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
10 years agosignal/all: remove __get/__put_user return value reading
Riku Voipio [Wed, 23 Apr 2014 07:26:05 +0000 (10:26 +0300)]
signal/all: remove __get/__put_user return value reading

Remove all the simple cases of reading the return value
of __get_user and __put_user.

We set err = 0 in sparc versions of do_sigreturn and
sparc64_set_context to avoid compile error, but else this patch is
just general removal of err |= __get_user ... idiom.

v2: remove err variable from target_rt_restore_ucontext

Signed-off-by: Riku Voipio <riku.voipio@linaro.org>
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
10 years agoMerge remote-tracking branch 'remotes/agraf/tags/signed-ppc-for-upstream' into staging
Peter Maydell [Mon, 16 Jun 2014 17:26:21 +0000 (18:26 +0100)]
Merge remote-tracking branch 'remotes/agraf/tags/signed-ppc-for-upstream' into staging

Patch queue for ppc - 2014-06-16

This pull request brings a lot of fun things. Among others we have

  - e500: u-boot firmware support
  - sPAPR: magic page enablement
  - sPAPR: add "compat" CPU option to support older guests
  - sPAPR: refactorings in preparation for VFIO
  - POWER8 live migration
  - mac99: expose bus frequency
  - little endian core dump, gdb and disas support
  - new ppc64le-linux-user target
  - DFP emulation
  - bug fixes

# gpg: Signature made Mon 16 Jun 2014 12:28:32 BST using RSA key ID 03FEDC60
# gpg: Can't check signature: public key not found

* remotes/agraf/tags/signed-ppc-for-upstream: (156 commits)
  spapr_pci: Advertise MSI quota
  PPC: KVM: Make pv hcall endian agnostic
  powerpc: use float64 for frsqrte
  spapr: Add kvm-type property
  spapr: Create SPAPRMachine struct
  linux-user: Tell guest about big host page sizes
  spapr_hcall: Add address-translation-mode-on-interrupt resource in H_SET_MODE
  spapr_hcall: Split h_set_mode()
  target-ppc: Enable DABRX SPR and limit it to <=POWER7
  target-ppc: Enable PPR and VRSAVE SPRs migration
  target-ppc: Add POWER8's Event Based Branch (EBB) control SPRs
  KVM: target-ppc: Enable TM state migration
  target-ppc: Add POWER8's TM SPRs
  target-ppc: Add POWER8's MMCR2/MMCRS SPRs
  target-ppc: Enable FSCR facility check for TAR
  target-ppc: Add POWER8's FSCR SPR
  target-ppc: Add POWER8's TIR SPR
  target-ppc: Refactor class init for POWER7/8
  target-ppc: Switch POWER7/8 classes to use correct PMU SPRs
  target-ppc: Make use of gen_spr_power5p_lpar() for POWER7/8
  ...

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
10 years agorules.mak: remove $(sort) from extract-libs
Paolo Bonzini [Mon, 16 Jun 2014 14:43:25 +0000 (16:43 +0200)]
rules.mak: remove $(sort) from extract-libs

Duplicate removal was added to extract-libs in order to avoid including
the same library multiple times into the linking command line; this could
potentially happen when using "foo.mo-libs" (which adds the library to
all components, causing it to appear N times if the module is composed
of N objects).  However, sorting and removing duplicates causes problems
with static linking, and also with space-separated linker options as
found in some Mac OS X packaging systems.  Furthermore, the "optimization"
is really a non-problem since we do not expect .mo modules to be composed
of many files.

Reported-by: Sean Bruno <sbruno@ignoranthack.me>
Tested-by: Sean Bruno <sbruno@ignoranthack.me>
Reviewed-by: Fam Zheng <famz@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Message-id: 1402929805-16836-1-git-send-email-pbonzini@redhat.com
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
10 years agoMerge remote-tracking branch 'remotes/stefanha/tags/block-pull-request' into staging
Peter Maydell [Mon, 16 Jun 2014 11:27:47 +0000 (12:27 +0100)]
Merge remote-tracking branch 'remotes/stefanha/tags/block-pull-request' into staging

Block pull request

# gpg: Signature made Mon 16 Jun 2014 12:22:22 BST using RSA key ID 81AB73C8
# gpg: Good signature from "Stefan Hajnoczi <stefanha@redhat.com>"
# gpg:                 aka "Stefan Hajnoczi <stefanha@gmail.com>"

* remotes/stefanha/tags/block-pull-request: (39 commits)
  QemuOpts: cleanup tmp 'allocated' member from QemuOptsList
  cleanup QEMUOptionParameter
  vpc.c: replace QEMUOptionParameter with QemuOpts
  vmdk.c: replace QEMUOptionParameter with QemuOpts
  vhdx.c: replace QEMUOptionParameter with QemuOpts
  vdi.c: replace QEMUOptionParameter with QemuOpts
  ssh.c: replace QEMUOptionParameter with QemuOpts
  sheepdog.c: replace QEMUOptionParameter with QemuOpts
  rbd.c: replace QEMUOptionParameter with QemuOpts
  raw_bsd.c: replace QEMUOptionParameter with QemuOpts
  raw-win32.c: replace QEMUOptionParameter with QemuOpts
  raw-posix.c: replace QEMUOptionParameter with QemuOpts
  qed.c: replace QEMUOptionParameter with QemuOpts
  qcow2.c: replace QEMUOptionParameter with QemuOpts
  QemuOpts: export qemu_opt_find
  qcow.c: replace QEMUOptionParameter with QemuOpts
  nfs.c: replace QEMUOptionParameter with QemuOpts
  iscsi.c: replace QEMUOptionParameter with QemuOpts
  gluster.c: replace QEMUOptionParameter with QemuOpts
  cow.c: replace QEMUOptionParameter with QemuOpts
  ...

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
10 years agospapr_pci: Advertise MSI quota
Badari Pulavarty [Wed, 11 Jun 2014 08:49:33 +0000 (18:49 +1000)]
spapr_pci: Advertise MSI quota

Hotplug of multiple disks fails due to MSI vector quota check.
Number of MSI vectors default to 8 allowing only 4 devices.
This happens on RHEL6.5 guest. RHEL7 and SLES11 guests fallback
to INTX.

One way to workaround the issue is to increase total MSIs,
so that MSI quota check allows us to hotplug multiple disks.

This sets the quota to the maximum number of interupts XICS has
which is 1024 now (XICS_IRQS). This moves XICS_IRQS from spapr.c
to xics.h for wider visibility.

Signed-off-by: Badari Pulavarty <pbadari@us.ibm.com>
[aik: put XICS_IRQS=1024 instead of 64i, fixed endianness and size]
Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
Signed-off-by: Alexander Graf <agraf@suse.de>