All of lore.kernel.org
 help / color / mirror / Atom feed
* [Qemu-devel] question about qemu-monitor-event result redirecting to a file
@ 2019-02-26 11:51 Zhan Adlun
  2019-02-26 20:18 ` John Snow
  2019-02-26 20:51 ` Eric Blake
  0 siblings, 2 replies; 3+ messages in thread
From: Zhan Adlun @ 2019-02-26 11:51 UTC (permalink / raw)
  To: jsnow; +Cc: qemu-devel

Dear Sir:
      Sorry to bother you. I use dirty bitmap to do backup in KVM. I could get output from the terminal when I use the command ' virsh qemu-monitor-event DOMAIN --timestamp --loop', but when using ' virsh qemu-monitor-event DOMAIN --timestamp --loop > /file ' to redirect the output to a file, I got nothing both from the terminal and the file. My os version is 'Distributor ID: Ubuntu   Description: Ubuntu 12.04 LTS   Release: 12.04   Codename: precise,Linux version 4.1.0-generic (root@cvknode183) (gcc version 4.6.3 (Ubuntu/Linaro 4.6.3-1ubuntu5) ) #1 SMP Wed Nov 9 02:04:23 CST 2016'. KVM version is 'QEMU emulator version 2.7.1(Debian 1:2.7+dfsg-3)'. Hoping for you reply. Thanks!


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [Qemu-devel] question about qemu-monitor-event result redirecting to a file
  2019-02-26 11:51 [Qemu-devel] question about qemu-monitor-event result redirecting to a file Zhan Adlun
@ 2019-02-26 20:18 ` John Snow
  2019-02-26 20:51 ` Eric Blake
  1 sibling, 0 replies; 3+ messages in thread
From: John Snow @ 2019-02-26 20:18 UTC (permalink / raw)
  To: Zhan Adlun; +Cc: qemu-devel



On 2/26/19 6:51 AM, Zhan Adlun wrote:
> Dear Sir:
>       Sorry to bother you. I use dirty bitmap to do backup in KVM. I could get output from the terminal when I use the command ' virsh qemu-monitor-event DOMAIN --timestamp --loop', but when using ' virsh qemu-monitor-event DOMAIN --timestamp --loop > /file ' to redirect the output to a file, I got nothing both from the terminal and the file. My os version is 'Distributor ID: Ubuntu   Description: Ubuntu 12.04 LTS   Release: 12.04   Codename: precise,Linux version 4.1.0-generic (root@cvknode183) (gcc version 4.6.3 (Ubuntu/Linaro 4.6.3-1ubuntu5) ) #1 SMP Wed Nov 9 02:04:23 CST 2016'. KVM version is 'QEMU emulator version 2.7.1(Debian 1:2.7+dfsg-3)'. Hoping for you reply. Thanks!
> 

Hi, I'm not experienced with how virsh manages its IO streams. The
behavior that you see no output in the file OR the console is strange to
me, though.

If you are using bash (or a bash-alike), try
`virsh ...etc... > file.txt 2>&1`
which should really truly output everything to file, but you may have to
wait for stdout flushes to see it, or you can try:
`virsh ...etc... 2>&2 | tee file.txt`
which will hopefully let you monitor the output as it occurs.

Maybe someone else on list with more knowledge of virsh's behaviors can
comment.

--js

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [Qemu-devel] question about qemu-monitor-event result redirecting to a file
  2019-02-26 11:51 [Qemu-devel] question about qemu-monitor-event result redirecting to a file Zhan Adlun
  2019-02-26 20:18 ` John Snow
@ 2019-02-26 20:51 ` Eric Blake
  1 sibling, 0 replies; 3+ messages in thread
From: Eric Blake @ 2019-02-26 20:51 UTC (permalink / raw)
  To: Zhan Adlun, jsnow; +Cc: qemu-devel

On 2/26/19 5:51 AM, Zhan Adlun wrote:
> Dear Sir:
>       Sorry to bother you. I use dirty bitmap to do backup in KVM. I could get output from the terminal when I use the command ' virsh qemu-monitor-event DOMAIN --timestamp --loop', but when using ' virsh qemu-monitor-event DOMAIN --timestamp --loop > /file ' to redirect the output to a file, I got nothing both from the terminal and the file.

virsh questions may be better asked on the libvirt-users mailing list,
as it is not part of qemu.git.

In your second invocation, you didn't use tee, so that would explain why
you got no output on the terminal. As for nothing in the file, are you
sure that you have a domain event occur during the time that virsh was
running?  But even when you end virsh, you should get a line stating
'events received: N' with the overall results.  The other thing that is
probably going on is that virsh is probably not doing anything special
about output buffering. When you output to a terminal, libc
automatically defaults to line-buffering (every time virsh writes \n,
the full line gets flushed right away); but when you output to a file,
libc's default behavior for stdout is to buffer things in FILE* buffers
until you hit a full buffer's worth, and only then flush (where exiting
virsh will force the flush of any final incomplete buffer), so using
'tail' on the file while virsh is still running in buffered mode will
only see output in bursts of multiple lines once the buffer finally
fills up and spills, rather than as they happen. You can use the
'stdbuf' utility from GNU Coreutils to force virsh into line-buffering
(via tricks with LD_PRELOAD) even when virsh is connected to a file
rather than a terminal.  Or submit a bug report to libvirt asking that
they explicitly set line-buffered output when doing qemu-monitor-event
rather than relying on libc's defaults (I don't know that forcing line
buffering makes sense for all virsh commands, but for ones that are
intended to be long-running and print events as they happen, it may be
worth doing).

Finally, note that the libvirt people declare qemu-monitor-event to be
non-supported (use-at-your-own-risk).  I use it myself when debugging
new features, but wouldn't trust it in production.  What are you really
trying to monitor with that command, and should libvirt itself be taught
to expose that particular event to you in a supported API instead of
forcing you to use the developer's unsupported backdoor monitoring?

-- 
Eric Blake, Principal Software Engineer
Red Hat, Inc.           +1-919-301-3226
Virtualization:  qemu.org | libvirt.org

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2019-02-26 20:51 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-02-26 11:51 [Qemu-devel] question about qemu-monitor-event result redirecting to a file Zhan Adlun
2019-02-26 20:18 ` John Snow
2019-02-26 20:51 ` Eric Blake

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.