qemu with hax to log dma reads & writes jcs.org/2018/11/12/vfio

net/colo-compare.c: Expose "expired_scan_cycle" to users

The "expired_scan_cycle" determines period of scanning expired
primary node net packets.

Signed-off-by: Zhang Chen <chen.zhang@intel.com>
Signed-off-by: Jason Wang <jasowang@redhat.com>

authored by

Zhang Chen and committed by
Jason Wang
cca35ac4 9cc43c94

+48 -4
+45 -3
net/colo-compare.c
··· 48 48 #define COLO_COMPARE_FREE_PRIMARY 0x01 49 49 #define COLO_COMPARE_FREE_SECONDARY 0x02 50 50 51 - /* TODO: Should be configurable */ 52 51 #define REGULAR_PACKET_CHECK_MS 3000 53 52 #define DEFAULT_TIME_OUT_MS 3000 54 53 ··· 94 93 SocketReadState notify_rs; 95 94 bool vnet_hdr; 96 95 uint32_t compare_timeout; 96 + uint32_t expired_scan_cycle; 97 97 98 98 /* 99 99 * Record the connection that through the NIC ··· 823 823 /* if have old packet we will notify checkpoint */ 824 824 colo_old_packet_check(s); 825 825 timer_mod(s->packet_check_timer, qemu_clock_get_ms(QEMU_CLOCK_VIRTUAL) + 826 - REGULAR_PACKET_CHECK_MS); 826 + s->expired_scan_cycle); 827 827 } 828 828 829 829 /* Public API, Used for COLO frame to notify compare event */ ··· 853 853 SCALE_MS, check_old_packet_regular, 854 854 s); 855 855 timer_mod(s->packet_check_timer, qemu_clock_get_ms(QEMU_CLOCK_VIRTUAL) + 856 - REGULAR_PACKET_CHECK_MS); 856 + s->expired_scan_cycle); 857 857 } 858 858 859 859 static void colo_compare_timer_del(CompareState *s) ··· 1018 1018 error_propagate(errp, local_err); 1019 1019 } 1020 1020 1021 + static void compare_get_expired_scan_cycle(Object *obj, Visitor *v, 1022 + const char *name, void *opaque, 1023 + Error **errp) 1024 + { 1025 + CompareState *s = COLO_COMPARE(obj); 1026 + uint32_t value = s->expired_scan_cycle; 1027 + 1028 + visit_type_uint32(v, name, &value, errp); 1029 + } 1030 + 1031 + static void compare_set_expired_scan_cycle(Object *obj, Visitor *v, 1032 + const char *name, void *opaque, 1033 + Error **errp) 1034 + { 1035 + CompareState *s = COLO_COMPARE(obj); 1036 + Error *local_err = NULL; 1037 + uint32_t value; 1038 + 1039 + visit_type_uint32(v, name, &value, &local_err); 1040 + if (local_err) { 1041 + goto out; 1042 + } 1043 + if (!value) { 1044 + error_setg(&local_err, "Property '%s.%s' requires a positive value", 1045 + object_get_typename(obj), name); 1046 + goto out; 1047 + } 1048 + s->expired_scan_cycle = value; 1049 + 1050 + out: 1051 + error_propagate(errp, local_err); 1052 + } 1053 + 1021 1054 static void compare_pri_rs_finalize(SocketReadState *pri_rs) 1022 1055 { 1023 1056 CompareState *s = container_of(pri_rs, CompareState, pri_rs); ··· 1129 1162 s->compare_timeout = DEFAULT_TIME_OUT_MS; 1130 1163 } 1131 1164 1165 + if (!s->expired_scan_cycle) { 1166 + /* Set default value to 3000 MS */ 1167 + s->expired_scan_cycle = REGULAR_PACKET_CHECK_MS; 1168 + } 1169 + 1132 1170 if (find_and_check_chardev(&chr, s->pri_indev, errp) || 1133 1171 !qemu_chr_fe_init(&s->chr_pri_in, chr, errp)) { 1134 1172 return; ··· 1227 1265 object_property_add(obj, "compare_timeout", "uint32", 1228 1266 compare_get_timeout, 1229 1267 compare_set_timeout, NULL, NULL, NULL); 1268 + 1269 + object_property_add(obj, "expired_scan_cycle", "uint32", 1270 + compare_get_expired_scan_cycle, 1271 + compare_set_expired_scan_cycle, NULL, NULL, NULL); 1230 1272 1231 1273 s->vnet_hdr = false; 1232 1274 object_property_add_bool(obj, "vnet_hdr_support", compare_get_vnet_hdr,
+3 -1
qemu-options.hx
··· 4615 4615 stored. The file format is libpcap, so it can be analyzed with 4616 4616 tools such as tcpdump or Wireshark. 4617 4617 4618 - ``-object colo-compare,id=id,primary_in=chardevid,secondary_in=chardevid,outdev=chardevid,iothread=id[,vnet_hdr_support][,notify_dev=id][,compare_timeout=@var{ms}]`` 4618 + ``-object colo-compare,id=id,primary_in=chardevid,secondary_in=chardevid,outdev=chardevid,iothread=id[,vnet_hdr_support][,notify_dev=id][,compare_timeout=@var{ms}][,expired_scan_cycle=@var{ms}`` 4619 4619 Colo-compare gets packet from primary\_inchardevid and 4620 4620 secondary\_inchardevid, than compare primary packet with 4621 4621 secondary packet. If the packets are same, we will output ··· 4626 4626 vnet\_hdr\_support flag, colo compare will send/recv packet with 4627 4627 vnet\_hdr\_len. Then compare\_timeout=@var{ms} determines the 4628 4628 maximum delay colo-compare wait for the packet. 4629 + The expired\_scan\_cycle=@var{ms} to set the period of scanning 4630 + expired primary node network packets. 4629 4631 If you want to use Xen COLO, will need the notify\_dev to 4630 4632 notify Xen colo-frame to do checkpoint. 4631 4633