Skip to content

Commit 6a25a52

Browse files
committed
qemu: Convert ROOT_DISK_PATH to --root-disk-path
1 parent c34da3c commit 6a25a52

9 files changed

Lines changed: 19 additions & 63 deletions

File tree

lib/qemu.py

Lines changed: 19 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,14 @@ def __init__(self, machine):
4545
self.expected_release = None
4646
self.vmlinux = None
4747

48+
# Detect root disks if we're called from scripts/boot/qemu-xxx
49+
base = os.path.dirname(sys.argv[0])
50+
path = f'{base}/../../root-disks'
51+
if os.path.isdir(path):
52+
self.root_disk_path = path
53+
else:
54+
self.root_disk_path = None
55+
4856
def machine_is(self, needle):
4957
return self.machine.startswith(needle)
5058

@@ -79,6 +87,7 @@ def configure_from_args(self, orig_args):
7987
parser.add_argument('--modules-path', type=str, help='Path to modules tarball')
8088
parser.add_argument('--cap', dest='machine_caps', type=str, default=[], action='append', help='Machine caps')
8189
parser.add_argument('--qemu-path', dest='qemu_path', type=str, help='Path to qemu bin directory')
90+
parser.add_argument('--root-disk-path', dest='root_disk_path', type=str, help='Path to root disk directory')
8291
args = parser.parse_args(orig_args)
8392

8493
if args.gdb:
@@ -130,6 +139,9 @@ def configure_from_args(self, orig_args):
130139
if args.qemu_path:
131140
self.qemu_path = args.qemu_path
132141

142+
if args.root_disk_path:
143+
self.root_disk_path = args.root_disk_path
144+
133145
self.compat_rootfs = args.compat_rootfs
134146
self.use_vof = args.use_vof
135147
self.quiet = args.quiet
@@ -145,7 +157,11 @@ def apply_defaults(self):
145157
if not self.vmlinux:
146158
logging.error("Can't find kernel vmlinux")
147159
return
148-
160+
161+
if not self.root_disk_path:
162+
logging.error("Couldn't locate root disks")
163+
return
164+
149165
if self.machine_is('pseries'):
150166
if self.accel == 'tcg':
151167
self.machine_caps += ['cap-htm=off']
@@ -304,7 +320,7 @@ def prepare_cloud_image(self):
304320
if self.cloud_image is None:
305321
return
306322

307-
rdpath = get_root_disk_path()
323+
rdpath = self.root_disk_path
308324
img_path = f'{rdpath}/{self.cloud_image}'
309325

310326
if self.cloud_image.endswith('.qcow2'):
@@ -366,7 +382,7 @@ def cmd(self):
366382

367383
if self.initrd:
368384
l.append('-initrd')
369-
l.append(get_root_disk(self.initrd))
385+
l.append(os.path.join(self.root_disk_path, self.initrd))
370386

371387
if len(self.drives):
372388
l.extend(self.drives)
@@ -393,26 +409,6 @@ def qemu_monitor_shutdown(p):
393409
p.send('quit')
394410

395411

396-
def get_root_disk_path():
397-
path = get_env_var('ROOT_DISK_PATH', None)
398-
if path is not None:
399-
return path
400-
401-
base = os.path.dirname(sys.argv[0])
402-
# Assumes we're called from scripts/boot/qemu-xxx
403-
path = f'{base}/../../root-disks'
404-
if os.path.isdir(path):
405-
return path
406-
407-
return ''
408-
409-
410-
def get_root_disk(fname):
411-
val = os.path.join(get_root_disk_path(), fname)
412-
logging.debug(f'Using rootfs {val}')
413-
return val
414-
415-
416412
def get_qemu_version(emulator):
417413
p = PexpectHelper()
418414
p.spawn('%s --version' % emulator, quiet=True)

scripts/boot/qemu-44x

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,6 @@
33
# $ cd ~/src/linux
44
# $ make
55
# $ ~/src/ci-scripts/scripts/boot/qemu-44x
6-
#
7-
# Optional:
8-
# export ROOT_DISK_PATH=~/some/directory
9-
# Expects ppc-rootfs.cpio.gz in ROOT_DISK_PATH
106

117
import logging
128
import os, sys

scripts/boot/qemu-e500mc

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,6 @@
88
# $ cd ~/src/linux
99
# $ make
1010
# $ ~/src/ci-scripts/scripts/boot/qemu-e500mc
11-
#
12-
# Optional:
13-
# export ROOT_DISK_PATH=~/some/directory
14-
#
15-
# Expects ROOT_DISK_PATH to contain:
16-
# ppc-rootfs.cpio.gz
1711

1812
import logging
1913
import os, sys

scripts/boot/qemu-g3beige

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,6 @@
1111
# $ cd ~/src/linux
1212
# $ make
1313
# $ ~/src/ci-scripts/scripts/boot/qemu-g3beige
14-
#
15-
# Optional:
16-
# export ROOT_DISK_PATH=~/some/directory
17-
# Expects ppc-rootfs.cpio.gz in ROOT_DISK_PATH
1814

1915
import logging
2016
import os, sys

scripts/boot/qemu-g5

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,6 @@
99
# $ cd ~/src/linux
1010
# $ make
1111
# $ ~/src/ci-scripts/scripts/boot/qemu-g5
12-
#
13-
# Optional:
14-
# export ROOT_DISK_PATH=~/some/directory
15-
# Expects ppc64-rootfs.cpio.gz in ROOT_DISK_PATH
1612

1713
import os, sys
1814
sys.path.append(f'{os.path.dirname(sys.argv[0])}/../../lib')

scripts/boot/qemu-mac99

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,6 @@
1010
# $ cd ~/src/linux
1111
# $ make
1212
# $ ~/src/ci-scripts/scripts/boot/qemu-mac99
13-
#
14-
# Optional:
15-
# export ROOT_DISK_PATH=~/some/directory
16-
# Expects ppc-rootfs.cpio.gz in ROOT_DISK_PATH
1713

1814
import logging
1915
import os, sys

scripts/boot/qemu-powernv

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,6 @@
33
# $ cd ~/src/linux
44
# $ make
55
# $ ~/src/ci-scripts/scripts/boot/qemu-powernv
6-
#
7-
# Optional:
8-
# export ROOT_DISK_PATH=~/some/directory
9-
# Expects ppc64[le]-rootfs.cpio.gz in ROOT_DISK_PATH
106

117
import os, sys
128
sys.path.append(f'{os.path.dirname(sys.argv[0])}/../../lib')

scripts/boot/qemu-ppc64e

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,6 @@
77
# $ cd ~/src/linux
88
# $ make
99
# $ ~/src/ci-scripts/scripts/boot/qemu-ppc64e
10-
#
11-
# Optional:
12-
# export ROOT_DISK_PATH=~/some/directory
13-
#
14-
# Expects ROOT_DISK_PATH to contain either:
15-
# ppc64-novsx-rootfs.cpio.gz
16-
# or
17-
# ppc-rootfs.cpio.gz
18-
#
19-
# if --compat-rootfs is specified.
2010

2111
import logging
2212
import os, sys

scripts/boot/qemu-pseries

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,6 @@
33
# $ cd ~/src/linux
44
# $ make
55
# $ ~/src/ci-scripts/scripts/boot/qemu-pseries
6-
#
7-
# Optional:
8-
# export ROOT_DISK_PATH=~/some/directory
9-
# Expects ppc64[le]-rootfs.cpio.gz in ROOT_DISK_PATH
106

117
import os, sys
128
sys.path.append(f'{os.path.dirname(sys.argv[0])}/../../lib')

0 commit comments

Comments
 (0)