@@ -41,7 +41,11 @@ func NewDomainCommand() *cobra.Command {
4141 }
4242
4343 cmd .Flags ().BoolVarP (& fromFile , "from-file" , "f" , false , "Read domain specification from file" )
44- cmd .AddCommand (NewDomainStatsCommand ())
44+ cmd .AddCommand (
45+ NewDomainStatsCommand (),
46+ NewDomainBlockJobsCommand (),
47+ NewDomainJobsCommand (),
48+ )
4549
4650 return cmd
4751}
@@ -103,6 +107,30 @@ func NewDomainStatsCommand() *cobra.Command {
103107
104108}
105109
110+ func NewDomainBlockJobsCommand () * cobra.Command {
111+ return & cobra.Command {
112+ Use : "block-jobs" ,
113+ Short : "Get current QEMU block jobs status" ,
114+ Args : cobra .NoArgs ,
115+ RunE : func (cmd * cobra.Command , _ []string ) error {
116+ baseOpts := BaseOptionsFromCommand (cmd )
117+ return runDomainBlockJobsCommand (baseOpts )
118+ },
119+ }
120+ }
121+
122+ func NewDomainJobsCommand () * cobra.Command {
123+ return & cobra.Command {
124+ Use : "jobs" ,
125+ Short : "Get current QEMU jobs status" ,
126+ Args : cobra .NoArgs ,
127+ RunE : func (cmd * cobra.Command , _ []string ) error {
128+ baseOpts := BaseOptionsFromCommand (cmd )
129+ return runDomainJobsCommand (baseOpts )
130+ },
131+ }
132+ }
133+
106134func runDomainStatsCommand (opts BaseOptions ) error {
107135 if err := opts .Validate (); err != nil {
108136 return err
@@ -124,3 +152,41 @@ func runDomainStatsCommand(opts BaseOptions) error {
124152
125153 return marshalAndPrintOutput (& opts , stats )
126154}
155+
156+ func runDomainBlockJobsCommand (opts BaseOptions ) error {
157+ if err := opts .Validate (); err != nil {
158+ return err
159+ }
160+
161+ client , err := opts .Client ()
162+ if err != nil {
163+ return fmt .Errorf ("failed to create client: %w" , err )
164+ }
165+ defer client .Close ()
166+
167+ jobs , err := client .GetBlockJobsStatus ()
168+ if err != nil {
169+ return fmt .Errorf ("failed to get block jobs status: %w" , err )
170+ }
171+
172+ return marshalAndPrintOutput (& opts , jobs )
173+ }
174+
175+ func runDomainJobsCommand (opts BaseOptions ) error {
176+ if err := opts .Validate (); err != nil {
177+ return err
178+ }
179+
180+ client , err := opts .Client ()
181+ if err != nil {
182+ return fmt .Errorf ("failed to create client: %w" , err )
183+ }
184+ defer client .Close ()
185+
186+ jobs , err := client .GetJobsStatus ()
187+ if err != nil {
188+ return fmt .Errorf ("failed to get jobs status: %w" , err )
189+ }
190+
191+ return marshalAndPrintOutput (& opts , jobs )
192+ }
0 commit comments