From nobody Mon Feb 9 21:37:39 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1508873750954645.7446715338068; Tue, 24 Oct 2017 12:35:50 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 21970C062EDF; Tue, 24 Oct 2017 19:35:49 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 8830960F84; Tue, 24 Oct 2017 19:35:48 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id EDFE51804487; Tue, 24 Oct 2017 19:35:45 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id v9OJZiYO009672 for ; Tue, 24 Oct 2017 15:35:44 -0400 Received: by smtp.corp.redhat.com (Postfix) id 2A68B18994; Tue, 24 Oct 2017 19:35:44 +0000 (UTC) Received: from mx1.redhat.com (ext-mx09.extmail.prod.ext.phx2.redhat.com [10.5.110.38]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 2459F6031E for ; Tue, 24 Oct 2017 19:35:43 +0000 (UTC) Received: from mail-qt0-f172.google.com (mail-qt0-f172.google.com [209.85.216.172]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 2B65A49035 for ; Tue, 24 Oct 2017 19:35:41 +0000 (UTC) Received: by mail-qt0-f172.google.com with SMTP id 8so31965035qtv.1 for ; Tue, 24 Oct 2017 12:35:41 -0700 (PDT) Received: from dawid-fedora.datto.lan ([47.19.105.250]) by smtp.gmail.com with ESMTPSA id f66sm683127qkc.25.2017.10.24.12.35.39 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 24 Oct 2017 12:35:39 -0700 (PDT) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 21970C062EDF Authentication-Results: ext-mx07.extmail.prod.ext.phx2.redhat.com; dmarc=fail (p=none dis=none) header.from=datto.com Authentication-Results: ext-mx07.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=libvir-list-bounces@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 21970C062EDF Authentication-Results: mx1.redhat.com; dkim=fail reason="signature verification failed" (2048-bit key) header.d=datto-com.20150623.gappssmtp.com header.i=@datto-com.20150623.gappssmtp.com header.b="TlIPoo72" DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 2B65A49035 Authentication-Results: ext-mx09.extmail.prod.ext.phx2.redhat.com; dmarc=pass (p=none dis=none) header.from=datto.com Authentication-Results: ext-mx09.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=dzamirski@datto.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 2B65A49035 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=datto-com.20150623.gappssmtp.com; s=20150623; h=from:to:subject:date:message-id:in-reply-to:references; bh=gEbYJv/TJGwKYoaq6NSsJLiVwkdaCEdVUKsM36jqFNY=; b=TlIPoo72GvSAokd7WzTWYsAJVBmAN6m8BUmsXHF7vxQ1o1vJhMYqM/XNA2rTepb54I lSJu9+h7yv/kOLYSAz7cqggjC1XBJPKz+XUAsGh09CfnOn0ykGPf2c/loIMYbYgMEv/n 74l6Y48Ujnif0S9VhEJ6xHUDVSaQ3o+jWXPRaQ/jhleLhLZIgFPenYymwPq6BXI/3nCg oOrwMiGDa56sLX+ScUtufC2GUlKzRZ7kRnghGKoY0s2qAl0d7UGOvH//Hrw9y/PBImUY fd6IX6kqx6Xi2D66jd69QId4HcicpWKsca/l6Eq1bKy2ifGxGmnAgnTaKwB4TLWLUrOV NcuA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references; bh=gEbYJv/TJGwKYoaq6NSsJLiVwkdaCEdVUKsM36jqFNY=; b=BCPbFFJjJfVPfJqlE6Ccu6cdZ1j/2EkFHqo26WHUngHu8coDkirPTCaQgwyz8k8MVl gC2rFhv+7l6PoTOLSvFsZ6ckcE7q0BhojEN0jn6cObvEz7Y1eI8SXgrkJR1nUvaHneuK yHHxzaReu8xLQaY2vyVnGDhbRmAk79Ys83nR8Tswb9meUNcfuivrfB0ynz0qjsfbAXni PYLqyXGphyGYW7MNG6cjgVBtciLBSmOliknHjUImyaROw0IDKJc4Or535D/JBZ6UOanq /qLa4i/tIeOkZ9v7SxIbmycqQAvoeuXQAK6/o4CZOVgtxyI/zozHOYALIutA13t5T5S7 PZ6w== X-Gm-Message-State: AMCzsaVwLMAv3R0M97nl7hVMfeGn9KGfFbyffNjt7WCtnJ9YNUxbp4Bf kNYgOBcSNmzJKPgJS6xXEWAREhg4GQ8= X-Google-Smtp-Source: ABhQp+SpbSUgEgeg5+J1V99QEISl3l36eHHmYGjMwOd0AeJgLe7SnVCFbT9B4sPqKomXjTV35lNYxQ== X-Received: by 10.200.50.230 with SMTP id a35mr26424781qtb.226.1508873740175; Tue, 24 Oct 2017 12:35:40 -0700 (PDT) From: Dawid Zamirski To: libvir-list@redhat.com Date: Tue, 24 Oct 2017 15:35:25 -0400 Message-Id: <20171024193538.9078-3-dzamirski@datto.com> In-Reply-To: <20171024193538.9078-1-dzamirski@datto.com> References: <20171024193538.9078-1-dzamirski@datto.com> X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Tue, 24 Oct 2017 19:35:41 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Tue, 24 Oct 2017 19:35:41 +0000 (UTC) for IP:'209.85.216.172' DOMAIN:'mail-qt0-f172.google.com' HELO:'mail-qt0-f172.google.com' FROM:'dzamirski@datto.com' RCPT:'' X-RedHat-Spam-Score: 0.469 (DKIM_SIGNED, DKIM_VALID, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, RCVD_IN_SORBS_SPAM, SPF_PASS) 209.85.216.172 mail-qt0-f172.google.com 209.85.216.172 mail-qt0-f172.google.com X-Scanned-By: MIMEDefang 2.78 on 10.5.110.38 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH v2 02/15] vbox: Close media when undefining domains X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.31]); Tue, 24 Oct 2017 19:35:49 +0000 (UTC) X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" When registering a VM we call OpenMedium on each disk image which adds it to vbox's global media registry. Therefore, we should make sure to call Close when unregistering VM so we cleanup the media registry entries after ourselves - this does not remove disk image files. This follows the behaviour of the VBoxManage unregistervm command. Reviewed-by: John Ferlan --- src/vbox/vbox_tmpl.c | 24 +++++++++++++++++++----- 1 file changed, 19 insertions(+), 5 deletions(-) diff --git a/src/vbox/vbox_tmpl.c b/src/vbox/vbox_tmpl.c index 4aa5e9a63..2679b60f7 100644 --- a/src/vbox/vbox_tmpl.c +++ b/src/vbox/vbox_tmpl.c @@ -378,6 +378,8 @@ _unregisterMachine(vboxDriverPtr data, vboxIID *iid, IM= achine **machine) { nsresult rc; vboxArray media =3D VBOX_ARRAY_INITIALIZER; + size_t i; + rc =3D data->vboxObj->vtbl->FindMachine(data->vboxObj, iid->value, mac= hine); if (NS_FAILED(rc)) { virReportError(VIR_ERR_NO_DOMAIN, "%s", @@ -385,12 +387,24 @@ _unregisterMachine(vboxDriverPtr data, vboxIID *iid, = IMachine **machine) return rc; } =20 - /* We're not interested in the array returned by the Unregister method, - * but in the side effect of unregistering the virtual machine. In ord= er - * to call the Unregister method correctly we need to use the vboxArray - * wrapper here. */ rc =3D vboxArrayGetWithUintArg(&media, *machine, (*machine)->vtbl->Unr= egister, - CleanupMode_DetachAllReturnNone); + CleanupMode_DetachAllReturnHardDisksOnly); + + if (NS_FAILED(rc)) + goto cleanup; + + /* close each medium attached to VM to remove from media registry */ + for (i =3D 0; i < media.count; i++) { + IMedium *medium =3D media.items[i]; + + if (!medium) + continue; + + /* it's ok to ignore failure here - e.g. it may be used by another= VM */ + ignore_value(medium->vtbl->Close(medium)); + } + + cleanup: vboxArrayUnalloc(&media); return rc; } --=20 2.14.2 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list