Commit Graph

194 Commits

Author SHA1 Message Date
Peter Lieven 211ea74022 migration: do not overwrite zero pages
on incoming migration do not memset pages to zero if they already read as zero.
this will allocate a new zero page and consume memory unnecessarily. even
if we madvise a MADV_DONTNEED later this will only deallocate the memory
asynchronously.

Signed-off-by: Peter Lieven <pl@kamp.de>
Signed-off-by: Juan Quintela <quintela@redhat.com>
2013-06-27 02:36:32 +02:00
Peter Lieven 9ef051e553 Revert "migration: do not sent zero pages in bulk stage"
Not sending zero pages breaks migration if a page is zero
at the source but not at the destination. This can e.g. happen
if different BIOS versions are used at source and destination.
It has also been reported that migration on pseries is completely
broken with this patch.

This effectively reverts commit f1c72795af.

Conflicts:

	arch_init.c

Signed-off-by: Peter Lieven <pl@kamp.de>
Signed-off-by: Juan Quintela <quintela@redhat.com>
2013-06-27 02:36:32 +02:00
Alon Levy 87d2f82543 arch_init/ram_load: add error message for block length mismatch
Makes it easier to debug situations where the source and target have
different ram blocks in a device and migration fails due to that, for
instance a BAR size change on a PCI device.

Signed-off-by: Alon Levy <alevy@redhat.com>
Signed-off-by: Juan Quintela <quintela@redhat.com>
2013-06-27 02:32:15 +02:00
Anthony Liguori 38aea177d9 Merge remote-tracking branch 'pmaydell/configury.next' into staging
# By Paolo Bonzini (4) and others
# Via Peter Maydell
* pmaydell/configury.next:
  ppc: Remove CONFIG_FDT conditionals
  microblaze: Remove CONFIG_FDT conditionals
  arm: Remove CONFIG_FDT conditionals
  configure: Require libfdt for arm, ppc, microblaze softmmu targets
  configure: dtc: Probe for libfdt_env.h
  build: drop TARGET_TYPE
  main: use TARGET_ARCH only for the target-specific #define
  build: do not use TARGET_ARCH
  build: rename TARGET_ARCH2 to TARGET_NAME
  Add a stp file for usage from build directory

Message-id: 1371221594-11556-1-git-send-email-peter.maydell@linaro.org
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2013-06-17 08:57:57 -05:00
Paolo Bonzini c02a9552a4 build: drop TARGET_TYPE
Just use the TARGET_NAME free string.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Message-id: 1370349928-20419-6-git-send-email-pbonzini@redhat.com
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
2013-06-14 15:33:12 +01:00
Paolo Bonzini 2e59915d43 main: use TARGET_ARCH only for the target-specific #define
Everything else needs to match the executable name, which is
TARGET_NAME.

Before:
    $ sh4eb-linux-user/qemu-sh4eb --help
    usage: qemu-sh4 [options] program [arguments...]
    Linux CPU emulator (compiled for sh4 emulation)

After:
    $ sh4eb-linux-user/qemu-sh4eb --help
    usage: qemu-sh4eb [options] program [arguments...]
    Linux CPU emulator (compiled for sh4eb emulation)

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Message-id: 1370349928-20419-5-git-send-email-pbonzini@redhat.com
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
2013-06-14 15:33:11 +01:00
Markus Armbruster ebc85e3f72 smbios: Clean up smbios_add_field() parameters
Having size precede the associated pointer is odd.  Swap them, and fix
up the types.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Laszlo "ever the optimist" Ersek <lersek@redhat.com>
Message-id: 1370610036-10577-5-git-send-email-armbru@redhat.com
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2013-06-14 08:58:57 -05:00
Markus Armbruster 5bb95e4186 smbios: Convert to error_report()
Improves diagnistics from ad hoc messages like

    Invalid SMBIOS UUID string

to

    qemu-system-x86_64: -smbios type=1,uuid=gaga: Invalid UUID

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Laszlo "ever the optimist" Ersek <lersek@redhat.com>
Message-id: 1370610036-10577-4-git-send-email-armbru@redhat.com
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2013-06-14 08:58:57 -05:00
Paolo Bonzini 1d671369c3 memory: make memory_global_sync_dirty_bitmap take an AddressSpace
Since this is a MemoryListener operation, it only makes sense
on an AddressSpace granularity.

