• Jason Andryuk's avatar
    libxl: retry QMP PCI device_add · 0f4fd6b6
    Jason Andryuk authored
    
    
    PCI device assignment to an HVM with stubdom is potentially racy.  First
    the PCI device is assigned to the stubdom via the PV PCI protocol.  Then
    QEMU is sent a QMP command to attach the PCI device to QEMU running
    within the stubdom.  However, the sysfs entries within the stubdom may
    not have appeared by the time QEMU receives the device_add command
    resulting in errors like:
    
    libxl_qmp.c:1838:qmp_ev_parse_error_messages:Domain 10:Could not open '/sys/bus/pci/devices/0000:00:1f.3/config': No such file or directory
    
    This patch retries the device assignment up to 10 times with a 1 second
    delay between.  That roughly matches the overall hotplug timeout for
    pci_add_timeout.  pci_add_timeout's initialization is moved to
    do_pci_add since retries call into pci_add_qmp_device_add again.
    
    The qmp_ev_parse_error_messages error is still printed since it happens
    at a lower level than the pci code controlling the retries.  With that,
    the "Retrying PCI add %d" message is also printed at ERROR level to
    clarify what is happening.
    Signed-off-by: default avatarJason Andryuk <jandryuk@gmail.com>
    Reviewed-by: default avatarAnthony PERARD <anthony.perard@citrix.com>
    0f4fd6b6
libxl_pci.c 80.7 KB