Skip to contentSkip to conversation

Cleanup internal WHPX headers

PATCH In review Paolo Bonzini 4 participants 7 messages Dec 19, 2020 – Jan 7, 2021

lore
Share & tools
lore
#0 lore raw

cover Cleanup internal WHPX headers

Remove Windows type usage from sysemu/whpx.h, because the whp-dispatch.h header is internal to the WHPX accelerator implementation. Fixes WHPX build.

Paolo Bonzini (2):
whpx: rename whp-dispatch to whpx-internal.h
whpx: move internal definitions to whpx-internal.h

 include/sysemu/whpx.h                         | 22 +----------------
 target/i386/whpx/whpx-all.c                   |  9 +++----
 target/i386/whpx/whpx-apic.c                  |  2 +-
 target/i386/whpx/whpx-cpus.c                  |  4 +---
 .../whpx/{whp-dispatch.h => whpx-internal.h}  | 24 ++++++++++++++++---
 5 files changed, 29 insertions(+), 32 deletions(-)
 rename target/i386/whpx/{whp-dispatch.h => whpx-internal.h} (91%)
Signature · 1 line
2.26.2
#1 lore raw

PATCH 1/2 whpx: rename whp-dispatch to whpx-internal.h

Rename the file in preparation for moving more implementation-internal definitions to it. The build is still broken though.

---
 target/i386/whpx/whpx-all.c                          | 5 +----
 target/i386/whpx/whpx-apic.c                         | 2 +-
 target/i386/whpx/whpx-cpus.c                         | 4 +---
 target/i386/whpx/{whp-dispatch.h => whpx-internal.h} | 6 +++---
 4 files changed, 6 insertions(+), 11 deletions(-)
 rename target/i386/whpx/{whp-dispatch.h => whpx-internal.h} (98%)
target/i386/whpx/whpx-all.c +1 -4
index 3b824fc9d7..12f79e2cd6 100644
@@ -26,13 +26,10 @@
 #include "qapi/qapi-types-common.h"
 #include "qapi/qapi-visit-common.h"
 #include "migration/blocker.h"
-#include "whp-dispatch.h"
 #include <winerror.h>
 
 #include "whpx-cpus.h"
-
-#include <WinHvPlatform.h>
-#include <WinHvEmulation.h>
+#include "whpx-internal.h"
 
 #define HYPERV_APIC_BUS_FREQUENCY      (200000000ULL)
 
target/i386/whpx/whpx-apic.c +1 -1
index b127a3cb8a..1d330bf749 100644
@@ -18,7 +18,7 @@
 #include "hw/pci/msi.h"
 #include "sysemu/hw_accel.h"
 #include "sysemu/whpx.h"
-#include "whp-dispatch.h"
+#include "whpx-internal.h"
 
 static void whpx_put_apic_state(APICCommonState *s,
                                 struct whpx_lapic_state *kapic)
target/i386/whpx/whpx-cpus.c +1 -3
index d9bd5a2d36..f7e69881a3 100644
@@ -15,11 +15,9 @@
 #include "qemu/guest-random.h"
 
 #include "sysemu/whpx.h"
+#include "whpx-internal.h"
 #include "whpx-cpus.h"
 
