add
This commit is contained in:
@@ -3,6 +3,8 @@ import os
|
||||
import sys
|
||||
import argparse
|
||||
from subprocess import Popen, PIPE
|
||||
|
||||
from gentooimgr import LOG
|
||||
import gentooimgr.config
|
||||
import gentooimgr.common
|
||||
def create_image(args, config: dict, overwrite: bool = False) -> str:
|
||||
@@ -36,6 +38,8 @@ def run_image(
|
||||
- mount_isos: list of iso paths to mount in qemu as disks.
|
||||
"""
|
||||
iso = config.get("iso")
|
||||
prefix = args.temporary_dir
|
||||
LOG.info(f"iso from config {iso}")
|
||||
if iso is None:
|
||||
iso = gentooimgr.common.find_iso(
|
||||
os.path.join(
|
||||
@@ -43,6 +47,13 @@ def run_image(
|
||||
".."
|
||||
)
|
||||
)
|
||||
LOG.info(f"iso from cwd {iso}")
|
||||
if not iso:
|
||||
prefix = config.get('temporary_dir')
|
||||
iso = gentooimgr.common.find_iso(prefix)
|
||||
LOG.info(f"iso from {prefix} {iso}")
|
||||
|
||||
assert iso, f"iso not found {iso}"
|
||||
|
||||
if isinstance(iso, list):
|
||||
assert len(iso), f"iso list is empty {iso}"
|
||||
@@ -55,6 +66,11 @@ def run_image(
|
||||
qmounts.append("-drive")
|
||||
qmounts.append(f"file={i},media=cdrom")
|
||||
|
||||
assert image, f"image is empty {image}"
|
||||
if not os.path.exists(image):
|
||||
if os.path.exists(os.path.join(prefix, image)):
|
||||
image = os.path.join(prefix, image)
|
||||
assert os.path.exists(image), f"image not found {image}"
|
||||
threads = args.threads
|
||||
cmd = [
|
||||
"qemu-system-x86_64",
|
||||
@@ -65,7 +81,6 @@ def run_image(
|
||||
"-drive", f"file={image},if=virtio,index=0",
|
||||
"-cdrom", iso,
|
||||
"-net", "nic,model=virtio",
|
||||
"-net", "user",
|
||||
"-vga", "virtio",
|
||||
"-cpu", "kvm64",
|
||||
"-chardev", "file,id=charserial0,path=gentoo.log",
|
||||
@@ -73,12 +88,14 @@ def run_image(
|
||||
"-chardev", "pty,id=charserial1",
|
||||
"-device", "isa-serial,chardev=charserial1,id=serial1"
|
||||
]
|
||||
# "-net", "user",
|
||||
# -net user: network backend 'user' is not compiled into this binary"
|
||||
|
||||
cmd += qmounts
|
||||
print(cmd)
|
||||
LOG.info(cmd)
|
||||
proc = Popen(cmd, stderr=PIPE, stdout=PIPE)
|
||||
stdout, stderr = proc.communicate()
|
||||
if stderr:
|
||||
sys.stderr.write(str(stderr))
|
||||
sys.stderr.write("\n")
|
||||
LOG.error(str(stderr))
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user