USBDevice *usbdevice_create(const char *cmdline)
{
    USBBus *bus = usb_bus_find(-1 /* any */);
    LegacyUSBFactory *f = NULL;
    Error *err = NULL;
    GSList *i;
    char driver[32];
    const char *params;
    int len;
    USBDevice *dev;
    ObjectClass *klass;
    DeviceClass *dc;
    params = strchr(cmdline,':');
    if (params) {
        params++;
        len = params - cmdline;
        if (len > sizeof(driver))
            len = sizeof(driver);
        pstrcpy(driver, len, cmdline);
    } else {
        params = "";
        pstrcpy(driver, sizeof(driver), cmdline);
    for (i = legacy_usb_factory; i; i = i->next) {
        f = i->data;
        if (strcmp(f->usbdevice_name, driver) == 0) {
            break;
    if (i == NULL) {
#if 0
        /* no error because some drivers are not converted (yet) */
        error_report("usbdevice %s not found", driver);
#endif
    if (!bus) {
        error_report("Error: no usb bus to attach usbdevice %s, "
                     "please try -machine usb=on and check that "
                     "the machine model supports USB", driver);
    if (f->usbdevice_init) {
        dev = f->usbdevice_init(bus, params);
    } else {
        if (*params) {
            error_report("usbdevice %s accepts no params", driver);
        dev = usb_create(bus, f->name);
    if (!dev) {
        error_report("Failed to create USB device '%s'", f->name);
    object_property_set_bool(OBJECT(dev), true, "realized", &err);
    if (err) {
        error_reportf_err(err, "Failed to initialize USB device '%s': ",
                          f->name);
        object_unparent(OBJECT(dev));
    return dev;
USBDevice *usbdevice_create(const char *cmdline)
{
    USBBus *bus = usb_bus_find(-1 );
    LegacyUSBFactory *f = NULL;
    Error *err = NULL;
    GSList *i;
    char driver[32];
    const char *params;
    int len;
    USBDevice *dev;
    ObjectClass *klass;
    DeviceClass *dc;
    params = strchr(cmdline,':');
    if (params) {
        params++;
        len = params - cmdline;
        if (len > sizeof(driver))
            len = sizeof(driver);
        pstrcpy(driver, len, cmdline);
    } else {
        params = "";
        pstrcpy(driver, sizeof(driver), cmdline);
    for (i = legacy_usb_factory; i; i = i->next) {
        f = i->data;
        if (strcmp(f->usbdevice_name, driver) == 0) {
            break;
    if (i == NULL) {
#if 0
        
        error_report("usbdevice %s not found", driver);
#endif
    if (!bus) {
        error_report("Error: no usb bus to attach usbdevice %s, "
                     "please try -machine usb=on and check that "
                     "the machine model supports USB", driver);
    if (f->usbdevice_init) {
        dev = f->usbdevice_init(bus, params);
    } else {
        if (*params) {
            error_report("usbdevice %s accepts no params", driver);
        dev = usb_create(bus, f->name);
    if (!dev) {
        error_report("Failed to create USB device '%s'", f->name);
    object_property_set_bool(OBJECT(dev), true, "realized", &err);
    if (err) {
        error_reportf_err(err, "Failed to initialize USB device '%s': ",
                          f->name);
        object_unparent(OBJECT(dev));
    return dev;
USBDevice *FUNC_0(const char *cmdline)
{
    USBBus *bus = usb_bus_find(-1 );
    LegacyUSBFactory *f = NULL;
    Error *err = NULL;
    GSList *i;
    char VAR_0[32];
    const char *VAR_1;
    int VAR_2;
    USBDevice *dev;
    ObjectClass *klass;
    DeviceClass *dc;
    VAR_1 = strchr(cmdline,':');
    if (VAR_1) {
        VAR_1++;
        VAR_2 = VAR_1 - cmdline;
        if (VAR_2 > sizeof(VAR_0))
            VAR_2 = sizeof(VAR_0);
        pstrcpy(VAR_0, VAR_2, cmdline);
    } else {
        VAR_1 = "";
        pstrcpy(VAR_0, sizeof(VAR_0), cmdline);
    for (i = legacy_usb_factory; i; i = i->next) {
        f = i->data;
        if (strcmp(f->usbdevice_name, VAR_0) == 0) {
            break;
    if (i == NULL) {
#if 0
        
        error_report("usbdevice %s not found", VAR_0);
#endif
    if (!bus) {
        error_report("Error: no usb bus to attach usbdevice %s, "
                     "please try -machine usb=on and check that "
                     "the machine model supports USB", VAR_0);
    if (f->usbdevice_init) {
        dev = f->usbdevice_init(bus, VAR_1);
    } else {
        if (*VAR_1) {
            error_report("usbdevice %s accepts no VAR_1", VAR_0);
        dev = usb_create(bus, f->name);
    if (!dev) {
        error_report("Failed to create USB device '%s'", f->name);
    object_property_set_bool(OBJECT(dev), true, "realized", &err);
    if (err) {
        error_reportf_err(err, "Failed to initialize USB device '%s': ",
                          f->name);
        object_unparent(OBJECT(dev));
    return dev;
USBDevice *FUNC_0(const char *cmdline)
{ USBBus *bus = usb_bus_find(-1 ); LegacyUSBFactory *f = NULL; Error *err = NULL; GSList *i; char VAR_0[32]; const char *VAR_1; int VAR_2; USBDevice *dev; ObjectClass *klass; DeviceClass *dc; VAR_1 = strchr(cmdline,':'); if (VAR_1) { VAR_1++; VAR_2 = VAR_1 - cmdline; if (VAR_2 > sizeof(VAR_0))
VAR_2 = sizeof(VAR_0); pstrcpy(VAR_0, VAR_2, cmdline); } else { VAR_1 = ""; pstrcpy(VAR_0, sizeof(VAR_0), cmdline); for (i = legacy_usb_factory; i; i = i->next) { f = i->data; if (strcmp(f->usbdevice_name, VAR_0) == 0) { break; if (i == NULL) { #if 0
error_report("usbdevice %s not found", VAR_0); #endif
if (!bus) { error_report("Error: no usb bus to attach usbdevice %s, "
"please try -machine usb=on and check that "
"the machine model supports USB", VAR_0); if (f->usbdevice_init) { dev = f->usbdevice_init(bus, VAR_1); } else { if (*VAR_1) { error_report("usbdevice %s accepts no VAR_1", VAR_0); dev = usb_create(bus, f->name); if (!dev) { error_report("Failed to create USB device '%s'", f->name); object_property_set_bool(OBJECT(dev), true, "realized", &err); if (err) { error_reportf_err(err, "Failed to initialize USB device '%s': ",
f->name); object_unparent(OBJECT(dev)); return dev;