Before restoring DVM, check for available xen memory
As we already do xm mem-set 0 800 in qubes_core, this is a correct check. Now, there should be no errors from qubes_restore in normal circumstances.
This commit is contained in:
parent
a5f11913be
commit
4cf0a61858
@ -187,6 +187,16 @@ class DomainState:
|
|||||||
|
|
||||||
def handle_transfer_disposable(self, transaction_seq):
|
def handle_transfer_disposable(self, transaction_seq):
|
||||||
|
|
||||||
|
mem_for_dvm = 400
|
||||||
|
xenfreepages_s = subprocess.Popen(["/usr/lib/qubes/xenfreepages"],stdout=subprocess.PIPE).stdout.readline()
|
||||||
|
xenfree_mb = int(xenfreepages_s)*4096/1024/1024
|
||||||
|
if xenfree_mb < mem_for_dvm:
|
||||||
|
errmsg = 'Not enough memory to create DVM: '
|
||||||
|
errmsg +='have ' + str(xenfree_mb) + 'MB, need '
|
||||||
|
errmsg +=str(mem_for_dvm) + 'MB. Terminate some appVM and retry.'
|
||||||
|
subprocess.call(['/usr/bin/kdialog', '--sorry', errmsg])
|
||||||
|
return False
|
||||||
|
|
||||||
qvm_collection = QubesVmCollection()
|
qvm_collection = QubesVmCollection()
|
||||||
qvm_collection.lock_db_for_writing()
|
qvm_collection.lock_db_for_writing()
|
||||||
qvm_collection.load()
|
qvm_collection.load()
|
||||||
|
@ -1,9 +1,14 @@
|
|||||||
CC=gcc
|
CC=gcc
|
||||||
all: qubes_restore xenstore-watch
|
all: qubes_restore xenstore-watch xenfreepages
|
||||||
qubes_restore: qubes_restore.o
|
qubes_restore: qubes_restore.o
|
||||||
$(CC) -o qubes_restore qubes_restore.o -lxenstore
|
$(CC) -o qubes_restore qubes_restore.o -lxenstore
|
||||||
|
|
||||||
xenstore-watch: xenstore-watch.o
|
xenstore-watch: xenstore-watch.o
|
||||||
$(CC) -o xenstore-watch xenstore-watch.o -lxenstore
|
$(CC) -o xenstore-watch xenstore-watch.o -lxenstore
|
||||||
|
|
||||||
|
xenfreepages: xenfreepages.o
|
||||||
|
$(CC) -o xenfreepages xenfreepages.o -lxenctrl
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
rm -f *.o *~ qubes_restore xenstore-watch
|
rm -f *.o *~ qubes_restore xenstore-watch xenfreepages
|
||||||
|
|
||||||
|
18
dom0/restore/xenfreepages.c
Normal file
18
dom0/restore/xenfreepages.c
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
#include <xenctrl.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
struct xen_sysctl_physinfo xphysinfo;
|
||||||
|
main()
|
||||||
|
{
|
||||||
|
int handle = xc_interface_open();
|
||||||
|
if (handle == -1) {
|
||||||
|
perror("xc_interface_open");
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
if (xc_physinfo(handle, &xphysinfo)) {
|
||||||
|
perror("xc_physinfo");
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
printf("%lld", xphysinfo.free_pages);
|
||||||
|
return 0;
|
||||||
|
}
|
@ -79,7 +79,7 @@ cp aux-tools/remove_appvm_appmenus.sh $RPM_BUILD_ROOT/usr/lib/qubes
|
|||||||
cp pendrive_swapper/qubes_pencmd $RPM_BUILD_ROOT/usr/lib/qubes
|
cp pendrive_swapper/qubes_pencmd $RPM_BUILD_ROOT/usr/lib/qubes
|
||||||
|
|
||||||
cp restore/xenstore-watch restore/qvm-create-default-dvm $RPM_BUILD_ROOT/usr/bin
|
cp restore/xenstore-watch restore/qvm-create-default-dvm $RPM_BUILD_ROOT/usr/bin
|
||||||
cp restore/qubes_restore $RPM_BUILD_ROOT/usr/lib/qubes
|
cp restore/qubes_restore restore/xenfreepages $RPM_BUILD_ROOT/usr/lib/qubes
|
||||||
cp restore/qubes_prepare_saved_domain.sh $RPM_BUILD_ROOT/usr/lib/qubes
|
cp restore/qubes_prepare_saved_domain.sh $RPM_BUILD_ROOT/usr/lib/qubes
|
||||||
|
|
||||||
mkdir -p $RPM_BUILD_ROOT/var/lib/qubes
|
mkdir -p $RPM_BUILD_ROOT/var/lib/qubes
|
||||||
@ -221,3 +221,4 @@ fi
|
|||||||
/usr/lib/qubes/qubes_restore
|
/usr/lib/qubes/qubes_restore
|
||||||
/usr/lib/qubes/qubes_prepare_saved_domain.sh
|
/usr/lib/qubes/qubes_prepare_saved_domain.sh
|
||||||
/etc/xen/scripts/block.qubes
|
/etc/xen/scripts/block.qubes
|
||||||
|
%attr(4750,root,qubes) /usr/lib/qubes/xenfreepages
|
||||||
|
Loading…
Reference in New Issue
Block a user