Skip to contentSkip to conversation

Questions regarding ivshmem spec

DISCUSSION Sasha Levin 3 participants 8 messages Aug 25, 2011 – Aug 30, 2011 KVM

lore
Share & tools
lore
#0 lore raw

Hello,

I am looking to implement an ivshmem device for KVM tools, the purpose is to provide same functionality as QEMU and interoperability with QEMU.

Going through the spec (I found here:
https://gitorious.org/nahanni/guest-code/blobs/master/device_spec.txt ) and the code in QEMU I have gathered several questions, I'll be happy for some help with it.

1. File handles and guest IDs are passed between the server and the peers using sockets, is the protocol itself documented anywhere? I would like to be able to work alongside QEMU servers/peers.

2. The spec describes DOORBELL as an array of DWORDs, when one guest wants to poke a different guest it would write something into the offset of the other guest in the DOORBELL array.
Looking at the implementation in QEMU, DOORBELL is one DWORD, when writing to it the upper WORD is the guest id and the lower WORD is the value.
What am I missing here?

3. There are 3 ways for guests to communicate between each other, and I'm assuming all guests using the same SHM block must use the same method. Is it safe to assume we'll always use ioeventfds as in the implementation now?

Thanks!

Signature · 1 line
Sasha.
#1 lore raw
Quoted 8 lines · Sasha Levin

2. The spec describes DOORBELL as an array of DWORDs, when one guest wants to poke a different guest it would write something into the offset of the other guest in the DOORBELL array.
Looking at the implementation in QEMU, DOORBELL is one DWORD, when writing to it the upper WORD is the guest id and the lower WORD is the value.
What am I missing here?

The spec in qemu.git is accurate. The intent is to use an ioeventfd bound into an irqfd so a write into the doorbell injects an interrupt directly into the other guest, without going through qemu^Wkvm tool.

Signature · 2 lines
I have a truly marvellous patch that fixes the bug which this
signature is too narrow to contain.
#2 lore raw
Quoted 10 lines · Avi Kivity
Quoted 8 lines · Sasha Levin

2. The spec describes DOORBELL as an array of DWORDs, when one guest wants to poke a different guest it would write something into the offset of the other guest in the DOORBELL array.
Looking at the implementation in QEMU, DOORBELL is one DWORD, when writing to it the upper WORD is the guest id and the lower WORD is the value.
What am I missing here?

Quoted 4 lines

The spec in qemu.git is accurate. The intent is to use an ioeventfd bound into an irqfd so a write into the doorbell injects an interrupt directly into the other guest, without going through qemu^Wkvm tool.

But the doorbell is a single DWORD, so if a guest writes to it we'd still need to figure out which guest/vector he wants to poke from userspace, no?

If it was an array of doorbells then yes, we could assign an ioeventfd to each offset - but now I don't quite see how we can avoid passing through the userspace.

Signature · 1 line
Sasha.
#3 lore raw
Quoted 16 lines · Sasha Levin
Quoted 10 lines · Avi Kivity
Quoted 8 lines · Sasha Levin

2. The spec describes DOORBELL as an array of DWORDs, when one guest wants to poke a different guest it would write something into the offset of the other guest in the DOORBELL array.
Looking at the implementation in QEMU, DOORBELL is one DWORD, when writing to it the upper WORD is the guest id and the lower WORD is the value.
What am I missing here?

Quoted 4 lines

The spec in qemu.git is accurate. The intent is to use an ioeventfd bound into an irqfd so a write into the doorbell injects an interrupt directly into the other guest, without going through qemu^Wkvm tool.

Quoted 8 lines

But the doorbell is a single DWORD, so if a guest writes to it we'd still need to figure out which guest/vector he wants to poke from userspace, no?

If it was an array of doorbells then yes, we could assign an ioeventfd to each offset - but now I don't quite see how we can avoid passing through the userspace.

Use the datamatch facility.

We didn't want an array of registers to avoid scaling issues (PIO space is quite small).

Signature · 2 lines
I have a truly marvellous patch that fixes the bug which this
signature is too narrow to contain.
#4 lore raw
Quoted 26 lines · Avi Kivity
Quoted 16 lines · Sasha Levin
Quoted 10 lines · Avi Kivity
Quoted 8 lines · Sasha Levin

2. The spec describes DOORBELL as an array of DWORDs, when one guest wants to poke a different guest it would write something into the offset of the other guest in the DOORBELL array.
Looking at the implementation in QEMU, DOORBELL is one DWORD, when writing to it the upper WORD is the guest id and the lower WORD is the value.
What am I missing here?

Quoted 4 lines

The spec in qemu.git is accurate. The intent is to use an ioeventfd bound into an irqfd so a write into the doorbell injects an interrupt directly into the other guest, without going through qemu^Wkvm tool.

Quoted 8 lines

But the doorbell is a single DWORD, so if a guest writes to it we'd still need to figure out which guest/vector he wants to poke from userspace, no?

If it was an array of doorbells then yes, we could assign an ioeventfd to each offset - but now I don't quite see how we can avoid passing through the userspace.

Quoted 6 lines

Use the datamatch facility.

We didn't want an array of registers to avoid scaling issues (PIO space is quite small).

Ah, right.

Thanks!

Signature · 1 line
Sasha.
#5 lore raw
In reply to Sasha Levin
Quoted 4 lines · Sasha Levin

Hello,

I am looking to implement an ivshmem device for KVM tools, the purpose is to provide same functionality as QEMU and interoperability with QEMU.

[snip]

Quoted 3 lines

1. File handles and guest IDs are passed between the server and the peers using sockets, is the protocol itself documented anywhere? I would like to be able to work alongside QEMU servers/peers.

I'm still wondering if someone could do a quick sketch of the client-server protocol or possibly point me to something that documents it?

Signature · 1 line
Sasha.
#6 lore raw
Quoted 8 lines · Sasha Levin
Quoted 4 lines · Sasha Levin

Hello,

I am looking to implement an ivshmem device for KVM tools, the purpose is to provide same functionality as QEMU and interoperability with QEMU.

[snip]

Quoted 7 lines
Quoted 3 lines

1. File handles and guest IDs are passed between the server and the peers using sockets, is the protocol itself documented anywhere? I would like to be able to work alongside QEMU servers/peers.

I'm still wondering if someone could do a quick sketch of the client-server protocol or possibly point me to something that documents it?

Hi Sasha,

I have something like that. I'll be in touch when I find it.

Cam

Quoted 6 lines

--

Sasha.

#7 lore raw
In reply to Sasha Levin
Quoted 22 lines · Sasha Levin

Hello,

I am looking to implement an ivshmem device for KVM tools, the purpose is to provide same functionality as QEMU and interoperability with QEMU.

Going through the spec (I found here:
https://gitorious.org/nahanni/guest-code/blobs/master/device_spec.txt ) and the code in QEMU I have gathered several questions, I'll be happy for some help with it.

1. File handles and guest IDs are passed between the server and the peers using sockets, is the protocol itself documented anywhere? I would like to be able to work alongside QEMU servers/peers.

2. The spec describes DOORBELL as an array of DWORDs, when one guest wants to poke a different guest it would write something into the offset of the other guest in the DOORBELL array.
Looking at the implementation in QEMU, DOORBELL is one DWORD, when writing to it the upper WORD is the guest id and the lower WORD is the value.
What am I missing here?

Quoted 4 lines

3. There are 3 ways for guests to communicate between each other, and I'm assuming all guests using the same SHM block must use the same method. Is it safe to assume we'll always use ioeventfds as in the implementation now?

Guests can either access the shared memory region directly or use the server, so I would count that as 2 ways to share memory via ivshmem. Can you clarify what you mean by "ways for guests to communicate"?

As for ioeventfds, they are an optional optimization to eventfds. We use eventfds currently, but since the guest VMs only see file descriptors (passed from the server) another mechanism could replace eventfds if there was some reason to.

Cam