Suggested-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2013-05-24 18:42:51 +02:00
Paolo Bonzini f81222bc0c audio: look for the ISA and PCI buses
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Message-id: 1366303444-24620-8-git-send-email-pbonzini@redhat.com
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2013-04-29 12:16:57 -05:00
Paolo Bonzini ffa48cf5ab audio: remove HAS_AUDIO
Several targets can have wavcapture/-soundhw support via PCI cards.
HAS_AUDIO is a useless limitation, remove it.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Message-id: 1366303444-24620-4-git-send-email-pbonzini@redhat.com
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2013-04-29 12:16:36 -05:00
Paolo Bonzini 36cd6f6f20 audio: remove the need for audio card CONFIG_* symbols
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Message-id: 1366303444-24620-3-git-send-email-pbonzini@redhat.com
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2013-04-29 12:16:36 -05:00
Paolo Bonzini 0bc3cd624f include: avoid useless includes of exec/ headers
Headers in include/exec/ are for the deepest innards of QEMU,
they should almost never be included directly.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2013-04-15 18:19:26 +02:00
Michael S. Tsirkin 0445259ba6 acpi: move declarations from pc.h to acpi.h
Functions defined in acpi/ should be declared in
acpi.h

Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2013-04-15 15:16:34 +02:00
Paolo Bonzini 0d09e41a51 hw: move headers to include/
Many of these should be cleaned up with proper qdev-/QOM-ification.
Right now there are many catch-all headers in include/hw/ARCH depending
on cpu.h, and this makes it necessary to compile these files per-target.
However, fixing this does not belong in these patches.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2013-04-08 18:13:10 +02:00
Laszlo Ersek 23084327dc like acpi_table_install(), acpi_table_add() should propagate Errors
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
Reviewed-by: Anthony Liguori <aliguori@us.ibm.com>
Message-id: 1363821803-3380-8-git-send-email-lersek@redhat.com
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2013-04-04 19:23:08 -05:00
Laszlo Ersek 0c764a9dfc acpi_table_add(): accept QemuOpts and parse it with OptsVisitor
As one consequence, strtok() -- which modifies its argument -- is replaced
with g_strsplit().

Signed-off-by: Laszlo Ersek <lersek@redhat.com>
Reviewed-by: Anthony Liguori <aliguori@us.ibm.com>
Message-id: 1363821803-3380-6-git-send-email-lersek@redhat.com
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2013-04-04 19:23:08 -05:00
Laszlo Ersek 4d8b3c6302 strip some whitespace
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
Reviewed-by: Anthony Liguori <aliguori@us.ibm.com>
Message-id: 1363821803-3380-2-git-send-email-lersek@redhat.com
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2013-04-04 19:23:08 -05:00
Orit Wasserman 500f0061d6 Use qemu_put_buffer_async for guest memory pages
This will remove an unneeded copy of guest memory pages.
For the page header and device state we still copy the data to the
static buffer the other option is to allocate the memory on demand
which is more expensive.

Signed-off-by: Orit Wasserman <owasserm@redhat.com>
Signed-off-by: Juan Quintela <quintela@redhat.com>
2013-03-26 13:32:33 +01:00
Peter Lieven 5cc11c46cf migration: use XBZRLE only after bulk stage
at the beginning of migration all pages are marked dirty and
in the first round a bulk migration of all pages is performed.

currently all these pages are copied to the page cache regardless
of whether they are frequently updated or not. this doesn't make sense
since most of these pages are never transferred again.

this patch changes the XBZRLE transfer to only be used after
the bulk stage has been completed. that means a page is added
to the page cache the second time it is transferred and XBZRLE
can benefit from the third time of transfer.

since the page cache is likely smaller than the number of pages
it's also likely that in the second round the page is missing in the
cache due to collisions in the bulk phase.

on the other hand a lot of unnecessary mallocs, memdups and frees
are saved.

the following results have been taken earlier while executing
the test program from docs/xbzrle.txt. (+) with the patch and (-)
without. (thanks to Eric Blake for reformatting and comments)

+ total time: 22185 milliseconds
- total time: 22410 milliseconds

Shaved 0.3 seconds, better than 1%!

+ downtime: 29 milliseconds
- downtime: 21 milliseconds

Not sure why downtime seemed worse, but probably not the end of the world.

+ transferred ram: 706034 kbytes
- transferred ram: 721318 kbytes

Fewer bytes sent - good.

+ remaining ram: 0 kbytes
- remaining ram: 0 kbytes
+ total ram: 1057216 kbytes
- total ram: 1057216 kbytes
+ duplicate: 108556 pages
- duplicate: 105553 pages
+ normal: 175146 pages
- normal: 179589 pages
+ normal bytes: 700584 kbytes
- normal bytes: 718356 kbytes

Fewer normal bytes...

+ cache size: 67108864 bytes
- cache size: 67108864 bytes
+ xbzrle transferred: 3127 kbytes
- xbzrle transferred: 630 kbytes

...and more compressed pages sent - good.

+ xbzrle pages: 117811 pages
- xbzrle pages: 21527 pages
+ xbzrle cache miss: 18750
- xbzrle cache miss: 179589

And very good improvement on the cache miss rate.

+ xbzrle overflow : 0
- xbzrle overflow : 0

Signed-off-by: Peter Lieven <pl@kamp.de>
Reviewed-by: Eric Blake <eblake@redhat.com>
Reviewed-by: Orit Wasserman <owasserm@redhat.com>
Signed-off-by: Juan Quintela <quintela@redhat.com>
2013-03-26 13:32:33 +01:00
Peter Lieven 70c8652bf3 migration: do not search dirty pages in bulk stage
avoid searching for dirty pages just increment the
page offset. all pages are dirty anyway.

Signed-off-by: Peter Lieven <pl@kamp.de>
Reviewed-by: Eric Blake <eblake@redhat.com>
Reviewed-by: Orit Wasserman <owasserm@redhat.com>
Signed-off-by: Juan Quintela <quintela@redhat.com>
2013-03-26 13:32:33 +01:00
Peter Lieven f1c72795af migration: do not sent zero pages in bulk stage
during bulk stage of ram migration if a page is a
zero page do not send it at all.
the memory at the destination reads as zero anyway.

even if there is an madvise with QEMU_MADV_DONTNEED
at the target upon receipt of a zero page I have observed
that the target starts swapping if the memory is overcommitted.
it seems that the pages are dropped asynchronously.

this patch also updates QMP to return the number of
skipped pages in MigrationStats.

Signed-off-by: Peter Lieven <pl@kamp.de>
Reviewed-by: Eric Blake <eblake@redhat.com>
Signed-off-by: Juan Quintela <quintela@redhat.com>
2013-03-26 13:32:33 +01:00
Peter Lieven 78d07ae7ac migration: add an indicator for bulk state of ram migration
the first round of ram transfer is special since all pages
are dirty and thus all memory pages are transferred to
the target. this patch adds a boolean variable to track
this stage.

Signed-off-by: Peter Lieven <pl@kamp.de>
Reviewed-by: Eric Blake <eblake@redhat.com>
Reviewed-by: Orit Wasserman <owasserm@redhat.com>
Signed-off-by: Juan Quintela <quintela@redhat.com>
2013-03-26 13:32:32 +01:00
Peter Lieven 3edcd7e6eb migration: search for zero instead of dup pages
virtually all dup pages are zero pages. remove
the special is_dup_page() function and use the
optimized buffer_find_nonzero_offset() function
instead.

here buffer_find_nonzero_offset() is used directly
to avoid the unnecssary additional checks in
buffer_is_zero().

raw performace gain checking 1 GByte zeroed memory
over is_dup_page() is approx. 10-12% with SSE2
and 8-10% with unsigned long arithmedtic.

Signed-off-by: Peter Lieven <pl@kamp.de>
Reviewed-by: Orit Wasserman <owasserm@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Signed-off-by: Juan Quintela <quintela@redhat.com>
2013-03-26 13:32:32 +01:00
Peter Lieven c61ca00ada move vector definitions to qemu-common.h
vector optimizations will now be used at various places
not just in is_dup_page() in arch_init.c

Signed-off-by: Peter Lieven <pl@kamp.de>
Signed-off-by: Juan Quintela <quintela@redhat.com>
2013-03-26 13:30:49 +01:00
Anthony Green d15a9c2390 Add top level changes for moxie
Signed-off-by: Anthony Green <green@moxielogic.com>
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
2013-03-23 14:25:42 +00:00
Peter Lieven ee0b44aa9d 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>
2013-03-11 13:32:03 +01:00
Paolo Bonzini 9b09503752 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>
2013-03-11 13:32:01 +01:00
Paolo Bonzini 32c835ba39 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>
2013-03-11 13:32:01 +01:00
Juan Quintela 90f8ae724a migration: calculate expected_downtime
We removed the calculation in commit e4ed1541ac

Now we add it back.  We need to create dirty_bytes_rate because we
can't include cpu-all.h from migration.c, and there is no other way to
include TARGET_PAGE_SIZE.

Signed-off-by: Juan Quintela <quintela@redhat.com>


Reviewed-by: Orit Wasserman <owasserm@redhat.com>
2013-02-22 10:12:52 +01:00
Orit Wasserman 1b1fdfeae6 Allow XBZRLE decoding without enabling the capability
Before this fix we couldn't load a guest from
XBZRLE compressed file.

For example:
The user activated the XBZRLE capability
The user run migrate -d "exec:gzip -c > vm.gz"
The user won't be able to load vm.gz and get an error.

Signed-off-by: Orit Wasserman <owasserm@redhat.com>
Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>

Signed-off-by: Juan Quintela <quintela@redhat.com>
2013-02-01 08:32:21 +01:00
Paolo Bonzini 9c339485f0 Protect migration_bitmap_sync() with the ramlist lock
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Juan Quintela <quintela@redhat.com>

Reviewed-by: Reviewed-by: Eric Blake <eblake@redhat.com>
2013-01-17 13:27:07 +01:00
Paolo Bonzini fb3409de22 Unlock ramlist lock also in error case
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Juan Quintela <quintela@redhat.com>

Reviewed-by: Reviewed-by: Eric Blake <eblake@redhat.com>
2013-01-17 13:27:07 +01:00
Juan Quintela b823ceaadf ram: refactor ram_save_block() return value
It could only return 0 if we only found dirty xbzrle pages that hadn't
changed (i.e. they were written with the same content).  We don't care
about that case, it is the same than nothing dirty.

