summaryrefslogtreecommitdiff
path: root/migration/ram.c
AgeCommit message (Collapse)AuthorFilesLines
2017-06-14migration: Don't create decompression threads if not enabledJuan Quintela1-0/+6
Signed-off-by: Juan Quintela <quintela@redhat.com> Reviewed-by: Dr. David Alan Gilbert <dgilbert@redhat.com> Reviewed-by: Peter Xu <peterx@redhat.com> -- I removed the [HACK] part because previous patch just check that compression pages are not received.
2017-06-14migration: Test for disabled features on receptionJuan Quintela1-1/+13
Right now, if we receive a compressed page while this features are disabled, Bad Things (TM) can happen. Just add a test for them. Signed-off-by: Juan Quintela <quintela@redhat.com> Reviewed-by: Dr. David Alan Gilbert <dgilbert@redhat.com> Reviewed-by: Peter Xu <peterx@redhat.com> -- I had XBZRLE here also, but it don't need extra resources on destination, only on source. Additionally libvirt don't enable it on destination, so don't put it here. - initialize invalid_flags at declaration time. - remove extra space (peter)
2017-06-14migration: Remove unneeded includesJuan Quintela1-4/+0
Signed-off-by: Juan Quintela <quintela@redhat.com> Reviewed-by: Peter Xu <peterx@redhat.com>
2017-06-13migration: Move migration.h to migration/Juan Quintela1-1/+1
Nothing uses it outside of migration.h Signed-off-by: Juan Quintela <quintela@redhat.com> Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> Reviewed-by: Peter Xu <peterx@redhat.com> Reviewed-by: Laurent Vivier <lvivier@redhat.com>
2017-06-13migration: Split registration functions from vmstate.hJuan Quintela1-0/+1
They are indpendent, and nowadays almost every device register things with qdev->vmsd. Signed-off-by: Juan Quintela <quintela@redhat.com> Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> Reviewed-by: Peter Xu <peterx@redhat.com>
2017-06-07ram: Make RAMState dynamicJuan Quintela1-23/+35
We create the variable while we are at migration and we remove it after migration. Signed-off-by: Juan Quintela <quintela@redhat.com> Reviewed-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
2017-06-07ram: Use MigrationStats for statisticsJuan Quintela1-119/+44
RAM Statistics need to survive migration to make info migrate work, so we need to store them outside of RAMState. As we already have an struct with those fields, just used them. (MigrationStats and XBZRLECacheStats). Signed-off-by: Juan Quintela <quintela@redhat.com> Reviewed-by: Dr. David Alan Gilbert <dgilbert@redhat.com> Reviewed-by: Peter Xu <peterx@redhat.com>
2017-06-07ram: Move ZERO_TARGET_PAGE inside XBZRLEJuan Quintela1-5/+6
It was only used by XBZRLE anyways. Signed-off-by: Juan Quintela <quintela@redhat.com> Reviewed-by: Dr. David Alan Gilbert <dgilbert@redhat.com> Reviewed-by: Peter Xu <peterx@redhat.com>
2017-06-07ram: Call migration_page_queue_free() at ram_migration_cleanup()Juan Quintela1-2/+3
We shouldn't be using memory later than that. Signed-off-by: Juan Quintela <quintela@redhat.com> Reviewed-by: Dr. David Alan Gilbert <dgilbert@redhat.com> Reviewed-by: Peter Xu <peterx@redhat.com>
2017-06-01migration: Export ram.c functions in its own fileJuan Quintela1-0/+2
All functions are internal except for ram_mig_init(). Create migration/misc.h for this kind of functions. Signed-off-by: Juan Quintela <quintela@redhat.com> Reviewed-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
2017-06-01migration: Split qemu-file.hJuan Quintela1-1/+1
Split the file into public and internal interfaces. I have to rename the external one because we can't have two include files with the same name in the same directory. Build system gets confused. The only exported functions are the ones that handle basic types. Signed-off-by: Juan Quintela <quintela@redhat.com> Reviewed-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
2017-05-31migration: use dirty_rate_high_cnt more aggressivelyFelipe Franciosi1-1/+1
The commit message from 070afca25 suggests that dirty_rate_high_cnt should be used more aggressively to start throttling after two iterations instead of four. The code, however, only changes the auto convergence behaviour to throttle after three iterations. This makes the behaviour more aggressive by kicking off throttling after two iterations as originally intended. Signed-off-by: Felipe Franciosi <felipe@nutanix.com> Reviewed-by: Peter Xu <peterx@redhat.com> Reviewed-by: Juan Quintela <quintela@redhat.com> Signed-off-by: Juan Quintela <quintela@redhat.com>
2017-05-31migration: set bytes_xfer_* outside of autoconverge logicFelipe Franciosi1-2/+2
The bytes_xfer_now/prev counters are only used by the auto convergence logic. However, they are used alongside the dirty_pages_rate counter, which is calculated (and required) outside of this logic. The problem with this approach is that if the auto convergence capability is changed while a migration is ongoing, the relationship of the counters will be broken. This moves the management of bytes_xfer_now/prev counters outside of the auto convergence logic to address this issue. Signed-off-by: Felipe Franciosi <felipe@nutanix.com> Reviewed-by: Peter Xu <peterx@redhat.com> Reviewed-by: Juan Quintela <quintela@redhat.com> Signed-off-by: Juan Quintela <quintela@redhat.com>
2017-05-31migration: set dirty_pages_rate before autoconverge logicFelipe Franciosi1-7/+10
Currently, a "period" in the RAM migration logic is at least a second long and accounts for what happened since the last period (or the beginning of the migration). The dirty_pages_rate counter is calculated at the end this logic. If the auto convergence capability is enabled from the start of the migration, it won't be able to use this counter the first time around. This calculates dirty_pages_rate as soon as a period is deemed over, which allows for it to be used immediately. Signed-off-by: Felipe Franciosi <felipe@nutanix.com> Reviewed-by: Peter Xu <peterx@redhat.com> Reviewed-by: Juan Quintela <quintela@redhat.com> Signed-off-by: Juan Quintela <quintela@redhat.com>
2017-05-31migration: keep bytes_xfer_prev init'd to zeroFelipe Franciosi1-4/+0
The first time migration_bitmap_sync() is called, bytes_xfer_prev is set to ram_state.bytes_transferred which is, at this point, zero. The next time migration_bitmap_sync() is called, an iteration has happened and bytes_xfer_prev is set to 'x' bytes. Most likely, more than one second has passed, so the auto converge logic will be triggered and bytes_xfer_now will also be set to 'x' bytes. This condition is currently masked by dirty_rate_high_cnt, which will wait for a few iterations before throttling. It would otherwise always assume zero bytes have been copied and therefore throttle the guest (possibly) prematurely. Given bytes_xfer_prev is only used by the auto convergence logic, it makes sense to only set its value after a check has been made against bytes_xfer_now. Signed-off-by: Felipe Franciosi <felipe@nutanix.com> Reviewed-by: Peter Xu <peterx@redhat.com> Reviewed-by: Juan Quintela <quintela@redhat.com> Signed-off-by: Juan Quintela <quintela@redhat.com>
2017-05-18migration: Remove vmstate.h from migration.hJuan Quintela1-0/+1
Signed-off-by: Juan Quintela <quintela@redhat.com> Reviewed-by: Dr. David Alan Gilbert <dgilbert@redhat.com> Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> --- Minor rearrangements due to rebase
2017-05-18migration: Remove qemu-file.h from vmstate.hJuan Quintela1-0/+1
Signed-off-by: Juan Quintela <quintela@redhat.com> Reviewed-by: Dr. David Alan Gilbert <dgilbert@redhat.com> -- minor rearangements due to the rebase
2017-05-18migration: Create migration/xbzrle.hJuan Quintela1-0/+1
Signed-off-by: Juan Quintela <quintela@redhat.com> Reviewed-by: Peter Xu <peterx@redhat.com>
2017-05-18migration: Fix non-multiple of page size migrationDr. David Alan Gilbert1-1/+4
Unfortunately it's legal to create a VM with a RAM size that's not a multiple of the underlying host page or huge page size. Recently I'd changed things to always send host sized pages, and that breaks if we have say a 1025MB guest on 2MB hugepages. Unfortunately we can't just make that illegal since it would break migration from/to existing oddly configured VMs. Symptom: qemu-system-x86_64: Illegal RAM offset 40100000 as it transmits the fraction of the hugepage after the end of the RAMBlock (may also cause a crash on the source - possibly due to clearing bits after the bitmap) Reported-by: Yumei Huang <yuhuang@redhat.com> Red Hat bug: https://bugzilla.redhat.com/show_bug.cgi?id=1449037 Signed-off-by: Dr. David Alan Gilbert <dgilbert@redhat.com> Reviewed-by: Juan Quintela <quintela@redhat.com> Signed-off-by: Juan Quintela <quintela@redhat.com>
2017-05-18Merge remote-tracking branch 'dgilbert/tags/pull-hmp-20170517' into stagingStefan Hajnoczi1-6/+7
HMP pull # gpg: Signature made Wed 17 May 2017 07:03:39 PM BST # gpg: using RSA key 0x0516331EBC5BFDE7 # gpg: Good signature from "Dr. David Alan Gilbert (RH2) <dgilbert@redhat.com>" # gpg: WARNING: This key is not certified with a trusted signature! # gpg: There is no indication that the signature belongs to the owner. # Primary key fingerprint: 45F5 C71B 4A0C B7FB 977A 9FA9 0516 331E BC5B FDE7 * dgilbert/tags/pull-hmp-20170517: ramblock: add new hmp command "info ramblock" utils: provide size_to_str() ramblock: add RAMBLOCK_FOREACH() Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
2017-05-17ramblock: add RAMBLOCK_FOREACH()Peter Xu1-6/+7
So that it can simplifies the iterators. Reviewed-by: Dr. David Alan Gilbert <dgilbert@redhat.com> Signed-off-by: Peter Xu <peterx@redhat.com> Message-Id: <1494562661-9063-2-git-send-email-peterx@redhat.com> Signed-off-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
2017-05-17ram: Rename RAM_SAVE_FLAG_COMPRESS to RAM_SAVE_FLAG_ZEROJuan Quintela1-6/+12
Reflects better what it does now, and avoid confussions with RAM_SAVE_FLAG_COMPRESS_PAGE. Signed-off-by: Juan Quintela <quintela@redhat.com> Reviewed-by: Peter Xu <peterx@redhat.com>
2017-05-17migration: Fix regression with compression threadsJuan Quintela1-9/+10
Compression threads got broken on commit commit 247956946651ae0280f7b1ea88bb6237dd01c231 Author: Juan Quintela <quintela@redhat.com> Date: Tue Mar 21 11:45:01 2017 +0100 ram: reorganize last_sent_block On do_compress_ram_page() we use a different QEMUFile than the migration one. We need to pass it there. The failure can be seen as: (qemu) qemu-system-x86_64: Unknown combination of migration flags: 0 qemu-system-x86_64: error while loading state section id 3(ram) qemu-system-x86_64: load of migration failed: Invalid argument Signed-off-by: Juan Quintela <quintela@redhat.com> Reviewed-by: Peter Xu <peterx@redhat.com> Tested-by: Peter Xu <peterx@redhat.com>
2017-05-04migration: Extra tracingDr. David Alan Gilbert1-0/+2
A couple more traces that would have made fixing that postcopy bug a bit easier. Signed-off-by: Dr. David Alan Gilbert <dgilbert@redhat.com> Reviewed-by: Juan Quintela <quintela@redhat.com> Signed-off-by: Juan Quintela <quintela@redhat.com>
2017-05-04migration: Move postcopy-ram.h to migration/Juan Quintela1-1/+1
It is internal to migration, not intended for other users. Signed-off-by: Juan Quintela <quintela@redhat.com> Reviewed-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
2017-05-04ram: Split dirty bitmap by RAMBlockJuan Quintela1-163/+102
Both the ram bitmap and the unsent bitmap are split by RAMBlock. Signed-off-by: Juan Quintela <quintela@redhat.com> Reviewed-by: zhanghailiang <zhang.zhanghailiang@huawei.com> Reviewed-by: Peter Xu <peterx@redhat.com> -- Fix compilation when DEBUG_POSTCOPY is enabled (thanks Hailiang)
2017-04-21ram: Remove migration_bitmap_extend()Juan Quintela1-34/+0
We have disabled memory hotplug, so we don't need to handle migration_bitamp there. Signed-off-by: Juan Quintela <quintela@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com> Reviewed-by: zhanghailiang <zhang.zhanghailiang@huawei.com>
2017-04-21ram: Use RAMBitmap type for coherenceJuan Quintela1-5/+5
Signed-off-by: Juan Quintela <quintela@redhat.com> Reviewed-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
2017-04-21ram: rename last_ram_offset() last_ram_pages()Juan Quintela1-6/+5
We always use it as pages anyways. Signed-off-by: Juan Quintela <quintela@redhat.com> Reviewed-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
2017-04-21ram: Use ramblock and page offset instead of absolute offsetJuan Quintela1-38/+27
This removes the needto pass also the absolute offset. Signed-off-by: Juan Quintela <quintela@redhat.com> Reviewed-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
2017-04-21ram: Change offset field in PageSearchStatus to pageJuan Quintela1-25/+26
We are moving everything to work on pages, not addresses. Signed-off-by: Juan Quintela <quintela@redhat.com> Reviewed-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
2017-04-21ram: Remember last_page instead of last_offsetJuan Quintela1-7/+7
Signed-off-by: Juan Quintela <quintela@redhat.com> Reviewed-by: Dr. David Alan Gilbert <dgilbert@redhat.com> Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> -- Improve comment Fix typo
2017-04-21ram: Use page number instead of an address for the bitmap operationsJuan Quintela1-42/+34
We use an unsigned long for the page number. Notice that our bitmaps already got that for the index, so we have that limit. Signed-off-by: Juan Quintela <quintela@redhat.com> Reviewed-by: Dr. David Alan Gilbert <dgilbert@redhat.com> -- rename page to page_abs everywhere. fix trace types for pages
2017-04-21ram: reorganize last_sent_blockJuan Quintela1-21/+15
We were setting it far away of when we changed it. Now everything is done inside save_page_header. Once there, reorganize code to pass RAMState. We also set CONTINUE flag in a single place. Signed-off-by: Juan Quintela <quintela@redhat.com> Reviewed-by: Dr. David Alan Gilbert <dgilbert@redhat.com> Reviewed-by: Peter Xu <peterx@redhat.com>
2017-04-21ram: ram_discard_range() don't use the mis parameterJuan Quintela1-6/+3
Signed-off-by: Juan Quintela <quintela@redhat.com> Reviewed-by: Peter Xu <peterx@redhat.com>
2017-04-21ram: Pass RAMBlock to bitmap_syncJuan Quintela1-4/+4
We change the meaning of start to be the offset from the beggining of the block. Signed-off-by: Juan Quintela <quintela@redhat.com> Reviewed-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
2017-04-21ram: We don't need MigrationState parameter anymoreJuan Quintela1-17/+10
Remove it from callers and callees. Signed-off-by: Juan Quintela <quintela@redhat.com> Reviewed-by: Dr. David Alan Gilbert <dgilbert@redhat.com> Reviewed-by: Peter Xu <peterx@redhat.com>
2017-04-21migration: Remove MigrationState from migration_in_postcopyJuan Quintela1-12/+10
We need to call for the migrate_get_current() in more that half of the uses, so call that inside. Signed-off-by: Juan Quintela <quintela@redhat.com> Reviewed-by: Dr. David Alan Gilbert <dgilbert@redhat.com> Reviewed-by: Peter Xu <peterx@redhat.com>
2017-04-21ram: Remove compression_switch and inline its logicJuan Quintela1-4/+8
We can calculate its value, so we don't create a variable for it. Signed-off-by: Juan Quintela <quintela@redhat.com> Reviewed-by: Dr. David Alan Gilbert <dgilbert@redhat.com> -- After Peter and Dave review, I dropped the variable and just inlined the condition. Fix typo
2017-04-21ram: Move QEMUFile into RAMStateJuan Quintela1-47/+37
We receive the file from save_live operations and we don't use it until 3 or 4 levels of calls down. Signed-off-by: Juan Quintela <quintela@redhat.com> Reviewed-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
2017-04-21ram: Add QEMUFile to RAMStateJuan Quintela1-7/+10
Signed-off-by: Juan Quintela <quintela@redhat.com> Reviewed-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
2017-04-21ram: Move postcopy_requests into RAMStateJuan Quintela1-4/+9
Signed-off-by: Juan Quintela <quintela@redhat.com> Reviewed-by: Peter Xu <peterx@redhat.com>
2017-04-21ram: Move dirty_pages_rate to RAMStateJuan Quintela1-3/+9
Treat it like the rest of ram stats counters. Export its value the same way. As an added bonus, no more MigrationState used in migration_bitmap_sync(); Signed-off-by: Juan Quintela <quintela@redhat.com> Reviewed-by: Dr. David Alan Gilbert <dgilbert@redhat.com> Reviewed-by: Peter Xu <peterx@redhat.com> -- Again, dave was the one reviewing it
2017-04-21ram: Remove dirty_bytes_rateJuan Quintela1-1/+0
It can be recalculated from dirty_pages_rate. Signed-off-by: Juan Quintela <quintela@redhat.com> Reviewed-by: Dr. David Alan Gilbert <dgilbert@redhat.com> Reviewed-by: Peter Xu <peterx@redhat.com> -- Dave was the one that reviewed it O:-)
2017-04-21ram: Create ram_dirty_sync_count()Juan Quintela1-1/+5
This is a ram field that was inside MigrationState. Move it to RAMState and make it the same that the other ram stats. Signed-off-by: Juan Quintela <quintela@redhat.com> Reviewed-by: Peter Xu <peterx@redhat.com>
2017-04-21ram: Move src_page_req* to RAMStateJuan Quintela1-23/+38
This are the last postcopy fields still at MigrationState. Once there Move MigrationSrcPageRequest to ram.c and remove MigrationState parameters where appropiate. Signed-off-by: Juan Quintela <quintela@redhat.com> Reviewed-by: Peter Xu <peterx@redhat.com>
2017-04-21ram: Move last_req_rb to RAMStateJuan Quintela1-2/+5
It was on MigrationState when it is only used inside ram.c for postcopy. Problem is that we need to access it without being able to pass it RAMState directly. Signed-off-by: Juan Quintela <quintela@redhat.com> Reviewed-by: Peter Xu <peterx@redhat.com>
2017-04-21ram: Remove ram_save_remainingJuan Quintela1-11/+6
Just unfold it. Move ram_bytes_remaining() with the rest of exported functions. Signed-off-by: Juan Quintela <quintela@redhat.com> Reviewed-by: Dr. David Alan Gilbert <dgilbert@redhat.com> Reviewed-by: Peter Xu <peterx@redhat.com>
2017-04-21ram: Use the RAMState bytes_transferred parameterJuan Quintela1-48/+27
Somewhere it was passed by reference, just use it from RAMState. Signed-off-by: Juan Quintela <quintela@redhat.com> Reviewed-by: Dr. David Alan Gilbert <dgilbert@redhat.com> Reviewed-by: Peter Xu <peterx@redhat.com>
2017-04-21ram: Move bytes_transferred into RAMStateJuan Quintela1-18/+17
Signed-off-by: Juan Quintela <quintela@redhat.com> Reviewed-by: Dr. David Alan Gilbert <dgilbert@redhat.com> Reviewed-by: Peter Xu <peterx@redhat.com>