qemu.git
8 years agocpu: Move halted and interrupt_request fields to CPUState
Andreas Färber [Thu, 17 Jan 2013 17:51:17 +0000 (18:51 +0100)] 
cpu: Move halted and interrupt_request fields to CPUState

Both fields are used in VMState, thus need to be moved together.
Explicitly zero them on reset since they were located before
breakpoints.

Pass PowerPCCPU to kvmppc_handle_halt().

Signed-off-by: Andreas Färber <afaerber@suse.de>
8 years agotarget-cris/helper.c: Update Coding Style
Andreas Färber [Fri, 25 Jan 2013 16:37:28 +0000 (17:37 +0100)] 
target-cris/helper.c: Update Coding Style

Reindent, add missing braces and drop/adjust whitespace.

Prepares for CPUArchState-to-CPUState field movements in
cpu_cris_handle_mmu_fault(), do_interruptv10() and do_interrupt().
The remaining functions were so minor that they can be fixed in one go.

Acked-by: Edgar E. Iglesias <edgar.iglesias@gmail.com>
Signed-off-by: Andreas Färber <afaerber@suse.de>
8 years agotarget-i386: Update VMStateDescription to X86CPU
Andreas Färber [Sat, 2 Feb 2013 12:38:08 +0000 (13:38 +0100)] 
target-i386: Update VMStateDescription to X86CPU

Expose vmstate_cpu as vmstate_x86_cpu and hook it up to CPUClass::vmsd.
Adapt opaques and VMState fields to X86CPU. Drop cpu_{save,load}().

Reviewed-by: Eduardo Habkost <ehabkost@redhat.com>
Signed-off-by: Andreas Färber <afaerber@suse.de>
8 years agocpu: Introduce cpu_class_set_vmsd()
Andreas Färber [Fri, 22 Feb 2013 20:50:10 +0000 (21:50 +0100)] 
cpu: Introduce cpu_class_set_vmsd()

This setter avoids redefining each VMStateDescription value to
vmstate_dummy by not referencing the value for CONFIG_USER_ONLY.

Suggested-by: Juan Quintela <quintela@redhat.com>
Reviewed-by: Eduardo Habkost <ehabkost@redhat.com>
Signed-off-by: Andreas Färber <afaerber@suse.de>
8 years agocpu: Register VMStateDescription through CPUState
Andreas Färber [Sun, 20 Jan 2013 19:23:22 +0000 (20:23 +0100)] 
cpu: Register VMStateDescription through CPUState

In comparison to DeviceClass::vmsd, CPU VMState is split in two,
"cpu_common" and "cpu", and uses cpu_index as instance_id instead of -1.
Therefore add a CPU-specific CPUClass::vmsd field.

Unlike the legacy CPUArchState registration, rather register CPUState.

Signed-off-by: Juan Quintela <quintela@redhat.com>
Signed-off-by: Andreas Färber <afaerber@suse.de>
Reviewed-by: Eduardo Habkost <ehabkost@redhat.com>
8 years agostubs: Add a vmstate_dummy struct for CONFIG_USER_ONLY
Andreas Färber [Mon, 18 Feb 2013 16:56:20 +0000 (17:56 +0100)] 
stubs: Add a vmstate_dummy struct for CONFIG_USER_ONLY

Reviewed-by: Juan Quintela <quintela@redhat.com>
Reviewed-by: Eduardo Habkost <ehabkost@redhat.com>
Signed-off-by: Andreas Färber <afaerber@suse.de>
8 years agovmstate: Make vmstate_register() static inline
Andreas Färber [Mon, 18 Feb 2013 20:41:59 +0000 (21:41 +0100)] 
vmstate: Make vmstate_register() static inline

This avoids adding a duplicate stub for CONFIG_USER_ONLY.

Suggested-by: Eduardo Habkost <ehabkost@redhat.com>
Reviewed-by: Eduardo Habkost <ehabkost@redhat.com>
Reviewed-by: Juan Quintela <quintela@redhat.com>
Signed-off-by: Andreas Färber <afaerber@suse.de>
8 years agotarget-sh4: Move PVR/PRR/CVR into SuperHCPUClass
Andreas Färber [Tue, 20 Nov 2012 15:15:47 +0000 (16:15 +0100)] 
target-sh4: Move PVR/PRR/CVR into SuperHCPUClass

They are never changed once initialized, and moving them to the class
will allow to inspect them before instantiating.

Signed-off-by: Andreas Färber <afaerber@suse.de>
8 years agotarget-sh4: Introduce SuperHCPU subclasses
Andreas Färber [Mon, 19 Nov 2012 01:42:18 +0000 (02:42 +0100)] 
target-sh4: Introduce SuperHCPU subclasses

Store legacy name in SuperHCPUClass for -cpu ? and for case-insensitive
class lookup.

List CPUs by iterating over TYPE_SUPERH_CPU subclasses.

Signed-off-by: Andreas Färber <afaerber@suse.de>
8 years agocpus: Replace open-coded CPU loop in qmp_memsave() with qemu_get_cpu()
Andreas Färber [Fri, 15 Feb 2013 14:41:49 +0000 (15:41 +0100)] 
cpus: Replace open-coded CPU loop in qmp_memsave() with qemu_get_cpu()

No functional change, just less usages of first_cpu and next_cpu fields.

env is passed to cpu_memory_rw_debug(), which in turn passes it to
target-specific cpu_get_phys_page_debug(). Changing both would be a
larger refactoring, so defer that by using env_ptr for now.

Reviewed-by: Luiz Capitulino <lcapitulino@redhat.com>
Signed-off-by: Andreas Färber <afaerber@suse.de>
8 years agomonitor: Use qemu_get_cpu() in monitor_set_cpu()
Andreas Färber [Fri, 15 Feb 2013 16:01:09 +0000 (17:01 +0100)] 
monitor: Use qemu_get_cpu() in monitor_set_cpu()

No functional change, just a reduction of CPU loops.

The mon_cpu field is left untouched for now since changing that requires
a number of larger prerequisites, including cpu_synchronize_state() and
mon_get_cpu().

Reviewed-by: Luiz Capitulino <lcapitulino@redhat.com>
Reviewed-by: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Andreas Färber <afaerber@suse.de>
8 years agocpu: Fix qemu_get_cpu() to return NULL if CPU not found
Igor Mammedov [Thu, 7 Mar 2013 18:12:43 +0000 (19:12 +0100)] 
cpu: Fix qemu_get_cpu() to return NULL if CPU not found

Commit 55e5c2850 breaks CPU not found return value, and returns
CPU corresponding to the last non NULL env.
Fix it by returning CPU only if env is not NULL, otherwise CPU is
not found and function should return NULL.

Signed-off-by: Igor Mammedov <imammedo@redhat.com>
Signed-off-by: Andreas Färber <afaerber@suse.de>
8 years agoMerge remote-tracking branch 'quintela/migration.next' into staging
Anthony Liguori [Mon, 11 Mar 2013 13:30:34 +0000 (08:30 -0500)] 
Merge remote-tracking branch 'quintela/migration.next' into staging

