Conversation
Fixes the following error observed on macOS hosts:
Traceback (most recent call last):
File "/Users/nick/Code/python/boot-utils/boot-qemu.py", line 724, in <module>
cfg = setup_cfg(args)
File "/Users/nick/Code/python/boot-utils/boot-qemu.py", line 242, in setup_cfg
"smp_value": get_smp_value(args),
File "/Users/nick/Code/python/boot-utils/boot-qemu.py", line 198, in get_smp_value
usable_cpus = len(os.sched_getaffinity(0))
AttributeError: module 'os' has no attribute 'sched_getaffinity'
The issue is that the `os` module in python does not have a
`sched_getaffinity` method on macOS.
Signed-off-by: Nick Desaulniers <nick.desaulniers@gmail.com>
Fixes the following observed exceptions:
Traceback (most recent call last):
File "/Users/nick/Code/python/boot-utils/boot-qemu.py", line 725, in <module>
cfg = get_qemu_args(cfg)
File "/Users/nick/Code/python/boot-utils/boot-qemu.py", line 451, in get_qemu_args
linux_ver_code = get_linux_ver_code(gzip_kernel_cmd)
File "/Users/nick/Code/python/boot-utils/boot-qemu.py", line 329, in get_linux_ver_code
for line in strings.stdout.decode("UTF-8").split("\n"):
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xfa in position 3: invalid start byte
I'm not sure precisely why we get non-utf8-decodable bytes from Apple
strings command.
Signed-off-by: Nick Desaulniers <nick.desaulniers@gmail.com>
nathanchance
approved these changes
Nov 13, 2022
nathanchance
left a comment
Member
There was a problem hiding this comment.
One nit if you care to address it. LGTM regardless.
| # Use the minimum of the number of usable processors for the script or | ||
| # CONFIG_NR_CPUS. | ||
| usable_cpus = len(os.sched_getaffinity(0)) | ||
| usable_cpus = os.cpu_count() |
Member
There was a problem hiding this comment.
I had originally gone with cpu_count() but switched to sched_getaffinity() after learning that it would respond to external resource limitations, such as limiting the number of cores that a program can actually use. I do not care much but we could do something like
usable_cpus = len(os.sched_getaffinity(0)) if hasattr(os, 'sched_getaffinity') else os.cpu_count()I do not care much though.
msfjarvis
approved these changes
Nov 14, 2022
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fix a few bugs so we can use this on macOS. Boot tested an aarch64 build.
I also needed to install
coreutilsthen add something to my~/.zshrcso thattimeoutwould be in my$PATHwithout agprefix.