summaryrefslogtreecommitdiffstats
path: root/scripts/runqemu
diff options
context:
space:
mode:
authorRobert Yang <liezhi.yang@windriver.com>2017-04-11 02:21:26 -0700
committerRichard Purdie <richard.purdie@linuxfoundation.org>2017-04-12 15:09:57 +0100
commitbe72eaf86f1301ff953683f71357286ae9239e2a (patch)
treeb005f77aa39168aaf3a56f93965e3b670c9ee88c /scripts/runqemu
parentd538cbb95e76991fa916d9b22b5a3d2fdd5ff796 (diff)
downloadpoky-be72eaf86f1301ff953683f71357286ae9239e2a.tar.gz
runqemu: use self.rootfs to replace self.nfs_dir
We can use self.rootfs as self.nfs_dir when self.fstype is nfs, this can reduce the code's complexity and we can re-use the code of checking ROOTFS conflictions. (From OE-Core rev: 1aafa13ae6faf620acac7338c42a8838e75da6b9) Signed-off-by: Robert Yang <liezhi.yang@windriver.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'scripts/runqemu')
-rwxr-xr-xscripts/runqemu28
1 files changed, 13 insertions, 15 deletions
diff --git a/scripts/runqemu b/scripts/runqemu
index 803b205690..5b5d56b9ef 100755
--- a/scripts/runqemu
+++ b/scripts/runqemu
@@ -179,7 +179,6 @@ class BaseConfig(object):
179 179
180 self.qemu_opt = '' 180 self.qemu_opt = ''
181 self.qemu_opt_script = '' 181 self.qemu_opt_script = ''
182 self.nfs_dir = ''
183 self.clean_nfs_dir = False 182 self.clean_nfs_dir = False
184 self.nfs_server = '' 183 self.nfs_server = ''
185 self.rootfs = '' 184 self.rootfs = ''
@@ -285,12 +284,11 @@ class BaseConfig(object):
285 284
286 def check_arg_nfs(self, p): 285 def check_arg_nfs(self, p):
287 if os.path.isdir(p): 286 if os.path.isdir(p):
288 self.nfs_dir = p 287 self.rootfs = p
289 else: 288 else:
290 m = re.match('(.*):(.*)', p) 289 m = re.match('(.*):(.*)', p)
291 self.nfs_server = m.group(1) 290 self.nfs_server = m.group(1)
292 self.nfs_dir = m.group(2) 291 self.rootfs = m.group(2)
293 self.rootfs = ""
294 self.check_arg_fstype('nfs') 292 self.check_arg_fstype('nfs')
295 293
296 def check_arg_path(self, p): 294 def check_arg_path(self, p):
@@ -760,7 +758,7 @@ class BaseConfig(object):
760 print('MACHINE: [%s]' % self.get('MACHINE')) 758 print('MACHINE: [%s]' % self.get('MACHINE'))
761 print('FSTYPE: [%s]' % self.fstype) 759 print('FSTYPE: [%s]' % self.fstype)
762 if self.fstype == 'nfs': 760 if self.fstype == 'nfs':
763 print('NFS_DIR: [%s]' % self.nfs_dir) 761 print('NFS_DIR: [%s]' % self.rootfs)
764 else: 762 else:
765 print('ROOTFS: [%s]' % self.rootfs) 763 print('ROOTFS: [%s]' % self.rootfs)
766 if self.ovmf_bios: 764 if self.ovmf_bios:
@@ -805,13 +803,13 @@ class BaseConfig(object):
805 803
806 self.unfs_opts="nfsvers=3,port=%s,mountprog=%s,nfsprog=%s,udp,mountport=%s" % (nfsd_port, mountd_rpcport, nfsd_rpcport, mountd_port) 804 self.unfs_opts="nfsvers=3,port=%s,mountprog=%s,nfsprog=%s,udp,mountport=%s" % (nfsd_port, mountd_rpcport, nfsd_rpcport, mountd_port)
807 805
808 # Extract .tar.bz2 or .tar.bz if no self.nfs_dir 806 # Extract .tar.bz2 or .tar.bz if no nfs dir
809 if not self.nfs_dir: 807 if not (self.rootfs and os.path.isdir(self.rootfs)):
810 src_prefix = '%s/%s' % (self.get('DEPLOY_DIR_IMAGE'), self.get('IMAGE_LINK_NAME')) 808 src_prefix = '%s/%s' % (self.get('DEPLOY_DIR_IMAGE'), self.get('IMAGE_LINK_NAME'))
811 dest = "%s-nfsroot" % src_prefix 809 dest = "%s-nfsroot" % src_prefix
812 if os.path.exists('%s.pseudo_state' % dest): 810 if os.path.exists('%s.pseudo_state' % dest):
813 logger.info('Use %s as NFS_DIR' % dest) 811 logger.info('Use %s as NFS_DIR' % dest)
814 self.nfs_dir = dest 812 self.rootfs = dest
815 else: 813 else:
816 src = "" 814 src = ""
817 src1 = '%s.tar.bz2' % src_prefix 815 src1 = '%s.tar.bz2' % src_prefix
@@ -828,10 +826,10 @@ class BaseConfig(object):
828 if subprocess.call(cmd, shell=True) != 0: 826 if subprocess.call(cmd, shell=True) != 0:
829 raise Exception('Failed to run %s' % cmd) 827 raise Exception('Failed to run %s' % cmd)
830 self.clean_nfs_dir = True 828 self.clean_nfs_dir = True
831 self.nfs_dir = dest 829 self.rootfs = dest
832 830
833 # Start the userspace NFS server 831 # Start the userspace NFS server
834 cmd = 'runqemu-export-rootfs start %s' % self.nfs_dir 832 cmd = 'runqemu-export-rootfs start %s' % self.rootfs
835 logger.info('Running %s...' % cmd) 833 logger.info('Running %s...' % cmd)
836 if subprocess.call(cmd, shell=True) != 0: 834 if subprocess.call(cmd, shell=True) != 0:
837 raise Exception('Failed to run %s' % cmd) 835 raise Exception('Failed to run %s' % cmd)
@@ -1005,7 +1003,7 @@ class BaseConfig(object):
1005 1003
1006 if self.fstype == 'nfs': 1004 if self.fstype == 'nfs':
1007 self.rootfs_options = '' 1005 self.rootfs_options = ''
1008 k_root = '/dev/nfs nfsroot=%s:%s,%s' % (self.nfs_server, self.nfs_dir, self.unfs_opts) 1006 k_root = '/dev/nfs nfsroot=%s:%s,%s' % (self.nfs_server, self.rootfs, self.unfs_opts)
1009 self.kernel_cmdline = 'root=%s rw highres=off' % k_root 1007 self.kernel_cmdline = 'root=%s rw highres=off' % k_root
1010 1008
1011 if self.fstype == 'none': 1009 if self.fstype == 'none':
@@ -1151,7 +1149,7 @@ class BaseConfig(object):
1151 1149
1152 if self.nfs_running: 1150 if self.nfs_running:
1153 logger.info("Shutting down the userspace NFS server...") 1151 logger.info("Shutting down the userspace NFS server...")
1154 cmd = "runqemu-export-rootfs stop %s" % self.nfs_dir 1152 cmd = "runqemu-export-rootfs stop %s" % self.rootfs
1155 logger.info('Running %s' % cmd) 1153 logger.info('Running %s' % cmd)
1156 subprocess.call(cmd, shell=True) 1154 subprocess.call(cmd, shell=True)
1157 1155
@@ -1160,9 +1158,9 @@ class BaseConfig(object):
1160 subprocess.call(cmd, shell=True) 1158 subprocess.call(cmd, shell=True)
1161 1159
1162 if self.clean_nfs_dir: 1160 if self.clean_nfs_dir:
1163 logger.info('Removing %s' % self.nfs_dir) 1161 logger.info('Removing %s' % self.rootfs)
1164 shutil.rmtree(self.nfs_dir) 1162 shutil.rmtree(self.rootfs)
1165 shutil.rmtree('%s.pseudo_state' % self.nfs_dir) 1163 shutil.rmtree('%s.pseudo_state' % self.rootfs)
1166 1164
1167 def load_bitbake_env(self, mach=None): 1165 def load_bitbake_env(self, mach=None):
1168 if self.bitbake_e: 1166 if self.bitbake_e: