Browse Source

dispvm: fix netvm presence reporting

If desired netvm presence is different than during savefile creation(*),
defer setting the netvm until new DispVM is running - otherwise kernel
there will not notice the change and will either have (not working)
'eth0' when it shouldn't, or will not have it while it should.

Additionally set dispvm.uses_default_netvm = False, so GUI tools will
display actual netvm value.

(*) Actually compare to netvm set for dispvm template (`TEMPLATE-dvm`
VM), which can be different if user just changed that but not
regenerated dispvm savefile yet.

Fixes qubesos/qubes-issues#985
Related to qubesos/qubes-issues#862
Marek Marczykowski-Górecki 9 years ago
parent
commit
77da23fba2
1 changed files with 9 additions and 1 deletions
  1. 9 1
      dispvm/qfile-daemon-dvm

+ 9 - 1
dispvm/qfile-daemon-dvm

@@ -88,7 +88,11 @@ class QfileDaemonDvm:
             assert os.path.exists(sys.argv[5]), "Invalid firewall.conf location"
             dispvm.firewall_conf = sys.argv[5]
         if vm.qid != 0:
-            dispvm.netvm = vm.dispvm_netvm
+            dispvm.uses_default_netvm = False
+            # netvm can be changed before restore,
+            # but cannot be enabled/disabled
+            if (dispvm.netvm is None) == (vm.dispvm_netvm is None):
+                dispvm.netvm = vm.dispvm_netvm
         # Wait for tar to finish
         if tar_process.wait() != 0:
             sys.stderr.write('Failed to unpack saved-cows.tar')
@@ -96,6 +100,10 @@ class QfileDaemonDvm:
             return None
         print >>sys.stderr, "time=%s, VM starting" % (str(time.time()))
         dispvm.start()
+        if vm.qid != 0:
+            # if need to enable/disable netvm, do it while DispVM is alive
+            if (dispvm.netvm is None) != (vm.dispvm_netvm is None):
+                dispvm.netvm = vm.dispvm_netvm
         print >>sys.stderr, "time=%s, VM started" % (str(time.time()))
         qvm_collection.save()
         qvm_collection.unlock_db()