Fixes for building on Solaris 11.4.42 CBE
v3 cover Fixes for building on Solaris 11.4.42 CBE
With these minor fixes, I can build qemu on Solaris 11.4.42 CBE (Oracle's new rolling release thing), using '--disable-rdma --enable-modules --disable-dbus-display --target-list=x86_64-softmmu'. I'm just interested in the guest agent right now, so that's all I've tested (briefly), but the rest of the build wasn't hard to get working. With this, the guest agent runs fine using isa-serial.
Changes since v2:
- Rename new symbol to HAVE_MADVISE_WITHOUT_PROTOTYPE
- Move madvise prototype to include/qemu/osdep.h
- More comments in meson.build
Changes since v1:
- Change the CONFIG_MADVISE checks to not be platform-specific
- Add the last commit removing util/osdep.c cruft
Andrew Deason (3):
util/osdep: Avoid madvise proto on modern Solaris hw/i386/acpi-build: Avoid 'sun' identifier util/osdep: Remove some early cruft
hw/i386/acpi-build.c | 4 ++-- include/qemu/osdep.h | 8 ++++++++ meson.build | 23 +++++++++++++++++++++-- util/osdep.c | 10 ---------- 4 files changed, 31 insertions(+), 14 deletions(-)
Signature · 1 line
2.11.0
PATCH v3 1/3 util/osdep: Avoid madvise proto on modern Solaris
On older Solaris releases (before Solaris 11), we didn't get a prototype for madvise, and so util/osdep.c provides its own prototype. Some time between the public Solaris 11.4 release and Solaris 11.4.42 CBE, we started getting an madvise prototype that looks like this:
extern int madvise(void *, size_t, int);
which conflicts with the prototype in util/osdeps.c. Instead of always declaring this prototype, check if we're missing the madvise() prototype, and only declare it ourselves if the prototype is missing. Move the prototype to include/qemu/osdep.h, the normal place to handle platform-specific header quirks.
The 'missing_madvise_proto' meson check contains an obviously wrong prototype for madvise. So if that code compiles and links, we must be missing the actual prototype for madvise.
---
Changes since v2:
- Rename new symbol to HAVE_MADVISE_WITHOUT_PROTOTYPE
- Move madvise prototype to include/qemu/osdep.h
- More comments in meson.build
Changes since v1:
- madvise prototype check changed to not be platforms-specific, and turned into CONFIG_MADVISE_MISSING_PROTOTYPE.
include/qemu/osdep.h | 8 ++++++++ meson.build | 23 +++++++++++++++++++++-- util/osdep.c | 3 --- 3 files changed, 29 insertions(+), 5 deletions(-)
include/qemu/osdep.h +8 -0
@@ -393,20 +393,28 @@ void qemu_anon_ram_free(void *ptr, size_t size);#if defined(__linux__) || defined(__FreeBSD__) || \ defined(__FreeBSD_kernel__) || defined(__DragonFly__)#define HAVE_CHARDEV_PARPORT 1#endif #if defined(__HAIKU__)#define SIGIO SIGPOLL#endif +#ifdef HAVE_MADVISE_WITHOUT_PROTOTYPE +/* +* See MySQL bug #7156 (http://bugs.mysql.com/bug.php?id=7156) for discussion +* about Solaris missing the madvise() prototype. +*/ +extern int madvise (char *,size_t ,int ); +#endif +#if defined(CONFIG_LINUX )#ifndef BUS_MCEERR_AR #define BUS_MCEERR_AR 4#endif #ifndef BUS_MCEERR_AO #define BUS_MCEERR_AO 5#endif #endif #if defined(__linux__) && \
meson.build +21 -2
@@ -1708,25 +1708,44 @@ config_host_data.set('CONFIG_EVENTFD', cc.links(''' int main(void) { return eventfd(0, EFD_NONBLOCK | EFD_CLOEXEC); }''')) config_host_data.set('CONFIG_FDATASYNC', cc.links(gnu_source_prefix + ''' #include <unistd.h> int main(void) { #if defined(_POSIX_SYNCHRONIZED_IO) && _POSIX_SYNCHRONIZED_IO > 0 return fdatasync(0); #else #error Not supported #endif }''')) -config_host_data.set('CONFIG_MADVISE', cc.links(gnu_source_prefix + ''' + +has_madvise = cc.links(gnu_source_prefix + ''' #include <sys/types.h> #include <sys/mman.h> #include <stddef.h> - int main(void) { return madvise(NULL, 0, MADV_DONTNEED); }''')) + int main(void) { return madvise(NULL, 0, MADV_DONTNEED); }''') +missing_madvise_proto = false +if has_madvise + # Some platforms (illumos and Solaris before Solaris 11) provide madvise() + # but forget to prototype it. In this case, has_madvise will be true (the + # test program links despite a compile warning). To detect the + # missing-prototype case, we try again with a definitely-bogus prototype. + # This will only compile if the system headers don't provide the prototype; + # otherwise the conflicting prototypes will cause a compiler error. + missing_madvise_proto = cc.links(gnu_source_prefix + ''' + #include <sys/types.h> + #include <sys/mman.h> + #include <stddef.h> + extern int madvise(int); + int main(void) { return madvise(0); }''') +endif +config_host_data.set('CONFIG_MADVISE', has_madvise) +config_host_data.set('HAVE_MADVISE_WITHOUT_PROTOTYPE', missing_madvise_proto) + config_host_data.set('CONFIG_MEMFD', cc.links(gnu_source_prefix + ''' #include <sys/mman.h> int main(void) { return memfd_create("foo", MFD_ALLOW_SEALING); }''')) config_host_data.set('CONFIG_OPEN_BY_HANDLE', cc.links(gnu_source_prefix + ''' #include <fcntl.h> #if !defined(AT_EMPTY_PATH) # error missing definition #else int main(void) { struct file_handle fh; return open_by_handle_at(0, &fh, 0); } #endif'''))
util/osdep.c +0 -3
@@ -21,23 +21,20 @@* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. */ #include "qemu/osdep.h" #include "qapi/error.h" /* Needed early for CONFIG_BSD etc. */ #ifdef CONFIG_SOLARIS #include <sys/statvfs.h> -/* See MySQL bug #7156 (http://bugs.mysql.com/bug.php?id=7156) for -discussion about Solaris header problems */ -extern int madvise (char *,size_t ,int );#endif #include "qemu-common.h" #include "qemu/cutils.h" #include "qemu/sockets.h" #include "qemu/error-report.h" #include "qemu/madvise.h" #include "qemu/mprotect.h" #include "qemu/hw-version.h" #include "monitor/monitor.h"
Signature · 1 line
2.11.0
Re: [PATCH v3 1/3] util/osdep: Avoid madvise proto on modern Solaris
Quoted 14 lines · Andrew Deason
On older Solaris releases (before Solaris 11), we didn't get a prototype for madvise, and so
util/osdep.cprovides its own prototype. Some time between the public Solaris 11.4 release and Solaris 11.4.42 CBE, we started getting an madvise prototype that looks like this:extern int madvise(void *, size_t, int);which conflicts with the prototype in
util/osdeps.c. Instead of always declaring this prototype, check if we're missing themadvise()prototype, and only declare it ourselves if the prototype is missing. Move the prototype toinclude/qemu/osdep.h, the normal place to handle platform-specific header quirks.
Quoted 5 lines
The '
missing_madvise_proto' meson check contains an obviously wrong prototype for madvise. So if that code compiles and links, we must be missing the actual prototype for madvise.Signed-off-by Andrew Deason <[email protected]>
thanks
-- PMM
PATCH v3 2/3 hw/i386/acpi-build: Avoid 'sun' identifier
In reply to Andrew DeasonOn Solaris, 'sun' is #define'd to 1, which causes errors if a variable is named 'sun'. Slightly change the name of the var for the Slot User Number so we can build on Solaris.
--- hw/i386/acpi-build.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
hw/i386/acpi-build.c +2 -2
@@ -576,32 +576,32 @@ static void build_append_pci_bus_devices(Aml *parent_scope, PCIBus *bus, }Aml *aml_pci_device_dsm (void ) {Aml *method, *UUID , *ifctx, *ifctx1, *ifctx2, *ifctx3, *elsectx;Aml *acpi_index =aml_local (0 );Aml *zero =aml_int (0 );Aml *bnum =aml_arg (4 );Aml *func =aml_arg (2 );Aml *rev =aml_arg (1 ); -Aml *sun =aml_arg (5 ); +Aml *sunum =aml_arg (5 ); method =aml_method ("PDSM" ,6 ,AML_SERIALIZED );/* * PCI Firmware Specification 3.1 * 4.6. _DSM Definitions for PCI */ UUID =aml_touuid ("E5C937D0-3553-4D7A-9117-EA4D19C3434D" ); ifctx =aml_if (aml_equal (aml_arg (0 ),UUID )); { -aml_append (ifctx,aml_store (aml_call2 ("AIDX" , bnum, sun), acpi_index)); +aml_append (ifctx,aml_store (aml_call2 ("AIDX" , bnum, sunum), acpi_index)); ifctx1 =aml_if (aml_equal (func, zero)); {uint8_t byte_list[1 ]; ifctx2 =aml_if (aml_equal (rev,aml_int (2 ))); {/* * advertise function 7 if device has acpi-index * acpi_index values: * 0: not present (default value)
Signature · 1 line
2.11.0
Re: [PATCH v3 2/3] hw/i386/acpi-build: Avoid 'sun' identifier
Quoted 6 lines · Andrew Deason
On Solaris, 'sun' is #define'd to 1, which causes errors if a variable is named 'sun'. Slightly change the name of the var for the Slot User Number so we can build on Solaris.
Reviewed-by Ani Sinha <[email protected]>Signed-off-by Andrew Deason <[email protected]>
Quoted 45 lines
--- hw/i386/acpi-build.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)hw/i386/acpi-build.c +2
-2@@ -576,32 +576,32 @@ static void build_append_pci_bus_devices(Aml *parent_scope, PCIBus *bus, }Aml *aml_pci_device_dsm (void ) {Aml *method, *UUID , *ifctx, *ifctx1, *ifctx2, *ifctx3, *elsectx;Aml *acpi_index =aml_local (0 );Aml *zero =aml_int (0 );Aml *bnum =aml_arg (4 );Aml *func =aml_arg (2 );Aml *rev =aml_arg (1 ); -Aml *sun =aml_arg (5 ); +Aml *sunum =aml_arg (5 ); method =aml_method ("PDSM" ,6 ,AML_SERIALIZED );/* * PCI Firmware Specification 3.1 * 4.6. _DSM Definitions for PCI */ UUID =aml_touuid ("E5C937D0-3553-4D7A-9117-EA4D19C3434D" ); ifctx =aml_if (aml_equal (aml_arg (0 ),UUID )); { -aml_append (ifctx,aml_store (aml_call2 ("AIDX" , bnum, sun), acpi_index)); +aml_append (ifctx,aml_store (aml_call2 ("AIDX" , bnum, sunum), acpi_index)); ifctx1 =aml_if (aml_equal (func, zero)); {uint8_t byte_list[1 ]; ifctx2 =aml_if (aml_equal (rev,aml_int (2 ))); {/* * advertise function 7 if device has acpi-index * acpi_index values: * 0: not present (default value) Signature · 1 line
2.11.0
PATCH v3 3/3 util/osdep: Remove some early cruft
In reply to Andrew DeasonThe include for statvfs.h has not been needed since all statvfs calls were removed in commit 4a1418e07bdc ("Unbreak large mem support by removing kqemu").
The comment mentioning CONFIG_BSD hasn't made sense since an include for config-host.h was removed in commit aafd75841001 ("util: Clean up includes").
Remove this cruft.
--- util/osdep.c | 7 ------- 1 file changed, 7 deletions(-)
util/osdep.c +0 -7
@@ -16,27 +16,20 @@* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. */ #include "qemu/osdep.h" #include "qapi/error.h" - -/* Needed early for CONFIG_BSD etc. */ - -#ifdef CONFIG_SOLARIS -#include <sys/statvfs.h> -#endif -#include "qemu-common.h" #include "qemu/cutils.h" #include "qemu/sockets.h" #include "qemu/error-report.h" #include "qemu/madvise.h" #include "qemu/mprotect.h" #include "qemu/hw-version.h" #include "monitor/monitor.h" static bool fips_enabled = false;
Signature · 1 line
2.11.0
Quoted 6 lines · Andrew Deason
With these minor fixes, I can build qemu on Solaris 11.4.42 CBE (Oracle's new rolling release thing), using '--disable-rdma --enable-modules --disable-dbus-display --target-list=x86_64-softmmu'. I'm just interested in the guest agent right now, so that's all I've tested (briefly), but the rest of the build wasn't hard to get working. With this, the guest agent runs fine using isa-serial.
Who's merging this? Me?
Quoted 22 lines
Changes since v2:
- Rename new symbol toHAVE_MADVISE_WITHOUT_PROTOTYPE
- Move madvise prototype toinclude/qemu/osdep.h
- More comments in meson.buildChanges since v1:
- Change theCONFIG_MADVISEchecks to not be platform-specific
- Add the last commit removingutil/osdep.ccruftAndrew Deason (3):
util/osdep: Avoid madvise proto on modern Solaris hw/i386/acpi-build: Avoid 'sun' identifier util/osdep: Remove some early crufthw/i386/acpi-build.c | 4 ++-- include/qemu/osdep.h | 8 ++++++++ meson.build | 23 +++++++++++++++++++++-- util/osdep.c | 10 ---------- 4 files changed, 31 insertions(+), 14 deletions(-)Signature · 1 line
2.11.0
Quoted 10 lines · Michael S. Tsirkin
Quoted 6 lines · Andrew Deason
With these minor fixes, I can build qemu on Solaris 11.4.42 CBE (Oracle's new rolling release thing), using '--disable-rdma --enable-modules --disable-dbus-display --target-list=x86_64-softmmu'. I'm just interested in the guest agent right now, so that's all I've tested (briefly), but the rest of the build wasn't hard to get working. With this, the guest agent runs fine using isa-serial.
Who's merging this? Me?
I'm putting together a pullreq this morning anyway, so I can take it through target-arm.next.
thanks
-- PMM