[pve-devel] [PATCH 5/8] add qm nbdstop

Alexandre Derumier aderumier at odiso.com
Tue Jan 3 15:03:16 CET 2017


we use it to stop remote nbd server

Signed-off-by: Alexandre Derumier <aderumier at odiso.com>
---
 PVE/CLI/qm.pm     | 24 ++++++++++++++++++++++++
 PVE/QemuServer.pm |  6 ++++++
 2 files changed, 30 insertions(+)

diff --git a/PVE/CLI/qm.pm b/PVE/CLI/qm.pm
index c13ff4c..4789ee1 100755
--- a/PVE/CLI/qm.pm
+++ b/PVE/CLI/qm.pm
@@ -221,6 +221,28 @@ __PACKAGE__->register_method ({
     }});
 
 __PACKAGE__->register_method ({
+    name => 'nbdstop',
+    path => 'nbdstop',
+    method => 'PUT',
+    description => "Stop embedded nbd server.",
+    parameters => {
+	additionalProperties => 0,
+	properties => {
+	    vmid => get_standard_option('pve-vmid', { completion => \&PVE::QemuServer::complete_vmid }),
+	},
+    },
+    returns => { type => 'null'},
+    code => sub {
+	my ($param) = @_;
+
+	my $vmid = $param->{vmid};
+
+	PVE::QemuServer::nbd_stop($vmid);
+
+	return undef;
+    }});
+
+__PACKAGE__->register_method ({
     name => 'mtunnel',
     path => 'mtunnel',
     method => 'POST',
@@ -558,6 +580,8 @@ our $cmddef = {
 
     mtunnel => [ __PACKAGE__, 'mtunnel', []],
 
+    nbdstop => [ __PACKAGE__, 'nbdstop', ['vmid']],
+
     terminal => [ __PACKAGE__, 'terminal', ['vmid']],
 };
 
diff --git a/PVE/QemuServer.pm b/PVE/QemuServer.pm
index e7071c0..a2acf0c 100644
--- a/PVE/QemuServer.pm
+++ b/PVE/QemuServer.pm
@@ -6370,4 +6370,10 @@ sub complete_storage {
     return $res;
 }
 
+sub nbd_stop {
+    my ($vmid) = @_;
+
+    vm_mon_cmd($vmid, 'nbd-server-stop');
+}
+
 1;
-- 
2.1.4




More information about the pve-devel mailing list