From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:59171) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1c1tyH-0006JL-Ak for qemu-devel@nongnu.org; Wed, 02 Nov 2016 07:44:46 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1c1tyE-0000xf-2y for qemu-devel@nongnu.org; Wed, 02 Nov 2016 07:44:45 -0400 Date: Wed, 2 Nov 2016 12:45:17 +0100 From: Henning Schild Message-ID: <20161102124517.2673fb35@md1em3qc> In-Reply-To: <20161102095416.GA2573@redhat.com> References: <20161028132819.6d6ee449@md1em3qc> <20161102095416.GA2573@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] pci-assign fails with read error on config-space file List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: "Daniel P. Berrange" Cc: libvir-list@redhat.com, libvirt-users@redhat.com, qemu-devel@nongnu.org, qemu-discuss@nongnu.org Am Wed, 2 Nov 2016 09:54:16 +0000 schrieb "Daniel P. Berrange" : > On Fri, Oct 28, 2016 at 01:28:19PM +0200, Henning Schild wrote: > > Hey, > > > > i am running an unusual setup where i assign pci devices behind the > > back of libvirt. I have two options to do that: > > 1. a wrapper script for qemu that takes care of suid-root and > > appends arguments for pci-assign > > 2. virsh qemu-monitor-command ... 'device_add pci-assign...' > > > > I know i should probably not be doing this, it is a workaround to > > introduce fine-grained pci-assignment in an openstack setup, where > > vendor and device id are not enough to pick the right device for a > > vm. > > > > In both cases qemu will crash with the following output: > > > > > qemu: hardware error: pci read failed, ret = 0 errno = 22 > > > > followed by the usual machine state dump. With strace i found it to > > be a failing read on the config space file of my device. > > /sys/bus/pci/devices/0000:xx:xx.x/config > > A few reads out of that file succeeded, as well as accesses on > > vendor etc. > > errno == 22, means EINVAL, so it feels unlikely to be a permissions > problem unless the kernel or QEMU is reporting the wrong errno. > > > Manually launching a qemu with the pci-assign works without a > > problem, so i "blame" libvirt and the cgroup environment the qemu > > ends up in. > > The 'config' file is a plain file, so not affected by cgroups - that > only affects block devices. > > When libvirt runs QEMU, it runs unprivileged qemu:qemu user/group, > so perhaps it is a permissions thing, despite the fact that you're > getting EINVAL, not EACCESS. If the wrapper qemu decides to assign a PCI device it will use a suid-root qemu to do so. So it is no EACCESS, as i said other reads worked fine. > It would be interesting to know just what part of the config space > QEMU was trying to read I guess, to better understand why it might > be failing I should have said that before, it is a one byte read on offest 64. So just behind the regular cfg-space. regards, Henning