From 5a50ac2ddfe70fa929dbad6e5318da77803e69f5 Mon Sep 17 00:00:00 2001 From: Renbo Date: Thu, 15 Sep 2022 11:23:43 +0800 Subject: [PATCH 1/2] update to libvirt-8.0.0-5.4.module+el8.6.0+16370+bb85faee Signed-off-by: Renbo --- libvirt-Add-VIR_MIGRATE_ZEROCOPY-flag.patch | 49 + libvirt-Add-loongarch-support.patch | 1233 ----------------- ...nalMemlock-into-qemuDomainObjPrivate.patch | 91 ++ ...ut-validation-of-disk-startup-policy.patch | 112 ++ ...u-Add-qemuDomainSetMaxMemLock-helper.patch | 155 +++ ...qemuDomainObjPrivate-originalMemlock.patch | 55 + ...-Implement-VIR_MIGRATE_ZEROCOPY-flag.patch | 120 ++ ...estore-original-memory-locking-limit.patch | 138 ++ ...igration-Use-qemuDomainSetMaxMemLock.patch | 53 + ...or-messages-for-startupPolicy-checks.patch | 52 + ...rtupPolicy-Validate-disk-type-better.patch | 43 + ...ix-check-of-startupPolicy-definition.patch | 57 + ...upport-for-VIR_MIGRATE_ZEROCOPY-flag.patch | 80 ++ libvirt.spec | 45 +- 14 files changed, 1041 insertions(+), 1242 deletions(-) create mode 100644 libvirt-Add-VIR_MIGRATE_ZEROCOPY-flag.patch delete mode 100644 libvirt-Add-loongarch-support.patch create mode 100644 libvirt-conf-Move-virDomainObj-originalMemlock-into-qemuDomainObjPrivate.patch create mode 100644 libvirt-domain_validate-Split-out-validation-of-disk-startup-policy.patch create mode 100644 libvirt-qemu-Add-qemuDomainSetMaxMemLock-helper.patch create mode 100644 libvirt-qemu_domain-Format-qemuDomainObjPrivate-originalMemlock.patch create mode 100644 libvirt-qemu_migration-Implement-VIR_MIGRATE_ZEROCOPY-flag.patch create mode 100644 libvirt-qemu_migration-Restore-original-memory-locking-limit.patch create mode 100644 libvirt-qemu_migration-Use-qemuDomainSetMaxMemLock.patch create mode 100644 libvirt-virDomainDiskDefValidate-Improve-error-messages-for-startupPolicy-checks.patch create mode 100644 libvirt-virDomainDiskDefValidateStartupPolicy-Validate-disk-type-better.patch create mode 100644 libvirt-virDomainDiskTranslateSourcePool-Fix-check-of-startupPolicy-definition.patch create mode 100644 libvirt-virsh-Add-support-for-VIR_MIGRATE_ZEROCOPY-flag.patch diff --git a/libvirt-Add-VIR_MIGRATE_ZEROCOPY-flag.patch b/libvirt-Add-VIR_MIGRATE_ZEROCOPY-flag.patch new file mode 100644 index 0000000..e1bf11f --- /dev/null +++ b/libvirt-Add-VIR_MIGRATE_ZEROCOPY-flag.patch @@ -0,0 +1,49 @@ +From 2f3e89c97c7babc1d4da579eadf34979c8fc1725 Mon Sep 17 00:00:00 2001 +Message-Id: <2f3e89c97c7babc1d4da579eadf34979c8fc1725@dist-git> +From: Jiri Denemark +Date: Wed, 22 Jun 2022 16:35:50 +0200 +Subject: [PATCH] Add VIR_MIGRATE_ZEROCOPY flag +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +The flag can be used to enable zero-copy mechanism for migrating memory +pages. + +Signed-off-by: Jiri Denemark +Reviewed-by: Ján Tomko +(cherry picked from commit 8744beecb36600e773c8a8c4823db2bf4b3e262d) + +https://bugzilla.redhat.com/show_bug.cgi?id=2117272 + +Conflicts: + include/libvirt/libvirt-domain.h + - post-copy recovery not backported + +Signed-off-by: Jiri Denemark +--- + include/libvirt/libvirt-domain.h | 8 ++++++++ + 1 file changed, 8 insertions(+) + +diff --git a/include/libvirt/libvirt-domain.h b/include/libvirt/libvirt-domain.h +index 5f0a9b7572..792973ce2d 100644 +--- a/include/libvirt/libvirt-domain.h ++++ b/include/libvirt/libvirt-domain.h +@@ -860,6 +860,14 @@ typedef enum { + */ + VIR_MIGRATE_NON_SHARED_SYNCHRONOUS_WRITES = (1 << 18), + ++ /* Use zero-copy mechanism for migrating memory pages. For QEMU/KVM this ++ * means QEMU will be temporarily allowed to lock all guest pages in host's ++ * memory, although only those that are queued for transfer will be locked ++ * at the same time. ++ * ++ * Since: 8.5.0 ++ */ ++ VIR_MIGRATE_ZEROCOPY = (1 << 20), + } virDomainMigrateFlags; + + +-- +2.35.1 + diff --git a/libvirt-Add-loongarch-support.patch b/libvirt-Add-loongarch-support.patch deleted file mode 100644 index 94fd22a..0000000 --- a/libvirt-Add-loongarch-support.patch +++ /dev/null @@ -1,1233 +0,0 @@ -From da7befb4ce165d692f34156f740f4ea3ce2b7fec Mon Sep 17 00:00:00 2001 -From: zhaotianrui -Date: Sat, 3 Sep 2022 14:23:43 -0400 -Subject: [PATCH] Add loongarch support - -Signed-off-by: zhaotianrui -Change-Id: I8d245bc2fb914b08af4ade8e334d59ba3a5c2f01 ---- - po/POTFILES.in | 1 + - src/cpu/cpu.c | 3 +- - src/cpu/cpu.h | 3 +- - src/cpu/cpu_loongarch.c | 727 ++++++++++++++++++++++++++++++ - src/cpu/cpu_loongarch.h | 28 ++ - src/cpu/cpu_loongarch_data.h | 40 ++ - src/cpu/meson.build | 1 + - src/cpu_map/index.xml | 5 + - src/cpu_map/loongarch_vendors.xml | 3 + - src/cpu_map/ls_3a5000.xml | 6 + - src/cpu_map/meson.build | 2 + - src/qemu/qemu_capabilities.c | 5 + - src/qemu/qemu_conf.c | 4 +- - src/qemu/qemu_domain.c | 20 +- - src/qemu/qemu_domain.h | 1 + - src/qemu/qemu_domain_address.c | 58 +++ - src/qemu/qemu_validate.c | 3 +- - src/util/virarch.c | 3 + - src/util/virarch.h | 3 + - src/util/virhostcpu.c | 2 +- - src/util/virsysinfo.c | 2 +- - 21 files changed, 913 insertions(+), 7 deletions(-) - create mode 100644 src/cpu/cpu_loongarch.c - create mode 100644 src/cpu/cpu_loongarch.h - create mode 100644 src/cpu/cpu_loongarch_data.h - create mode 100644 src/cpu_map/loongarch_vendors.xml - create mode 100644 src/cpu_map/ls_3a5000.xml - -diff --git a/po/POTFILES.in b/po/POTFILES.in -index bf0a3b3529..1153e78265 100644 ---- a/po/POTFILES.in -+++ b/po/POTFILES.in -@@ -68,6 +68,7 @@ - @SRCDIR@src/cpu/cpu_arm.c - @SRCDIR@src/cpu/cpu_map.c - @SRCDIR@src/cpu/cpu_ppc64.c -+@SRCDIR@src/cpu/cpu_loongarch.c - @SRCDIR@src/cpu/cpu_s390.c - @SRCDIR@src/cpu/cpu_x86.c - @SRCDIR@src/datatypes.c -diff --git a/src/cpu/cpu.c b/src/cpu/cpu.c -index 285c7eee44..49527c3688 100644 ---- a/src/cpu/cpu.c -+++ b/src/cpu/cpu.c -@@ -31,7 +31,7 @@ - #include "cpu_arm.h" - #include "capabilities.h" - #include "virstring.h" -- -+#include "cpu_loongarch.h" - - #define VIR_FROM_THIS VIR_FROM_CPU - -@@ -42,6 +42,7 @@ static struct cpuArchDriver *drivers[] = { - &cpuDriverPPC64, - &cpuDriverS390, - &cpuDriverArm, -+ &cpuDriverLoongArch, - }; - - -diff --git a/src/cpu/cpu.h b/src/cpu/cpu.h -index 071b33fe76..ce7aee4757 100644 ---- a/src/cpu/cpu.h -+++ b/src/cpu/cpu.h -@@ -28,7 +28,7 @@ - #include "cpu_x86_data.h" - #include "cpu_ppc64_data.h" - #include "cpu_arm_data.h" -- -+#include "cpu_loongarch_data.h" - - typedef struct _virCPUData virCPUData; - struct _virCPUData { -@@ -37,6 +37,7 @@ struct _virCPUData { - virCPUx86Data x86; - virCPUppc64Data ppc64; - virCPUarmData arm; -+ virCPULoongArchData loongarch; - /* generic driver needs no data */ - } data; - }; -diff --git a/src/cpu/cpu_loongarch.c b/src/cpu/cpu_loongarch.c -new file mode 100644 -index 0000000000..f7b4b85a44 ---- /dev/null -+++ b/src/cpu/cpu_loongarch.c -@@ -0,0 +1,727 @@ -+/* -+ * cpu_loongarch.c: CPU driver for 64-bit LOONGARCH CPUs -+ * -+ * Copyright (C) 2013 Red Hat, Inc. -+ * Copyright (C) IBM Corporation, 2010 -+ * -+ * 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 -+ * . -+ */ -+ -+#include -+#include -+#include -+#include -+#include -+ -+#include -+#include -+#include -+#include -+#include -+#include -+ -+#include "virlog.h" -+#include "viralloc.h" -+#include "cpu.h" -+#include "virstring.h" -+#include "cpu_map.h" -+#include "virbuffer.h" -+#include "cpu_loongarch.h" -+#include "cpu_loongarch_data.h" -+ -+#define VIR_FROM_THIS VIR_FROM_CPU -+ -+VIR_LOG_INIT("cpu.cpu_loongarch"); -+ -+static const virArch archs[] = { VIR_ARCH_LOONGARCH64 }; -+ -+typedef struct _LoongArch_vendor LoongArch_vendor; -+struct _LoongArch_vendor { -+ char *name; -+}; -+ -+typedef struct _LoongArch_model LoongArch_model; -+struct _LoongArch_model { -+ char *name; -+ LoongArch_vendor *vendor; -+ virCPULoongArchData data; -+}; -+ -+typedef struct _LoongArch_map LoongArch_map; -+struct _LoongArch_map { -+ size_t nvendors; -+ LoongArch_vendor **vendors; -+ size_t nmodels; -+ LoongArch_model **models; -+}; -+ -+static void -+LoongArchDataClear(virCPULoongArchData *data) -+{ -+ if (!data) -+ return; -+ -+ g_free(data->prid); -+} -+ -+static int -+LoongArchDataCopy(virCPULoongArchData *dst, const virCPULoongArchData *src) -+{ -+ size_t i; -+ -+ dst->prid = g_new0(virCPULoongArchPrid, src->len); -+ dst->len = src->len; -+ -+ for (i = 0; i < src->len; i++) { -+ dst->prid[i].value = src->prid[i].value; -+ dst->prid[i].mask = src->prid[i].mask; -+ } -+ -+ return 0; -+} -+ -+static void -+LoongArchVendorFree(LoongArch_vendor *vendor) -+{ -+ if (!vendor) -+ return; -+ -+ g_free(vendor); -+} -+ -+static LoongArch_vendor * -+LoongArchVendorFind(LoongArch_map *map, -+ const char *name) -+{ -+ size_t i; -+ -+ for (i = 0; i < map->nvendors; i++) { -+ if (STREQ(map->vendors[i]->name, name)) -+ return map->vendors[i]; -+ } -+ -+ return NULL; -+} -+ -+static void -+LoongArchModelFree(LoongArch_model *model) -+{ -+ if (!model) -+ return; -+ -+ LoongArchDataClear(&model->data); -+ g_free(model->name); -+ g_free(model); -+} -+ -+static LoongArch_model * -+LoongArchModelCopy(LoongArch_model *model) -+{ -+ LoongArch_model *copy; -+ -+ copy = g_new0(LoongArch_model, 1); -+ copy->name = g_strdup(model->name); -+ -+ if (LoongArchDataCopy(©->data, &model->data) < 0) -+ goto error; -+ -+ copy->vendor = model->vendor; -+ -+ return copy; -+ -+ error: -+ LoongArchModelFree(copy); -+ return NULL; -+} -+ -+static LoongArch_model * -+LoongArchModelFind(LoongArch_map *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 LoongArch_model * -+LoongArchModelFindPrid(LoongArch_map *map, -+ uint32_t prid) -+{ -+ size_t i; -+ size_t j; -+ -+ for (i = 0; i < map->nmodels; i++) { -+ LoongArch_model *model = map->models[i]; -+ for (j = 0; j < model->data.len; j++) { -+ if ((prid & model->data.prid[j].mask) == model->data.prid[j].value) -+ return model; -+ } -+ } -+ -+ return NULL; -+} -+ -+static LoongArch_model * -+LoongArchModelFromCPU(const virCPUDef *cpu, -+ LoongArch_map *map) -+{ -+ LoongArch_model *model; -+ -+ if (!cpu->model) { -+ virReportError(VIR_ERR_INVALID_ARG, "%s", -+ _("no CPU model specified")); -+ return NULL; -+ } -+ -+ if (!(model = LoongArchModelFind(map, cpu->model))) { -+ virReportError(VIR_ERR_INTERNAL_ERROR, -+ _("Unknown CPU model %s"), cpu->model); -+ return NULL; -+ } -+ -+ return LoongArchModelCopy(model); -+} -+ -+static void -+LoongArchMapFree(LoongArch_map *map) -+{ -+ size_t i; -+ -+ if (!map) -+ return; -+ -+ for (i = 0; i < map->nmodels; i++) -+ LoongArchModelFree(map->models[i]); -+ g_free(map->models); -+ -+ for (i = 0; i < map->nvendors; i++) -+ LoongArchVendorFree(map->vendors[i]); -+ g_free(map->vendors); -+ -+ g_free(map); -+} -+ -+static int -+LoongArchVendorParse(xmlXPathContextPtr ctxt ATTRIBUTE_UNUSED, -+ const char *name, -+ void *data) -+{ -+ LoongArch_map *map = data; -+ LoongArch_vendor *vendor; -+ int ret = -1; -+ -+ vendor = g_new0(LoongArch_vendor, 1); -+ vendor->name = g_strdup(name); -+ -+ if (LoongArchVendorFind(map, vendor->name)) { -+ virReportError(VIR_ERR_INTERNAL_ERROR, -+ _("CPU vendor %s already defined"), vendor->name); -+ goto cleanup; -+ } -+ -+ VIR_APPEND_ELEMENT(map->vendors, map->nvendors, vendor); -+ ret = 0; -+ -+ cleanup: -+ LoongArchVendorFree(vendor); -+ return ret; -+} -+ -+static int -+LoongArchModelParse(xmlXPathContextPtr ctxt, -+ const char *name, -+ void *data) -+{ -+ LoongArch_map *map = data; -+ LoongArch_model *model; -+ xmlNodePtr *nodes = NULL; -+ char *vendor = NULL; -+ unsigned long prid; -+ size_t i; -+ int n; -+ int ret = -1; -+ -+ model = g_new0(LoongArch_model, 1); -+ model->name = g_strdup(name); -+ -+ if (LoongArchModelFind(map, model->name)) { -+ virReportError(VIR_ERR_INTERNAL_ERROR, -+ _("CPU model %s already defined"), model->name); -+ goto cleanup; -+ } -+ -+ if (virXPathBoolean("boolean(./vendor)", ctxt)) { -+ vendor = virXPathString("string(./vendor/@name)", ctxt); -+ if (!vendor) { -+ virReportError(VIR_ERR_INTERNAL_ERROR, -+ _("Invalid vendor element in CPU model %s"), -+ model->name); -+ goto cleanup; -+ } -+ -+ if (!(model->vendor = LoongArchVendorFind(map, vendor))) { -+ virReportError(VIR_ERR_INTERNAL_ERROR, -+ _("Unknown vendor %s referenced by CPU model %s"), -+ vendor, model->name); -+ goto cleanup; -+ } -+ } -+ -+ if ((n = virXPathNodeSet("./prid", ctxt, &nodes)) <= 0) { -+ virReportError(VIR_ERR_INTERNAL_ERROR, -+ _("Missing Prid information for CPU model %s"), -+ model->name); -+ goto cleanup; -+ } -+ -+ model->data.prid = g_new0(virCPULoongArchPrid, n); -+ model->data.len = n; -+ -+ for (i = 0; i < n; i++) { -+ ctxt->node = nodes[i]; -+ -+ if (virXPathULongHex("string(./@value)", ctxt, &prid) < 0) { -+ virReportError(VIR_ERR_INTERNAL_ERROR, -+ _("Missing or invalid Prid value in CPU model %s"), -+ model->name); -+ goto cleanup; -+ } -+ model->data.prid[i].value = prid; -+ -+ if (virXPathULongHex("string(./@mask)", ctxt, &prid) < 0) { -+ virReportError(VIR_ERR_INTERNAL_ERROR, -+ _("Missing or invalid PVR mask in CPU model %s"), -+ model->name); -+ goto cleanup; -+ } -+ model->data.prid[i].mask = prid; -+ } -+ -+ VIR_APPEND_ELEMENT(map->models, map->nmodels, model); -+ ret = 0; -+ -+ cleanup: -+ LoongArchModelFree(model); -+ g_free(vendor); -+ g_free(nodes); -+ return ret; -+} -+ -+static LoongArch_map * -+LoongArchLoadMap(void) -+{ -+ LoongArch_map *map; -+ -+ map = g_new0(LoongArch_map, 1); -+ if (cpuMapLoad("loongarch64", LoongArchVendorParse, NULL, LoongArchModelParse, map) < 0) -+ goto error; -+ -+ return map; -+ -+ error: -+ LoongArchMapFree(map); -+ return NULL; -+} -+ -+static virCPUData * -+LoongArchMakeCPUData(virArch arch, -+ virCPULoongArchData *data) -+{ -+ virCPUData *cpuData; -+ -+ cpuData = g_new0(virCPUData, 1); -+ cpuData->arch = arch; -+ -+ if (LoongArchDataCopy(&cpuData->data.loongarch, data) < 0) -+ g_free(cpuData); -+ -+ return cpuData; -+} -+ -+static virCPUCompareResult -+LoongArchCompute(virCPUDef *host, -+ const virCPUDef *other, -+ virCPUData *guestData, -+ char **message) -+{ -+ LoongArch_map *map = NULL; -+ LoongArch_model *host_model = NULL; -+ LoongArch_model *guest_model = NULL; -+ virCPUDef *cpu = NULL; -+ virCPUCompareResult ret = VIR_CPU_COMPARE_ERROR; -+ virArch arch; -+ size_t i; -+ -+ /* Ensure existing configurations are handled correctly */ -+ if (!(cpu = virCPUDefCopy(other))) -+ goto cleanup; -+ -+ if (cpu->arch != VIR_ARCH_NONE) { -+ bool found = false; -+ -+ for (i = 0; i < G_N_ELEMENTS(archs); i++) { -+ if (archs[i] == cpu->arch) { -+ found = true; -+ break; -+ } -+ } -+ -+ if (!found) { -+ VIR_DEBUG("CPU arch %s does not match host arch", -+ virArchToString(cpu->arch)); -+ if (message) { -+ *message = g_strdup_printf(_("CPU arch %s does not match host arch"), -+ virArchToString(cpu->arch)); -+ } -+ ret = VIR_CPU_COMPARE_INCOMPATIBLE; -+ goto cleanup; -+ } -+ arch = cpu->arch; -+ } else { -+ arch = host->arch; -+ } -+ -+ if (cpu->vendor && -+ (!host->vendor || STRNEQ(cpu->vendor, host->vendor))) { -+ VIR_DEBUG("host CPU vendor does not match required CPU vendor %s", -+ cpu->vendor); -+ if (message) { -+ *message = g_strdup_printf(_("host CPU vendor does not match required " -+ "CPU vendor %s"), cpu->vendor); -+ } -+ ret = VIR_CPU_COMPARE_INCOMPATIBLE; -+ goto cleanup; -+ } -+ -+ if (!(map = LoongArchLoadMap())) -+ goto cleanup; -+ -+ /* Host CPU information */ -+ if (!(host_model = LoongArchModelFromCPU(host, map))) -+ goto cleanup; -+ -+ if (cpu->type == VIR_CPU_TYPE_GUEST) { -+ /* Guest CPU information */ -+ switch (cpu->mode) { -+ case VIR_CPU_MODE_HOST_MODEL: -+ case VIR_CPU_MODE_HOST_PASSTHROUGH: -+ /* host-model and host-passthrough: -+ * the guest CPU is the same as the host */ -+ guest_model = LoongArchModelCopy(host_model); -+ break; -+ -+ case VIR_CPU_MODE_CUSTOM: -+ /* custom: -+ * look up guest CPU information */ -+ guest_model = LoongArchModelFromCPU(cpu, map); -+ break; -+ } -+ } else { -+ /* Other host CPU information */ -+ guest_model = LoongArchModelFromCPU(cpu, map); -+ } -+ -+ if (!guest_model) -+ goto cleanup; -+ -+ if (STRNEQ(guest_model->name, host_model->name)) { -+ VIR_DEBUG("host CPU model does not match required CPU model %s", -+ guest_model->name); -+ if (message) { -+ *message = g_strdup_printf(_("host CPU model does not match required " -+ "CPU model %s"),guest_model->name); -+ } -+ ret = VIR_CPU_COMPARE_INCOMPATIBLE; -+ goto cleanup; -+ } -+ -+ if (guestData) -+ if (!(guestData = LoongArchMakeCPUData(arch, &guest_model->data))) -+ goto cleanup; -+ -+ ret = VIR_CPU_COMPARE_IDENTICAL; -+ -+ cleanup: -+ virCPUDefFree(cpu); -+ LoongArchMapFree(map); -+ LoongArchModelFree(host_model); -+ LoongArchModelFree(guest_model); -+ return ret; -+} -+ -+static virCPUCompareResult -+virCPULoongArchCompare(virCPUDef *host, -+ virCPUDef *cpu, -+ bool failIncompatible) -+{ -+ virCPUCompareResult ret; -+ char *message = NULL; -+ -+ if (!host || !host->model) { -+ if (failIncompatible) { -+ virReportError(VIR_ERR_CPU_INCOMPATIBLE, "%s", -+ _("unknown host CPU")); -+ } else { -+ VIR_WARN("unknown host CPU"); -+ ret = VIR_CPU_COMPARE_INCOMPATIBLE; -+ } -+ return -1; -+ } -+ -+ ret = LoongArchCompute(host, cpu, NULL, &message); -+ -+ if (failIncompatible && ret == VIR_CPU_COMPARE_INCOMPATIBLE) { -+ ret = VIR_CPU_COMPARE_ERROR; -+ if (message) { -+ virReportError(VIR_ERR_CPU_INCOMPATIBLE, "%s", message); -+ } else { -+ virReportError(VIR_ERR_CPU_INCOMPATIBLE, NULL); -+ } -+ } -+ g_free(message); -+ -+ return ret; -+} -+ -+static int -+LoongArchDriverDecode(virCPUDef *cpu, -+ const virCPUData *data, -+ virDomainCapsCPUModels *models) -+{ -+ int ret = -1; -+ LoongArch_map *map; -+ LoongArch_model *model; -+ -+ if (!data || !(map = LoongArchLoadMap())) -+ return -1; -+ -+ if (!(model = LoongArchModelFindPrid(map, data->data.loongarch.prid[0].value))) { -+ virReportError(VIR_ERR_OPERATION_FAILED, -+ _("Cannot find CPU model with Prid 0x%08x"), -+ data->data.loongarch.prid[0].value); -+ goto cleanup; -+ } -+ -+ if (!virCPUModelIsAllowed(model->name, models)) { -+ virReportError(VIR_ERR_CONFIG_UNSUPPORTED, -+ _("CPU model %s is not supported by hypervisor"), -+ model->name); -+ goto cleanup; -+ } -+ -+ cpu->model = g_strdup(model->name); -+ if (model->vendor) { -+ cpu->vendor = g_strdup(model->vendor->name); -+ } -+ ret = 0; -+ -+ cleanup: -+ LoongArchMapFree(map); -+ -+ return ret; -+} -+ -+static void -+virCPULoongArchDataFree(virCPUData *data) -+{ -+ if (!data) -+ return; -+ -+ LoongArchDataClear(&data->data.loongarch); -+ g_free(data); -+} -+ -+static int virCPULoongArchGetHostPRID(void) -+{ -+ return 0x14c010; -+} -+ -+static int -+virCPULoongArchGetHost(virCPUDef *cpu, -+ virDomainCapsCPUModels *models) -+{ -+ virCPUData *cpuData = NULL; -+ virCPULoongArchData *data; -+ int ret = -1; -+ -+ if (!(cpuData = virCPUDataNew(archs[0]))) -+ goto cleanup; -+ -+ data = &cpuData->data.loongarch; -+ -+ data->prid = g_new0(virCPULoongArchPrid, 1); -+ data->len = 1; -+ -+ data->prid[0].value = virCPULoongArchGetHostPRID(); -+ data->prid[0].mask = 0xffff00ul; -+ -+ ret = LoongArchDriverDecode(cpu, cpuData, models); -+ -+ cleanup: -+ virCPULoongArchDataFree(cpuData); -+ return ret; -+} -+ -+ -+static int -+virCPULoongArchUpdate(virCPUDef *guest, -+ const virCPUDef *host, -+ bool relative) -+{ -+ /* -+ * - host-passthrough doesn't even get here -+ * - host-model is used for host CPU running in a compatibility mode and -+ * it needs to remain unchanged -+ * - custom doesn't support any optional features, there's nothing to -+ * update -+ */ -+ VIR_DEBUG("host model %s, if relatived %d",host->model, relative); -+ if (guest->mode == VIR_CPU_MODE_CUSTOM) -+ guest->match = VIR_CPU_MATCH_EXACT; -+ -+ return 0; -+} -+ -+static virCPUDef * -+LoongArchDriverBaseline(virCPUDef **cpus, -+ unsigned int ncpus, -+ virDomainCapsCPUModels *models, -+ const char **features, -+ bool migratable) -+{ -+ LoongArch_map *map; -+ LoongArch_model *model; -+ LoongArch_vendor *vendor = NULL; -+ virCPUDef *cpu = NULL; -+ size_t i; -+ if (models && *features) { -+ VIR_DEBUG("migratable %d features %s",migratable, *features); -+ } -+ if (!(map = LoongArchLoadMap())) -+ goto error; -+ -+ if (!(model = LoongArchModelFind(map, cpus[0]->model))) { -+ virReportError(VIR_ERR_INTERNAL_ERROR, -+ _("Unknown CPU model %s"), cpus[0]->model); -+ goto error; -+ } -+ -+ for (i = 0; i < ncpus; i++) { -+ LoongArch_vendor *vnd; -+ -+ if (STRNEQ(cpus[i]->model, model->name)) { -+ virReportError(VIR_ERR_OPERATION_FAILED, "%s", -+ _("CPUs are incompatible")); -+ goto error; -+ } -+ -+ if (!cpus[i]->vendor) -+ continue; -+ -+ if (!(vnd = LoongArchVendorFind(map, cpus[i]->vendor))) { -+ virReportError(VIR_ERR_OPERATION_FAILED, -+ _("Unknown CPU vendor %s"), cpus[i]->vendor); -+ goto error; -+ } -+ -+ if (model->vendor) { -+ if (model->vendor != vnd) { -+ virReportError(VIR_ERR_OPERATION_FAILED, -+ _("CPU vendor %s of model %s differs from " -+ "vendor %s"), -+ model->vendor->name, model->name, -+ vnd->name); -+ goto error; -+ } -+ } else if (vendor) { -+ if (vendor != vnd) { -+ virReportError(VIR_ERR_OPERATION_FAILED, "%s", -+ _("CPU vendors do not match")); -+ goto error; -+ } -+ } else { -+ vendor = vnd; -+ } -+ } -+ -+ cpu = g_new0(virCPUDef ,1); -+ cpu->model = g_strdup(model->name); -+ if (vendor) { -+ cpu->vendor = g_strdup(vendor->name); -+ } -+ cpu->type = VIR_CPU_TYPE_GUEST; -+ cpu->match = VIR_CPU_MATCH_EXACT; -+ cpu->fallback = VIR_CPU_FALLBACK_FORBID; -+ -+ cleanup: -+ LoongArchMapFree(map); -+ -+ return cpu; -+ -+ error: -+ virCPUDefFree(cpu); -+ cpu = NULL; -+ goto cleanup; -+} -+ -+static int -+virCPULoongArchDriverGetModels(char ***models) -+{ -+ LoongArch_map *map; -+ size_t i; -+ int ret = -1; -+ -+ if (!(map = LoongArchLoadMap())) -+ 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: -+ LoongArchMapFree(map); -+ return ret; -+ -+ error: -+ if (models) { -+ g_strfreev(*models); -+ *models = NULL; -+ } -+ goto cleanup; -+} -+ -+struct cpuArchDriver cpuDriverLoongArch = { -+ .name = "LoongArch", -+ .arch = archs, -+ .narch = G_N_ELEMENTS(archs), -+ .compare = virCPULoongArchCompare, -+ .decode = LoongArchDriverDecode, -+ .encode = NULL, -+ .dataFree = virCPULoongArchDataFree, -+ .getHost = virCPULoongArchGetHost, -+ .baseline = LoongArchDriverBaseline, -+ .update = virCPULoongArchUpdate, -+ .getModels = virCPULoongArchDriverGetModels, -+}; -diff --git a/src/cpu/cpu_loongarch.h b/src/cpu/cpu_loongarch.h -new file mode 100644 -index 0000000000..1fde3b5162 ---- /dev/null -+++ b/src/cpu/cpu_loongarch.h -@@ -0,0 +1,28 @@ -+/* -+ * cpu_loongarch.h: CPU driver for 64-bit LOONGARCH CPUs -+ * -+ * Copyright (C) Copyright (C) IBM Corporation, 2010 -+ * -+ * 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 -+ * . -+ */ -+ -+#ifndef __VIR_CPU_LOONGARCH_H__ -+# define __VIR_CPU_LOONGARCH_H__ -+ -+# include "cpu.h" -+ -+extern struct cpuArchDriver cpuDriverLoongArch; -+ -+#endif /* __VIR_CPU_LOONGARCH_H__ */ -diff --git a/src/cpu/cpu_loongarch_data.h b/src/cpu/cpu_loongarch_data.h -new file mode 100644 -index 0000000000..1a759e7d16 ---- /dev/null -+++ b/src/cpu/cpu_loongarch_data.h -@@ -0,0 +1,40 @@ -+/* -+ * cpu_loongarch_data.h: 64-bit LOONGARCH CPU specific data -+ * -+ * Copyright (C) 2012 IBM Corporation. -+ * -+ * 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 -+ * . -+ */ -+ -+#ifndef __VIR_CPU_LOONGARCH_DATA_H__ -+# define __VIR_CPU_LOONGARCH_DATA_H__ -+ -+# include -+ -+typedef struct _virCPULoongArchPrid virCPULoongArchPrid; -+struct _virCPULoongArchPrid { -+ uint32_t value; -+ uint32_t mask; -+}; -+ -+# define VIR_CPU_LOONGARCH_DATA_INIT { 0 } -+ -+typedef struct _virCPULoongArchData virCPULoongArchData; -+struct _virCPULoongArchData { -+ size_t len; -+ virCPULoongArchPrid *prid; -+}; -+ -+#endif /* __VIR_CPU_MIPS64_DATA_H__ */ -diff --git a/src/cpu/meson.build b/src/cpu/meson.build -index b4ad95e46d..ad2f859fd8 100644 ---- a/src/cpu/meson.build -+++ b/src/cpu/meson.build -@@ -5,6 +5,7 @@ cpu_sources = [ - 'cpu_ppc64.c', - 'cpu_s390.c', - 'cpu_x86.c', -+ 'cpu_loongarch.c', - ] - - cpu_lib = static_library( -diff --git a/src/cpu_map/index.xml b/src/cpu_map/index.xml -index ffe1fa91e5..d302de396a 100644 ---- a/src/cpu_map/index.xml -+++ b/src/cpu_map/index.xml -@@ -110,4 +110,9 @@ - - - -+ -+ -+ -+ -+ - -diff --git a/src/cpu_map/loongarch_vendors.xml b/src/cpu_map/loongarch_vendors.xml -new file mode 100644 -index 0000000000..c744654617 ---- /dev/null -+++ b/src/cpu_map/loongarch_vendors.xml -@@ -0,0 +1,3 @@ -+ -+ -+ -diff --git a/src/cpu_map/ls_3a5000.xml b/src/cpu_map/ls_3a5000.xml -new file mode 100644 -index 0000000000..f6fe3386f7 ---- /dev/null -+++ b/src/cpu_map/ls_3a5000.xml -@@ -0,0 +1,6 @@ -+ -+ -+ -+ -+ -+ -diff --git a/src/cpu_map/meson.build b/src/cpu_map/meson.build -index 013fc62a02..9657c5164e 100644 ---- a/src/cpu_map/meson.build -+++ b/src/cpu_map/meson.build -@@ -77,6 +77,8 @@ cpumap_data = [ - 'x86_vendors.xml', - 'x86_Westmere-IBRS.xml', - 'x86_Westmere.xml', -+ 'loongarch_vendors.xml', -+ 'ls_3a5000.xml', - ] - - install_data(cpumap_data, install_dir: pkgdatadir / 'cpu_map') -diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c -index c4f7db55c8..75668c6451 100644 ---- a/src/qemu/qemu_capabilities.c -+++ b/src/qemu/qemu_capabilities.c -@@ -2073,6 +2073,9 @@ bool virQEMUCapsHasPCIMultiBus(const virDomainDef *def) - if (ARCH_IS_X86(def->os.arch)) - return true; - -+ if (STRPREFIX(def->os.machine,"loongson7a")) -+ return true; -+ - /* PPC supports multibus on all machine types which have pci since qemu-2.0.0 */ - if (def->os.arch == VIR_ARCH_PPC || - ARCH_IS_PPC64(def->os.arch)) { -@@ -2690,6 +2693,7 @@ static const char *preferredMachines[] = - - "malta", /* VIR_ARCH_MIPS64 */ - "malta", /* VIR_ARCH_MIPS64EL */ -+ "loongson7a", /* VIR_ARCH_LOONGARCH64 */ - "or1k-sim", /* VIR_ARCH_OR32 */ - NULL, /* VIR_ARCH_PARISC (no QEMU impl) */ - NULL, /* VIR_ARCH_PARISC64 (no QEMU impl) */ -@@ -5115,6 +5119,7 @@ virQEMUCapsInitQMPBasicArch(virQEMUCaps *qemuCaps) - case VIR_ARCH_MIPSEL: - case VIR_ARCH_MIPS64: - case VIR_ARCH_MIPS64EL: -+ case VIR_ARCH_LOONGARCH64: - case VIR_ARCH_OR32: - case VIR_ARCH_PARISC: - case VIR_ARCH_PARISC64: -diff --git a/src/qemu/qemu_conf.c b/src/qemu/qemu_conf.c -index a0b8076d6b..8cd03261ac 100644 ---- a/src/qemu/qemu_conf.c -+++ b/src/qemu/qemu_conf.c -@@ -101,7 +101,9 @@ qemuDriverUnlock(virQEMUDriver *driver) - "/usr/share/OVMF/OVMF_CODE.fd:/usr/share/OVMF/OVMF_VARS.fd:" \ - "/usr/share/OVMF/OVMF_CODE.secboot.fd:/usr/share/OVMF/OVMF_VARS.fd:" \ - "/usr/share/AAVMF/AAVMF_CODE.fd:/usr/share/AAVMF/AAVMF_VARS.fd:" \ -- "/usr/share/AAVMF/AAVMF32_CODE.fd:/usr/share/AAVMF/AAVMF32_VARS.fd" -+ "/usr/share/AAVMF/AAVMF32_CODE.fd:/usr/share/AAVMF/AAVMF32_VARS.fd:" \ -+ "/usr/share/qemu-kvm/loongarch_bios.bin:/usr/share/qemu-kvm/loongarch_bios.bin" -+ - #endif - - -diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c -index 40fe9985e6..814d8cb67d 100644 ---- a/src/qemu/qemu_domain.c -+++ b/src/qemu/qemu_domain.c -@@ -3668,6 +3668,10 @@ qemuDomainDefAddDefaultDevices(virQEMUDriver *driver, - addPCIeRoot = virQEMUCapsGet(qemuCaps, QEMU_CAPS_OBJECT_GPEX); - break; - -+ case VIR_ARCH_LOONGARCH64: -+ addPCIeRoot = true; -+ break; -+ - case VIR_ARCH_PPC64: - case VIR_ARCH_PPC64LE: - addPCIRoot = true; -@@ -5065,6 +5069,11 @@ 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 (ARCH_IS_LOONGARCH(def->os.arch)) { -+ if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE_QEMU_XHCI)) -+ 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; - } - } - /* forbid usb model 'qusb1' and 'qusb2' in this kind of hyperviosr */ -@@ -8324,6 +8333,13 @@ qemuDomainDefCheckABIStability(virQEMUDriver *driver, - } - - -+bool -+qemuDomainIsLoongson(const virDomainDef *def) -+{ -+ return (STRPREFIX(def->os.machine,"loongson3a") || STRPREFIX(def->os.machine,"loongson7a")); -+} -+ -+ - bool - qemuDomainCheckABIStability(virQEMUDriver *driver, - virDomainObj *vm, -@@ -8664,7 +8680,9 @@ qemuDomainMachineHasBuiltinIDE(const char *machine, - return qemuDomainMachineIsI440FX(machine, arch) || - STREQ(machine, "malta") || - STREQ(machine, "sun4u") || -- STREQ(machine, "g3beige"); -+ STREQ(machine, "g3beige") || -+ STREQ(machine, "loongson3a") || -+ STREQ(machine, "loongson7a"); - } - - -diff --git a/src/qemu/qemu_domain.h b/src/qemu/qemu_domain.h -index e5046367e3..57f1f97348 100644 ---- a/src/qemu/qemu_domain.h -+++ b/src/qemu/qemu_domain.h -@@ -770,6 +770,7 @@ bool qemuDomainIsS390CCW(const virDomainDef *def); - bool qemuDomainIsARMVirt(const virDomainDef *def); - bool qemuDomainIsRISCVVirt(const virDomainDef *def); - bool qemuDomainIsPSeries(const virDomainDef *def); -+bool qemuDomainIsLoongson(const virDomainDef *def); - bool qemuDomainHasPCIRoot(const virDomainDef *def); - bool qemuDomainHasPCIeRoot(const virDomainDef *def); - bool qemuDomainHasBuiltinIDE(const virDomainDef *def); -diff --git a/src/qemu/qemu_domain_address.c b/src/qemu/qemu_domain_address.c -index 18fc34d049..c3fac1c33b 100644 ---- a/src/qemu/qemu_domain_address.c -+++ b/src/qemu/qemu_domain_address.c -@@ -2026,6 +2026,59 @@ qemuDomainValidateDevicePCISlotsQ35(virDomainDef *def, - } - - -+static int -+qemuDomainValidateDevicePCISlotsLoongson(virDomainDef *def, -+ virDomainPCIAddressSet *addrs) -+{ -+ int ret = -1; -+ virPCIDeviceAddress tmp_addr; -+ char *addrStr = NULL; -+ virDomainPCIConnectFlags flags = (VIR_PCI_CONNECT_AUTOASSIGN -+ | VIR_PCI_CONNECT_TYPE_PCI_DEVICE); -+ -+ if (addrs->nbuses) { -+ memset(&tmp_addr, 0, sizeof(tmp_addr)); -+ tmp_addr.slot = 1; -+ /* pci-ohci at 00:01.0 */ -+ if (virDomainPCIAddressReserveAddr(addrs, &tmp_addr, flags, 0) < 0) -+ goto cleanup; -+ } -+ -+ if (def->nvideos > 0 && -+ def->videos[0]->type != VIR_DOMAIN_VIDEO_TYPE_NONE && -+ def->videos[0]->type != VIR_DOMAIN_VIDEO_TYPE_RAMFB) { -+ /*reserve slot 2 for vga device */ -+ virDomainVideoDef *primaryVideo = def->videos[0]; -+ -+ if (virDeviceInfoPCIAddressIsWanted(&primaryVideo->info)) { -+ memset(&tmp_addr, 0, sizeof(tmp_addr)); -+ tmp_addr.slot = 2; -+ -+ if (!(addrStr = virPCIDeviceAddressAsString(&tmp_addr))) -+ goto cleanup; -+ if (!virDomainPCIAddressValidate(addrs, &tmp_addr, -+ addrStr, flags, true)) -+ goto cleanup; -+ -+ if (virDomainPCIAddressSlotInUse(addrs, &tmp_addr)) { -+ if (qemuDomainPCIAddressReserveNextAddr(addrs, -+ &primaryVideo->info) < 0) -+ goto cleanup; -+ } else { -+ if (virDomainPCIAddressReserveAddr(addrs, &tmp_addr, flags, 0) < 0) -+ goto cleanup; -+ primaryVideo->info.addr.pci = tmp_addr; -+ primaryVideo->info.type = VIR_DOMAIN_DEVICE_ADDRESS_TYPE_PCI; -+ } -+ } -+ } -+ ret = 0; -+ cleanup: -+ VIR_FREE(addrStr); -+ return ret; -+} -+ -+ - static int - qemuDomainValidateDevicePCISlotsChipsets(virDomainDef *def, - virDomainPCIAddressSet *addrs) -@@ -2040,6 +2093,11 @@ qemuDomainValidateDevicePCISlotsChipsets(virDomainDef *def, - return -1; - } - -+ if (qemuDomainIsLoongson(def) && -+ qemuDomainValidateDevicePCISlotsLoongson(def, addrs) < 0) { -+ return -1; -+ } -+ - return 0; - } - -diff --git a/src/qemu/qemu_validate.c b/src/qemu/qemu_validate.c -index 7bc14293d6..7d01d31aaf 100644 ---- a/src/qemu/qemu_validate.c -+++ b/src/qemu/qemu_validate.c -@@ -186,7 +186,8 @@ qemuValidateDomainDefFeatures(const virDomainDef *def, - switch ((virDomainFeature) i) { - case VIR_DOMAIN_FEATURE_IOAPIC: - if (def->features[i] != VIR_DOMAIN_IOAPIC_NONE) { -- if (!ARCH_IS_X86(def->os.arch)) { -+ if (!(ARCH_IS_X86(def->os.arch) -+ || ARCH_IS_LOONGARCH(def->os.arch))) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, - _("The '%s' feature is not supported for " - "architecture '%s' or machine type '%s'"), -diff --git a/src/util/virarch.c b/src/util/virarch.c -index 2134dd6a9d..9f40a7110c 100644 ---- a/src/util/virarch.c -+++ b/src/util/virarch.c -@@ -59,6 +59,7 @@ static const struct virArchData { - - { "mips64", 64, VIR_ARCH_BIG_ENDIAN }, - { "mips64el", 64, VIR_ARCH_LITTLE_ENDIAN }, -+ { "loongarch64", 64, VIR_ARCH_LITTLE_ENDIAN }, - { "openrisc", 32, VIR_ARCH_BIG_ENDIAN }, - { "parisc", 32, VIR_ARCH_BIG_ENDIAN }, - { "parisc64", 64, VIR_ARCH_BIG_ENDIAN }, -@@ -222,6 +223,8 @@ virArch virArchFromHost(void) - arch = VIR_ARCH_X86_64; - } else if (STREQ(ut.machine, "arm64")) { - arch = VIR_ARCH_AARCH64; -+ } else if (STREQ(ut.machine, "loongarch64")) { -+ arch = VIR_ARCH_LOONGARCH64; - } else { - /* Otherwise assume the canonical name */ - if ((arch = virArchFromString(ut.machine)) == VIR_ARCH_NONE) { -diff --git a/src/util/virarch.h b/src/util/virarch.h -index 528f84f8a5..7d396f2fff 100644 ---- a/src/util/virarch.h -+++ b/src/util/virarch.h -@@ -44,6 +44,7 @@ typedef enum { - - VIR_ARCH_MIPS64, /* MIPS 64 BE https://en.wikipedia.org/wiki/MIPS_architecture */ - VIR_ARCH_MIPS64EL, /* MIPS 64 LE https://en.wikipedia.org/wiki/MIPS_architecture */ -+ VIR_ARCH_LOONGARCH64, - VIR_ARCH_OR32, /* OpenRisc 32 BE https://en.wikipedia.org/wiki/OpenRISC#QEMU_support */ - VIR_ARCH_PARISC, /* PA-Risc 32 BE https://en.wikipedia.org/wiki/PA-RISC */ - VIR_ARCH_PARISC64, /* PA-Risc 64 BE https://en.wikipedia.org/wiki/PA-RISC */ -@@ -98,6 +99,8 @@ typedef enum { - #define ARCH_IS_MIPS64(arch) ((arch) == VIR_ARCH_MIPS64 ||\ - (arch) == VIR_ARCH_MIPS64EL) - -+#define ARCH_IS_LOONGARCH(arch) ((arch) == VIR_ARCH_LOONGARCH64) -+ - typedef enum { - VIR_ARCH_LITTLE_ENDIAN, - VIR_ARCH_BIG_ENDIAN, -diff --git a/src/util/virhostcpu.c b/src/util/virhostcpu.c -index 35f41daef2..137796ea07 100644 ---- a/src/util/virhostcpu.c -+++ b/src/util/virhostcpu.c -@@ -546,7 +546,7 @@ virHostCPUParseFrequency(FILE *cpuinfo, - char line[1024]; - - /* No sensible way to retrieve CPU frequency */ -- if (ARCH_IS_ARM(arch)) -+ if (ARCH_IS_ARM(arch) || ARCH_IS_LOONGARCH(arch)) - return 0; - - if (ARCH_IS_X86(arch)) -diff --git a/src/util/virsysinfo.c b/src/util/virsysinfo.c -index af9e03c5ac..9577cf1910 100644 ---- a/src/util/virsysinfo.c -+++ b/src/util/virsysinfo.c -@@ -1247,7 +1247,7 @@ virSysinfoRead(void) - { - #if defined(__powerpc__) - return virSysinfoReadPPC(); --#elif defined(__arm__) || defined(__aarch64__) -+#elif defined(__arm__) || defined(__aarch64__) || defined(__loongarch__) - return virSysinfoReadARM(); - #elif defined(__s390__) || defined(__s390x__) - return virSysinfoReadS390(); --- -2.27.0 - diff --git a/libvirt-conf-Move-virDomainObj-originalMemlock-into-qemuDomainObjPrivate.patch b/libvirt-conf-Move-virDomainObj-originalMemlock-into-qemuDomainObjPrivate.patch new file mode 100644 index 0000000..6cd0e37 --- /dev/null +++ b/libvirt-conf-Move-virDomainObj-originalMemlock-into-qemuDomainObjPrivate.patch @@ -0,0 +1,91 @@ +From b4469bda27e54a948f0d2750637226afc2b2be61 Mon Sep 17 00:00:00 2001 +Message-Id: +From: Michal Privoznik +Date: Wed, 11 May 2022 16:27:18 +0200 +Subject: [PATCH] conf: Move virDomainObj::originalMemlock into + qemuDomainObjPrivate + +Since v1.3.0-90-gafbe1d4c56 the original value of memlock limit +is stored inside virDomainObj struct directly (under +originalMemlock member). This is needless because the value is +used only inside QEMU driver and thus can reside in +qemuDomainObjPrivate struct. + +Signed-off-by: Michal Privoznik +Reviewed-by: Peter Krempa +(cherry picked from commit 75df6d2c291c48d65c1e54dd93e3d2d3cb0712e7) + +https://bugzilla.redhat.com/show_bug.cgi?id=2117272 + +Signed-off-by: Jiri Denemark +--- + src/conf/domain_conf.h | 3 --- + src/qemu/qemu_domain.c | 9 +++++---- + src/qemu/qemu_domain.h | 3 +++ + 3 files changed, 8 insertions(+), 7 deletions(-) + +diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h +index 10af94e2e4..7e3255e41a 100644 +--- a/src/conf/domain_conf.h ++++ b/src/conf/domain_conf.h +@@ -3030,9 +3030,6 @@ struct _virDomainObj { + int taint; + size_t ndeprecations; + char **deprecations; +- +- unsigned long long originalMemlock; /* Original RLIMIT_MEMLOCK, zero if no +- * restore will be required later */ + }; + + G_DEFINE_AUTOPTR_CLEANUP_FUNC(virDomainObj, virObjectUnref); +diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c +index 40fe9985e6..86d673dafa 100644 +--- a/src/qemu/qemu_domain.c ++++ b/src/qemu/qemu_domain.c +@@ -9269,6 +9269,7 @@ int + qemuDomainAdjustMaxMemLock(virDomainObj *vm, + bool forceVFIO) + { ++ qemuDomainObjPrivate *priv = vm->privateData; + unsigned long long currentMemLock = 0; + unsigned long long desiredMemLock = 0; + +@@ -9281,8 +9282,8 @@ qemuDomainAdjustMaxMemLock(virDomainObj *vm, + /* If this is the first time adjusting the limit, save the current + * value so that we can restore it once memory locking is no longer + * required */ +- if (vm->originalMemlock == 0) { +- vm->originalMemlock = currentMemLock; ++ if (priv->originalMemlock == 0) { ++ priv->originalMemlock = currentMemLock; + } + } else { + /* If the limit is already high enough, we can assume +@@ -9295,8 +9296,8 @@ qemuDomainAdjustMaxMemLock(virDomainObj *vm, + } else { + /* Once memory locking is no longer required, we can restore the + * original, usually very low, limit */ +- desiredMemLock = vm->originalMemlock; +- vm->originalMemlock = 0; ++ desiredMemLock = priv->originalMemlock; ++ priv->originalMemlock = 0; + } + + if (desiredMemLock > 0 && +diff --git a/src/qemu/qemu_domain.h b/src/qemu/qemu_domain.h +index e5046367e3..e9497d20de 100644 +--- a/src/qemu/qemu_domain.h ++++ b/src/qemu/qemu_domain.h +@@ -241,6 +241,9 @@ struct _qemuDomainObjPrivate { + GSList *dbusVMStateIds; + /* true if -object dbus-vmstate was added */ + bool dbusVMState; ++ ++ unsigned long long originalMemlock; /* Original RLIMIT_MEMLOCK, zero if no ++ * restore will be required later */ + }; + + #define QEMU_DOMAIN_PRIVATE(vm) \ +-- +2.35.1 + diff --git a/libvirt-domain_validate-Split-out-validation-of-disk-startup-policy.patch b/libvirt-domain_validate-Split-out-validation-of-disk-startup-policy.patch new file mode 100644 index 0000000..4783fab --- /dev/null +++ b/libvirt-domain_validate-Split-out-validation-of-disk-startup-policy.patch @@ -0,0 +1,112 @@ +From bfd8d181d45a22731ae5b1f05f3cb9488a2c7939 Mon Sep 17 00:00:00 2001 +Message-Id: +From: Peter Krempa +Date: Tue, 14 Jun 2022 13:23:29 +0200 +Subject: [PATCH] domain_validate: Split out validation of disk startup policy +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +Move the code into 'virDomainDiskDefValidateStartupPolicy' which will be +later reused in the qemu driver. + +Signed-off-by: Peter Krempa +Reviewed-by: Ján Tomko +(cherry picked from commit 3603a18bcec18842cedecbd8329723062b87795c) +https://bugzilla.redhat.com/show_bug.cgi?id=2095758 +https://bugzilla.redhat.com/show_bug.cgi?id=2109571 +--- + src/conf/domain_validate.c | 45 ++++++++++++++++++++++++-------------- + src/conf/domain_validate.h | 2 ++ + src/libvirt_private.syms | 1 + + 3 files changed, 31 insertions(+), 17 deletions(-) + +diff --git a/src/conf/domain_validate.c b/src/conf/domain_validate.c +index 452742e67c..bfff7339ef 100644 +--- a/src/conf/domain_validate.c ++++ b/src/conf/domain_validate.c +@@ -598,6 +598,32 @@ virDomainDiskDefSourceLUNValidate(const virStorageSource *src) + } + + ++int ++virDomainDiskDefValidateStartupPolicy(const virDomainDiskDef *disk) ++{ ++ if (disk->startupPolicy == VIR_DOMAIN_STARTUP_POLICY_DEFAULT) ++ return 0; ++ ++ if (disk->src->type == VIR_STORAGE_TYPE_NETWORK) { ++ virReportError(VIR_ERR_XML_ERROR, ++ _("disk startupPolicy '%s' is not allowed for disk of '%s' type"), ++ virDomainStartupPolicyTypeToString(disk->startupPolicy), ++ virStorageTypeToString(disk->src->type)); ++ return -1; ++ } ++ ++ if (disk->device != VIR_DOMAIN_DISK_DEVICE_CDROM && ++ disk->device != VIR_DOMAIN_DISK_DEVICE_FLOPPY && ++ disk->startupPolicy == VIR_DOMAIN_STARTUP_POLICY_REQUISITE) { ++ virReportError(VIR_ERR_XML_ERROR, "%s", ++ _("disk startupPolicy 'requisite' is allowed only for cdrom or floppy")); ++ return -1; ++ } ++ ++ return 0; ++} ++ ++ + static int + virDomainDiskDefValidate(const virDomainDef *def, + const virDomainDiskDef *disk) +@@ -775,23 +801,8 @@ virDomainDiskDefValidate(const virDomainDef *def, + return -1; + } + +- if (disk->startupPolicy != VIR_DOMAIN_STARTUP_POLICY_DEFAULT) { +- if (disk->src->type == VIR_STORAGE_TYPE_NETWORK) { +- virReportError(VIR_ERR_XML_ERROR, +- _("disk startupPolicy '%s' is not allowed for disk of '%s' type"), +- virDomainStartupPolicyTypeToString(disk->startupPolicy), +- virStorageTypeToString(disk->src->type)); +- return -1; +- } +- +- if (disk->device != VIR_DOMAIN_DISK_DEVICE_CDROM && +- disk->device != VIR_DOMAIN_DISK_DEVICE_FLOPPY && +- disk->startupPolicy == VIR_DOMAIN_STARTUP_POLICY_REQUISITE) { +- virReportError(VIR_ERR_XML_ERROR, "%s", +- _("disk startupPolicy 'requisite' is allowed only for cdrom or floppy")); +- return -1; +- } +- } ++ if (virDomainDiskDefValidateStartupPolicy(disk) < 0) ++ return -1; + + if (disk->wwn && !virValidateWWN(disk->wwn)) + return -1; +diff --git a/src/conf/domain_validate.h b/src/conf/domain_validate.h +index 430d61fd3c..07b99195e3 100644 +--- a/src/conf/domain_validate.h ++++ b/src/conf/domain_validate.h +@@ -41,4 +41,6 @@ int virDomainDeviceDefValidate(const virDomainDeviceDef *dev, + + int virDomainDiskDefValidateSource(const virStorageSource *src); + ++int virDomainDiskDefValidateStartupPolicy(const virDomainDiskDef *disk); ++ + int virDomainDiskDefSourceLUNValidate(const virStorageSource *src); +diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms +index 2c42e2a5e8..5b7a056151 100644 +--- a/src/libvirt_private.syms ++++ b/src/libvirt_private.syms +@@ -777,6 +777,7 @@ virDomainActualNetDefValidate; + virDomainDefValidate; + virDomainDeviceValidateAliasForHotplug; + virDomainDiskDefSourceLUNValidate; ++virDomainDiskDefValidateStartupPolicy; + + + # conf/interface_conf.h +-- +2.35.1 + diff --git a/libvirt-qemu-Add-qemuDomainSetMaxMemLock-helper.patch b/libvirt-qemu-Add-qemuDomainSetMaxMemLock-helper.patch new file mode 100644 index 0000000..740f4f1 --- /dev/null +++ b/libvirt-qemu-Add-qemuDomainSetMaxMemLock-helper.patch @@ -0,0 +1,155 @@ +From 7f5b89a15bfcd964c7f2b6ccbf3c03fd867f93b5 Mon Sep 17 00:00:00 2001 +Message-Id: <7f5b89a15bfcd964c7f2b6ccbf3c03fd867f93b5@dist-git> +From: Jiri Denemark +Date: Wed, 22 Jun 2022 15:21:30 +0200 +Subject: [PATCH] qemu: Add qemuDomainSetMaxMemLock helper +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +qemuDomainAdjustMaxMemLock combined computing the desired limit with +applying it. This patch separates the code to apply a memory locking +limit to a new qemuDomainSetMaxMemLock helper for better reusability. + +Signed-off-by: Jiri Denemark +Reviewed-by: Ján Tomko +(cherry picked from commit dff51c7f5760ded8235076f55d082fe4363f2f78) + +https://bugzilla.redhat.com/show_bug.cgi?id=2117272 + +Signed-off-by: Jiri Denemark +--- + src/qemu/qemu_domain.c | 95 ++++++++++++++++++++++++++---------------- + src/qemu/qemu_domain.h | 3 ++ + 2 files changed, 61 insertions(+), 37 deletions(-) + +diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c +index ee7d310903..a81789f194 100644 +--- a/src/qemu/qemu_domain.c ++++ b/src/qemu/qemu_domain.c +@@ -9261,6 +9261,61 @@ qemuDomainGetMemLockLimitBytes(virDomainDef *def, + } + + ++/** ++ * qemuDomainSetMaxMemLock: ++ * @vm: domain ++ * @limit: the desired memory locking limit ++ * @origPtr: where to store (or load from) the original value of the limit ++ * ++ * Set the memory locking limit for @vm unless it's already big enough. If ++ * @origPtr is non-NULL, the original value of the limit will be store there ++ * and can be restored by calling this function with @limit == 0. ++ * ++ * Returns: 0 on success, -1 otherwise. ++ */ ++int ++qemuDomainSetMaxMemLock(virDomainObj *vm, ++ unsigned long long limit, ++ unsigned long long *origPtr) ++{ ++ unsigned long long current = 0; ++ ++ if (virProcessGetMaxMemLock(vm->pid, ¤t) < 0) ++ return -1; ++ ++ if (limit > 0) { ++ VIR_DEBUG("Requested memory lock limit: %llu", limit); ++ /* If the limit is already high enough, we can assume ++ * that some external process is taking care of managing ++ * process limits and we shouldn't do anything ourselves: ++ * we're probably running in a containerized environment ++ * where we don't have enough privilege anyway */ ++ if (current >= limit) { ++ VIR_DEBUG("Current limit %llu is big enough", current); ++ return 0; ++ } ++ ++ /* If this is the first time adjusting the limit, save the current ++ * value so that we can restore it once memory locking is no longer ++ * required */ ++ if (origPtr && *origPtr == 0) ++ *origPtr = current; ++ } else { ++ /* Once memory locking is no longer required, we can restore the ++ * original, usually very low, limit. But only if we actually stored ++ * the original limit before. */ ++ if (!origPtr || *origPtr == 0) ++ return 0; ++ ++ limit = *origPtr; ++ *origPtr = 0; ++ VIR_DEBUG("Resetting memory lock limit back to %llu", limit); ++ } ++ ++ return virProcessSetMaxMemLock(vm->pid, limit); ++} ++ ++ + /** + * qemuDomainAdjustMaxMemLock: + * @vm: domain +@@ -9282,43 +9337,9 @@ int + qemuDomainAdjustMaxMemLock(virDomainObj *vm, + bool forceVFIO) + { +- qemuDomainObjPrivate *priv = vm->privateData; +- unsigned long long currentMemLock = 0; +- unsigned long long desiredMemLock = 0; +- +- desiredMemLock = qemuDomainGetMemLockLimitBytes(vm->def, forceVFIO); +- if (virProcessGetMaxMemLock(vm->pid, ¤tMemLock) < 0) +- return -1; +- +- if (desiredMemLock > 0) { +- if (currentMemLock < desiredMemLock) { +- /* If this is the first time adjusting the limit, save the current +- * value so that we can restore it once memory locking is no longer +- * required */ +- if (priv->originalMemlock == 0) { +- priv->originalMemlock = currentMemLock; +- } +- } else { +- /* If the limit is already high enough, we can assume +- * that some external process is taking care of managing +- * process limits and we shouldn't do anything ourselves: +- * we're probably running in a containerized environment +- * where we don't have enough privilege anyway */ +- desiredMemLock = 0; +- } +- } else { +- /* Once memory locking is no longer required, we can restore the +- * original, usually very low, limit */ +- desiredMemLock = priv->originalMemlock; +- priv->originalMemlock = 0; +- } +- +- if (desiredMemLock > 0 && +- virProcessSetMaxMemLock(vm->pid, desiredMemLock) < 0) { +- return -1; +- } +- +- return 0; ++ return qemuDomainSetMaxMemLock(vm, ++ qemuDomainGetMemLockLimitBytes(vm->def, forceVFIO), ++ &QEMU_DOMAIN_PRIVATE(vm)->originalMemlock); + } + + +diff --git a/src/qemu/qemu_domain.h b/src/qemu/qemu_domain.h +index e9497d20de..6d1d23439a 100644 +--- a/src/qemu/qemu_domain.h ++++ b/src/qemu/qemu_domain.h +@@ -789,6 +789,9 @@ int qemuDomainAdjustMaxMemLock(virDomainObj *vm, + bool forceVFIO); + int qemuDomainAdjustMaxMemLockHostdev(virDomainObj *vm, + virDomainHostdevDef *hostdev); ++int qemuDomainSetMaxMemLock(virDomainObj *vm, ++ unsigned long long limit, ++ unsigned long long *origPtr); + + int qemuDomainDefValidateMemoryHotplug(const virDomainDef *def, + const virDomainMemoryDef *mem); +-- +2.35.1 + diff --git a/libvirt-qemu_domain-Format-qemuDomainObjPrivate-originalMemlock.patch b/libvirt-qemu_domain-Format-qemuDomainObjPrivate-originalMemlock.patch new file mode 100644 index 0000000..b1c20ff --- /dev/null +++ b/libvirt-qemu_domain-Format-qemuDomainObjPrivate-originalMemlock.patch @@ -0,0 +1,55 @@ +From cbfe812a4affe5be7677bf28764b58dc7f99c969 Mon Sep 17 00:00:00 2001 +Message-Id: +From: Michal Privoznik +Date: Wed, 11 May 2022 16:37:27 +0200 +Subject: [PATCH] qemu_domain: Format qemuDomainObjPrivate::originalMemlock + +Now that qemuDomainObjPrivate struct gained new member format it +into XML and parse it so that the value is preserved across +daemon restarts. + +Signed-off-by: Michal Privoznik +Reviewed-by: Peter Krempa +(cherry picked from commit 21aec91790ae14d24512856b20cff49764ede637) + +https://bugzilla.redhat.com/show_bug.cgi?id=2117272 + +Signed-off-by: Jiri Denemark +--- + src/qemu/qemu_domain.c | 13 +++++++++++++ + 1 file changed, 13 insertions(+) + +diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c +index 86d673dafa..ee7d310903 100644 +--- a/src/qemu/qemu_domain.c ++++ b/src/qemu/qemu_domain.c +@@ -2383,6 +2383,12 @@ qemuDomainObjPrivateXMLFormat(virBuffer *buf, + if (qemuDomainObjPrivateXMLFormatBackups(buf, vm) < 0) + return -1; + ++ if (priv->originalMemlock > 0) { ++ virBufferAsprintf(buf, ++ "%llu\n", ++ priv->originalMemlock); ++ } ++ + return 0; + } + +@@ -3104,6 +3110,13 @@ qemuDomainObjPrivateXMLParse(xmlXPathContextPtr ctxt, + + priv->memPrealloc = virXPathBoolean("boolean(./memPrealloc)", ctxt) == 1; + ++ if (virXPathULongLong("string(./originalMemlock)", ++ ctxt, &priv->originalMemlock) == -2) { ++ virReportError(VIR_ERR_INTERNAL_ERROR, "%s", ++ _("failed to parse original memlock size")); ++ goto error; ++ } ++ + return 0; + + error: +-- +2.35.1 + diff --git a/libvirt-qemu_migration-Implement-VIR_MIGRATE_ZEROCOPY-flag.patch b/libvirt-qemu_migration-Implement-VIR_MIGRATE_ZEROCOPY-flag.patch new file mode 100644 index 0000000..e1d38c3 --- /dev/null +++ b/libvirt-qemu_migration-Implement-VIR_MIGRATE_ZEROCOPY-flag.patch @@ -0,0 +1,120 @@ +From 34dc905251ca0f00d92e8419adc63580c6266394 Mon Sep 17 00:00:00 2001 +Message-Id: <34dc905251ca0f00d92e8419adc63580c6266394@dist-git> +From: Jiri Denemark +Date: Wed, 22 Jun 2022 16:37:31 +0200 +Subject: [PATCH] qemu_migration: Implement VIR_MIGRATE_ZEROCOPY flag +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +Resolves: https://gitlab.com/libvirt/libvirt/-/issues/306 + +Signed-off-by: Jiri Denemark +Reviewed-by: Ján Tomko +(cherry picked from commit d375993ab314a41bca7ef6c846e07afc18c37774) + +https://bugzilla.redhat.com/show_bug.cgi?id=2117272 + +Conflicts: + src/qemu/qemu_migration.c + src/qemu/qemu_migration.h + - post-copy recovery not bacported + +Signed-off-by: Jiri Denemark +--- + src/qemu/qemu_migration.c | 21 +++++++++++++++++++++ + src/qemu/qemu_migration.h | 1 + + src/qemu/qemu_migration_params.c | 6 ++++++ + src/qemu/qemu_migration_params.h | 1 + + 4 files changed, 29 insertions(+) + +diff --git a/src/qemu/qemu_migration.c b/src/qemu/qemu_migration.c +index 01102c4300..11f87296d6 100644 +--- a/src/qemu/qemu_migration.c ++++ b/src/qemu/qemu_migration.c +@@ -2366,6 +2366,12 @@ qemuMigrationSrcBeginPhase(virQEMUDriver *driver, + return NULL; + } + ++ if (flags & VIR_MIGRATE_ZEROCOPY && !(flags & VIR_MIGRATE_PARALLEL)) { ++ virReportError(VIR_ERR_OPERATION_INVALID, "%s", ++ _("zero-copy is only available for parallel migration")); ++ return NULL; ++ } ++ + if (flags & (VIR_MIGRATE_NON_SHARED_DISK | VIR_MIGRATE_NON_SHARED_INC)) { + if (flags & VIR_MIGRATE_NON_SHARED_SYNCHRONOUS_WRITES && + !virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_BLOCKDEV)) { +@@ -4137,6 +4143,21 @@ qemuMigrationSrcRun(virQEMUDriver *driver, + migParams) < 0) + goto error; + ++ if (flags & VIR_MIGRATE_ZEROCOPY) { ++ /* Zero-copy requires pages in transfer to be locked in host memory. ++ * Unfortunately, we have no reliable way of computing how many pages ++ * will need to be locked at the same time. Thus we set the limit to ++ * the whole guest memory and reset it back once migration is done. */ ++ unsigned long long limit; ++ ++ if (virMemoryLimitIsSet(vm->def->mem.hard_limit)) ++ limit = vm->def->mem.hard_limit; ++ else ++ limit = virDomainDefGetMemoryTotal(vm->def); ++ ++ if (qemuDomainSetMaxMemLock(vm, limit << 10, &priv->preMigrationMemlock) < 0) ++ goto error; ++ } + + if (storageMigration) { + if (mig->nbd) { +diff --git a/src/qemu/qemu_migration.h b/src/qemu/qemu_migration.h +index b233358a51..6f737f7b4c 100644 +--- a/src/qemu/qemu_migration.h ++++ b/src/qemu/qemu_migration.h +@@ -60,6 +60,7 @@ + VIR_MIGRATE_TLS | \ + VIR_MIGRATE_PARALLEL | \ + VIR_MIGRATE_NON_SHARED_SYNCHRONOUS_WRITES | \ ++ VIR_MIGRATE_ZEROCOPY | \ + 0) + + /* All supported migration parameters and their types. */ +diff --git a/src/qemu/qemu_migration_params.c b/src/qemu/qemu_migration_params.c +index 7b225fdf4b..c985583861 100644 +--- a/src/qemu/qemu_migration_params.c ++++ b/src/qemu/qemu_migration_params.c +@@ -96,6 +96,7 @@ VIR_ENUM_IMPL(qemuMigrationCapability, + "multifd", + "dirty-bitmaps", + "return-path", ++ "zero-copy-send", + ); + + +@@ -177,6 +178,11 @@ static const qemuMigrationParamsFlagMapItem qemuMigrationParamsFlagMap[] = { + VIR_MIGRATE_TUNNELLED, + QEMU_MIGRATION_CAP_RETURN_PATH, + QEMU_MIGRATION_SOURCE | QEMU_MIGRATION_DESTINATION}, ++ ++ {QEMU_MIGRATION_FLAG_REQUIRED, ++ VIR_MIGRATE_ZEROCOPY, ++ QEMU_MIGRATION_CAP_ZERO_COPY_SEND, ++ QEMU_MIGRATION_SOURCE}, + }; + + /* Translation from VIR_MIGRATE_PARAM_* typed parameters to +diff --git a/src/qemu/qemu_migration_params.h b/src/qemu/qemu_migration_params.h +index b4de8dda7b..caa5e47f0f 100644 +--- a/src/qemu/qemu_migration_params.h ++++ b/src/qemu/qemu_migration_params.h +@@ -41,6 +41,7 @@ typedef enum { + QEMU_MIGRATION_CAP_MULTIFD, + QEMU_MIGRATION_CAP_BLOCK_DIRTY_BITMAPS, + QEMU_MIGRATION_CAP_RETURN_PATH, ++ QEMU_MIGRATION_CAP_ZERO_COPY_SEND, + + QEMU_MIGRATION_CAP_LAST + } qemuMigrationCapability; +-- +2.35.1 + diff --git a/libvirt-qemu_migration-Restore-original-memory-locking-limit.patch b/libvirt-qemu_migration-Restore-original-memory-locking-limit.patch new file mode 100644 index 0000000..3011e5f --- /dev/null +++ b/libvirt-qemu_migration-Restore-original-memory-locking-limit.patch @@ -0,0 +1,138 @@ +From 7cbfdb081de6e4eb684447ba48869082df798419 Mon Sep 17 00:00:00 2001 +Message-Id: <7cbfdb081de6e4eb684447ba48869082df798419@dist-git> +From: Jiri Denemark +Date: Wed, 22 Jun 2022 16:12:02 +0200 +Subject: [PATCH] qemu_migration: Restore original memory locking limit +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +For RDMA migration we update memory locking limit, but never set it back +once migration finishes (on the destination host) or aborts (on the +source host). + +Signed-off-by: Jiri Denemark +Reviewed-by: Ján Tomko +(cherry picked from commit d4d3bb813031275c2c7cf72724b83c97ce82ab7a) + +https://bugzilla.redhat.com/show_bug.cgi?id=2117272 + +Conflicts: + src/qemu/qemu_migration.c + - post-copy resovery not backported + +The original 8.7.0 backport contained a bug which was later fixed by +"qemu_migration: Fix restoring memlock limit on destination". This +backport includes the follow up fix squashed in. + +Signed-off-by: Jiri Denemark +--- + src/qemu/qemu_domain.c | 12 ++++++++++++ + src/qemu/qemu_domain.h | 3 +++ + src/qemu/qemu_migration.c | 11 +++++++++-- + 3 files changed, 24 insertions(+), 2 deletions(-) + +diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c +index a81789f194..c24d1e4d53 100644 +--- a/src/qemu/qemu_domain.c ++++ b/src/qemu/qemu_domain.c +@@ -2389,6 +2389,11 @@ qemuDomainObjPrivateXMLFormat(virBuffer *buf, + priv->originalMemlock); + } + ++ if (priv->preMigrationMemlock > 0) { ++ virBufferAsprintf(buf, "%llu\n", ++ priv->preMigrationMemlock); ++ } ++ + return 0; + } + +@@ -3117,6 +3122,13 @@ qemuDomainObjPrivateXMLParse(xmlXPathContextPtr ctxt, + goto error; + } + ++ if (virXPathULongLong("string(./preMigrationMemlock)", ctxt, ++ &priv->preMigrationMemlock) == -2) { ++ virReportError(VIR_ERR_INTERNAL_ERROR, "%s", ++ _("failed to parse pre-migration memlock limit")); ++ return -1; ++ } ++ + return 0; + + error: +diff --git a/src/qemu/qemu_domain.h b/src/qemu/qemu_domain.h +index 6d1d23439a..d6e8a7a0fb 100644 +--- a/src/qemu/qemu_domain.h ++++ b/src/qemu/qemu_domain.h +@@ -146,6 +146,9 @@ struct _qemuDomainObjPrivate { + int nbdPort; /* Port used for migration with NBD */ + unsigned short migrationPort; + int preMigrationState; ++ unsigned long long preMigrationMemlock; /* Original RLIMIT_MEMLOCK in case ++ it was changed for the current ++ migration job. */ + + virChrdevs *devs; + +diff --git a/src/qemu/qemu_migration.c b/src/qemu/qemu_migration.c +index 10338f8e87..01102c4300 100644 +--- a/src/qemu/qemu_migration.c ++++ b/src/qemu/qemu_migration.c +@@ -2974,7 +2974,8 @@ qemuMigrationDstPrepareAny(virQEMUDriver *driver, + + if (STREQ_NULLABLE(protocol, "rdma") && + vm->def->mem.hard_limit > 0 && +- qemuDomainSetMaxMemLock(vm, vm->def->mem.hard_limit << 10, NULL) < 0) { ++ qemuDomainSetMaxMemLock(vm, vm->def->mem.hard_limit << 10, ++ &priv->preMigrationMemlock) < 0) { + goto stopjob; + } + +@@ -3451,6 +3452,7 @@ qemuMigrationSrcConfirmPhase(virQEMUDriver *driver, + VIR_DOMAIN_EVENT_STOPPED_MIGRATED); + virObjectEventStateQueue(driver->domainEventState, event); + qemuDomainEventEmitJobCompleted(driver, vm); ++ priv->preMigrationMemlock = 0; + } else { + virErrorPtr orig_err; + int reason; +@@ -3471,6 +3473,7 @@ qemuMigrationSrcConfirmPhase(virQEMUDriver *driver, + + qemuMigrationParamsReset(driver, vm, QEMU_ASYNC_JOB_MIGRATION_OUT, + jobPriv->migParams, priv->job.apiFlags); ++ qemuDomainSetMaxMemLock(vm, 0, &priv->preMigrationMemlock); + + qemuDomainSaveStatus(vm); + } +@@ -4224,7 +4227,8 @@ qemuMigrationSrcRun(virQEMUDriver *driver, + case MIGRATION_DEST_HOST: + if (STREQ(spec->dest.host.protocol, "rdma") && + vm->def->mem.hard_limit > 0 && +- qemuDomainSetMaxMemLock(vm, vm->def->mem.hard_limit << 10, NULL) < 0) { ++ qemuDomainSetMaxMemLock(vm, vm->def->mem.hard_limit << 10, ++ &priv->preMigrationMemlock) < 0) { + goto exit_monitor; + } + rc = qemuMonitorMigrateToHost(priv->mon, migrate_flags, +@@ -5408,6 +5412,7 @@ qemuMigrationSrcPerformPhase(virQEMUDriver *driver, + if (ret < 0) { + qemuMigrationParamsReset(driver, vm, QEMU_ASYNC_JOB_MIGRATION_OUT, + jobPriv->migParams, priv->job.apiFlags); ++ qemuDomainSetMaxMemLock(vm, 0, &priv->preMigrationMemlock); + qemuMigrationJobFinish(driver, vm); + } else { + qemuMigrationJobContinue(vm); +@@ -5869,6 +5874,8 @@ qemuMigrationDstFinish(virQEMUDriver *driver, + */ + if (inPostCopy) + g_clear_pointer(&priv->job.completed, qemuDomainJobInfoFree); ++ ++ qemuDomainSetMaxMemLock(vm, 0, &priv->preMigrationMemlock); + } + + qemuMigrationParamsReset(driver, vm, QEMU_ASYNC_JOB_MIGRATION_IN, +-- +2.35.1 + diff --git a/libvirt-qemu_migration-Use-qemuDomainSetMaxMemLock.patch b/libvirt-qemu_migration-Use-qemuDomainSetMaxMemLock.patch new file mode 100644 index 0000000..2b853a2 --- /dev/null +++ b/libvirt-qemu_migration-Use-qemuDomainSetMaxMemLock.patch @@ -0,0 +1,53 @@ +From ad3f1dceac21369b9c18b6032a4ff859dc79bbc7 Mon Sep 17 00:00:00 2001 +Message-Id: +From: Jiri Denemark +Date: Wed, 22 Jun 2022 09:04:04 +0200 +Subject: [PATCH] qemu_migration: Use qemuDomainSetMaxMemLock +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +This helper will not try to set the limit if it is already big enough, +which may be useful when libvirt daemon is running in a containerized +environment and is not allowed to change memory locking limit. + +Signed-off-by: Jiri Denemark +Reviewed-by: Ján Tomko +(cherry picked from commit 22ee8cbf090c45f999b76e3f8dc7a45065fc9edf) + +https://bugzilla.redhat.com/show_bug.cgi?id=2117272 + +Conflicts: + src/qemu/qemu_migration.c + - refactoring for post-copy recovery not backported + +Signed-off-by: Jiri Denemark +--- + src/qemu/qemu_migration.c | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +diff --git a/src/qemu/qemu_migration.c b/src/qemu/qemu_migration.c +index 2635ef1162..10338f8e87 100644 +--- a/src/qemu/qemu_migration.c ++++ b/src/qemu/qemu_migration.c +@@ -2974,7 +2974,7 @@ qemuMigrationDstPrepareAny(virQEMUDriver *driver, + + if (STREQ_NULLABLE(protocol, "rdma") && + vm->def->mem.hard_limit > 0 && +- virProcessSetMaxMemLock(vm->pid, vm->def->mem.hard_limit << 10) < 0) { ++ qemuDomainSetMaxMemLock(vm, vm->def->mem.hard_limit << 10, NULL) < 0) { + goto stopjob; + } + +@@ -4224,7 +4224,7 @@ qemuMigrationSrcRun(virQEMUDriver *driver, + case MIGRATION_DEST_HOST: + if (STREQ(spec->dest.host.protocol, "rdma") && + vm->def->mem.hard_limit > 0 && +- virProcessSetMaxMemLock(vm->pid, vm->def->mem.hard_limit << 10) < 0) { ++ qemuDomainSetMaxMemLock(vm, vm->def->mem.hard_limit << 10, NULL) < 0) { + goto exit_monitor; + } + rc = qemuMonitorMigrateToHost(priv->mon, migrate_flags, +-- +2.35.1 + diff --git a/libvirt-virDomainDiskDefValidate-Improve-error-messages-for-startupPolicy-checks.patch b/libvirt-virDomainDiskDefValidate-Improve-error-messages-for-startupPolicy-checks.patch new file mode 100644 index 0000000..015d22d --- /dev/null +++ b/libvirt-virDomainDiskDefValidate-Improve-error-messages-for-startupPolicy-checks.patch @@ -0,0 +1,52 @@ +From 4c57d8399b86c07ee0b1bafd2f8bf0ba10ff384f Mon Sep 17 00:00:00 2001 +Message-Id: <4c57d8399b86c07ee0b1bafd2f8bf0ba10ff384f@dist-git> +From: Peter Krempa +Date: Tue, 14 Jun 2022 13:13:48 +0200 +Subject: [PATCH] virDomainDiskDefValidate: Improve error messages for + 'startupPolicy' checks +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +Remove linebreak and mention the attribute name. Also prepare the error +messages for future by substituting the type of offending access. + +Signed-off-by: Peter Krempa +Reviewed-by: Ján Tomko +(cherry picked from commit 9a480737c8adf92c332aa850c5269191ceb04eb9) +https://bugzilla.redhat.com/show_bug.cgi?id=2095758 +https://bugzilla.redhat.com/show_bug.cgi?id=2109571 +--- + src/conf/domain_validate.c | 9 ++++----- + 1 file changed, 4 insertions(+), 5 deletions(-) + +diff --git a/src/conf/domain_validate.c b/src/conf/domain_validate.c +index a4271f1247..452742e67c 100644 +--- a/src/conf/domain_validate.c ++++ b/src/conf/domain_validate.c +@@ -778,9 +778,9 @@ virDomainDiskDefValidate(const virDomainDef *def, + if (disk->startupPolicy != VIR_DOMAIN_STARTUP_POLICY_DEFAULT) { + if (disk->src->type == VIR_STORAGE_TYPE_NETWORK) { + virReportError(VIR_ERR_XML_ERROR, +- _("Setting disk %s is not allowed for " +- "disk of network type"), +- virDomainStartupPolicyTypeToString(disk->startupPolicy)); ++ _("disk startupPolicy '%s' is not allowed for disk of '%s' type"), ++ virDomainStartupPolicyTypeToString(disk->startupPolicy), ++ virStorageTypeToString(disk->src->type)); + return -1; + } + +@@ -788,8 +788,7 @@ virDomainDiskDefValidate(const virDomainDef *def, + disk->device != VIR_DOMAIN_DISK_DEVICE_FLOPPY && + disk->startupPolicy == VIR_DOMAIN_STARTUP_POLICY_REQUISITE) { + virReportError(VIR_ERR_XML_ERROR, "%s", +- _("Setting disk 'requisite' is allowed only for " +- "cdrom or floppy")); ++ _("disk startupPolicy 'requisite' is allowed only for cdrom or floppy")); + return -1; + } + } +-- +2.35.1 + diff --git a/libvirt-virDomainDiskDefValidateStartupPolicy-Validate-disk-type-better.patch b/libvirt-virDomainDiskDefValidateStartupPolicy-Validate-disk-type-better.patch new file mode 100644 index 0000000..78b4dd1 --- /dev/null +++ b/libvirt-virDomainDiskDefValidateStartupPolicy-Validate-disk-type-better.patch @@ -0,0 +1,43 @@ +From a5cdca9995a05ac45e882ad3e1ca1e4ab53a2c34 Mon Sep 17 00:00:00 2001 +Message-Id: +From: Peter Krempa +Date: Tue, 14 Jun 2022 14:07:47 +0200 +Subject: [PATCH] virDomainDiskDefValidateStartupPolicy: Validate disk type + better +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +Our startup policy checkers work only for local paths, so disk sources +such as NVMe, or vhost-user can't be used with startup policy. + +Unfortunately the validation did not catch these cases. Fix it. + +Signed-off-by: Peter Krempa +Reviewed-by: Ján Tomko +(cherry picked from commit b90d0f0a1e4ee52c828fb683c14c14e241e6fcbb) +https://bugzilla.redhat.com/show_bug.cgi?id=2095758 +https://bugzilla.redhat.com/show_bug.cgi?id=2109571 +--- + src/conf/domain_validate.c | 5 ++++- + 1 file changed, 4 insertions(+), 1 deletion(-) + +diff --git a/src/conf/domain_validate.c b/src/conf/domain_validate.c +index bfff7339ef..55759af9f8 100644 +--- a/src/conf/domain_validate.c ++++ b/src/conf/domain_validate.c +@@ -604,7 +604,10 @@ virDomainDiskDefValidateStartupPolicy(const virDomainDiskDef *disk) + if (disk->startupPolicy == VIR_DOMAIN_STARTUP_POLICY_DEFAULT) + return 0; + +- if (disk->src->type == VIR_STORAGE_TYPE_NETWORK) { ++ /* We want to allow any startup policy for un-translated _TYPE_VOLUME disks. ++ * virStorageSourceGetActualType returns _TYPE_VOLUME in such case */ ++ if (virStorageSourceGetActualType(disk->src) != VIR_STORAGE_TYPE_VOLUME && ++ !virStorageSourceIsLocalStorage(disk->src)) { + virReportError(VIR_ERR_XML_ERROR, + _("disk startupPolicy '%s' is not allowed for disk of '%s' type"), + virDomainStartupPolicyTypeToString(disk->startupPolicy), +-- +2.35.1 + diff --git a/libvirt-virDomainDiskTranslateSourcePool-Fix-check-of-startupPolicy-definition.patch b/libvirt-virDomainDiskTranslateSourcePool-Fix-check-of-startupPolicy-definition.patch new file mode 100644 index 0000000..8db5803 --- /dev/null +++ b/libvirt-virDomainDiskTranslateSourcePool-Fix-check-of-startupPolicy-definition.patch @@ -0,0 +1,57 @@ +From d56c0a4b1b57d9547d40088b6787d7503c09e2b9 Mon Sep 17 00:00:00 2001 +Message-Id: +From: Peter Krempa +Date: Tue, 14 Jun 2022 14:21:33 +0200 +Subject: [PATCH] virDomainDiskTranslateSourcePool: Fix check of + 'startupPolicy' definition +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +The check was historically done only for _TYPE_VOLUME disks, but +refactors to allow _TYPE_VOLUME disks in the backing chain caused a +regression where we'd reject startupPolicy also for _TYPE_BLOCK disks +which historically worked well. + +Fix it by using the 'virDomainDiskDefValidateStartupPolicy' helper and +use it only when the top level image is a _TYPE_VOLUME as in other cases +it was already validated. This also allows _TYPE_BLOCK volumes to use +startup policy. + +Fixes: 37f01262eed9f37dd5eb7de8b83edd2fea741054 +Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=2095758 +Signed-off-by: Peter Krempa +Reviewed-by: Ján Tomko +(cherry picked from commit ed8984306e1cd44c424fda3ed412a4177dd7b84d) +https://bugzilla.redhat.com/show_bug.cgi?id=2109571 +--- + src/conf/domain_conf.c | 12 ++++++------ + 1 file changed, 6 insertions(+), 6 deletions(-) + +diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c +index 805a15848e..92510973e6 100644 +--- a/src/conf/domain_conf.c ++++ b/src/conf/domain_conf.c +@@ -31311,13 +31311,13 @@ virDomainDiskTranslateSourcePool(virDomainDiskDef *def) + + if (virDomainStorageSourceTranslateSourcePool(n, conn) < 0) + return -1; +- } + +- if (def->startupPolicy != 0 && +- virStorageSourceGetActualType(def->src) != VIR_STORAGE_TYPE_FILE) { +- virReportError(VIR_ERR_XML_ERROR, "%s", +- _("'startupPolicy' is only valid for 'file' type volume")); +- return -1; ++ /* The validity of 'startupPolicy' setting is checked only for the top ++ * level image. For any other subsequent images we honour it only if ++ * possible */ ++ if (n == def->src && ++ virDomainDiskDefValidateStartupPolicy(def) < 0) ++ return -1; + } + + return 0; +-- +2.35.1 + diff --git a/libvirt-virsh-Add-support-for-VIR_MIGRATE_ZEROCOPY-flag.patch b/libvirt-virsh-Add-support-for-VIR_MIGRATE_ZEROCOPY-flag.patch new file mode 100644 index 0000000..a3211db --- /dev/null +++ b/libvirt-virsh-Add-support-for-VIR_MIGRATE_ZEROCOPY-flag.patch @@ -0,0 +1,80 @@ +From eb87264dc41a7147fb88fdc4d666ef8d0e9bb882 Mon Sep 17 00:00:00 2001 +Message-Id: +From: Jiri Denemark +Date: Wed, 22 Jun 2022 16:36:53 +0200 +Subject: [PATCH] virsh: Add support for VIR_MIGRATE_ZEROCOPY flag +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +Signed-off-by: Jiri Denemark +Reviewed-by: Ján Tomko +(cherry picked from commit efa3baeae70fbdf4ab032ca485cb9272ee96bd50) + +https://bugzilla.redhat.com/show_bug.cgi?id=2117272 + +Conflicts: + docs/manpages/virsh.rst + tools/virsh-domain.c + - post-copy recovery not backported + +Signed-off-by: Jiri Denemark +--- + docs/manpages/virsh.rst | 8 +++++++- + tools/virsh-domain.c | 7 +++++++ + 2 files changed, 14 insertions(+), 1 deletion(-) + +diff --git a/docs/manpages/virsh.rst b/docs/manpages/virsh.rst +index dd534c10cb..d24e7774a6 100644 +--- a/docs/manpages/virsh.rst ++++ b/docs/manpages/virsh.rst +@@ -3225,7 +3225,8 @@ migrate + migrate [--live] [--offline] [--direct] [--p2p [--tunnelled]] + [--persistent] [--undefinesource] [--suspend] [--copy-storage-all] + [--copy-storage-inc] [--change-protection] [--unsafe] [--verbose] +- [--rdma-pin-all] [--abort-on-error] [--postcopy] [--postcopy-after-precopy] ++ [--rdma-pin-all] [--abort-on-error] [--postcopy] ++ [--postcopy-after-precopy] [--zerocopy] + domain desturi [migrateuri] [graphicsuri] [listen-address] [dname] + [--timeout seconds [--timeout-suspend | --timeout-postcopy]] + [--xml file] [--migrate-disks disk-list] [--disks-port port] +@@ -3298,6 +3299,11 @@ high (and thus allowing the domain to lock most of the host's memory). Doing so + may be dangerous to both the domain and the host itself since the host's kernel + may run out of memory. + ++*--zerocopy* requests zero-copy mechanism to be used for migrating memory pages. ++For QEMU/KVM this means QEMU will be temporarily allowed to lock all guest ++pages in host's memory, although only those that are queued for transfer will ++be locked at the same time. ++ + ``Note``: Individual hypervisors usually do not support all possible types of + migration. For example, QEMU does not support direct migration. + +diff --git a/tools/virsh-domain.c b/tools/virsh-domain.c +index b56f6a90f5..c5bade1dbf 100644 +--- a/tools/virsh-domain.c ++++ b/tools/virsh-domain.c +@@ -10730,6 +10730,10 @@ static const vshCmdOptDef opts_migrate[] = { + .type = VSH_OT_BOOL, + .help = N_("automatically switch to post-copy migration after one pass of pre-copy") + }, ++ {.name = "zerocopy", ++ .type = VSH_OT_BOOL, ++ .help = N_("use zero-copy mechanism for migrating memory pages") ++ }, + {.name = "migrateuri", + .type = VSH_OT_STRING, + .completer = virshCompleteEmpty, +@@ -11133,6 +11137,9 @@ doMigrate(void *opaque) + if (vshCommandOptBool(cmd, "postcopy")) + flags |= VIR_MIGRATE_POSTCOPY; + ++ if (vshCommandOptBool(cmd, "zerocopy")) ++ flags |= VIR_MIGRATE_ZEROCOPY; ++ + if (vshCommandOptBool(cmd, "tls")) + flags |= VIR_MIGRATE_TLS; + +-- +2.35.1 + diff --git a/libvirt.spec b/libvirt.spec index 248656f..3d6c119 100644 --- a/libvirt.spec +++ b/libvirt.spec @@ -6,16 +6,16 @@ %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 %if 0%{?rhel} %if 0%{?rhel} > 8 - %define arches_qemu_kvm x86_64 aarch64 s390x loongarch64 + %define arches_qemu_kvm x86_64 aarch64 s390x %else - %define arches_qemu_kvm x86_64 %{power64} aarch64 s390x loongarch64 + %define arches_qemu_kvm x86_64 %{power64} aarch64 s390x %endif %endif -%define arches_64bit x86_64 %{power64} aarch64 s390x riscv64 loongarch64 +%define arches_64bit x86_64 %{power64} aarch64 s390x riscv64 %define arches_x86 %{ix86} x86_64 %define arches_systemtap_64bit %{arches_64bit} @@ -23,9 +23,9 @@ %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_numactl %{arches_x86} %{power64} aarch64 s390x loongarch64 -%define arches_numad %{arches_x86} %{power64} aarch64 loongarch64 +%define arches_zfs %{arches_x86} %{power64} %{arm} +%define arches_numactl %{arches_x86} %{power64} aarch64 s390x +%define arches_numad %{arches_x86} %{power64} aarch64 # The hypervisor drivers that run in libvirtd %define with_qemu 0%{!?_without_qemu:1} @@ -210,7 +210,7 @@ Summary: Library providing a simple virtualization API Name: libvirt Version: 8.0.0 -Release: 5.2%{?dist}%{?extra_release} +Release: 5.4%{?dist}%{?extra_release} License: LGPLv2+ URL: https://libvirt.org/ @@ -250,7 +250,18 @@ Patch27: libvirt-cpu_x86-Consolidate-signature-match-in-x86DecodeUseCandidate.pa Patch28: libvirt-cpu_x86-Refactor-feature-list-comparison-in-x86DecodeUseCandidate.patch Patch29: libvirt-cpu_x86-Penalize-disabled-features-when-computing-CPU-model.patch Patch30: libvirt-cpu_x86-Ignore-enabled-features-for-input-models-in-x86DecodeUseCandidate.patch -Patch31: libvirt-Add-loongarch-support.patch +Patch31: libvirt-virDomainDiskDefValidate-Improve-error-messages-for-startupPolicy-checks.patch +Patch32: libvirt-domain_validate-Split-out-validation-of-disk-startup-policy.patch +Patch33: libvirt-virDomainDiskDefValidateStartupPolicy-Validate-disk-type-better.patch +Patch34: libvirt-virDomainDiskTranslateSourcePool-Fix-check-of-startupPolicy-definition.patch +Patch35: libvirt-conf-Move-virDomainObj-originalMemlock-into-qemuDomainObjPrivate.patch +Patch36: libvirt-qemu_domain-Format-qemuDomainObjPrivate-originalMemlock.patch +Patch37: libvirt-qemu-Add-qemuDomainSetMaxMemLock-helper.patch +Patch38: libvirt-qemu_migration-Use-qemuDomainSetMaxMemLock.patch +Patch39: libvirt-qemu_migration-Restore-original-memory-locking-limit.patch +Patch40: libvirt-Add-VIR_MIGRATE_ZEROCOPY-flag.patch +Patch41: libvirt-virsh-Add-support-for-VIR_MIGRATE_ZEROCOPY-flag.patch +Patch42: libvirt-qemu_migration-Implement-VIR_MIGRATE_ZEROCOPY-flag.patch Requires: libvirt-daemon = %{version}-%{release} Requires: libvirt-daemon-config-network = %{version}-%{release} @@ -2124,6 +2135,22 @@ exit 0 %changelog +* Thu Aug 18 2022 Jiri Denemark - 8.0.0-5.4.el8 +- conf: Move virDomainObj::originalMemlock into qemuDomainObjPrivate (rhbz#2117272) +- qemu_domain: Format qemuDomainObjPrivate::originalMemlock (rhbz#2117272) +- qemu: Add qemuDomainSetMaxMemLock helper (rhbz#2117272) +- qemu_migration: Use qemuDomainSetMaxMemLock (rhbz#2117272) +- qemu_migration: Restore original memory locking limit (rhbz#2117272) +- Add VIR_MIGRATE_ZEROCOPY flag (rhbz#2117272) +- virsh: Add support for VIR_MIGRATE_ZEROCOPY flag (rhbz#2117272) +- qemu_migration: Implement VIR_MIGRATE_ZEROCOPY flag (rhbz#2117272) + +* Fri Jul 29 2022 Jiri Denemark - 8.0.0-5.3.el8 +- virDomainDiskDefValidate: Improve error messages for 'startupPolicy' checks (rhbz#2109571) +- domain_validate: Split out validation of disk startup policy (rhbz#2109571) +- virDomainDiskDefValidateStartupPolicy: Validate disk type better (rhbz#2109571) +- virDomainDiskTranslateSourcePool: Fix check of 'startupPolicy' definition (rhbz#2109571) + * Tue May 17 2022 Jiri Denemark - 8.0.0-5.2.el8 - cpu_map: Disable cpu64-rhel* for host-model and baseline (rhbz#2084030) - cputest: Drop some old artificial baseline tests (rhbz#2084030) -- Gitee From 49cbbb4430167a4454222d94dcda492fad32cf0c Mon Sep 17 00:00:00 2001 From: zhaotianrui Date: Thu, 8 Sep 2022 09:28:25 -0400 Subject: [PATCH 2/2] Add loongarch support Signed-off-by: zhaotianrui --- libvirt-Add-loongarch-support.patch | 1233 +++++++++++++++++++++++++++ libvirt.spec | 21 +- 2 files changed, 1246 insertions(+), 8 deletions(-) create mode 100644 libvirt-Add-loongarch-support.patch diff --git a/libvirt-Add-loongarch-support.patch b/libvirt-Add-loongarch-support.patch new file mode 100644 index 0000000..94fd22a --- /dev/null +++ b/libvirt-Add-loongarch-support.patch @@ -0,0 +1,1233 @@ +From da7befb4ce165d692f34156f740f4ea3ce2b7fec Mon Sep 17 00:00:00 2001 +From: zhaotianrui +Date: Sat, 3 Sep 2022 14:23:43 -0400 +Subject: [PATCH] Add loongarch support + +Signed-off-by: zhaotianrui +Change-Id: I8d245bc2fb914b08af4ade8e334d59ba3a5c2f01 +--- + po/POTFILES.in | 1 + + src/cpu/cpu.c | 3 +- + src/cpu/cpu.h | 3 +- + src/cpu/cpu_loongarch.c | 727 ++++++++++++++++++++++++++++++ + src/cpu/cpu_loongarch.h | 28 ++ + src/cpu/cpu_loongarch_data.h | 40 ++ + src/cpu/meson.build | 1 + + src/cpu_map/index.xml | 5 + + src/cpu_map/loongarch_vendors.xml | 3 + + src/cpu_map/ls_3a5000.xml | 6 + + src/cpu_map/meson.build | 2 + + src/qemu/qemu_capabilities.c | 5 + + src/qemu/qemu_conf.c | 4 +- + src/qemu/qemu_domain.c | 20 +- + src/qemu/qemu_domain.h | 1 + + src/qemu/qemu_domain_address.c | 58 +++ + src/qemu/qemu_validate.c | 3 +- + src/util/virarch.c | 3 + + src/util/virarch.h | 3 + + src/util/virhostcpu.c | 2 +- + src/util/virsysinfo.c | 2 +- + 21 files changed, 913 insertions(+), 7 deletions(-) + create mode 100644 src/cpu/cpu_loongarch.c + create mode 100644 src/cpu/cpu_loongarch.h + create mode 100644 src/cpu/cpu_loongarch_data.h + create mode 100644 src/cpu_map/loongarch_vendors.xml + create mode 100644 src/cpu_map/ls_3a5000.xml + +diff --git a/po/POTFILES.in b/po/POTFILES.in +index bf0a3b3529..1153e78265 100644 +--- a/po/POTFILES.in ++++ b/po/POTFILES.in +@@ -68,6 +68,7 @@ + @SRCDIR@src/cpu/cpu_arm.c + @SRCDIR@src/cpu/cpu_map.c + @SRCDIR@src/cpu/cpu_ppc64.c ++@SRCDIR@src/cpu/cpu_loongarch.c + @SRCDIR@src/cpu/cpu_s390.c + @SRCDIR@src/cpu/cpu_x86.c + @SRCDIR@src/datatypes.c +diff --git a/src/cpu/cpu.c b/src/cpu/cpu.c +index 285c7eee44..49527c3688 100644 +--- a/src/cpu/cpu.c ++++ b/src/cpu/cpu.c +@@ -31,7 +31,7 @@ + #include "cpu_arm.h" + #include "capabilities.h" + #include "virstring.h" +- ++#include "cpu_loongarch.h" + + #define VIR_FROM_THIS VIR_FROM_CPU + +@@ -42,6 +42,7 @@ static struct cpuArchDriver *drivers[] = { + &cpuDriverPPC64, + &cpuDriverS390, + &cpuDriverArm, ++ &cpuDriverLoongArch, + }; + + +diff --git a/src/cpu/cpu.h b/src/cpu/cpu.h +index 071b33fe76..ce7aee4757 100644 +--- a/src/cpu/cpu.h ++++ b/src/cpu/cpu.h +@@ -28,7 +28,7 @@ + #include "cpu_x86_data.h" + #include "cpu_ppc64_data.h" + #include "cpu_arm_data.h" +- ++#include "cpu_loongarch_data.h" + + typedef struct _virCPUData virCPUData; + struct _virCPUData { +@@ -37,6 +37,7 @@ struct _virCPUData { + virCPUx86Data x86; + virCPUppc64Data ppc64; + virCPUarmData arm; ++ virCPULoongArchData loongarch; + /* generic driver needs no data */ + } data; + }; +diff --git a/src/cpu/cpu_loongarch.c b/src/cpu/cpu_loongarch.c +new file mode 100644 +index 0000000000..f7b4b85a44 +--- /dev/null ++++ b/src/cpu/cpu_loongarch.c +@@ -0,0 +1,727 @@ ++/* ++ * cpu_loongarch.c: CPU driver for 64-bit LOONGARCH CPUs ++ * ++ * Copyright (C) 2013 Red Hat, Inc. ++ * Copyright (C) IBM Corporation, 2010 ++ * ++ * 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 ++ * . ++ */ ++ ++#include ++#include ++#include ++#include ++#include ++ ++#include ++#include ++#include ++#include ++#include ++#include ++ ++#include "virlog.h" ++#include "viralloc.h" ++#include "cpu.h" ++#include "virstring.h" ++#include "cpu_map.h" ++#include "virbuffer.h" ++#include "cpu_loongarch.h" ++#include "cpu_loongarch_data.h" ++ ++#define VIR_FROM_THIS VIR_FROM_CPU ++ ++VIR_LOG_INIT("cpu.cpu_loongarch"); ++ ++static const virArch archs[] = { VIR_ARCH_LOONGARCH64 }; ++ ++typedef struct _LoongArch_vendor LoongArch_vendor; ++struct _LoongArch_vendor { ++ char *name; ++}; ++ ++typedef struct _LoongArch_model LoongArch_model; ++struct _LoongArch_model { ++ char *name; ++ LoongArch_vendor *vendor; ++ virCPULoongArchData data; ++}; ++ ++typedef struct _LoongArch_map LoongArch_map; ++struct _LoongArch_map { ++ size_t nvendors; ++ LoongArch_vendor **vendors; ++ size_t nmodels; ++ LoongArch_model **models; ++}; ++ ++static void ++LoongArchDataClear(virCPULoongArchData *data) ++{ ++ if (!data) ++ return; ++ ++ g_free(data->prid); ++} ++ ++static int ++LoongArchDataCopy(virCPULoongArchData *dst, const virCPULoongArchData *src) ++{ ++ size_t i; ++ ++ dst->prid = g_new0(virCPULoongArchPrid, src->len); ++ dst->len = src->len; ++ ++ for (i = 0; i < src->len; i++) { ++ dst->prid[i].value = src->prid[i].value; ++ dst->prid[i].mask = src->prid[i].mask; ++ } ++ ++ return 0; ++} ++ ++static void ++LoongArchVendorFree(LoongArch_vendor *vendor) ++{ ++ if (!vendor) ++ return; ++ ++ g_free(vendor); ++} ++ ++static LoongArch_vendor * ++LoongArchVendorFind(LoongArch_map *map, ++ const char *name) ++{ ++ size_t i; ++ ++ for (i = 0; i < map->nvendors; i++) { ++ if (STREQ(map->vendors[i]->name, name)) ++ return map->vendors[i]; ++ } ++ ++ return NULL; ++} ++ ++static void ++LoongArchModelFree(LoongArch_model *model) ++{ ++ if (!model) ++ return; ++ ++ LoongArchDataClear(&model->data); ++ g_free(model->name); ++ g_free(model); ++} ++ ++static LoongArch_model * ++LoongArchModelCopy(LoongArch_model *model) ++{ ++ LoongArch_model *copy; ++ ++ copy = g_new0(LoongArch_model, 1); ++ copy->name = g_strdup(model->name); ++ ++ if (LoongArchDataCopy(©->data, &model->data) < 0) ++ goto error; ++ ++ copy->vendor = model->vendor; ++ ++ return copy; ++ ++ error: ++ LoongArchModelFree(copy); ++ return NULL; ++} ++ ++static LoongArch_model * ++LoongArchModelFind(LoongArch_map *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 LoongArch_model * ++LoongArchModelFindPrid(LoongArch_map *map, ++ uint32_t prid) ++{ ++ size_t i; ++ size_t j; ++ ++ for (i = 0; i < map->nmodels; i++) { ++ LoongArch_model *model = map->models[i]; ++ for (j = 0; j < model->data.len; j++) { ++ if ((prid & model->data.prid[j].mask) == model->data.prid[j].value) ++ return model; ++ } ++ } ++ ++ return NULL; ++} ++ ++static LoongArch_model * ++LoongArchModelFromCPU(const virCPUDef *cpu, ++ LoongArch_map *map) ++{ ++ LoongArch_model *model; ++ ++ if (!cpu->model) { ++ virReportError(VIR_ERR_INVALID_ARG, "%s", ++ _("no CPU model specified")); ++ return NULL; ++ } ++ ++ if (!(model = LoongArchModelFind(map, cpu->model))) { ++ virReportError(VIR_ERR_INTERNAL_ERROR, ++ _("Unknown CPU model %s"), cpu->model); ++ return NULL; ++ } ++ ++ return LoongArchModelCopy(model); ++} ++ ++static void ++LoongArchMapFree(LoongArch_map *map) ++{ ++ size_t i; ++ ++ if (!map) ++ return; ++ ++ for (i = 0; i < map->nmodels; i++) ++ LoongArchModelFree(map->models[i]); ++ g_free(map->models); ++ ++ for (i = 0; i < map->nvendors; i++) ++ LoongArchVendorFree(map->vendors[i]); ++ g_free(map->vendors); ++ ++ g_free(map); ++} ++ ++static int ++LoongArchVendorParse(xmlXPathContextPtr ctxt ATTRIBUTE_UNUSED, ++ const char *name, ++ void *data) ++{ ++ LoongArch_map *map = data; ++ LoongArch_vendor *vendor; ++ int ret = -1; ++ ++ vendor = g_new0(LoongArch_vendor, 1); ++ vendor->name = g_strdup(name); ++ ++ if (LoongArchVendorFind(map, vendor->name)) { ++ virReportError(VIR_ERR_INTERNAL_ERROR, ++ _("CPU vendor %s already defined"), vendor->name); ++ goto cleanup; ++ } ++ ++ VIR_APPEND_ELEMENT(map->vendors, map->nvendors, vendor); ++ ret = 0; ++ ++ cleanup: ++ LoongArchVendorFree(vendor); ++ return ret; ++} ++ ++static int ++LoongArchModelParse(xmlXPathContextPtr ctxt, ++ const char *name, ++ void *data) ++{ ++ LoongArch_map *map = data; ++ LoongArch_model *model; ++ xmlNodePtr *nodes = NULL; ++ char *vendor = NULL; ++ unsigned long prid; ++ size_t i; ++ int n; ++ int ret = -1; ++ ++ model = g_new0(LoongArch_model, 1); ++ model->name = g_strdup(name); ++ ++ if (LoongArchModelFind(map, model->name)) { ++ virReportError(VIR_ERR_INTERNAL_ERROR, ++ _("CPU model %s already defined"), model->name); ++ goto cleanup; ++ } ++ ++ if (virXPathBoolean("boolean(./vendor)", ctxt)) { ++ vendor = virXPathString("string(./vendor/@name)", ctxt); ++ if (!vendor) { ++ virReportError(VIR_ERR_INTERNAL_ERROR, ++ _("Invalid vendor element in CPU model %s"), ++ model->name); ++ goto cleanup; ++ } ++ ++ if (!(model->vendor = LoongArchVendorFind(map, vendor))) { ++ virReportError(VIR_ERR_INTERNAL_ERROR, ++ _("Unknown vendor %s referenced by CPU model %s"), ++ vendor, model->name); ++ goto cleanup; ++ } ++ } ++ ++ if ((n = virXPathNodeSet("./prid", ctxt, &nodes)) <= 0) { ++ virReportError(VIR_ERR_INTERNAL_ERROR, ++ _("Missing Prid information for CPU model %s"), ++ model->name); ++ goto cleanup; ++ } ++ ++ model->data.prid = g_new0(virCPULoongArchPrid, n); ++ model->data.len = n; ++ ++ for (i = 0; i < n; i++) { ++ ctxt->node = nodes[i]; ++ ++ if (virXPathULongHex("string(./@value)", ctxt, &prid) < 0) { ++ virReportError(VIR_ERR_INTERNAL_ERROR, ++ _("Missing or invalid Prid value in CPU model %s"), ++ model->name); ++ goto cleanup; ++ } ++ model->data.prid[i].value = prid; ++ ++ if (virXPathULongHex("string(./@mask)", ctxt, &prid) < 0) { ++ virReportError(VIR_ERR_INTERNAL_ERROR, ++ _("Missing or invalid PVR mask in CPU model %s"), ++ model->name); ++ goto cleanup; ++ } ++ model->data.prid[i].mask = prid; ++ } ++ ++ VIR_APPEND_ELEMENT(map->models, map->nmodels, model); ++ ret = 0; ++ ++ cleanup: ++ LoongArchModelFree(model); ++ g_free(vendor); ++ g_free(nodes); ++ return ret; ++} ++ ++static LoongArch_map * ++LoongArchLoadMap(void) ++{ ++ LoongArch_map *map; ++ ++ map = g_new0(LoongArch_map, 1); ++ if (cpuMapLoad("loongarch64", LoongArchVendorParse, NULL, LoongArchModelParse, map) < 0) ++ goto error; ++ ++ return map; ++ ++ error: ++ LoongArchMapFree(map); ++ return NULL; ++} ++ ++static virCPUData * ++LoongArchMakeCPUData(virArch arch, ++ virCPULoongArchData *data) ++{ ++ virCPUData *cpuData; ++ ++ cpuData = g_new0(virCPUData, 1); ++ cpuData->arch = arch; ++ ++ if (LoongArchDataCopy(&cpuData->data.loongarch, data) < 0) ++ g_free(cpuData); ++ ++ return cpuData; ++} ++ ++static virCPUCompareResult ++LoongArchCompute(virCPUDef *host, ++ const virCPUDef *other, ++ virCPUData *guestData, ++ char **message) ++{ ++ LoongArch_map *map = NULL; ++ LoongArch_model *host_model = NULL; ++ LoongArch_model *guest_model = NULL; ++ virCPUDef *cpu = NULL; ++ virCPUCompareResult ret = VIR_CPU_COMPARE_ERROR; ++ virArch arch; ++ size_t i; ++ ++ /* Ensure existing configurations are handled correctly */ ++ if (!(cpu = virCPUDefCopy(other))) ++ goto cleanup; ++ ++ if (cpu->arch != VIR_ARCH_NONE) { ++ bool found = false; ++ ++ for (i = 0; i < G_N_ELEMENTS(archs); i++) { ++ if (archs[i] == cpu->arch) { ++ found = true; ++ break; ++ } ++ } ++ ++ if (!found) { ++ VIR_DEBUG("CPU arch %s does not match host arch", ++ virArchToString(cpu->arch)); ++ if (message) { ++ *message = g_strdup_printf(_("CPU arch %s does not match host arch"), ++ virArchToString(cpu->arch)); ++ } ++ ret = VIR_CPU_COMPARE_INCOMPATIBLE; ++ goto cleanup; ++ } ++ arch = cpu->arch; ++ } else { ++ arch = host->arch; ++ } ++ ++ if (cpu->vendor && ++ (!host->vendor || STRNEQ(cpu->vendor, host->vendor))) { ++ VIR_DEBUG("host CPU vendor does not match required CPU vendor %s", ++ cpu->vendor); ++ if (message) { ++ *message = g_strdup_printf(_("host CPU vendor does not match required " ++ "CPU vendor %s"), cpu->vendor); ++ } ++ ret = VIR_CPU_COMPARE_INCOMPATIBLE; ++ goto cleanup; ++ } ++ ++ if (!(map = LoongArchLoadMap())) ++ goto cleanup; ++ ++ /* Host CPU information */ ++ if (!(host_model = LoongArchModelFromCPU(host, map))) ++ goto cleanup; ++ ++ if (cpu->type == VIR_CPU_TYPE_GUEST) { ++ /* Guest CPU information */ ++ switch (cpu->mode) { ++ case VIR_CPU_MODE_HOST_MODEL: ++ case VIR_CPU_MODE_HOST_PASSTHROUGH: ++ /* host-model and host-passthrough: ++ * the guest CPU is the same as the host */ ++ guest_model = LoongArchModelCopy(host_model); ++ break; ++ ++ case VIR_CPU_MODE_CUSTOM: ++ /* custom: ++ * look up guest CPU information */ ++ guest_model = LoongArchModelFromCPU(cpu, map); ++ break; ++ } ++ } else { ++ /* Other host CPU information */ ++ guest_model = LoongArchModelFromCPU(cpu, map); ++ } ++ ++ if (!guest_model) ++ goto cleanup; ++ ++ if (STRNEQ(guest_model->name, host_model->name)) { ++ VIR_DEBUG("host CPU model does not match required CPU model %s", ++ guest_model->name); ++ if (message) { ++ *message = g_strdup_printf(_("host CPU model does not match required " ++ "CPU model %s"),guest_model->name); ++ } ++ ret = VIR_CPU_COMPARE_INCOMPATIBLE; ++ goto cleanup; ++ } ++ ++ if (guestData) ++ if (!(guestData = LoongArchMakeCPUData(arch, &guest_model->data))) ++ goto cleanup; ++ ++ ret = VIR_CPU_COMPARE_IDENTICAL; ++ ++ cleanup: ++ virCPUDefFree(cpu); ++ LoongArchMapFree(map); ++ LoongArchModelFree(host_model); ++ LoongArchModelFree(guest_model); ++ return ret; ++} ++ ++static virCPUCompareResult ++virCPULoongArchCompare(virCPUDef *host, ++ virCPUDef *cpu, ++ bool failIncompatible) ++{ ++ virCPUCompareResult ret; ++ char *message = NULL; ++ ++ if (!host || !host->model) { ++ if (failIncompatible) { ++ virReportError(VIR_ERR_CPU_INCOMPATIBLE, "%s", ++ _("unknown host CPU")); ++ } else { ++ VIR_WARN("unknown host CPU"); ++ ret = VIR_CPU_COMPARE_INCOMPATIBLE; ++ } ++ return -1; ++ } ++ ++ ret = LoongArchCompute(host, cpu, NULL, &message); ++ ++ if (failIncompatible && ret == VIR_CPU_COMPARE_INCOMPATIBLE) { ++ ret = VIR_CPU_COMPARE_ERROR; ++ if (message) { ++ virReportError(VIR_ERR_CPU_INCOMPATIBLE, "%s", message); ++ } else { ++ virReportError(VIR_ERR_CPU_INCOMPATIBLE, NULL); ++ } ++ } ++ g_free(message); ++ ++ return ret; ++} ++ ++static int ++LoongArchDriverDecode(virCPUDef *cpu, ++ const virCPUData *data, ++ virDomainCapsCPUModels *models) ++{ ++ int ret = -1; ++ LoongArch_map *map; ++ LoongArch_model *model; ++ ++ if (!data || !(map = LoongArchLoadMap())) ++ return -1; ++ ++ if (!(model = LoongArchModelFindPrid(map, data->data.loongarch.prid[0].value))) { ++ virReportError(VIR_ERR_OPERATION_FAILED, ++ _("Cannot find CPU model with Prid 0x%08x"), ++ data->data.loongarch.prid[0].value); ++ goto cleanup; ++ } ++ ++ if (!virCPUModelIsAllowed(model->name, models)) { ++ virReportError(VIR_ERR_CONFIG_UNSUPPORTED, ++ _("CPU model %s is not supported by hypervisor"), ++ model->name); ++ goto cleanup; ++ } ++ ++ cpu->model = g_strdup(model->name); ++ if (model->vendor) { ++ cpu->vendor = g_strdup(model->vendor->name); ++ } ++ ret = 0; ++ ++ cleanup: ++ LoongArchMapFree(map); ++ ++ return ret; ++} ++ ++static void ++virCPULoongArchDataFree(virCPUData *data) ++{ ++ if (!data) ++ return; ++ ++ LoongArchDataClear(&data->data.loongarch); ++ g_free(data); ++} ++ ++static int virCPULoongArchGetHostPRID(void) ++{ ++ return 0x14c010; ++} ++ ++static int ++virCPULoongArchGetHost(virCPUDef *cpu, ++ virDomainCapsCPUModels *models) ++{ ++ virCPUData *cpuData = NULL; ++ virCPULoongArchData *data; ++ int ret = -1; ++ ++ if (!(cpuData = virCPUDataNew(archs[0]))) ++ goto cleanup; ++ ++ data = &cpuData->data.loongarch; ++ ++ data->prid = g_new0(virCPULoongArchPrid, 1); ++ data->len = 1; ++ ++ data->prid[0].value = virCPULoongArchGetHostPRID(); ++ data->prid[0].mask = 0xffff00ul; ++ ++ ret = LoongArchDriverDecode(cpu, cpuData, models); ++ ++ cleanup: ++ virCPULoongArchDataFree(cpuData); ++ return ret; ++} ++ ++ ++static int ++virCPULoongArchUpdate(virCPUDef *guest, ++ const virCPUDef *host, ++ bool relative) ++{ ++ /* ++ * - host-passthrough doesn't even get here ++ * - host-model is used for host CPU running in a compatibility mode and ++ * it needs to remain unchanged ++ * - custom doesn't support any optional features, there's nothing to ++ * update ++ */ ++ VIR_DEBUG("host model %s, if relatived %d",host->model, relative); ++ if (guest->mode == VIR_CPU_MODE_CUSTOM) ++ guest->match = VIR_CPU_MATCH_EXACT; ++ ++ return 0; ++} ++ ++static virCPUDef * ++LoongArchDriverBaseline(virCPUDef **cpus, ++ unsigned int ncpus, ++ virDomainCapsCPUModels *models, ++ const char **features, ++ bool migratable) ++{ ++ LoongArch_map *map; ++ LoongArch_model *model; ++ LoongArch_vendor *vendor = NULL; ++ virCPUDef *cpu = NULL; ++ size_t i; ++ if (models && *features) { ++ VIR_DEBUG("migratable %d features %s",migratable, *features); ++ } ++ if (!(map = LoongArchLoadMap())) ++ goto error; ++ ++ if (!(model = LoongArchModelFind(map, cpus[0]->model))) { ++ virReportError(VIR_ERR_INTERNAL_ERROR, ++ _("Unknown CPU model %s"), cpus[0]->model); ++ goto error; ++ } ++ ++ for (i = 0; i < ncpus; i++) { ++ LoongArch_vendor *vnd; ++ ++ if (STRNEQ(cpus[i]->model, model->name)) { ++ virReportError(VIR_ERR_OPERATION_FAILED, "%s", ++ _("CPUs are incompatible")); ++ goto error; ++ } ++ ++ if (!cpus[i]->vendor) ++ continue; ++ ++ if (!(vnd = LoongArchVendorFind(map, cpus[i]->vendor))) { ++ virReportError(VIR_ERR_OPERATION_FAILED, ++ _("Unknown CPU vendor %s"), cpus[i]->vendor); ++ goto error; ++ } ++ ++ if (model->vendor) { ++ if (model->vendor != vnd) { ++ virReportError(VIR_ERR_OPERATION_FAILED, ++ _("CPU vendor %s of model %s differs from " ++ "vendor %s"), ++ model->vendor->name, model->name, ++ vnd->name); ++ goto error; ++ } ++ } else if (vendor) { ++ if (vendor != vnd) { ++ virReportError(VIR_ERR_OPERATION_FAILED, "%s", ++ _("CPU vendors do not match")); ++ goto error; ++ } ++ } else { ++ vendor = vnd; ++ } ++ } ++ ++ cpu = g_new0(virCPUDef ,1); ++ cpu->model = g_strdup(model->name); ++ if (vendor) { ++ cpu->vendor = g_strdup(vendor->name); ++ } ++ cpu->type = VIR_CPU_TYPE_GUEST; ++ cpu->match = VIR_CPU_MATCH_EXACT; ++ cpu->fallback = VIR_CPU_FALLBACK_FORBID; ++ ++ cleanup: ++ LoongArchMapFree(map); ++ ++ return cpu; ++ ++ error: ++ virCPUDefFree(cpu); ++ cpu = NULL; ++ goto cleanup; ++} ++ ++static int ++virCPULoongArchDriverGetModels(char ***models) ++{ ++ LoongArch_map *map; ++ size_t i; ++ int ret = -1; ++ ++ if (!(map = LoongArchLoadMap())) ++ 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: ++ LoongArchMapFree(map); ++ return ret; ++ ++ error: ++ if (models) { ++ g_strfreev(*models); ++ *models = NULL; ++ } ++ goto cleanup; ++} ++ ++struct cpuArchDriver cpuDriverLoongArch = { ++ .name = "LoongArch", ++ .arch = archs, ++ .narch = G_N_ELEMENTS(archs), ++ .compare = virCPULoongArchCompare, ++ .decode = LoongArchDriverDecode, ++ .encode = NULL, ++ .dataFree = virCPULoongArchDataFree, ++ .getHost = virCPULoongArchGetHost, ++ .baseline = LoongArchDriverBaseline, ++ .update = virCPULoongArchUpdate, ++ .getModels = virCPULoongArchDriverGetModels, ++}; +diff --git a/src/cpu/cpu_loongarch.h b/src/cpu/cpu_loongarch.h +new file mode 100644 +index 0000000000..1fde3b5162 +--- /dev/null ++++ b/src/cpu/cpu_loongarch.h +@@ -0,0 +1,28 @@ ++/* ++ * cpu_loongarch.h: CPU driver for 64-bit LOONGARCH CPUs ++ * ++ * Copyright (C) Copyright (C) IBM Corporation, 2010 ++ * ++ * 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 ++ * . ++ */ ++ ++#ifndef __VIR_CPU_LOONGARCH_H__ ++# define __VIR_CPU_LOONGARCH_H__ ++ ++# include "cpu.h" ++ ++extern struct cpuArchDriver cpuDriverLoongArch; ++ ++#endif /* __VIR_CPU_LOONGARCH_H__ */ +diff --git a/src/cpu/cpu_loongarch_data.h b/src/cpu/cpu_loongarch_data.h +new file mode 100644 +index 0000000000..1a759e7d16 +--- /dev/null ++++ b/src/cpu/cpu_loongarch_data.h +@@ -0,0 +1,40 @@ ++/* ++ * cpu_loongarch_data.h: 64-bit LOONGARCH CPU specific data ++ * ++ * Copyright (C) 2012 IBM Corporation. ++ * ++ * 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 ++ * . ++ */ ++ ++#ifndef __VIR_CPU_LOONGARCH_DATA_H__ ++# define __VIR_CPU_LOONGARCH_DATA_H__ ++ ++# include ++ ++typedef struct _virCPULoongArchPrid virCPULoongArchPrid; ++struct _virCPULoongArchPrid { ++ uint32_t value; ++ uint32_t mask; ++}; ++ ++# define VIR_CPU_LOONGARCH_DATA_INIT { 0 } ++ ++typedef struct _virCPULoongArchData virCPULoongArchData; ++struct _virCPULoongArchData { ++ size_t len; ++ virCPULoongArchPrid *prid; ++}; ++ ++#endif /* __VIR_CPU_MIPS64_DATA_H__ */ +diff --git a/src/cpu/meson.build b/src/cpu/meson.build +index b4ad95e46d..ad2f859fd8 100644 +--- a/src/cpu/meson.build ++++ b/src/cpu/meson.build +@@ -5,6 +5,7 @@ cpu_sources = [ + 'cpu_ppc64.c', + 'cpu_s390.c', + 'cpu_x86.c', ++ 'cpu_loongarch.c', + ] + + cpu_lib = static_library( +diff --git a/src/cpu_map/index.xml b/src/cpu_map/index.xml +index ffe1fa91e5..d302de396a 100644 +--- a/src/cpu_map/index.xml ++++ b/src/cpu_map/index.xml +@@ -110,4 +110,9 @@ + + + ++ ++ ++ ++ ++ + +diff --git a/src/cpu_map/loongarch_vendors.xml b/src/cpu_map/loongarch_vendors.xml +new file mode 100644 +index 0000000000..c744654617 +--- /dev/null ++++ b/src/cpu_map/loongarch_vendors.xml +@@ -0,0 +1,3 @@ ++ ++ ++ +diff --git a/src/cpu_map/ls_3a5000.xml b/src/cpu_map/ls_3a5000.xml +new file mode 100644 +index 0000000000..f6fe3386f7 +--- /dev/null ++++ b/src/cpu_map/ls_3a5000.xml +@@ -0,0 +1,6 @@ ++ ++ ++ ++ ++ ++ +diff --git a/src/cpu_map/meson.build b/src/cpu_map/meson.build +index 013fc62a02..9657c5164e 100644 +--- a/src/cpu_map/meson.build ++++ b/src/cpu_map/meson.build +@@ -77,6 +77,8 @@ cpumap_data = [ + 'x86_vendors.xml', + 'x86_Westmere-IBRS.xml', + 'x86_Westmere.xml', ++ 'loongarch_vendors.xml', ++ 'ls_3a5000.xml', + ] + + install_data(cpumap_data, install_dir: pkgdatadir / 'cpu_map') +diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c +index c4f7db55c8..75668c6451 100644 +--- a/src/qemu/qemu_capabilities.c ++++ b/src/qemu/qemu_capabilities.c +@@ -2073,6 +2073,9 @@ bool virQEMUCapsHasPCIMultiBus(const virDomainDef *def) + if (ARCH_IS_X86(def->os.arch)) + return true; + ++ if (STRPREFIX(def->os.machine,"loongson7a")) ++ return true; ++ + /* PPC supports multibus on all machine types which have pci since qemu-2.0.0 */ + if (def->os.arch == VIR_ARCH_PPC || + ARCH_IS_PPC64(def->os.arch)) { +@@ -2690,6 +2693,7 @@ static const char *preferredMachines[] = + + "malta", /* VIR_ARCH_MIPS64 */ + "malta", /* VIR_ARCH_MIPS64EL */ ++ "loongson7a", /* VIR_ARCH_LOONGARCH64 */ + "or1k-sim", /* VIR_ARCH_OR32 */ + NULL, /* VIR_ARCH_PARISC (no QEMU impl) */ + NULL, /* VIR_ARCH_PARISC64 (no QEMU impl) */ +@@ -5115,6 +5119,7 @@ virQEMUCapsInitQMPBasicArch(virQEMUCaps *qemuCaps) + case VIR_ARCH_MIPSEL: + case VIR_ARCH_MIPS64: + case VIR_ARCH_MIPS64EL: ++ case VIR_ARCH_LOONGARCH64: + case VIR_ARCH_OR32: + case VIR_ARCH_PARISC: + case VIR_ARCH_PARISC64: +diff --git a/src/qemu/qemu_conf.c b/src/qemu/qemu_conf.c +index a0b8076d6b..8cd03261ac 100644 +--- a/src/qemu/qemu_conf.c ++++ b/src/qemu/qemu_conf.c +@@ -101,7 +101,9 @@ qemuDriverUnlock(virQEMUDriver *driver) + "/usr/share/OVMF/OVMF_CODE.fd:/usr/share/OVMF/OVMF_VARS.fd:" \ + "/usr/share/OVMF/OVMF_CODE.secboot.fd:/usr/share/OVMF/OVMF_VARS.fd:" \ + "/usr/share/AAVMF/AAVMF_CODE.fd:/usr/share/AAVMF/AAVMF_VARS.fd:" \ +- "/usr/share/AAVMF/AAVMF32_CODE.fd:/usr/share/AAVMF/AAVMF32_VARS.fd" ++ "/usr/share/AAVMF/AAVMF32_CODE.fd:/usr/share/AAVMF/AAVMF32_VARS.fd:" \ ++ "/usr/share/qemu-kvm/loongarch_bios.bin:/usr/share/qemu-kvm/loongarch_bios.bin" ++ + #endif + + +diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c +index 40fe9985e6..814d8cb67d 100644 +--- a/src/qemu/qemu_domain.c ++++ b/src/qemu/qemu_domain.c +@@ -3668,6 +3668,10 @@ qemuDomainDefAddDefaultDevices(virQEMUDriver *driver, + addPCIeRoot = virQEMUCapsGet(qemuCaps, QEMU_CAPS_OBJECT_GPEX); + break; + ++ case VIR_ARCH_LOONGARCH64: ++ addPCIeRoot = true; ++ break; ++ + case VIR_ARCH_PPC64: + case VIR_ARCH_PPC64LE: + addPCIRoot = true; +@@ -5065,6 +5069,11 @@ 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 (ARCH_IS_LOONGARCH(def->os.arch)) { ++ if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE_QEMU_XHCI)) ++ 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; + } + } + /* forbid usb model 'qusb1' and 'qusb2' in this kind of hyperviosr */ +@@ -8324,6 +8333,13 @@ qemuDomainDefCheckABIStability(virQEMUDriver *driver, + } + + ++bool ++qemuDomainIsLoongson(const virDomainDef *def) ++{ ++ return (STRPREFIX(def->os.machine,"loongson3a") || STRPREFIX(def->os.machine,"loongson7a")); ++} ++ ++ + bool + qemuDomainCheckABIStability(virQEMUDriver *driver, + virDomainObj *vm, +@@ -8664,7 +8680,9 @@ qemuDomainMachineHasBuiltinIDE(const char *machine, + return qemuDomainMachineIsI440FX(machine, arch) || + STREQ(machine, "malta") || + STREQ(machine, "sun4u") || +- STREQ(machine, "g3beige"); ++ STREQ(machine, "g3beige") || ++ STREQ(machine, "loongson3a") || ++ STREQ(machine, "loongson7a"); + } + + +diff --git a/src/qemu/qemu_domain.h b/src/qemu/qemu_domain.h +index e5046367e3..57f1f97348 100644 +--- a/src/qemu/qemu_domain.h ++++ b/src/qemu/qemu_domain.h +@@ -770,6 +770,7 @@ bool qemuDomainIsS390CCW(const virDomainDef *def); + bool qemuDomainIsARMVirt(const virDomainDef *def); + bool qemuDomainIsRISCVVirt(const virDomainDef *def); + bool qemuDomainIsPSeries(const virDomainDef *def); ++bool qemuDomainIsLoongson(const virDomainDef *def); + bool qemuDomainHasPCIRoot(const virDomainDef *def); + bool qemuDomainHasPCIeRoot(const virDomainDef *def); + bool qemuDomainHasBuiltinIDE(const virDomainDef *def); +diff --git a/src/qemu/qemu_domain_address.c b/src/qemu/qemu_domain_address.c +index 18fc34d049..c3fac1c33b 100644 +--- a/src/qemu/qemu_domain_address.c ++++ b/src/qemu/qemu_domain_address.c +@@ -2026,6 +2026,59 @@ qemuDomainValidateDevicePCISlotsQ35(virDomainDef *def, + } + + ++static int ++qemuDomainValidateDevicePCISlotsLoongson(virDomainDef *def, ++ virDomainPCIAddressSet *addrs) ++{ ++ int ret = -1; ++ virPCIDeviceAddress tmp_addr; ++ char *addrStr = NULL; ++ virDomainPCIConnectFlags flags = (VIR_PCI_CONNECT_AUTOASSIGN ++ | VIR_PCI_CONNECT_TYPE_PCI_DEVICE); ++ ++ if (addrs->nbuses) { ++ memset(&tmp_addr, 0, sizeof(tmp_addr)); ++ tmp_addr.slot = 1; ++ /* pci-ohci at 00:01.0 */ ++ if (virDomainPCIAddressReserveAddr(addrs, &tmp_addr, flags, 0) < 0) ++ goto cleanup; ++ } ++ ++ if (def->nvideos > 0 && ++ def->videos[0]->type != VIR_DOMAIN_VIDEO_TYPE_NONE && ++ def->videos[0]->type != VIR_DOMAIN_VIDEO_TYPE_RAMFB) { ++ /*reserve slot 2 for vga device */ ++ virDomainVideoDef *primaryVideo = def->videos[0]; ++ ++ if (virDeviceInfoPCIAddressIsWanted(&primaryVideo->info)) { ++ memset(&tmp_addr, 0, sizeof(tmp_addr)); ++ tmp_addr.slot = 2; ++ ++ if (!(addrStr = virPCIDeviceAddressAsString(&tmp_addr))) ++ goto cleanup; ++ if (!virDomainPCIAddressValidate(addrs, &tmp_addr, ++ addrStr, flags, true)) ++ goto cleanup; ++ ++ if (virDomainPCIAddressSlotInUse(addrs, &tmp_addr)) { ++ if (qemuDomainPCIAddressReserveNextAddr(addrs, ++ &primaryVideo->info) < 0) ++ goto cleanup; ++ } else { ++ if (virDomainPCIAddressReserveAddr(addrs, &tmp_addr, flags, 0) < 0) ++ goto cleanup; ++ primaryVideo->info.addr.pci = tmp_addr; ++ primaryVideo->info.type = VIR_DOMAIN_DEVICE_ADDRESS_TYPE_PCI; ++ } ++ } ++ } ++ ret = 0; ++ cleanup: ++ VIR_FREE(addrStr); ++ return ret; ++} ++ ++ + static int + qemuDomainValidateDevicePCISlotsChipsets(virDomainDef *def, + virDomainPCIAddressSet *addrs) +@@ -2040,6 +2093,11 @@ qemuDomainValidateDevicePCISlotsChipsets(virDomainDef *def, + return -1; + } + ++ if (qemuDomainIsLoongson(def) && ++ qemuDomainValidateDevicePCISlotsLoongson(def, addrs) < 0) { ++ return -1; ++ } ++ + return 0; + } + +diff --git a/src/qemu/qemu_validate.c b/src/qemu/qemu_validate.c +index 7bc14293d6..7d01d31aaf 100644 +--- a/src/qemu/qemu_validate.c ++++ b/src/qemu/qemu_validate.c +@@ -186,7 +186,8 @@ qemuValidateDomainDefFeatures(const virDomainDef *def, + switch ((virDomainFeature) i) { + case VIR_DOMAIN_FEATURE_IOAPIC: + if (def->features[i] != VIR_DOMAIN_IOAPIC_NONE) { +- if (!ARCH_IS_X86(def->os.arch)) { ++ if (!(ARCH_IS_X86(def->os.arch) ++ || ARCH_IS_LOONGARCH(def->os.arch))) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("The '%s' feature is not supported for " + "architecture '%s' or machine type '%s'"), +diff --git a/src/util/virarch.c b/src/util/virarch.c +index 2134dd6a9d..9f40a7110c 100644 +--- a/src/util/virarch.c ++++ b/src/util/virarch.c +@@ -59,6 +59,7 @@ static const struct virArchData { + + { "mips64", 64, VIR_ARCH_BIG_ENDIAN }, + { "mips64el", 64, VIR_ARCH_LITTLE_ENDIAN }, ++ { "loongarch64", 64, VIR_ARCH_LITTLE_ENDIAN }, + { "openrisc", 32, VIR_ARCH_BIG_ENDIAN }, + { "parisc", 32, VIR_ARCH_BIG_ENDIAN }, + { "parisc64", 64, VIR_ARCH_BIG_ENDIAN }, +@@ -222,6 +223,8 @@ virArch virArchFromHost(void) + arch = VIR_ARCH_X86_64; + } else if (STREQ(ut.machine, "arm64")) { + arch = VIR_ARCH_AARCH64; ++ } else if (STREQ(ut.machine, "loongarch64")) { ++ arch = VIR_ARCH_LOONGARCH64; + } else { + /* Otherwise assume the canonical name */ + if ((arch = virArchFromString(ut.machine)) == VIR_ARCH_NONE) { +diff --git a/src/util/virarch.h b/src/util/virarch.h +index 528f84f8a5..7d396f2fff 100644 +--- a/src/util/virarch.h ++++ b/src/util/virarch.h +@@ -44,6 +44,7 @@ typedef enum { + + VIR_ARCH_MIPS64, /* MIPS 64 BE https://en.wikipedia.org/wiki/MIPS_architecture */ + VIR_ARCH_MIPS64EL, /* MIPS 64 LE https://en.wikipedia.org/wiki/MIPS_architecture */ ++ VIR_ARCH_LOONGARCH64, + VIR_ARCH_OR32, /* OpenRisc 32 BE https://en.wikipedia.org/wiki/OpenRISC#QEMU_support */ + VIR_ARCH_PARISC, /* PA-Risc 32 BE https://en.wikipedia.org/wiki/PA-RISC */ + VIR_ARCH_PARISC64, /* PA-Risc 64 BE https://en.wikipedia.org/wiki/PA-RISC */ +@@ -98,6 +99,8 @@ typedef enum { + #define ARCH_IS_MIPS64(arch) ((arch) == VIR_ARCH_MIPS64 ||\ + (arch) == VIR_ARCH_MIPS64EL) + ++#define ARCH_IS_LOONGARCH(arch) ((arch) == VIR_ARCH_LOONGARCH64) ++ + typedef enum { + VIR_ARCH_LITTLE_ENDIAN, + VIR_ARCH_BIG_ENDIAN, +diff --git a/src/util/virhostcpu.c b/src/util/virhostcpu.c +index 35f41daef2..137796ea07 100644 +--- a/src/util/virhostcpu.c ++++ b/src/util/virhostcpu.c +@@ -546,7 +546,7 @@ virHostCPUParseFrequency(FILE *cpuinfo, + char line[1024]; + + /* No sensible way to retrieve CPU frequency */ +- if (ARCH_IS_ARM(arch)) ++ if (ARCH_IS_ARM(arch) || ARCH_IS_LOONGARCH(arch)) + return 0; + + if (ARCH_IS_X86(arch)) +diff --git a/src/util/virsysinfo.c b/src/util/virsysinfo.c +index af9e03c5ac..9577cf1910 100644 +--- a/src/util/virsysinfo.c ++++ b/src/util/virsysinfo.c +@@ -1247,7 +1247,7 @@ virSysinfoRead(void) + { + #if defined(__powerpc__) + return virSysinfoReadPPC(); +-#elif defined(__arm__) || defined(__aarch64__) ++#elif defined(__arm__) || defined(__aarch64__) || defined(__loongarch__) + return virSysinfoReadARM(); + #elif defined(__s390__) || defined(__s390x__) + return virSysinfoReadS390(); +-- +2.27.0 + diff --git a/libvirt.spec b/libvirt.spec index 3d6c119..8a7d60d 100644 --- a/libvirt.spec +++ b/libvirt.spec @@ -3,19 +3,20 @@ # 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.1 %define min_rhel 8 %define min_fedora 33 -%define arches_qemu_kvm %{ix86} x86_64 %{power64} %{arm} aarch64 s390x +%define arches_qemu_kvm %{ix86} x86_64 %{power64} %{arm} aarch64 s390x loongarch64 %if 0%{?rhel} %if 0%{?rhel} > 8 - %define arches_qemu_kvm x86_64 aarch64 s390x + %define arches_qemu_kvm x86_64 aarch64 s390x loongarch64 %else - %define arches_qemu_kvm x86_64 %{power64} aarch64 s390x + %define arches_qemu_kvm x86_64 %{power64} aarch64 s390x loongarch64 %endif %endif -%define arches_64bit x86_64 %{power64} aarch64 s390x riscv64 +%define arches_64bit x86_64 %{power64} aarch64 s390x riscv64 loongarch64 %define arches_x86 %{ix86} x86_64 %define arches_systemtap_64bit %{arches_64bit} @@ -23,9 +24,9 @@ %define arches_xen %{arches_x86} aarch64 %define arches_vbox %{arches_x86} %define arches_ceph %{arches_64bit} -%define arches_zfs %{arches_x86} %{power64} %{arm} -%define arches_numactl %{arches_x86} %{power64} aarch64 s390x -%define arches_numad %{arches_x86} %{power64} aarch64 +%define arches_zfs %{arches_x86} %{power64} %{arm} loongarch64 +%define arches_numactl %{arches_x86} %{power64} aarch64 s390x loongarch64 +%define arches_numad %{arches_x86} %{power64} aarch64 loongarch64 # The hypervisor drivers that run in libvirtd %define with_qemu 0%{!?_without_qemu:1} @@ -210,7 +211,7 @@ Summary: Library providing a simple virtualization API Name: libvirt Version: 8.0.0 -Release: 5.4%{?dist}%{?extra_release} +Release: 5.4%{anolis_release}%{?dist}%{?extra_release} License: LGPLv2+ URL: https://libvirt.org/ @@ -262,6 +263,7 @@ Patch39: libvirt-qemu_migration-Restore-original-memory-locking-limit.patch Patch40: libvirt-Add-VIR_MIGRATE_ZEROCOPY-flag.patch Patch41: libvirt-virsh-Add-support-for-VIR_MIGRATE_ZEROCOPY-flag.patch Patch42: libvirt-qemu_migration-Implement-VIR_MIGRATE_ZEROCOPY-flag.patch +Patch1000: libvirt-Add-loongarch-support.patch Requires: libvirt-daemon = %{version}-%{release} Requires: libvirt-daemon-config-network = %{version}-%{release} @@ -2135,6 +2137,9 @@ exit 0 %changelog +* Thu Sep 15 2022 zhaotianrui - 8.0.0-5.4.0.1 +- Add loongarch support + * Thu Aug 18 2022 Jiri Denemark - 8.0.0-5.4.el8 - conf: Move virDomainObj::originalMemlock into qemuDomainObjPrivate (rhbz#2117272) - qemu_domain: Format qemuDomainObjPrivate::originalMemlock (rhbz#2117272) -- Gitee