diff mbox series

[RFC,v1,4/4] replay: do not build if TCG is not available

Message ID 20201009152108.16120-5-cfontana@suse.de
State New
Headers show
Series unbreak non-tcg builds | expand

Commit Message

Claudio Fontana Oct. 9, 2020, 3:21 p.m. UTC
replay requires icount, which needs TCG.

stub the needed functions in stub/,
including errors for hmp and qmp commands.

Signed-off-by: Claudio Fontana <cfontana@suse.de>
---
 migration/savevm.c         | 11 +++--
 replay/meson.build         |  2 +-
 stubs/replay.c             | 99 ++++++++++++++++++++++++++++++++++++++
 tests/qtest/qmp-cmd-test.c |  3 ++
 4 files changed, 110 insertions(+), 5 deletions(-)

Comments

Paolo Bonzini Oct. 9, 2020, 4:01 p.m. UTC | #1
On 09/10/20 17:21, Claudio Fontana wrote:
> replay requires icount, which needs TCG.

> 

> stub the needed functions in stub/,

> including errors for hmp and qmp commands.

> 

> Signed-off-by: Claudio Fontana <cfontana@suse.de>


Looks plausible, though probably I'd put it in replay/stubs.c and use
if_false to link it.

Paolo

> ---

>  migration/savevm.c         | 11 +++--

>  replay/meson.build         |  2 +-

>  stubs/replay.c             | 99 ++++++++++++++++++++++++++++++++++++++

>  tests/qtest/qmp-cmd-test.c |  3 ++

>  4 files changed, 110 insertions(+), 5 deletions(-)

> 

> diff --git a/migration/savevm.c b/migration/savevm.c

> index d2e141f7b1..d9181ca520 100644

> --- a/migration/savevm.c

> +++ b/migration/savevm.c

> @@ -63,6 +63,7 @@

>  #include "migration/colo.h"

>  #include "qemu/bitmap.h"

>  #include "net/announce.h"

> +#include "sysemu/tcg.h"

>  

>  const unsigned int postcopy_ram_discard_version = 0;

>  

> @@ -2674,10 +2675,12 @@ int save_snapshot(const char *name, Error **errp)

>          return ret;

>      }

>  

