From 006fdb4b55a5509659ba8daf2b02c7b9f86cde82 Mon Sep 17 00:00:00 2001 From: Erwan MAS Date: Thu, 17 Aug 2023 13:00:19 -0400 Subject: [PATCH] change natural order to be Width x Heigth --- doc/usage.md | 6 +++--- pkg/config/json_test.go | 2 +- pkg/config/virtio.go | 12 ++++++------ pkg/config/virtio_test.go | 10 +++++----- 4 files changed, 15 insertions(+), 15 deletions(-) diff --git a/doc/usage.md b/doc/usage.md index 71479aff..573ff6d1 100644 --- a/doc/usage.md +++ b/doc/usage.md @@ -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 @@ -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 ``` diff --git a/pkg/config/json_test.go b/pkg/config/json_test.go index 0bd8234d..6acddb9c 100644 --- a/pkg/config/json_test.go +++ b/pkg/config/json_test.go @@ -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}]}`, }, } diff --git a/pkg/config/virtio.go b/pkg/config/virtio.go index 39f18c70..7d7ba63f 100644 --- a/pkg/config/virtio.go +++ b/pkg/config/virtio.go @@ -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 @@ -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 @@ -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 @@ -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 { diff --git a/pkg/config/virtio_test.go b/pkg/config/virtio_test.go index 1c3387e2..82b67d54 100644 --- a/pkg/config/virtio_test.go +++ b/pkg/config/virtio_test.go @@ -158,9 +158,9 @@ 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) { @@ -168,14 +168,14 @@ var virtioDevTests = map[string]virtioDevTest{ 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"}, }, }