[pve-devel] [RFC PATCH qemu-server 2/4] add the VM profiles plugin
Dominik Csapak
d.csapak at proxmox.com
Fri Nov 3 12:53:37 CET 2023
simply uses the json_config_properties for the vm config and maps them
to "vm_${opt}"
Signed-off-by: Dominik Csapak <d.csapak at proxmox.com>
---
PVE/Makefile | 1 +
PVE/Profiles/Makefile | 5 +++++
PVE/Profiles/VM.pm | 37 +++++++++++++++++++++++++++++++++++++
3 files changed, 43 insertions(+)
create mode 100644 PVE/Profiles/Makefile
create mode 100644 PVE/Profiles/VM.pm
diff --git a/PVE/Makefile b/PVE/Makefile
index dc173681..d09ca98d 100644
--- a/PVE/Makefile
+++ b/PVE/Makefile
@@ -12,3 +12,4 @@ install:
$(MAKE) -C API2 install
$(MAKE) -C CLI install
$(MAKE) -C QemuServer install
+ $(MAKE) -C Profiles install
diff --git a/PVE/Profiles/Makefile b/PVE/Profiles/Makefile
new file mode 100644
index 00000000..e5f56833
--- /dev/null
+++ b/PVE/Profiles/Makefile
@@ -0,0 +1,5 @@
+SOURCES=VM.pm
+
+.PHONY: install
+install: ${SOURCES}
+ for i in ${SOURCES}; do install -D -m 0644 $$i ${DESTDIR}${PERLDIR}/PVE/Profiles/$$i; done
diff --git a/PVE/Profiles/VM.pm b/PVE/Profiles/VM.pm
new file mode 100644
index 00000000..c7ff241a
--- /dev/null
+++ b/PVE/Profiles/VM.pm
@@ -0,0 +1,37 @@
+package PVE::Profiles::VM;
+
+use strict;
+use warnings;
+
+use PVE::Profiles::Plugin;
+use PVE::QemuServer;
+
+use base qw(PVE::Profiles::Plugin);
+
+my $type = "vm";
+
+sub type {
+ return $type;
+}
+
+sub properties {
+ my $props = PVE::QemuServer::json_config_properties();
+ for my $opt (keys $props->%*) {
+ my $newopt = "${type}_${opt}";
+ $props->{$newopt} = delete $props->{$opt};
+ }
+
+ return $props;
+}
+
+sub options {
+ my $props = PVE::QemuServer::json_config_properties();
+ my $opts = {};
+ for my $opt (keys $props->%*) {
+ my $newopt = "${type}_${opt}";
+ $opts->{$newopt} = { optional => 1 };
+ }
+ return $opts;
+}
+
+1;
--
2.30.2
More information about the pve-devel
mailing list