From: Arthur Bied-Charreton <a.bied-charreton@proxmox.com>
To: pve-devel@lists.proxmox.com
Subject: [PATCH pve-manager 1/3] custom cpu models: make 'reported-model' required in POST
Date: Tue, 19 May 2026 16:06:21 +0200 [thread overview]
Message-ID: <20260519140623.594472-2-a.bied-charreton@proxmox.com> (raw)
In-Reply-To: <20260519140623.594472-1-a.bied-charreton@proxmox.com>
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
next prev parent reply other threads:[~2026-05-19 14:06 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
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 [this message]
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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260519140623.594472-2-a.bied-charreton@proxmox.com \
--to=a.bied-charreton@proxmox.com \
--cc=pve-devel@lists.proxmox.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.