[pve-devel] [PATCH 1/7] add vm_qga_command

Alexandre Derumier aderumier at odiso.com
Sun Mar 17 16:09:01 CET 2013


and reuse vm_qmp_command && qmp_socket with $qga param

Signed-off-by: Alexandre Derumier <aderumier at odiso.com>
---
 PVE/QemuServer.pm |   20 ++++++++++++++------
 1 file changed, 14 insertions(+), 6 deletions(-)

diff --git a/PVE/QemuServer.pm b/PVE/QemuServer.pm
index eba9aed..8c4a1a1 100644
--- a/PVE/QemuServer.pm
+++ b/PVE/QemuServer.pm
@@ -2470,8 +2470,9 @@ sub vnc_socket {
 }
 
 sub qmp_socket {
-    my ($vmid) = @_;
-    return "${var_run_tmpdir}/$vmid.qmp";
+    my ($vmid, $qga) = @_;
+    my $sockettype = $qga ? 'qga' : 'qmp';
+    return "${var_run_tmpdir}/$vmid.$sockettype";
 }
 
 sub qga_socket {
@@ -3002,6 +3003,13 @@ sub vm_start {
     });
 }
 
+sub vm_qga_cmd {
+    my ($vmid, $execute, %params) = @_;
+
+    my $cmd = { execute => $execute, arguments => \%params };
+    vm_qmp_command($vmid, $cmd, undef, 1);
+}
+
 sub vm_mon_cmd {
     my ($vmid, $execute, %params) = @_;
 
@@ -3017,7 +3025,7 @@ sub vm_mon_cmd_nocheck {
 }
 
 sub vm_qmp_command {
-    my ($vmid, $cmd, $nocheck) = @_;
+    my ($vmid, $cmd, $nocheck, $qga) = @_;
 
     my $res;
 
@@ -3029,12 +3037,12 @@ sub vm_qmp_command {
  
     eval {
 	die "VM $vmid not running\n" if !check_running($vmid, $nocheck);
-	my $sname = qmp_socket($vmid);
+	my $sname = qmp_socket($vmid, $qga);
 	if (-e $sname) {
-	    my $qmpclient = PVE::QMPClient->new();
+	    my $qmpclient = PVE::QMPClient->new(undef, $qga);
 
 	    $res = $qmpclient->cmd($vmid, $cmd, $timeout);
-	} elsif (-e "${var_run_tmpdir}/$vmid.mon") {
+	} elsif (-e "${var_run_tmpdir}/$vmid.mon" && !$qga) {
 	    die "can't execute complex command on old monitor - stop/start your vm to fix the problem\n"
 		if scalar(%{$cmd->{arguments}});
 	    vm_monitor_command($vmid, $cmd->{execute}, $nocheck);
-- 
1.7.10.4




More information about the pve-devel mailing list