thomas.kuang
2020-Apr-07 07:08 UTC
why virConnectDomainEventRegisterAny can't alway trigger the callback ,how can i get a stable callback ?
hi, all: I create a vm with six nic, after the vm start, i delete tree nics. all the three nic delete logic will happen in a thread , every nic delete has the following process: int vnf_control_del_network(void *arg) { 。。。。。 call_id = virConnectDomainEventRegisterAny(conn, dom, VIR_DOMAIN_EVENT_ID_DEVICE_REMOVED, VIR_DOMAIN_EVENT_CALLBACK(vnf_control_del_network_cb), cb_para, vnf_control_del_network_cb_free); flags |= VIR_DOMAIN_AFFECT_CONFIG; if (virDomainIsActive(dom) == 1) { flags |= VIR_DOMAIN_AFFECT_LIVE; } ret = virDomainDetachDeviceFlags(dom, xml, flags); // detach a nic from vm guest os 。。。。 } void vnf_control_del_network_cb(virConnectPtr conn, virDomainPtr dom, const char *dev,void * opaque) //this callback can't already trigger to run ,why ? { struct vnf_del_netwk_opaque * arg = (struct vnf_del_netwk_opaque *)opaque; ........ do someing; if(0 == virConnectDomainEventDeregisterAny(conn, arg->call_id)) printf("succ to deRegister, conn:%p, call id:%d\n", conn, arg->call_id); else printf("fail to deRegister, conn:%p, call id:%d\n", conn, arg->call_id) } void* vnf_worker_proc(void *arg) { vnf_mission_t *mission = NULL; pthread_t tid = pthread_self(); vnf_task_ctx_t *task = vnf_task_get_task_info(tid); assert(task); pthread_detach(tid); while (1) { mission = vnf_mission_queue_get(task); if (mission == NULL) { sleep(1); continue; } VNF_IMAGE_DBG("tid:%lu, get one mission from mission queue\n", tid); vnf_op_process(&mission->info); //this cause vnf_control_del_network called if (mission) { vnf_mission_free(mission); } if(virEventRunDefaultImpl() < 0) { VNF_IMAGE_DBG("virEventRunDefaultImpl() called failure\n"); } } return NULL; }
Possibly Parallel Threads
- when virEventAddTimeout trigger timeout ,should in the callback call virConnectDomainEventDeregisterAny ?
- what a correct use for virConnectDomainEventRegisterAny API, how to Obtain a stable expected result
- Re: what a correct use for virConnectDomainEventRegisterAny API, how to Obtain a stable expected result
- virConnectDomainEventRegisterAny problem
- Re: virConnectDomainEventRegisterAny problem