From e36ad68c4bc8e230d6cfa1eb3b0c3757ef108a15 Mon Sep 17 00:00:00 2001 From: yujiayi <3076710949@qq.com> Date: Sun, 29 Sep 2024 14:46:29 +0800 Subject: [PATCH] Add sw64arch support for libvirt-8.0.0 Signed-off-by: lufeifei --- ...w64-architecture-support-for-libvirt.patch | 687 ++++++++++++++++++ libvirt.spec | 12 +- 2 files changed, 695 insertions(+), 4 deletions(-) create mode 100644 libvirt-Add-sw64-architecture-support-for-libvirt.patch diff --git a/libvirt-Add-sw64-architecture-support-for-libvirt.patch b/libvirt-Add-sw64-architecture-support-for-libvirt.patch new file mode 100644 index 0000000..7654027 --- /dev/null +++ b/libvirt-Add-sw64-architecture-support-for-libvirt.patch @@ -0,0 +1,687 @@ +From 6053366caf3573323e1436fc7c3e4e13d26fd3c2 Mon Sep 17 00:00:00 2001 +From: Chen Wang +Date: Wed, 25 May 2022 09:42:04 +0800 +Subject: [PATCH] sw_64: Add sw64 architecture support for libvirt-8.0.0 + +Signed-off-by: Chen Wang +--- + docs/schemas/basictypes.rng | 1 + + docs/schemas/domaincommon.rng | 1 + + meson.build | 2 +- + src/cpu/cpu.c | 2 + + src/cpu/cpu_sw64.c | 302 ++++++++++++++++++++++++++++++++++ + src/cpu/cpu_sw64.h | 31 ++++ + src/cpu/meson.build | 1 + + src/cpu_map/index.xml | 5 + + src/cpu_map/meson.build | 2 + + src/cpu_map/sw64_core3.xml | 4 + + src/cpu_map/sw64_core4.xml | 4 + + src/qemu/qemu_capabilities.c | 12 ++ + src/qemu/qemu_domain.c | 15 +- + src/util/virarch.c | 6 + + src/util/virarch.h | 3 + + src/util/virhostcpu.c | 2 + + src/util/virprocess.c | 2 + + src/util/virsysinfo.c | 3 +- + 18 files changed, 393 insertions(+), 5 deletions(-) + create mode 100644 src/cpu/cpu_sw64.c + create mode 100644 src/cpu/cpu_sw64.h + create mode 100644 src/cpu_map/sw64_core3.xml + create mode 100644 src/cpu_map/sw64_core4.xml + +diff --git a/docs/schemas/basictypes.rng b/docs/schemas/basictypes.rng +index ab18b18..e0724fe 100644 +--- a/docs/schemas/basictypes.rng ++++ b/docs/schemas/basictypes.rng +@@ -460,6 +460,7 @@ + sh4eb + sparc + sparc64 ++ sw_64 + unicore32 + x86_64 + xtensa +diff --git a/docs/schemas/domaincommon.rng b/docs/schemas/domaincommon.rng +index 79c8979..c2bd970 100644 +--- a/docs/schemas/domaincommon.rng ++++ b/docs/schemas/domaincommon.rng +@@ -2613,6 +2613,7 @@ + pcie-pci-bridge + + ioh3420 ++ pcie-root + pcie-root-port + + x3130-upstream +diff --git a/meson.build b/meson.build +index 214a3f0..e76cf4e 100644 +--- a/meson.build ++++ b/meson.build +@@ -1596,7 +1596,7 @@ elif get_option('driver_lxc').enabled() + error('linux and remote_driver are required for LXC') + endif + +-if not get_option('driver_ch').disabled() and host_machine.system() == 'linux' and (host_machine.cpu_family() == 'x86_64' or host_machine.cpu_family() == 'aarch64') ++if not get_option('driver_ch').disabled() and host_machine.system() == 'linux' and (host_machine.cpu_family() == 'x86_64' or host_machine.cpu_family() == 'aarch64' or host_machine.cpu_family() == 'sw_64') + use_ch = true + + if not conf.has('WITH_LIBVIRTD') +diff --git a/src/cpu/cpu.c b/src/cpu/cpu.c +index 49527c3..d11bcc9 100644 +--- a/src/cpu/cpu.c ++++ b/src/cpu/cpu.c +@@ -29,6 +29,7 @@ + #include "cpu_ppc64.h" + #include "cpu_s390.h" + #include "cpu_arm.h" ++#include "cpu_sw64.h" + #include "capabilities.h" + #include "virstring.h" + #include "cpu_loongarch.h" +@@ -43,6 +44,7 @@ static struct cpuArchDriver *drivers[] = { + &cpuDriverS390, + &cpuDriverArm, + &cpuDriverLoongArch, ++ &cpuDriverSW64, + }; + + +diff --git a/src/cpu/cpu_sw64.c b/src/cpu/cpu_sw64.c +new file mode 100644 +index 0000000..199ed60 +--- /dev/null ++++ b/src/cpu/cpu_sw64.c +@@ -0,0 +1,302 @@ ++/* ++ * cpu_sw64.c: CPU driver for sw64 CPUs ++ * ++ * Copyright (C) 2021 Lu Feifei ++ * ++ * This library is free software; you can redistribute it and/or ++ * modify it under the terms of the GNU Lesser General Public ++ * License as published by the Free Software Foundation; either ++ * version 2.1 of the License, or (at your option) any later version. ++ * ++ * This library is distributed in the hope that it will be useful, ++ * but WITHOUT ANY WARRANTY; without even the implied warranty of ++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ++ * Lesser General Public License for more details. ++ * ++ * You should have received a copy of the GNU Lesser General Public ++ * License along with this library. If not, see ++ * . ++ * ++ * Authors: ++ * Lu Feifei ++ */ ++ ++#include ++ ++#include "virfile.h" ++#include "viralloc.h" ++#include "cpu.h" ++#include "cpu_sw64.h" ++#include "cpu_map.h" ++#include "virstring.h" ++#include "virhostcpu.h" ++ ++#define VIR_FROM_THIS VIR_FROM_CPU ++#define CPUINFO_PATH "/proc/cpuinfo" ++ ++static const virArch archs[] = { VIR_ARCH_SW_64 }; ++ ++typedef struct _sw64Model sw64Model; ++struct _sw64Model { ++ char *name; ++}; ++ ++typedef struct _sw64Map sw64Map; ++struct _sw64Map { ++ size_t nmodels; ++ sw64Model **models; ++}; ++ ++static virCPUCompareResult ++virCPUsw64Compare(virCPUDef *host ATTRIBUTE_UNUSED, ++ virCPUDef *cpu ATTRIBUTE_UNUSED, ++ bool failMessages ATTRIBUTE_UNUSED) ++{ ++ return VIR_CPU_COMPARE_IDENTICAL; ++} ++ ++static int ++virCPUsw64Update(virCPUDef *guest, ++ const virCPUDef *host, ++ bool relative) ++{ ++ g_autoptr(virCPUDef) updated = NULL; ++ ++ if (!relative || guest->mode != VIR_CPU_MODE_HOST_MODEL) ++ return 0; ++ ++ if (!host) { ++ virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", ++ _("unknown host CPU model")); ++ return -1; ++ } ++ ++ if (!(updated = virCPUDefCopyWithoutModel(guest))) ++ return -1; ++ ++ updated->mode = VIR_CPU_MODE_CUSTOM; ++ if (virCPUDefCopyModel(updated, host, true) < 0) ++ return -1; ++ ++ virCPUDefStealModel(guest, updated, false); ++ guest->mode = VIR_CPU_MODE_CUSTOM; ++ guest->match = VIR_CPU_MATCH_EXACT; ++ ++ return 0; ++} ++ ++static void ++sw64ModelFree(sw64Model *model) ++{ ++ if (!model) ++ return; ++ ++ VIR_FREE(model->name); ++ VIR_FREE(model); ++} ++ ++static void ++sw64MapFree(sw64Map *map) ++{ ++ size_t i; ++ ++ if (!map) ++ return; ++ ++ for (i = 0; i < map->nmodels; i++) ++ sw64ModelFree(map->models[i]); ++ VIR_FREE(map->models); ++ VIR_FREE(map); ++} ++ ++static sw64Model * ++sw64ModelFind(const sw64Map *map, ++ const char *name) ++{ ++ size_t i; ++ ++ for (i = 0; i < map->nmodels; i++) { ++ if (STREQ(map->models[i]->name, name)) ++ return map->models[i]; ++ } ++ ++ return NULL; ++} ++ ++static int ++sw64ModelParse(xmlXPathContextPtr ctxt ATTRIBUTE_UNUSED, ++ const char *name, ++ void *data) ++{ ++ sw64Map *map = data; ++ sw64Model *model; ++ int ret = -1; ++ ++ model = g_new0(sw64Model, 1); ++ ++ model->name = g_strdup(name); ++ ++ if (sw64ModelFind(map, model->name)) { ++ virReportError(VIR_ERR_INTERNAL_ERROR, ++ _("CPU model %s already defined"), model->name); ++ goto cleanup; ++ } ++ ++ VIR_APPEND_ELEMENT(map->models, map->nmodels, model); ++ ++ ret = 0; ++ ++ cleanup: ++ sw64ModelFree(model); ++ return ret; ++} ++ ++static sw64Map * ++sw64LoadMap(void) ++{ ++ sw64Map *map; ++ ++ map = g_new0(sw64Map, 1); ++ ++ if (cpuMapLoad("sw64", NULL, NULL, sw64ModelParse, map) < 0) ++ goto error; ++ ++ return map; ++ ++ error: ++ sw64MapFree(map); ++ return NULL; ++} ++ ++static int ++sw64CPUParseCpuModeString(const char *str, ++ const char *prefix, ++ unsigned int *mode) ++{ ++ char *p; ++ unsigned int ui; ++ /* If the string doesn't start with the expected prefix, then ++ * we're not looking at the right string and we should move on */ ++ if (!STRPREFIX(str, prefix)) ++ return 1; ++ /* Skip the prefix */ ++ str += strlen(prefix); ++ ++ /* Skip all whitespace */ ++ while (g_ascii_isspace(*str)) ++ str++; ++ if (*str == '\0') ++ goto error; ++ ++ /* Skip the colon. If anything but a colon is found, then we're ++ * not looking at the right string and we should move on */ ++ if (*str != ':') ++ return 1; ++ str++; ++ ++ /* Skip all whitespace */ ++ while (g_ascii_isspace(*str)) ++ str++; ++ if (*str == '\0') ++ goto error; ++ ++ if (virStrToLong_ui(str, &p, 10, &ui) < 0 || ++ (*p != '.' && *p != '\0' && !g_ascii_isspace(*p))) { ++ goto error; ++ } ++ ++ *mode = ui; ++ return 0; ++ ++ error: ++ virReportError(VIR_ERR_INTERNAL_ERROR, ++ _("Missing or invalid CPU variation in %s"), ++ CPUINFO_PATH); ++ return -1; ++} ++ ++static int ++sw64CPUParseCpuMode(FILE *cpuinfo, unsigned int *mode) ++{ ++ const char *prefix = "cpu variation"; ++ char line[1024]; ++ ++ while (fgets(line, sizeof(line), cpuinfo) != NULL) { ++ if (sw64CPUParseCpuModeString(line, prefix, mode) < 0) ++ return -1; ++ } ++ ++ return 0; ++} ++ ++static int ++virCPUsw64GetHost(virCPUDef *cpu, ++ virDomainCapsCPUModels *models ATTRIBUTE_UNUSED) ++{ ++ int ret = -1; ++ unsigned int mode; ++ FILE *cpuinfo = fopen(CPUINFO_PATH, "r"); ++ if (!cpuinfo) { ++ virReportSystemError(errno, ++ _("cannot open %s"), CPUINFO_PATH); ++ return -1; ++ } ++ ++ ret = sw64CPUParseCpuMode(cpuinfo, &mode); ++ if (ret < 0) ++ goto cleanup; ++ ++ if (mode == 3) ++ cpu->model = g_strdup("core3"); ++ else if (mode == 4) ++ cpu->model = g_strdup("core4"); ++ ++ cleanup: ++ VIR_FORCE_FCLOSE(cpuinfo); ++ return ret; ++} ++ ++static int ++virCPUsw64DriverGetModels(char ***models) ++{ ++ sw64Map *map; ++ size_t i; ++ int ret = -1; ++ ++ if (!(map = sw64LoadMap())) ++ goto error; ++ ++ if (models) { ++ *models = g_new0(char *, map->nmodels + 1); ++ ++ for (i = 0; i < map->nmodels; i++) { ++ (*models)[i] = g_strdup(map->models[i]->name); ++ } ++ } ++ ++ ret = map->nmodels; ++ ++ cleanup: ++ sw64MapFree(map); ++ return ret; ++ ++ error: ++ if (models) { ++ g_strfreev(*models); ++ *models = NULL; ++ } ++ goto cleanup; ++} ++ ++struct cpuArchDriver cpuDriverSW64 = { ++ .name = "sw_64", ++ .arch = archs, ++ .narch = G_N_ELEMENTS(archs), ++ .getHost = virCPUsw64GetHost, ++ .compare = virCPUsw64Compare, ++ .decode = NULL, ++ .encode = NULL, ++ .baseline = NULL, ++ .update = virCPUsw64Update, ++ .getModels = virCPUsw64DriverGetModels, ++}; +diff --git a/src/cpu/cpu_sw64.h b/src/cpu/cpu_sw64.h +new file mode 100644 +index 0000000..211a7cf +--- /dev/null ++++ b/src/cpu/cpu_sw64.h +@@ -0,0 +1,31 @@ ++/* ++ * cpu_sw64.h: CPU driver for sw64 CPUs ++ * ++ * Copyright (C) 2021 Lu Feifei ++ * ++ * This library is free software; you can redistribute it and/or ++ * modify it under the terms of the GNU Lesser General Public ++ * License as published by the Free Software Foundation; either ++ * version 2.1 of the License, or (at your option) any later version. ++ * ++ * This library is distributed in the hope that it will be useful, ++ * but WITHOUT ANY WARRANTY; without even the implied warranty of ++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ++ * Lesser General Public License for more details. ++ * ++ * You should have received a copy of the GNU Lesser General Public ++ * License along with this library. If not, see ++ * . ++ * ++ * Authors: ++ * Lu Feifei ++ */ ++ ++#ifndef __VIR_CPU_SW64_H__ ++# define __VIR_CPU_SW64_H__ ++ ++# include "cpu.h" ++ ++extern struct cpuArchDriver cpuDriverSW64; ++ ++#endif /* __VIR_CPU_SW64_H__ */ +diff --git a/src/cpu/meson.build b/src/cpu/meson.build +index ad2f859..5e99dbd 100644 +--- a/src/cpu/meson.build ++++ b/src/cpu/meson.build +@@ -1,6 +1,7 @@ + cpu_sources = [ + 'cpu.c', + 'cpu_arm.c', ++ 'cpu_sw64.c', + 'cpu_map.c', + 'cpu_ppc64.c', + 'cpu_s390.c', +diff --git a/src/cpu_map/index.xml b/src/cpu_map/index.xml +index 3ae9348..5d1a999 100644 +--- a/src/cpu_map/index.xml ++++ b/src/cpu_map/index.xml +@@ -113,6 +113,11 @@ + + + ++ ++ ++ ++ ++ + + + +diff --git a/src/cpu_map/meson.build b/src/cpu_map/meson.build +index baeffa3..3871f09 100644 +--- a/src/cpu_map/meson.build ++++ b/src/cpu_map/meson.build +@@ -79,6 +79,8 @@ cpumap_data = [ + 'x86_vendors.xml', + 'x86_Westmere-IBRS.xml', + 'x86_Westmere.xml', ++ 'sw64_core3.xml', ++ 'sw64_core4.xml', + 'loongarch_vendors.xml', + 'ls_3a5000.xml', + ] +diff --git a/src/cpu_map/sw64_core3.xml b/src/cpu_map/sw64_core3.xml +new file mode 100644 +index 0000000..ec3fa0e +--- /dev/null ++++ b/src/cpu_map/sw64_core3.xml +@@ -0,0 +1,4 @@ ++ ++ ++ ++ +diff --git a/src/cpu_map/sw64_core4.xml b/src/cpu_map/sw64_core4.xml +new file mode 100644 +index 0000000..11e763b +--- /dev/null ++++ b/src/cpu_map/sw64_core4.xml +@@ -0,0 +1,4 @@ ++ ++ ++ ++ +diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c +index 75668c6..ca47a7a 100644 +--- a/src/qemu/qemu_capabilities.c ++++ b/src/qemu/qemu_capabilities.c +@@ -771,6 +771,8 @@ virArch virQEMUCapsArchFromString(const char *arch) + return VIR_ARCH_ARMV7L; + if (STREQ(arch, "or32")) + return VIR_ARCH_OR32; ++ if (STREQ(arch, "sw64")) ++ return VIR_ARCH_SW_64; + + return virArchFromString(arch); + } +@@ -784,6 +786,8 @@ const char *virQEMUCapsArchToString(virArch arch) + return "arm"; + if (arch == VIR_ARCH_OR32) + return "or32"; ++ if (arch == VIR_ARCH_SW_64) ++ return "sw64"; + + return virArchToString(arch); + } +@@ -2072,6 +2076,10 @@ bool virQEMUCapsHasPCIMultiBus(const virDomainDef *def) + * since forever */ + if (ARCH_IS_X86(def->os.arch)) + return true; ++ /* sw_64 support PCI-multibus on all machine types ++ * since forever */ ++ if (ARCH_IS_SW64(def->os.arch)) ++ return true; + + if (STRPREFIX(def->os.machine,"loongson7a")) + return true; +@@ -2718,6 +2726,8 @@ static const char *preferredMachines[] = + + "sim", /* VIR_ARCH_XTENSA */ + "sim", /* VIR_ARCH_XTENSAEB */ ++ ++ "core3", /* VIR_ARCH_SW_64 */ + }; + G_STATIC_ASSERT(G_N_ELEMENTS(preferredMachines) == VIR_ARCH_LAST); + +@@ -5129,6 +5139,8 @@ virQEMUCapsInitQMPBasicArch(virQEMUCaps *qemuCaps) + case VIR_ARCH_XTENSAEB: + case VIR_ARCH_NONE: + case VIR_ARCH_LAST: ++ case VIR_ARCH_SW_64: ++ + default: + break; + } +diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c +index 7a53b93..f32fdcb 100644 +--- a/src/qemu/qemu_domain.c ++++ b/src/qemu/qemu_domain.c +@@ -3740,6 +3740,10 @@ qemuDomainDefAddDefaultDevices(virQEMUDriver *driver, + addPCIRoot = true; + break; + ++ case VIR_ARCH_SW_64: ++ addPCIeRoot = true; ++ break; ++ + case VIR_ARCH_ARMV7B: + case VIR_ARCH_CRIS: + case VIR_ARCH_ITANIUM: +@@ -5099,7 +5103,10 @@ qemuDomainControllerDefPostParse(virDomainControllerDef *cont, + cont->model = VIR_DOMAIN_CONTROLLER_MODEL_USB_QEMU_XHCI; + else if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_NEC_USB_XHCI)) + cont->model = VIR_DOMAIN_CONTROLLER_MODEL_USB_NEC_XHCI; +- } ++ } else if (def->os.arch == VIR_ARCH_SW_64) { ++ if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE_QEMU_XHCI)) ++ cont->model = VIR_DOMAIN_CONTROLLER_MODEL_USB_QEMU_XHCI; ++ } + } + /* forbid usb model 'qusb1' and 'qusb2' in this kind of hyperviosr */ + if (cont->model == VIR_DOMAIN_CONTROLLER_MODEL_USB_QUSB1 || +@@ -5396,7 +5403,8 @@ qemuDomainDefaultVideoDevice(const virDomainDef *def, + return VIR_DOMAIN_VIDEO_TYPE_VGA; + if (qemuDomainIsARMVirt(def) || + qemuDomainIsRISCVVirt(def) || +- ARCH_IS_S390(def->os.arch)) { ++ ARCH_IS_S390(def->os.arch) || ++ ARCH_IS_SW64(def->os.arch)) { + return VIR_DOMAIN_VIDEO_TYPE_VIRTIO; + } + if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE_CIRRUS_VGA)) +@@ -8705,7 +8713,8 @@ qemuDomainMachineHasBuiltinIDE(const char *machine, + return qemuDomainMachineIsI440FX(machine, arch) || + STREQ(machine, "malta") || + STREQ(machine, "sun4u") || +- STREQ(machine, "g3beige") || ++ STRPREFIX(machine, "core") || ++ STREQ(machine, "g3beige") || + STREQ(machine, "loongson3a") || + STREQ(machine, "loongson7a"); + } +diff --git a/src/util/virarch.c b/src/util/virarch.c +index 9f40a71..ce149a4 100644 +--- a/src/util/virarch.c ++++ b/src/util/virarch.c +@@ -84,6 +84,8 @@ static const struct virArchData { + + { "xtensa", 32, VIR_ARCH_LITTLE_ENDIAN }, + { "xtensaeb", 32, VIR_ARCH_BIG_ENDIAN }, ++ ++ { "sw_64", 64, VIR_ARCH_LITTLE_ENDIAN }, + }; + + G_STATIC_ASSERT(G_N_ELEMENTS(virArchData) == VIR_ARCH_LAST); +@@ -197,6 +199,8 @@ virArch virArchFromHost(void) + return VIR_ARCH_ARMV7L; + case PROCESSOR_ARCHITECTURE_ARM64: + return VIR_ARCH_AARCH64; ++ case PROCESSOR_ARCHITECTURE_SW64: ++ return VIR_ARCH_SW_64; + default: + VIR_WARN("Unknown host arch '%d', report to libvir-list@redhat.com", + info.wProcessorArchitecture); +@@ -221,6 +225,8 @@ virArch virArchFromHost(void) + arch = VIR_ARCH_I686; + } else if (STREQ(ut.machine, "amd64")) { + arch = VIR_ARCH_X86_64; ++ } else if (STREQ(ut.machine, "sw_64")) { ++ arch = VIR_ARCH_SW_64; + } else if (STREQ(ut.machine, "arm64")) { + arch = VIR_ARCH_AARCH64; + } else if (STREQ(ut.machine, "loongarch64")) { +diff --git a/src/util/virarch.h b/src/util/virarch.h +index 7d396f2..2e4f7c9 100644 +--- a/src/util/virarch.h ++++ b/src/util/virarch.h +@@ -70,6 +70,8 @@ typedef enum { + VIR_ARCH_XTENSA, /* XTensa 32 LE https://en.wikipedia.org/wiki/Xtensa#Processor_Cores */ + VIR_ARCH_XTENSAEB, /* XTensa 32 BE https://en.wikipedia.org/wiki/Xtensa#Processor_Cores */ + ++ VIR_ARCH_SW_64, /* SW_64 64 LE XHB */ ++ + VIR_ARCH_LAST, + } virArch; + +@@ -98,6 +100,7 @@ typedef enum { + + #define ARCH_IS_MIPS64(arch) ((arch) == VIR_ARCH_MIPS64 ||\ + (arch) == VIR_ARCH_MIPS64EL) ++#define ARCH_IS_SW64(arch) ((arch) == VIR_ARCH_SW_64) + + #define ARCH_IS_LOONGARCH(arch) ((arch) == VIR_ARCH_LOONGARCH64) + +diff --git a/src/util/virhostcpu.c b/src/util/virhostcpu.c +index 137796e..2572229 100644 +--- a/src/util/virhostcpu.c ++++ b/src/util/virhostcpu.c +@@ -555,6 +555,8 @@ virHostCPUParseFrequency(FILE *cpuinfo, + prefix = "clock"; + else if (ARCH_IS_S390(arch)) + prefix = "cpu MHz dynamic"; ++ else if (ARCH_IS_SW64(arch)) ++ prefix = "cpu frequency [MHz]"; + + if (!prefix) { + VIR_WARN("%s is not supported by the %s parser", +diff --git a/src/util/virprocess.c b/src/util/virprocess.c +index f3933a2..04095e0 100644 +--- a/src/util/virprocess.c ++++ b/src/util/virprocess.c +@@ -89,6 +89,8 @@ VIR_LOG_INIT("util.process"); + # define __NR_setns 350 + # elif defined(__s390__) + # define __NR_setns 339 ++# elif defined(__sw_64__) ++# define __NR_setns 501 + # endif + # endif + +diff --git a/src/util/virsysinfo.c b/src/util/virsysinfo.c +index 9577cf1..4cdbf32 100644 +--- a/src/util/virsysinfo.c ++++ b/src/util/virsysinfo.c +@@ -1254,7 +1254,8 @@ virSysinfoRead(void) + #elif !defined(WIN32) && \ + (defined(__x86_64__) || \ + defined(__i386__) || \ +- defined(__amd64__)) ++ defined(__amd64__) || \ ++ defined(__sw_64__)) + return virSysinfoReadDMI(); + #else /* WIN32 || not supported arch */ + /* +-- +2.17.1 + diff --git a/libvirt.spec b/libvirt.spec index 91da24f..a3f4176 100644 --- a/libvirt.spec +++ b/libvirt.spec @@ -3,11 +3,11 @@ # This spec file assumes you are building on a Fedora or RHEL version # that's still supported by the vendor. It may work on other distros # or versions, but no effort will be made to ensure that going forward. -%define anolis_release .0.2 +%define anolis_release .0.3 %define min_rhel 8 %define min_fedora 33 -%define arches_qemu_kvm %{ix86} x86_64 %{power64} %{arm} aarch64 s390x loongarch64 +%define arches_qemu_kvm %{ix86} x86_64 %{power64} %{arm} aarch64 s390x loongarch64 sw_64 %if 0%{?rhel} %if 0%{?rhel} > 8 %define arches_qemu_kvm x86_64 aarch64 s390x loongarch64 @@ -16,7 +16,7 @@ %endif %endif -%define arches_64bit x86_64 %{power64} aarch64 s390x riscv64 loongarch64 +%define arches_64bit x86_64 %{power64} aarch64 s390x riscv64 loongarch64 sw_64 %define arches_x86 %{ix86} x86_64 %define arches_systemtap_64bit %{arches_64bit} @@ -24,7 +24,7 @@ %define arches_xen %{arches_x86} aarch64 %define arches_vbox %{arches_x86} %define arches_ceph %{arches_64bit} -%define arches_zfs %{arches_x86} %{power64} %{arm} loongarch64 +%define arches_zfs %{arches_x86} %{power64} %{arm} loongarch64 sw_64 %define arches_numactl %{arches_x86} %{power64} aarch64 s390x loongarch64 %define arches_numad %{arches_x86} %{power64} aarch64 loongarch64 @@ -328,6 +328,7 @@ Patch1004: qemu-validate-Drop-tpm-tis-arch-validation.patch Patch1005: qemu-command-Use-correct-tpm-device-for-all-non-x86.patch Patch1006: libvirt-cpu-Add-new-Dharma-CPU-model.patch Patch1007: libvirt-cpu-map-add-S5000C-cpu-model.patch +Patch1008: libvirt-Add-sw64-architecture-support-for-libvirt.patch Requires: libvirt-daemon = %{version}-%{release} Requires: libvirt-daemon-config-network = %{version}-%{release} @@ -2207,6 +2208,9 @@ exit 0 %changelog +* Mon Sep 30 2024 lufeifei - 8.0.0-23.2.0.3 +- Add sw64arch support + * Fri Sep 20 2024 Jiakun Shuai - 8.0.0-23.2.0.2 - Add Phytium S5000C CPU model -- Gitee