SEARCH
0-9 A B C D E F G H I J K L M N O P Q R S T U V W X Y Z
Prev | Current Page 321 | Next

David Chisnall

"The Definitive Guide to the Xen Hypervisor"

The
main di?¬?erence is that we don??™t support writing messages bigger than the size of
the bu?¬?er. Because the console was stream based, we could write a part of the
message and then tell the back end to handle it and then write the rest. We can??™t
152 Chapter 8. Looking through the XenStore
do this with the XenStore, because requests should be processed as a complete
message. If the message is too big for the bu?¬?er, we just return.
Listing 8.4: Writing a message to the XenStore back end [from: examples/chapter8/
xenstore.c]
34 /??— Write a r e q u e s t to the back end ??—/
35 i n t x e n s t o r e w r i t e r e q u e s t ( char ??— message , i n t l e n g t h )
36 {
37 /??— Check that the message w i l l f i t ??—/
38 i f ( length > XENSTORE RING SIZE)
39 {
40 return ??’1;
41 }
42
43 i n t i ;
44 f o r ( i=xenstore??’>req prod ; length > 0 ; i++,length ??’??’)
45 {
46 /??— Wait f o r the back end to c l e a r enough space in the
b u f f e r ??—/
47 XENSTORE RING IDX data ;
48 do
49 {
50 data = i ??’ xenstore??’>req cons ;
51 mb( ) ;
52 } while ( data >= s i z e o f ( xenstore??’>req ) ) ;
53 /??— Copy the byte ??—/
54 i n t r i n g i n d e x = MASK XENSTORE IDX( i ) ;
55 xenstore??’>req [ r i n g i n d e x ] = ??—message ;
56 message++;
57 }
58 /??— Ensure that the data r e a l l y i s in the r ing before
c o n t i n u i n g ??—/
59 wmb( ) ;
60 xenstore??’>req prod = i ;
61 return 0 ;
62 }
The other di?¬?erence is that we need to explicitly state the length of our message.


Pages:
309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333