<div style="line-height:1.7;color:#000000;font-size:14px;font-family:Arial"><div>Hi all, </div><div>I registe node device lifecycle event callback function after connect qemu. In the callback function, I printf the event and detail.</div><div>When I plug a USB into host, and then pull out, but there is nothing happen. The callback was not called.</div><div>Could you tell me Why? And what dose node device mean?<br></div><div>I want to auto-hotplug usb devices by using libvirt.</div><div><br></div><div>Bellow the call of libvirt:</div><div> // node device lifecycle callback function</div><div>void nodeDeviceEventLifecycleCallback(virConnectPtr conn, virNodeDevicePtr dev, int event,</div><div>                int detail, void * opaque)</div><div>{</div><div>    printf("event = %d, detail= %d\n", event, detail);</div><div>}</div><div><br></div><div>// registe node device lifecycle event</div><div>int registeNodeDevEvent()</div><div>{</div><div>    int ret = virEventRegisterDefaultImpl();</div><div>    if (ret) { return -1;}</div><div><br></div><div>    ret = virConnectNodeDeviceEventRegisterAny(vmh_conn, NULL, VIR_NODE_DEVICE_EVENT_ID_LIFECYCLE,</div><div>            VIR_NODE_DEVICE_EVENT_CALLBACK(nodeDeviceEventLifecycleCallback), NULL, NULL);</div><div>    if (-1 == ret) { return ret;}</div><div>}</div><div><br></div><div><pre style="width: 1076.34px;">Below some information about my hypervisor:</pre><pre style="width: 1076.34px;">root@ubuntu-05:/datapool/zhuohf# virsh -v
3.4.0</pre><pre style="width: 1076.34px;">root@ubuntu-05:/datapool/zhuohf# qemu-x86_64 -version
qemu-x86_64 version 2.9.0
Copyright (c) 2003-2017 Fabrice Bellard and the QEMU Project developers</pre></div></div>