public inbox for pve-devel@lists.proxmox.com
 help / color / mirror / Atom feed
* [PATCH manager/qemu-server 0/3] custom cpu models: tighten reported-model handling
@ 2026-05-19 14:06 Arthur Bied-Charreton
  2026-05-19 14:06 ` [PATCH pve-manager 1/3] custom cpu models: make 'reported-model' required in POST Arthur Bied-Charreton
                   ` (5 more replies)
  0 siblings, 6 replies; 7+ messages in thread
From: Arthur Bied-Charreton @ 2026-05-19 14:06 UTC (permalink / raw)
  To: pve-devel

The default reported-model for custom CPU models is kvm64, a legacy
model with a limited set of features.

This series tightens the handling around reported-model:

1. Require reported-model on creation via the API, as the UI already
   does
2. Prevent deletion of reported-model via PUT
3. Resolve and write out the default explicitly on config writes

This will be useful in case we ever want to make reported-model
required in a future major release.


pve-manager:

Arthur Bied-Charreton (2):
  custom cpu models: make 'reported-model' required in POST
  custom cpu models: do not allow deleting 'reported-model'

 PVE/API2/Cluster/Qemu/CustomCPUModels.pm |  5 +++++
 test/CustomCPUModels_test.pl             | 19 +++++++++++++------
 2 files changed, 18 insertions(+), 6 deletions(-)


qemu-server:

Arthur Bied-Charreton (1):
  cpu config: resolve default reported-model on write

 src/PVE/QemuServer/CPUConfig.pm | 2 ++
 1 file changed, 2 insertions(+)


Summary over all repositories:
  3 files changed, 20 insertions(+), 6 deletions(-)

-- 
Generated by murpp 0.11.0



^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH pve-manager 1/3] custom cpu models: make 'reported-model' required in POST
  2026-05-19 14:06 [PATCH manager/qemu-server 0/3] custom cpu models: tighten reported-model handling Arthur Bied-Charreton
@ 2026-05-19 14:06 ` Arthur Bied-Charreton
  2026-05-19 14:06 ` [PATCH pve-manager 2/3] custom cpu models: do not allow deleting 'reported-model' Arthur Bied-Charreton
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: Arthur Bied-Charreton @ 2026-05-19 14:06 UTC (permalink / raw)
  To: pve-devel

The default reported-model is kvm64, which is a legacy CPU model with a
very limited feature set that one should not really be using in
practice.

The UI already requires the reported-model, so this just brings the API
in line.

Signed-off-by: Arthur Bied-Charreton <a.bied-charreton@proxmox.com>
Suggested-by: Fiona Ebner <f.ebner@proxmox.com>
---
 PVE/API2/Cluster/Qemu/CustomCPUModels.pm |  4 ++++
 test/CustomCPUModels_test.pl             | 19 +++++++++++++------
 2 files changed, 17 insertions(+), 6 deletions(-)

diff --git a/PVE/API2/Cluster/Qemu/CustomCPUModels.pm b/PVE/API2/Cluster/Qemu/CustomCPUModels.pm
index 8628f20c..4ba04180 100644
--- a/PVE/API2/Cluster/Qemu/CustomCPUModels.pm
+++ b/PVE/API2/Cluster/Qemu/CustomCPUModels.pm
@@ -19,6 +19,9 @@ my $cputype_param = {
     description => "Name for the custom CPU model. The 'custom-' prefix is optional.",
 };
 
+my $reported_model_param =
+    { get_standard_option('pve-qm-custom-cpu-model')->{'reported-model'}->%*, optional => 0 };
+
 # privileges that grant any kind of visibility on a custom CPU model
 my $can_see_mapping_privs = ['Mapping.Modify', 'Mapping.Use', 'Mapping.Audit'];
 
