aboutsummaryrefslogtreecommitdiff
path: root/hw/msix.c
diff options
context:
space:
mode:
authorMichael S. Tsirkin <mst@redhat.com>2009-07-05 15:58:23 +0300
committerAvi Kivity <avi@redhat.com>2009-07-09 13:01:14 +0300
commite7c3c8afcfd8bc4fb03a49653c3494f204c520de (patch)
tree6c5b556a0f78b10ac91ba34dd2c80d76781f4fd1 /hw/msix.c
parentMove extboot to other optionroms (diff)
downloadqemu-kvm-e7c3c8afcfd8bc4fb03a49653c3494f204c520de.tar.gz
qemu-kvm-e7c3c8afcfd8bc4fb03a49653c3494f204c520de.tar.bz2
qemu-kvm-e7c3c8afcfd8bc4fb03a49653c3494f204c520de.zip
Fix segfault in msix_save
This fixes segfault reported by Kevin Wolf, and simplifies the code in msix_save. Reported-by: Kevin Wolf <kwolf@redhat.com> Signed-off-by: Michael S. Tsirkin <mst@redhat.com> Signed-off-by: Avi Kivity <avi@redhat.com>
Diffstat (limited to 'hw/msix.c')
-rw-r--r--hw/msix.c11
1 files changed, 6 insertions, 5 deletions
diff --git a/hw/msix.c b/hw/msix.c
index 8636f697a..0d400793e 100644
--- a/hw/msix.c
+++ b/hw/msix.c
@@ -404,15 +404,16 @@ int msix_uninit(PCIDevice *dev)
void msix_save(PCIDevice *dev, QEMUFile *f)
{
- unsigned nentries = (pci_get_word(dev->config + PCI_MSIX_FLAGS) &
- PCI_MSIX_FLAGS_QSIZE) + 1;
+ unsigned n = dev->msix_entries_nr;
if (!msix_supported)
return;
- qemu_put_buffer(f, dev->msix_table_page, nentries * MSIX_ENTRY_SIZE);
- qemu_put_buffer(f, dev->msix_table_page + MSIX_PAGE_PENDING,
- (nentries + 7) / 8);
+ if (!(dev->cap_present & QEMU_PCI_CAP_MSIX)) {
+ return;
+ }
+ qemu_put_buffer(f, dev->msix_table_page, n * MSIX_ENTRY_SIZE);
+ qemu_put_buffer(f, dev->msix_table_page + MSIX_PAGE_PENDING, (n + 7) / 8);
}
/* Should be called after restoring the config space. */