qemu-vmsr-helper: fix socket loop breakage

Between v5 and v6 of the series, the socket loop of qemu-vmsr-helper was changed to
allow sending multiple requests on the same socket.  Unfortunately, the condition
of the while loop is botched and the loop will never be entered.  Clean it up, and
also unify the handling of error reporting.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
This commit is contained in:
Paolo Bonzini 2024-07-30 17:55:37 +02:00
parent 6e623af301
commit 768a28394c
1 changed files with 9 additions and 7 deletions

View File

@ -227,19 +227,17 @@ static void coroutine_fn vh_co_entry(void *opaque)
&peer_pid, &peer_pid,
&local_err); &local_err);
if (r < 0) { if (r < 0) {
error_report_err(local_err);
goto out; goto out;
} }
while (r < 0) { for (;;) {
/* /*
* Read the requested MSR * Read the requested MSR
* Only RAPL MSR in rapl-msr-index.h is allowed * Only RAPL MSR in rapl-msr-index.h is allowed
*/ */
r = qio_channel_read_all(QIO_CHANNEL(client->ioc), r = qio_channel_read_all_eof(QIO_CHANNEL(client->ioc),
(char *) &request, sizeof(request), &local_err); (char *) &request, sizeof(request), &local_err);
if (r < 0) { if (r <= 0) {
error_report_err(local_err);
break; break;
} }
@ -261,11 +259,15 @@ static void coroutine_fn vh_co_entry(void *opaque)
sizeof(vmsr), sizeof(vmsr),
&local_err); &local_err);
if (r < 0) { if (r < 0) {
error_report_err(local_err);
break; break;
} }
} }
out: out:
if (local_err) {
error_report_err(local_err);
}
object_unref(OBJECT(client->ioc)); object_unref(OBJECT(client->ioc));
g_free(client); g_free(client);
} }