From nobody Mon Feb 9 14:33:13 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 1508873778383343.88226511475386; Tue, 24 Oct 2017 12:36:18 -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 DAB5633A167; Tue, 24 Oct 2017 19:36:16 +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 B19126024F; Tue, 24 Oct 2017 19:36:16 +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 43E5E6EF30; Tue, 24 Oct 2017 19:36:11 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id v9OJZlsV009725 for ; Tue, 24 Oct 2017 15:35:47 -0400 Received: by smtp.corp.redhat.com (Postfix) id 0835560F8B; Tue, 24 Oct 2017 19:35:47 +0000 (UTC) Received: from mx1.redhat.com (ext-mx02.extmail.prod.ext.phx2.redhat.com [10.5.110.26]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 026C760F84 for ; Tue, 24 Oct 2017 19:35:44 +0000 (UTC) Received: from mail-qt0-f178.google.com (mail-qt0-f178.google.com [209.85.216.178]) (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 278D4806C2 for ; Tue, 24 Oct 2017 19:35:43 +0000 (UTC) Received: by mail-qt0-f178.google.com with SMTP id 8so31965143qtv.1 for ; Tue, 24 Oct 2017 12:35:43 -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.41 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 24 Oct 2017 12:35:41 -0700 (PDT) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com DAB5633A167 Authentication-Results: ext-mx10.extmail.prod.ext.phx2.redhat.com; dmarc=fail (p=none dis=none) header.from=datto.com Authentication-Results: ext-mx10.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 DAB5633A167 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="rmkz3viQ" DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 278D4806C2 Authentication-Results: ext-mx02.extmail.prod.ext.phx2.redhat.com; dmarc=pass (p=none dis=none) header.from=datto.com Authentication-Results: ext-mx02.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=dzamirski@datto.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 278D4806C2 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=rm5UL81oqsJRgMCNkRwhq5YKiQaBUWaH3NEI1l8x2Fg=; b=rmkz3viQ9QlYRIEivHwOvXaTHtSD+7kBzftL3UFkSxnlIhBxGP2+8YjRx0/NuCC+ls bY0ETIn/n2Gc9ZBVLKTZ9PSnnA3O5LxtGW+Cg3mAjcuhVlf7IeRa6UQJVJCjgzIwZRrz J1y+5uo+OzoMsmEeC9IshEQan0KqusHb20mGxEm5CnBBq3YjbC2XRij+hoQqiCBOsEL6 F7d/fuMAfzhOE4MMZLIU3RxXkORMe/lz/EbjPR7y0VvuvChF8LVSErSUDbXE7eLlWRIj ez+9t3qKs+IER9ChVrQS2kMzJ+rSrldOIjhxYEICtqZoOwLQJvL6VWwwugYxg0uJmxhn mpHQ== 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=rm5UL81oqsJRgMCNkRwhq5YKiQaBUWaH3NEI1l8x2Fg=; b=qGm0BPi9Jjrkdg0P0+l7iMcguzy0EJEHGfU76jaSnXdwPbTDTXjZLnyKL/yi/8jeXy DSK3rSbQ6z3qGPbMObVBKIcHQ2qXgOTbXSgbZtbFXQwKVuU4rhss3ESRZVTwfh85IYHj OMbzfxuh2oDkU5ZXN88p4xhLHNWZt4qYsR9aj9jlQTa+CgshXRsb9eechDhKzw5oggFT CEcdu75vmmQ6jK6kvWq1bD0VUacua6LSeaEGSWr7DiyF/olEg0b0XhrgBn1b4EccaJvF cZrpL8mdYrh0EdK2vQx8d6a5rY+aXpKrRNVxfob+dNyTguafmqDOvMUzI2fKH9lsf488 ZU2A== X-Gm-Message-State: AMCzsaVoCrll1UWoFw/8WC5BrKKr8+9CKfOC9Qb5SxXpCAUUKqqNcyqH vRjHR2IohBaBvzN8A7Dr+XC88uas2Co= X-Google-Smtp-Source: ABhQp+Tvhxx8xHpKeT457XA+D0OqGtNXxBTZHsdhzzDO75rNODizz0NL/vn6X73xogUj4Afj4u6NiQ== X-Received: by 10.237.63.15 with SMTP id p15mr26594999qtf.155.1508873742097; Tue, 24 Oct 2017 12:35:42 -0700 (PDT) From: Dawid Zamirski To: libvir-list@redhat.com Date: Tue, 24 Oct 2017 15:35:29 -0400 Message-Id: <20171024193538.9078-7-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.26]); Tue, 24 Oct 2017 19:35:43 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.26]); Tue, 24 Oct 2017 19:35:43 +0000 (UTC) for IP:'209.85.216.178' DOMAIN:'mail-qt0-f178.google.com' HELO:'mail-qt0-f178.google.com' FROM:'dzamirski@datto.com' RCPT:'' X-RedHat-Spam-Score: -0.221 (DKIM_SIGNED, DKIM_VALID, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, RCVD_IN_SORBS_SPAM, SPF_PASS) 209.85.216.178 mail-qt0-f178.google.com 209.85.216.178 mail-qt0-f178.google.com X-Scanned-By: MIMEDefang 2.78 on 10.5.110.26 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH v2 06/15] vbox: Errors in vboxAttachDrives are now critical 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.39]); Tue, 24 Oct 2017 19:36:17 +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" Previously, if one tried to define a VBOX VM and the API failed to perform the requested actions for some reason, it would just log the error and move on to process remaining disk definitions. This is not desired as it could result in incorrectly defined VM without the caller even knowing about it. So now all the code paths that call virReportError are now treated as hard failures as they should have been. Reviewed-by: John Ferlan --- src/vbox/vbox_common.c | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/src/vbox/vbox_common.c b/src/vbox/vbox_common.c index b949c4db7..9f4bf18a3 100644 --- a/src/vbox/vbox_common.c +++ b/src/vbox/vbox_common.c @@ -955,17 +955,17 @@ vboxSetBootDeviceOrder(virDomainDefPtr def, vboxDrive= rPtr data, } } =20 -static void +static int vboxAttachDrives(virDomainDefPtr def, vboxDriverPtr data, IMachine *machin= e) { size_t i; - int type, format; + int type, format, ret =3D 0; const char *src =3D NULL; nsresult rc =3D 0; virDomainDiskDefPtr disk =3D NULL; PRUnichar *storageCtlName =3D NULL; IMedium *medium =3D NULL; - PRUnichar *mediumFileUtf16 =3D NULL, *mediumEmpty =3D NULL; + PRUnichar *mediumFileUtf16 =3D NULL; PRUint32 devicePort, deviceSlot, deviceType, accessMode; vboxIID mediumUUID; =20 @@ -1049,6 +1049,7 @@ vboxAttachDrives(virDomainDefPtr def, vboxDriverPtr d= ata, IMachine *machine) deviceType =3D DeviceType_Floppy; accessMode =3D AccessMode_ReadWrite; } else { + ret =3D -1; goto cleanup; } =20 @@ -1056,19 +1057,17 @@ vboxAttachDrives(virDomainDefPtr def, vboxDriverPtr= data, IMachine *machine) deviceType, accessMode, &me= dium); =20 if (!medium) { - VBOX_UTF8_TO_UTF16("", &mediumEmpty); - rc =3D gVBoxAPI.UIVirtualBox.OpenMedium(data->vboxObj, mediumFileUtf16, deviceType, accessMo= de, &medium); - VBOX_UTF16_FREE(mediumEmpty); } =20 if (!medium) { virReportError(VIR_ERR_INTERNAL_ERROR, _("Failed to attach the following disk/dvd/= floppy " "to the machine: %s, rc=3D%08x"), src, rc= ); + ret =3D -1; goto cleanup; } =20 @@ -1078,6 +1077,7 @@ vboxAttachDrives(virDomainDefPtr def, vboxDriverPtr d= ata, IMachine *machine) _("Can't get the UUID of the file to be att= ached " "as harddisk/dvd/floppy: %s, rc=3D%08x"), src, rc); + ret =3D -1; goto cleanup; } =20 @@ -1117,6 +1117,8 @@ vboxAttachDrives(virDomainDefPtr def, vboxDriverPtr d= ata, IMachine *machine) virReportError(VIR_ERR_INTERNAL_ERROR, _("Could not attach the file as " "harddisk/dvd/floppy: %s, rc=3D%08x"), sr= c, rc); + ret =3D -1; + goto cleanup; } else { DEBUGIID("Attached HDD/DVD/Floppy with UUID", &mediumUUID); } @@ -1125,8 +1127,13 @@ vboxAttachDrives(virDomainDefPtr def, vboxDriverPtr = data, IMachine *machine) vboxIIDUnalloc(&mediumUUID); VBOX_UTF16_FREE(mediumFileUtf16); VBOX_UTF16_FREE(storageCtlName); + + if (ret < 0) + break; } } + + return ret; } =20 static void @@ -1857,7 +1864,8 @@ vboxDomainDefineXMLFlags(virConnectPtr conn, const ch= ar *xml, unsigned int flags gVBoxAPI.UISession.GetMachine(data->vboxSession, &machine); =20 vboxSetBootDeviceOrder(def, data, machine); - vboxAttachDrives(def, data, machine); + if (vboxAttachDrives(def, data, machine) < 0) + goto cleanup; vboxAttachSound(def, machine); if (vboxAttachNetwork(def, data, machine) < 0) goto cleanup; --=20 2.14.2 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list