From ff2c925e1823bf3296c555136e5773c6928a49cd Mon Sep 17 00:00:00 2001 From: Marek Marczykowski Date: Mon, 10 Jun 2013 04:28:13 +0200 Subject: [PATCH] dispvm: use qubesdb instead of xenstore --- core-modules/01QubesDisposableVm.py | 17 ++++++----------- dispvm/qubes-prepare-saved-domain.sh | 19 ++++++++----------- 2 files changed, 14 insertions(+), 22 deletions(-) diff --git a/core-modules/01QubesDisposableVm.py b/core-modules/01QubesDisposableVm.py index b3f216c5..14525eb8 100644 --- a/core-modules/01QubesDisposableVm.py +++ b/core-modules/01QubesDisposableVm.py @@ -107,15 +107,6 @@ class QubesDisposableVm(QubesVm): def verify_files(self): return True - def create_xenstore_entries(self, xid): - super(QubesDisposableVm, self).create_xenstore_entries(xid) - - # TODO! - domain_path = vmm.xs.get_domain_path(xid) - - vmm.xs.write('', "{0}/qubes-restore-complete".format(domain_path), - 'True') - def get_config_params(self): attrs = super(QubesDisposableVm, self).get_config_params() attrs['privatedev'] = '' @@ -160,11 +151,15 @@ class QubesDisposableVm(QubesVm): print >>sys.stderr, "time=%s, done" % (str(time.time())) self._libvirt_domain = None + if verbose: + print >> sys.stderr, "--> Starting Qubes DB..." + self.start_qubesdb() + self.services['qubes-dvm'] = True if verbose: - print >> sys.stderr, "--> Setting Xen Store info for the VM..." + print >> sys.stderr, "--> Setting Qubes DB info for the VM..." self.create_xenstore_entries(self.xid) - print >>sys.stderr, "time=%s, done xenstore" % (str(time.time())) + print >>sys.stderr, "time=%s, done qubesdb" % (str(time.time())) # fire hooks for hook in self.hooks_start: diff --git a/dispvm/qubes-prepare-saved-domain.sh b/dispvm/qubes-prepare-saved-domain.sh index 97dbdfcf..95177703 100755 --- a/dispvm/qubes-prepare-saved-domain.sh +++ b/dispvm/qubes-prepare-saved-domain.sh @@ -29,29 +29,26 @@ if ! qvm-start $1 --no-guid --dvm ; then exit 1 fi -ID=`virsh -c xen:/// domid $1` -if [ "$ID" = "" ] ; then - echo "cannot get domain id" >&2 - exit 1 -fi -echo "Waiting for DVM domainid=$ID ..." >&2 +echo "Waiting for DVM $1 ..." >&2 if [ -n "$ENCODED_SCRIPT" ] ; then - xenstore-write /local/domain/$ID/qubes-save-script "$ENCODED_SCRIPT" + qubesdb-write -d $1 /qubes-save-script "$ENCODED_SCRIPT" fi #set -x -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 | \ +qubesdb-write -d $1 /qubes-save-request 1 +qubesdb-watch -d $1 /qubes-used-mem +qubesdb-read -d $1 /qubes-gateway | \ cut -d . -f 3 | tr -d "\n" > $VMDIR/netvm-id.txt # FIXME: get connection URI from core scripts virsh -c xen:/// detach-disk $1 xvdb -MEM=$(xenstore-read /local/domain/$ID/device/qubes-used-mem) +MEM=$(qubesdb-read -d $1 /qubes-used-mem) echo "DVM boot complete, memory used=$MEM. Saving image..." >&2 QMEMMAN_STOP=/var/run/qubes/do-not-membalance touch $QMEMMAN_STOP virsh -c xen:/// setmem $1 $MEM # Add some safety margin virsh -c xen:/// setmaxmem $1 $[ $MEM + 1024 ] +# Stop qubesdb daemon now, so VM can restart it later +kill `cat /var/run/qubes/qubesdb.$1.pid` sleep 1 touch $2 if ! virsh -c xen:/// save $1 $2; then