[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PULL 03/11] tools: build qemu-vmsr-helper
From: |
Paolo Bonzini |
Subject: |
Re: [PULL 03/11] tools: build qemu-vmsr-helper |
Date: |
Thu, 25 Jul 2024 12:30:44 +0200 |
On Thu, Jul 25, 2024 at 12:28 PM Peter Maydell <peter.maydell@linaro.org> wrote:
> > + if (r < 0) {
> > + error_report_err(local_err);
> > + goto out;
>
> Here we have a check for r < 0 that forces an early exit...
>
> > + }
> > +
> > + while (r < 0) {
>
> ...but then immediately we do a while (r < 0). r cannot be < 0
> here because we just checked that, so this while loop will
> never execute and the whole loop body is dead code.
>
> What was the intention here ?
The intention was to have "while (r >= 0)" which is effectively an
infinite loop.
Paolo
>
>
> > + /*
> > + * Read the requested MSR
> > + * Only RAPL MSR in rapl-msr-index.h is allowed
> > + */
> > + r = qio_channel_read_all(QIO_CHANNEL(client->ioc),
> > + (char *) &request, sizeof(request),
> > &local_err);
> > + if (r < 0) {
> > + error_report_err(local_err);
> > + break;
> > + }
> > +
> > + if (!is_msr_allowed(request[0])) {
> > + error_report("Requested unallowed msr: %d", request[0]);
> > + break;
> > + }
> > +
> > + vmsr = vmsr_read_msr(request[0], request[1]);
> > +
> > + if (!is_tid_present(peer_pid, request[2])) {
> > + error_report("Requested TID not in peer PID: %d %d",
> > + peer_pid, request[2]);
> > + vmsr = 0;
> > + }
> > +
> > + r = qio_channel_write_all(QIO_CHANNEL(client->ioc),
> > + (char *) &vmsr,
> > + sizeof(vmsr),
> > + &local_err);
> > + if (r < 0) {
> > + error_report_err(local_err);
> > + break;
> > + }
> > + }
> > +out:
> > + object_unref(OBJECT(client->ioc));
> > + g_free(client);
> > +}
>
> thanks
> -- PMM
>
- [PULL 00/11] target/i386, HPET changes for QEMU 9.1 soft freeze, Paolo Bonzini, 2024/07/23
- [PULL 01/11] target/i386: do not crash if microvm guest uses SGX CPUID leaves, Paolo Bonzini, 2024/07/23
- [PULL 02/11] qio: add support for SO_PEERCRED for socket channel, Paolo Bonzini, 2024/07/23
- [PULL 03/11] tools: build qemu-vmsr-helper, Paolo Bonzini, 2024/07/23
- [PULL 05/11] hpet: fix and cleanup persistence of interrupt status, Paolo Bonzini, 2024/07/23
- [PULL 04/11] Add support for RAPL MSRs in KVM/Qemu, Paolo Bonzini, 2024/07/23
- [PULL 07/11] hpet: remove unnecessary variable "index", Paolo Bonzini, 2024/07/23
- [PULL 08/11] hpet: place read-only bits directly in "new_val", Paolo Bonzini, 2024/07/23
- [PULL 06/11] hpet: ignore high bits of comparator in 32-bit mode, Paolo Bonzini, 2024/07/23
- [PULL 11/11] hpet: avoid timer storms on periodic timers, Paolo Bonzini, 2024/07/23
- [PULL 09/11] hpet: accept 64-bit reads and writes, Paolo Bonzini, 2024/07/23
- [PULL 10/11] hpet: store full 64-bit target value of the counter, Paolo Bonzini, 2024/07/23
- Re: [PULL 00/11] target/i386, HPET changes for QEMU 9.1 soft freeze, Richard Henderson, 2024/07/23