Skip to content

cxl-tool.py --run reports "env[qemu_extra_opt] undefined, return empty" #1

@sscargal

Description

@sscargal

When running cxl-tool.py --run for the first time on an Ubuntu 24.04 host, I encountered the following error:

$ ./cxl-tool.py --run
env[qemu_extra_opt] undefined, return empty
[...snip...]

This error originates from cxl-tool.py

if args["extra"]:
  os.environ["qemu_extra_opt"] = args["extra"]

It is expected that os.environ raises an exception if the environment variable does not exist. It's a harmless message, but the tool could handle this gracefully by setting the environment variable before it's read using:

# Set a default value if qemu_extra_opt is not set or doesn't exist
qemu_extra_opt = os.getenv("qemu_extra_opt", "")
---8<---
if args["extra"]:
    os.environ["qemu_extra_opt"] = args["extra"]

This will also help utils/tools.py, which also expects the variable, but handles non-existent environment variables gracefully

def run_qemu(qemu, topo, kernel, accel_mode=accel_mode, run_direct=False, qemu_img="", port_offset=0, allow_multivm=False):
    if not allow_multivm and vm_is_running():
        print("VM is running, exit")
        return;
    
    extra_opts = system_env("qemu_extra_opt")

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions