dispvm: use qubesdb instead of xenstore

This commit is contained in:
Marek Marczykowski 2013-06-10 04:28:13 +02:00 committed by Marek Marczykowski-Górecki
parent 457737b6cc
commit ff2c925e18
2 changed files with 14 additions and 22 deletions

View File

@ -107,15 +107,6 @@ class QubesDisposableVm(QubesVm):
def verify_files(self): def verify_files(self):
return True 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): def get_config_params(self):
attrs = super(QubesDisposableVm, self).get_config_params() attrs = super(QubesDisposableVm, self).get_config_params()
attrs['privatedev'] = '' attrs['privatedev'] = ''
@ -160,11 +151,15 @@ class QubesDisposableVm(QubesVm):
print >>sys.stderr, "time=%s, done" % (str(time.time())) print >>sys.stderr, "time=%s, done" % (str(time.time()))
self._libvirt_domain = None self._libvirt_domain = None
if verbose:
print >> sys.stderr, "--> Starting Qubes DB..."
self.start_qubesdb()
self.services['qubes-dvm'] = True self.services['qubes-dvm'] = True
if verbose: 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) 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 # fire hooks
for hook in self.hooks_start: for hook in self.hooks_start:

View File

@ -29,29 +29,26 @@ if ! qvm-start $1 --no-guid --dvm ; then
exit 1 exit 1
fi fi
ID=`virsh -c xen:/// domid $1` echo "Waiting for DVM $1 ..." >&2
if [ "$ID" = "" ] ; then
echo "cannot get domain id" >&2
exit 1
fi
echo "Waiting for DVM domainid=$ID ..." >&2
if [ -n "$ENCODED_SCRIPT" ] ; then 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 fi
#set -x #set -x
xenstore-write /local/domain/$ID/qubes-save-request 1 qubesdb-write -d $1 /qubes-save-request 1
xenstore-watch-qubes /local/domain/$ID/device/qubes-used-mem qubesdb-watch -d $1 /qubes-used-mem
xenstore-read /local/domain/$ID/qubes-gateway | \ qubesdb-read -d $1 /qubes-gateway | \
cut -d . -f 3 | tr -d "\n" > $VMDIR/netvm-id.txt cut -d . -f 3 | tr -d "\n" > $VMDIR/netvm-id.txt
# FIXME: get connection URI from core scripts # FIXME: get connection URI from core scripts
virsh -c xen:/// detach-disk $1 xvdb 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 echo "DVM boot complete, memory used=$MEM. Saving image..." >&2
QMEMMAN_STOP=/var/run/qubes/do-not-membalance QMEMMAN_STOP=/var/run/qubes/do-not-membalance
touch $QMEMMAN_STOP touch $QMEMMAN_STOP
virsh -c xen:/// setmem $1 $MEM virsh -c xen:/// setmem $1 $MEM
# Add some safety margin # Add some safety margin
virsh -c xen:/// setmaxmem $1 $[ $MEM + 1024 ] 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 sleep 1
touch $2 touch $2
if ! virsh -c xen:/// save $1 $2; then if ! virsh -c xen:/// save $1 $2; then