From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-qt1-f181.google.com ([209.85.160.181]) by ewsd; Sun Nov 22 18:24:51 -0500 2020 Received: by mail-qt1-f181.google.com with SMTP id t5so11951385qtp.2 for <9front@9front.org>; Sun, 22 Nov 2020 15:24:43 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:message-id:to:subject:date:mime-version :content-transfer-encoding; bh=5XzrWcCmydjMEDb7KQ5kQTP59H/8aZtHLdj/Lqhmsy0=; b=uPQ87RTF6ZhIWwkUNc+6AlpwfP2NCPhwmEIpTuSVy4hZCYK+AyisIOcQD12FxiVVWM 6bH9d9DCgbA8dNSwE/XtfyEK1JeM8wsOCx9GKxxYCcCa4NQgbmHmfM/dIXAqOt5lEFHV XVisU2uUecI44iXBx6Ns/tBBQ2tGmdvlZQF1CJKDgrk7lEUFqstP3sBBFfAZ22N/Z33U q1WvGIBSPMMcgoFogVMiifn1HXOQI4+JgLNhjCCPrvxjPtpZQuGBsbdbsNJPLmZtLica PVR6yOAr2/ccjuFV3wlFjovk92Fkt5wRJkiEcOnlmneYEmBMinA+3wrxwDXAOpNXfHBg s/iw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:message-id:to:subject:date:mime-version :content-transfer-encoding; bh=5XzrWcCmydjMEDb7KQ5kQTP59H/8aZtHLdj/Lqhmsy0=; b=fvk2lAFZaZwsPBeVfeYHX7szYFMuI48eLPYyuevKG6i19k+jKm0dv8qNJvtA9qgFbR OFO4zMNm6+dsFi38FnPdjCjuT961ome1eVRKdfqwzlvQ0YIlUnQo7SgMIIUZYBoRUHSM uSYn37L4ehdpMbdZcZt7Xzhx6CbtweD8idE8/eqsKhPWQKkiHO0NJU4gN2++IWU0ipBb nYkvldzOMWlaX7Hxa0sTifSiUcck/oHjZz6V1ZtFcoAodaG5Mnx/1IyfI3lzDa4grn5c COXVx0sD3EncLdzu9Vz81dd0+tnpTRcGb1RIr2oGKm3QCIRXXZ6LTyq2V6RCLBRRJ42T 6/4A== X-Gm-Message-State: AOAM5301K98nBUqO0NFuPT+xhZaxGKxlC9aPNoam4QcEK/7upcpoVZab jNdmsWzl7q5kMBs3PVGi6rHUNNIq2hBMVc5v X-Google-Smtp-Source: ABdhPJzYAV/VD/CXpLnPq5rWdyJks8TpBfegl0YvZ0El4cgfNSdnueIfNYoGigv440azU6BTzd5tyA== X-Received: by 2002:a05:622a:18a:: with SMTP id s10mr26617122qtw.37.1606087482862; Sun, 22 Nov 2020 15:24:42 -0800 (PST) Return-Path: Received: from junko.shrine (164.163.115.232.yesconnect.net.br. [164.163.115.232]) by smtp.gmail.com with ESMTPSA id k188sm8051737qkd.98.2020.11.22.15.24.41 for <9front@9front.org> (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Sun, 22 Nov 2020 15:24:42 -0800 (PST) From: estevan.cps@gmail.com X-Google-Original-From: tevo@gmail.com Message-ID: <2681E11A48D645CF4B79AC6420BBDC20@gmail.com> To: 9front@9front.org Subject: devvmx: don't keep moribund virtual machines around Date: Sun, 22 Nov 2020 23:24:38 +0000 MIME-Version: 1.0 Content-Type: text/plain; charset="US-ASCII" Content-Transfer-Encoding: 7bit List-ID: <9front.9front.org> List-Help: X-Glyph: ➈ X-Bullshit: element rich-client event plugin CMS proxy-oriented interface 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