[re-adding the list] On 08/17/2011 12:30 AM, Tom Vijlbrief wrote:
Hi Eric This is the complete patch including json (not tested) and a typo correction in an error message... Tom ---------- Doorgestuurd bericht ---------- Van: "Tom Vijlbrief"<tom@xxxxxxxxxxxxxxx> Datum: 17 aug. 2011 08:23 Onderwerp: mon.patch Aan:<tvijlbrief@xxxxxxxxx> mon.patch
Thanks again for taking the time to contribute. It is easier to work with patches generated by 'git format-patch' (and 'git send-email' is a nice wrapper that both formats the patch and mails it to the list); as written, your patch had no commit message, so I had to invent one.
I also added you to AUTHORS; let me know if I need to update any preferred spellings.
# NB, must pass the --listen flag to the libvirtd process for this to
Is this a stray line in your email, or is it pointing out a further issue?
diff --git a/src/qemu/qemu_monitor_json.c b/src/qemu/qemu_monitor_json.c index 2a9a078..618a45c 100644 --- a/src/qemu/qemu_monitor_json.c +++ b/src/qemu/qemu_monitor_json.c @@ -1894,6 +1894,31 @@ qemuMonitorJSONGetMigrationStatusReply(virJSONValuePtr reply, _("migration was active, but RAM 'total' data was missing")); return -1; } + + virJSONValuePtr disk = virJSONValueObjectGet(ret, "disk"); + if (!disk) { + return 0; + } + + unsigned long long t;
Our style tends to float declarations to the top, C89 style, even though this is valid as written (we require C99 for other reasons).
+ if (virJSONValueObjectGetNumberUlong(disk, "transferred",&t)< 0) { + qemuReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("disk migration was active, but DISK '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 DISK 'remaining' data was missing")); + return -1; + } + (*remaining)+= t;
I tweaked spacing between operators (yeah, it doesn't help that thunderbird corrupted spacing even worse in my reply to your mail). And the () are redundant; this can safely be:
*remaining += t;
+ if (virJSONValueObjectGetNumberUlong(disk, "total",&t)< 0) { + qemuReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("disk migration was active, but DISK 'total' data was missing")); + return -1; + } + (*total)+= t; } return 0; diff --git a/src/qemu/qemu_monitor_text.c b/src/qemu/qemu_monitor_text.c index 7bf733d..fef6f36 100644 --- a/src/qemu/qemu_monitor_text.c +++ b/src/qemu/qemu_monitor_text.c @@ -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, @@ -1246,6 +1249,7 @@ int qemuMonitorTextGetMigrationStatus(qemuMonitorPtr mon, goto cleanup; } *remaining *= 1024; + tmp = end; if (!(tmp = strstr(tmp, MIGRATION_TOTAL_PREFIX))) goto done; @@ -1257,7 +1261,53 @@ int qemuMonitorTextGetMigrationStatus(qemuMonitorPtr mon, goto cleanup; } *total *= 1024; + tmp = end; + + /* + * Check for Optional Disk Migration status + */ + + unsigned long long disk_transferred= 0; + unsigned long long disk_remaining= 0; + unsigned long long disk_total= 0; + + 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; + } + disk_transferred *= 1024; + (*transferred)+= disk_transferred;
For one less assignment, I merged these two lines into: *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; + } + disk_remaining *= 1024; + (*remaining)+= disk_remaining; + 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; + } + disk_total *= 1024; + (*total)+= disk_total; } }
ACK and pushed with those tweaks. -- Eric Blake eblake@xxxxxxxxxx +1-801-349-2682 Libvirt virtualization library http://libvirt.org -- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list