Skip to contentSkip to conversation

Make migration/savevm.c target independent

PATCH In review Juan Quintela 2 participants 4 messages May 18, 2017 Kbuild

lore
Share & tools
lore
#0 lore raw

v2 cover Make migration/savevm.c target independent

Hi

Changes for v2
- Make copyright notice correct (dave)

Please, review.

[v1]
Only reason that ram.c is compiled by target is because it use TARGET_PAGE_BITS. As we already have a function to export TARGET_PAGE_SIZE, do the same.
After this, we can make it target independent.

Juan Quintela (2):
exec: Create include for target_page_size()
migration: Make savevm.c target independent

 Makefile.target            |  2 +-
 exec.c                     | 10 ++++++++++
 include/exec/target_page.h | 21 +++++++++++++++++++++
 include/sysemu/sysemu.h    |  1 -
 migration/Makefile.objs    |  2 +-
 migration/migration.c      |  1 +
 migration/postcopy-ram.c   |  1 +
 migration/savevm.c         | 15 ++++++++-------
 8 files changed, 43 insertions(+), 10 deletions(-)
 create mode 100644 include/exec/target_page.h
Signature · 1 line
2.9.3
#1 lore raw

PATCH v2 1/2 exec: Create include for target_page_size()

That is the only function that we need from exec.c, and having to include the whole sysemu.h for this.

---

/me leans to be less sloppy with copyright notices thanks Dave

---
 exec.c                     |  1 +
 include/exec/target_page.h | 19 +++++++++++++++++++
 include/sysemu/sysemu.h    |  1 -
 migration/migration.c      |  1 +
 migration/postcopy-ram.c   |  1 +
 migration/savevm.c         |  1 +
 6 files changed, 23 insertions(+), 1 deletion(-)
 create mode 100644 include/exec/target_page.h
exec.c +1 -0
index 96e3ac9..de2961b 100644
@@ -24,6 +24,7 @@
 #include "qemu/cutils.h"
 #include "cpu.h"
 #include "exec/exec-all.h"
+#include "exec/target_page.h"
 #include "tcg.h"
 #include "hw/qdev-core.h"
 #if !defined(CONFIG_USER_ONLY)
include/exec/target_page.h new file +19 -0
new file mode 100644
index 0000000..626eda8
@@ -0,0 +1,19 @@
+/*
+ * Target page sizes and friends for non target files
+ *
+ * Copyright (c) 2017 Red Hat Inc
+ *
+ * Authors:
+ *  David Alan Gilbert <[email protected]>
+ *  Juan Quintela <[email protected]>
+ *
+ * This work is licensed under the terms of the GNU GPL, version 2 or later.
+ * See the COPYING file in the top-level directory.
+ */
+
+#ifndef EXEC_TARGET_PAGE_H
+#define EXEC_TARGET_PAGE_H
+
+size_t qemu_target_page_size(void);
+
+#endif
include/sysemu/sysemu.h +0 -1
index 765358e..ed8fe3b 100644
@@ -67,7 +67,6 @@ int qemu_reset_requested_get(void);
 void qemu_system_killed(int signal, pid_t pid);
 void qemu_system_reset(bool report);
 void qemu_system_guest_panicked(GuestPanicInformation *info);
-size_t qemu_target_page_size(void);
 
 void qemu_add_exit_notifier(Notifier *notify);
 void qemu_remove_exit_notifier(Notifier *notify);
migration/migration.c +1 -0
index 9fe474b..ad29e53 100644
@@ -37,6 +37,7 @@
 #include "qom/cpu.h"
 #include "exec/memory.h"
 #include "exec/address-spaces.h"
+#include "exec/target_page.h"
 #include "io/channel-buffer.h"
 #include "io/channel-tls.h"
 #include "migration/colo.h"
migration/postcopy-ram.c +1 -0
index 0e2a996..a37620d 100644
@@ -19,6 +19,7 @@
 #include "qemu/osdep.h"
 
 #include "qemu-common.h"
+#include "exec/target_page.h"
 #include "migration/migration.h"
 #include "migration/qemu-file.h"
 #include "postcopy-ram.h"
migration/savevm.c +1 -0
index 8565103..8763700 100644
@@ -43,6 +43,7 @@
 #include "qemu/queue.h"
 #include "sysemu/cpus.h"
 #include "exec/memory.h"
