Skip to content

Commit 7b35f4f

Browse files
Merge pull request #24694 from arixmkii/update-qemu-files
RFC: Fix compilation issues in QEMU machine files (Windows platform)
2 parents 50a0429 + 7f6a203 commit 7b35f4f

10 files changed

+47
-18
lines changed

pkg/machine/qemu/command/command.go

-9
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ import (
1010
"strconv"
1111
"time"
1212

13-
"github.com/containers/common/pkg/strongunits"
1413
"github.com/containers/podman/v5/pkg/machine/define"
1514
"github.com/containers/storage/pkg/fileutils"
1615
)
@@ -33,14 +32,6 @@ func NewQemuBuilder(binary string, options []string) QemuCmd {
3332
return append(q, options...)
3433
}
3534

36-
// SetMemory adds the specified amount of memory for the machine
37-
func (q *QemuCmd) SetMemory(m strongunits.MiB) {
38-
serializedMem := strconv.FormatUint(uint64(m), 10)
39-
// In order to use virtiofsd, we must enable shared memory
40-
*q = append(*q, "-object", fmt.Sprintf("memory-backend-memfd,id=mem,size=%sM,share=on", serializedMem))
41-
*q = append(*q, "-m", serializedMem)
42-
}
43-
4435
// SetCPUs adds the number of CPUs the machine will have
4536
func (q *QemuCmd) SetCPUs(c uint64) {
4637
*q = append(*q, "-smp", strconv.FormatUint(c, 10))
+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
//go:build dragonfly || freebsd || linux || netbsd || openbsd
2+
3+
package command
4+
5+
import (
6+
"fmt"
7+
"strconv"
8+
9+
"github.com/containers/common/pkg/strongunits"
10+
)
11+
12+
// SetMemory adds the specified amount of memory for the machine
13+
func (q *QemuCmd) SetMemory(m strongunits.MiB) {
14+
serializedMem := strconv.FormatUint(uint64(m), 10)
15+
// In order to use virtiofsd, we must enable shared memory
16+
*q = append(*q, "-object", fmt.Sprintf("memory-backend-memfd,id=mem,size=%sM,share=on", serializedMem))
17+
*q = append(*q, "-m", serializedMem)
18+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
//go:build windows
2+
3+
package command
4+
5+
import (
6+
"strconv"
7+
8+
"github.com/containers/common/pkg/strongunits"
9+
)
10+
11+
// SetMemory adds the specified amount of memory for the machine
12+
func (q *QemuCmd) SetMemory(m strongunits.MiB) {
13+
serializedMem := strconv.FormatUint(uint64(m), 10)
14+
*q = append(*q, "-m", serializedMem)
15+
}

pkg/machine/qemu/config.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
//go:build !darwin && !windows
1+
//go:build !darwin
22

33
package qemu
44

pkg/machine/qemu/machine.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
//go:build linux || freebsd
1+
//go:build linux || freebsd || windows
22

33
package qemu
44

pkg/machine/qemu/machine_unsupported.go

-3
This file was deleted.

pkg/machine/qemu/options_windows_amd64.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
//go:build tempoff
1+
//go:build windows && amd64
22

33
package qemu
44

pkg/machine/qemu/stubber.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
//go:build linux || freebsd
1+
//go:build linux || freebsd || windows
22

33
package qemu
44

pkg/machine/qemu/virtiofsd.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
//go:build linux || freebsd
1+
//go:build linux || freebsd || windows
22

33
package qemu
44

pkg/machine/vmconfigs/config_windows.go

+9-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
package vmconfigs
22

33
import (
4+
"github.com/containers/podman/v5/pkg/machine/define"
45
"github.com/containers/podman/v5/pkg/machine/hyperv/vsock"
6+
"github.com/containers/podman/v5/pkg/machine/qemu/command"
57
)
68

79
type HyperVConfig struct {
@@ -17,10 +19,16 @@ type WSLConfig struct {
1719
UserModeNetworking bool
1820
}
1921

22+
type QEMUConfig struct {
23+
// QMPMonitor is the qemu monitor object for sending commands
24+
QMPMonitor command.Monitor
25+
// QEMUPidPath is where to write the PID for QEMU when running
26+
QEMUPidPath *define.VMFile
27+
}
28+
2029
// Stubs
2130
type AppleHVConfig struct{}
2231
type LibKrunConfig struct{}
23-
type QEMUConfig struct{}
2432

2533
func getHostUID() int {
2634
return 1000

0 commit comments

Comments
 (0)