system/cpu-timers: Have icount_configure() return a boolean
Following the example documented since commit e3fe3988d7
("error:
Document Error API usage rules"), have icount_configure()
return a boolean indicating whether an error is set or not.
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Message-ID: <20231208113529.74067-2-philmd@linaro.org>
This commit is contained in:
parent
6adcba7c0a
commit
f07f246734
@ -419,7 +419,7 @@ void icount_account_warp_timer(void)
|
|||||||
icount_warp_rt();
|
icount_warp_rt();
|
||||||
}
|
}
|
||||||
|
|
||||||
void icount_configure(QemuOpts *opts, Error **errp)
|
bool icount_configure(QemuOpts *opts, Error **errp)
|
||||||
{
|
{
|
||||||
const char *option = qemu_opt_get(opts, "shift");
|
const char *option = qemu_opt_get(opts, "shift");
|
||||||
bool sleep = qemu_opt_get_bool(opts, "sleep", true);
|
bool sleep = qemu_opt_get_bool(opts, "sleep", true);
|
||||||
@ -429,27 +429,28 @@ void icount_configure(QemuOpts *opts, Error **errp)
|
|||||||
if (!option) {
|
if (!option) {
|
||||||
if (qemu_opt_get(opts, "align") != NULL) {
|
if (qemu_opt_get(opts, "align") != NULL) {
|
||||||
error_setg(errp, "Please specify shift option when using align");
|
error_setg(errp, "Please specify shift option when using align");
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
return;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (align && !sleep) {
|
if (align && !sleep) {
|
||||||
error_setg(errp, "align=on and sleep=off are incompatible");
|
error_setg(errp, "align=on and sleep=off are incompatible");
|
||||||
return;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (strcmp(option, "auto") != 0) {
|
if (strcmp(option, "auto") != 0) {
|
||||||
if (qemu_strtol(option, NULL, 0, &time_shift) < 0
|
if (qemu_strtol(option, NULL, 0, &time_shift) < 0
|
||||||
|| time_shift < 0 || time_shift > MAX_ICOUNT_SHIFT) {
|
|| time_shift < 0 || time_shift > MAX_ICOUNT_SHIFT) {
|
||||||
error_setg(errp, "icount: Invalid shift value");
|
error_setg(errp, "icount: Invalid shift value");
|
||||||
return;
|
return false;
|
||||||
}
|
}
|
||||||
} else if (icount_align_option) {
|
} else if (icount_align_option) {
|
||||||
error_setg(errp, "shift=auto and align=on are incompatible");
|
error_setg(errp, "shift=auto and align=on are incompatible");
|
||||||
return;
|
return false;
|
||||||
} else if (!icount_sleep) {
|
} else if (!icount_sleep) {
|
||||||
error_setg(errp, "shift=auto and sleep=off are incompatible");
|
error_setg(errp, "shift=auto and sleep=off are incompatible");
|
||||||
return;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
icount_sleep = sleep;
|
icount_sleep = sleep;
|
||||||
@ -463,7 +464,7 @@ void icount_configure(QemuOpts *opts, Error **errp)
|
|||||||
if (time_shift >= 0) {
|
if (time_shift >= 0) {
|
||||||
timers_state.icount_time_shift = time_shift;
|
timers_state.icount_time_shift = time_shift;
|
||||||
icount_enable_precise();
|
icount_enable_precise();
|
||||||
return;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
icount_enable_adaptive();
|
icount_enable_adaptive();
|
||||||
@ -491,6 +492,7 @@ void icount_configure(QemuOpts *opts, Error **errp)
|
|||||||
timer_mod(timers_state.icount_vm_timer,
|
timer_mod(timers_state.icount_vm_timer,
|
||||||
qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL) +
|
qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL) +
|
||||||
NANOSECONDS_PER_SECOND / 10);
|
NANOSECONDS_PER_SECOND / 10);
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void icount_notify_exit(void)
|
void icount_notify_exit(void)
|
||||||
|
@ -50,8 +50,14 @@ int64_t icount_get(void);
|
|||||||
*/
|
*/
|
||||||
int64_t icount_to_ns(int64_t icount);
|
int64_t icount_to_ns(int64_t icount);
|
||||||
|
|
||||||
/* configure the icount options, including "shift" */
|
/**
|
||||||
void icount_configure(QemuOpts *opts, Error **errp);
|
* icount_configure: configure the icount options, including "shift"
|
||||||
|
* @opts: Options to parse
|
||||||
|
* @errp: pointer to a NULL-initialized error object
|
||||||
|
*
|
||||||
|
* Return: true on success, else false setting @errp with error
|
||||||
|
*/
|
||||||
|
bool icount_configure(QemuOpts *opts, Error **errp);
|
||||||
|
|
||||||
/* used by tcg vcpu thread to calc icount budget */
|
/* used by tcg vcpu thread to calc icount budget */
|
||||||
int64_t icount_round(int64_t count);
|
int64_t icount_round(int64_t count);
|
||||||
|
@ -10,10 +10,12 @@ void icount_update(CPUState *cpu)
|
|||||||
{
|
{
|
||||||
abort();
|
abort();
|
||||||
}
|
}
|
||||||
void icount_configure(QemuOpts *opts, Error **errp)
|
bool icount_configure(QemuOpts *opts, Error **errp)
|
||||||
{
|
{
|
||||||
/* signal error */
|
/* signal error */
|
||||||
error_setg(errp, "cannot configure icount, TCG support not available");
|
error_setg(errp, "cannot configure icount, TCG support not available");
|
||||||
|
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
int64_t icount_get_raw(void)
|
int64_t icount_get_raw(void)
|
||||||
{
|
{
|
||||||
|
@ -2270,8 +2270,7 @@ static void user_register_global_props(void)
|
|||||||
|
|
||||||
static int do_configure_icount(void *opaque, QemuOpts *opts, Error **errp)
|
static int do_configure_icount(void *opaque, QemuOpts *opts, Error **errp)
|
||||||
{
|
{
|
||||||
icount_configure(opts, errp);
|
return !icount_configure(opts, errp);
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int accelerator_set_property(void *opaque,
|
static int accelerator_set_property(void *opaque,
|
||||||
|
Loading…
Reference in New Issue
Block a user