From nobody Mon Feb 9 05:24:58 2026 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=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.libvirt.org (lists.libvirt.org [8.43.85.245]) by mx.zohomail.com with SMTPS id 1727963309164580.9446512570391; Thu, 3 Oct 2024 06:48:29 -0700 (PDT) Received: by lists.libvirt.org (Postfix, from userid 996) id 02A4A15F8; Thu, 3 Oct 2024 09:48:27 -0400 (EDT) Received: from lists.libvirt.org (localhost [IPv6:::1]) by lists.libvirt.org (Postfix) with ESMTP id CC14911CA; Thu, 3 Oct 2024 09:47:07 -0400 (EDT) Received: by lists.libvirt.org (Postfix, from userid 996) id F0AFBC6A; Thu, 3 Oct 2024 09:47:02 -0400 (EDT) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by lists.libvirt.org (Postfix) with ESMTPS id 7E2A5A02 for ; Thu, 3 Oct 2024 09:46:51 -0400 (EDT) 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-365-ZXoUy-BBP2qGc1GLbKQ7wg-1; Thu, 03 Oct 2024 09:46:49 -0400 Received: from mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.12]) (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 AAD0B19560A6; Thu, 3 Oct 2024 13:46:48 +0000 (UTC) Received: from speedmetal.redhat.com (unknown [10.45.242.12]) by mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 69D2019560A3; Thu, 3 Oct 2024 13:46:47 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on lists.libvirt.org X-Spam-Level: X-Spam-Status: No, score=-0.5 required=5.0 tests=DKIM_INVALID,DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,RCVD_IN_VALIDITY_RPBL_BLOCKED, RCVD_IN_VALIDITY_SAFE_BLOCKED,SPF_HELO_NONE autolearn=unavailable autolearn_force=no version=3.4.4 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1727963211; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=0JVME2fccZR+o00EgWZeQJAyOy3cQU+TbbIu1L/GP6k=; b=T+voxfm1FXcJ+lRrFjKiM7qZiMKRC+VFsHHLUuh2E7vy1IbDaiWExZYD8/ip8tnvk5h8Ty lalg/OZE5Rgg3CS6ySWR6I4JPxouCXT1cMGKgmsvo9KVtTb+GwK3C6Ne+rSFsari4BOydk DXYpLz6df+JwHW3f9jHQduuinLavpME= X-MC-Unique: ZXoUy-BBP2qGc1GLbKQ7wg-1 From: Peter Krempa To: devel@lists.libvirt.org Subject: [PATCH v3 05/10] qemu: monitor: Store internal snapshot names from 'query-named-block-nodes' Date: Thu, 3 Oct 2024 15:46:31 +0200 Message-ID: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.0 on 10.30.177.12 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Message-ID-Hash: HA2GFBP3SHMAFWQOQM4HLAWVNYSHBY7Z X-Message-ID-Hash: HA2GFBP3SHMAFWQOQM4HLAWVNYSHBY7Z X-MailFrom: pkrempa@redhat.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-config-1; header-match-config-2; header-match-config-3; header-match-devel.lists.libvirt.org-0; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; suspicious-header CC: nikolai.barybin@virtuozzo.com, den@openvz.org X-Mailman-Version: 3.2.2 Precedence: list List-Id: Development discussions about the libvirt library & tools Archived-At: List-Archive: List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1727963394049116600 Content-Type: text/plain; charset="utf-8" Store the names of internal snapshots present in supported images in the data we dump from 'query-named-block-nodes' so that the upcoming changes to the internal snapshot code can access it. To test this we use the bitmap detection test cases which can be easily extended to dump this data. Signed-off-by: Peter Krempa --- src/qemu/qemu_monitor.h | 3 + src/qemu/qemu_monitor_json.c | 19 ++ tests/qemublocktest.c | 11 + .../bitmap/snapshots-internal.json | 298 ++++++++++++++++++ .../bitmap/snapshots-internal.out | 2 + 5 files changed, 333 insertions(+) create mode 100644 tests/qemublocktestdata/bitmap/snapshots-internal.json create mode 100644 tests/qemublocktestdata/bitmap/snapshots-internal.out diff --git a/src/qemu/qemu_monitor.h b/src/qemu/qemu_monitor.h index 6251f48d28..4341519cfe 100644 --- a/src/qemu/qemu_monitor.h +++ b/src/qemu/qemu_monitor.h @@ -709,6 +709,9 @@ struct _qemuBlockNamedNodeData { qemuBlockNamedNodeDataBitmap **bitmaps; size_t nbitmaps; + /* NULL terminated string list of internal snapshot names */ + char **snapshots; + /* the cluster size of the image is valid only when > 0 */ unsigned long long clusterSize; diff --git a/src/qemu/qemu_monitor_json.c b/src/qemu/qemu_monitor_json.c index 27f74181f6..2c3fce9002 100644 --- a/src/qemu/qemu_monitor_json.c +++ b/src/qemu/qemu_monitor_json.c @@ -2631,6 +2631,7 @@ qemuMonitorJSONBlockGetNamedNodeDataWorker(size_t pos= G_GNUC_UNUSED, GHashTable *nodes =3D opaque; virJSONValue *img; virJSONValue *bitmaps; + virJSONValue *snapshots; virJSONValue *format_specific; const char *nodename; g_autoptr(qemuBlockNamedNodeData) ent =3D NULL; @@ -2654,6 +2655,24 @@ qemuMonitorJSONBlockGetNamedNodeDataWorker(size_t po= s G_GNUC_UNUSED, if ((bitmaps =3D virJSONValueObjectGetArray(val, "dirty-bitmaps"))) qemuMonitorJSONBlockGetNamedNodeDataBitmaps(bitmaps, ent); + if ((snapshots =3D virJSONValueObjectGetArray(img, "snapshots"))) { + size_t nsnapshots =3D virJSONValueArraySize(snapshots); + size_t nsnapnames =3D 0; + size_t i; + + ent->snapshots =3D g_new0(char *, nsnapshots + 1); + + for (i =3D 0; i < nsnapshots; i++) { + virJSONValue *snapshot =3D virJSONValueArrayGet(snapshots, i); + const char *name =3D virJSONValueObjectGetString(snapshot, "na= me"); + + if (!name) + continue; + + ent->snapshots[nsnapnames++] =3D g_strdup(name); + } + } + /* query qcow2 format specific props */ if ((format_specific =3D virJSONValueObjectGetObject(img, "format-spec= ific")) && STREQ_NULLABLE(virJSONValueObjectGetString(format_specific, "type"= ), "qcow2")) { diff --git a/tests/qemublocktest.c b/tests/qemublocktest.c index 6c4e735466..60ac929e68 100644 --- a/tests/qemublocktest.c +++ b/tests/qemublocktest.c @@ -594,6 +594,15 @@ testQemuDetectBitmapsWorker(GHashTable *nodedata, bitmap->granularity, bitmap->dirtybytes); } + if (data->snapshots) { + char **sn; + + virBufferAddLit(buf, "internal snapshots:"); + + for (sn =3D data->snapshots; *sn; sn++) + virBufferAsprintf(buf, " '%s'", *sn); + } + virBufferAdjustIndent(buf, -1); } @@ -1201,6 +1210,7 @@ mymain(void) TEST_IMAGE_CREATE("network-rbd-qcow2", NULL); TEST_IMAGE_CREATE("network-ssh-qcow2", NULL); + /* The following group also tests internal snapshot detection */ #define TEST_BITMAP_DETECT(testname) \ do { \ if (virTestRun("bitmap detect " testname, \ @@ -1213,6 +1223,7 @@ mymain(void) TEST_BITMAP_DETECT("basic"); TEST_BITMAP_DETECT("snapshots"); TEST_BITMAP_DETECT("synthetic"); + TEST_BITMAP_DETECT("snapshots-internal"); #define TEST_BACKUP_BITMAP_CALCULATE(testname, source, incrbackup, named) \ do { \ diff --git a/tests/qemublocktestdata/bitmap/snapshots-internal.json b/tests= /qemublocktestdata/bitmap/snapshots-internal.json new file mode 100644 index 0000000000..2198f8f364 --- /dev/null +++ b/tests/qemublocktestdata/bitmap/snapshots-internal.json @@ -0,0 +1,298 @@ +[ + { + "iops_rd": 0, + "detect_zeroes": "off", + "image": { + "snapshots": [ + { + "vm-clock-nsec": 992826708, + "name": "1727868651", + "date-sec": 1727868651, + "date-nsec": 317899000, + "vm-clock-sec": 466, + "id": "1", + "vm-state-size": 57440493 + }, + { + "vm-clock-nsec": 159450672, + "name": "1727872064", + "date-sec": 1727872064, + "date-nsec": 991275000, + "vm-clock-sec": 2431, + "id": "2", + "vm-state-size": 57342213 + } + ], + "virtual-size": 104857600, + "filename": "/tmp/internal-snaps.qcow2", + "cluster-size": 65536, + "format": "qcow2", + "actual-size": 115228672, + "format-specific": { + "type": "qcow2", + "data": { + "compat": "1.1", + "compression-type": "zlib", + "lazy-refcounts": false, + "refcount-bits": 16, + "corrupt": false, + "extended-l2": false + } + }, + "dirty-flag": false + }, + "iops_wr": 0, + "ro": false, + "node-name": "libvirt-1-format", + "backing_file_depth": 0, + "drv": "qcow2", + "iops": 0, + "bps_wr": 0, + "write_threshold": 0, + "encrypted": false, + "bps": 0, + "bps_rd": 0, + "cache": { + "no-flush": false, + "direct": false, + "writeback": true + }, + "file": "/tmp/internal-snaps.qcow2" + }, + { + "iops_rd": 0, + "detect_zeroes": "off", + "image": { + "virtual-size": 115409408, + "filename": "/tmp/internal-snaps.qcow2", + "format": "file", + "actual-size": 115228672, + "format-specific": { + "type": "file", + "data": { + + } + }, + "dirty-flag": false + }, + "iops_wr": 0, + "ro": false, + "node-name": "libvirt-1-storage", + "backing_file_depth": 0, + "drv": "file", + "iops": 0, + "bps_wr": 0, + "write_threshold": 0, + "encrypted": false, + "bps": 0, + "bps_rd": 0, + "cache": { + "no-flush": false, + "direct": false, + "writeback": true + }, + "file": "/tmp/internal-snaps.qcow2" + }, + { + "iops_rd": 0, + "detect_zeroes": "off", + "image": { + "virtual-size": 708837376, + "filename": "/var/lib/libvirt/images/systemrescuecd-amd64-6.1.2.is= o", + "format": "file", + "actual-size": 708841472, + "format-specific": { + "type": "file", + "data": { + + } + }, + "dirty-flag": false + }, + "iops_wr": 0, + "ro": true, + "node-name": "libvirt-2-storage", + "backing_file_depth": 0, + "drv": "file", + "iops": 0, + "bps_wr": 0, + "write_threshold": 0, + "encrypted": false, + "bps": 0, + "bps_rd": 0, + "cache": { + "no-flush": false, + "direct": false, + "writeback": true + }, + "file": "/var/lib/libvirt/images/systemrescuecd-amd64-6.1.2.iso" + }, + { + "iops_rd": 0, + "detect_zeroes": "off", + "image": { + "snapshots": [ + { + "vm-clock-nsec": 992826708, + "name": "1727868651", + "date-sec": 1727868651, + "date-nsec": 317899000, + "vm-clock-sec": 466, + "id": "1", + "vm-state-size": 0 + }, + { + "vm-clock-nsec": 159450672, + "name": "1727872064", + "date-sec": 1727872064, + "date-nsec": 991275000, + "vm-clock-sec": 2431, + "id": "2", + "vm-state-size": 0 + } + ], + "virtual-size": 540672, + "filename": "/var/lib/libvirt/qemu/nvram/int-q35_VARS.qcow2", + "cluster-size": 4096, + "format": "qcow2", + "actual-size": 602112, + "format-specific": { + "type": "qcow2", + "data": { + "compat": "1.1", + "compression-type": "zlib", + "lazy-refcounts": false, + "refcount-bits": 16, + "corrupt": false, + "extended-l2": false + } + }, + "dirty-flag": false + }, + "iops_wr": 0, + "ro": false, + "node-name": "libvirt-pflash1-format", + "backing_file_depth": 0, + "drv": "qcow2", + "iops": 0, + "bps_wr": 0, + "write_threshold": 0, + "encrypted": false, + "bps": 0, + "bps_rd": 0, + "cache": { + "no-flush": false, + "direct": false, + "writeback": true + }, + "file": "/var/lib/libvirt/qemu/nvram/int-q35_VARS.qcow2" + }, + { + "iops_rd": 0, + "detect_zeroes": "off", + "image": { + "virtual-size": 598528, + "filename": "/var/lib/libvirt/qemu/nvram/int-q35_VARS.qcow2", + "format": "file", + "actual-size": 602112, + "format-specific": { + "type": "file", + "data": { + + } + }, + "dirty-flag": false + }, + "iops_wr": 0, + "ro": false, + "node-name": "libvirt-pflash1-storage", + "backing_file_depth": 0, + "drv": "file", + "iops": 0, + "bps_wr": 0, + "write_threshold": 0, + "encrypted": false, + "bps": 0, + "bps_rd": 0, + "cache": { + "no-flush": false, + "direct": false, + "writeback": true + }, + "file": "/var/lib/libvirt/qemu/nvram/int-q35_VARS.qcow2" + }, + { + "iops_rd": 0, + "detect_zeroes": "off", + "image": { + "virtual-size": 3653632, + "filename": "/usr/share/edk2/ovmf/OVMF_CODE_4M.secboot.qcow2", + "cluster-size": 4096, + "format": "qcow2", + "actual-size": 3678208, + "format-specific": { + "type": "qcow2", + "data": { + "compat": "1.1", + "compression-type": "zlib", + "lazy-refcounts": false, + "refcount-bits": 16, + "corrupt": false, + "extended-l2": false + } + }, + "dirty-flag": false + }, + "iops_wr": 0, + "ro": true, + "node-name": "libvirt-pflash0-format", + "backing_file_depth": 0, + "drv": "qcow2", + "iops": 0, + "bps_wr": 0, + "write_threshold": 0, + "encrypted": false, + "bps": 0, + "bps_rd": 0, + "cache": { + "no-flush": false, + "direct": false, + "writeback": true + }, + "file": "/usr/share/edk2/ovmf/OVMF_CODE_4M.secboot.qcow2" + }, + { + "iops_rd": 0, + "detect_zeroes": "off", + "image": { + "virtual-size": 3678208, + "filename": "/usr/share/edk2/ovmf/OVMF_CODE_4M.secboot.qcow2", + "format": "file", + "actual-size": 3678208, + "format-specific": { + "type": "file", + "data": { + + } + }, + "dirty-flag": false + }, + "iops_wr": 0, + "ro": false, + "node-name": "libvirt-pflash0-storage", + "backing_file_depth": 0, + "drv": "file", + "iops": 0, + "bps_wr": 0, + "write_threshold": 0, + "encrypted": false, + "bps": 0, + "bps_rd": 0, + "cache": { + "no-flush": false, + "direct": false, + "writeback": true + }, + "file": "/usr/share/edk2/ovmf/OVMF_CODE_4M.secboot.qcow2" + } +] diff --git a/tests/qemublocktestdata/bitmap/snapshots-internal.out b/tests/= qemublocktestdata/bitmap/snapshots-internal.out new file mode 100644 index 0000000000..f2fb0a1dcc --- /dev/null +++ b/tests/qemublocktestdata/bitmap/snapshots-internal.out @@ -0,0 +1,2 @@ +libvirt-1-format: + internal snapshots: '1727868651' '1727872064' --=20 2.46.0