1
00:00:00,320 --> 00:00:05,420
 The first example that we'll look at is how control and data transfer is

2
00:00:05,420 --> 00:00:12,850
 affected in zen for a network virtualization. Each guest has two I/O rings,

3
00:00:12,850 --> 00:00:18,110
 one for transmission and one for reception. If the guest wants to transmit

4
00:00:18,110 --> 00:00:22,275
 packets, it enqueues descriptors in the transmit

5
00:00:22,275 --> 00:00:25,990
 I/O ring. And placing these descriptors in

6
00:00:25,990 --> 00:00:30,480
 this IO ring is via hyper [UNKNOWN] that then

7
00:00:30,480 --> 00:00:35,140
 provide for desktop systems. The packets that need to be

8
00:00:35,140 --> 00:00:40,460
 transmitted are not copies into zen, but the buffers that contain these

9
00:00:40,460 --> 00:00:46,130
 packets are in the guest operating system buffers. And what the guest

10
00:00:46,130 --> 00:00:51,670
 does is it embeds pointers to these buffers

11
00:00:51,670 --> 00:00:57,670
 in the descriptors that have been enqueued for transmission by hypervisor. So in

12
00:00:57,670 --> 00:01:00,580
 other words, there's no copying of

13
00:01:00,580 --> 00:01:03,400
 the package themselves From the guest operating

14
00:01:03,400 --> 00:01:06,140
 system buffers into [INAUDIBLE]. Because the

15
00:01:06,140 --> 00:01:10,260
 pointers to the guest operating system buffers

16
00:01:10,260 --> 00:01:13,390
 have been embedded in these descriptors.

17
00:01:13,390 --> 00:01:16,690
 And for the duration of the transmission,

18
00:01:16,690 --> 00:01:19,560
 the pages associated with these network packets

19
00:01:19,560 --> 00:01:22,670
 are pinned So that Xen can complete

20
00:01:22,670 --> 00:01:25,000
 the transmission of the packets. Now, this

21
00:01:25,000 --> 00:01:30,020
 is showing interaction of one guest operating system

22
00:01:30,020 --> 00:01:36,790
 with Xen. Of course, more than one VM may want to transmit. And what Xen does

23
00:01:36,790 --> 00:01:42,530
 is it adopts its own draw bin packet scheduler. In order to transmit

24
00:01:42,530 --> 00:01:47,510
 packets from different virtual machines. Receiving

25
00:01:47,510 --> 00:01:49,570
 packets from the network and passing

26
00:01:49,570 --> 00:01:55,820
 it to the appropriate domain works exactly similar to what I described for

27
00:01:55,820 --> 00:02:01,260
 transmission except in the opposite direction. What xen does when it receives a

28
00:02:01,260 --> 00:02:03,610
 network packet intended for a particular

29
00:02:03,610 --> 00:02:08,050
 guest, it exchanges the received packet for

30
00:02:08,050 --> 00:02:15,090
 one of the guest operating system page that has been already provided to xen as

31
00:02:15,090 --> 00:02:20,050
 the holding place for incoming packets. In other words, in order to make things

32
00:02:20,050 --> 00:02:22,660
 efficient What a guest operating system will

33
00:02:22,660 --> 00:02:27,000
 do is pre-allocate network buffers which are

34
00:02:27,000 --> 00:02:33,110
 pages owned by the guest operating system. So when a package comes in, Xen can

35
00:02:33,110 --> 00:02:35,960
 directly put the network package into the

36
00:02:35,960 --> 00:02:38,860
 buffer that is owned by the guest operating

37
00:02:38,860 --> 00:02:43,010
 system. And in queue, a descriptor for

38
00:02:43,010 --> 00:02:46,120
 that particular guest operating system. So once again,

39
00:02:46,120 --> 00:02:52,870
 we can avoid copying in the direction of going from xen to the guest operating

40
00:02:52,870 --> 00:02:58,770
 system. So one of the cute tricks that xen also plays, is that when it receives

41
00:02:58,770 --> 00:03:02,090
 a packet into a machine page. Then it

42
00:03:02,090 --> 00:03:05,550
 can simply exchange that machine page with some

43
00:03:05,550 --> 00:03:07,580
 other page that belongs to the guest operating

44
00:03:07,580 --> 00:03:10,350
 system. And there again, is another trick to avoid

45
00:03:10,350 --> 00:03:13,690
 copying. Either the guest can pre-allocate a buffer,

46
00:03:13,690 --> 00:03:17,270
 in which case, xen can directly put that packet

47
00:03:17,270 --> 00:03:20,890
 into the pre-allocated buffer. Or if xen receives

48
00:03:20,890 --> 00:03:24,410
 a packet into a machine page, it can simply

49
00:03:24,410 --> 00:03:29,530
 swap that machine page. For a page that the guest already owns so those

50
00:03:29,530 --> 00:03:32,540
 are two different techinques for avoiding copying

51
00:03:32,540 --> 00:03:32,540
 altogether in the reverse direction as well.


