提交 108ca333 编写于 作者: T Tom Vijlbrief 提交者: Eric Blake

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.
上级 531c8581
...@@ -189,6 +189,7 @@ Patches have also been contributed by: ...@@ -189,6 +189,7 @@ Patches have also been contributed by:
Nan Zhang <nzhang@redhat.com> Nan Zhang <nzhang@redhat.com>
Wieland Hoffmann <themineo@googlemail.com> Wieland Hoffmann <themineo@googlemail.com>
Douglas Schilling Landgraf <dougsland@redhat.com> Douglas Schilling Landgraf <dougsland@redhat.com>
Tom Vijlbrief <tom.vijlbrief@xs4all.nl>
[....send patches to get your name here....] [....send patches to get your name here....]
......
...@@ -1852,6 +1852,7 @@ qemuMonitorJSONGetMigrationStatusReply(virJSONValuePtr reply, ...@@ -1852,6 +1852,7 @@ qemuMonitorJSONGetMigrationStatusReply(virJSONValuePtr reply,
{ {
virJSONValuePtr ret; virJSONValuePtr ret;
const char *statusstr; const char *statusstr;
unsigned long long t;
if (!(ret = virJSONValueObjectGet(reply, "return"))) { if (!(ret = virJSONValueObjectGet(reply, "return"))) {
qemuReportError(VIR_ERR_INTERNAL_ERROR, "%s", qemuReportError(VIR_ERR_INTERNAL_ERROR, "%s",
...@@ -1879,21 +1880,52 @@ qemuMonitorJSONGetMigrationStatusReply(virJSONValuePtr reply, ...@@ -1879,21 +1880,52 @@ qemuMonitorJSONGetMigrationStatusReply(virJSONValuePtr reply,
return -1; return -1;
} }
if (virJSONValueObjectGetNumberUlong(ram, "transferred", transferred) < 0) { if (virJSONValueObjectGetNumberUlong(ram, "transferred",
transferred) < 0) {
qemuReportError(VIR_ERR_INTERNAL_ERROR, "%s", 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; return -1;
} }
if (virJSONValueObjectGetNumberUlong(ram, "remaining", remaining) < 0) { if (virJSONValueObjectGetNumberUlong(ram, "remaining", remaining) < 0) {
qemuReportError(VIR_ERR_INTERNAL_ERROR, "%s", 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; return -1;
} }
if (virJSONValueObjectGetNumberUlong(ram, "total", total) < 0) { if (virJSONValueObjectGetNumberUlong(ram, "total", total) < 0) {
qemuReportError(VIR_ERR_INTERNAL_ERROR, "%s", 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; 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; return 0;
......
...@@ -149,7 +149,7 @@ int qemuMonitorTextIOProcess(qemuMonitorPtr mon ATTRIBUTE_UNUSED, ...@@ -149,7 +149,7 @@ int qemuMonitorTextIOProcess(qemuMonitorPtr mon ATTRIBUTE_UNUSED,
passwd = strstr(start, PASSWORD_PROMPT); passwd = strstr(start, PASSWORD_PROMPT);
if (passwd) { if (passwd) {
#if DEBUG_IO #if DEBUG_IO
VIR_DEBUG("Seen a passwowrd prompt [%s]", data + used); VIR_DEBUG("Seen a password prompt [%s]", data + used);
#endif #endif
if (msg->passwordHandler) { if (msg->passwordHandler) {
int i; int i;
...@@ -1183,6 +1183,9 @@ cleanup: ...@@ -1183,6 +1183,9 @@ cleanup:
#define MIGRATION_TRANSFER_PREFIX "transferred ram: " #define MIGRATION_TRANSFER_PREFIX "transferred ram: "
#define MIGRATION_REMAINING_PREFIX "remaining ram: " #define MIGRATION_REMAINING_PREFIX "remaining ram: "
#define MIGRATION_TOTAL_PREFIX "total 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 qemuMonitorTextGetMigrationStatus(qemuMonitorPtr mon,
int *status, int *status,
...@@ -1192,6 +1195,9 @@ int qemuMonitorTextGetMigrationStatus(qemuMonitorPtr mon, ...@@ -1192,6 +1195,9 @@ int qemuMonitorTextGetMigrationStatus(qemuMonitorPtr mon,
char *reply; char *reply;
char *tmp; char *tmp;
char *end; char *end;
unsigned long long disk_transferred = 0;
unsigned long long disk_remaining = 0;
unsigned long long disk_total = 0;
int ret = -1; int ret = -1;
*status = QEMU_MONITOR_MIGRATION_STATUS_INACTIVE; *status = QEMU_MONITOR_MIGRATION_STATUS_INACTIVE;
...@@ -1230,7 +1236,8 @@ int qemuMonitorTextGetMigrationStatus(qemuMonitorPtr mon, ...@@ -1230,7 +1236,8 @@ int qemuMonitorTextGetMigrationStatus(qemuMonitorPtr mon,
if (virStrToLong_ull(tmp, &end, 10, transferred) < 0) { if (virStrToLong_ull(tmp, &end, 10, transferred) < 0) {
qemuReportError(VIR_ERR_INTERNAL_ERROR, qemuReportError(VIR_ERR_INTERNAL_ERROR,
_("cannot parse migration data transferred statistic %s"), tmp); _("cannot parse migration data transferred "
"statistic %s"), tmp);
goto cleanup; goto cleanup;
} }
*transferred *= 1024; *transferred *= 1024;
...@@ -1242,10 +1249,12 @@ int qemuMonitorTextGetMigrationStatus(qemuMonitorPtr mon, ...@@ -1242,10 +1249,12 @@ int qemuMonitorTextGetMigrationStatus(qemuMonitorPtr mon,
if (virStrToLong_ull(tmp, &end, 10, remaining) < 0) { if (virStrToLong_ull(tmp, &end, 10, remaining) < 0) {
qemuReportError(VIR_ERR_INTERNAL_ERROR, qemuReportError(VIR_ERR_INTERNAL_ERROR,
_("cannot parse migration data remaining statistic %s"), tmp); _("cannot parse migration data remaining "
"statistic %s"), tmp);
goto cleanup; goto cleanup;
} }
*remaining *= 1024; *remaining *= 1024;
tmp = end;
if (!(tmp = strstr(tmp, MIGRATION_TOTAL_PREFIX))) if (!(tmp = strstr(tmp, MIGRATION_TOTAL_PREFIX)))
goto done; goto done;
...@@ -1253,11 +1262,53 @@ int qemuMonitorTextGetMigrationStatus(qemuMonitorPtr mon, ...@@ -1253,11 +1262,53 @@ int qemuMonitorTextGetMigrationStatus(qemuMonitorPtr mon,
if (virStrToLong_ull(tmp, &end, 10, total) < 0) { if (virStrToLong_ull(tmp, &end, 10, total) < 0) {
qemuReportError(VIR_ERR_INTERNAL_ERROR, qemuReportError(VIR_ERR_INTERNAL_ERROR,
_("cannot parse migration data total statistic %s"), tmp); _("cannot parse migration data total "
"statistic %s"), tmp);
goto cleanup; goto cleanup;
} }
*total *= 1024; *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;
} }
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册