From nobody Sun Feb 8 17:21:41 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 1507583073200813.1834256865358; Mon, 9 Oct 2017 14:04:33 -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 99E39C04AC6A; Mon, 9 Oct 2017 21:04:31 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id D46E460269; Mon, 9 Oct 2017 21:04:30 +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 911A84EE50; Mon, 9 Oct 2017 21:04:29 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id v99Ko0b7022375 for ; Mon, 9 Oct 2017 16:50:00 -0400 Received: by smtp.corp.redhat.com (Postfix) id 31AAA5C6BF; Mon, 9 Oct 2017 20:50:00 +0000 (UTC) Received: from mx1.redhat.com (ext-mx08.extmail.prod.ext.phx2.redhat.com [10.5.110.32]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 2C2CF7770D for ; Mon, 9 Oct 2017 20:49:58 +0000 (UTC) Received: from mail-qk0-f176.google.com (mail-qk0-f176.google.com [209.85.220.176]) (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 2EC72C058EBF for ; Mon, 9 Oct 2017 20:49:57 +0000 (UTC) Received: by mail-qk0-f176.google.com with SMTP id o187so22611807qke.7 for ; Mon, 09 Oct 2017 13:49:57 -0700 (PDT) Received: from dawid-fedora.datto.lan ([47.19.105.250]) by smtp.gmail.com with ESMTPSA id y31sm5505361qta.83.2017.10.09.13.49.55 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 09 Oct 2017 13:49:55 -0700 (PDT) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 99E39C04AC6A 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 99E39C04AC6A 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="lwJ3FXNj" DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 2EC72C058EBF Authentication-Results: ext-mx08.extmail.prod.ext.phx2.redhat.com; dmarc=pass (p=none dis=none) header.from=datto.com Authentication-Results: ext-mx08.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=dzamirski@datto.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 2EC72C058EBF 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=jkZU2ZY9cVy6yIN3lwWC/G0rEXDsvW/kZIOEkfYZg7s=; b=lwJ3FXNjzqr6liKNM6RD053wmzufjFVFjDPWL60SVIBdfaSVNcprYMSDSaVleQAgQz fYE3vgNGaUMfaBTW8eOMkrNyyY8Z+ZQDuU/6/d3wAqyjLQUoPV/vJxHQUdF2Pi+R2QVP mTMa3DQFd4VMvcNje7WT+wyBrl4on1Sg/UQa/xBbX7uhqZpuV/Vya1DeZodHu7rrUU/K DgF0U5px1Tea4C9Dh6rJ0JxcWkIFIRV/nGVRNMX3pko6lRC4NLZtqjWVPV2SkOfdpyZA 2hH3bVn8jFjgngL8hEq2Mz9tl474FaoWYcJhgoxNcJf8VRxdFs+mAwlB/WJeNLWgjwgw nZrw== 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=jkZU2ZY9cVy6yIN3lwWC/G0rEXDsvW/kZIOEkfYZg7s=; b=mCOnz5BX0+RBBoJ09JP8P6AdnVOEB7iDcqJeLmYDlJ8M5HdMs9vD6Gd+QM8i3YN+JW bey/Ug0OE+eFwB7wrGMJ6xRK1q1bkRbAyInsv0+ukXIU+yFunGKMEdIpDMKGSj3T4Pud f/HFaztn41E+SLesx3CvaDtG3eRznbAo5FyOnae+4kD0KPfMDZslDWyM4B+wF79ATflt MBO4fIr1FWn+Rqu25ybq27g9uyQ0ReIYiuIgKR6JhQ8AM3zLhrdfhKKZl8FD78GAQsvU WDhZhrGrhM10EaZ2glYuK3F2HySTx3RuzMRna6VWyo9wHa609t9MzX8pJDq3obxff4+r +c1Q== X-Gm-Message-State: AMCzsaXvghzBgo2ZEhnmP5YffyxeG+NkxCIxqLisQWjQXwsDOA6o6gbg 1fvJfBrWwXC0Ns5INfk4g4zU64o95Hs= X-Google-Smtp-Source: AOwi7QAmDKzVgFfQY3j/hpVHx/mxEy6uWuKq9zgeRokYH6NXLuc+QdKYHFwHdG+67PVpFBC2ZfXkww== X-Received: by 10.55.159.4 with SMTP id i4mr11339778qke.339.1507582196116; Mon, 09 Oct 2017 13:49:56 -0700 (PDT) From: Dawid Zamirski X-Google-Original-From: Dawid Zamirski To: libvir-list@redhat.com Date: Mon, 9 Oct 2017 16:49:49 -0400 Message-Id: <20171009204954.11382-2-dzrudy@gmail.com> In-Reply-To: <20171009204954.11382-1-dzrudy@gmail.com> References: <20171009204954.11382-1-dzrudy@gmail.com> X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.32]); Mon, 09 Oct 2017 20:49:57 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.32]); Mon, 09 Oct 2017 20:49:57 +0000 (UTC) for IP:'209.85.220.176' DOMAIN:'mail-qk0-f176.google.com' HELO:'mail-qk0-f176.google.com' FROM:'dzamirski@datto.com' RCPT:'' X-RedHat-Spam-Score: -2.311 (DKIM_SIGNED, DKIM_VALID, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, RCVD_IN_SORBS_SPAM, SPF_PASS) 209.85.220.176 mail-qk0-f176.google.com 209.85.220.176 mail-qk0-f176.google.com X-Scanned-By: MIMEDefang 2.78 on 10.5.110.32 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 1/6] 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]); Mon, 09 Oct 2017 21:04:32 +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" From: Dawid Zamirski 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. --- 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 dffeabde0..ac3b8fa00 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 */ + 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