Merge branch 'hvm' of 10.141.1.101:/var/lib/qubes/git/marmarek/core into hvm

This commit is contained in:
Joanna Rutkowska 2012-07-13 14:51:25 +02:00
commit 26de4312d5
10 changed files with 69 additions and 16 deletions

View File

@ -16,7 +16,7 @@ get_running_netvms() {
suspend_net()
{
for VM in `get_running_netvms`; do
qvm-run -u root --pass-io $VM 'service NetworkManager stop; for if in `ls /sys/class/net|grep -v "lo\|vif"`; do ip l s $if down; done; modprobe -r uhci_hcd ehci_hcd'
qvm-run -u root --pass-io $VM 'QUBESRPC qubes.SuspendPre dom0'
done
# Ignore exit status from netvm...
return 0
@ -25,7 +25,7 @@ suspend_net()
resume_net()
{
for VM in `get_running_netvms`; do
qvm-run -u root --pass-io $VM "modprobe ehci_hcd; modprobe uhci_hcd; [ -x /bin/systemctl ] && systemctl start NetworkManager.service || service qubes_core_netvm start"
qvm-run -u root --pass-io $VM 'QUBESRPC qubes.SuspendPost dom0'
done
# Ignore exit status from netvm...
return 0

View File

@ -1634,12 +1634,6 @@ class QubesTemplateVm(QubesVm):
raise IOError ("Error while copying {0} to {1}".\
format(self.clean_img, self.volatile_img))
if verbose:
print >> sys.stderr, "--> Copying the template's DispVM prerun script..."
retcode = subprocess.call (["cp", src_vm.dir_path + '/dispvm-prerun.sh', self.dir_path + '/dispvm-prerun.sh'])
if retcode != 0:
raise IOError ("Error while copying DispVM prerun script")
# Create root-cow.img
self.commit_changes(verbose=verbose)

View File

@ -1,11 +1,15 @@
#!/bin/bash
get_encoded_script()
{
if ! [ -f "$1" ] ; then
if [ "$1" == "vm-default" ]; then
SCRIPT_CMD="echo /usr/lib/qubes/dispvm-prerun.sh"
elif ! [ -f "$1" ] ; then
echo $1 is not a file ?
exit 1
else
SCRIPT_CMD="cat $1"
fi
ENCODED_SCRIPT=`cat "$1" | perl -e 'use MIME::Base64 qw(encode_base64); local($/) = undef;print encode_base64(<STDIN>)'|tr -d "\n"`
ENCODED_SCRIPT=`$SCRIPT_CMD | perl -e 'use MIME::Base64 qw(encode_base64); local($/) = undef;print encode_base64(<STDIN>)'|tr -d "\n"`
}
if [ $# != 2 -a $# != 3 ] ; then

View File

@ -21,13 +21,9 @@ if [ "$TEMPLATENAME" = --default-template ] ; then
fi
if [ "X""$2" = "X""--default-script" ] ; then
SCRIPTNAME="/var/lib/qubes/vm-templates/$TEMPLATENAME"/dispvm-prerun.sh
if ! [ -f $SCRIPTNAME ] ; then
echo $SCRIPTNAME does not exist
exit 1
fi
SCRIPTNAME="vm-default"
else
SCRIPTNAME=$2
SCRIPTNAME=$2
fi
if ! [ -d "/var/lib/qubes/vm-templates/$TEMPLATENAME" ] ; then

BIN
misc/dispvm-dotfiles.tbz Normal file

Binary file not shown.

27
misc/dispvm-prerun.sh Executable file
View File

@ -0,0 +1,27 @@
#!/bin/sh
apps="evince /usr/libexec/evinced soffice firefox"
cat /etc/dispvm-dotfiles.tbz | tar -xjf- --overwrite -C /home/user --owner user 2>&1 >/tmp/dispvm-dotfiles-errors.log
for app in $apps ; do
echo "Launching: $app..."
$app >>/tmp/dispvm_prerun_errors.log 2>&1 &
done
echo "Sleeping..."
PREV_IO=0
while true; do
IO=`vmstat -D | awk '/read|write/ {IOs+=$1} END {print IOs}'`
if [ $IO -lt $[ $PREV_IO + 50 ] ]; then
break;
fi
PREV_IO=$IO
sleep 1
done
ps ax > /tmp/dispvm-prerun-proclist.log
cat /etc/dispvm-dotfiles.tbz | tar -xjf- --overwrite -C /home/user --owner user 2>&1 >>/tmp/dispvm-dotfiles-errors.log
echo done.

16
qubes_rpc/prepare-suspend Executable file
View File

@ -0,0 +1,16 @@
#!/bin/sh
action=$1
[ -z "$action" ] && action=suspend
if [ x"$action" == x"suspend" ]; then
nmcli nm sleep true || service NetworkManager stop
# Force interfaces down, just in case when NM didn't done it
for if in `ls /sys/class/net|grep -v "lo\|vif"`; do
ip l s $if down
done
modprobe -r uhci_hcd ehci_hcd
else
modprobe ehci_hcd; modprobe uhci_hcd;
nmcli nm sleep false || { [ -x /bin/systemctl ] && systemctl start NetworkManager.service; } || service qubes_core_netvm start
fi

View File

@ -0,0 +1 @@
/usr/lib/qubes/prepare-suspend resume

View File

@ -0,0 +1 @@
/usr/lib/qubes/prepare-suspend suspend

View File

@ -119,6 +119,13 @@ install misc/qubes_trigger_sync_appmenus.sh $RPM_BUILD_ROOT/usr/lib/qubes/
install -D -m 0644 misc/qubes_trigger_sync_appmenus.action $RPM_BUILD_ROOT/etc/yum/post-actions/qubes_trigger_sync_appmenus.action
mkdir -p $RPM_BUILD_ROOT/usr/lib/qubes
if [ -r misc/dispvm-dotfiles.%{dist}.tbz ]; then
install misc/dispvm-dotfiles.%{dist}.tbz $RPM_BUILD_ROOT/etc/dispvm-dotfiles.tbz
else
install misc/dispvm-dotfiles.tbz $RPM_BUILD_ROOT/etc/dispvm-dotfiles.tbz
fi
install misc/dispvm-prerun.sh $RPM_BUILD_ROOT/usr/lib/qubes/dispvm-prerun.sh
install -D misc/qubes_core.modules $RPM_BUILD_ROOT/etc/sysconfig/modules/qubes_core.modules
install -m 0644 network/qubes_network.rules $RPM_BUILD_ROOT/etc/udev/rules.d/99-qubes_network.rules
@ -151,10 +158,12 @@ install qubes_rpc/qvm-copy-to-vm.gnome $RPM_BUILD_ROOT/usr/lib/qubes
install qubes_rpc/{vm-file-editor,qfile-agent,qopen-in-vm,qfile-unpacker} $RPM_BUILD_ROOT/usr/lib/qubes
install qubes_rpc/{vm-shell,qrun-in-vm} $RPM_BUILD_ROOT/usr/lib/qubes
install qubes_rpc/sync-ntp-clock $RPM_BUILD_ROOT/usr/lib/qubes
install qubes_rpc/prepare-suspend $RPM_BUILD_ROOT/usr/lib/qubes
install -d $RPM_BUILD_ROOT/%{kde_service_dir}
install -m 0644 qubes_rpc/{qvm-copy.desktop,qvm-dvm.desktop} $RPM_BUILD_ROOT/%{kde_service_dir}
install -d $RPM_BUILD_ROOT/etc/qubes_rpc
install -m 0644 qubes_rpc/{qubes.Filecopy,qubes.OpenInVM,qubes.VMShell,qubes.SyncNtpClock} $RPM_BUILD_ROOT/etc/qubes_rpc
install -m 0644 qubes_rpc/{qubes.SuspendPre,qubes.SuspendPost} $RPM_BUILD_ROOT/etc/qubes_rpc
install qrexec/qrexec_agent $RPM_BUILD_ROOT/usr/lib/qubes
install qrexec/qrexec_client_vm $RPM_BUILD_ROOT/usr/lib/qubes
@ -355,6 +364,7 @@ rm -rf $RPM_BUILD_ROOT
/etc/NetworkManager/dispatcher.d/30-qubes_external_ip
/etc/NetworkManager/dispatcher.d/qubes_nmhook
/etc/X11/xorg-preload-apps.conf
/etc/dispvm-dotfiles.tbz
/etc/dhclient.d/qubes_setup_dnat_to_ns.sh
/etc/fstab
/etc/pki/rpm-gpg/RPM-GPG-KEY-qubes*
@ -363,6 +373,8 @@ rm -rf $RPM_BUILD_ROOT
/etc/qubes_rpc/qubes.OpenInVM
/etc/qubes_rpc/qubes.VMShell
/etc/qubes_rpc/qubes.SyncNtpClock
/etc/qubes_rpc/qubes.SuspendPre
/etc/qubes_rpc/qubes.SuspendPost
/etc/sudoers.d/qubes
/etc/sysconfig/iptables
/etc/sysconfig/modules/qubes_core.modules
@ -386,7 +398,9 @@ rm -rf $RPM_BUILD_ROOT
/usr/lib/qubes/block_add_change
/usr/lib/qubes/block_cleanup
/usr/lib/qubes/block_remove
/usr/lib/qubes/dispvm-prerun.sh
/usr/lib/qubes/sync-ntp-clock
/usr/lib/qubes/prepare-suspend
/usr/lib/qubes/meminfo-writer
/usr/lib/qubes/network-manager-prepare-conf-dir
/usr/lib/qubes/qfile-agent