# By Paolo Bonzini (40) and others
# Via Juan Quintela
* quintela/migration.next: (46 commits)
  page_cache: dup memory on insert
  page_cache: fix memory leak
  Fix cache_resize to keep old entry age
  Fix page_cache leak in cache_resize
  migration: inline migrate_fd_close
  migration: eliminate s->migration_file
  migration: move contents of migration_close to migrate_fd_cleanup
  migration: move rate limiting to QEMUFile
  migration: small changes around rate-limiting
  migration: use qemu_ftell to compute bandwidth
  migration: use QEMUFile for writing outgoing migration data
  migration: use QEMUFile for migration channel lifetime
  qemu-file: simplify and export qemu_ftell
  qemu-file: add writable socket QEMUFile
  qemu-file: check exit status when closing a pipe QEMUFile
  qemu-file: fsync a writable stdio QEMUFile
  migration: merge qemu_popen_cmd with qemu_popen
  migration: use qemu_file_rate_limit consistently
  migration: remove useless qemu_file_get_error check
  migration: detect error before sleeping
  ...

8 years agoarm: fix compilation with CONFIG_FDT
Paolo Bonzini [Mon, 11 Mar 2013 10:31:26 +0000 (11:31 +0100)] 
arm: fix compilation with CONFIG_FDT

A conflict was resolved the wrong way when merging commit 320ba5f (build:
always link device_tree.o into emulators if libfdt available, 2013-02-05).
This causes a build failure for the arm-softmmu target due to multiply
defined symbol.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Message-id: 1362997886-9470-1-git-send-email-pbonzini@redhat.com
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
8 years agopage_cache: dup memory on insert
Peter Lieven [Mon, 25 Feb 2013 17:12:04 +0000 (19:12 +0200)] 
page_cache: dup memory on insert

The page cache frees all data on finish, on resize and
if there is collision on insert. So it should be the caches
responsibility to dup the data that is stored in the cache.

Signed-off-by: Peter Lieven <pl@kamp.de>
Signed-off-by: Orit Wasserman <owasserm@redhat.com>
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Juan Quintela <quintela@redhat.com>
8 years agopage_cache: fix memory leak
Peter Lieven [Mon, 25 Feb 2013 17:12:03 +0000 (19:12 +0200)] 
page_cache: fix memory leak

XBZRLE encoded migration introduced a MRU page cache
meachnism. Unfortunately, cached items where never freed in
case of a collision in the page cache on cache_insert().

This lead to out of memory conditions during XBZRLE migration
if the page cache was small and there where a lot of collisions
in the cache.

Signed-off-by: Peter Lieven <pl@kamp.de>
Signed-off-by: Orit Wasserman <owasserm@redhat.com>
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Juan Quintela <quintela@redhat.com>
8 years agoFix cache_resize to keep old entry age
Orit Wasserman [Mon, 25 Feb 2013 17:12:02 +0000 (19:12 +0200)] 
Fix cache_resize to keep old entry age

Instead of using cache_insert do the update itself

Signed-off-by: Orit Wasserman <owasserm@redhat.com>
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Juan Quintela <quintela@redhat.com>
8 years agoFix page_cache leak in cache_resize
Orit Wasserman [Mon, 25 Feb 2013 17:12:01 +0000 (19:12 +0200)] 
Fix page_cache leak in cache_resize

Signed-off-by: Orit Wasserman <owasserm@redhat.com>
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Juan Quintela <quintela@redhat.com>
8 years agomigration: inline migrate_fd_close
Paolo Bonzini [Fri, 22 Feb 2013 16:36:48 +0000 (17:36 +0100)] 
migration: inline migrate_fd_close

Reviewed-by: Orit Wasserman <owasserm@redhat.com>
Reviewed-by: Juan Quintela <quintela@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Juan Quintela <quintela@redhat.com>
8 years agomigration: eliminate s->migration_file
Paolo Bonzini [Fri, 22 Feb 2013 16:36:47 +0000 (17:36 +0100)] 
migration: eliminate s->migration_file

The indirection is useless now.  Backends can open s->file directly.

Reviewed-by: Orit Wasserman <owasserm@redhat.com>
Reviewed-by: Juan Quintela <quintela@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Juan Quintela <quintela@redhat.com>
8 years agomigration: move contents of migration_close to migrate_fd_cleanup
Paolo Bonzini [Fri, 22 Feb 2013 16:36:46 +0000 (17:36 +0100)] 
migration: move contents of migration_close to migrate_fd_cleanup

With this patch, the migration_file is not needed anymore.

Reviewed-by: Orit Wasserman <owasserm@redhat.com>
Reviewed-by: Juan Quintela <quintela@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Juan Quintela <quintela@redhat.com>
8 years agomigration: move rate limiting to QEMUFile
Paolo Bonzini [Fri, 22 Feb 2013 16:36:45 +0000 (17:36 +0100)] 
migration: move rate limiting to QEMUFile

Rate limiting is now simply a byte counter; client call
qemu_file_rate_limit() manually to determine if they have to exit.
So it is possible and simple to move the functionality to QEMUFile.

This makes the remaining functionality of s->file redundant;
in the next patch we can remove it and write directly to s->migration_file.

Reviewed-by: Orit Wasserman <owasserm@redhat.com>
Reviewed-by: Juan Quintela <quintela@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Juan Quintela <quintela@redhat.com>
8 years agomigration: small changes around rate-limiting
Paolo Bonzini [Fri, 22 Feb 2013 16:36:44 +0000 (17:36 +0100)] 
migration: small changes around rate-limiting

This patch extracts a few small changes from the next patch, which
are unrelated to adding generic rate-limiting functionality to
QEMUFile.  Make migration_set_rate_limit a simple accessor, and
use qemu_file_set_rate_limit consistently.  Also fix a typo where
INT_MAX should have been SIZE_MAX.

Reviewed-by: Orit Wasserman <owasserm@redhat.com>
Reviewed-by: Juan Quintela <quintela@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Juan Quintela <quintela@redhat.com>
8 years agomigration: use qemu_ftell to compute bandwidth
Paolo Bonzini [Fri, 22 Feb 2013 16:36:43 +0000 (17:36 +0100)] 
migration: use qemu_ftell to compute bandwidth

Prepare for when s->bytes_xfer will be removed.

Reviewed-by: Orit Wasserman <owasserm@redhat.com>
Reviewed-by: Juan Quintela <quintela@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Juan Quintela <quintela@redhat.com>
8 years agomigration: use QEMUFile for writing outgoing migration data
Paolo Bonzini [Fri, 22 Feb 2013 16:36:42 +0000 (17:36 +0100)] 
migration: use QEMUFile for writing outgoing migration data

Second, drop the file descriptor indirection, and write directly to the
QEMUFile.

Reviewed-by: Orit Wasserman <owasserm@redhat.com>
Reviewed-by: Juan Quintela <quintela@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Juan Quintela <quintela@redhat.com>
8 years agomigration: use QEMUFile for migration channel lifetime
Paolo Bonzini [Fri, 22 Feb 2013 16:36:41 +0000 (17:36 +0100)] 
migration: use QEMUFile for migration channel lifetime

As a start, use QEMUFile to store the destination and close it.
qemu_get_fd gets a file descriptor that will be used by the write
callbacks.

Reviewed-by: Orit Wasserman <owasserm@redhat.com>
Reviewed-by: Juan Quintela <quintela@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Juan Quintela <quintela@redhat.com>
8 years agoqemu-file: simplify and export qemu_ftell
Paolo Bonzini [Fri, 22 Feb 2013 16:36:40 +0000 (17:36 +0100)] 
qemu-file: simplify and export qemu_ftell

Force a flush when qemu_ftell is called.  This simplifies the buffer magic
(it also breaks qemu_ftell for input QEMUFiles, but we never use it).

