Skip to content

Commit

Permalink
livemedia-creator: Use /usr/libexec/qemu-kvm on supported arches
Browse files Browse the repository at this point in the history
For RHEL qemu support is limited, and only qemu-kvm is supported. This
updates lmc to only support it on x86 and aarch64.
It also disables cross-arch building, it is only supported on the same
arch as the host.

Related: RHEL-31830
  • Loading branch information
bcl committed May 31, 2024
1 parent 05bad3f commit 7a52719
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 28 deletions.
2 changes: 1 addition & 1 deletion src/pylorax/creator.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@


# Default parameters for rebuilding initramfs, override with --dracut-arg or --dracut-conf
DRACUT_DEFAULT = ["--xz", "--add", "livenet dmsquash-live dmsquash-live-ntfs convertfs pollcdrom qemu qemu-net",
DRACUT_DEFAULT = ["--xz", "--add", "livenet dmsquash-live convertfs pollcdrom qemu qemu-net",
"--no-hostonly", "--debug", "--no-early-microcode"]

RUNTIME = "images/install.img"
Expand Down
34 changes: 10 additions & 24 deletions src/pylorax/installer.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,36 +137,21 @@ class QEMUInstall(object):
"""
# Mapping of arch to qemu command and options
QEMU = {"x86_64": {
"cmd": "qemu-system-x86_64",
"arches": ["x86_64", "i386"],
"cmd": "/usr/libexec/qemu-kvm",
"arches": ["x86_64"],
"machine": "q35",
"uefi": ["ovmf/OVMF_CODE.secboot.fd", "ovmf/OVMF_VARS.secboot.fd"],
"uefi_machine": "q35,smm=on",
"uefi_args": ["-global", "driver=cfi.pflash01,property=secure,value=on"],
},
"i386": {
"cmd": "qemu-system-i386",
"arches": ["i386"],
"machine": "q35",
},
"arm": {
"cmd": "qemu-system-arm",
"arches": ["arm"],
"machine": "virt",
},
"aarch64": {
"cmd": "qemu-system-aarch64",
"arches": ["aarch64", "arm"],
"cmd": "/usr/libexec/qemu-kvm",
"arches": ["aarch64"],
"machine": "virt",
"uefi": ["aarch64/QEMU_EFI-pflash.raw", "aarch64/vars-template-pflash.raw"],
"uefi_machine": "virt",
"uefi_args": ["-global", "driver=cfi.pflash01,property=secure,value=off"],
},
"ppc64le": {
"cmd": "qemu-system-ppc64",
"arches": ["ppc64le"],
"machine": "pseries",
},
}

def __init__(self, opts, iso, ks_paths, disk_img, img_size=2048,
Expand All @@ -186,7 +171,7 @@ def __init__(self, opts, iso, ks_paths, disk_img, img_size=2048,
:param int memory: Amount of RAM to assign to the virt, in MiB
:param int vcpus: Number of virtual cpus
:param str vnc: Arguments to pass to qemu -display
:param str arch: Optional architecture to use in the virt
:param str arch: Unsupported on RHEL10
:param cancel_func: Function that returns True if the installation fails
:type cancel_func: function
:param str virtio_host: Hostname to connect virtio log to
Expand All @@ -197,12 +182,10 @@ def __init__(self, opts, iso, ks_paths, disk_img, img_size=2048,
"""
target_arch = arch or os.uname().machine
# Lookup qemu-system- for arch if passed, or try to guess using host arch
if target_arch in self.QEMU:
if target_arch in self.QEMU and os.path.exists(self.QEMU[target_arch]["cmd"]):
qemu_cmd = [self.QEMU[target_arch]["cmd"]]
elif os.path.exists("/usr/bin/"+"qemu-system-"+os.uname().machine):
qemu_cmd = ["/usr/bin/qemu-system-"+os.uname().machine]
else:
raise InstallError("/usr/bin/qemu-system-%s does not exist, cannot run qemu" % os.uname().machine)
raise InstallError("RHEL10 does not support running qemu on %s" % os.uname().machine)

# Default to using the host cpu capabilities
qemu_cmd += ["-cpu", opts.cpu or "host"]
Expand Down Expand Up @@ -269,6 +252,9 @@ def __init__(self, opts, iso, ks_paths, disk_img, img_size=2048,
log.info("qemu %s", display_args)
qemu_cmd += ["-nographic", "-monitor", "none", "-serial", "null", "-display", display_args ]

# Setup virtio networking
qemu_cmd += ["-netdev", "user,id=n1", "-device", "virtio-net-pci,netdev=n1"]

# Setup the virtio log port
qemu_cmd += ["-device", "virtio-serial-pci,id=virtio-serial0"]
qemu_cmd += ["-device", "virtserialport,bus=virtio-serial0.0,nr=1,chardev=charchannel0"
Expand Down
8 changes: 5 additions & 3 deletions src/sbin/livemedia-creator
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
import logging
log = logging.getLogger("livemedia-creator")

import glob
import os
import sys
import tempfile
Expand Down Expand Up @@ -87,8 +86,8 @@ def main():
errors.append("the volume id cannot be longer than 32 characters")

if is_install and not opts.no_virt \
and not any(glob.glob("/usr/bin/qemu-system-*")):
errors.append("qemu needs to be installed.")
and not os.path.exists("/usr/libexec/qemu-kvm"):
errors.append("qemu-kvm needs to be installed.")

if is_install and opts.no_virt \
and not os.path.exists("/usr/sbin/anaconda"):
Expand Down Expand Up @@ -147,6 +146,9 @@ def main():
if opts.domacboot and not os.path.exists("/usr/sbin/mkfs.hfsplus"):
errors.append("mkfs.hfsplus is missing. Install hfsplus-tools, or pass --nomacboot")

if opts.arch != None:
errors.append("RHEL10 only supports virt for the host arch.")

if os.getuid() != 0:
errors.append("You need to run this as root")

Expand Down

0 comments on commit 7a52719

Please sign in to comment.