@@ -59,6 +59,7 @@ static bool colo_compare_active;
59
59
static QemuMutex event_mtx ;
60
60
static QemuCond event_complete_cond ;
61
61
static int event_unhandled_count ;
62
+ static uint32_t max_queue_size ;
62
63
63
64
/*
64
65
* + CompareState ++
@@ -222,7 +223,7 @@ static void fill_pkt_tcp_info(void *data, uint32_t *max_ack)
222
223
*/
223
224
static int colo_insert_packet (GQueue * queue , Packet * pkt , uint32_t * max_ack )
224
225
{
225
- if (g_queue_get_length (queue ) <= MAX_QUEUE_SIZE ) {
226
+ if (g_queue_get_length (queue ) <= max_queue_size ) {
226
227
if (pkt -> ip -> ip_p == IPPROTO_TCP ) {
227
228
fill_pkt_tcp_info (pkt , max_ack );
228
229
g_queue_insert_sorted (queue ,
@@ -1134,6 +1135,37 @@ static void compare_set_expired_scan_cycle(Object *obj, Visitor *v,
1134
1135
s -> expired_scan_cycle = value ;
1135
1136
}
1136
1137
1138
+ static void get_max_queue_size (Object * obj , Visitor * v ,
1139
+ const char * name , void * opaque ,
1140
+ Error * * errp )
1141
+ {
1142
+ uint32_t value = max_queue_size ;
1143
+
1144
+ visit_type_uint32 (v , name , & value , errp );
1145
+ }
1146
+
1147
+ static void set_max_queue_size (Object * obj , Visitor * v ,
1148
+ const char * name , void * opaque ,
1149
+ Error * * errp )
1150
+ {
1151
+ Error * local_err = NULL ;
1152
+ uint32_t value ;
1153
+
1154
+ visit_type_uint32 (v , name , & value , & local_err );
1155
+ if (local_err ) {
1156
+ goto out ;
1157
+ }
1158
+ if (!value ) {
1159
+ error_setg (& local_err , "Property '%s.%s' requires a positive value" ,
1160
+ object_get_typename (obj ), name );
1161
+ goto out ;
1162
+ }
1163
+ max_queue_size = value ;
1164
+
1165
+ out :
1166
+ error_propagate (errp , local_err );
1167
+ }
1168
+
1137
1169
static void compare_pri_rs_finalize (SocketReadState * pri_rs )
1138
1170
{
1139
1171
CompareState * s = container_of (pri_rs , CompareState , pri_rs );
@@ -1251,6 +1283,11 @@ static void colo_compare_complete(UserCreatable *uc, Error **errp)
1251
1283
s -> expired_scan_cycle = REGULAR_PACKET_CHECK_MS ;
1252
1284
}
1253
1285
1286
+ if (!max_queue_size ) {
1287
+ /* Set default queue size to 1024 */
1288
+ max_queue_size = MAX_QUEUE_SIZE ;
1289
+ }
1290
+
1254
1291
if (find_and_check_chardev (& chr , s -> pri_indev , errp ) ||
1255
1292
!qemu_chr_fe_init (& s -> chr_pri_in , chr , errp )) {
1256
1293
return ;
@@ -1370,6 +1407,10 @@ static void colo_compare_init(Object *obj)
1370
1407
compare_get_expired_scan_cycle ,
1371
1408
compare_set_expired_scan_cycle , NULL , NULL );
1372
1409
1410
+ object_property_add (obj , "max_queue_size" , "uint32" ,
1411
+ get_max_queue_size ,
1412
+ set_max_queue_size , NULL , NULL );
1413
+
1373
1414
s -> vnet_hdr = false;
1374
1415
object_property_add_bool (obj , "vnet_hdr_support" , compare_get_vnet_hdr ,
1375
1416
compare_set_vnet_hdr );
0 commit comments