From nobody Sat May 18 23:55:09 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 205.139.110.120 as permitted sender) client-ip=205.139.110.120; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 205.139.110.120 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1587031023; cv=none; d=zohomail.com; s=zohoarc; b=M77Ow2pIwidJIbz+LYoY+HAELIdN0JUoqYwrJAoKC5moz/CGwX4K/ph9IJkQ7bluH5xfDfFQf21YFrb37OgD49JESyMilkXpkRXuqmwpCKWx4rUhSPeY19oZpgJJwWRV+g32A/lzawd3B0Ao8NCCFQQM+ihFlYNv3Sm3lapF92Q= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1587031023; h=Content-Type:Content-Transfer-Encoding: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=fNC/50DyNaFN14cf3mL8ZifbG5hDkqYUaRN3GZaPLb0=; b=Ns1n4xZO+gTJZwqf/p/35io9DbXHkSu5BSSFE/115+LtlgoATW+m5pEI4NGRPSgGDvuwXz2u1WX7MhK0cfMLKcJfMEonsL1XnlfEjv2uQtqI06Sp6uqWcIRq3vYnQuHKGnvlwrt+mZTakb7RbFvesxdzHpUPLfAIIUSGMhB+Ut8= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 205.139.110.120 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [205.139.110.120]) by mx.zohomail.com with SMTPS id 1587031023676878.748351570931; Thu, 16 Apr 2020 02:57:03 -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-53-rdvhljXRNtO-tF46iuMToQ-1; Thu, 16 Apr 2020 05:56:17 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id D07CB8017F3; Thu, 16 Apr 2020 09:56:11 +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 A7C9F119EAF; Thu, 16 Apr 2020 09:56:11 +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 5FA1F9338F; Thu, 16 Apr 2020 09:56:11 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 03G9tq1t020177 for ; Thu, 16 Apr 2020 05:55:52 -0400 Received: by smtp.corp.redhat.com (Postfix) id C1B375DA7B; Thu, 16 Apr 2020 09:55:52 +0000 (UTC) Received: from localhost.localdomain.com (unknown [10.40.208.39]) by smtp.corp.redhat.com (Postfix) with ESMTP id 3DA1E5DA2C for ; Thu, 16 Apr 2020 09:55:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1587031022; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=fNC/50DyNaFN14cf3mL8ZifbG5hDkqYUaRN3GZaPLb0=; b=NgdbuZm6aQdXmmGZc48Xi2O7Uq4CAGi+f82eYS7S+OItp2uQviEj1G+3T3rqfZ1TACcyFV NpcY7xFe56NoCge2sWNxbG1niAX8PiD6EMJp2fdjuz175J/JHtpoXK91MjmZPWcWVhLxWz t38iEGwktfSFTBTqjIOPjOZczN5Z7qc= X-MC-Unique: rdvhljXRNtO-tF46iuMToQ-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 1/5] remote: remoteDispatchDomainGetJobStats: Encode typed parameter strings Date: Thu, 16 Apr 2020 11:55:42 +0200 Message-Id: <23a32c58a985f69565d6da69e3fc2be2024d10c7.1587030883.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-loop: libvir-list@redhat.com 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.15 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" String typed parameter values were introduced in v0.9.7-30-g40624d32fb. virDomainGetJobStats was introduced in v1.0.2-239-g4dd00f4238 so all clients already support typed parameter stings at that time thus we can enable it unconditionally. Signed-off-by: Peter Krempa Reviewed-by: Eric Blake --- src/remote/remote_daemon_dispatch.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/remote/remote_daemon_dispatch.c b/src/remote/remote_daemon= _dispatch.c index c5506c2e11..5d1c6971c0 100644 --- a/src/remote/remote_daemon_dispatch.c +++ b/src/remote/remote_daemon_dispatch.c @@ -5505,7 +5505,7 @@ remoteDispatchDomainGetJobStats(virNetServerPtr serve= r G_GNUC_UNUSED, REMOTE_DOMAIN_JOB_STATS_MAX, (virTypedParameterRemotePtr *) &ret->param= s.params_val, &ret->params.params_len, - 0) < 0) + VIR_TYPED_PARAM_STRING_OKAY) < 0) goto cleanup; rv =3D 0; --=20 2.26.0 From nobody Sat May 18 23:55:09 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 205.139.110.120 as permitted sender) client-ip=205.139.110.120; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 205.139.110.120 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1587031016; cv=none; d=zohomail.com; s=zohoarc; b=EvEe1fGHKpNKI/bmSD4GP/pMmvBA/Hkg5ErRU1hFzr5DAQLumi+is7HC7pHqFDJ7mnKW7wYvr2cLStgnK+/krucpVESGbwA1//6zVDtblp43KK+ojoFOGpnB15FkGDv9ebv/om7iP2Rn5qkz3IbLCoKUQPZjkx3z3K2Ivsc5mbc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1587031016; h=Content-Type:Content-Transfer-Encoding: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=lQgreEwg38/b+0z0EZrqNqkRjf7PMx4qCBy1x6x98Po=; b=mPV1YlCYLKtX9sVd8mwRj9t6f3XeD/fLSOm9o/Fl/jBPsg4Cjdoss7zE/kLQKWJKgAT8JATw4Q01/yT5RuDMkOemKzV16isGLdxx9Q5JDUJEgqcAzX/rzOgtwDFsl4n8jDvzv/yTYljn3qkuAwoxVgcYhwQU3hiE+XGKO6JnSi0= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 205.139.110.120 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [205.139.110.120]) by mx.zohomail.com with SMTPS id 158703101670862.453639844363124; Thu, 16 Apr 2020 02:56:56 -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-492-EjdAFRpYOqmJUkoJ_VPxxQ-1; Thu, 16 Apr 2020 05:56:51 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 61B6C13FC; Thu, 16 Apr 2020 09:56:16 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 3EBF9118DF1; Thu, 16 Apr 2020 09:56:16 +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 ED80518089D0; Thu, 16 Apr 2020 09:56:15 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 03G9trA3020186 for ; Thu, 16 Apr 2020 05:55:53 -0400 Received: by smtp.corp.redhat.com (Postfix) id BC7C15DA2C; Thu, 16 Apr 2020 09:55:53 +0000 (UTC) Received: from localhost.localdomain.com (unknown [10.40.208.39]) by smtp.corp.redhat.com (Postfix) with ESMTP id 2BF1E5DA7B for ; Thu, 16 Apr 2020 09:55:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1587031014; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=lQgreEwg38/b+0z0EZrqNqkRjf7PMx4qCBy1x6x98Po=; b=YpQ+f5zY92T+t2Xd0+jZ3fFq608/XTTH5XRY4y7ZKEi62JQFL+YCA3w1hhJhNb5B6dxKYO 7MG7jb1cnMW8urvP7UoLY1vvIpc4wOh57GiqjOv2GMvubKuk6TMpdTUJDN9KEbPhPLmGBO 4lWYPO/+FreuzaztSvf0ZOq43TuggJo= X-MC-Unique: EjdAFRpYOqmJUkoJ_VPxxQ-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 2/5] qemu: Add free and copy function for qemuDomainJobInfo and use it Date: Thu, 16 Apr 2020 11:55:43 +0200 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-loop: libvir-list@redhat.com 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.15 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" In order to add a string to qemuDomainJobInfo we must ensure that it's freed and copied properly. Add helpers to copy and free the structure and adjust the code to use them properly for the new semantics. Additionally also allocation is changed to g_new0 as it includes the type and thus it's very easy to grep for all the allocations of a given type. Signed-off-by: Peter Krempa Reviewed-by: Eric Blake --- src/qemu/qemu_backup.c | 5 ++--- src/qemu/qemu_domain.c | 26 +++++++++++++++++----- src/qemu/qemu_domain.h | 8 +++++++ src/qemu/qemu_driver.c | 37 ++++++++++++++++---------------- src/qemu/qemu_migration.c | 16 ++++++-------- src/qemu/qemu_migration_cookie.c | 10 ++++----- 6 files changed, 61 insertions(+), 41 deletions(-) diff --git a/src/qemu/qemu_backup.c b/src/qemu/qemu_backup.c index 5d18720f53..03d34c9378 100644 --- a/src/qemu/qemu_backup.c +++ b/src/qemu/qemu_backup.c @@ -641,9 +641,8 @@ qemuBackupJobTerminate(virDomainObjPtr vm, qemuDomainJobInfoUpdateTime(priv->job.current); - g_free(priv->job.completed); - priv->job.completed =3D g_new0(qemuDomainJobInfo, 1); - *priv->job.completed =3D *priv->job.current; + g_clear_pointer(&priv->job.completed, qemuDomainJobInfoFree); + priv->job.completed =3D qemuDomainJobInfoCopy(priv->job.current); priv->job.completed->stats.backup.total =3D priv->backup->push_total; priv->job.completed->stats.backup.transferred =3D priv->backup->push_t= ransferred; diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index 91e234d644..13b1c4e402 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -305,6 +305,23 @@ qemuDomainDisableNamespace(virDomainObjPtr vm, } +void +qemuDomainJobInfoFree(qemuDomainJobInfoPtr info) +{ + g_free(info); +} + + +qemuDomainJobInfoPtr +qemuDomainJobInfoCopy(qemuDomainJobInfoPtr info) +{ + qemuDomainJobInfoPtr ret =3D g_new0(qemuDomainJobInfo, 1); + + memcpy(ret, info, sizeof(*info)); + + return ret; +} + void qemuDomainEventEmitJobCompleted(virQEMUDriverPtr driver, virDomainObjPtr vm) @@ -385,7 +402,7 @@ qemuDomainObjResetAsyncJob(qemuDomainObjPrivatePtr priv) job->spiceMigrated =3D false; job->dumpCompleted =3D false; VIR_FREE(job->error); - VIR_FREE(job->current); + g_clear_pointer(&job->current, qemuDomainJobInfoFree); qemuMigrationParamsFree(job->migParams); job->migParams =3D NULL; job->apiFlags =3D 0; @@ -415,8 +432,8 @@ qemuDomainObjFreeJob(qemuDomainObjPrivatePtr priv) { qemuDomainObjResetJob(priv); qemuDomainObjResetAsyncJob(priv); - VIR_FREE(priv->job.current); - VIR_FREE(priv->job.completed); + g_clear_pointer(&priv->job.current, qemuDomainJobInfoFree); + g_clear_pointer(&priv->job.completed, qemuDomainJobInfoFree); virCondDestroy(&priv->job.cond); virCondDestroy(&priv->job.asyncCond); } @@ -6291,8 +6308,7 @@ qemuDomainObjBeginJobInternal(virQEMUDriverPtr driver, qemuDomainAsyncJobTypeToString(asyncJob), obj, obj->def->name); qemuDomainObjResetAsyncJob(priv); - if (VIR_ALLOC(priv->job.current) < 0) - goto cleanup; + priv->job.current =3D g_new0(qemuDomainJobInfo, 1); priv->job.current->status =3D QEMU_DOMAIN_JOB_STATUS_ACTIVE; priv->job.asyncJob =3D asyncJob; priv->job.asyncOwner =3D virThreadSelfID(); diff --git a/src/qemu/qemu_domain.h b/src/qemu/qemu_domain.h index cf19f4d101..c7f28b04c2 100644 --- a/src/qemu/qemu_domain.h +++ b/src/qemu/qemu_domain.h @@ -177,6 +177,14 @@ struct _qemuDomainJobInfo { qemuDomainMirrorStats mirrorStats; }; +void +qemuDomainJobInfoFree(qemuDomainJobInfoPtr info); + +G_DEFINE_AUTOPTR_CLEANUP_FUNC(qemuDomainJobInfo, qemuDomainJobInfoFree); + +qemuDomainJobInfoPtr +qemuDomainJobInfoCopy(qemuDomainJobInfoPtr info); + typedef struct _qemuDomainJobObj qemuDomainJobObj; typedef qemuDomainJobObj *qemuDomainJobObjPtr; struct _qemuDomainJobObj { diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index 31f199fdef..63e92b84c6 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -3746,7 +3746,7 @@ qemuDumpToFd(virQEMUDriverPtr driver, if (detach) priv->job.current->statsType =3D QEMU_DOMAIN_JOB_STATS_TYPE_MEMDUM= P; else - VIR_FREE(priv->job.current); + g_clear_pointer(&priv->job.current, qemuDomainJobInfoFree); if (qemuDomainObjEnterMonitorAsync(driver, vm, asyncJob) < 0) return -1; @@ -13598,16 +13598,16 @@ static int qemuDomainGetJobStatsInternal(virQEMUDriverPtr driver, virDomainObjPtr vm, bool completed, - qemuDomainJobInfoPtr jobInfo) + qemuDomainJobInfoPtr *jobInfo) { qemuDomainObjPrivatePtr priv =3D vm->privateData; int ret =3D -1; + *jobInfo =3D NULL; + if (completed) { if (priv->job.completed && !priv->job.current) - *jobInfo =3D *priv->job.completed; - else - jobInfo->status =3D QEMU_DOMAIN_JOB_STATUS_NONE; + *jobInfo =3D qemuDomainJobInfoCopy(priv->job.completed); return 0; } @@ -13626,26 +13626,25 @@ qemuDomainGetJobStatsInternal(virQEMUDriverPtr dr= iver, goto cleanup; if (!priv->job.current) { - jobInfo->status =3D QEMU_DOMAIN_JOB_STATUS_NONE; ret =3D 0; goto cleanup; } - *jobInfo =3D *priv->job.current; + *jobInfo =3D qemuDomainJobInfoCopy(priv->job.current); - switch (jobInfo->statsType) { + switch ((*jobInfo)->statsType) { case QEMU_DOMAIN_JOB_STATS_TYPE_MIGRATION: case QEMU_DOMAIN_JOB_STATS_TYPE_SAVEDUMP: - if (qemuDomainGetJobInfoMigrationStats(driver, vm, jobInfo) < 0) + if (qemuDomainGetJobInfoMigrationStats(driver, vm, *jobInfo) < 0) goto cleanup; break; case QEMU_DOMAIN_JOB_STATS_TYPE_MEMDUMP: - if (qemuDomainGetJobInfoDumpStats(driver, vm, jobInfo) < 0) + if (qemuDomainGetJobInfoDumpStats(driver, vm, *jobInfo) < 0) goto cleanup; break; case QEMU_DOMAIN_JOB_STATS_TYPE_BACKUP: - if (qemuBackupGetJobInfoStats(driver, vm, jobInfo) < 0) + if (qemuBackupGetJobInfoStats(driver, vm, *jobInfo) < 0) goto cleanup; break; @@ -13666,7 +13665,7 @@ qemuDomainGetJobInfo(virDomainPtr dom, virDomainJobInfoPtr info) { virQEMUDriverPtr driver =3D dom->conn->privateData; - qemuDomainJobInfo jobInfo; + g_autoptr(qemuDomainJobInfo) jobInfo =3D NULL; virDomainObjPtr vm; int ret =3D -1; @@ -13681,12 +13680,13 @@ qemuDomainGetJobInfo(virDomainPtr dom, if (qemuDomainGetJobStatsInternal(driver, vm, false, &jobInfo) < 0) goto cleanup; - if (jobInfo.status =3D=3D QEMU_DOMAIN_JOB_STATUS_NONE) { + if (!jobInfo || + jobInfo->status =3D=3D QEMU_DOMAIN_JOB_STATUS_NONE) { ret =3D 0; goto cleanup; } - ret =3D qemuDomainJobInfoToInfo(&jobInfo, info); + ret =3D qemuDomainJobInfoToInfo(jobInfo, info); cleanup: virDomainObjEndAPI(&vm); @@ -13704,7 +13704,7 @@ qemuDomainGetJobStats(virDomainPtr dom, virQEMUDriverPtr driver =3D dom->conn->privateData; virDomainObjPtr vm; qemuDomainObjPrivatePtr priv; - qemuDomainJobInfo jobInfo; + g_autoptr(qemuDomainJobInfo) jobInfo =3D NULL; bool completed =3D !!(flags & VIR_DOMAIN_JOB_STATS_COMPLETED); int ret =3D -1; @@ -13721,7 +13721,8 @@ qemuDomainGetJobStats(virDomainPtr dom, if (qemuDomainGetJobStatsInternal(driver, vm, completed, &jobInfo) < 0) goto cleanup; - if (jobInfo.status =3D=3D QEMU_DOMAIN_JOB_STATUS_NONE) { + if (!jobInfo || + jobInfo->status =3D=3D QEMU_DOMAIN_JOB_STATUS_NONE) { *type =3D VIR_DOMAIN_JOB_NONE; *params =3D NULL; *nparams =3D 0; @@ -13729,10 +13730,10 @@ qemuDomainGetJobStats(virDomainPtr dom, goto cleanup; } - ret =3D qemuDomainJobInfoToParams(&jobInfo, type, params, nparams); + ret =3D qemuDomainJobInfoToParams(jobInfo, type, params, nparams); if (completed && ret =3D=3D 0 && !(flags & VIR_DOMAIN_JOB_STATS_KEEP_C= OMPLETED)) - VIR_FREE(priv->job.completed); + g_clear_pointer(&priv->job.completed, qemuDomainJobInfoFree); cleanup: virDomainObjEndAPI(&vm); diff --git a/src/qemu/qemu_migration.c b/src/qemu/qemu_migration.c index bc280e856a..02e8271e42 100644 --- a/src/qemu/qemu_migration.c +++ b/src/qemu/qemu_migration.c @@ -1724,11 +1724,9 @@ qemuMigrationSrcWaitForCompletion(virQEMUDriverPtr d= river, qemuDomainJobInfoUpdateTime(jobInfo); qemuDomainJobInfoUpdateDowntime(jobInfo); - VIR_FREE(priv->job.completed); - if (VIR_ALLOC(priv->job.completed) =3D=3D 0) { - *priv->job.completed =3D *jobInfo; - priv->job.completed->status =3D QEMU_DOMAIN_JOB_STATUS_COMPLETED; - } + g_clear_pointer(&priv->job.completed, qemuDomainJobInfoFree); + priv->job.completed =3D qemuDomainJobInfoCopy(jobInfo); + priv->job.completed->status =3D QEMU_DOMAIN_JOB_STATUS_COMPLETED; if (asyncJob !=3D QEMU_ASYNC_JOB_MIGRATION_OUT && jobInfo->status =3D=3D QEMU_DOMAIN_JOB_STATUS_QEMU_COMPLETED) @@ -3017,7 +3015,7 @@ qemuMigrationSrcConfirmPhase(virQEMUDriverPtr driver, if (retcode =3D=3D 0) jobInfo =3D priv->job.completed; else - VIR_FREE(priv->job.completed); + g_clear_pointer(&priv->job.completed, qemuDomainJobInfoFree); /* Update times with the values sent by the destination daemon */ if (mig->jobInfo && jobInfo) { @@ -5036,7 +5034,7 @@ qemuMigrationDstFinish(virQEMUDriverPtr driver, : QEMU_MIGRATION_PHASE_FINISH2); qemuDomainCleanupRemove(vm, qemuMigrationDstPrepareCleanup); - VIR_FREE(priv->job.completed); + g_clear_pointer(&priv->job.completed, qemuDomainJobInfoFree); cookie_flags =3D QEMU_MIGRATION_COOKIE_NETWORK | QEMU_MIGRATION_COOKIE_STATS | @@ -5257,7 +5255,7 @@ qemuMigrationDstFinish(virQEMUDriverPtr driver, * is obsolete anyway. */ if (inPostCopy) - VIR_FREE(priv->job.completed); + g_clear_pointer(&priv->job.completed, qemuDomainJobInfoFree); } qemuMigrationParamsReset(driver, vm, QEMU_ASYNC_JOB_MIGRATION_IN, @@ -5268,7 +5266,7 @@ qemuMigrationDstFinish(virQEMUDriverPtr driver, qemuDomainRemoveInactiveJob(driver, vm); cleanup: - VIR_FREE(jobInfo); + g_clear_pointer(&jobInfo, qemuDomainJobInfoFree); virPortAllocatorRelease(port); if (priv->mon) qemuMonitorSetDomainLog(priv->mon, NULL, NULL, NULL); diff --git a/src/qemu/qemu_migration_cookie.c b/src/qemu/qemu_migration_coo= kie.c index 1d88ac1d22..fb8b5bcd92 100644 --- a/src/qemu/qemu_migration_cookie.c +++ b/src/qemu/qemu_migration_cookie.c @@ -123,7 +123,7 @@ qemuMigrationCookieFree(qemuMigrationCookiePtr mig) VIR_FREE(mig->name); VIR_FREE(mig->lockState); VIR_FREE(mig->lockDriver); - VIR_FREE(mig->jobInfo); + g_clear_pointer(&mig->jobInfo, qemuDomainJobInfoFree); virCPUDefFree(mig->cpu); qemuMigrationCookieCapsFree(mig->caps); VIR_FREE(mig); @@ -513,10 +513,9 @@ qemuMigrationCookieAddStatistics(qemuMigrationCookiePt= r mig, if (!priv->job.completed) return 0; - if (!mig->jobInfo && VIR_ALLOC(mig->jobInfo) < 0) - return -1; + g_clear_pointer(&mig->jobInfo, qemuDomainJobInfoFree); + mig->jobInfo =3D qemuDomainJobInfoCopy(priv->job.completed); - *mig->jobInfo =3D *priv->job.completed; mig->flags |=3D QEMU_MIGRATION_COOKIE_STATS; return 0; @@ -1051,8 +1050,7 @@ qemuMigrationCookieStatisticsXMLParse(xmlXPathContext= Ptr ctxt) if (!(ctxt->node =3D virXPathNode("./statistics", ctxt))) return NULL; - if (VIR_ALLOC(jobInfo) < 0) - return NULL; + jobInfo =3D g_new0(qemuDomainJobInfo, 1); stats =3D &jobInfo->stats.mig; jobInfo->status =3D QEMU_DOMAIN_JOB_STATUS_COMPLETED; --=20 2.26.0 From nobody Sat May 18 23:55:09 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; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 207.211.31.120 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1587030966; cv=none; d=zohomail.com; s=zohoarc; b=YkWWpLuH2WFYOAwVI+tSHIbUnKtIbZRUO8TIFuSAP16GMRSdE5HneNjqsHdaf2RapNr1e+I9BUDhag+3C9mFeu5l4ZPcg9LPXmkXudlpb/8bl1feFFIVAiro0diqus2JPaX2lOwlICM4s8DOqP6H+31Ixy/65SVIwzDYH8A3AHI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1587030966; h=Content-Type:Content-Transfer-Encoding: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=6I2ZOlfggfHLblS8Vz0AL1J+qt8PMKlHnSGcC41/cd0=; b=eAK5YOuEOjt+M7A4/RGfW/8A+POHuXkRGc4uoh+AgG1kqgjzRbxqoNlYIH1UtWz4LfuuaZ1XKT/XarwmtbnC0DZ4xwz6eHISH4HYTRgpuNbmywuSMZ1eGigyGIAVsANw3b/Q9Cm/2dLS5tT92pAgRwXwxdH6Z3V1bIEWhZEqBtQ= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 207.211.31.120 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass 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 1587030966696104.41560123923534; Thu, 16 Apr 2020 02:56:06 -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-439-ldlPGa4ePGiLqXgrSMmkfQ-1; Thu, 16 Apr 2020 05:56:03 -0400 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 1F862108442D; Thu, 16 Apr 2020 09:55:58 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 0F3102719A; Thu, 16 Apr 2020 09:55:57 +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 DA1AF18089C8; Thu, 16 Apr 2020 09:55:55 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 03G9tsbi020193 for ; Thu, 16 Apr 2020 05:55:54 -0400 Received: by smtp.corp.redhat.com (Postfix) id B243D5DA7B; Thu, 16 Apr 2020 09:55:54 +0000 (UTC) Received: from localhost.localdomain.com (unknown [10.40.208.39]) by smtp.corp.redhat.com (Postfix) with ESMTP id 2676A5DA2C for ; Thu, 16 Apr 2020 09:55:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1587030965; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=6I2ZOlfggfHLblS8Vz0AL1J+qt8PMKlHnSGcC41/cd0=; b=Qzv/moPLP6Wv68tH2v18aMhAjBpMsZBmYrc7Ve12yUS23b9qU87UKx/fgOa5EGMYtgHTJl j5gpZ22ezGIk/ZYZI3mko2JNyL0B1TGCXjeWwCRKGj95rO4W20sIlMESgfJMixuvil2jBw mwt7vNIqyvDl1YMogP2H/yf1jWZNtbs= X-MC-Unique: ldlPGa4ePGiLqXgrSMmkfQ-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 3/5] API: Add VIR_DOMAIN_JOB_ERRMSG domain job statistics field Date: Thu, 16 Apr 2020 11:55:44 +0200 Message-Id: <6644d8cbb4e37fac2de9be36a780ed76e5220a87.1587030883.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-loop: libvir-list@redhat.com 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.84 on 10.5.11.23 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" In some cases it's useful to report the error which caused the domain job to fail. Add an optional field for holding the error message so that it can be later retrieved from statistics of a completed job. Add the field name macro and code for extracting it in virsh. Signed-off-by: Peter Krempa Reviewed-by: Eric Blake --- include/libvirt/libvirt-domain.h | 9 +++++++++ tools/virsh-domain.c | 8 ++++++++ 2 files changed, 17 insertions(+) diff --git a/include/libvirt/libvirt-domain.h b/include/libvirt/libvirt-dom= ain.h index b440818ec2..f129e6a1af 100644 --- a/include/libvirt/libvirt-domain.h +++ b/include/libvirt/libvirt-domain.h @@ -3612,6 +3612,15 @@ typedef enum { */ # define VIR_DOMAIN_JOB_SUCCESS "success" +/** + * VIR_DOMAIN_JOB_ERRMSG: + * + * virDomainGetJobStats field: Present only in statistics for a completed = job. + * Optional error message for a failed job. + */ +# define VIR_DOMAIN_JOB_ERRMSG "errmsg" + + /** * VIR_DOMAIN_JOB_DISK_TEMP_USED: * virDomainGetJobStats field: current usage of temporary disk space for t= he diff --git a/tools/virsh-domain.c b/tools/virsh-domain.c index d52eb7bc2f..f2dc41cb31 100644 --- a/tools/virsh-domain.c +++ b/tools/virsh-domain.c @@ -6228,6 +6228,7 @@ cmdDomjobinfo(vshControl *ctl, const vshCmd *cmd) unsigned long long value; unsigned int flags =3D 0; int ivalue; + const char *svalue; int op; int rc; size_t i; @@ -6508,6 +6509,13 @@ cmdDomjobinfo(vshControl *ctl, const vshCmd *cmd) vshPrint(ctl, "%-17s %-.3lf %s\n", _("Temporary disk space total:"= ), val, unit); } + if ((rc =3D virTypedParamsGetString(params, nparams, VIR_DOMAIN_JOB_ER= RMSG, + &svalue)) < 0) { + goto save_error; + } else if (rc =3D=3D 1) { + vshPrint(ctl, "%-17s %s\n", _("Error message:"), svalue); + } + ret =3D true; cleanup: --=20 2.26.0 From nobody Sat May 18 23:55:09 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 207.211.31.81 as permitted sender) client-ip=207.211.31.81; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 207.211.31.81 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1587030991; cv=none; d=zohomail.com; s=zohoarc; b=BNEtavGr0XfWT+t8vQseoKJedXF29mlF35+IavWEL3RBIeCPcIZddWtHgR9wBnmta6Egs/AbpAFe9pdZOzhi0DjoKx8ngaftUhITNq2b1aWl33nRyReyQLN3Gmet8NrxwnRhqPzj/1Qpur2iX0H8qeZ5YrsZ/QOROpk6T9Pa9MQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1587030991; h=Content-Type:Content-Transfer-Encoding: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=AP/CcJt8YZ0ujgj9lapsOhtMQq3nz4y5T2kTkIgjTz8=; b=fTsdmcZ65y0PvZIpJNbxFftwrAplK98SeSQLWm0wD7ziEycimq4KAwebxsv9+NzwqTKztpooHpy7kaaSMlOXjvn/xxXmSuI++FzahMqaq+g4Oj97qjm8WPUVIyiEs/qc8JDqH+CfGHVqijHgGlpdZCMk7Vw6lAPnn3U0m06pIqQ= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 207.211.31.81 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-delivery-1.mimecast.com (us-smtp-2.mimecast.com [207.211.31.81]) by mx.zohomail.com with SMTPS id 1587030991882763.5848223668024; Thu, 16 Apr 2020 02:56:31 -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-313-LXfRJCdXNXyH98ISaNvwPw-1; Thu, 16 Apr 2020 05:56:28 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id BAACC8018A8; Thu, 16 Apr 2020 09:56:22 +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 9642D7E7D7; Thu, 16 Apr 2020 09:56:22 +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 4C11093391; Thu, 16 Apr 2020 09:56:22 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 03G9ttVT020198 for ; Thu, 16 Apr 2020 05:55:55 -0400 Received: by smtp.corp.redhat.com (Postfix) id B785C5DA2C; Thu, 16 Apr 2020 09:55:55 +0000 (UTC) Received: from localhost.localdomain.com (unknown [10.40.208.39]) by smtp.corp.redhat.com (Postfix) with ESMTP id 1D6FE5DA7B for ; Thu, 16 Apr 2020 09:55:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1587030990; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=AP/CcJt8YZ0ujgj9lapsOhtMQq3nz4y5T2kTkIgjTz8=; b=hA0go8dZBO1icFQQ3YgX6+FL6CQnZa8jJeL7rHFdgfexvGFyXr2HqCUB7tXP26LqJufZL1 79SeBj9YYYdPLqn3bgeOGPtjDcxj3Gc+kjm9gEjhfBeMiud20R/1Mk0MBpT5spde+xc+/y wRbYrhATnIuPRgTpDKzsNRGcHVUYcSg= X-MC-Unique: LXfRJCdXNXyH98ISaNvwPw-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 4/5] qemu: domain: Add 'errmsg' field to qemuDomainJobInfo Date: Thu, 16 Apr 2020 11:55:45 +0200 Message-Id: <3efb4038d2587d037515b4c860b5669e78b4e08d.1587030883.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-loop: libvir-list@redhat.com 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.11 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" The field can be used by jobs to add an optional error message to a completed (failed) job. Signed-off-by: Peter Krempa Reviewed-by: Eric Blake --- src/qemu/qemu_domain.c | 3 +++ src/qemu/qemu_domain.h | 2 ++ 2 files changed, 5 insertions(+) diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index 13b1c4e402..dba222dde5 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -308,6 +308,7 @@ qemuDomainDisableNamespace(virDomainObjPtr vm, void qemuDomainJobInfoFree(qemuDomainJobInfoPtr info) { + g_free(info->errmsg); g_free(info); } @@ -319,6 +320,8 @@ qemuDomainJobInfoCopy(qemuDomainJobInfoPtr info) memcpy(ret, info, sizeof(*info)); + ret->errmsg =3D g_strdup(info->errmsg); + return ret; } diff --git a/src/qemu/qemu_domain.h b/src/qemu/qemu_domain.h index c7f28b04c2..639d27d8a5 100644 --- a/src/qemu/qemu_domain.h +++ b/src/qemu/qemu_domain.h @@ -175,6 +175,8 @@ struct _qemuDomainJobInfo { qemuDomainBackupStats backup; } stats; qemuDomainMirrorStats mirrorStats; + + char *errmsg; /* optional error message for failed completed jobs */ }; void --=20 2.26.0 From nobody Sat May 18 23:55:09 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 207.211.31.81 as permitted sender) client-ip=207.211.31.81; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 207.211.31.81 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1587031010; cv=none; d=zohomail.com; s=zohoarc; b=FXTPgA+/djnV22HlMq/rj3nQLoFBCFOm0ZEaUXn1rUWZHxRuAgTHa/CjgnmokWk6HbjJI6dZQh4jsLgVmkxFIiplZOweYqkYUqiCysihRVXAh3W2J/TumPhVvM/k6NATCHkXFeUiOXZVHypNll7WdkfAtVzZ/tVVURQqyLqEwN0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1587031010; h=Content-Type:Content-Transfer-Encoding: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=qXUM3O7UtUOMpQaq3GfqUxE+ZhKvljoCXartqWlscII=; b=E5+t8ie8GkixzqeVNKFdNKiwBEqmXlWqLnRIDF9ycZYMEPaCC+TeZ7xDGD1++SyCXbKR3/nSfnazaElvvHXuICMqhRVf2sraIisSaU02G3mTOpTvHBPfTYjPTJLVVaX1z/83OUWL2M2CB+dVKuc0TqZXBm+sybWM2kS5zp+7BXc= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 207.211.31.81 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-delivery-1.mimecast.com (us-smtp-2.mimecast.com [207.211.31.81]) by mx.zohomail.com with SMTPS id 1587031010739140.34813342937218; Thu, 16 Apr 2020 02:56:50 -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-329-dO4rKbnZNQmtp65AZKYhXA-1; Thu, 16 Apr 2020 05:56:47 -0400 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 1216410753F4; Thu, 16 Apr 2020 09:56:11 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id D52E3272A5; Thu, 16 Apr 2020 09:56:10 +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 7D5D118089CF; Thu, 16 Apr 2020 09:56:10 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 03G9tuEV020206 for ; Thu, 16 Apr 2020 05:55:56 -0400 Received: by smtp.corp.redhat.com (Postfix) id A4C555DA7B; Thu, 16 Apr 2020 09:55:56 +0000 (UTC) Received: from localhost.localdomain.com (unknown [10.40.208.39]) by smtp.corp.redhat.com (Postfix) with ESMTP id 18BA15DA2C for ; Thu, 16 Apr 2020 09:55:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1587031009; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=qXUM3O7UtUOMpQaq3GfqUxE+ZhKvljoCXartqWlscII=; b=AqdD3uVEhcTkOef3GFq5zLwBx91zYgcbpN5N4SqDIFFquYcjJiYiOGCizZaRZ14WSjgPVA qvL7UwDRd2jPp8FoaKeqgqS79/rAASzVbrv1AqDjvZctI72LAW2CxRfXl4NZsDxAvmUiyg SUl3nokXfvEJwNZqfsawgKXizbAtK4w= X-MC-Unique: dO4rKbnZNQmtp65AZKYhXA-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 5/5] backup: Store error message for failed backups Date: Thu, 16 Apr 2020 11:55:46 +0200 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-loop: libvir-list@redhat.com 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.84 on 10.5.11.23 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" If a backup job fails midway it's hard to figure out what happened as it's running asynchronous. Use the VIR_DOMAIN_JOB_ERRMSG job statistics field to pass through the error from the first failed backup-blockjob so that both the consumer of the virDomainGetJobStats and the corresponding event can see the error. event 'job-completed' for domain backup-test: operation: 9 time_elapsed: 46 disk_total: 104857600 disk_processed: 10158080 disk_remaining: 94699520 success: 0 errmsg: No space left on device virsh domjobinfo backup-test --completed --anystats Job type: Failed Operation: Backup Time elapsed: 46 ms File processed: 9.688 MiB File remaining: 90.312 MiB File total: 100.000 MiB Error message: No space left on device https://bugzilla.redhat.com/show_bug.cgi?id=3D1812827 Signed-off-by: Peter Krempa Reviewed-by: Eric Blake --- src/conf/backup_conf.c | 1 + src/conf/backup_conf.h | 2 ++ src/qemu/qemu_backup.c | 10 ++++++++-- src/qemu/qemu_backup.h | 1 + src/qemu/qemu_blockjob.c | 2 +- src/qemu/qemu_domain.c | 4 ++++ 6 files changed, 17 insertions(+), 3 deletions(-) diff --git a/src/conf/backup_conf.c b/src/conf/backup_conf.c index 64c8f6cc09..c5677cdb05 100644 --- a/src/conf/backup_conf.c +++ b/src/conf/backup_conf.c @@ -65,6 +65,7 @@ virDomainBackupDefFree(virDomainBackupDefPtr def) return; g_free(def->incremental); + g_free(def->errmsg); virStorageNetHostDefFree(1, def->server); for (i =3D 0; i < def->ndisks; i++) { diff --git a/src/conf/backup_conf.h b/src/conf/backup_conf.h index 672fd52ee7..b5685317c5 100644 --- a/src/conf/backup_conf.h +++ b/src/conf/backup_conf.h @@ -79,6 +79,8 @@ struct _virDomainBackupDef { unsigned long long push_total; unsigned long long pull_tmp_used; unsigned long long pull_tmp_total; + + char *errmsg; /* error message of failed sub-blockjob */ }; typedef enum { diff --git a/src/qemu/qemu_backup.c b/src/qemu/qemu_backup.c index 03d34c9378..80fc5d77f8 100644 --- a/src/qemu/qemu_backup.c +++ b/src/qemu/qemu_backup.c @@ -650,6 +650,7 @@ qemuBackupJobTerminate(virDomainObjPtr vm, priv->job.completed->stats.backup.tmp_total =3D priv->backup->pull_tmp= _total; priv->job.completed->status =3D jobstatus; + priv->job.completed->errmsg =3D g_strdup(priv->backup->errmsg); qemuDomainEventEmitJobCompleted(priv->driver, vm); @@ -951,6 +952,7 @@ void qemuBackupNotifyBlockjobEnd(virDomainObjPtr vm, virDomainDiskDefPtr disk, qemuBlockjobState state, + const char *errmsg, unsigned long long cur, unsigned long long end, int asyncJob) @@ -964,8 +966,8 @@ qemuBackupNotifyBlockjobEnd(virDomainObjPtr vm, virDomainBackupDefPtr backup =3D priv->backup; size_t i; - VIR_DEBUG("vm: '%s', disk:'%s', state:'%d'", - vm->def->name, disk->dst, state); + VIR_DEBUG("vm: '%s', disk:'%s', state:'%d' errmsg:'%s'", + vm->def->name, disk->dst, state, NULLSTR(errmsg)); if (!backup) return; @@ -985,6 +987,10 @@ qemuBackupNotifyBlockjobEnd(virDomainObjPtr vm, backup->push_total +=3D end; } + /* record first error message */ + if (!backup->errmsg) + backup->errmsg =3D g_strdup(errmsg); + for (i =3D 0; i < backup->ndisks; i++) { virDomainBackupDiskDefPtr backupdisk =3D backup->disks + i; diff --git a/src/qemu/qemu_backup.h b/src/qemu/qemu_backup.h index 3321ba0b6f..b19c3bf1c9 100644 --- a/src/qemu/qemu_backup.h +++ b/src/qemu/qemu_backup.h @@ -38,6 +38,7 @@ void qemuBackupNotifyBlockjobEnd(virDomainObjPtr vm, virDomainDiskDefPtr disk, qemuBlockjobState state, + const char *errmsg, unsigned long long cur, unsigned long long end, int asyncJob); diff --git a/src/qemu/qemu_blockjob.c b/src/qemu/qemu_blockjob.c index 2032c0c1c5..b9eecd3f98 100644 --- a/src/qemu/qemu_blockjob.c +++ b/src/qemu/qemu_blockjob.c @@ -1435,7 +1435,7 @@ qemuBlockJobProcessEventConcludedBackup(virQEMUDriver= Ptr driver, g_autoptr(qemuBlockStorageSourceAttachData) backend =3D NULL; g_autoptr(virJSONValue) actions =3D NULL; - qemuBackupNotifyBlockjobEnd(vm, job->disk, newstate, + qemuBackupNotifyBlockjobEnd(vm, job->disk, newstate, job->errmsg, progressCurrent, progressTotal, asyncJob); if (job->data.backup.store && diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index dba222dde5..22bb808177 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -836,6 +836,10 @@ qemuDomainBackupJobInfoToParams(qemuDomainJobInfoPtr j= obInfo, VIR_DOMAIN_JOB_SUCCESS) < 0) return -1; + if (jobInfo->errmsg && + virTypedParamListAddString(par, jobInfo->errmsg, VIR_DOMAIN_JOB_ER= RMSG) < 0) + return -1; + *nparams =3D virTypedParamListStealParams(par, params); *type =3D qemuDomainJobStatusToType(jobInfo->status); return 0; --=20 2.26.0