On Thu, Sep 10, 2015 at 10:18:32PM +0300, Denis V. Lunev wrote: > On 09/10/2015 11:51 AM, Stefan Hajnoczi wrote: > >On Tue, Sep 08, 2015 at 11:00:25AM +0300, Denis V. Lunev wrote: > >>From: Raushaniya Maksudova <rmaksud...@virtuozzo.com> > >> > >>In some cases one needs to pause and resume a Virtual Machine from inside > >>of Qemu. Currently there are request functions to pause VM (vmstop), but > >>there are no respective ones to resume VM. > >> > >>Signed-off-by: Raushaniya Maksudova <rmaksud...@virtuozzo.com> > >>Signed-off-by: Denis V. Lunev <d...@openvz.org> > >>CC: Stefan Hajnoczi <stefa...@redhat.com> > >>CC: Kevin Wolf <kw...@redhat.com> > >>CC: Paolo Bonzini <pbonz...@redhat.com> > >>--- > >> include/sysemu/sysemu.h | 1 + > >> stubs/vm-stop.c | 5 +++++ > >> vl.c | 18 ++++++++++++++++++ > >> 3 files changed, 24 insertions(+) > >Why can't vm_start() be used? > > > > we do fear about correct thread to perform this operation. > this code eventually redirect state changing code into > main event loop.
The code isn't thread-safe though: There is a race condition if qemu_vmstart_requested() is called while qemu_vmstart_request() is called. qemu_vmstart_requested() might return false and the qemu_vmstart_request() is missed. Please add doc comments to these functions explaining assumptions about thread-safety and environment. If the guest is resumed in an I/O completion handler function it probably needs to be truly thread-safe.