From f3f470afe5f335e01c62d018f2af71f3779bae4c Mon Sep 17 00:00:00 2001 From: Jlan45 Date: Thu, 26 Oct 2023 01:11:09 +0800 Subject: [PATCH] Fix the bug that AgentExec didn't return right pid number --- virtual_machine.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/virtual_machine.go b/virtual_machine.go index 88e457d..9dbf335 100644 --- a/virtual_machine.go +++ b/virtual_machine.go @@ -491,13 +491,14 @@ func (v *VirtualMachine) WaitForAgent(seconds int) error { } func (v *VirtualMachine) AgentExec(command, inputData string) (pid int, err error) { + tmpdata := map[string]interface{}{} err = v.client.Post(fmt.Sprintf("/nodes/%s/qemu/%d/agent/exec", v.Node, v.VMID), map[string]string{ "command": command, "input-data": inputData, }, - &pid) - + &tmpdata) + pid = int(tmpdata["pid"].(float64)) return }