Fix compilation issues in QEMU machine files (Windows platform)

Signed-off-by: Arthur Sengileyev <arthur.sengileyev@gmail.com>
This commit is contained in:
Arthur Sengileyev
2024-11-27 17:13:28 +02:00
parent ceee7cb0a6
commit 7f6a203558
10 changed files with 47 additions and 18 deletions

View File

@@ -10,7 +10,6 @@ import (
"strconv" "strconv"
"time" "time"
"github.com/containers/common/pkg/strongunits"
"github.com/containers/podman/v5/pkg/machine/define" "github.com/containers/podman/v5/pkg/machine/define"
"github.com/containers/storage/pkg/fileutils" "github.com/containers/storage/pkg/fileutils"
) )
@@ -33,14 +32,6 @@ func NewQemuBuilder(binary string, options []string) QemuCmd {
return append(q, options...) 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 // SetCPUs adds the number of CPUs the machine will have
func (q *QemuCmd) SetCPUs(c uint64) { func (q *QemuCmd) SetCPUs(c uint64) {
*q = append(*q, "-smp", strconv.FormatUint(c, 10)) *q = append(*q, "-smp", strconv.FormatUint(c, 10))

View File

@@ -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)
}

View File

@@ -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)
}

View File

@@ -1,4 +1,4 @@
//go:build !darwin && !windows //go:build !darwin
package qemu package qemu

View File

@@ -1,4 +1,4 @@
//go:build linux || freebsd //go:build linux || freebsd || windows
package qemu package qemu

View File

@@ -1,3 +0,0 @@
//go:build !amd64 && !arm64 && darwin
package qemu

View File

@@ -1,4 +1,4 @@
//go:build tempoff //go:build windows && amd64
package qemu package qemu

View File

@@ -1,4 +1,4 @@
//go:build linux || freebsd //go:build linux || freebsd || windows
package qemu package qemu

View File

@@ -1,4 +1,4 @@
//go:build linux || freebsd //go:build linux || freebsd || windows
package qemu package qemu

View File

@@ -1,7 +1,9 @@
package vmconfigs package vmconfigs
import ( 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/hyperv/vsock"
"github.com/containers/podman/v5/pkg/machine/qemu/command"
) )
type HyperVConfig struct { type HyperVConfig struct {
@@ -17,10 +19,16 @@ type WSLConfig struct {
UserModeNetworking bool 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 // Stubs
type AppleHVConfig struct{} type AppleHVConfig struct{}
type LibKrunConfig struct{} type LibKrunConfig struct{}
type QEMUConfig struct{}
func getHostUID() int { func getHostUID() int {
return 1000 return 1000