Re: [PATCH 2/3] show mig progress

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 01/23/2011 07:20 PM, Wen Congyang wrote:

s/mig/migration/ in the subject line, so that the log is a bit more legible

>  
> +static void
> +print_job_progress(unsigned long long remaining, unsigned long long total)
> +{
> +    int progress;
> +
> +    if (total == 0)
> +        /* migration has not been started */
> +        return;
> +
> +    if (remaining == 0) {
> +        /* migration has completed */
> +        progress = 100;
> +    } else if (remaining * 100 / total == 0) {

Is overflow a risk here, or will total never exceed UINT64_MAX/100?

> +        /* migration has not completed, do not print [100 %] */
> +        progress = 99;
> +    } else {
> +        progress = 100 - remaining * 100 / total;
> +    }
> +
> +    fprintf(stderr, "\rMigration: [%3d %%]", progress);

Are we guaranteed that this function always gets called with a 100%
total as the last thing to be printed?  Or if you have a really fast
migration, can the thread that calls this leave output stuck at 99%
because things completed between the last output and when the monitor
thread goes away?

> +}
> +
>  static int
>  cmdMigrate (vshControl *ctl, const vshCmd *cmd)
>  {
> @@ -3524,6 +3547,9 @@ cmdMigrate (vshControl *ctl, const vshCmd *cmd)
>      char retchar;
>      struct sigaction sig_action;
>      struct sigaction old_sig_action;
> +    virDomainJobInfo jobinfo;
> +    bool verbose = FALSE;

s/FALSE/false/

> +    sigset_t sigmask, oldsigmask;
>  
>      struct {
>          vshControl *ctl;
> @@ -3534,6 +3560,9 @@ cmdMigrate (vshControl *ctl, const vshCmd *cmd)
>      if (!(dom = vshCommandOptDomain (ctl, cmd, NULL)))
>          return FALSE;
>  
> +    if (vshCommandOptBool (cmd, "verbose"))
> +        verbose = TRUE;

s/TRUE/true/

> +    while (1) {

> +        if (ret < 0) {
> +            if (errno == EINTR && intCatched) {

s/intCatched/intCaught/ from patch 1, and I'm still not sure that you
are properly handling EINTR when your flag reports that no SIGINT was
caught.

> +++ b/tools/virsh.pod
> @@ -489,7 +489,8 @@ type attribute for the <domain> element of XML.
>  
>  =item B<migrate> optional I<--live> I<--p2p> I<--direct> I<--tunnelled>
>  I<--persistent> I<--undefinesource> I<--suspend> I<--copy-storage-all>
> -I<--copy-storage-inc> I<domain-id> I<desturi> I<migrateuri> I<dname>
> +I<--copy-storage-inc> I<--verbose> I<domain-id> I<desturi> I<migrateuri>
> +I<dname>

Thanks for the doc update!  Too many patches forget that.

-- 
Eric Blake   eblake@xxxxxxxxxx    +1-801-349-2682
Libvirt virtualization library http://libvirt.org

Attachment: signature.asc
Description: OpenPGP digital signature

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list

[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]