[libvirt-users] node device lifecycle callback can't resive event

netsurfed zhuohaofan at 126.com
Tue Jul 4 02:52:16 UTC 2017


Hi all, 
I registe node device lifecycle event callback function after connect qemu. In the callback function, I printf the event and detail.
When I plug a USB into host, and then pull out, but there is nothing happen. The callback was not called.
Could you tell me Why? And what dose node device mean?

I want to auto-hotplug usb devices by using libvirt.


Bellow the call of libvirt:
 // node device lifecycle callback function
void nodeDeviceEventLifecycleCallback(virConnectPtr conn, virNodeDevicePtr dev, int event,
                int detail, void * opaque)
{
    printf("event = %d, detail= %d\n", event, detail);
}


// registe node device lifecycle event
int registeNodeDevEvent()
{
    int ret = virEventRegisterDefaultImpl();
    if (ret) { return -1;}


    ret = virConnectNodeDeviceEventRegisterAny(vmh_conn, NULL, VIR_NODE_DEVICE_EVENT_ID_LIFECYCLE,
            VIR_NODE_DEVICE_EVENT_CALLBACK(nodeDeviceEventLifecycleCallback), NULL, NULL);
    if (-1 == ret) { return ret;}
}


Below some information about my hypervisor:
root at ubuntu-05:/datapool/zhuohf# virsh -v
3.4.0
root at 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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://listman.redhat.com/archives/libvirt-users/attachments/20170704/7024f9e2/attachment.htm>


More information about the libvirt-users mailing list