All of lore.kernel.org
 help / color / mirror / Atom feed
* [RFC 0/7] Move accel, KVM, Xen, qtest files to accel/ subdir
@ 2016-12-20 17:43 ` Eduardo Habkost
  0 siblings, 0 replies; 37+ messages in thread
From: Eduardo Habkost @ 2016-12-20 17:43 UTC (permalink / raw)
  To: qemu-devel
  Cc: Paolo Bonzini, kvm, Christoffer Dall, Anthony Perard,
	Stefano Stabellini, xen-devel

This moves the KVM and Xen files to the an accel/ subdir.

Instead of moving the *-stubs.c file to accel/ as-is, I tried to
move most of the stub code to libqemustub.a. This way the obj-y
logic for accel/ is simpler: obj-y includes accel/ only if
CONFIG_SOFTMMU is set.

The Xen stubs could be moved completely to stubs/, but some of
the KVM stubs depend on cpu.h. So most of the kvm-stub.c code was
moved to stubs/kvm.c, but some of that code was kept in
accel/kvm-stub.c.

About TCG:
----------

It is not obvious to me which TCG-related files could be moved to
accel/, so this series don't move any of them yet.

About other CONFIG_SOFTMMU top-level files:
-------------------------------------------

I would like to know what we should do with the top-level
CONFIG_SOFTMMU-only files that don't belong to hw/. Some
candidates: arch_init.c cpus.c monitor.c gdbstub.c balloon.c
ioport.c bootdevice.c memory.c cputlb.c memory_mapping.c dump.c.

Maybe a sysemu/ subdir? In that case, should we still create an
accel/ subdir, or move xen-*, kvm-* and friends to sysemu/ too?

Cc: Paolo Bonzini <pbonzini@redhat.com>
Cc: kvm@vger.kernel.org
Cc: Christoffer Dall <christoffer.dall@linaro.org>
Cc: Anthony Perard <anthony.perard@citrix.com>
Cc: Stefano Stabellini <sstabellini@kernel.org>
Cc: xen-devel@lists.xensource.com

Eduardo Habkost (7):
  xen: Move xen-*-stub.c to stubs/
  xen: Move xen files to accel/
  kvm: Move some kvm-stub.c code to stubs/kvm.c
  kvm: Include kvm-stub.o only on CONFIG_SOFTMMU
  kvm: Move kvm*.c files to accel/
  accel: Move accel.c to accel/
  accel: Move qtest.c to accel/

 Makefile.objs                          |  2 +-
 Makefile.target                        | 10 ++----
 accel.c => accel/accel.c               |  0
 kvm-all.c => accel/kvm-common.c        |  0
 kvm-stub.c => accel/kvm-stub.c         | 51 --------------------------
 qtest.c => accel/qtest.c               |  0
 xen-common.c => accel/xen-common.c     |  0
 xen-hvm.c => accel/xen-hvm.c           |  0
 xen-mapcache.c => accel/xen-mapcache.c |  0
 stubs/kvm.c                            | 65 ++++++++++++++++++++++++++++++++++
 xen-hvm-stub.c => stubs/xen-hvm.c      |  0
 xen-common-stub.c => stubs/xen.c       |  0
 MAINTAINERS                            |  4 +--
 accel/Makefile.objs                    |  9 +++++
 stubs/Makefile.objs                    |  2 ++
 15 files changed, 80 insertions(+), 63 deletions(-)
 rename accel.c => accel/accel.c (100%)
 rename kvm-all.c => accel/kvm-common.c (100%)
 rename kvm-stub.c => accel/kvm-stub.c (71%)
 rename qtest.c => accel/qtest.c (100%)
 rename xen-common.c => accel/xen-common.c (100%)
 rename xen-hvm.c => accel/xen-hvm.c (100%)
 rename xen-mapcache.c => accel/xen-mapcache.c (100%)
 rename xen-hvm-stub.c => stubs/xen-hvm.c (100%)
 rename xen-common-stub.c => stubs/xen.c (100%)
 create mode 100644 accel/Makefile.objs

-- 
2.7.4


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

* [Qemu-devel] [RFC 0/7] Move accel, KVM, Xen, qtest files to accel/ subdir
@ 2016-12-20 17:43 ` Eduardo Habkost
  0 siblings, 0 replies; 37+ messages in thread
From: Eduardo Habkost @ 2016-12-20 17:43 UTC (permalink / raw)
  To: qemu-devel
  Cc: Paolo Bonzini, kvm, Christoffer Dall, Anthony Perard,
	Stefano Stabellini, xen-devel

This moves the KVM and Xen files to the an accel/ subdir.

Instead of moving the *-stubs.c file to accel/ as-is, I tried to
move most of the stub code to libqemustub.a. This way the obj-y
logic for accel/ is simpler: obj-y includes accel/ only if
CONFIG_SOFTMMU is set.

The Xen stubs could be moved completely to stubs/, but some of
the KVM stubs depend on cpu.h. So most of the kvm-stub.c code was
moved to stubs/kvm.c, but some of that code was kept in
accel/kvm-stub.c.

About TCG:
----------

It is not obvious to me which TCG-related files could be moved to
accel/, so this series don't move any of them yet.

About other CONFIG_SOFTMMU top-level files:
-------------------------------------------

I would like to know what we should do with the top-level
CONFIG_SOFTMMU-only files that don't belong to hw/. Some
candidates: arch_init.c cpus.c monitor.c gdbstub.c balloon.c
ioport.c bootdevice.c memory.c cputlb.c memory_mapping.c dump.c.

Maybe a sysemu/ subdir? In that case, should we still create an
accel/ subdir, or move xen-*, kvm-* and friends to sysemu/ too?

Cc: Paolo Bonzini <pbonzini@redhat.com>
Cc: kvm@vger.kernel.org
Cc: Christoffer Dall <christoffer.dall@linaro.org>
Cc: Anthony Perard <anthony.perard@citrix.com>
Cc: Stefano Stabellini <sstabellini@kernel.org>
Cc: xen-devel@lists.xensource.com

Eduardo Habkost (7):
  xen: Move xen-*-stub.c to stubs/
  xen: Move xen files to accel/
  kvm: Move some kvm-stub.c code to stubs/kvm.c
  kvm: Include kvm-stub.o only on CONFIG_SOFTMMU
  kvm: Move kvm*.c files to accel/
  accel: Move accel.c to accel/
  accel: Move qtest.c to accel/

 Makefile.objs                          |  2 +-
 Makefile.target                        | 10 ++----
 accel.c => accel/accel.c               |  0
 kvm-all.c => accel/kvm-common.c        |  0
 kvm-stub.c => accel/kvm-stub.c         | 51 --------------------------
 qtest.c => accel/qtest.c               |  0
 xen-common.c => accel/xen-common.c     |  0
 xen-hvm.c => accel/xen-hvm.c           |  0
 xen-mapcache.c => accel/xen-mapcache.c |  0
 stubs/kvm.c                            | 65 ++++++++++++++++++++++++++++++++++
 xen-hvm-stub.c => stubs/xen-hvm.c      |  0
 xen-common-stub.c => stubs/xen.c       |  0
 MAINTAINERS                            |  4 +--
 accel/Makefile.objs                    |  9 +++++
 stubs/Makefile.objs                    |  2 ++
 15 files changed, 80 insertions(+), 63 deletions(-)
 rename accel.c => accel/accel.c (100%)
 rename kvm-all.c => accel/kvm-common.c (100%)
 rename kvm-stub.c => accel/kvm-stub.c (71%)
 rename qtest.c => accel/qtest.c (100%)
 rename xen-common.c => accel/xen-common.c (100%)
 rename xen-hvm.c => accel/xen-hvm.c (100%)
 rename xen-mapcache.c => accel/xen-mapcache.c (100%)
 rename xen-hvm-stub.c => stubs/xen-hvm.c (100%)
 rename xen-common-stub.c => stubs/xen.c (100%)
 create mode 100644 accel/Makefile.objs

-- 
2.7.4

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

* [Qemu-devel] [RFC 1/7] xen: Move xen-*-stub.c to stubs/
  2016-12-20 17:43 ` [Qemu-devel] " Eduardo Habkost
@ 2016-12-20 17:43   ` Eduardo Habkost
  -1 siblings, 0 replies; 37+ messages in thread
From: Eduardo Habkost @ 2016-12-20 17:43 UTC (permalink / raw)
  To: qemu-devel; +Cc: Stefano Stabellini, Anthony Perard, xen-devel, Paolo Bonzini

Move xen stubs to stubs/ so they are handled automatically by
libqemustub.a.

Cc: Stefano Stabellini <sstabellini@kernel.org>
Cc: Anthony Perard <anthony.perard@citrix.com>
Cc: xen-devel@lists.xensource.com
Cc: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
---
 Makefile.target                   | 2 --
 xen-hvm-stub.c => stubs/xen-hvm.c | 0
 xen-common-stub.c => stubs/xen.c  | 0
 stubs/Makefile.objs               | 2 ++
 4 files changed, 2 insertions(+), 2 deletions(-)
 rename xen-hvm-stub.c => stubs/xen-hvm.c (100%)
 rename xen-common-stub.c => stubs/xen.c (100%)

diff --git a/Makefile.target b/Makefile.target
index 7a5080e..7c2fda9 100644
--- a/Makefile.target
+++ b/Makefile.target
@@ -147,8 +147,6 @@ LIBS := $(libs_softmmu) $(LIBS)
 # xen support
 obj-$(CONFIG_XEN) += xen-common.o
 obj-$(CONFIG_XEN_I386) += xen-hvm.o xen-mapcache.o
-obj-$(call lnot,$(CONFIG_XEN)) += xen-common-stub.o
-obj-$(call lnot,$(CONFIG_XEN_I386)) += xen-hvm-stub.o
 
 # Hardware support
 ifeq ($(TARGET_NAME), sparc64)
diff --git a/xen-hvm-stub.c b/stubs/xen-hvm.c
similarity index 100%
rename from xen-hvm-stub.c
rename to stubs/xen-hvm.c
diff --git a/xen-common-stub.c b/stubs/xen.c
similarity index 100%
rename from xen-common-stub.c
rename to stubs/xen.c
diff --git a/stubs/Makefile.objs b/stubs/Makefile.objs
index 2b5bb74..227e154 100644
--- a/stubs/Makefile.objs
+++ b/stubs/Makefile.objs
@@ -50,3 +50,5 @@ stub-obj-y += smbios_type_38.o
 stub-obj-y += ipmi.o
 stub-obj-y += pc_madt_cpu_entry.o
 stub-obj-y += migration-colo.o
+stub-obj-y += xen.o
+stub-obj-y += xen-hvm.o
-- 
2.7.4

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

* [RFC 1/7] xen: Move xen-*-stub.c to stubs/
@ 2016-12-20 17:43   ` Eduardo Habkost
  0 siblings, 0 replies; 37+ messages in thread
From: Eduardo Habkost @ 2016-12-20 17:43 UTC (permalink / raw)
  To: qemu-devel; +Cc: Anthony Perard, Paolo Bonzini, Stefano Stabellini, xen-devel

Move xen stubs to stubs/ so they are handled automatically by
libqemustub.a.

Cc: Stefano Stabellini <sstabellini@kernel.org>
Cc: Anthony Perard <anthony.perard@citrix.com>
Cc: xen-devel@lists.xensource.com
Cc: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
---
 Makefile.target                   | 2 --
 xen-hvm-stub.c => stubs/xen-hvm.c | 0
 xen-common-stub.c => stubs/xen.c  | 0
 stubs/Makefile.objs               | 2 ++
 4 files changed, 2 insertions(+), 2 deletions(-)
 rename xen-hvm-stub.c => stubs/xen-hvm.c (100%)
 rename xen-common-stub.c => stubs/xen.c (100%)

diff --git a/Makefile.target b/Makefile.target
index 7a5080e..7c2fda9 100644
--- a/Makefile.target
+++ b/Makefile.target
@@ -147,8 +147,6 @@ LIBS := $(libs_softmmu) $(LIBS)
 # xen support
 obj-$(CONFIG_XEN) += xen-common.o
 obj-$(CONFIG_XEN_I386) += xen-hvm.o xen-mapcache.o
-obj-$(call lnot,$(CONFIG_XEN)) += xen-common-stub.o
-obj-$(call lnot,$(CONFIG_XEN_I386)) += xen-hvm-stub.o
 
 # Hardware support
 ifeq ($(TARGET_NAME), sparc64)
diff --git a/xen-hvm-stub.c b/stubs/xen-hvm.c
similarity index 100%
rename from xen-hvm-stub.c
rename to stubs/xen-hvm.c
diff --git a/xen-common-stub.c b/stubs/xen.c
similarity index 100%
rename from xen-common-stub.c
rename to stubs/xen.c
diff --git a/stubs/Makefile.objs b/stubs/Makefile.objs
index 2b5bb74..227e154 100644
--- a/stubs/Makefile.objs
+++ b/stubs/Makefile.objs
@@ -50,3 +50,5 @@ stub-obj-y += smbios_type_38.o
 stub-obj-y += ipmi.o
 stub-obj-y += pc_madt_cpu_entry.o
 stub-obj-y += migration-colo.o
+stub-obj-y += xen.o
+stub-obj-y += xen-hvm.o
-- 
2.7.4

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

* [Qemu-devel] [RFC 2/7] xen: Move xen files to accel/
  2016-12-20 17:43 ` [Qemu-devel] " Eduardo Habkost
