Skip to content

Commit

Permalink
KVM: Save/restore state of assigned PCI device
Browse files Browse the repository at this point in the history
The guest may change states that pci_reset_function does not touch. So
we better save/restore the assigned device across guest usage.

Acked-by: Alex Williamson <[email protected]>
Acked-by: Michael S. Tsirkin <[email protected]>
Signed-off-by: Jan Kiszka <[email protected]>
Signed-off-by: Marcelo Tosatti <[email protected]>
  • Loading branch information
jan-kiszka authored and avikivity committed Jan 12, 2011
1 parent 1e001d4 commit ed78661
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion virt/kvm/assigned-dev.c
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,8 @@ static void kvm_free_assigned_device(struct kvm *kvm,
{
kvm_free_assigned_irq(kvm, assigned_dev);

pci_reset_function(assigned_dev->dev);
__pci_reset_function(assigned_dev->dev);
pci_restore_state(assigned_dev->dev);

pci_release_regions(assigned_dev->dev);
pci_disable_device(assigned_dev->dev);
Expand Down Expand Up @@ -514,6 +515,7 @@ static int kvm_vm_ioctl_assign_device(struct kvm *kvm,
}

pci_reset_function(dev);
pci_save_state(dev);

match->assigned_dev_id = assigned_dev->assigned_dev_id;
match->host_segnr = assigned_dev->segnr;
Expand Down Expand Up @@ -544,6 +546,7 @@ static int kvm_vm_ioctl_assign_device(struct kvm *kvm,
mutex_unlock(&kvm->lock);
return r;
out_list_del:
pci_restore_state(dev);
list_del(&match->list);
pci_release_regions(dev);
out_disable:
Expand Down

0 comments on commit ed78661

Please sign in to comment.