Revision 26b9b5fe hw/virtio-pci.c

b/hw/virtio-pci.c
160 160
}
161 161

  
162 162
static int virtio_pci_set_host_notifier_internal(VirtIOPCIProxy *proxy,
163
                                                 int n, bool assign)
163
                                                 int n, bool assign, bool set_handler)
164 164
{
165 165
    VirtQueue *vq = virtio_get_queue(proxy->vdev, n);
166 166
    EventNotifier *notifier = virtio_queue_get_host_notifier(vq);
......
173 173
                         __func__, r);
174 174
            return r;
175 175
        }
176
        virtio_queue_set_host_notifier_fd_handler(vq, true);
176
        virtio_queue_set_host_notifier_fd_handler(vq, true, set_handler);
177 177
        memory_region_add_eventfd(&proxy->bar, VIRTIO_PCI_QUEUE_NOTIFY, 2,
178 178
                                  true, n, notifier);
179 179
    } else {
180 180
        memory_region_del_eventfd(&proxy->bar, VIRTIO_PCI_QUEUE_NOTIFY, 2,
181 181
                                  true, n, notifier);
182
        virtio_queue_set_host_notifier_fd_handler(vq, false);
182
        virtio_queue_set_host_notifier_fd_handler(vq, false, false);
183 183
        event_notifier_cleanup(notifier);
184 184
    }
185 185
    return r;
......
200 200
            continue;
201 201
        }
202 202

  
203
        r = virtio_pci_set_host_notifier_internal(proxy, n, true);
203
        r = virtio_pci_set_host_notifier_internal(proxy, n, true, true);
204 204
        if (r < 0) {
205 205
            goto assign_error;
206 206
        }
......
214 214
            continue;
215 215
        }
216 216

  
217
        r = virtio_pci_set_host_notifier_internal(proxy, n, false);
217
        r = virtio_pci_set_host_notifier_internal(proxy, n, false, false);
218 218
        assert(r >= 0);
219 219
    }
220 220
    proxy->ioeventfd_started = false;
......
235 235
            continue;
236 236
        }
237 237

  
238
        r = virtio_pci_set_host_notifier_internal(proxy, n, false);
238
        r = virtio_pci_set_host_notifier_internal(proxy, n, false, false);
239 239
        assert(r >= 0);
240 240
    }
241 241
    proxy->ioeventfd_started = false;
......
683 683
     * currently only stops on status change away from ok,
684 684
     * reset, vmstop and such. If we do add code to start here,
685 685
     * need to check vmstate, device state etc. */
686
    return virtio_pci_set_host_notifier_internal(proxy, n, assign);
686
    return virtio_pci_set_host_notifier_internal(proxy, n, assign, false);
687 687
}
688 688

  
689 689
static void virtio_pci_vmstate_change(void *opaque, bool running)

Also available in: Unified diff