+# Note: List of special QGA command. Those commands can close the connection
+# without sending a response.
+
+my $qga_allow_close_cmds = {
+ 'guest-shutdown' => 1,
+ 'guest-suspend-ram' => 1,
+ 'guest-suspend-disk' => 1,
+ 'guest-suspend-hybrid' => 1,
+};
+
+my $push_cmd_to_queue = sub {
+ my ($self, $vmid, $cmd) = @_;
+
+ my $execute = $cmd->{execute} || die "no command name specified";
+
+ my $qga = ($execute =~ /^guest\-+/) ? 1 : 0;
+
+ my $sname = PVE::QemuServer::qmp_socket($vmid, $qga);
+
+ $self->{queue_info}->{$sname} = { qga => $qga, vmid => $vmid, sname => $sname, cmds => [] }
+ if !$self->{queue_info}->{$sname};
+
+ push @{$self->{queue_info}->{$sname}->{cmds}}, $cmd;
+
+ return $self->{queue_info}->{$sname};
+};
+