Skip to content

Commit 630bfbf

Browse files
Merge pull request #21686 from arixmkii/qemu-machine-5-bugfixes
Improve cross platform support in QEMU machine sources
2 parents 7dd8fc5 + e0a7668 commit 630bfbf

5 files changed

Lines changed: 9 additions & 24 deletions

File tree

pkg/machine/qemu/machine.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -149,9 +149,9 @@ func (q *QEMUStubber) StopVM(mc *vmconfigs.MachineConfig, _ bool) error {
149149
// stopLocked stops the machine and expects the caller to hold the machine's lock.
150150
func (q *QEMUStubber) stopLocked(mc *vmconfigs.MachineConfig) error {
151151
// check if the qmp socket is there. if not, qemu instance is gone
152-
if _, err := os.Stat(q.QMPMonitor.Address.GetPath()); errors.Is(err, fs.ErrNotExist) {
152+
if _, err := os.Stat(mc.QEMUHypervisor.QMPMonitor.Address.GetPath()); errors.Is(err, fs.ErrNotExist) {
153153
// Right now it is NOT an error to stop a stopped machine
154-
logrus.Debugf("QMP monitor socket %v does not exist", q.QMPMonitor.Address)
154+
logrus.Debugf("QMP monitor socket %v does not exist", mc.QEMUHypervisor.QMPMonitor.Address)
155155
// Fix incorrect starting state in case of crash during start
156156
if mc.Starting {
157157
mc.Starting = false
@@ -162,7 +162,7 @@ func (q *QEMUStubber) stopLocked(mc *vmconfigs.MachineConfig) error {
162162
return nil
163163
}
164164

165-
qmpMonitor, err := qmp.NewSocketMonitor(q.QMPMonitor.Network, q.QMPMonitor.Address.GetPath(), q.QMPMonitor.Timeout)
165+
qmpMonitor, err := qmp.NewSocketMonitor(mc.QEMUHypervisor.QMPMonitor.Network, mc.QEMUHypervisor.QMPMonitor.Address.GetPath(), mc.QEMUHypervisor.QMPMonitor.Timeout)
166166
if err != nil {
167167
return err
168168
}
@@ -196,7 +196,7 @@ func (q *QEMUStubber) stopLocked(mc *vmconfigs.MachineConfig) error {
196196
}
197197

198198
// Remove socket
199-
if err := q.QMPMonitor.Address.Delete(); err != nil {
199+
if err := mc.QEMUHypervisor.QMPMonitor.Address.Delete(); err != nil {
200200
return err
201201
}
202202

@@ -206,14 +206,14 @@ func (q *QEMUStubber) stopLocked(mc *vmconfigs.MachineConfig) error {
206206
}
207207
disconnected = true
208208

209-
if q.QEMUPidPath.GetPath() == "" {
209+
if mc.QEMUHypervisor.QEMUPidPath.GetPath() == "" {
210210
// no vm pid file path means it's probably a machine created before we
211211
// started using it, so we revert to the old way of waiting for the
212212
// machine to stop
213213
return q.waitForMachineToStop(mc)
214214
}
215215

216-
vmPid, err := q.QEMUPidPath.ReadPIDFrom()
216+
vmPid, err := mc.QEMUHypervisor.QEMUPidPath.ReadPIDFrom()
217217
if err != nil {
218218
return err
219219
}

pkg/machine/qemu/machine_unix.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ func checkProcessStatus(processHint string, pid int, stderrBuf *bytes.Buffer) er
2222
var status syscall.WaitStatus
2323
pid, err := syscall.Wait4(pid, &status, syscall.WNOHANG, nil)
2424
if err != nil {
25-
return fmt.Errorf("failed to read qem%su process status: %w", processHint, err)
25+
return fmt.Errorf("failed to read %s process status: %w", processHint, err)
2626
}
2727
if pid > 0 {
2828
// child exited

pkg/machine/qemu/options_windows_amd64.go

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,3 @@ func (q *QEMUStubber) addArchOptions(_ *setNewMachineCMDOpts) []string {
1010
opts := []string{"-machine", "q35,accel=whpx:tcg", "-cpu", "qemu64"}
1111
return opts
1212
}
13-
14-
func (v *MachineVM) prepare() error {
15-
return nil
16-
}
17-
18-
func (v *MachineVM) archRemovalFiles() []string {
19-
return []string{}
20-
}

pkg/machine/qemu/options_windows_arm64.go

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,3 @@ func (q *QEMUStubber) addArchOptions(_ *setNewMachineCMDOpts) []string {
99
opts := []string{}
1010
return opts
1111
}
12-
13-
func (v *MachineVM) prepare() error {
14-
return nil
15-
}
16-
17-
func (v *MachineVM) archRemovalFiles() []string {
18-
return []string{}
19-
}

pkg/machine/qemu/stubber.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import (
88
"net"
99
"os"
1010
"os/exec"
11+
"path/filepath"
1112
"strconv"
1213
"strings"
1314
"time"
@@ -296,7 +297,7 @@ func (q *QEMUStubber) StartNetworking(mc *vmconfigs.MachineConfig, cmd *gvproxy.
296297
if err := gvProxySock.Delete(); err != nil {
297298
logrus.Error(err)
298299
}
299-
cmd.AddQemuSocket(fmt.Sprintf("unix://%s", gvProxySock.GetPath()))
300+
cmd.AddQemuSocket(fmt.Sprintf("unix://%s", filepath.ToSlash(gvProxySock.GetPath())))
300301
return nil
301302
}
302303

0 commit comments

Comments
 (0)