@ 2016-12-20 17:43   ` Eduardo Habkost
  -1 siblings, 0 replies; 37+ messages in thread
From: Eduardo Habkost @ 2016-12-20 17:43 UTC (permalink / raw)
  To: qemu-devel; +Cc: Stefano Stabellini, Anthony Perard, xen-devel

Cc: Stefano Stabellini <sstabellini@kernel.org>
Cc: Anthony Perard <anthony.perard@citrix.com>
Cc: xen-devel@lists.xensource.com
Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
---
 Makefile.target                        | 4 +---
 xen-common.c => accel/xen-common.c     | 0
 xen-hvm.c => accel/xen-hvm.c           | 0
 xen-mapcache.c => accel/xen-mapcache.c | 0
 MAINTAINERS                            | 1 -
 accel/Makefile.objs                    | 2 ++
 6 files changed, 3 insertions(+), 4 deletions(-)
 rename xen-common.c => accel/xen-common.c (100%)
 rename xen-hvm.c => accel/xen-hvm.c (100%)
 rename xen-mapcache.c => accel/xen-mapcache.c (100%)
 create mode 100644 accel/Makefile.objs

diff --git a/Makefile.target b/Makefile.target
index 7c2fda9..0b2ad86 100644
--- a/Makefile.target
+++ b/Makefile.target
@@ -144,9 +144,7 @@ obj-y += dump.o
 obj-y += migration/ram.o migration/savevm.o
 LIBS := $(libs_softmmu) $(LIBS)
 
-# xen support
-obj-$(CONFIG_XEN) += xen-common.o
-obj-$(CONFIG_XEN_I386) += xen-hvm.o xen-mapcache.o
+obj-y += accel/
 
 # Hardware support
 ifeq ($(TARGET_NAME), sparc64)
diff --git a/xen-common.c b/accel/xen-common.c
similarity index 100%
rename from xen-common.c
rename to accel/xen-common.c
diff --git a/xen-hvm.c b/accel/xen-hvm.c
similarity index 100%
rename from xen-hvm.c
rename to accel/xen-hvm.c
diff --git a/xen-mapcache.c b/accel/xen-mapcache.c
similarity index 100%
rename from xen-mapcache.c
rename to accel/xen-mapcache.c
diff --git a/MAINTAINERS b/MAINTAINERS
index 4a60579..8e25438 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -311,7 +311,6 @@ M: Stefano Stabellini <sstabellini@kernel.org>
 M: Anthony Perard <anthony.perard@citrix.com>
 L: xen-devel@lists.xensource.com
 S: Supported
-F: xen-*
 F: */xen*
 F: hw/char/xen_console.c
 F: hw/display/xenfb.c
diff --git a/accel/Makefile.objs b/accel/Makefile.objs
new file mode 100644
index 0000000..6f3630e
--- /dev/null
+++ b/accel/Makefile.objs
@@ -0,0 +1,2 @@
+obj-$(CONFIG_XEN) += xen-common.o
+obj-$(CONFIG_XEN_I386) += xen-hvm.o xen-mapcache.o
-- 
2.7.4

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

* [RFC 2/7] xen: Move xen files to accel/
@ 2016-12-20 17:43   ` Eduardo Habkost
  0 siblings, 0 replies; 37+ messages in thread
From: Eduardo Habkost @ 2016-12-20 17:43 UTC (permalink / raw)
  To: qemu-devel; +Cc: Anthony Perard, Stefano Stabellini, xen-devel

Cc: Stefano Stabellini <sstabellini@kernel.org>
Cc: Anthony Perard <anthony.perard@citrix.com>
Cc: xen-devel@lists.xensource.com
Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
---
 Makefile.target                        | 4 +---
 xen-common.c => accel/xen-common.c     | 0
 xen-hvm.c => accel/xen-hvm.c           | 0
 xen-mapcache.c => accel/xen-mapcache.c | 0
 MAINTAINERS                            | 1 -
 accel/Makefile.objs                    | 2 ++
 6 files changed, 3 insertions(+), 4 deletions(-)
 rename xen-common.c => accel/xen-common.c (100%)
 rename xen-hvm.c => accel/xen-hvm.c (100%)
 rename xen-mapcache.c => accel/xen-mapcache.c (100%)
 create mode 100644 accel/Makefile.objs

diff --git a/Makefile.target b/Makefile.target
index 7c2fda9..0b2ad86 100644
--- a/Makefile.target
+++ b/Makefile.target
@@ -144,9 +144,7 @@ obj-y += dump.o
 obj-y += migration/ram.o migration/savevm.o
 LIBS := $(libs_softmmu) $(LIBS)
 
-# xen support
-obj-$(CONFIG_XEN) += xen-common.o
-obj-$(CONFIG_XEN_I386) += xen-hvm.o xen-mapcache.o
+obj-y += accel/
 
 # Hardware support
 ifeq ($(TARGET_NAME), sparc64)
diff --git a/xen-common.c b/accel/xen-common.c
similarity index 100%
rename from xen-common.c
rename to accel/xen-common.c
diff --git a/xen-hvm.c b/accel/xen-hvm.c
similarity index 100%
rename from xen-hvm.c
rename to accel/xen-hvm.c
diff --git a/xen-mapcache.c b/accel/xen-mapcache.c
similarity index 100%
rename from xen-mapcache.c
rename to accel/xen-mapcache.c
diff --git a/MAINTAINERS b/MAINTAINERS
index 4a60579..8e25438 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -311,7 +311,6 @@ M: Stefano Stabellini <sstabellini@kernel.org>
 M: Anthony Perard <anthony.perard@citrix.com>
 L: xen-devel@lists.xensource.com
 S: Supported
-F: xen-*
 F: */xen*
 F: hw/char/xen_console.c
 F: hw/display/xenfb.c
diff --git a/accel/Makefile.objs b/accel/Makefile.objs
new file mode 100644
index 0000000..6f3630e
--- /dev/null
+++ b/accel/Makefile.objs
@@ -0,0 +1,2 @@
+obj-$(CONFIG_XEN) += xen-common.o
+obj-$(CONFIG_XEN_I386) += xen-hvm.o xen-mapcache.o
-- 
2.7.4


_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel

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

* [RFC 3/7] kvm: Move some kvm-stub.c code to stubs/kvm.c
  2016-12-20 17:43 ` [Qemu-devel] " Eduardo Habkost
@ 2016-12-20 17:43   ` Eduardo Habkost
  -1 siblings, 0 replies; 37+ messages in thread
From: Eduardo Habkost @ 2016-12-20 17:43 UTC (permalink / raw)
  To: qemu-devel; +Cc: Paolo Bonzini, kvm, Christoffer Dall

Move the kvm-stub.c code that doesn't depend on cpu.h or CONFIG_*
defines to stubs/kvm.c.

Notes about copyright, licensing, and authorship:

* There was no copyright not on the original stubs/kvm.c file.
* As include/sysemu/kvm.h and kvm-all.c are licensed as
  GPLv2+, I am assuming stubs/kvm.c file is also licensed as
  GPLv2+.
* I have copied the copyright info from kvm-stub.c and added the
  original author of stubs/kvm.c (Christoffer Dall) to the author
  list.

Cc: Paolo Bonzini <pbonzini@redhat.com>
Cc: kvm@vger.kernel.org
Cc: Christoffer Dall <christoffer.dall@linaro.org>
Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
---
 kvm-stub.c  | 51 ------------------------------------------------
 stubs/kvm.c | 65 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 65 insertions(+), 51 deletions(-)

diff --git a/kvm-stub.c b/kvm-stub.c
index b1b6b96..7ba697b 100644
--- a/kvm-stub.c
+++ b/kvm-stub.c
@@ -19,61 +19,10 @@
 #include "hw/pci/msi.h"
 #endif
 
-KVMState *kvm_state;
-bool kvm_kernel_irqchip;
-bool kvm_async_interrupts_allowed;
-bool kvm_eventfds_allowed;
-bool kvm_irqfds_allowed;
-bool kvm_resamplefds_allowed;
-bool kvm_msi_via_irqfd_allowed;
-bool kvm_gsi_routing_allowed;
-bool kvm_gsi_direct_mapping;
-bool kvm_allowed;
-bool kvm_readonly_mem_allowed;
-bool kvm_ioeventfd_any_length_allowed;
-bool kvm_msi_use_devid;
-
-int kvm_destroy_vcpu(CPUState *cpu)
-{
-    return -ENOSYS;
-}
-
-int kvm_init_vcpu(CPUState *cpu)
-{
-    return -ENOSYS;
-}
-
 void kvm_flush_coalesced_mmio_buffer(void)
 {
 }
 
