From nobody Mon May 13 21:00:46 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) client-ip=170.10.129.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1647016730; cv=none; d=zohomail.com; s=zohoarc; b=ULMFa0bGWPazATQUtzOH4ylkBRKqpbrtAq++fmqesXHutSj8jMbudd7S5rVYoSsOAC5Ay1qsmm7Ln0PxDnKAxqEbdUKiCuwDqHTzqeL/aQYYEOGBihhg2dS1ktOx8Kth6w4oqLexSmPRbPdmFC3l4wbau6HYLMxAviDsNT8vJds= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1647016730; 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=cznEfvCwgrJgBF3NK5eAmCp3CWb6lvVpXf2ZOg+PM1g=; b=EmpFU7das3GHd5tuO9eJcXw3E7A5dMGnJoz7S6c6cM3CqmlVUgG0ksT/z6hJJ4Dg0sAQQSqxWJe3ZC9cGawutJ3wsqaSchaV7UqTrBaUhUbMX5xQH9G94kQqMEvachU3/4woIh0xGDXQgYYTyM3hCVL2f0capTDZvDQImFKFlEs= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by mx.zohomail.com with SMTPS id 1647016730148571.0546813312134; Fri, 11 Mar 2022 08:38:50 -0800 (PST) Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-649-fcbl7lpWOW6aI3XdJ2SxvQ-1; Fri, 11 Mar 2022 11:38:45 -0500 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.rdu2.redhat.com [10.11.54.8]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id C6C653C11C72; Fri, 11 Mar 2022 16:38:37 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id 9416BC23DC2; Fri, 11 Mar 2022 16:38:37 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 7024E1953556; Fri, 11 Mar 2022 16:38:37 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 6FA7A194E109 for ; Fri, 11 Mar 2022 16:38:36 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id EA0B47BCD9; Fri, 11 Mar 2022 16:38:35 +0000 (UTC) Received: from speedmetal.redhat.com (unknown [10.40.208.30]) by smtp.corp.redhat.com (Postfix) with ESMTP id F1B097C021 for ; Fri, 11 Mar 2022 16:38:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1647016727; 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=cznEfvCwgrJgBF3NK5eAmCp3CWb6lvVpXf2ZOg+PM1g=; b=fD3+l9HvepCsMsxTh6o6L7PZafahP76vNLMN6tw8YcKa+YY35x8czERwJrnYiM8vhE0ZiZ we1AhsBuTj7wR6wXK4COIEjxx8h4qMtvLtdnZLzuob7NCGJbIdsC8NzXP0838l/bNn9OdG g+Lci+KvWnobJH6ZQ7FMKNg2zj+j5nM= X-MC-Unique: fcbl7lpWOW6aI3XdJ2SxvQ-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 1/3] conf: snapshot: Introduce 'manual' mode for snapshot of a disk Date: Fri, 11 Mar 2022 17:38:30 +0100 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 2.85 on 10.11.54.8 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1647016730436100001 Content-Type: text/plain; charset="utf-8" The idea of the manual mode is to allow a synchronized snapshot in cases when the storage is outsourced to an unmanaged storage provider which requires cooperation with snapshotting. The mode will instruct the hypervisor to pause along when the other components are snapshotted and the 'manual' disk can be snapshotted along. This increases latency of the snapshot but allows them in otherwise impossible situations. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- docs/formatdomain.rst | 15 ++++++++------- docs/formatsnapshot.rst | 9 +++++++++ docs/schemas/domainsnapshot.rng | 3 +++ src/conf/domain_conf.c | 1 + src/conf/domain_conf.h | 1 + src/conf/snapshot_conf.c | 6 ++++++ src/qemu/qemu_snapshot.c | 5 +++++ src/test/test_driver.c | 17 +++++++++++++++++ 8 files changed, 50 insertions(+), 7 deletions(-) diff --git a/docs/formatdomain.rst b/docs/formatdomain.rst index 9b1b69bb4d..d188de4858 100644 --- a/docs/formatdomain.rst +++ b/docs/formatdomain.rst @@ -2620,13 +2620,14 @@ paravirtualized driver is specified via the ``disk`= ` element. Indicates the default behavior of the disk during disk snapshots: "``internal``" requires a file format such as qcow2 that can store b= oth the snapshot and the data changes since the snapshot; "``external``"= will - separate the snapshot from the live data; and "``no``" means the dis= k will - not participate in snapshots. Read-only disks default to "``no``", w= hile - the default for other disks depends on the hypervisor's capabilities= . Some - hypervisors allow a per-snapshot choice as well, during `domain snap= shot - creation `__. Not all snapshot modes are suppor= ted; - for example, enabling snapshots with a transient disk generally does= not - make sense. :since:`Since 0.9.5` + separate the snapshot from the live data; "``no``" means the disk wi= ll + not participate in snapshots; and ``manual`` allows snapshotting don= e via + an unmanaged storage provider. Read-only disks default to "``no``", = while + the default for other disks depends on the hypervisor's capabilities. + Some hypervisors allow a per-snapshot choice as well, during `domain + snapshot creation `__. Not all snapshot modes a= re + supported; for example, enabling snapshots with a transient disk + generally does not make sense. :since:`Since 0.9.5` ``source`` Representation of the disk ``source`` depends on the disk ``type`` attr= ibute diff --git a/docs/formatsnapshot.rst b/docs/formatsnapshot.rst index 0fee35d89c..4635df89cb 100644 --- a/docs/formatsnapshot.rst +++ b/docs/formatsnapshot.rst @@ -124,6 +124,15 @@ The top-level ``domainsnapshot`` element may contain t= he following elements: corresponding domain disk, while others like qemu allow this field to override the domain default. + :since:`Since 8.2.0` the ``snapshot`` attribute supports the ``manua= l`` + value which instructs the hypervisor to create the snapshot and keep= a + synchronized state by pausing the VM which allows to snapshot disk + storage from outside of the hypervisor if the storage provider suppo= rts + it. The caller is responsible for resuming a VM paused by requestin= g a + ``manual`` snapshot When reverting such snapshot, the expectation is= that + the storage is configured in a way where the hypervisor will see the + correct image state. + :since:`Since 1.2.2` the ``disk`` element supports an optional attri= bute ``type`` if the ``snapshot`` attribute is set to ``external``. This attribute specifies the snapshot target storage type and allows to diff --git a/docs/schemas/domainsnapshot.rng b/docs/schemas/domainsnapshot.= rng index 58c370878d..a5d1a40493 100644 --- a/docs/schemas/domainsnapshot.rng +++ b/docs/schemas/domainsnapshot.rng @@ -200,6 +200,9 @@ + + manual + diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index e0dfc9e45f..153954a0b0 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -1408,6 +1408,7 @@ VIR_ENUM_IMPL(virDomainSnapshotLocation, "no", "internal", "external", + "manual", ); /* Internal mapping: subset of block job types that can be present in diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h index a4de46773c..b69abfa270 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -542,6 +542,7 @@ typedef enum { VIR_DOMAIN_SNAPSHOT_LOCATION_NO, VIR_DOMAIN_SNAPSHOT_LOCATION_INTERNAL, VIR_DOMAIN_SNAPSHOT_LOCATION_EXTERNAL, + VIR_DOMAIN_SNAPSHOT_LOCATION_MANUAL, VIR_DOMAIN_SNAPSHOT_LOCATION_LAST } virDomainSnapshotLocation; diff --git a/src/conf/snapshot_conf.c b/src/conf/snapshot_conf.c index e2442441d0..80946beba9 100644 --- a/src/conf/snapshot_conf.c +++ b/src/conf/snapshot_conf.c @@ -312,6 +312,12 @@ virDomainSnapshotDefParse(xmlXPathContextPtr ctxt, &def->memory, VIR_DOMAIN_SNAPSHOT_LOCATION_DEFAULT) < = 0) return NULL; + + if (def->memory =3D=3D VIR_DOMAIN_SNAPSHOT_LOCATION_MANUAL) { + virReportError(VIR_ERR_XML_ERROR, "%s", + _("'manual' memory snapshot mode not supported"= )); + return NULL; + } } if (def->memory =3D=3D VIR_DOMAIN_SNAPSHOT_LOCATION_DEFAULT) { diff --git a/src/qemu/qemu_snapshot.c b/src/qemu/qemu_snapshot.c index a7901779fc..3fa6caaaec 100644 --- a/src/qemu/qemu_snapshot.c +++ b/src/qemu/qemu_snapshot.c @@ -757,6 +757,11 @@ qemuSnapshotPrepare(virDomainObj *vm, external++; break; + case VIR_DOMAIN_SNAPSHOT_LOCATION_MANUAL: + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("'manual' disk snapshot mode not yet implemen= ted")); + return -1; + case VIR_DOMAIN_SNAPSHOT_LOCATION_NO: /* Remember seeing a disk that has snapshot disabled */ if (!virStorageSourceIsEmpty(dom_disk->src) && diff --git a/src/test/test_driver.c b/src/test/test_driver.c index 9ceb0b45c8..4020662353 100644 --- a/src/test/test_driver.c +++ b/src/test/test_driver.c @@ -8715,6 +8715,23 @@ testDomainSnapshotAlignDisks(virDomainObj *vm, unsigned int flags) { virDomainSnapshotLocation align_location =3D VIR_DOMAIN_SNAPSHOT_LOCAT= ION_INTERNAL; + size_t i; + + for (i =3D 0; i < def->ndisks; i++) { + switch (def->disks[i].snapshot) { + case VIR_DOMAIN_SNAPSHOT_LOCATION_DEFAULT: + case VIR_DOMAIN_SNAPSHOT_LOCATION_NO: + case VIR_DOMAIN_SNAPSHOT_LOCATION_INTERNAL: + case VIR_DOMAIN_SNAPSHOT_LOCATION_EXTERNAL: + case VIR_DOMAIN_SNAPSHOT_LOCATION_LAST: + break; + + case VIR_DOMAIN_SNAPSHOT_LOCATION_MANUAL: + virReportError(VIR_ERR_OPERATION_UNSUPPORTED, "%s", + _("'manual' snapshot mode is not supported by t= he test driver")); + return -1; + } + } if (flags & VIR_DOMAIN_SNAPSHOT_CREATE_DISK_ONLY) { align_location =3D VIR_DOMAIN_SNAPSHOT_LOCATION_EXTERNAL; --=20 2.35.1 From nobody Mon May 13 21:00:46 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) client-ip=170.10.129.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1647016726; cv=none; d=zohomail.com; s=zohoarc; b=AzJFBb9E6IDeJo94aVXQ1o6spQrcqrMlOj3DONkK0y9NInbBEGkGZ6QB3HUVBv/RDiFKaSnwFYX3wkT3wD+xSPzRJmE8fYgWjFZr4NFW0rNkgWYed0oMhCnJIeyFfQIQI+4B98PMltP9yLlgvlX2x1V4suijhLR60KalF9c4+Fg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1647016726; 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=bVVXP+S471TGMmLPrfbGC5E4yzp6gSodXFXV7ZxGsSo=; b=ORX+IgMaJv8dsENTNpad3ByTaih/MtxCTvR/Q469oTPjQ+NkHXiRZCBcWLkVm70UOQN3QZypdEPpSTnJmqJxyGLM6gDBSfyzX5N0LLGr7Yoq2mwVK5GWQo5AI8B+iXoGiY6S1Y+/HHUo4QTpHp0nEdFBygqNxM1idf29SmdlSHk= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by mx.zohomail.com with SMTPS id 1647016726228454.6660126487528; Fri, 11 Mar 2022 08:38:46 -0800 (PST) Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-647-EjZV1-CpOkWFm_AyRxVpUg-1; Fri, 11 Mar 2022 11:38:40 -0500 Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 80C4A2A5955B; Fri, 11 Mar 2022 16:38:38 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id 6BC79464B52; Fri, 11 Mar 2022 16:38:38 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 0214A1953551; Fri, 11 Mar 2022 16:38:38 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 390F01953542 for ; Fri, 11 Mar 2022 16:38:37 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 09C207BCDE; Fri, 11 Mar 2022 16:38:37 +0000 (UTC) Received: from speedmetal.redhat.com (unknown [10.40.208.30]) by smtp.corp.redhat.com (Postfix) with ESMTP id 5C7467BCCF for ; Fri, 11 Mar 2022 16:38:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1647016724; 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=bVVXP+S471TGMmLPrfbGC5E4yzp6gSodXFXV7ZxGsSo=; b=dtnYpxI4JMymo9HyvcfYCjHRCssIzJf3OPCrQux9xFadkqaX/ym8S37xmlSw9u5rutA2SO 54tm6rlcBPxI9evxOgMrTu7Wrv8xSk41WF0pEbP+eEVIz8h0iVk8/yjmOjd7O9g3K1sum2 rzQhXZXKCPjqLvsv5zvp4H3qaFN0fjc= X-MC-Unique: EjZV1-CpOkWFm_AyRxVpUg-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 2/3] qemuSnapshotCreateActiveExternal: Implement manual snapshot mode Date: Fri, 11 Mar 2022 17:38:31 +0100 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 2.85 on 10.11.54.9 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1647016728347100003 Content-Type: text/plain; charset="utf-8" In case we are snapshotting at least one 'manual' disk we will pause the VM and keep it paused. Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=3D1866400 Signed-off-by: Peter Krempa --- src/qemu/qemu_snapshot.c | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-) diff --git a/src/qemu/qemu_snapshot.c b/src/qemu/qemu_snapshot.c index 3fa6caaaec..03c070b911 100644 --- a/src/qemu/qemu_snapshot.c +++ b/src/qemu/qemu_snapshot.c @@ -458,6 +458,9 @@ qemuSnapshotPrepareDiskExternalActive(virDomainObj *vm, { int actualType =3D virStorageSourceGetActualType(snapdisk->src); + if (snapdisk->snapshot =3D=3D VIR_DOMAIN_SNAPSHOT_LOCATION_MANUAL) + return 0; + if (domdisk->device =3D=3D VIR_DOMAIN_DISK_DEVICE_LUN) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", _("external active snapshots are not supported on s= csi " @@ -677,6 +680,7 @@ qemuSnapshotPrepareDiskInternal(virDomainDiskDef *disk, static int qemuSnapshotPrepare(virDomainObj *vm, virDomainSnapshotDef *def, + bool *has_manual, unsigned int *flags) { qemuDomainObjPrivate *priv =3D vm->privateData; @@ -758,9 +762,9 @@ qemuSnapshotPrepare(virDomainObj *vm, break; case VIR_DOMAIN_SNAPSHOT_LOCATION_MANUAL: - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("'manual' disk snapshot mode not yet implemen= ted")); - return -1; + *has_manual =3D true; + forbid_internal =3D true; + break; case VIR_DOMAIN_SNAPSHOT_LOCATION_NO: /* Remember seeing a disk that has snapshot disabled */ @@ -1341,6 +1345,7 @@ qemuSnapshotCreateActiveExternal(virQEMUDriver *drive= r, virDomainObj *vm, virDomainMomentObj *snap, virQEMUDriverConfig *cfg, + bool has_manual, unsigned int flags) { virObjectEvent *event; @@ -1391,11 +1396,14 @@ qemuSnapshotCreateActiveExternal(virQEMUDriver *dri= ver, } else if (virDomainObjGetState(vm, NULL) =3D=3D VIR_DOMAIN_RUNNING) { /* For full system external snapshots (those with memory), the gue= st * must pause (either by libvirt up front, or by qemu after - * _LIVE converges). */ - if (memory) + * _LIVE converges). We don't want to unpause it though if user has + * elected to manually snapshot some disks */ + if (memory && !has_manual) resume =3D true; - if (memory && !(flags & VIR_DOMAIN_SNAPSHOT_CREATE_LIVE)) { + /* we need to pause the VM even when we aren't taking a memory sna= pshot + * when the user wants to manually snapshot some disks */ + if (((memory || has_manual) && !(flags & VIR_DOMAIN_SNAPSHOT_CREAT= E_LIVE))) { if (qemuProcessStopCPUs(driver, vm, VIR_DOMAIN_PAUSED_SNAPSHOT, QEMU_ASYNC_JOB_SNAPSHOT) < 0) goto cleanup; @@ -1765,11 +1773,12 @@ qemuSnapshotCreate(virDomainObj *vm, virDomainMomentObj *snap =3D NULL; virDomainMomentObj *current =3D NULL; virDomainSnapshotPtr ret =3D NULL; + bool has_manual =3D false; /* user wants to manually snapshot some dis= ks */ if (qemuSnapshotCreateAlignDisks(vm, snapdef, driver, flags) < 0) return NULL; - if (qemuSnapshotPrepare(vm, snapdef, &flags) < 0) + if (qemuSnapshotPrepare(vm, snapdef, &has_manual, &flags) < 0) return NULL; if (flags & VIR_DOMAIN_SNAPSHOT_CREATE_NO_METADATA) { @@ -1790,7 +1799,7 @@ qemuSnapshotCreate(virDomainObj *vm, if (flags & VIR_DOMAIN_SNAPSHOT_CREATE_DISK_ONLY || virDomainSnapshotObjGetDef(snap)->memory =3D=3D VIR_DOMAIN_SNA= PSHOT_LOCATION_EXTERNAL) { /* external full system or disk snapshot */ - if (qemuSnapshotCreateActiveExternal(driver, vm, snap, cfg, fl= ags) < 0) + if (qemuSnapshotCreateActiveExternal(driver, vm, snap, cfg, ha= s_manual, flags) < 0) goto error; } else { /* internal full system */ --=20 2.35.1 From nobody Mon May 13 21:00:46 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) client-ip=170.10.133.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1647016725; cv=none; d=zohomail.com; s=zohoarc; b=TmCQy7/tUd7gDJFZtZh8Dx6/YPd0Q+WREYWNfo+eN0E/I2C00ozwMAG5tboAbjnVVQOKHtspk6/Rrh3NIeNek6gHb939/0juJBL9pmFpS0ctQPRhghwa4AaCnYJbpp5b/bX8Ze0Q7AUoj0FIaYo1yCe6Pcz62R/opUYMUt1NFC8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1647016725; 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=0LjboBL1bbAEbfaLPVxyo+bE36/7ijJPIQoE3gbNRTo=; b=VJ6ooAQ2Pum7/j4vsnBXlgNZAbATdTERA4JFw50SAGtm7zyhrkJ8tHSPTwcWW3r2UEfwRolE/J9nipdOAW4Maz2j5u1I+Om5+SD7lEc+zYFFygPVr1f7NnihExVwKyzIBgyyhcnVOQzqXptkxH2qgXN3BIYJnBWstnr0uS0JBAs= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mx.zohomail.com with SMTPS id 1647016725472336.1926574312115; Fri, 11 Mar 2022 08:38:45 -0800 (PST) Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-32-6kTXKmb8NiKkv6H3U-T9Fg-1; Fri, 11 Mar 2022 11:38:42 -0500 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.rdu2.redhat.com [10.11.54.7]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 5251B10726A5; Fri, 11 Mar 2022 16:38:40 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id 3CAE51457F06; Fri, 11 Mar 2022 16:38:40 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id D88BF1953556; Fri, 11 Mar 2022 16:38:39 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 81D9E1954385 for ; Fri, 11 Mar 2022 16:38:38 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 0DEEC7BCCF; Fri, 11 Mar 2022 16:38:38 +0000 (UTC) Received: from speedmetal.redhat.com (unknown [10.40.208.30]) by smtp.corp.redhat.com (Postfix) with ESMTP id 675257BCCC for ; Fri, 11 Mar 2022 16:38:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1647016724; 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=0LjboBL1bbAEbfaLPVxyo+bE36/7ijJPIQoE3gbNRTo=; b=cRp3ZwPrHtinJP1ec+4L+sEwBDsmfE8qro1LxTFzx7JnYqHxY1ODgyY1utHmhw9IgSzz7j 8WaJfG9+4jslNYYqQF3xdQYZPrex7q08R4SD8/VROof3S1I4NNrBL/0csMxoae0p1R9deC 7vHgJVLTwQJj4RZ9PMUMFGQ84FbpJrg= X-MC-Unique: 6kTXKmb8NiKkv6H3U-T9Fg-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 3/3] kbase: Introduce 'snapshots' page and describe the new 'manual' snapshot Date: Fri, 11 Mar 2022 17:38:32 +0100 Message-Id: <0552ad3412905cefda34f62ce0fd036986738856.1647016672.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 2.85 on 10.11.54.7 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1647016726693100001 Content-Type: text/plain; charset="utf-8" Signed-off-by: Peter Krempa --- docs/kbase/index.rst | 3 +++ docs/kbase/meson.build | 1 + docs/kbase/snapshots.rst | 53 ++++++++++++++++++++++++++++++++++++++++ 3 files changed, 57 insertions(+) create mode 100644 docs/kbase/snapshots.rst diff --git a/docs/kbase/index.rst b/docs/kbase/index.rst index 09b19ed1af..77b23e96a8 100644 --- a/docs/kbase/index.rst +++ b/docs/kbase/index.rst @@ -55,6 +55,9 @@ Usage `Memory devices `__ Memory devices and their use +`Snapshots ` + Details about snapshotting a VM + Internals / Debugging --------------------- diff --git a/docs/kbase/meson.build b/docs/kbase/meson.build index af067db453..d632f9bda1 100644 --- a/docs/kbase/meson.build +++ b/docs/kbase/meson.build @@ -18,6 +18,7 @@ docs_kbase_files =3D [ 'rpm-deployment', 's390_protected_virt', 'secureusage', + 'snapshots', 'systemtap', 'virtiofs', ] diff --git a/docs/kbase/snapshots.rst b/docs/kbase/snapshots.rst new file mode 100644 index 0000000000..bc457197a0 --- /dev/null +++ b/docs/kbase/snapshots.rst @@ -0,0 +1,53 @@ +=3D=3D=3D=3D=3D=3D=3D=3D=3D +Snapshots +=3D=3D=3D=3D=3D=3D=3D=3D=3D + +.. contents:: + +Manual storage snapshotting +=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 + +Certain use cases such as block storage on LVM or disks backed via storage +exported through the ``vhost-user-blk`` protocol may require that snapshot= s are +done in conjunction with the storage provider which is not managed by **li= bvirt**. + +To achieve this such disks can use ``snapshot`` mode ``manual``. When a sn= apshot +has a disk in manual mode the following happens: + + #. ``libvirt`` takes snapshot of the VM memory if requested + + #. If a live snapshot is requested (``VIR_DOMAIN_SNAPSHOT_CREATE_LIVE``= ) the + VM runs until the memory snapshot phase completes and is then paused. + #. Otherwise the VM is paused right away. + + #. Snapshot of disks which are marked for external snapsot is executed + #. The API return success, the VM is paused. + #. The user snapshots the externally managed storage + #. The user resumes the execution of the VM (``virsh resume $VM``) + +*Note:* It's not required to wait until the API finishes. The snapshotting= of +``manual`` disks can be done right after a event of +``VIR_DOMAIN_EVENT_ID_LIFECYCLE`` type with value of +``VIR_DOMAIN_EVENT_SUSPENDED`` is emitted by libvirtd. + +Overview of manual snapshots +---------------------------- + +Manual snapshot of a disk is requested by setting the ``snapshot`` propert= y to +``manual`` in the snapshot XML :: + + + + + + + + + + +or ``--diskspec vda,snapshot=3Dmanual`` when using ``virsh snapshot-create= -as``:: + + $ virsh snapshot-create-as --diskspec vda,snapshot=3Dmanual \ + --diskspec vdb,snapshot=3Dexternal \ + --diskspec vdc,snapshot=3Dno $VM \ + --memspec file=3D/path/to/memory/img --=20 2.35.1