Skip to contentSkip to conversation

some small cleanups for xen_machine_pv.c

PATCH In review Gerd Hoffmann 3 participants 11 messages Mar 20, 2009 – Mar 23, 2009

lore
Share & tools
lore
#0 lore raw

cover some small cleanups for xen_machine_pv.c

Hi,

Here are a few cleanup patches for qemu-xen's xen_machine_pv.c, in preparation for merging into upstream qemu.

please apply,
Gerd

#1 lore raw

PATCH 1/5 xen_machine_pv.c: switch to C99 initializers.

---
 hw/xen_machine_pv.c |    8 ++++----
 1 files changed, 4 insertions(+), 4 deletions(-)
hw/xen_machine_pv.c +4 -4
index 674ffca..df34590 100644
@@ -72,10 +72,10 @@ static void xen_init_pv(ram_addr_t ram_size, int vga_ram_size,
 }
 
 QEMUMachine xenpv_machine = {
-    "xenpv",
-    "Xen Para-virtualized PC",
-    xen_init_pv,
-    BIOS_SIZE | RAMSIZE_FIXED,
+    .name = "xenpv",
+    .desc = "Xen Para-virtualized PC",
+    .init = xen_init_pv,
+    .ram_require = BIOS_SIZE | RAMSIZE_FIXED,
     .max_cpus = 1,
     .nodisk_ok = 1,
 };
Signature · 1 line
1.6.1.3
#2 lore raw

PATCH 2/5 xen_machine_pv.c: delete pointless coomment.

In reply to Gerd Hoffmann
---
 hw/xen_machine_pv.c |    5 -----
 1 files changed, 0 insertions(+), 5 deletions(-)
hw/xen_machine_pv.c +0 -5
index df34590..624d8dd 100644
@@ -33,11 +33,6 @@ enum xen_mode xen_mode = XEN_EMULATE;
 
 extern void init_blktap(void);
 