+#include "exec/target_page.h"
 #include "qmp-commands.h"
 #include "trace.h"
 #include "qemu/bitops.h"
Signature · 1 line
2.9.3
Reviewed-by on v2 1/2
#2 lore raw

Re: [Qemu-devel] [PATCH v2 1/2] exec: Create include for target_page_size()

Quoted 4 lines · * Juan Quintela ([email protected]) wrote:

That is the only function that we need from exec.c, and having to include the whole sysemu.h for this.

Quoted 103 lines

---

/me leans to be less sloppy with copyright notices thanks Dave

---
 exec.c                     |  1 +
 include/exec/target_page.h | 19 +++++++++++++++++++
 include/sysemu/sysemu.h    |  1 -
 migration/migration.c      |  1 +
 migration/postcopy-ram.c   |  1 +
 migration/savevm.c         |  1 +
 6 files changed, 23 insertions(+), 1 deletion(-)
 create mode 100644 include/exec/target_page.h
exec.c +1 -0
index 96e3ac9..de2961b 100644
@@ -24,6 +24,7 @@
 #include "qemu/cutils.h"
 #include "cpu.h"
 #include "exec/exec-all.h"
+#include "exec/target_page.h"
 #include "tcg.h"
 #include "hw/qdev-core.h"
 #if !defined(CONFIG_USER_ONLY)
include/exec/target_page.h new file +19 -0
new file mode 100644
index 0000000..626eda8
@@ -0,0 +1,19 @@
+/*
+ * Target page sizes and friends for non target files
+ *
+ * Copyright (c) 2017 Red Hat Inc
+ *
+ * Authors:
+ *  David Alan Gilbert <[email protected]>
+ *  Juan Quintela <[email protected]>
+ *
+ * This work is licensed under the terms of the GNU GPL, version 2 or later.
+ * See the COPYING file in the top-level directory.
+ */
+
+#ifndef EXEC_TARGET_PAGE_H
+#define EXEC_TARGET_PAGE_H
+
+size_t qemu_target_page_size(void);
+
+#endif
include/sysemu/sysemu.h +0 -1
index 765358e..ed8fe3b 100644
@@ -67,7 +67,6 @@ int qemu_reset_requested_get(void);
 void qemu_system_killed(int signal, pid_t pid);
 void qemu_system_reset(bool report);
 void qemu_system_guest_panicked(GuestPanicInformation *info);
-size_t qemu_target_page_size(void);
 
 void qemu_add_exit_notifier(Notifier *notify);
 void qemu_remove_exit_notifier(Notifier *notify);
migration/migration.c +1 -0
index 9fe474b..ad29e53 100644
@@ -37,6 +37,7 @@
 #include "qom/cpu.h"
 #include "exec/memory.h"
 #include "exec/address-spaces.h"
+#include "exec/target_page.h"
 #include "io/channel-buffer.h"
 #include "io/channel-tls.h"
 #include "migration/colo.h"
migration/postcopy-ram.c +1 -0
index 0e2a996..a37620d 100644
@@ -19,6 +19,7 @@
 #include "qemu/osdep.h"
 
 #include "qemu-common.h"
+#include "exec/target_page.h"
 #include "migration/migration.h"
 #include "migration/qemu-file.h"
 #include "postcopy-ram.h"
migration/savevm.c +1 -0
index 8565103..8763700 100644
@@ -43,6 +43,7 @@
 #include "qemu/queue.h"
 #include "sysemu/cpus.h"
 #include "exec/memory.h"
+#include "exec/target_page.h"
 #include "qmp-commands.h"
 #include "trace.h"
 #include "qemu/bitops.h"
Signature · 1 line
2.9.3

--
Dr. David Alan Gilbert / [email protected] / Manchester, UK

#3 lore raw

PATCH v2 2/2 migration: Make savevm.c target independent

In reply to Juan Quintela

It only needed TARGET_PAGE_SIZE/BITS/BITS_MIN values, so just export them from exec.h

---
 Makefile.target            |  2 +-
 exec.c                     |  9 +++++++++
 include/exec/target_page.h |  2 ++
 migration/Makefile.objs    |  2 +-
 migration/savevm.c         | 14 +++++++-------
 5 files changed, 20 insertions(+), 9 deletions(-)
