Skip to content

Commit 4a77a5f

Browse files
authored
Merge pull request #1696 from AkihiroSuda/cli-video
`limactl (create|start|edit)`: add `--video=<bool>`
2 parents e250979 + da0e628 commit 4a77a5f

File tree

4 files changed

+33
-6
lines changed

4 files changed

+33
-6
lines changed

cmd/limactl/editflags/editflags.go

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,9 @@ func registerEdit(cmd *cobra.Command, commentPrefix string) {
5959
flags.Bool("rosetta", false, commentPrefix+"enable Rosetta (for vz instances)")
6060

6161
flags.String("set", "", commentPrefix+"modify the template inplace, using yq syntax")
62+
63+
// negative performance impact: https://gitlab.com/qemu-project/qemu/-/issues/334
64+
flags.Bool("video", false, commentPrefix+"enable video output (has negative performance impact for QEMU)")
6265
}
6366

6467
// RegisterCreate registers flags related to in-place YAML modification, for `limactl create`.
@@ -179,6 +182,18 @@ func YQExpressions(flags *flag.FlagSet) ([]string, error) {
179182
},
180183
true},
181184
{"set", d("%s"), true},
185+
{"video",
186+
func(_ *flag.Flag) (string, error) {
187+
b, err := flags.GetBool("video")
188+
if err != nil {
189+
return "", err
190+
}
191+
if b {
192+
return ".video.display = \"default\"", nil
193+
}
194+
return ".video.display = \"none\"", nil
195+
},
196+
true},
182197
{"arch", d(".arch = %q"), false},
183198
{"containerd",
184199
func(_ *flag.Flag) (string, error) {

docs/experimental.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,5 @@ The following commands are experimental and subject to change:
1515

1616
- `limactl (create|start|edit) --set=<YQ EXPRESSION>`
1717
- `limactl (create|start|edit) --network=<NETWORK>`
18+
- `limactl (create|start|edit) --video=<BOOL>`
1819
- `limactl snapshot *`

pkg/vz/vm_darwin.go

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -487,7 +487,8 @@ func attachDisks(driver *driver.BaseDriver, vmConfig *vz.VirtualMachineConfigura
487487
}
488488

489489
func attachDisplay(driver *driver.BaseDriver, vmConfig *vz.VirtualMachineConfiguration) error {
490-
if *driver.Yaml.Video.Display == "vz" {
490+
switch *driver.Yaml.Video.Display {
491+
case "vz", "default":
491492
graphicsDeviceConfiguration, err := vz.NewVirtioGraphicsDeviceConfiguration()
492493
if err != nil {
493494
return err
@@ -501,8 +502,12 @@ func attachDisplay(driver *driver.BaseDriver, vmConfig *vz.VirtualMachineConfigu
501502
vmConfig.SetGraphicsDevicesVirtualMachineConfiguration([]vz.GraphicsDeviceConfiguration{
502503
graphicsDeviceConfiguration,
503504
})
505+
return nil
506+
case "none":
507+
return nil
508+
default:
509+
return fmt.Errorf("unexpected video display %q", *driver.Yaml.Video.Display)
504510
}
505-
return nil
506511
}
507512

508513
func attachFolderMounts(driver *driver.BaseDriver, vmConfig *vz.VirtualMachineConfiguration) error {

pkg/vz/vz_driver_darwin.go

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -120,9 +120,10 @@ func (l *LimaVzDriver) Validate() error {
120120
logrus.Warnf("field `audio.device` must be %q for VZ driver , got %q", "vz", audioDevice)
121121
}
122122

123-
videoDisplay := *l.Yaml.Video.Display
124-
if videoDisplay != "none" && videoDisplay != "vz" {
125-
logrus.Warnf("field `video.display` must be %q for VZ driver , got %q", "vz", videoDisplay)
123+
switch videoDisplay := *l.Yaml.Video.Display; videoDisplay {
124+
case "vz", "default", "none":
125+
default:
126+
logrus.Warnf("field `video.display` must be \"vz\", \"default\", or \"none\" for VZ driver , got %q", videoDisplay)
126127
}
127128
return nil
128129
}
@@ -146,7 +147,12 @@ func (l *LimaVzDriver) Start(ctx context.Context) (chan error, error) {
146147
}
147148

148149
func (l *LimaVzDriver) CanRunGUI() bool {
149-
return *l.Yaml.Video.Display == "vz"
150+
switch *l.Yaml.Video.Display {
151+
case "vz", "default":
152+
return true
153+
default:
154+
return false
155+
}
150156
}
151157

152158
func (l *LimaVzDriver) RunGUI() error {

0 commit comments

Comments
 (0)