Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Set machine other than "q35" if not on X86. #143

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

ikitayama
Copy link
Collaborator

Architecture is checked by looking at the arch variable which is set at the top of run_qemu.sh.

Introduce a new variable, arch.
@ikitayama ikitayama requested a review from stellarhopper as a code owner April 2, 2025 07:24
@@ -1509,7 +1511,11 @@ prepare_qcmd()
if [[ $_arg_kvm = "off" ]]; then
accel="tcg" # the default
fi
machine_args=("q35" "accel=$accel")
if [[ $(arch) != "aarch64" ]]; then
Copy link
Member

@stellarhopper stellarhopper Apr 2, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The negative check is awkward to read, it should be flipped around, but additionally, I'm thinking instead of a situation where we do something for arm vs something else for anything else, it might be clearer to make it more explicit?

i.e. something like:

case $arch in
x86_64)
    <stuff>
    ;;
aarch64)
    <stuff>
    ;;
*)
    fail "Running on $arch is not supported
    ;;
esac

It does depend a bit on how many of these we have to sprinkle around. It could be worth seeing if the places that need arm specific changes can be consolidated together a bit more first, and then we have arch-specific functions to do those.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking ahead, the negative if pattern follows in all the other PRs too, but I think a lot of that can be consolidated into an arch specific setup function which is called early on, and sets up variables for say things like where to find the kernel image etc. @marc-hb Thoughts on this arch specific 'setup' function approach vs something else?

One other approach I can think of would be to have a set of arch_do_thing() type helpers, and they could live in separate arch-specific files, and at the start, $arch decides which of the files to source. That can be cleaner overall, but could also make it a bit harder to follow what's coming from where for future debugging/changes.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Even if most combinations do not work yet, let's please separate host_arch and guest_arch from the very beginning. I suspect only "homogeneous" configurations will only work initially and be better tested and maintained going forward but QEMU is... an emulator after all! So, run_qemu.sh should really not get in the way of someone wanting to try some "heterogenous" configuration where host_arch and guest_arch are different.

host_arch should be initialized from uname or similar, while guest_arch can default to host_arch for now. Later, guest_arch could be configurable somehow.

but I think a lot of that can be consolidated into an arch specific setup function which is called early on, and sets up variables for say things like where to find the kernel image etc
@marc-hb Thoughts on this arch specific 'setup' function approach vs something else?

Agreed, let's try to have all the arch-specific logic and configuration centralized in a small number of setup functions and/or files in order to keep the rest of the code simple, only referencing already initialized variables like for instance guest_arch_machine=virt,highmem=on.

but could also make it a bit harder to follow what's coming from where for future debugging/changes.

I think it's easier to have arch-specific configuration more centralized.

PS: in #140 (comment), @ikitayama you wrote that you are testing ARM64 on an M1 mac but you didn't say whether the M1 is running Linux or macOS? I'd be amazed if run_qemu works on macOS :-)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed on the host_arch vs guest_arch distinction.

I think I'd slightly prefer the separate files that are sourced route for this instead of making the main script even longer with copies of arch specific setup functions.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@marc-hb I'm running the run_qemu.sh script on an Ubuntu 24.10 VM on an M1 powered by macOS Sequoia 15.4. I never tested run_qemu on macOS.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think I'd slightly prefer the separate files that are sourced

How about this middle ground: inside the script for host_arch stuff and outside for guest_arch stuff? host_arch is logically more "hardcoded" / not configurable.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm running the run_qemu.sh script on an Ubuntu 24.10 VM on an M1 powered by macOS Sequoia 15.4.

So you got two, "stacked" layers of emulation! Which means it should be possible to run some tests in GitHub Actions...

PS: I know people have been raving about M1 performance but I would really recommend a server-class host to test run_qemu.sh changes if you can find one... "Plain" users can leverage incremental build tricks but making changes to run_qemu.sh itself very often requires build from scratch.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@marc-hb @stellarhopper do you guys want to come up with a unified framework and I need to restart work from the refined run_qemu.sh?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll get a skeleton started.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll get a skeleton started.

Done and tested in #160. @stellarhopper can you please review?

Copy link
Collaborator

@marc-hb marc-hb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

marc-hb added a commit to marc-hb/run_qemu that referenced this pull request Apr 9, 2025
Initial support for q35 and "virt". Default to the host architecture.

Progress towards supporting ARM64 as discussed in pmem#140, pmem#143 and others.

Signed-off-by: Marc Herbert <marc.herbert@intel.com>
ikitayama pushed a commit to ikitayama/run_qemu that referenced this pull request Apr 9, 2025
Initial support for q35 and "virt". Default to the host architecture.

Progress towards supporting ARM64 as discussed in pmem#140, pmem#143 and others.

Signed-off-by: Marc Herbert <marc.herbert@intel.com>
marc-hb added a commit to marc-hb/run_qemu that referenced this pull request Apr 9, 2025
Initial support for q35 and "virt". Default to the host architecture.

Progress towards supporting ARM64 as discussed in pmem#140, pmem#143 and others.

Signed-off-by: Marc Herbert <marc.herbert@intel.com>
marc-hb added a commit to marc-hb/run_qemu that referenced this pull request Apr 9, 2025
Initial support for q35 and "virt". Default to the host architecture.

Progress towards supporting ARM64 as discussed in pmem#140, pmem#143 and others.

Signed-off-by: Marc Herbert <marc.herbert@intel.com>
marc-hb added a commit to marc-hb/run_qemu that referenced this pull request Apr 9, 2025
Progress towards supporting ARM64 as discussed in pmem#140, pmem#143 and others.

Signed-off-by: Marc Herbert <marc.herbert@intel.com>
marc-hb added a commit to marc-hb/run_qemu that referenced this pull request Apr 10, 2025
Progress towards supporting ARM64 as discussed in pmem#140, pmem#143 and others.

Signed-off-by: Marc Herbert <marc.herbert@intel.com>
Signed-off-by: Itaru Kitayama itaru.kitayama@fujitsu.com
Tested-by: Itaru Kitayama itaru.kitayama@fujitsu.com
marc-hb added a commit that referenced this pull request Apr 10, 2025
Progress towards supporting ARM64 as discussed in #140, #143 and others.

Signed-off-by: Marc Herbert <marc.herbert@intel.com>
Signed-off-by: Itaru Kitayama itaru.kitayama@fujitsu.com
Tested-by: Itaru Kitayama itaru.kitayama@fujitsu.com
@marc-hb
Copy link
Collaborator

marc-hb commented Apr 10, 2025

Superseded by #160

if [[ $(arch) != "aarch64" ]]; then
machine_args=("q35" "accel=$accel")
else
machine_args=("virt,highmem=on" "accel=$acel")
Copy link
Collaborator

@marc-hb marc-hb Apr 10, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This PR has been superseded by #160 but I forgot highmem=on, sorry.

@marc-hb marc-hb marked this pull request as draft April 10, 2025 06:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants