@@ -72,9 +72,6 @@ pub struct GuestContext {
7272 g2h_producer : G2hProducer ,
7373 /// host-to-guest driver
7474 h2g_producer : H2gProducer ,
75- /// Max writable bytes the host can write into a G2H completion.
76- /// Derived from the G2H pool upper slab slot size.
77- g2h_response_cap : usize ,
7875 /// H2G slot size in bytes (each prefilled writable descriptor).
7976 h2g_slot_size : usize ,
8077 /// snapshot generation counter
@@ -91,7 +88,6 @@ impl GuestContext {
9188 let size = g2h. pool_pages * PAGE_SIZE_USIZE ;
9289 let g2h_pool =
9390 BufferPool :: new ( g2h. pool_gva , size) . expect ( "failed to create G2H buffer pool" ) ;
94- let g2h_response_cap = BufferPool :: < 256 , 4096 > :: upper_slot_size ( ) ;
9591 let g2h_producer =
9692 VirtqProducer :: new ( g2h. layout , GuestMemOps , GuestNotifier , g2h_pool. clone ( ) ) ;
9793
@@ -105,7 +101,6 @@ impl GuestContext {
105101 let mut ctx = Self {
106102 g2h_producer,
107103 h2g_producer,
108- g2h_response_cap,
109104 h2g_slot_size,
110105 generation,
111106 pending_replies : 0 ,
@@ -118,21 +113,20 @@ impl GuestContext {
118113
119114 /// Call a host function via the G2H virtqueue.
120115 ///
121- /// Uses the default completion capacity (4096 bytes) for the response
122- /// buffer. For host functions known to return large payloads, use
116+ /// For host functions known to return payloads larger than 4096 bytes, use
123117 /// [`call_host_function_with_hint`](Self::call_host_function_with_hint).
124118 pub fn call_host_function < T : TryFrom < ReturnValue > > (
125119 & mut self ,
126120 function_name : & str ,
127121 parameters : Option < Vec < ParameterValue > > ,
128122 return_type : ReturnType ,
129123 ) -> Result < T > {
130- self . call_host_function_with_hint (
131- function_name ,
132- parameters ,
133- return_type ,
134- self . g2h_response_cap ,
135- )
124+ let hint = if matches ! ( return_type , ReturnType :: String | ReturnType :: VecBytes ) {
125+ BufferPool :: upper_slot_size ( )
126+ } else {
127+ BufferPool :: lower_slot_size ( )
128+ } ;
129+ self . call_host_function_with_hint ( function_name , parameters , return_type , hint )
136130 }
137131
138132 /// Call a host function with an explicit response capacity hint.
0 commit comments