Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions src/libvfio/control/iommu.nim
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import ../types
type
Physical = object ## Internal structure to help us with sorting
## the files.
numVfs: Positive ## Number of virtual functions exposed by the PCI.
numVfs: Positive = 1 ## Number of virtual functions exposed by the PCI.
baseDir: string ## Base directory holding the physical device.
case kind: VfioTypes
of vtGPU:
Expand Down Expand Up @@ -149,9 +149,10 @@ proc getVfios*(cfg: Config, uuid: string, monad: CommandMonad): seq[Vfio] =
result = (ret, newList)

func lowCpuLoadSort(a, b: (string, seq[Physical])): int =
const
# Nim is complaining about this syntax
f = (y: seq[Physical]) => sum(map(y, (x: Physical) => x.numVfs))

proc f(y: seq[Physical]): int =
result = sum(map(y, proc (x: Physical): int = x.numVfs))

let
aSum: int = f(a[1])
bSum: int = f(b[1])
Expand Down
3 changes: 2 additions & 1 deletion src/libvfio/types/config.nim
Original file line number Diff line number Diff line change
Expand Up @@ -372,5 +372,6 @@ proc writeConfigFile*(s: string, cfg: Config) =
##
## Side effects - Writes a configuration file.
let fileStream = newFileStream(s, fmWrite)
dump(cfg, fileStream)
let dumper = canonicalDumper()
dumper.dump(cfg, fileStream)
close(fileStream)