Skip to content

Commit ee8c9e4

Browse files
feat(vm): add domain jobs info subcommands to vlctl (#2280)
Signed-off-by: Yaroslav Borbat <yaroslav.borbat@flant.com>
1 parent c372fd0 commit ee8c9e4

7 files changed

Lines changed: 531 additions & 148 deletions

File tree

build/components/versions.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ firmware:
33
libvirt: v10.9.0
44
edk2: stable202411
55
core:
6-
3p-kubevirt: v1.6.2-v12n.25
6+
3p-kubevirt: v1.6.2-v12n.26
77
3p-containerized-data-importer: v1.60.3-v12n.18
88
distribution: 2.8.3
99
package:

images/virt-launcher/vlctl/cmd/vlctl/app/domain.go

Lines changed: 67 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -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+
106134
func 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

Comments
 (0)