Reviewed-by: Orit Wasserman <owasserm@redhat.com>
Reviewed-by: Juan Quintela <quintela@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Juan Quintela <quintela@redhat.com>
8 years agoqemu-file: add writable socket QEMUFile
Paolo Bonzini [Fri, 22 Feb 2013 16:36:39 +0000 (17:36 +0100)] 
qemu-file: add writable socket QEMUFile

Reviewed-by: Orit Wasserman <owasserm@redhat.com>
Reviewed-by: Juan Quintela <quintela@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Juan Quintela <quintela@redhat.com>
8 years agoqemu-file: check exit status when closing a pipe QEMUFile
Paolo Bonzini [Fri, 22 Feb 2013 16:36:38 +0000 (17:36 +0100)] 
qemu-file: check exit status when closing a pipe QEMUFile

This is what exec_close does.  Move this to the underlying QEMUFile.

Reviewed-by: Orit Wasserman <owasserm@redhat.com>
Reviewed-by: Juan Quintela <quintela@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Juan Quintela <quintela@redhat.com>
8 years agoqemu-file: fsync a writable stdio QEMUFile
Paolo Bonzini [Fri, 22 Feb 2013 16:36:37 +0000 (17:36 +0100)] 
qemu-file: fsync a writable stdio QEMUFile

This is what fd_close does.  Prepare for switching to a QEMUFile.

Reviewed-by: Orit Wasserman <owasserm@redhat.com>
Reviewed-by: Juan Quintela <quintela@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Juan Quintela <quintela@redhat.com>
8 years agomigration: merge qemu_popen_cmd with qemu_popen
Paolo Bonzini [Fri, 22 Feb 2013 16:36:36 +0000 (17:36 +0100)] 
migration: merge qemu_popen_cmd with qemu_popen

There is no reason for outgoing exec migration to do popen manually
anymore (the reason used to be that we needed the FILE* to make it
non-blocking).  Use qemu_popen_cmd.

Reviewed-by: Orit Wasserman <owasserm@redhat.com>
Reviewed-by: Juan Quintela <quintela@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Juan Quintela <quintela@redhat.com>
8 years agomigration: use qemu_file_rate_limit consistently
Paolo Bonzini [Fri, 22 Feb 2013 16:36:35 +0000 (17:36 +0100)] 
migration: use qemu_file_rate_limit consistently

Reviewed-by: Orit Wasserman <owasserm@redhat.com>
Reviewed-by: Juan Quintela <quintela@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Juan Quintela <quintela@redhat.com>
8 years agomigration: remove useless qemu_file_get_error check
Paolo Bonzini [Fri, 22 Feb 2013 16:36:34 +0000 (17:36 +0100)] 
migration: remove useless qemu_file_get_error check

migration_put_buffer is never called if there has been an error.

Reviewed-by: Orit Wasserman <owasserm@redhat.com>
Reviewed-by: Juan Quintela <quintela@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Juan Quintela <quintela@redhat.com>
8 years agomigration: detect error before sleeping
Paolo Bonzini [Fri, 22 Feb 2013 16:36:33 +0000 (17:36 +0100)] 
migration: detect error before sleeping

Reviewed-by: Orit Wasserman <owasserm@redhat.com>
Reviewed-by: Juan Quintela <quintela@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Juan Quintela <quintela@redhat.com>
8 years agomigration: eliminate last_round
Paolo Bonzini [Fri, 22 Feb 2013 16:36:32 +0000 (17:36 +0100)] 
migration: eliminate last_round

We will go around the loop exactly once after setting last_round.
Eliminate the variable altogether.

Reviewed-by: Orit Wasserman <owasserm@redhat.com>
Reviewed-by: Juan Quintela <quintela@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Juan Quintela <quintela@redhat.com>
8 years agoqemu-file: make qemu_fflush and qemu_file_set_error private again
Paolo Bonzini [Fri, 22 Feb 2013 16:36:31 +0000 (17:36 +0100)] 
qemu-file: make qemu_fflush and qemu_file_set_error private again

Reviewed-by: Orit Wasserman <owasserm@redhat.com>
Reviewed-by: Juan Quintela <quintela@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Juan Quintela <quintela@redhat.com>
8 years agoRename buffered_ to migration_
Juan Quintela [Fri, 22 Feb 2013 16:36:30 +0000 (17:36 +0100)] 
Rename buffered_ to migration_

This is consistent once that we have moved everything to migration.c

Reviewed-by: Orit Wasserman <owasserm@redhat.com>
Reviewed-by: Juan Quintela <quintela@redhat.com>
Signed-off-by: Juan Quintela <quintela@redhat.com>
8 years agomigration: yay, buffering is gone
Paolo Bonzini [Fri, 22 Feb 2013 16:36:29 +0000 (17:36 +0100)] 
migration: yay, buffering is gone

Buffering was needed because blocking writes could take a long time
and starve other threads seeking to grab the big QEMU mutex.

Now that all writes (except within _complete callbacks) are done
outside the big QEMU mutex, we do not need buffering at all.

Reviewed-by: Orit Wasserman <owasserm@redhat.com>
Reviewed-by: Juan Quintela <quintela@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Juan Quintela <quintela@redhat.com>
8 years agomigration: run setup callbacks out of big lock
Paolo Bonzini [Fri, 22 Feb 2013 16:36:28 +0000 (17:36 +0100)] 
migration: run setup callbacks out of big lock

Only the migration_bitmap_sync() call needs the iothread lock.

Reviewed-by: Orit Wasserman <owasserm@redhat.com>
Reviewed-by: Juan Quintela <quintela@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Juan Quintela <quintela@redhat.com>
8 years agomigration: run pending/iterate callbacks out of big lock
Paolo Bonzini [Fri, 22 Feb 2013 16:36:27 +0000 (17:36 +0100)] 
migration: run pending/iterate callbacks out of big lock

This makes it possible to do blocking writes directly to the socket,
with no buffer in the middle.  For RAM, only the migration_bitmap_sync()
call needs the iothread lock.  For block migration, it is needed by
the block layer (including bdrv_drain_all and dirty bitmap access),
but because some code is shared between iterate and complete, all of
mig_save_device_dirty is run with the lock taken.

In the savevm case, the iterate callback runs within the big lock.
This is annoying because it complicates the rules.  Luckily we do not
need to do anything about it: the RAM iterate callback does not need
the iothread lock, and block migration never runs during savevm.

Reviewed-by: Orit Wasserman <owasserm@redhat.com>
Reviewed-by: Juan Quintela <quintela@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Juan Quintela <quintela@redhat.com>
8 years agomigration: reorder SaveVMHandlers members
Paolo Bonzini [Fri, 22 Feb 2013 16:36:26 +0000 (17:36 +0100)] 
migration: reorder SaveVMHandlers members

This groups together the callbacks that later will have similar
locking rules.

Reviewed-by: Orit Wasserman <owasserm@redhat.com>
Reviewed-by: Juan Quintela <quintela@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Juan Quintela <quintela@redhat.com>
8 years agoblock-migration: add lock
Paolo Bonzini [Fri, 22 Feb 2013 16:36:25 +0000 (17:36 +0100)] 
block-migration: add lock

Some state is shared between the block migration code and its AIO
callbacks.  Once block migration will run outside the iothread,
the block migration code and the AIO callbacks will be able to
run concurrently.  Protect the critical sections with a separate
lock.  Do the same for completed_sectors, which can be used from
the monitor.

