On Wed, 27 Mar 2019 16:03:47 +0100 Markus Armbruster <arm...@redhat.com> wrote:
> When the user specifies a list of accelerators, we pick the first one > that initializes successfully. Recent commit 1a3ec8c1564 broke that. > Reproducer: > > $ qemu-system-x86_64 --machine accel=xen:tcg > xencall: error: Could not obtain handle on privileged command interface: > No such file or directory > xen be core: xen be core: can't open xen interface > can't open xen interface > qemu-system-x86_64: failed to initialize Xen: Operation not permitted > qemu-system-x86_64: /home/armbru/work/qemu/qom/object.c:436: > object_set_accelerator_compat_props: Assertion `!object_compat_props[0]' > failed. > > Root cause: we register accelerator compat properties even when the > accelerator fails. The failed assertion is > object_set_accelerator_compat_props() telling us off. Fix by calling > it only for the accelerator that succeeded. > > Fixes: 1a3ec8c1564f51628cce10d435a2e22559ea29fd > Signed-off-by: Markus Armbruster <arm...@redhat.com> Reviewed-by: Igor Mammedov <imamm...@redhat.com> > --- > accel/accel.c | 3 ++- > 1 file changed, 2 insertions(+), 1 deletion(-) > > diff --git a/accel/accel.c b/accel/accel.c > index 8deb475b5d..454fef9d92 100644 > --- a/accel/accel.c > +++ b/accel/accel.c > @@ -65,8 +65,9 @@ static int accel_init_machine(AccelClass *acc, MachineState > *ms) > ms->accelerator = NULL; > *(acc->allowed) = false; > object_unref(OBJECT(accel)); > + } else { > + object_set_accelerator_compat_props(acc->compat_props); > } > - object_set_accelerator_compat_props(acc->compat_props); > return ret; > } >