Skip to content

Commit

Permalink
Merge pull request #21686 from arixmkii/qemu-machine-5-bugfixes
Browse files Browse the repository at this point in the history
Improve cross platform support in QEMU machine sources
  • Loading branch information
openshift-merge-bot[bot] authored Feb 18, 2024
2 parents 7dd8fc5 + e0a7668 commit 630bfbf
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 24 deletions.
12 changes: 6 additions & 6 deletions pkg/machine/qemu/machine.go
Original file line number Diff line number Diff line change
Expand Up @@ -149,9 +149,9 @@ func (q *QEMUStubber) StopVM(mc *vmconfigs.MachineConfig, _ bool) error {
// stopLocked stops the machine and expects the caller to hold the machine's lock.
func (q *QEMUStubber) stopLocked(mc *vmconfigs.MachineConfig) error {
// check if the qmp socket is there. if not, qemu instance is gone
if _, err := os.Stat(q.QMPMonitor.Address.GetPath()); errors.Is(err, fs.ErrNotExist) {
if _, err := os.Stat(mc.QEMUHypervisor.QMPMonitor.Address.GetPath()); errors.Is(err, fs.ErrNotExist) {
// Right now it is NOT an error to stop a stopped machine
logrus.Debugf("QMP monitor socket %v does not exist", q.QMPMonitor.Address)
logrus.Debugf("QMP monitor socket %v does not exist", mc.QEMUHypervisor.QMPMonitor.Address)
// Fix incorrect starting state in case of crash during start
if mc.Starting {
mc.Starting = false
Expand All @@ -162,7 +162,7 @@ func (q *QEMUStubber) stopLocked(mc *vmconfigs.MachineConfig) error {
return nil
}

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

// Remove socket
if err := q.QMPMonitor.Address.Delete(); err != nil {
if err := mc.QEMUHypervisor.QMPMonitor.Address.Delete(); err != nil {
return err
}

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

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

vmPid, err := q.QEMUPidPath.ReadPIDFrom()
vmPid, err := mc.QEMUHypervisor.QEMUPidPath.ReadPIDFrom()
if err != nil {
return err
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/machine/qemu/machine_unix.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ func checkProcessStatus(processHint string, pid int, stderrBuf *bytes.Buffer) er
var status syscall.WaitStatus
pid, err := syscall.Wait4(pid, &status, syscall.WNOHANG, nil)
if err != nil {
return fmt.Errorf("failed to read qem%su process status: %w", processHint, err)
return fmt.Errorf("failed to read %s process status: %w", processHint, err)
}
if pid > 0 {
// child exited
Expand Down
8 changes: 0 additions & 8 deletions pkg/machine/qemu/options_windows_amd64.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,3 @@ func (q *QEMUStubber) addArchOptions(_ *setNewMachineCMDOpts) []string {
opts := []string{"-machine", "q35,accel=whpx:tcg", "-cpu", "qemu64"}
return opts
}

func (v *MachineVM) prepare() error {
return nil
}

func (v *MachineVM) archRemovalFiles() []string {
return []string{}
}
8 changes: 0 additions & 8 deletions pkg/machine/qemu/options_windows_arm64.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,3 @@ func (q *QEMUStubber) addArchOptions(_ *setNewMachineCMDOpts) []string {
opts := []string{}
return opts
}

func (v *MachineVM) prepare() error {
return nil
}

func (v *MachineVM) archRemovalFiles() []string {
return []string{}
}
3 changes: 2 additions & 1 deletion pkg/machine/qemu/stubber.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"net"
"os"
"os/exec"
"path/filepath"
"strconv"
"strings"
"time"
Expand Down Expand Up @@ -296,7 +297,7 @@ func (q *QEMUStubber) StartNetworking(mc *vmconfigs.MachineConfig, cmd *gvproxy.
if err := gvProxySock.Delete(); err != nil {
logrus.Error(err)
}
cmd.AddQemuSocket(fmt.Sprintf("unix://%s", gvProxySock.GetPath()))
cmd.AddQemuSocket(fmt.Sprintf("unix://%s", filepath.ToSlash(gvProxySock.GetPath())))
return nil
}

Expand Down

0 comments on commit 630bfbf

Please sign in to comment.