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)
|
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",
|