[PATCH qemu-server 05/10] qmphelpers: add qmp_deviceadd && qmp_devicedel

Alexandre Derumier alexandre.derumier at groupe-cyllene.com
Wed Jul 2 16:48:55 CEST 2025


old hmp methos can be removed when everything will be
converted to hash/json

Signed-off-by: Alexandre Derumier <alexandre.derumier at groupe-cyllene.com>
---
 src/PVE/QemuServer/QMPHelpers.pm | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)

diff --git a/src/PVE/QemuServer/QMPHelpers.pm b/src/PVE/QemuServer/QMPHelpers.pm
index c3be2b8e..327ecec4 100644
--- a/src/PVE/QemuServer/QMPHelpers.pm
+++ b/src/PVE/QemuServer/QMPHelpers.pm
@@ -9,6 +9,8 @@ use PVE::QemuServer::Monitor qw(mon_cmd);
 use base 'Exporter';
 
 our @EXPORT_OK = qw(
+    qmp_deviceadd
+    qmp_devicedel
     qemu_deviceadd
     qemu_devicedel
     qemu_objectadd
@@ -35,6 +37,20 @@ sub qemu_devicedel {
     PVE::QemuServer::Monitor::hmp_cmd($vmid, "device_del $deviceid", 25);
 }
 
+sub qmp_deviceadd {
+    my ($vmid, $opts) = @_;
+
+    $opts->{timeout} = 25;
+    mon_cmd($vmid, "device_add", %$opts);
+}
+
+sub qmp_devicedel {
+    my ($vmid, $deviceid) = @_;
+
+    my $opts = { id => $deviceid, timeout => 25 };
+    mon_cmd($vmid, "device_del", %$opts);
+}
+
 sub qemu_objectadd {
     my ($vmid, $objectid, $qomtype) = @_;
 
-- 
2.39.5




More information about the pve-devel mailing list