[pve-devel] [PATCH qemu-server 3/4] use qmeventd to execute qm cleanup

Dominik Csapak d.csapak at proxmox.com
Tue Oct 16 12:07:05 CEST 2018


we add a second qmp socket/monitor to vms with qemu >= 3.0 (because
of live migration) and execute qmeventd to monitor it

Signed-off-by: Dominik Csapak <d.csapak at proxmox.com>
---
 PVE/QemuServer.pm | 17 +++++++++++++++--
 1 file changed, 15 insertions(+), 2 deletions(-)

diff --git a/PVE/QemuServer.pm b/PVE/QemuServer.pm
index 541d7b0..4838e79 100644
--- a/PVE/QemuServer.pm
+++ b/PVE/QemuServer.pm
@@ -3200,6 +3200,11 @@ sub config_to_command {
     push @$cmd, '-chardev', "socket,id=qmp,path=$qmpsocket,server,nowait";
     push @$cmd, '-mon', "chardev=qmp,mode=control";
 
+    if (qemu_machine_feature_enabled ($machine_type, $kvmver, 3, 0)) {
+	my $eventsocket = qmp_socket($vmid, 0, 'event');
+	push @$cmd, '-chardev', "socket,id=qmp-event,path=$eventsocket,server,nowait";
+	push @$cmd, '-mon', "chardev=qmp-event,mode=control";
+    }
 
     push @$cmd, '-pidfile' , pidfile_name($vmid);
 
@@ -3690,9 +3695,10 @@ sub spice_port {
 }
 
 sub qmp_socket {
-    my ($vmid, $qga) = @_;
+    my ($vmid, $qga, $name) = @_;
     my $sockettype = $qga ? 'qga' : 'qmp';
-    return "${var_run_tmpdir}/$vmid.$sockettype";
+    my $ext = $name ? '-'.$name : '';
+    return "${var_run_tmpdir}/$vmid$ext.$sockettype";
 }
 
 sub pidfile_name {
@@ -5050,6 +5056,13 @@ sub vm_start {
 		    property => "guest-stats-polling-interval",
 		    value => 2) if (!defined($conf->{balloon}) || $conf->{balloon});
 
+	# start cleanup daemon
+	if (qemu_machine_feature_enabled ($forcemachine, kvm_user_version(), 3, 0)) {
+	    my $monitorcmd = ['/usr/sbin/qmeventd', qmp_socket($vmid, 0, 'event')];
+	    my $cleanupcmd = ['/usr/sbin/qm', 'cleanup', $vmid];
+	    push @$monitorcmd, @$cleanupcmd;
+	    run_command($monitorcmd);
+	}
     });
 }
 
-- 
2.11.0





More information about the pve-devel mailing list