@@ -77,6 +80,7 @@ __PACKAGE__->register_method({
         additionalProperties => 0,
         properties => PVE::QemuServer::CPUConfig::add_cpu_json_properties({
             cputype => $cputype_param,
+            'reported-model' => $reported_model_param,
         }),
     },
     returns => { type => 'null' },
diff --git a/test/CustomCPUModels_test.pl b/test/CustomCPUModels_test.pl
index b416b684..5511dbb7 100755
--- a/test/CustomCPUModels_test.pl
+++ b/test/CustomCPUModels_test.pl
@@ -49,27 +49,34 @@ like(
     'POST without cputype rejected by schema',
 );
 
+eval { validate_params('POST', '', { cputype => 'name' }) };
+like(
+    $@,
+    qr/reported-model.*(?:missing|required|not optional)/i,
+    'POST without reported-model rejected by schema',
+);
+
 # --- create: cputype must be a valid pve-configid (A1) ---
-eval { validate_params('POST', '', { cputype => '4foo' }) };
+eval { validate_params('POST', '', { cputype => '4foo', 'reported-model' => 'qemu64' }) };
 like(
     $@, qr/format/i, 'POST with cputype starting with digit rejected by schema',
 );
 
-eval { validate_params('POST', '', { cputype => 'bad name' }) };
+eval { validate_params('POST', '', { cputype => 'bad name', 'reported-model' => 'qemu64' }) };
 like(
     $@, qr/format/i, 'POST with whitespace in cputype rejected by schema',
 );
 
-eval { validate_params('POST', '', { cputype => 'a' x 50 }) };
+eval { validate_params('POST', '', { cputype => 'a' x 50, 'reported-model' => 'qemu64' }) };
 like(
     $@, qr/40 characters|maxLength|too long/i, 'POST with overly long cputype rejected by schema',
 );
 
 # Valid cputype with optional 'custom-' prefix passes the schema.
-eval { validate_params('POST', '', { cputype => 'custom-foo' }) };
+eval { validate_params('POST', '', { cputype => 'custom-foo', 'reported-model' => 'qemu64' }) };
 is($@, '', 'POST with valid prefixed cputype accepted by schema');
 
-eval { validate_params('POST', '', { cputype => 'my_model' }) };
+eval { validate_params('POST', '', { cputype => 'my_model', 'reported-model' => 'qemu64' }) };
 is($@, '', 'POST with valid unprefixed cputype accepted by schema');
 
 # --- create: empty name after stripping 'custom-' is rejected by runtime check (A1) ---
@@ -81,7 +88,7 @@ is($@, '', 'POST with valid unprefixed cputype accepted by schema');
     $config_mock->mock(
         lock_custom_cpu_model_config => sub { fail('lock reached for empty stripped name'); },
     );
-    eval { invoke_method('POST', '', { cputype => 'custom-' }) };
+    eval { invoke_method('POST', '', { cputype => 'custom-', 'reported-model' => 'qemu64' }) };
     like($@, qr/configid|invalid/i, 'POST with cputype "custom-" rejected after stripping');
 }
 
-- 
2.47.3




