The first example that we'll look at is how control and data transfer is
affected in zen for a network virtualization. Each guest has two I/O rings,
one for transmission and one for reception. If the guest wants to transmit
packets, it enqueues descriptors in the transmit
I/O ring. And placing these descriptors in
this IO ring is via hyper [UNKNOWN] that then
provide for desktop systems. The packets that need to be
transmitted are not copies into zen, but the buffers that contain these
packets are in the guest operating system buffers. And what the guest
does is it embeds pointers to these buffers
in the descriptors that have been enqueued for transmission by hypervisor. So in
other words, there's no copying of
the package themselves From the guest operating
system buffers into [INAUDIBLE]. Because the
pointers to the guest operating system buffers
have been embedded in these descriptors.
And for the duration of the transmission,
the pages associated with these network packets
are pinned So that Xen can complete
the transmission of the packets. Now, this
is showing interaction of one guest operating system
with Xen. Of course, more than one VM may want to transmit. And what Xen does
is it adopts its own draw bin packet scheduler. In order to transmit
packets from different virtual machines. Receiving
packets from the network and passing
it to the appropriate domain works exactly similar to what I described for
transmission except in the opposite direction. What xen does when it receives a
network packet intended for a particular
guest, it exchanges the received packet for
one of the guest operating system page that has been already provided to xen as
the holding place for incoming packets. In other words, in order to make things
efficient What a guest operating system will
do is pre-allocate network buffers which are
pages owned by the guest operating system. So when a package comes in, Xen can
directly put the network package into the
buffer that is owned by the guest operating
system. And in queue, a descriptor for
that particular guest operating system. So once again,
we can avoid copying in the direction of going from xen to the guest operating
system. So one of the cute tricks that xen also plays, is that when it receives
a packet into a machine page. Then it
can simply exchange that machine page with some
other page that belongs to the guest operating
system. And there again, is another trick to avoid
copying. Either the guest can pre-allocate a buffer,
in which case, xen can directly put that packet
into the pre-allocated buffer. Or if xen receives
a packet into a machine page, it can simply
swap that machine page. For a page that the guest already owns so those
are two different techinques for avoiding copying
altogether in the reverse direction as well.