Skip to content

Commit

Permalink
Add bitmap info to getQemuImageInfo
Browse files Browse the repository at this point in the history
We add bitmap info the the getQemuImageInfo output so this can be used
within ovirt-engine.

Signed-off-by: Jean-Louis Dupond <[email protected]>
  • Loading branch information
dupondje committed Jun 12, 2023
1 parent 07d3089 commit 02b9fe8
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 0 deletions.
43 changes: 43 additions & 0 deletions lib/vdsm/api/vdsm-api.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -8131,6 +8171,9 @@ types:
- description: The compat version.
name: compat
type: *Qcow2Compat
- description: Volume bitmaps
name: bitmaps
type: *Qcow2Bitmaps
type: object

VolumeSizeInfo: &VolumeSizeInfo
Expand Down
1 change: 1 addition & 0 deletions lib/vdsm/host/caps.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
10 changes: 10 additions & 0 deletions lib/vdsm/storage/volume.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

import os.path
import logging
from collections import namedtuple
from contextlib import contextmanager

from vdsm import utils
Expand All @@ -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 ../<imgUUID>/<volUUID> but this caused
Expand Down Expand Up @@ -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

Expand Down

0 comments on commit 02b9fe8

Please sign in to comment.