Index: vws ================================================================== --- vws +++ vws @@ -48,10 +48,12 @@ dummy_greeting = sock.recv(1024) return sock def send_command(sock, command): """ Sends monitor command to given socket and returns answer """ + if sock is None: + raise RuntimeError("None socket is passed to send_command") fcntl.flock(sock, fcntl.LOCK_EX) try: # There can be stray (qemu) prompt in the socket. Try to drain # it try: @@ -185,11 +187,11 @@ from config, if not so """ f = open(filename, "r+") data = f.read() idx0 = data.find("-net bridge,br=") - if idx != -1: + if idx0 != -1: idx = data.find("=", idx0) idx += 1 idx2 = data.find(" ", idx) bridgename = data[idx:idx2] if not bridgename in list_bridges(): @@ -252,18 +254,21 @@ if snapshot_id is not None: arg = arg + " -loadvm " + snapshot_id # Check for correct brige name try: os.stat("monitor") - except OSError: + except FileNotFoundError: # We cannot find monitor socket. So this machine might be # never run on this host fix_bridge_name("start") os.system("./start%s" % arg) os.chdir(cwd) time.sleep(2) options.sock = connect_vm(options.dir) + if options.sock is None: + print("VM start failed", file=sys.stderr) + sys.exit(1) if snapshot_id: send_command(options.sock, "delvm " + snapshot_id) else: if options.snapshot or options.args or options.password: print("Cannot change qemu options. " +