From nobody Fri Nov 21 09:59:51 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=1763545142; cv=none; d=zohomail.com; s=zohoarc; b=UJMUbgqxUxTy4iDqtqaVhxMW61Tf14pjuQOBYPTC35H9Jlp1sczj3Uq8C3l/V2xrx5h5VovnJ3jyxAtcMMmGaz9NEHzFDAVgNcc5JDe44bnyaHp7lcCY1jIuGBJhRUkxM+zbUQReTAn14bLmLDqGFm26MDjX5r6sW/K4VwfMChA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1763545142; 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=/qh4dqZSdCqUgzYE9UrMqTu7/8rTUslXEBk/fMq2W0s=; b=eagS3AVrDmBDG0GW48nYm5ijXNE6NxIzRH9LzMR4/tLWDyH6BbZthdPTiEjx0pbGQHlVq66BuDt3LKbjtB9BoRHA7+DGxJ9UxOpjBT1SAr3vhxK3icgG8Hjjl9vn323UANeS+ur1r7P13qTsXHaUMPR9LkZPwW6FqKYIgrjHDwg= 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 1763545142479981.5574613941956; Wed, 19 Nov 2025 01:39:02 -0800 (PST) Received: by lists.libvirt.org (Postfix, from userid 993) id 3B2B744136; Wed, 19 Nov 2025 04:39:00 -0500 (EST) Received: from [172.19.199.50] (lists.libvirt.org [8.43.85.245]) by lists.libvirt.org (Postfix) with ESMTP id 5D98943FEB; Wed, 19 Nov 2025 04:38:08 -0500 (EST) Received: by lists.libvirt.org (Postfix, from userid 993) id 4F68B43EC1; Wed, 19 Nov 2025 04:37:59 -0500 (EST) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.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 200A143EBD for ; Wed, 19 Nov 2025 04:37:58 -0500 (EST) Received: from mx-prod-mc-01.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-164-ddkolBdgPhm21LIQk7WwmQ-1; Wed, 19 Nov 2025 04:37:56 -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-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 382F6195605A for ; Wed, 19 Nov 2025 09:37:55 +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 55379180049F for ; Wed, 19 Nov 2025 09:37:54 +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=1763545077; 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=/qh4dqZSdCqUgzYE9UrMqTu7/8rTUslXEBk/fMq2W0s=; b=JIjq2wOZhmFU2MztiuA3WO5XrmWMUqfadcmqYQfGq5CEnl9TMnzxm6rYrAK+zD39TG2Tx9 pEGjh+dol5SzLBHgFE9pEe3EVc5j3x3sk1DXqgAiNRbCcErsOPIT1xHCcgYq5r0WjCtlxk qUDQMDuN+LLrv4317DodoMRSYfi4NyY= X-MC-Unique: ddkolBdgPhm21LIQk7WwmQ-1 X-Mimecast-MFC-AGG-ID: ddkolBdgPhm21LIQk7WwmQ_1763545075 To: devel@lists.libvirt.org Subject: [PATCH 1/8] virDomainNestedJobAllowed: Allow VIR_JOB_MODIFY_MIGRATION_SAFE if VIR_JOB_MODIFY is allowed Date: Wed, 19 Nov 2025 10:37:44 +0100 Message-ID: <1ebbfa8aeb6dd9483c8e6a873ded9371b2381a0e.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: XtIw0WWriw9RNkbFLEASp653gmYSATg2wQ37xOyqp3E_1763545075 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Message-ID-Hash: 3FM5DNRJER2S6XFMGC2HUYHYQSMHER7J X-Message-ID-Hash: 3FM5DNRJER2S6XFMGC2HUYHYQSMHER7J 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: 1763545147761153000 Content-Type: text/plain; charset="utf-8" From: Peter Krempa The VIR_JOB_MODIFY_MIGRATION_SAFE is supposed to be a subset of _MODIFY jobs which are allowed during migration. Now with async jobs which allow VIR_JOB_MODIFY (namely the backup job) it shouldn't be required to explicitly mention VIR_JOB_MODIFY_MIGRATION_SAFE since we already allow everything. Adjust the logic in virDomainNestedJobAllowed to accept VIR_JOB_MODIFY_MIGRATION_SAFE if VIR_JOB_MODIFY is allowed so that other places can simply allow the latter. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/conf/virdomainjob.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/conf/virdomainjob.c b/src/conf/virdomainjob.c index 99c362d593..c2e7d33097 100644 --- a/src/conf/virdomainjob.c +++ b/src/conf/virdomainjob.c @@ -257,6 +257,7 @@ virDomainNestedJobAllowed(virDomainJobObj *jobs, virDom= ainJob newJob) { return !jobs->asyncJob || newJob =3D=3D VIR_JOB_NONE || + (newJob =3D=3D VIR_JOB_MODIFY_MIGRATION_SAFE && jobs->mask & JO= B_MASK(VIR_JOB_MODIFY)) || (jobs->mask & JOB_MASK(newJob)); } --=20 2.51.1 From nobody Fri Nov 21 09:59:51 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=1763545264; cv=none; d=zohomail.com; s=zohoarc; b=FOFpfcl8RB/KOvslLwS4+xbgdvi+CS8LhQk/swKlNQJ0ItSnf+EQAk8UXmGZiuH8DzvCr2DYAxxbJiMIXWIS4lPgddWpSvKtDV+iAc/oFp5q38VDFbWNEjQDy2QA/HZEVL3IXgJGLjLw/t37TtRqAIENygxnQldRAwflnjcpI8w= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1763545264; 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=59RYCYyy62xUrjZ5BfUJcDRzmt3v3/oHoCoWKj5chVA=; b=fu3cQboHQcq+J3m9wrP4yCDPiXPlT0apy0K40hFSFOTtRaZOxFGfU9jQFsktPX7WxLFtqxEFOqB938a10AwgvDfdgIjXsPlDHalpM38S/Ln2OeFO3OA438bC4oE3Hj1NpWdRJO9CI/zpYXPlWJYZuFLqxX0Khi2CD1/1vwTqrVE= 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 17635452647451008.2994483181474; Wed, 19 Nov 2025 01:41:04 -0800 (PST) Received: by lists.libvirt.org (Postfix, from userid 993) id 087764408F; Wed, 19 Nov 2025 04:41:02 -0500 (EST) Received: from [172.19.199.50] (lists.libvirt.org [8.43.85.245]) by lists.libvirt.org (Postfix) with ESMTP id 5FC7D43F93; Wed, 19 Nov 2025 04:38:18 -0500 (EST) Received: by lists.libvirt.org (Postfix, from userid 993) id 6E99D41BC7; Wed, 19 Nov 2025 04:38:00 -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 542AF43EBD for ; Wed, 19 Nov 2025 04:37:59 -0500 (EST) Received: from mx-prod-mc-06.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-133-8H9F6fR9MyOOF7hZy_XmRQ-1; Wed, 19 Nov 2025 04:37:57 -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-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 8BA781801301 for ; Wed, 19 Nov 2025 09:37:56 +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 C319B180049F for ; Wed, 19 Nov 2025 09:37:55 +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=1763545079; 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=59RYCYyy62xUrjZ5BfUJcDRzmt3v3/oHoCoWKj5chVA=; b=h6RQLbZvOQfHd4LHEKNF4y7pFsrsZMd/9TAs9e77Td7MVan3HHBxlgeAfzwm+l77u3CGDU 8PPJnIKNkWnJlGMYH7MYNyGbqHJ9sLIPtWdUGtrofE89clFXqDMSiRE4X/4jhAASbWWp6f 26++MukYPQLSaJ4daNtw6M0g4x8jpwY= X-MC-Unique: 8H9F6fR9MyOOF7hZy_XmRQ-1 X-Mimecast-MFC-AGG-ID: 8H9F6fR9MyOOF7hZy_XmRQ_1763545076 To: devel@lists.libvirt.org Subject: [PATCH 2/8] qemuProcessReconnect: Continue reconnection if VM untergoes fake-reboot Date: Wed, 19 Nov 2025 10:37:45 +0100 Message-ID: <8985da4e76587874e0007e4d92cc69aa845d5da8.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: Qfg2hRxXWU7Nvy1DvY131II7ltAuUyT-K6sv_YKCIRM_1763545076 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Message-ID-Hash: BRTOPSETCRVK65RLTTYSILAGHIXCK2KP X-Message-ID-Hash: BRTOPSETCRVK65RLTTYSILAGHIXCK2KP 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: 1763545265917158500 Content-Type: text/plain; charset="utf-8" From: Peter Krempa 'qemuProcessShutdownOrReboot' may or may not kill the VM. In 'qemuProcessReconnect' if we decided that the VM was in a state requiring 'qemuProcessShutdownOrReboot' to be called we'd stop the reconnection unconditionally. Now if the VM ought to undergo a fake reboot we really need to reconnect to the process because the process will be kept around for much longer. Make qemuProcessShutdownOrReboot return whether it killed the VM and continue the reconnection if it didn't. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/qemu/qemu_driver.c | 2 +- src/qemu/qemu_process.c | 25 +++++++++++++++++++++---- src/qemu/qemu_process.h | 3 ++- 3 files changed, 24 insertions(+), 6 deletions(-) diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index 1f7e587f61..d99528724e 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -3557,7 +3557,7 @@ processGuestPanicEvent(virQEMUDriver *driver, case VIR_DOMAIN_LIFECYCLE_ACTION_RESTART: qemuDomainSetFakeReboot(vm, true); - qemuProcessShutdownOrReboot(vm); + ignore_value(qemuProcessShutdownOrReboot(vm)); break; case VIR_DOMAIN_LIFECYCLE_ACTION_PRESERVE: diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c index 45fc32a663..bbd9859ef4 100644 --- a/src/qemu/qemu_process.c +++ b/src/qemu/qemu_process.c @@ -597,7 +597,16 @@ qemuProcessFakeReboot(void *opaque) } -void +/** + * qemuProcessShutdownOrReboot: + * @vm: domain object + * + * Perform the appropriate action when the guest OS shuts down. This can be + * either fake reboot (the VM is reset started again) or the VM is termina= ted. + * + * The function returns true if the VM was terminated. + */ +bool qemuProcessShutdownOrReboot(virDomainObj *vm) { qemuDomainObjPrivate *priv =3D vm->privateData; @@ -620,9 +629,14 @@ qemuProcessShutdownOrReboot(virDomainObj *vm) qemuDomainSetFakeReboot(vm, false); virObjectUnref(vm); } + + return false; } else { ignore_value(qemuProcessKill(vm, VIR_QEMU_PROCESS_KILL_NOWAIT)); + return true; } + + return false; } @@ -714,7 +728,7 @@ qemuProcessHandleShutdown(qemuMonitor *mon G_GNUC_UNUSE= D, if (priv->agent) qemuAgentNotifyEvent(priv->agent, QEMU_AGENT_EVENT_SHUTDOWN); - qemuProcessShutdownOrReboot(vm); + ignore_value(qemuProcessShutdownOrReboot(vm)); unlock: virObjectUnlock(vm); @@ -9705,8 +9719,11 @@ qemuProcessReconnect(void *opaque) reason =3D=3D VIR_DOMAIN_PAUSED_USER)) { VIR_DEBUG("Finishing shutdown sequence for domain %s", obj->def->name); - qemuProcessShutdownOrReboot(obj); - goto cleanup; + /* qemuProcessShutdownOrReboot returns 'true' if the VM was termin= ated. + * If the VM is kept (e.g. for fake reboot) we need to continue the + * reconnection */ + if (qemuProcessShutdownOrReboot(obj)) + goto cleanup; } /* if domain requests security driver we haven't loaded, report error,= but diff --git a/src/qemu/qemu_process.h b/src/qemu/qemu_process.h index 9f783790ac..426e11d79e 100644 --- a/src/qemu/qemu_process.h +++ b/src/qemu/qemu_process.h @@ -192,7 +192,8 @@ int qemuProcessKill(virDomainObj *vm, unsigned int flag= s); int qemuProcessFakeRebootViaRecreate(virDomainObj *vm, bool locked); -void qemuProcessShutdownOrReboot(virDomainObj *vm); +bool qemuProcessShutdownOrReboot(virDomainObj *vm) + G_GNUC_WARN_UNUSED_RESULT; void qemuProcessAutoDestroy(virDomainObj *dom, virConnectPtr conn); --=20 2.51.1 From nobody Fri Nov 21 09:59:51 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=1763545344; cv=none; d=zohomail.com; s=zohoarc; b=NbhIcoFXPUN0bvywCWNuOjexUGZZcFr8E1NJ5D1TPbTyrsWmM/HwPGIrjamGB3asI+LzYh464ds5/PfsShsZ+xecABSn58yGoj69CFqnhw8XICCcYVQ1jAt9FR1rDcNDmgsGH+wZ/+qxbrLJWBeVVxJSKIY5xrUgn76e3ocDTwk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1763545344; 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=0d1Kb701Z5NFWQsuBAKXI2rMwKMfLXo8EJ6CfuV261Q=; b=YPkG8ShV/ol2HM1+R+z2DZ5Fvry4YsXH4s6ygk1Su6mcBZxhXu6j5B1/lXv9ucUNvWLMlsBpnSdY0w+rrWB30SYy1T7Rq7w2L1jQzK7+IcyZqoaSgatdJ4bl3UHGj835pehWoaq8yQt0vh4RMzvTUbUkvbmOs0P2LTkFk5IYOTw= 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 1763545344000872.3411038151477; Wed, 19 Nov 2025 01:42:24 -0800 (PST) Received: by lists.libvirt.org (Postfix, from userid 993) id 5090743FFE; Wed, 19 Nov 2025 04:42:23 -0500 (EST) Received: from [172.19.199.50] (lists.libvirt.org [8.43.85.245]) by lists.libvirt.org (Postfix) with ESMTP id 814D844128; Wed, 19 Nov 2025 04:38:26 -0500 (EST) Received: by lists.libvirt.org (Postfix, from userid 993) id 4432443EBA; Wed, 19 Nov 2025 04:38:01 -0500 (EST) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.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 7666F43EBD for ; Wed, 19 Nov 2025 04:38:00 -0500 (EST) Received: from mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-654-xmZrp-FxNPK_K9wplAgp6Q-1; Wed, 19 Nov 2025 04:37:58 -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-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id CECC419560B2 for ; Wed, 19 Nov 2025 09:37:57 +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 11816180049F for ; Wed, 19 Nov 2025 09:37:56 +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=1763545080; 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=0d1Kb701Z5NFWQsuBAKXI2rMwKMfLXo8EJ6CfuV261Q=; b=avzgkmcLWX+tXnYkPFjazxmAZed6bn4OmQ5Q/O1lBgA/zAQqVBZMyftWt3gsp0yrM07yAz nmGuiO/LtIwUwQw4WXWSHvT2qpWlSPOtHp+I8HzJJeNcDdYW405gRZ0Ug4VSGazjJ7Vgzb +t2cReRsnT3LGINdWZGV2vhmbMWRmeY= X-MC-Unique: xmZrp-FxNPK_K9wplAgp6Q-1 X-Mimecast-MFC-AGG-ID: xmZrp-FxNPK_K9wplAgp6Q_1763545077 To: devel@lists.libvirt.org Subject: [PATCH 3/8] qemu: backup: Don't attempt to stop the NBD server twice Date: Wed, 19 Nov 2025 10:37:46 +0100 Message-ID: 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: CWkiuLeTn_cX3YPR7_hEY3wMD4GTv_QkCs_9u57l170_1763545077 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Message-ID-Hash: 4MH7JN5MCZLDID5YRXH2UPIOCJR4IZ35 X-Message-ID-Hash: 4MH7JN5MCZLDID5YRXH2UPIOCJR4IZ35 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: 1763545347317153000 Content-Type: text/plain; charset="utf-8" From: Peter Krempa When notifying the backup code about termination of the block job which is part of a backup operation the code attempts to terminate the NBD server. This is done for every blockjob so could cause us to attempt to terminate the NBD server multiple times which doesn't cause problems but generates spurious errors. Add a flag that the NBD server was stopped and do it just once. Don't bother storing the flag in the status XML as it's just for the shutdown phase. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/conf/backup_conf.h | 4 ++++ src/qemu/qemu_backup.c | 19 +++++++++++-------- 2 files changed, 15 insertions(+), 8 deletions(-) diff --git a/src/conf/backup_conf.h b/src/conf/backup_conf.h index 9c3532a546..f90a4dcaee 100644 --- a/src/conf/backup_conf.h +++ b/src/conf/backup_conf.h @@ -99,6 +99,10 @@ struct _virDomainBackupDef { char *errmsg; /* error message of failed sub-blockjob */ unsigned int apiFlags; /* original flags used when starting the job */ + + bool nbdStopped; /* The NBD server for a pull-mode backup was stopped.= This + flag is deliberately not stored in the status XML = as + it's related only to termination of the backup. */ }; typedef enum { diff --git a/src/qemu/qemu_backup.c b/src/qemu/qemu_backup.c index 3b4fe54854..9832c186a8 100644 --- a/src/qemu/qemu_backup.c +++ b/src/qemu/qemu_backup.c @@ -1006,14 +1006,17 @@ qemuBackupNotifyBlockjobEnd(virDomainObj *vm, return; if (backup->type =3D=3D VIR_DOMAIN_BACKUP_TYPE_PULL) { - if (qemuDomainObjEnterMonitorAsync(vm, asyncJob) < 0) - return; - ignore_value(qemuMonitorNBDServerStop(priv->mon)); - if (backup->tlsAlias) - ignore_value(qemuMonitorDelObject(priv->mon, backup->tlsAlias,= false)); - if (backup->tlsSecretAlias) - ignore_value(qemuMonitorDelObject(priv->mon, backup->tlsSecret= Alias, false)); - qemuDomainObjExitMonitor(vm); + 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; --=20 2.51.1 From nobody Fri Nov 21 09:59:51 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 Reviewed-by: J=C3=A1n Tomko --- 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 From nobody Fri Nov 21 09:59:51 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=1763545548; cv=none; d=zohomail.com; s=zohoarc; b=lqpuwgn5A199w6cSlEh8zBNcHVgAcW++YhPZt0216Egi7fZZmsiCftp54kuijKbPGmIls0pq5+TNKhsygVjzOq6D2/OH2RDNBXgmJZYlHYGfIQ3oWvq4QzDeIpP7xMMhV8CIBMuCYpOup0R4BQqNYRpfaK6m3lPdSneiKg1qND0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1763545548; 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=ApDkDClmcCSY6cCHk0pre9kFFqU2CrNpdNjq+9zj+Rg=; b=KNf39Tt3XQkO0Uc245p8OTX0aG4TSBXjqzELLRAijEqp9wFW4e4JdY59H4yRi6sobpD4mdSEtayuf5XK7Op911MA1vm99TZc/AxiL3xsDPGUImmYTrOJNoJsQNFetEVnFpfgDxi376FIY1m+usamKuZbDJGuDQ3iTXOKeBhCWzM= 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 1763545548099385.49608579501864; Wed, 19 Nov 2025 01:45:48 -0800 (PST) Received: by lists.libvirt.org (Postfix, from userid 993) id 6171243FF7; Wed, 19 Nov 2025 04:45:44 -0500 (EST) Received: from [172.19.199.50] (lists.libvirt.org [8.43.85.245]) by lists.libvirt.org (Postfix) with ESMTP id 8E46F441FD; Wed, 19 Nov 2025 04:38:36 -0500 (EST) Received: by lists.libvirt.org (Postfix, from userid 993) id 3D8F144067; Wed, 19 Nov 2025 04:38:14 -0500 (EST) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.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 D086B43F45 for ; Wed, 19 Nov 2025 04:38:03 -0500 (EST) Received: from mx-prod-mc-06.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-390-t2AHAJNOP5KBf20_9rYM0g-1; Wed, 19 Nov 2025 04:38:01 -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-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 8EE871800561 for ; Wed, 19 Nov 2025 09:38:00 +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 B461C18004A3 for ; Wed, 19 Nov 2025 09:37:59 +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=1763545083; 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=ApDkDClmcCSY6cCHk0pre9kFFqU2CrNpdNjq+9zj+Rg=; b=VDAqrD5nBvS4SXLJh7OSEFq0XeMQebG36VOWDpbs0fXaiyKtwEEtNkkE7Eyxq6lh2d/+Ca f4ejsQPvPqnRP/M/0W7Tuo/v2SRKadHHiL79pPJbwCaI5JSTl3/nCXiWChxaAwStb8+76S b3Z0XX02grbgb73qUfFW/vfKGnjpQT4= X-MC-Unique: t2AHAJNOP5KBf20_9rYM0g-1 X-Mimecast-MFC-AGG-ID: t2AHAJNOP5KBf20_9rYM0g_1763545080 To: devel@lists.libvirt.org Subject: [PATCH 5/8] lib: Introduce VIR_DOMAIN_EVENT_SUSPENDED_GUEST_SHUTDOWN event reason Date: Wed, 19 Nov 2025 10:37:48 +0100 Message-ID: <084fa1de95aba92a6c4cdfc6fea98edc9da629df.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: JRL6k9kRqXfRUIjagSfULGrgRWChucIfUN6rwnZvikM_1763545080 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Message-ID-Hash: QUEZ2FW5TM7EWK4ZX3EES76Q247QJEUP X-Message-ID-Hash: QUEZ2FW5TM7EWK4ZX3EES76Q247QJEUP 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: 1763545549621153000 Content-Type: text/plain; charset="utf-8" From: Peter Krempa Upcoming patches will introduce the possibility for the domain to be kept paused after the guest OS shuts itself down. It'll allow jobs such as backup to finish as e.g. in the qemu driver it requires the qemu process. Add an the appropriate reason for the VIR_DOMAIN_EVENT_SUSPENDED lifecycle event. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- examples/c/misc/event-test.c | 3 +++ include/libvirt/libvirt-domain.h | 1 + tools/virsh-domain-event.c | 3 ++- 3 files changed, 6 insertions(+), 1 deletion(-) diff --git a/examples/c/misc/event-test.c b/examples/c/misc/event-test.c index 347ec44682..2ce82ca9e0 100644 --- a/examples/c/misc/event-test.c +++ b/examples/c/misc/event-test.c @@ -180,6 +180,9 @@ eventDetailToString(int event, case VIR_DOMAIN_EVENT_SUSPENDED_POSTCOPY_FAILED: return "Post-copy Error"; + case VIR_DOMAIN_EVENT_SUSPENDED_GUEST_SHUTDOWN: + return "guest OS shutdown"; + case VIR_DOMAIN_EVENT_SUSPENDED_LAST: break; } diff --git a/include/libvirt/libvirt-domain.h b/include/libvirt/libvirt-dom= ain.h index 56bd085ef5..a2cf762e1a 100644 --- a/include/libvirt/libvirt-domain.h +++ b/include/libvirt/libvirt-domain.h @@ -5401,6 +5401,7 @@ typedef enum { VIR_DOMAIN_EVENT_SUSPENDED_API_ERROR =3D 6, /* Some APIs (e.g., migrat= ion, snapshot) internally need to suspend a domain. This event detail is us= ed when resume operation at the end of such API fails. (Since: 1.0.1) */ VIR_DOMAIN_EVENT_SUSPENDED_POSTCOPY =3D 7, /* suspended for post-copy = migration (Since: 1.3.3) */ VIR_DOMAIN_EVENT_SUSPENDED_POSTCOPY_FAILED =3D 8, /* suspended after f= ailed post-copy (Since: 1.3.3) */ + VIR_DOMAIN_EVENT_SUSPENDED_GUEST_SHUTDOWN =3D 9, /* suspended after gu= est os shut-down (a long running job is preserving the VM until completion)= (Since: 11.10.0) */ # ifdef VIR_ENUM_SENTINELS VIR_DOMAIN_EVENT_SUSPENDED_LAST /* (Since: 0.9.10) */ diff --git a/tools/virsh-domain-event.c b/tools/virsh-domain-event.c index a47fdfc7fd..b9d1cdf019 100644 --- a/tools/virsh-domain-event.c +++ b/tools/virsh-domain-event.c @@ -85,7 +85,8 @@ VIR_ENUM_IMPL(virshDomainEventSuspended, N_("Snapshot"), N_("API error"), N_("Post-copy"), - N_("Post-copy Error")); + N_("Post-copy Error"), + N_("guest shutdown")); VIR_ENUM_DECL(virshDomainEventResumed); VIR_ENUM_IMPL(virshDomainEventResumed, --=20 2.51.1 From nobody Fri Nov 21 09:59:51 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=1763545646; cv=none; d=zohomail.com; s=zohoarc; b=glge8ktEFEc5ttY4bEg0GdZpU7HzrbtsErmzkcEbMCgL9HXszaBt8sVoTq+y4lo63uwLRp8GsqkWaVnlcRI2+qAUhMhKkP87s8KOtojVb3i2Dr0oZivgrQRIlSnK3VTBgprhZVxaSVLnuw+9dtX60o8Xrl6iDt7mKhdrrrI4+ng= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1763545646; 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=ngw5uqpHvBvOyCABI43yY73G3GzGin01XU1l/m1GGHA=; b=QnC+flicA5rHVzsk2kRybsFTnIo1fVtkCg/G71CD/UMOd4T/szuqLdAwFxUVd8j9TPh8pU7miGmhD24g9jC3ZK3D+pE8hfPdlf8axW7ZbKQzFB9/P5wCAk7IDCcsX58VeGaSmW2I8iYO3A73HbBkyskEzeUFOBeQmLOeq2SI98A= 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 176354564696963.342818098903194; Wed, 19 Nov 2025 01:47:26 -0800 (PST) Received: by lists.libvirt.org (Postfix, from userid 993) id 589B0418A1; Wed, 19 Nov 2025 04:47:24 -0500 (EST) Received: from [172.19.199.50] (lists.libvirt.org [8.43.85.245]) by lists.libvirt.org (Postfix) with ESMTP id 9D53444121; Wed, 19 Nov 2025 04:38:41 -0500 (EST) Received: by lists.libvirt.org (Postfix, from userid 993) id E90F043F5E; Wed, 19 Nov 2025 04:38:15 -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 90D4B43F66 for ; Wed, 19 Nov 2025 04:38:04 -0500 (EST) Received: from mx-prod-mc-01.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-363-JV438wdWPZiaGvzX_NgG_Q-1; Wed, 19 Nov 2025 04:38:02 -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-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id D1E6F1956050 for ; Wed, 19 Nov 2025 09:38:01 +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 1458718004A3 for ; Wed, 19 Nov 2025 09:38:00 +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=1763545084; 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=ngw5uqpHvBvOyCABI43yY73G3GzGin01XU1l/m1GGHA=; b=hlEjcxvD1b7har0ikw/7h7fumMKltzG4w0rlWKTFbobjvjNLcVj1w+gH3JhP3Lm2RBcw1N mmQJiuspqkg6drcQfT/RF6JlpNDharxAEJIgMIHK4n4TEtTVU67XSo/A+b91KkL+91SKDP TVhMPndxUNdk5L80GmU8F9McGt4LtCQ= X-MC-Unique: JV438wdWPZiaGvzX_NgG_Q-1 X-Mimecast-MFC-AGG-ID: JV438wdWPZiaGvzX_NgG_Q_1763545081 To: devel@lists.libvirt.org Subject: [PATCH 6/8] lib: Introduce VIR_DOMAIN_BACKUP_BEGIN_PRESERVE_SHUTDOWN_DOMAIN flag Date: Wed, 19 Nov 2025 10:37:49 +0100 Message-ID: <9b296a23112f45bddc8bb1e4fdda753572c8561a.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: f_5tI1A3Se4yicJ4GjrG-s5KLZP6uwJxuWkywh86FPs_1763545081 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Message-ID-Hash: PU7OZNJ65PDRKBGOOSIK5MZ23NLIUCOA X-Message-ID-Hash: PU7OZNJ65PDRKBGOOSIK5MZ23NLIUCOA 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: 1763545648991153000 Content-Type: text/plain; charset="utf-8" From: Peter Krempa This flag will instruct the hypervisor driver to keep the VM around while the backup is running if the guest OS decides to shut down, so that the backup can be finished. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- docs/manpages/virsh.rst | 6 ++++++ include/libvirt/libvirt-domain.h | 6 ++++-- src/libvirt-domain.c | 5 +++++ tools/virsh-backup.c | 7 +++++++ 4 files changed, 22 insertions(+), 2 deletions(-) diff --git a/docs/manpages/virsh.rst b/docs/manpages/virsh.rst index 73263ffc7f..a9d691824e 100644 --- a/docs/manpages/virsh.rst +++ b/docs/manpages/virsh.rst @@ -2186,6 +2186,7 @@ backup-begin :: backup-begin domain [backupxml] [checkpointxml] [--reuse-external] + [--preserve-domain-on-shutdown] Begin a new backup job. If *backupxml* is omitted, this defaults to a full backup using a push model to filenames generated by libvirt; supplying XML @@ -2199,6 +2200,11 @@ libvirt. For more information on backup XML, see: If *--reuse-external* is used it instructs libvirt to reuse temporary and output files provided by the user in *backupxml*. +When the *--preserve-domain-on-shutdown* flag is used libvirt will not +terminate the VM if the guest OS shuts down while the backup is running. T= he VM +will be instead kept in VIR_DOMAIN_PAUSED state until the backup job finis= hes. +The vm can be also resumed in order to boot again. + If *checkpointxml* is specified, a second file with a top-level element of *domaincheckpoint* is used to create a simultaneous checkpoint, for doing a later incremental backup relative to the time diff --git a/include/libvirt/libvirt-domain.h b/include/libvirt/libvirt-dom= ain.h index a2cf762e1a..ad25ed14e1 100644 --- a/include/libvirt/libvirt-domain.h +++ b/include/libvirt/libvirt-domain.h @@ -8518,8 +8518,10 @@ int virDomainAgentSetResponseTimeout(virDomainPtr do= main, * Since: 6.0.0 */ typedef enum { - VIR_DOMAIN_BACKUP_BEGIN_REUSE_EXTERNAL =3D (1 << 0), /* reuse separate= ly - provided images = (Since: 6.0.0) */ + /* reuse separately provided images (Since: 6.0.0) */ + VIR_DOMAIN_BACKUP_BEGIN_REUSE_EXTERNAL =3D (1 << 0), + /* preserve the domain if the guest OS shuts down while the backup is = running (Since: 11.10.0) */ + VIR_DOMAIN_BACKUP_BEGIN_PRESERVE_SHUTDOWN_DOMAIN =3D (1 << 1), } virDomainBackupBeginFlags; int virDomainBackupBegin(virDomainPtr domain, diff --git a/src/libvirt-domain.c b/src/libvirt-domain.c index ca110bdf85..74c70a0a43 100644 --- a/src/libvirt-domain.c +++ b/src/libvirt-domain.c @@ -13682,6 +13682,11 @@ virDomainAgentSetResponseTimeout(virDomainPtr doma= in, * temporary files described by the @backupXML document were created by the * caller with correct format and size to hold the backup or temporary dat= a. * + * When the VIR_DOMAIN_BACKUP_BEGIN_PRESERVE_SHUTDOWN_DOMAIN flag is used + * libvirt will not terminate the VM if the guest OS shuts down while the + * backup is running. The VM will be kept in the VIR_DOMAIN_PAUSED state + * until the backup job finishes or until it's resumed via virDomainResume. + * * The creation of a new checkpoint allows for future incremental backups. * Note that some hypervisors may require a particular disk format, such as * qcow2, in order to take advantage of checkpoints, while allowing arbitr= ary diff --git a/tools/virsh-backup.c b/tools/virsh-backup.c index 39e62f9ba9..1d009a3f2c 100644 --- a/tools/virsh-backup.c +++ b/tools/virsh-backup.c @@ -48,6 +48,10 @@ static const vshCmdOptDef opts_backup_begin[] =3D { .type =3D VSH_OT_BOOL, .help =3D N_("reuse files provided by caller"), }, + {.name =3D "preserve-domain-on-shutdown", + .type =3D VSH_OT_BOOL, + .help =3D N_("avoid shutdown of the domain while the backup is runnin= g"), + }, {.name =3D NULL} }; @@ -65,6 +69,9 @@ cmdBackupBegin(vshControl *ctl, if (vshCommandOptBool(cmd, "reuse-external")) flags |=3D VIR_DOMAIN_BACKUP_BEGIN_REUSE_EXTERNAL; + if (vshCommandOptBool(cmd, "preserve-domain-on-shutdown")) + flags |=3D VIR_DOMAIN_BACKUP_BEGIN_PRESERVE_SHUTDOWN_DOMAIN; + if (!(dom =3D virshCommandOptDomain(ctl, cmd, NULL))) return false; --=20 2.51.1 From nobody Fri Nov 21 09:59:51 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=1763545719; cv=none; d=zohomail.com; s=zohoarc; b=kFnvrIX9BXKz+zlJFJErvFPkfXCYV1q/r7pwdb4KpBOxMx7aXuE/gy5eXTX+1hztw3EFD1YEBZkKzyK2q07W+WgTKQaKCeDny+Jv6/B975RMmOdgMlphrOERtILBOFIPEHyF0+oupwFGrD+gFxKW3YAI4POFyW0ipoGqwALBBfo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1763545719; 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=YEPj5QvWsPJf4n0pF8eO7u83Undt5GuqkHUFolUVuHo=; b=AWBW3NCA/l+ZrPe32MG9ZDnoDCTJEvothM3vwC7wBdh421Z/EIdBCakqtgPlr9Alc3HzSSAU+Ul27M9xJ8N7/8HgjsArhq2YAvNpAfISZ0po5YyuDFQybEumeaIpwITRZ2gE5ySSvpjKamjtwZbU91boLT4ChcdWI+BeaAB5fv0= 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 1763545719186604.2451243729193; Wed, 19 Nov 2025 01:48:39 -0800 (PST) Received: by lists.libvirt.org (Postfix, from userid 993) id 383E944047; Wed, 19 Nov 2025 04:48:38 -0500 (EST) Received: from [172.19.199.50] (lists.libvirt.org [8.43.85.245]) by lists.libvirt.org (Postfix) with ESMTP id 988C244330; Wed, 19 Nov 2025 04:38:47 -0500 (EST) Received: by lists.libvirt.org (Postfix, from userid 993) id AE7C343F15; Wed, 19 Nov 2025 04:38:26 -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 C15C143F8C for ; Wed, 19 Nov 2025 04:38:05 -0500 (EST) Received: from mx-prod-mc-03.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-449-cFeBGT26Mjilkio3XcECWg-1; Wed, 19 Nov 2025 04:38:03 -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-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 1B6F418AB300 for ; Wed, 19 Nov 2025 09:38:03 +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 53FCC180049F for ; Wed, 19 Nov 2025 09:38:02 +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=1763545085; 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=YEPj5QvWsPJf4n0pF8eO7u83Undt5GuqkHUFolUVuHo=; b=PZ/+atKlqzieuy4xdo1SZ8gdRzQjBOtT/jK2xo8KaYvcM3dHO23xxyG6osLyu/Y9jBZakZ KKwJwvzBDZJ2tsZjTiHRlTjXk/Y3Nsg7YXsahX3RVim/aQo2dN2kKLOhwbpj44jC/eYxo5 rOH2OUZnQ8mCCUfz9mOdzEWmQI2XtjA= X-MC-Unique: cFeBGT26Mjilkio3XcECWg-1 X-Mimecast-MFC-AGG-ID: cFeBGT26Mjilkio3XcECWg_1763545083 To: devel@lists.libvirt.org Subject: [PATCH 7/8] qemu: backup: Add support for VIR_DOMAIN_BACKUP_BEGIN_PRESERVE_SHUTDOWN_DOMAIN Date: Wed, 19 Nov 2025 10:37:50 +0100 Message-ID: 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: tXEcW9HSGgAiPrA0AqIdE3ZPCQtDqi-toSasSz-OpEU_1763545083 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Message-ID-Hash: 4LLB7ULMHDDBJVHADQ2XS56IZ7D44IB4 X-Message-ID-Hash: 4LLB7ULMHDDBJVHADQ2XS56IZ7D44IB4 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: 1763545720961158500 Content-Type: text/plain; charset="utf-8" From: Peter Krempa Implement the support for VIR_DOMAIN_BACKUP_BEGIN_PRESERVE_SHUTDOWN_DOMAIN which will keep the qemu process around while the backup is still running. The above is achieved by avoiding killing the qemu process in the shutdown qemu monitor event handlers. Instead 'system_reset' QMP command is issued and the domain object is transitioned into _PAUSED state in sync with what qemu does. Now once the backup job finishes (or is cancelled e.g. for pull mode backups) the backup job termination code re-asseses if the qemu process needs to be killed or the VM was re-started by un-pausing. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/qemu/qemu_backup.c | 23 ++++++++++++- src/qemu/qemu_process.c | 76 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 98 insertions(+), 1 deletion(-) diff --git a/src/qemu/qemu_backup.c b/src/qemu/qemu_backup.c index 5eed35b471..c3566bcd57 100644 --- a/src/qemu/qemu_backup.c +++ b/src/qemu/qemu_backup.c @@ -27,6 +27,7 @@ #include "qemu_checkpoint.h" #include "qemu_command.h" #include "qemu_security.h" +#include "qemu_process.h" #include "storage_source.h" #include "storage_source_conf.h" @@ -559,6 +560,8 @@ qemuBackupJobTerminate(virDomainObj *vm, { qemuDomainObjPrivate *priv =3D vm->privateData; g_autoptr(virQEMUDriverConfig) cfg =3D NULL; + /* some flags need to be probed after the private data is freed */ + unsigned int apiFlags =3D priv->backup->apiFlags; size_t i; for (i =3D 0; i < priv->backup->ndisks; i++) { @@ -623,6 +626,23 @@ qemuBackupJobTerminate(virDomainObj *vm, if (vm->job->asyncJob =3D=3D VIR_ASYNC_JOB_BACKUP) virDomainObjEndAsyncJob(vm); + + /* Users can request that the VM is preserved after a guest OS shutdow= n for + * the duration of the backup. This is the place where we need to chec= k if + * this happened and optionally terminate the VM if the guest OS is st= ill + * shut down */ + if (apiFlags & VIR_DOMAIN_BACKUP_BEGIN_PRESERVE_SHUTDOWN_DOMAIN) { + int reason =3D -1; + virDomainState state =3D virDomainObjGetState(vm, &reason); + + VIR_DEBUG("state: '%u', reason:'%d'", state, reason); + + if (state =3D=3D VIR_DOMAIN_SHUTDOWN || + (state =3D=3D VIR_DOMAIN_PAUSED && reason =3D=3D VIR_DOMAIN_PA= USED_SHUTTING_DOWN)) { + VIR_DEBUG("backup job finished terminating the previously shut= down VM"); + ignore_value(qemuProcessShutdownOrReboot(vm)); + } + } } @@ -766,7 +786,8 @@ qemuBackupBegin(virDomainObj *vm, int ret =3D -1; g_autoptr(qemuFDPassDirect) fdpass =3D NULL; - virCheckFlags(VIR_DOMAIN_BACKUP_BEGIN_REUSE_EXTERNAL, -1); + virCheckFlags(VIR_DOMAIN_BACKUP_BEGIN_REUSE_EXTERNAL | + VIR_DOMAIN_BACKUP_BEGIN_PRESERVE_SHUTDOWN_DOMAIN, -1); if (!(def =3D virDomainBackupDefParseString(backupXML, priv->driver->x= mlopt, 0))) return -1; diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c index bbd9859ef4..4769d6694d 100644 --- a/src/qemu/qemu_process.c +++ b/src/qemu/qemu_process.c @@ -597,6 +597,51 @@ qemuProcessFakeReboot(void *opaque) } +static void +qemuProcessResetPreservedDomain(void *opaque) +{ + virDomainObj *vm =3D opaque; + qemuDomainObjPrivate *priv =3D vm->privateData; + virQEMUDriver *driver =3D priv->driver; + virObjectEvent *event =3D NULL; + int rc; + + VIR_DEBUG("vm=3D%p", vm); + + virObjectLock(vm); + if (virDomainObjBeginJob(vm, VIR_JOB_MODIFY) < 0) + goto cleanup; + + if (!virDomainObjIsActive(vm)) { + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("guest unexpectedly quit")); + goto endjob; + } + + qemuDomainObjEnterMonitor(vm); + rc =3D qemuMonitorSystemReset(priv->mon); + qemuDomainObjExitMonitor(vm); + + /* A guest-initiated OS shutdown completes qemu pauses the CPUs thus w= e need + * to also update the state */ + virDomainObjSetState(vm, VIR_DOMAIN_PAUSED, VIR_DOMAIN_PAUSED_SHUTTING= _DOWN); + event =3D virDomainEventLifecycleNewFromObj(vm, + VIR_DOMAIN_EVENT_SUSPENDED, + VIR_DOMAIN_EVENT_SUSPENDED_G= UEST_SHUTDOWN); + + if (rc < 0) + goto endjob; + + endjob: + virDomainObjEndJob(vm); + + cleanup: + qemuDomainSaveStatus(vm); + virDomainObjEndAPI(&vm); + virObjectEventStateQueue(driver->domainEventState, event); +} + + /** * qemuProcessShutdownOrReboot: * @vm: domain object @@ -630,6 +675,37 @@ qemuProcessShutdownOrReboot(virDomainObj *vm) virObjectUnref(vm); } + return false; + } else if (priv->backup && priv->backup->apiFlags & VIR_DOMAIN_BACKUP_= BEGIN_PRESERVE_SHUTDOWN_DOMAIN) { + /* The users can request that while the 'backup' job is active (and + * possibly also other block jobs in the future) the qemu process = will + * be kept around even when the guest OS shuts down, evem when the + * requested action is to terminate the VM. + * + * In such case we'll reset the VM and keep it paused with proper = state + * so that users can re-start it if needed. + * + * Terminating of the qemu process once the backup job is + * completed/terminated (unless the guest was unpaused/restarted) = is + * then done in qemuBackupJobTerminate by invoking this function o= nce + * again. + */ + g_autofree char *name =3D g_strdup_printf("reset-%s", vm->def->nam= e); + virThread th; + + VIR_DEBUG("preserving qemu process while backup job is running"); + + virObjectRef(vm); + if (virThreadCreateFull(&th, + false, + qemuProcessResetPreservedDomain, + name, + false, + vm) < 0) { + VIR_WARN("Failed to create thread to reset shutdown VM"); + virObjectUnref(vm); + } + return false; } else { ignore_value(qemuProcessKill(vm, VIR_QEMU_PROCESS_KILL_NOWAIT)); --=20 2.51.1 From nobody Fri Nov 21 09:59:51 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=1763545759; cv=none; d=zohomail.com; s=zohoarc; b=aXJ1WP5itf+o1rfA19A74m+XeZCUeYNriDY/PAmVCHPQkbCsdHvgtIX8xlEyEWxV2WIIylgVG6Vda6rAyG+crUUNRv8GwOudNEjX2FbFrCWR0qqhJgf7MZKjoQfOdVNVUQs23lYG9gK3d0XhYnHoH8p9Mi5ClcDJ83Txz3mOLIY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1763545759; 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=qZpNB88Ti1zMwuDhA+wKc/PQ6muVBiNZU80piwB9Xj0=; b=FglvVL2iwzAKbYQsS6JYi1dGutpoKFqDBKy1H9MWbDwDxt2tjBiEUXiUA25xW2O4p6rXvlX5oRdtqxD7+LXEIm2ZXINhPjEUamimxkBTxZx1EtpwUhb1uL9HbtQr9oB3aRWPwGgi5wyAQ5tIYNcAHLU9LjiaRLafaDv5okgAGT0= 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 1763545759907514.1633901430396; Wed, 19 Nov 2025 01:49:19 -0800 (PST) Received: by lists.libvirt.org (Postfix, from userid 993) id DDD6B3F30F; Wed, 19 Nov 2025 04:49:18 -0500 (EST) Received: from [172.19.199.50] (lists.libvirt.org [8.43.85.245]) by lists.libvirt.org (Postfix) with ESMTP id 8894844332; Wed, 19 Nov 2025 04:38:51 -0500 (EST) Received: by lists.libvirt.org (Postfix, from userid 993) id 56F5044274; Wed, 19 Nov 2025 04:38:41 -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 6209843FCB for ; Wed, 19 Nov 2025 04:38:07 -0500 (EST) Received: from mx-prod-mc-03.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-475-lZglWAsEPS6tHTV3V_MxcQ-1; Wed, 19 Nov 2025 04:38:05 -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-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id A793718AB428 for ; Wed, 19 Nov 2025 09:38:04 +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 9D63E18004A3 for ; Wed, 19 Nov 2025 09:38:03 +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=1763545087; 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=qZpNB88Ti1zMwuDhA+wKc/PQ6muVBiNZU80piwB9Xj0=; b=XApbKN0QStV5Oq646GbXaj2rwSpszACubNcPbBm5efMkBdwDgA/tevPF9XiRDmwHVehOhL zN0FUX6AwcTEyvqn9myKyaodLJvJ9VPoh9+eUZhXXAbMqmLzCCzbnndzZRj4VodKs4a3b8 qN3GyQ10Kw0y4LithaZlhE0I7F/2Nmo= X-MC-Unique: lZglWAsEPS6tHTV3V_MxcQ-1 X-Mimecast-MFC-AGG-ID: lZglWAsEPS6tHTV3V_MxcQ_1763545084 To: devel@lists.libvirt.org Subject: [PATCH 8/8] kbase: Add note about preserving VM on shutdown to backup article Date: Wed, 19 Nov 2025 10:37:51 +0100 Message-ID: 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: eaucAo7tImWk6hP9azY4fIy40_Zr6QIHB--WboYCquo_1763545084 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Message-ID-Hash: YZYL7QG2X3CF2MRCMOV7WNANS7KJADEW X-Message-ID-Hash: YZYL7QG2X3CF2MRCMOV7WNANS7KJADEW 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: 1763545760959158500 Content-Type: text/plain; charset="utf-8" From: Peter Krempa Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- docs/kbase/live_full_disk_backup.rst | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/docs/kbase/live_full_disk_backup.rst b/docs/kbase/live_full_di= sk_backup.rst index be95d9d2e2..2b3b19772e 100644 --- a/docs/kbase/live_full_disk_backup.rst +++ b/docs/kbase/live_full_disk_backup.rst @@ -84,6 +84,24 @@ This requires libvirt-7.2.0 and QEMU-4.2, or higher vers= ions. 15M -rw-r--r--. 1 qemu qemu 15M May 10 12:22 vm1.qcow2 21M -rw-------. 1 root root 21M May 10 12:23 vm1.qcow2.1620642185 +Shutdown of the guest OS during backup +-------------------------------------- + +The backup job is a long running job, potentially copying a lot of data, w= hich +requires the VM to be active (The backup is done by the qemu process) and +can't be continued if the VM shuts down. This includes shut down initiated= by +the guest OS itself. + +Starting from ``libvirt-11.10`` the ``virDomainBackupBegin()`` supports the +``VIR_DOMAIN_BACKUP_BEGIN_PRESERVE_SHUTDOWN_DOMAIN`` flag +(``virsh backup-begin --preserve-domain-on-shutdown``) which instructs lib= virt +to avoid termination of the VM if the guest OS shuts down while the backup= is +still running. The VM is in that scenario reset and paused instead of term= inated +allowing the backup to finish. Once the backup finishes the VM process is +terminated. Users can resume the VM (e.g. ``virsh resume``) which causes it +to boot normally using the exsiting VM process and will continue to run af= ter +completion of the backup job. + Full backup with older libvirt versions =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --=20 2.51.1