41
41
type Domain struct {
42
42
Name string
43
43
m qmp.Monitor
44
+ rm * raw.Monitor
44
45
done chan struct {}
45
46
connect chan chan qmp.Event
46
47
disconnect chan chan qmp.Event
@@ -296,7 +297,7 @@ const (
296
297
297
298
// Status returns the current status of the domain.
298
299
func (d * Domain ) Status () (Status , error ) {
299
- out , err := d .Run (qmp. Command { Execute : "query-status" } )
300
+ status , err := d .rm . QueryStatus ( )
300
301
if err != nil {
301
302
// libvirt returns an error if the domain is not running
302
303
if strings .Contains (err .Error (), "not running" ) {
@@ -306,16 +307,7 @@ func (d *Domain) Status() (Status, error) {
306
307
return 0 , err
307
308
}
308
309
309
- var response struct {
310
- ID string `json:"id"`
311
- Return raw.StatusInfo `json:"return"`
312
- }
313
-
314
- if err = json .Unmarshal (out , & response ); err != nil {
315
- return 0 , err
316
- }
317
-
318
- return Status (response .Return .Status ), nil
310
+ return Status (status .Status ), nil
319
311
}
320
312
321
313
// Supported returns true if the provided command is supported by the domain.
@@ -449,6 +441,7 @@ func NewDomain(m qmp.Monitor, name string) (*Domain, error) {
449
441
d := & Domain {
450
442
Name : name ,
451
443
m : m ,
444
+ rm : raw .NewMonitor (m ),
452
445
done : make (chan struct {}),
453
446
connect : make (chan chan qmp.Event ),
454
447
disconnect : make (chan chan qmp.Event ),
0 commit comments