-#include <WinHvPlatform.h>
-#include <WinHvEmulation.h>
-
 static void *whpx_cpu_thread_fn(void *arg)
 {
     CPUState *cpu = arg;
target/i386/whpx/whpx-internal.h renamed from target/i386/whpx/whp-dispatch.h +3 -3
similarity index 98%
rename from target/i386/whpx/whp-dispatch.h
rename to target/i386/whpx/whpx-internal.h
index cef5d848bd..e0a9ea1dce 100644
@@ -1,5 +1,5 @@
-#ifndef WHP_DISPATCH_H
-#define WHP_DISPATCH_H
+#ifndef WHP_INTERNAL_H
+#define WHP_INTERNAL_H
 
 #include <windows.h>
 #include <WinHvPlatform.h>
@@ -72,4 +72,4 @@ typedef enum WHPFunctionList {
     WINHV_PLATFORM_FNS_SUPPLEMENTAL
 } WHPFunctionList;
 
-#endif /* WHP_DISPATCH_H */
+#endif /* WHP_INTERNAL_H */
Signature · 1 line
2.26.2
Reviewed-by on v1 1/2
#2 lore raw

Re: [PATCH 1/2] whpx: rename whp-dispatch to whpx-internal.h

Quoted 5 lines · Paolo Bonzini

Rename the file in preparation for moving more implementation-internal definitions to it. The build is still broken though.

---

Quoted 83 lines
 target/i386/whpx/whpx-all.c                          | 5 +----
 target/i386/whpx/whpx-apic.c                         | 2 +-
 target/i386/whpx/whpx-cpus.c                         | 4 +---
 target/i386/whpx/{whp-dispatch.h => whpx-internal.h} | 6 +++---
 4 files changed, 6 insertions(+), 11 deletions(-)
 rename target/i386/whpx/{whp-dispatch.h => whpx-internal.h} (98%)
target/i386/whpx/whpx-all.c +1 -4
index 3b824fc9d7..12f79e2cd6 100644
@@ -26,13 +26,10 @@
 #include "qapi/qapi-types-common.h"
 #include "qapi/qapi-visit-common.h"
 #include "migration/blocker.h"
-#include "whp-dispatch.h"
 #include <winerror.h>
 
 #include "whpx-cpus.h"
-
-#include <WinHvPlatform.h>
-#include <WinHvEmulation.h>
+#include "whpx-internal.h"
 
 #define HYPERV_APIC_BUS_FREQUENCY      (200000000ULL)
 
target/i386/whpx/whpx-apic.c +1 -1
index b127a3cb8a..1d330bf749 100644
@@ -18,7 +18,7 @@
 #include "hw/pci/msi.h"
 #include "sysemu/hw_accel.h"
 #include "sysemu/whpx.h"
-#include "whp-dispatch.h"
+#include "whpx-internal.h"
 
 static void whpx_put_apic_state(APICCommonState *s,
                                 struct whpx_lapic_state *kapic)
target/i386/whpx/whpx-cpus.c +1 -3
index d9bd5a2d36..f7e69881a3 100644
@@ -15,11 +15,9 @@
 #include "qemu/guest-random.h"
 
 #include "sysemu/whpx.h"
+#include "whpx-internal.h"
 #include "whpx-cpus.h"
 
-#include <WinHvPlatform.h>
-#include <WinHvEmulation.h>
-
 static void *whpx_cpu_thread_fn(void *arg)
 {
     CPUState *cpu = arg;
target/i386/whpx/whpx-internal.h renamed from target/i386/whpx/whp-dispatch.h +3 -4
similarity index 98%
rename from target/i386/whpx/whp-dispatch.h
rename to target/i386/whpx/whpx-internal.h
index cef5d848bd..e0a9ea1dce 100644
@@ -1,5 +1,5 @@
-#ifndef WHP_DISPATCH_H
-#define WHP_DISPATCH_H
+#ifndef WHP_INTERNAL_H
+#define WHP_INTERNAL_H
 
 #include <windows.h>
 #include <WinHvPlatform.h>
@@ -72,4 +72,4 @@ typedef enum WHPFunctionList {
     WINHV_PLATFORM_FNS_SUPPLEMENTAL
 } WHPFunctionList;
 
-#endif /* WHP_DISPATCH_H */
+#endif /* WHP_INTERNAL_H */
--

2.26.2

#3 lore raw

PATCH 2/2 whpx: move internal definitions to whpx-internal.h

In reply to Paolo Bonzini

Only leave the external interface in sysemu/whpx.h. whpx_apic_in_platform is moved to a .c file because it needs whpx_state.

---
 include/sysemu/whpx.h            | 22 +---------------------
 target/i386/whpx/whpx-all.c      |  4 ++++
 target/i386/whpx/whpx-internal.h | 18 ++++++++++++++++++
 3 files changed, 23 insertions(+), 21 deletions(-)
include/sysemu/whpx.h +1 -21
index 9346fd92e9..8ca1c1c4ac 100644
@@ -15,28 +15,8 @@
 
 #ifdef CONFIG_WHPX
 
-#include "whp-dispatch.h"
-
-struct whpx_state {
-    uint64_t mem_quota;
-    WHV_PARTITION_HANDLE partition;
-    bool kernel_irqchip_allowed;
-    bool kernel_irqchip_required;
-    bool apic_in_platform;
-};
-
-struct whpx_lapic_state {
-    struct {
-        uint32_t data;
-        uint32_t padding[3];
-    } fields[256];
-};
-
-extern struct whpx_state whpx_global;
 int whpx_enabled(void);
-
-void whpx_apic_get(DeviceState *s);
-#define whpx_apic_in_platform() (whpx_global.apic_in_platform)
+bool whpx_apic_in_platform(void);
 
 #else /* CONFIG_WHPX */
 
target/i386/whpx/whpx-all.c +4 -0
index 12f79e2cd6..985ceba8f8 100644
@@ -1866,6 +1866,10 @@ int whpx_enabled(void)
     return whpx_allowed;
 }
 
+bool whpx_apic_in_platform(void) {
+    return whpx_global.apic_in_platform;
+}
+
 static void whpx_accel_class_init(ObjectClass *oc, void *data)
 {
     AccelClass *ac = ACCEL_CLASS(oc);
target/i386/whpx/whpx-internal.h +18 -0
index e0a9ea1dce..8cfaaef141 100644
@@ -5,6 +5,24 @@
 #include <WinHvPlatform.h>
 #include <WinHvEmulation.h>
 
+struct whpx_state {
+    uint64_t mem_quota;
+    WHV_PARTITION_HANDLE partition;
+    bool kernel_irqchip_allowed;
+    bool kernel_irqchip_required;
+    bool apic_in_platform;
+};
+
+struct whpx_lapic_state {
+    struct {
+        uint32_t data;
+        uint32_t padding[3];
+    } fields[256];
+};
+
+extern struct whpx_state whpx_global;
+void whpx_apic_get(DeviceState *s);
+
 #define WHV_E_UNKNOWN_CAPABILITY 0x80370300L
 
 #define LIST_WINHVPLATFORM_FUNCTIONS(X) \
Signature · 1 line
2.26.2
Reviewed-by on v1 2/2
#4 lore raw

Re: [PATCH 2/2] whpx: move internal definitions to whpx-internal.h

Quoted 6 lines · Paolo Bonzini

Only leave the external interface in sysemu/whpx.h. whpx_apic_in_platform is moved to a .c file because it needs whpx_state.

---

Quoted 88 lines
 include/sysemu/whpx.h            | 22 +---------------------
 target/i386/whpx/whpx-all.c      |  4 ++++
 target/i386/whpx/whpx-internal.h | 18 ++++++++++++++++++
 3 files changed, 23 insertions(+), 21 deletions(-)
include/sysemu/whpx.h +1 -21
index 9346fd92e9..8ca1c1c4ac 100644
@@ -15,28 +15,8 @@
 
 #ifdef CONFIG_WHPX
 
-#include "whp-dispatch.h"
-
-struct whpx_state {
-    uint64_t mem_quota;
-    WHV_PARTITION_HANDLE partition;
-    bool kernel_irqchip_allowed;
-    bool kernel_irqchip_required;
-    bool apic_in_platform;
-};
-
-struct whpx_lapic_state {
-    struct {
-        uint32_t data;
-        uint32_t padding[3];
-    } fields[256];
-};
-
-extern struct whpx_state whpx_global;
 int whpx_enabled(void);
-
-void whpx_apic_get(DeviceState *s);
-#define whpx_apic_in_platform() (whpx_global.apic_in_platform)
+bool whpx_apic_in_platform(void);
 
 #else /* CONFIG_WHPX */
 
target/i386/whpx/whpx-all.c +4 -0
index 12f79e2cd6..985ceba8f8 100644
@@ -1866,6 +1866,10 @@ int whpx_enabled(void)
     return whpx_allowed;
 }
 
+bool whpx_apic_in_platform(void) {
+    return whpx_global.apic_in_platform;
+}
+
 static void whpx_accel_class_init(ObjectClass *oc, void *data)
 {
     AccelClass *ac = ACCEL_CLASS(oc);
target/i386/whpx/whpx-internal.h +18 -1
index e0a9ea1dce..8cfaaef141 100644
@@ -5,6 +5,24 @@
 #include <WinHvPlatform.h>
 #include <WinHvEmulation.h>
 
+struct whpx_state {
+    uint64_t mem_quota;
+    WHV_PARTITION_HANDLE partition;
+    bool kernel_irqchip_allowed;
+    bool kernel_irqchip_required;
+    bool apic_in_platform;
+};
+
+struct whpx_lapic_state {
+    struct {
+        uint32_t data;
+        uint32_t padding[3];
+    } fields[256];
+};
+
+extern struct whpx_state whpx_global;
+void whpx_apic_get(DeviceState *s);
+
 #define WHV_E_UNKNOWN_CAPABILITY 0x80370300L
 
 #define LIST_WINHVPLATFORM_FUNCTIONS(X) \
--

2.26.2

Reviewed-by on v1 2/2
#5 lore raw

Re: [PATCH 2/2] whpx: move internal definitions to whpx-internal.h

In reply to Paolo Bonzini
Quoted 10 lines · Paolo Bonzini

Only leave the external interface in sysemu/whpx.h. whpx_apic_in_platform is moved to a .c file because it needs whpx_state.

---
 include/sysemu/whpx.h            | 22 +---------------------
 target/i386/whpx/whpx-all.c      |  4 ++++
 target/i386/whpx/whpx-internal.h | 18 ++++++++++++++++++
 3 files changed, 23 insertions(+), 21 deletions(-)
#6 lore raw
In reply to Paolo Bonzini
Patchew URL: https://patchew.org/QEMU/[email protected]/

Patchew URL: https://patchew.org/QEMU/[email protected]/

Hi,

This series seems to have some coding style problems. See output below for more information:

Type: series
Message-id: [email protected]
Subject: [PATCH 0/2] Cleanup internal WHPX headers

=== TEST SCRIPT BEGIN ===
#!/bin/bash
git rev-parse base > /dev/null || exit 0
git config --local diff.renamelimit 0
git config --local diff.renames True
git config --local diff.algorithm histogram
./scripts/checkpatch.pl --mailback base..
=== TEST SCRIPT END ===

Updating 3c8cf5a9c21ff8782164d1def7f44bd888713384 From https://github.com/patchew-project/qemu
* [new tag] patchew/[email protected] -> patchew/[email protected]
Switched to a new branch 'test'
aada1bf whpx: move internal definitions to whpx-internal.h 2b0771a whpx: rename whp-dispatch to whpx-internal.h

=== OUTPUT BEGIN ===
1/2 Checking commit 2b0771ae8ad0 (whpx: rename whp-dispatch to whpx-internal.h)
WARNING: added, moved or deleted file(s), does MAINTAINERS need updating? #64:
rename from target/i386/whpx/whp-dispatch.h

total: 0 errors, 1 warnings, 46 lines checked

Patch 1/2 has style problems, please review. If any of these errors are false positives report them to the maintainer, see
CHECKPATCH in MAINTAINERS.
2/2 Checking commit aada1bf26255 (whpx: move internal definitions to whpx-internal.h)
ERROR: open brace '{' following function declarations go on the next line #56: FILE: target/i386/whpx/whpx-all.c:1869:
+bool whpx_apic_in_platform(void) {

total: 1 errors, 0 warnings, 63 lines checked

Patch 2/2 has style problems, please review. If any of these errors are false positives report them to the maintainer, see CHECKPATCH in MAINTAINERS.

=== OUTPUT END ===

Test command exited with code: 1

The full log is available at
http://patchew.org/logs/[email protected]/testing.checkpatch/?type=message.
---
Email generated automatically by Patchew [https://patchew.org/].
Please send your feedback to [email protected]