Skip to contentSkip to conversation

xen: fix build without pci passthrough

PATCH In review Roger Pau Monne 2 participants 3 messages May 19, 2020

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 xen: fix build without pci passthrough

has_igd_gfx_passthru is only available when QEMU is built with CONFIG_XEN_PCI_PASSTHROUGH, and hence shouldn't be used in common code without checking if it's available.

Fixes 46472d82322d0 ('xen: convert "-machine igd-passthru" to an accelerator property')

---
Cc: Stefano Stabellini <[email protected]>
Cc: Anthony Perard <[email protected]>
Cc: Paul Durrant <[email protected]>
Cc: [email protected]
---
Changes since v1:
- Do not include osdep in header file.
- Always add the setters/getters of igd-passthru, report an error when attempting to set igd-passthru without built in pci-passthrough support.

---
 hw/xen/xen-common.c | 4 ++++
 hw/xen/xen_pt.h     | 6 ++++++
 2 files changed, 10 insertions(+)
hw/xen/xen-common.c +4 -0
index 70564cc952..d758770da0 100644
@@ -134,7 +134,11 @@ static bool xen_get_igd_gfx_passthru(Object *obj, Error **errp)
 
 static void xen_set_igd_gfx_passthru(Object *obj, bool value, Error **errp)
 {
+#ifdef CONFIG_XEN_PCI_PASSTHROUGH
     has_igd_gfx_passthru = value;
+#else
+    error_setg(errp, "Xen PCI passthrough support not built in");
+#endif
 }
 
 static void xen_setup_post(MachineState *ms, AccelState *accel)
hw/xen/xen_pt.h +6 -0
index 179775db7b..7430235a27 100644
@@ -322,7 +322,13 @@ extern void *pci_assign_dev_load_option_rom(PCIDevice *dev,
                                             unsigned int domain,
                                             unsigned int bus, unsigned int slot,
                                             unsigned int function);
+
+#ifdef CONFIG_XEN_PCI_PASSTHROUGH
 extern bool has_igd_gfx_passthru;
+#else
+# define has_igd_gfx_passthru false
+#endif
+
 static inline bool is_igd_vga_passthrough(XenHostPCIDevice *dev)
 {
     return (has_igd_gfx_passthru
Signature · 1 line
2.26.2
#1 lore raw
Quoted 27 lines · Roger Pau Monne

has_igd_gfx_passthru is only available when QEMU is built with CONFIG_XEN_PCI_PASSTHROUGH, and hence shouldn't be used in common code without checking if it's available.

Fixes 46472d82322d0 ('xen: convert "-machine igd-passthru" to an accelerator property')

---
Cc: Stefano Stabellini <[email protected]>
Cc: Anthony Perard <[email protected]>
Cc: Paul Durrant <[email protected]>
Cc: [email protected]
---
Changes since v1:
- Do not include osdep in header file.
- Always add the setters/getters of igd-passthru, report an error when attempting to set igd-passthru without built in pci-passthrough support.

---
 hw/xen/xen-common.c | 4 ++++
 hw/xen/xen_pt.h     | 6 ++++++
 2 files changed, 10 insertions(+)
hw/xen/xen-common.c +0 -0
index 70564cc952..d758770da0 100644

hw/xen/xen-common.c static bool xen_get_igd_gfx_passthru(Object *obj, Error **errp) · line 143

Quoted 10 lines
hw/xen/xen-common.c +4 -0
@@ -134,7 +134,11 @@ static bool xen_get_igd_gfx_passthru(Object *obj, Error **errp)
 
 static void xen_set_igd_gfx_passthru(Object *obj, bool value, Error **errp)
 {
+#ifdef CONFIG_XEN_PCI_PASSTHROUGH
     has_igd_gfx_passthru = value;
+#else
+    error_setg(errp, "Xen PCI passthrough support not built in");
+#endif
 }
 

There's an issue that I haven't thought about before. CONFIG_XEN_PCI_PASSTHROUGH is never defined in xen-common.c. So xen_set_igd_gfx_passthru will always return an error.

I'm not sure what to do about that yet, maybe change the way that CONFIG_ is defined, or maybe have have the setter/getter in xen_pt.c with a stub in stubs/ which would return an error. or maybe some other way.

Signature · 1 line
Anthony PERARD
#2 lore raw
Quoted 43 lines · Anthony PERARD
Quoted 27 lines · Roger Pau Monne

has_igd_gfx_passthru is only available when QEMU is built with CONFIG_XEN_PCI_PASSTHROUGH, and hence shouldn't be used in common code without checking if it's available.

Fixes 46472d82322d0 ('xen: convert "-machine igd-passthru" to an accelerator property')

---
Cc: Stefano Stabellini <[email protected]>
Cc: Anthony Perard <[email protected]>
Cc: Paul Durrant <[email protected]>
Cc: [email protected]
---
Changes since v1:
- Do not include osdep in header file.
- Always add the setters/getters of igd-passthru, report an error when attempting to set igd-passthru without built in pci-passthrough support.

---
 hw/xen/xen-common.c | 4 ++++
 hw/xen/xen_pt.h     | 6 ++++++
 2 files changed, 10 insertions(+)
hw/xen/xen-common.c +0 -0
index 70564cc952..d758770da0 100644

hw/xen/xen-common.c static bool xen_get_igd_gfx_passthru(Object *obj, Error **errp) · line 143

Quoted 10 lines
hw/xen/xen-common.c +4 -0
@@ -134,7 +134,11 @@ static bool xen_get_igd_gfx_passthru(Object *obj, Error **errp)
 
 static void xen_set_igd_gfx_passthru(Object *obj, bool value, Error **errp)
 {
+#ifdef CONFIG_XEN_PCI_PASSTHROUGH
     has_igd_gfx_passthru = value;
+#else
+    error_setg(errp, "Xen PCI passthrough support not built in");
+#endif
 }
 

There's an issue that I haven't thought about before. CONFIG_XEN_PCI_PASSTHROUGH is never defined in xen-common.c. So xen_set_igd_gfx_passthru will always return an error.

Quoted 4 lines

I'm not sure what to do about that yet, maybe change the way that CONFIG_ is defined, or maybe have have the setter/getter in xen_pt.c with a stub in stubs/ which would return an error. or maybe some other way.

Hm, I think making it available is OK? Would it make sense to set it in $config_host_mak instead of $config_target_mak?

It's a host property, not a target one AFAICT, as the support in the host determines whether PCI passthrough is supported or not.

Thanks, Roger.