Skip to content
Snippets Groups Projects
  1. Mar 05, 2017
    • Markus Armbruster's avatar
      qmp: Dumb down how we run QMP command registration · 05875687
      Markus Armbruster authored
      
      The way we get QMP commands registered is high tech:
      
      * qapi-commands.py generates qmp_init_marshal() that does the actual work
      
      * it also generates the magic to register it as a MODULE_INIT_QAPI
        function, so it runs when someone calls
        module_call_init(MODULE_INIT_QAPI)
      
      * main() calls module_call_init()
      
      QEMU needs to register a few non-qapified commands.  Same high tech
      works: monitor.c has its own qmp_init_marshal() along with the magic
      to make it run in module_call_init(MODULE_INIT_QAPI).
      
      QEMU also needs to unregister commands that are not wanted in this
      build's configuration (commit 5032a16d).  Simple enough:
      qmp_unregister_commands_hack().  The difficulty is to make it run
      after the generated qmp_init_marshal().  We can't simply run it in
      monitor.c's qmp_init_marshal(), because the order in which the
      registered functions run is indeterminate.  So qmp_init_marshal()
      registers qmp_unregister_commands_hack() separately.  Since
      registering *appends* to the list of registered functions, this will
      make it run after all the functions that have been registered already.
      
      I suspect it takes a long and expensive computer science education to
      not find this silly.
      
      Dumb it down as follows:
      
      * Drop MODULE_INIT_QAPI entirely
      
      * Give the generated qmp_init_marshal() external linkage.
      
      * Call it instead of module_call_init(MODULE_INIT_QAPI)
      
      * Except in QEMU proper, call new monitor_init_qmp_commands() that in
        turn calls the generated qmp_init_marshal(), registers the
        additional commands and unregisters the unwanted ones.
      
      Signed-off-by: default avatarMarkus Armbruster <armbru@redhat.com>
      Reviewed-by: default avatarEric Blake <eblake@redhat.com>
      Message-Id: <1488544368-30622-5-git-send-email-armbru@redhat.com>
      05875687
  2. Jan 27, 2017
  3. Nov 22, 2016
  4. Oct 28, 2016
  5. Aug 08, 2016
    • Marc-André Lureau's avatar
      monitor: fix crash when leaving qemu with spice audio · 2ef45716
      Marc-André Lureau authored
      
      Since aa5cb7f5, the chardevs are being cleaned up when leaving
      qemu. However, the monitor has still references to them, which may
      lead to crashes when running atexit() and trying to send monitor
      events:
      
       #0  0x00007fffdb18f6f5 in __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:54
       #1  0x00007fffdb1912fa in __GI_abort () at abort.c:89
       #2  0x0000555555c263e7 in error_exit (err=22, msg=0x555555d47980 <__func__.13537> "qemu_mutex_lock") at util/qemu-thread-posix.c:39
       #3  0x0000555555c26488 in qemu_mutex_lock (mutex=0x5555567a2420) at util/qemu-thread-posix.c:66
       #4  0x00005555558c52db in qemu_chr_fe_write (s=0x5555567a2420, buf=0x55555740dc40 "{\"timestamp\": {\"seconds\": 1470041716, \"microseconds\": 989699}, \"event\": \"SPICE_DISCONNECTED\", \"data\": {\"server\": {\"port\": \"5900\", \"family\": \"ipv4\", \"host\": \"127.0.0.1\"}, \"client\": {\"port\": \"40272\", \"f"..., len=240) at qemu-char.c:280
       #5  0x0000555555787cad in monitor_flush_locked (mon=0x5555567bd9e0) at /home/elmarco/src/qemu/monitor.c:311
       #6  0x0000555555787e46 in monitor_puts (mon=0x5555567bd9e0, str=0x5555567a44ef "") at /home/elmarco/src/qemu/monitor.c:353
       #7  0x00005555557880fe in monitor_json_emitter (mon=0x5555567bd9e0, data=0x5555567c73a0) at /home/elmarco/src/qemu/monitor.c:401
       #8  0x00005555557882d2 in monitor_qapi_event_emit (event=QAPI_EVENT_SPICE_DISCONNECTED, qdict=0x5555567c73a0) at /home/elmarco/src/qemu/monitor.c:472
       #9  0x000055555578838f in monitor_qapi_event_queue (event=QAPI_EVENT_SPICE_DISCONNECTED, qdict=0x5555567c73a0, errp=0x7fffffffca88) at /home/elmarco/src/qemu/monitor.c:497
       #10 0x0000555555c15541 in qapi_event_send_spice_disconnected (server=0x5555571139d0, client=0x5555570d0db0, errp=0x5555566c0428 <error_abort>) at qapi-event.c:1038
       #11 0x0000555555b11bc6 in channel_event (event=3, info=0x5555570d6c00) at ui/spice-core.c:248
       #12 0x00007fffdcc9983a in adapter_channel_event (event=3, info=0x5555570d6c00) at reds.c:120
       #13 0x00007fffdcc99a25 in reds_handle_channel_event (reds=0x5555567a9d60, event=3, info=0x5555570d6c00) at reds.c:324
       #14 0x00007fffdcc7d4c4 in main_dispatcher_self_handle_channel_event (self=0x5555567b28b0, event=3, info=0x5555570d6c00) at main-dispatcher.c:175
       #15 0x00007fffdcc7d5b1 in main_dispatcher_channel_event (self=0x5555567b28b0, event=3, info=0x5555570d6c00) at main-dispatcher.c:194
       #16 0x00007fffdcca7674 in reds_stream_push_channel_event (s=0x5555570d9910, event=3) at reds-stream.c:354
       #17 0x00007fffdcca749b in reds_stream_free (s=0x5555570d9910) at reds-stream.c:323
       #18 0x00007fffdccb5dad in snd_disconnect_channel (channel=0x5555576a89a0) at sound.c:229
       #19 0x00007fffdccb9e57 in snd_detach_common (worker=0x555557739720) at sound.c:1589
       #20 0x00007fffdccb9f0e in snd_detach_playback (sin=0x5555569fe3f8) at sound.c:1602
       #21 0x00007fffdcca3373 in spice_server_remove_interface (sin=0x5555569fe3f8) at reds.c:3387
       #22 0x00005555558ff6e2 in line_out_fini (hw=0x5555569fe370) at audio/spiceaudio.c:152
       #23 0x00005555558f909e in audio_atexit () at audio/audio.c:1754
       #24 0x00007fffdb1941e8 in __run_exit_handlers (status=0, listp=0x7fffdb5175d8 <__exit_funcs>, run_list_atexit=run_list_atexit@entry=true) at exit.c:82
       #25 0x00007fffdb194235 in __GI_exit (status=<optimized out>) at exit.c:104
       #26 0x00007fffdb17b738 in __libc_start_main (main=0x5555558d7874 <main>, argc=67, argv=0x7fffffffcf48, init=<optimized out>, fini=<optimized out>, rtld_fini=<optimized out>, stack_end=0x7fffffffcf38) at ../csu/libc-start.c:323
      
      Add a monitor_cleanup() functions to remove all the monitors before
      cleaning up the chardev. Note that we are "losing" some events that
      used to be sent during atexit().
      
      Signed-off-by: default avatarMarc-André Lureau <marcandre.lureau@redhat.com>
      Message-Id: <20160801112343.29082-2-marcandre.lureau@redhat.com>
      Reviewed-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
      Reviewed-by: default avatarMarkus Armbruster <armbru@redhat.com>
      Signed-off-by: default avatarMarkus Armbruster <armbru@redhat.com>
      2ef45716
  6. Jul 12, 2016
  7. Mar 22, 2016
  8. Feb 16, 2016
    • Daniel P. Berrangé's avatar
      qom: add helpers for UserCreatable object types · 90998d58
      Daniel P. Berrangé authored
      
      The QMP monitor code has two helper methods object_add
      and qmp_object_del that are called from several places
      in the code (QMP, HMP and main emulator startup).
      
      The HMP and main emulator startup code also share
      further logic that extracts the qom-type & id
      values from a qdict.
      
      We soon need to use this logic from qemu-img, qemu-io
      and qemu-nbd too, but don't want those to depend on
      the monitor, nor do we want to duplicate the code.
      
      To avoid this, move some code out of qmp.c and hmp.c
      adding new methods to qom/object_interfaces.c
      
       - user_creatable_add - takes a QDict holding a full
         object definition & instantiates it
       - user_creatable_add_type - takes an ID, type name,
         and QDict holding object properties & instantiates
         it
       - user_creatable_add_opts - takes a QemuOpts holding
         a full object definition & instantiates it
       - user_creatable_add_opts_foreach - variant on
         user_creatable_add_opts which can be directly used
         in conjunction with qemu_opts_foreach.
       - user_creatable_del - takes an ID and deletes the
         corresponding object
      
      The existing code is updated to use these new methods.
      
      Signed-off-by: default avatarDaniel P. Berrange <berrange@redhat.com>
      Message-Id: <1455129674-17255-2-git-send-email-berrange@redhat.com>
      Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
      90998d58
  9. Nov 12, 2015
    • Alexey Kardashevskiy's avatar
      monitor/target-ppc: Define target_get_monitor_def · 0a9516c2
      Alexey Kardashevskiy authored
      
      At the moment get_monitor_def() returns only registers from statically
      defined monitor_defs array. However there is a lot of BOOK3S SPRs
      which are not in the list and cannot be printed from the monitor.
      
      This adds a new target platform hook - target_get_monitor_def().
      The hook is called if a register was not found in the static
      array returned by the target_monitor_defs() hook.
      
      The hook is only defined for POWERPC, it returns registered
      SPRs and fails on unregistered ones providing the user with information
      on what is actually supported on the running CPU. The register value is
      saved as uint64_t as it is the biggest supported register size;
      target_ulong cannot be used because of the stub - it is in a "common"
      code and cannot include "cpu.h", etc; this is also why the hook prototype
      is redefined in the stub instead of being included from some header.
      
      This replaces static descriptors for GPRs, FPRs, SRs with a helper which
      looks for a value in a corresponding array in the CPUPPCState.
      The immediate effect is that all 32 SRs can be printed now (instead of 16);
      later this can be reused for VSX or TM registers.
      
      This replaces callbacks for MSR and XER with static descriptors in
      monitor_defs as they are stored in CPUPPCState.
      
      While we are here, this adds "cr" as a synonym of "ccr".
      
      Signed-off-by: default avatarAlexey Kardashevskiy <aik@ozlabs.ru>
      Signed-off-by: default avatarDavid Gibson <david@gibson.dropbear.id.au>
      0a9516c2
  10. Sep 25, 2015
    • Pavel Butsykin's avatar
      hmp: added io apic dump state · d665d696
      Pavel Butsykin authored
      
      Added the hmp command to query io apic state, may be usefull after guest
      crashes to understand IRQ routing in guest.
      
      Implementation is only for kvm here. The dump will look like
      (qemu) info ioapic
      ioapic id=0x00 sel=0x26 (redir[11])
      pin 0  0x0000000000010000 dest=0 vec=0   active-hi edge  masked fixed  physical
      pin 1  0x0000000000000031 dest=0 vec=49  active-hi edge         fixed  physical
      ...
      pin 23 0x0000000000010000 dest=0 vec=0   active-hi edge  masked fixed  physical
      IRR        (none)
      Remote IRR (none)
      
      Signed-off-by: default avatarPavel Butsykin <pbutsykin@virtuozzo.com>
      Signed-off-by: default avatarDenis V. Lunev <den@openvz.org>
      CC: Paolo Bonzini <pbonzini@redhat.com>
      CC: Andreas Färber <afaerber@suse.de>
      Message-Id: <1442927901-1084-9-git-send-email-den@openvz.org>
      Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
      d665d696
    • Pavel Butsykin's avatar
      hmp: added local apic dump state · 1f871d49
      Pavel Butsykin authored
      
      Added the hmp command to query local apic registers state, may be
      usefull after guest crashes to understand IRQ routing in guest.
      
      (qemu) info lapic
      dumping local APIC state for CPU 0
      
      LVT0    0x00010700 active-hi edge  masked                      ExtINT (vec 0)
      LVT1    0x00000400 active-hi edge                              NMI
      LVTPC   0x00010000 active-hi edge  masked                      Fixed  (vec 0)
      LVTERR  0x000000fe active-hi edge                              Fixed  (vec 254)
      LVTTHMR 0x00010000 active-hi edge  masked                      Fixed  (vec 0)
      LVTT    0x000000ef active-hi edge                 one-shot     Fixed  (vec 239)
      Timer   DCR=0x3 (divide by 16) initial_count = 61360
      SPIV    0x000001ff APIC enabled, focus=off, spurious vec 255
      ICR     0x000000fd physical edge de-assert no-shorthand
      ICR2    0x00000001 cpu 1 (X2APIC ID)
      ESR     0x00000000
      ISR     (none)
      IRR     239
      
      APR 0x00 TPR 0x00 DFR 0x0f LDR 0x00 PPR 0x00
      
      Signed-off-by: default avatarPavel Butsykin <pbutsykin@virtuozzo.com>
      Signed-off-by: default avatarDenis V. Lunev <den@openvz.org>
      CC: Paolo Bonzini <pbonzini@redhat.com>
      CC: Andreas Färber <afaerber@suse.de>
      Message-Id: <1442927901-1084-7-git-send-email-den@openvz.org>
      Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
      1f871d49
    • Pavel Butsykin's avatar
      monitor: make monitor_fprintf and mon_get_cpu externally visible · caf15319
      Pavel Butsykin authored
      
      monitor_fprintf and mon_get_cpu will be used in the target-specific monitor,
      so it is advisable to make it external.
      
      Signed-off-by: default avatarPavel Butsykin <pbutsykin@virtuozzo.com>
      Signed-off-by: default avatarDenis V. Lunev <den@openvz.org>
      CC: Paolo Bonzini <pbonzini@redhat.com>
      CC: Andreas Färber <afaerber@suse.de>
      Message-Id: <1442927901-1084-6-git-send-email-den@openvz.org>
      Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
      caf15319
  11. Sep 21, 2015
  12. Sep 16, 2015
  13. Jun 22, 2015
  14. Jun 15, 2015
  15. Jun 02, 2015
    • Markus Armbruster's avatar
    • Markus Armbruster's avatar
      monitor: Drop broken, unused asynchronous command interface · 65207c59
      Markus Armbruster authored
      The asynchronous monitor command interface goes back to commit 940cc30d
      (Jan 2010).  Added a third case to command execution.  The hope back
      then according to the commit message was that all commands get
      converted to the asynchronous interface, killing off the other two
      cases.  Didn't happen.
      
      The initial asynchronous commands balloon and info balloon were
      converted back to synchronous long ago (commit 96637bcd and d72f32),
      with commit messages calling the asynchronous interface "not fully
      working" and "deprecated".  The only other user went away in commit
      3b5704b2.
      
      New code generally uses synchronous commands and asynchronous events.
      
      What exactly is still "not fully working" with asynchronous commands?
      Well, here's a bug that defeats actual asynchronous use pretty
      reliably: the reply's ID is wrong (and has always been wrong) unless
      you use the command synchronously!  To reproduce, we need an
      asynchronous command, so we have to go back before commit 3b5704b2.
      Run QEMU with spice:
      
          $ qemu-system-x86_64 -nodefaults -S -spice port=5900,disable-ticketing -qmp stdio
          {"QMP": {"version": {"qemu": {"micro": 94, "minor": 2, "major": 2}, "package": ""}, "capabilities": []}}
      
      Connect a spice client in another terminal:
      
          $ remote-viewer spice://localhost:5900
      
      
      
      Set up a migration destination dummy in a third terminal:
      
          $ socat TCP-LISTEN:12345 STDIO
      
      Now paste the following into the QMP monitor:
      
          { "execute": "qmp_capabilities", "id": "i0" }
          { "execute": "client_migrate_info", "id": "i1", "arguments": { "protocol": "spice", "hostname": "localhost", "port": 12345 } }
          { "execute": "query-kvm", "id": "i2" }
      
      Produces two replies immediately, one to qmp_capabilities, and one to
      query-kvm:
      
          {"return": {}, "id": "i0"}
          {"return": {"enabled": false, "present": true}, "id": "i2"}
      
      Both are correct.  Two lines of debug output from libspice-server not
      shown.
      
      Now EOF socat's standard input to make it close the connection.  This
      makes the asynchronous client_migrate_info complete.  It replies:
      
          {"return": {}}
      
      Bug: "id": "i1" is missing.  Two lines of debug output from
      libspice-server not shown.  Cherry on top: storage for the missing ID
      is leaked.
      
      Get rid of this stuff before somebody hurts himself with it.
      
      Signed-off-by: default avatarMarkus Armbruster <armbru@redhat.com>
      Reviewed-by: default avatarEric Blake <eblake@redhat.com>
      Reviewed-by: default avatarLuiz Capitulino <lcapitulino@redhat.com>
      65207c59
  16. Apr 30, 2015
  17. Mar 17, 2015
  18. Feb 18, 2015
    • Markus Armbruster's avatar
      hmp: Name HMP info handler functions hmp_info_SUBCOMMAND() · 1ce6be24
      Markus Armbruster authored
      
      Some are called do_info_SUBCOMMAND() (old ones, usually), some
      hmp_info_SUBCOMMAND(), some SUBCOMMAND_info(), sometimes SUBCOMMAND
      pointlessly differs in spelling.
      
      Normalize to hmp_info_SUBCOMMAND(), where SUBCOMMAND is exactly the
      subcommand name with '-' replaced by '_'.
      
      Exceptions:
      
      * sun4m_irq_info(), sun4m_pic_info() renamed to sun4m_hmp_info_irq(),
        sun4m_hmp_info_pic().
      
      * lm32_irq_info(), lm32_pic_info() renamed to lm32_hmp_info_irq(),
        lm32_hmp_info_pic().
      
      Signed-off-by: default avatarMarkus Armbruster <armbru@redhat.com>
      1ce6be24
    • Markus Armbruster's avatar
      monitor: Clean up around monitor_handle_fd_param() · 1677f4c6
      Markus Armbruster authored
      
      monitor_handle_fd_param() is a wrapper around
      monitor_handle_fd_param2() that feeds errors to qerror_report_err()
      instead of returning them.  qerror_report_err() is inappropriate in
      many contexts.  monitor_handle_fd_param() looks simpler than
      monitor_handle_fd_param2(), which tempts use.  Remove the temptation:
      drop the wrapper and open-code the (trivial) error handling instead.
      
      Replace the open-coded qerror_report_err() by error_report_err() in
      places that already use error_report().  Turns out that's everywhere.
      
      While there, rename monitor_handle_fd_param2() to monitor_fd_param().
      
      Signed-off-by: default avatarMarkus Armbruster <armbru@redhat.com>
      Reviewed-by: default avatarEric Blake <eblake@redhat.com>
      1677f4c6
  19. Oct 20, 2014
  20. Aug 18, 2014
  21. Jun 23, 2014
  22. Jun 19, 2014
  23. May 08, 2014
  24. Apr 25, 2014
  25. Feb 21, 2014
    • Benoît Canet's avatar
      quorum: Add quorum mechanism. · 95c6bff3
      Benoît Canet authored
      
      This patchset enables the core of the quorum mechanism.
      The num_children reads are compared to get the majority version and if this
      version exists more than threshold times the guest won't see the error at all.
      
      If a block is corrupted or if an error occurs during an IO or if the quorum
      cannot be established QMP events are used to report to the management.
      
      Use gnutls's SHA-256 to compare versions.
      
      --enable-quorum must be used to enable the feature.
      
      Signed-off-by: default avatarBenoit Canet <benoit@irqsave.net>
      Reviewed-by: default avatarMax Reitz <mreitz@redhat.com>
      Signed-off-by: default avatarKevin Wolf <kwolf@redhat.com>
      95c6bff3
  26. Jan 22, 2014
    • Stefan Hajnoczi's avatar
      readline: move readline to a generic location · 0150cd81
      Stefan Hajnoczi authored
      
      Now that the monitor and readline are decoupled, readline.h no longer
      belongs in include/monitor/.  Put the header into include/qemu/.
      
      Move the source file into util/ so it can be linked as part of
      libqemuutil.a.
      
      Signed-off-by: default avatarStefan Hajnoczi <stefanha@redhat.com>
      Signed-off-by: default avatarKevin Wolf <kwolf@redhat.com>
      0150cd81
    • Stefan Hajnoczi's avatar
      readline: decouple readline from the monitor · c60bf339
      Stefan Hajnoczi authored
      
      Make the readline.c functionality reusable.  Instead of calling
      monitor_printf() and monitor_flush() directly, invoke function pointers
      provided by the user.
      
      This way readline.c does not know about Monitor and other users will be
      able to make use of readline.c.
      
      Note that there is already an "opaque" argument to the ReadLineFunc
      callback.  Consistently call it "readline_opaque" from now on to
      distinguish from the ReadLinePrintfFunc/ReadLineFlushFunc "opaque"
      argument.
      
      I also dropped the printf macro trickery since it's now highly unlikely
      that anyone modifying readline.c would call printf(3) directly.  We no
      longer need this protection.
      
      Signed-off-by: default avatarStefan Hajnoczi <stefanha@redhat.com>
      Signed-off-by: default avatarKevin Wolf <kwolf@redhat.com>
      c60bf339
  27. Jan 06, 2014
  28. Aug 30, 2013
Loading