int cbm2_snapshot_write(const char *name, int save_roms, int save_disks, int event_mode) { snapshot_t *s; s = snapshot_create(name, SNAP_MAJOR, SNAP_MINOR, machine_get_name()); if (s == NULL) { return -1; } sound_snapshot_prepare(); if (maincpu_snapshot_write_module(s) < 0 || cbm2_snapshot_write_module(s, save_roms) < 0 || crtc_snapshot_write_module(s) < 0 || ciacore_snapshot_write_module(machine_context.cia1, s) < 0 || tpicore_snapshot_write_module(machine_context.tpi1, s) < 0 || tpicore_snapshot_write_module(machine_context.tpi2, s) < 0 || acia1_snapshot_write_module(s) < 0 || sid_snapshot_write_module(s) < 0 || drive_snapshot_write_module(s, save_disks, save_roms) < 0 || event_snapshot_write_module(s, event_mode) < 0 || tape_snapshot_write_module(s, save_disks) < 0 || keyboard_snapshot_write_module(s) || joystick_snapshot_write_module(s)) { snapshot_close(s); ioutil_remove(name); return -1; } snapshot_close(s); return 0; }
int scpu64_snapshot_write(const char *name, int save_roms, int save_disks, int event_mode) { snapshot_t *s; s = snapshot_create(name, ((BYTE)(SNAP_MAJOR)), ((BYTE)(SNAP_MINOR)), machine_get_name()); if (s == NULL) { return -1; } sound_snapshot_prepare(); /* Execute drive CPUs to get in sync with the main CPU. */ drivecpu_execute_all(maincpu_clk); if (maincpu_snapshot_write_module(s) < 0 || scpu64_snapshot_write_module(s, save_roms) < 0 || ciacore_snapshot_write_module(machine_context.cia1, s) < 0 || ciacore_snapshot_write_module(machine_context.cia2, s) < 0 || sid_snapshot_write_module(s) < 0 || drive_snapshot_write_module(s, save_disks, save_roms) < 0 || vicii_snapshot_write_module(s) < 0 || scpu64_glue_snapshot_write_module(s) < 0 || event_snapshot_write_module(s, event_mode) < 0 || keyboard_snapshot_write_module(s) || joystick_snapshot_write_module(s)) { snapshot_close(s); ioutil_remove(name); return -1; } snapshot_close(s); return 0; }
int c128_snapshot_write(const char *name, int save_roms, int save_disks, int event_mode) { snapshot_t *s; s = snapshot_create(name, ((BYTE)(SNAP_MAJOR)), ((BYTE)(SNAP_MINOR)), SNAP_MACHINE_NAME); if (s == NULL) { return -1; } sound_snapshot_prepare(); if (maincpu_snapshot_write_module(s) < 0 || c128_snapshot_write_module(s, save_roms) < 0 || ciacore_snapshot_write_module(machine_context.cia1, s) < 0 || ciacore_snapshot_write_module(machine_context.cia2, s) < 0 || sid_snapshot_write_module(s) < 0 || drive_snapshot_write_module(s, save_disks, save_roms) < 0 || vicii_snapshot_write_module(s) < 0 || event_snapshot_write_module(s, event_mode) < 0 || tapeport_snapshot_write_module(s, save_disks) < 0 || keyboard_snapshot_write_module(s) < 0 || joyport_snapshot_write_module(s, JOYPORT_1) < 0 || joyport_snapshot_write_module(s, JOYPORT_2) < 0 || userport_snapshot_write_module(s) < 0) { snapshot_close(s); ioutil_remove(name); return -1; } snapshot_close(s); return 0; }
int vic20_snapshot_write(const char *name, int save_roms, int save_disks, int event_mode) { snapshot_t *s; int ieee488; s = snapshot_create(name, ((BYTE)(SNAP_MAJOR)), ((BYTE)(SNAP_MINOR)), machine_name); if (s == NULL) { return -1; } sound_snapshot_prepare(); /* FIXME: Missing sound. */ if (maincpu_snapshot_write_module(s) < 0 || vic20_snapshot_write_module(s, save_roms) < 0 || vic_snapshot_write_module(s) < 0 || viacore_snapshot_write_module(machine_context.via1, s) < 0 || viacore_snapshot_write_module(machine_context.via2, s) < 0 || drive_snapshot_write_module(s, save_disks, save_roms) < 0 || event_snapshot_write_module(s, event_mode) < 0 || tapeport_snapshot_write_module(s, save_disks) < 0 || keyboard_snapshot_write_module(s) < 0 || joyport_snapshot_write_module(s, JOYPORT_1) < 0 || userport_snapshot_write_module(s) < 0) { snapshot_close(s); ioutil_remove(name); return -1; } resources_get_int("IEEE488", &ieee488); if (ieee488) { if (viacore_snapshot_write_module(machine_context.ieeevia1, s) < 0 || viacore_snapshot_write_module(machine_context.ieeevia2, s) < 0) { snapshot_close(s); ioutil_remove(name); return 1; } } snapshot_close(s); return 0; }
/* * ndmp_create_snapshot * * This function will parse the path to get the real volume name. * It will then create a snapshot based on volume and job name. * This function should be called before the NDMP backup is started. * * Parameters: * vol_name (input) - name of the volume * * Returns: * 0: on success * -1: otherwise */ int ndmp_create_snapshot(char *vol_name, char *jname) { char vol[ZFS_MAXNAMELEN]; if (vol_name == 0 || get_zfsvolname(vol, sizeof (vol), vol_name) == -1) return (0); /* * If there is an old snapshot left from the previous * backup it could be stale one and it must be * removed before using it. */ if (ndmp_has_backup_snapshot(vol, jname)) (void) snapshot_destroy(vol, jname, B_FALSE, B_TRUE, NULL); return (snapshot_create(vol, jname, B_FALSE, B_TRUE)); }
int pet_snapshot_write(const char *name, int save_roms, int save_disks, int event_mode) { snapshot_t *s; int ef = 0; s = snapshot_create(name, SNAP_MAJOR, SNAP_MINOR, machine_name); if (s == NULL) { return -1; } sound_snapshot_prepare(); if (maincpu_snapshot_write_module(s) < 0 || cpu6809_snapshot_write_module(s) < 0 || pet_snapshot_write_module(s, save_roms) < 0 || crtc_snapshot_write_module(s) < 0 || pia1_snapshot_write_module(s) < 0 || pia2_snapshot_write_module(s) < 0 || petdww_snapshot_write_module(s) < 0 || viacore_snapshot_write_module(machine_context.via, s) < 0 || drive_snapshot_write_module(s, save_disks, save_roms) < 0 || event_snapshot_write_module(s, event_mode) < 0 || tapeport_snapshot_write_module(s, save_disks) < 0 || keyboard_snapshot_write_module(s) < 0 || userport_snapshot_write_module(s) < 0) { ef = -1; } if ((!ef) && petres.superpet) { ef = acia1_snapshot_write_module(s); } snapshot_close(s); if (ef) { ioutil_remove(name); } return ef; }
int c64dtv_snapshot_write(const char *name, int save_roms, int save_disks, int event_mode) { snapshot_t *s; s = snapshot_create(name, ((BYTE)(SNAP_MAJOR)), ((BYTE)(SNAP_MINOR)), machine_name); if (s == NULL) { return -1; } sound_snapshot_prepare(); /* Execute drive CPUs to get in sync with the main CPU. */ drive_cpu_execute_all(maincpu_clk); if (maincpu_snapshot_write_module(s) < 0 || c64dtv_snapshot_write_module(s, save_roms) < 0 || c64dtvdma_snapshot_write_module(s) < 0 || c64dtvblitter_snapshot_write_module(s) < 0 || c64dtvmisc_snapshot_write_module(s) < 0 || ciacore_snapshot_write_module(machine_context.cia1, s) < 0 || ciacore_snapshot_write_module(machine_context.cia2, s) < 0 || sid_snapshot_write_module(s) < 0 || drive_snapshot_write_module(s, save_disks, save_roms) < 0 || vicii_snapshot_write_module(s) < 0 || event_snapshot_write_module(s, event_mode) < 0 || keyboard_snapshot_write_module(s) < 0 || joyport_snapshot_write_module(s, JOYPORT_1) < 0 || joyport_snapshot_write_module(s, JOYPORT_2) < 0 || userport_snapshot_write_module(s) < 0) { snapshot_close(s); ioutil_remove(name); return -1; } snapshot_close(s); return 0; }
void cpu_snapshot_tick(cpu_snapshot *cpu) { snapshot *snap = 0; if (snapshot_create("/proc/stat", &snap) < 0) { fprintf(stderr, "Failed to save /proc/stat.\n"); snapshot_delete(snap); return; } char const *data = snap->data; char buf[32]; while (data) { uint64_t t1; column(data, 0, buf, 32); /* save the total number of jiffies spent in cpu user+system time */ if (equal(buf, "cpu")) { cpu_save_snapshot_to_history(data, snap->time, cpu->main); } else if (startswith(buf, "cpu")) { int cpu_num = atoi(buf+3); cpu_save_snapshot_to_history(data, snap->time, cpu->cpus[cpu_num]); } /* save the number of context switches */ if (equal(buf, "ctxt")) { column(data, 1, buf, 32); t1 = strtoull(buf, 0, 10); history_append(cpu->ctxt, snap->time, t1); } data = next_line(data); } snapshot_delete(snap); }