From nobody Mon Apr 29 05:23:13 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 205.139.110.61 as permitted sender) client-ip=205.139.110.61; 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 205.139.110.61 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=1578321454; cv=none; d=zohomail.com; s=zohoarc; b=AsanzLoE3GPvnFG+/SpEtC3wdEMb+mBL0lau+aprvp/XTo/ld5hc85Gdi+r62vrzKEE1wNQLpt51iIOk4dnq0+4pxnECQpnsUF3ogHqmKWVXGLb/SwMSpMo7MtRqWYT0QORTx2wr4AScvIa7poyC+l4UjQzg+xPEOZNFDj+YM0s= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1578321454; 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=y/SRANBFNQCgKc202VVYXt6K9J+o/ABdxAtXjVqNQzQ=; b=Dt+xdZbkynkXWAmgPY1IGZJCAmztsLHthXCSCKe72rvcI4Lf/XCGdr0c0GbzsKA7oDbXYtUbgaVmij9oH8AUaEG7n15+PCcKNbn5lbTCRNC/S5ZjbJESbzKhxr95mEe0zDZIWewn7pZbR+0mff6/7PrLYRqnzvM3xFp+CGCBD2c= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 205.139.110.61 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-1.mimecast.com [205.139.110.61]) by mx.zohomail.com with SMTPS id 1578321454571436.50894795175384; Mon, 6 Jan 2020 06:37:34 -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-232-l1pLVRVQPjevnc2MjZboLg-1; Mon, 06 Jan 2020 09:37:31 -0500 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 5513B18557CE; Mon, 6 Jan 2020 14:37:26 +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 2303F1BC6D; Mon, 6 Jan 2020 14:37:26 +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 D918718089CF; Mon, 6 Jan 2020 14:37:25 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 006EbF3T010906 for ; Mon, 6 Jan 2020 09:37:15 -0500 Received: by smtp.corp.redhat.com (Postfix) id 29B4C1084194; Mon, 6 Jan 2020 14:37:15 +0000 (UTC) Received: from angien.redhat.com (unknown [10.43.2.48]) by smtp.corp.redhat.com (Postfix) with ESMTP id A5F081084192 for ; Mon, 6 Jan 2020 14:37:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1578321453; 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=y/SRANBFNQCgKc202VVYXt6K9J+o/ABdxAtXjVqNQzQ=; b=Wfrdz4B3I4ihytteZXQ0M08J8CfxMA8tdgaEzM+tdJCaexq7FW3pq4J9Sq8JL7FEAvakEc gmHxjJ/V5m2+9ZcVkPBAOjK4H4P3NcQ6FwQXmhfNRZEArkihsK5vM01cLIWOXFlmefSkTK MnloPuH9ITVnDIcIuxSUGSfaVNzSo5c= From: Peter Krempa To: libvir-list@redhat.com Date: Mon, 6 Jan 2020 15:37:09 +0100 Message-Id: <46ec511932266befad7ac864eabdc6b4f7aecba9.1578321367.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 1/2] qemu: checkpoint: Extract and export rollback of checkpoint metadata storing 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-MC-Unique: l1pLVRVQPjevnc2MjZboLg-1 X-Mimecast-Spam-Score: 0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" If we are certain that the checkpoint creation failed we remove the metadata from the list. To allow reusing this in the backup code add a new helper and export it. Signed-off-by: Peter Krempa Reviewed-by: Daniel P. Berrang=C3=A9 --- src/qemu/qemu_checkpoint.c | 22 ++++++++++++++++++++-- src/qemu/qemu_checkpoint.h | 4 ++++ 2 files changed, 24 insertions(+), 2 deletions(-) diff --git a/src/qemu/qemu_checkpoint.c b/src/qemu/qemu_checkpoint.c index 97bc97bb8e..2fa5c1ae00 100644 --- a/src/qemu/qemu_checkpoint.c +++ b/src/qemu/qemu_checkpoint.c @@ -400,6 +400,24 @@ qemuCheckpointCreateCommon(virQEMUDriverPtr driver, } +/** + * qemuCheckpointRollbackMetadata: + * @vm: domain object + * @chk: checkpoint object + * + * If @chk is not null remove the @chk object from the list of checkpoints= of @vm. + */ +void +qemuCheckpointRollbackMetadata(virDomainObjPtr vm, + virDomainMomentObjPtr chk) +{ + if (!chk) + return; + + virDomainCheckpointObjListRemove(vm->checkpoints, chk); +} + + static virDomainMomentObjPtr qemuCheckpointCreate(virQEMUDriverPtr driver, virDomainObjPtr vm, @@ -415,7 +433,7 @@ qemuCheckpointCreate(virQEMUDriverPtr driver, qemuDomainObjEnterMonitor(driver, vm); rc =3D qemuMonitorTransaction(qemuDomainGetMonitor(vm), &actions); if (qemuDomainObjExitMonitor(driver, vm) < 0 || rc < 0) { - virDomainCheckpointObjListRemove(vm->checkpoints, chk); + qemuCheckpointRollbackMetadata(vm, chk); return NULL; } @@ -441,7 +459,7 @@ qemuCheckpointCreateFinalize(virQEMUDriverPtr driver, virReportError(VIR_ERR_INTERNAL_ERROR, _("unable to save metadata for checkpoint %s"), chk->def->name); - virDomainCheckpointObjListRemove(vm->checkpoints, chk); + qemuCheckpointRollbackMetadata(vm, chk); return -1; } diff --git a/src/qemu/qemu_checkpoint.h b/src/qemu/qemu_checkpoint.h index 00548beec9..eb85611ea6 100644 --- a/src/qemu/qemu_checkpoint.h +++ b/src/qemu/qemu_checkpoint.h @@ -67,3 +67,7 @@ qemuCheckpointCreateFinalize(virQEMUDriverPtr driver, virQEMUDriverConfigPtr cfg, virDomainMomentObjPtr chk, bool update_current); + +void +qemuCheckpointRollbackMetadata(virDomainObjPtr vm, + virDomainMomentObjPtr chk); --=20 2.24.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Mon Apr 29 05:23:13 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-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=1578321446; cv=none; d=zohomail.com; s=zohoarc; b=kbEuA29KatiqQdHv3nmL2Vubv9iWRSOf9iWlrbcMwHMtDlpDec7n2clxNv27Xn8eFh7VZH78wmkzzDe2he6BLvRxsy0P467dAn4DKd4DpoNwisqlfyAgzBvEE/7GnQBl3zYG6NnaaG5Y2tA8BchglsnixD4nqspGqXxXd6btAII= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1578321446; 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=NnM4OIl/xxFmSgXfRmgEeKWVd4OfqD/YuAhKuFbnX2Q=; b=fYvmN7bpqIfhE8jzIiEEqAZnkcM/TeeoywUOTJAwZCObVWO7Gw4jzfNypaEXaL85qRh4OMbKLOlY5FfcuX0foLQsB6KfJJfibe2MbWBrfj2karoPI7Ght2vm9JgorxcHEQ0mSHp0Op8loGkRNTLKHkSCMsriHmk33NWQZG0P3Y4= 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-1.mimecast.com (us-smtp-2.mimecast.com [207.211.31.81]) by mx.zohomail.com with SMTPS id 1578321446378206.9361256641604; Mon, 6 Jan 2020 06:37:26 -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-17--W3NxhgaNHGuhAVNOc089w-1; Mon, 06 Jan 2020 09:37:23 -0500 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 D2301DB35; Mon, 6 Jan 2020 14:37:17 +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 A7B61858A2; Mon, 6 Jan 2020 14:37:17 +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 4216B81C73; Mon, 6 Jan 2020 14:37:17 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 006EbF6r010912 for ; Mon, 6 Jan 2020 09:37:16 -0500 Received: by smtp.corp.redhat.com (Postfix) id EEB331084194; Mon, 6 Jan 2020 14:37:15 +0000 (UTC) Received: from angien.redhat.com (unknown [10.43.2.48]) by smtp.corp.redhat.com (Postfix) with ESMTP id 77A331084192 for ; Mon, 6 Jan 2020 14:37:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1578321445; 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=NnM4OIl/xxFmSgXfRmgEeKWVd4OfqD/YuAhKuFbnX2Q=; b=R1xHaS367I4x3mJ1YO0mO+wWmKMwh1TqtUT9wOoDgUGUCzzWUncLF6+GUFglbEcG8XAXwU X6j4rfNxCqEPn2hSoZEnHHOhZ0HvhxOqy6UA9EySf7agzlbQbxvTTI74NC6WmIdALXh4wQ gXk1SttiRaiIDdhAl0w7GBBRjSH96Ik= From: Peter Krempa To: libvir-list@redhat.com Date: Mon, 6 Jan 2020 15:37:10 +0100 Message-Id: <0446b18dc490a2a1fdd93958fd39bd746b2cccbb.1578321367.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 2/2] qemu: backup: roll-back checkpoint metadata if the checkpoint wasn't taken 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 X-MC-Unique: -W3NxhgaNHGuhAVNOc089w-1 X-Mimecast-Spam-Score: 0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" We insert the checkpoint metadata into the list of checkpoints prior to actually creating the on-disk bits. If the 'transaction' or any other steps done between inserting the checkpoint and creating the on-disk data fail we'd end up with an unusable checkpoint that would vanish after libvirtd restart. Prevent this by rolling back the metadata if we didn't actually take and record the checkpoint. Signed-off-by: Peter Krempa Reviewed-by: Daniel P. Berrang=C3=A9 --- src/qemu/qemu_backup.c | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/src/qemu/qemu_backup.c b/src/qemu/qemu_backup.c index c0445e0869..e7358082d5 100644 --- a/src/qemu/qemu_backup.c +++ b/src/qemu/qemu_backup.c @@ -812,6 +812,8 @@ qemuBackupBegin(virDomainObjPtr vm, if (!(actions =3D virJSONValueNewArray())) goto endjob; + /* The 'chk' checkpoint must be rolled back if the transaction command + * which creates it on disk is not executed or fails */ if (chkdef) { if (qemuCheckpointCreateCommon(priv->driver, vm, &chkdef, &actions, &chk) < 0) @@ -857,9 +859,11 @@ qemuBackupBegin(virDomainObjPtr vm, job_started =3D true; qemuBackupDiskStarted(vm, dd, ndd); - if (chk && - qemuCheckpointCreateFinalize(priv->driver, vm, cfg, chk, true) < 0) - goto endjob; + if (chk) { + virDomainMomentObjPtr tmpchk =3D g_steal_pointer(&chk); + if (qemuCheckpointCreateFinalize(priv->driver, vm, cfg, tmpchk, tr= ue) < 0) + goto endjob; + } if (pull) { if (qemuDomainObjEnterMonitorAsync(priv->driver, vm, QEMU_ASYNC_JO= B_BACKUP) < 0) @@ -880,6 +884,10 @@ qemuBackupBegin(virDomainObjPtr vm, endjob: qemuBackupDiskDataCleanup(vm, dd, ndd); + + /* if 'chk' is non-NULL here it's a failure and it must be rolled back= */ + qemuCheckpointRollbackMetadata(vm, chk); + if (!job_started && nbd_running && qemuDomainObjEnterMonitorAsync(priv->driver, vm, QEMU_ASYNC_JOB_BA= CKUP) < 0) { ignore_value(qemuMonitorNBDServerStop(priv->mon)); --=20 2.24.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list