livemedia-creator: RHEL9 only supports qemu-kvm

Return an error if --arch is passed, and drop the mapping to
qemu-system-<arch> from installer.py and replace it with
/usr/libexec/qemu-kvm

Resolves: rhbz#1955674
This commit is contained in:
Brian C. Lane 2021-04-30 14:43:23 -07:00
parent 04dccefa5b
commit b240c9bf1a
4 changed files with 15 additions and 18 deletions

View File

@ -103,13 +103,12 @@ Includes the full html documentation for lorax, livemedia-creator, and the pylor
%package lmc-virt
Summary: livemedia-creator libvirt dependencies
Requires: lorax = %{version}-%{release}
Requires: qemu
Requires: qemu-kvm
# Fedora edk2 builds currently only support these arches
%ifarch %{ix86} x86_64 %{arm} aarch64
Requires: edk2-ovmf
%endif
Recommends: qemu-kvm
%description lmc-virt
Additional dependencies required by livemedia-creator when using it with qemu.

View File

@ -48,7 +48,7 @@ from pylorax.sysutils import joinpaths, remove
# 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",
"--omit", "plymouth", "--no-hostonly", "--debug", "--no-early-microcode"]
RUNTIME = "images/install.img"

View File

@ -135,14 +135,6 @@ class QEMUInstall(object):
"""
Run qemu using an iso and a kickstart
"""
# Mapping of arch to qemu command
QEMU_CMDS = {"x86_64": "qemu-system-x86_64",
"i386": "qemu-system-i386",
"arm": "qemu-system-arm",
"aarch64": "qemu-system-aarch64",
"ppc64le": "qemu-system-ppc64"
}
def __init__(self, opts, iso, ks_paths, disk_img, img_size=2048,
kernel_args=None, memory=1024, vcpus=None, vnc=None, arch=None,
cancel_func=None, virtio_host="127.0.0.1", virtio_port=6080,
@ -160,7 +152,7 @@ class QEMUInstall(object):
: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 in RHEL9
: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
@ -169,9 +161,10 @@ class QEMUInstall(object):
:param bool boot_uefi: Use OVMF to boot the VM in UEFI mode
:param str ovmf_path: Path to the OVMF firmware
"""
# Lookup qemu-system- for arch if passed, or try to guess using host arch
qemu_cmd = [self.QEMU_CMDS.get(arch or os.uname().machine, "qemu-system-"+os.uname().machine)]
if not os.path.exists("/usr/bin/"+qemu_cmd[0]):
# RHEL9 only supports 1 path for the qemu-kvm binary
qemu_cmd = ["/usr/libexec/qemu-kvm", "-cpu", "host"]
if not os.path.exists(qemu_cmd[0]):
raise InstallError("%s does not exist, cannot run qemu" % qemu_cmd[0])
qemu_cmd += ["-no-user-config"]
@ -228,6 +221,9 @@ class QEMUInstall(object):
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"

View File

@ -20,7 +20,6 @@
import logging
log = logging.getLogger("livemedia-creator")
import glob
import os
import sys
import tempfile
@ -84,8 +83,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"):
@ -145,6 +144,9 @@ def main():
if not os.path.exists(joinpaths(opts.ovmf_path, f)):
errors.append("OVMF secure boot firmware file %s is missing from %s" % (f, opts.ovmf_path))
if opts.arch != None:
errors.append("RHEL9 only support virt for the host arch.")
if os.getuid() != 0:
errors.append("You need to run this as root")