From nobody Sat May 4 07:17:58 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 63.128.21.124 as permitted sender) client-ip=63.128.21.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 63.128.21.124 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=1615477853; cv=none; d=zohomail.com; s=zohoarc; b=Mlt4JKcsyMe6Iloy38edgoLISPEnHZtyzclFfgNq+XH7zfeJqP36hkUNEYjShGRm2z/vIqNtDaKN29UpfRlfe0cTNWlNIiwQi9HabWz/H5JfhVx7nV1orEx/yZM5/9dNRyXAGHKbIbxgzgBzDelZz4HFbPokfZYE36ydwiNbAQo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1615477853; 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=3AtWKOz61QJD+xPViq4keGukQWnGMJiv4RiLJA7215c=; b=EvL6vjeUVZ3SnqRKo4Xv3oOUVyklQM909BnhavOI1ad5ztRwJ3LwGsyLJyTwqViIzmFHPwkiOo1KPffrsEZmp9cluBFot1VT4vuPUlB2i16LAowQSe0ysJi0eWdx5gGHzga7A4oTDsJ5BeDI+d3C5Gp+CY7smViqOvLx+iO2AOY= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 63.128.21.124 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-124.mimecast.com (us-smtp-delivery-124.mimecast.com [63.128.21.124]) by mx.zohomail.com with SMTPS id 1615477853852245.98147019807834; Thu, 11 Mar 2021 07:50:53 -0800 (PST) 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-272-TkMHqQz7Na-V1KqGWp_f7A-1; Thu, 11 Mar 2021 10:50:50 -0500 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 2ADC583DD22; Thu, 11 Mar 2021 15:50:45 +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 E54421001281; Thu, 11 Mar 2021 15:50:44 +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 731BA1809C84; Thu, 11 Mar 2021 15:50:43 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 12BFoepw014421 for ; Thu, 11 Mar 2021 10:50:40 -0500 Received: by smtp.corp.redhat.com (Postfix) id 14A455C1CF; Thu, 11 Mar 2021 15:50:40 +0000 (UTC) Received: from speedmetal.lan (unknown [10.40.208.53]) by smtp.corp.redhat.com (Postfix) with ESMTP id 719981C4 for ; Thu, 11 Mar 2021 15:50:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1615477852; 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=3AtWKOz61QJD+xPViq4keGukQWnGMJiv4RiLJA7215c=; b=Gml3JUmw217Rn0tNrgqGM5CiSpocWaFS+X8XQF7oM4k8ErRRRv/PeegF8Cn0IbxxmvO1dJ dbEq8m+idndgFMBN+HM9jmVwsZ5k6x2RuU8r6j3oaoxUTCTnr6BArjD9juXvM3xmNSwBuP 5NgiegA50VjoXfwaL4o7WnfQJCDiXFM= X-MC-Unique: TkMHqQz7Na-V1KqGWp_f7A-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 1/2] backup: Store 'apiFlags' in private section of virDomainBackupDef Date: Thu, 11 Mar 2021 16:50:36 +0100 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 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.22 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com 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" 'qemuBackupJobTerminate' needs the API flags to see whether VIR_DOMAIN_BACKUP_BEGIN_REUSE_EXTERNAL. Unfortunately when called via qemuProcessReconnect()->qemuProcessStop() early (e.g. if the qemu process died while we were reconnecting) the job is cleared temporarily so that other APIs can be called. This would mean that we couldn't clean up the files in some cases. Save the 'apiFlags' inside the backup object and set it from the 'qemuDomainJobObj' 'apiFlags' member when reconnecting to a VM. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/conf/backup_conf.h | 2 ++ src/qemu/qemu_backup.c | 4 +++- src/qemu/qemu_process.c | 9 ++++++--- 3 files changed, 11 insertions(+), 4 deletions(-) diff --git a/src/conf/backup_conf.h b/src/conf/backup_conf.h index bda2bdcfe4..2902f39fb7 100644 --- a/src/conf/backup_conf.h +++ b/src/conf/backup_conf.h @@ -99,6 +99,8 @@ struct _virDomainBackupDef { unsigned long long pull_tmp_total; char *errmsg; /* error message of failed sub-blockjob */ + + unsigned int apiFlags; /* original flags used when starting the job */ }; typedef enum { diff --git a/src/qemu/qemu_backup.c b/src/qemu/qemu_backup.c index 6ce29c28e1..f6096f643f 100644 --- a/src/qemu/qemu_backup.c +++ b/src/qemu/qemu_backup.c @@ -560,7 +560,7 @@ qemuBackupJobTerminate(virDomainObjPtr vm, qemuDomainObjPrivatePtr priv =3D vm->privateData; size_t i; - if (!(priv->job.apiFlags & VIR_DOMAIN_BACKUP_BEGIN_REUSE_EXTERNAL) && + if (!(priv->backup->apiFlags & VIR_DOMAIN_BACKUP_BEGIN_REUSE_EXTERNAL)= && (priv->backup->type =3D=3D VIR_DOMAIN_BACKUP_TYPE_PULL || (priv->backup->type =3D=3D VIR_DOMAIN_BACKUP_TYPE_PUSH && jobstatus !=3D QEMU_DOMAIN_JOB_STATUS_COMPLETED))) { @@ -766,6 +766,8 @@ qemuBackupBegin(virDomainObjPtr vm, if (def->type =3D=3D VIR_DOMAIN_BACKUP_TYPE_PULL) pull =3D true; + def->apiFlags =3D flags; + /* we'll treat this kind of backup job as an asyncjob as it uses some = of the * infrastructure for async jobs. We'll allow standard modify-type jobs * as the interlocking of conflicting operations is handled on the blo= ck diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c index 89ede27751..971a270793 100644 --- a/src/qemu/qemu_process.c +++ b/src/qemu/qemu_process.c @@ -96,6 +96,7 @@ #include "virthreadjob.h" #include "virutil.h" #include "storage_source.h" +#include "backup_conf.h" #define VIR_FROM_THIS VIR_FROM_QEMU @@ -8315,12 +8316,14 @@ qemuProcessReconnect(void *opaque) g_clear_object(&data->identity); VIR_FREE(data); + cfg =3D virQEMUDriverGetConfig(driver); + priv =3D obj->privateData; + qemuDomainObjRestoreJob(obj, &oldjob); if (oldjob.asyncJob =3D=3D QEMU_ASYNC_JOB_MIGRATION_IN) stopFlags |=3D VIR_QEMU_PROCESS_STOP_MIGRATED; - - cfg =3D virQEMUDriverGetConfig(driver); - priv =3D obj->privateData; + if (oldjob.asyncJob =3D=3D QEMU_ASYNC_JOB_BACKUP && priv->backup) + priv->backup->apiFlags =3D oldjob.apiFlags; /* expect that libvirt might have crashed during VM start, so prevent * cleanup of transient disks */ --=20 2.29.2 From nobody Sat May 4 07:17:58 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 63.128.21.124 as permitted sender) client-ip=63.128.21.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 63.128.21.124 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=1615477853; cv=none; d=zohomail.com; s=zohoarc; b=lcyxyzSImbvyFbmX04nC12EPQzBKCvcNHbfq+TKEzL5iAVABIb3DPERP0QiwZ72felTrcvrVttKODa2yie82oqNBwnED7zVLTyZzDszDYgnAN0NVPdo5xv7BxTwG2O8lSeNc9r5sEs7ystqugJ6bW9GWbKD2FBBKT/R8eMVu1tk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1615477853; 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=GA59NcgsvfM+JN3KjeeOy4zuy7/SYlYRgUS5W5AfriY=; b=j4m9V9QnWQ3ogfywK4T8JtiqX7K5gpjrf/HR5jS3bwBGpDKSIcOwej7CtfPOpt/4S9++BTR5h4y1sTJ/2BXaSTRQnDBUJoav2iYolZihdX1vKoh0wnZOGlG0xnY71cwJAZrHDK7BRxTlFUwBEcYQnxnua5cKHZBKjZ+jJrtOvz8= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 63.128.21.124 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-124.mimecast.com (us-smtp-delivery-124.mimecast.com [63.128.21.124]) by mx.zohomail.com with SMTPS id 1615477853911749.2021836202217; Thu, 11 Mar 2021 07:50:53 -0800 (PST) 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-476-3TvC7LMNN2C4YbwrtiZ5mg-1; Thu, 11 Mar 2021 10:50:50 -0500 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 072EA83DD21; Thu, 11 Mar 2021 15:50:45 +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 98CC519C78; Thu, 11 Mar 2021 15:50:44 +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 C73441800232; Thu, 11 Mar 2021 15:50:43 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 12BFofx4014429 for ; Thu, 11 Mar 2021 10:50:41 -0500 Received: by smtp.corp.redhat.com (Postfix) id 1D91E5C23E; Thu, 11 Mar 2021 15:50:41 +0000 (UTC) Received: from speedmetal.lan (unknown [10.40.208.53]) by smtp.corp.redhat.com (Postfix) with ESMTP id 7E8615C1CF for ; Thu, 11 Mar 2021 15:50:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1615477852; 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=GA59NcgsvfM+JN3KjeeOy4zuy7/SYlYRgUS5W5AfriY=; b=K94PN5LpNSrJ3YVhZw9qQPnH1wF5ClX5u3GdWyVSWC6XAD5EC+MzpnHidoKzfElwIk23A0 Y8qu1ZP5hbAGo6eK3iSba3yDP5jUsSkff0Y3ROS7JSopLHZvZSv+m25WSGTCJGyoQevmd1 KP0qcNPXj/FHmLC8RjHqRCsB4kD99Z4= X-MC-Unique: 3TvC7LMNN2C4YbwrtiZ5mg-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 2/2] qemuBackupJobTerminate: Fix job termination for inactive VMs Date: Thu, 11 Mar 2021 16:50:37 +0100 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 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 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com 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" Commit cb29e4e801d didn't take into account that the VM can be inactive when it's destroyed. This means that the job would remain active also when the VM became inactive. To fix this properly: 1) Remove the bogus VM liveness check and early return (reverts the aforementioned commit) 2) Conditionalize the stats assignment only when the stats object is present (properly fix the crash when VM dies when reconnecting) 3) end the asyncjob only when it was already set (prevent corruption of priv->jobs_queued) Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=3D1937598 Fixes: cb29e4e801d Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- I didn't come up with a reasonable split so that I'd avoid the 'technically' 3 changes in one patch so that it'd still make sense. src/qemu/qemu_backup.c | 29 +++++++++++++++-------------- 1 file changed, 15 insertions(+), 14 deletions(-) diff --git a/src/qemu/qemu_backup.c b/src/qemu/qemu_backup.c index f6096f643f..f91d632715 100644 --- a/src/qemu/qemu_backup.c +++ b/src/qemu/qemu_backup.c @@ -583,27 +583,28 @@ qemuBackupJobTerminate(virDomainObjPtr vm, } } - if (!virDomainObjIsActive(vm)) - return; - - qemuDomainJobInfoUpdateTime(priv->job.current); + if (priv->job.current) { + qemuDomainJobInfoUpdateTime(priv->job.current); - g_clear_pointer(&priv->job.completed, qemuDomainJobInfoFree); - priv->job.completed =3D qemuDomainJobInfoCopy(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; - 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; + priv->job.completed->stats.backup.total =3D priv->backup->push_tot= al; + priv->job.completed->stats.backup.transferred =3D priv->backup->pu= sh_transferred; + 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; - priv->job.completed->status =3D jobstatus; - priv->job.completed->errmsg =3D g_strdup(priv->backup->errmsg); + priv->job.completed->status =3D jobstatus; + priv->job.completed->errmsg =3D g_strdup(priv->backup->errmsg); - qemuDomainEventEmitJobCompleted(priv->driver, vm); + qemuDomainEventEmitJobCompleted(priv->driver, vm); + } virDomainBackupDefFree(priv->backup); priv->backup =3D NULL; - qemuDomainObjEndAsyncJob(priv->driver, vm); + + if (priv->job.asyncJob =3D=3D QEMU_ASYNC_JOB_BACKUP) + qemuDomainObjEndAsyncJob(priv->driver, vm); } --=20 2.29.2