Skip to content

Conversation

@Lankou66
Copy link

@Lankou66 Lankou66 commented Nov 12, 2025

Implement recursive CBT deactivation for VDI snapshot chains

Add recursive CBT deactivation for VDI and all child snapshots Delete CBT log files when present
Update parent/child references in CBT metadata

Fixes: Incomplete CBT deactivation on snapshot chains

@Lankou66 Lankou66 force-pushed the allow_CBT_disabling_on_snapshot branch from 6642746 to fc458c8 Compare November 12, 2025 13:19
@stormi
Copy link
Member

stormi commented Nov 12, 2025

Here's a reminder regarding the commit message conventions. The commit title is largely over 70 chars, here :)

https://docs.xcp-ng.org/project/development-process/commit-message-conventions/

@Lankou66 Lankou66 force-pushed the allow_CBT_disabling_on_snapshot branch from fc458c8 to 315794d Compare November 12, 2025 15:39
@Lankou66 Lankou66 changed the title implement the capability to desactivate CBT on all vdi snapshot child… implement the capability to desactivate CBT on all vdi snapshot child Nov 12, 2025
@Lankou66 Lankou66 marked this pull request as ready for review November 13, 2025 09:57
@Wescoeur Wescoeur requested review from Nambrok and Wescoeur November 14, 2025 10:26
@Lankou66 Lankou66 force-pushed the allow_CBT_disabling_on_snapshot branch from 315794d to 2648b19 Compare November 17, 2025 10:10
drivers/VDI.py Outdated
return [
self.session.xenapi.VDI.get_uuid(ref)
for ref in record.get("snapshots", [])
if self.session.xenapi.VDI.get_uuid(ref)
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Two call for the XAPI is not optimal but also, this will raise if ref is not a correct OpaqueRef

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can also return the ref directly since you use it later

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i've removed the comprehension list
now we get ant return the list of rest directly

drivers/VDI.py Outdated
blktap2.VDI.tap_unpause(self.session, sr_uuid, vdi_uuid)

def _disable_cbt(self, vdi_uuid, visited=None):
# Prevent infite loop
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
# Prevent infite loop
# Prevent infinite loop

I don't think you need to do this, you should call for the VDI and then the same function doing the disable on the snapshots.
The snapshot won't have snapshots.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i removed it
indeed this protection was useless

@Lankou66 Lankou66 force-pushed the allow_CBT_disabling_on_snapshot branch from 2648b19 to 832aef0 Compare November 20, 2025 09:35
drivers/VDI.py Outdated
finally:
blktap2.VDI.tap_unpause(self.session, sr_uuid, vdi_uuid)

def _disable_cbt(self, vdi_uuid ):
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
def _disable_cbt(self, vdi_uuid ):
def _disable_cbt(self, vdi_uuid):

drivers/VDI.py Outdated
lock = Lock("cbtlog", str(vdi_uuid))
lock.acquire()
try:
self.uuid = vdi_uuid
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's not in the original code. You are in a VDI object refererring to a specific, modifying this parameter could have adverse effect later.

drivers/VDI.py Outdated
self.session.xenapi.VDI.set_cbt_enabled(vdi_ref, False)
for snapshot_ref in self._list_vdi_snapshots(self.uuid):
snapshot_uuid = self.session.xenapi.VDI.get_uuid(snapshot_ref)
self._disable_cbt(snapshot_uuid)
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you can do a function doing the above with just the ref and not the snapshot loop.
And call this once for the normal VDI then for the snapshot refs.
It might need to go deeper in self._cbt_op to know if they use info stored in self that are from the main VDI.

- Recursive CBT disabling on VDI all child snapshots
- Delete CBT log files when present

This resolves issues where CBT deactivation was incomplete
when processing multi-level snapshot chains.

Fixes: incomplete CBT deactivation on snapshot chains
Signed-off-by: Goulven Riou <[email protected]>
@Lankou66 Lankou66 force-pushed the allow_CBT_disabling_on_snapshot branch from 832aef0 to c9dcd5f Compare November 21, 2025 09:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants