Re: [PATCH v5 3/5] Add functions for assigning ioeventfd and irqfds.

2010-05-10 Thread Avi Kivity

On 05/10/2010 06:13 PM, Cam Macdonell wrote:



+int kvm_set_ioeventfd_mmio_long(int fd, uint32_t addr, uint32_t val, bool
assign)
+{
+
+int ret;
+struct kvm_ioeventfd iofd;
+
+iofd.datamatch = val;
+iofd.addr = addr;
+iofd.len = 4;
+iofd.flags = KVM_IOEVENTFD_FLAG_DATAMATCH;
+iofd.fd = fd;
+
+if (!kvm_enabled())
+return -ENOSYS;
+if (!assign)
+iofd.flags |= KVM_IOEVENTFD_FLAG_DEASSIGN;

   

May be more usable to have separate assign and deassign functions (that can
call into a single internal implementation).
 

I believe the convention so far is to use the 'assign' flag as
Michael's patch and the PIO version kvm_set_ioeventfd_pio_word() do.
   


I dislike bool arguments since they're hard to understand at the call 
site.  However if there's precedent we can stick to it and perhaps 
change it all later.


--
error compiling committee.c: too many arguments to function

--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v5 3/5] Add functions for assigning ioeventfd and irqfds.

2010-05-10 Thread Cam Macdonell
On Mon, May 10, 2010 at 4:43 AM, Avi Kivity  wrote:
> On 04/21/2010 08:53 PM, Cam Macdonell wrote:
>>
>> Generic functions to assign irqfds and ioeventfds.
>>
>>
>
> Signoff.
>
>>  }
>>
>>  #ifdef KVM_IOEVENTFD
>> +int kvm_set_irqfd(int fd, uint16_t vector, uint32_t gsi)
>> +{
>> +    struct kvm_irqfd call = { };
>> +    int r;
>> +
>> +    call.fd = fd;
>> +    call.gsi = gsi;
>>
>
>> +
>> +    if (!kvm_enabled())
>> +        return -ENOSYS;
>>
>
> Braces, here and elsewhere.

This function is unnecessary as Michael added one that does the same thing.

>
>> +    r = kvm_vm_ioctl(kvm_state, KVM_IRQFD,&call);
>> +
>> +    if (r<  0) {
>> +        return r;
>>
>
> -errno
>
>> +    }
>> +    return 0;
>> +}
>> +
>> +int kvm_set_ioeventfd_mmio_long(int fd, uint32_t addr, uint32_t val, bool
>> assign)
>> +{
>> +
>> +    int ret;
>> +    struct kvm_ioeventfd iofd;
>> +
>> +    iofd.datamatch = val;
>> +    iofd.addr = addr;
>> +    iofd.len = 4;
>> +    iofd.flags = KVM_IOEVENTFD_FLAG_DATAMATCH;
>> +    iofd.fd = fd;
>> +
>> +    if (!kvm_enabled())
>> +        return -ENOSYS;
>> +    if (!assign)
>> +        iofd.flags |= KVM_IOEVENTFD_FLAG_DEASSIGN;
>>
>
> May be more usable to have separate assign and deassign functions (that can
> call into a single internal implementation).

I believe the convention so far is to use the 'assign' flag as
Michael's patch and the PIO version kvm_set_ioeventfd_pio_word() do.

>
>> +
>> +    ret = kvm_vm_ioctl(kvm_state, KVM_IOEVENTFD,&iofd);
>> +
>> +    if (ret<  0) {
>> +        return ret;
>>
>
> -errno
>
>> +    }
>> +
>> +    return 0;
>> +}
>> +
>>
>
> --
> error compiling committee.c: too many arguments to function
>
>
--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v5 3/5] Add functions for assigning ioeventfd and irqfds.

2010-05-10 Thread Avi Kivity

On 04/21/2010 08:53 PM, Cam Macdonell wrote:

Generic functions to assign irqfds and ioeventfds.

   


Signoff.


  }

  #ifdef KVM_IOEVENTFD
