]> git.ipfire.org Git - people/stevee/pakfire.git/commitdiff
jail: Enable all QEMU CPU features by default
authorMichael Tremer <michael.tremer@ipfire.org>
Wed, 15 Mar 2023 18:29:42 +0000 (18:29 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Wed, 15 Mar 2023 18:29:42 +0000 (18:29 +0000)
When we are emulating a different architecture, QEMU by default emulates
a very basic processor which might not be able to emulate for example
SIMD instructions.

Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
src/libpakfire/arch.c
src/libpakfire/include/pakfire/arch.h
src/libpakfire/jail.c

index eabf953c622e169fe04e0c7469f463553eb20ca8..68076e5e2b2c5238e6929e9f804cea267ee82ed9 100644 (file)
@@ -248,7 +248,7 @@ int pakfire_arch_is_compatible(const char* name, const char* compatible_arch) {
        return 0;
 }
 
-static int pakfire_arch_supported_by_host(const char* name) {
+int pakfire_arch_supported_by_host(const char* name) {
        if (!name) {
                errno = EINVAL;
                return 1;
index 268c1b68bf104500d1a3860e4ff805dadeb15149..84ff0387a42ff0d5b27947dca8601779556cf602 100644 (file)
@@ -40,6 +40,7 @@ int __pakfire_arch_buildtarget(char* buffer, size_t length, const char* arch, co
 const char* pakfire_arch_platform(const char* name);
 int pakfire_arch_is_compatible(const char* name, const char* compatible_arch);
 
+int pakfire_arch_supported_by_host(const char* name);
 char* pakfire_arch_find_interpreter(const char* name);
 
 #endif
index 9cb347335ef2c0a3f117ef674de970e382d388f2..c81c169aedac49affcfa401807ea4f90630a4fb0 100644 (file)
@@ -253,6 +253,8 @@ PAKFIRE_EXPORT int pakfire_jail_create(struct pakfire_jail** jail,
                struct pakfire* pakfire, int flags) {
        int r;
 
+       const char* arch = pakfire_get_arch(pakfire);
+
        // Allocate a new jail
        struct pakfire_jail* j = calloc(1, sizeof(*j));
        if (!j)
@@ -279,6 +281,13 @@ PAKFIRE_EXPORT int pakfire_jail_create(struct pakfire_jail** jail,
                        goto ERROR;
        }
 
+       // Enable all CPU features that CPU has to offer
+       if (!pakfire_arch_supported_by_host(arch)) {
+               r = pakfire_jail_set_env(j, "QEMU_CPU", "max");
+               if (r)
+                       goto ERROR;
+       }
+
        // Set container UUID
        r = pakfire_jail_set_env(j, "container_uuid", pakfire_jail_uuid(j));
        if (r)