summaryrefslogtreecommitdiffstats
path: root/core/modules/qemu/data/usr/bin/qemu-system-x86_64.openslx
blob: bc743f48824c20596db04567f02e9d03e8c2e696 (plain) (blame)
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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
#!/bin/sh

bin="${0%.openslx}"

allflags="$( "$bin" -cpu help | sed -En '/^Recognized CPUID flags:/,/^$/s/ +/,+/gp' | tail -n+2 | tr -d '\n' )"

replace_params () {
  modelname=
  model=
  family=
  stepping=
  vendor=
  for i; do
    shift
    case "$i" in
    migratable=*)
      continue
      ;;
    model=*)
      model=1
      ;;
    model-id=*)
      modelname=1
      ;;
    family=*)
      family=1
      ;;
    stepping=*)
      stepping=1
      ;;
    vendor=*)
      vendor=1
      ;;
    *)
      ;;
    esac
    set -- "$@" "$i"
  done
  [ -z "$modelname" ] && set -- "$@" "model-id=$( awk '/^model name\s/ {print substr($0,index($0, ":")+2); exit}' /proc/cpuinfo )"
  [ -z "$vendor" ] && set -- "$@" "vendor=$( awk '/^vendor_id\s/ {print substr($0,index($0, ":")+2); exit}' /proc/cpuinfo )"
  [ -z "$model" ] && set -- "$@" "model=$( awk '$1$2 == "model:" {print $3; exit}' /proc/cpuinfo )"
  [ -z "$family" ] && set -- "$@" "family=$( awk '$1$2$3 == "cpufamily:" {print $4; exit}' /proc/cpuinfo )"
  [ -z "$stepping" ] && set -- "$@" "stepping=$( awk '$1$2 == "stepping:" {print $3; exit}' /proc/cpuinfo )"
  printf "%s" "$*"
}

i="$#"
while [ "$i" -gt 0 ]; do
  case "$1" in
    -cpu)
      case "$2" in
      host|max)
        set -- "$@" -cpu "Cascadelake-Server$allflags"
        : "$(( i -= 2 ))"
        shift 2
        continue
        ;;
      host*|max*)
        params="${2#*,}"
        params="$( set -f ; IFS=, ; replace_params $params )"
        set -- "$@" -cpu "Cascadelake-Server,$params$allflags"
        : "$(( i -= 2 ))"
        shift 2
        continue
        ;;
      esac
  esac
  set -- "$@" "$1"
  : "$(( i -= 1 ))"
  shift 1
done

exec "$bin" "$@"