[pve-devel] [PATCH qemu-server v2 14/25] move nbd_stop helper to QMPHelpers module

Fiona Ebner f.ebner at proxmox.com
Tue Aug 13 15:28:18 CEST 2024


Like this nbd_stop() can be called from a module that cannot include
QemuServer.pm.

Signed-off-by: Fiona Ebner <f.ebner at proxmox.com>
---

No changes in v2.

 PVE/API2/Qemu.pm             | 3 ++-
 PVE/CLI/qm.pm                | 3 ++-
 PVE/QemuServer.pm            | 6 ------
 PVE/QemuServer/QMPHelpers.pm | 6 ++++++
 4 files changed, 10 insertions(+), 8 deletions(-)

diff --git a/PVE/API2/Qemu.pm b/PVE/API2/Qemu.pm
index d25a79fe..212cfc1b 100644
--- a/PVE/API2/Qemu.pm
+++ b/PVE/API2/Qemu.pm
@@ -35,6 +35,7 @@ use PVE::QemuServer::Monitor qw(mon_cmd);
 use PVE::QemuServer::Machine;
 use PVE::QemuServer::Memory qw(get_current_memory);
 use PVE::QemuServer::PCI;
+use PVE::QemuServer::QMPHelpers;
 use PVE::QemuServer::USB;
 use PVE::QemuMigrate;
 use PVE::RPCEnvironment;
@@ -5910,7 +5911,7 @@ __PACKAGE__->register_method({
 		    return;
 		},
 		'nbdstop' => sub {
-		    PVE::QemuServer::nbd_stop($state->{vmid});
+		    PVE::QemuServer::QMPHelpers::nbd_stop($state->{vmid});
 		    return;
 		},
 		'resume' => sub {
diff --git a/PVE/CLI/qm.pm b/PVE/CLI/qm.pm
index d3dbf7b4..8349997e 100755
--- a/PVE/CLI/qm.pm
+++ b/PVE/CLI/qm.pm
@@ -35,6 +35,7 @@ use PVE::QemuServer::Agent qw(agent_available);
 use PVE::QemuServer::ImportDisk;
 use PVE::QemuServer::Monitor qw(mon_cmd);
 use PVE::QemuServer::OVF;
+use PVE::QemuServer::QMPHelpers;
 use PVE::QemuServer;
 
 use PVE::CLIHandler;
@@ -385,7 +386,7 @@ __PACKAGE__->register_method ({
 
 	my $vmid = $param->{vmid};
 
-	eval { PVE::QemuServer::nbd_stop($vmid) };
+	eval { PVE::QemuServer::QMPHelpers::nbd_stop($vmid) };
 	warn $@ if $@;
 
 	return;
diff --git a/PVE/QemuServer.pm b/PVE/QemuServer.pm
index b26da505..e5ff5efb 100644
--- a/PVE/QemuServer.pm
+++ b/PVE/QemuServer.pm
@@ -8548,12 +8548,6 @@ sub generate_smbios1_uuid {
     return "uuid=".generate_uuid();
 }
 
-sub nbd_stop {
-    my ($vmid) = @_;
-
-    mon_cmd($vmid, 'nbd-server-stop', timeout => 25);
-}
-
 sub create_reboot_request {
     my ($vmid) = @_;
     open(my $fh, '>', "/run/qemu-server/$vmid.reboot")
diff --git a/PVE/QemuServer/QMPHelpers.pm b/PVE/QemuServer/QMPHelpers.pm
index 0269ea46..826938de 100644
--- a/PVE/QemuServer/QMPHelpers.pm
+++ b/PVE/QemuServer/QMPHelpers.pm
@@ -15,6 +15,12 @@ qemu_objectadd
 qemu_objectdel
 );
 
+sub nbd_stop {
+    my ($vmid) = @_;
+
+    mon_cmd($vmid, 'nbd-server-stop', timeout => 25);
+}
+
 sub qemu_deviceadd {
     my ($vmid, $devicefull) = @_;
 
-- 
2.39.2





More information about the pve-devel mailing list