9front - general discussion about 9front
 help / color / mirror / Atom feed
From: estevan.cps@gmail.com
To: 9front@9front.org
Subject: devvmx: don't keep moribund virtual machines around
Date: Sun, 22 Nov 2020 23:24:38 +0000	[thread overview]
Message-ID: <2681E11A48D645CF4B79AC6420BBDC20@gmail.com> (raw)

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


                 reply	other threads:[~2020-11-22 23:24 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=2681E11A48D645CF4B79AC6420BBDC20@gmail.com \
    --to=estevan.cps@gmail.com \
    --cc=9front@9front.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).