void pci_device_hot_add(Monitor *mon, const QDict *qdict, QObject **ret_data)

{

    PCIDevice *dev = NULL;

    const char *pci_addr = qdict_get_str(qdict, "pci_addr");

    const char *type = qdict_get_str(qdict, "type");

    const char *opts = qdict_get_try_str(qdict, "opts");



    /* strip legacy tag */

    if (!strncmp(pci_addr, "pci_addr=", 9)) {

        pci_addr += 9;

    }



    if (!opts) {

        opts = "";

    }



    if (!strcmp(pci_addr, "auto"))

        pci_addr = NULL;



    if (strcmp(type, "nic") == 0)

        dev = qemu_pci_hot_add_nic(mon, pci_addr, opts);

    else if (strcmp(type, "storage") == 0)

        dev = qemu_pci_hot_add_storage(mon, pci_addr, opts);

    else

        monitor_printf(mon, "invalid type: %s\n", type);



    if (dev) {

        *ret_data =

        qobject_from_jsonf("{ 'domain': 0, 'bus': %d, 'slot': %d, "

                           "'function': %d }", pci_bus_num(dev->bus),

                           PCI_SLOT(dev->devfn), PCI_FUNC(dev->devfn));

        assert(*ret_data != NULL);

    } else

        monitor_printf(mon, "failed to add %s\n", opts);

}

void pci_device_hot_add(Monitor *mon, const QDict *qdict, QObject **ret_data)

{

    PCIDevice *dev = NULL;

    const char *pci_addr = qdict_get_str(qdict, "pci_addr");

    const char *type = qdict_get_str(qdict, "type");

    const char *opts = qdict_get_try_str(qdict, "opts");



    

    if (!strncmp(pci_addr, "pci_addr=", 9)) {

        pci_addr += 9;

    }



    if (!opts) {

        opts = "";

    }



    if (!strcmp(pci_addr, "auto"))

        pci_addr = NULL;



    if (strcmp(type, "nic") == 0)

        dev = qemu_pci_hot_add_nic(mon, pci_addr, opts);

    else if (strcmp(type, "storage") == 0)

        dev = qemu_pci_hot_add_storage(mon, pci_addr, opts);

    else

        monitor_printf(mon, "invalid type: %s\n", type);



    if (dev) {

        *ret_data =

        qobject_from_jsonf("{ 'domain': 0, 'bus': %d, 'slot': %d, "

                           "'function': %d }", pci_bus_num(dev->bus),

                           PCI_SLOT(dev->devfn), PCI_FUNC(dev->devfn));

        assert(*ret_data != NULL);

    } else

        monitor_printf(mon, "failed to add %s\n", opts);

}

void FUNC_0(Monitor *VAR_0, const QDict *VAR_1, QObject **VAR_2)

{

    PCIDevice *dev = NULL;

    const char *VAR_3 = qdict_get_str(VAR_1, "VAR_3");

    const char *VAR_4 = qdict_get_str(VAR_1, "VAR_4");

    const char *VAR_5 = qdict_get_try_str(VAR_1, "VAR_5");



    

    if (!strncmp(VAR_3, "VAR_3=", 9)) {

        VAR_3 += 9;

    }



    if (!VAR_5) {

        VAR_5 = "";

    }



    if (!strcmp(VAR_3, "auto"))

        VAR_3 = NULL;



    if (strcmp(VAR_4, "nic") == 0)

        dev = qemu_pci_hot_add_nic(VAR_0, VAR_3, VAR_5);

    else if (strcmp(VAR_4, "storage") == 0)

        dev = qemu_pci_hot_add_storage(VAR_0, VAR_3, VAR_5);

    else

        monitor_printf(VAR_0, "invalid VAR_4: %s\n", VAR_4);



    if (dev) {

        *VAR_2 =

        qobject_from_jsonf("{ 'domain': 0, 'bus': %d, 'slot': %d, "

                           "'function': %d }", pci_bus_num(dev->bus),

                           PCI_SLOT(dev->devfn), PCI_FUNC(dev->devfn));

        assert(*VAR_2 != NULL);

    } else

        monitor_printf(VAR_0, "failed to add %s\n", VAR_5);

}

void FUNC_0(Monitor *VAR_0, const QDict *VAR_1, QObject **VAR_2)
{ PCIDevice *dev = NULL; const char *VAR_3 = qdict_get_str(VAR_1, "VAR_3"); const char *VAR_4 = qdict_get_str(VAR_1, "VAR_4"); const char *VAR_5 = qdict_get_try_str(VAR_1, "VAR_5"); if (!strncmp(VAR_3, "VAR_3=", 9)) { VAR_3 += 9; } if (!VAR_5) { VAR_5 = ""; } if (!strcmp(VAR_3, "auto"))
VAR_3 = NULL; if (strcmp(VAR_4, "nic") == 0)
dev = qemu_pci_hot_add_nic(VAR_0, VAR_3, VAR_5); else if (strcmp(VAR_4, "storage") == 0)
dev = qemu_pci_hot_add_storage(VAR_0, VAR_3, VAR_5); else
monitor_printf(VAR_0, "invalid VAR_4: %s\n", VAR_4); if (dev) { *VAR_2 =
qobject_from_jsonf("{ 'domain': 0, 'bus': %d, 'slot': %d, " "'function': %d }", pci_bus_num(dev->bus), PCI_SLOT(dev->devfn), PCI_FUNC(dev->devfn)); assert(*VAR_2 != NULL); } else monitor_printf(VAR_0, "failed to add %s\n", VAR_5); }