From 02b9fe89c93192aec900bdf7439ab05d986edb9a Mon Sep 17 00:00:00 2001 From: Jean-Louis Dupond Date: Mon, 12 Jun 2023 15:01:15 +0200 Subject: [PATCH] Add bitmap info to getQemuImageInfo We add bitmap info the the getQemuImageInfo output so this can be used within ovirt-engine. Signed-off-by: Jean-Louis Dupond --- lib/vdsm/api/vdsm-api.yml | 43 ++++++++++++++++++++++++++++++++++++++ lib/vdsm/host/caps.py | 1 + lib/vdsm/storage/volume.py | 10 +++++++++ 3 files changed, 54 insertions(+) diff --git a/lib/vdsm/api/vdsm-api.yml b/lib/vdsm/api/vdsm-api.yml index 2382ecfb7..37f6490dc 100644 --- a/lib/vdsm/api/vdsm-api.yml +++ b/lib/vdsm/api/vdsm-api.yml @@ -557,6 +557,46 @@ types: 1.1: qemu versions starting with 1.1 which are supported by QCOW2 version 3. + Qcow2BitmapInfoFlags: &Qcow2BitmapInfoFlags + added: '4.5.5' + description: An enumeration of qcow compat version. + name: Qcow2BitmapInfoFlags + type: enum + values: + 'in-use': This flag is set by any process actively modifying the + qcow2 file, and cleared when the updated bitmap is flushed + to the qcow2 image. The presence of this flag in an + offline image means that the bitmap was not saved correctly + after its last usage, and may contain inconsistent data. + 'auto': The bitmap must reflect all changes of the virtual disk by + any application that would write to this qcow2 file. + + Qcow2BitmapInfo: &Qcow2BitmapInfo + added: '4.5.5' + description: Information about a Bitmap + name: Qcow2BitmapInfo + properties: + - description: The UUID of bitmap + name: name + type: *UUID + + - description: Granularity of the bitmap + name: granularity + type: uint + + - description: Bitmap flags + name: flags + defaultvalue: '[]' + type: *Qcow2BitmapInfoFlags + type: object + + Qcow2Bitmaps: &Qcow2Bitmaps + added: '4.5.5' + description: A list of qcow2 bitmaps + name: Qcow2Bitmaps + defaultvalue: '[]' + type: *Qcow2BitmapInfo + Qcow2Attributes: &Qcow2Attributes added: '4.1' description: Possible QCOW2 attributes which are allowed @@ -8131,6 +8171,9 @@ types: - description: The compat version. name: compat type: *Qcow2Compat + - description: Volume bitmaps + name: bitmaps + type: *Qcow2Bitmaps type: object VolumeSizeInfo: &VolumeSizeInfo diff --git a/lib/vdsm/host/caps.py b/lib/vdsm/host/caps.py index c6ae827bc..87b87d5d3 100644 --- a/lib/vdsm/host/caps.py +++ b/lib/vdsm/host/caps.py @@ -175,6 +175,7 @@ def get(): caps['measure_active'] = True caps['mailbox_events'] = config.getboolean("mailbox", "events_enable") caps['zerocopy_migrations'] = hasattr(libvirt, 'VIR_MIGRATE_ZEROCOPY') + caps['qemu_image_info_bitmaps'] = True return caps diff --git a/lib/vdsm/storage/volume.py b/lib/vdsm/storage/volume.py index 066fc69eb..77e04817e 100644 --- a/lib/vdsm/storage/volume.py +++ b/lib/vdsm/storage/volume.py @@ -5,6 +5,7 @@ import os.path import logging +from collections import namedtuple from contextlib import contextmanager from vdsm import utils @@ -27,6 +28,8 @@ log = logging.getLogger('storage.volume') +Qcow2BitmapInfo = namedtuple("Qcow2BitmapInfo", "name, granularity, flags") + def getBackingVolumePath(imgUUID, volUUID): # We used to return a relative path ..// but this caused @@ -289,6 +292,13 @@ def getQemuImageInfo(self): result["backingfile"] = info["backing-filename"] if "format-specific" in info: result["compat"] = info["format-specific"]["data"]["compat"] + if "bitmaps" in info["format-specific"]["data"]: + result["bitmaps"] = [] + for bitmap in info["format-specific"]["data"]["bitmaps"]: + bitmapInfo = Qcow2BitmapInfo(bitmap["name"], + bitmap["granularity"], + bitmap["flags"]) + result["bitmaps"].append(bitmapInfo) return result