[pve-devel] [PATCH 2/7] qmpclient-qga : add qga option at object creation

2013-03-17 Thread Alexandre Derumier
Signed-off-by: Alexandre Derumier aderum...@odiso.com
---
 PVE/QMPClient.pm |3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/PVE/QMPClient.pm b/PVE/QMPClient.pm
index 6782c37..e5d4356 100755
--- a/PVE/QMPClient.pm
+++ b/PVE/QMPClient.pm
@@ -19,7 +19,7 @@ use Data::Dumper;
 # Note: kvm can onyl handle 1 connection, so we close connections asap
 
 sub new {
-my ($class, $eventcb) = @_;
+my ($class, $eventcb, $qga) = @_;
 
 my $mux = new IO::Multiplex;
 
@@ -33,6 +33,7 @@ sub new {
 }, $class;
 
 $self-{eventcb} = $eventcb if $eventcb;
+$self-{qga} = $qga if $qga;
 
 $mux-set_callback_object($self);
 
-- 
1.7.10.4

___
pve-devel mailing list
pve-devel@pve.proxmox.com
http://pve.proxmox.com/cgi-bin/mailman/listinfo/pve-devel


[pve-devel] add qemu guest agent command support

2013-03-17 Thread Alexandre Derumier
This patch series add code to send command to quest guest agent.

The procotol is qmp, so I have reuse as much as possible the current qmpclient


the only big difference is that we can't pass an id to a request, so we must 
send a guest-sync command with an id before the real command


command

{ execute: guest-sync, arguments: { id: 123456 } 
}{execute:guest-ping}

result

{ return: 123456}\n{return: {}}

___
pve-devel mailing list
pve-devel@pve.proxmox.com
http://pve.proxmox.com/cgi-bin/mailman/listinfo/pve-devel


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

2013-03-17 Thread Alexandre Derumier
and reuse vm_qmp_command  qmp_socket with $qga param

Signed-off-by: Alexandre Derumier aderum...@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

___
pve-devel mailing list
pve-devel@pve.proxmox.com
http://pve.proxmox.com/cgi-bin/mailman/listinfo/pve-devel