Revision 8bc27249 hw/qdev.c

b/hw/qdev.c
586 586
        dev = qbus_find_dev(bus, elem);
587 587
        if (!dev) {
588 588
            qerror_report(QERR_DEVICE_NOT_FOUND, elem);
589
            qbus_list_dev(bus);
589
            if (!monitor_cur_is_qmp()) {
590
                qbus_list_dev(bus);
591
            }
590 592
            return NULL;
591 593
        }
592 594

  
......
605 607
                return QLIST_FIRST(&dev->child_bus);
606 608
            default:
607 609
                qerror_report(QERR_DEVICE_MULTIPLE_BUSSES, elem);
608
                qbus_list_bus(dev);
610
                if (!monitor_cur_is_qmp()) {
611
                    qbus_list_bus(dev);
612
                }
609 613
                return NULL;
610 614
            }
611 615
        }
......
619 623
        bus = qbus_find_bus(dev, elem);
620 624
        if (!bus) {
621 625
            qerror_report(QERR_BUS_NOT_FOUND, elem);
622
            qbus_list_bus(dev);
626
            if (!monitor_cur_is_qmp()) {
627
                qbus_list_bus(dev);
628
            }
623 629
            return NULL;
624 630
        }
625 631
    }
......
762 768
    }
763 769
}
764 770

  
765
void do_device_add(Monitor *mon, const QDict *qdict)
771
/**
772
 * do_device_add(): Add a device
773
 *
774
 * Argument qdict contains
775
 * - "driver": the name of the new device's driver
776
 * - "bus": the device's parent bus (device tree path)
777
 * - "id": the device's ID (must be unique)
778
 * - device properties
779
 *
780
 * Example:
781
 *
782
 * { "driver": "usb-net", "id": "eth1", "netdev": "netdev1" }
783
 */
784
int do_device_add(Monitor *mon, const QDict *qdict, QObject **ret_data)
766 785
{
767 786
    QemuOpts *opts;
768 787

  
769 788
    opts = qemu_opts_from_qdict(&qemu_device_opts, qdict);
770
    if (opts) {
771
        if (qdev_device_help(opts) || qdev_device_add(opts) == NULL) {
772
            qemu_opts_del(opts);
773
        }
789
    if (!opts) {
790
        return -1;
791
    }
792
    if (!monitor_cur_is_qmp() && qdev_device_help(opts)) {
793
        qemu_opts_del(opts);
794
        return 0;
774 795
    }
796
    if (!qdev_device_add(opts)) {
797
        qemu_opts_del(opts);
798
        return -1;
799
    }
800
    return 0;
775 801
}
776 802

  
777 803
void do_device_del(Monitor *mon, const QDict *qdict)

Also available in: Unified diff