Re: [PATCH v2] device-assignment: register a reset function

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tue, 2010-11-16 at 15:05 +0100, Bernhard Kohl wrote:
> This is necessary because during reboot of a VM the assigned devices
> continue DMA transfers which causes memory corruption.
> 
> Signed-off-by: Thomas Ostler <thomas.ostler@xxxxxxx>
> Signed-off-by: Bernhard Kohl <bernhard.kohl@xxxxxxx>
> ---
> Changes v1 -> v2:
> - use defined macros, e.g. PCI_COMMAND
> - write all zero to the command register to disconnect the device logically
> ---
>  hw/device-assignment.c |   12 ++++++++++++
>  1 files changed, 12 insertions(+), 0 deletions(-)

Looks good to me.

Acked-by: Alex Williamson <alex.williamson@xxxxxxxxxx>

> diff --git a/hw/device-assignment.c b/hw/device-assignment.c
> index 5f5bde1..8d5a609 100644
> --- a/hw/device-assignment.c
> +++ b/hw/device-assignment.c
> @@ -1434,6 +1434,17 @@ static void assigned_dev_unregister_msix_mmio(AssignedDevice *dev)
>      dev->msix_table_page = NULL;
>  }
>  
> +static void reset_assigned_device(DeviceState *dev)
> +{
> +    PCIDevice *d = DO_UPCAST(PCIDevice, qdev, dev);
> +
> +    /*
> +     * When a 0 is written to the command register, the device is logically
> +     * disconnected from the PCI bus. This avoids further DMA transfers.
> +     */
> +    assigned_dev_pci_write_config(d, PCI_COMMAND, 0, 2);
> +}
> +
>  static int assigned_initfn(struct PCIDevice *pci_dev)
>  {
>      AssignedDevice *dev = DO_UPCAST(AssignedDevice, dev, pci_dev);
> @@ -1544,6 +1555,7 @@ static PCIDeviceInfo assign_info = {
>      .qdev.name    = "pci-assign",
>      .qdev.desc    = "pass through host pci devices to the guest",
>      .qdev.size    = sizeof(AssignedDevice),
> +    .qdev.reset   = reset_assigned_device,
>      .init         = assigned_initfn,
>      .exit         = assigned_exitfn,
>      .config_read  = assigned_dev_pci_read_config,



--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [KVM ARM]     [KVM ia64]     [KVM ppc]     [Virtualization Tools]     [Spice Development]     [Libvirt]     [Libvirt Users]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite Questions]     [Linux Kernel]     [Linux SCSI]     [XFree86]
  Powered by Linux