Commit 8707eccac83bda82d802c0cfa04fc0ff6bcdce27
1 parent
016c62c8
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 <ehabkost@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com> git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@6981 c046a42c-6fe2-441c-8c8c-71466251a162
Showing
1 changed file
with
7 additions
and
5 deletions
hw/pci-hotplug.c
... | ... | @@ -97,19 +97,22 @@ static PCIDevice *qemu_pci_hot_add_storage(Monitor *mon, PCIBus *pci_bus, |
97 | 97 | type = IF_SCSI; |
98 | 98 | else if (!strcmp(buf, "virtio")) { |
99 | 99 | type = IF_VIRTIO; |
100 | + } else { | |
101 | + monitor_printf(mon, "type %s not a hotpluggable PCI device.\n", buf); | |
102 | + goto out; | |
100 | 103 | } |
101 | 104 | } else { |
102 | 105 | monitor_printf(mon, "no if= specified\n"); |
103 | - return NULL; | |
106 | + goto out; | |
104 | 107 | } |
105 | 108 | |
106 | 109 | if (get_param_value(buf, sizeof(buf), "file", opts)) { |
107 | 110 | drive_idx = add_init_drive(opts); |
108 | 111 | if (drive_idx < 0) |
109 | - return NULL; | |
112 | + goto out; | |
110 | 113 | } else if (type == IF_VIRTIO) { |
111 | 114 | monitor_printf(mon, "virtio requires a backing file/device.\n"); |
112 | - return NULL; | |
115 | + goto out; | |
113 | 116 | } |
114 | 117 | |
115 | 118 | switch (type) { |
... | ... | @@ -122,10 +125,9 @@ static PCIDevice *qemu_pci_hot_add_storage(Monitor *mon, PCIBus *pci_bus, |
122 | 125 | case IF_VIRTIO: |
123 | 126 | opaque = virtio_blk_init (pci_bus, drives_table[drive_idx].bdrv); |
124 | 127 | break; |
125 | - default: | |
126 | - monitor_printf(mon, "type %s not a hotpluggable PCI device.\n", buf); | |
127 | 128 | } |
128 | 129 | |
130 | +out: | |
129 | 131 | return opaque; |
130 | 132 | } |
131 | 133 | ... | ... |