why virConnectDomainEventRegisterAny can't alway trigger the callback ,how can i get a stable callback ?

thomas.kuang ks002278 at 163.com
Tue Apr 7 07:08:59 UTC 2020


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;

}
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://listman.redhat.com/archives/libvirt-users/attachments/20200407/327a3526/attachment.htm>


More information about the libvirt-users mailing list