So now the return of the function is how much have it written, nothing
else. Adjust callers.

And we also made ram_save_iterate() return the number of transferred
bytes, not the number of transferred pages.

Signed-off-by: Juan Quintela <quintela@redhat.com>
2012-12-20 23:09:40 +01:00
Juan Quintela 3f7d7b0981 ram: account the amount of transferred ram better
Signed-off-by: Juan Quintela <quintela@redhat.com>
2012-12-20 23:09:40 +01:00
Juan Quintela 4c8ae0f60e ram: optimize migration bitmap walking
Instead of testing each page individually, we search what is the next
dirty page with a bitmap operation.  We have to reorganize the code to
move from a "for" loop, to a while(dirty) loop.

Signed-off-by: Juan Quintela <quintela@redhat.com>
2012-12-20 23:09:40 +01:00
Juan Quintela ece7931817 ram: Use memory_region_test_and_clear_dirty
This avoids having to do two walks over the dirty bitmap, once reading
the dirty bits, and anthoer cleaning them.

Signed-off-by: Juan Quintela <quintela@redhat.com>
2012-12-20 23:09:40 +01:00
Juan Quintela 5f718a15d0 ram: Add last_sent_block
This is the last block from where we have sent data.

Signed-off-by: Orit Wasserman <owasserm@redhat.com>
Signed-off-by: Juan Quintela <quintela@redhat.com>
2012-12-20 23:09:39 +01:00
Juan Quintela b23a9a5cad ram: rename last_block to last_seen_block
Signed-off-by: Juan Quintela <quintela@redhat.com>
2012-12-20 23:09:39 +01:00
Juan Quintela e4ed1541ac savevm: New save live migration method: pending
Code just now does (simplified for clarity)

    if (qemu_savevm_state_iterate(s->file) == 1) {
       vm_stop_force_state(RUN_STATE_FINISH_MIGRATE);
       qemu_savevm_state_complete(s->file);
    }

Problem here is that qemu_savevm_state_iterate() returns 1 when it
knows that remaining memory to sent takes less than max downtime.

But this means that we could end spending 2x max_downtime, one
downtime in qemu_savevm_iterate, and the other in
qemu_savevm_state_complete.

Changed code to:

    pending_size = qemu_savevm_state_pending(s->file, max_size);
    DPRINTF("pending size %lu max %lu\n", pending_size, max_size);
    if (pending_size >= max_size) {
        ret = qemu_savevm_state_iterate(s->file);
     } else {
        vm_stop_force_state(RUN_STATE_FINISH_MIGRATE);
        qemu_savevm_state_complete(s->file);
     }

So what we do is: at current network speed, we calculate the maximum
number of bytes we can sent: max_size.

Then we ask every save_live section how much they have pending.  If
they are less than max_size, we move to complete phase, otherwise we
do an iterate one.

This makes things much simpler, because now individual sections don't
have to caluclate the bandwidth (it was implossible to do right from
there).

Signed-off-by: Juan Quintela <quintela@redhat.com>

Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
2012-12-20 23:09:25 +01:00
Umesh Deshpande b2a8658ef5 protect the ramlist with a separate mutex
Add the new mutex that protects shared state between ram_save_live
and the iothread.  If the iothread mutex has to be taken together
with the ramlist mutex, the iothread shall always be _outside_.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Umesh Deshpande <udeshpan@redhat.com>
Signed-off-by: Juan Quintela <quintela@redhat.com>

Reviewed-by: Orit Wasserman <owasserm@redhat.com>
2012-12-20 23:08:47 +01:00
Umesh Deshpande f798b07f51 add a version number to ram_list
This will be used to detect if last_block might have become invalid
across different calls to ram_save_live.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Umesh Deshpande <udeshpan@redhat.com>
Signed-off-by: Juan Quintela <quintela@redhat.com>

Reviewed-by: Orit Wasserman <owasserm@redhat.com>
2012-12-20 23:08:47 +01:00
Paolo Bonzini abb26d63e7 exec: sort the memory from biggest to smallest
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Juan Quintela <quintela@redhat.com>
2012-12-20 23:08:47 +01:00
Paolo Bonzini a3161038a1 exec: change RAM list to a TAILQ
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Juan Quintela <quintela@redhat.com>
2012-12-20 23:08:47 +01:00
Paolo Bonzini 0d6d3c87a2 exec: change ramlist from MRU order to a 1-item cache
Most of the time, only 2 items will be active (from/to for a string operation,
or code/data).  But TCG guests likely won't have gigabytes of memory, so
this actually goes down to 1 item.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Juan Quintela <quintela@redhat.com>
2012-12-20 23:08:40 +01:00
Paolo Bonzini 244eaa7514 migration: fix migration_bitmap leak
Cc: qemu-stable@nongnu.org
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Juan Quintela <quintela@redhat.com>
2012-12-20 22:44:29 +01:00
Paolo Bonzini 9c17d615a6 softmmu: move include files to include/sysemu/
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2012-12-19 08:32:45 +01:00
Paolo Bonzini 1de7afc984 misc: move include files to include/qemu/
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2012-12-19 08:32:39 +01:00
Paolo Bonzini caf71f86a3 migration: move include files to include/migration/
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2012-12-19 08:31:32 +01:00
Paolo Bonzini 83c9089e73 monitor: move include files to include/monitor/
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2012-12-19 08:31:32 +01:00
Paolo Bonzini 022c62cbbc exec: move include files to include/exec/
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2012-12-19 08:31:31 +01:00
Paolo Bonzini 7fa22f2bf7 net: do not include net.h everywhere
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2012-12-19 08:29:59 +01:00
Paolo Bonzini 077805fa92 janitor: do not rely on indirect inclusions of or from qemu-char.h
Various header files rely on qemu-char.h including qemu-config.h or
main-loop.h, but they really do not need qemu-char.h at all (particularly
interesting is the case of the block layer!).  Clean this up, and also
add missing inclusions of qemu-char.h itself.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2012-12-19 08:29:52 +01:00
Paolo Bonzini 6f991980a5 Merge commit '1dd3a74d2ee2d873cde0b390b536e45420b3fe05' into HEAD
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2012-12-17 18:56:22 +01:00
Michael S. Tsirkin a2cb15b0dd pci: update all users to look in pci/
update all users so we can remove the makefile hack.

Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
2012-12-17 13:02:26 +02:00
David Gibson 45e6cee42b migration: Fix madvise breakage if host and guest have different page sizes
madvise(DONTNEED) will throw away the contents of the whole page at the
given address, even if the given length is less than the page size.  One
can argue about whether that's the correct behaviour, but that's what it's
done for a long time in Linux at least.

That means that the madvise() in ram_load(), on a setup where
TARGET_PAGE_SIZE is smaller than the host page size, can throw away data
in guest pages adjacent to the one it's actually processing right now,
leading to guest memory corruption on an incoming migration.

This patch therefore, disables the madvise() if the host page size is
larger than TARGET_PAGE_SIZE.  This means we don't get the benefits of that
madvise() in this case, but a more complete fix is more difficult to
accomplish.  This at least fixes the guest memory corruption.

Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
Reported-by: Alexey Kardashevskiy <aik@ozlabs.ru>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2012-12-12 15:03:31 -06:00
David Gibson 7ec81e56ed Fix off-by-1 error in RAM migration code
The code for migrating (or savevm-ing) memory pages starts off by creating
a dirty bitmap and filling it with 1s.  Except, actually, because bit
addresses are 0-based it fills every bit except bit 0 with 1s and puts an
extra 1 beyond the end of the bitmap, potentially corrupting unrelated
memory.  Oops.  This patch fixes it.

Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2012-12-12 15:03:31 -06:00
Juan Quintela 8d017193e2 migration: Add dirty_pages_rate to query migrate output
It indicates how many pages were dirtied during the last second.

Signed-off-by: Juan Quintela <quintela@redhat.com>
2012-10-17 18:34:58 +02:00
Juan Quintela c6bf8e0e0c Separate migration bitmap
This patch creates a migration bitmap, which is periodically kept in
sync with the qemu bitmap. A separate copy of the dirty bitmap for the
migration limits the amount of concurrent access to the qemu bitmap
from iothread and migration thread (which requires taking the big
lock).

We use the qemu bitmap type.  We have to "undo" the dirty_pages
counting optimization on the general dirty bitmap and do the counting
optimization with the migration local bitmap.

Signed-off-by: Umesh Deshpande <udeshpan@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Juan Quintela <quintela@redhat.com>
2012-10-17 18:34:58 +02:00
Juan Quintela 3c12193d99 ram: create trace event for migration sync bitmap
Signed-off-by: Juan Quintela <quintela@redhat.com>

Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
2012-10-17 18:34:58 +02:00
Juan Quintela dd2df737ef ram: introduce migration_bitmap_sync()
Helper that we use each time that we need to syncronize the migration
bitmap with the other dirty bitmaps.

Signed-off-by: Juan Quintela <quintela@redhat.com>

Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
2012-10-17 18:34:58 +02:00
Juan Quintela 69268cde14 ram: Introduce migration_bitmap_test_and_reset_dirty()
It just test if the dirty bit is set, and clears it.

Signed-off-by: Juan Quintela <quintela@redhat.com>

Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
Reviewed-by: Orit Wasserman <owasserm@redhat.com>
2012-10-17 18:34:58 +02:00
Juan Quintela e44d26c8f3 ram: introduce migration_bitmap_set_dirty()
It just marks a region of memory as dirty.

