Juan Quintela <quint...@redhat.com> wrote:
> Tejus GK <tejus...@nutanix.com> wrote:
>> On 04/10/23 1:53 pm, Juan Quintela wrote:
>>> Tejus GK <tejus...@nutanix.com> wrote:
>>>> On 03/10/23 6:14 pm, Juan Quintela wrote:
> Ouch, that again.
>
> I think that I know how to fix that.
>
> Will take a look.
>
> Later, Juan.

I first only saw that you were missing migrate_set_error().
migrate_get_current() is .... more interesting.

The problem is that migration.c has lots of things that depend of qemu
and we can't use that in qtest.
This is one disection toh help fix it, but I can't see a trivial way to
get current_migration() working as needed.  Really what we should have
is a way to have vmstate store its own error, and only set
migrate_set_error() at callers time, but that don't seem completely
obvious how to do it.

Later, Juan.


>From cdbdbca65059ebb9fd6a4d354a94c3be7cf69f92 Mon Sep 17 00:00:00 2001
From: Juan Quintela <quint...@redhat.com>
Date: Wed, 4 Oct 2023 15:22:39 +0200
Subject: [PATCH] migration: Create common.c

We can (yet) add migration.c to migration_files because it brings too
many dependencies to the tests.

This file is a place where to move things that are also needed for
tests.

Signed-off-by: Juan Quintela <quint...@redhat.com>
---
 migration/common.c    | 25 +++++++++++++++++++++++++
 migration/migration.c |  8 --------
 migration/meson.build |  1 +
 3 files changed, 26 insertions(+), 8 deletions(-)
 create mode 100644 migration/common.c

diff --git a/migration/common.c b/migration/common.c
new file mode 100644
index 0000000000..1d02f37c99
--- /dev/null
+++ b/migration/common.c
@@ -0,0 +1,25 @@
+/*
+ * QEMU live migration common code for qemu and qtests
+ *
+ * Copyright (c) 2011 Red Hat Inc
+ *
+ * Authors:
+ *  Juan Quintela <quint...@redhat.com>
+ *
+ * This work is licensed under the terms of the GNU GPL, version 2 or later.
+ * See the COPYING file in the top-level directory.
+ */
+
+#include "qemu/osdep.h"
+#include "qemu/cutils.h"
+#include "qemu/error-report.h"
+#include "qapi/error.h"
+#include "migration.h"
+
+void migrate_set_error(MigrationState *s, const Error *error)
+{
+    QEMU_LOCK_GUARD(&s->error_mutex);
+    if (!s->error) {
+        s->error = error_copy(error);
+    }
+}
diff --git a/migration/migration.c b/migration/migration.c
index 585d3c8f55..f143b3a41e 100644
--- a/migration/migration.c
+++ b/migration/migration.c
@@ -1221,14 +1221,6 @@ static void migrate_fd_cleanup_bh(void *opaque)
     object_unref(OBJECT(s));
 }
 
-void migrate_set_error(MigrationState *s, const Error *error)
-{
-    QEMU_LOCK_GUARD(&s->error_mutex);
-    if (!s->error) {
-        s->error = error_copy(error);
-    }
-}
-
 static void migrate_error_free(MigrationState *s)
 {
     QEMU_LOCK_GUARD(&s->error_mutex);
diff --git a/migration/meson.build b/migration/meson.build
index 92b1cc4297..57b3098c46 100644
--- a/migration/meson.build
+++ b/migration/meson.build
@@ -1,5 +1,6 @@
 # Files needed by unit tests
 migration_files = files(
+  'common.c',
   'migration-stats.c',
   'page_cache.c',
   'xbzrle.c',

-- 
2.41.0


Reply via email to