From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1LqWL3-0002g5-Ni for qemu-devel@nongnu.org; Sun, 05 Apr 2009 13:40:57 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1LqWL2-0002fE-PM for qemu-devel@nongnu.org; Sun, 05 Apr 2009 13:40:57 -0400 Received: from [199.232.76.173] (port=34525 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1LqWL2-0002f6-IU for qemu-devel@nongnu.org; Sun, 05 Apr 2009 13:40:56 -0400 Received: from savannah.gnu.org ([199.232.41.3]:40637 helo=sv.gnu.org) by monty-python.gnu.org with esmtps (TLS-1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1LqWL2-00048R-5q for qemu-devel@nongnu.org; Sun, 05 Apr 2009 13:40:56 -0400 Received: from cvs.savannah.gnu.org ([199.232.41.69]) by sv.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1LqWL1-0006Av-Ll for qemu-devel@nongnu.org; Sun, 05 Apr 2009 17:40:55 +0000 Received: from aliguori by cvs.savannah.gnu.org with local (Exim 4.69) (envelope-from ) id 1LqWL1-0006Ar-Cj for qemu-devel@nongnu.org; Sun, 05 Apr 2009 17:40:55 +0000 MIME-Version: 1.0 Errors-To: aliguori Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit From: Anthony Liguori Message-Id: Date: Sun, 05 Apr 2009 17:40:55 +0000 Subject: [Qemu-devel] [6981] pci_add storage: fix error handling for 'if' parameter ( Eduardo Habkost) Reply-To: qemu-devel@nongnu.org List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Revision: 6981 http://svn.sv.gnu.org/viewvc/?view=rev&root=qemu&revision=6981 Author: aliguori Date: 2009-04-05 17:40:55 +0000 (Sun, 05 Apr 2009) Log Message: ----------- pci_add storage: fix error handling for 'if' parameter (Eduardo Habkost) This fixes: - The error message to show the actual if= argument value. It was showing the filename instead, because 'buf' is reaused on the filename parsing. - A bug that makes a block device to be created even when an unsupported if= arg is passed to pci_add. Signed-off-by: Eduardo Habkost Signed-off-by: Anthony Liguori Modified Paths: -------------- trunk/hw/pci-hotplug.c Modified: trunk/hw/pci-hotplug.c =================================================================== --- trunk/hw/pci-hotplug.c 2009-04-05 17:40:50 UTC (rev 6980) +++ trunk/hw/pci-hotplug.c 2009-04-05 17:40:55 UTC (rev 6981) @@ -97,19 +97,22 @@ type = IF_SCSI; else if (!strcmp(buf, "virtio")) { type = IF_VIRTIO; + } else { + monitor_printf(mon, "type %s not a hotpluggable PCI device.\n", buf); + goto out; } } else { monitor_printf(mon, "no if= specified\n"); - return NULL; + goto out; } if (get_param_value(buf, sizeof(buf), "file", opts)) { drive_idx = add_init_drive(opts); if (drive_idx < 0) - return NULL; + goto out; } else if (type == IF_VIRTIO) { monitor_printf(mon, "virtio requires a backing file/device.\n"); - return NULL; + goto out; } switch (type) { @@ -122,10 +125,9 @@ case IF_VIRTIO: opaque = virtio_blk_init (pci_bus, drives_table[drive_idx].bdrv); break; - default: - monitor_printf(mon, "type %s not a hotpluggable PCI device.\n", buf); } +out: return opaque; }