Skip to contentSkip to conversation

Move stuff out of vl.c

PATCH In review Paolo Bonzini 2 participants 7 messages Apr 1, 2010 – Apr 9, 2010 Kbuild

lore
Share & tools
lore
#0 lore raw

v3 cover Move stuff out of vl.c

v2->v3
- re-rebased
- salvage some cleanups made while trying to compile balloon.c once, but do not do it because it breaks (I have patches to do it also for vl.o, but they are ugly!)

Paolo Bonzini (5):
move socket_init to qemu-sockets.c
move two variable declarations out of vl.c
move targphys.h and hw/poison.h inclusion to cpu-common.h move around definitions in kvm.h that do not require CPUState move balloon handling to balloon.c

 Makefile.target         |    2 +-
 balloon.c               |  146 +++++++++++++++++++++++++++++++++++++++++++++++
 balloon.h               |    7 ++
 cpu-common.h            |    8 +++
 hw/hw.h                 |    2 -
 hw/i8259.c              |    1 +
 hw/isa-bus.c            |    1 +
 kvm.h                   |    8 +-
 monitor.c               |   85 ---------------------------
 hw/poison.h => poison.h |    0
 qemu-sockets.c          |   24 ++++++++
 qemu_socket.h           |    1 +
 vl.c                    |   62 --------------------
 13 files changed, 193 insertions(+), 154 deletions(-)
 create mode 100644 balloon.c
 rename hw/poison.h => poison.h (100%)
#1 lore raw

PATCH v3 1/5 move socket_init to qemu-sockets.c

---
 qemu-sockets.c |   24 ++++++++++++++++++++++++
 qemu_socket.h  |    1 +
 vl.c           |   24 ------------------------
 3 files changed, 25 insertions(+), 24 deletions(-)
qemu-sockets.c +24 -0
index 23c3def..a7399aa 100644
@@ -648,3 +648,27 @@ int unix_connect(const char *path)
 }
 
 #endif
+
+#ifdef _WIN32
+static void socket_cleanup(void)
+{
+    WSACleanup();
+}
+#endif
+
+int socket_init(void)
+{
+#ifdef _WIN32
+    WSADATA Data;
+    int ret, err;
+
+    ret = WSAStartup(MAKEWORD(2,2), &Data);
+    if (ret != 0) {
+        err = WSAGetLastError();
+        fprintf(stderr, "WSAStartup: %d\n", err);
+        return -1;
+    }
+    atexit(socket_cleanup);
+#endif
+    return 0;
+}
qemu_socket.h +1 -0
index 7ee46ac..164ae3e 100644
@@ -56,5 +56,6 @@ int parse_host_port(struct sockaddr_in *saddr, const char *str);
 int parse_host_src_port(struct sockaddr_in *haddr,
                         struct sockaddr_in *saddr,
                         const char *str);
+int socket_init(void);
 
 #endif /* QEMU_SOCKET_H */
vl.c +0 -24
index 6768cf1..9ce6e4c 100644
@@ -494,28 +494,6 @@ static void configure_rtc(QemuOpts *opts)
     }
 }
 
-#ifdef _WIN32
-static void socket_cleanup(void)
-{
-    WSACleanup();
-}
-
-static int socket_init(void)
-{
-    WSADATA Data;
-    int ret, err;
-
-    ret = WSAStartup(MAKEWORD(2,2), &Data);
-    if (ret != 0) {
-        err = WSAGetLastError();
-        fprintf(stderr, "WSAStartup: %d\n", err);
-        return -1;
-    }
-    atexit(socket_cleanup);
-    return 0;
-}
-#endif
-
 /***********************************************************/
 /* Bluetooth support */
 static int nb_hcis;
@@ -3622,9 +3600,7 @@ int main(int argc, char **argv, char **envp)
     }
     configure_icount(icount_option);
 
-#ifdef _WIN32
     socket_init();
