提交 f36d55af 编写于 作者: O Orit Wasserman 提交者: Juan Quintela
上级 004d4c10
...@@ -206,6 +206,10 @@ typedef struct AccountingInfo { ...@@ -206,6 +206,10 @@ typedef struct AccountingInfo {
uint64_t dup_pages; uint64_t dup_pages;
uint64_t norm_pages; uint64_t norm_pages;
uint64_t iterations; uint64_t iterations;
uint64_t xbzrle_bytes;
uint64_t xbzrle_pages;
uint64_t xbzrle_cache_miss;
uint64_t xbzrle_overflows;
} AccountingInfo; } AccountingInfo;
static AccountingInfo acct_info; static AccountingInfo acct_info;
...@@ -235,6 +239,26 @@ uint64_t norm_mig_pages_transferred(void) ...@@ -235,6 +239,26 @@ uint64_t norm_mig_pages_transferred(void)
return acct_info.norm_pages; return acct_info.norm_pages;
} }
uint64_t xbzrle_mig_bytes_transferred(void)
{
return acct_info.xbzrle_bytes;
}
uint64_t xbzrle_mig_pages_transferred(void)
{
return acct_info.xbzrle_pages;
}
uint64_t xbzrle_mig_pages_cache_miss(void)
{
return acct_info.xbzrle_cache_miss;
}
uint64_t xbzrle_mig_pages_overflow(void)
{
return acct_info.xbzrle_overflows;
}
static void save_block_hdr(QEMUFile *f, RAMBlock *block, ram_addr_t offset, static void save_block_hdr(QEMUFile *f, RAMBlock *block, ram_addr_t offset,
int cont, int flag) int cont, int flag)
{ {
...@@ -259,6 +283,7 @@ static int save_xbzrle_page(QEMUFile *f, uint8_t *current_data, ...@@ -259,6 +283,7 @@ static int save_xbzrle_page(QEMUFile *f, uint8_t *current_data,
if (!cache_is_cached(XBZRLE.cache, current_addr)) { if (!cache_is_cached(XBZRLE.cache, current_addr)) {
cache_insert(XBZRLE.cache, current_addr, cache_insert(XBZRLE.cache, current_addr,
g_memdup(current_data, TARGET_PAGE_SIZE)); g_memdup(current_data, TARGET_PAGE_SIZE));
acct_info.xbzrle_cache_miss++;
return -1; return -1;
} }
...@@ -276,6 +301,7 @@ static int save_xbzrle_page(QEMUFile *f, uint8_t *current_data, ...@@ -276,6 +301,7 @@ static int save_xbzrle_page(QEMUFile *f, uint8_t *current_data,
return 0; return 0;
} else if (encoded_len == -1) { } else if (encoded_len == -1) {
DPRINTF("Overflow\n"); DPRINTF("Overflow\n");
acct_info.xbzrle_overflows++;
/* update data in the cache */ /* update data in the cache */
memcpy(prev_cached_page, current_data, TARGET_PAGE_SIZE); memcpy(prev_cached_page, current_data, TARGET_PAGE_SIZE);
return -1; return -1;
...@@ -290,6 +316,8 @@ static int save_xbzrle_page(QEMUFile *f, uint8_t *current_data, ...@@ -290,6 +316,8 @@ static int save_xbzrle_page(QEMUFile *f, uint8_t *current_data,
qemu_put_be16(f, encoded_len); qemu_put_be16(f, encoded_len);
qemu_put_buffer(f, XBZRLE.encoded_buf, encoded_len); qemu_put_buffer(f, XBZRLE.encoded_buf, encoded_len);
bytes_sent = encoded_len + 1 + 2; bytes_sent = encoded_len + 1 + 2;
acct_info.xbzrle_pages++;
acct_info.xbzrle_bytes += bytes_sent;
return bytes_sent; return bytes_sent;
} }
......
...@@ -177,6 +177,19 @@ void hmp_info_migrate(Monitor *mon) ...@@ -177,6 +177,19 @@ void hmp_info_migrate(Monitor *mon)
info->disk->total >> 10); info->disk->total >> 10);
} }
if (info->has_xbzrle_cache) {
monitor_printf(mon, "cache size: %" PRIu64 " bytes\n",
info->xbzrle_cache->cache_size);
monitor_printf(mon, "xbzrle transferred: %" PRIu64 " kbytes\n",
info->xbzrle_cache->bytes >> 10);
monitor_printf(mon, "xbzrle pages: %" PRIu64 " pages\n",
info->xbzrle_cache->pages);
monitor_printf(mon, "xbzrle cache miss: %" PRIu64 "\n",
info->xbzrle_cache->cache_miss);
monitor_printf(mon, "xbzrle overflow : %" PRIu64 "\n",
info->xbzrle_cache->overflow);
}
qapi_free_MigrationInfo(info); qapi_free_MigrationInfo(info);
qapi_free_MigrationCapabilityStatusList(caps); qapi_free_MigrationCapabilityStatusList(caps);
} }
......
...@@ -141,6 +141,19 @@ MigrationCapabilityStatusList *qmp_query_migrate_capabilities(Error **errp) ...@@ -141,6 +141,19 @@ MigrationCapabilityStatusList *qmp_query_migrate_capabilities(Error **errp)
return head; return head;
} }
static void get_xbzrle_cache_stats(MigrationInfo *info)
{
if (migrate_use_xbzrle()) {
info->has_xbzrle_cache = true;
info->xbzrle_cache = g_malloc0(sizeof(*info->xbzrle_cache));
info->xbzrle_cache->cache_size = migrate_xbzrle_cache_size();
info->xbzrle_cache->bytes = xbzrle_mig_bytes_transferred();
info->xbzrle_cache->pages = xbzrle_mig_pages_transferred();
info->xbzrle_cache->cache_miss = xbzrle_mig_pages_cache_miss();
info->xbzrle_cache->overflow = xbzrle_mig_pages_overflow();
}
}
MigrationInfo *qmp_query_migrate(Error **errp) MigrationInfo *qmp_query_migrate(Error **errp)
{ {
MigrationInfo *info = g_malloc0(sizeof(*info)); MigrationInfo *info = g_malloc0(sizeof(*info));
...@@ -172,8 +185,12 @@ MigrationInfo *qmp_query_migrate(Error **errp) ...@@ -172,8 +185,12 @@ MigrationInfo *qmp_query_migrate(Error **errp)
info->disk->remaining = blk_mig_bytes_remaining(); info->disk->remaining = blk_mig_bytes_remaining();
info->disk->total = blk_mig_bytes_total(); info->disk->total = blk_mig_bytes_total();
} }
get_xbzrle_cache_stats(info);
break; break;
case MIG_STATE_COMPLETED: case MIG_STATE_COMPLETED:
get_xbzrle_cache_stats(info);
info->has_status = true; info->has_status = true;
info->status = g_strdup("completed"); info->status = g_strdup("completed");
......
...@@ -91,6 +91,10 @@ uint64_t dup_mig_bytes_transferred(void); ...@@ -91,6 +91,10 @@ uint64_t dup_mig_bytes_transferred(void);
uint64_t dup_mig_pages_transferred(void); uint64_t dup_mig_pages_transferred(void);
uint64_t norm_mig_bytes_transferred(void); uint64_t norm_mig_bytes_transferred(void);
uint64_t norm_mig_pages_transferred(void); uint64_t norm_mig_pages_transferred(void);
uint64_t xbzrle_mig_bytes_transferred(void);
uint64_t xbzrle_mig_pages_transferred(void);
uint64_t xbzrle_mig_pages_overflow(void);
uint64_t xbzrle_mig_pages_cache_miss(void);
/** /**
* @migrate_add_blocker - prevent migration from proceeding * @migrate_add_blocker - prevent migration from proceeding
......
...@@ -277,6 +277,27 @@ ...@@ -277,6 +277,27 @@
'total-time': 'int', 'duplicate': 'int', 'normal': 'int', 'total-time': 'int', 'duplicate': 'int', 'normal': 'int',
'normal-bytes': 'int' } } 'normal-bytes': 'int' } }
##
# @XBZRLECacheStats
#
# Detailed XBZRLE migration cache statistics
#
# @cache-size: XBZRLE cache size
#
# @bytes: amount of bytes already transferred to the target VM
#
# @pages: amount of pages transferred to the target VM
#
# @cache-miss: number of cache miss
#
# @overflow: number of overflows
#
# Since: 1.2
##
{ 'type': 'XBZRLECacheStats',
'data': {'cache-size': 'int', 'bytes': 'int', 'pages': 'int',
'cache-miss': 'int', 'overflow': 'int' } }
## ##
# @MigrationInfo # @MigrationInfo
# #
...@@ -295,11 +316,16 @@ ...@@ -295,11 +316,16 @@
# status, only returned if status is 'active' and it is a block # status, only returned if status is 'active' and it is a block
# migration # migration
# #
# @xbzrle-cache: #optional @XBZRLECacheStats containing detailed XBZRLE
# migration statistics, only returned if XBZRLE feature is on and
# status is 'active' or 'completed' (since 1.2)
#
# Since: 0.14.0 # Since: 0.14.0
## ##
{ 'type': 'MigrationInfo', { 'type': 'MigrationInfo',
'data': {'*status': 'str', '*ram': 'MigrationStats', 'data': {'*status': 'str', '*ram': 'MigrationStats',
'*disk': 'MigrationStats'} } '*disk': 'MigrationStats',
'*xbzrle-cache': 'XBZRLECacheStats'} }
## ##
# @query-migrate # @query-migrate
......
...@@ -2133,7 +2133,13 @@ The main json-object contains the following: ...@@ -2133,7 +2133,13 @@ The main json-object contains the following:
- "transferred": amount transferred (json-int) - "transferred": amount transferred (json-int)
- "remaining": amount remaining (json-int) - "remaining": amount remaining (json-int)
- "total": total (json-int) - "total": total (json-int)
- "xbzrle-cache": only present if XBZRLE is active.
It is a json-object with the following XBZRLE information:
- "cache-size": XBZRLE cache size
- "bytes": total XBZRLE bytes transferred
- "pages": number of XBZRLE compressed pages
- "cache-miss": number of cache misses
- "overflow": number of XBZRLE overflows
Examples: Examples:
1. Before the first migration 1. Before the first migration
...@@ -2204,6 +2210,32 @@ Examples: ...@@ -2204,6 +2210,32 @@ Examples:
} }
} }
6. Migration is being performed and XBZRLE is active:
-> { "execute": "query-migrate" }
<- {
"return":{
"status":"active",
"capabilities" : [ { "capability": "xbzrle", "state" : true } ],
"ram":{
"total":1057024,
"remaining":1053304,
"transferred":3720,
"total-time":12345,
"duplicate":10,
"normal":3333,
"normal-bytes":3412992
},
"xbzrle-cache":{
"cache-size":67108864,
"bytes":20971520,
"pages":2444343,
"cache-miss":2244,
"overflow":34434
}
}
}
EQMP EQMP
{ {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册