void migrate_fd_put_ready(void *opaque) { FdMigrationState *s = opaque; if (s->state != MIG_STATE_ACTIVE) { DPRINTF("put_ready returning because of non-active state\n"); return; } DPRINTF("iterate\n"); if (qemu_savevm_state_iterate(s->mon, s->file) == 1) { int state; int old_vm_running = vm_running; DPRINTF("done iterating\n"); vm_stop(0); qemu_aio_flush(); bdrv_flush_all(); if ((qemu_savevm_state_complete(s->mon, s->file)) < 0) { if (old_vm_running) { vm_start(); } state = MIG_STATE_ERROR; } else { state = MIG_STATE_COMPLETED; } migrate_fd_cleanup(s); s->state = state; } }
void do_savevm(const char *name) { QEMUFile *f; int saved_vm_running, ret; f = qemu_fopen(name, "wb"); /* ??? Should this occur after vm_stop? */ qemu_aio_flush(); saved_vm_running = vm_running; vm_stop(0); if (!f) { fprintf(logfile, "Failed to open savevm file '%s'\n", name); goto the_end; } ret = qemu_savevm_state(f); qemu_fclose(f); if (ret < 0) fprintf(logfile, "Error %d while writing VM to savevm file '%s'\n", ret, name); the_end: if (saved_vm_running) vm_start(); return; }
static void virtio_blk_reset(VirtIODevice *vdev) { /* * This should cancel pending requests, but can't do nicely until there * are per-device request lists. */ qemu_aio_flush(); }
static void do_vm_stop(int reason) { if (vm_running) { cpu_disable_ticks(); vm_running = 0; pause_all_vcpus(); vm_state_notify(0, reason); qemu_aio_flush(); bdrv_flush_all(); monitor_protocol_event(QEVENT_STOP, NULL); } }
static void do_vm_stop(RunState state) { if (runstate_is_running()) { cpu_disable_ticks(); pause_all_vcpus(); runstate_set(state); vm_state_notify(0, state); qemu_aio_flush(); bdrv_flush_all(); monitor_protocol_event(QEVENT_STOP, NULL); } }
static void platform_fixed_ioport_writew(void *opaque, uint32_t addr, uint32_t val) { PCIXenPlatformState *s = opaque; switch (addr - XEN_PLATFORM_IOPORT) { case 0: /* Unplug devices. Value is a bitmask of which devices to unplug, with bit 0 the IDE devices, bit 1 the network devices, and bit 2 the non-primary-master IDE devices. */ if (val & UNPLUG_ALL_IDE_DISKS) { DPRINTF("unplug disks\n"); qemu_aio_flush(); bdrv_flush_all(); pci_unplug_disks(s->pci_dev.bus); } if (val & UNPLUG_ALL_NICS) { DPRINTF("unplug nics\n"); pci_unplug_nics(s->pci_dev.bus); } if (val & UNPLUG_AUX_IDE_DISKS) { DPRINTF("unplug auxiliary disks not supported\n"); } break; case 2: switch (val) { case 1: DPRINTF("Citrix Windows PV drivers loaded in guest\n"); break; case 0: DPRINTF("Guest claimed to be running PV product 0?\n"); break; default: DPRINTF("Unknown PV product %d loaded in guest\n", val); break; } s->driver_product_version = val; break; } }
void do_loadvm(const char *name) { QEMUFile *f; int saved_vm_running, ret; /* Flush all IO requests so they don't interfere with the new state. */ qemu_aio_flush(); saved_vm_running = vm_running; vm_stop(0); /* restore the VM state */ f = qemu_fopen(name, "rb"); if (!f) { fprintf(logfile, "Could not open VM state file\n"); goto the_end; } ret = qemu_loadvm_state(f); qemu_fclose(f); if (ret < 0) { fprintf(logfile, "Error %d while loading savevm file '%s'\n", ret, name); goto the_end; } #if 0 /* del tmp file */ if (unlink(name) == -1) fprintf(stderr, "delete tmp qemu state file failed.\n"); #endif the_end: if (saved_vm_running) vm_start(); }
int main(int argc, char **argv) { int readonly = 0; int growable = 0; const char *sopt = "hVc:rsnmgk"; const struct option lopt[] = { { "help", 0, NULL, 'h' }, { "version", 0, NULL, 'V' }, { "offset", 1, NULL, 'o' }, { "cmd", 1, NULL, 'c' }, { "read-only", 0, NULL, 'r' }, { "snapshot", 0, NULL, 's' }, { "nocache", 0, NULL, 'n' }, { "misalign", 0, NULL, 'm' }, { "growable", 0, NULL, 'g' }, { "native-aio", 0, NULL, 'k' }, { NULL, 0, NULL, 0 } }; int c; int opt_index = 0; int flags = 0; progname = basename(argv[0]); while ((c = getopt_long(argc, argv, sopt, lopt, &opt_index)) != -1) { switch (c) { case 's': flags |= BDRV_O_SNAPSHOT; break; case 'n': flags |= BDRV_O_NOCACHE; break; case 'c': add_user_command(optarg); break; case 'r': readonly = 1; break; case 'm': misalign = 1; break; case 'g': growable = 1; break; case 'k': flags |= BDRV_O_NATIVE_AIO; break; case 'V': printf("%s version %s\n", progname, VERSION); exit(0); case 'h': usage(progname); exit(0); default: usage(progname); exit(1); } } if ((argc - optind) > 1) { usage(progname); exit(1); } bdrv_init(); /* initialize commands */ quit_init(); help_init(); add_command(&open_cmd); add_command(&close_cmd); add_command(&read_cmd); add_command(&readv_cmd); add_command(&write_cmd); add_command(&writev_cmd); add_command(&multiwrite_cmd); add_command(&aio_read_cmd); add_command(&aio_write_cmd); add_command(&aio_flush_cmd); add_command(&flush_cmd); add_command(&truncate_cmd); add_command(&length_cmd); add_command(&info_cmd); add_command(&alloc_cmd); add_args_command(init_args_command); add_check_command(init_check_command); /* open the device */ if (!readonly) { flags |= BDRV_O_RDWR; } if ((argc - optind) == 1) openfile(argv[optind], flags, growable); command_loop(); /* * Make sure all outstanding requests get flushed the program exits. */ qemu_aio_flush(); if (bs) bdrv_close(bs); return 0; }
static int aio_flush_f(int argc, char **argv) { qemu_aio_flush(); return 0; }