From: Jon Doron <arilou@gmail.com>
To: Emanuele Giuseppe Esposito <eesposit@redhat.com>
Cc: pbonzini@redhat.com, vkuznets@redhat.com, qemu-devel@nongnu.org
Subject: Re: [PATCH v1 4/4] hw: hyperv: Initial commit for Synthetic Debugging device
Date: Wed, 16 Feb 2022 12:28:27 +0200 [thread overview]
Message-ID: <YgzRywoqNvCI759G@jondnuc> (raw)
In-Reply-To: <82d00de9-3784-161d-bb3e-a36940fd9396@redhat.com>
On 16/02/2022, Emanuele Giuseppe Esposito wrote:
>
>> +
>> +static uint16_t handle_recv_msg(HvSynDbg *syndbg, uint64_t outgpa,
>> + uint32_t count, bool is_raw, uint32_t options,
>> + uint64_t timeout, uint32_t *retrieved_count)
>> +{
>> + uint16_t ret;
>> + uint8_t data_buf[TARGET_PAGE_SIZE - UDP_PKT_HEADER_SIZE];
>> + hwaddr out_len;
>> + void *out_data = NULL;
>> + ssize_t recv_byte_count;
>> +
>> + /* TODO: Handle options and timeout */
>> + (void)options;
>> + (void)timeout;
>> +
>> + if (!syndbg->has_data_pending) {
>> + recv_byte_count = 0;
>> + } else {
>> + recv_byte_count = qemu_recv(syndbg->socket, data_buf,
>> + MIN(sizeof(data_buf), count), MSG_WAITALL);
>> + if (recv_byte_count == -1) {
>> + ret = HV_STATUS_INVALID_PARAMETER;
>> + goto cleanup;
>> + }
>> + }
>> +
>> + if (!recv_byte_count) {
>> + *retrieved_count = 0;
>> + ret = HV_STATUS_NO_DATA;
>> + goto cleanup;
>> + }
>> +
>> + set_pending_state(syndbg, false);
>> +
>> + out_len = recv_byte_count;
>> + if (is_raw) {
>> + out_len += UDP_PKT_HEADER_SIZE;
>> + }
>> + out_data = cpu_physical_memory_map(outgpa, &out_len, 1);
>> + if (!out_data) {
>> + ret = HV_STATUS_INSUFFICIENT_MEMORY;
>> + goto cleanup;
>> + }
>> +
>> + if (is_raw &&
>> + !create_udp_pkt(syndbg, out_data,
>> + recv_byte_count + UDP_PKT_HEADER_SIZE,
>> + data_buf, recv_byte_count)) {
>> + ret = HV_STATUS_INSUFFICIENT_MEMORY;
>> + goto cleanup;
>> + } else if (!is_raw) {
>> + memcpy(out_data, data_buf, recv_byte_count);
>> + }
>> +
>> + *retrieved_count = recv_byte_count;
>> + if (is_raw) {
>> + *retrieved_count += UDP_PKT_HEADER_SIZE;
>> + }
>> + ret = HV_STATUS_SUCCESS;
>> +cleanup:
>> + if (out_data) {
>> + cpu_physical_memory_unmap(out_data, out_len, 1, out_len);
>> + }
>
>Same nitpick as done in patch 1, I think you can use more gotos labels
>instead of adding if statements.
>
Done
>> +
>> + return ret;
>> +}
>> +
>
next prev parent reply other threads:[~2022-02-16 10:45 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-02-04 10:07 [PATCH v1 0/4] HyperV: Synthetic Debugging device Jon Doron
2022-02-04 10:07 ` [PATCH v1 1/4] hyperv: SControl is optional to enable SynIc Jon Doron
2022-02-16 9:10 ` Emanuele Giuseppe Esposito
2022-02-16 10:27 ` Jon Doron
2022-02-04 10:07 ` [PATCH v1 2/4] hyperv: Add definitions for syndbg Jon Doron
2022-02-16 9:10 ` Emanuele Giuseppe Esposito
2022-02-16 10:27 ` Jon Doron
2022-02-04 10:07 ` [PATCH v1 3/4] hyperv: Add support to process syndbg commands Jon Doron
2022-02-16 9:10 ` Emanuele Giuseppe Esposito
2022-02-16 10:28 ` Jon Doron
2022-02-04 10:07 ` [PATCH v1 4/4] hw: hyperv: Initial commit for Synthetic Debugging device Jon Doron
2022-02-16 9:11 ` Emanuele Giuseppe Esposito
2022-02-16 10:28 ` Jon Doron [this message]
2022-02-13 7:49 ` [PATCH v1 0/4] HyperV: " Jon Doron
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=YgzRywoqNvCI759G@jondnuc \
--to=arilou@gmail.com \
--cc=eesposit@redhat.com \
--cc=pbonzini@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=vkuznets@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).