From nobody Sun Feb 8 21:06:46 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 1510080605880325.0461903518858; Tue, 7 Nov 2017 10:50:05 -0800 (PST) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 56FF620272; Tue, 7 Nov 2017 18:50:04 +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 207C45C886; Tue, 7 Nov 2017 18:50:04 +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 A7E493D380; Tue, 7 Nov 2017 18:50:03 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id vA7IneL7024847 for ; Tue, 7 Nov 2017 13:49:40 -0500 Received: by smtp.corp.redhat.com (Postfix) id 3CDB75EDE4; Tue, 7 Nov 2017 18:49:40 +0000 (UTC) Received: from mx1.redhat.com (ext-mx05.extmail.prod.ext.phx2.redhat.com [10.5.110.29]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 378515EDE0 for ; Tue, 7 Nov 2017 18:49:38 +0000 (UTC) Received: from mail-qt0-f171.google.com (mail-qt0-f171.google.com [209.85.216.171]) (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 ED06820272 for ; Tue, 7 Nov 2017 18:49:36 +0000 (UTC) Received: by mail-qt0-f171.google.com with SMTP id k31so278588qta.6 for ; Tue, 07 Nov 2017 10:49:36 -0800 (PST) Received: from dawid-fedora.datto.lan ([47.19.105.250]) by smtp.gmail.com with ESMTPSA id t34sm1313175qtb.79.2017.11.07.10.49.35 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 07 Nov 2017 10:49:35 -0800 (PST) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 56FF620272 Authentication-Results: ext-mx05.extmail.prod.ext.phx2.redhat.com; dmarc=fail (p=none dis=none) header.from=datto.com Authentication-Results: ext-mx05.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 56FF620272 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="DymM6HTX" DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com ED06820272 Authentication-Results: ext-mx05.extmail.prod.ext.phx2.redhat.com; dmarc=pass (p=none dis=none) header.from=datto.com Authentication-Results: ext-mx05.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=dzamirski@datto.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com ED06820272 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=mgqUvdeHXJDNdtirB3xhkuLp3Jce4bvF5fzSlKcqkMk=; b=DymM6HTX8A3l6PPie5qVNKx1WxOiA2AV+XEUc6siBXRH8589nX84AVz9c183MZpJo6 667vspS0PRFNhJH/K7FzwYw+Oo/awQJIgaW2t+JbyswmaKIs3VLC2yy4CKwDMcbwL9Ch F8IW0083dojwKXZJyP1lEwIBvoDjgzErvr6J+k3C4VMpgPGSb6RghUNsyNZhKj99R/u0 tq8GW3wKUNRQD2XtD7+RLHsZeOI4t+z1Pne+2SojHuGqGW73lqucc3nNLAhSF3qbskNG gBtzxv7Rz8OsMqF71Actzf9I1xX6oD3FDeFAZuot9hljcgONPgSzr/eU7n/wigknxDcK YiIQ== 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=mgqUvdeHXJDNdtirB3xhkuLp3Jce4bvF5fzSlKcqkMk=; b=LjV8fr9JzaIu7biU5VnyKH+w0WbTYBP9o62oLVKH5i786BWWthZaMMylWtCw3GrQgj VOuRtV6HipTf6ZaRAerMq2oHvgwbNcPaOjbPZnQDjZNZ5wWrtUoWSH/GUUo6Pd81uJhZ 4K32a1drECCFNXS/TED4mx+V5p0jF6z+xhqH/Lyaj1ELmpMEz75kjp4y9y/yOB0HCtyK 8KcIOl3xqquuCWTWwLKlb4fHn0LuIqT3wUCOCmueZ6wbsiFpZGdT+DLqYz6O3kWAKNVd 7hONbSZGwFPGArQ4ZFqN2kBUGjZ7COknJPdZiNT3l5+5jTQq17/J8dLFTDY/hA6dCzDX hQzQ== X-Gm-Message-State: AMCzsaVlswnrTJBltoBTivhwXoWxUTRYxtbPHGgrNWgQu3N/nQ2mXCK3 MwnK9C9M9t8qr3K/Mnxu8BW59KbOuUo= X-Google-Smtp-Source: ABhQp+T4OxdlU4eNN4r474oSB2FBD8jDbuqIGQfu8uHQnzV5tsfcCyaYE0bn0kA2ucK0+OyZ+luf4g== X-Received: by 10.200.45.28 with SMTP id n28mr30428026qta.100.1510080575910; Tue, 07 Nov 2017 10:49:35 -0800 (PST) From: Dawid Zamirski To: libvir-list@redhat.com Date: Tue, 7 Nov 2017 13:49:21 -0500 Message-Id: <20171107184930.12769-5-dzamirski@datto.com> In-Reply-To: <20171107184930.12769-1-dzamirski@datto.com> References: <20171107184930.12769-1-dzamirski@datto.com> X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.29]); Tue, 07 Nov 2017 18:49:37 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.29]); Tue, 07 Nov 2017 18:49:37 +0000 (UTC) for IP:'209.85.216.171' DOMAIN:'mail-qt0-f171.google.com' HELO:'mail-qt0-f171.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.171 mail-qt0-f171.google.com 209.85.216.171 mail-qt0-f171.google.com X-Scanned-By: MIMEDefang 2.78 on 10.5.110.29 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH v3 04/13] vbox: Rename vboxDumpIDEHDDs to vboxDumpDisks 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.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.29]); Tue, 07 Nov 2017 18:50:04 +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" Because it deals with other disk types as well not just IDE. Also this function now returns -1 on error --- src/vbox/vbox_common.c | 57 ++++++++++++++++++++++------------------------= ---- 1 file changed, 25 insertions(+), 32 deletions(-) diff --git a/src/vbox/vbox_common.c b/src/vbox/vbox_common.c index 4d596075c..2e0d7ee9a 100644 --- a/src/vbox/vbox_common.c +++ b/src/vbox/vbox_common.c @@ -3254,13 +3254,11 @@ vboxDumpStorageControllers(virDomainDefPtr def, IMa= chine *machine) } =20 =20 -static void -vboxDumpIDEHDDs(virDomainDefPtr def, vboxDriverPtr data, IMachine *machine) +static int +vboxDumpDisks(virDomainDefPtr def, vboxDriverPtr data, IMachine *machine) { - /* dump IDE hdds if present */ vboxArray mediumAttachments =3D VBOX_ARRAY_INITIALIZER; - bool error =3D false; - int diskCount =3D 0; + int ret =3D -1, diskCount =3D 0; size_t i; PRUint32 maxPortPerInst[StorageBus_Floppy + 1] =3D {}; PRUint32 maxSlotPerPort[StorageBus_Floppy + 1] =3D {}; @@ -3284,24 +3282,22 @@ vboxDumpIDEHDDs(virDomainDefPtr def, vboxDriverPtr = data, IMachine *machine) } =20 /* Allocate mem, if fails return error */ - if (VIR_ALLOC_N(def->disks, def->ndisks) >=3D 0) { - for (i =3D 0; i < def->ndisks; i++) { - virDomainDiskDefPtr disk =3D virDomainDiskDefNew(NULL); - if (!disk) { - error =3D true; - break; - } - def->disks[i] =3D disk; - } - } else { - error =3D true; + if (VIR_ALLOC_N(def->disks, def->ndisks) < 0) + goto cleanup; + + for (i =3D 0; i < def->ndisks; i++) { + virDomainDiskDefPtr disk =3D virDomainDiskDefNew(NULL); + if (!disk) + goto cleanup; + + def->disks[i] =3D disk; } =20 - if (!error) - error =3D !vboxGetMaxPortSlotValues(data->vboxObj, maxPortPerInst,= maxSlotPerPort); + if (!vboxGetMaxPortSlotValues(data->vboxObj, maxPortPerInst, maxSlotPe= rPort)) + goto cleanup; =20 /* get the attachment details here */ - for (i =3D 0; i < mediumAttachments.count && diskCount < def->ndisks &= & !error; i++) { + for (i =3D 0; i < mediumAttachments.count && diskCount < def->ndisks; = i++) { IMediumAttachment *imediumattach =3D mediumAttachments.items[i]; IStorageController *storageController =3D NULL; PRUnichar *storageControllerName =3D NULL; @@ -3347,8 +3343,8 @@ vboxDumpIDEHDDs(virDomainDefPtr def, vboxDriverPtr da= ta, IMachine *machine) if (!virDomainDiskGetSource(def->disks[diskCount])) { VBOX_RELEASE(medium); VBOX_RELEASE(storageController); - error =3D true; - break; + + goto cleanup; } =20 gVBoxAPI.UIStorageController.GetBus(storageController, &storageBus= ); @@ -3385,8 +3381,8 @@ vboxDumpIDEHDDs(virDomainDefPtr def, vboxDriverPtr da= ta, IMachine *machine) deviceInst, devicePort, deviceSlot); VBOX_RELEASE(medium); VBOX_RELEASE(storageController); - error =3D true; - break; + + goto cleanup; } =20 gVBoxAPI.UIMedium.GetReadOnly(medium, &readOnly); @@ -3401,15 +3397,12 @@ vboxDumpIDEHDDs(virDomainDefPtr def, vboxDriverPtr = data, IMachine *machine) diskCount++; } =20 + ret =3D 0; + + cleanup: gVBoxAPI.UArray.vboxArrayRelease(&mediumAttachments); =20 - /* cleanup on error */ - if (error) { - for (i =3D 0; i < def->ndisks; i++) - VIR_FREE(def->disks[i]); - VIR_FREE(def->disks); - def->ndisks =3D 0; - } + return ret; } =20 static int @@ -4103,8 +4096,8 @@ static char *vboxDomainGetXMLDesc(virDomainPtr dom, u= nsigned int flags) goto cleanup; if (vboxDumpStorageControllers(def, machine) < 0) goto cleanup; - - vboxDumpIDEHDDs(def, data, machine); + if (vboxDumpDisks(def, data, machine) < 0) + goto cleanup; =20 vboxDumpSharedFolders(def, data, machine); vboxDumpNetwork(def, data, machine, networkAdapterCount); --=20 2.14.3 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list