1. parse will put all options after -device to qemu_device_opts

2. moudle_call_init(MODULE_INIT_DEVICE) add device type to system.

3. qemu_opts_foreach(&qemu_device_opts, device_init_func, NULL, 1) create specific device.

4. device_init_func call qdev_device_add(opts)

 

5. For qdev_device_add(opts)

   a) qemu_opt_get(opts,"driver") get driver

   b) qdev_find_info(NULL,driver) get Deviceifo.

   c)qemu_opt_get(opts,"bus") get bus path

   d) if path is not empty, use qbus_find(path) to get bus instance.

        d.1) search root bus, if start with "/", it is main_system_bus, otherwise use qbus_find_recursive to search again.

        d.2)if finished, return current bus

         d.3) parse next component, use qbus_find_dev search dev and use qbus_find_bus search children bus from last level.

    e) if path is empty, use qbus_find_recursive to get bus instance.

    f) call qdev_create_from_info to create dev , return Devicestate.

   g) if qemu_opts_id(opts) is not null, then set qdev->id

   h) use qemu_opt_foreach(opts,set_property,qdev,1) to set device property.

   i) use qdev_init to initialize device

   j) qdev_init will call dev->info->init.