Am 12.03.26 um 9:40 AM schrieb Arthur Bied-Charreton:
> Add GET handlers for both all custom CPU models and specific ones, POST
> handler for creating custom CPU models, PUT handler for updating them,
> and DELETE handler for deleting them.
>
> Original patches:
> https://lore.proxmox.com/pve-devel/[email protected]/
> https://lore.proxmox.com/pve-devel/[email protected]/
>
> Originally-by: Stefan Reiter <[email protected]>
> Signed-off-by: Arthur Bied-Charreton <[email protected]>
> ---
> src/PVE/API2/Qemu/CPU.pm | 236 ++++++++++++++++++++++++++++++++++++++-
> 1 file changed, 235 insertions(+), 1 deletion(-)
>
> diff --git a/src/PVE/API2/Qemu/CPU.pm b/src/PVE/API2/Qemu/CPU.pm
> index f8a7e11d..9d89504d 100644
> --- a/src/PVE/API2/Qemu/CPU.pm
> +++ b/src/PVE/API2/Qemu/CPU.pm
> @@ -52,7 +52,7 @@ __PACKAGE__->register_method({
> },
> },
> },
> - links => [{ rel => 'child', href => '{name}' }],
> + links => [{ rel => 'child', href => 'model/{cputype}' }],
Pre-existing issues from the original series:
This does not work in pvesh, because the extract_children() function
there only matches:
if ($href =~ m/^\{(\S+)\}$/) {
Also, it's called 'name' in the returned result, not 'cputype'.
But this is the wrong place for a link to begin with, since we only want
to provide the link for custom models, it should be added to the 'model'
endpoint. There, it is called 'cputype' ;)
Having the 'model' endpoint below here seems wrong to me, for two reasons:
1. Since the 'cpu' endpoint already returns a result other than an index
of sub-endpoints, it cannot at the same time show in its result that the
sub-endpoint exists, and this breaks the directory structure.
2. It's below /nodes/ but it's touching cluster-wide configuration.
I think we should just have a new, dedicated endpoint, maybe
/cluster/qemu/custom-cpu-models? And then, we might want to drop the
need for specifying a 'custom-' prefix when using the calls?