mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-12-22 21:55:25 +00:00
qemu: Ignore missing memory statistics in query-migrate
We want to use query-migrate QMP command to check the current migration state when reconnecting to active domains, but the reply we get to this command may not contain any statistics at all if called on the destination host. Signed-off-by: Jiri Denemark <jdenemar@redhat.com> Reviewed-by: Peter Krempa <pkrempa@redhat.com> Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
This commit is contained in:
parent
6908f857f8
commit
c556d02551
@ -3249,56 +3249,49 @@ qemuMonitorJSONGetMigrationStatsReply(virJSONValue *reply,
|
||||
case QEMU_MONITOR_MIGRATION_STATUS_PRE_SWITCHOVER:
|
||||
case QEMU_MONITOR_MIGRATION_STATUS_DEVICE:
|
||||
ram = virJSONValueObjectGetObject(ret, "ram");
|
||||
if (!ram) {
|
||||
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
||||
_("migration was active, but no RAM info was set"));
|
||||
return -1;
|
||||
}
|
||||
if (ram) {
|
||||
if (virJSONValueObjectGetNumberUlong(ram, "transferred",
|
||||
&stats->ram_transferred) < 0) {
|
||||
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
||||
_("migration was active, but RAM 'transferred' data was missing"));
|
||||
return -1;
|
||||
}
|
||||
if (virJSONValueObjectGetNumberUlong(ram, "remaining",
|
||||
&stats->ram_remaining) < 0) {
|
||||
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
||||
_("migration was active, but RAM 'remaining' data was missing"));
|
||||
return -1;
|
||||
}
|
||||
if (virJSONValueObjectGetNumberUlong(ram, "total",
|
||||
&stats->ram_total) < 0) {
|
||||
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
||||
_("migration was active, but RAM 'total' data was missing"));
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (virJSONValueObjectGetNumberUlong(ram, "transferred",
|
||||
&stats->ram_transferred) < 0) {
|
||||
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
||||
_("migration was active, but RAM 'transferred' "
|
||||
"data was missing"));
|
||||
return -1;
|
||||
}
|
||||
if (virJSONValueObjectGetNumberUlong(ram, "remaining",
|
||||
&stats->ram_remaining) < 0) {
|
||||
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
||||
_("migration was active, but RAM 'remaining' "
|
||||
"data was missing"));
|
||||
return -1;
|
||||
}
|
||||
if (virJSONValueObjectGetNumberUlong(ram, "total",
|
||||
&stats->ram_total) < 0) {
|
||||
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
||||
_("migration was active, but RAM 'total' "
|
||||
"data was missing"));
|
||||
return -1;
|
||||
}
|
||||
if (virJSONValueObjectGetNumberDouble(ram, "mbps", &mbps) == 0 &&
|
||||
mbps > 0) {
|
||||
/* mpbs from QEMU reports Mbits/s (M as in 10^6 not Mi as 2^20) */
|
||||
stats->ram_bps = mbps * (1000 * 1000 / 8);
|
||||
}
|
||||
|
||||
if (virJSONValueObjectGetNumberDouble(ram, "mbps", &mbps) == 0 &&
|
||||
mbps > 0) {
|
||||
/* mpbs from QEMU reports Mbits/s (M as in 10^6 not Mi as 2^20) */
|
||||
stats->ram_bps = mbps * (1000 * 1000 / 8);
|
||||
if (virJSONValueObjectGetNumberUlong(ram, "duplicate",
|
||||
&stats->ram_duplicate) == 0)
|
||||
stats->ram_duplicate_set = true;
|
||||
ignore_value(virJSONValueObjectGetNumberUlong(ram, "normal",
|
||||
&stats->ram_normal));
|
||||
ignore_value(virJSONValueObjectGetNumberUlong(ram, "normal-bytes",
|
||||
&stats->ram_normal_bytes));
|
||||
ignore_value(virJSONValueObjectGetNumberUlong(ram, "dirty-pages-rate",
|
||||
&stats->ram_dirty_rate));
|
||||
ignore_value(virJSONValueObjectGetNumberUlong(ram, "page-size",
|
||||
&stats->ram_page_size));
|
||||
ignore_value(virJSONValueObjectGetNumberUlong(ram, "dirty-sync-count",
|
||||
&stats->ram_iteration));
|
||||
ignore_value(virJSONValueObjectGetNumberUlong(ram, "postcopy-requests",
|
||||
&stats->ram_postcopy_reqs));
|
||||
}
|
||||
|
||||
if (virJSONValueObjectGetNumberUlong(ram, "duplicate",
|
||||
&stats->ram_duplicate) == 0)
|
||||
stats->ram_duplicate_set = true;
|
||||
ignore_value(virJSONValueObjectGetNumberUlong(ram, "normal",
|
||||
&stats->ram_normal));
|
||||
ignore_value(virJSONValueObjectGetNumberUlong(ram, "normal-bytes",
|
||||
&stats->ram_normal_bytes));
|
||||
ignore_value(virJSONValueObjectGetNumberUlong(ram, "dirty-pages-rate",
|
||||
&stats->ram_dirty_rate));
|
||||
ignore_value(virJSONValueObjectGetNumberUlong(ram, "page-size",
|
||||
&stats->ram_page_size));
|
||||
ignore_value(virJSONValueObjectGetNumberUlong(ram, "dirty-sync-count",
|
||||
&stats->ram_iteration));
|
||||
ignore_value(virJSONValueObjectGetNumberUlong(ram, "postcopy-requests",
|
||||
&stats->ram_postcopy_reqs));
|
||||
|
||||
disk = virJSONValueObjectGetObject(ret, "disk");
|
||||
if (disk) {
|
||||
rc = virJSONValueObjectGetNumberUlong(disk, "transferred",
|
||||
|
Loading…
Reference in New Issue
Block a user