Skip to content

Commit

Permalink
change natural order to be Width x Heigth
Browse files Browse the repository at this point in the history
  • Loading branch information
ErwanMAS authored and cfergeau committed Aug 19, 2023
1 parent 09bbd86 commit 006fdb4
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 15 deletions.
6 changes: 3 additions & 3 deletions doc/usage.md
Original file line number Diff line number Diff line change
Expand Up @@ -221,11 +221,11 @@ The share can be mounted in the guest with `mount -t virtiofs vfkitTag /mnt`, wi
The `--device virtio-gpu` option allows the user to add graphical devices to the virtual machine.

#### Arguments
- `height`: the vertical resolution of the graphical device's resolution. Defaults to 600
- `width`: the horizontal resolution of the graphical device's resolution. Defaults to 800
- `height`: the vertical resolution of the graphical device's resolution. Defaults to 600

#### Example
`--device virtio-gpu,height=1080,width=1920`
`--device virtio-gpu,width=1920,height=1080`

### Input

Expand Down Expand Up @@ -284,5 +284,5 @@ In order to tell vfkit that you want to start a graphical application window, yo

Proper use of this flag may look similar to the following section of a command:
```bash
--device virtio-input,keyboard --device virtio-input,pointing --device virtio-gpu,height=1080,width=1920 --gui
--device virtio-input,keyboard --device virtio-input,pointing --device virtio-gpu,width=1920,height=1080 --gui
```
2 changes: 1 addition & 1 deletion pkg/config/json_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ var jsonTests = map[string]jsonTest{

return vm
},
expectedJSON: `{"vcpus":3,"memoryBytes":4000000000,"bootloader":{"kind":"linuxBootloader","VmlinuzPath":"/vmlinuz","KernelCmdLine":"/initrd","InitrdPath":"console=hvc0"},"devices":[{"kind":"virtioserial","LogFile":"/virtioserial","UsesStdio":false},{"kind":"virtioinput","inputType":"keyboard"},{"kind":"virtiogpu","usesGUI":false,"height":600,"width":800},{"kind":"virtionet","Nat":true,"MacAddress":"ABEiM0RV","Socket":null,"UnixSocketPath":""},{"kind":"virtiorng"},{"kind":"virtioblk","DevName":"virtio-blk","ImagePath":"/virtioblk","ReadOnly":false,"DeviceIdentifier":""},{"kind":"virtiosock","Port":1234,"SocketURL":"/virtiovsock","Listen":false},{"kind":"virtiofs","SharedDir":"/virtiofs","MountTag":"tag"},{"kind":"usbmassstorage","DevName":"usb-mass-storage","ImagePath":"/usbmassstorage","ReadOnly":false}]}`,
expectedJSON: `{"vcpus":3,"memoryBytes":4000000000,"bootloader":{"kind":"linuxBootloader","VmlinuzPath":"/vmlinuz","KernelCmdLine":"/initrd","InitrdPath":"console=hvc0"},"devices":[{"kind":"virtioserial","LogFile":"/virtioserial","UsesStdio":false},{"kind":"virtioinput","inputType":"keyboard"},{"kind":"virtiogpu","usesGUI":false,"width":800,"height":600},{"kind":"virtionet","Nat":true,"MacAddress":"ABEiM0RV","Socket":null,"UnixSocketPath":""},{"kind":"virtiorng"},{"kind":"virtioblk","DevName":"virtio-blk","ImagePath":"/virtioblk","ReadOnly":false,"DeviceIdentifier":""},{"kind":"virtiosock","Port":1234,"SocketURL":"/virtiovsock","Listen":false},{"kind":"virtiofs","SharedDir":"/virtiofs","MountTag":"tag"},{"kind":"usbmassstorage","DevName":"usb-mass-storage","ImagePath":"/usbmassstorage","ReadOnly":false}]}`,
},
}

Expand Down
12 changes: 6 additions & 6 deletions pkg/config/virtio.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,12 @@ const (
VirtioInputKeyboardDevice = "keyboard"

// Options for VirtioGPUResolution
VirtioGPUResolutionHeight = "height"
VirtioGPUResolutionWidth = "width"
VirtioGPUResolutionHeight = "height"

// Default VirtioGPU Resolution
defaultVirtioGPUResolutionHeight = 600
defaultVirtioGPUResolutionWidth = 800
defaultVirtioGPUResolutionHeight = 600
)

// VirtioInput configures an input device, such as a keyboard or pointing device
Expand All @@ -32,8 +32,8 @@ type VirtioInput struct {
}

type VirtioGPUResolution struct {
Height int `json:"height"`
Width int `json:"width"`
Height int `json:"height"`
}

// VirtioGPU configures a GPU device, such as the host computer's display
Expand Down Expand Up @@ -268,15 +268,15 @@ func VirtioGPUNew() (VirtioDevice, error) {
return &VirtioGPU{
UsesGUI: false,
VirtioGPUResolution: VirtioGPUResolution{
Height: defaultVirtioGPUResolutionHeight,
Width: defaultVirtioGPUResolutionWidth,
Height: defaultVirtioGPUResolutionHeight,
},
}, nil
}

func (dev *VirtioGPU) validate() error {
if dev.Height < 1 || dev.Width < 1 {
return fmt.Errorf("Invalid dimensions for virtio-gpu device resolution: %dx%d", dev.Height, dev.Width)
return fmt.Errorf("Invalid dimensions for virtio-gpu device resolution: %dx%d", dev.Width, dev.Height)
}

return nil
Expand All @@ -287,7 +287,7 @@ func (dev *VirtioGPU) ToCmdLine() ([]string, error) {
return nil, err
}

return []string{"--device", fmt.Sprintf("virtio-gpu,height=%d,width=%d", dev.Height, dev.Width)}, nil
return []string{"--device", fmt.Sprintf("virtio-gpu,width=%d,height=%d", dev.Width, dev.Height)}, nil
}

func (dev *VirtioGPU) FromOptions(options []option) error {
Expand Down
10 changes: 5 additions & 5 deletions pkg/config/virtio_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -158,24 +158,24 @@ var virtioDevTests = map[string]virtioDevTest{
newDev: VirtioGPUNew,
expectedDev: &VirtioGPU{
false,
VirtioGPUResolution{600, 800},
VirtioGPUResolution{Width: 800, Height: 600},
},
expectedCmdLine: []string{"--device", "virtio-gpu,height=600,width=800"},
expectedCmdLine: []string{"--device", "virtio-gpu,width=800,height=600"},
},
"NewVirtioGPUDeviceWithDimensions": {
newDev: func() (VirtioDevice, error) {
dev, err := VirtioGPUNew()
if err != nil {
return nil, err
}
dev.(*VirtioGPU).VirtioGPUResolution = VirtioGPUResolution{1080 ,1920}
dev.(*VirtioGPU).VirtioGPUResolution = VirtioGPUResolution{Width: 1920, Height: 1080}
return dev, nil
},
expectedDev: &VirtioGPU{
false,
VirtioGPUResolution{1080, 1920},
VirtioGPUResolution{Width: 1920, Height: 1080},
},
expectedCmdLine: []string{"--device", "virtio-gpu,height=1080,width=1920"},
expectedCmdLine: []string{"--device", "virtio-gpu,width=1920,height=1080"},
},
}

Expand Down

0 comments on commit 006fdb4

Please sign in to comment.