[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [Xen-devel] [PATCH V4 05/10] Introduce HostPCIDevice to
From: |
Anthony PERARD |
Subject: |
Re: [Qemu-devel] [Xen-devel] [PATCH V4 05/10] Introduce HostPCIDevice to access a pci device on the host. |
Date: |
Wed, 23 Nov 2011 18:25:07 +0000 |
On Fri, Nov 18, 2011 at 15:06, Konrad Rzeszutek Wilk
<address@hidden> wrote:
>> +static int host_pci_config_read(HostPCIDevice *d, int pos, void *buf, int
>> len)
>> +{
>> + int fd = host_pci_config_fd(d);
>> + int res = 0;
>> +
>> +again:
>> + res = pread(fd, buf, len, pos);
>> + if (res != len) {
>> + if (res < 0 && (errno == EINTR || errno == EAGAIN)) {
>> + goto again;
>> + }
>> + fprintf(stderr, "host_pci_config: read failed: %s (fd: %i)\n",
>> + strerror(errno), fd);
>> + return -errno;
>> + }
>> + return 0;
>> +}
>> +static int host_pci_config_write(HostPCIDevice *d,
>> + int pos, const void *buf, int len)
>> +{
>> + int fd = host_pci_config_fd(d);
>> + int res = 0;
>> +
>> +again:
>> + res = pwrite(fd, buf, len, pos);
>> + if (res != len) {
>> + if (res < 0 && (errno == EINTR || errno == EAGAIN)) {
>> + goto again;
>> + }
>> + fprintf(stderr, "host_pci_config: write failed: %s\n",
>> + strerror(errno));
>> + return -errno;
>> + }
>> + return 0;
>> +}
>> +
>> +int host_pci_get_byte(HostPCIDevice *d, int pos, uint8_t *p)
>> +{
>> + uint8_t buf;
>> + if (host_pci_config_read(d, pos, &buf, 1)) {
>> + return -1;
>
> Would it make sense to use the nice enum you decleraed at the
> top of the file? Or not?
I should probably return -errno instead, I mean the return value of
host_pci_config_read/write.
I just introduce the enum to have a differente value than -errno for
some internal function (get_ressource/get_hex_value), so I don't think
that the enum can really by used outside of this file, yet.
(I will change the rest of the patch as you sugest in your comment)
Thanks,
--
Anthony PERARD
- [Qemu-devel] [PATCH V4 00/10] Xen PCI Passthrough, Anthony PERARD, 2011/11/17
- [Qemu-devel] [PATCH V4 01/10] pci_ids: Add INTEL_82599_VF id., Anthony PERARD, 2011/11/17
- [Qemu-devel] [PATCH V4 02/10] pci_regs: Fix value of PCI_EXP_TYPE_RC_EC., Anthony PERARD, 2011/11/17
- [Qemu-devel] [PATCH V4 03/10] pci_regs: Add PCI_EXP_TYPE_PCIE_BRIDGE, Anthony PERARD, 2011/11/17
- [Qemu-devel] [PATCH V4 05/10] Introduce HostPCIDevice to access a pci device on the host., Anthony PERARD, 2011/11/17
- [Qemu-devel] [PATCH V4 04/10] configure: Introduce --enable-xen-pci-passthrough., Anthony PERARD, 2011/11/17
- [Qemu-devel] [PATCH V4 06/10] pci.c: Add pci_check_bar_overlap, Anthony PERARD, 2011/11/17
- [Qemu-devel] [PATCH V4 07/10] Introduce Xen PCI Passthrough, qdevice (1/3), Anthony PERARD, 2011/11/17
- [Qemu-devel] [PATCH V4 08/10] Introduce Xen PCI Passthrough, PCI config space helpers (2/3), Anthony PERARD, 2011/11/17
- [Qemu-devel] [PATCH V4 09/10] Introduce apic-msidef.h, Anthony PERARD, 2011/11/17
- [Qemu-devel] [PATCH V4 10/10] Introduce Xen PCI Passthrough, MSI (3/3), Anthony PERARD, 2011/11/17
- Re: [Qemu-devel] [PATCH V4 00/10] Xen PCI Passthrough, Stefano Stabellini, 2011/11/18