mirror of https://gitee.com/openkylin/qemu.git
i386/kvm/pci-assign: Fix return type of verify_irqchip_kernel()
When the function no success value to transmit, it usually make the function return void. It has turned out not to be a success, because it means that the extra local_err variable and error_propagate() will be needed. It leads to cumbersome code, therefore, transmit success/ failure in the return value is worth. So fix the return type to avoid it. Cc: pbonzini@redhat.com Cc: rth@twiddle.net Cc: ehabkost@redhat.com Cc: mst@redhat.com Cc: armbru@redhat.com Cc: marcel@redhat.com Signed-off-by: Mao Zhongyi <maozy.fnst@cn.fujitsu.com> Reviewed-by: Marcel Apfelbaum <marcel@redhat.com> Reviewed-by: Michael S. Tsirkin <mst@redhat.com> Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
This commit is contained in:
parent
344475e77d
commit
6b728b3116
|
@ -824,12 +824,13 @@ static void assign_device(AssignedDevice *dev, Error **errp)
|
|||
}
|
||||
}
|
||||
|
||||
static void verify_irqchip_in_kernel(Error **errp)
|
||||
static int verify_irqchip_in_kernel(Error **errp)
|
||||
{
|
||||
if (kvm_irqchip_in_kernel()) {
|
||||
return;
|
||||
return -1;
|
||||
}
|
||||
error_setg(errp, "pci-assign requires KVM with in-kernel irqchip enabled");
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int assign_intx(AssignedDevice *dev, Error **errp)
|
||||
|
@ -838,7 +839,6 @@ static int assign_intx(AssignedDevice *dev, Error **errp)
|
|||
PCIINTxRoute intx_route;
|
||||
bool intx_host_msi;
|
||||
int r;
|
||||
Error *local_err = NULL;
|
||||
|
||||
/* Interrupt PIN 0 means don't use INTx */
|
||||
if (assigned_dev_pci_read_byte(&dev->dev, PCI_INTERRUPT_PIN) == 0) {
|
||||
|
@ -846,9 +846,7 @@ static int assign_intx(AssignedDevice *dev, Error **errp)
|
|||
return 0;
|
||||
}
|
||||
|
||||
verify_irqchip_in_kernel(&local_err);
|
||||
if (local_err) {
|
||||
error_propagate(errp, local_err);
|
||||
if (verify_irqchip_in_kernel(errp) < 0) {
|
||||
return -ENOTSUP;
|
||||
}
|
||||
|
||||
|
@ -1246,9 +1244,7 @@ static int assigned_device_pci_cap_init(PCIDevice *pci_dev, Error **errp)
|
|||
* MSI capability is the 1st capability in capability config */
|
||||
pos = pci_find_cap_offset(pci_dev, PCI_CAP_ID_MSI, 0);
|
||||
if (pos != 0 && kvm_check_extension(kvm_state, KVM_CAP_ASSIGN_DEV_IRQ)) {
|
||||
verify_irqchip_in_kernel(&local_err);
|
||||
if (local_err) {
|
||||
error_propagate(errp, local_err);
|
||||
if (verify_irqchip_in_kernel(errp) < 0) {
|
||||
return -ENOTSUP;
|
||||
}
|
||||
dev->dev.cap_present |= QEMU_PCI_CAP_MSI;
|
||||
|
@ -1281,9 +1277,7 @@ static int assigned_device_pci_cap_init(PCIDevice *pci_dev, Error **errp)
|
|||
uint32_t msix_table_entry;
|
||||
uint16_t msix_max;
|
||||
|
||||
verify_irqchip_in_kernel(&local_err);
|
||||
if (local_err) {
|
||||
error_propagate(errp, local_err);
|
||||
if (verify_irqchip_in_kernel(errp) < 0) {
|
||||
return -ENOTSUP;
|
||||
}
|
||||
dev->dev.cap_present |= QEMU_PCI_CAP_MSIX;
|
||||
|
|
Loading…
Reference in New Issue