-void kvm_cpu_synchronize_state(CPUState *cpu)
-{
-}
-
-void kvm_cpu_synchronize_post_reset(CPUState *cpu)
-{
-}
-
-void kvm_cpu_synchronize_post_init(CPUState *cpu)
-{
-}
-
-int kvm_cpu_exec(CPUState *cpu)
-{
-    abort();
-}
-
-int kvm_has_sync_mmu(void)
-{
-    return 0;
-}
-
-int kvm_has_many_ioeventfds(void)
-{
-    return 0;
-}
-
 int kvm_update_guest_debug(CPUState *cpu, unsigned long reinject_trap)
 {
     return -ENOSYS;
diff --git a/stubs/kvm.c b/stubs/kvm.c
index ddd6204..9d491c1 100644
--- a/stubs/kvm.c
+++ b/stubs/kvm.c
@@ -1,7 +1,72 @@
+/*
+ * QEMU KVM stub
+ *
+ * Copyright Red Hat, Inc. 2010
+ *
+ * Authors:
+ *  Christoffer Dall  <christoffer.dall@linaro.org>
+ *  Paolo Bonzini     <pbonzini@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-common.h"
 #include "sysemu/kvm.h"
 
+KVMState *kvm_state;
+bool kvm_kernel_irqchip;
+bool kvm_async_interrupts_allowed;
+bool kvm_eventfds_allowed;
+bool kvm_irqfds_allowed;
+bool kvm_resamplefds_allowed;
+bool kvm_msi_via_irqfd_allowed;
+bool kvm_gsi_routing_allowed;
+bool kvm_gsi_direct_mapping;
+bool kvm_allowed;
+bool kvm_readonly_mem_allowed;
+bool kvm_ioeventfd_any_length_allowed;
+bool kvm_msi_use_devid;
+
+int kvm_destroy_vcpu(CPUState *cpu)
+{
+    return -ENOSYS;
+}
+
+int kvm_init_vcpu(CPUState *cpu)
+{
+    return -ENOSYS;
+}
+
+void kvm_cpu_synchronize_state(CPUState *cpu)
+{
+}
+
+void kvm_cpu_synchronize_post_reset(CPUState *cpu)
+{
+}
+
+void kvm_cpu_synchronize_post_init(CPUState *cpu)
+{
+}
+
+int kvm_cpu_exec(CPUState *cpu)
+{
+    abort();
+}
+
+int kvm_has_sync_mmu(void)
+{
+    return 0;
+}
+
+int kvm_has_many_ioeventfds(void)
+{
+    return 0;
+}
+
 int kvm_arch_irqchip_create(MachineState *ms, KVMState *s)
 {
     return 0;
-- 
2.7.4


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

* [Qemu-devel] [RFC 3/7] kvm: Move some kvm-stub.c code to stubs/kvm.c
@ 2016-12-20 17:43   ` Eduardo Habkost
  0 siblings, 0 replies; 37+ messages in thread
From: Eduardo Habkost @ 2016-12-20 17:43 UTC (permalink / raw)
  To: qemu-devel; +Cc: Paolo Bonzini, kvm, Christoffer Dall

Move the kvm-stub.c code that doesn't depend on cpu.h or CONFIG_*
defines to stubs/kvm.c.

Notes about copyright, licensing, and authorship:

* There was no copyright not on the original stubs/kvm.c file.
* As include/sysemu/kvm.h and kvm-all.c are licensed as
  GPLv2+, I am assuming stubs/kvm.c file is also licensed as
  GPLv2+.
* I have copied the copyright info from kvm-stub.c and added the
  original author of stubs/kvm.c (Christoffer Dall) to the author
  list.

Cc: Paolo Bonzini <pbonzini@redhat.com>
Cc: kvm@vger.kernel.org
Cc: Christoffer Dall <christoffer.dall@linaro.org>
Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
---
 kvm-stub.c  | 51 ------------------------------------------------
 stubs/kvm.c | 65 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 65 insertions(+), 51 deletions(-)

diff --git a/kvm-stub.c b/kvm-stub.c
index b1b6b96..7ba697b 100644
--- a/kvm-stub.c
+++ b/kvm-stub.c
@@ -19,61 +19,10 @@
 #include "hw/pci/msi.h"
 #endif
 
-KVMState *kvm_state;
-bool kvm_kernel_irqchip;
-bool kvm_async_interrupts_allowed;
-bool kvm_eventfds_allowed;
-bool kvm_irqfds_allowed;
-bool kvm_resamplefds_allowed;
-bool kvm_msi_via_irqfd_allowed;
-bool kvm_gsi_routing_allowed;
-bool kvm_gsi_direct_mapping;
-bool kvm_allowed;
-bool kvm_readonly_mem_allowed;
-bool kvm_ioeventfd_any_length_allowed;
-bool kvm_msi_use_devid;
-
-int kvm_destroy_vcpu(CPUState *cpu)
-{
-    return -ENOSYS;
-}
-
-int kvm_init_vcpu(CPUState *cpu)
-{
-    return -ENOSYS;
-}
-
 void kvm_flush_coalesced_mmio_buffer(void)
 {
 }
 
-void kvm_cpu_synchronize_state(CPUState *cpu)
-{
-}
-
-void kvm_cpu_synchronize_post_reset(CPUState *cpu)
-{
-}
-
-void kvm_cpu_synchronize_post_init(CPUState *cpu)
-{
-}
-
-int kvm_cpu_exec(CPUState *cpu)
-{
-    abort();
-}
-
-int kvm_has_sync_mmu(void)
-{
-    return 0;
-}
-
-int kvm_has_many_ioeventfds(void)
-{
-    return 0;
-}
-
 int kvm_update_guest_debug(CPUState *cpu, unsigned long reinject_trap)
 {
     return -ENOSYS;
diff --git a/stubs/kvm.c b/stubs/kvm.c
index ddd6204..9d491c1 100644
--- a/stubs/kvm.c
+++ b/stubs/kvm.c
@@ -1,7 +1,72 @@
+/*
+ * QEMU KVM stub
+ *
+ * Copyright Red Hat, Inc. 2010
+ *
+ * Authors:
+ *  Christoffer Dall  <christoffer.dall@linaro.org>
+ *  Paolo Bonzini     <pbonzini@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-common.h"
 #include "sysemu/kvm.h"
 
+KVMState *kvm_state;
+bool kvm_kernel_irqchip;
+bool kvm_async_interrupts_allowed;
+bool kvm_eventfds_allowed;
+bool kvm_irqfds_allowed;
+bool kvm_resamplefds_allowed;
+bool kvm_msi_via_irqfd_allowed;
+bool kvm_gsi_routing_allowed;
+bool kvm_gsi_direct_mapping;
+bool kvm_allowed;
+bool kvm_readonly_mem_allowed;
+bool kvm_ioeventfd_any_length_allowed;
+bool kvm_msi_use_devid;
+
+int kvm_destroy_vcpu(CPUState *cpu)
+{
+    return -ENOSYS;
+}
+
+int kvm_init_vcpu(CPUState *cpu)
+{
+    return -ENOSYS;
+}
+
+void kvm_cpu_synchronize_state(CPUState *cpu)
+{
+}
+
+void kvm_cpu_synchronize_post_reset(CPUState *cpu)
+{
+}
+
+void kvm_cpu_synchronize_post_init(CPUState *cpu)
+{
+}
+
+int kvm_cpu_exec(CPUState *cpu)
+{
+    abort();
+}
+
+int kvm_has_sync_mmu(void)
+{
+    return 0;
+}
+
+int kvm_has_many_ioeventfds(void)
+{
+    return 0;
+}
+
 int kvm_arch_irqchip_create(MachineState *ms, KVMState *s)
 {
     return 0;
-- 
2.7.4

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

* [RFC 4/7] kvm: Include kvm-stub.o only on CONFIG_SOFTMMU
  2016-12-20 17:43 ` [Qemu-devel] " Eduardo Habkost
@ 2016-12-20 17:43   ` Eduardo Habkost
  -1 siblings, 0 replies; 37+ messages in thread
From: Eduardo Habkost @ 2016-12-20 17:43 UTC (permalink / raw)
  To: qemu-devel; +Cc: Paolo Bonzini, kvm

Now the stubs required by *-user are inside stubs/kvm.c, so
kvm-stub.c is needed only by CONFIG_SOFTMMU.

Cc: Paolo Bonzini <pbonzini@redhat.com>
Cc: kvm@vger.kernel.org
Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
---
 Makefile.target | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/Makefile.target b/Makefile.target
index 0b2ad86..5e78bb0 100644
--- a/Makefile.target
+++ b/Makefile.target
@@ -96,7 +96,6 @@ obj-y += target-$(TARGET_BASE_ARCH)/
 obj-y += disas.o
 obj-y += tcg-runtime.o
 obj-$(call notempty,$(TARGET_XML_FILES)) += gdbstub-xml.o
-obj-$(call lnot,$(CONFIG_KVM)) += kvm-stub.o
 
 obj-$(CONFIG_LIBDECNUMBER) += libdecnumber/decContext.o
 obj-$(CONFIG_LIBDECNUMBER) += libdecnumber/decNumber.o
@@ -138,6 +137,7 @@ obj-y += arch_init.o cpus.o monitor.o gdbstub.o balloon.o ioport.o numa.o
 obj-y += qtest.o bootdevice.o
 obj-y += hw/
 obj-$(CONFIG_KVM) += kvm-all.o
+obj-$(call lnot,$(CONFIG_KVM)) += kvm-stub.o
 obj-y += memory.o cputlb.o
 obj-y += memory_mapping.o
 obj-y += dump.o
-- 
2.7.4


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

* [Qemu-devel] [RFC 4/7] kvm: Include kvm-stub.o only on CONFIG_SOFTMMU
@ 2016-12-20 17:43   ` Eduardo Habkost
  0 siblings, 0 replies; 37+ messages in thread
From: Eduardo Habkost @ 2016-12-20 17:43 UTC (permalink / raw)
  To: qemu-devel; +Cc: Paolo Bonzini, kvm

Now the stubs required by *-user are inside stubs/kvm.c, so
kvm-stub.c is needed only by CONFIG_SOFTMMU.

Cc: Paolo Bonzini <pbonzini@redhat.com>
Cc: kvm@vger.kernel.org
Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
---
 Makefile.target | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/Makefile.target b/Makefile.target
index 0b2ad86..5e78bb0 100644
--- a/Makefile.target
+++ b/Makefile.target
@@ -96,7 +96,6 @@ obj-y += target-$(TARGET_BASE_ARCH)/
 obj-y += disas.o
 obj-y += tcg-runtime.o
 obj-$(call notempty,$(TARGET_XML_FILES)) += gdbstub-xml.o
-obj-$(call lnot,$(CONFIG_KVM)) += kvm-stub.o
 
 obj-$(CONFIG_LIBDECNUMBER) += libdecnumber/decContext.o
 obj-$(CONFIG_LIBDECNUMBER) += libdecnumber/decNumber.o
@@ -138,6 +137,7 @@ obj-y += arch_init.o cpus.o monitor.o gdbstub.o balloon.o ioport.o numa.o
 obj-y += qtest.o bootdevice.o
 obj-y += hw/
 obj-$(CONFIG_KVM) += kvm-all.o
+obj-$(call lnot,$(CONFIG_KVM)) += kvm-stub.o
 obj-y += memory.o cputlb.o
 obj-y += memory_mapping.o
 obj-y += dump.o
-- 
2.7.4

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

* [RFC 5/7] kvm: Move kvm*.c files to accel/
  2016-12-20 17:43 ` [Qemu-devel] " Eduardo Habkost
@ 2016-12-20 17:43   ` Eduardo Habkost
  -1 siblings, 0 replies; 37+ messages in thread
From: Eduardo Habkost @ 2016-12-20 17:43 UTC (permalink / raw)
  To: qemu-devel; +Cc: Paolo Bonzini, kvm

While doing it, rename kvm-all.c to kvm-common.c to follow the
same pattern used for xen.

Cc: Paolo Bonzini <pbonzini@redhat.com>
Cc: kvm@vger.kernel.org
Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
---
 Makefile.target                 | 2 --
 kvm-all.c => accel/kvm-common.c | 0
 kvm-stub.c => accel/kvm-stub.c  | 0
 MAINTAINERS                     | 3 +--
 accel/Makefile.objs             | 3 +++
 5 files changed, 4 insertions(+), 4 deletions(-)
 rename kvm-all.c => accel/kvm-common.c (100%)
 rename kvm-stub.c => accel/kvm-stub.c (100%)

diff --git a/Makefile.target b/Makefile.target
index 5e78bb0..70a1261 100644
--- a/Makefile.target
+++ b/Makefile.target
@@ -136,8 +136,6 @@ ifdef CONFIG_SOFTMMU
 obj-y += arch_init.o cpus.o monitor.o gdbstub.o balloon.o ioport.o numa.o
 obj-y += qtest.o bootdevice.o
 obj-y += hw/
-obj-$(CONFIG_KVM) += kvm-all.o
-obj-$(call lnot,$(CONFIG_KVM)) += kvm-stub.o
 obj-y += memory.o cputlb.o
 obj-y += memory_mapping.o
 obj-y += dump.o
diff --git a/kvm-all.c b/accel/kvm-common.c
similarity index 100%
rename from kvm-all.c
rename to accel/kvm-common.c
diff --git a/kvm-stub.c b/accel/kvm-stub.c
similarity index 100%
rename from kvm-stub.c
rename to accel/kvm-stub.c
diff --git a/MAINTAINERS b/MAINTAINERS
index 8e25438..9c6dae9 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -261,8 +261,7 @@ Overall
 M: Paolo Bonzini <pbonzini@redhat.com>
 L: kvm@vger.kernel.org
 S: Supported
-F: kvm-*
-F: */kvm.*
+F: */kvm*
 F: include/sysemu/kvm*.h
 
 ARM
diff --git a/accel/Makefile.objs b/accel/Makefile.objs
index 6f3630e..3f3866d 100644
--- a/accel/Makefile.objs
+++ b/accel/Makefile.objs
@@ -1,2 +1,5 @@
 obj-$(CONFIG_XEN) += xen-common.o
 obj-$(CONFIG_XEN_I386) += xen-hvm.o xen-mapcache.o
+
+obj-$(CONFIG_KVM) += kvm-common.o
+obj-$(call lnot,$(CONFIG_KVM)) += kvm-stub.o
-- 
2.7.4


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

* [Qemu-devel] [RFC 5/7] kvm: Move kvm*.c files to accel/
@ 2016-12-20 17:43   ` Eduardo Habkost
  0 siblings, 0 replies; 37+ messages in thread
From: Eduardo Habkost @ 2016-12-20 17:43 UTC (permalink / raw)
  To: qemu-devel; +Cc: Paolo Bonzini, kvm

While doing it, rename kvm-all.c to kvm-common.c to follow the
same pattern used for xen.

Cc: Paolo Bonzini <pbonzini@redhat.com>
Cc: kvm@vger.kernel.org
Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
---
 Makefile.target                 | 2 --
 kvm-all.c => accel/kvm-common.c | 0
 kvm-stub.c => accel/kvm-stub.c  | 0
 MAINTAINERS                     | 3 +--
 accel/Makefile.objs             | 3 +++
 5 files changed, 4 insertions(+), 4 deletions(-)
 rename kvm-all.c => accel/kvm-common.c (100%)
 rename kvm-stub.c => accel/kvm-stub.c (100%)

diff --git a/Makefile.target b/Makefile.target
index 5e78bb0..70a1261 100644
--- a/Makefile.target
+++ b/Makefile.target
@@ -136,8 +136,6 @@ ifdef CONFIG_SOFTMMU
 obj-y += arch_init.o cpus.o monitor.o gdbstub.o balloon.o ioport.o numa.o
 obj-y += qtest.o bootdevice.o
 obj-y += hw/
-obj-$(CONFIG_KVM) += kvm-all.o
-obj-$(call lnot,$(CONFIG_KVM)) += kvm-stub.o
 obj-y += memory.o cputlb.o
 obj-y += memory_mapping.o
 obj-y += dump.o
diff --git a/kvm-all.c b/accel/kvm-common.c
similarity index 100%
rename from kvm-all.c
rename to accel/kvm-common.c
diff --git a/kvm-stub.c b/accel/kvm-stub.c
similarity index 100%
rename from kvm-stub.c
rename to accel/kvm-stub.c
diff --git a/MAINTAINERS b/MAINTAINERS
index 8e25438..9c6dae9 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -261,8 +261,7 @@ Overall
 M: Paolo Bonzini <pbonzini@redhat.com>
 L: kvm@vger.kernel.org
 S: Supported
-F: kvm-*
-F: */kvm.*
+F: */kvm*
 F: include/sysemu/kvm*.h
 
 ARM
diff --git a/accel/Makefile.objs b/accel/Makefile.objs
index 6f3630e..3f3866d 100644
--- a/accel/Makefile.objs
+++ b/accel/Makefile.objs
@@ -1,2 +1,5 @@
 obj-$(CONFIG_XEN) += xen-common.o
 obj-$(CONFIG_XEN_I386) += xen-hvm.o xen-mapcache.o
+
+obj-$(CONFIG_KVM) += kvm-common.o
+obj-$(call lnot,$(CONFIG_KVM)) += kvm-stub.o
-- 
2.7.4

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

* [Qemu-devel] [RFC 6/7] accel: Move accel.c to accel/
  2016-12-20 17:43 ` [Qemu-devel] " Eduardo Habkost
                   ` (5 preceding siblings ...)
  (?)
@ 2016-12-20 17:43 ` Eduardo Habkost
  2016-12-21  7:30   ` Thomas Huth
  -1 siblings, 1 reply; 37+ messages in thread
From: Eduardo Habkost @ 2016-12-20 17:43 UTC (permalink / raw)
  To: qemu-devel

Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
---
 Makefile.objs            | 2 +-
 accel.c => accel/accel.c | 0
 accel/Makefile.objs      | 2 ++
 3 files changed, 3 insertions(+), 1 deletion(-)
 rename accel.c => accel/accel.c (100%)

diff --git a/Makefile.objs b/Makefile.objs
index 06f74b8..6d62f54 100644
--- a/Makefile.objs
+++ b/Makefile.objs
@@ -58,7 +58,7 @@ common-obj-$(CONFIG_SPICE) += spice-qemu-char.o
 
 common-obj-y += audio/
 common-obj-y += hw/
-common-obj-y += accel.o
+common-obj-y += accel/
 
 common-obj-y += replay/
 
diff --git a/accel.c b/accel/accel.c
similarity index 100%
rename from accel.c
rename to accel/accel.c
diff --git a/accel/Makefile.objs b/accel/Makefile.objs
index 3f3866d..52f7cac 100644
--- a/accel/Makefile.objs
+++ b/accel/Makefile.objs
@@ -3,3 +3,5 @@ obj-$(CONFIG_XEN_I386) += xen-hvm.o xen-mapcache.o
 
 obj-$(CONFIG_KVM) += kvm-common.o
 obj-$(call lnot,$(CONFIG_KVM)) += kvm-stub.o
+
+common-obj-y = accel.o
-- 
2.7.4

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

* [Qemu-devel] [RFC 7/7] accel: Move qtest.c to accel/
  2016-12-20 17:43 ` [Qemu-devel] " Eduardo Habkost
                   ` (6 preceding siblings ...)
  (?)
@ 2016-12-20 17:43 ` Eduardo Habkost
  -1 siblings, 0 replies; 37+ messages in thread
From: Eduardo Habkost @ 2016-12-20 17:43 UTC (permalink / raw)
  To: qemu-devel

Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
---
 Makefile.target          | 2 +-
 qtest.c => accel/qtest.c | 0
 accel/Makefile.objs      | 2 ++
 3 files changed, 3 insertions(+), 1 deletion(-)
 rename qtest.c => accel/qtest.c (100%)

diff --git a/Makefile.target b/Makefile.target
index 70a1261..fd319ac 100644
--- a/Makefile.target
+++ b/Makefile.target
@@ -134,7 +134,7 @@ endif #CONFIG_BSD_USER
 # System emulator target
 ifdef CONFIG_SOFTMMU
 obj-y += arch_init.o cpus.o monitor.o gdbstub.o balloon.o ioport.o numa.o
-obj-y += qtest.o bootdevice.o
+obj-y += bootdevice.o
 obj-y += hw/
 obj-y += memory.o cputlb.o
 obj-y += memory_mapping.o
diff --git a/qtest.c b/accel/qtest.c
similarity index 100%
rename from qtest.c
rename to accel/qtest.c
diff --git a/accel/Makefile.objs b/accel/Makefile.objs
index 52f7cac..a71bc78 100644
--- a/accel/Makefile.objs
+++ b/accel/Makefile.objs
@@ -4,4 +4,6 @@ obj-$(CONFIG_XEN_I386) += xen-hvm.o xen-mapcache.o
 obj-$(CONFIG_KVM) += kvm-common.o
 obj-$(call lnot,$(CONFIG_KVM)) += kvm-stub.o
 
+obj-y += qtest.o
+
 common-obj-y = accel.o
-- 
2.7.4

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

* Re: [RFC 0/7] Move accel, KVM, Xen, qtest files to accel/ subdir
  2016-12-20 17:43 ` [Qemu-devel] " Eduardo Habkost
@ 2016-12-20 19:01   ` Stefan Weil
  -1 siblings, 0 replies; 37+ messages in thread
From: Stefan Weil @ 2016-12-20 19:01 UTC (permalink / raw)
  To: Eduardo Habkost, qemu-devel
  Cc: Stefano Stabellini, kvm, xen-devel, Anthony Perard,
	Paolo Bonzini, Christoffer Dall

On 12/20/16 18:43, Eduardo Habkost wrote:
> This moves the KVM and Xen files to the an accel/ subdir.

I hope that it won't last long until we also get acceleration
for Windows and macOS. Those HAXM files will have to be moved
as well.

Regards,
Stefan

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

* Re: [Qemu-devel] [RFC 0/7] Move accel, KVM, Xen, qtest files to accel/ subdir
@ 2016-12-20 19:01   ` Stefan Weil
  0 siblings, 0 replies; 37+ messages in thread
From: Stefan Weil @ 2016-12-20 19:01 UTC (permalink / raw)
  To: Eduardo Habkost, qemu-devel
  Cc: Stefano Stabellini, kvm, xen-devel, Anthony Perard,
	Paolo Bonzini, Christoffer Dall

On 12/20/16 18:43, Eduardo Habkost wrote:
> This moves the KVM and Xen files to the an accel/ subdir.

I hope that it won't last long until we also get acceleration
for Windows and macOS. Those HAXM files will have to be moved
as well.

Regards,
Stefan

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

* Re: [RFC 0/7] Move accel, KVM, Xen, qtest files to accel/ subdir
  2016-12-20 17:43 ` [Qemu-devel] " Eduardo Habkost
@ 2016-12-21  0:31   ` Stefano Stabellini
  -1 siblings, 0 replies; 37+ messages in thread
From: Stefano Stabellini @ 2016-12-21  0:31 UTC (permalink / raw)
  To: Eduardo Habkost
  Cc: qemu-devel, Paolo Bonzini, kvm, Christoffer Dall, Anthony Perard,
	Stefano Stabellini, xen-devel

On Tue, 20 Dec 2016, Eduardo Habkost wrote:
> This moves the KVM and Xen files to the an accel/ subdir.
> 
> Instead of moving the *-stubs.c file to accel/ as-is, I tried to
> move most of the stub code to libqemustub.a. This way the obj-y
> logic for accel/ is simpler: obj-y includes accel/ only if
> CONFIG_SOFTMMU is set.
> 
> The Xen stubs could be moved completely to stubs/, but some of
> the KVM stubs depend on cpu.h. So most of the kvm-stub.c code was
> moved to stubs/kvm.c, but some of that code was kept in
> accel/kvm-stub.c.

Fine by me. My build test succeeded.


> About TCG:
> ----------
> 
> It is not obvious to me which TCG-related files could be moved to
> accel/, so this series don't move any of them yet.
> 
> About other CONFIG_SOFTMMU top-level files:
> -------------------------------------------
> 
> I would like to know what we should do with the top-level
> CONFIG_SOFTMMU-only files that don't belong to hw/. Some
> candidates: arch_init.c cpus.c monitor.c gdbstub.c balloon.c
> ioport.c bootdevice.c memory.c cputlb.c memory_mapping.c dump.c.
> 
> Maybe a sysemu/ subdir? In that case, should we still create an
> accel/ subdir, or move xen-*, kvm-* and friends to sysemu/ too?
> 
> Cc: Paolo Bonzini <pbonzini@redhat.com>
> Cc: kvm@vger.kernel.org
> Cc: Christoffer Dall <christoffer.dall@linaro.org>
> Cc: Anthony Perard <anthony.perard@citrix.com>
> Cc: Stefano Stabellini <sstabellini@kernel.org>
> Cc: xen-devel@lists.xensource.com
> 
> Eduardo Habkost (7):
>   xen: Move xen-*-stub.c to stubs/
>   xen: Move xen files to accel/
>   kvm: Move some kvm-stub.c code to stubs/kvm.c
>   kvm: Include kvm-stub.o only on CONFIG_SOFTMMU
>   kvm: Move kvm*.c files to accel/
>   accel: Move accel.c to accel/
>   accel: Move qtest.c to accel/
> 
>  Makefile.objs                          |  2 +-
>  Makefile.target                        | 10 ++----
>  accel.c => accel/accel.c               |  0
>  kvm-all.c => accel/kvm-common.c        |  0
>  kvm-stub.c => accel/kvm-stub.c         | 51 --------------------------
>  qtest.c => accel/qtest.c               |  0
>  xen-common.c => accel/xen-common.c     |  0
>  xen-hvm.c => accel/xen-hvm.c           |  0
>  xen-mapcache.c => accel/xen-mapcache.c |  0
>  stubs/kvm.c                            | 65 ++++++++++++++++++++++++++++++++++
>  xen-hvm-stub.c => stubs/xen-hvm.c      |  0
>  xen-common-stub.c => stubs/xen.c       |  0
>  MAINTAINERS                            |  4 +--
>  accel/Makefile.objs                    |  9 +++++
>  stubs/Makefile.objs                    |  2 ++
>  15 files changed, 80 insertions(+), 63 deletions(-)
>  rename accel.c => accel/accel.c (100%)
>  rename kvm-all.c => accel/kvm-common.c (100%)
>  rename kvm-stub.c => accel/kvm-stub.c (71%)
>  rename qtest.c => accel/qtest.c (100%)
>  rename xen-common.c => accel/xen-common.c (100%)
>  rename xen-hvm.c => accel/xen-hvm.c (100%)
>  rename xen-mapcache.c => accel/xen-mapcache.c (100%)
>  rename xen-hvm-stub.c => stubs/xen-hvm.c (100%)
>  rename xen-common-stub.c => stubs/xen.c (100%)
>  create mode 100644 accel/Makefile.objs
> 
> -- 
> 2.7.4
> 

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

* Re: [Qemu-devel] [RFC 0/7] Move accel, KVM, Xen, qtest files to accel/ subdir
@ 2016-12-21  0:31   ` Stefano Stabellini
  0 siblings, 0 replies; 37+ messages in thread
From: Stefano Stabellini @ 2016-12-21  0:31 UTC (permalink / raw)
  To: Eduardo Habkost
  Cc: qemu-devel, Paolo Bonzini, kvm, Christoffer Dall, Anthony Perard,
	Stefano Stabellini, xen-devel

On Tue, 20 Dec 2016, Eduardo Habkost wrote:
> This moves the KVM and Xen files to the an accel/ subdir.
> 
> Instead of moving the *-stubs.c file to accel/ as-is, I tried to
> move most of the stub code to libqemustub.a. This way the obj-y
> logic for accel/ is simpler: obj-y includes accel/ only if
> CONFIG_SOFTMMU is set.
> 
> The Xen stubs could be moved completely to stubs/, but some of
> the KVM stubs depend on cpu.h. So most of the kvm-stub.c code was
> moved to stubs/kvm.c, but some of that code was kept in
> accel/kvm-stub.c.

Fine by me. My build test succeeded.


> About TCG:
> ----------
> 
> It is not obvious to me which TCG-related files could be moved to
> accel/, so this series don't move any of them yet.
> 
> About other CONFIG_SOFTMMU top-level files:
> -------------------------------------------
> 
> I would like to know what we should do with the top-level
> CONFIG_SOFTMMU-only files that don't belong to hw/. Some
> candidates: arch_init.c cpus.c monitor.c gdbstub.c balloon.c
> ioport.c bootdevice.c memory.c cputlb.c memory_mapping.c dump.c.
> 
> Maybe a sysemu/ subdir? In that case, should we still create an
> accel/ subdir, or move xen-*, kvm-* and friends to sysemu/ too?
> 
> Cc: Paolo Bonzini <pbonzini@redhat.com>
> Cc: kvm@vger.kernel.org
> Cc: Christoffer Dall <christoffer.dall@linaro.org>
> Cc: Anthony Perard <anthony.perard@citrix.com>
> Cc: Stefano Stabellini <sstabellini@kernel.org>
> Cc: xen-devel@lists.xensource.com
> 
> Eduardo Habkost (7):
>   xen: Move xen-*-stub.c to stubs/
>   xen: Move xen files to accel/
>   kvm: Move some kvm-stub.c code to stubs/kvm.c
>   kvm: Include kvm-stub.o only on CONFIG_SOFTMMU
>   kvm: Move kvm*.c files to accel/
>   accel: Move accel.c to accel/
>   accel: Move qtest.c to accel/
> 
>  Makefile.objs                          |  2 +-
>  Makefile.target                        | 10 ++----
>  accel.c => accel/accel.c               |  0
>  kvm-all.c => accel/kvm-common.c        |  0
>  kvm-stub.c => accel/kvm-stub.c         | 51 --------------------------
>  qtest.c => accel/qtest.c               |  0
>  xen-common.c => accel/xen-common.c     |  0
>  xen-hvm.c => accel/xen-hvm.c           |  0
>  xen-mapcache.c => accel/xen-mapcache.c |  0
>  stubs/kvm.c                            | 65 ++++++++++++++++++++++++++++++++++
>  xen-hvm-stub.c => stubs/xen-hvm.c      |  0
>  xen-common-stub.c => stubs/xen.c       |  0
>  MAINTAINERS                            |  4 +--
>  accel/Makefile.objs                    |  9 +++++
>  stubs/Makefile.objs                    |  2 ++
>  15 files changed, 80 insertions(+), 63 deletions(-)
>  rename accel.c => accel/accel.c (100%)
>  rename kvm-all.c => accel/kvm-common.c (100%)
>  rename kvm-stub.c => accel/kvm-stub.c (71%)
>  rename qtest.c => accel/qtest.c (100%)
>  rename xen-common.c => accel/xen-common.c (100%)
>  rename xen-hvm.c => accel/xen-hvm.c (100%)
>  rename xen-mapcache.c => accel/xen-mapcache.c (100%)
>  rename xen-hvm-stub.c => stubs/xen-hvm.c (100%)
>  rename xen-common-stub.c => stubs/xen.c (100%)
>  create mode 100644 accel/Makefile.objs
> 
> -- 
> 2.7.4
> 

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

* Re: [Qemu-devel] [RFC 4/7] kvm: Include kvm-stub.o only on CONFIG_SOFTMMU
  2016-12-20 17:43   ` [Qemu-devel] " Eduardo Habkost
  (?)
@ 2016-12-21  7:27   ` Thomas Huth
  2016-12-21  8:44     ` David Hildenbrand
  -1 siblings, 1 reply; 37+ messages in thread
From: Thomas Huth @ 2016-12-21  7:27 UTC (permalink / raw)
  To: Eduardo Habkost, qemu-devel; +Cc: Paolo Bonzini, kvm

On 20.12.2016 18:43, Eduardo Habkost wrote:
> Now the stubs required by *-user are inside stubs/kvm.c, so
> kvm-stub.c is needed only by CONFIG_SOFTMMU.
> 
> Cc: Paolo Bonzini <pbonzini@redhat.com>
> Cc: kvm@vger.kernel.org
> Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
> ---
>  Makefile.target | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/Makefile.target b/Makefile.target
> index 0b2ad86..5e78bb0 100644
> --- a/Makefile.target
> +++ b/Makefile.target
> @@ -96,7 +96,6 @@ obj-y += target-$(TARGET_BASE_ARCH)/
>  obj-y += disas.o
>  obj-y += tcg-runtime.o
>  obj-$(call notempty,$(TARGET_XML_FILES)) += gdbstub-xml.o
> -obj-$(call lnot,$(CONFIG_KVM)) += kvm-stub.o
>  
>  obj-$(CONFIG_LIBDECNUMBER) += libdecnumber/decContext.o
>  obj-$(CONFIG_LIBDECNUMBER) += libdecnumber/decNumber.o
> @@ -138,6 +137,7 @@ obj-y += arch_init.o cpus.o monitor.o gdbstub.o balloon.o ioport.o numa.o
>  obj-y += qtest.o bootdevice.o
>  obj-y += hw/
>  obj-$(CONFIG_KVM) += kvm-all.o
> +obj-$(call lnot,$(CONFIG_KVM)) += kvm-stub.o
>  obj-y += memory.o cputlb.o
>  obj-y += memory_mapping.o
>  obj-y += dump.o

<bikeshedding>
IMHO you could also squash this change into the next patch (and just
mention it in the commit description).
</bikeshedding>

 Thomas


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

* Re: [Qemu-devel] [RFC 6/7] accel: Move accel.c to accel/
  2016-12-20 17:43 ` [Qemu-devel] [RFC 6/7] accel: Move accel.c " Eduardo Habkost
@ 2016-12-21  7:30   ` Thomas Huth
  0 siblings, 0 replies; 37+ messages in thread
From: Thomas Huth @ 2016-12-21  7:30 UTC (permalink / raw)
  To: Eduardo Habkost, qemu-devel

On 20.12.2016 18:43, Eduardo Habkost wrote:
> Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
> ---
>  Makefile.objs            | 2 +-
>  accel.c => accel/accel.c | 0
>  accel/Makefile.objs      | 2 ++
>  3 files changed, 3 insertions(+), 1 deletion(-)
>  rename accel.c => accel/accel.c (100%)
> 
> diff --git a/Makefile.objs b/Makefile.objs
> index 06f74b8..6d62f54 100644
> --- a/Makefile.objs
> +++ b/Makefile.objs
> @@ -58,7 +58,7 @@ common-obj-$(CONFIG_SPICE) += spice-qemu-char.o
>  
>  common-obj-y += audio/
>  common-obj-y += hw/
> -common-obj-y += accel.o
> +common-obj-y += accel/

Not sure, but there is already "obj-y += accel/" in patch 2 ... do we
need both ?

 Thomas

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

* Re: [Qemu-devel] [RFC 0/7] Move accel, KVM, Xen, qtest files to accel/ subdir
  2016-12-20 17:43 ` [Qemu-devel] " Eduardo Habkost
                   ` (9 preceding siblings ...)
  (?)
@ 2016-12-21  7:37 ` Thomas Huth
  -1 siblings, 0 replies; 37+ messages in thread
From: Thomas Huth @ 2016-12-21  7:37 UTC (permalink / raw)
  To: Eduardo Habkost, qemu-devel
  Cc: Stefano Stabellini, kvm, xen-devel, Anthony Perard,
	Paolo Bonzini, Christoffer Dall

On 20.12.2016 18:43, Eduardo Habkost wrote:
> This moves the KVM and Xen files to the an accel/ subdir.
> 
> Instead of moving the *-stubs.c file to accel/ as-is, I tried to
> move most of the stub code to libqemustub.a. This way the obj-y
> logic for accel/ is simpler: obj-y includes accel/ only if
> CONFIG_SOFTMMU is set.
> 
> The Xen stubs could be moved completely to stubs/, but some of
> the KVM stubs depend on cpu.h. So most of the kvm-stub.c code was
> moved to stubs/kvm.c, but some of that code was kept in
> accel/kvm-stub.c.

Thanks for cleaning this up!

> About other CONFIG_SOFTMMU top-level files:
> -------------------------------------------
> 
> I would like to know what we should do with the top-level
> CONFIG_SOFTMMU-only files that don't belong to hw/. Some
> candidates: arch_init.c cpus.c monitor.c gdbstub.c balloon.c
> ioport.c bootdevice.c memory.c cputlb.c memory_mapping.c dump.c.

arch_init.c is a potpourri of various topics, I think we should rather
split this file up and move the parts to other (new?) files, e.g. the
sound specific parts to the audio/ directory.

I think somebody (Paolo?) also suggested a monitor/ directory already,
so monitor.c and gdbstub.c could go into that directory?

> Maybe a sysemu/ subdir? In that case, should we still create an
> accel/ subdir, or move xen-*, kvm-* and friends to sysemu/ too?

IMHO the separate accel/ directory is fine. After your patch series,
there are already quite a bunch of files in it, and if Stefan Weil is
right, we'll soon get acceleration for Windows and macOS, too, so the
separate directory is justified.

 Thomas


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

* Re: [RFC 3/7] kvm: Move some kvm-stub.c code to stubs/kvm.c
  2016-12-20 17:43   ` [Qemu-devel] " Eduardo Habkost
@ 2016-12-21  8:42     ` David Hildenbrand
  -1 siblings, 0 replies; 37+ messages in thread
From: David Hildenbrand @ 2016-12-21  8:42 UTC (permalink / raw)
  To: Eduardo Habkost, qemu-devel; +Cc: Paolo Bonzini, kvm, Christoffer Dall

Am 20.12.2016 um 18:43 schrieb Eduardo Habkost:
> Move the kvm-stub.c code that doesn't depend on cpu.h or CONFIG_*
> defines to stubs/kvm.c.
>
> Notes about copyright, licensing, and authorship:
>
> * There was no copyright not on the original stubs/kvm.c file.
> * As include/sysemu/kvm.h and kvm-all.c are licensed as
>   GPLv2+, I am assuming stubs/kvm.c file is also licensed as
>   GPLv2+.
> * I have copied the copyright info from kvm-stub.c and added the
>   original author of stubs/kvm.c (Christoffer Dall) to the author
>   list.
>
> Cc: Paolo Bonzini <pbonzini@redhat.com>
> Cc: kvm@vger.kernel.org
> Cc: Christoffer Dall <christoffer.dall@linaro.org>
> Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>

Reviewed-by: David Hildenbrand <david@redhat.com>

Guess we have to wait for an ack of paolo and christoffer.

-- 

David

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

* Re: [Qemu-devel] [RFC 3/7] kvm: Move some kvm-stub.c code to stubs/kvm.c
@ 2016-12-21  8:42     ` David Hildenbrand
  0 siblings, 0 replies; 37+ messages in thread
From: David Hildenbrand @ 2016-12-21  8:42 UTC (permalink / raw)
  To: Eduardo Habkost, qemu-devel; +Cc: Paolo Bonzini, kvm, Christoffer Dall

Am 20.12.2016 um 18:43 schrieb Eduardo Habkost:
> Move the kvm-stub.c code that doesn't depend on cpu.h or CONFIG_*
> defines to stubs/kvm.c.
>
> Notes about copyright, licensing, and authorship:
>
> * There was no copyright not on the original stubs/kvm.c file.
> * As include/sysemu/kvm.h and kvm-all.c are licensed as
>   GPLv2+, I am assuming stubs/kvm.c file is also licensed as
>   GPLv2+.
> * I have copied the copyright info from kvm-stub.c and added the
>   original author of stubs/kvm.c (Christoffer Dall) to the author
>   list.
>
> Cc: Paolo Bonzini <pbonzini@redhat.com>
> Cc: kvm@vger.kernel.org
> Cc: Christoffer Dall <christoffer.dall@linaro.org>
> Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>

Reviewed-by: David Hildenbrand <david@redhat.com>

Guess we have to wait for an ack of paolo and christoffer.

-- 

David

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

* Re: [Qemu-devel] [RFC 4/7] kvm: Include kvm-stub.o only on CONFIG_SOFTMMU
  2016-12-21  7:27   ` Thomas Huth
@ 2016-12-21  8:44     ` David Hildenbrand
  0 siblings, 0 replies; 37+ messages in thread
From: David Hildenbrand @ 2016-12-21  8:44 UTC (permalink / raw)
  To: Thomas Huth, Eduardo Habkost, qemu-devel; +Cc: Paolo Bonzini, kvm


>>  obj-$(CONFIG_LIBDECNUMBER) += libdecnumber/decContext.o
>>  obj-$(CONFIG_LIBDECNUMBER) += libdecnumber/decNumber.o
>> @@ -138,6 +137,7 @@ obj-y += arch_init.o cpus.o monitor.o gdbstub.o balloon.o ioport.o numa.o
>>  obj-y += qtest.o bootdevice.o
>>  obj-y += hw/
>>  obj-$(CONFIG_KVM) += kvm-all.o
>> +obj-$(call lnot,$(CONFIG_KVM)) += kvm-stub.o
>>  obj-y += memory.o cputlb.o
>>  obj-y += memory_mapping.o
>>  obj-y += dump.o
>
> <bikeshedding>
> IMHO you could also squash this change into the next patch (and just
> mention it in the commit description).
> </bikeshedding>

+1

-- 

David

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

* Re: [RFC 0/7] Move accel, KVM, Xen, qtest files to accel/ subdir
  2016-12-20 17:43 ` [Qemu-devel] " Eduardo Habkost
@ 2016-12-21 11:21   ` Paolo Bonzini
  -1 siblings, 0 replies; 37+ messages in thread
From: Paolo Bonzini @ 2016-12-21 11:21 UTC (permalink / raw)
  To: Eduardo Habkost, qemu-devel
  Cc: kvm, Christoffer Dall, Anthony Perard, Stefano Stabellini, xen-devel



On 20/12/2016 18:43, Eduardo Habkost wrote:
> This moves the KVM and Xen files to the an accel/ subdir.
> 
> Instead of moving the *-stubs.c file to accel/ as-is, I tried to
> move most of the stub code to libqemustub.a. This way the obj-y
> logic for accel/ is simpler: obj-y includes accel/ only if
> CONFIG_SOFTMMU is set.
> 
> The Xen stubs could be moved completely to stubs/, but some of
> the KVM stubs depend on cpu.h. So most of the kvm-stub.c code was
> moved to stubs/kvm.c, but some of that code was kept in
> accel/kvm-stub.c.

I think we need to decide what libqemustub is for.

The original purpose was to provide different implementations of some
functions for tools vs. emulators or (more rarely) for user-mode vs.
system emulation.

There are also some cases where we use it for functions that are only
implemented by some targets.

In general, I think libqemustub should be the last resort.  If possible,
inlines in headers should be the first choice, and stubs in objs-y or
common-objs-y (using $(call lnot) in the Makefile) should be the second.

The reason is that stubs/ hides files from the corresponding maintainer;
for example, commit 07a32d6b's addition of stubs/get-next-serial.c was
in all likelihood unnecessary, but the new file went in without an ack
for a character device maintainer.  Tracking stubs in the MAINTAINERS
file is unwieldy and, from this point of view, I find

	F: accel/kvm*

to be preferrable to

	F: accel/kvm*
	F: stubs/kvm.c

Thanks,

Paolo

> About TCG:
> ----------
> 
> It is not obvious to me which TCG-related files could be moved to
> accel/, so this series don't move any of them yet.
> 
> About other CONFIG_SOFTMMU top-level files:
> -------------------------------------------
> 
> I would like to know what we should do with the top-level
> CONFIG_SOFTMMU-only files that don't belong to hw/. Some
> candidates: arch_init.c cpus.c monitor.c gdbstub.c balloon.c
> ioport.c bootdevice.c memory.c cputlb.c memory_mapping.c dump.c.
> 
> Maybe a sysemu/ subdir? In that case, should we still create an
> accel/ subdir, or move xen-*, kvm-* and friends to sysemu/ too?
> 
> Cc: Paolo Bonzini <pbonzini@redhat.com>
> Cc: kvm@vger.kernel.org
> Cc: Christoffer Dall <christoffer.dall@linaro.org>
> Cc: Anthony Perard <anthony.perard@citrix.com>
> Cc: Stefano Stabellini <sstabellini@kernel.org>
> Cc: xen-devel@lists.xensource.com
> 
> Eduardo Habkost (7):
>   xen: Move xen-*-stub.c to stubs/
>   xen: Move xen files to accel/
>   kvm: Move some kvm-stub.c code to stubs/kvm.c
>   kvm: Include kvm-stub.o only on CONFIG_SOFTMMU
>   kvm: Move kvm*.c files to accel/
>   accel: Move accel.c to accel/
>   accel: Move qtest.c to accel/

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

* Re: [Qemu-devel] [RFC 0/7] Move accel, KVM, Xen, qtest files to accel/ subdir
@ 2016-12-21 11:21   ` Paolo Bonzini
  0 siblings, 0 replies; 37+ messages in thread
From: Paolo Bonzini @ 2016-12-21 11:21 UTC (permalink / raw)
  To: Eduardo Habkost, qemu-devel
  Cc: kvm, Christoffer Dall, Anthony Perard, Stefano Stabellini, xen-devel



On 20/12/2016 18:43, Eduardo Habkost wrote:
> This moves the KVM and Xen files to the an accel/ subdir.
> 
> Instead of moving the *-stubs.c file to accel/ as-is, I tried to
> move most of the stub code to libqemustub.a. This way the obj-y
> logic for accel/ is simpler: obj-y includes accel/ only if
> CONFIG_SOFTMMU is set.
> 
> The Xen stubs could be moved completely to stubs/, but some of
> the KVM stubs depend on cpu.h. So most of the kvm-stub.c code was
> moved to stubs/kvm.c, but some of that code was kept in
> accel/kvm-stub.c.

I think we need to decide what libqemustub is for.

The original purpose was to provide different implementations of some
functions for tools vs. emulators or (more rarely) for user-mode vs.
system emulation.

There are also some cases where we use it for functions that are only
implemented by some targets.

In general, I think libqemustub should be the last resort.  If possible,
inlines in headers should be the first choice, and stubs in objs-y or
common-objs-y (using $(call lnot) in the Makefile) should be the second.

The reason is that stubs/ hides files from the corresponding maintainer;
for example, commit 07a32d6b's addition of stubs/get-next-serial.c was
in all likelihood unnecessary, but the new file went in without an ack
for a character device maintainer.  Tracking stubs in the MAINTAINERS
file is unwieldy and, from this point of view, I find

	F: accel/kvm*

to be preferrable to

	F: accel/kvm*
	F: stubs/kvm.c

Thanks,

Paolo

> About TCG:
> ----------
> 
> It is not obvious to me which TCG-related files could be moved to
> accel/, so this series don't move any of them yet.
> 
> About other CONFIG_SOFTMMU top-level files:
> -------------------------------------------
> 
> I would like to know what we should do with the top-level
> CONFIG_SOFTMMU-only files that don't belong to hw/. Some
> candidates: arch_init.c cpus.c monitor.c gdbstub.c balloon.c
> ioport.c bootdevice.c memory.c cputlb.c memory_mapping.c dump.c.
> 
> Maybe a sysemu/ subdir? In that case, should we still create an
> accel/ subdir, or move xen-*, kvm-* and friends to sysemu/ too?
> 
> Cc: Paolo Bonzini <pbonzini@redhat.com>
> Cc: kvm@vger.kernel.org
> Cc: Christoffer Dall <christoffer.dall@linaro.org>
> Cc: Anthony Perard <anthony.perard@citrix.com>
> Cc: Stefano Stabellini <sstabellini@kernel.org>
> Cc: xen-devel@lists.xensource.com
> 
> Eduardo Habkost (7):
>   xen: Move xen-*-stub.c to stubs/
>   xen: Move xen files to accel/
>   kvm: Move some kvm-stub.c code to stubs/kvm.c
>   kvm: Include kvm-stub.o only on CONFIG_SOFTMMU
>   kvm: Move kvm*.c files to accel/
>   accel: Move accel.c to accel/
>   accel: Move qtest.c to accel/

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

* Re: [RFC 0/7] Move accel, KVM, Xen, qtest files to accel/ subdir
  2016-12-21 11:21   ` [Qemu-devel] " Paolo Bonzini
@ 2016-12-21 13:14     ` Eduardo Habkost
  -1 siblings, 0 replies; 37+ messages in thread
From: Eduardo Habkost @ 2016-12-21 13:14 UTC (permalink / raw)
  To: Paolo Bonzini
  Cc: qemu-devel, kvm, Christoffer Dall, Anthony Perard,
	Stefano Stabellini, xen-devel

On Wed, Dec 21, 2016 at 12:21:44PM +0100, Paolo Bonzini wrote:
> 
> 
> On 20/12/2016 18:43, Eduardo Habkost wrote:
> > This moves the KVM and Xen files to the an accel/ subdir.
> > 
> > Instead of moving the *-stubs.c file to accel/ as-is, I tried to
> > move most of the stub code to libqemustub.a. This way the obj-y
> > logic for accel/ is simpler: obj-y includes accel/ only if
> > CONFIG_SOFTMMU is set.
> > 
> > The Xen stubs could be moved completely to stubs/, but some of
> > the KVM stubs depend on cpu.h. So most of the kvm-stub.c code was
> > moved to stubs/kvm.c, but some of that code was kept in
> > accel/kvm-stub.c.
> 
> I think we need to decide what libqemustub is for.
> 
> The original purpose was to provide different implementations of some
> functions for tools vs. emulators or (more rarely) for user-mode vs.
> system emulation.
> 

So, is sysemu vs user-mode a valid reason for using libqemustub?
The main reason I have moved some code to sbus/kvm.c is to avoid
having to include accel/kvm-stub.c in *-user.

Moving xen-stub.c to libqemustub, on the other hand, is really
unnecessary.

> There are also some cases where we use it for functions that are only
> implemented by some targets.
> 
> In general, I think libqemustub should be the last resort.  If possible,
> inlines in headers should be the first choice, and stubs in objs-y or
> common-objs-y (using $(call lnot) in the Makefile) should be the second.

I understand the reasoning, but I fail to see cases when
libqemustub would be considered appropriate. Using stubs in
obj-y/common-obj-y using $(call lnot) is always possible, isn't
it?

Hmm, maybe on cases where the decision to use the stub doesn't
depend on a single build variable (e.g. a function implemented by
a handful of targets, but not all of them). Are there other
examples?

> 
> The reason is that stubs/ hides files from the corresponding maintainer;
> for example, commit 07a32d6b's addition of stubs/get-next-serial.c was
> in all likelihood unnecessary, but the new file went in without an ack
> for a character device maintainer.  Tracking stubs in the MAINTAINERS
> file is unwieldy and, from this point of view, I find
> 
> 	F: accel/kvm*
> 
> to be preferrable to
> 
> 	F: accel/kvm*
> 	F: stubs/kvm.c

> 
> Thanks,
> 
> Paolo
> 
> > About TCG:
> > ----------
> > 
> > It is not obvious to me which TCG-related files could be moved to
> > accel/, so this series don't move any of them yet.
> > 
> > About other CONFIG_SOFTMMU top-level files:
> > -------------------------------------------
> > 
> > I would like to know what we should do with the top-level
> > CONFIG_SOFTMMU-only files that don't belong to hw/. Some
> > candidates: arch_init.c cpus.c monitor.c gdbstub.c balloon.c
> > ioport.c bootdevice.c memory.c cputlb.c memory_mapping.c dump.c.
> > 
> > Maybe a sysemu/ subdir? In that case, should we still create an
> > accel/ subdir, or move xen-*, kvm-* and friends to sysemu/ too?
> > 
> > Cc: Paolo Bonzini <pbonzini@redhat.com>
> > Cc: kvm@vger.kernel.org
> > Cc: Christoffer Dall <christoffer.dall@linaro.org>
> > Cc: Anthony Perard <anthony.perard@citrix.com>
> > Cc: Stefano Stabellini <sstabellini@kernel.org>
> > Cc: xen-devel@lists.xensource.com
> > 
> > Eduardo Habkost (7):
> >   xen: Move xen-*-stub.c to stubs/
> >   xen: Move xen files to accel/
> >   kvm: Move some kvm-stub.c code to stubs/kvm.c
> >   kvm: Include kvm-stub.o only on CONFIG_SOFTMMU
> >   kvm: Move kvm*.c files to accel/
> >   accel: Move accel.c to accel/
> >   accel: Move qtest.c to accel/

-- 
Eduardo

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

* Re: [Qemu-devel] [RFC 0/7] Move accel, KVM, Xen, qtest files to accel/ subdir
@ 2016-12-21 13:14     ` Eduardo Habkost
  0 siblings, 0 replies; 37+ messages in thread
From: Eduardo Habkost @ 2016-12-21 13:14 UTC (permalink / raw)
  To: Paolo Bonzini
  Cc: qemu-devel, kvm, Christoffer Dall, Anthony Perard,
	Stefano Stabellini, xen-devel

On Wed, Dec 21, 2016 at 12:21:44PM +0100, Paolo Bonzini wrote:
> 
> 
> On 20/12/2016 18:43, Eduardo Habkost wrote:
> > This moves the KVM and Xen files to the an accel/ subdir.
> > 
> > Instead of moving the *-stubs.c file to accel/ as-is, I tried to
> > move most of the stub code to libqemustub.a. This way the obj-y
> > logic for accel/ is simpler: obj-y includes accel/ only if
> > CONFIG_SOFTMMU is set.
> > 
> > The Xen stubs could be moved completely to stubs/, but some of
> > the KVM stubs depend on cpu.h. So most of the kvm-stub.c code was
> > moved to stubs/kvm.c, but some of that code was kept in
> > accel/kvm-stub.c.
> 
> I think we need to decide what libqemustub is for.
> 
> The original purpose was to provide different implementations of some
> functions for tools vs. emulators or (more rarely) for user-mode vs.
> system emulation.
> 

So, is sysemu vs user-mode a valid reason for using libqemustub?
The main reason I have moved some code to sbus/kvm.c is to avoid
having to include accel/kvm-stub.c in *-user.

Moving xen-stub.c to libqemustub, on the other hand, is really
unnecessary.

> There are also some cases where we use it for functions that are only
> implemented by some targets.
> 
> In general, I think libqemustub should be the last resort.  If possible,
> inlines in headers should be the first choice, and stubs in objs-y or
> common-objs-y (using $(call lnot) in the Makefile) should be the second.

I understand the reasoning, but I fail to see cases when
libqemustub would be considered appropriate. Using stubs in
obj-y/common-obj-y using $(call lnot) is always possible, isn't
it?

Hmm, maybe on cases where the decision to use the stub doesn't
depend on a single build variable (e.g. a function implemented by
a handful of targets, but not all of them). Are there other
examples?

> 
> The reason is that stubs/ hides files from the corresponding maintainer;
> for example, commit 07a32d6b's addition of stubs/get-next-serial.c was
> in all likelihood unnecessary, but the new file went in without an ack
> for a character device maintainer.  Tracking stubs in the MAINTAINERS
> file is unwieldy and, from this point of view, I find
> 
> 	F: accel/kvm*
> 
> to be preferrable to
> 
> 	F: accel/kvm*
> 	F: stubs/kvm.c

> 
> Thanks,
> 
> Paolo
> 
> > About TCG:
> > ----------
> > 
> > It is not obvious to me which TCG-related files could be moved to
> > accel/, so this series don't move any of them yet.
> > 
> > About other CONFIG_SOFTMMU top-level files:
> > -------------------------------------------
> > 
> > I would like to know what we should do with the top-level
> > CONFIG_SOFTMMU-only files that don't belong to hw/. Some
> > candidates: arch_init.c cpus.c monitor.c gdbstub.c balloon.c
> > ioport.c bootdevice.c memory.c cputlb.c memory_mapping.c dump.c.
> > 
> > Maybe a sysemu/ subdir? In that case, should we still create an
> > accel/ subdir, or move xen-*, kvm-* and friends to sysemu/ too?
> > 
> > Cc: Paolo Bonzini <pbonzini@redhat.com>
> > Cc: kvm@vger.kernel.org
> > Cc: Christoffer Dall <christoffer.dall@linaro.org>
> > Cc: Anthony Perard <anthony.perard@citrix.com>
> > Cc: Stefano Stabellini <sstabellini@kernel.org>
> > Cc: xen-devel@lists.xensource.com
> > 
> > Eduardo Habkost (7):
> >   xen: Move xen-*-stub.c to stubs/
> >   xen: Move xen files to accel/
> >   kvm: Move some kvm-stub.c code to stubs/kvm.c
> >   kvm: Include kvm-stub.o only on CONFIG_SOFTMMU
> >   kvm: Move kvm*.c files to accel/
> >   accel: Move accel.c to accel/
> >   accel: Move qtest.c to accel/

-- 
Eduardo

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

* Re: [RFC 0/7] Move accel, KVM, Xen, qtest files to accel/ subdir
  2016-12-21 13:14     ` [Qemu-devel] " Eduardo Habkost
@ 2016-12-21 13:47       ` Paolo Bonzini
  -1 siblings, 0 replies; 37+ messages in thread
From: Paolo Bonzini @ 2016-12-21 13:47 UTC (permalink / raw)
  To: Eduardo Habkost
  Cc: qemu-devel, kvm, Christoffer Dall, Anthony Perard,
	Stefano Stabellini, xen-devel



On 21/12/2016 14:14, Eduardo Habkost wrote:
> On Wed, Dec 21, 2016 at 12:21:44PM +0100, Paolo Bonzini wrote:
>>
>>
>> On 20/12/2016 18:43, Eduardo Habkost wrote:
>>> This moves the KVM and Xen files to the an accel/ subdir.
>>>
>>> Instead of moving the *-stubs.c file to accel/ as-is, I tried to
>>> move most of the stub code to libqemustub.a. This way the obj-y
>>> logic for accel/ is simpler: obj-y includes accel/ only if
>>> CONFIG_SOFTMMU is set.
>>>
>>> The Xen stubs could be moved completely to stubs/, but some of
>>> the KVM stubs depend on cpu.h. So most of the kvm-stub.c code was
>>> moved to stubs/kvm.c, but some of that code was kept in
>>> accel/kvm-stub.c.
>>
>> I think we need to decide what libqemustub is for.
>>
>> The original purpose was to provide different implementations of some
>> functions for tools vs. emulators or (more rarely) for user-mode vs.
>> system emulation.
> 
> So, is sysemu vs user-mode a valid reason for using libqemustub?

Yes, but I was thinking of a different distinction.

You'd use libqemustub if user-mode emulation (or tools) only needs 2-3
functions out of a large file, while system-mode emulation needs all of it.

For example, of the entire monitor API, the tools need pretty much
nothing but monitor_init, monitor_get_fd, cur_mon and
monitor_cur_is_qmp.  Such a small extract of the API makes little sense
except for "this is what is needed to compile the tools", so it's stubs/
rather than monitor-stub.c.

Instead, non-KVM targets need a stub implementation of the entire API,
so it's kvm-stub.c rather than stubs/kvm.c (kvm-stub.c depends on cpu.h
but that's really only needed to compile it---the kvm-stub.c code
actually has no dependency).

There are certainly cases where libqemustub is used instead of lnot.  In
the specific case of sysemu vs. user-mode, stubs/cpus.c and
stubs/replay-user.c should not be in libqemustub.  They should be in a
separate file user-exec-stub.c, which is only used if !CONFIG_SOFTMMU.

> The main reason I have moved some code to sbus/kvm.c is to avoid
> having to include accel/kvm-stub.c in *-user.

What's wrong with

ifeq ($(CONFIG_SOFTMMU),y)
obj-$(CONFIG_KVM) += kvm-all.c
obj-$(call lnot, $(CONFIG_KVM)) += kvm-stub.c
endif

similar to what is done already in Makefile.objs?

> Moving xen-stub.c to libqemustub, on the other hand, is really
> unnecessary.

Why would it be different?

>> In general, I think libqemustub should be the last resort.  If possible,
>> inlines in headers should be the first choice, and stubs in objs-y or
>> common-objs-y (using $(call lnot) in the Makefile) should be the second.
> 
> I understand the reasoning, but I fail to see cases when
> libqemustub would be considered appropriate. Using stubs in
> obj-y/common-obj-y using $(call lnot) is always possible, isn't
> it?
> 
> Hmm, maybe on cases where the decision to use the stub doesn't
> depend on a single build variable (e.g. a function implemented by
> a handful of targets, but not all of them).

This is a good one.

> Are there other examples?

Does the one above (extract a small part of an API) make sense?

libqemustub is a necessary evil and it's almost never necessary.  It
basically exists for cases where you cannot replace a source file with
another wholesale.

There are also some cases of premature optimization.  For example reset
handlers are stubbed, but: 1) system emulation implements them in vl.c
which is an antipattern of its own, and 2) they are small enough that
including them in user-mode emulators (together with the rest of qdev)
is not a big deal.  (I'm planning to remove some stubs in 2.9, so I'm
taking these examples from that branch).

Paolo

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

* Re: [Qemu-devel] [RFC 0/7] Move accel, KVM, Xen, qtest files to accel/ subdir
@ 2016-12-21 13:47       ` Paolo Bonzini
  0 siblings, 0 replies; 37+ messages in thread
From: Paolo Bonzini @ 2016-12-21 13:47 UTC (permalink / raw)
  To: Eduardo Habkost
  Cc: qemu-devel, kvm, Christoffer Dall, Anthony Perard,
	Stefano Stabellini, xen-devel



On 21/12/2016 14:14, Eduardo Habkost wrote:
> On Wed, Dec 21, 2016 at 12:21:44PM +0100, Paolo Bonzini wrote:
>>
>>
>> On 20/12/2016 18:43, Eduardo Habkost wrote:
>>> This moves the KVM and Xen files to the an accel/ subdir.
>>>
>>> Instead of moving the *-stubs.c file to accel/ as-is, I tried to
>>> move most of the stub code to libqemustub.a. This way the obj-y
>>> logic for accel/ is simpler: obj-y includes accel/ only if
>>> CONFIG_SOFTMMU is set.
>>>
>>> The Xen stubs could be moved completely to stubs/, but some of
>>> the KVM stubs depend on cpu.h. So most of the kvm-stub.c code was
>>> moved to stubs/kvm.c, but some of that code was kept in
>>> accel/kvm-stub.c.
>>
>> I think we need to decide what libqemustub is for.
>>
>> The original purpose was to provide different implementations of some
>> functions for tools vs. emulators or (more rarely) for user-mode vs.
>> system emulation.
> 
> So, is sysemu vs user-mode a valid reason for using libqemustub?

Yes, but I was thinking of a different distinction.

You'd use libqemustub if user-mode emulation (or tools) only needs 2-3
functions out of a large file, while system-mode emulation needs all of it.

For example, of the entire monitor API, the tools need pretty much
nothing but monitor_init, monitor_get_fd, cur_mon and
monitor_cur_is_qmp.  Such a small extract of the API makes little sense
except for "this is what is needed to compile the tools", so it's stubs/
rather than monitor-stub.c.

Instead, non-KVM targets need a stub implementation of the entire API,
so it's kvm-stub.c rather than stubs/kvm.c (kvm-stub.c depends on cpu.h
but that's really only needed to compile it---the kvm-stub.c code
actually has no dependency).

