-
-
Notifications
You must be signed in to change notification settings - Fork 108
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
KVM #438
base: master
Are you sure you want to change the base?
KVM #438
Changes from all commits
8809592
cc25490
564d691
e249832
f323d83
e4a2cc0
06a33e8
85e6376
94140d1
dd39207
0a6f9ed
1643e2c
d1709fe
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
@@ -0,0 +1,32 @@ | ||||||
#!/bin/sh | ||||||
|
||||||
# Return hypervisor name or match result if 'name' provided | ||||||
hypervisor () { | ||||||
local name="$1" | ||||||
local hypervisor | ||||||
|
||||||
if [[ $(cat /sys/hypervisor/type 2>/dev/null) == 'xen' ]]; then | ||||||
hypervisor="xen" | ||||||
|
||||||
elif [ -e /sys/devices/virtual/misc/kvm ]; then | ||||||
hypervisor="kvm" | ||||||
fi | ||||||
|
||||||
if [ ! -z $hypervisor ]; then | ||||||
if [ -z "$name" ]; then | ||||||
echo "$hypervisor" | ||||||
return 0 | ||||||
fi | ||||||
if [ "$name" == "$hypervisor" ]; then | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
return 0 | ||||||
fi | ||||||
fi | ||||||
return 1 | ||||||
} | ||||||
|
||||||
|
||||||
(return 0 2>/dev/null) && sourced=1 || sourced=0 | ||||||
if (( ! sourced )); then | ||||||
hypervisor "$1" | ||||||
fi | ||||||
|
Original file line number | Diff line number | Diff line change | ||||||
---|---|---|---|---|---|---|---|---|
@@ -1,14 +1,21 @@ | ||||||||
#!/bin/sh | ||||||||
#!/usr/bin/sh | ||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||
|
||||||||
# Misc dom0 startup setup | ||||||||
#### KVM: | ||||||||
. /usr/lib/qubes/hypervisor.sh | ||||||||
######## | ||||||||
|
||||||||
/usr/lib/qubes/fix-dir-perms.sh | ||||||||
DOM0_MAXMEM=$(/usr/sbin/xl list 0 | tail -1 | awk '{ print $3 }') | ||||||||
xenstore-write /local/domain/0/memory/static-max $[ $DOM0_MAXMEM * 1024 ] | ||||||||
#### KVM: | ||||||||
if hypervisor xen; then | ||||||||
/usr/lib/qubes/fix-dir-perms.sh | ||||||||
DOM0_MAXMEM=$(/usr/sbin/xl list 0 | tail -1 | awk '{ print $3 }') | ||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This runs into an
Suggested change
|
||||||||
xenstore-write /local/domain/0/memory/static-max $[ $DOM0_MAXMEM * 1024 ] | ||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||
|
||||||||
xl sched-credit -d 0 -w 2000 | ||||||||
cp /var/lib/qubes/qubes.xml /var/lib/qubes/backup/qubes-$(date +%F-%T).xml | ||||||||
xl sched-credit -d 0 -w 2000 | ||||||||
fi | ||||||||
######## | ||||||||
|
||||||||
cp /var/lib/qubes/qubes.xml /var/lib/qubes/backup/qubes-$(date +%F-%T).xml | ||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||
/usr/lib/qubes/cleanup-dispvms | ||||||||
|
||||||||
# Hide mounted devices from qubes-block list (at first udev run, only / is mounted) | ||||||||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
# | ||
# The Qubes OS Project, https://www.qubes-os.org/ | ||
# | ||
# Copyright (C) 2020 Jason Mehring <[email protected]> | ||
# | ||
# This library is free software; you can redistribute it and/or | ||
# modify it under the terms of the GNU Lesser General Public | ||
# License as published by the Free Software Foundation; either | ||
# version 2.1 of the License, or (at your option) any later version. | ||
# | ||
# This library is distributed in the hope that it will be useful, | ||
# but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
# Lesser General Public License for more details. | ||
# | ||
# You should have received a copy of the GNU Lesser General Public | ||
# License along with this library; if not, see <https://www.gnu.org/licenses/>. | ||
# | ||
|
||
'''Hypervisor utilities.''' | ||
|
||
import pathlib | ||
|
||
|
||
def hypervisor_name(): | ||
'''Return hypervisor name.''' | ||
hypervisor = pathlib.Path('/sys/hypervisor/type') | ||
if hypervisor.exists(): | ||
return hypervisor.read_text().strip().lower() | ||
if pathlib.Path('/sys/devices/virtual/misc/kvm').exists(): | ||
return 'kvm' | ||
return None | ||
|
||
|
||
def is_xen(): | ||
'''Check if hypervisor is xen.''' | ||
return hypervisor_name() == 'xen' | ||
|
||
|
||
def is_kvm(): | ||
'''Check if hypervisor is xen.''' | ||
return hypervisor_name() == 'xen' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.