From: Sheng Yang <sheng@linux.intel.com>
To: Avi Kivity <avi@redhat.com>
Cc: kvm@vger.kernel.org
Subject: Re: [PATCH 1/2] kvm: libkvm: support for irq routing
Date: Thu, 15 Jan 2009 18:05:02 +0800 [thread overview]
Message-ID: <200901151805.03447.sheng@linux.intel.com> (raw)
In-Reply-To: <496F090F.4050805@redhat.com>
On Thursday 15 January 2009 17:59:43 Avi Kivity wrote:
> Sheng Yang wrote:
> > On Thursday 15 January 2009 14:17:16 Sheng Yang wrote:
> >> On Wednesday 14 January 2009 21:53:10 Avi Kivity wrote:
> >>> Signed-off-by: Avi Kivity <avi@redhat.com>
> >>
> >> Do we need a lock for the table?
> >
> > And kvm_add_irq_route/kvm_del_irq_route should be generic used, how about
> > transfer a kvm_irq_routing_entry as parameter?
>
> These structures + selectors + unions are clumsy. For libkvm, I'd
> prefer adding kvm_add_msi() and kvm_del_msi().
But...
> +int kvm_add_irq_route(kvm_context_t kvm, int gsi, int irqchip, int pin)
> +{
> +#ifdef KVM_CAP_IRQ_ROUTING
> + struct kvm_irq_routing *z;
> + struct kvm_irq_routing_entry *e;
> + int n, size;
> +
> + if (kvm->irq_routes->nr == kvm->nr_allocated_irq_routes) {
> + n = kvm->nr_allocated_irq_routes * 2;
> + if (n < 64)
> + n = 64;
> + size = sizeof(struct kvm_irq_routing);
> + size += n * sizeof(*e);
> + z = realloc(kvm->irq_routes, size);
> + if (!z)
> + return -ENOMEM;
> + kvm->nr_allocated_irq_routes = n;
> + kvm->irq_routes = z;
> + }
> + n = kvm->irq_routes->nr++;
> + e = &kvm->irq_routes->entries[n];
> + memset(e, 0, sizeof(*e));
> + e->gsi = gsi;
> + e->type = KVM_IRQ_ROUTING_IRQCHIP;
> + e->flags = 0;
> + e->u.irqchip.irqchip = irqchip;
> + e->u.irqchip.pin = pin;
> + return 0;
> +#else
> + return -ENOSYS;
> +#endif
> +}
Besides three lines, all can be reused... I don't see the reason for another
function...
And the name here is irq_route, I suppose it should be generic used. Can be
core function which can be wrapped.
--
regards
Yang, Sheng
next prev parent reply other threads:[~2009-01-15 10:05 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-01-14 13:53 [PATCH 0/2] irq routing userspace Avi Kivity
2009-01-14 13:53 ` [PATCH 1/2] kvm: libkvm: support for irq routing Avi Kivity
2009-01-15 6:17 ` Sheng Yang
2009-01-15 6:20 ` Sheng Yang
2009-01-15 9:59 ` Avi Kivity
2009-01-15 10:05 ` Sheng Yang [this message]
2009-01-15 10:10 ` Avi Kivity
2009-01-15 9:58 ` Avi Kivity
2009-01-14 13:53 ` [PATCH 2/2] kvm: qemu: initialize irq routing table Avi Kivity
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=200901151805.03447.sheng@linux.intel.com \
--to=sheng@linux.intel.com \
--cc=avi@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.