Index: vws ================================================================== --- vws +++ vws @@ -580,18 +580,15 @@ os.chmod(i, 0o664) return 0 def cmd_snapshots(options): """ vws snapshots - list existing snapshots """ - if not options.stopped: - print("Cannot list snapshots of running VW", file=sys.stderr) - sys.exit(1) os.chdir(options.dir) drives = get_drives(options.dir) lst = [] info = {} - with os.popen("qemu-img info --backing-chain " + drives[0], "r") as f: + with os.popen("qemu-img info -U --backing-chain " + drives[0], "r") as f: for line in f: if line.find(": ") != -1: var, val = line.strip().split(": ") if val != "": info[var] = val @@ -642,11 +639,11 @@ Commits last snapshot changes into it's backing file There would be one snapshot less for virtual machine """ if options.stopped: # - # Stoppend vm - last snapshot is commited into its backing file. + # Stopped vm - last snapshot is commited into its backing file. # Backing file is made current drive image # os.chdir(options.dir) found = 0 for drive in get_drives(options.dir): @@ -953,20 +950,21 @@ cmds = args.add_subparsers(dest='command', help="sub-command help") p = cmds.add_parser("list", help="List existing VWs", description="List existing VWs") p.add_argument("-l", "--state", const=True, default=False, dest='state', action='store_const', help='Show state of the machine') - p.add_argument("--usb", action='store_const', const=True, default=False, - dest='usb', help='Show connected USB devices') + p.add_argument('-u', "--usb", action='store_const', const=True, + default=False, dest='usb', help='Show connected USB devices') p.add_argument("pattern", nargs='*', default='*', help="Name patterns") p = cmds.add_parser("version", help="show vws version") p = cmds.add_parser("autostart", help="Autostart all VMs marked as autostartable") p = cmds.add_parser("shutdown", help="shut down all running VMs") - p.add_argument("--wait", help="wait until all machines would be shoutdown", + p.add_argument('-w', "--wait", + help="wait until all machines would be shutdown", action="store_const", const=True, default=False, dest="wait") - p.add_argument("--timeout", type=int, default=90, + p.add_argument('-t', "--timeout", type=int, default=90, help="how long to way for VMs shutdown before forcing it off") # Power management p = new_command(cmds, 'start', help='Start VW and connect to console', description="Start VW if not running and connect " + "to the console") @@ -1017,16 +1015,24 @@ p.add_argument('snapname', help='name of snapshot to revert to') p = new_command(cmds, 'commit', help='Commit snapshot changes into backing file') p = new_command(cmds, 'snapshots', help='List existing snapshots') # Screenshoits and recording - p = new_command(cmds, 'screenshot', help='take a screenshot') - p.add_argument('filename', help='PPM image filename to write screenshot to') + p = new_command(cmds, 'screenshot', help='take a screenshot', + description='Takes a screenshot', + epilog="""Writes current screen contents of the virtual machine into PPM format file""") + p.add_argument('filename', metavar='filename.ppm', + help='PPM image filename to write screenshot to') p = new_command(cmds, 'record', help='Record audio output from VM') p.add_argument('filename', help='wav file to record autdio to') new_command(cmds, 'stoprecord', help='stop recording audio') - p = new_command(cmds, 'sendkey', help='Send a keystroke to VM') + p = new_command(cmds, 'sendkey', help='Send a keystroke to VM', + description='Send a key combination into VM', + epilog='Each key combination should be passed as separate' + + 'argument.\nAll non-alphanumeric keys should be passed by' + + 'names, not characters\n(see table in the manual).' + ) p.add_argument('keyspec', help='key specification like ctrl-alt-delete', nargs='+') # Create new VM p = new_command(cmds, 'create', help="Create new VW") p.add_argument("--no-usb", help="Disable USB controller", action='store_const', Index: vws.mkd ================================================================== --- vws.mkd +++ vws.mkd @@ -324,10 +324,43 @@ Detaches USB device. SNAPSHOTS --------- +**vws snapshot** *machine* *name* + +Creates named snapshot. This means that there would be additional image +file for each virtual disks. All writes would go to new file, and +previous file would be unchanged until commit operation. Note that +having long chain of snapshots significantly slower disk IO operations. + +**vws** allows snapshots be made only when virtual machine is stopped. + +**vws** **commit** *machine* + +Writes changes in the current snapshot into previous one. +There would be one snapshot less for this machine after this operation. + +If this operation is performed on stopped machine it operates on stack +of snapshots created by **vws** **snapshot** command. + +If it is performed on running machine, this machine should run in the +snapshot mode (see **start** command for details) and changes made since +start in the snapshot mode are committed into permanent images. + +**vws** **revert** *machine* + +Discard changes made to disks since last **vms snapshot** command +and recreates snapshot. This command can be only performed +on stopped machine. Number of snapshots would be same after this +command. + +**vws** **snapshots** *machine* + +List named snapshots available for given machine. This command +can be used on running machine, despite of that machine must be shutdown +before snapshots could be committed or reverted. MISCELLANEA ----------- **vws** allows to take virtual machine screenshot or record sound,