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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

RHEL 9 kernel panic on Packer launched qemu-kvm #76

Closed
hc-github-team-packer opened this issue Jun 9, 2022 · 4 comments 路 Fixed by #114
Closed

RHEL 9 kernel panic on Packer launched qemu-kvm #76

hc-github-team-packer opened this issue Jun 9, 2022 · 4 comments 路 Fixed by #114

Comments

@hc-github-team-packer
Copy link

This issue was originally opened by @myllynen in hashicorp/packer#11839 and has been migrated to this repository. The original issue description is below.


Community Note

  • Please vote on this issue by adding a 馃憤 reaction to the original issue to help the community and maintainers prioritize this request
  • Please do not leave "+1" or other comments that do not add relevant new information or questions, they generate extra noise for issue followers and do not help prioritize the request
  • If you are interested in working on this issue or have submitted a pull request, please leave a comment

When filing a bug, please include the following headings if possible. Any
example text in this template can be deleted.

Description of the Issue

When trying to create a RHEL 9 VM with Packer + Qemu builder running on RHEL 7.9, the installer fails due to kernel panic. See the screenshot at the below mentioned other report. The relevant part of qemu-kvm command line is:

/usr/libexec/qemu-kvm -m 4096M ... -machine type=pc,accel=kvm -smp cpus=2,sockets=2

If configuring Packer to add "-cpu host" to qemu-kvm command line then the installer starts normally. Another user reported the same issue elsewhere and fixed this slightly differently: https://discuss.hashicorp.com/t/packer-qemu-kvm-redhat-9-kernel-panic/39886.

I'm not sure what's the root cause for this so I'm filing the issue for both Red Hat and Packer, hopefully either or both sides can be tweaked to fix this issue. Thanks.

Version information:
RHEL 9.0 / Packer 1.8.1

@myllynen
Copy link

Red Hat has closed the RHEL bug report, please see the following BZs for details:

https://bugzilla.redhat.com/show_bug.cgi?id=2060839
https://bugzilla.redhat.com/show_bug.cgi?id=2094260

Red Hat is suggesting that ideally Packer should use libvirt instead of qemu-kvm directly but since it might require quite some work initially avoiding issue by adding -cpu host the the qemu-kvm command line might be suitable workaround for this.

@joubbi
Copy link

joubbi commented Dec 29, 2022

What is the status of this issue? My guess is that other distributions will start doing the same thing as Red Hat.

What is the "best" workarund?
Is it better to do this:

  qemuargs                = [
    [
      "-cpu",
      "host,x2apic=on,tsc-deadline=on,hypervisor=on,tsc-adjust=on,erms=on,vaes=on,vpclmulqdq=on,",
      "spec-ctrl=on,stibp=on,arch-capabilities=on,ssbd=on,xsaves=on,cmp-legacy=on,ibrs=on,",
      "amd-ssbd=on,virt-ssbd=on,rdctl-no=on,skip-l1dfl-vmentry=on,mds-no=on,pschange-mc-no=on"
    ]
  ]

Compared with just -cpu host ?

@lbajolet-hashicorp
Copy link
Contributor

lbajolet-hashicorp commented Jan 6, 2023

Hi @joubbi,

According to the qemu documentation, -cpu host will support everything your host CPU supports, so I would imagine the following flags are probably not useful, as you will effectively be limited by what is supported by the host CPU (scratch that, not everything is enabled by default, see: https://qemu.readthedocs.io/en/latest/system/qemu-cpu-models.html#important-cpu-features-for-intel-x86-hosts for more information).

Regarding this issue, this is indeed a problem for users that are on a RHEL 9+ system (and if it generalises to other distributions this will become a bigger issue indeed), so this warrants some more thoughts on our part to make the experience smoother for them, but we also don't want to break existing workflows, as much as we can at least.

I think we can probably introduce a cpu (name subject to change) attribute to the supported configuration for the plugin, that way we can make it clear that it is settable through this, and not through the more obscure qemu_args. Having a specialised attribute for this purpose would also let us document this potential roadblock for RHEL users, and document the recommended workaround.

As for the default value, I can imagine that either host or max may be good. Though host will only work in virtualised environments (i.e. not for TCG-backed emulation), and I'm not yet sure what max implies, so that needs a bit of testing on our part to figure out what would be a sane default value here.

Regarding Redhat's suggestion to use libvirt rather than invoking qemu directly, this is out-of-scope for this plugin, but this may signal that we need to think into investing more effort towards the libvirt Packer plugin in the future.

I'll keep this issue updated, thanks for bringing this up again!

@anish
Copy link
Contributor

anish commented Jan 24, 2023

Not sure if this is the same problem as you have, but we had to modify qemu args for RHEL9 as follows :

          "qemuargs": [
                  ["-cpu", "host,+nx"]
          ],

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 a pull request may close this issue.

5 participants