9front - general discussion about 9front
 help / color / mirror / Atom feed
* devvmx: don't keep moribund virtual machines around
@ 2020-11-22 23:24 estevan.cps
  0 siblings, 0 replies; only message in thread
From: estevan.cps @ 2020-11-22 23:24 UTC (permalink / raw)
  To: 9front

Hello,

When removing a VM's ctl file, devvmx keeps it around as moribund, together with it's state and resources; it only gets cleaned up after another ctl file is removed. While this might be useful for debugging the VM post-mortem, I don't see much point in keeping a VM explicitly marked as dead around (from what I can see, it seems like the only way to mark a VM as moribund is by removing it's ctl file), and it does seem to cause more pain than it's worth; perhaps someone else could shine a better light on this. The patch below reverts this behaviour, cleaning up a virtual machine as soon as it's ctl file is removed.

I think it could also be a good idea to add a command line flag to vmx(1) that makes it open() the VM without ORCLOSE, for cases where it is desirable to keep a VM around after death.

--
Tevo

diff -r a7cc619b0017 sys/src/9/pc/devvmx.c
--- a/sys/src/9/pc/devvmx.c	Tue Nov 17 18:37:38 2020 -0800
+++ b/sys/src/9/pc/devvmx.c	Sun Nov 22 23:04:13 2020 +0000
@@ -318,7 +318,6 @@
 	[VMXENDING]"ending"
 };
 
-static Vmx *moribund;
 static QLock vmxtablock;
 static Vmx **vmxtab;
 static int nvmxtab;
@@ -1166,8 +1165,6 @@
 	qunlock(vmxmach);
 	
 	qlock(&vmxtablock);
-	if(moribund == vmx)
-		moribund = nil;
 	vmxtab[vmx->index] = nil;
 	qunlock(&vmxtablock);
 	free(vmx);
@@ -1966,7 +1963,7 @@
 static void
 vmxremove(Chan *ch)
 {
-	Vmx *vmx, *old;
+	Vmx *vmx;
 
 	vmxclunk(ch);
 	if(SLOT(ch->qid) == -1 || FILE(ch->qid) != Qctl)
@@ -1974,12 +1971,8 @@
 	vmx = vmxent(ch->qid);
 	if(vmx == nil)
 		error(Enonexist);
-	qlock(&vmxtablock);
-	old = moribund;
-	moribund = vmx;
-	qunlock(&vmxtablock);
-	if(old != nil)
-		vmxcmd(old, cmdquit);
+	else
+		vmxcmd(vmx, cmdquit);
 }
 
 static void


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2020-11-22 23:24 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-11-22 23:24 devvmx: don't keep moribund virtual machines around estevan.cps

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).