QemuOpts: Convert qemu_opt_set_bool() to Error, fix its use

Return the Error object instead of reporting it with
qerror_report_err().

Change callers that assume the function can't fail to pass
&error_abort, so that should the assumption ever break, it'll break
noisily.

Turns out all callers outside its unit test assume that.  We could
drop the Error ** argument, but that would make the interface less
regular, so don't.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
This commit is contained in:
Markus Armbruster 2015-02-12 16:37:44 +01:00
parent c5c6d7f81a
commit cccb7967bd
6 changed files with 19 additions and 18 deletions

View file

@ -169,10 +169,10 @@ static void test_qemu_opt_get(void)
static void test_qemu_opt_get_bool(void)
{
Error *err = NULL;
QemuOptsList *list;
QemuOpts *opts;
bool opt;
int ret;
list = qemu_find_opts("opts_list_02");
g_assert(list != NULL);
@ -192,16 +192,16 @@ static void test_qemu_opt_get_bool(void)
opt = qemu_opt_get_bool(opts, "bool1", false);
g_assert(opt == false);
ret = qemu_opt_set_bool(opts, "bool1", true);
g_assert(ret == 0);
qemu_opt_set_bool(opts, "bool1", true, &err);
g_assert(!err);
/* now we have set bool1, should know about it */
opt = qemu_opt_get_bool(opts, "bool1", false);
g_assert(opt == true);
/* having reset the value, opt should be the reset one not defval */
ret = qemu_opt_set_bool(opts, "bool1", false);
g_assert(ret == 0);
qemu_opt_set_bool(opts, "bool1", false, &err);
g_assert(!err);
opt = qemu_opt_get_bool(opts, "bool1", true);
g_assert(opt == false);