[pve-devel] [RFC storage 00/26+10+3] unify vtype and content-type and

Wolfgang Bumiller
2025-07-29T11:16:36Z

This series is a first attempt at updating the storage API so that
- vtype == content type
- VM volumes have type "vm-vol"
- Container volumes have type "ct-vol"
- "images" is a generic "legacy" term which means "unknown OR vm-vol or
ct-vol"
- remaining openvz-related 'rootdir' parts are removed
- rootdir is now intended to mean "unknown or ct-vol"

There are several reasons for adding 2 new types, rather than making the
old ones more strict:
- The "rootdir" vs "images" distinction in `list_volumes` only happened
if our code to check the actually existing guest type was used. This
could not be enforced for external storage plugins and is a weird and
surprising API quirk.
- The "rootdir" *vtype* was otherwise *never* used as it referred to old
openvz 'private/' subdirectories.
- The container code allocated "images", not "rootdirs".
- Since containers were allocated as type "images", the `content-dir`
option for "rootdir" never had any effect. (You can now set
content-dirs for types 'vm-vol' and 'ct-vol' which will be honored for
any new disks allocated from the update pve-container and qemu-server
code.)

API Notes:
- vtype parameters are added to several API methods - but they are
optional
- list_images now also includes a `vtype` in its return value, but
only if it is NOT `images` (so legacy volumes are returned unchanged
via the API).
- old plugins should still function as they did previously but keep
using the legacy "images" vtype/content-type

Storage notes:

Storages now need to be able to tell vm/ct volumes apart from
"images", for which this not only introduced separate directories, but
also adapts the volume id naming scheme. In order to *somewhat* void
running into rogue `/^vm-/` regexes affecting new style volumes, the
new prefixes are the reverse of the type names: `vol-vm-` and
`vol-ct-`. For base images, the entire name is prefixed with `base-`
instead of, like previously, doing `s/vm-/base-/`.

Patch notes:

Initially I did the vtype separately from the content type, but the
series became a bit of a back & forth. This version is mostly split by
functionality as it seemed nicer for reviews and might sort of work
for external plugin writers as a guide. Therefore patches add vtype
parameters without adapting all the callers. (This *should* mostly be
fine since they are optional, though...) And Tests are only changed as
a whole at the end.

For qemu-server, most of the tests were updated via `sed`.