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

Re: [libvirt] [PATCH v3 REBASE 12/16] qemu: migrate: show disks stats on job info requests



On Thu, Aug 24, 2017 at 09:56:49 +0300, Nikolay Shirokovskiy wrote:
> This patch shows incorrect info when client request comes
> when migration routine is stopping mirror jobs or mirror
> jobs already stopped. This issue will be addressed in next
> patch.
...
> diff --git a/src/qemu/qemu_migration.c b/src/qemu/qemu_migration.c
> index 2a8a721..c7af1ac 100644
> --- a/src/qemu/qemu_migration.c
> +++ b/src/qemu/qemu_migration.c
> @@ -5922,3 +5922,52 @@ qemuMigrationReset(virQEMUDriverPtr driver,
>          virFreeError(err);
>      }
>  }
> +
> +
> +int
> +qemuMigrationFetchMirrorStats(virQEMUDriverPtr driver,
> +                              virDomainObjPtr vm,
> +                              qemuDomainAsyncJob asyncJob,
> +                              qemuMonitorMigrationStatsPtr stats)
> +{
> +    size_t i;
> +    qemuDomainObjPrivatePtr priv = vm->privateData;
> +    bool nbd = false;
> +    virHashTablePtr blockinfo = NULL;
> +
> +    for (i = 0; i < vm->def->ndisks; i++) {
> +        virDomainDiskDefPtr disk = vm->def->disks[i];
> +        if (QEMU_DOMAIN_DISK_PRIVATE(disk)->migrating) {
> +            nbd = true;
> +            break;
> +        }
> +    }
> +
> +    if (!nbd)
> +        return 0;
> +
> +    if (qemuDomainObjEnterMonitorAsync(driver, vm, asyncJob) < 0)
> +        return -1;
> +
> +    blockinfo = qemuMonitorGetAllBlockJobInfo(priv->mon);
> +
> +    if (qemuDomainObjExitMonitor(driver, vm) < 0 || !blockinfo)
> +        return -1;
> +
> +    for (i = 0; i < vm->def->ndisks; i++) {
> +        virDomainDiskDefPtr disk = vm->def->disks[i];
> +        qemuDomainDiskPrivatePtr diskPriv = QEMU_DOMAIN_DISK_PRIVATE(disk);
> +        qemuMonitorBlockJobInfoPtr data;
> +
> +        if (!diskPriv->migrating ||
> +            !(data = virHashLookup(blockinfo, disk->info.alias)))
> +            continue;
> +
> +        stats->disk_transferred += data->cur;
> +        stats->disk_total += data->end;
> +        stats->disk_remaining += data->end - data->cur;

You should not touch qemuMonitorMigrationStatsPtr here. The scructure is
used to store raw data from query_migrate QMP command. Just add another
structure to jobInfo for storing NBD migration statistics. If you do
this, you don't need the hack to conditionally clear
qemuMonitorMigrationStats. Both structs can be combined in
qemuDomainJobInfoTo*.

Jirka


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