mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-22 04:25:18 +00:00
qemu: disk migration verbose progress
A virsh command like: migrate --live --copy-storage-all Guest qemu+ssh://user@host/system --persistent --verbose shows Migration: [ 0 %] during the storage copy and does not start counting until the ram transfer starts Fix this by scraping optional disk transfer status, and adding it into the progress meter.
This commit is contained in:
parent
531c858131
commit
108ca33357
1
AUTHORS
1
AUTHORS
@ -189,6 +189,7 @@ Patches have also been contributed by:
|
||||
Nan Zhang <nzhang@redhat.com>
|
||||
Wieland Hoffmann <themineo@googlemail.com>
|
||||
Douglas Schilling Landgraf <dougsland@redhat.com>
|
||||
Tom Vijlbrief <tom.vijlbrief@xs4all.nl>
|
||||
|
||||
[....send patches to get your name here....]
|
||||
|
||||
|
@ -1852,6 +1852,7 @@ qemuMonitorJSONGetMigrationStatusReply(virJSONValuePtr reply,
|
||||
{
|
||||
virJSONValuePtr ret;
|
||||
const char *statusstr;
|
||||
unsigned long long t;
|
||||
|
||||
if (!(ret = virJSONValueObjectGet(reply, "return"))) {
|
||||
qemuReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
||||
@ -1879,21 +1880,52 @@ qemuMonitorJSONGetMigrationStatusReply(virJSONValuePtr reply,
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (virJSONValueObjectGetNumberUlong(ram, "transferred", transferred) < 0) {
|
||||
if (virJSONValueObjectGetNumberUlong(ram, "transferred",
|
||||
transferred) < 0) {
|
||||
qemuReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
||||
_("migration was active, but RAM 'transferred' data was missing"));
|
||||
_("migration was active, but RAM 'transferred' "
|
||||
"data was missing"));
|
||||
return -1;
|
||||
}
|
||||
if (virJSONValueObjectGetNumberUlong(ram, "remaining", remaining) < 0) {
|
||||
qemuReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
||||
_("migration was active, but RAM 'remaining' data was missing"));
|
||||
_("migration was active, but RAM 'remaining' "
|
||||
"data was missing"));
|
||||
return -1;
|
||||
}
|
||||
if (virJSONValueObjectGetNumberUlong(ram, "total", total) < 0) {
|
||||
qemuReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
||||
_("migration was active, but RAM 'total' data was missing"));
|
||||
_("migration was active, but RAM 'total' "
|
||||
"data was missing"));
|
||||
return -1;
|
||||
}
|
||||
|
||||
virJSONValuePtr disk = virJSONValueObjectGet(ret, "disk");
|
||||
if (!disk) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (virJSONValueObjectGetNumberUlong(disk, "transferred", &t) < 0) {
|
||||
qemuReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
||||
_("disk migration was active, but 'transferred' "
|
||||
"data was missing"));
|
||||
return -1;
|
||||
}
|
||||
*transferred += t;
|
||||
if (virJSONValueObjectGetNumberUlong(disk, "remaining", &t) < 0) {
|
||||
qemuReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
||||
_("disk migration was active, but 'remaining' "
|
||||
"data was missing"));
|
||||
return -1;
|
||||
}
|
||||
*remaining += t;
|
||||
if (virJSONValueObjectGetNumberUlong(disk, "total", &t) < 0) {
|
||||
qemuReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
||||
_("disk migration was active, but 'total' "
|
||||
"data was missing"));
|
||||
return -1;
|
||||
}
|
||||
*total += t;
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
@ -149,7 +149,7 @@ int qemuMonitorTextIOProcess(qemuMonitorPtr mon ATTRIBUTE_UNUSED,
|
||||
passwd = strstr(start, PASSWORD_PROMPT);
|
||||
if (passwd) {
|
||||
#if DEBUG_IO
|
||||
VIR_DEBUG("Seen a passwowrd prompt [%s]", data + used);
|
||||
VIR_DEBUG("Seen a password prompt [%s]", data + used);
|
||||
#endif
|
||||
if (msg->passwordHandler) {
|
||||
int i;
|
||||
@ -1183,6 +1183,9 @@ cleanup:
|
||||
#define MIGRATION_TRANSFER_PREFIX "transferred ram: "
|
||||
#define MIGRATION_REMAINING_PREFIX "remaining ram: "
|
||||
#define MIGRATION_TOTAL_PREFIX "total ram: "
|
||||
#define MIGRATION_DISK_TRANSFER_PREFIX "transferred disk: "
|
||||
#define MIGRATION_DISK_REMAINING_PREFIX "remaining disk: "
|
||||
#define MIGRATION_DISK_TOTAL_PREFIX "total disk: "
|
||||
|
||||
int qemuMonitorTextGetMigrationStatus(qemuMonitorPtr mon,
|
||||
int *status,
|
||||
@ -1192,6 +1195,9 @@ int qemuMonitorTextGetMigrationStatus(qemuMonitorPtr mon,
|
||||
char *reply;
|
||||
char *tmp;
|
||||
char *end;
|
||||
unsigned long long disk_transferred = 0;
|
||||
unsigned long long disk_remaining = 0;
|
||||
unsigned long long disk_total = 0;
|
||||
int ret = -1;
|
||||
|
||||
*status = QEMU_MONITOR_MIGRATION_STATUS_INACTIVE;
|
||||
@ -1230,7 +1236,8 @@ int qemuMonitorTextGetMigrationStatus(qemuMonitorPtr mon,
|
||||
|
||||
if (virStrToLong_ull(tmp, &end, 10, transferred) < 0) {
|
||||
qemuReportError(VIR_ERR_INTERNAL_ERROR,
|
||||
_("cannot parse migration data transferred statistic %s"), tmp);
|
||||
_("cannot parse migration data transferred "
|
||||
"statistic %s"), tmp);
|
||||
goto cleanup;
|
||||
}
|
||||
*transferred *= 1024;
|
||||
@ -1242,10 +1249,12 @@ int qemuMonitorTextGetMigrationStatus(qemuMonitorPtr mon,
|
||||
|
||||
if (virStrToLong_ull(tmp, &end, 10, remaining) < 0) {
|
||||
qemuReportError(VIR_ERR_INTERNAL_ERROR,
|
||||
_("cannot parse migration data remaining statistic %s"), tmp);
|
||||
_("cannot parse migration data remaining "
|
||||
"statistic %s"), tmp);
|
||||
goto cleanup;
|
||||
}
|
||||
*remaining *= 1024;
|
||||
tmp = end;
|
||||
|
||||
if (!(tmp = strstr(tmp, MIGRATION_TOTAL_PREFIX)))
|
||||
goto done;
|
||||
@ -1253,11 +1262,53 @@ int qemuMonitorTextGetMigrationStatus(qemuMonitorPtr mon,
|
||||
|
||||
if (virStrToLong_ull(tmp, &end, 10, total) < 0) {
|
||||
qemuReportError(VIR_ERR_INTERNAL_ERROR,
|
||||
_("cannot parse migration data total statistic %s"), tmp);
|
||||
_("cannot parse migration data total "
|
||||
"statistic %s"), tmp);
|
||||
goto cleanup;
|
||||
}
|
||||
*total *= 1024;
|
||||
tmp = end;
|
||||
|
||||
/*
|
||||
* Check for Optional Disk Migration status
|
||||
*/
|
||||
if (!(tmp = strstr(tmp, MIGRATION_DISK_TRANSFER_PREFIX)))
|
||||
goto done;
|
||||
tmp += strlen(MIGRATION_DISK_TRANSFER_PREFIX);
|
||||
|
||||
if (virStrToLong_ull(tmp, &end, 10, &disk_transferred) < 0) {
|
||||
qemuReportError(VIR_ERR_INTERNAL_ERROR,
|
||||
_("cannot parse disk migration data "
|
||||
"transferred statistic %s"), tmp);
|
||||
goto cleanup;
|
||||
}
|
||||
*transferred += disk_transferred * 1024;
|
||||
tmp = end;
|
||||
|
||||
if (!(tmp = strstr(tmp, MIGRATION_DISK_REMAINING_PREFIX)))
|
||||
goto done;
|
||||
tmp += strlen(MIGRATION_DISK_REMAINING_PREFIX);
|
||||
|
||||
if (virStrToLong_ull(tmp, &end, 10, &disk_remaining) < 0) {
|
||||
qemuReportError(VIR_ERR_INTERNAL_ERROR,
|
||||
_("cannot parse disk migration data remaining "
|
||||
"statistic %s"), tmp);
|
||||
goto cleanup;
|
||||
}
|
||||
*remaining += disk_remaining * 1024;
|
||||
tmp = end;
|
||||
|
||||
if (!(tmp = strstr(tmp, MIGRATION_DISK_TOTAL_PREFIX)))
|
||||
goto done;
|
||||
tmp += strlen(MIGRATION_DISK_TOTAL_PREFIX);
|
||||
|
||||
if (virStrToLong_ull(tmp, &end, 10, &disk_total) < 0) {
|
||||
qemuReportError(VIR_ERR_INTERNAL_ERROR,
|
||||
_("cannot parse disk migration data total "
|
||||
"statistic %s"), tmp);
|
||||
goto cleanup;
|
||||
}
|
||||
*total += disk_total * 1024;
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user