mirror of
https://github.com/containers/podman.git
synced 2025-11-30 10:07:33 +08:00
Fix compilation issues in QEMU machine files (Windows platform)
Signed-off-by: Arthur Sengileyev <arthur.sengileyev@gmail.com>
This commit is contained in:
@@ -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))
|
||||||
|
|||||||
18
pkg/machine/qemu/command/command_unix.go
Normal file
18
pkg/machine/qemu/command/command_unix.go
Normal 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)
|
||||||
|
}
|
||||||
15
pkg/machine/qemu/command/command_windows.go
Normal file
15
pkg/machine/qemu/command/command_windows.go
Normal 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)
|
||||||
|
}
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
//go:build !darwin && !windows
|
//go:build !darwin
|
||||||
|
|
||||||
package qemu
|
package qemu
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
//go:build linux || freebsd
|
//go:build linux || freebsd || windows
|
||||||
|
|
||||||
package qemu
|
package qemu
|
||||||
|
|
||||||
|
|||||||
@@ -1,3 +0,0 @@
|
|||||||
//go:build !amd64 && !arm64 && darwin
|
|
||||||
|
|
||||||
package qemu
|
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
//go:build tempoff
|
//go:build windows && amd64
|
||||||
|
|
||||||
package qemu
|
package qemu
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
//go:build linux || freebsd
|
//go:build linux || freebsd || windows
|
||||||
|
|
||||||
package qemu
|
package qemu
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
//go:build linux || freebsd
|
//go:build linux || freebsd || windows
|
||||||
|
|
||||||
package qemu
|
package qemu
|
||||||
|
|
||||||
|
|||||||
@@ -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
|
||||||
|
|||||||
Reference in New Issue
Block a user