已开启
lorax中livemedia-creator无法找到qemu #23
suichangyin创建于  2025年9月18日
suichangyin
2025年9月18日 创建

系统:openEuler 2403
内核:6.6.0-28.0.0.34.oe2403.x86_64

【场景描述】(如下载场景/使用文档场景/安装及迁移场景/其他场景)
使用openEuler制作live cd

【ISSUE描述】

  1. 使用livemedia-creator制作live cd时,总是提示qemu必须安装,无法制作成功

  2. 问题原因1
    livemedia-creator启动脚本和python代码中,代码判断qemu安装匹配错误

# cat /usr/sbin/livemedia-creator |grep -A 1 -B 1 qemu-system
    if is_install and not opts.no_virt \
       and not any(glob.glob("/usr/bin/qemu-system-*")):
        errors.append("qemu needs to be installed.")

# cat /usr/lib/python3.11/site-packages/pylorax/installer.py |grep qemu-system
    QEMU_CMDS = {"x86_64":  "qemu-system-x86_64",
                 "i386":    "qemu-system-i386",
                 "arm":     "qemu-system-arm",
                 "aarch64": "qemu-system-aarch64",
                 "ppc64le": "qemu-system-ppc64"

# rpm -qf /usr/sbin/livemedia-creator
lorax-34.1-5.oe2403.x86_64
  1. ks参数不再支持
    报错信息
04:21:11,800 INFO anaconda:anaconda: main: /sbin/anaconda 36.16.5-34.oe2403
04:21:11,801 WARNING anaconda:anaconda: stdout: Kernel boot argument 'ks' detected. Did you want to use 'inst.ks' for the installer instead?
04:21:11,801 WARNING anaconda:anaconda: stdout: All Anaconda kernel boot arguments are now required to use 'inst.' prefix!
04:21:11,801 WARNING anaconda:anaconda: stdout: #012############## Installer errors encountered during boot ###############012'ks' is deprecated and has been removed.#012All usage of Anaconda boot arguments without 'inst.' prefix was removed. Please use inst.ks instead.#012#012############ Installer errors encountered during boot end ############

问题原因:

# cat /usr/lib/python3.11/site-packages/pylorax/installer.py |grep ks=file
        cmdline_args = "ks=file:/%s" % os.path.basename(ks_paths[0])

应修改为 inst.ks=file:/%s

  1. image-minimizer报错
06:49:00,313 INFO anaconda:program: File "/mnt/sysimage/bin/image-minimizer", line 73, in add_pattern_rpm
06:49:00,313 INFO anaconda:program: rpms.add(hdr['name'].decode("utf8"))
06:49:00,313 INFO anaconda:program: ^^^^^^^^^^^^^^^^^^
06:49:00,313 INFO anaconda:program: AttributeError: 'str' object has no attribute 'decode'. Did you mean: 'encode'?

根据代码比对,应该去掉decode

    def add_pattern_rpm(self, rpms, pattern):
        if self.ts is None:
            if self.prefix is None:
                raise Exception('Must specify installation root for droprpm/keeprpm')
            self.ts = rpm.TransactionSet(self.prefix)
        mi = self.ts.dbMatch()
        mi.pattern('name', rpm.RPMMIRE_GLOB, pattern)
        not_found = True
        for hdr in mi:
            not_found = False
            rpms.add(hdr['name'])
        if self.verbose and not_found:
            print("%s package not found" % pattern)
  1. os.ftruncate错误
2025-09-18 16:07:24,961: Traceback (most recent call last):
  File "/sbin/livemedia-creator", line 207, in main
    (result_dir, disk_img) = run_creator(opts)
                             ^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/site-packages/pylorax/creator.py", line 708, in run_creator
    rc = make_runtime(opts, img_mount.mount_dir, work_dir, calculate_disk_size(opts, ks)/1024.0)
         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/site-packages/pylorax/creator.py", line 230, in make_runtime
    return rb.create_ext4_runtime(joinpaths(work_dir, RUNTIME), size=size,
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/site-packages/pylorax/treebuilder.py", line 251, in create_ext4_runtime
    imgutils.mkrootfsimg(self.vars.root, joinpaths(workdir, "LiveOS/rootfs.img"),
  File "/usr/lib/python3.11/site-packages/pylorax/imgutils.py", line 126, in mkrootfsimg
    mkext4img(rootdir, outfile, label=label, size=fssize)
  File "/usr/lib/python3.11/site-packages/pylorax/imgutils.py", line 511, in mkext4img
    mkfsimage("ext4", rootdir, outfile, size, mountargs=mountargs,
  File "/usr/lib/python3.11/site-packages/pylorax/imgutils.py", line 479, in mkfsimage
    with LoopDev(outfile, size) as loopdev:
         ^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/site-packages/pylorax/imgutils.py", line 345, in __init__
    mksparse(self.filename, size)
  File "/usr/lib/python3.11/site-packages/pylorax/imgutils.py", line 134, in mksparse
    os.ftruncate(fobj.fileno(), size)
TypeError: 'float' object cannot be interpreted as an integer

参考社区源码修复,强制转换size为int类型

def mksparse(outfile, size):
    '''use os.ftruncate to create a sparse file of the given size.'''
    with open(outfile, "w") as fobj:
        os.ftruncate(fobj.fileno(), int(size))
likedislike
Ssuichangyin
2025年9月18日 创建了任务
openeuler-ci-bot
openeuler-ci-bot成员
2025年9月18日 评论:

Hi suichangyin, welcome to the openEuler Community.
I'm the Bot here serving you. You can find the instructions on how to interact with me at Here.
If you have any questions, please contact the SIG: sig-OS-Builder, and any of the maintainers: @yanan-rock , @t_feng , @Anonymous_Z , @shenyangyang01 , @overweight , @zhuchunyi , @compile_success , any of the committers: @shenyangyang01 , @overweight , @zhuchunyi

likedislike
openeuler-ci-botopeneuler-ci-bot成员
2025年9月18日 添加了   sig/sig-OS-Builder 标签
Ssuichangyin
2025年9月18日 修改了描述
Ssuichangyin
2025年9月18日 修改了描述
Ssuichangyin
2025年9月18日 修改了描述
Ssuichangyin
2025年9月18日 修改了描述
Ssuichangyin
2025年9月18日 修改了描述
nickyang
nickyang
2025年11月5日 评论:

新版本已合入修复补丁,PR如下:
https://gitee.com/src-openeuler/lorax/pulls/78

likedislike