-
-/* The Xen PV machine currently provides
- *   - a virtual framebuffer
- *   - ....
- */
 static void xen_init_pv(ram_addr_t ram_size, int vga_ram_size,
 			const char *boot_device, DisplayState *ds,
 			const char *kernel_filename,
Signature · 1 line
1.6.1.3
#3 lore raw

PATCH 3/5 Fixup dummy cpu setup.

In reply to Gerd Hoffmann

Passing NULL to cpu_init() doesn't work in upstream qemu. Also make sure the dummy cpu is in halted mode.

---
 hw/xen_machine_pv.c |   10 +++++++++-
 1 files changed, 9 insertions(+), 1 deletions(-)
hw/xen_machine_pv.c +9 -1
index 624d8dd..df28be9 100644
@@ -51,7 +51,15 @@ static void xen_init_pv(ram_addr_t ram_size, int vga_ram_size,
 #endif
 
     /* Initialize a dummy CPU */
-    env = cpu_init(NULL);
+    if (cpu_model == NULL) {
+#ifdef TARGET_X86_64
+        cpu_model = "qemu64";
+#else
+        cpu_model = "qemu32";
+#endif
+    }
+    env = cpu_init(cpu_model);
+    env->halted = 1;
 
     /* Initialize backend core & drivers */
     if (-1 == xen_be_init()) {
Signature · 1 line
1.6.1.3
#4 lore raw

Re: [PATCH 3/5] Fixup dummy cpu setup.

Quoted 19 lines · Gerd Hoffmann

Passing NULL to cpu_init() doesn't work in upstream qemu. Also make sure the dummy cpu is in halted mode.

---
 hw/xen_machine_pv.c |   10 +++++++++-
 1 files changed, 9 insertions(+), 1 deletions(-)
hw/xen_machine_pv.c +2 -1
index 624d8dd..df28be9 100644
@@ -51,7 +51,15 @@ static void xen_init_pv(ram_addr_t ram_size, int vga_ram_size,
 #endif
 
     /* Initialize a dummy CPU */
-    env = cpu_init(NULL);
+    if (cpu_model == NULL) {
+#ifdef TARGET_X86_64

hw/xen_machine_pv.c static void xen_init_pv(ram_addr_t ram_size, int vga_ram_size, · line 65

Quoted 10 lines
hw/xen_machine_pv.c +7 -0
+        cpu_model = "qemu64";
+#else
+        cpu_model = "qemu32";
+#endif
+    }
+    env = cpu_init(cpu_model);
+    env->halted = 1;
 
     /* Initialize backend core & drivers */
     if (-1 == xen_be_init()) {

Is there a way to achieve this without ifdef nastiness?

Signature · 3 lines
Simon Horman
  VA Linux Systems Japan K.K., Sydney, Australia Satellite Office
  H: www.vergenet.net/~horms/             W: www.valinux.co.jp/en
#5 lore raw

Re: [PATCH 3/5] Fixup dummy cpu setup.

Quoted 11 lines · Simon Horman

hw/xen_machine_pv.c static void xen_init_pv(ram_addr_t ram_size, int vga_ram_size, · line 61

Quoted 9 lines
hw/xen_machine_pv.c +8 -1
-    env = cpu_init(NULL);
+    if (cpu_model == NULL) {
+#ifdef TARGET_X86_64
+        cpu_model = "qemu64";
+#else
+        cpu_model = "qemu32";
+#endif
+    }
+    env = cpu_init(cpu_model);

Is there a way to achieve this without ifdef nastiness?

Well, one could try to make cpu_init(NULL) pick a sane default. But in the end that most likely would just be moving the ifdef to another place.

cheers,
Gerd

#6 lore raw

Re: [PATCH 3/5] Fixup dummy cpu setup.

Quoted 13 lines · Gerd Hoffmann
Quoted 11 lines · Simon Horman

hw/xen_machine_pv.c static void xen_init_pv(ram_addr_t ram_size, int vga_ram_size, · line 61

Quoted 9 lines
hw/xen_machine_pv.c +8 -1
-    env = cpu_init(NULL);
+    if (cpu_model == NULL) {
+#ifdef TARGET_X86_64
+        cpu_model = "qemu64";
+#else
+        cpu_model = "qemu32";
+#endif
+    }
+    env = cpu_init(cpu_model);

Is there a way to achieve this without ifdef nastiness?

Quoted 2 lines

Well, one could try to make cpu_init(NULL) pick a sane default. But in the end that most likely would just be moving the ifdef to another place.

Understood.

Signature · 3 lines
Simon Horman
  VA Linux Systems Japan K.K., Sydney, Australia Satellite Office
  H: www.vergenet.net/~horms/             W: www.valinux.co.jp/en
#7 lore raw

PATCH 4/5 use uint32_t for xen_domid

In reply to Gerd Hoffmann
---
 hw/xen.h            |    2 +-
 hw/xen_machine_pv.c |    2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)
hw/xen.h +1 -1
index 4bcc0f1..3c8da41 100644
@@ -14,7 +14,7 @@ enum xen_mode {
     XEN_ATTACH        // attach to xen domain created by xend
 };
 
-extern int xen_domid;
+extern uint32_t xen_domid;
 extern enum xen_mode xen_mode;
 
 #endif /* QEMU_HW_XEN_H */
hw/xen_machine_pv.c +1 -1
index df28be9..6525856 100644
@@ -28,7 +28,7 @@
 #include "boards.h"
 #include "xen_backend.h"
 
-int xen_domid;
+uint32_t xen_domid;
 enum xen_mode xen_mode = XEN_EMULATE;
 
 extern void init_blktap(void);
Signature · 1 line
1.6.1.3
#8 lore raw

RE: [PATCH 4/5] use uint32_t for xen_domid

May not matter but isn't a domid limited to 16-bits in the hypervisor? Probably should be consistent lest sign-extension or something cause a problem.

Quoted 51 lines

-----Original Message-----
From: Gerd Hoffmann [mailto:[email protected]]
Sent: Friday, March 20, 2009 10:03 AM
To: [email protected]
Cc: [email protected]; Gerd Hoffmann; [email protected]
Subject: [Xen-devel] [PATCH 4/5] use uint32_t for xen_domid

---
 hw/xen.h            |    2 +-
 hw/xen_machine_pv.c |    2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)
hw/xen.h +1 -1
index 4bcc0f1..3c8da41 100644
@@ -14,7 +14,7 @@ enum xen_mode {
     XEN_ATTACH        // attach to xen domain created by xend
 };
 
-extern int xen_domid;
+extern uint32_t xen_domid;
 extern enum xen_mode xen_mode;
 
 #endif /* QEMU_HW_XEN_H */
hw/xen_machine_pv.c +1 -1
index df28be9..6525856 100644
@@ -28,7 +28,7 @@
 #include "boards.h"
 #include "xen_backend.h"
 
-int xen_domid;
+uint32_t xen_domid;
 enum xen_mode xen_mode = XEN_EMULATE;
 
 extern void init_blktap(void);
Signature · 7 lines
1.6.1.3


_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel
#9 lore raw

Re: [PATCH 4/5] use uint32_t for xen_domid

Quoted 3 lines · Dan Magenheimer

May not matter but isn't a domid limited to 16-bits in the hypervisor? Probably should be consistent lest sign-extension or something cause a problem.

In /usr/include/xenctrl.h it is uint32_t everythere.

cheers,
Gerd

#10 lore raw

PATCH 5/5 kill unused variables

In reply to Gerd Hoffmann
---
 hw/xen_machine_pv.c |    2 --
 1 files changed, 0 insertions(+), 2 deletions(-)
hw/xen_machine_pv.c +0 -2
index 6525856..b7f8e28 100644
@@ -41,8 +41,6 @@ static void xen_init_pv(ram_addr_t ram_size, int vga_ram_size,
 			const char *cpu_model,
 			const char *direct_pci)
 {
-    struct xenfb *xenfb;
-    extern int domid;
     CPUState *env;
 
 #ifndef CONFIG_STUBDOM
Signature · 1 line
1.6.1.3