Package init
This commit is contained in:
commit
29372b3f10
BIN
libvirt-5.5.0.tar.xz
Normal file
BIN
libvirt-5.5.0.tar.xz
Normal file
Binary file not shown.
@ -0,0 +1,81 @@
|
||||
From c27fda8374562a9b6061e18f8c9ba78ae9df2c08 Mon Sep 17 00:00:00 2001
|
||||
From: =?UTF-8?q?J=C3=A1n=20Tomko?= <jtomko@redhat.com>
|
||||
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 <jtomko@redhat.com>
|
||||
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
|
||||
(cherry-picked from commit 5d74619329a2063efc8028536b3f8acc8e949f88)
|
||||
Signed-off-by: Xu Yandong <xuyandong2@huawei.com>
|
||||
---
|
||||
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 @@
|
||||
<pool type='mpath' supported='no'>
|
||||
</pool>
|
||||
<pool type='rbd' supported='no'>
|
||||
+ <volOptions>
|
||||
+ <defaultFormat type='raw'/>
|
||||
+ <enum name='targetFormatType'>
|
||||
+ </enum>
|
||||
+ </volOptions>
|
||||
</pool>
|
||||
<pool type='sheepdog' supported='no'>
|
||||
</pool>
|
||||
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 @@
|
||||
<pool type='mpath' supported='yes'>
|
||||
</pool>
|
||||
<pool type='rbd' supported='yes'>
|
||||
+ <volOptions>
|
||||
+ <defaultFormat type='raw'/>
|
||||
+ <enum name='targetFormatType'>
|
||||
+ </enum>
|
||||
+ </volOptions>
|
||||
</pool>
|
||||
<pool type='sheepdog' supported='yes'>
|
||||
</pool>
|
||||
--
|
||||
2.19.1
|
||||
|
||||
@ -0,0 +1,35 @@
|
||||
From d5ac07dee8c9337878ed0085e940c86d3f2ade0b Mon Sep 17 00:00:00 2001
|
||||
From: Xu Yandong <xuyandong2@huawei.com>
|
||||
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 <xuyandong2@huawei.com>
|
||||
---
|
||||
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
|
||||
|
||||
@ -0,0 +1,30 @@
|
||||
From 62c8b7f6afec8f8a51d5f2d6a33b9ac5cd0b2988 Mon Sep 17 00:00:00 2001
|
||||
From: Xu Yandong <xuyandong2@huawei.com>
|
||||
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 <xuyandong2@huawei.com>
|
||||
---
|
||||
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
|
||||
|
||||
@ -0,0 +1,32 @@
|
||||
From 662ca668ba205216fe908eb5ab1816842625b83e Mon Sep 17 00:00:00 2001
|
||||
From: Feng Ni <fengni@huawei.com>
|
||||
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 <fengni@huawei.com>
|
||||
---
|
||||
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
|
||||
|
||||
@ -0,0 +1,28 @@
|
||||
From bf5ba702bb7cbd362a2dc6b278e083e7e475dcff Mon Sep 17 00:00:00 2001
|
||||
From: Feng Ni <fengni@huawei.com>
|
||||
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 <fengni@huawei.com>
|
||||
---
|
||||
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
|
||||
|
||||
29
libvirt-conf-use-virDomainDeviceDefFree-free-dev.patch
Normal file
29
libvirt-conf-use-virDomainDeviceDefFree-free-dev.patch
Normal file
@ -0,0 +1,29 @@
|
||||
From c46e864f40ce35f0b67543990b46dc0731121f9d Mon Sep 17 00:00:00 2001
|
||||
From: Feng Ni <fengni@huawei.com>
|
||||
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 <fengni@huawei.com>
|
||||
---
|
||||
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
|
||||
|
||||
@ -0,0 +1,41 @@
|
||||
From bed928dada1ed8fe50dd4792d7b201df29016c12 Mon Sep 17 00:00:00 2001
|
||||
From: Xu Yandong <xuyandong2@huawei.com>
|
||||
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 <xuyandong2@huawei.com>
|
||||
---
|
||||
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
|
||||
|
||||
133
libvirt-cpu-add-getHostCPU-for-ARM-CPUS.patch
Normal file
133
libvirt-cpu-add-getHostCPU-for-ARM-CPUS.patch
Normal file
@ -0,0 +1,133 @@
|
||||
From 4c3a9684e7fccef83158a4a2f74680c6d8e166f7 Mon Sep 17 00:00:00 2001
|
||||
From: Xu Yandong <xuyandong2@huawei.com>
|
||||
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 <xuyandong2@huawei.com>
|
||||
---
|
||||
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
|
||||
|
||||
292
libvirt-cpu-fix-cpu-compare-and-cpu-baseline-for-ARM-CPU.patch
Normal file
292
libvirt-cpu-fix-cpu-compare-and-cpu-baseline-for-ARM-CPU.patch
Normal file
@ -0,0 +1,292 @@
|
||||
From 57b8e156e898ccf878842c3cba1ed97a415cff6a Mon Sep 17 00:00:00 2001
|
||||
From: Xu Yandong <xuyandong2@huawei.com>
|
||||
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 <xuyandong2@huawei.com>
|
||||
---
|
||||
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
|
||||
|
||||
649
libvirt-cpu-introduce-cpu-baseline-for-ARM-CPU.patch
Normal file
649
libvirt-cpu-introduce-cpu-baseline-for-ARM-CPU.patch
Normal file
@ -0,0 +1,649 @@
|
||||
From 2dc7c9bc3dc24d991834f7657cd65cf4b5774ff8 Mon Sep 17 00:00:00 2001
|
||||
From: Xu Yandong <xuyandong2@huawei.com>
|
||||
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 <xuyandong2.huawei.com>
|
||||
---
|
||||
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 <config.h>
|
||||
|
||||
+#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
|
||||
|
||||
76
libvirt-cpu-introduce-virCPUarmData-to-virCPUData.patch
Normal file
76
libvirt-cpu-introduce-virCPUarmData-to-virCPUData.patch
Normal file
@ -0,0 +1,76 @@
|
||||
From e814e4a7e227cd681b9dd95aedc93f3a087c42a1 Mon Sep 17 00:00:00 2001
|
||||
From: Xu Yandong <xuyandong2@huawei.com>
|
||||
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 <xuyandong2.huawei.com>
|
||||
---
|
||||
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
|
||||
+ * <http://www.gnu.org/licenses/>.
|
||||
+ *
|
||||
+ */
|
||||
+
|
||||
+#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
|
||||
|
||||
150
libvirt-cpu_map-Introduce-arm-CPU-models.patch
Normal file
150
libvirt-cpu_map-Introduce-arm-CPU-models.patch
Normal file
@ -0,0 +1,150 @@
|
||||
From 4274e2d7d00058b5a6aca7c4b256c0c6fb01d69d Mon Sep 17 00:00:00 2001
|
||||
From: Xu Yandong <xuyandong2@huawei.com>
|
||||
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 <xuyandong2@huawei.com>
|
||||
---
|
||||
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 @@
|
||||
+<cpus>
|
||||
+ <model name='Kunpeng-T82'>
|
||||
+ <vendor name='Hisilicon'/>
|
||||
+ <pvr value='0xd01'/>
|
||||
+ <feature name="fp"/>
|
||||
+ <feature name="asimd"/>
|
||||
+ <feature name="evtstrm"/>
|
||||
+ <feature name="aes"/>
|
||||
+ <feature name="pmull"/>
|
||||
+ <feature name="sha1"/>
|
||||
+ <feature name="sha2"/>
|
||||
+ <feature name="crc32"/>
|
||||
+ <feature name="atomics"/>
|
||||
+ <feature name="fphp"/>
|
||||
+ <feature name="asimdhp"/>
|
||||
+ <feature name="cpuid"/>
|
||||
+ <feature name="asimdrdm"/>
|
||||
+ <feature name="jscvt"/>
|
||||
+ <feature name="fcma"/>
|
||||
+ <feature name="dcpop"/>
|
||||
+ <feature name="asimddp"/>
|
||||
+ <feature name="asimdfhm"/>
|
||||
+ </model>
|
||||
+</cpus>
|
||||
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 @@
|
||||
+<cpus>
|
||||
+ <model name='cortex-a53'>
|
||||
+ <vendor name='ARM'/>
|
||||
+ <pvr value='0xd03'/>
|
||||
+ </model>
|
||||
+</cpus>
|
||||
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 @@
|
||||
+<cpus>
|
||||
+ <model name='cortex-a57'>
|
||||
+ <vendor name='ARM'/>
|
||||
+ <pvr value='0xd07'/>
|
||||
+ </model>
|
||||
+</cpus>
|
||||
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 @@
|
||||
+<cpus>
|
||||
+ <model name='cortex-a72'>
|
||||
+ <vendor name='ARM'/>
|
||||
+ <pvr value='0xd08'/>
|
||||
+ </model>
|
||||
+</cpus>
|
||||
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 @@
|
||||
+<cpus>
|
||||
+ <vendor name="ARM" value="0x41"/>
|
||||
+ <vendor name="Broadcom" value="0x42"/>
|
||||
+ <vendor name="Cavium" value="0x43"/>
|
||||
+ <vendor name="DigitalEquipment" value="0x44"/>
|
||||
+ <vendor name="Hisilicon" value="0x48"/>
|
||||
+ <vendor name="Infineon" value="0x49"/>
|
||||
+ <vendor name="Freescale" value="0x4D"/>
|
||||
+ <vendor name="NVIDIA" value="0x4E"/>
|
||||
+ <vendor name="APM" value="0x50"/>
|
||||
+ <vendor name="Qualcomm" value="0x51"/>
|
||||
+ <vendor name="Marvell" value="0x56"/>
|
||||
+ <vendor name="Intel" value="0x69"/>
|
||||
+</cpus>
|
||||
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 @@
|
||||
<include filename="ppc64_POWERPC_e5500.xml"/>
|
||||
<include filename="ppc64_POWERPC_e6500.xml"/>
|
||||
</arch>
|
||||
+
|
||||
+ <arch name='arm'>
|
||||
+ <include filename="arm_vendors.xml"/>
|
||||
+
|
||||
+ <!-- ARM-based CPU models -->
|
||||
+ <include filename="arm_cortex-a53.xml"/>
|
||||
+ <include filename="arm_cortex-a57.xml"/>
|
||||
+ <include filename="arm_cortex-a72.xml"/>
|
||||
+
|
||||
+ <!-- Hisilicon-based CPU models -->
|
||||
+ <include filename="arm_Kunpeng-T82.xml"/>
|
||||
+ </arch>
|
||||
</cpus>
|
||||
--
|
||||
2.19.1
|
||||
|
||||
@ -0,0 +1,55 @@
|
||||
From 554597f2fc6fec3191426a88fd2e5a19246a989a Mon Sep 17 00:00:00 2001
|
||||
From: Xu Yandong <xuyandong2@huawei.com>
|
||||
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 <xuyandong2@huawei.com>
|
||||
---
|
||||
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
|
||||
|
||||
@ -0,0 +1,29 @@
|
||||
From b32fefd72878ca398f9a83c9eea3533f74dfcd5a Mon Sep 17 00:00:00 2001
|
||||
From: Xu Yandong <xuyandong2@huawei.com>
|
||||
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 <xuyandong2@huawei.com>
|
||||
---
|
||||
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
|
||||
|
||||
@ -0,0 +1,47 @@
|
||||
From d2be5a59d36a743505185c0f5bb636088a6e37da Mon Sep 17 00:00:00 2001
|
||||
From: Wu Jing <wujing42@huawei.com>
|
||||
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 <wujing42@huawei.com>
|
||||
---
|
||||
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
|
||||
|
||||
60
libvirt-nodedev-fix-potential-heap-use-after-free.patch
Normal file
60
libvirt-nodedev-fix-potential-heap-use-after-free.patch
Normal file
@ -0,0 +1,60 @@
|
||||
From c53f20683ef66939d94e690e875500628a5b4f3f Mon Sep 17 00:00:00 2001
|
||||
From: Xu Yandong <xuyandong2@huawei.com>
|
||||
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 <xuyandong2@huawei.com>
|
||||
---
|
||||
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
|
||||
|
||||
@ -0,0 +1,98 @@
|
||||
From f8c3c7f120aafa218615b7f6e4b380538efeb674 Mon Sep 17 00:00:00 2001
|
||||
From: Michal Privoznik <mprivozn@redhat.com>
|
||||
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 <mprivozn@redhat.com>
|
||||
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
|
||||
(cherry-picked from commit 7711a7346a990810603c0715d3c6ba922eb88c51)
|
||||
Signed-off-by: Xu Yandong <xuyandong2@huawei.com>
|
||||
---
|
||||
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 @@
|
||||
<boot dev='hd'/>
|
||||
</os>
|
||||
<features>
|
||||
+ <acpi/>
|
||||
<apic/>
|
||||
<pae/>
|
||||
<gic version='2'/>
|
||||
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 @@
|
||||
<boot dev='hd'/>
|
||||
</os>
|
||||
<features>
|
||||
+ <acpi/>
|
||||
<apic/>
|
||||
<pae/>
|
||||
<gic version='2'/>
|
||||
--
|
||||
2.19.1
|
||||
|
||||
@ -0,0 +1,56 @@
|
||||
From c829c453baad259c1161dcd4bfed4b9a9372e6b2 Mon Sep 17 00:00:00 2001
|
||||
From: Michal Privoznik <mprivozn@redhat.com>
|
||||
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 <mprivozn@redhat.com>
|
||||
Reviewed-by: Erik Skultety <eskultet@redhat.com>
|
||||
(cherry-picked from commit 881686d4b15306fd5a5f0592d502ddb33ee6437e)
|
||||
Signed-off-by: Xu Yandong <xuyandong2@huawei.com>
|
||||
---
|
||||
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
|
||||
|
||||
31
libvirt-qemu-add-pointer-check-in-qemuMonitorLastError.patch
Normal file
31
libvirt-qemu-add-pointer-check-in-qemuMonitorLastError.patch
Normal file
@ -0,0 +1,31 @@
|
||||
From 7487eaefca026da3b0ccc8e8872a8e7ba0101640 Mon Sep 17 00:00:00 2001
|
||||
From: Feng Ni <fengni@huawei.com>
|
||||
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 <fengni@huawei.com>
|
||||
---
|
||||
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
|
||||
|
||||
42
libvirt-qemu-clear-vcpupin-when-unhotplug-vcpu.patch
Normal file
42
libvirt-qemu-clear-vcpupin-when-unhotplug-vcpu.patch
Normal file
@ -0,0 +1,42 @@
|
||||
From d65307ab8bfeb67075bef1fb643aaaf3fa86a790 Mon Sep 17 00:00:00 2001
|
||||
From: Feng Ni <fengni@huawei.com>
|
||||
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 <fengni@huawei.com>
|
||||
---
|
||||
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
|
||||
|
||||
@ -0,0 +1,29 @@
|
||||
From 04c959123d238c5922389381b02155bc8b66dc6c Mon Sep 17 00:00:00 2001
|
||||
From: Xu Yandong <xuyandong2@huawei.com>
|
||||
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 <xuyandong2@huawei.com>
|
||||
---
|
||||
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
|
||||
|
||||
33
libvirt-qemu-fix-a-concurrent-operation-situation.patch
Normal file
33
libvirt-qemu-fix-a-concurrent-operation-situation.patch
Normal file
@ -0,0 +1,33 @@
|
||||
From 19078ccc1e2160dcb4b223097c6bbc032567514b Mon Sep 17 00:00:00 2001
|
||||
From: Feng Ni <fengni@huawei.com>
|
||||
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 <fengni@huawei.com>
|
||||
---
|
||||
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
|
||||
|
||||
74
libvirt-qemu-fix-potential-memory-leak.patch
Normal file
74
libvirt-qemu-fix-potential-memory-leak.patch
Normal file
@ -0,0 +1,74 @@
|
||||
From 34b8be0d7bd7980ee8be6ca70685788ed81b087b Mon Sep 17 00:00:00 2001
|
||||
From: Feng Ni <fengni@huawei.com>
|
||||
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 <fengni@huawei.com>
|
||||
---
|
||||
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
|
||||
|
||||
@ -0,0 +1,36 @@
|
||||
From ba3884fbb6321923d6b3f88dce82ba01974f8a4d Mon Sep 17 00:00:00 2001
|
||||
From: Xu Yandong <xuyandong2@huawei.com>
|
||||
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 <xuyandong2@huawei.com>
|
||||
---
|
||||
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
|
||||
|
||||
28
libvirt-remote-fix-a-memory-free-error.patch
Normal file
28
libvirt-remote-fix-a-memory-free-error.patch
Normal file
@ -0,0 +1,28 @@
|
||||
From 2a4b0d76a0701f8895d612918ad77a30a2062263 Mon Sep 17 00:00:00 2001
|
||||
From: Feng Ni <fengni@huawei.com>
|
||||
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 <fengni@huawei.com>
|
||||
---
|
||||
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
|
||||
|
||||
37
libvirt-remote-mention-libssh-in-error-message.patch
Normal file
37
libvirt-remote-mention-libssh-in-error-message.patch
Normal file
@ -0,0 +1,37 @@
|
||||
From 13722d386dc65077976d4c557ddcc3458493e9dc Mon Sep 17 00:00:00 2001
|
||||
From: Pino Toscano <ptoscano@redhat.com>
|
||||
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 <ptoscano@redhat.com>
|
||||
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
|
||||
(cherry-picked from commit cfec206e84d6151007a38a9228e10a23b8df57a8)
|
||||
Signed-off-by: Xu Yandong <xuyandong2@huawei.com>
|
||||
---
|
||||
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
|
||||
|
||||
@ -0,0 +1,35 @@
|
||||
From a86a87fc28aee52af46f75ad13e4638e00e06b34 Mon Sep 17 00:00:00 2001
|
||||
From: =?UTF-8?q?J=C3=A1n=20Tomko?= <jtomko@redhat.com>
|
||||
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 <jtomko@redhat.com>
|
||||
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
|
||||
(cherry-picked from commit 9b7c4048fa0559fd81d57b7f7d13b1dccd6a99b2)
|
||||
Signed-off-by: Xu Yandong <xuyandong2@huawei.com>
|
||||
---
|
||||
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
|
||||
|
||||
35
libvirt-storage-rbd-use-VIR_REALLOC-in-the-loop.patch
Normal file
35
libvirt-storage-rbd-use-VIR_REALLOC-in-the-loop.patch
Normal file
@ -0,0 +1,35 @@
|
||||
From 51cf4c75664fd6653a3bf9cb8b83a5a1a0496e5f Mon Sep 17 00:00:00 2001
|
||||
From: =?UTF-8?q?J=C3=A1n=20Tomko?= <jtomko@redhat.com>
|
||||
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 <jtomko@redhat.com>
|
||||
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
|
||||
(cherry-picked from commit d43bc53eddd49c8c22cb52f8b6554e1f7d4216f8)
|
||||
Signed-off-by: Xu Yandong <xuyandong2@huawei.com>
|
||||
---
|
||||
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
|
||||
|
||||
263
libvirt-tests-add-baseline-test-cases-for-arm-CPU.patch
Normal file
263
libvirt-tests-add-baseline-test-cases-for-arm-CPU.patch
Normal file
@ -0,0 +1,263 @@
|
||||
From 940df0f99ab0fcc350fca0df29c74b2f6674cb8a Mon Sep 17 00:00:00 2001
|
||||
From: Xu Yandong <xuyandong2@huawei.com>
|
||||
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 <xuyandong2@huawei.com>
|
||||
---
|
||||
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 @@
|
||||
+<cpuTest>
|
||||
+<cpu>
|
||||
+ <arch>aarch64</arch>
|
||||
+ <model>cortex-a57</model>
|
||||
+ <vendor>ARM</vendor>
|
||||
+ <feature name='fp'/>
|
||||
+ <feature name='asimd'/>
|
||||
+ <feature name='aes'/>
|
||||
+ <feature name='pmull'/>
|
||||
+ <feature name='sha1'/>
|
||||
+ <feature name='sha2'/>
|
||||
+ <feature name='crc32'/>
|
||||
+</cpu>
|
||||
+<cpu>
|
||||
+ <arch>aarch64</arch>
|
||||
+ <model>cortex-a72</model>
|
||||
+ <vendor>Hisilicon</vendor>
|
||||
+ <feature name='fp'/>
|
||||
+ <feature name='asimd'/>
|
||||
+ <feature name='aes'/>
|
||||
+ <feature name='pmull'/>
|
||||
+ <feature name='sha1'/>
|
||||
+ <feature name='sha2'/>
|
||||
+ <feature name='crc32'/>
|
||||
+</cpu>
|
||||
+</cpuTest>
|
||||
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 @@
|
||||
+<cpu mode='custom' match='exact'>
|
||||
+ <model fallback='forbid'>cortex-a57</model>
|
||||
+ <vendor>ARM</vendor>
|
||||
+</cpu>
|
||||
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 @@
|
||||
+<cpuTest>
|
||||
+<cpu>
|
||||
+ <arch>aarch64</arch>
|
||||
+ <model>cortex-a57</model>
|
||||
+ <vendor>ARM</vendor>
|
||||
+ <feature name='fp'/>
|
||||
+ <feature name='asimd'/>
|
||||
+ <feature name='pmull'/>
|
||||
+ <feature name='sha2'/>
|
||||
+ <feature name='crc32'/>
|
||||
+</cpu>
|
||||
+<cpu>
|
||||
+ <arch>aarch64</arch>
|
||||
+ <model>cortex-a57</model>
|
||||
+ <vendor>ARM</vendor>
|
||||
+ <feature name='aes'/>
|
||||
+ <feature name='sha1'/>
|
||||
+</cpu>
|
||||
+</cpuTest>
|
||||
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 @@
|
||||
+<cpu mode='custom' match='exact'>
|
||||
+ <model fallback='forbid'>cortex-a57</model>
|
||||
+ <vendor>ARM</vendor>
|
||||
+</cpu>
|
||||
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 @@
|
||||
+<cpuTest>
|
||||
+<cpu>
|
||||
+ <arch>aarch64</arch>
|
||||
+ <model>cortex-a57</model>
|
||||
+ <vendor>ARM</vendor>
|
||||
+</cpu>
|
||||
+</cpuTest>
|
||||
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 @@
|
||||
+<cpuTest>
|
||||
+<cpu>
|
||||
+ <arch>aarch64</arch>
|
||||
+ <vendor>ARM</vendor>
|
||||
+ <feature name='fp'/>
|
||||
+ <feature name='asimd'/>
|
||||
+ <feature name='aes'/>
|
||||
+ <feature name='pmull'/>
|
||||
+ <feature name='sha1'/>
|
||||
+ <feature name='sha2'/>
|
||||
+ <feature name='crc32'/>
|
||||
+</cpu>
|
||||
+</cpuTest>
|
||||
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 @@
|
||||
+<cpu mode='custom' match='exact'>
|
||||
+ <model fallback='forbid'>cortex-a57</model>
|
||||
+ <feature policy='require' name='fp'/>
|
||||
+ <feature policy='require' name='asimd'/>
|
||||
+ <feature policy='require' name='aes'/>
|
||||
+ <feature policy='require' name='pmull'/>
|
||||
+ <feature policy='require' name='sha1'/>
|
||||
+ <feature policy='require' name='sha2'/>
|
||||
+ <feature policy='require' name='crc32'/>
|
||||
+</cpu>
|
||||
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 @@
|
||||
+<cpuTest>
|
||||
+<cpu>
|
||||
+ <arch>aarch64</arch>
|
||||
+ <model>cortex-a57</model>
|
||||
+ <feature name='fp'/>
|
||||
+ <feature name='asimd'/>
|
||||
+ <feature name='aes'/>
|
||||
+ <feature name='pmull'/>
|
||||
+ <feature name='sha1'/>
|
||||
+ <feature name='sha2'/>
|
||||
+ <feature name='crc32'/>
|
||||
+</cpu>
|
||||
+</cpuTest>
|
||||
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 @@
|
||||
+<cpu mode='custom' match='exact'>
|
||||
+ <model fallback='forbid'>cortex-a57</model>
|
||||
+ <vendor>ARM</vendor>
|
||||
+ <feature policy='require' name='sha1'/>
|
||||
+</cpu>
|
||||
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 @@
|
||||
+<cpuTest>
|
||||
+<cpu>
|
||||
+ <arch>aarch64</arch>
|
||||
+ <model>cortex-a57</model>
|
||||
+ <vendor>ARM</vendor>
|
||||
+ <feature name='fp'/>
|
||||
+ <feature name='asimd'/>
|
||||
+ <feature name='aes'/>
|
||||
+ <feature name='pmull'/>
|
||||
+ <feature name='sha1'/>
|
||||
+ <feature name='sha2'/>
|
||||
+ <feature name='crc32'/>
|
||||
+</cpu>
|
||||
+<cpu>
|
||||
+ <arch>aarch64</arch>
|
||||
+ <model>cortex-a57</model>
|
||||
+ <vendor>ARM</vendor>
|
||||
+ <feature name='sha1'/>
|
||||
+</cpu>
|
||||
+</cpuTest>
|
||||
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 @@
|
||||
+<cpu mode='custom' match='exact'>
|
||||
+ <model fallback='forbid'>cortex-a57</model>
|
||||
+ <vendor>ARM</vendor>
|
||||
+ <feature policy='require' name='fp'/>
|
||||
+</cpu>
|
||||
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 @@
|
||||
+<cpuTest>
|
||||
+<cpu>
|
||||
+ <arch>aarch64</arch>
|
||||
+ <model>cortex-a57</model>
|
||||
+ <vendor>ARM</vendor>
|
||||
+ <feature name='fp'/>
|
||||
+</cpu>
|
||||
+</cpuTest>
|
||||
--
|
||||
2.19.1
|
||||
|
||||
171
libvirt-tests-add-cpu-compare-test-cases-for-arm-CPU.patch
Normal file
171
libvirt-tests-add-cpu-compare-test-cases-for-arm-CPU.patch
Normal file
@ -0,0 +1,171 @@
|
||||
From 0535b2880dd5804170490f8156a95964bd2f1ad3 Mon Sep 17 00:00:00 2001
|
||||
From: Xu Yandong <xuyandong2@huawei.com>
|
||||
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 <xuyandong2@huawei.com>
|
||||
---
|
||||
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 @@
|
||||
+<cpu mode='custom'>
|
||||
+ <model>cortex-a72</model>
|
||||
+ <vendor>ARM</vendor>
|
||||
+</cpu>
|
||||
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 @@
|
||||
+<cpu mode='host-model'/>
|
||||
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 @@
|
||||
+<cpu mode='host-model'>
|
||||
+ <model>cortex-a57</model>
|
||||
+</cpu>
|
||||
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 @@
|
||||
+<cpu match='exact'>
|
||||
+ <model>cortex-a72</model>
|
||||
+ <vendor>ARM</vendor>
|
||||
+</cpu>
|
||||
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 @@
|
||||
+<cpu>
|
||||
+ <model>cortex-a57</model>
|
||||
+ <vendor>ARM</vendor>
|
||||
+ <feature name='fp'/>
|
||||
+ <feature name='asimd'/>
|
||||
+ <feature name='aes'/>
|
||||
+ <feature name='pmull'/>
|
||||
+ <feature name='sha1'/>
|
||||
+ <feature name='sha2'/>
|
||||
+ <feature name='crc32'/>
|
||||
+ <feature name='sha3'/>
|
||||
+</cpu>
|
||||
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 @@
|
||||
+<cpu>
|
||||
+ <model>cortex-a57</model>
|
||||
+ <vendor>ARM</vendor>
|
||||
+ <feature name='asimd'/>
|
||||
+ <feature name='aes'/>
|
||||
+ <feature name='crc32'/>
|
||||
+</cpu>
|
||||
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 @@
|
||||
+<cpu mode='custom' match='exact'>
|
||||
+ <model fallback='allow'>cortex-a72</model>
|
||||
+ <vendor>ARM</vendor>
|
||||
+</cpu>
|
||||
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 @@
|
||||
+<cpu mode='custom' match='exact'>
|
||||
+ <model fallback='allow'>cortex-a57</model>
|
||||
+ <vendor>ARM</vendor>
|
||||
+</cpu>
|
||||
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 @@
|
||||
+<cpu match='strict'>
|
||||
+ <model>cortex-a57</model>
|
||||
+ <vendor>ARM</vendor>
|
||||
+</cpu>
|
||||
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 @@
|
||||
+<cpu>
|
||||
+ <arch>aarch64</arch>
|
||||
+ <model>cortex-a57</model>
|
||||
+ <vendor>ARM</vendor>
|
||||
+ <feature name='fp'/>
|
||||
+ <feature name='asimd'/>
|
||||
+ <feature name='aes'/>
|
||||
+ <feature name='pmull'/>
|
||||
+ <feature name='sha1'/>
|
||||
+ <feature name='sha2'/>
|
||||
+ <feature name='crc32'/>
|
||||
+</cpu>
|
||||
--
|
||||
2.19.1
|
||||
|
||||
@ -0,0 +1,118 @@
|
||||
From b47d53edc1a00d845d2200f67f20edfc60dedc29 Mon Sep 17 00:00:00 2001
|
||||
From: Peter Krempa <pkrempa@redhat.com>
|
||||
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 <pkrempa@redhat.com>
|
||||
Reviewed-by: Ján Tomko <jtomko@redhat.com>
|
||||
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
|
||||
(cherry-picked from commit 5b8e64f0bcbbab826cff5be1b0adb000923abfb4)
|
||||
Signed-off-by: Xu Yandong <xuyandong2@huawei.com>
|
||||
---
|
||||
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
|
||||
|
||||
@ -0,0 +1,60 @@
|
||||
From 68947484f8411b50fd0a17548a4e92ec07628782 Mon Sep 17 00:00:00 2001
|
||||
From: Peter Krempa <pkrempa@redhat.com>
|
||||
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 <pkrempa@redhat.com>
|
||||
Reviewed-by: Ján Tomko <jtomko@redhat.com>
|
||||
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
|
||||
(cherry-picked from commit f0430d069af991475de6fa83ed62a45f8669c645)
|
||||
Signed-off-by: Xu Yandong <xuyandong2@huawei.com>
|
||||
---
|
||||
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
|
||||
|
||||
@ -0,0 +1,51 @@
|
||||
From 27616d1c02b697df151ed8c9116e46e440549036 Mon Sep 17 00:00:00 2001
|
||||
From: Michal Privoznik <mprivozn@redhat.com>
|
||||
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 <mprivozn@redhat.com>
|
||||
Reviewed-by: Erik Skultety <eskultet@redhat.com>
|
||||
(cherry-picked from commit 37d8d6b98d2046c023935a6c9723defcdbf6c069)
|
||||
Signed-off-by: Xu Yandong <xuyandong2@huawei.com>
|
||||
---
|
||||
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
|
||||
|
||||
@ -0,0 +1,60 @@
|
||||
From 07df0ab940bb3688a3208b80d733db3cbfbde687 Mon Sep 17 00:00:00 2001
|
||||
From: Jiri Denemark <jdenemar@redhat.com>
|
||||
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 <jdenemar@redhat.com>
|
||||
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
|
||||
(cherry-picked from commit 88ce7bac413a7a5722b2ffe53dd844c0d677168a)
|
||||
Signed-off-by: Xu Yandong <xuyandong2@huawei.com>
|
||||
---
|
||||
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
|
||||
|
||||
1818
libvirt.spec
Normal file
1818
libvirt.spec
Normal file
File diff suppressed because it is too large
Load Diff
Loading…
x
Reference in New Issue
Block a user