Index: vws ================================================================== --- vws +++ vws @@ -211,11 +211,11 @@ Returns either id of this snapshot or None """ nxt = 0 with os.popen("qemu-img info \"%s\"" % - (get_drives(vmdir)[0]), "r") as f: + (os.path.join(vmdir, get_drives(vmdir)[0])), "r") as f: for line in f: if line == 'Snapshot list:\n': nxt = 2 elif nxt == 2 and line.startswith('ID'): nxt = 1 @@ -283,11 +283,11 @@ elif not options.stopped: print("VM already running use uri %s" % uri, file=sys.stderr) def cmd_stop(options): """ vws stop """ - if snapshot_mode(options.sock) or options.hard: + if options.hard or snapshot_mode(options.sock): try: send_command(options.sock, 'quit') except IOError as ex: # Expect IOError here if str(ex).find("EOF from monitor"): @@ -330,11 +330,12 @@ answer = send_command(options.sock, 'savevm') if re.search("Error", answer): print(answer, file=sys.stderr) sys.exit(1) else: - send_command(options.sock, 'quit') + options.hard = True + cmd_stop(options) def cmd_cdrom(options): """ vws cdrom """ if options.id is None: # Search for devices which could be interpreted as CDROM @@ -427,23 +428,27 @@ def make_vm_listing(vmname, dirname, vmtype): """ makes dict with vm properties for short index """ f = {"name":vmname, "type":vmtype} sock = connect_vm(dirname) if sock is None: - f.update({"state":"stopped", "uri":"-", "ip":"-"}) + if check_for_snapshot(dirname): + f['state'] = "sleeping" + else: + f['state'] = 'stopped ' + f.update({"uri":"-", "ip":"-"}) f.update(read_netinfo(os.path.join(dirname, "start"))) else: uri = spiceurl(sock) if uri is None: - f.update({"state":"problem", "uri":"None", "ip":"-"}) + f.update({"state":"problem ", "uri":"None", "ip":"-"}) f.update(read_netinfo(os.path.join(dirname, "start"))) else: f["uri"] = uri[uri.rindex(":")+1:] f.update(get_netinfo(sock)) sock.shutdown(socket.SHUT_RDWR) sock.close() - f["state"] = "running" + f["state"] = "running " return f def add_ip_address(listing): """ Adds IP addresses from ARP into VM listing """