Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

platform/qemu: add 'qemu-vnc' option #540

Merged
merged 1 commit into from
Jul 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,13 @@ _Note for both architectures_:
```shell
ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -o ProxyCommand="sudo nsenter -n -t <PID of the QEMU instance> nc %h %p" -p 22 core@<IP of the QEMU instance>
```
- using `--qemu-vnc 0`, it's possible to setup a VNC server. Similar to SSH you need to identify the PID of the `qemu` instance to setup a proxy:
```
mkfifo reply
ncat -kl 12800 < reply | sudo nsenter -t "${QEMUPID}" -n ncat localhost 5900 > reply
rm reply
```
Now, you can access the VNC session on localhost:12800 using a VNC client.

##### Advanced usage with Equinix Metal

Expand Down
1 change: 1 addition & 0 deletions cmd/kola/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,7 @@ func init() {
sv(&kola.QEMUOptions.Board, "board", defaultTargetBoard, "target board")
sv(&kola.QEMUOptions.DiskImage, "qemu-image", "", "path to CoreOS disk image")
sv(&kola.QEMUOptions.BIOSImage, "qemu-bios", "", "BIOS to use for QEMU vm")
sv(&kola.QEMUOptions.VNC, "qemu-vnc", "", "VNC port (0 for 5900, 1 for 5901, etc.)")
bv(&kola.QEMUOptions.UseVanillaImage, "qemu-skip-mangle", false, "don't modify CL disk image to capture console log")
sv(&kola.QEMUOptions.ExtraBaseDiskSize, "qemu-grow-base-disk-by", "", "grow base disk by the given size in bytes, following optional 1024-based suffixes are allowed: b (ignored), k, K, M, G, T")
bv(&kola.QEMUOptions.EnableTPM, "qemu-tpm", false, "enable TPM device in QEMU. Requires installing swtpm. Use only with 'kola spawn', test cases are responsible for creating a VM with TPM explicitly.")
Expand Down
1 change: 1 addition & 0 deletions platform/machine/qemu/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ func (qc *Cluster) NewMachine(userdata *conf.UserData) (platform.Machine, error)
// Use for 'kola spawn'; test cases should pass true through
// NewMachineWithOptions()
EnableTPM: qc.flight.opts.EnableTPM,
VNC: qc.flight.opts.VNC,
}
return qc.NewMachineWithOptions(userdata, options)
}
Expand Down
3 changes: 3 additions & 0 deletions platform/machine/qemu/flight.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,9 @@ type Options struct {

EnableTPM bool

// VNC port to provide a VNC session
VNC string

*platform.Options
}

Expand Down
5 changes: 5 additions & 0 deletions platform/qemu.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ type MachineOptions struct {
ExtraPrimaryDiskSize string
EnableTPM bool
SoftwareTPMSocket string
VNC string
}

type Disk struct {
Expand Down Expand Up @@ -375,6 +376,10 @@ func CreateQEMUCommand(board, uuid, biosImage, consolePath, confPath, diskImageP
"-device", Virtio(board, "9p", "fsdev=cfg,mount_tag=config-2"))
}

if options.VNC != "" {
qmCmd = append(qmCmd, "-vnc", fmt.Sprintf(":%s", options.VNC))
}

// auto-read-only is only available in 3.1.0 & greater versions of QEMU
var autoReadOnly string
version, err := exec.Command(qmBinary, "--version").CombinedOutput()
Expand Down