From: Alex Williamson <alex.williamson@redhat.com>
To: Markus Armbruster <armbru@redhat.com>
Cc: Chris Wright <chrisw@redhat.com>, kvm@vger.kernel.org
Subject: Re: [PATCH qemu-kvm] device-assignment: add config fd qdev property
Date: Tue, 25 May 2010 15:14:18 -0600 [thread overview]
Message-ID: <1274822058.2654.72.camel@x201> (raw)
In-Reply-To: <m3y6f84h2u.fsf@blackfin.pond.sub.org>
On Tue, 2010-05-25 at 08:43 +0200, Markus Armbruster wrote:
> Alex Williamson <alex.williamson@redhat.com> writes:
>
> > On Wed, 2010-05-19 at 12:00 -0700, Chris Wright wrote:
> >> When libvirt launches a guest it first chowns the relevenat
> >> /sys/bus/pci/.../config file for an assigned device then drops privileges.
> >>
> >> This causes an issue for device assignment because despite being file
> >> owner, the sysfs config space file checks for CAP_SYS_ADMIN before
> >> allowing access to device dependent config space.
> >>
> >> This adds a new qdev configfd property which allows libvirt to open the
> >> sysfs config space file and give qemu an already opened file descriptor.
> >> Along with a change pending for the 2.6.35 kernel, this allows the
> >> capability check to compare against privileges from when the file was
> >> opened.
> >
> > We need to make configfd be a string option so that we can pass a
> > descriptor from libvirt for the hotplug case. Here's a rework.
> >
> > Signed-off-by: Chris Wright <chrisw@redhat.com>
> > Signed-off-by: Alex Williamson <alex.williamson@redhat.com>
> > ---
> >
> > diff --git a/hw/device-assignment.c b/hw/device-assignment.c
> > index eb31c78..3c5184f 100644
> > --- a/hw/device-assignment.c
> > +++ b/hw/device-assignment.c
> > @@ -37,6 +37,7 @@
> > #include "console.h"
> > #include "device-assignment.h"
> > #include "loader.h"
> > +#include "monitor.h"
> > #include <pci/pci.h>
> >
> > /* From linux/ioport.h */
> > @@ -612,14 +613,28 @@ static int get_real_device(AssignedDevice *pci_dev, uint16_t r_seg,
> >
> > snprintf(name, sizeof(name), "%sconfig", dir);
> >
> > - fd = open(name, O_RDWR);
> > - if (fd == -1) {
> > - fprintf(stderr, "%s: %s: %m\n", __func__, name);
> > - return 1;
> > + if (pci_dev->configfd_name && *pci_dev->configfd_name) {
> > + if (qemu_isdigit(pci_dev->configfd_name[0])) {
> > + dev->config_fd = strtol(pci_dev->configfd_name, NULL, 0);
> > + } else {
> > + dev->config_fd = monitor_get_fd(cur_mon, pci_dev->configfd_name);
> > + if (dev->config_fd < 0) {
> > + fprintf(stderr, "%s: (%s) unkown\n", __func__,
> > + pci_dev->configfd_name);
> > + return 1;
> > + }
> > + }
>
> Similar to net_handle_fd_param(). What about factoring into a common
> helper?
Yep, maybe we should move that into monitor.c. Thanks,
Alex
next prev parent reply other threads:[~2010-05-25 21:14 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-05-19 19:00 [PATCH qemu-kvm] device-assignment: add config fd qdev property Chris Wright
2010-05-19 19:08 ` Alex Williamson
2010-05-19 19:18 ` Anthony Liguori
2010-05-19 21:10 ` Chris Wright
2010-05-19 21:50 ` Anthony Liguori
2010-05-19 21:59 ` Chris Wright
2010-05-19 22:27 ` Anthony Liguori
2010-05-20 10:06 ` Daniel P. Berrange
2010-05-20 12:11 ` Markus Armbruster
2010-05-24 16:53 ` Alex Williamson
2010-05-24 18:20 ` Chris Wright
2010-05-25 6:43 ` Markus Armbruster
2010-05-25 21:14 ` Alex Williamson [this message]
2010-05-31 20:22 ` 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=1274822058.2654.72.camel@x201 \
--to=alex.williamson@redhat.com \
--cc=armbru@redhat.com \
--cc=chrisw@redhat.com \
--cc=kvm@vger.kernel.org \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.