Reviewed-by: Orit Wasserman <owasserm@redhat.com>
Reviewed-by: Juan Quintela <quintela@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Juan Quintela <quintela@redhat.com>
8 years agoblock-migration: document usage of state across threads
Paolo Bonzini [Fri, 22 Feb 2013 16:36:24 +0000 (17:36 +0100)] 
block-migration: document usage of state across threads

Reviewed-by: Orit Wasserman <owasserm@redhat.com>
Reviewed-by: Juan Quintela <quintela@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Juan Quintela <quintela@redhat.com>
8 years agoblock-migration: small preparatory changes for locking
Paolo Bonzini [Fri, 22 Feb 2013 16:36:23 +0000 (17:36 +0100)] 
block-migration: small preparatory changes for locking

Some small changes that will simplify the positioning of lock/unlock
primitives.

Reviewed-by: Orit Wasserman <owasserm@redhat.com>
Reviewed-by: Juan Quintela <quintela@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Juan Quintela <quintela@redhat.com>
8 years agoblock-migration: remove variables that are never read
Paolo Bonzini [Fri, 22 Feb 2013 16:36:22 +0000 (17:36 +0100)] 
block-migration: remove variables that are never read

Reviewed-by: Orit Wasserman <owasserm@redhat.com>
Reviewed-by: Juan Quintela <quintela@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Juan Quintela <quintela@redhat.com>
8 years agomigration: cleanup migration (including thread) in the iothread
Paolo Bonzini [Fri, 22 Feb 2013 16:36:21 +0000 (17:36 +0100)] 
migration: cleanup migration (including thread) in the iothread

Perform final cleanup in a bottom half, and add joining the thread to
the series of cleanup actions.

migrate_fd_error remains for connection error, but it doesn't need
to cleanup anything anymore.

Reviewed-by: Orit Wasserman <owasserm@redhat.com>
Reviewed-by: Juan Quintela <quintela@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Juan Quintela <quintela@redhat.com>
8 years agomigration: prepare to access s->state outside critical sections
Paolo Bonzini [Fri, 22 Feb 2013 16:36:20 +0000 (17:36 +0100)] 
migration: prepare to access s->state outside critical sections

Accessing s->state outside the big QEMU lock will simplify a bit the
locking/unlocking of the iothread lock.

We need to keep the lock in migrate_fd_error and migrate_fd_completed,
however, because they call migrate_fd_cleanup.

Reviewed-by: Orit Wasserman <owasserm@redhat.com>
Reviewed-by: Juan Quintela <quintela@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Juan Quintela <quintela@redhat.com>
8 years agomigration: add migrate_set_state tracepoint
Kazuya Saito [Fri, 22 Feb 2013 16:36:19 +0000 (17:36 +0100)] 
migration: add migrate_set_state tracepoint

Signed-off-by: Kazuya Saito <saito.kazuya@jp.fujitsu.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Juan Quintela <quintela@redhat.com>
8 years agomigration: do not nest flushing of device data
Paolo Bonzini [Fri, 22 Feb 2013 16:36:18 +0000 (17:36 +0100)] 
migration: do not nest flushing of device data

Completion of migration is currently done with a "nested" loop that
invokes buffered_flush: migrate_fd_completed is called by
buffered_file_thread, which calls migrate_fd_cleanup, which calls
buffered_close (via qemu_fclose), which flushes the buffer.

Simplify this, by reusing the buffered_flush call of buffered_file_thread.
Then if qemu_savevm_state_complete was called, and the buffer is empty
(including the QEMUFile buffer, for which we need the previous patch), we
are done.

Reviewed-by: Orit Wasserman <owasserm@redhat.com>
Reviewed-by: Juan Quintela <quintela@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Juan Quintela <quintela@redhat.com>
8 years agomigration: simplify error handling
Paolo Bonzini [Fri, 22 Feb 2013 16:36:17 +0000 (17:36 +0100)] 
migration: simplify error handling

Always use qemu_file_get_error to detect errors, since that is how
QEMUFile itself drops I/O after an error occurs.  There is no need
to propagate and check return values all the time.

Also remove the "complete" member, since we know that it is set (via
migrate_fd_cleanup) only when the state changes.

Reviewed-by: Orit Wasserman <owasserm@redhat.com>
Reviewed-by: Juan Quintela <quintela@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Juan Quintela <quintela@redhat.com>
8 years agomigration: use qemu_file_set_error
Paolo Bonzini [Fri, 22 Feb 2013 16:36:16 +0000 (17:36 +0100)] 
migration: use qemu_file_set_error

Remove the return value of buffered_flush, pass it via the error code
of s->file.  Once this is done, the error can be retrieved simply
via migrate_fd_close's call to qemu_fclose.

Reviewed-by: Orit Wasserman <owasserm@redhat.com>
Reviewed-by: Juan Quintela <quintela@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Juan Quintela <quintela@redhat.com>
8 years agomigration: flush all data to fd when buffered_flush is called
Paolo Bonzini [Fri, 22 Feb 2013 16:36:15 +0000 (17:36 +0100)] 
migration: flush all data to fd when buffered_flush is called

Including data that resided in the QEMUFile's own buffer.

Reviewed-by: Orit Wasserman <owasserm@redhat.com>
Reviewed-by: Juan Quintela <quintela@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Juan Quintela <quintela@redhat.com>
8 years agoqemu-file: temporarily expose qemu_file_set_error and qemu_fflush
Paolo Bonzini [Fri, 22 Feb 2013 16:36:14 +0000 (17:36 +0100)] 
qemu-file: temporarily expose qemu_file_set_error and qemu_fflush

Right now, migration cannot entirely rely on QEMUFile's automatic
drop of I/O after an error, because it does its "real" I/O outside
the put_buffer callback.  To fix this until buffering is gone, expose
qemu_file_set_error which we will use in buffered_flush.

Similarly, buffered_flush is not a complete flush because some data may
still reside in the QEMUFile's own buffer.  This somewhat complicates the
process of closing the migration thread.  Again, when buffering is gone
buffered_flush will disappear and calling qemu_fflush will not be needed;
in the meanwhile, we expose the function for use in migration.c.

Reviewed-by: Orit Wasserman <owasserm@redhat.com>
Reviewed-by: Juan Quintela <quintela@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Juan Quintela <quintela@redhat.com>
8 years agomigration: use qemu_file_set_error to pass error codes back to qemu_savevm_state
Paolo Bonzini [Fri, 22 Feb 2013 16:36:13 +0000 (17:36 +0100)] 
migration: use qemu_file_set_error to pass error codes back to qemu_savevm_state

Reviewed-by: Orit Wasserman <owasserm@redhat.com>
Reviewed-by: Juan Quintela <quintela@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Juan Quintela <quintela@redhat.com>
8 years agoqemu-file: pass errno from qemu_fflush via f->last_error
Paolo Bonzini [Fri, 22 Feb 2013 16:36:12 +0000 (17:36 +0100)] 
qemu-file: pass errno from qemu_fflush via f->last_error

This is done by almost all callers of qemu_fflush, move the code
directly to qemu_fflush.

Reviewed-by: Orit Wasserman <owasserm@redhat.com>
Reviewed-by: Juan Quintela <quintela@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Juan Quintela <quintela@redhat.com>
8 years agoblock-migration: remove useless calls to blk_mig_cleanup
Paolo Bonzini [Fri, 22 Feb 2013 16:36:11 +0000 (17:36 +0100)] 
block-migration: remove useless calls to blk_mig_cleanup

