--- /dev/null
+{
+ "return": [
+ {
+ "props": {
+ "core-id": 0,
+ "thread-id": 0,
+ "socket-id": 10
+ },
+ "vcpus-count": 1,
+ "qom-path": "/machine/peripheral/vcpu10",
+ "type": "Broadwell-x86_64-cpu"
+ },
+ {
+ "props": {
+ "core-id": 0,
+ "thread-id": 0,
+ "socket-id": 9
+ },
+ "vcpus-count": 1,
+ "qom-path": "/machine/peripheral/vcpu9",
+ "type": "Broadwell-x86_64-cpu"
+ },
+ {
+ "props": {
+ "core-id": 0,
+ "thread-id": 0,
+ "socket-id": 8
+ },
+ "vcpus-count": 1,
+ "qom-path": "/machine/peripheral/vcpu8",
+ "type": "Broadwell-x86_64-cpu"
+ },
+ {
+ "props": {
+ "core-id": 0,
+ "thread-id": 0,
+ "socket-id": 7
+ },
+ "vcpus-count": 1,
+ "qom-path": "/machine/peripheral/vcpu7",
+ "type": "Broadwell-x86_64-cpu"
+ },
+ {
+ "props": {
+ "core-id": 0,
+ "thread-id": 0,
+ "socket-id": 6
+ },
+ "vcpus-count": 1,
+ "qom-path": "/machine/peripheral/vcpu6",
+ "type": "Broadwell-x86_64-cpu"
+ },
+ {
+ "props": {
+ "core-id": 0,
+ "thread-id": 0,
+ "socket-id": 5
+ },
+ "vcpus-count": 1,
+ "qom-path": "/machine/peripheral/vcpu5",
+ "type": "Broadwell-x86_64-cpu"
+ },
+ {
+ "props": {
+ "core-id": 0,
+ "thread-id": 0,
+ "socket-id": 4
+ },
+ "vcpus-count": 1,
+ "qom-path": "/machine/peripheral/vcpu4",
+ "type": "Broadwell-x86_64-cpu"
+ },
+ {
+ "props": {
+ "core-id": 0,
+ "thread-id": 0,
+ "socket-id": 3
+ },
+ "vcpus-count": 1,
+ "qom-path": "/machine/peripheral/vcpu3",
+ "type": "Broadwell-x86_64-cpu"
+ },
+ {
+ "props": {
+ "core-id": 0,
+ "thread-id": 0,
+ "socket-id": 2
+ },
+ "vcpus-count": 1,
+ "qom-path": "/machine/peripheral/vcpu2",
+ "type": "Broadwell-x86_64-cpu"
+ },
+ {
+ "props": {
+ "core-id": 0,
+ "thread-id": 0,
+ "socket-id": 1
+ },
+ "vcpus-count": 1,
+ "qom-path": "/machine/peripheral/vcpu1",
+ "type": "Broadwell-x86_64-cpu"
+ },
+ {
+ "props": {
+ "core-id": 0,
+ "thread-id": 0,
+ "socket-id": 0
+ },
+ "vcpus-count": 1,
+ "qom-path": "/machine/unattached/device[0]",
+ "type": "Broadwell-x86_64-cpu"
+ }
+ ],
+ "id": "libvirt-51"
+}
--- /dev/null
+[vcpu libvirt-id='0']
+ online=yes
+ hotpluggable=no
+ thread-id='895040'
+ enable-id='1'
+ query-cpus-id='0'
+ type='Broadwell-x86_64-cpu'
+ qom_path='/machine/unattached/device[0]'
+ topology: socket='0' core='0' thread='0' vcpus='1'
+[vcpu libvirt-id='1']
+ online=yes
+ hotpluggable=yes
+ thread-id='895056'
+ enable-id='2'
+ query-cpus-id='1'
+ type='Broadwell-x86_64-cpu'
+ alias='vcpu1'
+ qom_path='/machine/peripheral/vcpu1'
+ topology: socket='1' core='0' thread='0' vcpus='1'
+[vcpu libvirt-id='2']
+ online=yes
+ hotpluggable=yes
+ thread-id='895057'
+ enable-id='3'
+ query-cpus-id='2'
+ type='Broadwell-x86_64-cpu'
+ alias='vcpu2'
+ qom_path='/machine/peripheral/vcpu2'
+ topology: socket='2' core='0' thread='0' vcpus='1'
+[vcpu libvirt-id='3']
+ online=yes
+ hotpluggable=yes
+ thread-id='895058'
+ enable-id='4'
+ query-cpus-id='3'
+ type='Broadwell-x86_64-cpu'
+ alias='vcpu3'
+ qom_path='/machine/peripheral/vcpu3'
+ topology: socket='3' core='0' thread='0' vcpus='1'
+[vcpu libvirt-id='4']
+ online=yes
+ hotpluggable=yes
+ thread-id='895059'
+ enable-id='5'
+ query-cpus-id='4'
+ type='Broadwell-x86_64-cpu'
+ alias='vcpu4'
+ qom_path='/machine/peripheral/vcpu4'
+ topology: socket='4' core='0' thread='0' vcpus='1'
+[vcpu libvirt-id='5']
+ online=yes
+ hotpluggable=yes
+ thread-id='895060'
+ enable-id='6'
+ query-cpus-id='5'
+ type='Broadwell-x86_64-cpu'
+ alias='vcpu5'
+ qom_path='/machine/peripheral/vcpu5'
+ topology: socket='5' core='0' thread='0' vcpus='1'
+[vcpu libvirt-id='6']
+ online=yes
+ hotpluggable=yes
+ thread-id='895061'
+ enable-id='7'
+ query-cpus-id='6'
+ type='Broadwell-x86_64-cpu'
+ alias='vcpu6'
+ qom_path='/machine/peripheral/vcpu6'
+ topology: socket='6' core='0' thread='0' vcpus='1'
+[vcpu libvirt-id='7']
+ online=yes
+ hotpluggable=yes
+ thread-id='895062'
+ enable-id='8'
+ query-cpus-id='7'
+ type='Broadwell-x86_64-cpu'
+ alias='vcpu7'
+ qom_path='/machine/peripheral/vcpu7'
+ topology: socket='7' core='0' thread='0' vcpus='1'
+[vcpu libvirt-id='8']
+ online=yes
+ hotpluggable=yes
+ thread-id='895063'
+ enable-id='9'
+ query-cpus-id='8'
+ type='Broadwell-x86_64-cpu'
+ alias='vcpu8'
+ qom_path='/machine/peripheral/vcpu8'
+ topology: socket='8' core='0' thread='0' vcpus='1'
+[vcpu libvirt-id='9']
+ online=yes
+ hotpluggable=yes
+ thread-id='895064'
+ enable-id='10'
+ query-cpus-id='9'
+ type='Broadwell-x86_64-cpu'
+ alias='vcpu9'
+ qom_path='/machine/peripheral/vcpu9'
+ topology: socket='9' core='0' thread='0' vcpus='1'
+[vcpu libvirt-id='10']
+ online=yes
+ hotpluggable=yes
+ thread-id='895065'
+ enable-id='11'
+ query-cpus-id='10'
+ type='Broadwell-x86_64-cpu'
+ alias='vcpu10'
+ qom_path='/machine/peripheral/vcpu10'
+ topology: socket='10' core='0' thread='0' vcpus='1'
}
+static int
+testQEMUMonitorJSONqemuMonitorJSONQueryCPUsHelper(qemuMonitorTestPtr test,
+ struct qemuMonitorQueryCpusEntry *expect,
+ bool fast,
+ size_t num)
+{
+ struct qemuMonitorQueryCpusEntry *cpudata = NULL;
+ size_t ncpudata = 0;
+ size_t i;
+ int ret = -1;
+
+ if (qemuMonitorJSONQueryCPUs(qemuMonitorTestGetMonitor(test),
+ &cpudata, &ncpudata, true, fast) < 0)
+ goto cleanup;
+
+ if (ncpudata != num) {
+ virReportError(VIR_ERR_INTERNAL_ERROR,
+ "Expecting ncpupids = %zu but got %zu", num, ncpudata);
+ goto cleanup;
+ }
+
+ for (i = 0; i < ncpudata; i++) {
+ if (!testQemuMonitorJSONqemuMonitorJSONQueryCPUsEqual(cpudata + i,
+ expect + i)) {
+ virReportError(VIR_ERR_INTERNAL_ERROR,
+ "vcpu entry %zu does not match expected data", i);
+ goto cleanup;
+ }
+ }
+
+ ret = 0;
+
+ cleanup:
+ qemuMonitorQueryCpusFree(cpudata, ncpudata);
+ return ret;
+}
+
+
static int
testQemuMonitorJSONqemuMonitorJSONQueryCPUs(const void *data)
{
virDomainXMLOptionPtr xmlopt = (virDomainXMLOptionPtr)data;
qemuMonitorTestPtr test = qemuMonitorTestNewSimple(true, xmlopt);
int ret = -1;
- struct qemuMonitorQueryCpusEntry *cpudata = NULL;
- struct qemuMonitorQueryCpusEntry expect[] = {
- {0, 17622, (char *) "/machine/unattached/device[0]", true},
- {1, 17624, (char *) "/machine/unattached/device[1]", true},
- {2, 17626, (char *) "/machine/unattached/device[2]", true},
- {3, 17628, NULL, true},
+ struct qemuMonitorQueryCpusEntry expect_slow[] = {
+ {0, 17622, (char *) "/machine/unattached/device[0]", true},
+ {1, 17624, (char *) "/machine/unattached/device[1]", true},
+ {2, 17626, (char *) "/machine/unattached/device[2]", true},
+ {3, 17628, NULL, true},
+ };
+ struct qemuMonitorQueryCpusEntry expect_fast[] = {
+ {0, 17629, (char *) "/machine/unattached/device[0]", false},
+ {1, 17630, (char *) "/machine/unattached/device[1]", false},
};
- size_t ncpudata = 0;
- size_t i;
if (!test)
return -1;
"}") < 0)
goto cleanup;
- if (qemuMonitorJSONQueryCPUs(qemuMonitorTestGetMonitor(test),
- &cpudata, &ncpudata, true, false) < 0)
+ if (qemuMonitorTestAddItem(test, "query-cpus-fast",
+ "{"
+ " \"return\": ["
+ " {"
+ " \"cpu-index\": 0,"
+ " \"qom-path\": \"/machine/unattached/device[0]\","
+ " \"thread-id\": 17629"
+ " },"
+ " {"
+ " \"cpu-index\": 1,"
+ " \"qom-path\": \"/machine/unattached/device[1]\","
+ " \"thread-id\": 17630"
+ " }"
+ " ],"
+ " \"id\": \"libvirt-8\""
+ "}") < 0)
goto cleanup;
- if (ncpudata != 4) {
- virReportError(VIR_ERR_INTERNAL_ERROR,
- "Expecting ncpupids = 4 but got %zu", ncpudata);
+ /* query-cpus */
+ if (testQEMUMonitorJSONqemuMonitorJSONQueryCPUsHelper(test, expect_slow,
+ false, 4))
goto cleanup;
- }
- for (i = 0; i < ncpudata; i++) {
- if (!testQemuMonitorJSONqemuMonitorJSONQueryCPUsEqual(cpudata + i,
- expect + i)) {
- virReportError(VIR_ERR_INTERNAL_ERROR,
- "vcpu entry %zu does not match expected data", i);
- goto cleanup;
- }
- }
+ /* query-cpus-fast */
+ if (testQEMUMonitorJSONqemuMonitorJSONQueryCPUsHelper(test, expect_fast,
+ true, 2))
+ goto cleanup;
ret = 0;
cleanup:
- qemuMonitorQueryCpusFree(cpudata, ncpudata);
qemuMonitorTestFree(test);
return ret;
}
const char *name;
size_t maxvcpus;
virDomainXMLOptionPtr xmlopt;
+ bool fast;
};
{
const struct testCPUInfoData *data = opaque;
qemuMonitorTestPtr test = qemuMonitorTestNewSimple(true, data->xmlopt);
+ virDomainObjPtr vm = NULL;
char *queryCpusFile = NULL;
char *queryHotpluggableFile = NULL;
char *dataFile = NULL;
char *queryCpusStr = NULL;
char *queryHotpluggableStr = NULL;
char *actual = NULL;
+ const char *queryCpusFunction;
qemuMonitorCPUInfoPtr vcpus = NULL;
int rc;
int ret = -1;
queryHotpluggableStr) < 0)
goto cleanup;
- if (qemuMonitorTestAddItem(test, "query-cpus", queryCpusStr) < 0)
+ if (data->fast)
+ queryCpusFunction = "query-cpus-fast";
+ else
+ queryCpusFunction = "query-cpus";
+
+ if (qemuMonitorTestAddItem(test, queryCpusFunction, queryCpusStr) < 0)
goto cleanup;
+ vm = qemuMonitorTestGetDomainObj(test);
+ if (!vm)
+ return -1;
+
rc = qemuMonitorGetCPUInfo(qemuMonitorTestGetMonitor(test),
- &vcpus, data->maxvcpus, true, false);
+ &vcpus, data->maxvcpus, true, data->fast);
if (rc < 0)
goto cleanup;
#define DO_TEST_CPU_INFO(name, maxvcpus) \
do { \
- struct testCPUInfoData data = {name, maxvcpus, driver.xmlopt}; \
+ struct testCPUInfoData data = {name, maxvcpus, driver.xmlopt, false}; \
+ if (virTestRun("GetCPUInfo(" name ")", testQemuMonitorCPUInfo, \
+ &data) < 0) \
+ ret = -1; \
+ } while (0)
+
+#define DO_TEST_CPU_INFO_FAST(name, maxvcpus) \
+ do { \
+ struct testCPUInfoData data = {name, maxvcpus, driver.xmlopt, true}; \
if (virTestRun("GetCPUInfo(" name ")", testQemuMonitorCPUInfo, \
&data) < 0) \
ret = -1; \
DO_TEST_CPU_INFO("x86-basic-pluggable", 8);
DO_TEST_CPU_INFO("x86-full", 11);
DO_TEST_CPU_INFO("x86-node-full", 8);
+ DO_TEST_CPU_INFO_FAST("x86-full-fast", 11);
DO_TEST_CPU_INFO("ppc64-basic", 24);
DO_TEST_CPU_INFO("ppc64-hotplug-1", 24);