^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH pve-manager 2/3] custom cpu models: do not allow deleting 'reported-model'
  2026-05-19 14:06 [PATCH manager/qemu-server 0/3] custom cpu models: tighten reported-model handling Arthur Bied-Charreton
  2026-05-19 14:06 ` [PATCH pve-manager 1/3] custom cpu models: make 'reported-model' required in POST Arthur Bied-Charreton
@ 2026-05-19 14:06 ` Arthur Bied-Charreton
  2026-05-19 14:06 ` [PATCH qemu-server 3/3] cpu config: resolve default reported-model on write Arthur Bied-Charreton
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: Arthur Bied-Charreton @ 2026-05-19 14:06 UTC (permalink / raw)
  To: pve-devel

Now that reported-model is required on creation, prevent it from being
removed via the delete parameter on PUT.

Signed-off-by: Arthur Bied-Charreton <a.bied-charreton@proxmox.com>
Suggested-by: Fiona Ebner <f.ebner@proxmox.com>
---
 PVE/API2/Cluster/Qemu/CustomCPUModels.pm | 1 +
 1 file changed, 1 insertion(+)

diff --git a/PVE/API2/Cluster/Qemu/CustomCPUModels.pm b/PVE/API2/Cluster/Qemu/CustomCPUModels.pm
index 4ba04180..fdeb2ce3 100644
--- a/PVE/API2/Cluster/Qemu/CustomCPUModels.pm
+++ b/PVE/API2/Cluster/Qemu/CustomCPUModels.pm
@@ -173,6 +173,7 @@ __PACKAGE__->register_method({
         if ($delete) {
             $delete = [PVE::Tools::split_list($delete)];
             die "cannot delete 'cputype'\n" if grep { $_ eq 'cputype' } @$delete;
+            die "cannot delete 'reported-model'\n" if grep { $_ eq 'reported-model' } @$delete;
         }
 
         (my $name = $param->{cputype}) =~ s/^custom-//;
-- 
2.47.3




^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH qemu-server 3/3] cpu config: resolve default reported-model on write
  2026-05-19 14:06 [PATCH manager/qemu-server 0/3] custom cpu models: tighten reported-model handling Arthur Bied-Charreton
  2026-05-19 14:06 ` [PATCH pve-manager 1/3] custom cpu models: make 'reported-model' required in POST Arthur Bied-Charreton
  2026-05-19 14:06 ` [PATCH pve-manager 2/3] custom cpu models: do not allow deleting 'reported-model' Arthur Bied-Charreton
@ 2026-05-19 14:06 ` Arthur Bied-Charreton
  2026-05-19 14:50 ` [PATCH manager/qemu-server 0/3] custom cpu models: tighten reported-model handling Fiona Ebner
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: Arthur Bied-Charreton @ 2026-05-19 14:06 UTC (permalink / raw)
  To: pve-devel

When writing the custom CPU model config, fill in the default
reported-model (kvm64) explicitly if not defined.

This makes the default visible in the config file and prepares for
potentially making the field required in a future major release.

Signed-off-by: Arthur Bied-Charreton <a.bied-charreton@proxmox.com>
Suggested-by: Fiona Ebner <f.ebner@proxmox.com>
---
 src/PVE/QemuServer/CPUConfig.pm | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/src/PVE/QemuServer/CPUConfig.pm b/src/PVE/QemuServer/CPUConfig.pm
index c8b54ec2..9be145ef 100644
--- a/src/PVE/QemuServer/CPUConfig.pm
+++ b/src/PVE/QemuServer/CPUConfig.pm
@@ -554,6 +554,8 @@ sub write_config($class, $filename, $cfg) {
                 . " $model_conf->{cputype}) not equal to \$cfg->ids entry ($model)\n";
         }
 
+        $model_conf->{'reported-model'} //= $cpu_fmt->{'reported-model'}->{default};
+
         # saved in section header
         delete $model_conf->{cputype};
     }
-- 
2.47.3




^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [PATCH manager/qemu-server 0/3] custom cpu models: tighten reported-model handling
  2026-05-19 14:06 [PATCH manager/qemu-server 0/3] custom cpu models: tighten reported-model handling Arthur Bied-Charreton
                   ` (2 preceding siblings ...)
  2026-05-19 14:06 ` [PATCH qemu-server 3/3] cpu config: resolve default reported-model on write Arthur Bied-Charreton
@ 2026-05-19 14:50 ` Fiona Ebner
  2026-05-19 19:17 ` applied: " Thomas Lamprecht
  2026-05-19 20:17 ` Thomas Lamprecht
  5 siblings, 0 replies; 7+ messages in thread
From: Fiona Ebner @ 2026-05-19 14:50 UTC (permalink / raw)
  To: Arthur Bied-Charreton, pve-devel

Am 19.05.26 um 4:06 PM schrieb Arthur Bied-Charreton:
> The default reported-model for custom CPU models is kvm64, a legacy
> model with a limited set of features.
> 
> This series tightens the handling around reported-model:
> 
> 1. Require reported-model on creation via the API, as the UI already
>    does
> 2. Prevent deletion of reported-model via PUT
> 3. Resolve and write out the default explicitly on config writes
> 
> This will be useful in case we ever want to make reported-model
> required in a future major release.

Nit: the Suggested-by trailer should come before the Signed-off-by to
keep the chronological order.

