From nobody Mon Nov 25 17:51:33 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 207.211.31.120 as permitted sender) client-ip=207.211.31.120; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-1.mimecast.com; Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of redhat.com designates 207.211.31.120 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=fail(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1598215119; cv=none; d=zohomail.com; s=zohoarc; b=ihXhtqkGL09J0CqAz2JVU6Vd9+lH9gzdBd7xcI0016i9jRpYumOtbsUpSbZSFYebB+TF8vkamKwqIOVxWxcVvtIyLXSkRgfg7KwoDYkeIM14q9PdOa6A5VibKCZdLKCKpIsaJMy1XrRVjlj951oM6E4IpkiOqL81Tz8E6iLEzCE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1598215119; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=9A8hr0nam5MZqqSrHCWg96h7fgT1/FHVTAKcE/CWObg=; b=GBpZ8uth+LJhUq6fStLBz4kxKWB1ZEPFyjO20xZopKThMieJSqfVUSavjVwVhO6xoDhNP0EJu5blRwim7mhFxhjpQ2cTZcFyJrMaMHeDlwBxFx5h+8bPXq1WLoLUgFideIg5RUUqItjxKJAG+Nx0gDPhyLZvoU7IkV50kErloys= ARC-Authentication-Results: i=1; mx.zohomail.com; spf=pass (zohomail.com: domain of redhat.com designates 207.211.31.120 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [207.211.31.120]) by mx.zohomail.com with SMTPS id 1598215119086244.9497364935761; Sun, 23 Aug 2020 13:38:39 -0700 (PDT) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-77-sImRivYeNHS-BY2UrNEDew-1; Sun, 23 Aug 2020 16:38:34 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 2B2B881F006; Sun, 23 Aug 2020 20:38:29 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 0B3D77BE76; Sun, 23 Aug 2020 20:38:29 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id BB1996691A; Sun, 23 Aug 2020 20:38:28 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 07NKcRho020998 for ; Sun, 23 Aug 2020 16:38:27 -0400 Received: by smtp.corp.redhat.com (Postfix) id 54BA74407E; Sun, 23 Aug 2020 20:38:27 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast02.extmail.prod.ext.rdu2.redhat.com [10.11.55.18]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 4F3B93325F for ; Sun, 23 Aug 2020 20:38:25 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-1.mimecast.com [205.139.110.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id DCC6280019A for ; Sun, 23 Aug 2020 20:38:24 +0000 (UTC) Received: from mail-pg1-f193.google.com (mail-pg1-f193.google.com [209.85.215.193]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-442--ih0dSmJNJWKv4PT54oJFA-1; Sun, 23 Aug 2020 16:38:20 -0400 Received: by mail-pg1-f193.google.com with SMTP id p37so3564297pgl.3 for ; Sun, 23 Aug 2020 13:38:20 -0700 (PDT) Received: from localhost.localdomain ([125.99.149.9]) by smtp.gmail.com with ESMTPSA id t19sm8926898pfq.179.2020.08.23.13.38.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 23 Aug 2020 13:38:17 -0700 (PDT) X-MC-Unique: sImRivYeNHS-BY2UrNEDew-1 X-MC-Unique: -ih0dSmJNJWKv4PT54oJFA-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=9A8hr0nam5MZqqSrHCWg96h7fgT1/FHVTAKcE/CWObg=; b=sRy/uE90XgA84v1sASrSqH425VhI+SFF49deDRUupRWuKnh2AZ8JktgLBSHB6RwBh/ tcVgz3S8Po1chmO0NmY0/ZA9x5eSDldObOPyo99by+mQmMkaki7Vb+P+iBAkilu9gXAx wUuBbeB5oiG75TOGHX7mQU02EmPdumh5pjs8sBpayjYQ5gdVlpwdA0sKkbP4dukkHVyF oSMrYqj86LkPHk5pGmw9eqVFfEBIKUSe2HxI1PBB1Ws1fslRrhBJLETBwaDR3cGz/e8w hWtnGfu0D7QQr6PAfv4+C2KR+f0/Y4xi/zXkXmSeaSq9JGoziT11sVozKaAZAuightGx /gzg== X-Gm-Message-State: AOAM532dTbz03iWJ4qMbrnhxur5kXqXxZhMQMvzL2HgcJpS/x5i/3uHa mSIXN68ma/f5TJ43z5B856a8f32Iq1Wzow== X-Google-Smtp-Source: ABdhPJwmbmoIIZ+HVCp7LB2UJrcrfohCXB+QmyIEABfeNCJojGFvUVljxVxKGZa78gRwb55AVu+vOw== X-Received: by 2002:a63:5a59:: with SMTP id k25mr1474287pgm.116.1598215098409; Sun, 23 Aug 2020 13:38:18 -0700 (PDT) From: Prathamesh Chavan To: libvir-list@redhat.com Subject: [GSoC][PATCH v3 2/8] qemu_domain: Added `qemuDomainJobInfo` to domainJob's `privateData` Date: Mon, 24 Aug 2020 02:08:02 +0530 Message-Id: <20200823203808.97348-3-pc44800@gmail.com> In-Reply-To: <20200823203808.97348-1-pc44800@gmail.com> References: <20200823203808.97348-1-pc44800@gmail.com> MIME-Version: 1.0 X-Mimecast-Impersonation-Protect: Policy=CLT - Impersonation Protection Definition; Similar Internal Domain=false; Similar Monitored External Domain=false; Custom External Domain=false; Mimecast External Domain=false; Newly Observed Domain=false; Internal User Name=false; Custom Display Name List=false; Reply-to Address Mismatch=false; Targeted Threat Dictionary=false; Mimecast Threat Dictionary=false; Custom Threat Dictionary=false; X-Scanned-By: MIMEDefang 2.79 on 10.11.54.5 X-loop: libvir-list@redhat.com Cc: Prathamesh Chavan X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0.004 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" As `qemuDomainJobInfo` had attributes specific to qemu hypervisor's jobs, we moved the attribute `current` and `completed` from `qemuDomainJobObj` to its `privateData` structure. In this process, two callback functions: `setJobInfoOperation` and `currentJobInfoInit` were introduced to qemuDomainJob's callback structure. Signed-off-by: Prathamesh Chavan --- src/qemu/qemu_backup.c | 22 ++++++----- src/qemu/qemu_domain.c | 29 ++++++++++++++- src/qemu/qemu_domain.h | 50 +++++++++++++++++++++++++ src/qemu/qemu_domainjob.c | 6 +-- src/qemu/qemu_domainjob.h | 64 +++----------------------------- src/qemu/qemu_driver.c | 49 +++++++++++++++--------- src/qemu/qemu_migration.c | 62 +++++++++++++++++-------------- src/qemu/qemu_migration_cookie.c | 8 ++-- src/qemu/qemu_process.c | 32 +++++++++------- 9 files changed, 185 insertions(+), 137 deletions(-) diff --git a/src/qemu/qemu_backup.c b/src/qemu/qemu_backup.c index a402730d38..1822c6f267 100644 --- a/src/qemu/qemu_backup.c +++ b/src/qemu/qemu_backup.c @@ -529,20 +529,21 @@ qemuBackupJobTerminate(virDomainObjPtr vm, =20 { qemuDomainObjPrivatePtr priv =3D vm->privateData; + qemuDomainJobPrivatePtr jobPriv =3D priv->job.privateData; size_t i; =20 - qemuDomainJobInfoUpdateTime(priv->job.current); + qemuDomainJobInfoUpdateTime(jobPriv->current); =20 - g_clear_pointer(&priv->job.completed, qemuDomainJobInfoFree); - priv->job.completed =3D qemuDomainJobInfoCopy(priv->job.current); + g_clear_pointer(&jobPriv->completed, qemuDomainJobInfoFree); + jobPriv->completed =3D qemuDomainJobInfoCopy(jobPriv->current); =20 - priv->job.completed->stats.backup.total =3D priv->backup->push_total; - priv->job.completed->stats.backup.transferred =3D priv->backup->push_t= ransferred; - priv->job.completed->stats.backup.tmp_used =3D priv->backup->pull_tmp_= used; - priv->job.completed->stats.backup.tmp_total =3D priv->backup->pull_tmp= _total; + jobPriv->completed->stats.backup.total =3D priv->backup->push_total; + jobPriv->completed->stats.backup.transferred =3D priv->backup->push_tr= ansferred; + jobPriv->completed->stats.backup.tmp_used =3D priv->backup->pull_tmp_u= sed; + jobPriv->completed->stats.backup.tmp_total =3D priv->backup->pull_tmp_= total; =20 - priv->job.completed->status =3D jobstatus; - priv->job.completed->errmsg =3D g_strdup(priv->backup->errmsg); + jobPriv->completed->status =3D jobstatus; + jobPriv->completed->errmsg =3D g_strdup(priv->backup->errmsg); =20 qemuDomainEventEmitJobCompleted(priv->driver, vm); =20 @@ -694,6 +695,7 @@ qemuBackupBegin(virDomainObjPtr vm, unsigned int flags) { qemuDomainObjPrivatePtr priv =3D vm->privateData; + qemuDomainJobPrivatePtr jobPriv =3D priv->job.privateData; g_autoptr(virQEMUDriverConfig) cfg =3D virQEMUDriverGetConfig(priv->dr= iver); g_autoptr(virDomainBackupDef) def =3D NULL; g_autofree char *suffix =3D NULL; @@ -745,7 +747,7 @@ qemuBackupBegin(virDomainObjPtr vm, qemuDomainObjSetAsyncJobMask(vm, (QEMU_JOB_DEFAULT_MASK | JOB_MASK(QEMU_JOB_SUSPEND) | JOB_MASK(QEMU_JOB_MODIFY))); - priv->job.current->statsType =3D QEMU_DOMAIN_JOB_STATS_TYPE_BACKUP; + jobPriv->current->statsType =3D QEMU_DOMAIN_JOB_STATS_TYPE_BACKUP; =20 if (!virDomainObjIsActive(vm)) { virReportError(VIR_ERR_OPERATION_UNSUPPORTED, "%s", diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index ae8ce37be2..ea740bcf60 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -542,6 +542,8 @@ qemuJobFreePrivate(void *opaque) return; =20 qemuMigrationParamsFree(priv->migParams); + g_clear_pointer(&priv->current, qemuDomainJobInfoFree); + g_clear_pointer(&priv->completed, qemuDomainJobInfoFree); VIR_FREE(priv); } =20 @@ -555,6 +557,7 @@ qemuJobResetPrivate(void *opaque) priv->spiceMigrated =3D false; priv->dumpCompleted =3D false; qemuMigrationParamsFree(priv->migParams); + g_clear_pointer(&priv->current, qemuDomainJobInfoFree); priv->migParams =3D NULL; } =20 @@ -629,20 +632,40 @@ qemuDomainFormatJobPrivate(virBufferPtr buf, return 0; } =20 +static void +qemuDomainCurrentJobInfoInit(qemuDomainJobObjPtr job, + unsigned long long now) +{ + qemuDomainJobPrivatePtr priv =3D job->privateData; + priv->current =3D g_new0(qemuDomainJobInfo, 1); + priv->current->status =3D QEMU_DOMAIN_JOB_STATUS_ACTIVE; + priv->current->started =3D now; + +} + +static void +qemuDomainJobInfoSetOperation(qemuDomainJobObjPtr job, + virDomainJobOperation operation) +{ + qemuDomainJobPrivatePtr priv =3D job->privateData; + priv->current->operation =3D operation; +} + void qemuDomainEventEmitJobCompleted(virQEMUDriverPtr driver, virDomainObjPtr vm) { qemuDomainObjPrivatePtr priv =3D vm->privateData; + qemuDomainJobPrivatePtr jobPriv =3D priv->job.privateData; virObjectEventPtr event; virTypedParameterPtr params =3D NULL; int nparams =3D 0; int type; =20 - if (!priv->job.completed) + if (!jobPriv->completed) return; =20 - if (qemuDomainJobInfoToParams(priv->job.completed, &type, + if (qemuDomainJobInfoToParams(jobPriv->completed, &type, ¶ms, &nparams) < 0) { VIR_WARN("Could not get stats for completed job; domain %s", vm->def->name); @@ -759,6 +782,8 @@ static qemuDomainObjPrivateJobCallbacks qemuPrivateJobC= allbacks =3D { .resetJobPrivate =3D qemuJobResetPrivate, .formatJob =3D qemuDomainFormatJobPrivate, .parseJob =3D qemuDomainParseJobPrivate, + .setJobInfoOperation =3D qemuDomainJobInfoSetOperation, + .currentJobInfoInit =3D qemuDomainCurrentJobInfoInit, }; =20 /** diff --git a/src/qemu/qemu_domain.h b/src/qemu/qemu_domain.h index 3f5f73bbb6..1e180bf684 100644 --- a/src/qemu/qemu_domain.h +++ b/src/qemu/qemu_domain.h @@ -483,6 +483,52 @@ struct _qemuDomainXmlNsDef { char **capsdel; }; =20 +typedef struct _qemuDomainMirrorStats qemuDomainMirrorStats; +typedef qemuDomainMirrorStats *qemuDomainMirrorStatsPtr; +struct _qemuDomainMirrorStats { + unsigned long long transferred; + unsigned long long total; +}; + +typedef struct _qemuDomainBackupStats qemuDomainBackupStats; +struct _qemuDomainBackupStats { + unsigned long long transferred; + unsigned long long total; + unsigned long long tmp_used; + unsigned long long tmp_total; +}; + +typedef struct _qemuDomainJobInfo qemuDomainJobInfo; +typedef qemuDomainJobInfo *qemuDomainJobInfoPtr; +struct _qemuDomainJobInfo { + qemuDomainJobStatus status; + virDomainJobOperation operation; + unsigned long long started; /* When the async job started */ + unsigned long long stopped; /* When the domain's CPUs were stopped */ + unsigned long long sent; /* When the source sent status info to the + destination (only for migrations). */ + unsigned long long received; /* When the destination host received sta= tus + info from the source (migrations only)= . */ + /* Computed values */ + unsigned long long timeElapsed; + long long timeDelta; /* delta =3D received - sent, i.e., the difference + between the source and the destination time pl= us + the time between the end of Perform phase on t= he + source and the beginning of Finish phase on the + destination. */ + bool timeDeltaSet; + /* Raw values from QEMU */ + qemuDomainJobStatsType statsType; + union { + qemuMonitorMigrationStats mig; + qemuMonitorDumpStats dump; + qemuDomainBackupStats backup; + } stats; + qemuDomainMirrorStats mirrorStats; + + char *errmsg; /* optional error message for failed completed jobs */ +}; + typedef struct _qemuDomainJobPrivate qemuDomainJobPrivate; typedef qemuDomainJobPrivate *qemuDomainJobPrivatePtr; struct _qemuDomainJobPrivate { @@ -491,6 +537,8 @@ struct _qemuDomainJobPrivate { bool spiceMigrated; /* spice migration completed */ bool dumpCompleted; /* dump completed */ qemuMigrationParamsPtr migParams; + qemuDomainJobInfoPtr current; /* async job progress data */ + qemuDomainJobInfoPtr completed; /* statistics data of a recently c= ompleted job */ }; =20 =20 @@ -500,6 +548,8 @@ void qemuDomainEventEmitJobCompleted(virQEMUDriverPtr d= river, void qemuDomainJobInfoFree(qemuDomainJobInfoPtr info); =20 +G_DEFINE_AUTOPTR_CLEANUP_FUNC(qemuDomainJobInfo, qemuDomainJobInfoFree); + qemuDomainJobInfoPtr qemuDomainJobInfoCopy(qemuDomainJobInfoPtr info); =20 diff --git a/src/qemu/qemu_domainjob.c b/src/qemu/qemu_domainjob.c index a8167f25f8..60b834a5cb 100644 --- a/src/qemu/qemu_domainjob.c +++ b/src/qemu/qemu_domainjob.c @@ -417,13 +417,11 @@ qemuDomainObjBeginJobInternal(virQEMUDriverPtr driver, qemuDomainAsyncJobTypeToString(asyncJob), obj, obj->def->name); qemuDomainObjResetAsyncJob(&priv->job); - priv->job.current =3D g_new0(qemuDomainJobInfo, 1); - priv->job.current->status =3D QEMU_DOMAIN_JOB_STATUS_ACTIVE; + priv->job.cb->currentJobInfoInit(&priv->job, now); priv->job.asyncJob =3D asyncJob; priv->job.asyncOwner =3D virThreadSelfID(); priv->job.asyncOwnerAPI =3D virThreadJobGet(); priv->job.asyncStarted =3D now; - priv->job.current->started =3D now; } } =20 @@ -589,7 +587,7 @@ int qemuDomainObjBeginAsyncJob(virQEMUDriverPtr driver, return -1; =20 priv =3D obj->privateData; - priv->job.current->operation =3D operation; + priv->job.cb->setJobInfoOperation(&priv->job, operation); priv->job.apiFlags =3D apiFlags; return 0; } diff --git a/src/qemu/qemu_domainjob.h b/src/qemu/qemu_domainjob.h index 84b60a466a..c09cfb1a16 100644 --- a/src/qemu/qemu_domainjob.h +++ b/src/qemu/qemu_domainjob.h @@ -19,7 +19,6 @@ #pragma once =20 #include -#include "qemu_monitor.h" =20 #define JOB_MASK(job) (job =3D=3D 0 ? 0 : 1 << (job - 1)) #define QEMU_JOB_DEFAULT_MASK \ @@ -99,61 +98,6 @@ typedef enum { QEMU_DOMAIN_JOB_STATS_TYPE_BACKUP, } qemuDomainJobStatsType; =20 - -typedef struct _qemuDomainMirrorStats qemuDomainMirrorStats; -typedef qemuDomainMirrorStats *qemuDomainMirrorStatsPtr; -struct _qemuDomainMirrorStats { - unsigned long long transferred; - unsigned long long total; -}; - -typedef struct _qemuDomainBackupStats qemuDomainBackupStats; -struct _qemuDomainBackupStats { - unsigned long long transferred; - unsigned long long total; - unsigned long long tmp_used; - unsigned long long tmp_total; -}; - -typedef struct _qemuDomainJobInfo qemuDomainJobInfo; -typedef qemuDomainJobInfo *qemuDomainJobInfoPtr; -struct _qemuDomainJobInfo { - qemuDomainJobStatus status; - virDomainJobOperation operation; - unsigned long long started; /* When the async job started */ - unsigned long long stopped; /* When the domain's CPUs were stopped */ - unsigned long long sent; /* When the source sent status info to the - destination (only for migrations). */ - unsigned long long received; /* When the destination host received sta= tus - info from the source (migrations only)= . */ - /* Computed values */ - unsigned long long timeElapsed; - long long timeDelta; /* delta =3D received - sent, i.e., the difference - between the source and the destination time pl= us - the time between the end of Perform phase on t= he - source and the beginning of Finish phase on the - destination. */ - bool timeDeltaSet; - /* Raw values from QEMU */ - qemuDomainJobStatsType statsType; - union { - qemuMonitorMigrationStats mig; - qemuMonitorDumpStats dump; - qemuDomainBackupStats backup; - } stats; - qemuDomainMirrorStats mirrorStats; - - char *errmsg; /* optional error message for failed completed jobs */ -}; - -void -qemuDomainJobInfoFree(qemuDomainJobInfoPtr info); - -G_DEFINE_AUTOPTR_CLEANUP_FUNC(qemuDomainJobInfo, qemuDomainJobInfoFree); - -qemuDomainJobInfoPtr -qemuDomainJobInfoCopy(qemuDomainJobInfoPtr info); - typedef struct _qemuDomainJobObj qemuDomainJobObj; typedef qemuDomainJobObj *qemuDomainJobObjPtr; =20 @@ -166,6 +110,10 @@ typedef int (*qemuDomainObjPrivateJobFormat)(virBuffer= Ptr, typedef int (*qemuDomainObjPrivateJobParse)(xmlXPathContextPtr, qemuDomainJobObjPtr, virDomainObjPtr); +typedef void (*qemuDomainObjJobInfoSetOperation)(qemuDomainJobObjPtr, + virDomainJobOperation); +typedef void (*qemuDomainObjCurrentJobInfoInit)(qemuDomainJobObjPtr, + unsigned long long); =20 typedef struct _qemuDomainObjPrivateJobCallbacks qemuDomainObjPrivateJobCa= llbacks; typedef qemuDomainObjPrivateJobCallbacks *qemuDomainObjPrivateJobCallbacks= Ptr; @@ -175,6 +123,8 @@ struct _qemuDomainObjPrivateJobCallbacks { qemuDomainObjPrivateJobReset resetJobPrivate; qemuDomainObjPrivateJobFormat formatJob; qemuDomainObjPrivateJobParse parseJob; + qemuDomainObjJobInfoSetOperation setJobInfoOperation; + qemuDomainObjCurrentJobInfoInit currentJobInfoInit; }; =20 struct _qemuDomainJobObj { @@ -200,8 +150,6 @@ struct _qemuDomainJobObj { unsigned long long asyncStarted; /* When the current async job star= ted */ int phase; /* Job phase (mainly for migration= s) */ unsigned long long mask; /* Jobs allowed during async job */ - qemuDomainJobInfoPtr current; /* async job progress data */ - qemuDomainJobInfoPtr completed; /* statistics data of a recently c= ompleted job */ bool abortJob; /* abort of the job requested */ char *error; /* job event completion error */ unsigned long apiFlags; /* flags passed to the API which started the a= sync job */ diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index 1b2ff1b3da..77d9a841ed 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -2724,6 +2724,7 @@ qemuDomainGetControlInfo(virDomainPtr dom, { virDomainObjPtr vm; qemuDomainObjPrivatePtr priv; + qemuDomainJobPrivatePtr jobPriv; int ret =3D -1; =20 virCheckFlags(0, -1); @@ -2738,6 +2739,7 @@ qemuDomainGetControlInfo(virDomainPtr dom, goto cleanup; =20 priv =3D vm->privateData; + jobPriv =3D priv->job.privateData; =20 memset(info, 0, sizeof(*info)); =20 @@ -2747,9 +2749,9 @@ qemuDomainGetControlInfo(virDomainPtr dom, } else if (priv->job.active) { if (virTimeMillisNow(&info->stateTime) < 0) goto cleanup; - if (priv->job.current) { + if (jobPriv->current) { info->state =3D VIR_DOMAIN_CONTROL_JOB; - info->stateTime -=3D priv->job.current->started; + info->stateTime -=3D jobPriv->current->started; } else { if (priv->monStart > 0) { info->state =3D VIR_DOMAIN_CONTROL_OCCUPIED; @@ -3314,6 +3316,7 @@ qemuDomainSaveInternal(virQEMUDriverPtr driver, int ret =3D -1; virObjectEventPtr event =3D NULL; qemuDomainObjPrivatePtr priv =3D vm->privateData; + qemuDomainJobPrivatePtr jobPriv =3D priv->job.privateData; virQEMUSaveDataPtr data =3D NULL; g_autoptr(qemuDomainSaveCookie) cookie =3D NULL; =20 @@ -3330,7 +3333,7 @@ qemuDomainSaveInternal(virQEMUDriverPtr driver, goto endjob; } =20 - priv->job.current->statsType =3D QEMU_DOMAIN_JOB_STATS_TYPE_SAVEDUMP; + jobPriv->current->statsType =3D QEMU_DOMAIN_JOB_STATS_TYPE_SAVEDUMP; =20 /* Pause */ if (virDomainObjGetState(vm, NULL) =3D=3D VIR_DOMAIN_RUNNING) { @@ -3715,7 +3718,7 @@ qemuDumpWaitForCompletion(virDomainObjPtr vm) return -1; } =20 - if (priv->job.current->stats.dump.status =3D=3D QEMU_MONITOR_DUMP_STAT= US_FAILED) { + if (jobPriv->current->stats.dump.status =3D=3D QEMU_MONITOR_DUMP_STATU= S_FAILED) { if (priv->job.error) virReportError(VIR_ERR_OPERATION_FAILED, _("memory-only dump failed: %s"), @@ -3726,7 +3729,7 @@ qemuDumpWaitForCompletion(virDomainObjPtr vm) =20 return -1; } - qemuDomainJobInfoUpdateTime(priv->job.current); + qemuDomainJobInfoUpdateTime(jobPriv->current); =20 return 0; } @@ -3740,6 +3743,7 @@ qemuDumpToFd(virQEMUDriverPtr driver, const char *dumpformat) { qemuDomainObjPrivatePtr priv =3D vm->privateData; + qemuDomainJobPrivatePtr jobPriv =3D priv->job.privateData; bool detach =3D false; int ret =3D -1; =20 @@ -3755,9 +3759,9 @@ qemuDumpToFd(virQEMUDriverPtr driver, return -1; =20 if (detach) - priv->job.current->statsType =3D QEMU_DOMAIN_JOB_STATS_TYPE_MEMDUM= P; + jobPriv->current->statsType =3D QEMU_DOMAIN_JOB_STATS_TYPE_MEMDUMP; else - g_clear_pointer(&priv->job.current, qemuDomainJobInfoFree); + g_clear_pointer(&jobPriv->current, qemuDomainJobInfoFree); =20 if (qemuDomainObjEnterMonitorAsync(driver, vm, asyncJob) < 0) return -1; @@ -3895,6 +3899,7 @@ qemuDomainCoreDumpWithFormat(virDomainPtr dom, virQEMUDriverPtr driver =3D dom->conn->privateData; virDomainObjPtr vm; qemuDomainObjPrivatePtr priv =3D NULL; + qemuDomainJobPrivatePtr jobPriv; bool resume =3D false, paused =3D false; int ret =3D -1; virObjectEventPtr event =3D NULL; @@ -3919,7 +3924,8 @@ qemuDomainCoreDumpWithFormat(virDomainPtr dom, goto endjob; =20 priv =3D vm->privateData; - priv->job.current->statsType =3D QEMU_DOMAIN_JOB_STATS_TYPE_SAVEDUMP; + jobPriv =3D priv->job.privateData; + jobPriv->current->statsType =3D QEMU_DOMAIN_JOB_STATS_TYPE_SAVEDUMP; =20 /* Migrate will always stop the VM, so the resume condition is independent of whether the stop command is issued. */ @@ -7480,6 +7486,7 @@ qemuDomainObjStart(virConnectPtr conn, bool force_boot =3D (flags & VIR_DOMAIN_START_FORCE_BOOT) !=3D 0; unsigned int start_flags =3D VIR_QEMU_PROCESS_START_COLD; qemuDomainObjPrivatePtr priv =3D vm->privateData; + qemuDomainJobPrivatePtr jobPriv =3D priv->job.privateData; =20 start_flags |=3D start_paused ? VIR_QEMU_PROCESS_START_PAUSED : 0; start_flags |=3D autodestroy ? VIR_QEMU_PROCESS_START_AUTODESTROY : 0; @@ -7503,8 +7510,8 @@ qemuDomainObjStart(virConnectPtr conn, } vm->hasManagedSave =3D false; } else { - virDomainJobOperation op =3D priv->job.current->operation; - priv->job.current->operation =3D VIR_DOMAIN_JOB_OPERATION_REST= ORE; + virDomainJobOperation op =3D jobPriv->current->operation; + jobPriv->current->operation =3D VIR_DOMAIN_JOB_OPERATION_RESTO= RE; =20 ret =3D qemuDomainObjRestore(conn, driver, vm, managed_save, start_paused, bypass_cache, asyncJo= b); @@ -7522,7 +7529,7 @@ qemuDomainObjStart(virConnectPtr conn, return ret; } else { VIR_WARN("Ignoring incomplete managed state %s", managed_s= ave); - priv->job.current->operation =3D op; + jobPriv->current->operation =3D op; vm->hasManagedSave =3D false; } } @@ -13576,13 +13583,14 @@ qemuDomainGetJobStatsInternal(virQEMUDriverPtr dr= iver, qemuDomainJobInfoPtr *jobInfo) { qemuDomainObjPrivatePtr priv =3D vm->privateData; + qemuDomainJobPrivatePtr jobPriv =3D priv->job.privateData; int ret =3D -1; =20 *jobInfo =3D NULL; =20 if (completed) { - if (priv->job.completed && !priv->job.current) - *jobInfo =3D qemuDomainJobInfoCopy(priv->job.completed); + if (jobPriv->completed && !jobPriv->current) + *jobInfo =3D qemuDomainJobInfoCopy(jobPriv->completed); =20 return 0; } @@ -13600,11 +13608,11 @@ qemuDomainGetJobStatsInternal(virQEMUDriverPtr dr= iver, if (virDomainObjCheckActive(vm) < 0) goto cleanup; =20 - if (!priv->job.current) { + if (!jobPriv->current) { ret =3D 0; goto cleanup; } - *jobInfo =3D qemuDomainJobInfoCopy(priv->job.current); + *jobInfo =3D qemuDomainJobInfoCopy(jobPriv->current); =20 switch ((*jobInfo)->statsType) { case QEMU_DOMAIN_JOB_STATS_TYPE_MIGRATION: @@ -13679,6 +13687,7 @@ qemuDomainGetJobStats(virDomainPtr dom, virQEMUDriverPtr driver =3D dom->conn->privateData; virDomainObjPtr vm; qemuDomainObjPrivatePtr priv; + qemuDomainJobPrivatePtr jobPriv; g_autoptr(qemuDomainJobInfo) jobInfo =3D NULL; bool completed =3D !!(flags & VIR_DOMAIN_JOB_STATS_COMPLETED); int ret =3D -1; @@ -13693,6 +13702,7 @@ qemuDomainGetJobStats(virDomainPtr dom, goto cleanup; =20 priv =3D vm->privateData; + jobPriv =3D priv->job.privateData; if (qemuDomainGetJobStatsInternal(driver, vm, completed, &jobInfo) < 0) goto cleanup; =20 @@ -13708,7 +13718,7 @@ qemuDomainGetJobStats(virDomainPtr dom, ret =3D qemuDomainJobInfoToParams(jobInfo, type, params, nparams); =20 if (completed && ret =3D=3D 0 && !(flags & VIR_DOMAIN_JOB_STATS_KEEP_C= OMPLETED)) - g_clear_pointer(&priv->job.completed, qemuDomainJobInfoFree); + g_clear_pointer(&jobPriv->completed, qemuDomainJobInfoFree); =20 cleanup: virDomainObjEndAPI(&vm); @@ -13740,6 +13750,7 @@ static int qemuDomainAbortJob(virDomainPtr dom) virDomainObjPtr vm; int ret =3D -1; qemuDomainObjPrivatePtr priv; + qemuDomainJobPrivatePtr jobPriv; int reason; =20 if (!(vm =3D qemuDomainObjFromDomain(dom))) @@ -13755,6 +13766,7 @@ static int qemuDomainAbortJob(virDomainPtr dom) goto endjob; =20 priv =3D vm->privateData; + jobPriv =3D priv->job.privateData; =20 switch (priv->job.asyncJob) { case QEMU_ASYNC_JOB_NONE: @@ -13775,7 +13787,7 @@ static int qemuDomainAbortJob(virDomainPtr dom) break; =20 case QEMU_ASYNC_JOB_MIGRATION_OUT: - if ((priv->job.current->status =3D=3D QEMU_DOMAIN_JOB_STATUS_POSTC= OPY || + if ((jobPriv->current->status =3D=3D QEMU_DOMAIN_JOB_STATUS_POSTCO= PY || (virDomainObjGetState(vm, &reason) =3D=3D VIR_DOMAIN_PAUSED && reason =3D=3D VIR_DOMAIN_PAUSED_POSTCOPY))) { virReportError(VIR_ERR_OPERATION_INVALID, "%s", @@ -15443,6 +15455,7 @@ qemuDomainSnapshotCreateActiveExternal(virQEMUDrive= rPtr driver, bool resume =3D false; int ret =3D -1; qemuDomainObjPrivatePtr priv =3D vm->privateData; + qemuDomainJobPrivatePtr jobPriv =3D priv->job.privateData; g_autofree char *xml =3D NULL; virDomainSnapshotDefPtr snapdef =3D virDomainSnapshotObjGetDef(snap); bool memory =3D snapdef->memory =3D=3D VIR_DOMAIN_SNAPSHOT_LOCATION_EX= TERNAL; @@ -15520,7 +15533,7 @@ qemuDomainSnapshotCreateActiveExternal(virQEMUDrive= rPtr driver, if (!qemuMigrationSrcIsAllowed(driver, vm, false, 0)) goto cleanup; =20 - priv->job.current->statsType =3D QEMU_DOMAIN_JOB_STATS_TYPE_SAVEDU= MP; + jobPriv->current->statsType =3D QEMU_DOMAIN_JOB_STATS_TYPE_SAVEDUM= P; =20 /* allow the migration job to be cancelled or the domain to be pau= sed */ qemuDomainObjSetAsyncJobMask(vm, (QEMU_JOB_DEFAULT_MASK | diff --git a/src/qemu/qemu_migration.c b/src/qemu/qemu_migration.c index 142faa2cf9..9b481c3443 100644 --- a/src/qemu/qemu_migration.c +++ b/src/qemu/qemu_migration.c @@ -1008,6 +1008,7 @@ qemuMigrationSrcNBDStorageCopy(virQEMUDriverPtr drive= r, unsigned int flags) { qemuDomainObjPrivatePtr priv =3D vm->privateData; + qemuDomainJobPrivatePtr jobPriv =3D priv->job.privateData; int port; size_t i; unsigned long long mirror_speed =3D speed; @@ -1052,7 +1053,7 @@ qemuMigrationSrcNBDStorageCopy(virQEMUDriverPtr drive= r, return -1; =20 if (priv->job.abortJob) { - priv->job.current->status =3D QEMU_DOMAIN_JOB_STATUS_CANCELED; + jobPriv->current->status =3D QEMU_DOMAIN_JOB_STATUS_CANCELED; virReportError(VIR_ERR_OPERATION_ABORTED, _("%s: %s"), qemuDomainAsyncJobTypeToString(priv->job.asyncJ= ob), _("canceled by client")); @@ -1070,7 +1071,7 @@ qemuMigrationSrcNBDStorageCopy(virQEMUDriverPtr drive= r, } =20 qemuMigrationSrcFetchMirrorStats(driver, vm, QEMU_ASYNC_JOB_MIGRATION_= OUT, - priv->job.current); + jobPriv->current); =20 /* Okay, all disks are ready. Modify migrate_flags */ *migrate_flags &=3D ~(QEMU_MONITOR_MIGRATE_NON_SHARED_DISK | @@ -1550,7 +1551,8 @@ qemuMigrationJobCheckStatus(virQEMUDriverPtr driver, qemuDomainAsyncJob asyncJob) { qemuDomainObjPrivatePtr priv =3D vm->privateData; - qemuDomainJobInfoPtr jobInfo =3D priv->job.current; + qemuDomainJobPrivatePtr jobPriv =3D priv->job.privateData; + qemuDomainJobInfoPtr jobInfo =3D jobPriv->current; char *error =3D NULL; bool events =3D virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_MIGRATION_EVE= NT); int ret =3D -1; @@ -1620,7 +1622,8 @@ qemuMigrationAnyCompleted(virQEMUDriverPtr driver, unsigned int flags) { qemuDomainObjPrivatePtr priv =3D vm->privateData; - qemuDomainJobInfoPtr jobInfo =3D priv->job.current; + qemuDomainJobPrivatePtr jobPriv =3D priv->job.privateData; + qemuDomainJobInfoPtr jobInfo =3D jobPriv->current; int pauseReason; =20 if (qemuMigrationJobCheckStatus(driver, vm, asyncJob) < 0) @@ -1711,7 +1714,8 @@ qemuMigrationSrcWaitForCompletion(virQEMUDriverPtr dr= iver, unsigned int flags) { qemuDomainObjPrivatePtr priv =3D vm->privateData; - qemuDomainJobInfoPtr jobInfo =3D priv->job.current; + qemuDomainJobPrivatePtr jobPriv =3D priv->job.privateData; + qemuDomainJobInfoPtr jobInfo =3D jobPriv->current; bool events =3D virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_MIGRATION_EVE= NT); int rv; =20 @@ -1743,9 +1747,9 @@ qemuMigrationSrcWaitForCompletion(virQEMUDriverPtr dr= iver, =20 qemuDomainJobInfoUpdateTime(jobInfo); qemuDomainJobInfoUpdateDowntime(jobInfo); - g_clear_pointer(&priv->job.completed, qemuDomainJobInfoFree); - priv->job.completed =3D qemuDomainJobInfoCopy(jobInfo); - priv->job.completed->status =3D QEMU_DOMAIN_JOB_STATUS_COMPLETED; + g_clear_pointer(&jobPriv->completed, qemuDomainJobInfoFree); + jobPriv->completed =3D qemuDomainJobInfoCopy(jobInfo); + jobPriv->completed->status =3D QEMU_DOMAIN_JOB_STATUS_COMPLETED; =20 if (asyncJob !=3D QEMU_ASYNC_JOB_MIGRATION_OUT && jobInfo->status =3D=3D QEMU_DOMAIN_JOB_STATUS_QEMU_COMPLETED) @@ -3018,16 +3022,16 @@ qemuMigrationSrcConfirmPhase(virQEMUDriverPtr drive= r, return -1; =20 if (retcode =3D=3D 0) - jobInfo =3D priv->job.completed; + jobInfo =3D jobPriv->completed; else - g_clear_pointer(&priv->job.completed, qemuDomainJobInfoFree); + g_clear_pointer(&jobPriv->completed, qemuDomainJobInfoFree); =20 /* Update times with the values sent by the destination daemon */ if (mig->jobInfo && jobInfo) { int reason; =20 /* We need to refresh migration statistics after a completed post-= copy - * migration since priv->job.completed contains obsolete data from= the + * migration since jobPriv->completed contains obsolete data from = the * time we switched to post-copy mode. */ if (virDomainObjGetState(vm, &reason) =3D=3D VIR_DOMAIN_PAUSED && @@ -3479,6 +3483,7 @@ qemuMigrationSrcRun(virQEMUDriverPtr driver, int ret =3D -1; unsigned int migrate_flags =3D QEMU_MONITOR_MIGRATE_BACKGROUND; qemuDomainObjPrivatePtr priv =3D vm->privateData; + qemuDomainJobPrivatePtr jobPriv =3D priv->job.privateData; g_autoptr(qemuMigrationCookie) mig =3D NULL; g_autofree char *tlsAlias =3D NULL; qemuMigrationIOThreadPtr iothread =3D NULL; @@ -3636,7 +3641,7 @@ qemuMigrationSrcRun(virQEMUDriverPtr driver, /* explicitly do this *after* we entered the monitor, * as this is a critical section so we are guaranteed * priv->job.abortJob will not change */ - priv->job.current->status =3D QEMU_DOMAIN_JOB_STATUS_CANCELED; + jobPriv->current->status =3D QEMU_DOMAIN_JOB_STATUS_CANCELED; virReportError(VIR_ERR_OPERATION_ABORTED, _("%s: %s"), qemuDomainAsyncJobTypeToString(priv->job.asyncJob), _("canceled by client")); @@ -3741,7 +3746,7 @@ qemuMigrationSrcRun(virQEMUDriverPtr driver, * resume it now once we finished all block jobs and wait for the real * end of the migration. */ - if (priv->job.current->status =3D=3D QEMU_DOMAIN_JOB_STATUS_PAUSED) { + if (jobPriv->current->status =3D=3D QEMU_DOMAIN_JOB_STATUS_PAUSED) { if (qemuMigrationSrcContinue(driver, vm, QEMU_MONITOR_MIGRATION_STATUS_PRE_SWI= TCHOVER, QEMU_ASYNC_JOB_MIGRATION_OUT) < 0) @@ -3769,11 +3774,11 @@ qemuMigrationSrcRun(virQEMUDriverPtr driver, goto error; } =20 - if (priv->job.completed) { - priv->job.completed->stopped =3D priv->job.current->stopped; - qemuDomainJobInfoUpdateTime(priv->job.completed); - qemuDomainJobInfoUpdateDowntime(priv->job.completed); - ignore_value(virTimeMillisNow(&priv->job.completed->sent)); + if (jobPriv->completed) { + jobPriv->completed->stopped =3D jobPriv->current->stopped; + qemuDomainJobInfoUpdateTime(jobPriv->completed); + qemuDomainJobInfoUpdateDowntime(jobPriv->completed); + ignore_value(virTimeMillisNow(&jobPriv->completed->sent)); } =20 cookieFlags |=3D QEMU_MIGRATION_COOKIE_NETWORK | @@ -3801,7 +3806,7 @@ qemuMigrationSrcRun(virQEMUDriverPtr driver, =20 if (virDomainObjIsActive(vm)) { if (cancel && - priv->job.current->status !=3D QEMU_DOMAIN_JOB_STATUS_QEMU_COM= PLETED && + jobPriv->current->status !=3D QEMU_DOMAIN_JOB_STATUS_QEMU_COMP= LETED && qemuDomainObjEnterMonitorAsync(driver, vm, QEMU_ASYNC_JOB_MIGRATION_OUT) = =3D=3D 0) { qemuMonitorMigrateCancel(priv->mon); @@ -3814,8 +3819,8 @@ qemuMigrationSrcRun(virQEMUDriverPtr driver, QEMU_ASYNC_JOB_MIGRATION_OUT, dconn); =20 - if (priv->job.current->status !=3D QEMU_DOMAIN_JOB_STATUS_CANCELED) - priv->job.current->status =3D QEMU_DOMAIN_JOB_STATUS_FAILED; + if (jobPriv->current->status !=3D QEMU_DOMAIN_JOB_STATUS_CANCELED) + jobPriv->current->status =3D QEMU_DOMAIN_JOB_STATUS_FAILED; } =20 if (iothread) @@ -5023,7 +5028,7 @@ qemuMigrationDstFinish(virQEMUDriverPtr driver, : QEMU_MIGRATION_PHASE_FINISH2); =20 qemuDomainCleanupRemove(vm, qemuMigrationDstPrepareCleanup); - g_clear_pointer(&priv->job.completed, qemuDomainJobInfoFree); + g_clear_pointer(&jobPriv->completed, qemuDomainJobInfoFree); =20 cookie_flags =3D QEMU_MIGRATION_COOKIE_NETWORK | QEMU_MIGRATION_COOKIE_STATS | @@ -5115,7 +5120,7 @@ qemuMigrationDstFinish(virQEMUDriverPtr driver, goto endjob; } =20 - if (priv->job.current->status =3D=3D QEMU_DOMAIN_JOB_STATUS_POSTCOPY) + if (jobPriv->current->status =3D=3D QEMU_DOMAIN_JOB_STATUS_POSTCOPY) inPostCopy =3D true; =20 if (!(flags & VIR_MIGRATE_PAUSED)) { @@ -5229,9 +5234,9 @@ qemuMigrationDstFinish(virQEMUDriverPtr driver, =20 if (dom) { if (jobInfo) { - priv->job.completed =3D g_steal_pointer(&jobInfo); - priv->job.completed->status =3D QEMU_DOMAIN_JOB_STATUS_COMPLET= ED; - priv->job.completed->statsType =3D QEMU_DOMAIN_JOB_STATS_TYPE_= MIGRATION; + jobPriv->completed =3D g_steal_pointer(&jobInfo); + jobPriv->completed->status =3D QEMU_DOMAIN_JOB_STATUS_COMPLETE= D; + jobPriv->completed->statsType =3D QEMU_DOMAIN_JOB_STATS_TYPE_M= IGRATION; } =20 if (qemuMigrationBakeCookie(mig, driver, vm, @@ -5244,7 +5249,7 @@ qemuMigrationDstFinish(virQEMUDriverPtr driver, * is obsolete anyway. */ if (inPostCopy) - g_clear_pointer(&priv->job.completed, qemuDomainJobInfoFree); + g_clear_pointer(&jobPriv->completed, qemuDomainJobInfoFree); } =20 qemuMigrationParamsReset(driver, vm, QEMU_ASYNC_JOB_MIGRATION_IN, @@ -5473,6 +5478,7 @@ qemuMigrationJobStart(virQEMUDriverPtr driver, unsigned long apiFlags) { qemuDomainObjPrivatePtr priv =3D vm->privateData; + qemuDomainJobPrivatePtr jobPriv =3D priv->job.privateData; virDomainJobOperation op; unsigned long long mask; =20 @@ -5489,7 +5495,7 @@ qemuMigrationJobStart(virQEMUDriverPtr driver, if (qemuDomainObjBeginAsyncJob(driver, vm, job, op, apiFlags) < 0) return -1; =20 - priv->job.current->statsType =3D QEMU_DOMAIN_JOB_STATS_TYPE_MIGRATION; + jobPriv->current->statsType =3D QEMU_DOMAIN_JOB_STATS_TYPE_MIGRATION; =20 qemuDomainObjSetAsyncJobMask(vm, mask); return 0; diff --git a/src/qemu/qemu_migration_cookie.c b/src/qemu/qemu_migration_coo= kie.c index 81b557e0a8..a0e8cba8ba 100644 --- a/src/qemu/qemu_migration_cookie.c +++ b/src/qemu/qemu_migration_cookie.c @@ -509,12 +509,13 @@ qemuMigrationCookieAddStatistics(qemuMigrationCookieP= tr mig, virDomainObjPtr vm) { qemuDomainObjPrivatePtr priv =3D vm->privateData; + qemuDomainJobPrivatePtr jobPriv =3D priv->job.privateData; =20 - if (!priv->job.completed) + if (!jobPriv->completed) return 0; =20 g_clear_pointer(&mig->jobInfo, qemuDomainJobInfoFree); - mig->jobInfo =3D qemuDomainJobInfoCopy(priv->job.completed); + mig->jobInfo =3D qemuDomainJobInfoCopy(jobPriv->completed); =20 mig->flags |=3D QEMU_MIGRATION_COOKIE_STATS; =20 @@ -1465,6 +1466,7 @@ qemuMigrationEatCookie(virQEMUDriverPtr driver, unsigned int flags) { g_autoptr(qemuMigrationCookie) mig =3D NULL; + qemuDomainJobPrivatePtr jobPriv =3D priv->job.privateData; =20 /* Parse & validate incoming cookie (if any) */ if (cookiein && cookieinlen && @@ -1513,7 +1515,7 @@ qemuMigrationEatCookie(virQEMUDriverPtr driver, } =20 if (flags & QEMU_MIGRATION_COOKIE_STATS && mig->jobInfo) - mig->jobInfo->operation =3D priv->job.current->operation; + mig->jobInfo->operation =3D jobPriv->current->operation; =20 return g_steal_pointer(&mig); } diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c index 126fabf5ef..652d217b5c 100644 --- a/src/qemu/qemu_process.c +++ b/src/qemu/qemu_process.c @@ -657,6 +657,7 @@ qemuProcessHandleStop(qemuMonitorPtr mon G_GNUC_UNUSED, virDomainEventSuspendedDetailType detail; g_autoptr(virQEMUDriverConfig) cfg =3D virQEMUDriverGetConfig(driver); qemuDomainObjPrivatePtr priv =3D vm->privateData; + qemuDomainJobPrivatePtr jobPriv =3D priv->job.privateData; =20 virObjectLock(vm); =20 @@ -668,7 +669,7 @@ qemuProcessHandleStop(qemuMonitorPtr mon G_GNUC_UNUSED, if (virDomainObjGetState(vm, NULL) =3D=3D VIR_DOMAIN_RUNNING && !priv->pausedShutdown) { if (priv->job.asyncJob =3D=3D QEMU_ASYNC_JOB_MIGRATION_OUT) { - if (priv->job.current->status =3D=3D QEMU_DOMAIN_JOB_STATUS_PO= STCOPY) + if (jobPriv->current->status =3D=3D QEMU_DOMAIN_JOB_STATUS_POS= TCOPY) reason =3D VIR_DOMAIN_PAUSED_POSTCOPY; else reason =3D VIR_DOMAIN_PAUSED_MIGRATION; @@ -680,8 +681,8 @@ qemuProcessHandleStop(qemuMonitorPtr mon G_GNUC_UNUSED, vm->def->name, virDomainPausedReasonTypeToString(reason), detail); =20 - if (priv->job.current) - ignore_value(virTimeMillisNow(&priv->job.current->stopped)); + if (jobPriv->current) + ignore_value(virTimeMillisNow(&jobPriv->current->stopped)); =20 if (priv->signalStop) virDomainObjBroadcast(vm); @@ -1649,6 +1650,7 @@ qemuProcessHandleMigrationStatus(qemuMonitorPtr mon G= _GNUC_UNUSED, void *opaque) { qemuDomainObjPrivatePtr priv; + qemuDomainJobPrivatePtr jobPriv; virQEMUDriverPtr driver =3D opaque; virObjectEventPtr event =3D NULL; g_autoptr(virQEMUDriverConfig) cfg =3D virQEMUDriverGetConfig(driver); @@ -1661,12 +1663,13 @@ qemuProcessHandleMigrationStatus(qemuMonitorPtr mon= G_GNUC_UNUSED, qemuMonitorMigrationStatusTypeToString(status)); =20 priv =3D vm->privateData; + jobPriv =3D priv->job.privateData; if (priv->job.asyncJob =3D=3D QEMU_ASYNC_JOB_NONE) { VIR_DEBUG("got MIGRATION event without a migration job"); goto cleanup; } =20 - priv->job.current->stats.mig.status =3D status; + jobPriv->current->stats.mig.status =3D status; virDomainObjBroadcast(vm); =20 if (status =3D=3D QEMU_MONITOR_MIGRATION_STATUS_POSTCOPY && @@ -1747,13 +1750,13 @@ qemuProcessHandleDumpCompleted(qemuMonitorPtr mon G= _GNUC_UNUSED, goto cleanup; } jobPriv->dumpCompleted =3D true; - priv->job.current->stats.dump =3D *stats; + jobPriv->current->stats.dump =3D *stats; priv->job.error =3D g_strdup(error); =20 /* Force error if extracting the DUMP_COMPLETED status failed */ if (!error && status < 0) { priv->job.error =3D g_strdup(virGetLastErrorMessage()); - priv->job.current->stats.dump.status =3D QEMU_MONITOR_DUMP_STATUS_= FAILED; + jobPriv->current->stats.dump.status =3D QEMU_MONITOR_DUMP_STATUS_F= AILED; } =20 virDomainObjBroadcast(vm); @@ -3267,6 +3270,7 @@ int qemuProcessStopCPUs(virQEMUDriverPtr driver, { int ret =3D -1; qemuDomainObjPrivatePtr priv =3D vm->privateData; + qemuDomainJobPrivatePtr jobPriv =3D priv->job.privateData; =20 VIR_FREE(priv->lockState); =20 @@ -3285,8 +3289,8 @@ int qemuProcessStopCPUs(virQEMUDriverPtr driver, /* de-activate netdevs after stopping CPUs */ ignore_value(qemuInterfaceStopDevices(vm->def)); =20 - if (priv->job.current) - ignore_value(virTimeMillisNow(&priv->job.current->stopped)); + if (jobPriv->current) + ignore_value(virTimeMillisNow(&jobPriv->current->stopped)); =20 /* The STOP event handler will change the domain state with the reason * saved in priv->pausedReason and it will also emit corresponding dom= ain @@ -3583,6 +3587,7 @@ qemuProcessRecoverJob(virQEMUDriverPtr driver, unsigned int *stopFlags) { qemuDomainObjPrivatePtr priv =3D vm->privateData; + qemuDomainJobPrivatePtr jobPriv =3D priv->job.privateData; virDomainState state; int reason; unsigned long long now; @@ -3651,11 +3656,11 @@ qemuProcessRecoverJob(virQEMUDriverPtr driver, /* We reset the job parameters for backup so that the job will look * active. This is possible because we are able to recover the sta= te * of blockjobs and also the backup job allows all sub-job types */ - priv->job.current =3D g_new0(qemuDomainJobInfo, 1); - priv->job.current->operation =3D VIR_DOMAIN_JOB_OPERATION_BACKUP; - priv->job.current->statsType =3D QEMU_DOMAIN_JOB_STATS_TYPE_BACKUP; - priv->job.current->status =3D QEMU_DOMAIN_JOB_STATUS_ACTIVE; - priv->job.current->started =3D now; + jobPriv->current =3D g_new0(qemuDomainJobInfo, 1); + jobPriv->current->operation =3D VIR_DOMAIN_JOB_OPERATION_BACKUP; + jobPriv->current->statsType =3D QEMU_DOMAIN_JOB_STATS_TYPE_BACKUP; + jobPriv->current->status =3D QEMU_DOMAIN_JOB_STATUS_ACTIVE; + jobPriv->current->started =3D now; break; =20 case QEMU_ASYNC_JOB_NONE: @@ -3760,7 +3765,6 @@ qemuDomainPerfRestart(virDomainObjPtr vm) return 0; } =20 - static void qemuProcessReconnectCheckMemAliasOrderMismatch(virDomainObjPtr vm) { --=20 2.25.1