-#endif
 
     if (net_init_clients() < 0) {
         exit(1);
Signature · 1 line
1.6.6.1
#2 lore raw

PATCH v3 2/5 move two variable declarations out of vl.c

In reply to Paolo Bonzini
---
 hw/i8259.c   |    1 +
 hw/isa-bus.c |    1 +
 vl.c         |    4 ----
 3 files changed, 2 insertions(+), 4 deletions(-)
hw/i8259.c +1 -0
index 3de22e3..37ef04e 100644
@@ -68,6 +68,7 @@ static int irq_level[16];
 #ifdef DEBUG_IRQ_COUNT
 static uint64_t irq_count[16];
 #endif
+PicState2 *isa_pic;
 
 /* set irq level. If an edge is detected, then the IRR is set to 1 */
 static inline void pic_set_irq1(PicState *s, int irq, int level)
hw/isa-bus.c +1 -0
index 4d489d2..4e306de 100644
@@ -28,6 +28,7 @@ struct ISABus {
     uint32_t assigned;
 };
 static ISABus *isabus;
+target_phys_addr_t isa_mem_base = 0;
 
 static void isabus_dev_print(Monitor *mon, DeviceState *dev, int indent);
 
vl.c +0 -4
index 9ce6e4c..8828beb 100644
@@ -292,10 +292,6 @@ static int default_driver_check(QemuOpts *opts, void *opaque)
 }
 
 /***********************************************************/
-/* x86 ISA bus support */
-
-target_phys_addr_t isa_mem_base = 0;
-PicState2 *isa_pic;
 
 static void set_proc_name(const char *s)
 {
Signature · 1 line
1.6.6.1
#3 lore raw

PATCH v3 3/5 move targphys.h and hw/poison.h inclusion to cpu-common.h

In reply to Paolo Bonzini

With more files from outside the hw/ directory being placed into libhw, avoid the need to include hw/hw.h for the sake of targ_phys_addr_t.

---
 cpu-common.h            |    8 ++++++++
 hw/hw.h                 |    2 --
 hw/poison.h => poison.h |    0
 3 files changed, 8 insertions(+), 2 deletions(-)
 rename hw/poison.h => poison.h (100%)
cpu-common.h +8 -0
index bb05300..2abd4a8 100644
@@ -7,6 +7,14 @@
 #define WORDS_ALIGNED
 #endif
 
+#ifdef TARGET_PHYS_ADDR_BITS
+#include "targphys.h"
+#endif
+
+#ifndef NEED_CPU_H
+#include "poison.h"
+#endif
+
 #include "bswap.h"
 #include "qemu-queue.h"
 
hw/hw.h +0 -2
index 7b500f4..328b704 100644
@@ -5,8 +5,6 @@
 #include "qemu-common.h"
 
 #if defined(TARGET_PHYS_ADDR_BITS) && !defined(NEED_CPU_H)
-#include "targphys.h"
-#include "poison.h"
 #include "cpu-common.h"
 #endif
 
poison.h renamed from hw/poison.h +0 -0
similarity index 100%
rename from hw/poison.h
rename to poison.h
Signature · 1 line
1.6.6.1
#4 lore raw

PATCH v3 4/5 move around definitions in kvm.h that do not require CPUState

In reply to Paolo Bonzini
---
 kvm.h |    8 ++++----
 1 files changed, 4 insertions(+), 4 deletions(-)
kvm.h +4 -4
index 4f77188..8bbd127 100644
@@ -31,6 +31,10 @@ struct kvm_run;
 
 int kvm_init(int smp_cpus);
 
+int kvm_has_sync_mmu(void);
+int kvm_has_vcpu_events(void);
+int kvm_has_robust_singlestep(void);
+
 #ifdef NEED_CPU_H
 int kvm_init_vcpu(CPUState *env);
 
@@ -40,10 +44,6 @@ int kvm_cpu_exec(CPUState *env);
 int kvm_log_start(target_phys_addr_t phys_addr, ram_addr_t size);
 int kvm_log_stop(target_phys_addr_t phys_addr, ram_addr_t size);
 
-int kvm_has_sync_mmu(void);
-int kvm_has_vcpu_events(void);
-int kvm_has_robust_singlestep(void);
-
 void kvm_setup_guest_memory(void *start, size_t size);
 
 int kvm_coalesce_mmio_region(target_phys_addr_t start, ram_addr_t size);
Signature · 1 line
1.6.6.1
#5 lore raw

PATCH v3 5/5 move balloon handling to balloon.c

In reply to Paolo Bonzini
---
 Makefile.target |    2 +-
 balloon.c       |  146 +++++++++++++++++++++++++++++++++++++++++++++++++++++++
 balloon.h       |    7 +++
 monitor.c       |   85 --------------------------------
 vl.c            |   34 -------------
 5 files changed, 154 insertions(+), 120 deletions(-)
 create mode 100644 balloon.c
Makefile.target +1 -1
index 2157554..d5e1e60 100644
@@ -161,7 +161,7 @@ endif #CONFIG_BSD_USER
 # System emulator target
 ifdef CONFIG_SOFTMMU
 
-obj-y = arch_init.o cpus.o monitor.o machine.o gdbstub.o vl.o
+obj-y = arch_init.o cpus.o monitor.o machine.o gdbstub.o vl.o balloon.o
 # virtio has to be here due to weird dependency between PCI and virtio-net.
 # need to fix this properly
 obj-y += virtio-blk.o virtio-balloon.o virtio-net.o virtio-serial-bus.o
balloon.c new file +146 -0

146 lines not on this page · raw message

balloon.h +7 -0
index 8c019eb..d478e28 100644
@@ -14,6 +14,8 @@
 #ifndef _QEMU_BALLOON_H
 #define _QEMU_BALLOON_H
 
+#include "monitor.h"
+
 typedef void (QEMUBalloonEvent)(void *opaque, ram_addr_t target,
                                 MonitorCompletion cb, void *cb_data);
 
@@ -23,4 +25,9 @@ int qemu_balloon(ram_addr_t target, MonitorCompletion cb, void *opaque);
 
 int qemu_balloon_status(MonitorCompletion cb, void *opaque);
 
+void monitor_print_balloon(Monitor *mon, const QObject *data);
+int do_info_balloon(Monitor *mon, MonitorCompletion cb, void *opaque);
+int do_balloon(Monitor *mon, const QDict *params,
+               MonitorCompletion cb, void *opaque);
+
 #endif
monitor.c +0 -85

91 lines not on this page · raw message

vl.c +0 -34
index 8828beb..e7192fc 100644
@@ -146,7 +146,6 @@ int main(int argc, char **argv)
 #include "audio/audio.h"
 #include "migration.h"
 #include "kvm.h"
-#include "balloon.h"
 #include "qemu-option.h"
 #include "qemu-config.h"
 #include "qemu-objects.h"
@@ -307,39 +306,6 @@ static void set_proc_name(const char *s)
 #endif    	
 }
  
