Skip to content

Commit

Permalink
refactor: Clarify "shared resource" vs "MAP_SHARED" terminology
Browse files Browse the repository at this point in the history
  • Loading branch information
pojntfx committed Jul 5, 2024
1 parent 8ae09dc commit daf1748
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 42 deletions.
8 changes: 4 additions & 4 deletions cmd/drafter-peer/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,8 @@ func main() {

mapShared := flag.Bool("map-shared", true, "Whether to use MAP_SHARED for memory and state devices")

stateOutput := flag.String("state-output", "", "Path to write the changed state to (leave empty to write back to device directly) (ignored if `--map-shared=true`)")
memoryOutput := flag.String("memory-output", "", "Path to write the changed memory to (leave empty to write back to device directly) (ignored if `--map-shared=true`)")
sharedStateOutput := flag.String("shared-state-output", "", "Path to write the local changes to the shared state to (leave empty to write back to device directly) (ignored if --map-shared=true)")
sharedMemoryOutput := flag.String("shared-memory-output", "", "Path to write the local changes to the shared memory to (leave empty to write back to device directly) (ignored if --map-shared=true)")

defaultDevices, err := json.Marshal([]CompositeDevices{
{
Expand Down Expand Up @@ -399,8 +399,8 @@ func main() {

*mapShared,

*stateOutput,
*memoryOutput,
*sharedStateOutput,
*sharedMemoryOutput,
)

if err != nil {
Expand Down
52 changes: 26 additions & 26 deletions cmd/drafter-runner/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,45 +19,45 @@ import (
)

type SharableDevice struct {
Name string `json:"name"`
Path string `json:"path"`
MapShared bool `json:"mapShared"`
Name string `json:"name"`
Path string `json:"path"`
Shared bool `json:"shared"`
}

func main() {
defaultDevices, err := json.Marshal([]SharableDevice{
{
Name: roles.StateName,
Path: filepath.Join("out", "package", "state.bin"),
MapShared: false,
Name: roles.StateName,
Path: filepath.Join("out", "package", "state.bin"),
Shared: false,
},
{
Name: roles.MemoryName,
Path: filepath.Join("out", "package", "memory.bin"),
MapShared: false,
Name: roles.MemoryName,
Path: filepath.Join("out", "package", "memory.bin"),
Shared: false,
},

{
Name: roles.KernelName,
Path: filepath.Join("out", "package", "vmlinux"),
MapShared: false,
Name: roles.KernelName,
Path: filepath.Join("out", "package", "vmlinux"),
Shared: false,
},
{
Name: roles.DiskName,
Path: filepath.Join("out", "package", "rootfs.ext4"),
MapShared: false,
Name: roles.DiskName,
Path: filepath.Join("out", "package", "rootfs.ext4"),
Shared: false,
},

{
Name: roles.ConfigName,
Path: filepath.Join("out", "package", "config.json"),
MapShared: false,
Name: roles.ConfigName,
Path: filepath.Join("out", "package", "config.json"),
Shared: false,
},

{
Name: "oci",
Path: filepath.Join("out", "blueprint", "oci.ext4"),
MapShared: false,
Name: "oci",
Path: filepath.Join("out", "blueprint", "oci.ext4"),
Shared: false,
},
})
if err != nil {
Expand Down Expand Up @@ -85,8 +85,8 @@ func main() {

mapShared := flag.Bool("map-shared", true, "Whether to use MAP_SHARED for memory and state devices")

stateOutput := flag.String("state-output", "", "Path to write the changed state to (leave empty to write back to device directly) (ignored if --map-shared=true)")
memoryOutput := flag.String("memory-output", "", "Path to write the changed memory to (leave empty to write back to device directly) (ignored if --map-shared=true)")
sharedStateOutput := flag.String("shared-state-output", "", "Path to write the local changes to the shared state to (leave empty to write back to device directly) (ignored if --map-shared=true)")
sharedMemoryOutput := flag.String("shared-memory-output", "", "Path to write the local changes to the shared memory to (leave empty to write back to device directly) (ignored if --map-shared=true)")

rawDevices := flag.String("devices", string(defaultDevices), "Devices configuration")

Expand Down Expand Up @@ -249,7 +249,7 @@ func main() {
}()

file := ""
if device.MapShared {
if device.Shared {
file = device.Path
} else {
mnt := utils.NewLoopMount(device.Path)
Expand Down Expand Up @@ -304,8 +304,8 @@ func main() {

*mapShared,

*stateOutput,
*memoryOutput,
*sharedStateOutput,
*sharedMemoryOutput,
)

if err != nil {
Expand Down
12 changes: 6 additions & 6 deletions pkg/roles/peer.go
Original file line number Diff line number Diff line change
Expand Up @@ -115,8 +115,8 @@ type MigratedPeer struct {

mapShared bool,

stateOutput,
memoryOutput string,
sharedStateOutput,
sharedMemoryOutput string,
) (
resumedPeer *ResumedPeer,

Expand Down Expand Up @@ -827,8 +827,8 @@ func StartPeer(

mapShared bool,

stateOutput,
memoryOutput string,
sharedStateOutput,
sharedMemoryOutput string,
) (resumedPeer *ResumedPeer, errs error) {
configBasePath := ""
for _, device := range devices {
Expand Down Expand Up @@ -863,8 +863,8 @@ func StartPeer(

mapShared,

stateOutput,
memoryOutput,
sharedStateOutput,
sharedMemoryOutput,
)
if err != nil {
return nil, errors.Join(ErrCouldNotResumeRunner, err)
Expand Down
12 changes: 6 additions & 6 deletions pkg/roles/runner.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,8 @@ type Runner struct {

mapShared bool,

stateOutput,
memoryOutput string,
sharedStateOutput,
sharedMemoryOutput string,
) (
resumedRunner *ResumedRunner,

Expand Down Expand Up @@ -212,8 +212,8 @@ func StartRunner(

mapShared bool,

stateOutput,
memoryOutput string,
sharedStateOutput,
sharedMemoryOutput string,
) (
resumedRunner *ResumedRunner,

Expand Down Expand Up @@ -274,8 +274,8 @@ func StartRunner(
}

for _, device := range [][3]string{
{stateName, stateCopyName, stateOutput},
{memoryName, memoryCopyName, memoryOutput},
{stateName, stateCopyName, sharedStateOutput},
{memoryName, memoryCopyName, sharedMemoryOutput},
} {
inputFile, err := os.Open(filepath.Join(server.VMPath, device[1]))
if err != nil {
Expand Down

0 comments on commit daf1748

Please sign in to comment.