sysbus: add sysbus_address_space()

Given a bus device, retrieves the memory address space for its bus.

Signed-off-by: Avi Kivity <avi@redhat.com>
memory: add memory_region_is_ram()

Signed-off-by: Avi Kivity <avi@redhat.com>
memory: add memory_region_is_rom()

Signed-off-by: Avi Kivity <avi@redhat.com>
memory: add memory_region_is_logging()

Signed-off-by: Avi Kivity <avi@redhat.com>
memory: introduce memory_region_find()

Given an address space (represented by the top-level memory region),
returns the memory region that maps a given range.  Useful for implementing
DMA.

The implementation is a simplistic binary search.  Once we have a tree
representation this can be optimized.

Signed-off-by: Avi Kivity <avi@redhat.com>
framebuffer: drop use of cpu_get_physical_page_desc()

cpu_get_physical_page_desc() is tied into the memory core's
innards, replace it with uses of the API.

Signed-off-by: Avi Kivity <avi@redhat.com>
loader: remove calls to cpu_get_physical_page_desc()

cpu_get_physical_page_desc() is tied into the memory core's
innards, replace it with uses of the API.

Signed-off-by: Avi Kivity <avi@redhat.com>
framebuffer: drop use of cpu_physical_sync_dirty_bitmap()

Replace with memory API equivalent.

Signed-off-by: Avi Kivity <avi@redhat.com>
memory: replace cpu_physical_sync_dirty_bitmap() with a memory API

The function is still used as the implementation.

Signed-off-by: Avi Kivity <avi@redhat.com>
memory: add API for observing updates to the physical memory map

Add an API that allows a client to observe changes in the global
memory map:
 - region added (possibly with logging enabled)
 - region removed (possibly with logging enabled)
 - logging started on a region
 - logging stopped on a region
 - global logging started
 - global logging removed

This API will eventually replace cpu_register_physical_memory_client().

Signed-off-by: Avi Kivity <avi@redhat.com>
kvm: switch kvm slots to use host virtual address instead of ram_addr_t

This simplifies a later switch to the memory API in slot management.

Signed-off-by: Avi Kivity <avi@redhat.com>
kvm: convert to MemoryListener API

Drop the use of cpu_register_phys_memory_client() in favour of the new
MemoryListener API.  The new API simplifies the caller, since there is no
need to deal with splitting and merging slots; however this is not exploited
in this patch.

Signed-off-by: Avi Kivity <avi@redhat.com>
vhost: convert to MemoryListener API

Drop the use of cpu_register_phys_memory_client() in favour of the new
MemoryListener API.  The new API simplifies the caller, since there is no
need to deal with splitting and merging slots; however this is not exploited
in this patch.

Signed-off-by: Avi Kivity <avi@redhat.com>
xen, vga: add API for registering the framebuffer

Xen currently uses the name of a memory region to determine whether it
is the framebuffer.  Replace with an explicit API.

Signed-off-by: Avi Kivity <avi@redhat.com>
memory: temporarily add memory_region_get_ram_addr()

This is a layering violation, but needed while the code contains
naked calls to qemu_get_ram_ptr() and the like.

Signed-off-by: Avi Kivity <avi@redhat.com>
hw/9pfs: replace iovec manipulation with QEMUIOVector

The v9fs_read() and v9fs_write() functions rely on iovec[] manipulation
code should be replaced with QEMUIOVector to avoid duplicating code.
In the future it may be possible to make the code even more concise by
using QEMUIOVector consistently across virtio and 9pfs.

The "v" format specifier for pdu_marshal() and pdu_unmarshal() is
dropped since it does not actually pack/unpack anything.  The specifier
was also not implemented to update the offset variable and could only be
used at the end of a format string, another sign that this shouldn't
really be a format specifier.  Instead, see the new
v9fs_init_qiov_from_pdu() function.

This change avoids a possible iovec[] buffer overflow when indirect
vrings are used since the number of vectors is now limited by the
underlying VirtQueueElement and cannot be out-of-bounds.

Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
hw/9pfs: Use the correct signed type for different variables

Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
hw/9pfs: iattr_valid flags are kernel internal flags map them to 9p values.
    
Kernel internal values can change, add protocol values for these constant and
use them.

Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
scripts/analyse-9p-simpletrace.py:	Add symbolic names for 9p operations.

Currently, we just print the numerical value of 9p operation identifier in
case of RERROR which is less meaningful for readability. Mapping 9p
operation ids to symbolic names provides a better tracelog:

	RERROR (tag = 1 , id = TWALK , err = " No such file or directory ")
	RERROR (tag = 1 , id = TUNLINKAT , err = " Directory not empty ")

This patch provides a dictionary of all possible 9p operation symbols mapped
to their numerical identifiers which are likely to be used in future at
various places in this script.

Signed-off-by: Harsh Prateek Bora <harsh@linux.vnet.ibm.com>
Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
add qemu_send_full and qemu_recv_full

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>