There are certainly cases where libqemustub is used instead of lnot.  In
the specific case of sysemu vs. user-mode, stubs/cpus.c and
stubs/replay-user.c should not be in libqemustub.  They should be in a
separate file user-exec-stub.c, which is only used if !CONFIG_SOFTMMU.

> The main reason I have moved some code to sbus/kvm.c is to avoid
> having to include accel/kvm-stub.c in *-user.

What's wrong with

ifeq ($(CONFIG_SOFTMMU),y)
obj-$(CONFIG_KVM) += kvm-all.c
obj-$(call lnot, $(CONFIG_KVM)) += kvm-stub.c
endif

similar to what is done already in Makefile.objs?

> Moving xen-stub.c to libqemustub, on the other hand, is really
> unnecessary.

Why would it be different?

>> In general, I think libqemustub should be the last resort.  If possible,
>> inlines in headers should be the first choice, and stubs in objs-y or
>> common-objs-y (using $(call lnot) in the Makefile) should be the second.
> 
> I understand the reasoning, but I fail to see cases when
> libqemustub would be considered appropriate. Using stubs in
> obj-y/common-obj-y using $(call lnot) is always possible, isn't
> it?
> 
> Hmm, maybe on cases where the decision to use the stub doesn't
> depend on a single build variable (e.g. a function implemented by
> a handful of targets, but not all of them).