> -    if (!replay_can_snapshot()) {

> -        error_setg(errp, "Record/replay does not allow making snapshot "

> -                   "right now. Try once more later.");

> -        return ret;

> +    if (tcg_enabled()) {

> +        if (!replay_can_snapshot()) {

> +            error_setg(errp, "Record/replay does not allow making snapshot "

> +                       "right now. Try once more later.");

> +            return ret;

> +        }

>      }

>  

>      if (!bdrv_all_can_snapshot(&bs)) {

> diff --git a/replay/meson.build b/replay/meson.build

> index f91163fb1e..cb3207740a 100644

> --- a/replay/meson.build

> +++ b/replay/meson.build

> @@ -1,4 +1,4 @@

> -softmmu_ss.add(files(

> +softmmu_ss.add(when: 'CONFIG_TCG', if_true: files(

>    'replay.c',

>    'replay-internal.c',

>    'replay-events.c',

> diff --git a/stubs/replay.c b/stubs/replay.c

> index 45ebe77fb9..ff35daf198 100644

> --- a/stubs/replay.c

> +++ b/stubs/replay.c

> @@ -103,3 +103,102 @@ bool replay_reverse_continue(void)

>  {

>      return false;

>  }

> +

> +void replay_add_blocker(Error *reason)

> +{

> +}

> +void replay_audio_in(size_t *recorded, void *samples, size_t *wpos, size_t size)

> +{

> +}

> +void replay_audio_out(size_t *played)

> +{

> +}

> +void replay_bh_schedule_event(QEMUBH *bh)

> +{

> +}

> +void replay_breakpoint(void)

> +{

> +}

> +bool replay_can_snapshot(void)

> +{

> +    return false;

> +}

> +void replay_configure(struct QemuOpts *opts)

> +{

> +}

> +void replay_flush_events(void)

> +{

> +}

> +void replay_gdb_attached(void)

> +{

> +}

> +void replay_input_event(QemuConsole *src, InputEvent *evt)

> +{

> +}

> +void replay_input_sync_event(void)

> +{

> +}

> +void replay_net_packet_event(ReplayNetState *rns, unsigned flags,

> +                             const struct iovec *iov, int iovcnt)

> +{

> +}

> +ReplayNetState *replay_register_net(NetFilterState *nfs)

> +{

> +    return NULL;

> +}

> +bool replay_running_debug(void)

> +{

> +    return false;

> +}

> +void replay_shutdown_request(ShutdownCause cause)

> +{

> +}

> +void replay_start(void)

> +{

> +}

> +void replay_unregister_net(ReplayNetState *rns)

> +{

> +}

> +void replay_vmstate_init(void)

> +{

> +}

> +

> +#include "monitor/monitor.h"

> +#include "monitor/hmp.h"

> +#include "qapi/qapi-commands-replay.h"

> +#include "qapi/error.h"

> +#include "qemu/error-report.h"

> +

> +void hmp_info_replay(Monitor *mon, const QDict *qdict)

> +{

> +    error_report("replay support not available\n");

> +}

> +void hmp_replay_break(Monitor *mon, const QDict *qdict)

> +{

> +    error_report("replay support not available\n");

> +}

> +void hmp_replay_delete_break(Monitor *mon, const QDict *qdict)

> +{

> +    error_report("replay support not available\n");

> +}

> +void hmp_replay_seek(Monitor *mon, const QDict *qdict)

> +{

> +    error_report("replay support not available\n");

> +}

> +ReplayInfo *qmp_query_replay(Error **errp)

> +{

> +    error_set(errp, ERROR_CLASS_COMMAND_NOT_FOUND, "replay support not available");

> +    return NULL;

> +}

> +void qmp_replay_break(int64_t icount, Error **errp)

> +{

> +    error_set(errp, ERROR_CLASS_COMMAND_NOT_FOUND, "replay support not available");

> +}

> +void qmp_replay_delete_break(Error **errp)

> +{

> +    error_set(errp, ERROR_CLASS_COMMAND_NOT_FOUND, "replay support not available");

> +}

> +void qmp_replay_seek(int64_t icount, Error **errp)

> +{

> +    error_set(errp, ERROR_CLASS_COMMAND_NOT_FOUND, "replay support not available");

> +}

> diff --git a/tests/qtest/qmp-cmd-test.c b/tests/qtest/qmp-cmd-test.c

> index 8a4c570e83..1c7186e53c 100644

> --- a/tests/qtest/qmp-cmd-test.c

> +++ b/tests/qtest/qmp-cmd-test.c

> @@ -31,6 +31,9 @@ static int query_error_class(const char *cmd)

>  #ifndef CONFIG_SPICE

>          { "query-spice", ERROR_CLASS_COMMAND_NOT_FOUND },

>  #endif

> +#ifndef CONFIG_TCG

> +        { "query-replay", ERROR_CLASS_COMMAND_NOT_FOUND },

> +#endif

>  #ifndef CONFIG_VNC

>          { "query-vnc", ERROR_CLASS_GENERIC_ERROR },

>          { "query-vnc-servers", ERROR_CLASS_GENERIC_ERROR },

>
diff mbox series

Patch

diff --git a/migration/savevm.c b/migration/savevm.c
index d2e141f7b1..d9181ca520 100644
--- a/migration/savevm.c
+++ b/migration/savevm.c
@@ -63,6 +63,7 @@ 
 #include "migration/colo.h"
 #include "qemu/bitmap.h"
 #include "net/announce.h"
+#include "sysemu/tcg.h"
 
 const unsigned int postcopy_ram_discard_version = 0;
 
@@ -2674,10 +2675,12 @@  int save_snapshot(const char *name, Error **errp)
         return ret;
     }
 
-    if (!replay_can_snapshot()) {
-        error_setg(errp, "Record/replay does not allow making snapshot "
-                   "right now. Try once more later.");
-        return ret;
+    if (tcg_enabled()) {
+        if (!replay_can_snapshot()) {
+            error_setg(errp, "Record/replay does not allow making snapshot "
+                       "right now. Try once more later.");
+            return ret;
+        }
     }
 
     if (!bdrv_all_can_snapshot(&bs)) {
diff --git a/replay/meson.build b/replay/meson.build
index f91163fb1e..cb3207740a 100644
--- a/replay/meson.build
+++ b/replay/meson.build
@@ -1,4 +1,4 @@ 
-softmmu_ss.add(files(
+softmmu_ss.add(when: 'CONFIG_TCG', if_true: files(
   'replay.c',
   'replay-internal.c',
   'replay-events.c',
diff --git a/stubs/replay.c b/stubs/replay.c
index 45ebe77fb9..ff35daf198 100644
--- a/stubs/replay.c
+++ b/stubs/replay.c
@@ -103,3 +103,102 @@  bool replay_reverse_continue(void)
 {
     return false;
 }
+
+void replay_add_blocker(Error *reason)
+{
+}
+void replay_audio_in(size_t *recorded, void *samples, size_t *wpos, size_t size)
+{
+}
+void replay_audio_out(size_t *played)
+{
+}
+void replay_bh_schedule_event(QEMUBH *bh)
+{
+}
+void replay_breakpoint(void)
+{
+}
+bool replay_can_snapshot(void)
+{
+    return false;
+}
+void replay_configure(struct QemuOpts *opts)
+{
+}
+void replay_flush_events(void)
+{
+}
+void replay_gdb_attached(void)
+{
+}
+void replay_input_event(QemuConsole *src, InputEvent *evt)
+{
+}
+void replay_input_sync_event(void)
+{
+}
+void replay_net_packet_event(ReplayNetState *rns, unsigned flags,
+                             const struct iovec *iov, int iovcnt)
+{
+}
+ReplayNetState *replay_register_net(NetFilterState *nfs)
+{
+    return NULL;
+}
+bool replay_running_debug(void)
+{
+    return false;
+}
+void replay_shutdown_request(ShutdownCause cause)
+{
+}
+void replay_start(void)
+{
+}
+void replay_unregister_net(ReplayNetState *rns)
+{
+}
+void replay_vmstate_init(void)
+{
+}
+
+#include "monitor/monitor.h"
+#include "monitor/hmp.h"
+#include "qapi/qapi-commands-replay.h"
+#include "qapi/error.h"
+#include "qemu/error-report.h"
+
+void hmp_info_replay(Monitor *mon, const QDict *qdict)
+{
+    error_report("replay support not available\n");
+}
+void hmp_replay_break(Monitor *mon, const QDict *qdict)
+{
+    error_report("replay support not available\n");
+}
+void hmp_replay_delete_break(Monitor *mon, const QDict *qdict)
+{
+    error_report("replay support not available\n");
+}
+void hmp_replay_seek(Monitor *mon, const QDict *qdict)
+{
+    error_report("replay support not available\n");
+}
+ReplayInfo *qmp_query_replay(Error **errp)
+{
+    error_set(errp, ERROR_CLASS_COMMAND_NOT_FOUND, "replay support not available");
+    return NULL;
+}
+void qmp_replay_break(int64_t icount, Error **errp)
+{
+    error_set(errp, ERROR_CLASS_COMMAND_NOT_FOUND, "replay support not available");
+}
+void qmp_replay_delete_break(Error **errp)
+{
+    error_set(errp, ERROR_CLASS_COMMAND_NOT_FOUND, "replay support not available");
+}
+void qmp_replay_seek(int64_t icount, Error **errp)
+{
+    error_set(errp, ERROR_CLASS_COMMAND_NOT_FOUND, "replay support not available");
+}
diff --git a/tests/qtest/qmp-cmd-test.c b/tests/qtest/qmp-cmd-test.c
index 8a4c570e83..1c7186e53c 100644
--- a/tests/qtest/qmp-cmd-test.c
+++ b/tests/qtest/qmp-cmd-test.c
@@ -31,6 +31,9 @@  static int query_error_class(const char *cmd)
 #ifndef CONFIG_SPICE
         { "query-spice", ERROR_CLASS_COMMAND_NOT_FOUND },
 #endif
+#ifndef CONFIG_TCG
+        { "query-replay", ERROR_CLASS_COMMAND_NOT_FOUND },
+#endif
 #ifndef CONFIG_VNC
         { "query-vnc", ERROR_CLASS_GENERIC_ERROR },
         { "query-vnc-servers", ERROR_CLASS_GENERIC_ERROR },