mirror of
https://github.com/containers/podman.git
synced 2025-07-03 09:17:15 +08:00
Improve cross platform support in QEMU machine sources
Signed-off-by: Arthur Sengileyev <arthur.sengileyev@gmail.com>
This commit is contained in:
@ -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.
|
// stopLocked stops the machine and expects the caller to hold the machine's lock.
|
||||||
func (q *QEMUStubber) stopLocked(mc *vmconfigs.MachineConfig) error {
|
func (q *QEMUStubber) stopLocked(mc *vmconfigs.MachineConfig) error {
|
||||||
// check if the qmp socket is there. if not, qemu instance is gone
|
// 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
|
// 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
|
// Fix incorrect starting state in case of crash during start
|
||||||
if mc.Starting {
|
if mc.Starting {
|
||||||
mc.Starting = false
|
mc.Starting = false
|
||||||
@ -162,7 +162,7 @@ func (q *QEMUStubber) stopLocked(mc *vmconfigs.MachineConfig) error {
|
|||||||
return nil
|
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 {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@ -196,7 +196,7 @@ func (q *QEMUStubber) stopLocked(mc *vmconfigs.MachineConfig) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Remove socket
|
// Remove socket
|
||||||
if err := q.QMPMonitor.Address.Delete(); err != nil {
|
if err := mc.QEMUHypervisor.QMPMonitor.Address.Delete(); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -206,14 +206,14 @@ func (q *QEMUStubber) stopLocked(mc *vmconfigs.MachineConfig) error {
|
|||||||
}
|
}
|
||||||
disconnected = true
|
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
|
// 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
|
// started using it, so we revert to the old way of waiting for the
|
||||||
// machine to stop
|
// machine to stop
|
||||||
return q.waitForMachineToStop(mc)
|
return q.waitForMachineToStop(mc)
|
||||||
}
|
}
|
||||||
|
|
||||||
vmPid, err := q.QEMUPidPath.ReadPIDFrom()
|
vmPid, err := mc.QEMUHypervisor.QEMUPidPath.ReadPIDFrom()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
@ -22,7 +22,7 @@ func checkProcessStatus(processHint string, pid int, stderrBuf *bytes.Buffer) er
|
|||||||
var status syscall.WaitStatus
|
var status syscall.WaitStatus
|
||||||
pid, err := syscall.Wait4(pid, &status, syscall.WNOHANG, nil)
|
pid, err := syscall.Wait4(pid, &status, syscall.WNOHANG, nil)
|
||||||
if err != 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 {
|
if pid > 0 {
|
||||||
// child exited
|
// child exited
|
||||||
|
@ -10,11 +10,3 @@ func (q *QEMUStubber) addArchOptions(_ *setNewMachineCMDOpts) []string {
|
|||||||
opts := []string{"-machine", "q35,accel=whpx:tcg", "-cpu", "qemu64"}
|
opts := []string{"-machine", "q35,accel=whpx:tcg", "-cpu", "qemu64"}
|
||||||
return opts
|
return opts
|
||||||
}
|
}
|
||||||
|
|
||||||
func (v *MachineVM) prepare() error {
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func (v *MachineVM) archRemovalFiles() []string {
|
|
||||||
return []string{}
|
|
||||||
}
|
|
||||||
|
@ -9,11 +9,3 @@ func (q *QEMUStubber) addArchOptions(_ *setNewMachineCMDOpts) []string {
|
|||||||
opts := []string{}
|
opts := []string{}
|
||||||
return opts
|
return opts
|
||||||
}
|
}
|
||||||
|
|
||||||
func (v *MachineVM) prepare() error {
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func (v *MachineVM) archRemovalFiles() []string {
|
|
||||||
return []string{}
|
|
||||||
}
|
|
||||||
|
@ -8,6 +8,7 @@ import (
|
|||||||
"net"
|
"net"
|
||||||
"os"
|
"os"
|
||||||
"os/exec"
|
"os/exec"
|
||||||
|
"path/filepath"
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
@ -296,7 +297,7 @@ func (q *QEMUStubber) StartNetworking(mc *vmconfigs.MachineConfig, cmd *gvproxy.
|
|||||||
if err := gvProxySock.Delete(); err != nil {
|
if err := gvProxySock.Delete(); err != nil {
|
||||||
logrus.Error(err)
|
logrus.Error(err)
|
||||||
}
|
}
|
||||||
cmd.AddQemuSocket(fmt.Sprintf("unix://%s", gvProxySock.GetPath()))
|
cmd.AddQemuSocket(fmt.Sprintf("unix://%s", filepath.ToSlash(gvProxySock.GetPath())))
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user