Diff
Not logged in

Differences From Artifact [f931d28fe4]:

To Artifact [8e374cbb8b]:


44
45
46
47
48
49
50







51
52
53
54
55
56
57
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64







+
+
+
+
+
+
+







        dummy_greeting = sock.recv(1024)
    return sock

def send_command(sock, command):
    """ Sends monitor command to given socket and returns answer """
    fcntl.flock(sock, fcntl.LOCK_EX)
    try:
        # There can be stray (qemu) prompt in the socket. Try to drain
        # it
        try:
            sock.recv(64,socket.MSG_DONTWAIT)
        except socket.error as e:
             if e.errno != errno.EAGAIN and e.errno!=errno.EWOULDBLOCK:
                raise e
        sock.send(command + "\n")
        answer = ""
        while not answer.endswith("(qemu) "):
            chunk = sock.recv(1024)
            if chunk == '':
                raise IOError("Unexpected EOF from monitor")
            answer += chunk