This is a good one.

> Are there other examples?

Does the one above (extract a small part of an API) make sense?

libqemustub is a necessary evil and it's almost never necessary.  It
basically exists for cases where you cannot replace a source file with
another wholesale.

There are also some cases of premature optimization.  For example reset
handlers are stubbed, but: 1) system emulation implements them in vl.c
which is an antipattern of its own, and 2) they are small enough that
including them in user-mode emulators (together with the rest of qdev)
is not a big deal.  (I'm planning to remove some stubs in 2.9, so I'm
taking these examples from that branch).

Paolo

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

* Re: [RFC 0/7] Move accel, KVM, Xen, qtest files to accel/ subdir
  2016-12-21 13:47       ` [Qemu-devel] " Paolo Bonzini
@ 2016-12-21 14:15         ` Eduardo Habkost
  -1 siblings, 0 replies; 37+ messages in thread
From: Eduardo Habkost @ 2016-12-21 14:15 UTC (permalink / raw)
  To: Paolo Bonzini
  Cc: qemu-devel, kvm, Christoffer Dall, Anthony Perard,
	Stefano Stabellini, xen-devel

On Wed, Dec 21, 2016 at 02:47:54PM +0100, Paolo Bonzini wrote:
> 
> 
> On 21/12/2016 14:14, Eduardo Habkost wrote:
> > On Wed, Dec 21, 2016 at 12:21:44PM +0100, Paolo Bonzini wrote:
> >>
> >>
> >> On 20/12/2016 18:43, Eduardo Habkost wrote:
> >>> This moves the KVM and Xen files to the an accel/ subdir.
> >>>
> >>> Instead of moving the *-stubs.c file to accel/ as-is, I tried to
> >>> move most of the stub code to libqemustub.a. This way the obj-y
> >>> logic for accel/ is simpler: obj-y includes accel/ only if
> >>> CONFIG_SOFTMMU is set.
> >>>
> >>> The Xen stubs could be moved completely to stubs/, but some of
> >>> the KVM stubs depend on cpu.h. So most of the kvm-stub.c code was
> >>> moved to stubs/kvm.c, but some of that code was kept in
> >>> accel/kvm-stub.c.
> >>
> >> I think we need to decide what libqemustub is for.
> >>
> >> The original purpose was to provide different implementations of some
> >> functions for tools vs. emulators or (more rarely) for user-mode vs.
> >> system emulation.
> > 
> > So, is sysemu vs user-mode a valid reason for using libqemustub?
> 
> Yes, but I was thinking of a different distinction.
> 
> You'd use libqemustub if user-mode emulation (or tools) only needs 2-3
> functions out of a large file, while system-mode emulation needs all of it.
> 
> For example, of the entire monitor API, the tools need pretty much
> nothing but monitor_init, monitor_get_fd, cur_mon and
> monitor_cur_is_qmp.  Such a small extract of the API makes little sense
> except for "this is what is needed to compile the tools", so it's stubs/
> rather than monitor-stub.c.
> 
> Instead, non-KVM targets need a stub implementation of the entire API,
> so it's kvm-stub.c rather than stubs/kvm.c (kvm-stub.c depends on cpu.h
> but that's really only needed to compile it---the kvm-stub.c code
> actually has no dependency).
> 
> There are certainly cases where libqemustub is used instead of lnot.  In
> the specific case of sysemu vs. user-mode, stubs/cpus.c and
> stubs/replay-user.c should not be in libqemustub.  They should be in a
> separate file user-exec-stub.c, which is only used if !CONFIG_SOFTMMU.
> 
> > The main reason I have moved some code to sbus/kvm.c is to avoid
> > having to include accel/kvm-stub.c in *-user.
> 
> What's wrong with
> 
> ifeq ($(CONFIG_SOFTMMU),y)
> obj-$(CONFIG_KVM) += kvm-all.c
> obj-$(call lnot, $(CONFIG_KVM)) += kvm-stub.c
> endif
> 
> similar to what is done already in Makefile.objs?

