summary refs log tree commit diff stats
diff options
context:
space:
mode:
-rw-r--r--Makefile1
-rw-r--r--hw/e1000.c31
-rw-r--r--hw/pci.c6
-rw-r--r--hw/pci.h4
-rw-r--r--hw/qdev.c2
-rw-r--r--hw/rtl8139.c6
-rw-r--r--[-rwxr-xr-x]microblaze-dis.c0
-rw-r--r--monitor.c57
-rw-r--r--qemu-options.hx2
-rw-r--r--vl.c22
10 files changed, 79 insertions, 52 deletions
diff --git a/Makefile b/Makefile
index 767d6c5d8d..31776160c0 100644
--- a/Makefile
+++ b/Makefile
@@ -256,6 +256,7 @@ clean:
 	rm -f config.mak config.h op-i386.h opc-i386.h gen-op-i386.h op-arm.h opc-arm.h gen-op-arm.h
 	rm -f *.o *.d *.a $(TOOLS) TAGS cscope.* *.pod *~ */*~
 	rm -f slirp/*.o slirp/*.d audio/*.o audio/*.d block/*.o block/*.d
+	rm -f qemu-img-cmds.h
 	$(MAKE) -C tests clean
 	for d in $(TARGET_DIRS) libhw32 libhw64; do \
 	$(MAKE) -C $$d $@ || exit 1 ; \
diff --git a/hw/e1000.c b/hw/e1000.c
index 7f8f5b2ae4..eed02a69f7 100644
--- a/hw/e1000.c
+++ b/hw/e1000.c
@@ -150,12 +150,18 @@ ioport_map(PCIDevice *pci_dev, int region_num, uint32_t addr,
 }
 
 static void
+update_irqs(E1000State *s)
+{
+    qemu_set_irq(s->dev.irq[0], (s->mac_reg[IMS] & s->mac_reg[ICR]) != 0);
+}
+
+static void
 set_interrupt_cause(E1000State *s, int index, uint32_t val)
 {
     if (val)
         val |= E1000_ICR_INT_ASSERTED;
     s->mac_reg[ICR] = val;
-    qemu_set_irq(s->dev.irq[0], (s->mac_reg[IMS] & s->mac_reg[ICR]) != 0);
+    update_irqs(s);
 }
 
 static void
@@ -972,6 +978,7 @@ nic_load(QEMUFile *f, void *opaque, int version_id)
         for (j = 0; j < mac_regarraystosave[i].size; j++)
             qemu_get_be32s(f,
                            s->mac_reg + mac_regarraystosave[i].array0 + j);
+    update_irqs(s);
     return 0;
 }
 
@@ -1060,6 +1067,19 @@ pci_e1000_uninit(PCIDevice *dev)
     return 0;
 }
 
+static void e1000_reset(void *opaque)
+{
+    E1000State *d = opaque;
+
+    memset(d->phy_reg, 0, sizeof d->phy_reg);
+    memmove(d->phy_reg, phy_reg_init, sizeof phy_reg_init);
+    memset(d->mac_reg, 0, sizeof d->mac_reg);
+    memmove(d->mac_reg, mac_reg_init, sizeof mac_reg_init);
+    d->rxbuf_min_shift = 1;
+    memset(&d->tx, 0, sizeof d->tx);
+    update_irqs(d);
+}
+
 static void pci_e1000_init(PCIDevice *pci_dev)
 {
     E1000State *d = (E1000State *)pci_dev;
@@ -1100,13 +1120,6 @@ static void pci_e1000_init(PCIDevice *pci_dev)
     checksum = (uint16_t) EEPROM_SUM - checksum;
     d->eeprom_data[EEPROM_CHECKSUM_REG] = checksum;
 
-    memset(d->phy_reg, 0, sizeof d->phy_reg);
-    memmove(d->phy_reg, phy_reg_init, sizeof phy_reg_init);
-    memset(d->mac_reg, 0, sizeof d->mac_reg);
-    memmove(d->mac_reg, mac_reg_init, sizeof mac_reg_init);
-    d->rxbuf_min_shift = 1;
-    memset(&d->tx, 0, sizeof d->tx);
-
     d->vc = qdev_get_vlan_client(&d->dev.qdev,
                                  e1000_can_receive, e1000_receive,
                                  NULL, e1000_cleanup, d);
@@ -1116,6 +1129,8 @@ static void pci_e1000_init(PCIDevice *pci_dev)
 
     register_savevm(info_str, -1, 2, nic_save, nic_load, d);
     d->dev.unregister = pci_e1000_uninit;
+    qemu_register_reset(e1000_reset, 0, d);
+    e1000_reset(d);
 }
 
 static void e1000_register_devices(void)
diff --git a/hw/pci.c b/hw/pci.c
index 0ab5b94a7d..8c904bafdb 100644
--- a/hw/pci.c
+++ b/hw/pci.c
@@ -54,7 +54,6 @@ static void pci_set_irq(void *opaque, int irq_num, int level);
 target_phys_addr_t pci_mem_base;
 static uint16_t pci_default_sub_vendor_id = PCI_SUBVENDOR_ID_REDHAT_QUMRANET;
 static uint16_t pci_default_sub_device_id = PCI_SUBDEVICE_ID_QEMU;
-static int pci_irq_index;
 static PCIBus *first_bus;
 
 static void pcibus_save(QEMUFile *f, void *opaque)
@@ -245,9 +244,6 @@ static PCIDevice *do_pci_register_device(PCIDevice *pci_dev, PCIBus *bus,
                                          PCIConfigReadFunc *config_read,
                                          PCIConfigWriteFunc *config_write)
 {
-    if (pci_irq_index >= PCI_DEVICES_MAX)
-        return NULL;
-
     if (devfn < 0) {
         for(devfn = bus->devfn_min ; devfn < 256; devfn += 8) {
             if (!bus->devices[devfn])
@@ -268,7 +264,6 @@ static PCIDevice *do_pci_register_device(PCIDevice *pci_dev, PCIBus *bus,
         config_write = pci_default_write_config;
     pci_dev->config_read = config_read;
     pci_dev->config_write = config_write;
-    pci_dev->irq_index = pci_irq_index++;
     bus->devices[devfn] = pci_dev;
     pci_dev->irq = qemu_allocate_irqs(pci_set_irq, pci_dev, 4);
     return pci_dev;
@@ -322,7 +317,6 @@ int pci_unregister_device(PCIDevice *pci_dev)
     pci_unregister_io_regions(pci_dev);
 
     qemu_free_irqs(pci_dev->irq);
-    pci_irq_index--;
     pci_dev->bus->devices[pci_dev->devfn] = NULL;
     qdev_free(&pci_dev->qdev);
     return 0;
diff --git a/hw/pci.h b/hw/pci.h
index 0405837f73..af6c8fd153 100644
--- a/hw/pci.h
+++ b/hw/pci.h
@@ -92,8 +92,6 @@ typedef struct PCIIORegion {
 #define PCI_ROM_SLOT 6
 #define PCI_NUM_REGIONS 7
 
-#define PCI_DEVICES_MAX 64
-
 /* Declarations from linux/pci_regs.h */
 #define PCI_VENDOR_ID		0x00	/* 16 bits */
 #define PCI_DEVICE_ID		0x02	/* 16 bits */
