 b7e875b2f9
			
		
	
	
		b7e875b2f9
		
	
	
	
	
		
			
			The LUKS block driver tests will require the ability to specify encryption secrets with block devices. This requires using the --object argument to qemu-img/qemu-io to create a 'secret' object. When the IMGKEYSECRET env variable is set, it provides the password to be associated with a secret called 'keysec0' The _qemu_img_wrapper function isn't modified as that needs to cope with differing syntax for subcommands, so can't be made to use the image opts syntax unconditionally. Signed-off-by: Daniel P. Berrange <berrange@redhat.com> Message-id: 1462896689-18450-3-git-send-email-berrange@redhat.com Signed-off-by: Max Reitz <mreitz@redhat.com>
		
			
				
	
	
		
			150 lines
		
	
	
		
			4.6 KiB
		
	
	
	
		
			Bash
		
	
	
	
	
	
			
		
		
	
	
			150 lines
		
	
	
		
			4.6 KiB
		
	
	
	
		
			Bash
		
	
	
	
	
	
| #!/bin/bash
 | |
| #
 | |
| # Copyright (C) 2009 Red Hat, Inc.
 | |
| # Copyright (c) 2000-2001 Silicon Graphics, Inc.  All Rights Reserved.
 | |
| #
 | |
| # This program is free software; you can redistribute it and/or
 | |
| # modify it under the terms of the GNU General Public License as
 | |
| # published by the Free Software Foundation.
 | |
| #
 | |
| # This program is distributed in the hope that it would be useful,
 | |
| # but WITHOUT ANY WARRANTY; without even the implied warranty of
 | |
| # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 | |
| # GNU General Public License for more details.
 | |
| #
 | |
| # You should have received a copy of the GNU General Public License
 | |
| # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 | |
| #
 | |
| #
 | |
| # standard filters
 | |
| #
 | |
| 
 | |
| # ctime(3) dates
 | |
| #
 | |
| _filter_date()
 | |
| {
 | |
|     sed \
 | |
|         -e 's/[A-Z][a-z][a-z] [A-z][a-z][a-z]  *[0-9][0-9]* [0-9][0-9]:[0-9][0-9]:[0-9][0-9] [0-9][0-9][0-9][0-9]$/DATE/'
 | |
| }
 | |
| 
 | |
| _filter_generated_node_ids()
 | |
| {
 | |
|      sed -re 's/\#block[0-9]{3,}/NODE_NAME/'
 | |
| }
 | |
| 
 | |
| # replace occurrences of the actual TEST_DIR value with TEST_DIR
 | |
| _filter_testdir()
 | |
| {
 | |
|     sed -e "s#$TEST_DIR#TEST_DIR#g"
 | |
| }
 | |
| 
 | |
| # replace occurrences of the actual IMGFMT value with IMGFMT
 | |
| _filter_imgfmt()
 | |
| {
 | |
|     sed -e "s#$IMGFMT#IMGFMT#g"
 | |
| }
 | |
| 
 | |
| # Removes \r from messages
 | |
| _filter_win32()
 | |
| {
 | |
|     sed -e 's/\r//g'
 | |
| }
 | |
| 
 | |
| # sanitize qemu-io output
 | |
| _filter_qemu_io()
 | |
| {
 | |
|     _filter_win32 | sed -e "s/[0-9]* ops\; [0-9/:. sec]* ([0-9/.inf]* [EPTGMKiBbytes]*\/sec and [0-9/.inf]* ops\/sec)/X ops\; XX:XX:XX.X (XXX YYY\/sec and XXX ops\/sec)/" \
 | |
|         -e "s/: line [0-9][0-9]*:  *[0-9][0-9]*\( Aborted\| Killed\)/:\1/" \
 | |
|         -e "s/qemu-io> //g"
 | |
| }
 | |
| 
 | |
| # replace occurrences of QEMU_PROG with "qemu"
 | |
| _filter_qemu()
 | |
| {
 | |
|     sed -e "s#\\(^\\|(qemu) \\)$(basename $QEMU_PROG):#\1QEMU_PROG:#" \
 | |
|         -e 's#^QEMU [0-9]\+\.[0-9]\+\.[0-9]\+ monitor#QEMU X.Y.Z monitor#' \
 | |
|         -e '/main-loop: WARNING: I\/O thread spun for [0-9]\+ iterations/d' \
 | |
|         -e $'s#\r##' # QEMU monitor uses \r\n line endings
 | |
| }
 | |
| 
 | |
| # replace problematic QMP output like timestamps
 | |
| _filter_qmp()
 | |
| {
 | |
|     _filter_win32 | \
 | |
|     sed -e 's#\("\(micro\)\?seconds": \)[0-9]\+#\1 TIMESTAMP#g' \
 | |
|         -e 's#^{"QMP":.*}$#QMP_VERSION#' \
 | |
|         -e '/^    "QMP": {\s*$/, /^    }\s*$/ c\' \
 | |
|         -e '    QMP_VERSION'
 | |
| }
 | |
| 
 | |
| # replace driver-specific options in the "Formatting..." line
 | |
| _filter_img_create()
 | |
| {
 | |
|     sed -e "s#$IMGPROTO:$TEST_DIR#TEST_DIR#g" \
 | |
|         -e "s#$TEST_DIR#TEST_DIR#g" \
 | |
|         -e "s#$IMGFMT#IMGFMT#g" \
 | |
|         -e "s# encryption=off##g" \
 | |
|         -e "s# cluster_size=[0-9]\\+##g" \
 | |
|         -e "s# table_size=[0-9]\\+##g" \
 | |
|         -e "s# compat=[^ ]*##g" \
 | |
|         -e "s# compat6=\\(on\\|off\\)##g" \
 | |
|         -e "s# static=\\(on\\|off\\)##g" \
 | |
|         -e "s# zeroed_grain=\\(on\\|off\\)##g" \
 | |
|         -e "s# subformat='[^']*'##g" \
 | |
|         -e "s# adapter_type='[^']*'##g" \
 | |
|         -e "s# hwversion=[^ ]*##g" \
 | |
|         -e "s# lazy_refcounts=\\(on\\|off\\)##g" \
 | |
|         -e "s# block_size=[0-9]\\+##g" \
 | |
|         -e "s# block_state_zero=\\(on\\|off\\)##g" \
 | |
|         -e "s# log_size=[0-9]\\+##g" \
 | |
|         -e "s/archipelago:a/TEST_DIR\//g" \
 | |
|         -e "s# refcount_bits=[0-9]\\+##g" \
 | |
|         -e "s# key-secret=[a-zA-Z0-9]\\+##g"
 | |
| }
 | |
| 
 | |
| _filter_img_info()
 | |
| {
 | |
|     sed -e "s#$IMGPROTO:$TEST_DIR#TEST_DIR#g" \
 | |
|         -e "s#$TEST_DIR#TEST_DIR#g" \
 | |
|         -e "s#$IMGFMT#IMGFMT#g" \
 | |
|         -e 's#nbd://127.0.0.1:10810$#TEST_DIR/t.IMGFMT#g' \
 | |
|         -e "/encrypted: yes/d" \
 | |
|         -e "/cluster_size: [0-9]\\+/d" \
 | |
|         -e "/table_size: [0-9]\\+/d" \
 | |
|         -e "/compat: '[^']*'/d" \
 | |
|         -e "/compat6: \\(on\\|off\\)/d" \
 | |
|         -e "/static: \\(on\\|off\\)/d" \
 | |
|         -e "/zeroed_grain: \\(on\\|off\\)/d" \
 | |
|         -e "/subformat: '[^']*'/d" \
 | |
|         -e "/adapter_type: '[^']*'/d" \
 | |
|         -e "/hwversion: '[^']*'/d" \
 | |
|         -e "/lazy_refcounts: \\(on\\|off\\)/d" \
 | |
|         -e "/block_size: [0-9]\\+/d" \
 | |
|         -e "/block_state_zero: \\(on\\|off\\)/d" \
 | |
|         -e "/log_size: [0-9]\\+/d" \
 | |
|         -e "s/archipelago:a/TEST_DIR\//g"
 | |
| }
 | |
| 
 | |
| # filter out offsets and file names from qemu-img map
 | |
| _filter_qemu_img_map()
 | |
| {
 | |
|     sed -e 's/\([0-9a-fx]* *[0-9a-fx]* *\)[0-9a-fx]* */\1/g' \
 | |
|         -e 's/Mapped to *//' | _filter_testdir | _filter_imgfmt
 | |
| }
 | |
| 
 | |
| _filter_nbd()
 | |
| {
 | |
|     # nbd.c error messages contain function names and line numbers that are
 | |
|     # prone to change.  Message ordering depends on timing between send and
 | |
|     # receive callbacks sometimes, making them unreliable.
 | |
|     #
 | |
|     # Filter out the TCP port number since this changes between runs.
 | |
|     sed -e '/nbd\/.*\.c:/d' \
 | |
|         -e 's#nbd:\(//\)\?127\.0\.0\.1:[0-9]*#nbd:\1127.0.0.1:PORT#g' \
 | |
|         -e "s#?socket=$TEST_DIR#?socket=TEST_DIR#g" \
 | |
|         -e 's#\(exportname=foo\|PORT\): Failed to .*$#\1#'
 | |
| }
 | |
| 
 | |
| # make sure this script returns success
 | |
| true
 |