From nobody Fri Nov 21 10:14:02 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.libvirt.org designates 8.43.85.245 as permitted sender) client-ip=8.43.85.245; envelope-from=devel-bounces@lists.libvirt.org; helo=lists.libvirt.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of lists.libvirt.org designates 8.43.85.245 as permitted sender) smtp.mailfrom=devel-bounces@lists.libvirt.org; dmarc=pass(p=reject dis=none) header.from=lists.libvirt.org ARC-Seal: i=1; a=rsa-sha256; t=1763545459; cv=none; d=zohomail.com; s=zohoarc; b=aqMOia2h01vnNlbCUoK0VBUb/ld29yMDcrWuVFVhkaOKtmZ1VD6s7ungUTCOShyhdL9Jo4JD+N/sCXCcQmcDbv0yZgPYebYxFCr65G3tcLKcEXt/ES5tVPpsChHWvRjnsAf6MHKdbct0S5hHjMswkKUEh104kfcPXj85Q4Jjn2Y= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1763545459; h=Content-Type:Content-Transfer-Encoding:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Owner:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:Reply-To:References:Subject:Subject:To:To:Message-Id:Cc; bh=yhIeBqL/s8hL4zAkex1Ya2BGL4tTSp8zWS8dj7VjLQ0=; b=kYK+LPmUV3rgUDDwd4DGKmGXjKH7K31oYdkr6Ww/PU6GN/DDZiWue651M5EkR9+8VsdD1SaVvcM3AstuXxBknnwhuR2HO+0LsQQGHy4Mgg6mxyTjAo0uNdAwywwFXsUcB4jbWFHdd5RWp0A9EuAlBULm42A1YV8faTmXwVTPuc0= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of lists.libvirt.org designates 8.43.85.245 as permitted sender) smtp.mailfrom=devel-bounces@lists.libvirt.org; dmarc=pass header.from= (p=reject dis=none) Return-Path: Received: from lists.libvirt.org (lists.libvirt.org [8.43.85.245]) by mx.zohomail.com with SMTPS id 1763545459221611.4634793029303; Wed, 19 Nov 2025 01:44:19 -0800 (PST) Received: by lists.libvirt.org (Postfix, from userid 993) id 1744B43F4A; Wed, 19 Nov 2025 04:44:17 -0500 (EST) Received: from [172.19.199.50] (lists.libvirt.org [8.43.85.245]) by lists.libvirt.org (Postfix) with ESMTP id 3E257441B7; Wed, 19 Nov 2025 04:38:32 -0500 (EST) Received: by lists.libvirt.org (Postfix, from userid 993) id 4EA8E43EBF; Wed, 19 Nov 2025 04:38:02 -0500 (EST) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (3072 bits) server-digest SHA256) (No client certificate requested) by lists.libvirt.org (Postfix) with ESMTPS id 8CA3E43EBA for ; Wed, 19 Nov 2025 04:38:01 -0500 (EST) Received: from mx-prod-mc-08.mail-002.prod.us-west-2.aws.redhat.com (ec2-35-165-154-97.us-west-2.compute.amazonaws.com [35.165.154.97]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-287-wRv_QHf9NmWRZ_cgoBkiQA-1; Wed, 19 Nov 2025 04:37:59 -0500 Received: from mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.93]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 25F8618002DD for ; Wed, 19 Nov 2025 09:37:59 +0000 (UTC) Received: from speedmetal.openshiftapps.com (unknown [10.45.242.12]) by mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 5C78D180049F for ; Wed, 19 Nov 2025 09:37:58 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-26) on lists.libvirt.org X-Spam-Level: X-Spam-Status: No, score=-5.0 required=5.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED,RCVD_IN_VALIDITY_RPBL_BLOCKED, RCVD_IN_VALIDITY_SAFE_BLOCKED,SPF_PASS autolearn=unavailable autolearn_force=no version=4.0.1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1763545081; h=from:from: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; bh=yhIeBqL/s8hL4zAkex1Ya2BGL4tTSp8zWS8dj7VjLQ0=; b=iSTExBy0XV3AS2ea2PQE2v4u9LTl5+5QegfoV5gWRwxbYYZEuqhRGagFrnfu6hJgBeE2GQ /hfZeN2xYeANABADD9gsP1Th1RunYM+1q5IVTl+pfcB9WswS/YtkHZsQ1CtlCL4iNzld89 DSc6ZQInj/duYKNzrYAbsfVay2nSuFU= X-MC-Unique: wRv_QHf9NmWRZ_cgoBkiQA-1 X-Mimecast-MFC-AGG-ID: wRv_QHf9NmWRZ_cgoBkiQA_1763545079 To: devel@lists.libvirt.org Subject: [PATCH 4/8] qemuBlockJobProcessEventConcludedBackup: Notify the backup job later Date: Wed, 19 Nov 2025 10:37:47 +0100 Message-ID: <21754138047146971ff00fda8a62b6896c0db736.1763544909.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.93 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: VddzDwNGuL2yd8Oet0I6esR7BrdwwkZGgS97cdWDHY0_1763545079 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Message-ID-Hash: 7ZKZOFGGMO2HQHKRM5AJQFM642NVDHGQ X-Message-ID-Hash: 7ZKZOFGGMO2HQHKRM5AJQFM642NVDHGQ X-MailFrom: pkrempa@redhat.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; header-match-devel.lists.libvirt.org-0; emergency; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.10 Precedence: list List-Id: Development discussions about the libvirt library & tools Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: From: Peter Krempa via Devel Reply-To: Peter Krempa X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1763545462581153000 Content-Type: text/plain; charset="utf-8" From: Peter Krempa Move the notification to the backup job after finishing the cleanup of the current block job the backup operation consists of. Currently the termination of the blockjob would e.g. delete the scratch files before they are detached from qemu. In later patches the termination of the backup job may cause the qemu process to be killed (if the guest OS shut down but the qemu process was being kept alive to finish the backup) which would cause errors in the monitor commands for dismissing the block job. Since the NBD server still needs to be terminated first as otherwise the scratch files can't be unplugged from qemu we need to split the operation into two. First the NBD server is terminated, then the current block job is finalized and then the backup job is notified. Signed-off-by: Peter Krempa --- src/qemu/qemu_backup.c | 41 +++++++++++++++++++++++++++------------- src/qemu/qemu_backup.h | 4 ++++ src/qemu/qemu_blockjob.c | 7 +++++-- 3 files changed, 37 insertions(+), 15 deletions(-) diff --git a/src/qemu/qemu_backup.c b/src/qemu/qemu_backup.c index 9832c186a8..5eed35b471 100644 --- a/src/qemu/qemu_backup.c +++ b/src/qemu/qemu_backup.c @@ -981,6 +981,33 @@ qemuBackupGetXMLDesc(virDomainObj *vm, } +void +qemuBackupNotifyBlockjobEndStopNBD(virDomainObj *vm, + int asyncJob) +{ + qemuDomainObjPrivate *priv =3D vm->privateData; + virDomainBackupDef *backup =3D priv->backup; + + VIR_DEBUG("vm: '%s'", vm->def->name); + + if (!backup || + backup->type !=3D VIR_DOMAIN_BACKUP_TYPE_PULL || + backup->nbdStopped) + return; + + if (qemuDomainObjEnterMonitorAsync(vm, asyncJob) < 0) + return; + ignore_value(qemuMonitorNBDServerStop(priv->mon)); + if (backup->tlsAlias) + ignore_value(qemuMonitorDelObject(priv->mon, backup->tlsAlias, fal= se)); + if (backup->tlsSecretAlias) + ignore_value(qemuMonitorDelObject(priv->mon, backup->tlsSecretAlia= s, false)); + qemuDomainObjExitMonitor(vm); + + backup->nbdStopped =3D true; +} + + void qemuBackupNotifyBlockjobEnd(virDomainObj *vm, const char *diskdst, @@ -1005,20 +1032,8 @@ qemuBackupNotifyBlockjobEnd(virDomainObj *vm, if (!backup) return; + /* update the final statistics with the current job's data */ if (backup->type =3D=3D VIR_DOMAIN_BACKUP_TYPE_PULL) { - if (!backup->nbdStopped) { - if (qemuDomainObjEnterMonitorAsync(vm, asyncJob) < 0) - return; - ignore_value(qemuMonitorNBDServerStop(priv->mon)); - if (backup->tlsAlias) - ignore_value(qemuMonitorDelObject(priv->mon, backup->tlsAl= ias, false)); - if (backup->tlsSecretAlias) - ignore_value(qemuMonitorDelObject(priv->mon, backup->tlsSe= cretAlias, false)); - qemuDomainObjExitMonitor(vm); - backup->nbdStopped =3D true; - } - - /* update the final statistics with the current job's data */ backup->pull_tmp_used +=3D cur; backup->pull_tmp_total +=3D end; } else { diff --git a/src/qemu/qemu_backup.h b/src/qemu/qemu_backup.h index 768da6cbef..c259883bca 100644 --- a/src/qemu/qemu_backup.h +++ b/src/qemu/qemu_backup.h @@ -34,6 +34,10 @@ qemuBackupJobCancelBlockjobs(virDomainObj *vm, bool terminatebackup, int asyncJob); +void +qemuBackupNotifyBlockjobEndStopNBD(virDomainObj *vm, + int asyncJob); + void qemuBackupNotifyBlockjobEnd(virDomainObj *vm, const char *diskdst, diff --git a/src/qemu/qemu_blockjob.c b/src/qemu/qemu_blockjob.c index 315b742053..b54a5b3811 100644 --- a/src/qemu/qemu_blockjob.c +++ b/src/qemu/qemu_blockjob.c @@ -1392,8 +1392,7 @@ qemuBlockJobProcessEventConcludedBackup(virQEMUDriver= *driver, if (job->disk) diskdst =3D job->disk->dst; - qemuBackupNotifyBlockjobEnd(vm, diskdst, newstate, job->errmsg, - progressCurrent, progressTotal, asyncJob); + qemuBackupNotifyBlockjobEndStopNBD(vm, asyncJob); if (job->data.backup.store && !(backend =3D qemuBlockStorageSourceDetachPrepare(job->data.backup= .store))) @@ -1415,6 +1414,10 @@ qemuBlockJobProcessEventConcludedBackup(virQEMUDrive= r *driver, if (job->data.backup.store) qemuDomainStorageSourceAccessRevoke(driver, vm, job->data.backup.s= tore); + + qemuBackupNotifyBlockjobEnd(vm, diskdst, newstate, job->errmsg, + progressCurrent, progressTotal, asyncJob); + } --=20 2.51.1