Signed-off-by: Juan Quintela <quintela@redhat.com>

Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
Reviewed-by: Orit Wasserman <owasserm@redhat.com>
2012-10-17 18:34:58 +02:00
Juan Quintela 5a17077529 savevm: Factorize ram globals reset in its own function
Signed-off-by: Juan Quintela <quintela@redhat.com>

Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
Reviewed-by: Orit Wasserman <owasserm@redhat.com>
2012-10-17 18:34:58 +02:00
Juan Quintela 2c52ddf1cb migration: print expected downtime in info migrate
Signed-off-by: Juan Quintela <quintela@redhat.com>
2012-10-17 18:34:58 +02:00
Juan Quintela c00012f68b migration: rename expected_time to expected_downtime
Signed-off-by: Juan Quintela <quintela@redhat.com>

Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
Reviewed-by: Orit Wasserman <owasserm@redhat.com>
2012-10-17 18:34:58 +02:00
Juan Quintela 79536f4f16 fix migration sync
Signed-off-by: Juan Quintela <quintela@redhat.com>

Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
2012-10-17 18:34:58 +02:00
Eduardo Habkost ba6212d8a8 Eliminate cpus-x86_64.conf file
This file is not needed anymore, as QEMU won't ship any config-based
cpudefs out of the box, relying only on the builtin CPU models.

Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
Reviewed-by: Igor Mammedov <imammedo@redhat.com>
Signed-off-by: Andreas Färber <afaerber@suse.de>
2012-09-21 15:12:58 +02:00
Peter Maydell 55d4fd3c24 arch_init.c: Improve '-soundhw help' for non-HAS_AUDIO_CHOICE archs
For architectures which don't set HAS_AUDIO_CHOICE, improve the
'-soundhw help' message so that it doesn't simply print an empty
list, implying no sound support at all.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: malc <av1474@comtv.ru>
2012-09-19 17:55:08 +04:00
Igor Mitsyanko ef37a699a0 arch_init.c: add missing '%' symbols before PRIu64 in debug printfs
'%' symbols were missing in front of PRIu64 macros in DPRINTF() messages in
arch_init.c, this caused compilation warnings when compiled with DEBUG_ARCH_INIT defined.

Signed-off-by: Igor Mitsyanko <i.mitsyanko@samsung.com>
Signed-off-by: Stefan Hajnoczi <stefanha@gmail.com>
2012-09-14 08:21:29 +01:00
Daniel P. Berrange 99afc91d6c qapi: add 'query-target' command to return target arch
Add a 'query-target' QAPI command to allow management applications
to determine what target architecture a QEMU binary is emulating
without having to parse the binary name or -help output

  $ qmp-shell -p /tmp/qemu
  (QEMU) query-target
  {   u'return': {   u'arch': u'x86_64' }}

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2012-08-22 10:47:17 -05:00
Anthony Liguori ac839ccd8c Merge remote-tracking branch 'quintela/migration-next-20120808' into staging
* quintela/migration-next-20120808:
  Restart optimization on stage3 update version
  Add XBZRLE statistics
  Add migration accounting for normal and duplicate pages
  Change total_time to total-time in MigrationStats
  Add migrate_set_cache_size command
  Add XBZRLE to ram_save_block and ram_save_live
  Add xbzrle_encode_buffer and xbzrle_decode_buffer functions
  Add uleb encoding/decoding functions
  Add cache handling functions
  Add XBZRLE documentation
  Add migrate-set-capabilities
  Add migration capabilities
2012-08-13 16:02:11 -05:00
Guan Xuetao 4f23a1e645 unicore32-softmmu: Add unicore32-softmmu build support
This patch adds unicore32-softmmu build support, include configure,
makefile, arch_init, and all missing functions needed by softmmu.
Although all missing functions are empty, unicore32-softmmu could
be build successfully.
By 20120804: change QEMU_ARCH_UNICORE32 to 0x4000

Signed-off-by: Guan Xuetao <gxt@mprc.pku.edu.cn>
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
2012-08-11 09:36:55 +00:00
Juan Quintela dd051c7217 Restart optimization on stage3 update version
Signed-off-by: Juan Quintela <quintela@redhat.com>

Reviewed-by: Luiz Capitulino <lcapitulino@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
2012-08-08 13:51:12 +02:00
Orit Wasserman f36d55af74 Add XBZRLE statistics
Signed-off-by: Benoit Hudzia <benoit.hudzia@sap.com>
Signed-off-by: Petter Svard <petters@cs.umu.se>
Signed-off-by: Aidan Shribman <aidan.shribman@sap.com>
Signed-off-by: Orit Wasserman <owasserm@redhat.com>
Signed-off-by: Juan Quintela <quintela@redhat.com>

Reviewed-by: Luiz Capitulino <lcapitulino@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
2012-08-08 13:51:12 +02:00
Orit Wasserman 004d4c10ae Add migration accounting for normal and duplicate pages
Signed-off-by: Benoit Hudzia <benoit.hudzia@sap.com>
Signed-off-by: Petter Svard <petters@cs.umu.se>
Signed-off-by: Aidan Shribman <aidan.shribman@sap.com>
Signed-off-by: Orit Wasserman <owasserm@redhat.com>
Signed-off-by: Juan Quintela <quintela@redhat.com>

