commit 29372b3f1094f320308dd0a5bca36bf72d0af39d Author: overweight <5324761+overweight@user.noreply.gitee.com> Date: Mon Sep 30 10:58:53 2019 -0400 Package init diff --git a/libvirt-5.5.0.tar.xz b/libvirt-5.5.0.tar.xz new file mode 100644 index 0000000..444f704 Binary files /dev/null and b/libvirt-5.5.0.tar.xz differ diff --git a/libvirt-Revert-conf-Remove-volOptions-for-VIR_STORAGE_POOL_R.patch b/libvirt-Revert-conf-Remove-volOptions-for-VIR_STORAGE_POOL_R.patch new file mode 100644 index 0000000..a97d2ff --- /dev/null +++ b/libvirt-Revert-conf-Remove-volOptions-for-VIR_STORAGE_POOL_R.patch @@ -0,0 +1,81 @@ +From c27fda8374562a9b6061e18f8c9ba78ae9df2c08 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?J=C3=A1n=20Tomko?= +Date: Fri, 12 Jul 2019 16:13:17 +0200 +Subject: [PATCH] Revert "conf: Remove volOptions for VIR_STORAGE_POOL_RBD" +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +This reverts commit 035db37394ad11a39d47f8bd2b6a8a2734283cbf + +Even though we only allow using RBD with raw volumes, +removing the options and the default format causes our +parser not to fill out the volume format and the backend code +rejects creating a non-raw volume. + +Re-introduce the volume options to fix volume creation while +erroring out on requests to use non-raw formats. + +https://bugzilla.redhat.com/show_bug.cgi?id=1724065 + +Signed-off-by: Ján Tomko +Reviewed-by: Daniel P. Berrangé +(cherry-picked from commit 5d74619329a2063efc8028536b3f8acc8e949f88) +Signed-off-by: Xu Yandong +--- + src/conf/storage_conf.c | 5 +++++ + tests/storagepoolcapsschemadata/poolcaps-fs.xml | 5 +++++ + tests/storagepoolcapsschemadata/poolcaps-full.xml | 5 +++++ + 3 files changed, 15 insertions(+) + +diff --git a/src/conf/storage_conf.c b/src/conf/storage_conf.c +index 397bd66..05055cd 100644 +--- a/src/conf/storage_conf.c ++++ b/src/conf/storage_conf.c +@@ -241,6 +241,11 @@ static virStoragePoolTypeInfo poolTypeInfo[] = { + VIR_STORAGE_POOL_SOURCE_NETWORK | + VIR_STORAGE_POOL_SOURCE_NAME), + }, ++ .volOptions = { ++ .defaultFormat = VIR_STORAGE_FILE_RAW, ++ .formatFromString = virStorageVolumeFormatFromString, ++ .formatToString = virStorageFileFormatTypeToString, ++ } + }, + {.poolType = VIR_STORAGE_POOL_SHEEPDOG, + .poolOptions = { +diff --git a/tests/storagepoolcapsschemadata/poolcaps-fs.xml b/tests/storagepoolcapsschemadata/poolcaps-fs.xml +index 6513ea6..182fa39 100644 +--- a/tests/storagepoolcapsschemadata/poolcaps-fs.xml ++++ b/tests/storagepoolcapsschemadata/poolcaps-fs.xml +@@ -145,6 +145,11 @@ + + + ++ ++ ++ ++ ++ + + + +diff --git a/tests/storagepoolcapsschemadata/poolcaps-full.xml b/tests/storagepoolcapsschemadata/poolcaps-full.xml +index 32003dd..980c6d2 100644 +--- a/tests/storagepoolcapsschemadata/poolcaps-full.xml ++++ b/tests/storagepoolcapsschemadata/poolcaps-full.xml +@@ -145,6 +145,11 @@ + + + ++ ++ ++ ++ ++ + + + +-- +2.19.1 + diff --git a/libvirt-cgroup-cleanup-eventParams-when-virTypedParamsAddULL.patch b/libvirt-cgroup-cleanup-eventParams-when-virTypedParamsAddULL.patch new file mode 100644 index 0000000..14abc60 --- /dev/null +++ b/libvirt-cgroup-cleanup-eventParams-when-virTypedParamsAddULL.patch @@ -0,0 +1,35 @@ +From d5ac07dee8c9337878ed0085e940c86d3f2ade0b Mon Sep 17 00:00:00 2001 +From: Xu Yandong +Date: Thu, 25 Jul 2019 16:47:50 +0800 +Subject: [PATCH] cgroup: cleanup eventParams when virTypedParamsAddULLong + failed + +Function virTypedParamsAddULLong use realloc to gain memory, +and doesn't free it when failed. so we need free eventParams to +prevent a memory leak. + +Signed-off-by: Xu Yandong +--- + src/qemu/qemu_cgroup.c | 5 ++++- + 1 file changed, 4 insertions(+), 1 deletion(-) + +diff --git a/src/qemu/qemu_cgroup.c b/src/qemu/qemu_cgroup.c +index ca76c4f..8a00703 100644 +--- a/src/qemu/qemu_cgroup.c ++++ b/src/qemu/qemu_cgroup.c +@@ -870,8 +870,11 @@ qemuSetupCpuCgroup(virDomainObjPtr vm) + if (virTypedParamsAddULLong(&eventParams, &eventNparams, + &eventMaxparams, + VIR_DOMAIN_TUNABLE_CPU_CPU_SHARES, +- val) < 0) ++ val) < 0) { ++ if (eventParams) ++ virTypedParamsFree(eventParams, eventNparams); + return -1; ++ } + + event = virDomainEventTunableNewFromObj(vm, eventParams, eventNparams); + } +-- +2.19.1 + diff --git a/libvirt-conf-Avoid-double-free-when-prase-device-xml-failed.patch b/libvirt-conf-Avoid-double-free-when-prase-device-xml-failed.patch new file mode 100644 index 0000000..9fd8cd0 --- /dev/null +++ b/libvirt-conf-Avoid-double-free-when-prase-device-xml-failed.patch @@ -0,0 +1,30 @@ +From 62c8b7f6afec8f8a51d5f2d6a33b9ac5cd0b2988 Mon Sep 17 00:00:00 2001 +From: Xu Yandong +Date: Wed, 14 Aug 2019 10:03:39 +0800 +Subject: [PATCH] conf: Avoid double free when prase device xml failed + +This patch fixes a possible double free. In virDomainDeviceDefParse() +if parse xml failes, then call virDomainDeviceDefFree() free dev, but +does not assign dev to NULL, so will return a not NULL pointer already +freeed. + +Signed-off-by: Xu Yandong +--- + src/conf/domain_conf.c | 1 + + 1 file changed, 1 insertion(+) + +diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c +index ac9bdc0..92b7b4a 100644 +--- a/src/conf/domain_conf.c ++++ b/src/conf/domain_conf.c +@@ -16424,6 +16424,7 @@ virDomainDeviceDefParse(const char *xmlStr, + + error: + virDomainDeviceDefFree(dev); ++ dev = NULL; + goto cleanup; + } + +-- +2.19.1 + diff --git a/libvirt-conf-fix-memory-leak-in-virNodeDevPCICapSRIOVVirtual.patch b/libvirt-conf-fix-memory-leak-in-virNodeDevPCICapSRIOVVirtual.patch new file mode 100644 index 0000000..ede1f70 --- /dev/null +++ b/libvirt-conf-fix-memory-leak-in-virNodeDevPCICapSRIOVVirtual.patch @@ -0,0 +1,32 @@ +From 662ca668ba205216fe908eb5ab1816842625b83e Mon Sep 17 00:00:00 2001 +From: Feng Ni +Date: Thu, 25 Jul 2019 20:19:35 +0800 +Subject: [PATCH] conf: fix memory leak in virNodeDevPCICapSRIOVVirtualParseXML + +In function virNodeDevPCICapSRIOVVirtualParseXML, temp variable +addr could leak if VIR_APPEND_ELEMENT fails . + +Signed-off-by: Feng Ni +--- + src/conf/node_device_conf.c | 4 +++- + 1 file changed, 3 insertions(+), 1 deletion(-) + +diff --git a/src/conf/node_device_conf.c b/src/conf/node_device_conf.c +index 0c804f5..1a8351e 100644 +--- a/src/conf/node_device_conf.c ++++ b/src/conf/node_device_conf.c +@@ -1519,8 +1519,10 @@ virNodeDevPCICapSRIOVVirtualParseXML(xmlXPathContextPtr ctxt, + + if (VIR_APPEND_ELEMENT(pci_dev->virtual_functions, + pci_dev->num_virtual_functions, +- addr) < 0) ++ addr) < 0) { ++ VIR_FREE(addr); + goto cleanup; ++ } + } + + pci_dev->flags |= VIR_NODE_DEV_CAP_FLAG_PCI_VIRTUAL_FUNCTION; +-- +2.19.1 + diff --git a/libvirt-conf-fix-memory-leak-in-virNodeDeviceGetPCISRIOVCaps.patch b/libvirt-conf-fix-memory-leak-in-virNodeDeviceGetPCISRIOVCaps.patch new file mode 100644 index 0000000..26c3484 --- /dev/null +++ b/libvirt-conf-fix-memory-leak-in-virNodeDeviceGetPCISRIOVCaps.patch @@ -0,0 +1,28 @@ +From bf5ba702bb7cbd362a2dc6b278e083e7e475dcff Mon Sep 17 00:00:00 2001 +From: Feng Ni +Date: Thu, 25 Jul 2019 20:13:09 +0800 +Subject: [PATCH] conf: fix memory leak in virNodeDeviceGetPCISRIOVCaps + +Use API nodeDeviceLookupByName query FPGA device info, +pointer physical_function should be released. + +Signed-off-by: Feng Ni +--- + src/conf/node_device_conf.c | 1 + + 1 file changed, 1 insertion(+) + +diff --git a/src/conf/node_device_conf.c b/src/conf/node_device_conf.c +index 4ef92d5..0c804f5 100644 +--- a/src/conf/node_device_conf.c ++++ b/src/conf/node_device_conf.c +@@ -2509,6 +2509,7 @@ virNodeDeviceGetPCISRIOVCaps(const char *sysfsPath, + for (i = 0; i < pci_dev->num_virtual_functions; i++) + VIR_FREE(pci_dev->virtual_functions[i]); + VIR_FREE(pci_dev->virtual_functions); ++ VIR_FREE(pci_dev->physical_function); + pci_dev->num_virtual_functions = 0; + pci_dev->max_virtual_functions = 0; + pci_dev->flags &= ~VIR_NODE_DEV_CAP_FLAG_PCI_VIRTUAL_FUNCTION; +-- +2.19.1 + diff --git a/libvirt-conf-use-virDomainDeviceDefFree-free-dev.patch b/libvirt-conf-use-virDomainDeviceDefFree-free-dev.patch new file mode 100644 index 0000000..8df218b --- /dev/null +++ b/libvirt-conf-use-virDomainDeviceDefFree-free-dev.patch @@ -0,0 +1,29 @@ +From c46e864f40ce35f0b67543990b46dc0731121f9d Mon Sep 17 00:00:00 2001 +From: Feng Ni +Date: Thu, 25 Jul 2019 20:03:22 +0800 +Subject: [PATCH] conf: use virDomainDeviceDefFree free dev + +In function virDomainDeviceDefParse, we shoud use virDomainDeviceDefFree +free data structure avoid potential memory leak. + +Signed-off-by: Feng Ni +--- + src/conf/domain_conf.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c +index 3323c9a..ac9bdc0 100644 +--- a/src/conf/domain_conf.c ++++ b/src/conf/domain_conf.c +@@ -16423,7 +16423,7 @@ virDomainDeviceDefParse(const char *xmlStr, + return dev; + + error: +- VIR_FREE(dev); ++ virDomainDeviceDefFree(dev); + goto cleanup; + } + +-- +2.19.1 + diff --git a/libvirt-cpu-Introduce-mock-checkFeature-method-for-ARM-CPUS.patch b/libvirt-cpu-Introduce-mock-checkFeature-method-for-ARM-CPUS.patch new file mode 100644 index 0000000..5071981 --- /dev/null +++ b/libvirt-cpu-Introduce-mock-checkFeature-method-for-ARM-CPUS.patch @@ -0,0 +1,41 @@ +From bed928dada1ed8fe50dd4792d7b201df29016c12 Mon Sep 17 00:00:00 2001 +From: Xu Yandong +Date: Fri, 6 Sep 2019 12:30:15 +0800 +Subject: [PATCH] cpu: Introduce mock checkFeature method for ARM CPUS + +Introduce mock checkFeature method for ARM to avoid +runtime error messages. + +Signed-off-by: Xu Yandong +--- + src/cpu/cpu_arm.c | 9 +++++++++ + 1 file changed, 9 insertions(+) + +diff --git a/src/cpu/cpu_arm.c b/src/cpu/cpu_arm.c +index b3bc379..5733ddc 100644 +--- a/src/cpu/cpu_arm.c ++++ b/src/cpu/cpu_arm.c +@@ -1009,6 +1009,14 @@ virCPUarmCompare(virCPUDefPtr host, + } + + ++static int ++virCPUarmCheckFeature(const virCPUDef *cpu ATTRIBUTE_UNUSED, ++ const char *name ATTRIBUTE_UNUSED) ++{ ++ return -1; ++} ++ ++ + struct cpuArchDriver cpuDriverArm = { + .name = "arm", + .arch = archs, +@@ -1020,4 +1028,5 @@ struct cpuArchDriver cpuDriverArm = { + .getHost = virCPUarmGetHost, + .baseline = virCPUarmBaseline, + .update = virCPUarmUpdate, ++ .checkFeature = virCPUarmCheckFeature, + }; +-- +2.19.1 + diff --git a/libvirt-cpu-add-getHostCPU-for-ARM-CPUS.patch b/libvirt-cpu-add-getHostCPU-for-ARM-CPUS.patch new file mode 100644 index 0000000..d853f5a --- /dev/null +++ b/libvirt-cpu-add-getHostCPU-for-ARM-CPUS.patch @@ -0,0 +1,133 @@ +From 4c3a9684e7fccef83158a4a2f74680c6d8e166f7 Mon Sep 17 00:00:00 2001 +From: Xu Yandong +Date: Fri, 6 Sep 2019 10:56:39 +0800 +Subject: [PATCH] cpu: add getHostCPU for ARM CPUS + +support vendor and model for virConnectGetCapabilities in ARM, +introduce getHost frame for arm + +Signed-off-by: Xu Yandong +--- + src/cpu/cpu_arm.c | 92 +++++++++++++++++++++++++++++++++++++++++++++++ + 1 file changed, 92 insertions(+) + +diff --git a/src/cpu/cpu_arm.c b/src/cpu/cpu_arm.c +index b4c41c5..b3bc379 100644 +--- a/src/cpu/cpu_arm.c ++++ b/src/cpu/cpu_arm.c +@@ -532,6 +532,74 @@ armMakeCPUData(virArch arch, + } + + ++ ++static int ++armCpuDataFromCpuInfo(virCPUarmData *data) ++{ ++ int ret = -1; ++ char *eol = NULL; ++ char *str_vendor = NULL; ++ char *str_pvr = NULL; ++ char *outbuf = NULL; ++ const char *cur; ++ ++ if (!data) ++ return ret; ++ ++ if (virFileReadAll(CPUINFO, CPUINFO_FILE_LEN, &outbuf) < 0) { ++ virReportError(VIR_ERR_INTERNAL_ERROR, ++ _("Failed to open %s"), CPUINFO); ++ goto cleanup; ++ } ++ ++ if ((cur = strstr(outbuf, "CPU implementer")) == NULL) { ++ virReportError(VIR_ERR_INTERNAL_ERROR, ++ _("there is no \"CPU implementer\" info in %s"), CPUINFO); ++ goto cleanup; ++ } ++ ++ /* Account for format 'CPU implementer : XXXX'*/ ++ cur = strchr(cur, ':') + 1; ++ eol = strchr(cur, '\n'); ++ virSkipSpaces(&cur); ++ if (!eol || VIR_STRNDUP(str_vendor, cur, eol - cur) < 0 || ++ virStrToLong_ul(str_vendor, NULL, 16, &data->vendor_id) < 0) ++ goto cleanup; ++ ++ if ((cur = strstr(outbuf, "CPU part")) == NULL) { ++ virReportError(VIR_ERR_INTERNAL_ERROR, ++ _("there is no \"CPU part\" info in %s"), CPUINFO); ++ goto cleanup; ++ } ++ ++ cur = strchr(cur, ':') + 1; ++ eol = strchr(cur, '\n'); ++ virSkipSpaces(&cur); ++ if (!eol || VIR_STRNDUP(str_pvr, cur, eol - cur) < 0 || ++ virStrToLong_ul(str_pvr, NULL, 16, &data->pvr) < 0) ++ goto cleanup; ++ ++ if ((cur = strstr(outbuf, "Features")) == NULL) { ++ virReportError(VIR_ERR_INTERNAL_ERROR, ++ _("there is no \"Features\" info in %s"), CPUINFO); ++ goto cleanup; ++ } ++ cur = strchr(cur, ':') + 1; ++ eol = strchr(cur, '\n'); ++ virSkipSpaces(&cur); ++ if (eol && VIR_STRNDUP(data->features, cur, eol - cur) < 0) ++ goto cleanup; ++ ++ ret = 0; ++ ++ cleanup: ++ VIR_FREE(outbuf); ++ VIR_FREE(str_vendor); ++ VIR_FREE(str_pvr); ++ return ret; ++} ++ ++ + static int + armCpuDataParseFeatures(virCPUDefPtr cpu, + const virCPUarmData *cpuData) +@@ -628,6 +696,29 @@ armDecodeCPUData(virCPUDefPtr cpu, + return armDecode(cpu, &data->data.arm, models); + } + ++static int ++virCPUarmGetHost(virCPUDefPtr cpu, ++ virDomainCapsCPUModelsPtr models) ++{ ++ virCPUDataPtr cpuData = NULL; ++ int ret = -1; ++ ++ if (virCPUarmDriverInitialize() < 0) ++ goto cleanup; ++ ++ if (!(cpuData = virCPUDataNew(archs[0]))) ++ goto cleanup; ++ ++ if (armCpuDataFromCpuInfo(&cpuData->data.arm) < 0) ++ goto cleanup; ++ ++ ret = armDecodeCPUData(cpu, cpuData, models); ++ ++ cleanup: ++ virCPUarmDataFree(cpuData); ++ return ret; ++} ++ + + static int + virCPUarmUpdate(virCPUDefPtr guest, +@@ -926,6 +1017,7 @@ struct cpuArchDriver cpuDriverArm = { + .decode = armDecodeCPUData, + .encode = NULL, + .dataFree = virCPUarmDataFree, ++ .getHost = virCPUarmGetHost, + .baseline = virCPUarmBaseline, + .update = virCPUarmUpdate, + }; +-- +2.19.1 + diff --git a/libvirt-cpu-fix-cpu-compare-and-cpu-baseline-for-ARM-CPU.patch b/libvirt-cpu-fix-cpu-compare-and-cpu-baseline-for-ARM-CPU.patch new file mode 100644 index 0000000..cbd0995 --- /dev/null +++ b/libvirt-cpu-fix-cpu-compare-and-cpu-baseline-for-ARM-CPU.patch @@ -0,0 +1,292 @@ +From 57b8e156e898ccf878842c3cba1ed97a415cff6a Mon Sep 17 00:00:00 2001 +From: Xu Yandong +Date: Fri, 6 Sep 2019 11:27:33 +0800 +Subject: [PATCH] cpu: fix cpu-compare and cpu-baseline for ARM CPU + +Signed-off-by: Xu Yandong +--- + src/cpu/cpu_arm.c | 241 ++++++++++++++++++++++++++++++++++++++++++++-- + 1 file changed, 234 insertions(+), 7 deletions(-) + +diff --git a/src/cpu/cpu_arm.c b/src/cpu/cpu_arm.c +index 0c8cd50..1d0d3b6 100644 +--- a/src/cpu/cpu_arm.c ++++ b/src/cpu/cpu_arm.c +@@ -681,12 +681,18 @@ virCPUarmUpdate(virCPUDefPtr guest, + + static virCPUDefPtr + virCPUarmBaseline(virCPUDefPtr *cpus, +- unsigned int ncpus ATTRIBUTE_UNUSED, +- virDomainCapsCPUModelsPtr models ATTRIBUTE_UNUSED, ++ unsigned int ncpus, ++ virDomainCapsCPUModelsPtr models, + const char **features ATTRIBUTE_UNUSED, + bool migratable ATTRIBUTE_UNUSED) + { + virCPUDefPtr cpu = NULL; ++ virCPUarmMapPtr map = NULL; ++ virCPUarmModelPtr model = NULL; ++ virCPUarmModelPtr baseModel = NULL; ++ virCPUarmVendorPtr vendor = NULL; ++ bool outputVendor = true; ++ size_t i; + + if (VIR_ALLOC(cpu) < 0 || + VIR_STRDUP(cpu->model, cpus[0]->model) < 0) { +@@ -694,27 +700,248 @@ virCPUarmBaseline(virCPUDefPtr *cpus, + return NULL; + } + ++ cpu->arch = cpus[0]->arch; + cpu->type = VIR_CPU_TYPE_GUEST; + cpu->match = VIR_CPU_MATCH_EXACT; ++ cpu->fallback = VIR_CPU_FALLBACK_FORBID; ++ ++ if (!(map = virCPUarmGetMap())) ++ goto error; ++ ++ if (!(baseModel = armModelFromCPU(cpus[0], map))) ++ goto error; ++ ++ if (!cpus[0]->vendor) { ++ outputVendor = false; ++ } else if (!(vendor = armVendorFindByName(map, cpus[0]->vendor))) { ++ virReportError(VIR_ERR_OPERATION_FAILED, ++ _("Unknown CPU vendor %s"), cpus[0]->vendor); ++ goto error; ++ } ++ ++ for (i = 1; i < ncpus; i++) { ++ const char *vn = NULL; ++ ++ if (!(model = armModelFromCPU(cpus[i], map))) ++ goto error; ++ ++ if (cpus[i]->vendor) { ++ vn = cpus[i]->vendor; ++ } else { ++ outputVendor = false; ++ } ++ ++ if (vn) { ++ if (!vendor) { ++ if (!(vendor = armVendorFindByName(map, vn))) { ++ virReportError(VIR_ERR_OPERATION_FAILED, ++ _("Unknown CPU vendor %s"), vn); ++ goto error; ++ } ++ } else if (STRNEQ(vendor->name, vn)) { ++ virReportError(VIR_ERR_OPERATION_FAILED, ++ "%s", _("CPU vendors do not match")); ++ goto error; ++ } ++ } ++ ++ armDataIntersect(&baseModel->data, &model->data); ++ armModelFree(model); ++ model = NULL; ++ } ++ ++ if (armDecode(cpu, &baseModel->data, models) < 0) ++ goto error; ++ ++ if (!outputVendor) ++ VIR_FREE(cpu->vendor); ++ ++ cpu->arch = VIR_ARCH_NONE; ++ ++ cleanup: ++ armModelFree(baseModel); + + return cpu; ++ ++ error: ++ armModelFree(model); ++ virCPUDefFree(cpu); ++ cpu = NULL; ++ goto cleanup; + } + ++ + static virCPUCompareResult +-virCPUarmCompare(virCPUDefPtr host ATTRIBUTE_UNUSED, +- virCPUDefPtr cpu ATTRIBUTE_UNUSED, +- bool failMessages ATTRIBUTE_UNUSED) ++armCompute(virCPUDefPtr host, ++ virCPUDefPtr cpu, ++ virCPUDataPtr *guestData, ++ char **message) + { +- return VIR_CPU_COMPARE_IDENTICAL; ++ virCPUarmMapPtr map = NULL; ++ virCPUarmModelPtr hostModel = NULL; ++ virCPUarmModelPtr guestModel = NULL; ++ virCPUCompareResult ret = VIR_CPU_COMPARE_ERROR; ++ virArch arch; ++ size_t i; ++ ++ if (cpu->arch != VIR_ARCH_NONE) { ++ bool found = false; ++ ++ for (i = 0; i < ARRAY_CARDINALITY(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 && ++ virAsprintf(message, ++ _("CPU arch %s does not match host arch"), ++ virArchToString(cpu->arch)) < 0) ++ goto cleanup; ++ ++ 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 && ++ virAsprintf(message, ++ _("host CPU vendor does not match required " ++ "CPU vendor %s"), ++ cpu->vendor) < 0) ++ goto cleanup; ++ ++ ret = VIR_CPU_COMPARE_INCOMPATIBLE; ++ goto cleanup; ++ } ++ ++ if (!(map = virCPUarmGetMap())) ++ goto cleanup; ++ ++ /* Host CPU information */ ++ if (!(hostModel = armModelFromCPU(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 */ ++ guestModel = armModelCopy(hostModel); ++ break; ++ ++ case VIR_CPU_MODE_CUSTOM: ++ /* custom: ++ * look up guest CPU information */ ++ guestModel = armModelFromCPU(cpu, map); ++ break; ++ } ++ } else { ++ /* Other host CPU information */ ++ guestModel = armModelFromCPU(cpu, map); ++ } ++ ++ if (!guestModel) ++ goto cleanup; ++ ++ if (STRNEQ(guestModel->name, hostModel->name)) { ++ VIR_DEBUG("host CPU model %s does not match required CPU model %s", ++ hostModel->name, guestModel->name); ++ if (message && ++ virAsprintf(message, ++ _("host CPU model %s does not match required " ++ "CPU model %s"), ++ hostModel->name, guestModel->name) < 0) ++ goto cleanup; ++ ++ ret = VIR_CPU_COMPARE_INCOMPATIBLE; ++ goto cleanup; ++ } ++ ++ if (!armFeaturesIsSub(guestModel->data.features, hostModel->data.features)) { ++ VIR_DEBUG("guest CPU features '%s' is not subset of " ++ "host CPU features '%s'", ++ guestModel->data.features, hostModel->data.features); ++ if (message && ++ virAsprintf(message, ++ _("guest CPU features '%s' is not subset of " ++ "host CPU features '%s'"), ++ guestModel->data.features, ++ hostModel->data.features) < 0) ++ goto cleanup; ++ ++ ret = VIR_CPU_COMPARE_INCOMPATIBLE; ++ goto cleanup; ++ } ++ ++ if (guestData && ++ !(*guestData = armMakeCPUData(arch, &guestModel->data))) ++ goto cleanup; ++ ++ ret = VIR_CPU_COMPARE_IDENTICAL; ++ ++ cleanup: ++ armModelFree(hostModel); ++ armModelFree(guestModel); ++ return ret; + } + ++static virCPUCompareResult ++virCPUarmCompare(virCPUDefPtr host, ++ virCPUDefPtr cpu, ++ bool failIncompatible) ++{ ++ virCPUCompareResult ret = VIR_CPU_COMPARE_ERROR; ++ 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 ret; ++ } ++ ++ ret = armCompute(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); ++ } ++ } ++ VIR_FREE(message); ++ ++ return ret; ++} ++ ++ + struct cpuArchDriver cpuDriverArm = { + .name = "arm", + .arch = archs, + .narch = ARRAY_CARDINALITY(archs), + .compare = virCPUarmCompare, +- .decode = NULL, ++ .decode = armDecodeCPUData, + .encode = NULL, ++ .dataFree = virCPUarmDataFree, + .baseline = virCPUarmBaseline, + .update = virCPUarmUpdate, + }; +-- +2.19.1 + diff --git a/libvirt-cpu-introduce-cpu-baseline-for-ARM-CPU.patch b/libvirt-cpu-introduce-cpu-baseline-for-ARM-CPU.patch new file mode 100644 index 0000000..861c361 --- /dev/null +++ b/libvirt-cpu-introduce-cpu-baseline-for-ARM-CPU.patch @@ -0,0 +1,649 @@ +From 2dc7c9bc3dc24d991834f7657cd65cf4b5774ff8 Mon Sep 17 00:00:00 2001 +From: Xu Yandong +Date: Wed, 14 Aug 2019 21:33:37 +0800 +Subject: [PATCH] cpu: introduce cpu baseline for ARM CPU + +support vendor and model for ARM CPU + +Signed-off-by: Xu Yandong +--- + src/cpu/cpu_arm.c | 610 ++++++++++++++++++++++++++++++++++++++++++++++ + 1 file changed, 610 insertions(+) + +diff --git a/src/cpu/cpu_arm.c b/src/cpu/cpu_arm.c +index 65d69c0..0c8cd50 100644 +--- a/src/cpu/cpu_arm.c ++++ b/src/cpu/cpu_arm.c +@@ -21,12 +21,23 @@ + + #include + ++#include "virlog.h" + #include "viralloc.h" + #include "cpu.h" + #include "virstring.h" ++#include "cpu_map.h" ++#include "cpu_arm.h" ++#include "virfile.h" + + #define VIR_FROM_THIS VIR_FROM_CPU + ++VIR_LOG_INIT("cpu.cpu_arm"); ++ ++static const char *sysinfoCpuinfo = "/proc/cpuinfo"; ++ ++#define CPUINFO sysinfoCpuinfo ++#define CPUINFO_FILE_LEN (1024*1024) /* 1MB limit for /proc/cpuinfo file */ ++ + static const virArch archs[] = { + VIR_ARCH_ARMV6L, + VIR_ARCH_ARMV7B, +@@ -34,6 +45,605 @@ static const virArch archs[] = { + VIR_ARCH_AARCH64, + }; + ++typedef struct _virCPUarmVendor virCPUarmVendor; ++typedef virCPUarmVendor *virCPUarmVendorPtr; ++struct _virCPUarmVendor { ++ char *name; ++ unsigned long value; ++}; ++ ++typedef struct _virCPUarmModel virCPUarmModel; ++typedef virCPUarmModel *virCPUarmModelPtr; ++struct _virCPUarmModel { ++ char *name; ++ virCPUarmVendorPtr vendor; ++ virCPUarmData data; ++}; ++ ++typedef struct _virCPUarmMap virCPUarmMap; ++typedef virCPUarmMap *virCPUarmMapPtr; ++struct _virCPUarmMap { ++ size_t nvendors; ++ virCPUarmVendorPtr *vendors; ++ size_t nmodels; ++ virCPUarmModelPtr *models; ++}; ++ ++static virCPUarmMapPtr cpuMap; ++ ++int virCPUarmDriverOnceInit(void); ++VIR_ONCE_GLOBAL_INIT(virCPUarmDriver); ++ ++ ++static void ++virCPUarmDataClear(virCPUarmData *data) ++{ ++ if (!data) ++ return; ++ ++ VIR_FREE(data->features); ++} ++ ++ ++static int ++armDataCopy(virCPUarmData *dst, const virCPUarmData *src) ++{ ++ if (VIR_STRDUP(dst->features, src->features) < 0) ++ return -1; ++ ++ dst->vendor_id = src->vendor_id; ++ dst->pvr = src->pvr; ++ ++ return 0; ++} ++ ++ ++static void ++armDataIntersect(virCPUarmData *data1, ++ const virCPUarmData *data2) ++{ ++ char **features = NULL; ++ char **features1 = NULL; ++ char **features2 = NULL; ++ size_t count = 0; ++ size_t i; ++ ++ if (!data1 || !data2) ++ return; ++ ++ data1->pvr = MIN(data1->pvr, data2->pvr); ++ ++ if (virStringIsEmpty(data1->features) || ++ virStringIsEmpty(data2->features)) { ++ VIR_FREE(data1->features); ++ return; ++ } ++ ++ if (STREQ_NULLABLE(data1->features, data2->features)) ++ return; ++ ++ if (!(features = virStringSplitCount(data1->features, " ", 0, &count)) || ++ !(features1 = virStringSplitCount(data1->features, " ", 0, &count)) || ++ !(features2 = virStringSplit(data2->features, " ", 0))) ++ goto cleanup; ++ ++ for (i = 0; i < count; i++) { ++ if (!virStringListHasString((const char**)features2, features1[i])) ++ virStringListRemove(&features, features1[i]); ++ } ++ ++ VIR_FREE(data1->features); ++ if (features) ++ data1->features = virStringListJoin((const char**)features, " "); ++ ++ cleanup: ++ virStringListFree(features); ++ virStringListFree(features1); ++ virStringListFree(features2); ++ return; ++} ++ ++ ++static void ++virCPUarmDataFree(virCPUDataPtr cpuData) ++{ ++ if (!cpuData) ++ return; ++ ++ virCPUarmDataClear(&cpuData->data.arm); ++ VIR_FREE(cpuData); ++} ++ ++ ++static bool ++armFeaturesIsSub(char *subFeatures, ++ char *fullFeatures) ++{ ++ bool ret = false; ++ char **sub = NULL; ++ char **full = NULL; ++ size_t subCount = 0; ++ size_t fullCount = 0; ++ size_t i; ++ ++ if (virStringIsEmpty(subFeatures)) ++ return true; ++ ++ if (virStringIsEmpty(fullFeatures)) ++ return ret; ++ ++ if (STREQ(subFeatures, fullFeatures)) ++ return true; ++ ++ if (!(sub = virStringSplitCount(subFeatures, " ", 0, &subCount)) || ++ !(full = virStringSplitCount(fullFeatures, " ", 0, &fullCount)) || ++ subCount > fullCount) ++ goto cleanup; ++ ++ for (i = 0; i < subCount; i++) { ++ if (!virStringListHasString((const char**)full, sub[i])) ++ goto cleanup; ++ } ++ ++ ret = true; ++ ++ cleanup: ++ virStringListFree(sub); ++ virStringListFree(full); ++ return ret; ++} ++ ++ ++static void ++armVendorFree(virCPUarmVendorPtr vendor) ++{ ++ if (!vendor) ++ return; ++ ++ VIR_FREE(vendor->name); ++ VIR_FREE(vendor); ++} ++ ++ ++static virCPUarmVendorPtr ++armVendorFindByID(virCPUarmMapPtr map, ++ unsigned long vendor_id) ++{ ++ size_t i; ++ ++ for (i = 0; i < map->nvendors; i++) { ++ if (map->vendors[i]->value == vendor_id) ++ return map->vendors[i]; ++ } ++ ++ return NULL; ++} ++ ++ ++static virCPUarmVendorPtr ++armVendorFindByName(virCPUarmMapPtr 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 int ++armVendorParse(xmlXPathContextPtr ctxt, ++ const char *name, ++ void *data) ++{ ++ virCPUarmMapPtr map = (virCPUarmMapPtr)data; ++ virCPUarmVendorPtr vendor = NULL; ++ int ret = -1; ++ ++ if (VIR_ALLOC(vendor) < 0) ++ return ret; ++ ++ if (VIR_STRDUP(vendor->name, name) < 0) ++ goto cleanup; ++ ++ if (armVendorFindByName(map, vendor->name)) { ++ virReportError(VIR_ERR_INTERNAL_ERROR, ++ _("CPU vendor %s already defined"), vendor->name); ++ goto cleanup; ++ } ++ ++ if (virXPathULongHex("string(@value)", ctxt, &vendor->value) < 0) { ++ virReportError(VIR_ERR_INTERNAL_ERROR, ++ "%s", _("Missing CPU vendor value")); ++ goto cleanup; ++ } ++ ++ if (armVendorFindByID(map, vendor->value)) { ++ virReportError(VIR_ERR_INTERNAL_ERROR, ++ _("CPU vendor value 0x%2lx already defined"), vendor->value); ++ goto cleanup; ++ } ++ ++ if (VIR_APPEND_ELEMENT(map->vendors, map->nvendors, vendor) < 0) ++ goto cleanup; ++ ++ ret = 0; ++ ++ cleanup: ++ armVendorFree(vendor); ++ return ret; ++ ++} ++ ++ ++static void ++armModelFree(virCPUarmModelPtr model) ++{ ++ if (!model) ++ return; ++ ++ virCPUarmDataClear(&model->data); ++ VIR_FREE(model->name); ++ VIR_FREE(model); ++} ++ ++ ++static virCPUarmModelPtr ++armModelCopy(virCPUarmModelPtr model) ++{ ++ virCPUarmModelPtr copy; ++ ++ if (VIR_ALLOC(copy) < 0) ++ goto cleanup; ++ ++ if (VIR_STRDUP(copy->name, model->name) < 0) ++ goto cleanup; ++ ++ if (armDataCopy(©->data, &model->data) < 0) ++ goto cleanup; ++ ++ copy->vendor = model->vendor; ++ ++ return copy; ++ ++ cleanup: ++ armModelFree(copy); ++ return NULL; ++} ++ ++ ++static virCPUarmModelPtr ++armModelFind(virCPUarmMapPtr 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 virCPUarmModelPtr ++armModelFindByPVR(virCPUarmMapPtr map, ++ unsigned long pvr) ++{ ++ size_t i; ++ ++ for (i = 0; i < map->nmodels; i++) { ++ if (map->models[i]->data.pvr == pvr) ++ return map->models[i]; ++ } ++ ++ return NULL; ++} ++ ++ ++static virCPUarmModelPtr ++armModelFromCPU(const virCPUDef *cpu, ++ virCPUarmMapPtr map) ++{ ++ virCPUarmModelPtr model = NULL; ++ virCPUarmVendorPtr vendor = NULL; ++ char **features = NULL; ++ size_t i; ++ ++ if (!cpu->model) { ++ virReportError(VIR_ERR_INVALID_ARG, "%s", ++ _("no CPU model specified")); ++ return NULL; ++ } ++ ++ if (!(model = armModelFind(map, cpu->model))) { ++ virReportError(VIR_ERR_INTERNAL_ERROR, ++ _("Unknown CPU model %s"), cpu->model); ++ return NULL; ++ } ++ ++ if (!(model = armModelCopy(model))) ++ goto cleanup; ++ ++ if (cpu->vendor) { ++ if (!(vendor = armVendorFindByName(map, cpu->vendor))) { ++ virReportError(VIR_ERR_INTERNAL_ERROR, ++ _("Unknown CPU vendor %s"), cpu->vendor); ++ goto error; ++ } ++ model->data.vendor_id = vendor->value; ++ } ++ ++ if (cpu->nfeatures) { ++ if (VIR_REALLOC_N(features, cpu->nfeatures + 1) < 0) ++ goto cleanup; ++ ++ features[cpu->nfeatures] = NULL; ++ for (i = 0; i < cpu->nfeatures; i++) { ++ if (VIR_STRDUP(features[i], cpu->features[i].name) < 0) ++ goto error; ++ } ++ ++ VIR_FREE(model->data.features); ++ model->data.features = virStringListJoin((const char **)features, " "); ++ } ++ ++ cleanup: ++ virStringListFree(features); ++ return model; ++ ++ error: ++ armModelFree(model); ++ model = NULL; ++ goto cleanup; ++} ++ ++static int ++armModelParse(xmlXPathContextPtr ctxt, ++ const char *name, ++ void *data) ++{ ++ virCPUarmMapPtr map = (virCPUarmMapPtr)data; ++ virCPUarmModel *model; ++ xmlNodePtr *nodes = NULL; ++ char *vendor = NULL; ++ int ret = -1; ++ ++ if (VIR_ALLOC(model) < 0) ++ goto error; ++ ++ if (VIR_STRDUP(model->name, name) < 0) ++ goto error; ++ ++ if (armModelFind(map, model->name)) { ++ virReportError(VIR_ERR_INTERNAL_ERROR, ++ _("CPU model %s already defined"), model->name); ++ goto error; ++ } ++ ++ 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 error; ++ } ++ ++ if (!(model->vendor = armVendorFindByName(map, vendor))) { ++ virReportError(VIR_ERR_INTERNAL_ERROR, ++ _("Unknown vendor %s referenced by CPU model %s"), ++ vendor, model->name); ++ goto error; ++ } ++ } ++ ++ if (!virXPathBoolean("boolean(./pvr)", ctxt)) { ++ virReportError(VIR_ERR_INTERNAL_ERROR, ++ _("Missing PVR information for CPU model %s"), ++ model->name); ++ goto error; ++ } ++ ++ if (virXPathULongHex("string(./pvr/@value)", ctxt, &model->data.pvr) < 0) { ++ virReportError(VIR_ERR_INTERNAL_ERROR, ++ _("Missing or invalid PVR value in CPU model %s"), ++ model->name); ++ goto error; ++ } ++ ++ if (VIR_APPEND_ELEMENT(map->models, map->nmodels, model) < 0) ++ goto error; ++ ++ ret = 0; ++ ++ cleanup: ++ VIR_FREE(vendor); ++ VIR_FREE(nodes); ++ return ret; ++ ++ error: ++ armModelFree(model); ++ goto cleanup; ++} ++ ++ ++static void ++armMapFree(virCPUarmMapPtr map) ++{ ++ size_t i; ++ ++ if (!map) ++ return; ++ ++ for (i = 0; i < map->nmodels; i++) ++ armModelFree(map->models[i]); ++ VIR_FREE(map->models); ++ ++ for (i = 0; i < map->nvendors; i++) ++ armVendorFree(map->vendors[i]); ++ VIR_FREE(map->vendors); ++ ++ VIR_FREE(map); ++} ++ ++ ++static virCPUarmMapPtr ++virCPUarmLoadMap(void) ++{ ++ virCPUarmMapPtr map; ++ ++ if (VIR_ALLOC(map) < 0) ++ goto error; ++ ++ if (cpuMapLoad("arm", armVendorParse, NULL, armModelParse, map) < 0) ++ goto error; ++ ++ return map; ++ ++ error: ++ armMapFree(map); ++ return NULL; ++} ++ ++int ++virCPUarmDriverOnceInit(void) ++{ ++ if (!(cpuMap = virCPUarmLoadMap())) ++ return -1; ++ ++ return 0; ++} ++ ++ ++static virCPUarmMapPtr ++virCPUarmGetMap(void) ++{ ++ if (virCPUarmDriverInitialize() < 0) ++ return NULL; ++ ++ return cpuMap; ++} ++ ++static virCPUDataPtr ++armMakeCPUData(virArch arch, ++ virCPUarmData *data) ++{ ++ virCPUDataPtr cpuData; ++ ++ if (VIR_ALLOC(cpuData) < 0) ++ return NULL; ++ ++ cpuData->arch = arch; ++ ++ if (armDataCopy(&cpuData->data.arm, data) < 0) ++ VIR_FREE(cpuData); ++ ++ return cpuData; ++} ++ ++ ++static int ++armCpuDataParseFeatures(virCPUDefPtr cpu, ++ const virCPUarmData *cpuData) ++{ ++ int ret = -1; ++ size_t i; ++ char **features; ++ ++ if (!cpu || !cpuData) ++ return ret; ++ ++ if (!(features = virStringSplitCount(cpuData->features, " ", ++ 0, &cpu->nfeatures))) ++ return ret; ++ if (cpu->nfeatures) { ++ if (VIR_ALLOC_N(cpu->features, cpu->nfeatures) < 0) ++ goto error; ++ ++ for (i = 0; i < cpu->nfeatures; i++) { ++ cpu->features[i].policy = VIR_CPU_FEATURE_REQUIRE; ++ if (VIR_STRDUP(cpu->features[i].name, features[i]) < 0) ++ goto error; ++ } ++ } ++ ++ ret = 0; ++ ++ cleanup: ++ virStringListFree(features); ++ return ret; ++ ++ error: ++ for (i = 0; i < cpu->nfeatures; i++) ++ VIR_FREE(cpu->features[i].name); ++ VIR_FREE(cpu->features); ++ cpu->nfeatures = 0; ++ goto cleanup; ++} ++ ++ ++static int ++armDecode(virCPUDefPtr cpu, ++ const virCPUarmData *cpuData, ++ virDomainCapsCPUModelsPtr models) ++{ ++ virCPUarmMapPtr map; ++ virCPUarmModelPtr model; ++ virCPUarmVendorPtr vendor = NULL; ++ ++ if (!cpuData || !(map = virCPUarmGetMap())) ++ return -1; ++ ++ if (!(model = armModelFindByPVR(map, cpuData->pvr))) { ++ virReportError(VIR_ERR_OPERATION_FAILED, ++ _("Cannot find CPU model with PVR 0x%03lx"), ++ cpuData->pvr); ++ return -1; ++ } ++ ++ if (!virCPUModelIsAllowed(model->name, models)) { ++ virReportError(VIR_ERR_CONFIG_UNSUPPORTED, ++ _("CPU model %s is not supported by hypervisor"), ++ model->name); ++ return -1; ++ } ++ ++ if (VIR_STRDUP(cpu->model, model->name) < 0) ++ return -1; ++ ++ if (cpuData->vendor_id && ++ !(vendor = armVendorFindByID(map, cpuData->vendor_id))) { ++ virReportError(VIR_ERR_OPERATION_FAILED, ++ _("Cannot find CPU vendor with vendor id 0x%02lx"), ++ cpuData->vendor_id); ++ return -1; ++ } ++ ++ if (vendor && VIR_STRDUP(cpu->vendor, vendor->name) < 0) ++ return -1; ++ ++ if (cpuData->features && ++ armCpuDataParseFeatures(cpu, cpuData) < 0) ++ return -1; ++ ++ return 0; ++} ++ ++ ++static int ++armDecodeCPUData(virCPUDefPtr cpu, ++ const virCPUData *data, ++ virDomainCapsCPUModelsPtr models) ++{ ++ return armDecode(cpu, &data->data.arm, models); ++} ++ + + static int + virCPUarmUpdate(virCPUDefPtr guest, +-- +2.19.1 + diff --git a/libvirt-cpu-introduce-virCPUarmData-to-virCPUData.patch b/libvirt-cpu-introduce-virCPUarmData-to-virCPUData.patch new file mode 100644 index 0000000..d34e1c8 --- /dev/null +++ b/libvirt-cpu-introduce-virCPUarmData-to-virCPUData.patch @@ -0,0 +1,76 @@ +From e814e4a7e227cd681b9dd95aedc93f3a087c42a1 Mon Sep 17 00:00:00 2001 +From: Xu Yandong +Date: Wed, 14 Aug 2019 17:06:12 +0800 +Subject: [PATCH] cpu: introduce virCPUarmData to virCPUData + +support vendor and model for virConnectGetCapabilities in ARM, +introduce virCPUarmData to virCPUData. + +Signed-off-by: Xu Yandong +--- + src/cpu/cpu.h | 2 ++ + src/cpu/cpu_arm_data.h | 32 ++++++++++++++++++++++++++++++++ + 2 files changed, 34 insertions(+) + create mode 100644 src/cpu/cpu_arm_data.h + +diff --git a/src/cpu/cpu.h b/src/cpu/cpu.h +index 13909bb..f91b247 100644 +--- a/src/cpu/cpu.h ++++ b/src/cpu/cpu.h +@@ -27,6 +27,7 @@ + #include "cpu_conf.h" + #include "cpu_x86_data.h" + #include "cpu_ppc64_data.h" ++#include "cpu_arm_data.h" + + + typedef struct _virCPUData virCPUData; +@@ -36,6 +37,7 @@ struct _virCPUData { + union { + virCPUx86Data x86; + virCPUppc64Data ppc64; ++ virCPUarmData arm; + /* generic driver needs no data */ + } data; + }; +diff --git a/src/cpu/cpu_arm_data.h b/src/cpu/cpu_arm_data.h +new file mode 100644 +index 0000000..72b3a29 +--- /dev/null ++++ b/src/cpu/cpu_arm_data.h +@@ -0,0 +1,32 @@ ++/* ++ * cpu_arm_data.h: 64-bit arm CPU specific data ++ * ++ * Copyright (C) 2019. Huawei Technologies Co., Ltd. All rights reserved. ++ * ++ * 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 ++ * . ++ * ++ */ ++ ++#pragma once ++ ++ ++#define VIR_CPU_ARM_DATA_INIT { 0 } ++ ++typedef struct _virCPUarmData virCPUarmData; ++struct _virCPUarmData { ++ unsigned long vendor_id; ++ unsigned long pvr; ++ char *features; ++}; +-- +2.19.1 + diff --git a/libvirt-cpu_map-Introduce-arm-CPU-models.patch b/libvirt-cpu_map-Introduce-arm-CPU-models.patch new file mode 100644 index 0000000..36d29cc --- /dev/null +++ b/libvirt-cpu_map-Introduce-arm-CPU-models.patch @@ -0,0 +1,150 @@ +From 4274e2d7d00058b5a6aca7c4b256c0c6fb01d69d Mon Sep 17 00:00:00 2001 +From: Xu Yandong +Date: Wed, 14 Aug 2019 16:51:23 +0800 +Subject: [PATCH] cpu_map: Introduce arm CPU models + +support vendor and model for virConnectGetCapabilities in ARM, +add arm cpu info to cpu map + +Signed-off-by: Xu Yandong +--- + src/cpu_map/Makefile.inc.am | 5 +++++ + src/cpu_map/arm_Kunpeng-T82.xml | 24 ++++++++++++++++++++++++ + src/cpu_map/arm_cortex-a53.xml | 6 ++++++ + src/cpu_map/arm_cortex-a57.xml | 6 ++++++ + src/cpu_map/arm_cortex-a72.xml | 6 ++++++ + src/cpu_map/arm_vendors.xml | 14 ++++++++++++++ + src/cpu_map/index.xml | 12 ++++++++++++ + 7 files changed, 73 insertions(+) + create mode 100644 src/cpu_map/arm_Kunpeng-T82.xml + create mode 100644 src/cpu_map/arm_cortex-a53.xml + create mode 100644 src/cpu_map/arm_cortex-a57.xml + create mode 100644 src/cpu_map/arm_cortex-a72.xml + create mode 100644 src/cpu_map/arm_vendors.xml + +diff --git a/src/cpu_map/Makefile.inc.am b/src/cpu_map/Makefile.inc.am +index ce8a311..3b63203 100644 +--- a/src/cpu_map/Makefile.inc.am ++++ b/src/cpu_map/Makefile.inc.am +@@ -60,6 +60,11 @@ cpumap_DATA = \ + cpu_map/x86_Skylake-Server-IBRS.xml \ + cpu_map/x86_Westmere.xml \ + cpu_map/x86_Westmere-IBRS.xml \ ++ cpu_map/arm_vendors.xml \ ++ cpu_map/arm_cortex-a53.xml \ ++ cpu_map/arm_cortex-a57.xml \ ++ cpu_map/arm_cortex-a72.xml \ ++ cpu_map/arm_Kunpeng-T82.xml \ + $(NULL) + + EXTRA_DIST += $(cpumap_DATA) +diff --git a/src/cpu_map/arm_Kunpeng-T82.xml b/src/cpu_map/arm_Kunpeng-T82.xml +new file mode 100644 +index 0000000..619a2ef +--- /dev/null ++++ b/src/cpu_map/arm_Kunpeng-T82.xml +@@ -0,0 +1,24 @@ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ +diff --git a/src/cpu_map/arm_cortex-a53.xml b/src/cpu_map/arm_cortex-a53.xml +new file mode 100644 +index 0000000..3580236 +--- /dev/null ++++ b/src/cpu_map/arm_cortex-a53.xml +@@ -0,0 +1,6 @@ ++ ++ ++ ++ ++ ++ +diff --git a/src/cpu_map/arm_cortex-a57.xml b/src/cpu_map/arm_cortex-a57.xml +new file mode 100644 +index 0000000..3bc4324 +--- /dev/null ++++ b/src/cpu_map/arm_cortex-a57.xml +@@ -0,0 +1,6 @@ ++ ++ ++ ++ ++ ++ +diff --git a/src/cpu_map/arm_cortex-a72.xml b/src/cpu_map/arm_cortex-a72.xml +new file mode 100644 +index 0000000..c509a40 +--- /dev/null ++++ b/src/cpu_map/arm_cortex-a72.xml +@@ -0,0 +1,6 @@ ++ ++ ++ ++ ++ ++ +diff --git a/src/cpu_map/arm_vendors.xml b/src/cpu_map/arm_vendors.xml +new file mode 100644 +index 0000000..840bf9a +--- /dev/null ++++ b/src/cpu_map/arm_vendors.xml +@@ -0,0 +1,14 @@ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ +diff --git a/src/cpu_map/index.xml b/src/cpu_map/index.xml +index 3c6885f..d222fd3 100644 +--- a/src/cpu_map/index.xml ++++ b/src/cpu_map/index.xml +@@ -75,4 +75,16 @@ + + + ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ + +-- +2.19.1 + diff --git a/libvirt-event-reference-state-only-when-virEventAddTimeout-s.patch b/libvirt-event-reference-state-only-when-virEventAddTimeout-s.patch new file mode 100644 index 0000000..8cd3ee8 --- /dev/null +++ b/libvirt-event-reference-state-only-when-virEventAddTimeout-s.patch @@ -0,0 +1,55 @@ +From 554597f2fc6fec3191426a88fd2e5a19246a989a Mon Sep 17 00:00:00 2001 +From: Xu Yandong +Date: Thu, 25 Jul 2019 16:08:41 +0800 +Subject: [PATCH] event: reference state only when virEventAddTimeout success + +Reference state is not necessary when virEventAddTimeout failed, +this may cause a memory leak, so reference state only when +virEventAddTimeout success. + +Signed-off-by: Xu Yandong +--- + src/conf/object_event.c | 25 +++++++++++++------------ + 1 file changed, 13 insertions(+), 12 deletions(-) + +diff --git a/src/conf/object_event.c b/src/conf/object_event.c +index 5d84598..ee5def5 100644 +--- a/src/conf/object_event.c ++++ b/src/conf/object_event.c +@@ -891,20 +891,21 @@ virObjectEventStateRegisterID(virConnectPtr conn, + virObjectLock(state); + + if ((state->callbacks->count == 0) && +- (state->timer == -1) && +- (state->timer = virEventAddTimeout(-1, +- virObjectEventTimer, +- state, +- virObjectFreeCallback)) < 0) { +- virReportError(VIR_ERR_INTERNAL_ERROR, "%s", +- _("could not initialize domain event timer")); +- goto cleanup; ++ (state->timer == -1)) { ++ if ((state->timer = virEventAddTimeout(-1, ++ virObjectEventTimer, ++ state, ++ virObjectFreeCallback)) < 0) { ++ virReportError(VIR_ERR_INTERNAL_ERROR, "%s", ++ _("could not initialize domain event timer")); ++ goto cleanup; ++ } else { ++ /* event loop has one reference, but we need one more for the ++ * timer's opaque argument */ ++ virObjectRef(state); ++ } + } + +- /* event loop has one reference, but we need one more for the +- * timer's opaque argument */ +- virObjectRef(state); +- + ret = virObjectEventCallbackListAddID(conn, state->callbacks, + key, filter, filter_opaque, + klass, eventID, +-- +2.19.1 + diff --git a/libvirt-hostdev-remove-unnessary-virObjectUnref-after-use-VI.patch b/libvirt-hostdev-remove-unnessary-virObjectUnref-after-use-VI.patch new file mode 100644 index 0000000..3f17532 --- /dev/null +++ b/libvirt-hostdev-remove-unnessary-virObjectUnref-after-use-VI.patch @@ -0,0 +1,29 @@ +From b32fefd72878ca398f9a83c9eea3533f74dfcd5a Mon Sep 17 00:00:00 2001 +From: Xu Yandong +Date: Wed, 28 Aug 2019 10:45:02 +0800 +Subject: [PATCH] hostdev: remove unnessary virObjectUnref after use + VIR_AUTOUNREF + +After introduce the VIR_AUTOUNREF macro, virObjectUnref is no +longer needed. + +Signed-off-by: Xu Yandong +--- + src/util/virhostdev.c | 1 - + 1 file changed, 1 deletion(-) + +diff --git a/src/util/virhostdev.c b/src/util/virhostdev.c +index a3647a6..271a654 100644 +--- a/src/util/virhostdev.c ++++ b/src/util/virhostdev.c +@@ -1081,7 +1081,6 @@ virHostdevReAttachPCIDevices(virHostdevManagerPtr mgr, + + virObjectUnlock(mgr->activePCIHostdevs); + virObjectUnlock(mgr->inactivePCIHostdevs); +- virObjectUnref(pcidevs); + } + + int +-- +2.19.1 + diff --git a/libvirt-libvirtd-fix-driver-cleanup-order-to-avoid-coredump.patch b/libvirt-libvirtd-fix-driver-cleanup-order-to-avoid-coredump.patch new file mode 100644 index 0000000..847ec53 --- /dev/null +++ b/libvirt-libvirtd-fix-driver-cleanup-order-to-avoid-coredump.patch @@ -0,0 +1,47 @@ +From d2be5a59d36a743505185c0f5bb636088a6e37da Mon Sep 17 00:00:00 2001 +From: Wu Jing +Date: Thu, 15 Aug 2019 19:33:16 +0800 +Subject: [PATCH] libvirtd: fix driver cleanup order to avoid coredump + +In cleanup process, there may be some threads still working and accessing objs +of drivers. We should put virStateCleanup at the end. + +Signed-off-by: Wu Jing +--- + src/remote/remote_daemon.c | 14 +++++++------- + 1 file changed, 7 insertions(+), 7 deletions(-) + +diff --git a/src/remote/remote_daemon.c b/src/remote/remote_daemon.c +index fdc9e43..ece4baa 100644 +--- a/src/remote/remote_daemon.c ++++ b/src/remote/remote_daemon.c +@@ -1379,13 +1379,6 @@ int main(int argc, char **argv) { + + virNetlinkEventServiceStopAll(); + +- if (driversInitialized) { +- /* NB: Possible issue with timing window between driversInitialized +- * setting if virNetlinkEventServerStart fails */ +- driversInitialized = false; +- virStateCleanup(); +- } +- + virObjectUnref(adminProgram); + virObjectUnref(srvAdm); + virObjectUnref(qemuProgram); +@@ -1419,5 +1412,12 @@ int main(int argc, char **argv) { + VIR_FREE(remote_config_file); + daemonConfigFree(config); + ++ if (driversInitialized) { ++ /* NB: Possible issue with timing window between driversInitialized ++ * setting if virNetlinkEventServerStart fails */ ++ driversInitialized = false; ++ virStateCleanup(); ++ } ++ + return ret; + } +-- +2.19.1 + diff --git a/libvirt-nodedev-fix-potential-heap-use-after-free.patch b/libvirt-nodedev-fix-potential-heap-use-after-free.patch new file mode 100644 index 0000000..1e1cfdf --- /dev/null +++ b/libvirt-nodedev-fix-potential-heap-use-after-free.patch @@ -0,0 +1,60 @@ +From c53f20683ef66939d94e690e875500628a5b4f3f Mon Sep 17 00:00:00 2001 +From: Xu Yandong +Date: Thu, 29 Aug 2019 16:31:30 +0800 +Subject: [PATCH] nodedev: fix potential heap use after free + +After move device enumumeration into a thread(commit 9f0ae0b18e3), +flag driversInitialized no longer represent stateInitialized finished +complete, so reference driver->devs before use it to prevent devs freed +by virStateCleanup. + +Signed-off-by: Xu Yandong +--- + src/node_device/node_device_udev.c | 8 ++++++-- + 1 file changed, 6 insertions(+), 2 deletions(-) + +diff --git a/src/node_device/node_device_udev.c b/src/node_device/node_device_udev.c +index 276bf3d..cac9447 100644 +--- a/src/node_device/node_device_udev.c ++++ b/src/node_device/node_device_udev.c +@@ -1321,9 +1321,12 @@ udevAddOneDevice(struct udev_device *device) + virNodeDeviceObjPtr obj = NULL; + virNodeDeviceDefPtr objdef; + virObjectEventPtr event = NULL; ++ virNodeDeviceObjListPtr devs = driver->devs; + bool new_device = true; + int ret = -1; + ++ virObjectRef(devs); ++ + if (VIR_ALLOC(def) != 0) + goto cleanup; + +@@ -1348,14 +1351,14 @@ udevAddOneDevice(struct udev_device *device) + if (udevSetParent(device, def) != 0) + goto cleanup; + +- if ((obj = virNodeDeviceObjListFindByName(driver->devs, def->name))) { ++ if ((obj = virNodeDeviceObjListFindByName(devs, def->name))) { + virNodeDeviceObjEndAPI(&obj); + new_device = false; + } + + /* If this is a device change, the old definition will be freed + * and the current definition will take its place. */ +- if (!(obj = virNodeDeviceObjListAssignDef(driver->devs, def))) ++ if (!(obj = virNodeDeviceObjListAssignDef(devs, def))) + goto cleanup; + objdef = virNodeDeviceObjGetDef(obj); + +@@ -1371,6 +1374,7 @@ udevAddOneDevice(struct udev_device *device) + ret = 0; + + cleanup: ++ virObjectUnref(devs); + virObjectEventStateQueue(driver->nodeDeviceEventState, event); + + if (ret != 0) { +-- +2.19.1 + diff --git a/libvirt-qemu-Relax-os.loader-type-check-when-validating-doma.patch b/libvirt-qemu-Relax-os.loader-type-check-when-validating-doma.patch new file mode 100644 index 0000000..d3bc7e7 --- /dev/null +++ b/libvirt-qemu-Relax-os.loader-type-check-when-validating-doma.patch @@ -0,0 +1,98 @@ +From f8c3c7f120aafa218615b7f6e4b380538efeb674 Mon Sep 17 00:00:00 2001 +From: Michal Privoznik +Date: Sat, 13 Jul 2019 09:17:06 +0200 +Subject: [PATCH] qemu: Relax os.loader->type check when validating domain + +When validating a domain among all the checks there are two that +concern VIR_DOMAIN_LOADER_TYPE_PFLASH specifically. The first +check ensures that on x86 ACPI is enabled when UEFI is requested, +the second ensures that UEFI is used when ACPI is requested on +aarch64. However, check for UEFI is done by plain comparison of +def->os.loader->type which is insufficient because we have +def->os.firmware too. + +NB, this wouldn't be a problem for active domain, because on +startup process def->os.loader->type gets filled by +qemuFirmwareEnableFeatures(), but that's not the case for +inactive domains. + +Fixes: https://bugzilla.redhat.com/show_bug.cgi?id=1729604 + +Signed-off-by: Michal Privoznik +Reviewed-by: Andrea Bolognani +(cherry-picked from commit 7711a7346a990810603c0715d3c6ba922eb88c51) +Signed-off-by: Xu Yandong +--- + src/qemu/qemu_domain.c | 10 ++++++---- + .../aarch64-os-firmware-efi.aarch64-latest.args | 1 - + tests/qemuxml2argvdata/aarch64-os-firmware-efi.xml | 1 + + .../aarch64-os-firmware-efi.aarch64-latest.xml | 1 + + 4 files changed, 8 insertions(+), 5 deletions(-) + +diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c +index d71d9b3..56fadd5 100644 +--- a/src/qemu/qemu_domain.c ++++ b/src/qemu/qemu_domain.c +@@ -4230,8 +4230,9 @@ qemuDomainDefValidate(const virDomainDef *def, + } + + /* On x86, UEFI requires ACPI */ +- if (def->os.loader && +- def->os.loader->type == VIR_DOMAIN_LOADER_TYPE_PFLASH && ++ if ((def->os.firmware == VIR_DOMAIN_OS_DEF_FIRMWARE_EFI || ++ (def->os.loader && ++ def->os.loader->type == VIR_DOMAIN_LOADER_TYPE_PFLASH)) && + ARCH_IS_X86(def->os.arch) && + def->features[VIR_DOMAIN_FEATURE_ACPI] != VIR_TRISTATE_SWITCH_ON) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", +@@ -4242,8 +4243,9 @@ qemuDomainDefValidate(const virDomainDef *def, + /* On aarch64, ACPI requires UEFI */ + if (def->features[VIR_DOMAIN_FEATURE_ACPI] == VIR_TRISTATE_SWITCH_ON && + def->os.arch == VIR_ARCH_AARCH64 && +- (!def->os.loader || +- def->os.loader->type != VIR_DOMAIN_LOADER_TYPE_PFLASH)) { ++ (def->os.firmware != VIR_DOMAIN_OS_DEF_FIRMWARE_EFI && ++ (!def->os.loader || ++ def->os.loader->type != VIR_DOMAIN_LOADER_TYPE_PFLASH))) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("ACPI requires UEFI on this architecture")); + goto cleanup; +diff --git a/tests/qemuxml2argvdata/aarch64-os-firmware-efi.aarch64-latest.args b/tests/qemuxml2argvdata/aarch64-os-firmware-efi.aarch64-latest.args +index 9821e28..3914b6b 100644 +--- a/tests/qemuxml2argvdata/aarch64-os-firmware-efi.aarch64-latest.args ++++ b/tests/qemuxml2argvdata/aarch64-os-firmware-efi.aarch64-latest.args +@@ -29,7 +29,6 @@ format=raw,unit=1 \ + -mon chardev=charmonitor,id=monitor,mode=control \ + -rtc base=utc \ + -no-shutdown \ +--no-acpi \ + -boot strict=on \ + -kernel /aarch64.kernel \ + -initrd /aarch64.initrd \ +diff --git a/tests/qemuxml2argvdata/aarch64-os-firmware-efi.xml b/tests/qemuxml2argvdata/aarch64-os-firmware-efi.xml +index c3e25f3..48605f7 100644 +--- a/tests/qemuxml2argvdata/aarch64-os-firmware-efi.xml ++++ b/tests/qemuxml2argvdata/aarch64-os-firmware-efi.xml +@@ -13,6 +13,7 @@ + + + ++ + + + +diff --git a/tests/qemuxml2xmloutdata/aarch64-os-firmware-efi.aarch64-latest.xml b/tests/qemuxml2xmloutdata/aarch64-os-firmware-efi.aarch64-latest.xml +index 529ce6f..1e51d55 100644 +--- a/tests/qemuxml2xmloutdata/aarch64-os-firmware-efi.aarch64-latest.xml ++++ b/tests/qemuxml2xmloutdata/aarch64-os-firmware-efi.aarch64-latest.xml +@@ -13,6 +13,7 @@ + + + ++ + + + +-- +2.19.1 + diff --git a/libvirt-qemu-Validate-disk-against-domain-def-on-coldplug.patch b/libvirt-qemu-Validate-disk-against-domain-def-on-coldplug.patch new file mode 100644 index 0000000..af1aeb3 --- /dev/null +++ b/libvirt-qemu-Validate-disk-against-domain-def-on-coldplug.patch @@ -0,0 +1,56 @@ +From c829c453baad259c1161dcd4bfed4b9a9372e6b2 Mon Sep 17 00:00:00 2001 +From: Michal Privoznik +Date: Wed, 26 Jun 2019 15:35:11 +0200 +Subject: [PATCH] qemu: Validate disk against domain def on coldplug + +https://bugzilla.redhat.com/show_bug.cgi?id=1692296#c7 + +This is a counterpart for ddc72f99027 and implements the same +check for coldplug. + +Signed-off-by: Michal Privoznik +Reviewed-by: Erik Skultety +(cherry-picked from commit 881686d4b15306fd5a5f0592d502ddb33ee6437e) +Signed-off-by: Xu Yandong +--- + src/qemu/qemu_driver.c | 17 +++++++++++++++++ + 1 file changed, 17 insertions(+) + +diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c +index 5791c42..f80bdeb 100644 +--- a/src/qemu/qemu_driver.c ++++ b/src/qemu/qemu_driver.c +@@ -8078,6 +8078,21 @@ qemuDomainUpdateDeviceLive(virDomainObjPtr vm, + return ret; + } + ++ ++static int ++qemuCheckDiskConfigAgainstDomain(const virDomainDef *def, ++ const virDomainDiskDef *disk) ++{ ++ if (virDomainSCSIDriveAddressIsUsed(def, &disk->info.addr.drive)) { ++ virReportError(VIR_ERR_OPERATION_INVALID, "%s", ++ _("Domain already contains a disk with that address")); ++ return -1; ++ } ++ ++ return 0; ++} ++ ++ + static int + qemuDomainAttachDeviceConfig(virDomainDefPtr vmdef, + virDomainDeviceDefPtr dev, +@@ -8106,6 +8121,8 @@ qemuDomainAttachDeviceConfig(virDomainDefPtr vmdef, + return -1; + if (qemuCheckDiskConfig(disk, NULL) < 0) + return -1; ++ if (qemuCheckDiskConfigAgainstDomain(vmdef, disk) < 0) ++ return -1; + if (virDomainDiskInsert(vmdef, disk) < 0) + return -1; + /* vmdef has the pointer. Generic codes for vmdef will do all jobs */ +-- +2.19.1 + diff --git a/libvirt-qemu-add-pointer-check-in-qemuMonitorLastError.patch b/libvirt-qemu-add-pointer-check-in-qemuMonitorLastError.patch new file mode 100644 index 0000000..f2ffd31 --- /dev/null +++ b/libvirt-qemu-add-pointer-check-in-qemuMonitorLastError.patch @@ -0,0 +1,31 @@ +From 7487eaefca026da3b0ccc8e8872a8e7ba0101640 Mon Sep 17 00:00:00 2001 +From: Feng Ni +Date: Thu, 25 Jul 2019 15:37:14 +0800 +Subject: [PATCH] qemu: add pointer check in qemuMonitorLastError + +We found a exception when libvirt occurrs segmentation fault. +thread 1 is waiting object lock in qemuConnectMonitor, +qemu process exits and sends EOF event as well, so thread 2 invokes +qemuMonitorLastError but pointer mon is NULL. + +Signed-off-by: Feng Ni +--- + src/qemu/qemu_monitor.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/src/qemu/qemu_monitor.c b/src/qemu/qemu_monitor.c +index 731be2e..a5eeec6 100644 +--- a/src/qemu/qemu_monitor.c ++++ b/src/qemu/qemu_monitor.c +@@ -1103,7 +1103,7 @@ qemuMonitorSend(qemuMonitorPtr mon, + virErrorPtr + qemuMonitorLastError(qemuMonitorPtr mon) + { +- if (mon->lastError.code == VIR_ERR_OK) ++ if (!mon || mon->lastError.code == VIR_ERR_OK) + return NULL; + + return virErrorCopyNew(&mon->lastError); +-- +2.19.1 + diff --git a/libvirt-qemu-clear-vcpupin-when-unhotplug-vcpu.patch b/libvirt-qemu-clear-vcpupin-when-unhotplug-vcpu.patch new file mode 100644 index 0000000..2946315 --- /dev/null +++ b/libvirt-qemu-clear-vcpupin-when-unhotplug-vcpu.patch @@ -0,0 +1,42 @@ +From d65307ab8bfeb67075bef1fb643aaaf3fa86a790 Mon Sep 17 00:00:00 2001 +From: Feng Ni +Date: Thu, 25 Jul 2019 20:29:11 +0800 +Subject: [PATCH] qemu: clear vcpupin when unhotplug vcpu + +step1: hotplug vcpus +step2: pin vcpus +step3: unhotplug vcpus +As a result, vcpu pin info still show up in xml. +So we need clear it. + +Signed-off-by: Feng Ni +--- + src/qemu/qemu_hotplug.c | 5 +++++ + 1 file changed, 5 insertions(+) + +diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c +index 7e9c1a1..08b6e8b 100644 +--- a/src/qemu/qemu_hotplug.c ++++ b/src/qemu/qemu_hotplug.c +@@ -6008,6 +6008,9 @@ qemuDomainHotplugDelVcpu(virQEMUDriverPtr driver, + + qemuDomainVcpuPersistOrder(vm->def); + ++ virBitmapFree(vcpuinfo->cpumask); ++ vcpuinfo->cpumask = NULL; ++ + if (virDomainSaveStatus(driver->xmlopt, cfg->stateDir, vm, driver->caps) < 0) + goto cleanup; + +@@ -6293,6 +6296,8 @@ qemuDomainSetVcpusConfig(virDomainDefPtr def, + + vcpu->online = false; + vcpu->hotpluggable = VIR_TRISTATE_BOOL_YES; ++ virBitmapFree(vcpu->cpumask); ++ vcpu->cpumask = NULL; + + if (--curvcpus == nvcpus) + break; +-- +2.19.1 + diff --git a/libvirt-qemu-fix-Validate-scsi-disk-against-domain-def-on-co.patch b/libvirt-qemu-fix-Validate-scsi-disk-against-domain-def-on-co.patch new file mode 100644 index 0000000..3306f69 --- /dev/null +++ b/libvirt-qemu-fix-Validate-scsi-disk-against-domain-def-on-co.patch @@ -0,0 +1,29 @@ +From 04c959123d238c5922389381b02155bc8b66dc6c Mon Sep 17 00:00:00 2001 +From: Xu Yandong +Date: Fri, 16 Aug 2019 21:00:10 +0800 +Subject: [PATCH] qemu: fix Validate scsi disk against domain def on coldplug + +Check the disk scsi address only when the disk is scsi type. + +Signed-off-by: Xu Yandong +--- + src/qemu/qemu_driver.c | 3 ++- + 1 file changed, 2 insertions(+), 1 deletion(-) + +diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c +index f80bdeb..617d7d5 100644 +--- a/src/qemu/qemu_driver.c ++++ b/src/qemu/qemu_driver.c +@@ -8083,7 +8083,8 @@ static int + qemuCheckDiskConfigAgainstDomain(const virDomainDef *def, + const virDomainDiskDef *disk) + { +- if (virDomainSCSIDriveAddressIsUsed(def, &disk->info.addr.drive)) { ++ if (disk->bus == VIR_DOMAIN_DISK_BUS_SCSI && ++ virDomainSCSIDriveAddressIsUsed(def, &disk->info.addr.drive)) { + virReportError(VIR_ERR_OPERATION_INVALID, "%s", + _("Domain already contains a disk with that address")); + return -1; +-- +2.19.1 + diff --git a/libvirt-qemu-fix-a-concurrent-operation-situation.patch b/libvirt-qemu-fix-a-concurrent-operation-situation.patch new file mode 100644 index 0000000..dbbbf3a --- /dev/null +++ b/libvirt-qemu-fix-a-concurrent-operation-situation.patch @@ -0,0 +1,33 @@ +From 19078ccc1e2160dcb4b223097c6bbc032567514b Mon Sep 17 00:00:00 2001 +From: Feng Ni +Date: Thu, 25 Jul 2019 20:43:07 +0800 +Subject: [PATCH] qemu: fix a concurrent operation situation + +Migrate vm and shutdown in guestos, interface do not return occasionally. +In function qemuMigrationSrcNBDStorageCopy, it may be alays in while loop +if qemu exits. + +Signed-off-by: Feng Ni +--- + src/qemu/qemu_migration.c | 5 +++++ + 1 file changed, 5 insertions(+) + +diff --git a/src/qemu/qemu_migration.c b/src/qemu/qemu_migration.c +index 2436f50..c6f2436 100644 +--- a/src/qemu/qemu_migration.c ++++ b/src/qemu/qemu_migration.c +@@ -1032,6 +1032,11 @@ qemuMigrationSrcNBDStorageCopy(virQEMUDriverPtr driver, + if (rv < 0) + goto cleanup; + ++ if (!virDomainObjIsActive(vm)) { ++ VIR_ERROR(_("domain is no longer running, migrate will end")); ++ goto cleanup; ++ } ++ + if (priv->job.abortJob) { + priv->job.current->status = QEMU_DOMAIN_JOB_STATUS_CANCELED; + virReportError(VIR_ERR_OPERATION_ABORTED, _("%s: %s"), +-- +2.19.1 + diff --git a/libvirt-qemu-fix-potential-memory-leak.patch b/libvirt-qemu-fix-potential-memory-leak.patch new file mode 100644 index 0000000..2a97fce --- /dev/null +++ b/libvirt-qemu-fix-potential-memory-leak.patch @@ -0,0 +1,74 @@ +From 34b8be0d7bd7980ee8be6ca70685788ed81b087b Mon Sep 17 00:00:00 2001 +From: Feng Ni +Date: Thu, 25 Jul 2019 15:20:52 +0800 +Subject: [PATCH] qemu: fix potential memory leak + +function virTypedParamsAddString may return -1 but alloc params, +so invoker should free it. + +Signed-off-by: Feng Ni +--- + src/qemu/qemu_driver.c | 12 ++++++++++++ + 1 file changed, 12 insertions(+) + +diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c +index ef2e980..5791c42 100644 +--- a/src/qemu/qemu_driver.c ++++ b/src/qemu/qemu_driver.c +@@ -5093,6 +5093,8 @@ qemuDomainPinVcpuLive(virDomainObjPtr vm, + goto cleanup; + + event = virDomainEventTunableNewFromObj(vm, eventParams, eventNparams); ++ eventParams = NULL; ++ eventNparams = 0; + + ret = 0; + +@@ -5101,6 +5103,8 @@ qemuDomainPinVcpuLive(virDomainObjPtr vm, + virCgroupFree(&cgroup_vcpu); + VIR_FREE(str); + virObjectEventStateQueue(driver->domainEventState, event); ++ if (eventParams) ++ virTypedParamsFree(eventParams, eventNparams); + return ret; + } + +@@ -5308,6 +5312,8 @@ qemuDomainPinEmulator(virDomainPtr dom, + goto endjob; + + event = virDomainEventTunableNewFromDom(dom, eventParams, eventNparams); ++ eventParams = NULL; ++ eventNparams = 0; + } + + if (persistentDef) { +@@ -5329,6 +5335,8 @@ qemuDomainPinEmulator(virDomainPtr dom, + cleanup: + if (cgroup_emulator) + virCgroupFree(&cgroup_emulator); ++ if (eventParams) ++ virTypedParamsFree(eventParams, eventNparams); + virObjectEventStateQueue(driver->domainEventState, event); + VIR_FREE(str); + virBitmapFree(pcpumap); +@@ -5793,6 +5801,8 @@ qemuDomainPinIOThread(virDomainPtr dom, + goto endjob; + + event = virDomainEventTunableNewFromDom(dom, eventParams, eventNparams); ++ eventParams = NULL; ++ eventNparams = 0; + } + + if (persistentDef) { +@@ -5824,6 +5834,8 @@ qemuDomainPinIOThread(virDomainPtr dom, + cleanup: + if (cgroup_iothread) + virCgroupFree(&cgroup_iothread); ++ if (eventParams) ++ virTypedParamsFree(eventParams, eventNparams); + virObjectEventStateQueue(driver->domainEventState, event); + VIR_FREE(str); + virBitmapFree(pcpumap); +-- +2.19.1 + diff --git a/libvirt-qemu_conf-clear-domain-before-VIR_DELETE_ELEMENT.patch b/libvirt-qemu_conf-clear-domain-before-VIR_DELETE_ELEMENT.patch new file mode 100644 index 0000000..e57b792 --- /dev/null +++ b/libvirt-qemu_conf-clear-domain-before-VIR_DELETE_ELEMENT.patch @@ -0,0 +1,36 @@ +From ba3884fbb6321923d6b3f88dce82ba01974f8a4d Mon Sep 17 00:00:00 2001 +From: Xu Yandong +Date: Thu, 25 Jul 2019 12:18:23 +0800 +Subject: [PATCH] qemu_conf: clear domain before VIR_DELETE_ELEMENT + +The macro VIR_DELETE_ELEMENT assume that the items being deleted have +already been cleared, so we must explicitly delete domain memory to +prevent a memory leak. + +Signed-off-by: Xu Yandong +--- + src/qemu/qemu_conf.c | 6 ++++-- + 1 file changed, 4 insertions(+), 2 deletions(-) + +diff --git a/src/qemu/qemu_conf.c b/src/qemu/qemu_conf.c +index 8312f99..29bd07e 100644 +--- a/src/qemu/qemu_conf.c ++++ b/src/qemu/qemu_conf.c +@@ -1672,10 +1672,12 @@ qemuSharedDeviceEntryRemove(virQEMUDriverPtr driver, + if (!qemuSharedDeviceEntryDomainExists(entry, name, &idx)) + return 0; + +- if (entry->ref != 1) ++ if (entry->ref != 1) { ++ VIR_FREE(entry->domains[idx]); + VIR_DELETE_ELEMENT(entry->domains, idx, entry->ref); +- else ++ } else { + ignore_value(virHashRemoveEntry(driver->sharedDevices, key)); ++ } + + return 0; + } +-- +2.19.1 + diff --git a/libvirt-remote-fix-a-memory-free-error.patch b/libvirt-remote-fix-a-memory-free-error.patch new file mode 100644 index 0000000..f7d1ccb --- /dev/null +++ b/libvirt-remote-fix-a-memory-free-error.patch @@ -0,0 +1,28 @@ +From 2a4b0d76a0701f8895d612918ad77a30a2062263 Mon Sep 17 00:00:00 2001 +From: Feng Ni +Date: Thu, 25 Jul 2019 15:26:25 +0800 +Subject: [PATCH] remote: fix a memory free error + +In function remoteDeserializeDomainDiskErrors, there is a typo. + +Signed-off-by: Feng Ni +--- + src/remote/remote_driver.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/src/remote/remote_driver.c b/src/remote/remote_driver.c +index df58b23..ba98212 100644 +--- a/src/remote/remote_driver.c ++++ b/src/remote/remote_driver.c +@@ -1813,7 +1813,7 @@ remoteDeserializeDomainDiskErrors(remote_domain_disk_error *ret_errors_val, + + error: + for (j = 0; j < i; j++) +- VIR_FREE(errors[i].disk); ++ VIR_FREE(errors[j].disk); + + return -1; + } +-- +2.19.1 + diff --git a/libvirt-remote-mention-libssh-in-error-message.patch b/libvirt-remote-mention-libssh-in-error-message.patch new file mode 100644 index 0000000..153a13f --- /dev/null +++ b/libvirt-remote-mention-libssh-in-error-message.patch @@ -0,0 +1,37 @@ +From 13722d386dc65077976d4c557ddcc3458493e9dc Mon Sep 17 00:00:00 2001 +From: Pino Toscano +Date: Thu, 4 Jul 2019 12:38:26 +0200 +Subject: [PATCH] remote: mention libssh in error message +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +Mention libssh as possible transport in the error message of an +unrecognized transport. + +https://bugzilla.redhat.com/show_bug.cgi?id=1727013 + +Signed-off-by: Pino Toscano +Reviewed-by: Daniel P. Berrangé +(cherry-picked from commit cfec206e84d6151007a38a9228e10a23b8df57a8) +Signed-off-by: Xu Yandong +--- + src/remote/remote_driver.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/src/remote/remote_driver.c b/src/remote/remote_driver.c +index ba98212..c5fcbdb 100644 +--- a/src/remote/remote_driver.c ++++ b/src/remote/remote_driver.c +@@ -825,7 +825,7 @@ doRemoteOpen(virConnectPtr conn, + } else { + virReportError(VIR_ERR_INVALID_ARG, "%s", + _("remote_open: transport in URL not recognised " +- "(should be tls|unix|ssh|ext|tcp|libssh2)")); ++ "(should be tls|unix|ssh|ext|tcp|libssh2|libssh)")); + return VIR_DRV_OPEN_ERROR; + } + } +-- +2.19.1 + diff --git a/libvirt-storage-rbd-actually-index-the-array-when-iterating-.patch b/libvirt-storage-rbd-actually-index-the-array-when-iterating-.patch new file mode 100644 index 0000000..f8f17f3 --- /dev/null +++ b/libvirt-storage-rbd-actually-index-the-array-when-iterating-.patch @@ -0,0 +1,35 @@ +From a86a87fc28aee52af46f75ad13e4638e00e06b34 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?J=C3=A1n=20Tomko?= +Date: Fri, 12 Jul 2019 16:11:16 +0200 +Subject: [PATCH] storage: rbd: actually index the array when iterating over it +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +https://bugzilla.redhat.com/show_bug.cgi?id=1729292 + +Fixes: 3aa190f2a43a632b542a6ba751a6c3ab4d51f1dd +Signed-off-by: Ján Tomko +Reviewed-by: Daniel P. Berrangé +(cherry-picked from commit 9b7c4048fa0559fd81d57b7f7d13b1dccd6a99b2) +Signed-off-by: Xu Yandong +--- + src/storage/storage_backend_rbd.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/src/storage/storage_backend_rbd.c b/src/storage/storage_backend_rbd.c +index d305628..1cb447c 100644 +--- a/src/storage/storage_backend_rbd.c ++++ b/src/storage/storage_backend_rbd.c +@@ -637,7 +637,7 @@ virStorageBackendRBDGetVolNames(virStorageBackendRBDStatePtr ptr) + nnames = nimages; + + for (i = 0; i < nimages; i++) +- VIR_STEAL_PTR(names[i], images->name); ++ VIR_STEAL_PTR(names[i], images[i]->name); + + return names; + +-- +2.19.1 + diff --git a/libvirt-storage-rbd-use-VIR_REALLOC-in-the-loop.patch b/libvirt-storage-rbd-use-VIR_REALLOC-in-the-loop.patch new file mode 100644 index 0000000..8c1c6ad --- /dev/null +++ b/libvirt-storage-rbd-use-VIR_REALLOC-in-the-loop.patch @@ -0,0 +1,35 @@ +From 51cf4c75664fd6653a3bf9cb8b83a5a1a0496e5f Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?J=C3=A1n=20Tomko?= +Date: Fri, 12 Jul 2019 16:09:32 +0200 +Subject: [PATCH] storage: rbd: use VIR_REALLOC in the loop +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +If there are more than 16 images, the memory allocated in images +might be leaked on subsequent execution(s). + +Signed-off-by: Ján Tomko +Reviewed-by: Daniel P. Berrangé +(cherry-picked from commit d43bc53eddd49c8c22cb52f8b6554e1f7d4216f8) +Signed-off-by: Xu Yandong +--- + src/storage/storage_backend_rbd.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/src/storage/storage_backend_rbd.c b/src/storage/storage_backend_rbd.c +index 315bef2..d305628 100644 +--- a/src/storage/storage_backend_rbd.c ++++ b/src/storage/storage_backend_rbd.c +@@ -620,7 +620,7 @@ virStorageBackendRBDGetVolNames(virStorageBackendRBDStatePtr ptr) + size_t i; + + while (true) { +- if (VIR_ALLOC_N(images, nimages) < 0) ++ if (VIR_REALLOC_N(images, nimages) < 0) + goto error; + + rc = rbd_list2(ptr->ioctx, images, &nimages); +-- +2.19.1 + diff --git a/libvirt-tests-add-baseline-test-cases-for-arm-CPU.patch b/libvirt-tests-add-baseline-test-cases-for-arm-CPU.patch new file mode 100644 index 0000000..b305e6b --- /dev/null +++ b/libvirt-tests-add-baseline-test-cases-for-arm-CPU.patch @@ -0,0 +1,263 @@ +From 940df0f99ab0fcc350fca0df29c74b2f6674cb8a Mon Sep 17 00:00:00 2001 +From: Xu Yandong +Date: Mon, 16 Oct 2017 17:45:48 +0800 +Subject: [PATCH] tests: add baseline test cases for arm CPU + +add baseline test cases for aarch64 + +Signed-off-by: Xu Yandong +--- + tests/cputest.c | 7 +++++ + .../aarch64-baseline-incompatible-vendors.xml | 26 +++++++++++++++++++ + ...-baseline-no-compatible-feature-result.xml | 4 +++ + ...aarch64-baseline-no-compatible-feature.xml | 19 ++++++++++++++ + .../aarch64-baseline-no-feature-result.xml | 4 +++ + .../aarch64-baseline-no-feature.xml | 7 +++++ + .../cputestdata/aarch64-baseline-no-model.xml | 13 ++++++++++ + .../aarch64-baseline-no-vendor-result.xml | 10 +++++++ + .../aarch64-baseline-no-vendor.xml | 13 ++++++++++ + ...baseline-one-compatible-feature-result.xml | 5 ++++ + ...arch64-baseline-one-compatible-feature.xml | 20 ++++++++++++++ + .../aarch64-baseline-one-feature-result.xml | 5 ++++ + .../aarch64-baseline-one-feature.xml | 8 ++++++ + 13 files changed, 141 insertions(+) + create mode 100644 tests/cputestdata/aarch64-baseline-incompatible-vendors.xml + create mode 100644 tests/cputestdata/aarch64-baseline-no-compatible-feature-result.xml + create mode 100644 tests/cputestdata/aarch64-baseline-no-compatible-feature.xml + create mode 100644 tests/cputestdata/aarch64-baseline-no-feature-result.xml + create mode 100644 tests/cputestdata/aarch64-baseline-no-feature.xml + create mode 100644 tests/cputestdata/aarch64-baseline-no-model.xml + create mode 100644 tests/cputestdata/aarch64-baseline-no-vendor-result.xml + create mode 100644 tests/cputestdata/aarch64-baseline-no-vendor.xml + create mode 100644 tests/cputestdata/aarch64-baseline-one-compatible-feature-result.xml + create mode 100644 tests/cputestdata/aarch64-baseline-one-compatible-feature.xml + create mode 100644 tests/cputestdata/aarch64-baseline-one-feature-result.xml + create mode 100644 tests/cputestdata/aarch64-baseline-one-feature.xml + +diff --git a/tests/cputest.c b/tests/cputest.c +index 6e28e05..ee754bb 100644 +--- a/tests/cputest.c ++++ b/tests/cputest.c +@@ -1207,6 +1207,13 @@ mymain(void) + DO_TEST_BASELINE(VIR_ARCH_PPC64, "same-model", 0, 0); + DO_TEST_BASELINE(VIR_ARCH_PPC64, "legacy", 0, -1); + ++ DO_TEST_BASELINE(VIR_ARCH_AARCH64, "incompatible-vendors", 0, -1); ++ DO_TEST_BASELINE(VIR_ARCH_AARCH64, "no-vendor", 0, 0); ++ DO_TEST_BASELINE(VIR_ARCH_AARCH64, "no-feature", 0, 0); ++ DO_TEST_BASELINE(VIR_ARCH_AARCH64, "one-feature", 0, 0); ++ DO_TEST_BASELINE(VIR_ARCH_AARCH64, "no-compatible-feature", 0, 0); ++ DO_TEST_BASELINE(VIR_ARCH_AARCH64, "one-compatible-feature", 0, 0); ++ + /* CPU features */ + DO_TEST_HASFEATURE(VIR_ARCH_X86_64, "host", "vmx", YES); + DO_TEST_HASFEATURE(VIR_ARCH_X86_64, "host", "lm", YES); +diff --git a/tests/cputestdata/aarch64-baseline-incompatible-vendors.xml b/tests/cputestdata/aarch64-baseline-incompatible-vendors.xml +new file mode 100644 +index 0000000..f2c71a1 +--- /dev/null ++++ b/tests/cputestdata/aarch64-baseline-incompatible-vendors.xml +@@ -0,0 +1,26 @@ ++ ++ ++ aarch64 ++ cortex-a57 ++ ARM ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ aarch64 ++ cortex-a72 ++ Hisilicon ++ ++ ++ ++ ++ ++ ++ ++ ++ +diff --git a/tests/cputestdata/aarch64-baseline-no-compatible-feature-result.xml b/tests/cputestdata/aarch64-baseline-no-compatible-feature-result.xml +new file mode 100644 +index 0000000..6db66aa +--- /dev/null ++++ b/tests/cputestdata/aarch64-baseline-no-compatible-feature-result.xml +@@ -0,0 +1,4 @@ ++ ++ cortex-a57 ++ ARM ++ +diff --git a/tests/cputestdata/aarch64-baseline-no-compatible-feature.xml b/tests/cputestdata/aarch64-baseline-no-compatible-feature.xml +new file mode 100644 +index 0000000..5fd3228 +--- /dev/null ++++ b/tests/cputestdata/aarch64-baseline-no-compatible-feature.xml +@@ -0,0 +1,19 @@ ++ ++ ++ aarch64 ++ cortex-a57 ++ ARM ++ ++ ++ ++ ++ ++ ++ ++ aarch64 ++ cortex-a57 ++ ARM ++ ++ ++ ++ +diff --git a/tests/cputestdata/aarch64-baseline-no-feature-result.xml b/tests/cputestdata/aarch64-baseline-no-feature-result.xml +new file mode 100644 +index 0000000..6db66aa +--- /dev/null ++++ b/tests/cputestdata/aarch64-baseline-no-feature-result.xml +@@ -0,0 +1,4 @@ ++ ++ cortex-a57 ++ ARM ++ +diff --git a/tests/cputestdata/aarch64-baseline-no-feature.xml b/tests/cputestdata/aarch64-baseline-no-feature.xml +new file mode 100644 +index 0000000..0d6af96 +--- /dev/null ++++ b/tests/cputestdata/aarch64-baseline-no-feature.xml +@@ -0,0 +1,7 @@ ++ ++ ++ aarch64 ++ cortex-a57 ++ ARM ++ ++ +diff --git a/tests/cputestdata/aarch64-baseline-no-model.xml b/tests/cputestdata/aarch64-baseline-no-model.xml +new file mode 100644 +index 0000000..6033e4c +--- /dev/null ++++ b/tests/cputestdata/aarch64-baseline-no-model.xml +@@ -0,0 +1,13 @@ ++ ++ ++ aarch64 ++ ARM ++ ++ ++ ++ ++ ++ ++ ++ ++ +diff --git a/tests/cputestdata/aarch64-baseline-no-vendor-result.xml b/tests/cputestdata/aarch64-baseline-no-vendor-result.xml +new file mode 100644 +index 0000000..c1d74c2 +--- /dev/null ++++ b/tests/cputestdata/aarch64-baseline-no-vendor-result.xml +@@ -0,0 +1,10 @@ ++ ++ cortex-a57 ++ ++ ++ ++ ++ ++ ++ ++ +diff --git a/tests/cputestdata/aarch64-baseline-no-vendor.xml b/tests/cputestdata/aarch64-baseline-no-vendor.xml +new file mode 100644 +index 0000000..8aacb3e +--- /dev/null ++++ b/tests/cputestdata/aarch64-baseline-no-vendor.xml +@@ -0,0 +1,13 @@ ++ ++ ++ aarch64 ++ cortex-a57 ++ ++ ++ ++ ++ ++ ++ ++ ++ +diff --git a/tests/cputestdata/aarch64-baseline-one-compatible-feature-result.xml b/tests/cputestdata/aarch64-baseline-one-compatible-feature-result.xml +new file mode 100644 +index 0000000..84c559d +--- /dev/null ++++ b/tests/cputestdata/aarch64-baseline-one-compatible-feature-result.xml +@@ -0,0 +1,5 @@ ++ ++ cortex-a57 ++ ARM ++ ++ +diff --git a/tests/cputestdata/aarch64-baseline-one-compatible-feature.xml b/tests/cputestdata/aarch64-baseline-one-compatible-feature.xml +new file mode 100644 +index 0000000..c85059b +--- /dev/null ++++ b/tests/cputestdata/aarch64-baseline-one-compatible-feature.xml +@@ -0,0 +1,20 @@ ++ ++ ++ aarch64 ++ cortex-a57 ++ ARM ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ aarch64 ++ cortex-a57 ++ ARM ++ ++ ++ +diff --git a/tests/cputestdata/aarch64-baseline-one-feature-result.xml b/tests/cputestdata/aarch64-baseline-one-feature-result.xml +new file mode 100644 +index 0000000..0fcea51 +--- /dev/null ++++ b/tests/cputestdata/aarch64-baseline-one-feature-result.xml +@@ -0,0 +1,5 @@ ++ ++ cortex-a57 ++ ARM ++ ++ +diff --git a/tests/cputestdata/aarch64-baseline-one-feature.xml b/tests/cputestdata/aarch64-baseline-one-feature.xml +new file mode 100644 +index 0000000..e0ae15f +--- /dev/null ++++ b/tests/cputestdata/aarch64-baseline-one-feature.xml +@@ -0,0 +1,8 @@ ++ ++ ++ aarch64 ++ cortex-a57 ++ ARM ++ ++ ++ +-- +2.19.1 + diff --git a/libvirt-tests-add-cpu-compare-test-cases-for-arm-CPU.patch b/libvirt-tests-add-cpu-compare-test-cases-for-arm-CPU.patch new file mode 100644 index 0000000..110996b --- /dev/null +++ b/libvirt-tests-add-cpu-compare-test-cases-for-arm-CPU.patch @@ -0,0 +1,171 @@ +From 0535b2880dd5804170490f8156a95964bd2f1ad3 Mon Sep 17 00:00:00 2001 +From: Xu Yandong +Date: Mon, 16 Oct 2017 17:55:48 +0800 +Subject: [PATCH] tests: add cpu compare test cases for arm CPU + +add cpu compare test cases for arm CPU + +Signed-off-by: Xu Yandong +--- + tests/cputest.c | 10 ++++++++++ + .../aarch64-guest-compat-incompatible.xml | 4 ++++ + tests/cputestdata/aarch64-guest-compat-none.xml | 1 + + tests/cputestdata/aarch64-guest-compat-valid.xml | 3 +++ + tests/cputestdata/aarch64-guest-exact.xml | 4 ++++ + tests/cputestdata/aarch64-guest-features-invalid.xml | 12 ++++++++++++ + tests/cputestdata/aarch64-guest-features-valid.xml | 7 +++++++ + .../aarch64-guest-legacy-incompatible.xml | 4 ++++ + tests/cputestdata/aarch64-guest-legacy.xml | 4 ++++ + tests/cputestdata/aarch64-guest-strict.xml | 4 ++++ + tests/cputestdata/aarch64-host.xml | 12 ++++++++++++ + 11 files changed, 65 insertions(+) + create mode 100644 tests/cputestdata/aarch64-guest-compat-incompatible.xml + create mode 100644 tests/cputestdata/aarch64-guest-compat-none.xml + create mode 100644 tests/cputestdata/aarch64-guest-compat-valid.xml + create mode 100644 tests/cputestdata/aarch64-guest-exact.xml + create mode 100644 tests/cputestdata/aarch64-guest-features-invalid.xml + create mode 100644 tests/cputestdata/aarch64-guest-features-valid.xml + create mode 100644 tests/cputestdata/aarch64-guest-legacy-incompatible.xml + create mode 100644 tests/cputestdata/aarch64-guest-legacy.xml + create mode 100644 tests/cputestdata/aarch64-guest-strict.xml + create mode 100644 tests/cputestdata/aarch64-host.xml + +diff --git a/tests/cputest.c b/tests/cputest.c +index ee754bb..c0903bf 100644 +--- a/tests/cputest.c ++++ b/tests/cputest.c +@@ -1163,6 +1163,16 @@ mymain(void) + DO_TEST_COMPARE(VIR_ARCH_PPC64, "host", "guest-compat-invalid", VIR_CPU_COMPARE_ERROR); + DO_TEST_COMPARE(VIR_ARCH_PPC64, "host", "guest-compat-incompatible", VIR_CPU_COMPARE_INCOMPATIBLE); + ++ DO_TEST_COMPARE(VIR_ARCH_AARCH64, "host", "guest-strict", VIR_CPU_COMPARE_IDENTICAL); ++ DO_TEST_COMPARE(VIR_ARCH_AARCH64, "host", "guest-exact", VIR_CPU_COMPARE_INCOMPATIBLE); ++ DO_TEST_COMPARE(VIR_ARCH_AARCH64, "host", "guest-legacy", VIR_CPU_COMPARE_IDENTICAL); ++ DO_TEST_COMPARE(VIR_ARCH_AARCH64, "host", "guest-legacy-incompatible", VIR_CPU_COMPARE_INCOMPATIBLE); ++ DO_TEST_COMPARE(VIR_ARCH_AARCH64, "host", "guest-compat-none", VIR_CPU_COMPARE_IDENTICAL); ++ DO_TEST_COMPARE(VIR_ARCH_AARCH64, "host", "guest-compat-valid", VIR_CPU_COMPARE_IDENTICAL); ++ DO_TEST_COMPARE(VIR_ARCH_AARCH64, "host", "guest-compat-incompatible", VIR_CPU_COMPARE_INCOMPATIBLE); ++ DO_TEST_COMPARE(VIR_ARCH_AARCH64, "host", "guest-features-valid", VIR_CPU_COMPARE_IDENTICAL); ++ DO_TEST_COMPARE(VIR_ARCH_AARCH64, "host", "guest-features-invalid", VIR_CPU_COMPARE_INCOMPATIBLE); ++ + /* guest updates for migration + * automatically compares host CPU with the result */ + DO_TEST_UPDATE(VIR_ARCH_X86_64, "host", "min", VIR_CPU_COMPARE_IDENTICAL); +diff --git a/tests/cputestdata/aarch64-guest-compat-incompatible.xml b/tests/cputestdata/aarch64-guest-compat-incompatible.xml +new file mode 100644 +index 0000000..f68ead5 +--- /dev/null ++++ b/tests/cputestdata/aarch64-guest-compat-incompatible.xml +@@ -0,0 +1,4 @@ ++ ++ cortex-a72 ++ ARM ++ +diff --git a/tests/cputestdata/aarch64-guest-compat-none.xml b/tests/cputestdata/aarch64-guest-compat-none.xml +new file mode 100644 +index 0000000..fd50c03 +--- /dev/null ++++ b/tests/cputestdata/aarch64-guest-compat-none.xml +@@ -0,0 +1 @@ ++ +diff --git a/tests/cputestdata/aarch64-guest-compat-valid.xml b/tests/cputestdata/aarch64-guest-compat-valid.xml +new file mode 100644 +index 0000000..0206d6e +--- /dev/null ++++ b/tests/cputestdata/aarch64-guest-compat-valid.xml +@@ -0,0 +1,3 @@ ++ ++ cortex-a57 ++ +diff --git a/tests/cputestdata/aarch64-guest-exact.xml b/tests/cputestdata/aarch64-guest-exact.xml +new file mode 100644 +index 0000000..bbbe65f +--- /dev/null ++++ b/tests/cputestdata/aarch64-guest-exact.xml +@@ -0,0 +1,4 @@ ++ ++ cortex-a72 ++ ARM ++ +diff --git a/tests/cputestdata/aarch64-guest-features-invalid.xml b/tests/cputestdata/aarch64-guest-features-invalid.xml +new file mode 100644 +index 0000000..afbb402 +--- /dev/null ++++ b/tests/cputestdata/aarch64-guest-features-invalid.xml +@@ -0,0 +1,12 @@ ++ ++ cortex-a57 ++ ARM ++ ++ ++ ++ ++ ++ ++ ++ ++ +diff --git a/tests/cputestdata/aarch64-guest-features-valid.xml b/tests/cputestdata/aarch64-guest-features-valid.xml +new file mode 100644 +index 0000000..0858f76 +--- /dev/null ++++ b/tests/cputestdata/aarch64-guest-features-valid.xml +@@ -0,0 +1,7 @@ ++ ++ cortex-a57 ++ ARM ++ ++ ++ ++ +diff --git a/tests/cputestdata/aarch64-guest-legacy-incompatible.xml b/tests/cputestdata/aarch64-guest-legacy-incompatible.xml +new file mode 100644 +index 0000000..2f1941d +--- /dev/null ++++ b/tests/cputestdata/aarch64-guest-legacy-incompatible.xml +@@ -0,0 +1,4 @@ ++ ++ cortex-a72 ++ ARM ++ +diff --git a/tests/cputestdata/aarch64-guest-legacy.xml b/tests/cputestdata/aarch64-guest-legacy.xml +new file mode 100644 +index 0000000..64a05e4 +--- /dev/null ++++ b/tests/cputestdata/aarch64-guest-legacy.xml +@@ -0,0 +1,4 @@ ++ ++ cortex-a57 ++ ARM ++ +diff --git a/tests/cputestdata/aarch64-guest-strict.xml b/tests/cputestdata/aarch64-guest-strict.xml +new file mode 100644 +index 0000000..a057ebd +--- /dev/null ++++ b/tests/cputestdata/aarch64-guest-strict.xml +@@ -0,0 +1,4 @@ ++ ++ cortex-a57 ++ ARM ++ +diff --git a/tests/cputestdata/aarch64-host.xml b/tests/cputestdata/aarch64-host.xml +new file mode 100644 +index 0000000..60c20f2 +--- /dev/null ++++ b/tests/cputestdata/aarch64-host.xml +@@ -0,0 +1,12 @@ ++ ++ aarch64 ++ cortex-a57 ++ ARM ++ ++ ++ ++ ++ ++ ++ ++ +-- +2.19.1 + diff --git a/libvirt-util-storage-Clean-up-label-use-in-virStorageFileGet.patch b/libvirt-util-storage-Clean-up-label-use-in-virStorageFileGet.patch new file mode 100644 index 0000000..85f2971 --- /dev/null +++ b/libvirt-util-storage-Clean-up-label-use-in-virStorageFileGet.patch @@ -0,0 +1,118 @@ +From b47d53edc1a00d845d2200f67f20edfc60dedc29 Mon Sep 17 00:00:00 2001 +From: Peter Krempa +Date: Thu, 18 Jul 2019 16:30:18 +0200 +Subject: [PATCH] util: storage: Clean up label use in + virStorageFileGetMetadataInternal +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +The function does not do any cleanup, so replace the 'cleanup' label +with return of -1 and the 'done' label with return of 0. + +Signed-off-by: Peter Krempa +Reviewed-by: Ján Tomko +Reviewed-by: Michal Privoznik +(cherry-picked from commit 5b8e64f0bcbbab826cff5be1b0adb000923abfb4) +Signed-off-by: Xu Yandong +--- + src/util/virstoragefile.c | 27 +++++++++++---------------- + 1 file changed, 11 insertions(+), 16 deletions(-) + +diff --git a/src/util/virstoragefile.c b/src/util/virstoragefile.c +index 269d005..4e2e754 100644 +--- a/src/util/virstoragefile.c ++++ b/src/util/virstoragefile.c +@@ -973,7 +973,6 @@ virStorageFileGetMetadataInternal(virStorageSourcePtr meta, + int *backingFormat) + { + int dummy; +- int ret = -1; + size_t i; + + if (!backingFormat) +@@ -989,7 +988,7 @@ virStorageFileGetMetadataInternal(virStorageSourcePtr meta, + meta->format >= VIR_STORAGE_FILE_LAST) { + virReportSystemError(EINVAL, _("unknown storage file meta->format %d"), + meta->format); +- goto cleanup; ++ return -1; + } + + if (fileTypeInfo[meta->format].cryptInfo != NULL) { +@@ -999,7 +998,7 @@ virStorageFileGetMetadataInternal(virStorageSourcePtr meta, + int expt_fmt = fileTypeInfo[meta->format].cryptInfo[i].format; + if (!meta->encryption) { + if (VIR_ALLOC(meta->encryption) < 0) +- goto cleanup; ++ return -1; + + meta->encryption->format = expt_fmt; + } else { +@@ -1008,7 +1007,7 @@ virStorageFileGetMetadataInternal(virStorageSourcePtr meta, + _("encryption format %d doesn't match " + "expected format %d"), + meta->encryption->format, expt_fmt); +- goto cleanup; ++ return -1; + } + } + meta->encryption->payload_offset = +@@ -1021,12 +1020,12 @@ virStorageFileGetMetadataInternal(virStorageSourcePtr meta, + * code into this method, for non-magic files + */ + if (!fileTypeInfo[meta->format].magic) +- goto done; ++ return 0; + + /* Optionally extract capacity from file */ + if (fileTypeInfo[meta->format].sizeOffset != -1) { + if ((fileTypeInfo[meta->format].sizeOffset + 8) > len) +- goto done; ++ return 0; + + if (fileTypeInfo[meta->format].endian == LV_LITTLE_ENDIAN) + meta->capacity = virReadBufInt64LE(buf + +@@ -1037,7 +1036,7 @@ virStorageFileGetMetadataInternal(virStorageSourcePtr meta, + /* Avoid unlikely, but theoretically possible overflow */ + if (meta->capacity > (ULLONG_MAX / + fileTypeInfo[meta->format].sizeMultiplier)) +- goto done; ++ return 0; + meta->capacity *= fileTypeInfo[meta->format].sizeMultiplier; + } + +@@ -1047,25 +1046,21 @@ virStorageFileGetMetadataInternal(virStorageSourcePtr meta, + backingFormat, + buf, len); + if (store == BACKING_STORE_INVALID) +- goto done; ++ return 0; + + if (store == BACKING_STORE_ERROR) +- goto cleanup; ++ return -1; + } + + if (fileTypeInfo[meta->format].getFeatures != NULL && + fileTypeInfo[meta->format].getFeatures(&meta->features, meta->format, buf, len) < 0) +- goto cleanup; ++ return -1; + + if (meta->format == VIR_STORAGE_FILE_QCOW2 && meta->features && + VIR_STRDUP(meta->compat, "1.1") < 0) +- goto cleanup; +- +- done: +- ret = 0; ++ return -1; + +- cleanup: +- return ret; ++ return 0; + } + + +-- +2.19.1 + diff --git a/libvirt-util-storage-Don-t-leak-metadata-on-repeated-calls-o.patch b/libvirt-util-storage-Don-t-leak-metadata-on-repeated-calls-o.patch new file mode 100644 index 0000000..d729a55 --- /dev/null +++ b/libvirt-util-storage-Don-t-leak-metadata-on-repeated-calls-o.patch @@ -0,0 +1,60 @@ +From 68947484f8411b50fd0a17548a4e92ec07628782 Mon Sep 17 00:00:00 2001 +From: Peter Krempa +Date: Thu, 18 Jul 2019 16:32:44 +0200 +Subject: [PATCH] util: storage: Don't leak metadata on repeated calls of + virStorageFileGetMetadata +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +When querying storage metadata after a block job we re-run +virStorageFileGetMetadata on the top level storage file. This means that +the workers (virStorageFileGetMetadataInternal) must not overwrite any +pointers without freeing them. + +This was not considered for src->compat and src->features. Fix it and +add a comment mentioning that. + +Signed-off-by: Peter Krempa +Reviewed-by: Ján Tomko +Reviewed-by: Michal Privoznik +(cherry-picked from commit f0430d069af991475de6fa83ed62a45f8669c645) +Signed-off-by: Xu Yandong +--- + src/util/virstoragefile.c | 9 ++++++++- + 1 file changed, 8 insertions(+), 1 deletion(-) + +diff --git a/src/util/virstoragefile.c b/src/util/virstoragefile.c +index 4e2e754..a6de6a1 100644 +--- a/src/util/virstoragefile.c ++++ b/src/util/virstoragefile.c +@@ -965,7 +965,11 @@ virStorageFileGetEncryptionPayloadOffset(const struct FileEncryptionInfo *info, + * assuming it has the given FORMAT, populate information into META + * with information about the file and its backing store. Return format + * of the backing store as BACKING_FORMAT. PATH and FORMAT have to be +- * pre-populated in META */ ++ * pre-populated in META. ++ * ++ * Note that this function may be called repeatedly on @meta, so it must ++ * clean up any existing allocated memory which would be overwritten. ++ */ + int + virStorageFileGetMetadataInternal(virStorageSourcePtr meta, + char *buf, +@@ -1052,10 +1056,13 @@ virStorageFileGetMetadataInternal(virStorageSourcePtr meta, + return -1; + } + ++ virBitmapFree(meta->features); ++ meta->features = NULL; + if (fileTypeInfo[meta->format].getFeatures != NULL && + fileTypeInfo[meta->format].getFeatures(&meta->features, meta->format, buf, len) < 0) + return -1; + ++ VIR_FREE(meta->compat); + if (meta->format == VIR_STORAGE_FILE_QCOW2 && meta->features && + VIR_STRDUP(meta->compat, "1.1") < 0) + return -1; +-- +2.19.1 + diff --git a/libvirt-virnetworkobj-Free-retval-of-virNetworkObjGetPortSta.patch b/libvirt-virnetworkobj-Free-retval-of-virNetworkObjGetPortSta.patch new file mode 100644 index 0000000..8c32648 --- /dev/null +++ b/libvirt-virnetworkobj-Free-retval-of-virNetworkObjGetPortSta.patch @@ -0,0 +1,51 @@ +From 27616d1c02b697df151ed8c9116e46e440549036 Mon Sep 17 00:00:00 2001 +From: Michal Privoznik +Date: Tue, 9 Jul 2019 16:46:31 +0200 +Subject: [PATCH] virnetworkobj: Free retval of virNetworkObjGetPortStatusDir() + +The virNetworkObjGetPortStatusDir() function allocates a memory +to construct a path. None of the callers free it leading to a +memleak. + +Signed-off-by: Michal Privoznik +Reviewed-by: Erik Skultety +(cherry-picked from commit 37d8d6b98d2046c023935a6c9723defcdbf6c069) +Signed-off-by: Xu Yandong +--- + src/conf/virnetworkobj.c | 6 +++--- + 1 file changed, 3 insertions(+), 3 deletions(-) + +diff --git a/src/conf/virnetworkobj.c b/src/conf/virnetworkobj.c +index 12cefeb..45726e4 100644 +--- a/src/conf/virnetworkobj.c ++++ b/src/conf/virnetworkobj.c +@@ -1627,7 +1627,7 @@ virNetworkObjAddPort(virNetworkObjPtr net, + { + int ret = -1; + char uuidstr[VIR_UUID_STRING_BUFLEN]; +- char *dir = NULL; ++ VIR_AUTOFREE(char *) dir = NULL; + + virUUIDFormat(portdef->uuid, uuidstr); + +@@ -1717,7 +1717,7 @@ int + virNetworkObjDeleteAllPorts(virNetworkObjPtr net, + const char *stateDir) + { +- char *dir; ++ VIR_AUTOFREE(char *) dir = NULL; + DIR *dh = NULL; + struct dirent *de; + int rc; +@@ -1843,7 +1843,7 @@ static int + virNetworkObjLoadAllPorts(virNetworkObjPtr net, + const char *stateDir) + { +- char *dir; ++ VIR_AUTOFREE(char *) dir = NULL; + DIR *dh = NULL; + struct dirent *de; + int ret = -1; +-- +2.19.1 + diff --git a/libvirt-virsh-migrate-Properly-check-for-parallel-connection.patch b/libvirt-virsh-migrate-Properly-check-for-parallel-connection.patch new file mode 100644 index 0000000..a5d327e --- /dev/null +++ b/libvirt-virsh-migrate-Properly-check-for-parallel-connection.patch @@ -0,0 +1,60 @@ +From 07df0ab940bb3688a3208b80d733db3cbfbde687 Mon Sep 17 00:00:00 2001 +From: Jiri Denemark +Date: Fri, 19 Jul 2019 15:46:33 +0200 +Subject: [PATCH] virsh migrate: Properly check for --parallel-connections + +Ever since --parallel-connections option for virsh migrate was +introduced we did not properly check the return value of +vshCommandOptInt. We would set VIR_MIGRATE_PARAM_PARALLEL_CONNECTIONS +parameter even if vshCommandOptInt returned 0 (which means +--parallel-connections was not specified) when another int option which +was checked earlier was specified with a nonzero value. + +Specifically, running virsh migrate with either +--auto-converge-increment, --auto-converge-initial, --comp-mt-dthreads, +--comp-mt-threads, or --comp-mt-level would set +VIR_MIGRATE_PARAM_PARALLEL_CONNECTIONS parameter and if --parallel +option was not used, libvirt would complain + + error: invalid argument: Turn parallel migration on to tune it + +even though --parallel-connections option was not used at all. + +https://bugzilla.redhat.com/show_bug.cgi?id=1726643 + +Signed-off-by: Jiri Denemark +Reviewed-by: Michal Privoznik +(cherry-picked from commit 88ce7bac413a7a5722b2ffe53dd844c0d677168a) +Signed-off-by: Xu Yandong +--- + tools/virsh-domain.c | 13 +++++++------ + 1 file changed, 7 insertions(+), 6 deletions(-) + +diff --git a/tools/virsh-domain.c b/tools/virsh-domain.c +index 828ae30..2ad7395 100644 +--- a/tools/virsh-domain.c ++++ b/tools/virsh-domain.c +@@ -10785,13 +10785,14 @@ doMigrate(void *opaque) + goto save_error; + } + +- if (vshCommandOptInt(ctl, cmd, "parallel-connections", &intOpt) < 0) ++ if ((rv = vshCommandOptInt(ctl, cmd, "parallel-connections", &intOpt)) < 0) { + goto out; +- if (intOpt && +- virTypedParamsAddInt(¶ms, &nparams, &maxparams, +- VIR_MIGRATE_PARAM_PARALLEL_CONNECTIONS, +- intOpt) < 0) +- goto save_error; ++ } else if (rv > 0) { ++ if (virTypedParamsAddInt(¶ms, &nparams, &maxparams, ++ VIR_MIGRATE_PARAM_PARALLEL_CONNECTIONS, ++ intOpt) < 0) ++ goto save_error; ++ } + + if (vshCommandOptBool(cmd, "live")) + flags |= VIR_MIGRATE_LIVE; +-- +2.19.1 + diff --git a/libvirt.spec b/libvirt.spec new file mode 100644 index 0000000..710c14d --- /dev/null +++ b/libvirt.spec @@ -0,0 +1,1818 @@ +# -*- rpm-spec -*- + +# This spec file assumes you are building on openEuler version. +%define supported_platform 1 + +# Default to skipping autoreconf. Distros can change just this one line +# (or provide a command-line override) if they backport any patches that +# touch configure.ac or Makefile.am. +%{!?enable_autotools:%global enable_autotools 1} + +# The hypervisor drivers that run in libvirtd +%define with_qemu 0%{!?_without_qemu:1} +%define with_lxc 0%{!?_without_lxc:0} +%define with_libxl 0%{!?_without_libxl:0} +%define with_vbox 0%{!?_without_vbox:0} + +%define with_qemu_tcg %{with_qemu} + +%define qemu_kvm_arches %{ix86} x86_64 aarch64 + +%ifarch %{qemu_kvm_arches} + %define with_qemu_kvm %{with_qemu} +%else + %define with_qemu_kvm 0 +%endif + +%if ! %{with_qemu_tcg} && ! %{with_qemu_kvm} + %define with_qemu 0 +%endif + +# Then the hypervisor drivers that run outside libvirtd, in libvirt.so +%define with_openvz 0%{!?_without_openvz:0} +%define with_vmware 0%{!?_without_vmware:0} +%define with_phyp 0%{!?_without_phyp:0} +%define with_esx 0%{!?_without_esx:0} +%define with_hyperv 0%{!?_without_hyperv:0} + +# Then the secondary host drivers, which run inside libvirtd +%define with_storage_rbd 0%{!?_without_storage_rbd:1} +%define with_storage_sheepdog 0%{!?_without_storage_sheepdog:0} +%define with_storage_gluster 0%{!?_without_storage_gluster:1} + +%define with_numactl 0%{!?_without_numactl:1} + +# Numactl is not available on many non-x86 archs +%ifarch s390 s390x %{arm} riscv64 + %define with_numactl 0 +%endif + +%define with_storage_zfs 0%{!?_without_storage_zfs:1} +%ifarch s390 s390x aarch64 + %define with_storage_zfs 0 +%endif + +# We need a recent enough libiscsi (>= 1.18.0) +%define with_storage_iscsi_direct 0%{!?_without_storage_iscsi_direct:1} + +# A few optional bits off by default, we enable later +# fuse is used to provide virtualized /proc for LXC +%if %{with_lxc} + %define with_fuse 0%{!?_without_fuse:1} +%else + %define with_fuse 0%{!?_without_fuse:0} +%endif + +%define with_sanlock 0%{!?_without_sanlock:1} +%define with_numad 0%{!?_without_numad:0} +%define with_firewalld 0%{!?_without_firewalld:1} +%define with_libssh2 0%{!?_without_libssh2:1} +%define with_wireshark 0%{!?_without_wireshark:1} +%define with_libssh 0%{!?_without_libssh:1} +%define with_bash_completion 0%{!?_without_bash_completion:1} + +# Finally set the OS / architecture specific special cases + +# Xen is available only on i386 x86_64 ia64 +%ifnarch %{ix86} x86_64 ia64 + %define with_libxl 0 +%endif + +# vbox is available only on i386 x86_64 +%ifnarch %{ix86} x86_64 + %define with_vbox 0 +%endif + +# Enable wireshark plugins for all distros shipping libvirt 1.2.2 or newer +%define wireshark_plugindir %(pkg-config --variable plugindir wireshark)/epan + +# Default Use Python 3 +%define python python3 + +%if %{with_qemu} || %{with_lxc} +# numad is used to manage the CPU and memory placement dynamically, +# it's not available on many non-x86 architectures. + %ifnarch s390 s390x %{arm} riscv64 + %define with_numad 0%{!?_without_numad:1} + %endif +%endif + +# Force QEMU to run as non-root +%define qemu_user qemu +%define qemu_group qemu + +%define enable_werror --enable-werror + +%define tls_priority "@LIBVIRT,SYSTEM" + +%define with_systemd 1 +%define with_pm_utils 0 +%define with_firewalld_zone 0%{!?_without_firewalld_zone:0} +%define with_systemd_macros 1 + + +Summary: Library providing a simple virtualization API +Name: libvirt +Version: 5.5.0 +Release: 1 +License: LGPLv2+ +URL: https://libvirt.org/ + +%if %(echo %{version} | grep -q "\.0$"; echo $?) == 1 + %define mainturl stable_updates/ +%endif +Source: https://libvirt.org/sources/%{?mainturl}libvirt-%{version}.tar.xz +Patch0: libvirt-qemu-fix-potential-memory-leak.patch +Patch1: libvirt-remote-fix-a-memory-free-error.patch +Patch2: libvirt-qemu-add-pointer-check-in-qemuMonitorLastError.patch +Patch3: libvirt-conf-use-virDomainDeviceDefFree-free-dev.patch +Patch4: libvirt-conf-fix-memory-leak-in-virNodeDeviceGetPCISRIOVCaps.patch +Patch5: libvirt-conf-fix-memory-leak-in-virNodeDevPCICapSRIOVVirtual.patch +Patch6: libvirt-qemu-clear-vcpupin-when-unhotplug-vcpu.patch +Patch7: libvirt-qemu-fix-a-concurrent-operation-situation.patch +Patch8: libvirt-qemu_conf-clear-domain-before-VIR_DELETE_ELEMENT.patch +Patch9: libvirt-event-reference-state-only-when-virEventAddTimeout-s.patch +Patch10: libvirt-cgroup-cleanup-eventParams-when-virTypedParamsAddULL.patch +Patch11: libvirt-remote-mention-libssh-in-error-message.patch +Patch12: libvirt-qemu-Validate-disk-against-domain-def-on-coldplug.patch +Patch13: libvirt-virnetworkobj-Free-retval-of-virNetworkObjGetPortSta.patch +Patch14: libvirt-storage-rbd-use-VIR_REALLOC-in-the-loop.patch +Patch15: libvirt-storage-rbd-actually-index-the-array-when-iterating-.patch +Patch16: libvirt-Revert-conf-Remove-volOptions-for-VIR_STORAGE_POOL_R.patch +Patch17: libvirt-qemu-Relax-os.loader-type-check-when-validating-doma.patch +Patch18: libvirt-util-storage-Clean-up-label-use-in-virStorageFileGet.patch +Patch19: libvirt-util-storage-Don-t-leak-metadata-on-repeated-calls-o.patch +Patch20: libvirt-virsh-migrate-Properly-check-for-parallel-connection.patch +Patch21: libvirt-conf-Avoid-double-free-when-prase-device-xml-failed.patch +Patch22: libvirt-qemu-fix-Validate-scsi-disk-against-domain-def-on-co.patch +Patch23: libvirt-libvirtd-fix-driver-cleanup-order-to-avoid-coredump.patch +Patch24: libvirt-hostdev-remove-unnessary-virObjectUnref-after-use-VI.patch +Patch25: libvirt-nodedev-fix-potential-heap-use-after-free.patch +Patch26: libvirt-cpu_map-Introduce-arm-CPU-models.patch +Patch27: libvirt-cpu-introduce-virCPUarmData-to-virCPUData.patch +Patch28: libvirt-cpu-introduce-cpu-baseline-for-ARM-CPU.patch +Patch29: libvirt-cpu-fix-cpu-compare-and-cpu-baseline-for-ARM-CPU.patch +Patch30: libvirt-cpu-add-getHostCPU-for-ARM-CPUS.patch +Patch31: libvirt-cpu-Introduce-mock-checkFeature-method-for-ARM-CPUS.patch +Patch32: libvirt-tests-add-baseline-test-cases-for-arm-CPU.patch +Patch33: libvirt-tests-add-cpu-compare-test-cases-for-arm-CPU.patch + + +Requires: libvirt-daemon = %{version}-%{release} +Requires: libvirt-daemon-config-network = %{version}-%{release} +Requires: libvirt-daemon-config-nwfilter = %{version}-%{release} +%if %{with_libxl} +Requires: libvirt-daemon-driver-libxl = %{version}-%{release} +%endif +%if %{with_lxc} +Requires: libvirt-daemon-driver-lxc = %{version}-%{release} +%endif +%if %{with_qemu} +Requires: libvirt-daemon-driver-qemu = %{version}-%{release} +%endif +# We had UML driver, but we've removed it. +Obsoletes: libvirt-daemon-driver-uml <= 5.0.0 +Obsoletes: libvirt-daemon-uml <= 5.0.0 +%if %{with_vbox} +Requires: libvirt-daemon-driver-vbox = %{version}-%{release} +%endif +Requires: libvirt-daemon-driver-nwfilter = %{version}-%{release} + +Requires: libvirt-daemon-driver-interface = %{version}-%{release} +Requires: libvirt-daemon-driver-secret = %{version}-%{release} +Requires: libvirt-daemon-driver-storage = %{version}-%{release} +Requires: libvirt-daemon-driver-network = %{version}-%{release} +Requires: libvirt-daemon-driver-nodedev = %{version}-%{release} +Requires: libvirt-client = %{version}-%{release} +Requires: libvirt-libs = %{version}-%{release} + +# All build-time requirements. Run-time requirements are +# listed against each sub-RPM +%if 0%{?enable_autotools} +BuildRequires: autoconf +BuildRequires: automake +BuildRequires: gettext-devel +BuildRequires: libtool +BuildRequires: /usr/bin/pod2man +%endif +BuildRequires: gcc +BuildRequires: git +BuildRequires: hostname + +BuildRequires: perl-interpreter +BuildRequires: %{python} +BuildRequires: systemd-units +%if %{with_libxl} +BuildRequires: xen-devel +%endif +BuildRequires: libxml2-devel +BuildRequires: libxslt +BuildRequires: readline-devel +%if %{with_bash_completion} +BuildRequires: bash-completion >= 2.0 +%endif +BuildRequires: ncurses-devel +BuildRequires: gettext +BuildRequires: libtasn1-devel +BuildRequires: gnutls-devel +BuildRequires: libattr-devel +# For pool-build probing for existing pools +BuildRequires: libblkid-devel >= 2.17 +# for augparse, optionally used in testing +BuildRequires: augeas +BuildRequires: systemd-devel >= 185 +BuildRequires: libpciaccess-devel >= 0.10.9 +BuildRequires: yajl-devel +%if %{with_sanlock} +BuildRequires: sanlock-devel >= 2.4 +%endif +BuildRequires: libpcap-devel +BuildRequires: libnl3-devel +BuildRequires: avahi-devel +BuildRequires: libselinux-devel +BuildRequires: dnsmasq >= 2.41 +BuildRequires: iptables +BuildRequires: radvd +BuildRequires: ebtables +BuildRequires: module-init-tools +BuildRequires: cyrus-sasl-devel +BuildRequires: polkit >= 0.112 +# For mount/umount in FS driver +BuildRequires: util-linux +%if %{with_qemu} +# For managing ACLs +BuildRequires: libacl-devel +# From QEMU RPMs +BuildRequires: /usr/bin/qemu-img +%endif +# For LVM drivers +BuildRequires: lvm2 +# For pool type=iscsi +BuildRequires: iscsi-initiator-utils +%if %{with_storage_iscsi_direct} +# For pool type=iscsi-direct +BuildRequires: libiscsi-devel +%endif +# For disk driver +BuildRequires: parted-devel +# For Multipath support +BuildRequires: device-mapper-devel +%if %{with_storage_rbd} +BuildRequires: librados2-devel +BuildRequires: librbd1-devel +%endif +%if %{with_storage_gluster} +BuildRequires: glusterfs-api-devel >= 3.4.1 +BuildRequires: glusterfs-devel >= 3.4.1 +%endif +%if %{with_storage_sheepdog} +BuildRequires: sheepdog +%endif +%if %{with_storage_zfs} +# Support any conforming implementation of zfs. On stock Fedora +# this is zfs-fuse, but could be zfsonlinux upstream RPMs +BuildRequires: /sbin/zfs +BuildRequires: /sbin/zpool +%endif +%if %{with_numactl} +# For QEMU/LXC numa info +BuildRequires: numactl-devel +%endif +BuildRequires: libcap-ng-devel >= 0.5.0 +%if %{with_fuse} +BuildRequires: fuse-devel >= 2.8.6 +%endif +%if %{with_phyp} || %{with_libssh2} +BuildRequires: libssh2-devel >= 1.3.0 +%endif + +BuildRequires: netcf-devel >= 0.2.2 +%if %{with_esx} +BuildRequires: libcurl-devel +%endif +%if %{with_hyperv} +BuildRequires: libwsman-devel >= 2.2.3 +%endif +BuildRequires: audit-libs-devel +# we need /usr/sbin/dtrace +BuildRequires: systemtap-sdt-devel + +# For mount/umount in FS driver +BuildRequires: util-linux +# For showmount in FS driver (netfs discovery) +BuildRequires: nfs-utils + +# Communication with the firewall and polkit daemons use DBus +BuildRequires: dbus-devel + +# Fedora build root suckage +BuildRequires: gawk + +# For storage wiping with different algorithms +BuildRequires: scrub + +%if %{with_numad} +BuildRequires: numad +%endif + +%if %{with_wireshark} +BuildRequires: wireshark-devel >= 2.1.0 +%endif + +%if %{with_libssh} +BuildRequires: libssh-devel >= 0.7.0 +%endif + +BuildRequires: rpcgen +BuildRequires: libtirpc-devel + +Provides: bundled(gnulib) + +%description +Libvirt is a C toolkit to interact with the virtualization capabilities +of recent versions of Linux (and other OSes). The main package includes +the libvirtd server exporting the virtualization support. + +%package docs +Summary: API reference and website documentation + +%description docs +Includes the API reference for the libvirt C library, and a complete +copy of the libvirt.org website documentation. + +%package daemon +Summary: Server side daemon and supporting files for libvirt library + +# All runtime requirements for the libvirt package (runtime requrements +# for subpackages are listed later in those subpackages) + +# The client side, i.e. shared libs are in a subpackage +Requires: %{name}-libs = %{version}-%{release} + +# for modprobe of pci devices +Requires: module-init-tools + +# for /sbin/ip & /sbin/tc +Requires: iproute +# tc is provided by iproute-tc since at least Fedora 26 +Requires: iproute-tc + +Requires: avahi-libs +Requires: polkit >= 0.112 +%ifarch %{ix86} x86_64 ia64 +# For virConnectGetSysinfo +Requires: dmidecode +%endif +# For service management +%if %{with_systemd} +Requires(post): systemd-units +Requires(post): systemd-sysv +Requires(preun): systemd-units +Requires(postun): systemd-units +%endif + +%if %{with_numad} +Requires: numad +%endif +# libvirtd depends on 'messagebus' service +Requires: dbus +# For uid creation during pre +Requires(pre): shadow-utils + +%description daemon +Server side daemon required to manage the virtualization capabilities +of recent versions of Linux. Requires a hypervisor specific sub-RPM +for specific drivers. + +%package daemon-config-network +Summary: Default configuration files for the libvirtd daemon + +Requires: libvirt-daemon = %{version}-%{release} +Requires: libvirt-daemon-driver-network = %{version}-%{release} + +%description daemon-config-network +Default configuration files for setting up NAT based networking + +%package daemon-config-nwfilter +Summary: Network filter configuration files for the libvirtd daemon + +Requires: libvirt-daemon = %{version}-%{release} +Requires: libvirt-daemon-driver-nwfilter = %{version}-%{release} + +%description daemon-config-nwfilter +Network filter configuration files for cleaning guest traffic + +%package daemon-driver-network +Summary: Network driver plugin for the libvirtd daemon +Requires: libvirt-daemon = %{version}-%{release} +Requires: libvirt-libs = %{version}-%{release} +Requires: dnsmasq >= 2.41 +Requires: radvd +Requires: iptables + +%description daemon-driver-network +The network driver plugin for the libvirtd daemon, providing +an implementation of the virtual network APIs using the Linux +bridge capabilities. + + +%package daemon-driver-nwfilter +Summary: Nwfilter driver plugin for the libvirtd daemon +Requires: libvirt-daemon = %{version}-%{release} +Requires: libvirt-libs = %{version}-%{release} +Requires: iptables +Requires: ebtables + +%description daemon-driver-nwfilter +The nwfilter driver plugin for the libvirtd daemon, providing +an implementation of the firewall APIs using the ebtables, +iptables and ip6tables capabilities + + +%package daemon-driver-nodedev +Summary: Nodedev driver plugin for the libvirtd daemon +Requires: libvirt-daemon = %{version}-%{release} +Requires: libvirt-libs = %{version}-%{release} +# needed for device enumeration +Requires: systemd >= 185 + +%description daemon-driver-nodedev +The nodedev driver plugin for the libvirtd daemon, providing +an implementation of the node device APIs using the udev +capabilities. + + +%package daemon-driver-interface +Summary: Interface driver plugin for the libvirtd daemon +Requires: libvirt-daemon = %{version}-%{release} +Requires: libvirt-libs = %{version}-%{release} +Requires: netcf-libs >= 0.2.2 + +%description daemon-driver-interface +The interface driver plugin for the libvirtd daemon, providing +an implementation of the network interface APIs using the +netcf library + + +%package daemon-driver-secret +Summary: Secret driver plugin for the libvirtd daemon +Requires: libvirt-daemon = %{version}-%{release} +Requires: libvirt-libs = %{version}-%{release} + +%description daemon-driver-secret +The secret driver plugin for the libvirtd daemon, providing +an implementation of the secret key APIs. + +%package daemon-driver-storage-core +Summary: Storage driver plugin including base backends for the libvirtd daemon +Requires: libvirt-daemon = %{version}-%{release} +Requires: libvirt-libs = %{version}-%{release} +Requires: nfs-utils +# For mkfs +Requires: util-linux +%if %{with_qemu} +# From QEMU RPMs +Requires: /usr/bin/qemu-img +%endif + +%description daemon-driver-storage-core +The storage driver plugin for the libvirtd daemon, providing +an implementation of the storage APIs using files, local disks, LVM, SCSI, +iSCSI, and multipath storage. + +%package daemon-driver-storage-logical +Summary: Storage driver plugin for lvm volumes +Requires: libvirt-daemon-driver-storage-core = %{version}-%{release} +Requires: libvirt-libs = %{version}-%{release} +Requires: lvm2 + +%description daemon-driver-storage-logical +The storage driver backend adding implementation of the storage APIs for block +volumes using lvm. + + +%package daemon-driver-storage-disk +Summary: Storage driver plugin for disk +Requires: libvirt-daemon-driver-storage-core = %{version}-%{release} +Requires: libvirt-libs = %{version}-%{release} +Requires: parted +Requires: device-mapper + +%description daemon-driver-storage-disk +The storage driver backend adding implementation of the storage APIs for block +volumes using the host disks. + + +%package daemon-driver-storage-scsi +Summary: Storage driver plugin for local scsi devices +Requires: libvirt-daemon-driver-storage-core = %{version}-%{release} +Requires: libvirt-libs = %{version}-%{release} + +%description daemon-driver-storage-scsi +The storage driver backend adding implementation of the storage APIs for scsi +host devices. + + +%package daemon-driver-storage-iscsi +Summary: Storage driver plugin for iscsi +Requires: libvirt-daemon-driver-storage-core = %{version}-%{release} +Requires: libvirt-libs = %{version}-%{release} +Requires: iscsi-initiator-utils + +%description daemon-driver-storage-iscsi +The storage driver backend adding implementation of the storage APIs for iscsi +volumes using the host iscsi stack. + + +%if %{with_storage_iscsi_direct} +%package daemon-driver-storage-iscsi-direct +Summary: Storage driver plugin for iscsi-direct +Requires: libvirt-daemon-driver-storage-core = %{version}-%{release} +Requires: libvirt-libs = %{version}-%{release} +Requires: libiscsi + +%description daemon-driver-storage-iscsi-direct +The storage driver backend adding implementation of the storage APIs for iscsi +volumes using libiscsi direct connection. +%endif + + +%package daemon-driver-storage-mpath +Summary: Storage driver plugin for multipath volumes +Requires: libvirt-daemon-driver-storage-core = %{version}-%{release} +Requires: libvirt-libs = %{version}-%{release} +Requires: device-mapper + +%description daemon-driver-storage-mpath +The storage driver backend adding implementation of the storage APIs for +multipath storage using device mapper. + + +%if %{with_storage_gluster} +%package daemon-driver-storage-gluster +Summary: Storage driver plugin for gluster +Requires: libvirt-daemon-driver-storage-core = %{version}-%{release} +Requires: libvirt-libs = %{version}-%{release} +Requires: glusterfs-cli + +%description daemon-driver-storage-gluster +The storage driver backend adding implementation of the storage APIs for gluster +volumes using libgfapi. +%endif + + +%if %{with_storage_rbd} +%package daemon-driver-storage-rbd +Summary: Storage driver plugin for rbd +Requires: libvirt-daemon-driver-storage-core = %{version}-%{release} +Requires: libvirt-libs = %{version}-%{release} + +%description daemon-driver-storage-rbd +The storage driver backend adding implementation of the storage APIs for rbd +volumes using the ceph protocol. +%endif + + +%if %{with_storage_sheepdog} +%package daemon-driver-storage-sheepdog +Summary: Storage driver plugin for sheepdog +Requires: libvirt-daemon-driver-storage-core = %{version}-%{release} +Requires: libvirt-libs = %{version}-%{release} +Requires: sheepdog + +%description daemon-driver-storage-sheepdog +The storage driver backend adding implementation of the storage APIs for +sheepdog volumes using. +%endif + + +%if %{with_storage_zfs} +%package daemon-driver-storage-zfs +Summary: Storage driver plugin for ZFS +Requires: libvirt-daemon-driver-storage-core = %{version}-%{release} +Requires: libvirt-libs = %{version}-%{release} +# Support any conforming implementation of zfs +Requires: /sbin/zfs +Requires: /sbin/zpool + +%description daemon-driver-storage-zfs +The storage driver backend adding implementation of the storage APIs for +ZFS volumes. +%endif + + +%package daemon-driver-storage +Summary: Storage driver plugin including all backends for the libvirtd daemon +Requires: libvirt-daemon-driver-storage-core = %{version}-%{release} +Requires: libvirt-daemon-driver-storage-disk = %{version}-%{release} +Requires: libvirt-daemon-driver-storage-logical = %{version}-%{release} +Requires: libvirt-daemon-driver-storage-scsi = %{version}-%{release} +Requires: libvirt-daemon-driver-storage-iscsi = %{version}-%{release} +Requires: libvirt-daemon-driver-storage-mpath = %{version}-%{release} +%if %{with_storage_iscsi_direct} +Requires: libvirt-daemon-driver-storage-iscsi-direct = %{version}-%{release} +%endif +%if %{with_storage_gluster} +Requires: libvirt-daemon-driver-storage-gluster = %{version}-%{release} +%endif +%if %{with_storage_rbd} +Requires: libvirt-daemon-driver-storage-rbd = %{version}-%{release} +%endif +%if %{with_storage_sheepdog} +Requires: libvirt-daemon-driver-storage-sheepdog = %{version}-%{release} +%endif +%if %{with_storage_zfs} +Requires: libvirt-daemon-driver-storage-zfs = %{version}-%{release} +%endif + +%description daemon-driver-storage +The storage driver plugin for the libvirtd daemon, providing +an implementation of the storage APIs using LVM, iSCSI, +parted and more. + + +%if %{with_qemu} +%package daemon-driver-qemu +Summary: QEMU driver plugin for the libvirtd daemon +Requires: libvirt-daemon = %{version}-%{release} +Requires: libvirt-libs = %{version}-%{release} +# There really is a hard cross-driver dependency here +Requires: libvirt-daemon-driver-network = %{version}-%{release} +Requires: libvirt-daemon-driver-storage-core = %{version}-%{release} +Requires: /usr/bin/qemu-img +# For image compression +Requires: gzip +Requires: bzip2 +Requires: lzop +Requires: xz +Requires: systemd-container + +%description daemon-driver-qemu +The qemu driver plugin for the libvirtd daemon, providing +an implementation of the hypervisor driver APIs using +QEMU +%endif + + +%if %{with_lxc} +%package daemon-driver-lxc +Summary: LXC driver plugin for the libvirtd daemon +Requires: libvirt-daemon = %{version}-%{release} +Requires: libvirt-libs = %{version}-%{release} +# There really is a hard cross-driver dependency here +Requires: libvirt-daemon-driver-network = %{version}-%{release} +Requires: systemd-container + +%description daemon-driver-lxc +The LXC driver plugin for the libvirtd daemon, providing +an implementation of the hypervisor driver APIs using +the Linux kernel +%endif + + +%if %{with_vbox} +%package daemon-driver-vbox +Summary: VirtualBox driver plugin for the libvirtd daemon +Requires: libvirt-daemon = %{version}-%{release} +Requires: libvirt-libs = %{version}-%{release} + +%description daemon-driver-vbox +The vbox driver plugin for the libvirtd daemon, providing +an implementation of the hypervisor driver APIs using +VirtualBox +%endif + + +%if %{with_libxl} +%package daemon-driver-libxl +Summary: Libxl driver plugin for the libvirtd daemon +Requires: libvirt-daemon = %{version}-%{release} +Requires: libvirt-libs = %{version}-%{release} +Obsoletes: libvirt-daemon-driver-xen < 4.3.0 + +%description daemon-driver-libxl +The Libxl driver plugin for the libvirtd daemon, providing +an implementation of the hypervisor driver APIs using +Libxl +%endif + + +%if %{with_qemu_tcg} +%package daemon-qemu +Summary: Server side daemon & driver required to run QEMU guests + +Requires: libvirt-daemon = %{version}-%{release} +Requires: libvirt-daemon-driver-qemu = %{version}-%{release} +Requires: libvirt-daemon-driver-interface = %{version}-%{release} +Requires: libvirt-daemon-driver-network = %{version}-%{release} +Requires: libvirt-daemon-driver-nodedev = %{version}-%{release} +Requires: libvirt-daemon-driver-nwfilter = %{version}-%{release} +Requires: libvirt-daemon-driver-secret = %{version}-%{release} +Requires: libvirt-daemon-driver-storage = %{version}-%{release} +Requires: qemu + +%description daemon-qemu +Server side daemon and driver required to manage the virtualization +capabilities of the QEMU TCG emulators +%endif + + +%if %{with_qemu_kvm} +%package daemon-kvm +Summary: Server side daemon & driver required to run KVM guests + +Requires: libvirt-daemon = %{version}-%{release} +Requires: libvirt-daemon-driver-qemu = %{version}-%{release} +Requires: libvirt-daemon-driver-interface = %{version}-%{release} +Requires: libvirt-daemon-driver-network = %{version}-%{release} +Requires: libvirt-daemon-driver-nodedev = %{version}-%{release} +Requires: libvirt-daemon-driver-nwfilter = %{version}-%{release} +Requires: libvirt-daemon-driver-secret = %{version}-%{release} +Requires: libvirt-daemon-driver-storage = %{version}-%{release} +Requires: qemu + +%description daemon-kvm +Server side daemon and driver required to manage the virtualization +capabilities of the KVM hypervisor +%endif + + +%if %{with_lxc} +%package daemon-lxc +Summary: Server side daemon & driver required to run LXC guests + +Requires: libvirt-daemon = %{version}-%{release} +Requires: libvirt-daemon-driver-lxc = %{version}-%{release} +Requires: libvirt-daemon-driver-interface = %{version}-%{release} +Requires: libvirt-daemon-driver-network = %{version}-%{release} +Requires: libvirt-daemon-driver-nodedev = %{version}-%{release} +Requires: libvirt-daemon-driver-nwfilter = %{version}-%{release} +Requires: libvirt-daemon-driver-secret = %{version}-%{release} +Requires: libvirt-daemon-driver-storage = %{version}-%{release} + +%description daemon-lxc +Server side daemon and driver required to manage the virtualization +capabilities of LXC +%endif + + +%if %{with_libxl} +%package daemon-xen +Summary: Server side daemon & driver required to run XEN guests + +Requires: libvirt-daemon = %{version}-%{release} + %if %{with_libxl} +Requires: libvirt-daemon-driver-libxl = %{version}-%{release} + %endif +Requires: libvirt-daemon-driver-interface = %{version}-%{release} +Requires: libvirt-daemon-driver-network = %{version}-%{release} +Requires: libvirt-daemon-driver-nodedev = %{version}-%{release} +Requires: libvirt-daemon-driver-nwfilter = %{version}-%{release} +Requires: libvirt-daemon-driver-secret = %{version}-%{release} +Requires: libvirt-daemon-driver-storage = %{version}-%{release} +Requires: xen + +%description daemon-xen +Server side daemon and driver required to manage the virtualization +capabilities of XEN +%endif + +%if %{with_vbox} +%package daemon-vbox +Summary: Server side daemon & driver required to run VirtualBox guests + +Requires: libvirt-daemon = %{version}-%{release} +Requires: libvirt-daemon-driver-vbox = %{version}-%{release} +Requires: libvirt-daemon-driver-interface = %{version}-%{release} +Requires: libvirt-daemon-driver-network = %{version}-%{release} +Requires: libvirt-daemon-driver-nodedev = %{version}-%{release} +Requires: libvirt-daemon-driver-nwfilter = %{version}-%{release} +Requires: libvirt-daemon-driver-secret = %{version}-%{release} +Requires: libvirt-daemon-driver-storage = %{version}-%{release} + +%description daemon-vbox +Server side daemon and driver required to manage the virtualization +capabilities of VirtualBox +%endif + +%package client +Summary: Client side utilities of the libvirt library +Requires: %{name}-libs = %{version}-%{release} +Requires: readline +Requires: ncurses +# Needed by /usr/libexec/libvirt-guests.sh script. +Requires: gettext +# Needed by virt-pki-validate script. +Requires: gnutls-utils +%if %{with_bash_completion} +Requires: %{name}-bash-completion = %{version}-%{release} +%endif + +%description client +The client binaries needed to access the virtualization +capabilities of recent versions of Linux (and other OSes). + +%package libs +Summary: Client side libraries +# So remote clients can access libvirt over SSH tunnel +# (client invokes 'nc' against the UNIX socket on the server) +Requires: nc +Requires: cyrus-sasl +# Needed by default sasl.conf - no onerous extra deps, since +# 100's of other things on a system already pull in krb5-libs +Requires: cyrus-sasl-gssapi + +%description libs +Shared libraries for accessing the libvirt daemon. + +%package admin +Summary: Set of tools to control libvirt daemon +Requires: %{name}-libs = %{version}-%{release} +Requires: readline +%if %{with_bash_completion} +Requires: %{name}-bash-completion = %{version}-%{release} +%endif + +%description admin +The client side utilities to control the libvirt daemon. + +%if %{with_bash_completion} +%package bash-completion +Summary: Bash completion script + +%description bash-completion +Bash completion script stub. +%endif + +%if %{with_wireshark} +%package wireshark +Summary: Wireshark dissector plugin for libvirt RPC transactions +Requires: wireshark >= 1.12.6-4 +Requires: %{name}-libs = %{version}-%{release} + +%description wireshark +Wireshark dissector plugin for better analysis of libvirt RPC traffic. +%endif + +%if %{with_lxc} +%package login-shell +Summary: Login shell for connecting users to an LXC container +Requires: %{name}-libs = %{version}-%{release} + +%description login-shell +Provides the set-uid virt-login-shell binary that is used to +connect a user to an LXC container when they login, by switching +namespaces. +%endif + +%package devel +Summary: Libraries, includes, etc. to compile with the libvirt library +Requires: %{name}-libs = %{version}-%{release} +Requires: pkgconfig + +%description devel +Include header files & development libraries for the libvirt C library. + +%if %{with_sanlock} +%package lock-sanlock +Summary: Sanlock lock manager plugin for QEMU driver +Requires: sanlock >= 2.4 +#for virt-sanlock-cleanup require augeas +Requires: augeas +Requires: %{name}-daemon = %{version}-%{release} +Requires: %{name}-libs = %{version}-%{release} + +%description lock-sanlock +Includes the Sanlock lock manager plugin for the QEMU +driver +%endif + +%package nss +Summary: Libvirt plugin for Name Service Switch +Requires: libvirt-daemon-driver-network = %{version}-%{release} + +%description nss +Libvirt plugin for NSS for translating domain names into IP addresses. + + +%prep + +%autosetup -S git_am + +%build + +%if %{with_qemu} + %define arg_qemu --with-qemu +%else + %define arg_qemu --without-qemu +%endif + +%if %{with_openvz} + %define arg_openvz --with-openvz +%else + %define arg_openvz --without-openvz +%endif + +%if %{with_lxc} + %define arg_lxc --with-lxc + %define arg_login_shell --with-login-shell +%else + %define arg_lxc --without-lxc + %define arg_login_shell --without-login-shell +%endif + +%if %{with_vbox} + %define arg_vbox --with-vbox +%else + %define arg_vbox --without-vbox +%endif + +%if %{with_libxl} + %define arg_libxl --with-libxl +%else + %define arg_libxl --without-libxl +%endif + +%if %{with_phyp} + %define arg_phyp --with-phyp +%else + %define arg_phyp --without-phyp +%endif + +%if %{with_esx} + %define arg_esx --with-esx +%else + %define arg_esx --without-esx +%endif + +%if %{with_hyperv} + %define arg_hyperv --with-hyperv +%else + %define arg_hyperv --without-hyperv +%endif + +%if %{with_vmware} + %define arg_vmware --with-vmware +%else + %define arg_vmware --without-vmware +%endif + +%if %{with_storage_rbd} + %define arg_storage_rbd --with-storage-rbd +%else + %define arg_storage_rbd --without-storage-rbd +%endif + +%if %{with_storage_sheepdog} + %define arg_storage_sheepdog --with-storage-sheepdog +%else + %define arg_storage_sheepdog --without-storage-sheepdog +%endif + +%if %{with_storage_gluster} + %define arg_storage_gluster --with-storage-gluster +%else + %define arg_storage_gluster --without-storage-gluster +%endif + +%if %{with_storage_zfs} + %define arg_storage_zfs --with-storage-zfs +%else + %define arg_storage_zfs --without-storage-zfs +%endif + +%if %{with_numactl} + %define arg_numactl --with-numactl +%else + %define arg_numactl --without-numactl +%endif + +%if %{with_numad} + %define arg_numad --with-numad +%else + %define arg_numad --without-numad +%endif + +%if %{with_fuse} + %define arg_fuse --with-fuse +%else + %define arg_fuse --without-fuse +%endif + +%if %{with_sanlock} + %define arg_sanlock --with-sanlock +%else + %define arg_sanlock --without-sanlock +%endif + +%if %{with_firewalld} + %define arg_firewalld --with-firewalld +%else + %define arg_firewalld --without-firewalld +%endif + +%if %{with_firewalld_zone} + %define arg_firewalld_zone --with-firewalld-zone +%else + %define arg_firewalld_zone --without-firewalld-zone +%endif + +%if %{with_wireshark} + %define arg_wireshark --with-wireshark-dissector +%else + %define arg_wireshark --without-wireshark-dissector +%endif + +%if %{with_storage_iscsi_direct} + %define arg_storage_iscsi_direct --with-storage-iscsi-direct +%else + %define arg_storage_iscsi_direct --without-storage-iscsi-direct +%endif + +%if %{with_pm_utils} + %define arg_pm_utils --with-pm-utils +%else + %define arg_pm_utils --without-pm-utils +%endif + +%define when %(date +"%%F-%%T") +%define where %(hostname) +%define who %{?packager}%{!?packager:Unknown} +%define arg_packager --with-packager="%{who}, %{when}, %{where}" +%define arg_packager_version --with-packager-version="%{release}" + +%define arg_selinux_mount --with-selinux-mount="/sys/fs/selinux" + +# Nightly edk2.git-ovmf-x64 +LOADERS="/usr/share/edk2.git/ovmf-x64/OVMF_CODE-pure-efi.fd:/usr/share/edk2.git/ovmf-x64/OVMF_VARS-pure-efi.fd" +# Nightly edk2.git-ovmf-ia32 +LOADERS="$LOADERS:/usr/share/edk2.git/ovmf-ia32/OVMF_CODE-pure-efi.fd:/usr/share/edk2.git/ovmf-ia32/OVMF_VARS-pure-efi.fd" +# Nightly edk2.git-aarch64 +LOADERS="$LOADERS:/usr/share/edk2.git/aarch64/QEMU_EFI-pflash.raw:/usr/share/edk2.git/aarch64/vars-template-pflash.raw" +# Nightly edk2.git-arm +LOADERS="$LOADERS:/usr/share/edk2.git/arm/QEMU_EFI-pflash.raw:/usr/share/edk2.git/arm/vars-template-pflash.raw" +# Fedora edk2-ovmf +LOADERS="$LOADERS:/usr/share/edk2/ovmf/OVMF_CODE.fd:/usr/share/edk2/ovmf/OVMF_VARS.fd" +# Fedora edk2-ovmf-ia32 +LOADERS="$LOADERS:/usr/share/edk2/ovmf-ia32/OVMF_CODE.fd:/usr/share/edk2/ovmf-ia32/OVMF_VARS.fd" +# Fedora edk2-aarch64 +LOADERS="$LOADERS:/usr/share/edk2/aarch64/QEMU_EFI-pflash.raw:/usr/share/edk2/aarch64/vars-template-pflash.raw" +# Fedora edk2-arm +LOADERS="$LOADERS:/usr/share/edk2/arm/QEMU_EFI-pflash.raw:/usr/share/edk2/arm/vars-template-pflash.raw" +%define arg_loader_nvram --with-loader-nvram="$LOADERS" + +# place macros above and build commands below this comment + +export SOURCE_DATE_EPOCH=$(stat --printf='%Y' %{_specdir}/%{name}.spec) + +%if 0%{?enable_autotools} + autoreconf -if +%endif + +rm -f po/stamp-po +%configure %{?arg_qemu} \ + %{?arg_openvz} \ + %{?arg_lxc} \ + %{?arg_vbox} \ + %{?arg_libxl} \ + --with-sasl \ + --with-avahi \ + --with-polkit \ + --with-libvirtd \ + %{?arg_phyp} \ + %{?arg_esx} \ + %{?arg_hyperv} \ + %{?arg_vmware} \ + --without-xenapi \ + --without-vz \ + --without-bhyve \ + --with-interface \ + --with-network \ + --with-storage-fs \ + --with-storage-lvm \ + --with-storage-iscsi \ + %{?arg_storage_iscsi_direct} \ + --with-storage-scsi \ + --with-storage-disk \ + --with-storage-mpath \ + %{?arg_storage_rbd} \ + %{?arg_storage_sheepdog} \ + %{?arg_storage_gluster} \ + %{?arg_storage_zfs} \ + --without-storage-vstorage \ + %{?arg_numactl} \ + %{?arg_numad} \ + --with-capng \ + %{?arg_fuse} \ + --with-netcf \ + --with-selinux \ + %{?arg_selinux_mount} \ + --without-apparmor \ + --without-hal \ + --with-udev \ + --with-yajl \ + %{?arg_sanlock} \ + --with-libpcap \ + --with-macvtap \ + --with-audit \ + --with-dtrace \ + --with-driver-modules \ + %{?arg_firewalld} \ + %{?arg_firewalld_zone} \ + %{?arg_wireshark} \ + %{?arg_pm_utils} \ + --with-nss-plugin \ + %{arg_packager} \ + %{arg_packager_version} \ + --with-qemu-user=%{qemu_user} \ + --with-qemu-group=%{qemu_group} \ + --with-tls-priority=%{tls_priority} \ + %{?arg_loader_nvram} \ + %{?enable_werror} \ + --enable-expensive-tests \ + --with-init-script=systemd \ + %{?arg_login_shell} + +make %{?_smp_mflags} V=1 +gzip -9 ChangeLog + +%install +rm -fr %{buildroot} + +export SOURCE_DATE_EPOCH=$(stat --printf='%Y' %{_specdir}/%{name}.spec) + +%make_install %{?_smp_mflags} SYSTEMD_UNIT_DIR=%{_unitdir} V=1 + +make %{?_smp_mflags} -C examples distclean V=1 + +rm -f $RPM_BUILD_ROOT%{_libdir}/*.la +rm -f $RPM_BUILD_ROOT%{_libdir}/*.a +rm -f $RPM_BUILD_ROOT%{_libdir}/libvirt/lock-driver/*.la +rm -f $RPM_BUILD_ROOT%{_libdir}/libvirt/lock-driver/*.a +rm -f $RPM_BUILD_ROOT%{_libdir}/libvirt/connection-driver/*.la +rm -f $RPM_BUILD_ROOT%{_libdir}/libvirt/connection-driver/*.a +rm -f $RPM_BUILD_ROOT%{_libdir}/libvirt/storage-backend/*.la +rm -f $RPM_BUILD_ROOT%{_libdir}/libvirt/storage-backend/*.a +rm -f $RPM_BUILD_ROOT%{_libdir}/libvirt/storage-file/*.la +rm -f $RPM_BUILD_ROOT%{_libdir}/libvirt/storage-file/*.a +%if %{with_wireshark} +rm -f $RPM_BUILD_ROOT%{wireshark_plugindir}/libvirt.la +%endif + +install -d -m 0755 $RPM_BUILD_ROOT%{_datadir}/lib/libvirt/dnsmasq/ +# We don't want to install /etc/libvirt/qemu/networks in the main %files list +# because if the admin wants to delete the default network completely, we don't +# want to end up re-incarnating it on every RPM upgrade. +install -d -m 0755 $RPM_BUILD_ROOT%{_datadir}/libvirt/networks/ +cp $RPM_BUILD_ROOT%{_sysconfdir}/libvirt/qemu/networks/default.xml \ + $RPM_BUILD_ROOT%{_datadir}/libvirt/networks/default.xml +rm -f $RPM_BUILD_ROOT%{_sysconfdir}/libvirt/qemu/networks/default.xml +rm -f $RPM_BUILD_ROOT%{_sysconfdir}/libvirt/qemu/networks/autostart/default.xml + +# nwfilter files are installed in /usr/share/libvirt and copied to /etc in %post +# to avoid verification errors on changed files in /etc +install -d -m 0755 $RPM_BUILD_ROOT%{_datadir}/libvirt/nwfilter/ +cp -a $RPM_BUILD_ROOT%{_sysconfdir}/libvirt/nwfilter/*.xml \ + $RPM_BUILD_ROOT%{_datadir}/libvirt/nwfilter/ +# libvirt saves these files with mode 600 +chmod 600 $RPM_BUILD_ROOT%{_sysconfdir}/libvirt/nwfilter/*.xml + +# Strip auto-generated UUID - we need it generated per-install +sed -i -e "//d" $RPM_BUILD_ROOT%{_datadir}/libvirt/networks/default.xml +%if ! %{with_qemu} +rm -f $RPM_BUILD_ROOT%{_datadir}/augeas/lenses/libvirtd_qemu.aug +rm -f $RPM_BUILD_ROOT%{_datadir}/augeas/lenses/tests/test_libvirtd_qemu.aug +%endif +%find_lang %{name} + +%if ! %{with_sanlock} +rm -f $RPM_BUILD_ROOT%{_datadir}/augeas/lenses/libvirt_sanlock.aug +rm -f $RPM_BUILD_ROOT%{_datadir}/augeas/lenses/tests/test_libvirt_sanlock.aug +%endif + +%if ! %{with_lxc} +rm -f $RPM_BUILD_ROOT%{_datadir}/augeas/lenses/libvirtd_lxc.aug +rm -f $RPM_BUILD_ROOT%{_datadir}/augeas/lenses/tests/test_libvirtd_lxc.aug +%endif + +%if ! %{with_qemu} +rm -rf $RPM_BUILD_ROOT%{_sysconfdir}/libvirt/qemu.conf +rm -rf $RPM_BUILD_ROOT%{_sysconfdir}/logrotate.d/libvirtd.qemu +%endif +%if ! %{with_lxc} +rm -rf $RPM_BUILD_ROOT%{_sysconfdir}/libvirt/lxc.conf +rm -rf $RPM_BUILD_ROOT%{_sysconfdir}/logrotate.d/libvirtd.lxc +%endif +%if ! %{with_libxl} +rm -rf $RPM_BUILD_ROOT%{_sysconfdir}/libvirt/libxl.conf +rm -rf $RPM_BUILD_ROOT%{_sysconfdir}/logrotate.d/libvirtd.libxl +rm -f $RPM_BUILD_ROOT%{_datadir}/augeas/lenses/libvirtd_libxl.aug +rm -f $RPM_BUILD_ROOT%{_datadir}/augeas/lenses/tests/test_libvirtd_libxl.aug +%endif + +# Copied into libvirt-docs subpackage eventually +mv $RPM_BUILD_ROOT%{_datadir}/doc/libvirt libvirt-docs + +%ifarch %{power64} s390x x86_64 ia64 alpha sparc64 +mv $RPM_BUILD_ROOT%{_datadir}/systemtap/tapset/libvirt_probes.stp \ + $RPM_BUILD_ROOT%{_datadir}/systemtap/tapset/libvirt_probes-64.stp + + %if %{with_qemu} +mv $RPM_BUILD_ROOT%{_datadir}/systemtap/tapset/libvirt_qemu_probes.stp \ + $RPM_BUILD_ROOT%{_datadir}/systemtap/tapset/libvirt_qemu_probes-64.stp + %endif +%endif + +%check +cd tests +# These tests don't current work in a mock build root +for i in nodeinfotest seclabeltest +do + rm -f $i + printf 'int main(void) { return 0; }' > $i.c + printf '#!/bin/sh\nexit 0\n' > $i + chmod +x $i +done +if ! make %{?_smp_mflags} check VIR_TEST_DEBUG=1 +then + cat test-suite.log || true + exit 1 +fi + +%pre daemon +# 'libvirt' group is just to allow password-less polkit access to +# libvirtd. The uid number is irrelevant, so we use dynamic allocation +# described at the above link. +getent group libvirt >/dev/null || groupadd -r libvirt + +exit 0 + +%post daemon + +%systemd_post virtlockd.socket virtlockd-admin.socket +%systemd_post virtlogd.socket virtlogd-admin.socket +%systemd_post libvirtd.service + +# request daemon restart in posttrans +mkdir -p %{_localstatedir}/lib/rpm-state/libvirt || : +touch %{_localstatedir}/lib/rpm-state/libvirt/restart || : + +%preun daemon +%systemd_preun libvirtd.service +%systemd_preun virtlogd.socket virtlogd-admin.socket virtlogd.service +%systemd_preun virtlockd.socket virtlockd-admin.socket virtlockd.service + +%postun daemon +/bin/systemctl daemon-reload >/dev/null 2>&1 || : +if [ $1 -ge 1 ] ; then + /bin/systemctl reload-or-try-restart virtlockd.service >/dev/null 2>&1 || : + /bin/systemctl reload-or-try-restart virtlogd.service >/dev/null 2>&1 || : +fi + +# In upgrade scenario we must explicitly enable virtlockd/virtlogd +# sockets, if libvirtd is already enabled and start them if +# libvirtd is running, otherwise you'll get failures to start +# guests +%triggerpostun daemon -- libvirt-daemon < 1.3.0 +if [ $1 -ge 1 ] ; then + /bin/systemctl is-enabled libvirtd.service 1>/dev/null 2>&1 && + /bin/systemctl enable virtlogd.socket virtlogd-admin.socket || : + /bin/systemctl is-active libvirtd.service 1>/dev/null 2>&1 && + /bin/systemctl start virtlogd.socket virtlogd-admin.socket || : +fi + +%posttrans daemon +if [ -f %{_localstatedir}/lib/rpm-state/libvirt/restart ]; then + /bin/systemctl try-restart libvirtd.service >/dev/null 2>&1 || : +fi +rm -rf %{_localstatedir}/lib/rpm-state/libvirt || : + +%post daemon-config-network +if test $1 -eq 1 && test ! -f %{_sysconfdir}/libvirt/qemu/networks/default.xml ; then + # see if the network used by default network creates a conflict, + # and try to resolve it + # NB: 192.168.122.0/24 is used in the default.xml template file; + # do not modify any of those values here without also modifying + # them in the template. + orig_sub=122 + sub=${orig_sub} + nl=' +' + routes="${nl}$(ip route show | cut -d' ' -f1)${nl}" + case ${routes} in + *"${nl}192.168.${orig_sub}.0/24${nl}"*) + # there was a match, so we need to look for an unused subnet + for new_sub in $(seq 124 254); do + case ${routes} in + *"${nl}192.168.${new_sub}.0/24${nl}"*) + ;; + *) + sub=$new_sub + break; + ;; + esac + done + ;; + *) + ;; + esac + + UUID=`/usr/bin/uuidgen` + sed -e "s/${orig_sub}/${sub}/g" \ + -e "s,,\n $UUID," \ + < %{_datadir}/libvirt/networks/default.xml \ + > %{_sysconfdir}/libvirt/qemu/networks/default.xml + ln -s ../default.xml %{_sysconfdir}/libvirt/qemu/networks/autostart/default.xml + + # Make sure libvirt picks up the new network defininiton + mkdir -p %{_localstatedir}/lib/rpm-state/libvirt || : + touch %{_localstatedir}/lib/rpm-state/libvirt/restart || : +fi + +%posttrans daemon-config-network +if [ -f %{_localstatedir}/lib/rpm-state/libvirt/restart ]; then + /bin/systemctl try-restart libvirtd.service >/dev/null 2>&1 || : +fi +rm -rf %{_localstatedir}/lib/rpm-state/libvirt || : + +%post daemon-config-nwfilter +cp %{_datadir}/libvirt/nwfilter/*.xml %{_sysconfdir}/libvirt/nwfilter/ +# Make sure libvirt picks up the new nwfilter defininitons +mkdir -p %{_localstatedir}/lib/rpm-state/libvirt || : +touch %{_localstatedir}/lib/rpm-state/libvirt/restart || : + +%posttrans daemon-config-nwfilter +if [ -f %{_localstatedir}/lib/rpm-state/libvirt/restart ]; then + /bin/systemctl try-restart libvirtd.service >/dev/null 2>&1 || : +fi +rm -rf %{_localstatedir}/lib/rpm-state/libvirt || : + + +%triggerun -- libvirt < 0.9.4 +%{_bindir}/systemd-sysv-convert --save libvirtd >/dev/null 2>&1 ||: + +# If the package is allowed to autostart: +/bin/systemctl --no-reload enable libvirtd.service >/dev/null 2>&1 ||: + +# Run these because the SysV package being removed won't do them +/sbin/chkconfig --del libvirtd >/dev/null 2>&1 || : +/bin/systemctl try-restart libvirtd.service >/dev/null 2>&1 || : + +%if %{with_qemu} +%pre daemon-driver-qemu +# We want soft static allocation of well-known ids, as disk images +# are commonly shared across NFS mounts by id rather than name; see +# https://fedoraproject.org/wiki/Packaging:UsersAndGroups +getent group kvm >/dev/null || groupadd -f -g 36 -r kvm +getent group qemu >/dev/null || groupadd -f -g 107 -r qemu +if ! getent passwd qemu >/dev/null; then + if ! getent passwd 107 >/dev/null; then + useradd -r -u 107 -g qemu -G kvm -d / -s /sbin/nologin -c "qemu user" qemu + else + useradd -r -g qemu -G kvm -d / -s /sbin/nologin -c "qemu user" qemu + fi +fi +exit 0 +%endif + +%preun client + +%systemd_preun libvirt-guests.service + +%post client + +/sbin/ldconfig +%systemd_post libvirt-guests.service + +%postun client + +/sbin/ldconfig +%systemd_postun libvirt-guests.service + +%triggerun client -- libvirt < 0.9.4 +%{_bindir}/systemd-sysv-convert --save libvirt-guests >/dev/null 2>&1 ||: + +# If the package is allowed to autostart: +/bin/systemctl --no-reload enable libvirt-guests.service >/dev/null 2>&1 ||: + +# Run this because the SysV package being removed won't do them +/sbin/chkconfig --del libvirt-guests >/dev/null 2>&1 || : + +%if %{with_sanlock} +%post lock-sanlock +if getent group sanlock > /dev/null ; then + chmod 0770 %{_localstatedir}/lib/libvirt/sanlock + chown root:sanlock %{_localstatedir}/lib/libvirt/sanlock +fi +%endif + +%if %{with_lxc} +%pre login-shell +getent group virtlogin >/dev/null || groupadd -r virtlogin +exit 0 +%endif + +%files + +%files docs +%doc AUTHORS ChangeLog.gz NEWS README README.md +%doc libvirt-docs/* + +# API docs +%dir %{_datadir}/gtk-doc/html/libvirt/ +%doc %{_datadir}/gtk-doc/html/libvirt/*.devhelp +%doc %{_datadir}/gtk-doc/html/libvirt/*.html +%doc %{_datadir}/gtk-doc/html/libvirt/*.png +%doc %{_datadir}/gtk-doc/html/libvirt/*.css +%doc examples/c/admin +%doc examples/c/domain +%doc examples/c/misc +%doc examples/polkit +%doc examples/sh +%doc examples/systemtap +%doc examples/xml + + +%files daemon + +%dir %attr(0700, root, root) %{_sysconfdir}/libvirt/ + +%{_unitdir}/libvirtd.service +%{_unitdir}/virt-guest-shutdown.target +%{_unitdir}/virtlogd.service +%{_unitdir}/virtlogd.socket +%{_unitdir}/virtlogd-admin.socket +%{_unitdir}/virtlockd.service +%{_unitdir}/virtlockd.socket +%{_unitdir}/virtlockd-admin.socket +%config(noreplace) %{_sysconfdir}/sysconfig/libvirtd +%config(noreplace) %{_sysconfdir}/sysconfig/virtlogd +%config(noreplace) %{_sysconfdir}/sysconfig/virtlockd +%config(noreplace) %{_sysconfdir}/libvirt/libvirtd.conf +%config(noreplace) %{_sysconfdir}/libvirt/virtlogd.conf +%config(noreplace) %{_sysconfdir}/libvirt/virtlockd.conf +%config(noreplace) %{_sysconfdir}/sasl2/libvirt.conf +%config(noreplace) %{_prefix}/lib/sysctl.d/60-libvirtd.conf + +%config(noreplace) %{_sysconfdir}/logrotate.d/libvirtd +%dir %{_datadir}/libvirt/ + +%ghost %dir %{_localstatedir}/run/libvirt/ + +%dir %attr(0711, root, root) %{_localstatedir}/lib/libvirt/images/ +%dir %attr(0711, root, root) %{_localstatedir}/lib/libvirt/filesystems/ +%dir %attr(0711, root, root) %{_localstatedir}/lib/libvirt/boot/ +%dir %attr(0711, root, root) %{_localstatedir}/cache/libvirt/ + + +%dir %attr(0755, root, root) %{_libdir}/libvirt/ +%dir %attr(0755, root, root) %{_libdir}/libvirt/connection-driver/ +%dir %attr(0755, root, root) %{_libdir}/libvirt/lock-driver +%attr(0755, root, root) %{_libdir}/libvirt/lock-driver/lockd.so + +%{_datadir}/augeas/lenses/libvirtd.aug +%{_datadir}/augeas/lenses/tests/test_libvirtd.aug +%{_datadir}/augeas/lenses/virtlogd.aug +%{_datadir}/augeas/lenses/tests/test_virtlogd.aug +%{_datadir}/augeas/lenses/virtlockd.aug +%{_datadir}/augeas/lenses/tests/test_virtlockd.aug +%{_datadir}/augeas/lenses/libvirt_lockd.aug +%if %{with_qemu} +%{_datadir}/augeas/lenses/tests/test_libvirt_lockd.aug +%endif + +%{_datadir}/polkit-1/actions/org.libvirt.unix.policy +%{_datadir}/polkit-1/actions/org.libvirt.api.policy +%{_datadir}/polkit-1/rules.d/50-libvirt.rules + +%dir %attr(0700, root, root) %{_localstatedir}/log/libvirt/ + +%attr(0755, root, root) %{_libexecdir}/libvirt_iohelper + +%attr(0755, root, root) %{_sbindir}/libvirtd +%attr(0755, root, root) %{_sbindir}/virtlogd +%attr(0755, root, root) %{_sbindir}/virtlockd + +%{_mandir}/man8/libvirtd.8* +%{_mandir}/man8/virtlogd.8* +%{_mandir}/man8/virtlockd.8* +%{_mandir}/man7/virkey*.7* + +%doc examples/polkit/*.rules + +%files daemon-config-network +%dir %{_datadir}/libvirt/networks/ +%{_datadir}/libvirt/networks/default.xml + +%files daemon-config-nwfilter +%dir %{_datadir}/libvirt/nwfilter/ +%{_datadir}/libvirt/nwfilter/*.xml +%ghost %{_sysconfdir}/libvirt/nwfilter/*.xml + +%files daemon-driver-interface +%{_libdir}/%{name}/connection-driver/libvirt_driver_interface.so + +%files daemon-driver-network +%dir %attr(0700, root, root) %{_sysconfdir}/libvirt/qemu/ +%dir %attr(0700, root, root) %{_sysconfdir}/libvirt/qemu/networks/ +%dir %attr(0700, root, root) %{_sysconfdir}/libvirt/qemu/networks/autostart +%ghost %dir %{_localstatedir}/run/libvirt/network/ +%dir %attr(0700, root, root) %{_localstatedir}/lib/libvirt/network/ +%dir %attr(0755, root, root) %{_localstatedir}/lib/libvirt/dnsmasq/ +%attr(0755, root, root) %{_libexecdir}/libvirt_leaseshelper +%{_libdir}/%{name}/connection-driver/libvirt_driver_network.so + +%if %{with_firewalld_zone} +%{_prefix}/lib/firewalld/zones/libvirt.xml +%endif + +%files daemon-driver-nodedev +%{_libdir}/%{name}/connection-driver/libvirt_driver_nodedev.so + +%files daemon-driver-nwfilter +%dir %attr(0700, root, root) %{_sysconfdir}/libvirt/nwfilter/ +%ghost %dir %{_localstatedir}/run/libvirt/network/ +%{_libdir}/%{name}/connection-driver/libvirt_driver_nwfilter.so + +%files daemon-driver-secret +%{_libdir}/%{name}/connection-driver/libvirt_driver_secret.so + +%files daemon-driver-storage + +%files daemon-driver-storage-core +%attr(0755, root, root) %{_libexecdir}/libvirt_parthelper +%{_libdir}/%{name}/connection-driver/libvirt_driver_storage.so +%{_libdir}/%{name}/storage-backend/libvirt_storage_backend_fs.so +%{_libdir}/%{name}/storage-file/libvirt_storage_file_fs.so + +%files daemon-driver-storage-disk +%{_libdir}/%{name}/storage-backend/libvirt_storage_backend_disk.so + +%files daemon-driver-storage-logical +%{_libdir}/%{name}/storage-backend/libvirt_storage_backend_logical.so + +%files daemon-driver-storage-scsi +%{_libdir}/%{name}/storage-backend/libvirt_storage_backend_scsi.so + +%files daemon-driver-storage-iscsi +%{_libdir}/%{name}/storage-backend/libvirt_storage_backend_iscsi.so + +%if %{with_storage_iscsi_direct} +%files daemon-driver-storage-iscsi-direct +%{_libdir}/%{name}/storage-backend/libvirt_storage_backend_iscsi-direct.so +%endif + +%files daemon-driver-storage-mpath +%{_libdir}/%{name}/storage-backend/libvirt_storage_backend_mpath.so + +%if %{with_storage_gluster} +%files daemon-driver-storage-gluster +%{_libdir}/%{name}/storage-backend/libvirt_storage_backend_gluster.so +%{_libdir}/%{name}/storage-file/libvirt_storage_file_gluster.so +%endif + +%if %{with_storage_rbd} +%files daemon-driver-storage-rbd +%{_libdir}/%{name}/storage-backend/libvirt_storage_backend_rbd.so +%endif + +%if %{with_storage_sheepdog} +%files daemon-driver-storage-sheepdog +%{_libdir}/%{name}/storage-backend/libvirt_storage_backend_sheepdog.so +%endif + +%if %{with_storage_zfs} +%files daemon-driver-storage-zfs +%{_libdir}/%{name}/storage-backend/libvirt_storage_backend_zfs.so +%endif + +%if %{with_qemu} +%files daemon-driver-qemu +%dir %attr(0700, root, root) %{_sysconfdir}/libvirt/qemu/ +%dir %attr(0700, root, root) %{_localstatedir}/log/libvirt/qemu/ +%config(noreplace) %{_sysconfdir}/libvirt/qemu.conf +%config(noreplace) %{_sysconfdir}/libvirt/qemu-lockd.conf +%config(noreplace) %{_sysconfdir}/logrotate.d/libvirtd.qemu +%ghost %dir %attr(0700, root, root) %{_localstatedir}/run/libvirt/qemu/ +%dir %attr(0751, %{qemu_user}, %{qemu_group}) %{_localstatedir}/lib/libvirt/qemu/ +%dir %attr(0750, %{qemu_user}, %{qemu_group}) %{_localstatedir}/cache/libvirt/qemu/ +%{_datadir}/augeas/lenses/libvirtd_qemu.aug +%{_datadir}/augeas/lenses/tests/test_libvirtd_qemu.aug +%{_libdir}/%{name}/connection-driver/libvirt_driver_qemu.so +%dir %attr(0711, root, root) %{_localstatedir}/lib/libvirt/swtpm/ +%dir %attr(0711, root, root) %{_localstatedir}/log/swtpm/libvirt/qemu/ +%endif + +%if %{with_lxc} +%files daemon-driver-lxc +%dir %attr(0700, root, root) %{_localstatedir}/log/libvirt/lxc/ +%config(noreplace) %{_sysconfdir}/libvirt/lxc.conf +%config(noreplace) %{_sysconfdir}/logrotate.d/libvirtd.lxc +%ghost %dir %{_localstatedir}/run/libvirt/lxc/ +%dir %attr(0700, root, root) %{_localstatedir}/lib/libvirt/lxc/ +%{_datadir}/augeas/lenses/libvirtd_lxc.aug +%{_datadir}/augeas/lenses/tests/test_libvirtd_lxc.aug +%attr(0755, root, root) %{_libexecdir}/libvirt_lxc +%{_libdir}/%{name}/connection-driver/libvirt_driver_lxc.so +%endif + +%if %{with_libxl} +%files daemon-driver-libxl +%config(noreplace) %{_sysconfdir}/libvirt/libxl.conf +%config(noreplace) %{_sysconfdir}/logrotate.d/libvirtd.libxl +%config(noreplace) %{_sysconfdir}/libvirt/libxl-lockd.conf +%{_datadir}/augeas/lenses/libvirtd_libxl.aug +%{_datadir}/augeas/lenses/tests/test_libvirtd_libxl.aug +%dir %attr(0700, root, root) %{_localstatedir}/log/libvirt/libxl/ +%ghost %dir %{_localstatedir}/run/libvirt/libxl/ +%dir %attr(0700, root, root) %{_localstatedir}/lib/libvirt/libxl/ +%{_libdir}/%{name}/connection-driver/libvirt_driver_libxl.so +%endif + +%if %{with_vbox} +%files daemon-driver-vbox +%{_libdir}/%{name}/connection-driver/libvirt_driver_vbox.so +%endif + +%if %{with_qemu_tcg} +%files daemon-qemu +%endif + +%if %{with_qemu_kvm} +%files daemon-kvm +%endif + +%if %{with_lxc} +%files daemon-lxc +%endif + +%if %{with_libxl} +%files daemon-xen +%endif + +%if %{with_vbox} +%files daemon-vbox +%endif + +%if %{with_sanlock} +%files lock-sanlock + %if %{with_qemu} +%config(noreplace) %{_sysconfdir}/libvirt/qemu-sanlock.conf + %endif + %if %{with_libxl} +%config(noreplace) %{_sysconfdir}/libvirt/libxl-sanlock.conf + %endif +%attr(0755, root, root) %{_libdir}/libvirt/lock-driver/sanlock.so +%{_datadir}/augeas/lenses/libvirt_sanlock.aug +%{_datadir}/augeas/lenses/tests/test_libvirt_sanlock.aug +%dir %attr(0700, root, root) %{_localstatedir}/lib/libvirt/sanlock +%{_sbindir}/virt-sanlock-cleanup +%{_mandir}/man8/virt-sanlock-cleanup.8* +%attr(0755, root, root) %{_libexecdir}/libvirt_sanlock_helper +%endif + +%files client +%{_mandir}/man1/virsh.1* +%{_mandir}/man1/virt-xml-validate.1* +%{_mandir}/man1/virt-pki-validate.1* +%{_mandir}/man1/virt-host-validate.1* +%{_bindir}/virsh +%{_bindir}/virt-xml-validate +%{_bindir}/virt-pki-validate +%{_bindir}/virt-host-validate + +%{_datadir}/systemtap/tapset/libvirt_probes*.stp +%{_datadir}/systemtap/tapset/libvirt_functions.stp +%if %{with_qemu} +%{_datadir}/systemtap/tapset/libvirt_qemu_probes*.stp +%endif + +%if %{with_bash_completion} +%{_datadir}/bash-completion/completions/virsh +%endif + + +%{_unitdir}/libvirt-guests.service +%config(noreplace) %{_sysconfdir}/sysconfig/libvirt-guests +%attr(0755, root, root) %{_libexecdir}/libvirt-guests.sh + +%files libs -f %{name}.lang +%license COPYING COPYING.LESSER +%config(noreplace) %{_sysconfdir}/libvirt/libvirt.conf +%config(noreplace) %{_sysconfdir}/libvirt/libvirt-admin.conf +%{_libdir}/libvirt.so.* +%{_libdir}/libvirt-qemu.so.* +%{_libdir}/libvirt-lxc.so.* +%{_libdir}/libvirt-admin.so.* +%dir %{_datadir}/libvirt/ +%dir %{_datadir}/libvirt/schemas/ +%dir %attr(0755, root, root) %{_localstatedir}/lib/libvirt/ + +%{_datadir}/libvirt/schemas/basictypes.rng +%{_datadir}/libvirt/schemas/capability.rng +%{_datadir}/libvirt/schemas/cputypes.rng +%{_datadir}/libvirt/schemas/domain.rng +%{_datadir}/libvirt/schemas/domaincaps.rng +%{_datadir}/libvirt/schemas/domaincommon.rng +%{_datadir}/libvirt/schemas/domainsnapshot.rng +%{_datadir}/libvirt/schemas/interface.rng +%{_datadir}/libvirt/schemas/network.rng +%{_datadir}/libvirt/schemas/networkcommon.rng +%{_datadir}/libvirt/schemas/networkport.rng +%{_datadir}/libvirt/schemas/nodedev.rng +%{_datadir}/libvirt/schemas/nwfilter.rng +%{_datadir}/libvirt/schemas/nwfilter_params.rng +%{_datadir}/libvirt/schemas/nwfilterbinding.rng +%{_datadir}/libvirt/schemas/secret.rng +%{_datadir}/libvirt/schemas/storagecommon.rng +%{_datadir}/libvirt/schemas/storagepool.rng +%{_datadir}/libvirt/schemas/storagepoolcaps.rng +%{_datadir}/libvirt/schemas/storagevol.rng + +%{_datadir}/libvirt/cpu_map/*.xml + +%{_datadir}/libvirt/test-screenshot.png + +%files admin +%{_mandir}/man1/virt-admin.1* +%{_bindir}/virt-admin +%if %{with_bash_completion} +%{_datadir}/bash-completion/completions/virt-admin +%endif + +%if %{with_bash_completion} +%files bash-completion +%{_datadir}/bash-completion/completions/vsh +%endif + +%if %{with_wireshark} +%files wireshark +%{wireshark_plugindir}/libvirt.so +%endif + +%files nss +%{_libdir}/libnss_libvirt.so.2 +%{_libdir}/libnss_libvirt_guest.so.2 + +%if %{with_lxc} +%files login-shell +%attr(4750, root, virtlogin) %{_bindir}/virt-login-shell +%config(noreplace) %{_sysconfdir}/libvirt/virt-login-shell.conf +%{_mandir}/man1/virt-login-shell.1* +%endif + +%files devel +%{_libdir}/libvirt.so +%{_libdir}/libvirt-admin.so +%{_libdir}/libvirt-qemu.so +%{_libdir}/libvirt-lxc.so +%dir %{_includedir}/libvirt +%{_includedir}/libvirt/virterror.h +%{_includedir}/libvirt/libvirt.h +%{_includedir}/libvirt/libvirt-admin.h +%{_includedir}/libvirt/libvirt-common.h +%{_includedir}/libvirt/libvirt-domain.h +%{_includedir}/libvirt/libvirt-domain-snapshot.h +%{_includedir}/libvirt/libvirt-event.h +%{_includedir}/libvirt/libvirt-host.h +%{_includedir}/libvirt/libvirt-interface.h +%{_includedir}/libvirt/libvirt-network.h +%{_includedir}/libvirt/libvirt-nodedev.h +%{_includedir}/libvirt/libvirt-nwfilter.h +%{_includedir}/libvirt/libvirt-secret.h +%{_includedir}/libvirt/libvirt-storage.h +%{_includedir}/libvirt/libvirt-stream.h +%{_includedir}/libvirt/libvirt-qemu.h +%{_includedir}/libvirt/libvirt-lxc.h +%{_libdir}/pkgconfig/libvirt.pc +%{_libdir}/pkgconfig/libvirt-admin.pc +%{_libdir}/pkgconfig/libvirt-qemu.pc +%{_libdir}/pkgconfig/libvirt-lxc.pc + +%dir %{_datadir}/libvirt/api/ +%{_datadir}/libvirt/api/libvirt-api.xml +%{_datadir}/libvirt/api/libvirt-admin-api.xml +%{_datadir}/libvirt/api/libvirt-qemu-api.xml +%{_datadir}/libvirt/api/libvirt-lxc-api.xml +# Needed building python bindings +%doc docs/libvirt-api.xml + + +%changelog +* Fri Sep 6 2019 openEuler Buildteam - 5.5.0-1 +- Support ARM CPU Host Model. +- Support Kunpeng-T82 CPU. +* Wed Aug 28 2019 openEuler Buildteam - 5.5.0-1 +- Remove unnessary virObjectUnref after use VIR_AUTOUNREF +* Mon Aug 26 2019 openEuler Buildteam - 5.5.0-1 +- Use the same def of device when attach live and config. +* Thu Aug 15 2019 openEuler Buildteam - 5.5.0-1 +- Fix driver cleanup order to avoid coredump. +* Wed Aug 14 2019 openEuler Buildteam - 5.5.0-1 +- Avoid double free when prase device xml failed. +* Wed Jul 31 2019 openEuler Buildteam - 5.5.0-1 +- cherry-pick bugfix from upstream. +* Mon Jul 29 2019 openEuler Buildteam - 5.5.0-1 +- Backport some memory leak patches from Huawei. +* Fri Jul 19 2019 openEuler Buildteam - 5.5.0-1 +- Update to 5.5.0 release, Initial package for OpenEuler.