From: Juan Quintela <quintela@redhat.com>
To: qemu-devel@nongnu.org
Cc: dgilbert@redhat.com
Subject: [Qemu-devel] [PULL 39/65] ram: Move QEMUFile into RAMState
Date: Fri, 21 Apr 2017 13:56:20 +0200 [thread overview]
Message-ID: <20170421115646.15544-40-quintela@redhat.com> (raw)
In-Reply-To: <20170421115646.15544-1-quintela@redhat.com>
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>
---
migration/ram.c | 84 +++++++++++++++++++++++++--------------------------------
1 file changed, 37 insertions(+), 47 deletions(-)
diff --git a/migration/ram.c b/migration/ram.c
index 62b44cf..14d54fd 100644
--- a/migration/ram.c
+++ b/migration/ram.c
@@ -757,21 +757,20 @@ static void migration_bitmap_sync(RAMState *rs)
* Returns the number of pages written.
*
* @rs: current RAM state
- * @f: QEMUFile where to send the data
* @block: block that contains the page we want to send
* @offset: offset inside the block for the page
* @p: pointer to the page
*/
-static int save_zero_page(RAMState *rs, QEMUFile *f, RAMBlock *block,
- ram_addr_t offset, uint8_t *p)
+static int save_zero_page(RAMState *rs, RAMBlock *block, ram_addr_t offset,
+ uint8_t *p)
{
int pages = -1;
if (is_zero_range(p, TARGET_PAGE_SIZE)) {
rs->zero_pages++;
rs->bytes_transferred +=
- save_page_header(f, block, offset | RAM_SAVE_FLAG_COMPRESS);
- qemu_put_byte(f, 0);
+ save_page_header(rs->f, block, offset | RAM_SAVE_FLAG_COMPRESS);
+ qemu_put_byte(rs->f, 0);
rs->bytes_transferred += 1;
pages = 1;
}
@@ -799,12 +798,11 @@ static void ram_release_pages(MigrationState *ms, const char *rbname,
*
* @rs: current RAM state
* @ms: current migration state
- * @f: QEMUFile where to send the data
* @block: block that contains the page we want to send
* @offset: offset inside the block for the page
* @last_stage: if we are at the completion stage
*/
-static int ram_save_page(RAMState *rs, MigrationState *ms, QEMUFile *f,
+static int ram_save_page(RAMState *rs, MigrationState *ms,
PageSearchStatus *pss, bool last_stage)
{
int pages = -1;
@@ -820,7 +818,7 @@ static int ram_save_page(RAMState *rs, MigrationState *ms, QEMUFile *f,
/* In doubt sent page as normal */
bytes_xmit = 0;
- ret = ram_control_save_page(f, block->offset,
+ ret = ram_control_save_page(rs->f, block->offset,
offset, TARGET_PAGE_SIZE, &bytes_xmit);
if (bytes_xmit) {
rs->bytes_transferred += bytes_xmit;
@@ -843,7 +841,7 @@ static int ram_save_page(RAMState *rs, MigrationState *ms, QEMUFile *f,
}
}
} else {
- pages = save_zero_page(rs, f, block, offset, p);
+ pages = save_zero_page(rs, block, offset, p);
if (pages > 0) {
/* Must let xbzrle know, otherwise a previous (now 0'd) cached
* page would be stale
@@ -865,14 +863,14 @@ static int ram_save_page(RAMState *rs, MigrationState *ms, QEMUFile *f,
/* XBZRLE overflow or normal page */
if (pages == -1) {
- rs->bytes_transferred += save_page_header(f, block,
+ rs->bytes_transferred += save_page_header(rs->f, block,
offset | RAM_SAVE_FLAG_PAGE);
if (send_async) {
- qemu_put_buffer_async(f, p, TARGET_PAGE_SIZE,
+ qemu_put_buffer_async(rs->f, p, TARGET_PAGE_SIZE,
migrate_release_ram() &
migration_in_postcopy(ms));
} else {
- qemu_put_buffer(f, p, TARGET_PAGE_SIZE);
+ qemu_put_buffer(rs->f, p, TARGET_PAGE_SIZE);
}
rs->bytes_transferred += TARGET_PAGE_SIZE;
pages = 1;
@@ -907,7 +905,7 @@ static int do_compress_ram_page(QEMUFile *f, RAMBlock *block,
return bytes_sent;
}
-static void flush_compressed_data(RAMState *rs, QEMUFile *f)
+static void flush_compressed_data(RAMState *rs)
{
int idx, len, thread_count;
@@ -927,7 +925,7 @@ static void flush_compressed_data(RAMState *rs, QEMUFile *f)
for (idx = 0; idx < thread_count; idx++) {
qemu_mutex_lock(&comp_param[idx].mutex);
if (!comp_param[idx].quit) {
- len = qemu_put_qemu_file(f, comp_param[idx].file);
+ len = qemu_put_qemu_file(rs->f, comp_param[idx].file);
rs->bytes_transferred += len;
}
qemu_mutex_unlock(&comp_param[idx].mutex);
@@ -941,8 +939,8 @@ static inline void set_compress_params(CompressParam *param, RAMBlock *block,
param->offset = offset;
}
-static int compress_page_with_multi_thread(RAMState *rs, QEMUFile *f,
- RAMBlock *block, ram_addr_t offset)
+static int compress_page_with_multi_thread(RAMState *rs, RAMBlock *block,
+ ram_addr_t offset)
{
int idx, thread_count, bytes_xmit = -1, pages = -1;
@@ -952,7 +950,7 @@ static int compress_page_with_multi_thread(RAMState *rs, QEMUFile *f,
for (idx = 0; idx < thread_count; idx++) {
if (comp_param[idx].done) {
comp_param[idx].done = false;
- bytes_xmit = qemu_put_qemu_file(f, comp_param[idx].file);
+ bytes_xmit = qemu_put_qemu_file(rs->f, comp_param[idx].file);
qemu_mutex_lock(&comp_param[idx].mutex);
set_compress_params(&comp_param[idx], block, offset);
qemu_cond_signal(&comp_param[idx].cond);
@@ -981,13 +979,11 @@ static int compress_page_with_multi_thread(RAMState *rs, QEMUFile *f,
*
* @rs: current RAM state
* @ms: current migration state
- * @f: QEMUFile where to send the data
* @block: block that contains the page we want to send
* @offset: offset inside the block for the page
* @last_stage: if we are at the completion stage
*/
static int ram_save_compressed_page(RAMState *rs, MigrationState *ms,
- QEMUFile *f,
PageSearchStatus *pss, bool last_stage)
{
int pages = -1;
@@ -999,7 +995,7 @@ static int ram_save_compressed_page(RAMState *rs, MigrationState *ms,
p = block->host + offset;
- ret = ram_control_save_page(f, block->offset,
+ ret = ram_control_save_page(rs->f, block->offset,
offset, TARGET_PAGE_SIZE, &bytes_xmit);
if (bytes_xmit) {
rs->bytes_transferred += bytes_xmit;
@@ -1021,20 +1017,20 @@ static int ram_save_compressed_page(RAMState *rs, MigrationState *ms,
* is used to avoid resending the block name.
*/
if (block != rs->last_sent_block) {
- flush_compressed_data(rs, f);
- pages = save_zero_page(rs, f, block, offset, p);
+ flush_compressed_data(rs);
+ pages = save_zero_page(rs, block, offset, p);
if (pages == -1) {
/* Make sure the first page is sent out before other pages */
- bytes_xmit = save_page_header(f, block, offset |
+ bytes_xmit = save_page_header(rs->f, block, offset |
RAM_SAVE_FLAG_COMPRESS_PAGE);
- blen = qemu_put_compression_data(f, p, TARGET_PAGE_SIZE,
+ blen = qemu_put_compression_data(rs->f, p, TARGET_PAGE_SIZE,
migrate_compress_level());
if (blen > 0) {
rs->bytes_transferred += bytes_xmit + blen;
rs->norm_pages++;
pages = 1;
} else {
- qemu_file_set_error(f, blen);
+ qemu_file_set_error(rs->f, blen);
error_report("compressed data failed!");
}
}
@@ -1043,9 +1039,9 @@ static int ram_save_compressed_page(RAMState *rs, MigrationState *ms,
}
} else {
offset |= RAM_SAVE_FLAG_CONTINUE;
- pages = save_zero_page(rs, f, block, offset, p);
+ pages = save_zero_page(rs, block, offset, p);
if (pages == -1) {
- pages = compress_page_with_multi_thread(rs, f, block, offset);
+ pages = compress_page_with_multi_thread(rs, block, offset);
} else {
ram_release_pages(ms, block->idstr, pss->offset, pages);
}
@@ -1062,13 +1058,12 @@ static int ram_save_compressed_page(RAMState *rs, MigrationState *ms,
* Returns if a page is found
*
* @rs: current RAM state
- * @f: QEMUFile where to send the data
* @pss: data about the state of the current dirty page scan
* @again: set to false if the search has scanned the whole of RAM
* @ram_addr_abs: pointer into which to store the address of the dirty page
* within the global ram_addr space
*/
-static bool find_dirty_block(RAMState *rs, QEMUFile *f, PageSearchStatus *pss,
+static bool find_dirty_block(RAMState *rs, PageSearchStatus *pss,
bool *again, ram_addr_t *ram_addr_abs)
{
pss->offset = migration_bitmap_find_dirty(rs, pss->block, pss->offset,
@@ -1096,7 +1091,7 @@ static bool find_dirty_block(RAMState *rs, QEMUFile *f, PageSearchStatus *pss,
/* If xbzrle is on, stop using the data compression at this
* point. In theory, xbzrle can do better than compression.
*/
- flush_compressed_data(rs, f);
+ flush_compressed_data(rs);
compression_switch = false;
}
}
@@ -1317,12 +1312,11 @@ err:
*
* @rs: current RAM state
* @ms: current migration state
- * @f: QEMUFile where to send the data
* @pss: data about the page we want to send
* @last_stage: if we are at the completion stage
* @dirty_ram_abs: address of the start of the dirty page in ram_addr_t space
*/
-static int ram_save_target_page(RAMState *rs, MigrationState *ms, QEMUFile *f,
+static int ram_save_target_page(RAMState *rs, MigrationState *ms,
PageSearchStatus *pss,
bool last_stage,
ram_addr_t dirty_ram_abs)
@@ -1333,9 +1327,9 @@ static int ram_save_target_page(RAMState *rs, MigrationState *ms, QEMUFile *f,
if (migration_bitmap_clear_dirty(rs, dirty_ram_abs)) {
unsigned long *unsentmap;
if (compression_switch && migrate_use_compression()) {
- res = ram_save_compressed_page(rs, ms, f, pss, last_stage);
+ res = ram_save_compressed_page(rs, ms, pss, last_stage);
} else {
- res = ram_save_page(rs, ms, f, pss, last_stage);
+ res = ram_save_page(rs, ms, pss, last_stage);
}
if (res < 0) {
@@ -1370,12 +1364,11 @@ static int ram_save_target_page(RAMState *rs, MigrationState *ms, QEMUFile *f,
*
* @rs: current RAM state
* @ms: current migration state
- * @f: QEMUFile where to send the data
* @pss: data about the page we want to send
* @last_stage: if we are at the completion stage
* @dirty_ram_abs: Address of the start of the dirty page in ram_addr_t space
*/
-static int ram_save_host_page(RAMState *rs, MigrationState *ms, QEMUFile *f,
+static int ram_save_host_page(RAMState *rs, MigrationState *ms,
PageSearchStatus *pss,
bool last_stage,
ram_addr_t dirty_ram_abs)
@@ -1384,8 +1377,7 @@ static int ram_save_host_page(RAMState *rs, MigrationState *ms, QEMUFile *f,
size_t pagesize = qemu_ram_pagesize(pss->block);
do {
- tmppages = ram_save_target_page(rs, ms, f, pss, last_stage,
- dirty_ram_abs);
+ tmppages = ram_save_target_page(rs, ms, pss, last_stage, dirty_ram_abs);
if (tmppages < 0) {
return tmppages;
}
@@ -1408,14 +1400,13 @@ static int ram_save_host_page(RAMState *rs, MigrationState *ms, QEMUFile *f,
* Returns the number of pages written where zero means no dirty pages
*
* @rs: current RAM state
- * @f: QEMUFile where to send the data
* @last_stage: if we are at the completion stage
*
* On systems where host-page-size > target-page-size it will send all the
* pages in a host page that are dirty.
*/
-static int ram_find_and_save_block(RAMState *rs, QEMUFile *f, bool last_stage)
+static int ram_find_and_save_block(RAMState *rs, bool last_stage)
{
PageSearchStatus pss;
MigrationState *ms = migrate_get_current();
@@ -1443,12 +1434,11 @@ static int ram_find_and_save_block(RAMState *rs, QEMUFile *f, bool last_stage)
if (!found) {
/* priority queue empty, so just search for something dirty */
- found = find_dirty_block(rs, f, &pss, &again, &dirty_ram_abs);
+ found = find_dirty_block(rs, &pss, &again, &dirty_ram_abs);
}
if (found) {
- pages = ram_save_host_page(rs, ms, f, &pss, last_stage,
- dirty_ram_abs);
+ pages = ram_save_host_page(rs, ms, &pss, last_stage, dirty_ram_abs);
}
} while (!pages && again);
@@ -2148,7 +2138,7 @@ static int ram_save_iterate(QEMUFile *f, void *opaque)
while ((ret = qemu_file_rate_limit(f)) == 0) {
int pages;
- pages = ram_find_and_save_block(rs, f, false);
+ pages = ram_find_and_save_block(rs, false);
/* no more pages to sent */
if (pages == 0) {
done = 1;
@@ -2170,7 +2160,7 @@ static int ram_save_iterate(QEMUFile *f, void *opaque)
}
i++;
}
- flush_compressed_data(rs, f);
+ flush_compressed_data(rs);
rcu_read_unlock();
/*
@@ -2218,14 +2208,14 @@ static int ram_save_complete(QEMUFile *f, void *opaque)
while (true) {
int pages;
- pages = ram_find_and_save_block(rs, f, !migration_in_colo_state());
+ pages = ram_find_and_save_block(rs, !migration_in_colo_state());
/* no more blocks to sent */
if (pages == 0) {
break;
}
}
- flush_compressed_data(rs, f);
+ flush_compressed_data(rs);
ram_control_after_iterate(f, RAM_CONTROL_FINISH);
rcu_read_unlock();
--
2.9.3
next prev parent reply other threads:[~2017-04-21 11:58 UTC|newest]
Thread overview: 67+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-04-21 11:55 [Qemu-devel] [PULL 00/65] Migration pull request Juan Quintela
2017-04-21 11:55 ` [Qemu-devel] [PULL 01/65] ram: Update all functions comments Juan Quintela
2017-04-21 11:55 ` [Qemu-devel] [PULL 02/65] ram: Rename flush_page_queue() to migration_page_queue_free() Juan Quintela
2017-04-21 11:55 ` [Qemu-devel] [PULL 03/65] ram: Rename block_name to rbname Juan Quintela
2017-04-21 11:55 ` [Qemu-devel] [PULL 04/65] ram: Create RAMState Juan Quintela
2017-04-21 11:55 ` [Qemu-devel] [PULL 05/65] ram: Add dirty_rate_high_cnt to RAMState Juan Quintela
2017-04-21 11:55 ` [Qemu-devel] [PULL 06/65] ram: Move bitmap_sync_count into RAMState Juan Quintela
2017-04-21 11:55 ` [Qemu-devel] [PULL 07/65] ram: Move start time " Juan Quintela
2017-04-21 11:55 ` [Qemu-devel] [PULL 08/65] ram: Move bytes_xfer_prev " Juan Quintela
2017-04-21 11:55 ` [Qemu-devel] [PULL 09/65] ram: Change byte_xfer_{prev, now} type to uint64_t Juan Quintela
2017-04-21 11:55 ` [Qemu-devel] [PULL 10/65] ram: Move num_dirty_pages_period into RAMState Juan Quintela
2017-04-21 11:55 ` [Qemu-devel] [PULL 11/65] ram: Change num_dirty_pages_period type to uint64_t Juan Quintela
2017-04-21 11:55 ` [Qemu-devel] [PULL 12/65] ram: Move xbzrle_cache_miss_prev into RAMState Juan Quintela
2017-04-21 11:55 ` [Qemu-devel] [PULL 13/65] ram: Move iterations_prev " Juan Quintela
2017-04-21 11:55 ` [Qemu-devel] [PULL 14/65] ram: Move dup_pages " Juan Quintela
2017-04-21 11:55 ` [Qemu-devel] [PULL 15/65] ram: Remove unused dup_mig_bytes_transferred() Juan Quintela
2017-04-21 11:55 ` [Qemu-devel] [PULL 16/65] ram: Remove unused pages_skipped variable Juan Quintela
2017-04-21 11:55 ` [Qemu-devel] [PULL 17/65] ram: Move norm_pages to RAMState Juan Quintela
2017-04-21 11:55 ` [Qemu-devel] [PULL 18/65] ram: Remove norm_mig_bytes_transferred Juan Quintela
2017-04-21 11:56 ` [Qemu-devel] [PULL 19/65] ram: Move iterations into RAMState Juan Quintela
2017-04-21 11:56 ` [Qemu-devel] [PULL 20/65] ram: Move xbzrle_bytes " Juan Quintela
2017-04-21 11:56 ` [Qemu-devel] [PULL 21/65] ram: Move xbzrle_pages " Juan Quintela
2017-04-21 11:56 ` [Qemu-devel] [PULL 22/65] ram: Move xbzrle_cache_miss " Juan Quintela
2017-04-21 11:56 ` [Qemu-devel] [PULL 23/65] ram: Move xbzrle_cache_miss_rate " Juan Quintela
2017-04-21 11:56 ` [Qemu-devel] [PULL 24/65] ram: Move xbzrle_overflows " Juan Quintela
2017-04-21 11:56 ` [Qemu-devel] [PULL 25/65] ram: Move migration_dirty_pages to RAMState Juan Quintela
2017-04-21 11:56 ` [Qemu-devel] [PULL 26/65] ram: Everything was init to zero, so use memset Juan Quintela
2017-04-21 11:56 ` [Qemu-devel] [PULL 27/65] ram: Move migration_bitmap_mutex into RAMState Juan Quintela
2017-04-21 11:56 ` [Qemu-devel] [PULL 28/65] ram: Move migration_bitmap_rcu " Juan Quintela
2017-04-21 11:56 ` [Qemu-devel] [PULL 29/65] ram: Move bytes_transferred " Juan Quintela
2017-04-21 11:56 ` [Qemu-devel] [PULL 30/65] ram: Use the RAMState bytes_transferred parameter Juan Quintela
2017-04-21 11:56 ` [Qemu-devel] [PULL 31/65] ram: Remove ram_save_remaining Juan Quintela
2017-04-21 11:56 ` [Qemu-devel] [PULL 32/65] ram: Move last_req_rb to RAMState Juan Quintela
2017-04-21 11:56 ` [Qemu-devel] [PULL 33/65] ram: Move src_page_req* " Juan Quintela
2017-04-21 11:56 ` [Qemu-devel] [PULL 34/65] ram: Create ram_dirty_sync_count() Juan Quintela
2017-04-21 11:56 ` [Qemu-devel] [PULL 35/65] ram: Remove dirty_bytes_rate Juan Quintela
2017-04-21 11:56 ` [Qemu-devel] [PULL 36/65] ram: Move dirty_pages_rate to RAMState Juan Quintela
2017-04-21 11:56 ` [Qemu-devel] [PULL 37/65] ram: Move postcopy_requests into RAMState Juan Quintela
2017-04-21 11:56 ` [Qemu-devel] [PULL 38/65] ram: Add QEMUFile to RAMState Juan Quintela
2017-04-21 11:56 ` Juan Quintela [this message]
2017-04-21 11:56 ` [Qemu-devel] [PULL 40/65] ram: Remove compression_switch and inline its logic Juan Quintela
2017-04-21 11:56 ` [Qemu-devel] [PULL 41/65] migration: Remove MigrationState from migration_in_postcopy Juan Quintela
2017-04-21 11:56 ` [Qemu-devel] [PULL 42/65] ram: We don't need MigrationState parameter anymore Juan Quintela
2017-04-21 11:56 ` [Qemu-devel] [PULL 43/65] ram: Rename qemu_target_page_bits() to qemu_target_page_size() Juan Quintela
2017-04-21 11:56 ` [Qemu-devel] [PULL 44/65] ram: Add page-size to output in 'info migrate' Juan Quintela
2017-04-21 11:56 ` [Qemu-devel] [PULL 45/65] ram: Pass RAMBlock to bitmap_sync Juan Quintela
2017-04-21 11:56 ` [Qemu-devel] [PULL 46/65] ram: ram_discard_range() don't use the mis parameter Juan Quintela
2017-04-21 11:56 ` [Qemu-devel] [PULL 47/65] ram: reorganize last_sent_block Juan Quintela
2017-04-21 11:56 ` [Qemu-devel] [PULL 48/65] ram: Use page number instead of an address for the bitmap operations Juan Quintela
2017-04-21 11:56 ` [Qemu-devel] [PULL 49/65] ram: Remember last_page instead of last_offset Juan Quintela
2017-04-21 11:56 ` [Qemu-devel] [PULL 50/65] ram: Change offset field in PageSearchStatus to page Juan Quintela
2017-04-21 11:56 ` [Qemu-devel] [PULL 51/65] ram: Use ramblock and page offset instead of absolute offset Juan Quintela
2017-04-21 11:56 ` [Qemu-devel] [PULL 52/65] ram: rename last_ram_offset() last_ram_pages() Juan Quintela
2017-04-21 11:56 ` [Qemu-devel] [PULL 53/65] ram: Use RAMBitmap type for coherence Juan Quintela
2017-04-21 11:56 ` [Qemu-devel] [PULL 54/65] migration: Remove MigrationState parameter from migration_is_idle() Juan Quintela
2017-04-21 11:56 ` [Qemu-devel] [PULL 55/65] qdev: qdev_hotplug is really a bool Juan Quintela
2017-04-21 11:56 ` [Qemu-devel] [PULL 56/65] qdev: Export qdev_hot_removed Juan Quintela
2017-04-21 11:56 ` [Qemu-devel] [PULL 57/65] qdev: Move qdev_unplug() to qdev-monitor.c Juan Quintela
2017-04-21 11:56 ` [Qemu-devel] [PULL 58/65] migration: Disable hotplug/unplug during migration Juan Quintela
2017-04-21 11:56 ` [Qemu-devel] [PULL 59/65] ram: Remove migration_bitmap_extend() Juan Quintela
2017-04-21 11:56 ` [Qemu-devel] [PULL 60/65] migration: don't close a file descriptor while it can be in use Juan Quintela
2017-04-21 11:56 ` [Qemu-devel] [PULL 61/65] virtio-rng: stop virtqueue while the CPU is stopped Juan Quintela
2017-04-21 11:56 ` [Qemu-devel] [PULL 62/65] migration: set current_active_state once Juan Quintela
2017-04-21 11:56 ` [Qemu-devel] [PULL 63/65] migration: rename max_size to threshold_size Juan Quintela
2017-04-21 11:56 ` [Qemu-devel] [PULL 64/65] hmp: info migrate_capability format tunes Juan Quintela
2017-04-21 11:56 ` [Qemu-devel] [PULL 65/65] hmp: info migrate_parameters " Juan Quintela
2017-04-21 16:09 ` [Qemu-devel] [PULL 00/65] Migration pull request Peter Maydell
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20170421115646.15544-40-quintela@redhat.com \
--to=quintela@redhat.com \
--cc=dgilbert@redhat.com \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).