File: kvmmounts.sh

package info (click to toggle)
libreswan 5.2-2.2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 81,632 kB
  • sloc: ansic: 129,988; sh: 32,018; xml: 20,646; python: 10,303; makefile: 3,022; javascript: 1,506; sed: 574; yacc: 511; perl: 264; awk: 52
file content (49 lines) | stat: -rwxr-xr-x 711 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#!/bin/sh

set -eu

if test $# -eq 0 ; then
    cat <<EOF 1>&2
Usage: $0 <host> [ <mount> ]
List <host>s kvm mounts.
If <mount> is specified, just print that mount's path.
EOF
    exit 1
fi

host=$1 ; shift

mount=
if test $# -gt 0; then
    mount=$1 ; shift
fi

if test $# -gt 0; then
    echo "Unexpected argument: $*" 1>&2
    exit 1
fi

sudo virsh dumpxml $host | awk '
/<filesystem type=.mount. / {
    source = ""
    target = ""
}

/<source dir=/ {
    split($2, a, /'\''/)
    source = a[2]
}

/<target dir=/ {
    split($2, a, /'\''/)
    target = a[2]
}

/<\/filesystem>/ {
    if ("'$mount'" == "") {
        print target, source
    } else if ("'$mount'" == target) {
        print source
    }
}
'