@@ -154,8 +152,6 @@ struct PCIDevice {
     PCIConfigReadFunc *config_read;
     PCIConfigWriteFunc *config_write;
     PCIUnregisterFunc *unregister;
-    /* ??? This is a PC-specific hack, and should be removed.  */
-    int irq_index;
 
     /* IRQ objects for the INTA-INTD pins.  */
     qemu_irq *irq;
diff --git a/hw/qdev.c b/hw/qdev.c
index bab351c12f..d23298ca08 100644
--- a/hw/qdev.c
+++ b/hw/qdev.c
@@ -49,7 +49,7 @@ struct DeviceType {
 };
 
 /* This is a nasty hack to allow passing a NULL bus to qdev_create.  */
-BusState *main_system_bus;
+static BusState *main_system_bus;
 
 static DeviceType *device_type_list;
 
diff --git a/hw/rtl8139.c b/hw/rtl8139.c
index c86b782e4c..de5a68fc99 100644
--- a/hw/rtl8139.c
+++ b/hw/rtl8139.c
@@ -1173,8 +1173,9 @@ static void rtl8139_reset_rxring(RTL8139State *s, uint32_t bufferSize)
     s->RxBufAddr = 0;
 }
 
-static void rtl8139_reset(RTL8139State *s)
+static void rtl8139_reset(void *opaque)
 {
+    RTL8139State *s = opaque;
     int i;
 
     /* restore MAC address */
@@ -3316,6 +3317,8 @@ static int rtl8139_load(QEMUFile* f,void* opaque,int version_id)
         s->cplus_enabled = s->CpCmd != 0;
     }
 