I assume you mean:

 ifeq ($(CONFIG_SOFTMMU),y)
 obj-$(CONFIG_KVM) += kvm-all.c
 endif
 obj-$(call lnot, $(CONFIG_KVM)) += kvm-stub.c

Nothing really wrong, we can do that to avoid using libqemustub.
I was just trying to avoid a more complex rule involving
ifeq+lnot, and to avoid including accel/ in obj-y on the
non-softmmu case.

> 
> > Moving xen-stub.c to libqemustub, on the other hand, is really
> > unnecessary.
> 
> Why would it be different?

I meant the reason I mentioned above doesn't even exist in the
case of xen-stub.c.

> 
> >> In general, I think libqemustub should be the last resort.  If possible,
> >> inlines in headers should be the first choice, and stubs in objs-y or
> >> common-objs-y (using $(call lnot) in the Makefile) should be the second.
> > 
> > I understand the reasoning, but I fail to see cases when
> > libqemustub would be considered appropriate. Using stubs in
> > obj-y/common-obj-y using $(call lnot) is always possible, isn't
> > it?
> > 
> > Hmm, maybe on cases where the decision to use the stub doesn't
> > depend on a single build variable (e.g. a function implemented by
> > a handful of targets, but not all of them).
> 
> This is a good one.
> 
> > Are there other examples?
> 
> Does the one above (extract a small part of an API) make sense?

