scripts: Move root-disk processing to helper
The build-efi and build-qemu scripts have common code to set up the root disk. Move it to build_helper to avoid duplication. Signed-off-by: Simon Glass <sjg@chromium.org>
This commit is contained in:
@@ -113,15 +113,6 @@ class BuildEfi:
|
||||
if self.args.kvm:
|
||||
extra.extend(['-enable-kvm', '-cpu', 'host'])
|
||||
|
||||
img_fname = Path(self.args.disk) if self.args.disk else None
|
||||
if img_fname:
|
||||
if img_fname.exists():
|
||||
extra.extend([
|
||||
'-drive',
|
||||
f'if=virtio,file={img_fname},format=raw,id=hd1'])
|
||||
else:
|
||||
tout.warning(f"Disk image '{img_fname}' not found")
|
||||
|
||||
print(f'Running {qemu}{serial_msg}')
|
||||
|
||||
# Use 512MB since U-Boot EFI likes to have 256MB to play with
|
||||
|
||||
@@ -127,7 +127,6 @@ class BuildQemu:
|
||||
f'{bios_override}')
|
||||
|
||||
self.seq_fname = Path(args.sct_seq) if args.sct_seq else None
|
||||
self.img_fname = Path(args.disk) if args.disk else None
|
||||
|
||||
# arch-specific setup
|
||||
if args.arch == 'arm':
|
||||
@@ -284,14 +283,6 @@ class BuildQemu:
|
||||
# Add other parameters gathered from options
|
||||
qemu_cmd.extend(self.qemu_extra)
|
||||
|
||||
if self.img_fname:
|
||||
if self.img_fname.exists():
|
||||
qemu_cmd.extend([
|
||||
'-drive',
|
||||
f'if=virtio,file={self.img_fname},format=raw,id=hd1'])
|
||||
else:
|
||||
tout.warning(f"Disk image '{self.img_fname}' not found")
|
||||
|
||||
sock = Path('/tmp/virtiofs.sock')
|
||||
proc = None
|
||||
if self.args.share_dir:
|
||||
|
||||
@@ -43,6 +43,7 @@ class Helper:
|
||||
self.os_arch = 'amd64'
|
||||
else:
|
||||
self.os_arch = 'i386'
|
||||
self.img_fname = Path(args.disk) if args.disk else None
|
||||
|
||||
def read_settings(self):
|
||||
"""Get settings from the settings file"""
|
||||
@@ -160,6 +161,14 @@ sct_mnt = /mnt/sct
|
||||
'-drive',
|
||||
f'if=virtio,file={os_path},format=raw,id=hd0,readonly=on'])
|
||||
|
||||
if self.img_fname:
|
||||
if self.img_fname.exists():
|
||||
cmd.extend([
|
||||
'-drive',
|
||||
f'if=virtio,file={self.img_fname},format=raw,id=hd1'])
|
||||
else:
|
||||
tout.warning(f"Disk image '{self.img_fname}' not found")
|
||||
|
||||
|
||||
def add_common_args(parser):
|
||||
"""Add some arguments which are common to build-efi/qemu scripts
|
||||
|
||||
Reference in New Issue
Block a user