On 05/30/2017 10:24 AM, Juan Quintela wrote: > Vlad Yasevich <vyase...@redhat.com> wrote: >> On 05/30/2017 06:11 AM, Juan Quintela wrote: >>> Vladislav Yasevich <vyase...@redhat.com> wrote: >>>> Add a qmp command that can trigger guest announcements. >>>> >>>> Based on work of Germano Veit Michel <germ...@redhat.com> >>>> >>>> Signed-off-by: Vladislav Yasevich <vyase...@redhat.com> >>>> --- >>>> migration/savevm.c | 14 ++++++++++++++ >>>> qapi-schema.json | 19 +++++++++++++++++++ >>>> 2 files changed, 33 insertions(+) >>>> >>>> diff --git a/migration/savevm.c b/migration/savevm.c >>>> index a4097c9..b55ce6a 100644 >>>> --- a/migration/savevm.c >>>> +++ b/migration/savevm.c >>>> @@ -265,6 +265,20 @@ void qemu_announce_self(AnnounceParameters *params) >>>> qemu_announce_self_once(timer); >>>> } >>>> >>>> +void qmp_announce_self(bool has_params, AnnounceParameters *params, >>>> + Error **errp) >>>> +{ >>>> + AnnounceParameters announce_params; >>>> + >>>> + memcpy(&announce_params, qemu_get_announce_params(), >>>> + sizeof(announce_params)); >>>> + >>>> + if (has_params) >>>> + qemu_set_announce_parameters(&announce_params, params); >>>> + >>>> + qemu_announce_self(&announce_params); >>> >>> Are I missreading qemu_annouce_self()? >>> My reading is that it passes announce_params to a timer (i.e. async >>> function), but here announce_params is a local variable here, no? >>> >> >> The AnnounceTimer holds a copy since each timer may have it's own values. > > > >> AnnounceTimer *qemu_announce_timer_new(AnnounceParameters *params, >> QEMUClockType type) >> { >> AnnounceTimer *timer = g_new(AnnounceTimer, 1); >> >> timer->params = *params; > > I have to remomember that C has learn how to copy structures long ago. > > <repeat myself one hundred times> > > I was missing the "*" on my previous reading, sorry for the noise.
that actually changed, since as Eric Pointed out, shallow copies shouldn't be used. In the v2 code, this uses qemu_set_announce_paramters(), but the copy essentially remains. -vlad > >> timer->round = params->rounds; >> timer->type = type; >> >> return timer; >> } > >