Check-in [95a3d4e3ed]
Not logged in
Overview
Comment:Documented snapshot-related subcommands Make vws snapshots work on running vms Improved a bit some help messages
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 95a3d4e3edc48a9a3d2bd743667b941729513cf1
User & Date: vitus on 2019-10-04 09:26:45
Other Links: manifest | tags
Context
2019-10-04
09:28
Typo fix in README.Debian check-in: cb06bb8763 user: vitus tags: trunk
09:26
Documented snapshot-related subcommands Make vws snapshots work on running vms Improved a bit some help messages check-in: 95a3d4e3ed user: vitus tags: trunk
08:37
Make sendkey command send several keys at once. Updated list of keys in the documentation mentioned all alphanumeric keys check-in: 9e38c1fca9 user: vitus tags: trunk
Changes

Modified vws from [750dc8fdb8] to [772ec62123].

578
579
580
581
582
583
584
585
586
587
588
589
590
591
592

593
594
595
596
597
598
599
578
579
580
581
582
583
584



585
586
587
588

589
590
591
592
593
594
595
596







-
-
-




-
+







        os.system("qemu-img create -f qcow2 -b \"%s\" \"%s\"" %
                  (newnames[i], i))
        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
            elif line[0] == '\n':
                lst.append(info)
640
641
642
643
644
645
646
647

648
649
650
651
652
653
654
637
638
639
640
641
642
643

644
645
646
647
648
649
650
651







-
+







def cmd_commit(options):
    """
    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):
            backing = get_backing(drive)
            if backing is None:
951
952
953
954
955
956
957
958
959


960
961
962
963
964

965

966
967

968
969
970
971
972
973
974
948
949
950
951
952
953
954


955
956
957
958
959
960
961
962

963
964

965
966
967
968
969
970
971
972







-
-
+
+





+
-
+

-
+







    # Parse argument
    args = ArgumentParser(description="Manage Virtual Workstations")
    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('-w', "--wait", 
    p.add_argument("--wait", help="wait until all machines would be shoutdown",
                   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")
    p.add_argument('--no-gui', dest='gui', action='store_const', const=False,
                   default=True, help='do not open console window')
1015
1016
1017
1018
1019
1020
1021
1022
1023





1024
1025
1026
1027






1028
1029
1030
1031
1032
1033
1034
1013
1014
1015
1016
1017
1018
1019


1020
1021
1022
1023
1024
1025
1026
1027

1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040







-
-
+
+
+
+
+



-
+
+
+
+
+
+







    p.add_argument('snapname', help='snapshot name')
    p = new_command(cmds, 'revert', help='Revert to snapshot')
    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',
                   const=False, default=True, dest="usb")
    p.add_argument("--size", metavar='size', help="Size of primary disk images",

Modified vws.mkd from [3ea09a860d] to [a1c7e7421a].

322
323
324
325
326
327
328

































329
330
331
332
333
334
335
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368







+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+







**vws usb remove** *machine* [ *pattern* | **--address** *bus.device* ]

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,
produced by virtual machine. One don't need to have GUI window open to
take screenshots.