From: Ciro Santilli Date: Tue, 29 Oct 2019 16:00:24 +0000 (+0000) Subject: configs: fs.py can take multiple disk images on most ISAs X-Git-Tag: v19.0.0.0~59 X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=a6d98140ca4afb23817a8d9ff24f8a001128b146;p=gem5.git configs: fs.py can take multiple disk images on most ISAs All ISAs except SPARC can now take multiple disk images by passing the --disk-image option multiple times. Before this patch, several ISAs automatically mounted a secondary disk called "linux-bigswap2.img", which had to be in M5_PATH even if the end user did not want more than one disk. This was the case for for example for X86 but not ARM. This change was done to: * allow ARM to have a second disk image in fs.py, which was not possible, and allow other ISAs like X86 and ARM to take any number of disk images * provide a simpler, more intuitive CLI interface that does not require magic disk images to be present in M5_PATH to work for ISAs such as X86. Linux does not need that secondary image to boot correctly, so it is more friendly to support a minimal setup that requires the least amount of binaries to boot, and let supply the second image manually only if they need it. * make fs.py --disk-image work more similarly across all ISAs SPARC was left with a single disk only because its setup was a bit more complex and would require further testing. Change-Id: I8b6e08ae6daf0a5b6cd1d57d285a9677f01eb7ad Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/23671 Reviewed-by: Jason Lowe-Power Maintainer: Giacomo Travaglini Tested-by: kokoro --- diff --git a/configs/common/Benchmarks.py b/configs/common/Benchmarks.py index 3cf963bd5..9ed321ccf 100644 --- a/configs/common/Benchmarks.py +++ b/configs/common/Benchmarks.py @@ -34,10 +34,10 @@ from os import environ as env from m5.defines import buildEnv class SysConfig: - def __init__(self, script=None, mem=None, disk=None, rootdev=None, + def __init__(self, script=None, mem=None, disks=None, rootdev=None, os_type='linux'): self.scriptname = script - self.diskname = disk + self.disknames = disks self.memsize = mem self.root = rootdev self.ostype = os_type @@ -54,17 +54,17 @@ class SysConfig: else: return '128MB' - def disk(self): - if self.diskname: - return disk(self.diskname) + def disks(self): + if self.disknames: + return [disk(diskname) for diskname in self.disknames] elif buildEnv['TARGET_ISA'] == 'alpha': - return env.get('LINUX_IMAGE', disk('linux-latest.img')) + return [env.get('LINUX_IMAGE', disk('linux-latest.img'))] elif buildEnv['TARGET_ISA'] == 'x86': - return env.get('LINUX_IMAGE', disk('x86root.img')) + return [env.get('LINUX_IMAGE', disk('x86root.img'))] elif buildEnv['TARGET_ISA'] == 'arm': - return env.get('LINUX_IMAGE', disk('linux-aarch32-ael.img')) + return [env.get('LINUX_IMAGE', disk('linux-aarch32-ael.img'))] elif buildEnv['TARGET_ISA'] == 'sparc': - return env.get('LINUX_IMAGE', disk('disk.s10hw2')) + return [env.get('LINUX_IMAGE', disk('disk.s10hw2'))] else: print("Don't know what default disk image to use for %s ISA" % buildEnv['TARGET_ISA']) @@ -83,8 +83,8 @@ class SysConfig: # The first defined machine is the test system, the others are driving systems Benchmarks = { - 'PovrayBench': [SysConfig('povray-bench.rcS', '512MB', 'povray.img')], - 'PovrayAutumn': [SysConfig('povray-autumn.rcS', '512MB', 'povray.img')], + 'PovrayBench': [SysConfig('povray-bench.rcS', '512MB', ['povray.img'])], + 'PovrayAutumn': [SysConfig('povray-autumn.rcS', '512MB', ['povray.img'])], 'NetperfStream': [SysConfig('netperf-stream-client.rcS'), SysConfig('netperf-server.rcS')], @@ -129,16 +129,16 @@ Benchmarks = { 'MutexTest': [SysConfig('mutex-test.rcS', '128MB')], 'ArmAndroid-GB': [SysConfig('null.rcS', '256MB', - 'ARMv7a-Gingerbread-Android.SMP.mouse.nolock.clean.img', + ['ARMv7a-Gingerbread-Android.SMP.mouse.nolock.clean.img'], None, 'android-gingerbread')], - 'bbench-gb': [SysConfig('bbench-gb.rcS', '256MB', - 'ARMv7a-Gingerbread-Android.SMP.mouse.nolock.img', + 'bbench-gb': [SysConfig('bbench-gb.rcS', '256MB', + ['ARMv7a-Gingerbread-Android.SMP.mouse.nolock.img'], None, 'android-gingerbread')], 'ArmAndroid-ICS': [SysConfig('null.rcS', '256MB', - 'ARMv7a-ICS-Android.SMP.nolock.clean.img', + ['ARMv7a-ICS-Android.SMP.nolock.clean.img'], None, 'android-ics')], 'bbench-ics': [SysConfig('bbench-ics.rcS', '256MB', - 'ARMv7a-ICS-Android.SMP.nolock.img', + ['ARMv7a-ICS-Android.SMP.nolock.img'], None, 'android-ics')] } diff --git a/configs/common/FSConfig.py b/configs/common/FSConfig.py index e218c14c5..f21b1ecf5 100644 --- a/configs/common/FSConfig.py +++ b/configs/common/FSConfig.py @@ -86,17 +86,24 @@ def attach_9p(parent, bus): parent.attachPciDevice(viopci, bus) def fillInCmdline(mdesc, template, **kwargs): - kwargs.setdefault('disk', mdesc.disk()) kwargs.setdefault('rootdev', mdesc.rootdev()) kwargs.setdefault('mem', mdesc.mem()) kwargs.setdefault('script', mdesc.script()) return template % kwargs +def makeCowDisks(disk_paths): + disks = [] + for disk_path in disk_paths: + disk = CowIdeDisk(driveID='master') + disk.childImage(disk_path); + disks.append(disk) + return disks + def makeLinuxAlphaSystem(mem_mode, mdesc=None, ruby=False, cmdline=None): class BaseTsunami(Tsunami): ethernet = NSGigE(pci_bus=0, pci_dev=1, pci_func=0) - ide = IdeController(disks=[Parent.disk0, Parent.disk2], + ide = IdeController(disks=Parent.disks, pci_func=0, pci_dev=0, pci_bus=0) self = LinuxAlphaSystem() @@ -136,12 +143,9 @@ def makeLinuxAlphaSystem(mem_mode, mdesc=None, ruby=False, cmdline=None): self.system_port = self.membus.slave self.mem_ranges = [AddrRange(mdesc.mem())] - self.disk0 = CowIdeDisk(driveID='master') - self.disk2 = CowIdeDisk(driveID='master') - self.disk0.childImage(mdesc.disk()) - self.disk2.childImage(disk('linux-bigswap2.img')) - self.simple_disk = SimpleDisk(disk=RawDiskImage(image_file = mdesc.disk(), - read_only = True)) + self.disks = makeCowDisks(mdesc.disks()) + self.simple_disk = SimpleDisk(disk=RawDiskImage( + image_file = mdesc.disks()[0], read_only = True)) self.intrctrl = IntrControl() self.mem_mode = mem_mode self.terminal = Terminal() @@ -186,7 +190,7 @@ def makeSparcSystem(mem_mode, mdesc=None, cmdline=None): self.partition_desc.port = self.membus.master self.intrctrl = IntrControl() self.disk0 = CowMmDisk() - self.disk0.childImage(mdesc.disk()) + self.disk0.childImage(mdesc.disks()[0]) self.disk0.pio = self.iobus.master # The puart0 and hvuart are placed on the IO bus, so create ranges @@ -254,7 +258,7 @@ def makeArmSystem(mem_mode, machine_type, num_cpus=1, mdesc=None, self._bootmem = self.realview.bootmem if isinstance(self.realview, VExpress_EMM64): - if os.path.split(mdesc.disk())[-1] == 'linux-aarch32-ael.img': + if os.path.split(mdesc.disks()[0])[-1] == 'linux-aarch32-ael.img': print("Selected 64-bit ARM architecture, updating default " "disk image...") mdesc.diskname = 'linaro-minimal-aarch64.img' @@ -263,17 +267,16 @@ def makeArmSystem(mem_mode, machine_type, num_cpus=1, mdesc=None, # Attach any PCI devices this platform supports self.realview.attachPciDevices() - self.cf0 = CowIdeDisk(driveID='master') - self.cf0.childImage(mdesc.disk()) + disks = makeCowDisks(mdesc.disks()) # Old platforms have a built-in IDE or CF controller. Default to # the IDE controller if both exist. New platforms expect the # storage controller to be added from the config script. if hasattr(self.realview, "ide"): - self.realview.ide.disks = [self.cf0] + self.realview.ide.disks = disks elif hasattr(self.realview, "cf_ctrl"): - self.realview.cf_ctrl.disks = [self.cf0] + self.realview.cf_ctrl.disks = disks else: - self.pci_ide = IdeController(disks=[self.cf0]) + self.pci_ide = IdeController(disks=disks) pci_devices.append(self.pci_ide) self.mem_ranges = [] @@ -325,7 +328,8 @@ def makeArmSystem(mem_mode, machine_type, num_cpus=1, mdesc=None, # behavior has been replaced with a more explicit option per # the error message below. The disk can have any name now and # doesn't need to include 'android' substring. - if (os.path.split(mdesc.disk())[-1]).lower().count('android'): + if (mdesc.disks() and + os.path.split(mdesc.disks()[0])[-1]).lower().count('android'): if 'android' not in mdesc.os_type(): fatal("It looks like you are trying to boot an Android " \ "platform. To boot Android, you must specify " \ @@ -409,7 +413,7 @@ def makeArmSystem(mem_mode, machine_type, num_cpus=1, mdesc=None, def makeLinuxMipsSystem(mem_mode, mdesc=None, cmdline=None): class BaseMalta(Malta): ethernet = NSGigE(pci_bus=0, pci_dev=1, pci_func=0) - ide = IdeController(disks=[Parent.disk0, Parent.disk2], + ide = IdeController(disks=Parent.disks, pci_func=0, pci_dev=0, pci_bus=0) self = LinuxMipsSystem() @@ -423,18 +427,15 @@ def makeLinuxMipsSystem(mem_mode, mdesc=None, cmdline=None): self.mem_ranges = [AddrRange('1GB')] self.bridge.master = self.iobus.slave self.bridge.slave = self.membus.master - self.disk0 = CowIdeDisk(driveID='master') - self.disk2 = CowIdeDisk(driveID='master') - self.disk0.childImage(mdesc.disk()) - self.disk2.childImage(disk('linux-bigswap2.img')) + self.disks = makeCowDisks(mdesc.disks()) self.malta = BaseMalta() self.malta.attachIO(self.iobus) self.malta.ide.pio = self.iobus.master self.malta.ide.dma = self.iobus.slave self.malta.ethernet.pio = self.iobus.master self.malta.ethernet.dma = self.iobus.slave - self.simple_disk = SimpleDisk(disk=RawDiskImage(image_file = mdesc.disk(), - read_only = True)) + self.simple_disk = SimpleDisk(disk=RawDiskImage( + image_file = mdesc.disks()[0], read_only = True)) self.intrctrl = IntrControl() self.mem_mode = mem_mode self.terminal = Terminal() @@ -544,11 +545,8 @@ def makeX86System(mem_mode, numCPUs=1, mdesc=None, self=None, Ruby=False): self.intrctrl = IntrControl() # Disks - disk0 = CowIdeDisk(driveID='master') - disk2 = CowIdeDisk(driveID='master') - disk0.childImage(mdesc.disk()) - disk2.childImage(disk('linux-bigswap2.img')) - self.pc.south_bridge.ide.disks = [disk0, disk2] + disks = makeCowDisks(mdesc.disks()) + self.pc.south_bridge.ide.disks = disks # Add in a Bios information structure. structures = [X86SMBiosBiosInformation()] diff --git a/configs/common/Options.py b/configs/common/Options.py index 1405012d6..49434863a 100644 --- a/configs/common/Options.py +++ b/configs/common/Options.py @@ -461,10 +461,10 @@ def addFSOptions(parser): "ethernet traffic") # Disk Image Options - parser.add_option("--disk-image", action="store", type="string", default=None, - help="Path to the disk image to use.") - parser.add_option("--root-device", action="store", type="string", default=None, - help="OS device name for root partition") + parser.add_option("--disk-image", action="append", type="string", + default=[], help="Path to the disk images to use.") + parser.add_option("--root-device", action="store", type="string", + default=None, help="OS device name for root partition") # Command line options parser.add_option("--command-line", action="store", type="string", diff --git a/configs/example/fs.py b/configs/example/fs.py index e747b1aab..c9ae60e35 100644 --- a/configs/example/fs.py +++ b/configs/example/fs.py @@ -329,12 +329,12 @@ if options.benchmark: sys.exit(1) else: if options.dual: - bm = [SysConfig(disk=options.disk_image, rootdev=options.root_device, + bm = [SysConfig(disks=options.disk_image, rootdev=options.root_device, mem=options.mem_size, os_type=options.os_type), - SysConfig(disk=options.disk_image, rootdev=options.root_device, + SysConfig(disks=options.disk_image, rootdev=options.root_device, mem=options.mem_size, os_type=options.os_type)] else: - bm = [SysConfig(disk=options.disk_image, rootdev=options.root_device, + bm = [SysConfig(disks=options.disk_image, rootdev=options.root_device, mem=options.mem_size, os_type=options.os_type)] np = options.num_cpus diff --git a/tests/configs/arm_generic.py b/tests/configs/arm_generic.py index c074f99cf..dd75b50a4 100644 --- a/tests/configs/arm_generic.py +++ b/tests/configs/arm_generic.py @@ -98,7 +98,7 @@ class LinuxArmSystemBuilder(object): "VExpress_GEM5_V1": gem5_kernel, } - sc = SysConfig(None, self.mem_size, disk_image, "/dev/sda") + sc = SysConfig(None, self.mem_size, [disk_image], "/dev/sda") system = FSConfig.makeArmSystem(self.mem_mode, self.machine_type, self.num_cpus, sc, False, ruby=self.use_ruby) diff --git a/tests/configs/pc-simple-timing-ruby.py b/tests/configs/pc-simple-timing-ruby.py index ffac06266..7c7bf3369 100644 --- a/tests/configs/pc-simple-timing-ruby.py +++ b/tests/configs/pc-simple-timing-ruby.py @@ -51,7 +51,7 @@ options.l2_assoc=2 options.num_cpus = 2 #the system -mdesc = SysConfig(disk = 'linux-x86.img') +mdesc = SysConfig(disks = ['linux-x86.img']) system = FSConfig.makeLinuxX86System('timing', options.num_cpus, mdesc=mdesc, Ruby=True) system.kernel = SysPaths.binary('x86_64-vmlinux-2.6.22.9') diff --git a/tests/configs/x86_generic.py b/tests/configs/x86_generic.py index e280fc59c..5ae8e3052 100644 --- a/tests/configs/x86_generic.py +++ b/tests/configs/x86_generic.py @@ -56,7 +56,7 @@ class LinuxX86SystemBuilder(object): pass def create_system(self): - mdesc = SysConfig(disk = 'linux-x86.img') + mdesc = SysConfig(disks = ['linux-x86.img']) system = FSConfig.makeLinuxX86System(self.mem_mode, numCPUs=self.num_cpus, mdesc=mdesc)