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

Alexandre Derumier aderumier at odiso.com
Wed Oct 26 10:24:00 CEST 2016


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 e513f33..a44204c 100755
--- a/PVE/CLI/qm.pm
+++ b/PVE/CLI/qm.pm
@@ -220,6 +220,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',
@@ -520,6 +542,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 07b19f7..0b9d664 100644
--- a/PVE/QemuServer.pm
+++ b/PVE/QemuServer.pm
@@ -6287,4 +6287,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