Re: [PATCH 1/2] PCI: Add interfaces to store and load the device saved state

Alex Williamson
2011-04-18T19:44:11Z

On Sun, 2011-04-17 at 12:23 +0300, Avi Kivity wrote:
> On 04/15/2011 10:54 PM, Alex Williamson wrote:
> > For KVM device assignment, we'd like to save off the state of a device
> > prior to passing it to the guest and restore it later. We also want
> > to allow pci_reset_funciton() to be called while the device is owned
> > by the guest. This however overwrites and invalidates the struct pci_dev
> > buffers, so we can't just manually call save and restore. Add generic
> > interfaces for the saved state to be stored into a buffer and reloaded
> > back into struct pci_dev at a later time.
> >
> > +/**
> > + * pci_store_saved_state - Store the device saved state into a buffer
> > + * @dev: - PCI device that we're dealing with
> > + *
> > + * Returns an opaque buffer containing the device saved state.
> > + * NULL if no state or error.
> > + */
> > +void *pci_store_saved_state(struct pci_dev *dev)
>
> This is too opaque - no type safety. You can return a struct pci_state
> *, leaving it undefined in headers files.

Good idea, I'll roll this in. Thanks,

Alex