Skip to content

Commit

Permalink
Merge pull request #540 from flatcar/tormath1/vnc
Browse files Browse the repository at this point in the history
platform/qemu: add 'qemu-vnc' option
  • Loading branch information
tormath1 authored Jul 16, 2024
2 parents 5c9351d + c7cd56a commit 1adf266
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 0 deletions.
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

0 comments on commit 1adf266

Please sign in to comment.