I think so. But if you only need a small part of the API, inlines
in header files looks like a very simple way to avoid
libqemustub.

> 
> libqemustub is a necessary evil and it's almost never necessary.  It
> basically exists for cases where you cannot replace a source file with
> another wholesale.
> 
> There are also some cases of premature optimization.  For example reset
> handlers are stubbed, but: 1) system emulation implements them in vl.c
> which is an antipattern of its own, and 2) they are small enough that
> including them in user-mode emulators (together with the rest of qdev)
> is not a big deal.  (I'm planning to remove some stubs in 2.9, so I'm
> taking these examples from that branch).
> 
> Paolo

-- 
Eduardo

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

* Re: [Qemu-devel] [RFC 0/7] Move accel, KVM, Xen, qtest files to accel/ subdir
@ 2016-12-21 14:15         ` Eduardo Habkost
  0 siblings, 0 replies; 37+ messages in thread
From: Eduardo Habkost @ 2016-12-21 14:15 UTC (permalink / raw)
  To: Paolo Bonzini
  Cc: qemu-devel, kvm, Christoffer Dall, Anthony Perard,
	Stefano Stabellini, xen-devel

On Wed, Dec 21, 2016 at 02:47:54PM +0100, Paolo Bonzini wrote:
> 
> 
> On 21/12/2016 14:14, Eduardo Habkost wrote:
> > On Wed, Dec 21, 2016 at 12:21:44PM +0100, Paolo Bonzini wrote:
> >>
> >>
> >> On 20/12/2016 18:43, Eduardo Habkost wrote:
> >>> This moves the KVM and Xen files to the an accel/ subdir.
> >>>
> >>> Instead of moving the *-stubs.c file to accel/ as-is, I tried to
> >>> move most of the stub code to libqemustub.a. This way the obj-y
> >>> logic for accel/ is simpler: obj-y includes accel/ only if
> >>> CONFIG_SOFTMMU is set.
> >>>
> >>> The Xen stubs could be moved completely to stubs/, but some of
> >>> the KVM stubs depend on cpu.h. So most of the kvm-stub.c code was
> >>> moved to stubs/kvm.c, but some of that code was kept in
> >>> accel/kvm-stub.c.
> >>
> >> I think we need to decide what libqemustub is for.
> >>
> >> The original purpose was to provide different implementations of some
> >> functions for tools vs. emulators or (more rarely) for user-mode vs.
> >> system emulation.
> > 
> > So, is sysemu vs user-mode a valid reason for using libqemustub?
> 
> Yes, but I was thinking of a different distinction.
> 
> You'd use libqemustub if user-mode emulation (or tools) only needs 2-3
> functions out of a large file, while system-mode emulation needs all of it.
> 
> For example, of the entire monitor API, the tools need pretty much
> nothing but monitor_init, monitor_get_fd, cur_mon and
> monitor_cur_is_qmp.  Such a small extract of the API makes little sense
> except for "this is what is needed to compile the tools", so it's stubs/
> rather than monitor-stub.c.
> 
> Instead, non-KVM targets need a stub implementation of the entire API,
> so it's kvm-stub.c rather than stubs/kvm.c (kvm-stub.c depends on cpu.h
> but that's really only needed to compile it---the kvm-stub.c code
> actually has no dependency).
> 
> There are certainly cases where libqemustub is used instead of lnot.  In
> the specific case of sysemu vs. user-mode, stubs/cpus.c and
> stubs/replay-user.c should not be in libqemustub.  They should be in a
> separate file user-exec-stub.c, which is only used if !CONFIG_SOFTMMU.
> 
> > The main reason I have moved some code to sbus/kvm.c is to avoid
> > having to include accel/kvm-stub.c in *-user.
> 
> What's wrong with
> 
> ifeq ($(CONFIG_SOFTMMU),y)
> obj-$(CONFIG_KVM) += kvm-all.c
> obj-$(call lnot, $(CONFIG_KVM)) += kvm-stub.c
> endif
> 
> similar to what is done already in Makefile.objs?

I assume you mean:

 ifeq ($(CONFIG_SOFTMMU),y)
 obj-$(CONFIG_KVM) += kvm-all.c
 endif
 obj-$(call lnot, $(CONFIG_KVM)) += kvm-stub.c

Nothing really wrong, we can do that to avoid using libqemustub.
I was just trying to avoid a more complex rule involving
ifeq+lnot, and to avoid including accel/ in obj-y on the
non-softmmu case.

> 
> > Moving xen-stub.c to libqemustub, on the other hand, is really
> > unnecessary.
> 
> Why would it be different?

I meant the reason I mentioned above doesn't even exist in the
case of xen-stub.c.

> 
> >> In general, I think libqemustub should be the last resort.  If possible,
> >> inlines in headers should be the first choice, and stubs in objs-y or
> >> common-objs-y (using $(call lnot) in the Makefile) should be the second.
> > 
> > I understand the reasoning, but I fail to see cases when
> > libqemustub would be considered appropriate. Using stubs in
> > obj-y/common-obj-y using $(call lnot) is always possible, isn't
> > it?
> > 
> > Hmm, maybe on cases where the decision to use the stub doesn't
> > depend on a single build variable (e.g. a function implemented by
> > a handful of targets, but not all of them).
> 
> This is a good one.
> 
> > Are there other examples?
> 
> Does the one above (extract a small part of an API) make sense?

I think so. But if you only need a small part of the API, inlines
in header files looks like a very simple way to avoid
libqemustub.

> 
> libqemustub is a necessary evil and it's almost never necessary.  It
> basically exists for cases where you cannot replace a source file with
> another wholesale.
> 
> There are also some cases of premature optimization.  For example reset
> handlers are stubbed, but: 1) system emulation implements them in vl.c
> which is an antipattern of its own, and 2) they are small enough that
> including them in user-mode emulators (together with the rest of qdev)
> is not a big deal.  (I'm planning to remove some stubs in 2.9, so I'm
> taking these examples from that branch).
> 
> Paolo

-- 
Eduardo

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

* Re: [RFC 0/7] Move accel, KVM, Xen, qtest files to accel/ subdir
  2016-12-21 14:15         ` [Qemu-devel] " Eduardo Habkost
@ 2016-12-21 15:41           ` Paolo Bonzini
  -1 siblings, 0 replies; 37+ messages in thread
From: Paolo Bonzini @ 2016-12-21 15:41 UTC (permalink / raw)
  To: Eduardo Habkost
  Cc: qemu-devel, kvm, Christoffer Dall, Anthony Perard,
	Stefano Stabellini, xen-devel



On 21/12/2016 15:15, Eduardo Habkost wrote:
>>
>> ifeq ($(CONFIG_SOFTMMU),y)
>> obj-$(CONFIG_KVM) += kvm-all.c
>> obj-$(call lnot, $(CONFIG_KVM)) += kvm-stub.c
>> endif
>>
>> similar to what is done already in Makefile.objs?
> I assume you mean:
> 
>  ifeq ($(CONFIG_SOFTMMU),y)
>  obj-$(CONFIG_KVM) += kvm-all.c
>  endif
>  obj-$(call lnot, $(CONFIG_KVM)) += kvm-stub.c
> 
> Nothing really wrong, we can do that to avoid using libqemustub.
> I was just trying to avoid a more complex rule involving
> ifeq+lnot, and to avoid including accel/ in obj-y on the
> non-softmmu case.

TCG would need accel/ in obj-y in the non-softmmu case, for things such
as cpu-exec.c and translate-all.c.

Paolo

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

* Re: [Qemu-devel] [RFC 0/7] Move accel, KVM, Xen, qtest files to accel/ subdir
@ 2016-12-21 15:41           ` Paolo Bonzini
  0 siblings, 0 replies; 37+ messages in thread
From: Paolo Bonzini @ 2016-12-21 15:41 UTC (permalink / raw)
  To: Eduardo Habkost
  Cc: qemu-devel, kvm, Christoffer Dall, Anthony Perard,
	Stefano Stabellini, xen-devel



On 21/12/2016 15:15, Eduardo Habkost wrote:
>>
>> ifeq ($(CONFIG_SOFTMMU),y)
>> obj-$(CONFIG_KVM) += kvm-all.c
>> obj-$(call lnot, $(CONFIG_KVM)) += kvm-stub.c
>> endif
>>
>> similar to what is done already in Makefile.objs?
> I assume you mean:
> 
>  ifeq ($(CONFIG_SOFTMMU),y)
>  obj-$(CONFIG_KVM) += kvm-all.c
>  endif
>  obj-$(call lnot, $(CONFIG_KVM)) += kvm-stub.c
> 
> Nothing really wrong, we can do that to avoid using libqemustub.
> I was just trying to avoid a more complex rule involving
> ifeq+lnot, and to avoid including accel/ in obj-y on the
> non-softmmu case.

TCG would need accel/ in obj-y in the non-softmmu case, for things such
as cpu-exec.c and translate-all.c.

Paolo

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

* Re: [Qemu-devel] [RFC 0/7] Move accel, KVM, Xen, qtest files to accel/ subdir
  2016-12-20 17:43 ` [Qemu-devel] " Eduardo Habkost
                   ` (11 preceding siblings ...)
  (?)
@ 2017-04-24 10:40 ` Thomas Huth
  2017-04-24 19:11   ` Stefano Stabellini
  2017-04-24 19:35   ` Eduardo Habkost
  -1 siblings, 2 replies; 37+ messages in thread
From: Thomas Huth @ 2017-04-24 10:40 UTC (permalink / raw)
  To: Eduardo Habkost, qemu-devel
  Cc: Stefano Stabellini, kvm, xen-devel, Anthony Perard,
	Paolo Bonzini, Christoffer Dall

On 20.12.2016 18:43, Eduardo Habkost wrote:
> This moves the KVM and Xen files to the an accel/ subdir.
> 
> Instead of moving the *-stubs.c file to accel/ as-is, I tried to
> move most of the stub code to libqemustub.a. This way the obj-y
> logic for accel/ is simpler: obj-y includes accel/ only if
> CONFIG_SOFTMMU is set.
> 
> The Xen stubs could be moved completely to stubs/, but some of
> the KVM stubs depend on cpu.h. So most of the kvm-stub.c code was
> moved to stubs/kvm.c, but some of that code was kept in
> accel/kvm-stub.c.
> 
> About TCG:
> ----------
> 
> It is not obvious to me which TCG-related files could be moved to
> accel/, so this series don't move any of them yet.
> 
> About other CONFIG_SOFTMMU top-level files:
> -------------------------------------------
> 
> I would like to know what we should do with the top-level
> CONFIG_SOFTMMU-only files that don't belong to hw/. Some
> candidates: arch_init.c cpus.c monitor.c gdbstub.c balloon.c
> ioport.c bootdevice.c memory.c cputlb.c memory_mapping.c dump.c.
> 
> Maybe a sysemu/ subdir? In that case, should we still create an
> accel/ subdir, or move xen-*, kvm-* and friends to sysemu/ too?
> 
> Cc: Paolo Bonzini <pbonzini@redhat.com>
> Cc: kvm@vger.kernel.org
> Cc: Christoffer Dall <christoffer.dall@linaro.org>
> Cc: Anthony Perard <anthony.perard@citrix.com>
> Cc: Stefano Stabellini <sstabellini@kernel.org>
> Cc: xen-devel@lists.xensource.com
> 
> Eduardo Habkost (7):
>   xen: Move xen-*-stub.c to stubs/
>   xen: Move xen files to accel/
>   kvm: Move some kvm-stub.c code to stubs/kvm.c
>   kvm: Include kvm-stub.o only on CONFIG_SOFTMMU
>   kvm: Move kvm*.c files to accel/
>   accel: Move accel.c to accel/
>   accel: Move qtest.c to accel/
> 
>  Makefile.objs                          |  2 +-
>  Makefile.target                        | 10 ++----
>  accel.c => accel/accel.c               |  0
>  kvm-all.c => accel/kvm-common.c        |  0
>  kvm-stub.c => accel/kvm-stub.c         | 51 --------------------------
>  qtest.c => accel/qtest.c               |  0
>  xen-common.c => accel/xen-common.c     |  0
>  xen-hvm.c => accel/xen-hvm.c           |  0
>  xen-mapcache.c => accel/xen-mapcache.c |  0
>  stubs/kvm.c                            | 65 ++++++++++++++++++++++++++++++++++
>  xen-hvm-stub.c => stubs/xen-hvm.c      |  0
>  xen-common-stub.c => stubs/xen.c       |  0
>  MAINTAINERS                            |  4 +--
>  accel/Makefile.objs                    |  9 +++++
>  stubs/Makefile.objs                    |  2 ++
>  15 files changed, 80 insertions(+), 63 deletions(-)
>  rename accel.c => accel/accel.c (100%)
>  rename kvm-all.c => accel/kvm-common.c (100%)
>  rename kvm-stub.c => accel/kvm-stub.c (71%)
>  rename qtest.c => accel/qtest.c (100%)
>  rename xen-common.c => accel/xen-common.c (100%)
>  rename xen-hvm.c => accel/xen-hvm.c (100%)
>  rename xen-mapcache.c => accel/xen-mapcache.c (100%)
>  rename xen-hvm-stub.c => stubs/xen-hvm.c (100%)
>  rename xen-common-stub.c => stubs/xen.c (100%)
>  create mode 100644 accel/Makefile.objs

Now that the development tree is open again ... any chance that we could
get this series into 2.10 ?

 Thomas

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

* Re: [Qemu-devel] [RFC 0/7] Move accel, KVM, Xen, qtest files to accel/ subdir
  2017-04-24 10:40 ` Thomas Huth