Now that the cancel callback is called consistently for all errors,
we can avoid doing its work in the other callbacks.

Reviewed-by: Orit Wasserman <owasserm@redhat.com>
Reviewed-by: Juan Quintela <quintela@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Juan Quintela <quintela@redhat.com>
8 years agomigration: push qemu_savevm_state_cancel out of qemu_savevm_state_*
Paolo Bonzini [Fri, 22 Feb 2013 16:36:10 +0000 (17:36 +0100)] 
migration: push qemu_savevm_state_cancel out of qemu_savevm_state_*

This is useful, because it lets us keep the cancellation callbacks
inside the big lock while pushing the others out.

Reviewed-by: Orit Wasserman <owasserm@redhat.com>
Reviewed-by: Juan Quintela <quintela@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Juan Quintela <quintela@redhat.com>
8 years agomigration: move more error handling to migrate_fd_cleanup
Paolo Bonzini [Fri, 22 Feb 2013 16:36:09 +0000 (17:36 +0100)] 
migration: move more error handling to migrate_fd_cleanup

The next patch will add more cases where qemu_savevm_state_cancel
needs to be called; prepare for that already, the function can be
called twice with no ill effect.

Reviewed-by: Orit Wasserman <owasserm@redhat.com>
Reviewed-by: Juan Quintela <quintela@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Juan Quintela <quintela@redhat.com>
8 years agomigration: always use vm_stop_force_state
Paolo Bonzini [Fri, 22 Feb 2013 16:36:08 +0000 (17:36 +0100)] 
migration: always use vm_stop_force_state

vm_stop_force_state does:

    if (runstate_is_running()) {
        vm_stop(state);
    } else {
        runstate_set(state);
    }

migration.c does:

    if (runstate_is_running()) {
        vm_stop(state);
    } else {
        vm_stop_force_state(state);
    }

The code run is the same even if we always use vm_stop_force_state in
migration.c.

Reviewed-by: Orit Wasserman <owasserm@redhat.com>
Reviewed-by: Juan Quintela <quintela@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Juan Quintela <quintela@redhat.com>
8 years agomigration: simplify while loop
Paolo Bonzini [Fri, 22 Feb 2013 16:36:07 +0000 (17:36 +0100)] 
migration: simplify while loop

Unify the goto around the loop, with the exit condition at the end of it.
Both can be expressed as "while (ret >= 0)".

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Juan Quintela <quintela@redhat.com>
8 years agoMerge remote-tracking branch 'origin/master' into staging
Anthony Liguori [Mon, 11 Mar 2013 01:39:17 +0000 (20:39 -0500)] 
Merge remote-tracking branch 'origin/master' into staging

* origin/master: (75 commits)
  tcg: Don't make exitreq flag a local temporary
  Makefile: Add subdir dependency on config-devices-all.mak
  make_device_config.sh: Emit dependency file to directory where included
  Revert "make_device_config.sh: Fix target path in generated dependency file"
  s390/virtio-ccw: remove redundant call to blockdev_mark_auto_del
  s390/css: Fix subchannel detection
  Allow virtio-net features for legacy s390 virtio bus
  s390: virtio-ccw maintainer
  s390: simplify kvm cpu init
  pseries: Add compatible property to root of device tree
  target-ppc: Move CPU aliases out of translate_init.c
  target-ppc: Report CPU aliases for QMP
  target-ppc: List alias names alongside CPU models
  target-ppc: Make host CPU a subclass of the host's CPU model
  PPC: xnu kernel expects FLUSH to be cleared on STOP
  PPC: Fix dma interrupt
  target-ppc: Fix PPC_DUMP_SPR_ACCESS build
  target-ppc: Synchronize FPU state with KVM
  target-ppc: Add mechanism for synchronizing SPRs with KVM
  Save memory allocation in the elf loader
  ...

8 years agoMerge remote-tracking branch 'bonzini/hw-dirs' into staging
Anthony Liguori [Mon, 11 Mar 2013 00:39:07 +0000 (19:39 -0500)] 
Merge remote-tracking branch 'bonzini/hw-dirs' into staging

* bonzini/hw-dirs:
  sh: move files referencing CPU to hw/sh4/
  ppc: move more files to hw/ppc
  ppc: move files referencing CPU to hw/ppc/
  m68k: move files referencing CPU to hw/m68k/
  i386: move files referencing CPU to hw/i386/
  arm: move files referencing CPU to hw/arm/
  hw: move boards and other isolated files to hw/ARCH
  ppc: express FDT dependency of pSeries and e500 boards via default-configs/
  build: always link device_tree.o into emulators if libfdt available
  hw: include hw header files with full paths
  ppc: do not use ../ in include files
  vt82c686: vt82c686 is not a PCI host bridge
  virtio-9p: remove PCI dependencies from hw/9pfs/
  virtio-9p: use CONFIG_VIRTFS, not CONFIG_LINUX
  hw: move device-hotplug.o to toplevel, compile it once
  hw: move qdev-monitor.o to toplevel directory
  hw: move fifo.[ch] to libqemuutil
  hw: move char backends to backends/

Conflicts:
backends/baum.c
backends/msmouse.c
hw/a15mpcore.c
hw/arm/Makefile.objs
hw/arm/pic_cpu.c
hw/dataplane/event-poll.c
hw/dataplane/virtio-blk.c
include/char/baum.h
include/char/msmouse.h
qemu-char.c
vl.c

Resolve conflicts caused by header movements.

Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
8 years agoMerge remote-tracking branch 'stefanha/trivial-patches' into staging
Anthony Liguori [Mon, 11 Mar 2013 00:33:03 +0000 (19:33 -0500)] 
Merge remote-tracking branch 'stefanha/trivial-patches' into staging

# By Lei Li (2) and others
# Via Stefan Hajnoczi
* stefanha/trivial-patches:
  Fix the wrong description in qemu manual
  pci_host: Drop write-only address_space field
  rng-random: Use qemu_open / qemu_close
  configure: Require at least spice-protocol-0.12.3
  osdep: replace setsockopt by qemu_setsockopt
  lm32: remove unused function
  rtc-test: Fix test failures with recent glib
  configure: Create link to icon bitmap for out-of-tree builds

8 years agoMerge remote-tracking branch 'bonzini/scsi-next' into staging
Anthony Liguori [Mon, 11 Mar 2013 00:30:45 +0000 (19:30 -0500)] 
Merge remote-tracking branch 'bonzini/scsi-next' into staging

# By Paolo Bonzini (4) and Peter Lieven (2)
# Via Paolo Bonzini
* bonzini/scsi-next:
  scsi-disk: handle io_canceled uniformly and correctly
  scsi-disk: do not complete canceled UNMAP requests
  scsi: do not call scsi_read_data/scsi_write_data for a canceled request
  iscsi: look for pkg-config file too
  iscsi: add iscsi_truncate support
  iscsi: retry read, write, flush and unmap on unit attention check conditions

8 years agoqemu-char: fix win32 build
Blue Swirl [Sat, 9 Mar 2013 09:56:04 +0000 (09:56 +0000)] 
qemu-char: fix win32 build

96c6384776d631839a9c8fe02bf135f9ba22586c did not adjust
Win32 #ifdeffery properly, breaking build in later commits. Fix.

Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
Tested-by: Igor Mitsyanko <i.mitsyanko@gmail.com>
Message-id: 0ba5565b1ed44380c57d4a5fab86e9549f581ebf.1362822910.git.blauwirbel@gmail.com
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
8 years agobaum: fix build
Blue Swirl [Sat, 9 Mar 2013 09:56:03 +0000 (09:56 +0000)] 
baum: fix build

