From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from firstgate.proxmox.com (firstgate.proxmox.com [212.224.123.68]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by lists.proxmox.com (Postfix) with ESMTPS id EA1A263386 for ; Mon, 14 Feb 2022 15:02:39 +0100 (CET) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id DF411234ED for ; Mon, 14 Feb 2022 15:02:09 +0100 (CET) Received: from proxmox-new.maurer-it.com (proxmox-new.maurer-it.com [94.136.29.106]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by firstgate.proxmox.com (Proxmox) with ESMTPS id 2CF1823331 for ; Mon, 14 Feb 2022 15:02:04 +0100 (CET) Received: from proxmox-new.maurer-it.com (localhost.localdomain [127.0.0.1]) by proxmox-new.maurer-it.com (Proxmox) with ESMTP id F1111418DF for ; Mon, 14 Feb 2022 15:02:03 +0100 (CET) From: Matthias Heiserer To: pve-devel@lists.proxmox.com Date: Mon, 14 Feb 2022 15:01:41 +0100 Message-Id: <20220214140144.961041-5-m.heiserer@proxmox.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220214140144.961041-1-m.heiserer@proxmox.com> References: <20220214140144.961041-1-m.heiserer@proxmox.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SPAM-LEVEL: Spam detection results: 0 AWL 0.003 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record T_SCC_BODY_TEXT_LINE -0.01 - Subject: [pve-devel] [RFC qemu-server 2/2] QEMU: add comment fields X-BeenThere: pve-devel@lists.proxmox.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Proxmox VE development discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 14 Feb 2022 14:02:40 -0000 This patch adds comment fields to all values shown in the QEMU/Hardware GUI. As I tried to keep changes minimal, this is achieved in two different ways: - adding `comment` as field. Easiest/simplest option, but not always possible, when data is stored as a single int (e.g memory). Although the UI stores the data as a URIComponent-encoded string, this is not yet checked in the perl code. - adding a separate `_comment` field. Not that great, but it works. One advantage of this is that we don't have to encode/decode the data, but many new fields bloat the config. Changing this seems to require some more rewriting. Signed-off-by: Matthias Heiserer --- PVE/QemuServer.pm | 49 ++++++++++++++++++++++++++++++++++--- PVE/QemuServer/CPUConfig.pm | 7 ++++-- PVE/QemuServer/Drive.pm | 6 ++++- PVE/QemuServer/PCI.pm | 4 ++- 4 files changed, 58 insertions(+), 8 deletions(-) diff --git a/PVE/QemuServer.pm b/PVE/QemuServer.pm index 0071a06..3b2abfe 100644 --- a/PVE/QemuServer.pm +++ b/PVE/QemuServer.pm @@ -44,7 +44,7 @@ use PVE::Tools qw(run_command file_read_firstline file_get_contents dir_glob_for use PVE::QMPClient; use PVE::QemuConfig; -use PVE::QemuServer::Helpers qw(min_version config_aware_timeout); +use PVE::QemuServer::Helpers qw(min_version config_aware_timeout make_comment_fmt); use PVE::QemuServer::Cloudinit; use PVE::QemuServer::CGroup; use PVE::QemuServer::CPUConfig qw(print_cpu_device get_cpu_options); @@ -205,6 +205,7 @@ my $vga_fmt = { minimum => 4, maximum => 512, }, + comment => make_comment_fmt(), }; my $ivshmem_fmt = { @@ -235,6 +236,7 @@ my $audio_fmt = { optional => 1, description => "Driver backend for the audio device." }, + comment => make_comment_fmt(), }; my $spice_enhancements_fmt = { @@ -284,6 +286,7 @@ my $rng_fmt = { optional => 1, default => 1000, }, + comment => make_comment_fmt(), }; my $meta_info_fmt = { @@ -728,6 +731,31 @@ EODESCR description => "Some (read-only) meta-information about this guest.", optional => 1, }, + sockets_comment => { + type => 'string', + optional => 1, + description => 'Comment on cpu', + }, + memory_comment => { + type => 'string', + optional => 1, + description => 'Comment on memory', + }, + bios_comment => { + type => 'string', + optional => 1, + description => 'Comment on bios', + }, + machine_comment => { + type => 'string', + optional => 1, + description => 'Comment on machine', + }, + scsihw_comment => { + type => 'string', + optional => 1, + description => 'Comment on SCSI controller', + }, }; my $cicustom_fmt = { @@ -977,6 +1005,7 @@ my $net_fmt = { description => "Force MTU, for VirtIO only. Set to '1' to use the bridge MTU", optional => 1, }, + comment => make_comment_fmt(), }; my $netdesc = { @@ -1093,6 +1122,7 @@ EODESCR description => "Specifies whether if given host option is a USB3 device or port.", default => 0, }, + comment => make_comment_fmt(), }; my $usbdesc = { @@ -1102,12 +1132,23 @@ my $usbdesc = { }; PVE::JSONSchema::register_standard_option("pve-qm-usb", $usbdesc); -my $serialdesc = { +my $serial_fmt = { + serial => { + default_key => 1, optional => 1, type => 'string', pattern => '(/dev/.+|socket)', - description => "Create a serial device inside the VM (n is 0 to 3)", - verbose_description => < '(/dev/.+|socket)', + }, + comment => make_comment_fmt(), +}; + +my $serialdesc = { + optional => 1, + type => 'string', + format => $serial_fmt, + description => "Create a serial device inside the VM (n is 0 to 3)", + verbose_description => < 1, }, + comment => make_comment_fmt(), }; PVE::JSONSchema::register_format('pve-phys-bits', \&parse_phys_bits); @@ -368,7 +369,9 @@ sub print_cpu_device { my $current_core = ($id - 1) % $cores; my $current_socket = int(($id - 1 - $current_core)/$cores); - return "$cpu-x86_64-cpu,id=cpu$id,socket-id=$current_socket,core-id=$current_core,thread-id=0"; + my $comment = $conf->{comment} || ''; + + return "$cpu-x86_64-cpu,id=cpu$id,socket-id=$current_socket,core-id=$current_core,thread-id=0,comment=$comment"; } # Resolves multiple arrays of hashes representing CPU flags with metadata to a diff --git a/PVE/QemuServer/Drive.pm b/PVE/QemuServer/Drive.pm index 7b82fb2..708d95e 100644 --- a/PVE/QemuServer/Drive.pm +++ b/PVE/QemuServer/Drive.pm @@ -5,6 +5,7 @@ use warnings; use PVE::Storage; use PVE::JSONSchema qw(get_standard_option); +use PVE::QemuServer::Helpers qw(make_comment_fmt); use base qw(Exporter); @@ -146,7 +147,8 @@ my %drivedesc_base = ( verbose_description => "Mark this locally-managed volume as available on all nodes.\n\nWARNING: This option does not share the volume automatically, it assumes it is shared already!", optional => 1, default => 0, - } + }, + comment => make_comment_fmt(), ); my %iothread_fmt = ( iothread => { @@ -353,6 +355,7 @@ my $efidisk_fmt = { description => "Disk size. This is purely informational and has no effect.", optional => 1, }, + comment => make_comment_fmt(), %efitype_fmt, }; @@ -393,6 +396,7 @@ my $tpmstate_fmt = { optional => 1, }, %tpmversion_fmt, + comment => make_comment_fmt(), }; my $tpmstate_desc = { optional => 1, diff --git a/PVE/QemuServer/PCI.pm b/PVE/QemuServer/PCI.pm index 70987d8..a961bda 100644 --- a/PVE/QemuServer/PCI.pm +++ b/PVE/QemuServer/PCI.pm @@ -6,6 +6,7 @@ use strict; use PVE::JSONSchema; use PVE::SysFSTools; use PVE::Tools; +use PVE::QemuServer::Helpers qw(make_comment_fmt); use base 'Exporter'; @@ -105,7 +106,8 @@ EODESCR format_description => 'hex id', optional => 1, description => "Override PCI subsystem device ID visible to guest" - } + }, + comment => make_comment_fmt(), }; PVE::JSONSchema::register_format('pve-qm-hostpci', $hostpci_fmt); -- 2.30.2