diff options
author | Marcelo Tosatti <mtosatti@redhat.com> | 2010-08-26 20:38:04 -0300 |
---|---|---|
committer | Marcelo Tosatti <mtosatti@redhat.com> | 2010-08-26 20:38:04 -0300 |
commit | ee67c3f4534efd89a03d874c5d91b125c7b4ed51 (patch) | |
tree | 33c311aca994661925aeb8e76ebed1ac8b5c925f | |
parent | 422476cc42275e23e4ec2cf99d6c3aac6aa1f39f (diff) | |
parent | 84b89d782f03b99770759f1d9d6e4e95a2641c35 (diff) |
Merge commit '84b89d782f03b99770759f1d9d6e4e95a2641c35' into upstream-merge
* commit '84b89d782f03b99770759f1d9d6e4e95a2641c35':
Add qemu_ram_alloc_from_ptr function
microblaze: Fix the target version of stat64 struct
audio/sdl: return on error
mips: Add support for VInt and VEIC irq modes
audio/sdl: be more anal about errors
audio: make audio_pt_init block all signals
sparc32: use FW_CFG_CMDLINE_SIZE
ide: Avoid canceling IDE DMA
block: Change bdrv_eject() not to drop the image
block: Fix bdrv_has_zero_init
block migration: replace tabs by spaces.
loadvm: improve tests before bdrv_snapshot_goto()
block: Change bdrv_commit to handle multiple sectors at once
fix last cpu timer initialization
Conflicts:
cpu-common.h
exec.c
Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
-rw-r--r-- | audio/audio_pt_int.c | 25 | ||||
-rw-r--r-- | audio/esdaudio.c | 58 | ||||
-rw-r--r-- | audio/sdlaudio.c | 22 | ||||
-rw-r--r-- | block-migration.c | 12 | ||||
-rw-r--r-- | block.c | 50 | ||||
-rw-r--r-- | block/raw-posix.c | 13 | ||||
-rw-r--r-- | block/raw-win32.c | 6 | ||||
-rw-r--r-- | block/raw.c | 6 | ||||
-rw-r--r-- | block_int.h | 8 | ||||
-rw-r--r-- | cpu-common.h | 2 | ||||
-rw-r--r-- | cpu-exec.c | 2 | ||||
-rw-r--r-- | exec.c | 2 | ||||
-rw-r--r-- | hw/device-assignment.c | 3 | ||||
-rw-r--r-- | hw/ide/pci.c | 23 | ||||
-rw-r--r-- | hw/slavio_timer.c | 4 | ||||
-rw-r--r-- | hw/sun4m.c | 3 | ||||
-rw-r--r-- | linux-user/syscall_defs.h | 14 | ||||
-rw-r--r-- | monitor.c | 3 | ||||
-rw-r--r-- | savevm.c | 71 | ||||
-rw-r--r-- | target-mips/cpu.h | 23 | ||||
-rw-r--r-- | target-mips/helper.c | 27 |
21 files changed, 233 insertions, 144 deletions
diff --git a/audio/audio_pt_int.c b/audio/audio_pt_int.c index e889a983b..f15cc7015 100644 --- a/audio/audio_pt_int.c +++ b/audio/audio_pt_int.c @@ -6,6 +6,8 @@ #include "audio_int.h" #include "audio_pt_int.h" +#include <signal.h> + static void logerr (struct audio_pt *pt, int err, const char *fmt, ...) { va_list ap; @@ -23,9 +25,16 @@ int audio_pt_init (struct audio_pt *p, void *(*func) (void *), { int err, err2; const char *efunc; + sigset_t set, old_set; p->drv = drv; + err = sigfillset (&set); + if (err) { + logerr (p, errno, "%s(%s): sigfillset failed", cap, AUDIO_FUNC); + return -1; + } + err = pthread_mutex_init (&p->mutex, NULL); if (err) { efunc = "pthread_mutex_init"; @@ -38,7 +47,23 @@ int audio_pt_init (struct audio_pt *p, void *(*func) (void *), goto err1; } + err = pthread_sigmask (SIG_BLOCK, &set, &old_set); + if (err) { + efunc = "pthread_sigmask"; + goto err2; + } + err = pthread_create (&p->thread, NULL, func, opaque); + + err2 = pthread_sigmask (SIG_SETMASK, &old_set, NULL); + if (err2) { + logerr (p, err2, "%s(%s): pthread_sigmask (restore) failed", + cap, AUDIO_FUNC); + /* We have failed to restore original signal mask, all bets are off, + so terminate the process */ + exit (EXIT_FAILURE); + } + if (err) { efunc = "pthread_create"; goto err2; diff --git a/audio/esdaudio.c b/audio/esdaudio.c index 79142d170..9a1f2f861 100644 --- a/audio/esdaudio.c +++ b/audio/esdaudio.c @@ -24,7 +24,6 @@ #include <esd.h> #include "qemu-common.h" #include "audio.h" -#include <signal.h> #define AUDIO_CAP "esd" #include "audio_int.h" @@ -190,10 +189,6 @@ static int qesd_init_out (HWVoiceOut *hw, struct audsettings *as) ESDVoiceOut *esd = (ESDVoiceOut *) hw; struct audsettings obt_as = *as; int esdfmt = ESD_STREAM | ESD_PLAY; - int err; - sigset_t set, old_set; - - sigfillset (&set); esdfmt |= (as->nchannels == 2) ? ESD_STEREO : ESD_MONO; switch (as->fmt) { @@ -231,43 +226,25 @@ static int qesd_init_out (HWVoiceOut *hw, struct audsettings *as) return -1; } - esd->fd = -1; - err = pthread_sigmask (SIG_BLOCK, &set, &old_set); - if (err) { - qesd_logerr (err, "pthread_sigmask failed\n"); - goto fail1; - } - esd->fd = esd_play_stream (esdfmt, as->freq, conf.dac_host, NULL); if (esd->fd < 0) { qesd_logerr (errno, "esd_play_stream failed\n"); - goto fail2; + goto fail1; } if (audio_pt_init (&esd->pt, qesd_thread_out, esd, AUDIO_CAP, AUDIO_FUNC)) { - goto fail3; - } - - err = pthread_sigmask (SIG_SETMASK, &old_set, NULL); - if (err) { - qesd_logerr (err, "pthread_sigmask(restore) failed\n"); + goto fail2; } return 0; - fail3: + fail2: if (close (esd->fd)) { qesd_logerr (errno, "%s: close on esd socket(%d) failed\n", AUDIO_FUNC, esd->fd); } esd->fd = -1; - fail2: - err = pthread_sigmask (SIG_SETMASK, &old_set, NULL); - if (err) { - qesd_logerr (err, "pthread_sigmask(restore) failed\n"); - } - fail1: qemu_free (esd->pcm_buf); esd->pcm_buf = NULL; @@ -423,10 +400,6 @@ static int qesd_init_in (HWVoiceIn *hw, struct audsettings *as) ESDVoiceIn *esd = (ESDVoiceIn *) hw; struct audsettings obt_as = *as; int esdfmt = ESD_STREAM | ESD_RECORD; - int err; - sigset_t set, old_set; - - sigfillset (&set); esdfmt |= (as->nchannels == 2) ? ESD_STEREO : ESD_MONO; switch (as->fmt) { @@ -461,44 +434,25 @@ static int qesd_init_in (HWVoiceIn *hw, struct audsettings *as) return -1; } - esd->fd = -1; - - err = pthread_sigmask (SIG_BLOCK, &set, &old_set); - if (err) { - qesd_logerr (err, "pthread_sigmask failed\n"); - goto fail1; - } - esd->fd = esd_record_stream (esdfmt, as->freq, conf.adc_host, NULL); if (esd->fd < 0) { qesd_logerr (errno, "esd_record_stream failed\n"); - goto fail2; + goto fail1; } if (audio_pt_init (&esd->pt, qesd_thread_in, esd, AUDIO_CAP, AUDIO_FUNC)) { - goto fail3; - } - - err = pthread_sigmask (SIG_SETMASK, &old_set, NULL); - if (err) { - qesd_logerr (err, "pthread_sigmask(restore) failed\n"); + goto fail2; } return 0; - fail3: + fail2: if (close (esd->fd)) { qesd_logerr (errno, "%s: close on esd socket(%d) failed\n", AUDIO_FUNC, esd->fd); } esd->fd = -1; - fail2: - err = pthread_sigmask (SIG_SETMASK, &old_set, NULL); - if (err) { - qesd_logerr (err, "pthread_sigmask(restore) failed\n"); - } - fail1: qemu_free (esd->pcm_buf); esd->pcm_buf = NULL; diff --git a/audio/sdlaudio.c b/audio/sdlaudio.c index c353016c1..b74dcfa73 100644 --- a/audio/sdlaudio.c +++ b/audio/sdlaudio.c @@ -184,11 +184,20 @@ static int sdl_open (SDL_AudioSpec *req, SDL_AudioSpec *obt) { int status; #ifndef _WIN32 + int err; sigset_t new, old; /* Make sure potential threads created by SDL don't hog signals. */ - sigfillset (&new); - pthread_sigmask (SIG_BLOCK, &new, &old); + err = sigfillset (&new); + if (err) { + dolog ("sdl_open: sigfillset failed: %s\n", strerror (errno)); + return -1; + } + err = pthread_sigmask (SIG_BLOCK, &new, &old); + if (err) { + dolog ("sdl_open: pthread_sigmask failed: %s\n", strerror (err)); + return -1; + } #endif status = SDL_OpenAudio (req, obt); @@ -197,7 +206,14 @@ static int sdl_open (SDL_AudioSpec *req, SDL_AudioSpec *obt) } #ifndef _WIN32 - pthread_sigmask (SIG_SETMASK, &old, NULL); + err = pthread_sigmask (SIG_SETMASK, &old, NULL); + if (err) { + dolog ("sdl_open: pthread_sigmask (restore) failed: %s\n", + strerror (errno)); + /* We have failed to restore original signal mask, all bets are off, + so exit the process */ + exit (EXIT_FAILURE); + } #endif return status; } diff --git a/block-migration.c b/block-migration.c index 8eda307d7..0bfdb73c8 100644 --- a/block-migration.c +++ b/block-migration.c @@ -346,7 +346,7 @@ static int mig_save_device_dirty(Monitor *mon, QEMUFile *f, blk->iov.iov_len = nr_sectors * BDRV_SECTOR_SIZE; qemu_iovec_init_external(&blk->qiov, &blk->iov, 1); - blk->time = qemu_get_clock_ns(rt_clock); + blk->time = qemu_get_clock_ns(rt_clock); blk->aiocb = bdrv_aio_readv(bmds->bs, sector, &blk->qiov, nr_sectors, blk_mig_read_cb, blk); @@ -449,13 +449,13 @@ static int is_stage2_completed(void) if (block_mig_state.bulk_completed == 1) { remaining_dirty = get_remaining_dirty(); - if (remaining_dirty == 0) { - return 1; - } + if (remaining_dirty == 0) { + return 1; + } - bwidth = compute_read_bwidth(); + bwidth = compute_read_bwidth(); - if ((remaining_dirty / bwidth) <= + if ((remaining_dirty / bwidth) <= migrate_max_downtime()) { /* finish stage2 because we think that we can finish remaing work below max_downtime */ @@ -739,14 +739,16 @@ int bdrv_check(BlockDriverState *bs, BdrvCheckResult *res) return bs->drv->bdrv_check(bs, res); } +#define COMMIT_BUF_SECTORS 2048 + /* commit COW file into the raw image */ int bdrv_commit(BlockDriverState *bs) { BlockDriver *drv = bs->drv; - int64_t i, total_sectors; - int n, j, ro, open_flags; + int64_t sector, total_sectors; + int n, ro, open_flags; int ret = 0, rw_ret = 0; - unsigned char sector[BDRV_SECTOR_SIZE]; + uint8_t *buf; char filename[1024]; BlockDriverState *bs_rw, *bs_ro; @@ -789,22 +791,20 @@ int bdrv_commit(BlockDriverState *bs) } total_sectors = bdrv_getlength(bs) >> BDRV_SECTOR_BITS; - for (i = 0; i < total_sectors;) { - if (drv->bdrv_is_allocated(bs, i, 65536, &n)) { - for(j = 0; j < n; j++) { - if (bdrv_read(bs, i, sector, 1) != 0) { - ret = -EIO; - goto ro_cleanup; - } + buf = qemu_malloc(COMMIT_BUF_SECTORS * BDRV_SECTOR_SIZE); - if (bdrv_write(bs->backing_hd, i, sector, 1) != 0) { - ret = -EIO; - goto ro_cleanup; - } - i++; - } - } else { - i += n; + for (sector = 0; sector < total_sectors; sector += n) { + if (drv->bdrv_is_allocated(bs, sector, COMMIT_BUF_SECTORS, &n)) { + + if (bdrv_read(bs, sector, buf, n) != 0) { + ret = -EIO; + goto ro_cleanup; + } + + if (bdrv_write(bs->backing_hd, sector, buf, n) != 0) { + ret = -EIO; + goto ro_cleanup; + } } } @@ -821,6 +821,7 @@ int bdrv_commit(BlockDriverState *bs) bdrv_flush(bs->backing_hd); ro_cleanup: + qemu_free(buf); if (ro) { /* re-open as RO */ @@ -1476,10 +1477,8 @@ int bdrv_has_zero_init(BlockDriverState *bs) { assert(bs->drv); - if (bs->drv->no_zero_init) { - return 0; - } else if (bs->file) { - return bdrv_has_zero_init(bs->file); + if (bs->drv->bdrv_has_zero_init) { + return bs->drv->bdrv_has_zero_init(bs); } return 1; @@ -2518,7 +2517,7 @@ int bdrv_is_inserted(BlockDriverState *bs) if (!drv) return 0; if (!drv->bdrv_is_inserted) - return 1; + return !bs->tray_open; ret = drv->bdrv_is_inserted(bs); return ret; } @@ -2560,10 +2559,11 @@ int bdrv_eject(BlockDriverState *bs, int eject_flag) ret = drv->bdrv_eject(bs, eject_flag); } if (ret == -ENOTSUP) { - if (eject_flag) - bdrv_close(bs); ret = 0; } + if (ret >= 0) { + bs->tray_open = eject_flag; + } return ret; } diff --git a/block/raw-posix.c b/block/raw-posix.c index b72a08256..af47e82d5 100644 --- a/block/raw-posix.c +++ b/block/raw-posix.c @@ -995,6 +995,11 @@ static int hdev_create(const char *filename, QEMUOptionParameter *options) return ret; } +static int hdev_has_zero_init(BlockDriverState *bs) +{ + return 0; +} + static BlockDriver bdrv_host_device = { .format_name = "host_device", .protocol_name = "host_device", @@ -1004,7 +1009,7 @@ static BlockDriver bdrv_host_device = { .bdrv_close = raw_close, .bdrv_create = hdev_create, .create_options = raw_create_options, - .no_zero_init = 1, + .bdrv_has_zero_init = hdev_has_zero_init, .bdrv_flush = raw_flush, .bdrv_aio_readv = raw_aio_readv, @@ -1119,7 +1124,7 @@ static BlockDriver bdrv_host_floppy = { .bdrv_close = raw_close, .bdrv_create = hdev_create, .create_options = raw_create_options, - .no_zero_init = 1, + .bdrv_has_zero_init = hdev_has_zero_init, .bdrv_flush = raw_flush, .bdrv_aio_readv = raw_aio_readv, @@ -1219,7 +1224,7 @@ static BlockDriver bdrv_host_cdrom = { .bdrv_close = raw_close, .bdrv_create = hdev_create, .create_options = raw_create_options, - .no_zero_init = 1, + .bdrv_has_zero_init = hdev_has_zero_init, .bdrv_flush = raw_flush, .bdrv_aio_readv = raw_aio_readv, @@ -1342,7 +1347,7 @@ static BlockDriver bdrv_host_cdrom = { .bdrv_close = raw_close, .bdrv_create = hdev_create, .create_options = raw_create_options, - .no_zero_init = 1, + .bdrv_has_zero_init = hdev_has_zero_init, .bdrv_flush = raw_flush, .bdrv_aio_readv = raw_aio_readv, diff --git a/block/raw-win32.c b/block/raw-win32.c index 745bbde67..503ed3959 100644 --- a/block/raw-win32.c +++ b/block/raw-win32.c @@ -394,6 +394,11 @@ static int raw_set_locked(BlockDriverState *bs, int locked) } #endif +static int hdev_has_zero_init(BlockDriverState *bs) +{ + return 0; +} + static BlockDriver bdrv_host_device = { .format_name = "host_device", .protocol_name = "host_device", @@ -402,6 +407,7 @@ static BlockDriver bdrv_host_device = { .bdrv_file_open = hdev_open, .bdrv_close = raw_close, .bdrv_flush = raw_flush, + .bdrv_has_zero_init = hdev_has_zero_init, .bdrv_read = raw_read, .bdrv_write = raw_write, diff --git a/block/raw.c b/block/raw.c index 1414e777b..61e674856 100644 --- a/block/raw.c +++ b/block/raw.c @@ -237,6 +237,11 @@ static QEMUOptionParameter raw_create_options[] = { { NULL } }; +static int raw_has_zero_init(BlockDriverState *bs) +{ + return bdrv_has_zero_init(bs->file); +} + static BlockDriver bdrv_raw = { .format_name = "raw", @@ -264,6 +269,7 @@ static BlockDriver bdrv_raw = { .bdrv_create = raw_create, .create_options = raw_create_options, + .bdrv_has_zero_init = raw_has_zero_init, }; static void bdrv_raw_init(void) diff --git a/block_int.h b/block_int.h index f075a8cba..b86345177 100644 --- a/block_int.h +++ b/block_int.h @@ -127,8 +127,11 @@ struct BlockDriver { void (*bdrv_debug_event)(BlockDriverState *bs, BlkDebugEvent event); - /* Set if newly created images are not guaranteed to contain only zeros */ - int no_zero_init; + /* + * Returns 1 if newly created images are guaranteed to contain only + * zeros, 0 otherwise. + */ + int (*bdrv_has_zero_init)(BlockDriverState *bs); QLIST_ENTRY(BlockDriver) list; }; @@ -141,6 +144,7 @@ struct BlockDriverState { int open_flags; /* flags used to open the file, re-used for re-open */ int removable; /* if true, the media can be removed */ int locked; /* if true, the media cannot temporarily be ejected */ + int tray_open; /* if true, the virtual tray is open */ int encrypted; /* if true, the media is encrypted */ int valid_key; /* if true, a valid encryption key has been set */ int sg; /* if true, the device is a /dev/sg* */ diff --git a/cpu-common.h b/cpu-common.h index f430f2d35..81e824cf7 100644 --- a/cpu-common.h +++ b/cpu-common.h @@ -40,7 +40,7 @@ static inline void cpu_register_physical_memory(target_phys_addr_t start_addr, } ram_addr_t cpu_get_physical_page_desc(target_phys_addr_t addr); -ram_addr_t qemu_ram_map(DeviceState *dev, const char *name, +ram_addr_t qemu_ram_alloc_from_ptr(DeviceState *dev, const char *name, ram_addr_t size, void *host); ram_addr_t qemu_ram_alloc(DeviceState *dev, const char *name, ram_addr_t size); void qemu_ram_unmap(ram_addr_t addr); diff --git a/cpu-exec.c b/cpu-exec.c index 0a030da7d..a518d766d 100644 --- a/cpu-exec.c +++ b/cpu-exec.c @@ -455,7 +455,7 @@ int cpu_exec(CPUState *env1) } #elif defined(TARGET_MIPS) if ((interrupt_request & CPU_INTERRUPT_HARD) && - (env->CP0_Status & env->CP0_Cause & CP0Ca_IP_mask) && + cpu_mips_hw_interrupts_pending(env) && (env->CP0_Status & (1 << CP0St_IE)) && !(env->CP0_Status & (1 << CP0St_EXL)) && !(env->CP0_Status & (1 << CP0St_ERL)) && @@ -2824,7 +2824,7 @@ static ram_addr_t last_ram_offset(void) return last; } -ram_addr_t qemu_ram_map(DeviceState *dev, const char *name, +ram_addr_t qemu_ram_alloc_from_ptr(DeviceState *dev, const char *name, ram_addr_t size, void *host) { RAMBlock *new_block, *block; diff --git a/hw/device-assignment.c b/hw/device-assignment.c index 3bb7f0b24..bab6d91c9 100644 --- a/hw/device-assignment.c +++ b/hw/device-assignment.c @@ -584,7 +584,8 @@ static int assigned_dev_register_regions(PCIRegion *io_regions, snprintf(name, sizeof(name), "%s.bar%d", pci_dev->dev.qdev.info->name, i); pci_dev->v_addrs[i].memory_index = - qemu_ram_map(&pci_dev->dev.qdev, + qemu_ram_alloc_from_ptr( + &pci_dev->dev.qdev, name, cur_region->size, virtbase); } else diff --git a/hw/ide/pci.c b/hw/ide/pci.c index 4331d7723..ec90f266e 100644 --- a/hw/ide/pci.c +++ b/hw/ide/pci.c @@ -40,8 +40,27 @@ void bmdma_cmd_writeb(void *opaque, uint32_t addr, uint32_t val) printf("%s: 0x%08x\n", __func__, val); #endif if (!(val & BM_CMD_START)) { - /* XXX: do it better */ - ide_dma_cancel(bm); + /* + * We can't cancel Scatter Gather DMA in the middle of the + * operation or a partial (not full) DMA transfer would reach + * the storage so we wait for completion instead (we beahve + * like if the DMA was completed by the time the guest trying + * to cancel dma with bmdma_cmd_writeb with BM_CMD_START not + * set). + * + * In the future we'll be able to safely cancel the I/O if the + * whole DMA operation will be submitted to disk with a single + * aio operation with preadv/pwritev. + */ + if (bm->aiocb) { + qemu_aio_flush(); +#ifdef DEBUG_IDE + if (bm->aiocb) + printf("ide_dma_cancel: aiocb still pending"); + if (bm->status & BM_STATUS_DMAING) + printf("ide_dma_cancel: BM_STATUS_DMAING still pending"); +#endif + } bm->cmd = val & 0x09; } else { if (!(bm->status & BM_STATUS_DMAING)) { diff --git a/hw/slavio_timer.c b/hw/slavio_timer.c index d7875536b..c125de4b6 100644 --- a/hw/slavio_timer.c +++ b/hw/slavio_timer.c @@ -377,12 +377,12 @@ static void slavio_timer_reset(DeviceState *d) curr_timer->limit = 0; curr_timer->count = 0; curr_timer->reached = 0; - if (i < s->num_cpus) { + if (i <= s->num_cpus) { ptimer_set_limit(curr_timer->timer, LIMIT_TO_PERIODS(TIMER_MAX_COUNT32), 1); ptimer_run(curr_timer->timer, 0); + curr_timer->running = 1; } - curr_timer->running = 1; } s->cputimer_mode = 0; } diff --git a/hw/sun4m.c b/hw/sun4m.c index e7a4cf6c9..a1373d407 100644 --- a/hw/sun4m.c +++ b/hw/sun4m.c @@ -978,8 +978,11 @@ static void sun4m_hw_init(const struct sun4m_hwdef *hwdef, ram_addr_t RAM_size, fw_cfg_add_bytes(fw_cfg, FW_CFG_CMDLINE_DATA, (uint8_t*)strdup(kernel_cmdline), strlen(kernel_cmdline) + 1); + fw_cfg_add_i32(fw_cfg, FW_CFG_CMDLINE_SIZE, + strlen(kernel_cmdline) + 1); } else { fw_cfg_add_i32(fw_cfg, FW_CFG_KERNEL_CMDLINE, 0); + fw_cfg_add_i32(fw_cfg, FW_CFG_CMDLINE_SIZE, 0); } fw_cfg_add_i32(fw_cfg, FW_CFG_INITRD_ADDR, INITRD_LOAD_ADDR); fw_cfg_add_i32(fw_cfg, FW_CFG_INITRD_SIZE, 0); // not used diff --git a/linux-user/syscall_defs.h b/linux-user/syscall_defs.h index 46cb05ea9..6c57e2481 100644 --- a/linux-user/syscall_defs.h +++ b/linux-user/syscall_defs.h @@ -1282,7 +1282,10 @@ struct target_stat { /* FIXME: Microblaze no-mmu user-space has a difference stat64 layout... */ struct __attribute__((__packed__)) target_stat64 { uint64_t st_dev; - uint64_t st_ino; +#define TARGET_STAT64_HAS_BROKEN_ST_INO 1 + uint32_t pad0; + uint32_t __st_ino; + uint32_t st_mode; uint32_t st_nlink; uint32_t st_uid; @@ -1296,13 +1299,12 @@ struct __attribute__((__packed__)) target_stat64 { int64_t st_blocks; /* Number 512-byte blocks allocated. */ int target_st_atime; - unsigned int target_st_atime_nsec; + unsigned int target_st_atime_nsec; int target_st_mtime; - unsigned int target_st_mtime_nsec; + unsigned int target_st_mtime_nsec; int target_st_ctime; - unsigned int target_st_ctime_nsec; - uint32_t __unused4; - uint32_t __unused5; + unsigned int target_st_ctime_nsec; + uint64_t st_ino; }; #elif defined(TARGET_M68K) @@ -2303,8 +2303,9 @@ static void do_loadvm(Monitor *mon, const QDict *qdict) vm_stop(0); - if (load_vmstate(name) >= 0 && saved_vm_running) + if (load_vmstate(name) == 0 && saved_vm_running) { vm_start(); + } } int monitor_get_fd(Monitor *mon, const char *fdname) @@ -1917,12 +1917,27 @@ void do_savevm(Monitor *mon, const QDict *qdict) int load_vmstate(const char *name) { - BlockDriverState *bs, *bs1; + BlockDriverState *bs, *bs_vm_state; QEMUSnapshotInfo sn; QEMUFile *f; int ret; - /* Verify if there is a device that doesn't support snapshots and is writable */ + bs_vm_state = bdrv_snapshots(); + if (!bs_vm_state) { + error_report("No block device supports snapshots"); + return -ENOTSUP; + } + + /* Don't even try to load empty VM states */ + ret = bdrv_snapshot_find(bs_vm_state, &sn, name); + if (ret < 0) { + return ret; + } else if (sn.vm_state_size == 0) { + return -EINVAL; + } + + /* Verify if there is any device that doesn't support snapshots and is + writable and check if the requested snapshot is available too. */ bs = NULL; while ((bs = bdrv_next(bs))) { @@ -1935,63 +1950,45 @@ int load_vmstate(const char *name) bdrv_get_device_name(bs)); return -ENOTSUP; } - } - bs = bdrv_snapshots(); - if (!bs) { - error_report("No block device supports snapshots"); - return -EINVAL; + ret = bdrv_snapshot_find(bs, &sn, name); + if (ret < 0) { + error_report("Device '%s' does not have the requested snapshot '%s'", + bdrv_get_device_name(bs), name); + return ret; + } } /* Flush all IO requests so they don't interfere with the new state. */ qemu_aio_flush(); - bs1 = NULL; - while ((bs1 = bdrv_next(bs1))) { - if (bdrv_can_snapshot(bs1)) { - ret = bdrv_snapshot_goto(bs1, name); + bs = NULL; + while ((bs = bdrv_next(bs))) { + if (bdrv_can_snapshot(bs)) { + ret = bdrv_snapshot_goto(bs, name); if (ret < 0) { - switch(ret) { - case -ENOTSUP: - error_report("%sSnapshots not supported on device '%s'", - bs != bs1 ? "Warning: " : "", - bdrv_get_device_name(bs1)); - break; - case -ENOENT: - error_report("%sCould not find snapshot '%s' on device '%s'", - bs != bs1 ? "Warning: " : "", - name, bdrv_get_device_name(bs1)); - break; - default: - error_report("%sError %d while activating snapshot on '%s'", - bs != bs1 ? "Warning: " : "", - ret, bdrv_get_device_name(bs1)); - break; - } - /* fatal on snapshot block device */ - if (bs == bs1) - return 0; + error_report("Error %d while activating snapshot '%s' on '%s'", + ret, name, bdrv_get_device_name(bs)); + return ret; } } } - /* Don't even try to load empty VM states */ - ret = bdrv_snapshot_find(bs, &sn, name); - if ((ret >= 0) && (sn.vm_state_size == 0)) - return -EINVAL; - /* restore the VM state */ - f = qemu_fopen_bdrv(bs, 0); + f = qemu_fopen_bdrv(bs_vm_state, 0); if (!f) { error_report("Could not open VM state file"); return -EINVAL; } + ret = qemu_loadvm_state(f); + qemu_fclose(f); if (ret < 0) { error_report("Error %d while loading VM state", ret); return ret; } + return 0; } diff --git a/target-mips/cpu.h b/target-mips/cpu.h index b8e6feefc..19511d7f0 100644 --- a/target-mips/cpu.h +++ b/target-mips/cpu.h @@ -525,6 +525,29 @@ static inline void cpu_clone_regs(CPUState *env, target_ulong newsp) env->active_tc.gpr[2] = 0; } +static inline int cpu_mips_hw_interrupts_pending(CPUState *env) +{ + int32_t pending; + int32_t status; + int r; + + pending = env->CP0_Cause & CP0Ca_IP_mask; + status = env->CP0_Status & CP0Ca_IP_mask; + + if (env->CP0_Config3 & (1 << CP0C3_VEIC)) { + /* A MIPS configured with a vectorizing external interrupt controller + will feed a vector into the Cause pending lines. The core treats + the status lines as a vector level, not as indiviual masks. */ + r = pending > status; + } else { + /* A MIPS configured with compatibility or VInt (Vectored Interrupts) + treats the pending lines as individual interrupt lines, the status + lines are individual masks. */ + r = pending & status; + } + return r; +} + #include "cpu-all.h" /* Memory access type : diff --git a/target-mips/helper.c b/target-mips/helper.c index de2ed7d2c..bdc1e5366 100644 --- a/target-mips/helper.c +++ b/target-mips/helper.c @@ -478,6 +478,33 @@ void do_interrupt (CPUState *env) cause = 0; if (env->CP0_Cause & (1 << CP0Ca_IV)) offset = 0x200; + + if (env->CP0_Config3 & ((1 << CP0C3_VInt) | (1 << CP0C3_VEIC))) { + /* Vectored Interrupts. */ + unsigned int spacing; + unsigned int vector; + unsigned int pending = (env->CP0_Cause & CP0Ca_IP_mask) >> 8; + + /* Compute the Vector Spacing. */ + spacing = (env->CP0_IntCtl >> CP0IntCtl_VS) & ((1 << 6) - 1); + spacing <<= 5; + + if (env->CP0_Config3 & (1 << CP0C3_VInt)) { + /* For VInt mode, the MIPS computes the vector internally. */ + for (vector = 0; vector < 8; vector++) { + if (pending & 1) { + /* Found it. */ + break; + } + pending >>= 1; + } + } else { + /* For VEIC mode, the external interrupt controller feeds the + vector throught the CP0Cause IP lines. */ + vector = pending; + } + offset = 0x200 + vector * spacing; + } goto set_EPC; case EXCP_LTLBL: cause = 1; |