Skip to content

Commit 890e6a9

Browse files
Merge pull request digitalocean#143 from xmudrii/domain-command-refactor
Domain: Commands func refactored
2 parents 0c45556 + e23715a commit 890e6a9

File tree

1 file changed

+4
-15
lines changed

1 file changed

+4
-15
lines changed

qemu/domain.go

Lines changed: 4 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -62,25 +62,14 @@ func (d *Domain) Close() error {
6262

6363
// Commands returns all QMP commands supported by the domain.
6464
func (d *Domain) Commands() ([]string, error) {
65-
raw, err := d.Run(qmp.Command{Execute: "query-commands"})
65+
commands, err := d.rm.QueryCommands()
6666
if err != nil {
6767
return nil, err
6868
}
69-
70-
var response struct {
71-
ID string `json:"id"`
72-
Return []struct {
73-
Name string `json:"name"`
74-
} `json:"return"`
75-
}
76-
77-
if err = json.Unmarshal(raw, &response); err != nil {
78-
return nil, err
79-
}
80-
69+
8170
// flatten response
82-
cmds := make([]string, 0, len(response.Return))
83-
for _, c := range response.Return {
71+
cmds := make([]string, 0, len(commands))
72+
for _, c := range commands {
8473
cmds = append(cmds, c.Name)
8574
}
8675

0 commit comments

Comments
 (0)