Skip to content

Expose disk lock granularity as a user-configurable option #7553

@vieux

Description

@vieux

Cloud Hypervisor recently merged PR #7494, which switches from whole-file OFD locks to byte-range advisory locks over the full disk size. This change improves compatibility with NetApp storage systems, where whole-file OFD locks are interpreted as mandatory but byte-range locks retain advisory semantics. The implementation also intentionally leaves room for a future configuration knob to select the lock granularity.

Different environments may prefer different lock semantics:

Default (byte-range) works best for storage backends like NetApp, matching QEMU behavior and maintaining advisory-lock semantics.

Whole-file locking might still be desirable for environments that rely on the traditional OFD whole-file lock behavior.

Some users may also want to disable advisory locking entirely or run in warn-only mode (supported today via lock=off|warn|on).

Right now Cloud Hypervisor internally uses byte-range locks for all disks, but users cannot opt back into the previous whole-file behavior if their infrastructure depends on it.

I'd introduce an optional per-disk parameter, for example:

--disk path=/foo.img,lock_granularity=byte-range
--disk path=/bar.img,lock_granularity=full

With the following semantics:

  • byte-range (default) Locks [0, size) via OFD byte-range locking.
  • full Uses the original whole-file OFD lock (l_start=0, l_len=0).

This would map cleanly to the existing LockGranularity enum introduced in PR #7494 and require only limited plumbing through the config layer down to virtio-devices.

Is that sounds good, I can work on the implementation.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions