3 # Copyright (C) 2014 Red Hat Inc.
5 # This program is free software; you can redistribute it and/or modify
6 # it under the terms of the GNU General Public License as published by
7 # the Free Software Foundation; either version 2 of the License, or
8 # (at your option) any later version.
10 # This program is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 # GNU General Public License for more details.
15 # You should have received a copy of the GNU General Public License
16 # along with this program; if not, write to the Free Software
17 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19 # 'virt-bmap' is a shell script wrapper that runs nbdkit with the
20 # right options. Read virt-bmap(1) before trying to use this program.
22 # If you want to run this without installing then use the './run'
23 # script in the build directory, eg:
25 # ./run virt-bmap -o bmap disk.img
28 version="@PACKAGE_VERSION@"
35 --long help,format:,output:,version \
38 echo "$program: problem parsing the command line arguments"
46 echo " $program [-o bmap] [--format raw|qcow2|...] disk.img"
48 echo "Read $program(1) man page for more information."
61 echo "$program $version"
69 echo "internal error ($1)"
74 # At the moment we only support a single disk image argument.
75 # Supporting multiple disk images requires adding support for export
78 echo "$program: Missing disk image argument. See $program(1)."
82 # Turn the disk image arguments into disk=...
88 # Deal with stupid autotools libdir-not-expandable crap.
90 exec_prefix="@exec_prefix@"
93 # Get the examiner plugin.
94 if [ -z "$VIRTBMAP_PLUGIN_DIR" ]; then
95 VIRTBMAP_PLUGIN_DIR="$libdir"
104 trap cleanup EXIT ERR
105 socket="$tmpdir/socket"
107 # Run nbdkit with plugin and arguments.
108 nbdkit -r -f -U "$socket" \
109 "$VIRTBMAP_PLUGIN_DIR/virtbmapexaminer.so" \