+ guestfs_h *g = (guestfs_h *) data;
+ XDR xdr;
+ unsigned len;
+ int n;
+
+ if (g->verbose)
+ fprintf (stderr,
+ "sock_event: %p g->state = %d, fd = %d, events = 0x%x\n",
+ g, g->state, fd, events);
+
+ if (g->sock != fd) {
+ error (g, "sock_read_event: internal error: %d != %d", g->sock, fd);
+ return;
+ }
+
+ if (g->msg_in_size <= g->msg_in_allocated) {
+ g->msg_in_allocated += 4096;
+ g->msg_in = safe_realloc (g, g->msg_in, g->msg_in_allocated);
+ }
+ n = read (g->sock, g->msg_in + g->msg_in_size,
+ g->msg_in_allocated - g->msg_in_size);
+ if (n == 0)
+ /* Disconnected? Ignore it because stdout_watch will get called
+ * and will do the cleanup.
+ */
+ return;