Skip to content

Commit da64192

Browse files
committed
feat: add vsocket
Signed-off-by: Kevin Klopfenstein <[email protected]>
1 parent 27593b9 commit da64192

File tree

4 files changed

+13
-0
lines changed

4 files changed

+13
-0
lines changed

pkg/machine/qemu/command/command.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,14 @@ func (q *QemuCmd) SetDisplay(display string) {
100100
*q = append(*q, "-display", display)
101101
}
102102

103+
func (q *QemuCmd) SetVsocket(vsocket int32) {
104+
// must be greater than 2 in default mode
105+
if vsocket <= 2 {
106+
vsocket = 3
107+
}
108+
*q = append(*q, "-device", "vhost-vsock-pci,guest-cid="+strconv.Itoa(int(vsocket)))
109+
}
110+
103111
func (q *QemuCmd) Build() []string {
104112
return *q
105113
}

pkg/machine/qemu/stubber.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@ func (q *QEMUStubber) setQEMUCommandLine(mc *vmconfigs.MachineConfig) error {
8383
return err
8484
}
8585
q.Command.SetSerialPort(*readySocket, *mc.QEMUHypervisor.QEMUPidPath, mc.Name)
86+
q.Command.SetVsocket(mc.VSocketCid)
8687

8788
q.Command.SetUSBHostPassthrough(mc.Resources.USBs)
8889

pkg/machine/vmconfigs/config_common.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ type QEMUConfig struct {
1414
QMPMonitor command.Monitor
1515
// QEMUPidPath is where to write the PID for QEMU when running
1616
QEMUPidPath *define.VMFile
17+
// VSocketCid ID for VSocket communication
18+
VSocketCid int32
1719
}
1820

1921
// Stubs

pkg/machine/vmconfigs/config_windows.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@ type QEMUConfig struct {
2424
QMPMonitor command.Monitor
2525
// QEMUPidPath is where to write the PID for QEMU when running
2626
QEMUPidPath *define.VMFile
27+
// VSocketCid ID for VSocket communication
28+
VSocketCid int32
2729
}
2830

2931
// Stubs

0 commit comments

Comments
 (0)