Reviewed-by: Luiz Capitulino <lcapitulino@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
2012-08-08 13:51:12 +02:00
Orit Wasserman 9e1ba4cc4e Add migrate_set_cache_size command
Change XBZRLE cache size in bytes (the size should be a power of 2, it will be
rounded down to the nearest power of 2).
If XBZRLE cache size is too small there will be many cache miss.

New query-migrate-cache-size QMP command and 'info migrate_cache_size' HMP
command to query cache value.

Signed-off-by: Benoit Hudzia <benoit.hudzia@sap.com>
Signed-off-by: Petter Svard <petters@cs.umu.se>
Signed-off-by: Aidan Shribman <aidan.shribman@sap.com>
Signed-off-by: Orit Wasserman <owasserm@redhat.com>

Reviewed-by: Luiz Capitulino <lcapitulino@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
2012-08-08 13:51:12 +02:00
Orit Wasserman 17ad9b358b Add XBZRLE to ram_save_block and ram_save_live
In the outgoing migration check to see if the page is cached and
changed, then send compressed page by using save_xbrle_page function.
In the incoming migration check to see if RAM_SAVE_FLAG_XBZRLE is set
and decompress the page (by using load_xbrle function).

Signed-off-by: Benoit Hudzia <benoit.hudzia@sap.com>
Signed-off-by: Petter Svard <petters@cs.umu.se>
Signed-off-by: Aidan Shribman <aidan.shribman@sap.com>
Signed-off-by: Orit Wasserman <owasserm@redhat.com>

Reviewed-by: Luiz Capitulino <lcapitulino@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
2012-08-08 13:51:12 +02:00
Peter Maydell c8057f951d Support 'help' as a synonym for '?' in command line options
For command line options which permit '?' meaning 'please list the
permitted values', add support for 'help' as a synonym, by abstracting
the check out into a helper function.

This change means that in some cases where we were being lazy in
our string parsing, "?junk" will now be rejected as an invalid option
rather than being (undocumentedly) treated the same way as "?".

Update the documentation to use 'help' rather than '?', since '?'
is a shell metacharacter and thus prone to fail confusingly if there
is a single character filename in the current working directory and
the '?' has not been escaped. It's therefore better to steer users
towards 'help', though '?' is retained for backwards compatibility.

We do not, however, update the output of the system emulator's -help
(or any documentation autogenerated from the qemu-options.hx which
is the source of the -help text) because libvirt parses our -help
output and will break. At a later date when QEMU provides a better
interface so libvirt can avoid having to do this, we can update the
-help text too.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2012-08-02 13:16:42 -05:00
Anthony Liguori e6a7671998 Merge commit 'quintela/migration-next-v5' into staging
* commit '6c779f22a93cc6e4565b940ef616e3efc5b50ba5':
  Change ram_save_block to return -1 if there are no more changes
  ram: save_live_setup() we don't need to synchronize the dirty bitmap.
  ram: iterate phase
  ram: save_live_complete() only do one loop
  ram: save_live_setup() don't need to sent pages
  savevm: split save_live into stage2 and stage3
  savevm: split save_live_setup from save_live_state
  savevm: introduce is_active method
  savevm: Refactor cancel operation in its own operation
  savevm: remove SaveLiveStateHandler
  savevm: remove SaveSetParamsHandler
  savevm: Live migration handlers register the struct directly
  savevm: Use a struct to pass all handlers
2012-07-30 09:58:48 -05:00
Jia Liu e67db06e9f target-or32: Add target stubs and QOM cpu
Add OpenRISC target stubs, QOM cpu and basic machine.

Signed-off-by: Jia Liu <proljc@gmail.com>
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
2012-07-27 21:12:55 +00:00
Orit Wasserman 6c779f22a9 Change ram_save_block to return -1 if there are no more changes
It will return 0 if the page is unmodifed.

Signed-off-by: Orit Wasserman <owasserm@redhat.com>
2012-07-23 14:02:28 +02:00
Juan Quintela 6d2fe810ed ram: save_live_setup() we don't need to synchronize the dirty bitmap.
1st: we were synchonizing the dirty bitmap before calling
      memory_global_dirty_log_start().

2nd: We are marking all pages as dirty anywhere, no reason to go
     through all the bitmap to "mark" dirty same pages twice.

So, call removed.

Signed-off-by: Juan Quintela <quintela@redhat.com>
2012-07-20 08:19:27 +02:00
Juan Quintela 00d94f3f76 ram: iterate phase
We only need to synchronize the bitmap when the number of dirty pages is low.
Not every time that we call the function.

Signed-off-by: Juan Quintela <quintela@redhat.com>
2012-07-20 08:19:27 +02:00
Juan Quintela b81e712d25 ram: save_live_complete() only do one loop
We were doing the same loop that stage2, and a new one for stage3.  We
only need the one for stage3.