+    rtl8139_update_irq(s);
+
     return 0;
 }
 
@@ -3476,6 +3479,7 @@ static void pci_rtl8139_init(PCIDevice *dev)
 
     s->pci_dev = (PCIDevice *)d;
     qdev_get_macaddr(&dev->qdev, s->macaddr);
+    qemu_register_reset(rtl8139_reset, 0, s);
     rtl8139_reset(s);
     s->vc = qdev_get_vlan_client(&dev->qdev,
                                  rtl8139_can_receive, rtl8139_receive, NULL,
diff --git a/microblaze-dis.c b/microblaze-dis.c
index 0caacc0bc2..0caacc0bc2 100755..100644
--- a/microblaze-dis.c
+++ b/microblaze-dis.c
diff --git a/monitor.c b/monitor.c
index 7620bdebfe..6b45f6cca0 100644
--- a/monitor.c
+++ b/monitor.c
@@ -2381,6 +2381,32 @@ static int get_str(char *buf, int buf_size, const char **pp)
     return 0;
 }
 
+/*
+ * Store the command-name in cmdname, and return a pointer to
+ * the remaining of the command string.
+ */
+static const char *get_command_name(const char *cmdline,
+                                    char *cmdname, size_t nlen)
+{
+    size_t len;
+    const char *p, *pstart;
+
+    p = cmdline;
+    while (qemu_isspace(*p))
+        p++;
+    if (*p == '\0')
+        return NULL;
+    pstart = p;
+    while (*p != '\0' && *p != '/' && !qemu_isspace(*p))
+        p++;
+    len = p - pstart;
+    if (len > nlen - 1)
+        len = nlen - 1;
+    memcpy(cmdname, pstart, len);
+    cmdname[len] = '\0';
+    return p;
+}
+
 static int default_fmt_format = 'x';
 static int default_fmt_size = 4;
 
@@ -2388,9 +2414,8 @@ static int default_fmt_size = 4;
 
 static void monitor_handle_command(Monitor *mon, const char *cmdline)
 {
-    const char *p, *pstart, *typestr;
-    char *q;
-    int c, nb_args, len, i, has_arg;
+    const char *p, *typestr;
+    int c, nb_args, i, has_arg;
     const mon_cmd_t *cmd;
     char cmdname[256];
     char buf[1024];
@@ -2414,29 +2439,20 @@ static void monitor_handle_command(Monitor *mon, const char *cmdline)
 #endif
 
     /* extract the command name */
-    p = cmdline;
-    q = cmdname;
-    while (qemu_isspace(*p))
-        p++;
-    if (*p == '\0')
+    p = get_command_name(cmdline, cmdname, sizeof(cmdname));
+    if (!p)
         return;
-    pstart = p;
-    while (*p != '\0' && *p != '/' && !qemu_isspace(*p))
-        p++;
-    len = p - pstart;
-    if (len > sizeof(cmdname) - 1)
-        len = sizeof(cmdname) - 1;
-    memcpy(cmdname, pstart, len);
-    cmdname[len] = '\0';
 
     /* find the command */
     for(cmd = mon_cmds; cmd->name != NULL; cmd++) {
         if (compare_cmd(cmdname, cmd->name))
-            goto found;
+            break;
+    }
+
+    if (cmd->name == NULL) {
+        monitor_printf(mon, "unknown command: '%s'\n", cmdname);
+        return;
     }
-    monitor_printf(mon, "unknown command: '%s'\n", cmdname);
-    return;
- found:
 
     for(i = 0; i < MAX_ARGS; i++)
         str_allocated[i] = NULL;
@@ -2712,7 +2728,6 @@ static void monitor_handle_command(Monitor *mon, const char *cmdline)
  fail:
     for(i = 0; i < MAX_ARGS; i++)
         qemu_free(str_allocated[i]);
-    return;
 }
 
 static void cmd_completion(const char *name, const char *list)