-/***************/
-/* ballooning */
-
-static QEMUBalloonEvent *qemu_balloon_event;
-void *qemu_balloon_event_opaque;
-
-void qemu_add_balloon_handler(QEMUBalloonEvent *func, void *opaque)
-{
-    qemu_balloon_event = func;
-    qemu_balloon_event_opaque = opaque;
-}
-
-int qemu_balloon(ram_addr_t target, MonitorCompletion cb, void *opaque)
-{
-    if (qemu_balloon_event) {
-        qemu_balloon_event(qemu_balloon_event_opaque, target, cb, opaque);
-        return 1;
-    } else {
-        return 0;
-    }
-}
-
-int qemu_balloon_status(MonitorCompletion cb, void *opaque)
-{
-    if (qemu_balloon_event) {
-        qemu_balloon_event(qemu_balloon_event_opaque, 0, cb, opaque);
-        return 1;
-    } else {
-        return 0;
-    }
-}
-
-
 /***********************************************************/
 /* real time host monotonic timer */
 
Signature · 1 line
1.6.6.1
#6 lore raw
In reply to Paolo Bonzini
Quoted 5 lines · Paolo Bonzini

v2->v3
- re-rebased
- salvage some cleanups made while trying to compile balloon.c once, but do not do it because it breaks (I have patches to do it also for vl.o, but they are ugly!)

Thanks, all applied.

Quoted 27 lines

Paolo Bonzini (5):
move socket_init to qemu-sockets.c
move two variable declarations out of vl.c
move targphys.h and hw/poison.h inclusion to cpu-common.h move around definitions in kvm.h that do not require CPUState move balloon handling to balloon.c

 Makefile.target         |    2 +-
 balloon.c               |  146 +++++++++++++++++++++++++++++++++++++++++++++++
 balloon.h               |    7 ++
 cpu-common.h            |    8 +++
 hw/hw.h                 |    2 -
 hw/i8259.c              |    1 +
 hw/isa-bus.c            |    1 +
 kvm.h                   |    8 +-
 monitor.c               |   85 ---------------------------
 hw/poison.h => poison.h |    0
 qemu-sockets.c          |   24 ++++++++
 qemu_socket.h           |    1 +
 vl.c                    |   62 --------------------
 13 files changed, 193 insertions(+), 154 deletions(-)
 create mode 100644 balloon.c
 rename hw/poison.h => poison.h (100%)
Signature · 2 lines
Aurelien Jarno                          GPG: 1024D/F1BCDB73
[email protected]                 http://www.aurel32.net