08744c98115cfa144ed3493556024e400b2e2573 removed hw/baum.h
but did not adjust hw/baum.c, breaking build. Fix.

Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
Message-id: c50406bda98f8b277e8b9004a0012fa5e5c124d0.1362822910.git.blauwirbel@gmail.com
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
8 years agotcg: Don't make exitreq flag a local temporary
Richard Henderson [Tue, 5 Mar 2013 16:54:41 +0000 (08:54 -0800)] 
tcg: Don't make exitreq flag a local temporary

The value is not actually live across basic blocks, so there's no
need for the local property.  This eliminates storing the temporary
to its home location at the branch.

Signed-off-by: Richard Henderson <rth@twiddle.net>
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
8 years agoMakefile: Add subdir dependency on config-devices-all.mak
Andreas Färber [Thu, 21 Feb 2013 15:26:47 +0000 (16:26 +0100)] 
Makefile: Add subdir dependency on config-devices-all.mak

What 23bf49b5eca716aaad073f2b47613434e1515cb5 really seemed to try to
fix is that Makefile could recurse into *-softmmu/ subdirectories before
a new *-softmmu/config-devices.mak was generated from pci.mak.

Fix this by adding a dependency on config-all-devices.mak, which in turn
has dependencies on *-softmmu/config-devices.mak.

Reported-by: Gerhard Wiesinger <lists@wiesinger.com>
Signed-off-by: Andreas Färber <afaerber@suse.de>
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
8 years agomake_device_config.sh: Emit dependency file to directory where included
Andreas Färber [Thu, 21 Feb 2013 15:26:46 +0000 (16:26 +0100)] 
make_device_config.sh: Emit dependency file to directory where included

Placing the config-devices.mak.d file alongside the config-devices.mak
file in *-softmmu/ lead to it getting included into through
*-softmmu/Makefile in addition to ./Makefile, leading to confusion.

Instead, emit it to ./%-config-devices.mak.d, where it is included.

Signed-off-by: Andreas Färber <afaerber@suse.de>
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
8 years agoRevert "make_device_config.sh: Fix target path in generated dependency file"
Andreas Färber [Thu, 21 Feb 2013 15:26:45 +0000 (16:26 +0100)] 
Revert "make_device_config.sh: Fix target path in generated dependency file"

This reverts commit 23bf49b5eca716aaad073f2b47613434e1515cb5.

While *-softmmu/config-devices.mak.d is included through *.d pattern via
Makefile.target, the make_devices_config.sh call these dependencies are
for is in ./Makefile. Therefore revert to original behavior.

This should unbreak pci.mak dependencies not propagating.

Reported-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Andreas Färber <afaerber@suse.de>
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
8 years agoMerge branch 's390-for-upstream' of git://github.com/agraf/qemu
Blue Swirl [Sat, 9 Mar 2013 11:02:23 +0000 (11:02 +0000)] 
Merge branch 's390-for-upstream' of git://github.com/agraf/qemu

* 's390-for-upstream' of git://github.com/agraf/qemu:
  s390/virtio-ccw: remove redundant call to blockdev_mark_auto_del
  s390/css: Fix subchannel detection
  Allow virtio-net features for legacy s390 virtio bus
  s390: virtio-ccw maintainer
  s390: simplify kvm cpu init

8 years agoMerge branch 'ppc-for-upstream' of git://github.com/agraf/qemu
Blue Swirl [Sat, 9 Mar 2013 11:02:07 +0000 (11:02 +0000)] 
Merge branch 'ppc-for-upstream' of git://github.com/agraf/qemu

* 'ppc-for-upstream' of git://github.com/agraf/qemu: (66 commits)
  pseries: Add compatible property to root of device tree
  target-ppc: Move CPU aliases out of translate_init.c
  target-ppc: Report CPU aliases for QMP
  target-ppc: List alias names alongside CPU models
  target-ppc: Make host CPU a subclass of the host's CPU model
  PPC: xnu kernel expects FLUSH to be cleared on STOP
  PPC: Fix dma interrupt
  target-ppc: Fix PPC_DUMP_SPR_ACCESS build
  target-ppc: Synchronize FPU state with KVM
  target-ppc: Add mechanism for synchronizing SPRs with KVM
  Save memory allocation in the elf loader
  pseries: Implement h_read hcall
  target-ppc: Change "POWER7" CPU alias
  target-ppc: Fix remaining microcontroller typos among models
  target-ppc: Split model definitions out of translate_init.c
  target-ppc: Update Coding Style for CPU models
  target-ppc: Turn descriptive CPU model comments into device descriptions
  target-ppc: Turn descriptive CPU family comments into device descriptions
  target-ppc: Set remaining fields on CPU family classes
  target-ppc: Register all types for TARGET_PPCEMB
  ...

8 years agos390/virtio-ccw: remove redundant call to blockdev_mark_auto_del
Christian Borntraeger [Fri, 22 Feb 2013 09:01:33 +0000 (09:01 +0000)] 
s390/virtio-ccw: remove redundant call to blockdev_mark_auto_del

blockdev_mark_auto_del is already called in virtio-blk-exit.
Remove the redundant call.

Signed-off-by: Christian Borntraeger <borntraeger@de.ibm.com>
Signed-off-by: Jens Freimann <jfrei@linux.vnet.ibm.com>
Signed-off-by: Alexander Graf <agraf@suse.de>
8 years agos390/css: Fix subchannel detection
Christian Borntraeger [Fri, 22 Feb 2013 09:01:32 +0000 (09:01 +0000)] 
s390/css: Fix subchannel detection

We have to consider the m bit to find the real channel subsystem when
determining the last subchannel.

If we fail to take this into account, removal of a subchannel in
the middle of a big list of devices will stop device detection after
a reboot.

Signed-off-by: Christian Borntraeger <borntraeger@de.ibm.com>
Signed-off-by: Jens Freimann <jfrei@linux.vnet.ibm.com>
Reviewed-by: Cornelia Huck <cornelia.huck@de.ibm.com>
Signed-off-by: Alexander Graf <agraf@suse.de>
8 years agoAllow virtio-net features for legacy s390 virtio bus
Christian Borntraeger [Thu, 7 Mar 2013 16:21:41 +0000 (17:21 +0100)] 
Allow virtio-net features for legacy s390 virtio bus

Enable all virtio-net features for the legacy s390 virtio bus. This also fixes
kernel BUG at /usr/src/packages/BUILD/kernel-default-3.0.58/linux-3.0/drivers/s390/kvm/kvm_virtio.c:121!

Signed-off-by: Christian Borntraeger <borntraeger@de.ibm.com>
Cc: qemu-stable@nongnu.org
Signed-off-by: Alexander Graf <agraf@suse.de>
8 years agos390: virtio-ccw maintainer
Cornelia Huck [Tue, 5 Mar 2013 02:22:01 +0000 (02:22 +0000)] 
s390: virtio-ccw maintainer

Add myself as maintainer for virtio-ccw and the s390-ccw-virtio machine.

Signed-off-by: Cornelia Huck <cornelia.huck@de.ibm.com>
[agraf: add myself for virtio-ccw machine]
Signed-off-by: Alexander Graf <agraf@suse.de>
8 years agos390: simplify kvm cpu init
Christian Borntraeger [Mon, 4 Feb 2013 22:53:25 +0000 (22:53 +0000)] 
s390: simplify kvm cpu init