diff --git a/qemu-options.hx b/qemu-options.hx
index 87af798419..fa549c36e2 100644
--- a/qemu-options.hx
+++ b/qemu-options.hx
@@ -723,7 +723,7 @@ STEXI
 @table @option
 ETEXI
 
-DEF("net", HAS_ARG, QEMU_OPTION_net, \
+DEF("net", HAS_ARG, QEMU_OPTION_net,
     "-net nic[,vlan=n][,macaddr=addr][,model=type][,name=str]\n"
     "                create a new Network Interface Card and connect it to VLAN 'n'\n"
 #ifdef CONFIG_SLIRP
diff --git a/vl.c b/vl.c
index 94027c0d0d..bdd78cf8ea 100644
--- a/vl.c
+++ b/vl.c
@@ -4378,6 +4378,7 @@ static int tcg_has_work(void)
 
 static int qemu_calculate_timeout(void)
 {
+#ifndef CONFIG_IOTHREAD
     int timeout;
 
     if (!vm_running)
@@ -4423,6 +4424,9 @@ static int qemu_calculate_timeout(void)
     }
 
     return timeout;
+#else /* CONFIG_IOTHREAD */
+    return 1000;
+#endif
 }
 
 static int vm_can_run(void)
@@ -4458,11 +4462,7 @@ static void main_loop(void)
 #ifdef CONFIG_PROFILER
             ti = profile_getclock();
 #endif
-#ifdef CONFIG_IOTHREAD
-            main_loop_wait(1000);
-#else
             main_loop_wait(qemu_calculate_timeout());
-#endif
 #ifdef CONFIG_PROFILER
             dev_time += profile_getclock() - ti;
 #endif
@@ -4805,7 +4805,7 @@ static char *find_datadir(const char *argv0)
 
     len = GetModuleFileName(NULL, buf, sizeof(buf) - 1);
     if (len == 0) {
-        return len;
+        return NULL;
     }
 
     buf[len] = 0;
@@ -4833,6 +4833,7 @@ static char *find_datadir(const char *argv0)
 #ifdef PATH_MAX
     char buf[PATH_MAX];
 #endif
+    size_t max_len;
 
 #if defined(__linux__)
     {
@@ -4867,11 +4868,12 @@ static char *find_datadir(const char *argv0)
     dir = dirname(p);
     dir = dirname(dir);
 
-    res = qemu_mallocz(strlen(dir) + 
-        MAX(strlen(SHARE_SUFFIX), strlen(BUILD_SUFFIX)) + 1);
-    sprintf(res, "%s%s", dir, SHARE_SUFFIX);
+    max_len = strlen(dir) +
+        MAX(strlen(SHARE_SUFFIX), strlen(BUILD_SUFFIX)) + 1;
+    res = qemu_mallocz(max_len);
+    snprintf(res, max_len, "%s%s", dir, SHARE_SUFFIX);
     if (access(res, R_OK)) {
-        sprintf(res, "%s%s", dir, BUILD_SUFFIX);
+        snprintf(res, max_len, "%s%s", dir, BUILD_SUFFIX);
         if (access(res, R_OK)) {
             qemu_free(res);
             res = NULL;
@@ -4909,7 +4911,7 @@ char *qemu_find_file(int type, const char *name)
     }
     len = strlen(data_dir) + strlen(name) + strlen(subdir) + 2;
     buf = qemu_mallocz(len);
-    sprintf(buf, "%s/%s%s", data_dir, subdir, name);
+    snprintf(buf, len, "%s/%s%s", data_dir, subdir, name);
     if (access(buf, R_OK)) {
         qemu_free(buf);
         return NULL;