public inbox for kvm@vger.kernel.org
 help / color / mirror / Atom feed
From: Alex Williamson <alex.williamson@redhat.com>
To: Chris Wright <chrisw@redhat.com>
Cc: kvm@vger.kernel.org, ddutile@redhat.com, bernhard.kohl@nsn.com,
	libvir-list@redhat.com
Subject: Re: [PATCH] device-assignment: Reset device on system reset
Date: Thu, 17 Mar 2011 15:17:50 -0600	[thread overview]
Message-ID: <1300396670.3155.9.camel@x201> (raw)
In-Reply-To: <20110317211210.GL15007@x200.localdomain>

On Thu, 2011-03-17 at 14:12 -0700, Chris Wright wrote:
> * Alex Williamson (alex.williamson@redhat.com) 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


  reply	other threads:[~2011-03-17 21:17 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-03-17 19:29 [PATCH] device-assignment: Reset device on system reset Alex Williamson
2011-03-17 21:12 ` Chris Wright
2011-03-17 21:17   ` Alex Williamson [this message]
2011-03-17 21:59     ` Chris Wright
2011-03-17 21:24 ` [PATCH v2] " Alex Williamson
2011-03-17 21:55   ` Chris Wright
2011-04-01 21:57     ` Marcelo Tosatti
2011-04-03  0:20   ` Marcelo Tosatti

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1300396670.3155.9.camel@x201 \
    --to=alex.williamson@redhat.com \
    --cc=bernhard.kohl@nsn.com \
    --cc=chrisw@redhat.com \
    --cc=ddutile@redhat.com \
    --cc=kvm@vger.kernel.org \
    --cc=libvir-list@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox