all lists on lists.proxmox.com
 help / color / mirror / Atom feed
From: Matthias Heiserer <m.heiserer@proxmox.com>
To: pve-devel@lists.proxmox.com
Subject: [pve-devel] [RFC qemu-server 2/2] QEMU: add comment fields
Date: Mon, 14 Feb 2022 15:01:41 +0100	[thread overview]
Message-ID: <20220214140144.961041-5-m.heiserer@proxmox.com> (raw)
In-Reply-To: <20220214140144.961041-1-m.heiserer@proxmox.com>

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 `<name>_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 <m.heiserer@proxmox.com>
---
 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 =>  <<EODESCR,
+	format_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 =>  <<EODESCR,
 Create a serial device inside the VM (n is 0 to 3), and pass through a
 host serial device (i.e. /dev/ttyS0), or create a unix socket on the
 host side (use 'qm terminal' to open a terminal connection).
diff --git a/PVE/QemuServer/CPUConfig.pm b/PVE/QemuServer/CPUConfig.pm
index b9981c8..d83c1e9 100644
--- a/PVE/QemuServer/CPUConfig.pm
+++ b/PVE/QemuServer/CPUConfig.pm
@@ -5,7 +5,7 @@ use warnings;
 
 use PVE::JSONSchema;
 use PVE::Cluster qw(cfs_register_file cfs_read_file);
-use PVE::QemuServer::Helpers qw(min_version);
+use PVE::QemuServer::Helpers qw(min_version make_comment_fmt);
 
 use base qw(PVE::SectionConfig Exporter);
 
@@ -160,6 +160,7 @@ my $cpu_fmt = {
 		     . " doing so will break live migration to CPUs with other values.",
 	optional => 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





  parent reply	other threads:[~2022-02-14 14:02 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-02-14 14:01 [pve-devel] [RFC manager 0/5] GUI: Hardware comments Matthias Heiserer
2022-02-14 14:01 ` [pve-devel] [RFC manager 1/5] GUI: Parser: add comment support Matthias Heiserer
2022-02-14 14:01 ` [pve-devel] [RFC qemu-server 1/2] QEMU: add comment helper Matthias Heiserer
2022-02-14 14:01 ` [pve-devel] [RFC manager 2/5] GUI: Utils: add comment renderer and field provider Matthias Heiserer
2022-02-14 14:01 ` Matthias Heiserer [this message]
2022-02-14 14:01 ` [pve-devel] [RFC manager 3/5] GUI: QEMU Hardware: add comment column Matthias Heiserer
2022-02-14 14:01 ` [pve-devel] [RFC manager 4/5] GUI: QEMU Hardware: multikey support for comments Matthias Heiserer
2022-02-14 14:01 ` [pve-devel] [RFC manager 5/5] GUI: QEMU Hardware: add comment fields to rows Matthias Heiserer
2022-02-14 14:27 ` [pve-devel] [RFC manager 0/5] GUI: Hardware comments 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=20220214140144.961041-5-m.heiserer@proxmox.com \
    --to=m.heiserer@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.
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal