The Underscores Revolution: DispVM savefiles
This commit is contained in:
parent
341f202a26
commit
2e29b8ee86
@ -2,23 +2,23 @@
|
||||
|
||||
# Setup DispVM things at Qubes system startup
|
||||
|
||||
printf "\x00\x00\x00\x00" > /var/run/qubes/dispVM_seq
|
||||
chown root:qubes /var/run/qubes/dispVM_seq
|
||||
chmod 660 /var/run/qubes/dispVM_seq
|
||||
DEFAULT=/var/lib/qubes/dvmdata/default_savefile
|
||||
DEFAULT_CONFIG=/var/lib/qubes/dvmdata/default_dvm.conf
|
||||
printf "\x00\x00\x00\x00" > /var/run/qubes/dispVM.seq
|
||||
chown root:qubes /var/run/qubes/dispVM.seq
|
||||
chmod 660 /var/run/qubes/dispVM.seq
|
||||
DEFAULT=/var/lib/qubes/dvmdata/default-savefile
|
||||
DEFAULT_CONFIG=/var/lib/qubes/dvmdata/default-dvm.conf
|
||||
# setup DispVM files only when they exists
|
||||
if [ -r $DEFAULT ]; then
|
||||
ln -s $DEFAULT_CONFIG /var/run/qubes/current_dvm.conf
|
||||
if [ -f /var/lib/qubes/dvmdata/dont_use_shm ] ; then
|
||||
ln -s $DEFAULT /var/run/qubes/current_savefile
|
||||
ln -s $DEFAULT_CONFIG /var/run/qubes/current-dvm.conf
|
||||
if [ -f /var/lib/qubes/dvmdata/dont-use-shm ] ; then
|
||||
ln -s $DEFAULT /var/run/qubes/current-savefile
|
||||
else
|
||||
mkdir -m 770 /dev/shm/qubes
|
||||
chown root.qubes /dev/shm/qubes
|
||||
cp -a $(readlink $DEFAULT) /dev/shm/qubes/current_savefile
|
||||
chown root.qubes /dev/shm/qubes/current_savefile
|
||||
chmod 660 /dev/shm/qubes/current_savefile
|
||||
ln -s /dev/shm/qubes/current_savefile /var/run/qubes/current_savefile
|
||||
cp -a $(readlink $DEFAULT) /dev/shm/qubes/current-savefile
|
||||
chown root.qubes /dev/shm/qubes/current-savefile
|
||||
chmod 660 /dev/shm/qubes/current-savefile
|
||||
ln -s /dev/shm/qubes/current-savefile /var/run/qubes/current-savefile
|
||||
fi
|
||||
fi
|
||||
|
||||
|
@ -49,7 +49,7 @@ process()
|
||||
export PATH="/sbin:/bin:/usr/bin:/usr/sbin:$PATH"
|
||||
|
||||
XENBUS_PATH="${XENBUS_PATH:?}"
|
||||
if ! [ "$1" = "add" ] || ! [ -f /var/run/qubes/fast_block_attach ] ; then
|
||||
if ! [ "$1" = "add" ] || ! [ -f /var/run/qubes/fast-block-attach ] ; then
|
||||
exec flock /var/run/qubes/hotplug-block /etc/xen/scripts/block "$@"
|
||||
fi
|
||||
|
||||
|
@ -33,8 +33,8 @@ from qubes.qubes import QubesDaemonPidfile
|
||||
from qubes.qubes import QubesDispVmLabels
|
||||
from qubes.qmemman_client import QMemmanClient
|
||||
|
||||
current_savefile = '/var/run/qubes/current_savefile'
|
||||
current_dvm_conf = '/var/run/qubes/current_dvm.conf'
|
||||
current_savefile = '/var/run/qubes/current-savefile'
|
||||
current_dvm_conf = '/var/run/qubes/current-dvm.conf'
|
||||
notify_object = None
|
||||
|
||||
class QfileDaemonDvm:
|
||||
@ -69,7 +69,7 @@ class QfileDaemonDvm:
|
||||
if len(sys.argv) > 4 and len(sys.argv[4]) > 0:
|
||||
assert sys.argv[4] in QubesDispVmLabels.keys(), "Invalid label"
|
||||
label = QubesDispVmLabels[sys.argv[4]]
|
||||
print >>sys.stderr, "time=%s, starting qubes_restore" % (str(time.time()))
|
||||
print >>sys.stderr, "time=%s, starting qubes-restore" % (str(time.time()))
|
||||
retcode = subprocess.call(['/usr/lib/qubes/qubes-restore',
|
||||
current_savefile,
|
||||
current_dvm_conf,
|
||||
@ -85,7 +85,7 @@ class QfileDaemonDvm:
|
||||
subprocess.call(['/usr/bin/zenity', '--warning', 'DisposableVM creation failed, see qubes-restore.log'])
|
||||
qvm_collection.unlock_db()
|
||||
return None
|
||||
f = open('/var/run/qubes/dispVM_xid', 'r');
|
||||
f = open('/var/run/qubes/dispVM.xid', 'r');
|
||||
disp_xid = f.readline().rstrip('\n')
|
||||
disp_name = f.readline().rstrip('\n')
|
||||
disptempl = f.readline().rstrip('\n')
|
||||
@ -120,10 +120,10 @@ class QfileDaemonDvm:
|
||||
dvmdata_dir = '/var/lib/qubes/dvmdata/'
|
||||
if not os.path.isfile(current_savefile):
|
||||
return False
|
||||
if not os.path.isfile(dvmdata_dir+'default_savefile') or not os.path.isfile(dvmdata_dir+'savefile_root'):
|
||||
if not os.path.isfile(dvmdata_dir+'default-savefile') or not os.path.isfile(dvmdata_dir+'savefile-root'):
|
||||
return False
|
||||
dvm_mtime = os.stat(current_savefile).st_mtime
|
||||
root_mtime = os.stat(dvmdata_dir+'savefile_root').st_mtime
|
||||
root_mtime = os.stat(dvmdata_dir+'savefile-root').st_mtime
|
||||
if dvm_mtime < root_mtime:
|
||||
return False
|
||||
return True
|
||||
|
@ -42,7 +42,7 @@ fi
|
||||
xenstore-write /local/domain/$ID/qubes-save-request 1
|
||||
xenstore-watch-qubes /local/domain/$ID/device/qubes-used-mem
|
||||
xenstore-read /local/domain/$ID/qubes-gateway | \
|
||||
cut -d . -f 3 | tr -d "\n" > $VMDIR/netvm_id.txt
|
||||
cut -d . -f 3 | tr -d "\n" > $VMDIR/netvm-id.txt
|
||||
xl block-detach $1 xvdb
|
||||
MEM=$(xenstore-read /local/domain/$ID/device/qubes-used-mem)
|
||||
echo "DVM boot complete, memory used=$MEM. Saving image..."
|
||||
@ -59,5 +59,5 @@ rm -f $QMEMMAN_STOP
|
||||
cd $VMDIR
|
||||
# Fix start memory
|
||||
sed -i -e "s/^memory.*/memory = $((MEM/1000))/" dvm.conf
|
||||
tar -Scvf saved_cows.tar volatile.img
|
||||
tar -Scvf saved-cows.tar volatile.img
|
||||
echo "DVM savefile created successfully."
|
||||
|
@ -91,7 +91,7 @@ char *gettime()
|
||||
}
|
||||
|
||||
int actually_do_unlink = 1;
|
||||
#define FAST_FLAG_PATH "/var/run/qubes/fast_block_attach"
|
||||
#define FAST_FLAG_PATH "/var/run/qubes/fast-block-attach"
|
||||
void set_fast_flag()
|
||||
{
|
||||
int fd = open(FAST_FLAG_PATH, O_CREAT | O_RDONLY, 0600);
|
||||
@ -297,7 +297,7 @@ void unpack_cows(char *name)
|
||||
int status;
|
||||
snprintf(vmdir, sizeof(vmdir), "/var/lib/qubes/appvms/%s", name);
|
||||
snprintf(tarfile, sizeof(tarfile),
|
||||
"/var/lib/qubes/appvms/%s/saved_cows.tar", name);
|
||||
"/var/lib/qubes/appvms/%s/saved-cows.tar", name);
|
||||
switch (fork()) {
|
||||
case -1:
|
||||
fprintf(stderr, "fork");
|
||||
@ -347,7 +347,7 @@ int get_netvm_id_from_name(char *name)
|
||||
char netvm_id[256];
|
||||
char netvm_id_path[256];
|
||||
snprintf(netvm_id_path, sizeof(netvm_id_path),
|
||||
"/var/lib/qubes/appvms/%s/netvm_id.txt", name);
|
||||
"/var/lib/qubes/appvms/%s/netvm-id.txt", name);
|
||||
fd = open(netvm_id_path, O_RDONLY);
|
||||
if (fd < 0) {
|
||||
perror("open netvm_id");
|
||||
@ -391,9 +391,9 @@ void setup_xenstore(int netvm_id, int domid, int dvmid, char *name)
|
||||
int get_next_disposable_id()
|
||||
{
|
||||
int seq = 0;
|
||||
int fd = open("/var/run/qubes/dispVM_seq", O_RDWR);
|
||||
int fd = open("/var/run/qubes/dispVM.seq", O_RDWR);
|
||||
if (fd < 0) {
|
||||
perror("open dispVM_seq");
|
||||
perror("open dispVM.seq");
|
||||
exit(1);
|
||||
}
|
||||
read(fd, &seq, sizeof(seq));
|
||||
@ -406,9 +406,9 @@ int get_next_disposable_id()
|
||||
|
||||
void write_varrun_domid(int domid, char *dispname, char *orig)
|
||||
{
|
||||
FILE *f = fopen("/var/run/qubes/dispVM_xid", "w");
|
||||
FILE *f = fopen("/var/run/qubes/dispVM.xid", "w");
|
||||
if (!f) {
|
||||
perror("fopen dispVM_xid");
|
||||
perror("fopen dispVM.xid");
|
||||
exit(1);
|
||||
}
|
||||
fprintf(f, "%d\n%s\n%s\n", domid, dispname, orig);
|
||||
@ -418,10 +418,10 @@ void write_varrun_domid(int domid, char *dispname, char *orig)
|
||||
|
||||
void redirect_stderr()
|
||||
{
|
||||
int fd = open("/var/log/qubes/qubes_restore.log",
|
||||
int fd = open("/var/log/qubes/qubes-restore.log",
|
||||
O_CREAT | O_TRUNC | O_WRONLY, 0600);
|
||||
if (fd < 0) {
|
||||
syslog(LOG_DAEMON | LOG_ERR, "open qubes_restore.log");
|
||||
syslog(LOG_DAEMON | LOG_ERR, "open qubes-restore.log");
|
||||
exit(1);
|
||||
}
|
||||
dup2(fd, 2);
|
||||
|
@ -3,7 +3,7 @@ if [ $# != 1 -a $# != 2 ] ; then
|
||||
echo 'Usage: qvm-create-default-dvm templatename|--default-template|--used-template [script-name|--default-script]'
|
||||
exit 1
|
||||
fi
|
||||
export ROOT=/var/lib/qubes/dvmdata/savefile_root
|
||||
export ROOT=/var/lib/qubes/dvmdata/savefile-root
|
||||
TEMPLATENAME=$1
|
||||
if [ "$TEMPLATENAME" = --used-template ] ; then
|
||||
if [ -e $ROOT ] ; then
|
||||
@ -45,18 +45,18 @@ if ! /usr/lib/qubes/qubes-prepare-saved-domain.sh \
|
||||
"$DVMTMPL" "/var/lib/qubes/appvms/$DVMTMPL/dvm-savefile" $SCRIPTNAME ; then
|
||||
exit 1
|
||||
fi
|
||||
DEFAULT=/var/lib/qubes/dvmdata/default_savefile
|
||||
DEFAULTCONF=/var/lib/qubes/dvmdata/default_dvm.conf
|
||||
CURRENT=/var/run/qubes/current_savefile
|
||||
CURRENTCONF=/var/run/qubes/current_dvm.conf
|
||||
DEFAULT=/var/lib/qubes/dvmdata/default-savefile
|
||||
DEFAULTCONF=/var/lib/qubes/dvmdata/default-dvm.conf
|
||||
CURRENT=/var/run/qubes/current-savefile
|
||||
CURRENTCONF=/var/run/qubes/current-dvm.conf
|
||||
SHMDIR=/dev/shm/qubes
|
||||
SHMCOPY=$SHMDIR/current_savefile
|
||||
SHMCOPY=$SHMDIR/current-savefile
|
||||
rm -f $ROOT $DEFAULT $CURRENT $DEFAULTCONF $CURRENTCONF
|
||||
ln -s "/var/lib/qubes/appvms/$DVMTMPL/dvm-savefile" $DEFAULT
|
||||
ln -s "/var/lib/qubes/vm-templates/$TEMPLATENAME/root.img" $ROOT
|
||||
ln -s $DVMTMPLDIR/dvm.conf $DEFAULTCONF
|
||||
ln -s $DVMTMPLDIR/dvm.conf $CURRENTCONF
|
||||
if [ -f /var/lib/qubes/dvmdata/dont_use_shm ] ; then
|
||||
if [ -f /var/lib/qubes/dvmdata/dont-use-shm ] ; then
|
||||
ln -s $DEFAULT $CURRENT
|
||||
else
|
||||
mkdir -m 770 $SHMDIR 2>/dev/null
|
||||
|
Loading…
Reference in New Issue
Block a user