[pve-devel] [PATCH qemu-server 2/7] qm: add nextvmid

Alexandre Derumier aderumier at odiso.com
Mon Oct 29 16:38:47 CET 2018


return the next vmid free
---
 PVE/API2/Qemu.pm |  1 -
 PVE/CLI/qm.pm    | 19 +++++++++++++++++++
 2 files changed, 19 insertions(+), 1 deletion(-)

diff --git a/PVE/API2/Qemu.pm b/PVE/API2/Qemu.pm
index 64eaa0e..ac8b907 100644
--- a/PVE/API2/Qemu.pm
+++ b/PVE/API2/Qemu.pm
@@ -389,7 +389,6 @@ __PACKAGE__->register_method({
     }});
 
 
-
 __PACKAGE__->register_method({
     name => 'create_vm',
     path => '',
diff --git a/PVE/CLI/qm.pm b/PVE/CLI/qm.pm
index 46a7e2f..b1f146d 100755
--- a/PVE/CLI/qm.pm
+++ b/PVE/CLI/qm.pm
@@ -144,6 +144,23 @@ __PACKAGE__->register_method ({
     }});
 
 __PACKAGE__->register_method ({
+    name => 'nextvmid',
+    path => 'nextvmid',
+    method => 'GET',
+    description => "Return next free vmid.",
+    parameters => {
+	additionalProperties => 0,
+    },
+    returns => { type => 'null'},
+    code => sub {
+	my ($param) = @_;
+
+	my $nextvmid = PVE::Cluster::complete_next_vmid;
+	print $nextvmid->[0];
+	return undef;
+    }});
+
+__PACKAGE__->register_method ({
     name => 'status',
     path => 'status',
     method => 'GET',
@@ -896,6 +913,8 @@ our $cmddef = {
 
     mtunnel => [ __PACKAGE__, 'mtunnel', []],
 
+    nextvmid => [ __PACKAGE__, 'nextvmid', []],
+
     nbdstop => [ __PACKAGE__, 'nbdstop', ['vmid']],
 
     terminal => [ __PACKAGE__, 'terminal', ['vmid']],
-- 
2.11.0




More information about the pve-devel mailing list