Re: [PATCH] device-assignment: Reset device on system reset

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

 



On Thu, 2011-03-17 at 14:12 -0700, Chris Wright wrote:
> * Alex Williamson (alex.williamson@xxxxxxxxxx) wrote:
> >  static void reset_assigned_device(DeviceState *dev)
> >  {
> > -    PCIDevice *d = DO_UPCAST(PCIDevice, qdev, dev);
> > +    PCIDevice *pci_dev = DO_UPCAST(PCIDevice, qdev, dev);
> > +    AssignedDevice *adev = DO_UPCAST(AssignedDevice, dev, pci_dev);
> > +    char reset_file[64];
> > +    const char reset[] = "1";
> > +    int fd, ret;
> > +
> > +    snprintf(reset_file, sizeof(reset_file),
> > +             "/sys/bus/pci/devices/0000:%02x:%02x.%01x/reset",
> > +             adev->host.bus, adev->host.dev, adev->host.func);
> 
> need to consider segment: %04x:..., adev->host.seg, ...

Shoot, I ported this over from a code base w/o seg support.  Thanks for
the catch.

> > +    /*
> > +     * Issue a device reset via pci-sysfs.  Note that we use write(2) here
> > +     * and ignore the return value because some kernels have a bug that
> > +     * returns 0 rather than bytes written on success, sending us into an
> > +     * infinite retry loop using other write mechanisms.
> > +     */
> > +    fd = open(reset_file, O_WRONLY);
> > +    if (fd != -1) {
> > +        ret = write(fd, reset, strlen(reset));
> > +        close(fd);
> > +    }
> 
> This will probably fail when it's managed by libvirt.  I expect it
> will need some file ownership and security label mgmt added to device
> assignement path I expect.

Already posted a patch for adding file rights, seems to be sufficient:

https://www.redhat.com/archives/libvir-list/2011-March/msg00823.html

Thanks,

Alex

--
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