qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Alex Williamson <alex.williamson@redhat.com>
To: Alexey Kardashevskiy <aik@ozlabs.ru>
Cc: Anthony Liguori <aliguori@us.ibm.com>,
	"Michael S . Tsirkin" <mst@redhat.com>,
	Alexander Graf <agraf@suse.de>,
	qemu-devel@nongnu.org, qemu-ppc@nongnu.org,
	Paolo Bonzini <pbonzini@redhat.com>,
	Paul Mackerras <paulus@samba.org>,
	David Gibson <david@gibson.dropbear.id.au>
Subject: Re: [Qemu-devel] [PATCH 6/8] spapr vfio: add vfio_container_spapr_get_info()
Date: Mon, 12 Aug 2013 16:07:03 -0600	[thread overview]
Message-ID: <1376345223.22121.14.camel@ul30vt.home> (raw)
In-Reply-To: <1375863692-12207-7-git-send-email-aik@ozlabs.ru>

On Wed, 2013-08-07 at 18:21 +1000, Alexey Kardashevskiy wrote:
> As sPAPR platform supports DMA windows on a PCI bus, the information
> about their location and size should be passed into the guest via
> the device tree.
> 
> The patch adds a helper to read this info from the container fd.
> 
> Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
> ---
>  hw/misc/vfio.c         | 37 +++++++++++++++++++++++++++++++++++++
>  include/hw/misc/vfio.h | 11 +++++++++++
>  2 files changed, 48 insertions(+)
>  create mode 100644 include/hw/misc/vfio.h
> 
> diff --git a/hw/misc/vfio.c b/hw/misc/vfio.c
> index 3855efe..4571f64 100644
> --- a/hw/misc/vfio.c
> +++ b/hw/misc/vfio.c
> @@ -39,6 +39,7 @@
>  #include "qemu/range.h"
>  #include "sysemu/kvm.h"
>  #include "sysemu/sysemu.h"
> +#include "hw/misc/vfio.h"
>  
>  /* #define DEBUG_VFIO */
>  #ifdef DEBUG_VFIO
> @@ -3488,3 +3489,39 @@ static void register_vfio_pci_dev_type(void)
>  }
>  
>  type_init(register_vfio_pci_dev_type)
> +
> +int vfio_container_spapr_get_info(AddressSpace *as, int32_t groupid,
> +                                  struct vfio_iommu_spapr_tce_info *info,
> +                                  int *group_fd)
> +{
> +    VFIOAddressSpace *space;
> +    VFIOGroup *group;
> +    VFIOContainer *container;
> +    int ret, fd;
> +
> +    space = vfio_get_address_space(as);
> +    if (!space) {
> +        return -1;
> +    }
> +    group = vfio_get_group(groupid, space);
> +    if (!group) {
> +        return -1;
> +    }
> +    container = group->container;
> +    if (!group->container) {
> +        return -1;
> +    }
> +    fd = container->fd;
> +    if (!ioctl(fd, VFIO_CHECK_EXTENSION, VFIO_SPAPR_TCE_IOMMU)) {
> +        return -1;
> +    }
> +    ret = ioctl(fd, VFIO_IOMMU_SPAPR_TCE_GET_INFO, info);
> +    if (ret) {
> +        error_report("vfio: failed to get iommu info for container: %s",
> +                     strerror(errno));
> +        return -1;
> +    }


Doesn't this leak on all the exit paths if the address space and group
don't exist yet?

> +    *group_fd = group->fd;
> +
> +    return 0;
> +}
> diff --git a/include/hw/misc/vfio.h b/include/hw/misc/vfio.h
> new file mode 100644
> index 0000000..ac9a971
> --- /dev/null
> +++ b/include/hw/misc/vfio.h
> @@ -0,0 +1,11 @@
> +#ifndef VFIO_API_H
> +#define VFIO_API_H
> +
> +#include "qemu/typedefs.h"
> +#include <linux/vfio.h>
> +
> +extern int vfio_container_spapr_get_info(AddressSpace *as, int32_t groupid,
> +                                         struct vfio_iommu_spapr_tce_info *info,
> +                                         int *group_fd);
> +
> +#endif

  reply	other threads:[~2013-08-12 22:07 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-08-07  8:21 [Qemu-devel] [PATCH 0/8 v3] vfio on power: preparations for VFIO, guest IOMMUs and VFIO itself Alexey Kardashevskiy
2013-08-07  8:21 ` [Qemu-devel] [PATCH 1/8] pci: Introduce helper to retrieve a PCI device's DMA address space Alexey Kardashevskiy
2013-08-07 10:27   ` Michael S. Tsirkin
2013-08-07  8:21 ` [Qemu-devel] [PATCH 2/8] memory: Sanity check that no listeners remain on a destroyed AddressSpace Alexey Kardashevskiy
2013-08-07  8:21 ` [Qemu-devel] [PATCH 3/8] vfio: Introduce VFIO address spaces Alexey Kardashevskiy
2013-08-12 22:07   ` Alex Williamson
2013-08-19 13:15     ` Paolo Bonzini
2013-08-07  8:21 ` [Qemu-devel] [PATCH 4/8] vfio: Create VFIOAddressSpace objects as needed Alexey Kardashevskiy
2013-08-07  8:21 ` [Qemu-devel] [PATCH 5/8] vfio: Add guest side IOMMU support Alexey Kardashevskiy
2013-08-12 22:07   ` Alex Williamson
2013-08-15  6:02     ` Alexey Kardashevskiy
2013-08-19 13:12       ` Paolo Bonzini
2013-08-21  5:31         ` Alexey Kardashevskiy
2013-08-21  8:55           ` Paolo Bonzini
2013-08-07  8:21 ` [Qemu-devel] [PATCH 6/8] spapr vfio: add vfio_container_spapr_get_info() Alexey Kardashevskiy
2013-08-12 22:07   ` Alex Williamson [this message]
2013-08-07  8:21 ` [Qemu-devel] [PATCH 7/8] spapr vfio: add spapr-pci-vfio-host-bridge to support vfio Alexey Kardashevskiy
2013-08-27 11:08   ` Alexander Graf
2013-08-30  7:43     ` Alexey Kardashevskiy
2013-08-30 13:01       ` Andreas Färber
2013-08-07  8:21 ` [Qemu-devel] [PATCH 8/8] spapr vfio: enable for spapr Alexey Kardashevskiy

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=1376345223.22121.14.camel@ul30vt.home \
    --to=alex.williamson@redhat.com \
    --cc=agraf@suse.de \
    --cc=aik@ozlabs.ru \
    --cc=aliguori@us.ibm.com \
    --cc=david@gibson.dropbear.id.au \
    --cc=mst@redhat.com \
    --cc=paulus@samba.org \
    --cc=pbonzini@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=qemu-ppc@nongnu.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).