There is no special code right now and the reset ioctl is done later
on in the the reset handler anyway. Lets simplify the cpu init.

Signed-off-by: Christian Borntraeger <borntraeger@de.ibm.com>
Signed-off-by: Alexander Graf <agraf@suse.de>
8 years agopseries: Add compatible property to root of device tree
David Gibson [Mon, 25 Feb 2013 19:27:12 +0000 (19:27 +0000)] 
pseries: Add compatible property to root of device tree

Currently, for the pseries machine the device tree supplied by qemu to SLOF
and from there to the guest does not include a 'compatible property' at the
root level.  Usually that works fine, since in this case the compatible
property doesn't really give any information not already found in the
'device_type' or 'model' properties.

However, the lack of 'compatible' confuses the bootloader install in the
SLES11 SP2 and SLES11 SP3 installers.  This patch therefore adds a token
'compatible' property to work around that.

Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
Cc: qemu-stable@nongnu.org
Signed-off-by: Alexander Graf <agraf@suse.de>
8 years agotarget-ppc: Move CPU aliases out of translate_init.c
Andreas Färber [Mon, 25 Feb 2013 03:43:17 +0000 (03:43 +0000)] 
target-ppc: Move CPU aliases out of translate_init.c

Move array of CPU aliases to cpu-models.c, alongside model definitions.
This requires to zero-terminate the aliases array since ARRAY_SIZE() can
no longer be used in translate_init.c then.

Suggested-by: Alexander Graf <agraf@suse.de>
Signed-off-by: Andreas Färber <afaerber@suse.de>
Signed-off-by: Alexander Graf <agraf@suse.de>
8 years agotarget-ppc: Report CPU aliases for QMP
Andreas Färber [Sat, 23 Feb 2013 07:52:24 +0000 (07:52 +0000)] 
target-ppc: Report CPU aliases for QMP

The QMP query-cpu-definitions implementation iterated over CPU classes
only, which were getting less and less as aliases were extracted.

Keep them in QMP as valid -cpu arguments even if not guaranteed stable.

Signed-off-by: Andreas Färber <afaerber@suse.de>
Signed-off-by: Alexander Graf <agraf@suse.de>
8 years agotarget-ppc: List alias names alongside CPU models
Andreas Färber [Sat, 23 Feb 2013 07:34:28 +0000 (07:34 +0000)] 
target-ppc: List alias names alongside CPU models

Revert adding a separate -cpu ? output section for aliases and list them
per CPU subclass.

Requested-by: Alexander Graf <agraf@suse.de>
Signed-off-by: Andreas Färber <afaerber@suse.de>
Signed-off-by: Alexander Graf <agraf@suse.de>
8 years agotarget-ppc: Make host CPU a subclass of the host's CPU model
Andreas Färber [Sat, 23 Feb 2013 11:22:12 +0000 (11:22 +0000)] 
target-ppc: Make host CPU a subclass of the host's CPU model

This avoids assigning individual class fields and contributors
forgetting to add field assignments in KVM-only code.

ppc_cpu_class_find_by_pvr() requires the CPU model classes to be
registered, so defer host CPU type registration to kvm_arch_init().

Only register the host CPU type if there is a class with matching PVR.
This lets us drop error handling from instance_init.

Signed-off-by: Andreas Färber <afaerber@suse.de>
Signed-off-by: Alexander Graf <agraf@suse.de>
8 years agoPPC: xnu kernel expects FLUSH to be cleared on STOP
Amadeusz Sławiński [Thu, 21 Feb 2013 07:34:11 +0000 (07:34 +0000)] 
PPC: xnu kernel expects FLUSH to be cleared on STOP

otherwise it gets stuck in a loop
so clear it when unsetting run when flush is set

void
IODBDMAStop( volatile IODBDMAChannelRegisters *registers)
{

IOSetDBDMAChannelControl( registers,
IOClearDBDMAChannelControlBits( kdbdmaRun )
| IOSetDBDMAChannelControlBits(  kdbdmaFlush ));

DBDMA: writel 0x0000000000000b00 <= 0xa0002000
DBDMA: channel 0x16 reg 0x0
DBDMA:     status 0x00002000

while( IOGetDBDMAChannelStatus( registers) & (
kdbdmaActive | kdbdmaFlush))
eieio();

DBDMA: readl 0x0000000000000b04 => 0x00002000
DBDMA: channel 0x16 reg 0x1
DBDMA: readl 0x0000000000000b04 => 0x00002000
DBDMA: channel 0x16 reg 0x1
DBDMA: readl 0x0000000000000b04 => 0x00002000
DBDMA: channel 0x16 reg 0x1
DBDMA: readl 0x0000000000000b04 => 0x00002000
DBDMA: channel 0x16 reg 0x1
it continues to get printed

}

Signed-off-by: Amadeusz Sławiński <amade@asmblr.net>
[agraf: replace tabs with spaces]
Signed-off-by: Alexander Graf <agraf@suse.de>
8 years agoPPC: Fix dma interrupt
Amadeusz Sławiński [Thu, 21 Feb 2013 07:34:10 +0000 (07:34 +0000)] 
PPC: Fix dma interrupt

In openbios (drivers/ide.c) they are set to

0000000d 00000000 00000002 00000000
0000000e 00000000 00000003 00000000
0000000f 00000000 00000004 00000000
(The last one seems to be not implemented in qemu)

It follows convention of how they are set on real machines,
both ide and dma ones are increased

Real machine one:
http://web.archive.org/web/20090107151044/http://penguinppc.org/historical/dev-trees-html/g4_agp_500_2.html
00000013 00000001 0000000b 00000000
00000014 00000001 0000000c 00000000
00000015 00000001 0000000d 00000000

Signed-off-by: Amadeusz Sławiński <amade@asmblr.net>
Signed-off-by: Alexander Graf <agraf@suse.de>
8 years agotarget-ppc: Fix PPC_DUMP_SPR_ACCESS build
Andreas Färber [Wed, 20 Feb 2013 18:24:57 +0000 (18:24 +0000)] 
target-ppc: Fix PPC_DUMP_SPR_ACCESS build

A victim of the d523dd00a7d73b28f2e99acf45a4b3f92e56e40a AREG0
conversion, insert the missing cpu_env arguments.

Signed-off-by: Andreas Färber <afaerber@suse.de>
Signed-off-by: Alexander Graf <agraf@suse.de>
8 years agotarget-ppc: Synchronize FPU state with KVM
David Gibson [Wed, 20 Feb 2013 16:41:51 +0000 (16:41 +0000)] 
target-ppc: Synchronize FPU state with KVM

Currently qemu does not get and put the state of the floating point and
vector registers to KVM.  This is obviously a problem for savevm, as well
as possibly being problematic for debugging of FP-using guests.

This patch fixes this by using new extensions to the ONE_REG interface to
synchronize the qemu floating point state with KVM.

Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
Signed-off-by: Alexander Graf <agraf@suse.de>
8 years agotarget-ppc: Add mechanism for synchronizing SPRs with KVM
David Gibson [Wed, 20 Feb 2013 16:41:50 +0000 (16:41 +0000)] 
target-ppc: Add mechanism for synchronizing SPRs with KVM

Currently when runing under KVM on ppc, we synchronize a certain number of
vital SPRs to KVM through the SET_SREGS call.  This leaves out quite a lot
of important SPRs which are maintained in KVM.  It would be helpful to
have their contents in qemu for debugging purposes, and when we implement
migration it will be vital, since they include important guest state that
will need to be restored on the target.

This patch sets up for synchronization of any registers supported by the
KVM ONE_REG calls.  A new variant on spr_register() allows a ONE_REG id to
be stored with the SPR information.  When we set/get information to KVM
we also synchronize any SPRs so registered.

For now we set this mechanism up to synchronize a handful of important
registers that already have ONE_REG IDs, notably the DAR and DSISR.

Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
Signed-off-by: Alexander Graf <agraf@suse.de>
8 years agoSave memory allocation in the elf loader
Fabien Chouteau [Tue, 19 Feb 2013 04:41:11 +0000 (04:41 +0000)] 
Save memory allocation in the elf loader

The current elf loader uses too much memory. For example, I have a
executable with a bss section of 400 MB and I set the ram size to 512
MB. Qemu uses about 780MB of RAM (which is fine), but there's a peak at
1.6 GB during initialization (this is not fine).

This patch fixes two things:
 1) do not allocate each elf program twice.
 2) do not allocate memory for areas that are only zeros.

For this we need a new field in Rom: "datasize" which is the size of the
allocated data. If datasize is less than romsize, it means that the area
from datasize to romsize is filled with zeros.

Signed-off-by: Fabien Chouteau <chouteau@adacore.com>
Signed-off-by: Alexander Graf <agraf@suse.de>
8 years agopseries: Implement h_read hcall
Erlon Cruz [Mon, 18 Feb 2013 05:00:32 +0000 (05:00 +0000)] 
pseries: Implement h_read hcall

This h_call is useful for DLPAR in future amongst other things. Given an index
it fetches the corresponding PTE stored in the htab.

Signed-off-by: Erlon Cruz <erlon.cruz@br.flextronics.com>
Acked-by: David Gibson <david@gibson.dropbear.id.au>
Signed-off-by: Alexander Graf <agraf@suse.de>
8 years agotarget-ppc: Change "POWER7" CPU alias
Andreas Färber [Sun, 17 Feb 2013 23:16:51 +0000 (23:16 +0000)] 
target-ppc: Change "POWER7" CPU alias

Let it resolve to v2.3 rather than v2.0.

Suggested-by: David Gibson <david@gibson.dropbear.id.au>
Signed-off-by: Andreas Färber <afaerber@suse.de>
Signed-off-by: Alexander Graf <agraf@suse.de>
8 years agotarget-ppc: Fix remaining microcontroller typos among models
Andreas Färber [Sun, 17 Feb 2013 23:16:50 +0000 (23:16 +0000)] 
target-ppc: Fix remaining microcontroller typos among models

controler -> controller

Signed-off-by: Andreas Färber <afaerber@suse.de>
Signed-off-by: Alexander Graf <agraf@suse.de>
8 years agotarget-ppc: Split model definitions out of translate_init.c
Andreas Färber [Sun, 17 Feb 2013 23:16:49 +0000 (23:16 +0000)] 
target-ppc: Split model definitions out of translate_init.c

Now that model definitions only reference their parent type, model
definitions are independent of the family definitions and can be
compiled independently of TCG translation.

Keep all #if defined(TODO) code local to cpu-models.c.

Signed-off-by: Andreas Färber <afaerber@suse.de>
Signed-off-by: Alexander Graf <agraf@suse.de>
8 years agotarget-ppc: Update Coding Style for CPU models
Andreas Färber [Sun, 17 Feb 2013 23:16:48 +0000 (23:16 +0000)] 
target-ppc: Update Coding Style for CPU models

Drop the space in #if defined (TODO).

Signed-off-by: Andreas Färber <afaerber@suse.de>
Signed-off-by: Alexander Graf <agraf@suse.de>
8 years agotarget-ppc: Turn descriptive CPU model comments into device descriptions
Andreas Färber [Sun, 17 Feb 2013 23:16:47 +0000 (23:16 +0000)] 
target-ppc: Turn descriptive CPU model comments into device descriptions

Fix microcontroller typo while at it.

Signed-off-by: Andreas Färber <afaerber@suse.de>
Signed-off-by: Alexander Graf <agraf@suse.de>
8 years agotarget-ppc: Turn descriptive CPU family comments into device descriptions
Andreas Färber [Sun, 17 Feb 2013 23:16:46 +0000 (23:16 +0000)] 
target-ppc: Turn descriptive CPU family comments into device descriptions

This gets rid of some more overly long comments that have lost most of
their purpose now that in most cases there's only two functions left per
CPU family.

The class field is inherited by the actual CPU models, so override it.

Signed-off-by: Andreas Färber <afaerber@suse.de>
Signed-off-by: Alexander Graf <agraf@suse.de>
8 years agotarget-ppc: Set remaining fields on CPU family classes
Andreas Färber [Sun, 17 Feb 2013 23:16:45 +0000 (23:16 +0000)] 
target-ppc: Set remaining fields on CPU family classes

Now POWERPC_DEF_SVR() no longer sets family-specific fields itself.

Signed-off-by: Andreas Färber <afaerber@suse.de>
Signed-off-by: Alexander Graf <agraf@suse.de>
8 years agotarget-ppc: Register all types for TARGET_PPCEMB
Andreas Färber [Sun, 17 Feb 2013 23:16:44 +0000 (23:16 +0000)] 
target-ppc: Register all types for TARGET_PPCEMB

Don't attempt to suppress registration of CPU types, since the criteria
is actually a property of the class and should thus become a field.
Since we can't check a field set in a class_init function before
registering the type that leads to execution of that function, guard the
-cpu class lookup instead and suppress exposing these classes in -cpu ?
and in QMP.

In case someone tries to hot-add an incompatible CPU via device_add,
error out in realize.

Signed-off-by: Andreas Färber <afaerber@suse.de>
Signed-off-by: Alexander Graf <agraf@suse.de>
8 years agotarget-ppc: Set instruction flags on CPU family classes
Andreas Färber [Sun, 17 Feb 2013 23:16:43 +0000 (23:16 +0000)] 
target-ppc: Set instruction flags on CPU family classes

Signed-off-by: Andreas Färber <afaerber@suse.de>
Signed-off-by: Alexander Graf <agraf@suse.de>
8 years agotarget-ppc: Introduce abstract CPU family types
Andreas Färber [Sun, 17 Feb 2013 23:16:42 +0000 (23:16 +0000)] 
target-ppc: Introduce abstract CPU family types

Instead of assigning *_<family> constants, set .parent to a family type.

Introduce a POWERPC_FAMILY() macro to keep type registration close to
its implementation. This macro will need tweaking later.

Signed-off-by: Andreas Färber <afaerber@suse.de>
Signed-off-by: Alexander Graf <agraf@suse.de>
8 years agotarget-ppc: Convert CPU definitions
Andreas Färber [Sun, 17 Feb 2013 23:16:41 +0000 (23:16 +0000)] 
target-ppc: Convert CPU definitions

Turn the array of model definitions into a set of self-registering QOM
types with their own class_init. Unique identifiers are obtained from
the combination of PVR, SVR and family identifiers; this requires all
alias #defines to be removed from the list. Possibly there are some more
left after this commit that are not currently being compiled.

Prepares for introducing abstract intermediate CPU types for families.

Keep the right-aligned macro line breaks within 78 chars to aid
three-way merges.

Signed-off-by: Andreas Färber <afaerber@suse.de>
Signed-off-by: Alexander Graf <agraf@suse.de>