[pve-devel] [PATCH 6/7] qmpclient-qga : build qga command

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


example of command:

first json is guest-sync to sync and flush the client, second json is the command

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

Signed-off-by: Alexandre Derumier <aderumier at odiso.com>
---
 PVE/QMPClient.pm |   25 +++++++++++++++++++++----
 1 file changed, 21 insertions(+), 4 deletions(-)

diff --git a/PVE/QMPClient.pm b/PVE/QMPClient.pm
index 39a2869..193e53f 100755
--- a/PVE/QMPClient.pm
+++ b/PVE/QMPClient.pm
@@ -187,10 +187,27 @@ my $check_queue = sub {
 		delete $cmd->{arguments}->{fd};
 	    }
 
-	    my $qmpcmd = to_json({
-		execute => $cmd->{execute},
-		arguments => $cmd->{arguments},
-		id => $cmd->{id}});
+	    my $qmpcmd = undef;
+
+	    if($self->{qga}){
+
+		my $qmpcmdid =to_json({
+		    execute => 'guest-sync',
+		    arguments => { id => int($cmd->{id})}});
+
+		$qmpcmd = to_json({
+		    execute => $cmd->{execute},
+		    arguments => $cmd->{arguments}});
+
+		$qmpcmd = $qmpcmdid.$qmpcmd;
+
+	    }else{
+
+		$qmpcmd = to_json({
+		    execute => $cmd->{execute},
+		    arguments => $cmd->{arguments},
+		    id => $cmd->{id}});
+	    }
 
 	    if ($fd >= 0) {
 		my $ret = PVE::IPCC::sendfd(fileno($fh), $fd, $qmpcmd);
-- 
1.7.10.4



More information about the pve-devel mailing list