@ 2017-04-24 19:11   ` Stefano Stabellini
  2017-04-24 19:35   ` Eduardo Habkost
  1 sibling, 0 replies; 37+ messages in thread
From: Stefano Stabellini @ 2017-04-24 19:11 UTC (permalink / raw)
  To: Thomas Huth
  Cc: Eduardo Habkost, qemu-devel, Stefano Stabellini, kvm, xen-devel,
	Anthony Perard, Paolo Bonzini, Christoffer Dall

On Mon, 24 Apr 2017, Thomas Huth wrote:
> On 20.12.2016 18:43, Eduardo Habkost wrote:
> > This moves the KVM and Xen files to the an accel/ subdir.
> > 
> > Instead of moving the *-stubs.c file to accel/ as-is, I tried to
> > move most of the stub code to libqemustub.a. This way the obj-y
> > logic for accel/ is simpler: obj-y includes accel/ only if
> > CONFIG_SOFTMMU is set.
> > 
> > The Xen stubs could be moved completely to stubs/, but some of
> > the KVM stubs depend on cpu.h. So most of the kvm-stub.c code was
> > moved to stubs/kvm.c, but some of that code was kept in
> > accel/kvm-stub.c.
> > 
> > About TCG:
> > ----------
> > 
> > It is not obvious to me which TCG-related files could be moved to
> > accel/, so this series don't move any of them yet.
> > 
> > About other CONFIG_SOFTMMU top-level files:
> > -------------------------------------------
> > 
> > I would like to know what we should do with the top-level
> > CONFIG_SOFTMMU-only files that don't belong to hw/. Some
> > candidates: arch_init.c cpus.c monitor.c gdbstub.c balloon.c
> > ioport.c bootdevice.c memory.c cputlb.c memory_mapping.c dump.c.
> > 
> > Maybe a sysemu/ subdir? In that case, should we still create an
> > accel/ subdir, or move xen-*, kvm-* and friends to sysemu/ too?
> > 
> > Cc: Paolo Bonzini <pbonzini@redhat.com>
> > Cc: kvm@vger.kernel.org
> > Cc: Christoffer Dall <christoffer.dall@linaro.org>
> > Cc: Anthony Perard <anthony.perard@citrix.com>
> > Cc: Stefano Stabellini <sstabellini@kernel.org>
> > Cc: xen-devel@lists.xensource.com
> > 
> > Eduardo Habkost (7):
> >   xen: Move xen-*-stub.c to stubs/
> >   xen: Move xen files to accel/
> >   kvm: Move some kvm-stub.c code to stubs/kvm.c
> >   kvm: Include kvm-stub.o only on CONFIG_SOFTMMU
> >   kvm: Move kvm*.c files to accel/
> >   accel: Move accel.c to accel/
> >   accel: Move qtest.c to accel/
> > 
> >  Makefile.objs                          |  2 +-
> >  Makefile.target                        | 10 ++----
> >  accel.c => accel/accel.c               |  0
> >  kvm-all.c => accel/kvm-common.c        |  0
> >  kvm-stub.c => accel/kvm-stub.c         | 51 --------------------------
> >  qtest.c => accel/qtest.c               |  0
> >  xen-common.c => accel/xen-common.c     |  0
> >  xen-hvm.c => accel/xen-hvm.c           |  0
> >  xen-mapcache.c => accel/xen-mapcache.c |  0
> >  stubs/kvm.c                            | 65 ++++++++++++++++++++++++++++++++++
> >  xen-hvm-stub.c => stubs/xen-hvm.c      |  0
> >  xen-common-stub.c => stubs/xen.c       |  0
> >  MAINTAINERS                            |  4 +--
> >  accel/Makefile.objs                    |  9 +++++
> >  stubs/Makefile.objs                    |  2 ++
> >  15 files changed, 80 insertions(+), 63 deletions(-)
> >  rename accel.c => accel/accel.c (100%)
> >  rename kvm-all.c => accel/kvm-common.c (100%)
> >  rename kvm-stub.c => accel/kvm-stub.c (71%)
> >  rename qtest.c => accel/qtest.c (100%)
> >  rename xen-common.c => accel/xen-common.c (100%)
> >  rename xen-hvm.c => accel/xen-hvm.c (100%)
> >  rename xen-mapcache.c => accel/xen-mapcache.c (100%)
> >  rename xen-hvm-stub.c => stubs/xen-hvm.c (100%)
> >  rename xen-common-stub.c => stubs/xen.c (100%)
> >  create mode 100644 accel/Makefile.objs
> 
> Now that the development tree is open again ... any chance that we could
> get this series into 2.10 ?

FYI I took Anothony Xu's patches to move the xen files under hw/xen/ and
hw/i386/xen, see the last 3 patches of
alpine.DEB.2.10.1704211258580.18403@sstabellini-ThinkPad-X260. 

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

* Re: [Qemu-devel] [RFC 0/7] Move accel, KVM, Xen, qtest files to accel/ subdir
  2017-04-24 10:40 ` Thomas Huth
  2017-04-24 19:11   ` Stefano Stabellini
@ 2017-04-24 19:35   ` Eduardo Habkost
  1 sibling, 0 replies; 37+ messages in thread
From: Eduardo Habkost @ 2017-04-24 19:35 UTC (permalink / raw)
  To: Thomas Huth
  Cc: qemu-devel, Stefano Stabellini, kvm, xen-devel, Anthony Perard,
	Paolo Bonzini, Christoffer Dall

On Mon, Apr 24, 2017 at 12:40:07PM +0200, Thomas Huth wrote:
> On 20.12.2016 18:43, Eduardo Habkost wrote:
> > This moves the KVM and Xen files to the an accel/ subdir.
> > 
> > Instead of moving the *-stubs.c file to accel/ as-is, I tried to
> > move most of the stub code to libqemustub.a. This way the obj-y
> > logic for accel/ is simpler: obj-y includes accel/ only if
> > CONFIG_SOFTMMU is set.
> > 
> > The Xen stubs could be moved completely to stubs/, but some of
> > the KVM stubs depend on cpu.h. So most of the kvm-stub.c code was
> > moved to stubs/kvm.c, but some of that code was kept in
> > accel/kvm-stub.c.
> > 
> > About TCG:
> > ----------
> > 
> > It is not obvious to me which TCG-related files could be moved to
> > accel/, so this series don't move any of them yet.
> > 
> > About other CONFIG_SOFTMMU top-level files:
> > -------------------------------------------
> > 
> > I would like to know what we should do with the top-level
> > CONFIG_SOFTMMU-only files that don't belong to hw/. Some
> > candidates: arch_init.c cpus.c monitor.c gdbstub.c balloon.c
> > ioport.c bootdevice.c memory.c cputlb.c memory_mapping.c dump.c.
> > 
> > Maybe a sysemu/ subdir? In that case, should we still create an
> > accel/ subdir, or move xen-*, kvm-* and friends to sysemu/ too?
> > 
> > Cc: Paolo Bonzini <pbonzini@redhat.com>
> > Cc: kvm@vger.kernel.org
> > Cc: Christoffer Dall <christoffer.dall@linaro.org>
> > Cc: Anthony Perard <anthony.perard@citrix.com>
> > Cc: Stefano Stabellini <sstabellini@kernel.org>
> > Cc: xen-devel@lists.xensource.com
> > 
> > Eduardo Habkost (7):
> >   xen: Move xen-*-stub.c to stubs/
> >   xen: Move xen files to accel/
> >   kvm: Move some kvm-stub.c code to stubs/kvm.c
> >   kvm: Include kvm-stub.o only on CONFIG_SOFTMMU
> >   kvm: Move kvm*.c files to accel/
> >   accel: Move accel.c to accel/
> >   accel: Move qtest.c to accel/
> > 
> >  Makefile.objs                          |  2 +-
> >  Makefile.target                        | 10 ++----
> >  accel.c => accel/accel.c               |  0
> >  kvm-all.c => accel/kvm-common.c        |  0
> >  kvm-stub.c => accel/kvm-stub.c         | 51 --------------------------
> >  qtest.c => accel/qtest.c               |  0
> >  xen-common.c => accel/xen-common.c     |  0
> >  xen-hvm.c => accel/xen-hvm.c           |  0
> >  xen-mapcache.c => accel/xen-mapcache.c |  0
> >  stubs/kvm.c                            | 65 ++++++++++++++++++++++++++++++++++
> >  xen-hvm-stub.c => stubs/xen-hvm.c      |  0
> >  xen-common-stub.c => stubs/xen.c       |  0
> >  MAINTAINERS                            |  4 +--
> >  accel/Makefile.objs                    |  9 +++++
> >  stubs/Makefile.objs                    |  2 ++
> >  15 files changed, 80 insertions(+), 63 deletions(-)
> >  rename accel.c => accel/accel.c (100%)
> >  rename kvm-all.c => accel/kvm-common.c (100%)
> >  rename kvm-stub.c => accel/kvm-stub.c (71%)
> >  rename qtest.c => accel/qtest.c (100%)
> >  rename xen-common.c => accel/xen-common.c (100%)
> >  rename xen-hvm.c => accel/xen-hvm.c (100%)
> >  rename xen-mapcache.c => accel/xen-mapcache.c (100%)
> >  rename xen-hvm-stub.c => stubs/xen-hvm.c (100%)
> >  rename xen-common-stub.c => stubs/xen.c (100%)
> >  create mode 100644 accel/Makefile.objs
> 
> Now that the development tree is open again ... any chance that we could
> get this series into 2.10 ?

I remember there were some suggestions about the code movements,
especially about the files being moved inside stubs/. I never
took the time to make a v2 implementing those suggestions, so if
anybody wants to volunteer to address the feedback on this RFC
and redo the series, please be my guest.  :)

-- 
Eduardo

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

end of thread, other threads:[~2017-04-24 19:35 UTC | newest]

Thread overview: 37+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-12-20 17:43 [RFC 0/7] Move accel, KVM, Xen, qtest files to accel/ subdir Eduardo Habkost
2016-12-20 17:43 ` [Qemu-devel] " Eduardo Habkost
2016-12-20 17:43 ` [Qemu-devel] [RFC 1/7] xen: Move xen-*-stub.c to stubs/ Eduardo Habkost
2016-12-20 17:43   ` Eduardo Habkost
2016-12-20 17:43 ` [Qemu-devel] [RFC 2/7] xen: Move xen files to accel/ Eduardo Habkost
2016-12-20 17:43   ` Eduardo Habkost
2016-12-20 17:43 ` [RFC 3/7] kvm: Move some kvm-stub.c code to stubs/kvm.c Eduardo Habkost
2016-12-20 17:43   ` [Qemu-devel] " Eduardo Habkost
2016-12-21  8:42   ` David Hildenbrand
2016-12-21  8:42     ` [Qemu-devel] " David Hildenbrand
2016-12-20 17:43 ` [RFC 4/7] kvm: Include kvm-stub.o only on CONFIG_SOFTMMU Eduardo Habkost
2016-12-20 17:43   ` [Qemu-devel] " Eduardo Habkost
2016-12-21  7:27   ` Thomas Huth
2016-12-21  8:44     ` David Hildenbrand
2016-12-20 17:43 ` [RFC 5/7] kvm: Move kvm*.c files to accel/ Eduardo Habkost
2016-12-20 17:43   ` [Qemu-devel] " Eduardo Habkost
2016-12-20 17:43 ` [Qemu-devel] [RFC 6/7] accel: Move accel.c " Eduardo Habkost
2016-12-21  7:30   ` Thomas Huth
2016-12-20 17:43 ` [Qemu-devel] [RFC 7/7] accel: Move qtest.c " Eduardo Habkost
2016-12-20 19:01 ` [RFC 0/7] Move accel, KVM, Xen, qtest files to accel/ subdir Stefan Weil
2016-12-20 19:01   ` [Qemu-devel] " Stefan Weil
2016-12-21  0:31 ` Stefano Stabellini
2016-12-21  0:31   ` [Qemu-devel] " Stefano Stabellini
2016-12-21  7:37 ` Thomas Huth
2016-12-21 11:21 ` Paolo Bonzini
2016-12-21 11:21   ` [Qemu-devel] " Paolo Bonzini
2016-12-21 13:14   ` Eduardo Habkost
2016-12-21 13:14     ` [Qemu-devel] " Eduardo Habkost
2016-12-21 13:47     ` Paolo Bonzini
2016-12-21 13:47       ` [Qemu-devel] " Paolo Bonzini
2016-12-21 14:15       ` Eduardo Habkost
2016-12-21 14:15         ` [Qemu-devel] " Eduardo Habkost
2016-12-21 15:41         ` Paolo Bonzini
2016-12-21 15:41           ` [Qemu-devel] " Paolo Bonzini
2017-04-24 10:40 ` Thomas Huth
2017-04-24 19:11   ` Stefano Stabellini
2017-04-24 19:35   ` Eduardo Habkost

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.