Will have more users soon. Signed-off-by: Jan Kiszka <jan.kiszka@xxxxxxxxxxx> --- hw/device-assignment.c | 30 ++++++++++++++++++------------ 1 files changed, 18 insertions(+), 12 deletions(-) diff --git a/hw/device-assignment.c b/hw/device-assignment.c index e0b9cfe..e5ac54c 100644 --- a/hw/device-assignment.c +++ b/hw/device-assignment.c @@ -807,10 +807,25 @@ static int assign_device(AssignedDevice *dev) return r; } +static void deassign_irq(AssignedDevice *dev) +{ + int ret; + + if (dev->irq_requested_type) { + ret = kvm_device_irq_deassign(kvm_state, + calc_assigned_dev_id(dev), + dev->irq_requested_type); + if (ret) { + perror("assigned_dev: deassign irq"); + } + dev->girq = -1; + dev->irq_requested_type = 0; + } +} + static int assign_intx(AssignedDevice *dev) { struct kvm_assigned_irq assigned_irq_data; - uint32_t dev_id; int irq, r; /* Interrupt PIN 0 means don't use INTx */ @@ -824,19 +839,10 @@ static int assign_intx(AssignedDevice *dev) return 0; } - dev_id = calc_assigned_dev_id(dev); - - if (dev->irq_requested_type) { - r = kvm_device_irq_deassign(kvm_state, dev_id, - dev->irq_requested_type); - if (r) { - perror("assign_intx: deassign"); - } - dev->irq_requested_type = 0; - } + deassign_irq(dev); memset(&assigned_irq_data, 0, sizeof(assigned_irq_data)); - assigned_irq_data.assigned_dev_id = dev_id; + assigned_irq_data.assigned_dev_id = calc_assigned_dev_id(dev); assigned_irq_data.guest_irq = irq; assigned_irq_data.flags = KVM_DEV_IRQ_GUEST_INTX; if (dev->features & ASSIGNED_DEVICE_PREFER_MSI_MASK && -- 1.7.3.4 -- To unsubscribe from this list: send the line "unsubscribe kvm" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html