Signed-off-by: Juan Quintela <quintela@redhat.com>
2012-07-20 08:19:27 +02:00
Juan Quintela 5910d1e6cb ram: save_live_setup() don't need to sent pages
We should send pages on interate phase, not in setup one.  This was a
"bug".  Just removing the loop does what we want.  Tested that it
works with current ram_load().

Signed-off-by: Juan Quintela <quintela@redhat.com>
2012-07-20 08:19:27 +02:00
Juan Quintela 16310a3cca savevm: split save_live into stage2 and stage3
We split it into 2 functions, foo_live_iterate, and foo_live_complete.
At this point, we only remove the bits that are for the other stage,
functionally this is equivalent to previous code.

Signed-off-by: Juan Quintela <quintela@redhat.com>
2012-07-20 08:19:27 +02:00
Juan Quintela d1315aac6e savevm: split save_live_setup from save_live_state
This patch splits stage 1 to its own function for both save_live
users, ram and block.  It is just a copy of the function, removing the
parts of the other stages.  Optimizations would came later.

Signed-off-by: Juan Quintela <quintela@redhat.com>
2012-07-20 08:19:27 +02:00
Juan Quintela 9b5bfab05f savevm: Refactor cancel operation in its own operation
Intead of abusing stage with value -1.

Signed-off-by: Juan Quintela <quintela@redhat.com>
2012-07-20 08:19:27 +02:00
Juan Quintela 7908c78d3e savevm: Live migration handlers register the struct directly
Notice that the live migration users never unregister, so no problem
about freeing the ops structure.

Signed-off-by: Juan Quintela <quintela@redhat.com>
2012-07-20 08:19:27 +02:00
Juan Quintela 45f33f01f3 Maintain the number of dirty pages
Calculate the number of dirty pages takes a lot on hosts with lots
of memory.  Just maintain how many pages are dirty.

Signed-off-by: Juan Quintela <quintela@redhat.com>
2012-06-29 13:31:07 +02:00
Juan Quintela 4508bd9ed8 Exit loop if we have been there too long
Checking each 64 pages is a random magic number as good as any other.
We don't want to test too many times, but on the other hand,
qemu_get_clock_ns() is not so expensive either.  We want to be sure
that we spent less than 50ms (half of buffered_file timer), if we
spent more than 100ms, all the accounting got wrong.

Signed-off-by: Juan Quintela <quintela@redhat.com>
2012-06-29 13:31:04 +02:00
Juan Quintela 5b3c963887 Only calculate expected_time for stage 2
ram_save_remaining() is an expensive operation when there is a lot of memory.
So we only call the function when we need it.

Signed-off-by: Juan Quintela <quintela@redhat.com>
2012-06-29 13:28:09 +02:00
Orit Wasserman 8e21cd3200 Add migration_end function
Signed-off-by: Orit Wasserman <owasserm@redhat.com>
2012-06-29 13:27:28 +02:00
Orit Wasserman 3a697f697b Add debugging infrastructure
Signed-off-by: Orit Wasserman <owasserm@redhat.com>
2012-06-29 13:27:14 +02:00
Orit Wasserman 0c51f43d7a Add save_block_hdr function
Signed-off-by: Benoit Hudzia <benoit.hudzia@sap.com>
Signed-off-by: Petter Svard <petters@cs.umu.se>
Signed-off-by: Aidan Shribman <aidan.shribman@sap.com>
Signed-off-by: Orit Wasserman <owasserm@redhat.com>
2012-06-29 13:18:28 +02:00
Orit Wasserman 0ff1f9f585 Add missing check for host_from_stream_offset return value for RAM_SAVE_FLAG_PAGE
Signed-off-by: Orit Wasserman <owasserm@redhat.com>
2012-06-29 10:38:28 +02:00
Andreas Färber f283edc482 arch_init: Fix AltiVec build on Darwin/ppc
Commit f29a56147b (implement
-no-user-config command-line option (v3)) introduced uses of bool
in arch_init.c. Shortly before that usage is support code for
AltiVec (conditional to __ALTIVEC__).

GCC's altivec.h may in a !__APPLE_ALTIVEC__ code path redefine bool,
leading to type mismatches. altivec.h recommends to #undef for C++
compatibility, but doing so in C leads to bool remaining undefined.

Fix by redefining bool to _Bool as mandated for stdbool.h by POSIX.

Signed-off-by: Andreas Färber <andreas.faerber@web.de>
Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
2012-05-29 11:38:07 +02:00
Eduardo Habkost e2d87bff12 move CPU definitions to /usr/share/qemu/cpus-x86_64.conf (v2)
Changes v1 -> v2:
 - userconfig variable is now bool, not int

Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2012-05-10 12:37:57 -05:00
Eduardo Habkost f29a56147b implement -no-user-config command-line option (v3)
Changes v2 -> v3:
 - Rebase against latest qemu.git

Changes v1 -> v2:
 - Change 'userconfig' field/variables to bool instead of int
 - Coding style change

Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2012-05-10 12:37:57 -05:00