Makefile.target +1 -1
index 465a633..ce8dfe4 100644
@@ -146,7 +146,7 @@ obj-$(CONFIG_KVM) += kvm-all.o
 obj-y += memory.o cputlb.o
 obj-y += memory_mapping.o
 obj-y += dump.o
-obj-y += migration/ram.o migration/savevm.o
+obj-y += migration/ram.o
 LIBS := $(libs_softmmu) $(LIBS)
 
 # Hardware support
exec.c +9 -0
index de2961b..ff16f04 100644
@@ -3444,6 +3444,15 @@ size_t qemu_target_page_size(void)
     return TARGET_PAGE_SIZE;
 }
 
+int qemu_target_page_bits(void)
+{
+    return TARGET_PAGE_BITS;
+}
+
+int qemu_target_page_bits_min(void)
+{
+    return TARGET_PAGE_BITS_MIN;
+}
 #endif
 
 /*
include/exec/target_page.h +2 -0
index 626eda8..96726c3 100644
@@ -15,5 +15,7 @@
 #define EXEC_TARGET_PAGE_H
 
 size_t qemu_target_page_size(void);
+int qemu_target_page_bits(void);
+int qemu_target_page_bits_min(void);
 
 #endif
migration/Makefile.objs +1 -1
index 3272415..90f8c1f 100644
@@ -1,5 +1,5 @@
 common-obj-y += migration.o socket.o fd.o exec.o
-common-obj-y += tls.o channel.o
+common-obj-y += tls.o channel.o savevm.o
 common-obj-y += colo-comm.o colo.o colo-failover.o
 common-obj-y += vmstate.o vmstate-types.o page_cache.o
 common-obj-y += qemu-file.o
migration/savevm.c +7 -7
index 8763700..d971e5e 100644
@@ -27,7 +27,6 @@
  */
 
 #include "qemu/osdep.h"
-#include "cpu.h"
 #include "hw/boards.h"
 #include "hw/hw.h"
 #include "hw/qdev.h"
@@ -288,7 +287,7 @@ static void configuration_pre_save(void *opaque)
 
     state->len = strlen(current_name);
     state->name = current_name;
-    state->target_page_bits = TARGET_PAGE_BITS;
+    state->target_page_bits = qemu_target_page_bits();
 }
 
 static int configuration_pre_load(void *opaque)
@@ -299,7 +298,7 @@ static int configuration_pre_load(void *opaque)
      * predates the variable-target-page-bits support and is using the
      * minimum possible value for this CPU.
      */
-    state->target_page_bits = TARGET_PAGE_BITS_MIN;
+    state->target_page_bits = qemu_target_page_bits_min();
     return 0;
 }
 
@@ -314,9 +313,9 @@ static int configuration_post_load(void *opaque, int version_id)
         return -EINVAL;
     }
 
-    if (state->target_page_bits != TARGET_PAGE_BITS) {
+    if (state->target_page_bits != qemu_target_page_bits()) {
         error_report("Received TARGET_PAGE_BITS is %d but local is %d",
-                     state->target_page_bits, TARGET_PAGE_BITS);
+                     state->target_page_bits, qemu_target_page_bits());
         return -EINVAL;
     }
 
@@ -332,7 +331,8 @@ static int configuration_post_load(void *opaque, int version_id)
  */
 static bool vmstate_target_page_bits_needed(void *opaque)
 {
-    return TARGET_PAGE_BITS > TARGET_PAGE_BITS_MIN;
+    return qemu_target_page_bits()
+        > qemu_target_page_bits_min();
 }
 
 static const VMStateDescription vmstate_target_page_bits = {
@@ -1138,7 +1138,7 @@ void qemu_savevm_state_complete_precopy(QEMUFile *f, bool iterable_only)
     }
 
     vmdesc = qjson_new();
-    json_prop_int(vmdesc, "page_size", TARGET_PAGE_SIZE);
+    json_prop_int(vmdesc, "page_size", qemu_target_page_size());
     json_start_array(vmdesc, "devices");
     QTAILQ_FOREACH(se, &savevm_state.handlers, entry) {
 
Signature · 1 line
2.9.3