diff --git a/pkg/machine/qemu/command/command.go b/pkg/machine/qemu/command/command.go index 11994f85f1..de94ab396c 100644 --- a/pkg/machine/qemu/command/command.go +++ b/pkg/machine/qemu/command/command.go @@ -10,7 +10,6 @@ import ( "strconv" "time" - "github.com/containers/common/pkg/strongunits" "github.com/containers/podman/v5/pkg/machine/define" "github.com/containers/storage/pkg/fileutils" ) @@ -33,14 +32,6 @@ func NewQemuBuilder(binary string, options []string) QemuCmd { return append(q, options...) } -// SetMemory adds the specified amount of memory for the machine -func (q *QemuCmd) SetMemory(m strongunits.MiB) { - serializedMem := strconv.FormatUint(uint64(m), 10) - // In order to use virtiofsd, we must enable shared memory - *q = append(*q, "-object", fmt.Sprintf("memory-backend-memfd,id=mem,size=%sM,share=on", serializedMem)) - *q = append(*q, "-m", serializedMem) -} - // SetCPUs adds the number of CPUs the machine will have func (q *QemuCmd) SetCPUs(c uint64) { *q = append(*q, "-smp", strconv.FormatUint(c, 10)) diff --git a/pkg/machine/qemu/command/command_unix.go b/pkg/machine/qemu/command/command_unix.go new file mode 100644 index 0000000000..a9ecd4a7d6 --- /dev/null +++ b/pkg/machine/qemu/command/command_unix.go @@ -0,0 +1,18 @@ +//go:build dragonfly || freebsd || linux || netbsd || openbsd + +package command + +import ( + "fmt" + "strconv" + + "github.com/containers/common/pkg/strongunits" +) + +// SetMemory adds the specified amount of memory for the machine +func (q *QemuCmd) SetMemory(m strongunits.MiB) { + serializedMem := strconv.FormatUint(uint64(m), 10) + // In order to use virtiofsd, we must enable shared memory + *q = append(*q, "-object", fmt.Sprintf("memory-backend-memfd,id=mem,size=%sM,share=on", serializedMem)) + *q = append(*q, "-m", serializedMem) +} diff --git a/pkg/machine/qemu/command/command_windows.go b/pkg/machine/qemu/command/command_windows.go new file mode 100644 index 0000000000..61a5ffa4a0 --- /dev/null +++ b/pkg/machine/qemu/command/command_windows.go @@ -0,0 +1,15 @@ +//go:build windows + +package command + +import ( + "strconv" + + "github.com/containers/common/pkg/strongunits" +) + +// SetMemory adds the specified amount of memory for the machine +func (q *QemuCmd) SetMemory(m strongunits.MiB) { + serializedMem := strconv.FormatUint(uint64(m), 10) + *q = append(*q, "-m", serializedMem) +} diff --git a/pkg/machine/qemu/config.go b/pkg/machine/qemu/config.go index 7d86bb6349..760df18ead 100644 --- a/pkg/machine/qemu/config.go +++ b/pkg/machine/qemu/config.go @@ -1,4 +1,4 @@ -//go:build !darwin && !windows +//go:build !darwin package qemu diff --git a/pkg/machine/qemu/machine.go b/pkg/machine/qemu/machine.go index 64fb04a73d..1a33ba3b01 100644 --- a/pkg/machine/qemu/machine.go +++ b/pkg/machine/qemu/machine.go @@ -1,4 +1,4 @@ -//go:build linux || freebsd +//go:build linux || freebsd || windows package qemu diff --git a/pkg/machine/qemu/machine_unsupported.go b/pkg/machine/qemu/machine_unsupported.go deleted file mode 100644 index d3b969dd40..0000000000 --- a/pkg/machine/qemu/machine_unsupported.go +++ /dev/null @@ -1,3 +0,0 @@ -//go:build !amd64 && !arm64 && darwin - -package qemu diff --git a/pkg/machine/qemu/options_windows_amd64.go b/pkg/machine/qemu/options_windows_amd64.go index 1a929a5f32..6e0ba0271a 100644 --- a/pkg/machine/qemu/options_windows_amd64.go +++ b/pkg/machine/qemu/options_windows_amd64.go @@ -1,4 +1,4 @@ -//go:build tempoff +//go:build windows && amd64 package qemu diff --git a/pkg/machine/qemu/stubber.go b/pkg/machine/qemu/stubber.go index d9d657db3e..a1fee675b7 100644 --- a/pkg/machine/qemu/stubber.go +++ b/pkg/machine/qemu/stubber.go @@ -1,4 +1,4 @@ -//go:build linux || freebsd +//go:build linux || freebsd || windows package qemu diff --git a/pkg/machine/qemu/virtiofsd.go b/pkg/machine/qemu/virtiofsd.go index fe2c697006..29f6ba215c 100644 --- a/pkg/machine/qemu/virtiofsd.go +++ b/pkg/machine/qemu/virtiofsd.go @@ -1,4 +1,4 @@ -//go:build linux || freebsd +//go:build linux || freebsd || windows package qemu diff --git a/pkg/machine/vmconfigs/config_windows.go b/pkg/machine/vmconfigs/config_windows.go index be39e2f953..bbb694412b 100644 --- a/pkg/machine/vmconfigs/config_windows.go +++ b/pkg/machine/vmconfigs/config_windows.go @@ -1,7 +1,9 @@ package vmconfigs import ( + "github.com/containers/podman/v5/pkg/machine/define" "github.com/containers/podman/v5/pkg/machine/hyperv/vsock" + "github.com/containers/podman/v5/pkg/machine/qemu/command" ) type HyperVConfig struct { @@ -17,10 +19,16 @@ type WSLConfig struct { UserModeNetworking bool } +type QEMUConfig struct { + // QMPMonitor is the qemu monitor object for sending commands + QMPMonitor command.Monitor + // QEMUPidPath is where to write the PID for QEMU when running + QEMUPidPath *define.VMFile +} + // Stubs type AppleHVConfig struct{} type LibKrunConfig struct{} -type QEMUConfig struct{} func getHostUID() int { return 1000