Re: [PATCH v3 4/5] KVM: ioeventfd for virtio-ccw devices.

Stefan Hajnoczi
2013-02-26T14:21:01Z

On Mon, Feb 25, 2013 at 04:27:49PM +0100, Cornelia Huck wrote:
> diff --git a/virt/kvm/eventfd.c b/virt/kvm/eventfd.c
> index f0ced1a..8de3cd7 100644
> --- a/virt/kvm/eventfd.c
> +++ b/virt/kvm/eventfd.c
> @@ -679,11 +679,16 @@ static int
> kvm_assign_ioeventfd(struct kvm *kvm, struct kvm_ioeventfd *args)
> {
> int pio = args->flags & KVM_IOEVENTFD_FLAG_PIO;
> - enum kvm_bus bus_idx = pio ? KVM_PIO_BUS : KVM_MMIO_BUS;
> + int ccw;
> + enum kvm_bus bus_idx;
> struct _ioeventfd *p;
> struct eventfd_ctx *eventfd;
> int ret;
>
> + ccw = args->flags & KVM_IOEVENTFD_FLAG_VIRTIO_CCW_NOTIFY;
> + bus_idx = pio ? KVM_PIO_BUS :
> + ccw ? KVM_VIRTIO_CCW_NOTIFY_BUS :
> + KVM_MMIO_BUS;
> /* must be natural-word sized */
> switch (args->len) {
> case 1:
> @@ -759,11 +764,16 @@ static int
> kvm_deassign_ioeventfd(struct kvm *kvm, struct kvm_ioeventfd *args)
> {
> int pio = args->flags & KVM_IOEVENTFD_FLAG_PIO;
> - enum kvm_bus bus_idx = pio ? KVM_PIO_BUS : KVM_MMIO_BUS;
> + int ccw;
> + enum kvm_bus bus_idx;
> struct _ioeventfd *p, *tmp;
> struct eventfd_ctx *eventfd;
> int ret = -ENOENT;
>
> + ccw = args->flags & KVM_IOEVENTFD_FLAG_VIRTIO_CCW_NOTIFY;
> + bus_idx = pio ? KVM_PIO_BUS :
> + ccw ? KVM_VIRTIO_CCW_NOTIFY_BUS :
> + KVM_MMIO_BUS;

This is getting pretty convoluted. Drop of pio and ccw local variables,
replace ?: with an if statement:

if (args->flags & KVM_IOEVENTFD_FLAG_VIRTIO_CCW_NOTIFY)
bus_idx = KVM_VIRTIO_CCW_NOTIFY_BUS;
else if (args->flags & KVM_IOEVENTFD_FLAG_PIO)
bus_idx = KVM_PIO_BUS;
else
bus_idx = KVM_MMIO_BUS;