+int kvm_set_irqfd(int fd, uint16_t vector, uint32_t gsi)
+{
+struct kvm_irqfd call = { };
+int r;
+
+call.fd = fd;
+call.gsi = gsi;
   



+
+if (!kvm_enabled())
+return -ENOSYS;
   


Braces, here and elsewhere.


+r = kvm_vm_ioctl(kvm_state, KVM_IRQFD,&call);
+
+if (r<  0) {
+return r;
   


-errno


+}
+return 0;
+}
+
+int kvm_set_ioeventfd_mmio_long(int fd, uint32_t addr, uint32_t val, bool 
assign)
+{
+
+int ret;
+struct kvm_ioeventfd iofd;
+
+iofd.datamatch = val;
+iofd.addr = addr;
+iofd.len = 4;
+iofd.flags = KVM_IOEVENTFD_FLAG_DATAMATCH;
+iofd.fd = fd;
+
+if (!kvm_enabled())
+return -ENOSYS;
+if (!assign)
+iofd.flags |= KVM_IOEVENTFD_FLAG_DEASSIGN;
   


May be more usable to have separate assign and deassign functions (that 
can call into a single internal implementation).



+
+ret = kvm_vm_ioctl(kvm_state, KVM_IOEVENTFD,&iofd);
+
+if (ret<  0) {
+return ret;
   


-errno


+}
+
+return 0;
+}
+
   


--
error compiling committee.c: too many arguments to function

--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v5 3/5] Add functions for assigning ioeventfd and irqfds.

2010-04-21 Thread Cam Macdonell
Generic functions to assign irqfds and ioeventfds.

---
 kvm-all.c |   44 
 kvm.h |   14 ++
 2 files changed, 58 insertions(+), 0 deletions(-)

diff --git a/kvm-all.c b/kvm-all.c
index fb8d4b8..d5c7775 100644
--- a/kvm-all.c
+++ b/kvm-all.c
@@ -1193,6 +1193,50 @@ int kvm_set_signal_mask(CPUState *env, const sigset_t 
*sigset)
 }
 
 #ifdef KVM_IOEVENTFD
+int kvm_set_irqfd(int fd, uint16_t vector, uint32_t gsi)
+{
+struct kvm_irqfd call = { };
+int r;
+
+call.fd = fd;
+call.gsi = gsi;
+
+if (!kvm_enabled())
+return -ENOSYS;
+r = kvm_vm_ioctl(kvm_state, KVM_IRQFD, &call);
+
+if (r < 0) {
+return r;
+}
+return 0;
+}
+
+int kvm_set_ioeventfd_mmio_long(int fd, uint32_t addr, uint32_t val, bool 
assign)
+{
+
+int ret;
+struct kvm_ioeventfd iofd;
+
+iofd.datamatch = val;
+iofd.addr = addr;
+iofd.len = 4;
+iofd.flags = KVM_IOEVENTFD_FLAG_DATAMATCH;
+iofd.fd = fd;
+
+if (!kvm_enabled())
+return -ENOSYS;
+if (!assign)
+iofd.flags |= KVM_IOEVENTFD_FLAG_DEASSIGN;
+
+ret = kvm_vm_ioctl(kvm_state, KVM_IOEVENTFD, &iofd);
+
+if (ret < 0) {
+return ret;
+}
+
+return 0;
+}
+
 int kvm_set_ioeventfd_pio_word(int fd, uint16_t addr, uint16_t val, bool 
assign)
 {
 struct kvm_ioeventfd kick = {
diff --git a/kvm.h b/kvm.h
index c63e314..831d68f 100644
--- a/kvm.h
+++ b/kvm.h
@@ -174,9 +174,23 @@ static inline void cpu_synchronize_post_init(CPUState *env)
 }
 
 #if defined(KVM_IOEVENTFD) && defined(CONFIG_KVM)
+int kvm_set_irqfd(int fd, uint16_t vector, uint32_t gsi);
+int kvm_set_ioeventfd_mmio_long(int fd, uint32_t adr, uint32_t val, bool 
assign);
 int kvm_set_ioeventfd_pio_word(int fd, uint16_t adr, uint16_t val, bool 
assign);
 #else
 static inline
+int kvm_set_irqfd(PCIDevice* pdev, uint16_t vector, int fd)
+{
+return -ENOSYS;
+}
+
+static inline
+int kvm_set_ioeventfd_mmio_long(int fd, uint16_t adr, uint16_t val, bool 
assign)
+{
+return -ENOSYS;
+}
+
+static inline
 int kvm_set_ioeventfd_pio_word(int fd, uint16_t adr, uint16_t val, bool assign)
 {
 return -ENOSYS;
-- 
1.6.2.5

--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html