From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1LpnQg-0002gE-LH for qemu-devel@nongnu.org; Fri, 03 Apr 2009 13:43:46 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1LpnQb-0002fe-6W for qemu-devel@nongnu.org; Fri, 03 Apr 2009 13:43:45 -0400 Received: from [199.232.76.173] (port=46226 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1LpnQb-0002fb-49 for qemu-devel@nongnu.org; Fri, 03 Apr 2009 13:43:41 -0400 Received: from mx2.redhat.com ([66.187.237.31]:39395) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1LpnQa-0008Ch-FS for qemu-devel@nongnu.org; Fri, 03 Apr 2009 13:43:40 -0400 From: Eduardo Habkost Date: Fri, 3 Apr 2009 14:43:22 -0300 Message-Id: <1238780602-7087-1-git-send-email-ehabkost@redhat.com> Subject: [Qemu-devel] [PATCH] pci_add storage: fix error handling for 'if' parameter Reply-To: qemu-devel@nongnu.org List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Anthony Liguori Cc: qemu-devel@nongnu.org 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 --- hw/pci-hotplug.c | 12 +++++++----- 1 files changed, 7 insertions(+), 5 deletions(-) diff --git a/hw/pci-hotplug.c b/hw/pci-hotplug.c index a01efe0..d968a14 100644 --- a/hw/pci-hotplug.c +++ b/hw/pci-hotplug.c @@ -97,19 +97,22 @@ static PCIDevice *qemu_pci_hot_add_storage(Monitor *mon, PCIBus *pci_bus, 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 @@ static PCIDevice *qemu_pci_hot_add_storage(Monitor *mon, PCIBus *pci_bus, 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; } -- 1.6.1