Regarding patch 1: it is a breaking change, but the feature has only
been on no-subscription for a few days and I suspect most people would
use the UI or specify an explicit model anyways.

Reviewed-by: Fiona Ebner <f.ebner@proxmox.com>
Tested-by: Fiona Ebner <f.ebner@proxmox.com>




^ permalink raw reply	[flat|nested] 7+ messages in thread

* applied: [PATCH manager/qemu-server 0/3] custom cpu models: tighten reported-model handling
  2026-05-19 14:06 [PATCH manager/qemu-server 0/3] custom cpu models: tighten reported-model handling Arthur Bied-Charreton
                   ` (3 preceding siblings ...)
  2026-05-19 14:50 ` [PATCH manager/qemu-server 0/3] custom cpu models: tighten reported-model handling Fiona Ebner
@ 2026-05-19 19:17 ` Thomas Lamprecht
  2026-05-19 20:17 ` Thomas Lamprecht
  5 siblings, 0 replies; 7+ messages in thread
From: Thomas Lamprecht @ 2026-05-19 19:17 UTC (permalink / raw)
  To: pve-devel, Arthur Bied-Charreton

On Tue, 19 May 2026 16:06:20 +0200, Arthur Bied-Charreton wrote:
> The default reported-model for custom CPU models is kvm64, a legacy
> model with a limited set of features.
> 
> This series tightens the handling around reported-model:
> 
> 1. Require reported-model on creation via the API, as the UI already
>    does
> 2. Prevent deletion of reported-model via PUT
> 3. Resolve and write out the default explicitly on config writes
> 
> [...]

Applied, thanks!

[1/2] custom cpu models: make 'reported-model' required in POST
      commit: 013e8d4158310b4d378fa660791d0dbe95da84c0
[2/2] custom cpu models: do not allow deleting 'reported-model'
      commit: df53f47110268ee92011696bc7473bc5c79de373




^ permalink raw reply	[flat|nested] 7+ messages in thread

* applied: [PATCH manager/qemu-server 0/3] custom cpu models: tighten reported-model handling
  2026-05-19 14:06 [PATCH manager/qemu-server 0/3] custom cpu models: tighten reported-model handling Arthur Bied-Charreton
                   ` (4 preceding siblings ...)
  2026-05-19 19:17 ` applied: " Thomas Lamprecht
@ 2026-05-19 20:17 ` Thomas Lamprecht
  5 siblings, 0 replies; 7+ messages in thread
From: Thomas Lamprecht @ 2026-05-19 20:17 UTC (permalink / raw)
  To: pve-devel, Arthur Bied-Charreton

On Tue, 19 May 2026 16:06:20 +0200, Arthur Bied-Charreton wrote:
> The default reported-model for custom CPU models is kvm64, a legacy
> model with a limited set of features.
> 
> This series tightens the handling around reported-model:
> 
> 1. Require reported-model on creation via the API, as the UI already
>    does
> 2. Prevent deletion of reported-model via PUT
> 3. Resolve and write out the default explicitly on config writes
> 
> [...]

Applied, thanks!

[1/1] cpu config: resolve default reported-model on write
      commit: b1ce2b4e17fe5d2c315fe8cfa0469abc01eccf46




^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2026-05-19 20:18 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-05-19 14:06 [PATCH manager/qemu-server 0/3] custom cpu models: tighten reported-model handling Arthur Bied-Charreton
2026-05-19 14:06 ` [PATCH pve-manager 1/3] custom cpu models: make 'reported-model' required in POST Arthur Bied-Charreton
2026-05-19 14:06 ` [PATCH pve-manager 2/3] custom cpu models: do not allow deleting 'reported-model' Arthur Bied-Charreton
2026-05-19 14:06 ` [PATCH qemu-server 3/3] cpu config: resolve default reported-model on write Arthur Bied-Charreton
2026-05-19 14:50 ` [PATCH manager/qemu-server 0/3] custom cpu models: tighten reported-model handling Fiona Ebner
2026-05-19 19:17 ` applied: " Thomas Lamprecht
2026-05-19 20:17 ` Thomas Lamprecht

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal