2012-08-20 12:31:29 +00:00
|
|
|
/*
|
2014-04-04 23:36:25 +00:00
|
|
|
* Copyright (C) 2011-2014 Red Hat, Inc.
|
2012-08-20 12:31:29 +00:00
|
|
|
*
|
|
|
|
* 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
|
2012-09-20 22:30:55 +00:00
|
|
|
* License along with this library. If not, see
|
2012-08-20 12:31:29 +00:00
|
|
|
* <http://www.gnu.org/licenses/>.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <config.h>
|
|
|
|
|
|
|
|
#include "testutils.h"
|
|
|
|
#include "testutilsqemu.h"
|
2018-03-22 16:07:43 +00:00
|
|
|
#include "testutilsqemuschema.h"
|
2012-08-20 12:31:29 +00:00
|
|
|
#include "qemumonitortestutils.h"
|
2016-05-20 05:21:04 +00:00
|
|
|
#include "qemu/qemu_domain.h"
|
2017-03-13 11:47:46 +00:00
|
|
|
#include "qemu/qemu_block.h"
|
2013-06-24 17:51:56 +00:00
|
|
|
#include "qemu/qemu_monitor_json.h"
|
2018-03-22 16:07:43 +00:00
|
|
|
#include "qemu/qemu_qapi.h"
|
2022-02-08 18:58:07 +00:00
|
|
|
#include "qemu/qemu_alias.h"
|
2024-09-13 08:33:47 +00:00
|
|
|
#include "qemu/qemu_chardev.h"
|
2012-12-13 18:21:53 +00:00
|
|
|
#include "virerror.h"
|
2013-07-22 11:07:23 +00:00
|
|
|
#include "cpu/cpu.h"
|
2015-04-28 01:16:13 +00:00
|
|
|
#include "qemu/qemu_monitor.h"
|
2018-04-05 20:17:26 +00:00
|
|
|
#include "qemu/qemu_migration_params.h"
|
2018-12-13 14:53:50 +00:00
|
|
|
#define LIBVIRT_QEMU_MIGRATION_PARAMSPRIV_H_ALLOW
|
2018-04-05 18:59:07 +00:00
|
|
|
#include "qemu/qemu_migration_paramspriv.h"
|
2012-08-20 12:31:29 +00:00
|
|
|
|
|
|
|
#define VIR_FROM_THIS VIR_FROM_NONE
|
|
|
|
|
2013-09-18 15:28:31 +00:00
|
|
|
typedef struct _testQemuMonitorJSONSimpleFuncData testQemuMonitorJSONSimpleFuncData;
|
|
|
|
struct _testQemuMonitorJSONSimpleFuncData {
|
|
|
|
const char *cmd;
|
2021-03-11 07:16:13 +00:00
|
|
|
int (* func) (qemuMonitor *mon);
|
|
|
|
virDomainXMLOption *xmlopt;
|
2013-09-18 15:28:31 +00:00
|
|
|
const char *reply;
|
2020-10-22 17:04:18 +00:00
|
|
|
GHashTable *schema;
|
2020-04-29 17:41:38 +00:00
|
|
|
bool allowDeprecated;
|
|
|
|
bool allowRemoved;
|
2013-09-18 15:28:31 +00:00
|
|
|
};
|
|
|
|
|
qemumonitorjsontest: Validate more commands against schema
The DO_TEST() macro in qemumonitorjsontest.c was not passing the
schema through, which meant that we were not validating any of those
tests for correct usage according to the schema.
In the process of mechanically altering tests to pass the schema
through, use VIR_AUTOPTR on all of the affected test instances. The
next patch will do some further cleanups that it exposes.
Tested by using this hack, where the test mistakenly passed pre-patch,
but correctly diagnosed the garbage post-patch:
| diff --git i/src/qemu/qemu_monitor_json.c w/src/qemu/qemu_monitor_json.c
| index 53a7de8b77..86d8450814 100644
| --- i/src/qemu/qemu_monitor_json.c
| +++ w/src/qemu/qemu_monitor_json.c
| @@ -1532,7 +1532,8 @@ qemuMonitorJSONGetStatus(qemuMonitorPtr mon,
| if (reason)
| *reason = VIR_DOMAIN_PAUSED_UNKNOWN;
|
| - if (!(cmd = qemuMonitorJSONMakeCommand("query-status", NULL)))
| + if (!(cmd = qemuMonitorJSONMakeCommand("query-status",
| + "s:garbage", "foo", NULL)))
| return -1;
|
| if (qemuMonitorJSONCommand(mon, cmd, &reply) < 0)
Suggested-by: Peter Krempa <pkrempa@redhat.com>
Signed-off-by: Eric Blake <eblake@redhat.com>
Acked-by: Peter Krempa <pkrempa@redhat.com>
2019-06-12 01:59:11 +00:00
|
|
|
typedef struct _testGenericData testGenericData;
|
|
|
|
struct _testGenericData {
|
2021-03-11 07:16:13 +00:00
|
|
|
virDomainXMLOption *xmlopt;
|
2020-10-22 17:04:18 +00:00
|
|
|
GHashTable *schema;
|
qemumonitorjsontest: Validate more commands against schema
The DO_TEST() macro in qemumonitorjsontest.c was not passing the
schema through, which meant that we were not validating any of those
tests for correct usage according to the schema.
In the process of mechanically altering tests to pass the schema
through, use VIR_AUTOPTR on all of the affected test instances. The
next patch will do some further cleanups that it exposes.
Tested by using this hack, where the test mistakenly passed pre-patch,
but correctly diagnosed the garbage post-patch:
| diff --git i/src/qemu/qemu_monitor_json.c w/src/qemu/qemu_monitor_json.c
| index 53a7de8b77..86d8450814 100644
| --- i/src/qemu/qemu_monitor_json.c
| +++ w/src/qemu/qemu_monitor_json.c
| @@ -1532,7 +1532,8 @@ qemuMonitorJSONGetStatus(qemuMonitorPtr mon,
| if (reason)
| *reason = VIR_DOMAIN_PAUSED_UNKNOWN;
|
| - if (!(cmd = qemuMonitorJSONMakeCommand("query-status", NULL)))
| + if (!(cmd = qemuMonitorJSONMakeCommand("query-status",
| + "s:garbage", "foo", NULL)))
| return -1;
|
| if (qemuMonitorJSONCommand(mon, cmd, &reply) < 0)
Suggested-by: Peter Krempa <pkrempa@redhat.com>
Signed-off-by: Eric Blake <eblake@redhat.com>
Acked-by: Peter Krempa <pkrempa@redhat.com>
2019-06-12 01:59:11 +00:00
|
|
|
};
|
|
|
|
|
2013-10-02 16:46:42 +00:00
|
|
|
const char *queryBlockReply =
|
|
|
|
"{"
|
|
|
|
" \"return\": ["
|
|
|
|
" {"
|
|
|
|
" \"io-status\": \"ok\","
|
|
|
|
" \"device\": \"drive-virtio-disk0\","
|
|
|
|
" \"locked\": false,"
|
|
|
|
" \"removable\": false,"
|
|
|
|
" \"inserted\": {"
|
|
|
|
" \"iops_rd\": 5,"
|
|
|
|
" \"iops_wr\": 6,"
|
|
|
|
" \"ro\": false,"
|
|
|
|
" \"backing_file_depth\": 0,"
|
|
|
|
" \"drv\": \"qcow2\","
|
|
|
|
" \"iops\": 4,"
|
|
|
|
" \"bps_wr\": 3,"
|
|
|
|
" \"encrypted\": false,"
|
|
|
|
" \"bps\": 1,"
|
|
|
|
" \"bps_rd\": 2,"
|
2014-12-03 13:42:27 +00:00
|
|
|
" \"bps_max\": 7,"
|
|
|
|
" \"iops_max\": 10,"
|
|
|
|
" \"bps_rd_max\": 8,"
|
|
|
|
" \"bps_wr_max\": 9,"
|
|
|
|
" \"iops_rd_max\": 11,"
|
|
|
|
" \"iops_wr_max\": 12,"
|
|
|
|
" \"iops_size\": 13,"
|
2016-10-31 21:22:59 +00:00
|
|
|
" \"group\": \"group14\","
|
|
|
|
" \"bps_max_length\": 15,"
|
|
|
|
" \"bps_rd_max_length\": 16,"
|
|
|
|
" \"bps_wr_max_length\": 17,"
|
|
|
|
" \"iops_max_length\": 18,"
|
|
|
|
" \"iops_rd_max_length\": 19,"
|
|
|
|
" \"iops_wr_max_length\": 20,"
|
2013-10-02 16:46:42 +00:00
|
|
|
" \"file\": \"/home/zippy/work/tmp/gentoo.qcow2\","
|
|
|
|
" \"encryption_key_missing\": false"
|
|
|
|
" },"
|
|
|
|
" \"type\": \"unknown\""
|
|
|
|
" },"
|
|
|
|
" {"
|
|
|
|
" \"io-status\": \"ok\","
|
|
|
|
" \"device\": \"drive-virtio-disk1\","
|
|
|
|
" \"locked\": false,"
|
|
|
|
" \"removable\": false,"
|
|
|
|
" \"inserted\": {"
|
|
|
|
" \"iops_rd\": 0,"
|
|
|
|
" \"iops_wr\": 0,"
|
|
|
|
" \"ro\": false,"
|
|
|
|
" \"backing_file_depth\": 0,"
|
|
|
|
" \"drv\": \"raw\","
|
|
|
|
" \"iops\": 0,"
|
|
|
|
" \"bps_wr\": 0,"
|
|
|
|
" \"encrypted\": false,"
|
|
|
|
" \"bps\": 0,"
|
|
|
|
" \"bps_rd\": 0,"
|
|
|
|
" \"file\": \"/home/zippy/test.bin\","
|
|
|
|
" \"encryption_key_missing\": false"
|
|
|
|
" },"
|
|
|
|
" \"type\": \"unknown\""
|
|
|
|
" },"
|
|
|
|
" {"
|
|
|
|
" \"io-status\": \"ok\","
|
|
|
|
" \"device\": \"drive-ide0-1-0\","
|
|
|
|
" \"locked\": true,"
|
|
|
|
" \"removable\": true,"
|
|
|
|
" \"inserted\": {"
|
|
|
|
" \"iops_rd\": 0,"
|
|
|
|
" \"iops_wr\": 0,"
|
|
|
|
" \"ro\": true,"
|
|
|
|
" \"backing_file_depth\": 0,"
|
|
|
|
" \"drv\": \"raw\","
|
|
|
|
" \"iops\": 0,"
|
|
|
|
" \"bps_wr\": 0,"
|
|
|
|
" \"encrypted\": false,"
|
|
|
|
" \"bps\": 0,"
|
|
|
|
" \"bps_rd\": 0,"
|
|
|
|
" \"file\": \"/home/zippy/tmp/install-amd64-minimal-20121210.iso\","
|
|
|
|
" \"encryption_key_missing\": false"
|
|
|
|
" },"
|
|
|
|
" \"tray_open\": false,"
|
|
|
|
" \"type\": \"unknown\""
|
2016-05-19 12:57:41 +00:00
|
|
|
" },"
|
|
|
|
" {"
|
|
|
|
" \"io-status\": \"ok\","
|
|
|
|
" \"device\": \"drive-ide0-1-1\","
|
|
|
|
" \"locked\": false,"
|
|
|
|
" \"removable\": true,"
|
|
|
|
" \"tray_open\": false,"
|
|
|
|
" \"type\": \"unknown\""
|
2013-10-02 16:46:42 +00:00
|
|
|
" }"
|
|
|
|
" ],"
|
|
|
|
" \"id\": \"libvirt-10\""
|
|
|
|
"}";
|
|
|
|
|
2012-08-20 12:31:29 +00:00
|
|
|
static int
|
qemumonitorjsontest: Validate more commands against schema
The DO_TEST() macro in qemumonitorjsontest.c was not passing the
schema through, which meant that we were not validating any of those
tests for correct usage according to the schema.
In the process of mechanically altering tests to pass the schema
through, use VIR_AUTOPTR on all of the affected test instances. The
next patch will do some further cleanups that it exposes.
Tested by using this hack, where the test mistakenly passed pre-patch,
but correctly diagnosed the garbage post-patch:
| diff --git i/src/qemu/qemu_monitor_json.c w/src/qemu/qemu_monitor_json.c
| index 53a7de8b77..86d8450814 100644
| --- i/src/qemu/qemu_monitor_json.c
| +++ w/src/qemu/qemu_monitor_json.c
| @@ -1532,7 +1532,8 @@ qemuMonitorJSONGetStatus(qemuMonitorPtr mon,
| if (reason)
| *reason = VIR_DOMAIN_PAUSED_UNKNOWN;
|
| - if (!(cmd = qemuMonitorJSONMakeCommand("query-status", NULL)))
| + if (!(cmd = qemuMonitorJSONMakeCommand("query-status",
| + "s:garbage", "foo", NULL)))
| return -1;
|
| if (qemuMonitorJSONCommand(mon, cmd, &reply) < 0)
Suggested-by: Peter Krempa <pkrempa@redhat.com>
Signed-off-by: Eric Blake <eblake@redhat.com>
Acked-by: Peter Krempa <pkrempa@redhat.com>
2019-06-12 01:59:11 +00:00
|
|
|
testQemuMonitorJSONGetStatus(const void *opaque)
|
2012-08-20 12:31:29 +00:00
|
|
|
{
|
qemumonitorjsontest: Validate more commands against schema
The DO_TEST() macro in qemumonitorjsontest.c was not passing the
schema through, which meant that we were not validating any of those
tests for correct usage according to the schema.
In the process of mechanically altering tests to pass the schema
through, use VIR_AUTOPTR on all of the affected test instances. The
next patch will do some further cleanups that it exposes.
Tested by using this hack, where the test mistakenly passed pre-patch,
but correctly diagnosed the garbage post-patch:
| diff --git i/src/qemu/qemu_monitor_json.c w/src/qemu/qemu_monitor_json.c
| index 53a7de8b77..86d8450814 100644
| --- i/src/qemu/qemu_monitor_json.c
| +++ w/src/qemu/qemu_monitor_json.c
| @@ -1532,7 +1532,8 @@ qemuMonitorJSONGetStatus(qemuMonitorPtr mon,
| if (reason)
| *reason = VIR_DOMAIN_PAUSED_UNKNOWN;
|
| - if (!(cmd = qemuMonitorJSONMakeCommand("query-status", NULL)))
| + if (!(cmd = qemuMonitorJSONMakeCommand("query-status",
| + "s:garbage", "foo", NULL)))
| return -1;
|
| if (qemuMonitorJSONCommand(mon, cmd, &reply) < 0)
Suggested-by: Peter Krempa <pkrempa@redhat.com>
Signed-off-by: Eric Blake <eblake@redhat.com>
Acked-by: Peter Krempa <pkrempa@redhat.com>
2019-06-12 01:59:11 +00:00
|
|
|
const testGenericData *data = opaque;
|
2021-03-11 07:16:13 +00:00
|
|
|
virDomainXMLOption *xmlopt = data->xmlopt;
|
2012-08-20 12:31:29 +00:00
|
|
|
bool running = false;
|
|
|
|
virDomainPausedReason reason = 0;
|
2019-10-15 12:47:50 +00:00
|
|
|
g_autoptr(qemuMonitorTest) test = NULL;
|
2012-08-20 12:31:29 +00:00
|
|
|
|
qemumonitorjsontest: Validate more commands against schema
The DO_TEST() macro in qemumonitorjsontest.c was not passing the
schema through, which meant that we were not validating any of those
tests for correct usage according to the schema.
In the process of mechanically altering tests to pass the schema
through, use VIR_AUTOPTR on all of the affected test instances. The
next patch will do some further cleanups that it exposes.
Tested by using this hack, where the test mistakenly passed pre-patch,
but correctly diagnosed the garbage post-patch:
| diff --git i/src/qemu/qemu_monitor_json.c w/src/qemu/qemu_monitor_json.c
| index 53a7de8b77..86d8450814 100644
| --- i/src/qemu/qemu_monitor_json.c
| +++ w/src/qemu/qemu_monitor_json.c
| @@ -1532,7 +1532,8 @@ qemuMonitorJSONGetStatus(qemuMonitorPtr mon,
| if (reason)
| *reason = VIR_DOMAIN_PAUSED_UNKNOWN;
|
| - if (!(cmd = qemuMonitorJSONMakeCommand("query-status", NULL)))
| + if (!(cmd = qemuMonitorJSONMakeCommand("query-status",
| + "s:garbage", "foo", NULL)))
| return -1;
|
| if (qemuMonitorJSONCommand(mon, cmd, &reply) < 0)
Suggested-by: Peter Krempa <pkrempa@redhat.com>
Signed-off-by: Eric Blake <eblake@redhat.com>
Acked-by: Peter Krempa <pkrempa@redhat.com>
2019-06-12 01:59:11 +00:00
|
|
|
if (!(test = qemuMonitorTestNewSchema(xmlopt, data->schema)))
|
2012-08-20 12:31:29 +00:00
|
|
|
return -1;
|
|
|
|
|
|
|
|
if (qemuMonitorTestAddItem(test, "query-status",
|
|
|
|
"{ "
|
|
|
|
" \"return\": { "
|
|
|
|
" \"status\": \"running\", "
|
|
|
|
" \"singlestep\": false, "
|
|
|
|
" \"running\": true "
|
|
|
|
" } "
|
|
|
|
"}") < 0)
|
2019-06-11 03:01:08 +00:00
|
|
|
return -1;
|
2012-08-20 12:31:29 +00:00
|
|
|
if (qemuMonitorTestAddItem(test, "query-status",
|
|
|
|
"{ "
|
|
|
|
" \"return\": { "
|
|
|
|
" \"singlestep\": false, "
|
|
|
|
" \"running\": false "
|
|
|
|
" } "
|
|
|
|
"}") < 0)
|
2019-06-11 03:01:08 +00:00
|
|
|
return -1;
|
2012-08-20 12:31:29 +00:00
|
|
|
if (qemuMonitorTestAddItem(test, "query-status",
|
|
|
|
"{ "
|
|
|
|
" \"return\": { "
|
|
|
|
" \"status\": \"inmigrate\", "
|
|
|
|
" \"singlestep\": false, "
|
|
|
|
" \"running\": false "
|
|
|
|
" } "
|
|
|
|
"}") < 0)
|
2019-06-11 03:01:08 +00:00
|
|
|
return -1;
|
2012-08-20 12:31:29 +00:00
|
|
|
|
|
|
|
if (qemuMonitorGetStatus(qemuMonitorTestGetMonitor(test),
|
|
|
|
&running, &reason) < 0)
|
2019-06-11 03:01:08 +00:00
|
|
|
return -1;
|
2012-08-20 12:31:29 +00:00
|
|
|
|
|
|
|
if (!running) {
|
|
|
|
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
|
|
|
"Running was not true");
|
2019-06-11 03:01:08 +00:00
|
|
|
return -1;
|
2012-08-20 12:31:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (reason != VIR_DOMAIN_PAUSED_UNKNOWN) {
|
|
|
|
virReportError(VIR_ERR_INTERNAL_ERROR,
|
|
|
|
"Reason was unexpectedly set to %d", reason);
|
2019-06-11 03:01:08 +00:00
|
|
|
return -1;
|
2012-08-20 12:31:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (qemuMonitorGetStatus(qemuMonitorTestGetMonitor(test),
|
|
|
|
&running, &reason) < 0)
|
2019-06-11 03:01:08 +00:00
|
|
|
return -1;
|
2012-08-20 12:31:29 +00:00
|
|
|
|
|
|
|
if (running) {
|
|
|
|
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
|
|
|
"Running was not false");
|
2019-06-11 03:01:08 +00:00
|
|
|
return -1;
|
2012-08-20 12:31:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (reason != VIR_DOMAIN_PAUSED_UNKNOWN) {
|
|
|
|
virReportError(VIR_ERR_INTERNAL_ERROR,
|
|
|
|
"Reason was unexpectedly set to %d", reason);
|
2019-06-11 03:01:08 +00:00
|
|
|
return -1;
|
2012-08-20 12:31:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (qemuMonitorGetStatus(qemuMonitorTestGetMonitor(test),
|
|
|
|
&running, &reason) < 0)
|
2019-06-11 03:01:08 +00:00
|
|
|
return -1;
|
2012-08-20 12:31:29 +00:00
|
|
|
|
|
|
|
if (running) {
|
|
|
|
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
|
|
|
"Running was not false");
|
2019-06-11 03:01:08 +00:00
|
|
|
return -1;
|
2012-08-20 12:31:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (reason != VIR_DOMAIN_PAUSED_MIGRATION) {
|
|
|
|
virReportError(VIR_ERR_INTERNAL_ERROR,
|
|
|
|
"Reason was unexpectedly set to %d", reason);
|
2019-06-11 03:01:08 +00:00
|
|
|
return -1;
|
2012-08-20 12:31:29 +00:00
|
|
|
}
|
|
|
|
|
2019-06-11 03:01:08 +00:00
|
|
|
return 0;
|
2012-08-20 12:31:29 +00:00
|
|
|
}
|
|
|
|
|
2012-08-15 14:04:09 +00:00
|
|
|
static int
|
qemumonitorjsontest: Validate more commands against schema
The DO_TEST() macro in qemumonitorjsontest.c was not passing the
schema through, which meant that we were not validating any of those
tests for correct usage according to the schema.
In the process of mechanically altering tests to pass the schema
through, use VIR_AUTOPTR on all of the affected test instances. The
next patch will do some further cleanups that it exposes.
Tested by using this hack, where the test mistakenly passed pre-patch,
but correctly diagnosed the garbage post-patch:
| diff --git i/src/qemu/qemu_monitor_json.c w/src/qemu/qemu_monitor_json.c
| index 53a7de8b77..86d8450814 100644
| --- i/src/qemu/qemu_monitor_json.c
| +++ w/src/qemu/qemu_monitor_json.c
| @@ -1532,7 +1532,8 @@ qemuMonitorJSONGetStatus(qemuMonitorPtr mon,
| if (reason)
| *reason = VIR_DOMAIN_PAUSED_UNKNOWN;
|
| - if (!(cmd = qemuMonitorJSONMakeCommand("query-status", NULL)))
| + if (!(cmd = qemuMonitorJSONMakeCommand("query-status",
| + "s:garbage", "foo", NULL)))
| return -1;
|
| if (qemuMonitorJSONCommand(mon, cmd, &reply) < 0)
Suggested-by: Peter Krempa <pkrempa@redhat.com>
Signed-off-by: Eric Blake <eblake@redhat.com>
Acked-by: Peter Krempa <pkrempa@redhat.com>
2019-06-12 01:59:11 +00:00
|
|
|
testQemuMonitorJSONGetVersion(const void *opaque)
|
2012-08-15 14:04:09 +00:00
|
|
|
{
|
qemumonitorjsontest: Validate more commands against schema
The DO_TEST() macro in qemumonitorjsontest.c was not passing the
schema through, which meant that we were not validating any of those
tests for correct usage according to the schema.
In the process of mechanically altering tests to pass the schema
through, use VIR_AUTOPTR on all of the affected test instances. The
next patch will do some further cleanups that it exposes.
Tested by using this hack, where the test mistakenly passed pre-patch,
but correctly diagnosed the garbage post-patch:
| diff --git i/src/qemu/qemu_monitor_json.c w/src/qemu/qemu_monitor_json.c
| index 53a7de8b77..86d8450814 100644
| --- i/src/qemu/qemu_monitor_json.c
| +++ w/src/qemu/qemu_monitor_json.c
| @@ -1532,7 +1532,8 @@ qemuMonitorJSONGetStatus(qemuMonitorPtr mon,
| if (reason)
| *reason = VIR_DOMAIN_PAUSED_UNKNOWN;
|
| - if (!(cmd = qemuMonitorJSONMakeCommand("query-status", NULL)))
| + if (!(cmd = qemuMonitorJSONMakeCommand("query-status",
| + "s:garbage", "foo", NULL)))
| return -1;
|
| if (qemuMonitorJSONCommand(mon, cmd, &reply) < 0)
Suggested-by: Peter Krempa <pkrempa@redhat.com>
Signed-off-by: Eric Blake <eblake@redhat.com>
Acked-by: Peter Krempa <pkrempa@redhat.com>
2019-06-12 01:59:11 +00:00
|
|
|
const testGenericData *data = opaque;
|
2021-03-11 07:16:13 +00:00
|
|
|
virDomainXMLOption *xmlopt = data->xmlopt;
|
2012-08-15 14:04:09 +00:00
|
|
|
int major;
|
|
|
|
int minor;
|
|
|
|
int micro;
|
2021-11-01 09:33:49 +00:00
|
|
|
g_autofree char *package = NULL;
|
2019-10-15 12:47:50 +00:00
|
|
|
g_autoptr(qemuMonitorTest) test = NULL;
|
2012-08-15 14:04:09 +00:00
|
|
|
|
qemumonitorjsontest: Validate more commands against schema
The DO_TEST() macro in qemumonitorjsontest.c was not passing the
schema through, which meant that we were not validating any of those
tests for correct usage according to the schema.
In the process of mechanically altering tests to pass the schema
through, use VIR_AUTOPTR on all of the affected test instances. The
next patch will do some further cleanups that it exposes.
Tested by using this hack, where the test mistakenly passed pre-patch,
but correctly diagnosed the garbage post-patch:
| diff --git i/src/qemu/qemu_monitor_json.c w/src/qemu/qemu_monitor_json.c
| index 53a7de8b77..86d8450814 100644
| --- i/src/qemu/qemu_monitor_json.c
| +++ w/src/qemu/qemu_monitor_json.c
| @@ -1532,7 +1532,8 @@ qemuMonitorJSONGetStatus(qemuMonitorPtr mon,
| if (reason)
| *reason = VIR_DOMAIN_PAUSED_UNKNOWN;
|
| - if (!(cmd = qemuMonitorJSONMakeCommand("query-status", NULL)))
| + if (!(cmd = qemuMonitorJSONMakeCommand("query-status",
| + "s:garbage", "foo", NULL)))
| return -1;
|
| if (qemuMonitorJSONCommand(mon, cmd, &reply) < 0)
Suggested-by: Peter Krempa <pkrempa@redhat.com>
Signed-off-by: Eric Blake <eblake@redhat.com>
Acked-by: Peter Krempa <pkrempa@redhat.com>
2019-06-12 01:59:11 +00:00
|
|
|
if (!(test = qemuMonitorTestNewSchema(xmlopt, data->schema)))
|
2012-08-15 14:04:09 +00:00
|
|
|
return -1;
|
|
|
|
|
|
|
|
if (qemuMonitorTestAddItem(test, "query-version",
|
|
|
|
"{ "
|
|
|
|
" \"return\":{ "
|
|
|
|
" \"qemu\":{ "
|
|
|
|
" \"major\":1, "
|
|
|
|
" \"minor\":2, "
|
|
|
|
" \"micro\":3 "
|
|
|
|
" },"
|
|
|
|
" \"package\":\"\""
|
|
|
|
" }"
|
|
|
|
"}") < 0)
|
2021-11-01 09:20:57 +00:00
|
|
|
return -1;
|
2012-08-15 14:04:09 +00:00
|
|
|
|
|
|
|
if (qemuMonitorTestAddItem(test, "query-version",
|
|
|
|
"{ "
|
|
|
|
" \"return\":{ "
|
|
|
|
" \"qemu\":{ "
|
|
|
|
" \"major\":0, "
|
|
|
|
" \"minor\":11, "
|
|
|
|
" \"micro\":6 "
|
|
|
|
" },"
|
|
|
|
" \"package\":\"2.283.el6\""
|
|
|
|
" }"
|
|
|
|
"}") < 0)
|
2021-11-01 09:20:57 +00:00
|
|
|
return -1;
|
2012-08-15 14:04:09 +00:00
|
|
|
|
|
|
|
if (qemuMonitorGetVersion(qemuMonitorTestGetMonitor(test),
|
|
|
|
&major, &minor, µ,
|
|
|
|
&package) < 0)
|
2021-11-01 09:20:57 +00:00
|
|
|
return -1;
|
2012-08-15 14:04:09 +00:00
|
|
|
|
|
|
|
if (major != 1) {
|
|
|
|
virReportError(VIR_ERR_INTERNAL_ERROR,
|
|
|
|
"Major %d was not 1", major);
|
2021-11-01 09:20:57 +00:00
|
|
|
return -1;
|
2012-08-15 14:04:09 +00:00
|
|
|
}
|
|
|
|
if (minor != 2) {
|
|
|
|
virReportError(VIR_ERR_INTERNAL_ERROR,
|
|
|
|
"Minor %d was not 2", major);
|
2021-11-01 09:20:57 +00:00
|
|
|
return -1;
|
2012-08-15 14:04:09 +00:00
|
|
|
}
|
|
|
|
if (micro != 3) {
|
|
|
|
virReportError(VIR_ERR_INTERNAL_ERROR,
|
|
|
|
"Micro %d was not 3", major);
|
2021-11-01 09:20:57 +00:00
|
|
|
return -1;
|
2012-08-15 14:04:09 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (STRNEQ(package, "")) {
|
|
|
|
virReportError(VIR_ERR_INTERNAL_ERROR,
|
|
|
|
"Package %s was not ''", package);
|
2021-11-01 09:20:57 +00:00
|
|
|
return -1;
|
2012-08-15 14:04:09 +00:00
|
|
|
}
|
2013-02-04 16:17:52 +00:00
|
|
|
VIR_FREE(package);
|
2012-08-15 14:04:09 +00:00
|
|
|
|
|
|
|
if (qemuMonitorGetVersion(qemuMonitorTestGetMonitor(test),
|
|
|
|
&major, &minor, µ,
|
|
|
|
&package) < 0)
|
2021-11-01 09:20:57 +00:00
|
|
|
return -1;
|
2012-08-15 14:04:09 +00:00
|
|
|
|
|
|
|
if (major != 0) {
|
|
|
|
virReportError(VIR_ERR_INTERNAL_ERROR,
|
|
|
|
"Major %d was not 0", major);
|
2021-11-01 09:20:57 +00:00
|
|
|
return -1;
|
2012-08-15 14:04:09 +00:00
|
|
|
}
|
|
|
|
if (minor != 11) {
|
|
|
|
virReportError(VIR_ERR_INTERNAL_ERROR,
|
|
|
|
"Minor %d was not 11", major);
|
2021-11-01 09:20:57 +00:00
|
|
|
return -1;
|
2012-08-15 14:04:09 +00:00
|
|
|
}
|
|
|
|
if (micro != 6) {
|
|
|
|
virReportError(VIR_ERR_INTERNAL_ERROR,
|
|
|
|
"Micro %d was not 6", major);
|
2021-11-01 09:20:57 +00:00
|
|
|
return -1;
|
2012-08-15 14:04:09 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (STRNEQ(package, "2.283.el6")) {
|
|
|
|
virReportError(VIR_ERR_INTERNAL_ERROR,
|
|
|
|
"Package %s was not '2.283.el6'", package);
|
2021-11-01 09:20:57 +00:00
|
|
|
return -1;
|
2012-08-15 14:04:09 +00:00
|
|
|
}
|
|
|
|
|
2021-11-01 09:20:57 +00:00
|
|
|
return 0;
|
2012-08-15 14:04:09 +00:00
|
|
|
}
|
|
|
|
|
2012-08-15 15:18:41 +00:00
|
|
|
static int
|
qemumonitorjsontest: Validate more commands against schema
The DO_TEST() macro in qemumonitorjsontest.c was not passing the
schema through, which meant that we were not validating any of those
tests for correct usage according to the schema.
In the process of mechanically altering tests to pass the schema
through, use VIR_AUTOPTR on all of the affected test instances. The
next patch will do some further cleanups that it exposes.
Tested by using this hack, where the test mistakenly passed pre-patch,
but correctly diagnosed the garbage post-patch:
| diff --git i/src/qemu/qemu_monitor_json.c w/src/qemu/qemu_monitor_json.c
| index 53a7de8b77..86d8450814 100644
| --- i/src/qemu/qemu_monitor_json.c
| +++ w/src/qemu/qemu_monitor_json.c
| @@ -1532,7 +1532,8 @@ qemuMonitorJSONGetStatus(qemuMonitorPtr mon,
| if (reason)
| *reason = VIR_DOMAIN_PAUSED_UNKNOWN;
|
| - if (!(cmd = qemuMonitorJSONMakeCommand("query-status", NULL)))
| + if (!(cmd = qemuMonitorJSONMakeCommand("query-status",
| + "s:garbage", "foo", NULL)))
| return -1;
|
| if (qemuMonitorJSONCommand(mon, cmd, &reply) < 0)
Suggested-by: Peter Krempa <pkrempa@redhat.com>
Signed-off-by: Eric Blake <eblake@redhat.com>
Acked-by: Peter Krempa <pkrempa@redhat.com>
2019-06-12 01:59:11 +00:00
|
|
|
testQemuMonitorJSONGetMachines(const void *opaque)
|
2012-08-15 15:18:41 +00:00
|
|
|
{
|
qemumonitorjsontest: Validate more commands against schema
The DO_TEST() macro in qemumonitorjsontest.c was not passing the
schema through, which meant that we were not validating any of those
tests for correct usage according to the schema.
In the process of mechanically altering tests to pass the schema
through, use VIR_AUTOPTR on all of the affected test instances. The
next patch will do some further cleanups that it exposes.
Tested by using this hack, where the test mistakenly passed pre-patch,
but correctly diagnosed the garbage post-patch:
| diff --git i/src/qemu/qemu_monitor_json.c w/src/qemu/qemu_monitor_json.c
| index 53a7de8b77..86d8450814 100644
| --- i/src/qemu/qemu_monitor_json.c
| +++ w/src/qemu/qemu_monitor_json.c
| @@ -1532,7 +1532,8 @@ qemuMonitorJSONGetStatus(qemuMonitorPtr mon,
| if (reason)
| *reason = VIR_DOMAIN_PAUSED_UNKNOWN;
|
| - if (!(cmd = qemuMonitorJSONMakeCommand("query-status", NULL)))
| + if (!(cmd = qemuMonitorJSONMakeCommand("query-status",
| + "s:garbage", "foo", NULL)))
| return -1;
|
| if (qemuMonitorJSONCommand(mon, cmd, &reply) < 0)
Suggested-by: Peter Krempa <pkrempa@redhat.com>
Signed-off-by: Eric Blake <eblake@redhat.com>
Acked-by: Peter Krempa <pkrempa@redhat.com>
2019-06-12 01:59:11 +00:00
|
|
|
const testGenericData *data = opaque;
|
2021-03-11 07:16:13 +00:00
|
|
|
virDomainXMLOption *xmlopt = data->xmlopt;
|
2012-08-15 15:18:41 +00:00
|
|
|
int ret = -1;
|
2021-03-11 07:16:13 +00:00
|
|
|
qemuMonitorMachineInfo **info;
|
2013-02-04 16:17:52 +00:00
|
|
|
int ninfo = 0;
|
2012-08-15 15:18:41 +00:00
|
|
|
const char *null = NULL;
|
Convert 'int i' to 'size_t i' in tests/ files
Convert the type of loop iterators named 'i', 'j', k',
'ii', 'jj', 'kk', to be 'size_t' instead of 'int' or
'unsigned int', also santizing 'ii', 'jj', 'kk' to use
the normal 'i', 'j', 'k' naming
Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
2013-07-08 14:09:33 +00:00
|
|
|
size_t i;
|
2012-08-15 15:18:41 +00:00
|
|
|
|
2019-10-15 12:47:50 +00:00
|
|
|
g_autoptr(qemuMonitorTest) test = NULL;
|
qemumonitorjsontest: Validate more commands against schema
The DO_TEST() macro in qemumonitorjsontest.c was not passing the
schema through, which meant that we were not validating any of those
tests for correct usage according to the schema.
In the process of mechanically altering tests to pass the schema
through, use VIR_AUTOPTR on all of the affected test instances. The
next patch will do some further cleanups that it exposes.
Tested by using this hack, where the test mistakenly passed pre-patch,
but correctly diagnosed the garbage post-patch:
| diff --git i/src/qemu/qemu_monitor_json.c w/src/qemu/qemu_monitor_json.c
| index 53a7de8b77..86d8450814 100644
| --- i/src/qemu/qemu_monitor_json.c
| +++ w/src/qemu/qemu_monitor_json.c
| @@ -1532,7 +1532,8 @@ qemuMonitorJSONGetStatus(qemuMonitorPtr mon,
| if (reason)
| *reason = VIR_DOMAIN_PAUSED_UNKNOWN;
|
| - if (!(cmd = qemuMonitorJSONMakeCommand("query-status", NULL)))
| + if (!(cmd = qemuMonitorJSONMakeCommand("query-status",
| + "s:garbage", "foo", NULL)))
| return -1;
|
| if (qemuMonitorJSONCommand(mon, cmd, &reply) < 0)
Suggested-by: Peter Krempa <pkrempa@redhat.com>
Signed-off-by: Eric Blake <eblake@redhat.com>
Acked-by: Peter Krempa <pkrempa@redhat.com>
2019-06-12 01:59:11 +00:00
|
|
|
|
|
|
|
if (!(test = qemuMonitorTestNewSchema(xmlopt, data->schema)))
|
2012-08-15 15:18:41 +00:00
|
|
|
return -1;
|
|
|
|
|
|
|
|
if (qemuMonitorTestAddItem(test, "query-machines",
|
|
|
|
"{ "
|
|
|
|
" \"return\": [ "
|
|
|
|
" { "
|
|
|
|
" \"name\": \"pc-1.0\" "
|
|
|
|
" }, "
|
|
|
|
" { "
|
|
|
|
" \"name\": \"pc-1.1\" "
|
|
|
|
" }, "
|
|
|
|
" { "
|
|
|
|
" \"name\": \"pc-1.2\", "
|
|
|
|
" \"is-default\": true, "
|
|
|
|
" \"alias\": \"pc\" "
|
|
|
|
" } "
|
|
|
|
" ]"
|
|
|
|
"}") < 0)
|
|
|
|
goto cleanup;
|
|
|
|
|
|
|
|
if ((ninfo = qemuMonitorGetMachines(qemuMonitorTestGetMonitor(test),
|
|
|
|
&info)) < 0)
|
|
|
|
goto cleanup;
|
|
|
|
|
|
|
|
if (ninfo != 3) {
|
|
|
|
virReportError(VIR_ERR_INTERNAL_ERROR,
|
|
|
|
"ninfo %d is not 3", ninfo);
|
|
|
|
goto cleanup;
|
|
|
|
}
|
|
|
|
|
2017-11-03 12:09:47 +00:00
|
|
|
#define CHECK(i, wantname, wantisDefault, wantalias) \
|
|
|
|
do { \
|
|
|
|
if (STRNEQ(info[i]->name, (wantname))) { \
|
|
|
|
virReportError(VIR_ERR_INTERNAL_ERROR, \
|
|
|
|
"name %s is not %s", \
|
|
|
|
info[i]->name, (wantname)); \
|
|
|
|
goto cleanup; \
|
|
|
|
} \
|
|
|
|
if (info[i]->isDefault != (wantisDefault)) { \
|
|
|
|
virReportError(VIR_ERR_INTERNAL_ERROR, \
|
|
|
|
"isDefault %d is not %d", \
|
|
|
|
info[i]->isDefault, (wantisDefault)); \
|
|
|
|
goto cleanup; \
|
|
|
|
} \
|
|
|
|
if (STRNEQ_NULLABLE(info[i]->alias, (wantalias))) { \
|
|
|
|
virReportError(VIR_ERR_INTERNAL_ERROR, \
|
|
|
|
"alias %s is not %s", \
|
|
|
|
info[i]->alias, NULLSTR(wantalias)); \
|
|
|
|
goto cleanup; \
|
|
|
|
} \
|
2012-08-15 15:18:41 +00:00
|
|
|
} while (0)
|
|
|
|
|
|
|
|
CHECK(0, "pc-1.0", false, null);
|
|
|
|
CHECK(1, "pc-1.1", false, null);
|
|
|
|
CHECK(2, "pc-1.2", true, "pc");
|
|
|
|
|
|
|
|
#undef CHECK
|
|
|
|
|
|
|
|
ret = 0;
|
|
|
|
|
2014-03-25 06:53:44 +00:00
|
|
|
cleanup:
|
2013-02-04 16:17:52 +00:00
|
|
|
for (i = 0; i < ninfo; i++)
|
|
|
|
qemuMonitorMachineInfoFree(info[i]);
|
|
|
|
VIR_FREE(info);
|
|
|
|
|
2012-08-15 15:18:41 +00:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2012-08-20 14:58:20 +00:00
|
|
|
static int
|
qemumonitorjsontest: Validate more commands against schema
The DO_TEST() macro in qemumonitorjsontest.c was not passing the
schema through, which meant that we were not validating any of those
tests for correct usage according to the schema.
In the process of mechanically altering tests to pass the schema
through, use VIR_AUTOPTR on all of the affected test instances. The
next patch will do some further cleanups that it exposes.
Tested by using this hack, where the test mistakenly passed pre-patch,
but correctly diagnosed the garbage post-patch:
| diff --git i/src/qemu/qemu_monitor_json.c w/src/qemu/qemu_monitor_json.c
| index 53a7de8b77..86d8450814 100644
| --- i/src/qemu/qemu_monitor_json.c
| +++ w/src/qemu/qemu_monitor_json.c
| @@ -1532,7 +1532,8 @@ qemuMonitorJSONGetStatus(qemuMonitorPtr mon,
| if (reason)
| *reason = VIR_DOMAIN_PAUSED_UNKNOWN;
|
| - if (!(cmd = qemuMonitorJSONMakeCommand("query-status", NULL)))
| + if (!(cmd = qemuMonitorJSONMakeCommand("query-status",
| + "s:garbage", "foo", NULL)))
| return -1;
|
| if (qemuMonitorJSONCommand(mon, cmd, &reply) < 0)
Suggested-by: Peter Krempa <pkrempa@redhat.com>
Signed-off-by: Eric Blake <eblake@redhat.com>
Acked-by: Peter Krempa <pkrempa@redhat.com>
2019-06-12 01:59:11 +00:00
|
|
|
testQemuMonitorJSONGetCPUDefinitions(const void *opaque)
|
2012-08-20 14:58:20 +00:00
|
|
|
{
|
qemumonitorjsontest: Validate more commands against schema
The DO_TEST() macro in qemumonitorjsontest.c was not passing the
schema through, which meant that we were not validating any of those
tests for correct usage according to the schema.
In the process of mechanically altering tests to pass the schema
through, use VIR_AUTOPTR on all of the affected test instances. The
next patch will do some further cleanups that it exposes.
Tested by using this hack, where the test mistakenly passed pre-patch,
but correctly diagnosed the garbage post-patch:
| diff --git i/src/qemu/qemu_monitor_json.c w/src/qemu/qemu_monitor_json.c
| index 53a7de8b77..86d8450814 100644
| --- i/src/qemu/qemu_monitor_json.c
| +++ w/src/qemu/qemu_monitor_json.c
| @@ -1532,7 +1532,8 @@ qemuMonitorJSONGetStatus(qemuMonitorPtr mon,
| if (reason)
| *reason = VIR_DOMAIN_PAUSED_UNKNOWN;
|
| - if (!(cmd = qemuMonitorJSONMakeCommand("query-status", NULL)))
| + if (!(cmd = qemuMonitorJSONMakeCommand("query-status",
| + "s:garbage", "foo", NULL)))
| return -1;
|
| if (qemuMonitorJSONCommand(mon, cmd, &reply) < 0)
Suggested-by: Peter Krempa <pkrempa@redhat.com>
Signed-off-by: Eric Blake <eblake@redhat.com>
Acked-by: Peter Krempa <pkrempa@redhat.com>
2019-06-12 01:59:11 +00:00
|
|
|
const testGenericData *data = opaque;
|
2021-03-11 07:16:13 +00:00
|
|
|
virDomainXMLOption *xmlopt = data->xmlopt;
|
2019-09-24 11:42:00 +00:00
|
|
|
g_autoptr(qemuMonitorCPUDefs) defs = NULL;
|
2019-10-15 12:47:50 +00:00
|
|
|
g_autoptr(qemuMonitorTest) test = NULL;
|
2012-08-20 14:58:20 +00:00
|
|
|
|
qemumonitorjsontest: Validate more commands against schema
The DO_TEST() macro in qemumonitorjsontest.c was not passing the
schema through, which meant that we were not validating any of those
tests for correct usage according to the schema.
In the process of mechanically altering tests to pass the schema
through, use VIR_AUTOPTR on all of the affected test instances. The
next patch will do some further cleanups that it exposes.
Tested by using this hack, where the test mistakenly passed pre-patch,
but correctly diagnosed the garbage post-patch:
| diff --git i/src/qemu/qemu_monitor_json.c w/src/qemu/qemu_monitor_json.c
| index 53a7de8b77..86d8450814 100644
| --- i/src/qemu/qemu_monitor_json.c
| +++ w/src/qemu/qemu_monitor_json.c
| @@ -1532,7 +1532,8 @@ qemuMonitorJSONGetStatus(qemuMonitorPtr mon,
| if (reason)
| *reason = VIR_DOMAIN_PAUSED_UNKNOWN;
|
| - if (!(cmd = qemuMonitorJSONMakeCommand("query-status", NULL)))
| + if (!(cmd = qemuMonitorJSONMakeCommand("query-status",
| + "s:garbage", "foo", NULL)))
| return -1;
|
| if (qemuMonitorJSONCommand(mon, cmd, &reply) < 0)
Suggested-by: Peter Krempa <pkrempa@redhat.com>
Signed-off-by: Eric Blake <eblake@redhat.com>
Acked-by: Peter Krempa <pkrempa@redhat.com>
2019-06-12 01:59:11 +00:00
|
|
|
if (!(test = qemuMonitorTestNewSchema(xmlopt, data->schema)))
|
2012-08-20 14:58:20 +00:00
|
|
|
return -1;
|
|
|
|
|
|
|
|
if (qemuMonitorTestAddItem(test, "query-cpu-definitions",
|
|
|
|
"{ "
|
|
|
|
" \"return\": [ "
|
|
|
|
" { "
|
|
|
|
" \"name\": \"qemu64\" "
|
|
|
|
" }, "
|
|
|
|
" { "
|
2016-04-21 11:08:12 +00:00
|
|
|
" \"name\": \"Opteron_G4\", "
|
|
|
|
" \"unavailable-features\": [\"vme\"]"
|
2012-08-20 14:58:20 +00:00
|
|
|
" }, "
|
|
|
|
" { "
|
2016-04-21 11:08:12 +00:00
|
|
|
" \"name\": \"Westmere\", "
|
|
|
|
" \"unavailable-features\": []"
|
2012-08-20 14:58:20 +00:00
|
|
|
" } "
|
|
|
|
" ]"
|
|
|
|
"}") < 0)
|
2019-09-24 11:42:00 +00:00
|
|
|
return -1;
|
2012-08-20 14:58:20 +00:00
|
|
|
|
2019-09-24 11:42:00 +00:00
|
|
|
if (qemuMonitorGetCPUDefinitions(qemuMonitorTestGetMonitor(test), &defs) < 0)
|
|
|
|
return -1;
|
2012-08-20 14:58:20 +00:00
|
|
|
|
2019-09-24 11:42:00 +00:00
|
|
|
if (defs->ncpus != 3) {
|
2012-08-20 14:58:20 +00:00
|
|
|
virReportError(VIR_ERR_INTERNAL_ERROR,
|
2019-09-24 11:42:00 +00:00
|
|
|
"ncpus %zu is not 3", defs->ncpus);
|
|
|
|
return -1;
|
2012-08-20 14:58:20 +00:00
|
|
|
}
|
|
|
|
|
2017-11-03 12:09:47 +00:00
|
|
|
#define CHECK_FULL(i, wantname, Usable) \
|
|
|
|
do { \
|
2019-09-24 11:45:37 +00:00
|
|
|
if (STRNEQ(defs->cpus[i].name, (wantname))) { \
|
2017-11-03 12:09:47 +00:00
|
|
|
virReportError(VIR_ERR_INTERNAL_ERROR, \
|
|
|
|
"name %s is not %s", \
|
2019-09-24 11:45:37 +00:00
|
|
|
defs->cpus[i].name, (wantname)); \
|
2019-09-24 11:42:00 +00:00
|
|
|
return -1; \
|
2017-11-03 12:09:47 +00:00
|
|
|
} \
|
2019-09-24 11:45:37 +00:00
|
|
|
if (defs->cpus[i].usable != (Usable)) { \
|
2017-11-03 12:09:47 +00:00
|
|
|
virReportError(VIR_ERR_INTERNAL_ERROR, \
|
|
|
|
"%s: expecting usable flag %d, got %d", \
|
2019-09-24 11:45:37 +00:00
|
|
|
defs->cpus[i].name, Usable, defs->cpus[i].usable); \
|
2019-09-24 11:42:00 +00:00
|
|
|
return -1; \
|
2017-11-03 12:09:47 +00:00
|
|
|
} \
|
2012-08-20 14:58:20 +00:00
|
|
|
} while (0)
|
|
|
|
|
2017-11-03 12:09:47 +00:00
|
|
|
#define CHECK(i, wantname) \
|
2019-10-29 13:36:11 +00:00
|
|
|
CHECK_FULL(i, wantname, VIR_DOMCAPS_CPU_USABLE_UNKNOWN)
|
2016-04-21 11:08:12 +00:00
|
|
|
|
2017-11-03 12:09:47 +00:00
|
|
|
#define CHECK_USABLE(i, wantname, usable) \
|
|
|
|
CHECK_FULL(i, wantname, \
|
2019-10-29 13:36:11 +00:00
|
|
|
usable ? VIR_DOMCAPS_CPU_USABLE_YES : VIR_DOMCAPS_CPU_USABLE_NO)
|
2016-04-21 11:08:12 +00:00
|
|
|
|
2012-08-20 14:58:20 +00:00
|
|
|
CHECK(0, "qemu64");
|
2016-04-21 11:08:12 +00:00
|
|
|
CHECK_USABLE(1, "Opteron_G4", false);
|
|
|
|
CHECK_USABLE(2, "Westmere", true);
|
2012-08-20 14:58:20 +00:00
|
|
|
|
|
|
|
#undef CHECK
|
2016-04-21 11:08:12 +00:00
|
|
|
#undef CHECK_USABLE
|
|
|
|
#undef CHECK_FULL
|
2012-08-20 14:58:20 +00:00
|
|
|
|
2019-09-24 11:42:00 +00:00
|
|
|
return 0;
|
2012-08-20 14:58:20 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2013-04-26 11:13:05 +00:00
|
|
|
static int
|
qemumonitorjsontest: Validate more commands against schema
The DO_TEST() macro in qemumonitorjsontest.c was not passing the
schema through, which meant that we were not validating any of those
tests for correct usage according to the schema.
In the process of mechanically altering tests to pass the schema
through, use VIR_AUTOPTR on all of the affected test instances. The
next patch will do some further cleanups that it exposes.
Tested by using this hack, where the test mistakenly passed pre-patch,
but correctly diagnosed the garbage post-patch:
| diff --git i/src/qemu/qemu_monitor_json.c w/src/qemu/qemu_monitor_json.c
| index 53a7de8b77..86d8450814 100644
| --- i/src/qemu/qemu_monitor_json.c
| +++ w/src/qemu/qemu_monitor_json.c
| @@ -1532,7 +1532,8 @@ qemuMonitorJSONGetStatus(qemuMonitorPtr mon,
| if (reason)
| *reason = VIR_DOMAIN_PAUSED_UNKNOWN;
|
| - if (!(cmd = qemuMonitorJSONMakeCommand("query-status", NULL)))
| + if (!(cmd = qemuMonitorJSONMakeCommand("query-status",
| + "s:garbage", "foo", NULL)))
| return -1;
|
| if (qemuMonitorJSONCommand(mon, cmd, &reply) < 0)
Suggested-by: Peter Krempa <pkrempa@redhat.com>
Signed-off-by: Eric Blake <eblake@redhat.com>
Acked-by: Peter Krempa <pkrempa@redhat.com>
2019-06-12 01:59:11 +00:00
|
|
|
testQemuMonitorJSONGetTPMModels(const void *opaque)
|
2013-04-26 11:13:05 +00:00
|
|
|
{
|
qemumonitorjsontest: Validate more commands against schema
The DO_TEST() macro in qemumonitorjsontest.c was not passing the
schema through, which meant that we were not validating any of those
tests for correct usage according to the schema.
In the process of mechanically altering tests to pass the schema
through, use VIR_AUTOPTR on all of the affected test instances. The
next patch will do some further cleanups that it exposes.
Tested by using this hack, where the test mistakenly passed pre-patch,
but correctly diagnosed the garbage post-patch:
| diff --git i/src/qemu/qemu_monitor_json.c w/src/qemu/qemu_monitor_json.c
| index 53a7de8b77..86d8450814 100644
| --- i/src/qemu/qemu_monitor_json.c
| +++ w/src/qemu/qemu_monitor_json.c
| @@ -1532,7 +1532,8 @@ qemuMonitorJSONGetStatus(qemuMonitorPtr mon,
| if (reason)
| *reason = VIR_DOMAIN_PAUSED_UNKNOWN;
|
| - if (!(cmd = qemuMonitorJSONMakeCommand("query-status", NULL)))
| + if (!(cmd = qemuMonitorJSONMakeCommand("query-status",
| + "s:garbage", "foo", NULL)))
| return -1;
|
| if (qemuMonitorJSONCommand(mon, cmd, &reply) < 0)
Suggested-by: Peter Krempa <pkrempa@redhat.com>
Signed-off-by: Eric Blake <eblake@redhat.com>
Acked-by: Peter Krempa <pkrempa@redhat.com>
2019-06-12 01:59:11 +00:00
|
|
|
const testGenericData *data = opaque;
|
2021-03-11 07:16:13 +00:00
|
|
|
virDomainXMLOption *xmlopt = data->xmlopt;
|
2021-06-14 14:38:26 +00:00
|
|
|
g_auto(GStrv) tpmmodels = NULL;
|
2019-10-15 12:47:50 +00:00
|
|
|
g_autoptr(qemuMonitorTest) test = NULL;
|
2013-04-26 11:13:05 +00:00
|
|
|
|
qemumonitorjsontest: Validate more commands against schema
The DO_TEST() macro in qemumonitorjsontest.c was not passing the
schema through, which meant that we were not validating any of those
tests for correct usage according to the schema.
In the process of mechanically altering tests to pass the schema
through, use VIR_AUTOPTR on all of the affected test instances. The
next patch will do some further cleanups that it exposes.
Tested by using this hack, where the test mistakenly passed pre-patch,
but correctly diagnosed the garbage post-patch:
| diff --git i/src/qemu/qemu_monitor_json.c w/src/qemu/qemu_monitor_json.c
| index 53a7de8b77..86d8450814 100644
| --- i/src/qemu/qemu_monitor_json.c
| +++ w/src/qemu/qemu_monitor_json.c
| @@ -1532,7 +1532,8 @@ qemuMonitorJSONGetStatus(qemuMonitorPtr mon,
| if (reason)
| *reason = VIR_DOMAIN_PAUSED_UNKNOWN;
|
| - if (!(cmd = qemuMonitorJSONMakeCommand("query-status", NULL)))
| + if (!(cmd = qemuMonitorJSONMakeCommand("query-status",
| + "s:garbage", "foo", NULL)))
| return -1;
|
| if (qemuMonitorJSONCommand(mon, cmd, &reply) < 0)
Suggested-by: Peter Krempa <pkrempa@redhat.com>
Signed-off-by: Eric Blake <eblake@redhat.com>
Acked-by: Peter Krempa <pkrempa@redhat.com>
2019-06-12 01:59:11 +00:00
|
|
|
if (!(test = qemuMonitorTestNewSchema(xmlopt, data->schema)))
|
2013-04-26 11:13:05 +00:00
|
|
|
return -1;
|
|
|
|
|
|
|
|
if (qemuMonitorTestAddItem(test, "query-tpm-models",
|
|
|
|
"{ "
|
|
|
|
" \"return\": [ "
|
|
|
|
" \"passthrough\""
|
|
|
|
" ]"
|
|
|
|
"}") < 0)
|
2021-06-14 14:38:26 +00:00
|
|
|
return -1;
|
2013-04-26 11:13:05 +00:00
|
|
|
|
2021-06-14 14:41:09 +00:00
|
|
|
if (qemuMonitorGetTPMModels(qemuMonitorTestGetMonitor(test), &tpmmodels) < 0)
|
2021-06-14 14:38:26 +00:00
|
|
|
return -1;
|
2013-04-26 11:13:05 +00:00
|
|
|
|
2021-06-14 14:41:09 +00:00
|
|
|
if (g_strv_length(tpmmodels) != 1) {
|
|
|
|
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
|
|
|
"expected 1 tpm model");
|
2021-06-14 14:38:26 +00:00
|
|
|
return -1;
|
2013-04-26 11:13:05 +00:00
|
|
|
}
|
|
|
|
|
2017-11-03 12:09:47 +00:00
|
|
|
#define CHECK(i, wantname) \
|
|
|
|
do { \
|
|
|
|
if (STRNEQ(tpmmodels[i], (wantname))) { \
|
|
|
|
virReportError(VIR_ERR_INTERNAL_ERROR, \
|
|
|
|
"name %s is not %s", \
|
|
|
|
tpmmodels[i], (wantname)); \
|
2021-06-14 14:38:26 +00:00
|
|
|
return -1; \
|
2017-11-03 12:09:47 +00:00
|
|
|
} \
|
2013-04-26 11:13:05 +00:00
|
|
|
} while (0)
|
|
|
|
|
|
|
|
CHECK(0, "passthrough");
|
|
|
|
|
|
|
|
#undef CHECK
|
|
|
|
|
2021-06-14 14:38:26 +00:00
|
|
|
return 0;
|
2013-04-26 11:13:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2016-09-27 13:49:05 +00:00
|
|
|
struct qemuMonitorJSONTestAttachChardevData {
|
2021-03-11 07:16:13 +00:00
|
|
|
virDomainChrSourceDef *chr;
|
2016-09-27 13:49:05 +00:00
|
|
|
const char *expectPty;
|
|
|
|
bool fail;
|
2023-05-22 14:18:40 +00:00
|
|
|
|
|
|
|
virDomainXMLOption *xmlopt;
|
|
|
|
GHashTable *schema;
|
|
|
|
const char *expectargs;
|
|
|
|
const char *reply;
|
2016-09-27 13:49:05 +00:00
|
|
|
};
|
|
|
|
|
2013-03-12 18:48:04 +00:00
|
|
|
static int
|
2016-09-27 13:49:05 +00:00
|
|
|
testQemuMonitorJSONAttachChardev(const void *opaque)
|
2013-03-12 18:48:04 +00:00
|
|
|
{
|
2016-09-27 13:49:05 +00:00
|
|
|
const struct qemuMonitorJSONTestAttachChardevData *data = opaque;
|
2023-05-22 14:18:40 +00:00
|
|
|
g_autoptr(qemuMonitorTest) test = qemuMonitorTestNewSchema(data->xmlopt, data->schema);
|
2024-09-13 08:33:47 +00:00
|
|
|
g_autoptr(virJSONValue) props = NULL;
|
|
|
|
g_autofree char *ptypath = NULL;
|
2016-09-27 13:49:05 +00:00
|
|
|
int rc;
|
2013-03-12 18:48:04 +00:00
|
|
|
|
2023-05-22 14:18:40 +00:00
|
|
|
if (!test)
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
if (data->expectargs) {
|
|
|
|
g_autofree char *jsonreply = g_strdup_printf("{\"return\": {%s}}", NULLSTR_EMPTY(data->reply));
|
2023-05-22 11:43:53 +00:00
|
|
|
g_autofree char *jsoncommand = NULL;
|
|
|
|
char *n;
|
2023-05-22 14:18:40 +00:00
|
|
|
|
2023-05-22 11:43:53 +00:00
|
|
|
jsoncommand = g_strdup_printf("{\"execute\": \"chardev-add\", \"arguments\": %s, \"id\" : \"libvirt-1\"}", data->expectargs);
|
|
|
|
|
|
|
|
/* data->expectargs has ' instead of " */
|
|
|
|
for (n = jsoncommand; *n; n++) {
|
|
|
|
if (*n == '\'')
|
|
|
|
*n = '"';
|
|
|
|
}
|
|
|
|
|
|
|
|
if (qemuMonitorTestAddItemVerbatim(test, jsoncommand, NULL, jsonreply) < 0)
|
2023-05-22 14:18:40 +00:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2024-10-11 12:20:32 +00:00
|
|
|
if (qemuChardevGetBackendProps(data->chr, false, NULL, "alias", NULL, &props) < 0)
|
2024-09-13 08:33:47 +00:00
|
|
|
return -1;
|
|
|
|
|
|
|
|
if ((rc = qemuMonitorAttachCharDev(qemuMonitorTestGetMonitor(test), &props, &ptypath)) < 0)
|
2016-09-27 13:49:05 +00:00
|
|
|
goto cleanup;
|
|
|
|
|
|
|
|
if (data->chr->type == VIR_DOMAIN_CHR_TYPE_PTY) {
|
2024-09-13 08:33:47 +00:00
|
|
|
if (STRNEQ_NULLABLE(data->expectPty, ptypath)) {
|
2016-09-27 13:49:05 +00:00
|
|
|
virReportError(VIR_ERR_INTERNAL_ERROR,
|
|
|
|
"expected PTY path: %s got: %s",
|
|
|
|
NULLSTR(data->expectPty),
|
|
|
|
NULLSTR(data->chr->data.file.path));
|
|
|
|
rc = -1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
cleanup:
|
|
|
|
if ((rc != 0) != data->fail)
|
2013-03-12 18:48:04 +00:00
|
|
|
return -1;
|
2016-09-27 13:49:05 +00:00
|
|
|
else
|
|
|
|
return 0;
|
|
|
|
}
|
2013-03-12 18:48:04 +00:00
|
|
|
|
|
|
|
|
2016-09-27 13:49:05 +00:00
|
|
|
static int
|
2021-03-11 07:16:13 +00:00
|
|
|
qemuMonitorJSONTestAttachOneChardev(virDomainXMLOption *xmlopt,
|
2020-10-22 17:04:18 +00:00
|
|
|
GHashTable *schema,
|
2016-09-27 13:49:05 +00:00
|
|
|
const char *label,
|
2021-03-11 07:16:13 +00:00
|
|
|
virDomainChrSourceDef *chr,
|
2016-09-27 07:52:50 +00:00
|
|
|
const char *expectargs,
|
2016-09-27 13:49:05 +00:00
|
|
|
const char *reply,
|
|
|
|
const char *expectPty,
|
|
|
|
bool fail)
|
2013-03-12 18:48:04 +00:00
|
|
|
|
2016-09-27 13:49:05 +00:00
|
|
|
{
|
2023-05-22 14:18:40 +00:00
|
|
|
struct qemuMonitorJSONTestAttachChardevData data = { .chr = chr,
|
|
|
|
.fail = fail,
|
|
|
|
.expectPty = expectPty,
|
|
|
|
.expectargs = expectargs,
|
|
|
|
.reply = reply,
|
|
|
|
.xmlopt = xmlopt,
|
|
|
|
.schema = schema };
|
|
|
|
g_autofree char *fulllabel = g_strdup_printf("qemuMonitorJSONTestAttachChardev(%s)", label);
|
|
|
|
|
|
|
|
return virTestRun(fulllabel, &testQemuMonitorJSONAttachChardev, &data);
|
2016-09-27 13:49:05 +00:00
|
|
|
}
|
|
|
|
|
2023-05-22 14:18:40 +00:00
|
|
|
|
2016-09-27 13:49:05 +00:00
|
|
|
static int
|
2021-03-11 07:16:13 +00:00
|
|
|
qemuMonitorJSONTestAttachChardev(virDomainXMLOption *xmlopt,
|
2020-10-22 17:04:18 +00:00
|
|
|
GHashTable *schema)
|
2016-09-27 13:49:05 +00:00
|
|
|
{
|
2022-02-09 12:10:57 +00:00
|
|
|
virDomainChrDef chrdev = { .info = { .alias = (char *) "alias" }};
|
|
|
|
virDomainDeviceDef dev = { .type = VIR_DOMAIN_DEVICE_CHR, .data.chr = &chrdev };
|
2016-09-27 13:49:05 +00:00
|
|
|
int ret = 0;
|
|
|
|
|
2017-11-03 12:09:47 +00:00
|
|
|
#define CHECK(label, fail, expectargs) \
|
2022-02-08 15:41:33 +00:00
|
|
|
if (qemuMonitorJSONTestAttachOneChardev(xmlopt, schema, label, chr, \
|
qemumonitorjsontest: Validate more commands against schema
The DO_TEST() macro in qemumonitorjsontest.c was not passing the
schema through, which meant that we were not validating any of those
tests for correct usage according to the schema.
In the process of mechanically altering tests to pass the schema
through, use VIR_AUTOPTR on all of the affected test instances. The
next patch will do some further cleanups that it exposes.
Tested by using this hack, where the test mistakenly passed pre-patch,
but correctly diagnosed the garbage post-patch:
| diff --git i/src/qemu/qemu_monitor_json.c w/src/qemu/qemu_monitor_json.c
| index 53a7de8b77..86d8450814 100644
| --- i/src/qemu/qemu_monitor_json.c
| +++ w/src/qemu/qemu_monitor_json.c
| @@ -1532,7 +1532,8 @@ qemuMonitorJSONGetStatus(qemuMonitorPtr mon,
| if (reason)
| *reason = VIR_DOMAIN_PAUSED_UNKNOWN;
|
| - if (!(cmd = qemuMonitorJSONMakeCommand("query-status", NULL)))
| + if (!(cmd = qemuMonitorJSONMakeCommand("query-status",
| + "s:garbage", "foo", NULL)))
| return -1;
|
| if (qemuMonitorJSONCommand(mon, cmd, &reply) < 0)
Suggested-by: Peter Krempa <pkrempa@redhat.com>
Signed-off-by: Eric Blake <eblake@redhat.com>
Acked-by: Peter Krempa <pkrempa@redhat.com>
2019-06-12 01:59:11 +00:00
|
|
|
expectargs, NULL, NULL, fail) < 0) \
|
2016-09-27 13:49:05 +00:00
|
|
|
ret = -1
|
2013-03-12 18:48:04 +00:00
|
|
|
|
2022-02-08 15:41:33 +00:00
|
|
|
{
|
|
|
|
g_autoptr(virDomainChrSourceDef) chr = virDomainChrSourceDefNew(xmlopt);
|
|
|
|
|
|
|
|
chr->type = VIR_DOMAIN_CHR_TYPE_NULL;
|
|
|
|
CHECK("null", false,
|
|
|
|
"{'id':'alias','backend':{'type':'null','data':{}}}");
|
|
|
|
|
|
|
|
chr->type = VIR_DOMAIN_CHR_TYPE_VC;
|
|
|
|
CHECK("vc", false,
|
|
|
|
"{'id':'alias','backend':{'type':'vc','data':{}}}");
|
|
|
|
|
|
|
|
chr->type = VIR_DOMAIN_CHR_TYPE_SPICEVMC;
|
|
|
|
CHECK("spicevmc", false,
|
|
|
|
"{'id':'alias','backend':{'type':'spicevmc',"
|
|
|
|
"'data':{'type':'vdagent'}}}");
|
|
|
|
|
|
|
|
chr->type = VIR_DOMAIN_CHR_TYPE_PTY;
|
2024-09-13 08:33:47 +00:00
|
|
|
/* Higher level code regards the missing path as error, but we simply
|
|
|
|
* check here what we've parsed */
|
|
|
|
CHECK("pty missing path", false,
|
2022-02-08 15:41:33 +00:00
|
|
|
"{'id':'alias','backend':{'type':'pty','data':{}}}");
|
|
|
|
if (qemuMonitorJSONTestAttachOneChardev(xmlopt, schema, "pty", chr,
|
|
|
|
"{'id':'alias',"
|
|
|
|
"'backend':{'type':'pty',"
|
|
|
|
"'data':{}}}",
|
|
|
|
"\"pty\" : \"/dev/pts/0\"",
|
|
|
|
"/dev/pts/0", false) < 0)
|
|
|
|
ret = -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
{
|
|
|
|
g_autoptr(virDomainChrSourceDef) chr = virDomainChrSourceDefNew(xmlopt);
|
|
|
|
|
|
|
|
chr->data.file.path = g_strdup("/test/path");
|
|
|
|
|
|
|
|
chr->type = VIR_DOMAIN_CHR_TYPE_DEV;
|
|
|
|
CHECK("device", false,
|
|
|
|
"{'id':'alias','backend':{'type':'serial','data':{'device':'/test/path'}}}");
|
2022-02-09 09:19:56 +00:00
|
|
|
|
|
|
|
chr->type = VIR_DOMAIN_CHR_TYPE_FILE;
|
|
|
|
chr->logfile = g_strdup("/test/logfile");
|
|
|
|
chr->logappend = VIR_TRISTATE_SWITCH_OFF;
|
|
|
|
CHECK("file", false,
|
|
|
|
"{'id':'alias','backend':{'type':'file','data':{'out':'/test/path',"
|
|
|
|
"'logfile':'/test/logfile',"
|
|
|
|
"'logappend':false}}}");
|
2022-02-09 12:10:57 +00:00
|
|
|
|
|
|
|
chrdev.source = chr;
|
|
|
|
ignore_value(testQemuPrepareHostBackendChardevOne(&dev, chr, NULL));
|
|
|
|
CHECK("file", false,
|
|
|
|
"{'id':'alias','backend':{'type':'file','data':{'out':'/dev/fdset/monitor-fake',"
|
|
|
|
"'append':true,"
|
|
|
|
"'logfile':'/dev/fdset/monitor-fake',"
|
|
|
|
"'logappend':true}}}");
|
2022-02-08 15:41:33 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
{
|
|
|
|
g_autoptr(virDomainChrSourceDef) chr = virDomainChrSourceDefNew(xmlopt);
|
2022-02-08 18:58:07 +00:00
|
|
|
qemuDomainChrSourcePrivate *chrSourcePriv = QEMU_DOMAIN_CHR_SOURCE_PRIVATE(chr);
|
2022-02-08 15:41:33 +00:00
|
|
|
|
|
|
|
chr->type = VIR_DOMAIN_CHR_TYPE_TCP;
|
|
|
|
chr->data.tcp.host = g_strdup("example.com");
|
|
|
|
chr->data.tcp.service = g_strdup("1234");
|
|
|
|
CHECK("tcp", false,
|
|
|
|
"{'id':'alias',"
|
|
|
|
"'backend':{'type':'socket',"
|
|
|
|
"'data':{'addr':{'type':'inet',"
|
|
|
|
"'data':{'host':'example.com',"
|
|
|
|
"'port':'1234'}},"
|
|
|
|
"'telnet':false,"
|
|
|
|
"'server':false}}}");
|
2022-02-08 18:58:07 +00:00
|
|
|
|
|
|
|
chr->data.tcp.tlscreds = true;
|
|
|
|
chrSourcePriv->tlsCredsAlias = qemuAliasTLSObjFromSrcAlias("alias");
|
2022-02-09 09:19:56 +00:00
|
|
|
chr->logfile = g_strdup("/test/log");
|
2022-02-08 18:58:07 +00:00
|
|
|
CHECK("tcp", false,
|
|
|
|
"{'id':'alias',"
|
|
|
|
"'backend':{'type':'socket',"
|
|
|
|
"'data':{'addr':{'type':'inet',"
|
|
|
|
"'data':{'host':'example.com',"
|
|
|
|
"'port':'1234'}},"
|
|
|
|
"'telnet':false,"
|
|
|
|
"'server':false,"
|
2022-02-09 09:19:56 +00:00
|
|
|
"'tls-creds':'objalias_tls0',"
|
|
|
|
"'logfile':'/test/log'}}}");
|
2022-02-08 18:58:07 +00:00
|
|
|
|
2022-02-08 15:41:33 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
{
|
|
|
|
g_autoptr(virDomainChrSourceDef) chr = virDomainChrSourceDefNew(xmlopt);
|
|
|
|
|
|
|
|
chr->type = VIR_DOMAIN_CHR_TYPE_UDP;
|
|
|
|
chr->data.udp.connectHost = g_strdup("example.com");
|
|
|
|
chr->data.udp.connectService = g_strdup("1234");
|
|
|
|
CHECK("udp", false,
|
|
|
|
"{'id':'alias',"
|
|
|
|
"'backend':{'type':'udp',"
|
|
|
|
"'data':{'remote':{'type':'inet',"
|
|
|
|
"'data':{'host':'example.com',"
|
|
|
|
"'port':'1234'}}}}}");
|
|
|
|
|
|
|
|
chr->data.udp.bindService = g_strdup("4321");
|
|
|
|
CHECK("udp", false,
|
|
|
|
"{'id':'alias',"
|
|
|
|
"'backend':{'type':'udp',"
|
|
|
|
"'data':{'remote':{'type':'inet',"
|
|
|
|
"'data':{'host':'example.com',"
|
|
|
|
"'port':'1234'}},"
|
|
|
|
"'local':{'type':'inet',"
|
|
|
|
"'data':{'host':'',"
|
|
|
|
"'port':'4321'}}}}}");
|
|
|
|
|
|
|
|
chr->data.udp.bindHost = g_strdup("localhost");
|
|
|
|
CHECK("udp", false,
|
|
|
|
"{'id':'alias',"
|
|
|
|
"'backend':{'type':'udp',"
|
|
|
|
"'data':{'remote':{'type':'inet',"
|
|
|
|
"'data':{'host':'example.com',"
|
|
|
|
"'port':'1234'}},"
|
|
|
|
"'local':{'type':'inet',"
|
|
|
|
"'data':{'host':'localhost',"
|
|
|
|
"'port':'4321'}}}}}");
|
|
|
|
}
|
|
|
|
|
|
|
|
{
|
|
|
|
g_autoptr(virDomainChrSourceDef) chr = virDomainChrSourceDefNew(xmlopt);
|
|
|
|
|
|
|
|
chr->type = VIR_DOMAIN_CHR_TYPE_UNIX;
|
|
|
|
chr->data.nix.path = g_strdup("/path/to/socket");
|
|
|
|
CHECK("unix", false,
|
|
|
|
"{'id':'alias',"
|
|
|
|
"'backend':{'type':'socket',"
|
|
|
|
"'data':{'addr':{'type':'unix',"
|
|
|
|
"'data':{'path':'/path/to/socket'}},"
|
|
|
|
"'server':false}}}");
|
|
|
|
}
|
|
|
|
|
2013-03-12 18:48:04 +00:00
|
|
|
#undef CHECK
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
2013-04-26 17:13:45 +00:00
|
|
|
|
2016-09-27 13:49:05 +00:00
|
|
|
|
2013-03-12 18:57:48 +00:00
|
|
|
static int
|
qemumonitorjsontest: Validate more commands against schema
The DO_TEST() macro in qemumonitorjsontest.c was not passing the
schema through, which meant that we were not validating any of those
tests for correct usage according to the schema.
In the process of mechanically altering tests to pass the schema
through, use VIR_AUTOPTR on all of the affected test instances. The
next patch will do some further cleanups that it exposes.
Tested by using this hack, where the test mistakenly passed pre-patch,
but correctly diagnosed the garbage post-patch:
| diff --git i/src/qemu/qemu_monitor_json.c w/src/qemu/qemu_monitor_json.c
| index 53a7de8b77..86d8450814 100644
| --- i/src/qemu/qemu_monitor_json.c
| +++ w/src/qemu/qemu_monitor_json.c
| @@ -1532,7 +1532,8 @@ qemuMonitorJSONGetStatus(qemuMonitorPtr mon,
| if (reason)
| *reason = VIR_DOMAIN_PAUSED_UNKNOWN;
|
| - if (!(cmd = qemuMonitorJSONMakeCommand("query-status", NULL)))
| + if (!(cmd = qemuMonitorJSONMakeCommand("query-status",
| + "s:garbage", "foo", NULL)))
| return -1;
|
| if (qemuMonitorJSONCommand(mon, cmd, &reply) < 0)
Suggested-by: Peter Krempa <pkrempa@redhat.com>
Signed-off-by: Eric Blake <eblake@redhat.com>
Acked-by: Peter Krempa <pkrempa@redhat.com>
2019-06-12 01:59:11 +00:00
|
|
|
testQemuMonitorJSONDetachChardev(const void *opaque)
|
2013-03-12 18:57:48 +00:00
|
|
|
{
|
qemumonitorjsontest: Validate more commands against schema
The DO_TEST() macro in qemumonitorjsontest.c was not passing the
schema through, which meant that we were not validating any of those
tests for correct usage according to the schema.
In the process of mechanically altering tests to pass the schema
through, use VIR_AUTOPTR on all of the affected test instances. The
next patch will do some further cleanups that it exposes.
Tested by using this hack, where the test mistakenly passed pre-patch,
but correctly diagnosed the garbage post-patch:
| diff --git i/src/qemu/qemu_monitor_json.c w/src/qemu/qemu_monitor_json.c
| index 53a7de8b77..86d8450814 100644
| --- i/src/qemu/qemu_monitor_json.c
| +++ w/src/qemu/qemu_monitor_json.c
| @@ -1532,7 +1532,8 @@ qemuMonitorJSONGetStatus(qemuMonitorPtr mon,
| if (reason)
| *reason = VIR_DOMAIN_PAUSED_UNKNOWN;
|
| - if (!(cmd = qemuMonitorJSONMakeCommand("query-status", NULL)))
| + if (!(cmd = qemuMonitorJSONMakeCommand("query-status",
| + "s:garbage", "foo", NULL)))
| return -1;
|
| if (qemuMonitorJSONCommand(mon, cmd, &reply) < 0)
Suggested-by: Peter Krempa <pkrempa@redhat.com>
Signed-off-by: Eric Blake <eblake@redhat.com>
Acked-by: Peter Krempa <pkrempa@redhat.com>
2019-06-12 01:59:11 +00:00
|
|
|
const testGenericData *data = opaque;
|
2021-03-11 07:16:13 +00:00
|
|
|
virDomainXMLOption *xmlopt = data->xmlopt;
|
2019-10-15 12:47:50 +00:00
|
|
|
g_autoptr(qemuMonitorTest) test = NULL;
|
2013-03-12 18:57:48 +00:00
|
|
|
|
qemumonitorjsontest: Validate more commands against schema
The DO_TEST() macro in qemumonitorjsontest.c was not passing the
schema through, which meant that we were not validating any of those
tests for correct usage according to the schema.
In the process of mechanically altering tests to pass the schema
through, use VIR_AUTOPTR on all of the affected test instances. The
next patch will do some further cleanups that it exposes.
Tested by using this hack, where the test mistakenly passed pre-patch,
but correctly diagnosed the garbage post-patch:
| diff --git i/src/qemu/qemu_monitor_json.c w/src/qemu/qemu_monitor_json.c
| index 53a7de8b77..86d8450814 100644
| --- i/src/qemu/qemu_monitor_json.c
| +++ w/src/qemu/qemu_monitor_json.c
| @@ -1532,7 +1532,8 @@ qemuMonitorJSONGetStatus(qemuMonitorPtr mon,
| if (reason)
| *reason = VIR_DOMAIN_PAUSED_UNKNOWN;
|
| - if (!(cmd = qemuMonitorJSONMakeCommand("query-status", NULL)))
| + if (!(cmd = qemuMonitorJSONMakeCommand("query-status",
| + "s:garbage", "foo", NULL)))
| return -1;
|
| if (qemuMonitorJSONCommand(mon, cmd, &reply) < 0)
Suggested-by: Peter Krempa <pkrempa@redhat.com>
Signed-off-by: Eric Blake <eblake@redhat.com>
Acked-by: Peter Krempa <pkrempa@redhat.com>
2019-06-12 01:59:11 +00:00
|
|
|
if (!(test = qemuMonitorTestNewSchema(xmlopt, data->schema)))
|
2019-06-11 03:01:08 +00:00
|
|
|
return -1;
|
2013-03-12 18:57:48 +00:00
|
|
|
|
|
|
|
if (qemuMonitorTestAddItem(test, "chardev-remove", "{\"return\": {}}") < 0)
|
2019-06-11 03:01:08 +00:00
|
|
|
return -1;
|
2013-03-12 18:57:48 +00:00
|
|
|
|
|
|
|
if (qemuMonitorDetachCharDev(qemuMonitorTestGetMonitor(test),
|
|
|
|
"dummy_chrID") < 0)
|
2019-06-11 03:01:08 +00:00
|
|
|
return -1;
|
2013-03-12 18:57:48 +00:00
|
|
|
|
2019-06-11 03:01:08 +00:00
|
|
|
return 0;
|
2013-03-12 18:57:48 +00:00
|
|
|
}
|
|
|
|
|
2013-06-24 17:51:56 +00:00
|
|
|
/*
|
|
|
|
* This test will request to return a list of paths for "/". It should be
|
|
|
|
* a simple list of 1 real element that being the "machine". The following
|
|
|
|
* is the execution and expected return:
|
|
|
|
*
|
|
|
|
* {"execute":"qom-list", "arguments": { "path": "/"}}"
|
|
|
|
* {"return": [{"name": "machine", "type": "child<container>"}, \
|
|
|
|
* {"name": "type", "type": "string"}]}
|
|
|
|
*/
|
|
|
|
static int
|
qemumonitorjsontest: Validate more commands against schema
The DO_TEST() macro in qemumonitorjsontest.c was not passing the
schema through, which meant that we were not validating any of those
tests for correct usage according to the schema.
In the process of mechanically altering tests to pass the schema
through, use VIR_AUTOPTR on all of the affected test instances. The
next patch will do some further cleanups that it exposes.
Tested by using this hack, where the test mistakenly passed pre-patch,
but correctly diagnosed the garbage post-patch:
| diff --git i/src/qemu/qemu_monitor_json.c w/src/qemu/qemu_monitor_json.c
| index 53a7de8b77..86d8450814 100644
| --- i/src/qemu/qemu_monitor_json.c
| +++ w/src/qemu/qemu_monitor_json.c
| @@ -1532,7 +1532,8 @@ qemuMonitorJSONGetStatus(qemuMonitorPtr mon,
| if (reason)
| *reason = VIR_DOMAIN_PAUSED_UNKNOWN;
|
| - if (!(cmd = qemuMonitorJSONMakeCommand("query-status", NULL)))
| + if (!(cmd = qemuMonitorJSONMakeCommand("query-status",
| + "s:garbage", "foo", NULL)))
| return -1;
|
| if (qemuMonitorJSONCommand(mon, cmd, &reply) < 0)
Suggested-by: Peter Krempa <pkrempa@redhat.com>
Signed-off-by: Eric Blake <eblake@redhat.com>
Acked-by: Peter Krempa <pkrempa@redhat.com>
2019-06-12 01:59:11 +00:00
|
|
|
testQemuMonitorJSONGetListPaths(const void *opaque)
|
2013-06-24 17:51:56 +00:00
|
|
|
{
|
qemumonitorjsontest: Validate more commands against schema
The DO_TEST() macro in qemumonitorjsontest.c was not passing the
schema through, which meant that we were not validating any of those
tests for correct usage according to the schema.
In the process of mechanically altering tests to pass the schema
through, use VIR_AUTOPTR on all of the affected test instances. The
next patch will do some further cleanups that it exposes.
Tested by using this hack, where the test mistakenly passed pre-patch,
but correctly diagnosed the garbage post-patch:
| diff --git i/src/qemu/qemu_monitor_json.c w/src/qemu/qemu_monitor_json.c
| index 53a7de8b77..86d8450814 100644
| --- i/src/qemu/qemu_monitor_json.c
| +++ w/src/qemu/qemu_monitor_json.c
| @@ -1532,7 +1532,8 @@ qemuMonitorJSONGetStatus(qemuMonitorPtr mon,
| if (reason)
| *reason = VIR_DOMAIN_PAUSED_UNKNOWN;
|
| - if (!(cmd = qemuMonitorJSONMakeCommand("query-status", NULL)))
| + if (!(cmd = qemuMonitorJSONMakeCommand("query-status",
| + "s:garbage", "foo", NULL)))
| return -1;
|
| if (qemuMonitorJSONCommand(mon, cmd, &reply) < 0)
Suggested-by: Peter Krempa <pkrempa@redhat.com>
Signed-off-by: Eric Blake <eblake@redhat.com>
Acked-by: Peter Krempa <pkrempa@redhat.com>
2019-06-12 01:59:11 +00:00
|
|
|
const testGenericData *data = opaque;
|
2021-03-11 07:16:13 +00:00
|
|
|
virDomainXMLOption *xmlopt = data->xmlopt;
|
2013-06-24 17:51:56 +00:00
|
|
|
int ret = -1;
|
2021-03-11 07:16:13 +00:00
|
|
|
qemuMonitorJSONListPath **paths;
|
2013-06-24 17:51:56 +00:00
|
|
|
int npaths = 0;
|
|
|
|
size_t i;
|
2019-10-15 12:47:50 +00:00
|
|
|
g_autoptr(qemuMonitorTest) test = NULL;
|
2013-06-24 17:51:56 +00:00
|
|
|
|
qemumonitorjsontest: Validate more commands against schema
The DO_TEST() macro in qemumonitorjsontest.c was not passing the
schema through, which meant that we were not validating any of those
tests for correct usage according to the schema.
In the process of mechanically altering tests to pass the schema
through, use VIR_AUTOPTR on all of the affected test instances. The
next patch will do some further cleanups that it exposes.
Tested by using this hack, where the test mistakenly passed pre-patch,
but correctly diagnosed the garbage post-patch:
| diff --git i/src/qemu/qemu_monitor_json.c w/src/qemu/qemu_monitor_json.c
| index 53a7de8b77..86d8450814 100644
| --- i/src/qemu/qemu_monitor_json.c
| +++ w/src/qemu/qemu_monitor_json.c
| @@ -1532,7 +1532,8 @@ qemuMonitorJSONGetStatus(qemuMonitorPtr mon,
| if (reason)
| *reason = VIR_DOMAIN_PAUSED_UNKNOWN;
|
| - if (!(cmd = qemuMonitorJSONMakeCommand("query-status", NULL)))
| + if (!(cmd = qemuMonitorJSONMakeCommand("query-status",
| + "s:garbage", "foo", NULL)))
| return -1;
|
| if (qemuMonitorJSONCommand(mon, cmd, &reply) < 0)
Suggested-by: Peter Krempa <pkrempa@redhat.com>
Signed-off-by: Eric Blake <eblake@redhat.com>
Acked-by: Peter Krempa <pkrempa@redhat.com>
2019-06-12 01:59:11 +00:00
|
|
|
if (!(test = qemuMonitorTestNewSchema(xmlopt, data->schema)))
|
2013-06-24 17:51:56 +00:00
|
|
|
return -1;
|
|
|
|
|
|
|
|
if (qemuMonitorTestAddItem(test, "qom-list",
|
|
|
|
"{ "
|
|
|
|
" \"return\": [ "
|
|
|
|
" {\"name\": \"machine\", "
|
|
|
|
" \"type\": \"child<container>\"}, "
|
|
|
|
" {\"name\": \"type\", "
|
|
|
|
" \"type\": \"string\"} "
|
|
|
|
" ]"
|
|
|
|
"}") < 0)
|
|
|
|
goto cleanup;
|
|
|
|
|
|
|
|
/* present with path */
|
|
|
|
if ((npaths = qemuMonitorJSONGetObjectListPaths(
|
|
|
|
qemuMonitorTestGetMonitor(test),
|
|
|
|
"/",
|
|
|
|
&paths)) < 0)
|
|
|
|
goto cleanup;
|
|
|
|
|
|
|
|
if (npaths != 2) {
|
|
|
|
virReportError(VIR_ERR_INTERNAL_ERROR,
|
|
|
|
"npaths was %d, expected 1", npaths);
|
|
|
|
goto cleanup;
|
|
|
|
}
|
|
|
|
|
2017-11-03 12:09:47 +00:00
|
|
|
#define CHECK(i, wantname, wanttype) \
|
|
|
|
do { \
|
|
|
|
if (STRNEQ(paths[i]->name, (wantname))) { \
|
|
|
|
virReportError(VIR_ERR_INTERNAL_ERROR, \
|
|
|
|
"name was %s, expected %s", \
|
|
|
|
paths[i]->name, (wantname)); \
|
|
|
|
goto cleanup; \
|
|
|
|
} \
|
|
|
|
if (STRNEQ_NULLABLE(paths[i]->type, (wanttype))) { \
|
|
|
|
virReportError(VIR_ERR_INTERNAL_ERROR, \
|
|
|
|
"type was %s, expected %s", \
|
|
|
|
NULLSTR(paths[i]->type), (wanttype)); \
|
|
|
|
goto cleanup; \
|
|
|
|
} \
|
2013-06-24 17:51:56 +00:00
|
|
|
} while (0)
|
|
|
|
|
|
|
|
CHECK(0, "machine", "child<container>");
|
|
|
|
|
|
|
|
#undef CHECK
|
|
|
|
|
|
|
|
ret = 0;
|
|
|
|
|
2014-03-25 06:53:44 +00:00
|
|
|
cleanup:
|
2013-06-24 17:51:56 +00:00
|
|
|
for (i = 0; i < npaths; i++)
|
|
|
|
qemuMonitorJSONListPathFree(paths[i]);
|
|
|
|
VIR_FREE(paths);
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2013-07-03 18:15:07 +00:00
|
|
|
/*
|
|
|
|
* This test will use a path to /machine/i440fx which should exist in order
|
|
|
|
* to ensure that the qom-get property fetch works properly. The following
|
|
|
|
* is the execution and expected return:
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* { "execute": "qom-get","arguments": \
|
|
|
|
* { "path": "/machine/i440fx","property": "realized"}}
|
|
|
|
* {"return": true}
|
|
|
|
*/
|
|
|
|
static int
|
qemumonitorjsontest: Validate more commands against schema
The DO_TEST() macro in qemumonitorjsontest.c was not passing the
schema through, which meant that we were not validating any of those
tests for correct usage according to the schema.
In the process of mechanically altering tests to pass the schema
through, use VIR_AUTOPTR on all of the affected test instances. The
next patch will do some further cleanups that it exposes.
Tested by using this hack, where the test mistakenly passed pre-patch,
but correctly diagnosed the garbage post-patch:
| diff --git i/src/qemu/qemu_monitor_json.c w/src/qemu/qemu_monitor_json.c
| index 53a7de8b77..86d8450814 100644
| --- i/src/qemu/qemu_monitor_json.c
| +++ w/src/qemu/qemu_monitor_json.c
| @@ -1532,7 +1532,8 @@ qemuMonitorJSONGetStatus(qemuMonitorPtr mon,
| if (reason)
| *reason = VIR_DOMAIN_PAUSED_UNKNOWN;
|
| - if (!(cmd = qemuMonitorJSONMakeCommand("query-status", NULL)))
| + if (!(cmd = qemuMonitorJSONMakeCommand("query-status",
| + "s:garbage", "foo", NULL)))
| return -1;
|
| if (qemuMonitorJSONCommand(mon, cmd, &reply) < 0)
Suggested-by: Peter Krempa <pkrempa@redhat.com>
Signed-off-by: Eric Blake <eblake@redhat.com>
Acked-by: Peter Krempa <pkrempa@redhat.com>
2019-06-12 01:59:11 +00:00
|
|
|
testQemuMonitorJSONGetObjectProperty(const void *opaque)
|
2013-07-03 18:15:07 +00:00
|
|
|
{
|
qemumonitorjsontest: Validate more commands against schema
The DO_TEST() macro in qemumonitorjsontest.c was not passing the
schema through, which meant that we were not validating any of those
tests for correct usage according to the schema.
In the process of mechanically altering tests to pass the schema
through, use VIR_AUTOPTR on all of the affected test instances. The
next patch will do some further cleanups that it exposes.
Tested by using this hack, where the test mistakenly passed pre-patch,
but correctly diagnosed the garbage post-patch:
| diff --git i/src/qemu/qemu_monitor_json.c w/src/qemu/qemu_monitor_json.c
| index 53a7de8b77..86d8450814 100644
| --- i/src/qemu/qemu_monitor_json.c
| +++ w/src/qemu/qemu_monitor_json.c
| @@ -1532,7 +1532,8 @@ qemuMonitorJSONGetStatus(qemuMonitorPtr mon,
| if (reason)
| *reason = VIR_DOMAIN_PAUSED_UNKNOWN;
|
| - if (!(cmd = qemuMonitorJSONMakeCommand("query-status", NULL)))
| + if (!(cmd = qemuMonitorJSONMakeCommand("query-status",
| + "s:garbage", "foo", NULL)))
| return -1;
|
| if (qemuMonitorJSONCommand(mon, cmd, &reply) < 0)
Suggested-by: Peter Krempa <pkrempa@redhat.com>
Signed-off-by: Eric Blake <eblake@redhat.com>
Acked-by: Peter Krempa <pkrempa@redhat.com>
2019-06-12 01:59:11 +00:00
|
|
|
const testGenericData *data = opaque;
|
2021-03-11 07:16:13 +00:00
|
|
|
virDomainXMLOption *xmlopt = data->xmlopt;
|
2023-08-02 08:09:52 +00:00
|
|
|
qemuMonitorJSONObjectProperty prop = { 0 };
|
2019-10-15 12:47:50 +00:00
|
|
|
g_autoptr(qemuMonitorTest) test = NULL;
|
2013-07-03 18:15:07 +00:00
|
|
|
|
qemumonitorjsontest: Validate more commands against schema
The DO_TEST() macro in qemumonitorjsontest.c was not passing the
schema through, which meant that we were not validating any of those
tests for correct usage according to the schema.
In the process of mechanically altering tests to pass the schema
through, use VIR_AUTOPTR on all of the affected test instances. The
next patch will do some further cleanups that it exposes.
Tested by using this hack, where the test mistakenly passed pre-patch,
but correctly diagnosed the garbage post-patch:
| diff --git i/src/qemu/qemu_monitor_json.c w/src/qemu/qemu_monitor_json.c
| index 53a7de8b77..86d8450814 100644
| --- i/src/qemu/qemu_monitor_json.c
| +++ w/src/qemu/qemu_monitor_json.c
| @@ -1532,7 +1532,8 @@ qemuMonitorJSONGetStatus(qemuMonitorPtr mon,
| if (reason)
| *reason = VIR_DOMAIN_PAUSED_UNKNOWN;
|
| - if (!(cmd = qemuMonitorJSONMakeCommand("query-status", NULL)))
| + if (!(cmd = qemuMonitorJSONMakeCommand("query-status",
| + "s:garbage", "foo", NULL)))
| return -1;
|
| if (qemuMonitorJSONCommand(mon, cmd, &reply) < 0)
Suggested-by: Peter Krempa <pkrempa@redhat.com>
Signed-off-by: Eric Blake <eblake@redhat.com>
Acked-by: Peter Krempa <pkrempa@redhat.com>
2019-06-12 01:59:11 +00:00
|
|
|
if (!(test = qemuMonitorTestNewSchema(xmlopt, data->schema)))
|
2013-07-03 18:15:07 +00:00
|
|
|
return -1;
|
|
|
|
|
|
|
|
if (qemuMonitorTestAddItem(test, "qom-get",
|
|
|
|
"{ \"return\": true }") < 0)
|
2019-06-11 03:01:08 +00:00
|
|
|
return -1;
|
2013-07-03 18:15:07 +00:00
|
|
|
|
|
|
|
/* Present with path and property */
|
|
|
|
prop.type = QEMU_MONITOR_OBJECT_PROPERTY_BOOLEAN;
|
|
|
|
if (qemuMonitorJSONGetObjectProperty(qemuMonitorTestGetMonitor(test),
|
|
|
|
"/machine/i440fx",
|
|
|
|
"realized",
|
|
|
|
&prop) < 0)
|
2019-06-11 03:01:08 +00:00
|
|
|
return -1;
|
2013-07-03 18:15:07 +00:00
|
|
|
|
|
|
|
if (!prop.val.b) {
|
|
|
|
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
|
|
|
"expected true, but false returned");
|
2019-06-11 03:01:08 +00:00
|
|
|
return -1;
|
2013-07-03 18:15:07 +00:00
|
|
|
}
|
|
|
|
|
2019-06-11 03:01:08 +00:00
|
|
|
return 0;
|
2013-07-03 18:15:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2013-07-03 18:42:40 +00:00
|
|
|
/*
|
|
|
|
* This test will use a path to /machine/i440fx which should exist in order
|
|
|
|
* to ensure that the qom-set property set works properly. The test will
|
|
|
|
* set a true property to true just as a proof of concept. Setting it to
|
|
|
|
* false is not a good idea...
|
|
|
|
*/
|
|
|
|
static int
|
qemumonitorjsontest: Validate more commands against schema
The DO_TEST() macro in qemumonitorjsontest.c was not passing the
schema through, which meant that we were not validating any of those
tests for correct usage according to the schema.
In the process of mechanically altering tests to pass the schema
through, use VIR_AUTOPTR on all of the affected test instances. The
next patch will do some further cleanups that it exposes.
Tested by using this hack, where the test mistakenly passed pre-patch,
but correctly diagnosed the garbage post-patch:
| diff --git i/src/qemu/qemu_monitor_json.c w/src/qemu/qemu_monitor_json.c
| index 53a7de8b77..86d8450814 100644
| --- i/src/qemu/qemu_monitor_json.c
| +++ w/src/qemu/qemu_monitor_json.c
| @@ -1532,7 +1532,8 @@ qemuMonitorJSONGetStatus(qemuMonitorPtr mon,
| if (reason)
| *reason = VIR_DOMAIN_PAUSED_UNKNOWN;
|
| - if (!(cmd = qemuMonitorJSONMakeCommand("query-status", NULL)))
| + if (!(cmd = qemuMonitorJSONMakeCommand("query-status",
| + "s:garbage", "foo", NULL)))
| return -1;
|
| if (qemuMonitorJSONCommand(mon, cmd, &reply) < 0)
Suggested-by: Peter Krempa <pkrempa@redhat.com>
Signed-off-by: Eric Blake <eblake@redhat.com>
Acked-by: Peter Krempa <pkrempa@redhat.com>
2019-06-12 01:59:11 +00:00
|
|
|
testQemuMonitorJSONSetObjectProperty(const void *opaque)
|
2013-07-03 18:42:40 +00:00
|
|
|
{
|
qemumonitorjsontest: Validate more commands against schema
The DO_TEST() macro in qemumonitorjsontest.c was not passing the
schema through, which meant that we were not validating any of those
tests for correct usage according to the schema.
In the process of mechanically altering tests to pass the schema
through, use VIR_AUTOPTR on all of the affected test instances. The
next patch will do some further cleanups that it exposes.
Tested by using this hack, where the test mistakenly passed pre-patch,
but correctly diagnosed the garbage post-patch:
| diff --git i/src/qemu/qemu_monitor_json.c w/src/qemu/qemu_monitor_json.c
| index 53a7de8b77..86d8450814 100644
| --- i/src/qemu/qemu_monitor_json.c
| +++ w/src/qemu/qemu_monitor_json.c
| @@ -1532,7 +1532,8 @@ qemuMonitorJSONGetStatus(qemuMonitorPtr mon,
| if (reason)
| *reason = VIR_DOMAIN_PAUSED_UNKNOWN;
|
| - if (!(cmd = qemuMonitorJSONMakeCommand("query-status", NULL)))
| + if (!(cmd = qemuMonitorJSONMakeCommand("query-status",
| + "s:garbage", "foo", NULL)))
| return -1;
|
| if (qemuMonitorJSONCommand(mon, cmd, &reply) < 0)
Suggested-by: Peter Krempa <pkrempa@redhat.com>
Signed-off-by: Eric Blake <eblake@redhat.com>
Acked-by: Peter Krempa <pkrempa@redhat.com>
2019-06-12 01:59:11 +00:00
|
|
|
const testGenericData *data = opaque;
|
2021-03-11 07:16:13 +00:00
|
|
|
virDomainXMLOption *xmlopt = data->xmlopt;
|
2023-08-02 08:09:52 +00:00
|
|
|
qemuMonitorJSONObjectProperty prop = { 0 };
|
2019-10-15 12:47:50 +00:00
|
|
|
g_autoptr(qemuMonitorTest) test = NULL;
|
2013-07-03 18:42:40 +00:00
|
|
|
|
qemumonitorjsontest: Validate more commands against schema
The DO_TEST() macro in qemumonitorjsontest.c was not passing the
schema through, which meant that we were not validating any of those
tests for correct usage according to the schema.
In the process of mechanically altering tests to pass the schema
through, use VIR_AUTOPTR on all of the affected test instances. The
next patch will do some further cleanups that it exposes.
Tested by using this hack, where the test mistakenly passed pre-patch,
but correctly diagnosed the garbage post-patch:
| diff --git i/src/qemu/qemu_monitor_json.c w/src/qemu/qemu_monitor_json.c
| index 53a7de8b77..86d8450814 100644
| --- i/src/qemu/qemu_monitor_json.c
| +++ w/src/qemu/qemu_monitor_json.c
| @@ -1532,7 +1532,8 @@ qemuMonitorJSONGetStatus(qemuMonitorPtr mon,
| if (reason)
| *reason = VIR_DOMAIN_PAUSED_UNKNOWN;
|
| - if (!(cmd = qemuMonitorJSONMakeCommand("query-status", NULL)))
| + if (!(cmd = qemuMonitorJSONMakeCommand("query-status",
| + "s:garbage", "foo", NULL)))
| return -1;
|
| if (qemuMonitorJSONCommand(mon, cmd, &reply) < 0)
Suggested-by: Peter Krempa <pkrempa@redhat.com>
Signed-off-by: Eric Blake <eblake@redhat.com>
Acked-by: Peter Krempa <pkrempa@redhat.com>
2019-06-12 01:59:11 +00:00
|
|
|
if (!(test = qemuMonitorTestNewSchema(xmlopt, data->schema)))
|
2013-07-03 18:42:40 +00:00
|
|
|
return -1;
|
|
|
|
|
|
|
|
if (qemuMonitorTestAddItem(test, "qom-set",
|
|
|
|
"{ \"return\": {} }") < 0)
|
2019-06-11 03:01:08 +00:00
|
|
|
return -1;
|
2013-07-03 18:42:40 +00:00
|
|
|
if (qemuMonitorTestAddItem(test, "qom-get",
|
|
|
|
"{ \"return\": true }") < 0)
|
2019-06-11 03:01:08 +00:00
|
|
|
return -1;
|
2013-07-03 18:42:40 +00:00
|
|
|
|
|
|
|
/* Let's attempt the setting */
|
|
|
|
prop.type = QEMU_MONITOR_OBJECT_PROPERTY_BOOLEAN;
|
|
|
|
prop.val.b = true;
|
|
|
|
if (qemuMonitorJSONSetObjectProperty(qemuMonitorTestGetMonitor(test),
|
|
|
|
"/machine/i440fx",
|
|
|
|
"realized",
|
|
|
|
&prop) < 0)
|
2019-06-11 03:01:08 +00:00
|
|
|
return -1;
|
2013-07-03 18:42:40 +00:00
|
|
|
|
|
|
|
/* To make sure it worked, fetch the property - if this succeeds then
|
|
|
|
* we didn't hose things
|
|
|
|
*/
|
|
|
|
memset(&prop, 0, sizeof(qemuMonitorJSONObjectProperty));
|
|
|
|
prop.type = QEMU_MONITOR_OBJECT_PROPERTY_BOOLEAN;
|
|
|
|
if (qemuMonitorJSONGetObjectProperty(qemuMonitorTestGetMonitor(test),
|
|
|
|
"/machine/i440fx",
|
|
|
|
"realized",
|
|
|
|
&prop) < 0)
|
2019-06-11 03:01:08 +00:00
|
|
|
return -1;
|
2013-07-03 18:42:40 +00:00
|
|
|
|
|
|
|
if (!prop.val.b) {
|
|
|
|
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
|
|
|
"expected true, but false returned");
|
2019-06-11 03:01:08 +00:00
|
|
|
return -1;
|
2013-07-03 18:42:40 +00:00
|
|
|
}
|
|
|
|
|
2019-06-11 03:01:08 +00:00
|
|
|
return 0;
|
2013-07-03 18:42:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2013-07-19 13:01:38 +00:00
|
|
|
static int
|
qemumonitorjsontest: Validate more commands against schema
The DO_TEST() macro in qemumonitorjsontest.c was not passing the
schema through, which meant that we were not validating any of those
tests for correct usage according to the schema.
In the process of mechanically altering tests to pass the schema
through, use VIR_AUTOPTR on all of the affected test instances. The
next patch will do some further cleanups that it exposes.
Tested by using this hack, where the test mistakenly passed pre-patch,
but correctly diagnosed the garbage post-patch:
| diff --git i/src/qemu/qemu_monitor_json.c w/src/qemu/qemu_monitor_json.c
| index 53a7de8b77..86d8450814 100644
| --- i/src/qemu/qemu_monitor_json.c
| +++ w/src/qemu/qemu_monitor_json.c
| @@ -1532,7 +1532,8 @@ qemuMonitorJSONGetStatus(qemuMonitorPtr mon,
| if (reason)
| *reason = VIR_DOMAIN_PAUSED_UNKNOWN;
|
| - if (!(cmd = qemuMonitorJSONMakeCommand("query-status", NULL)))
| + if (!(cmd = qemuMonitorJSONMakeCommand("query-status",
| + "s:garbage", "foo", NULL)))
| return -1;
|
| if (qemuMonitorJSONCommand(mon, cmd, &reply) < 0)
Suggested-by: Peter Krempa <pkrempa@redhat.com>
Signed-off-by: Eric Blake <eblake@redhat.com>
Acked-by: Peter Krempa <pkrempa@redhat.com>
2019-06-12 01:59:11 +00:00
|
|
|
testQemuMonitorJSONGetDeviceAliases(const void *opaque)
|
2013-07-19 13:01:38 +00:00
|
|
|
{
|
qemumonitorjsontest: Validate more commands against schema
The DO_TEST() macro in qemumonitorjsontest.c was not passing the
schema through, which meant that we were not validating any of those
tests for correct usage according to the schema.
In the process of mechanically altering tests to pass the schema
through, use VIR_AUTOPTR on all of the affected test instances. The
next patch will do some further cleanups that it exposes.
Tested by using this hack, where the test mistakenly passed pre-patch,
but correctly diagnosed the garbage post-patch:
| diff --git i/src/qemu/qemu_monitor_json.c w/src/qemu/qemu_monitor_json.c
| index 53a7de8b77..86d8450814 100644
| --- i/src/qemu/qemu_monitor_json.c
| +++ w/src/qemu/qemu_monitor_json.c
| @@ -1532,7 +1532,8 @@ qemuMonitorJSONGetStatus(qemuMonitorPtr mon,
| if (reason)
| *reason = VIR_DOMAIN_PAUSED_UNKNOWN;
|
| - if (!(cmd = qemuMonitorJSONMakeCommand("query-status", NULL)))
| + if (!(cmd = qemuMonitorJSONMakeCommand("query-status",
| + "s:garbage", "foo", NULL)))
| return -1;
|
| if (qemuMonitorJSONCommand(mon, cmd, &reply) < 0)
Suggested-by: Peter Krempa <pkrempa@redhat.com>
Signed-off-by: Eric Blake <eblake@redhat.com>
Acked-by: Peter Krempa <pkrempa@redhat.com>
2019-06-12 01:59:11 +00:00
|
|
|
const testGenericData *data = opaque;
|
2021-03-11 07:16:13 +00:00
|
|
|
virDomainXMLOption *xmlopt = data->xmlopt;
|
2013-07-19 13:01:38 +00:00
|
|
|
int ret = -1;
|
2021-11-01 09:34:10 +00:00
|
|
|
g_auto(GStrv) aliases = NULL;
|
2016-08-16 10:20:56 +00:00
|
|
|
const char **alias;
|
2013-07-19 13:01:38 +00:00
|
|
|
const char *expected[] = {
|
|
|
|
"virtio-disk25", "video0", "serial0", "ide0-0-0", "usb", NULL };
|
2019-10-15 12:47:50 +00:00
|
|
|
g_autoptr(qemuMonitorTest) test = NULL;
|
2013-07-19 13:01:38 +00:00
|
|
|
|
qemumonitorjsontest: Validate more commands against schema
The DO_TEST() macro in qemumonitorjsontest.c was not passing the
schema through, which meant that we were not validating any of those
tests for correct usage according to the schema.
In the process of mechanically altering tests to pass the schema
through, use VIR_AUTOPTR on all of the affected test instances. The
next patch will do some further cleanups that it exposes.
Tested by using this hack, where the test mistakenly passed pre-patch,
but correctly diagnosed the garbage post-patch:
| diff --git i/src/qemu/qemu_monitor_json.c w/src/qemu/qemu_monitor_json.c
| index 53a7de8b77..86d8450814 100644
| --- i/src/qemu/qemu_monitor_json.c
| +++ w/src/qemu/qemu_monitor_json.c
| @@ -1532,7 +1532,8 @@ qemuMonitorJSONGetStatus(qemuMonitorPtr mon,
| if (reason)
| *reason = VIR_DOMAIN_PAUSED_UNKNOWN;
|
| - if (!(cmd = qemuMonitorJSONMakeCommand("query-status", NULL)))
| + if (!(cmd = qemuMonitorJSONMakeCommand("query-status",
| + "s:garbage", "foo", NULL)))
| return -1;
|
| if (qemuMonitorJSONCommand(mon, cmd, &reply) < 0)
Suggested-by: Peter Krempa <pkrempa@redhat.com>
Signed-off-by: Eric Blake <eblake@redhat.com>
Acked-by: Peter Krempa <pkrempa@redhat.com>
2019-06-12 01:59:11 +00:00
|
|
|
if (!(test = qemuMonitorTestNewSchema(xmlopt, data->schema)))
|
2013-07-19 13:01:38 +00:00
|
|
|
return -1;
|
|
|
|
|
|
|
|
if (qemuMonitorTestAddItem(test,
|
|
|
|
"qom-list",
|
|
|
|
"{\"return\": ["
|
|
|
|
" {\"name\": \"virtio-disk25\","
|
|
|
|
" \"type\": \"child<virtio-blk-pci>\"},"
|
|
|
|
" {\"name\": \"video0\","
|
|
|
|
" \"type\": \"child<VGA>\"},"
|
|
|
|
" {\"name\": \"serial0\","
|
|
|
|
" \"type\": \"child<isa-serial>\"},"
|
|
|
|
" {\"name\": \"ide0-0-0\","
|
|
|
|
" \"type\": \"child<ide-cd>\"},"
|
|
|
|
" {\"name\": \"usb\","
|
|
|
|
" \"type\": \"child<piix3-usb-uhci>\"},"
|
|
|
|
" {\"name\": \"type\", \"type\": \"string\"}"
|
|
|
|
"]}") < 0)
|
2021-11-01 09:20:57 +00:00
|
|
|
return -1;
|
2013-07-19 13:01:38 +00:00
|
|
|
|
|
|
|
if (qemuMonitorJSONGetDeviceAliases(qemuMonitorTestGetMonitor(test),
|
|
|
|
&aliases) < 0)
|
2021-11-01 09:20:57 +00:00
|
|
|
return -1;
|
2013-07-19 13:01:38 +00:00
|
|
|
|
|
|
|
if (!aliases) {
|
|
|
|
virReportError(VIR_ERR_INTERNAL_ERROR, "%s", "no aliases returned");
|
2021-11-01 09:20:57 +00:00
|
|
|
return -1;
|
2013-07-19 13:01:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
ret = 0;
|
2016-08-16 10:20:56 +00:00
|
|
|
for (alias = (const char **) aliases; *alias; alias++) {
|
2021-02-03 17:39:47 +00:00
|
|
|
if (!g_strv_contains(expected, *alias)) {
|
2013-07-19 13:01:38 +00:00
|
|
|
fprintf(stderr, "got unexpected device alias '%s'\n", *alias);
|
|
|
|
ret = -1;
|
|
|
|
}
|
|
|
|
}
|
2016-08-16 10:20:56 +00:00
|
|
|
for (alias = expected; *alias; alias++) {
|
2021-02-03 17:39:47 +00:00
|
|
|
if (!g_strv_contains((const char **) aliases, *alias)) {
|
2013-07-19 13:01:38 +00:00
|
|
|
fprintf(stderr, "missing expected alias '%s'\n", *alias);
|
|
|
|
ret = -1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2013-09-18 13:11:06 +00:00
|
|
|
static int
|
qemumonitorjsontest: Validate more commands against schema
The DO_TEST() macro in qemumonitorjsontest.c was not passing the
schema through, which meant that we were not validating any of those
tests for correct usage according to the schema.
In the process of mechanically altering tests to pass the schema
through, use VIR_AUTOPTR on all of the affected test instances. The
next patch will do some further cleanups that it exposes.
Tested by using this hack, where the test mistakenly passed pre-patch,
but correctly diagnosed the garbage post-patch:
| diff --git i/src/qemu/qemu_monitor_json.c w/src/qemu/qemu_monitor_json.c
| index 53a7de8b77..86d8450814 100644
| --- i/src/qemu/qemu_monitor_json.c
| +++ w/src/qemu/qemu_monitor_json.c
| @@ -1532,7 +1532,8 @@ qemuMonitorJSONGetStatus(qemuMonitorPtr mon,
| if (reason)
| *reason = VIR_DOMAIN_PAUSED_UNKNOWN;
|
| - if (!(cmd = qemuMonitorJSONMakeCommand("query-status", NULL)))
| + if (!(cmd = qemuMonitorJSONMakeCommand("query-status",
| + "s:garbage", "foo", NULL)))
| return -1;
|
| if (qemuMonitorJSONCommand(mon, cmd, &reply) < 0)
Suggested-by: Peter Krempa <pkrempa@redhat.com>
Signed-off-by: Eric Blake <eblake@redhat.com>
Acked-by: Peter Krempa <pkrempa@redhat.com>
2019-06-12 01:59:11 +00:00
|
|
|
testQemuMonitorJSONCPU(const void *opaque)
|
2013-09-18 13:11:06 +00:00
|
|
|
{
|
qemumonitorjsontest: Validate more commands against schema
The DO_TEST() macro in qemumonitorjsontest.c was not passing the
schema through, which meant that we were not validating any of those
tests for correct usage according to the schema.
In the process of mechanically altering tests to pass the schema
through, use VIR_AUTOPTR on all of the affected test instances. The
next patch will do some further cleanups that it exposes.
Tested by using this hack, where the test mistakenly passed pre-patch,
but correctly diagnosed the garbage post-patch:
| diff --git i/src/qemu/qemu_monitor_json.c w/src/qemu/qemu_monitor_json.c
| index 53a7de8b77..86d8450814 100644
| --- i/src/qemu/qemu_monitor_json.c
| +++ w/src/qemu/qemu_monitor_json.c
| @@ -1532,7 +1532,8 @@ qemuMonitorJSONGetStatus(qemuMonitorPtr mon,
| if (reason)
| *reason = VIR_DOMAIN_PAUSED_UNKNOWN;
|
| - if (!(cmd = qemuMonitorJSONMakeCommand("query-status", NULL)))
| + if (!(cmd = qemuMonitorJSONMakeCommand("query-status",
| + "s:garbage", "foo", NULL)))
| return -1;
|
| if (qemuMonitorJSONCommand(mon, cmd, &reply) < 0)
Suggested-by: Peter Krempa <pkrempa@redhat.com>
Signed-off-by: Eric Blake <eblake@redhat.com>
Acked-by: Peter Krempa <pkrempa@redhat.com>
2019-06-12 01:59:11 +00:00
|
|
|
const testGenericData *data = opaque;
|
2021-03-11 07:16:13 +00:00
|
|
|
virDomainXMLOption *xmlopt = data->xmlopt;
|
2013-09-18 13:11:06 +00:00
|
|
|
bool running = false;
|
|
|
|
virDomainPausedReason reason = 0;
|
2019-10-15 12:47:50 +00:00
|
|
|
g_autoptr(qemuMonitorTest) test = NULL;
|
2013-09-18 13:11:06 +00:00
|
|
|
|
qemumonitorjsontest: Validate more commands against schema
The DO_TEST() macro in qemumonitorjsontest.c was not passing the
schema through, which meant that we were not validating any of those
tests for correct usage according to the schema.
In the process of mechanically altering tests to pass the schema
through, use VIR_AUTOPTR on all of the affected test instances. The
next patch will do some further cleanups that it exposes.
Tested by using this hack, where the test mistakenly passed pre-patch,
but correctly diagnosed the garbage post-patch:
| diff --git i/src/qemu/qemu_monitor_json.c w/src/qemu/qemu_monitor_json.c
| index 53a7de8b77..86d8450814 100644
| --- i/src/qemu/qemu_monitor_json.c
| +++ w/src/qemu/qemu_monitor_json.c
| @@ -1532,7 +1532,8 @@ qemuMonitorJSONGetStatus(qemuMonitorPtr mon,
| if (reason)
| *reason = VIR_DOMAIN_PAUSED_UNKNOWN;
|
| - if (!(cmd = qemuMonitorJSONMakeCommand("query-status", NULL)))
| + if (!(cmd = qemuMonitorJSONMakeCommand("query-status",
| + "s:garbage", "foo", NULL)))
| return -1;
|
| if (qemuMonitorJSONCommand(mon, cmd, &reply) < 0)
Suggested-by: Peter Krempa <pkrempa@redhat.com>
Signed-off-by: Eric Blake <eblake@redhat.com>
Acked-by: Peter Krempa <pkrempa@redhat.com>
2019-06-12 01:59:11 +00:00
|
|
|
if (!(test = qemuMonitorTestNewSchema(xmlopt, data->schema)))
|
2013-09-20 11:02:43 +00:00
|
|
|
return -1;
|
|
|
|
|
2013-09-18 13:11:06 +00:00
|
|
|
if (qemuMonitorTestAddItem(test, "stop", "{\"return\": {}}") < 0 ||
|
|
|
|
qemuMonitorTestAddItem(test, "query-status",
|
|
|
|
"{\"return\": {"
|
|
|
|
" \"status\": \"paused\","
|
|
|
|
" \"singlestep\": false,"
|
|
|
|
" \"running\": false}}") < 0 ||
|
|
|
|
qemuMonitorTestAddItem(test, "cont", "{\"return\": {}}") < 0 ||
|
|
|
|
qemuMonitorTestAddItem(test, "query-status",
|
|
|
|
"{\"return\": {"
|
|
|
|
" \"status\": \"running\","
|
|
|
|
" \"singlestep\": false,"
|
|
|
|
" \"running\": true}}") < 0)
|
2019-06-11 03:01:08 +00:00
|
|
|
return -1;
|
2013-09-18 13:11:06 +00:00
|
|
|
|
|
|
|
if (qemuMonitorJSONStopCPUs(qemuMonitorTestGetMonitor(test)) < 0)
|
2019-06-11 03:01:08 +00:00
|
|
|
return -1;
|
2013-09-18 13:11:06 +00:00
|
|
|
|
|
|
|
if (qemuMonitorGetStatus(qemuMonitorTestGetMonitor(test),
|
|
|
|
&running, &reason) < 0)
|
2019-06-11 03:01:08 +00:00
|
|
|
return -1;
|
2013-09-18 13:11:06 +00:00
|
|
|
|
|
|
|
if (running) {
|
|
|
|
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
|
|
|
"Running was not false");
|
2019-06-11 03:01:08 +00:00
|
|
|
return -1;
|
2013-09-18 13:11:06 +00:00
|
|
|
}
|
|
|
|
|
2018-02-09 15:40:51 +00:00
|
|
|
if (qemuMonitorJSONStartCPUs(qemuMonitorTestGetMonitor(test)) < 0)
|
2019-06-11 03:01:08 +00:00
|
|
|
return -1;
|
2013-09-18 13:11:06 +00:00
|
|
|
|
|
|
|
if (qemuMonitorGetStatus(qemuMonitorTestGetMonitor(test),
|
|
|
|
&running, &reason) < 0)
|
2019-06-11 03:01:08 +00:00
|
|
|
return -1;
|
2013-09-18 13:11:06 +00:00
|
|
|
|
|
|
|
if (!running) {
|
|
|
|
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
|
|
|
"Running was not true");
|
2019-06-11 03:01:08 +00:00
|
|
|
return -1;
|
2013-09-18 13:11:06 +00:00
|
|
|
}
|
|
|
|
|
2019-06-11 03:01:08 +00:00
|
|
|
return 0;
|
2013-09-18 13:11:06 +00:00
|
|
|
}
|
2013-07-19 13:01:38 +00:00
|
|
|
|
2013-09-18 15:28:31 +00:00
|
|
|
static int
|
|
|
|
testQemuMonitorJSONSimpleFunc(const void *opaque)
|
|
|
|
{
|
2021-03-11 07:16:13 +00:00
|
|
|
testQemuMonitorJSONSimpleFuncData *data =
|
|
|
|
(testQemuMonitorJSONSimpleFuncData *) opaque;
|
|
|
|
virDomainXMLOption *xmlopt = data->xmlopt;
|
2013-09-18 15:28:31 +00:00
|
|
|
const char *reply = data->reply;
|
2019-10-15 12:47:50 +00:00
|
|
|
g_autoptr(qemuMonitorTest) test = NULL;
|
2013-09-18 15:28:31 +00:00
|
|
|
|
2019-06-11 03:01:08 +00:00
|
|
|
if (!(test = qemuMonitorTestNewSchema(xmlopt, data->schema)))
|
2013-09-20 11:02:43 +00:00
|
|
|
return -1;
|
|
|
|
|
2013-09-18 15:28:31 +00:00
|
|
|
if (!reply)
|
|
|
|
reply = "{\"return\":{}}";
|
|
|
|
|
|
|
|
if (qemuMonitorTestAddItem(test, data->cmd, reply) < 0)
|
2019-06-11 03:01:08 +00:00
|
|
|
return -1;
|
2013-09-18 15:28:31 +00:00
|
|
|
|
|
|
|
if (data->func(qemuMonitorTestGetMonitor(test)) < 0)
|
2019-06-11 03:01:08 +00:00
|
|
|
return -1;
|
2013-09-18 15:28:31 +00:00
|
|
|
|
2019-06-11 03:01:08 +00:00
|
|
|
return 0;
|
2013-09-18 15:28:31 +00:00
|
|
|
}
|
|
|
|
|
2017-11-03 12:09:47 +00:00
|
|
|
#define GEN_TEST_FUNC(funcName, ...) \
|
|
|
|
static int \
|
|
|
|
testQemuMonitorJSON ## funcName(const void *opaque) \
|
|
|
|
{ \
|
|
|
|
const testQemuMonitorJSONSimpleFuncData *data = opaque; \
|
2021-03-11 07:16:13 +00:00
|
|
|
virDomainXMLOption *xmlopt = data->xmlopt; \
|
2017-11-03 12:09:47 +00:00
|
|
|
const char *reply = data->reply; \
|
2019-10-15 12:47:50 +00:00
|
|
|
g_autoptr(qemuMonitorTest) test = NULL; \
|
2017-11-03 12:09:47 +00:00
|
|
|
\
|
2019-06-11 03:01:08 +00:00
|
|
|
if (!(test = qemuMonitorTestNewSchema(xmlopt, data->schema))) \
|
2017-11-03 12:09:47 +00:00
|
|
|
return -1; \
|
2020-04-29 17:41:38 +00:00
|
|
|
\
|
|
|
|
if (data->allowDeprecated) \
|
|
|
|
qemuMonitorTestSkipDeprecatedValidation(test, data->allowRemoved); \
|
2017-11-03 12:09:47 +00:00
|
|
|
\
|
|
|
|
if (!reply) \
|
|
|
|
reply = "{\"return\":{}}"; \
|
|
|
|
\
|
|
|
|
if (qemuMonitorTestAddItem(test, data->cmd, reply) < 0) \
|
2019-06-11 03:01:08 +00:00
|
|
|
return -1; \
|
2017-11-03 12:09:47 +00:00
|
|
|
\
|
|
|
|
if (funcName(qemuMonitorTestGetMonitor(test), __VA_ARGS__) < 0) \
|
2019-06-11 03:01:08 +00:00
|
|
|
return -1; \
|
2017-11-03 12:09:47 +00:00
|
|
|
\
|
2019-06-11 03:01:08 +00:00
|
|
|
return 0; \
|
2013-10-01 14:23:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
GEN_TEST_FUNC(qemuMonitorJSONSetLink, "vnet0", VIR_DOMAIN_NET_INTERFACE_LINK_STATE_DOWN)
|
2018-08-07 07:31:04 +00:00
|
|
|
GEN_TEST_FUNC(qemuMonitorJSONBlockResize, "vda", "asdf", 123456)
|
2013-10-01 14:23:50 +00:00
|
|
|
GEN_TEST_FUNC(qemuMonitorJSONSetPassword, "spice", "secret_password", "disconnect")
|
|
|
|
GEN_TEST_FUNC(qemuMonitorJSONExpirePassword, "spice", "123456")
|
|
|
|
GEN_TEST_FUNC(qemuMonitorJSONSetBalloon, 1024)
|
|
|
|
GEN_TEST_FUNC(qemuMonitorJSONSaveVirtualMemory, 0, 1024, "/foo/bar")
|
|
|
|
GEN_TEST_FUNC(qemuMonitorJSONSavePhysicalMemory, 0, 1024, "/foo/bar")
|
2022-09-08 11:04:54 +00:00
|
|
|
GEN_TEST_FUNC(qemuMonitorJSONMigrate, 0, "tcp:localhost:12345")
|
2022-05-10 13:20:25 +00:00
|
|
|
GEN_TEST_FUNC(qemuMonitorJSONMigrateRecover, "tcp://destination.host:54321");
|
2018-03-22 17:39:32 +00:00
|
|
|
GEN_TEST_FUNC(qemuMonitorJSONDump, "dummy_protocol", "elf",
|
2017-11-20 20:05:23 +00:00
|
|
|
true)
|
2013-10-01 14:23:50 +00:00
|
|
|
GEN_TEST_FUNC(qemuMonitorJSONGraphicsRelocate, VIR_DOMAIN_GRAPHICS_TYPE_SPICE,
|
2018-08-16 14:36:41 +00:00
|
|
|
"localhost", 12345, 12346, "certsubjectval")
|
2013-10-01 14:23:50 +00:00
|
|
|
GEN_TEST_FUNC(qemuMonitorJSONRemoveNetdev, "net0")
|
|
|
|
GEN_TEST_FUNC(qemuMonitorJSONDelDevice, "ide0")
|
2021-11-30 19:22:46 +00:00
|
|
|
GEN_TEST_FUNC(qemuMonitorJSONBlockdevMirror, "jobname", true, "vdb", "targetnode", 1024, 1234, 31234, true, true)
|
2022-07-20 10:39:43 +00:00
|
|
|
GEN_TEST_FUNC(qemuMonitorJSONBlockStream, "vdb", "jobname", "backingnode", "backingfilename", 1024)
|
2022-12-13 15:40:02 +00:00
|
|
|
GEN_TEST_FUNC(qemuMonitorJSONBlockCommit, "vdb", "jobname", "topnode", "basenode", "backingfilename", 1024, VIR_TRISTATE_BOOL_YES)
|
2022-12-07 09:50:04 +00:00
|
|
|
GEN_TEST_FUNC(qemuMonitorJSONScreendump, "devicename", 1, NULL, "/foo/bar")
|
2013-10-01 14:23:50 +00:00
|
|
|
GEN_TEST_FUNC(qemuMonitorJSONOpenGraphics, "spice", "spicefd", false)
|
2019-06-06 02:25:05 +00:00
|
|
|
GEN_TEST_FUNC(qemuMonitorJSONNBDServerAdd, "vda", "export", true, "bitmap")
|
2013-10-01 14:23:50 +00:00
|
|
|
GEN_TEST_FUNC(qemuMonitorJSONDetachCharDev, "serial1")
|
2018-07-12 10:11:31 +00:00
|
|
|
GEN_TEST_FUNC(qemuMonitorJSONBlockdevTrayOpen, "foodev", true)
|
|
|
|
GEN_TEST_FUNC(qemuMonitorJSONBlockdevTrayClose, "foodev")
|
|
|
|
GEN_TEST_FUNC(qemuMonitorJSONBlockdevMediumRemove, "foodev")
|
|
|
|
GEN_TEST_FUNC(qemuMonitorJSONBlockdevMediumInsert, "foodev", "newnode")
|
2021-02-08 15:58:53 +00:00
|
|
|
GEN_TEST_FUNC(qemuMonitorJSONBitmapRemove, "foodev", "newnode")
|
2018-08-16 09:48:41 +00:00
|
|
|
GEN_TEST_FUNC(qemuMonitorJSONJobDismiss, "jobname")
|
2018-08-16 09:48:41 +00:00
|
|
|
GEN_TEST_FUNC(qemuMonitorJSONJobComplete, "jobname")
|
2022-06-21 13:22:15 +00:00
|
|
|
GEN_TEST_FUNC(qemuMonitorJSONJobFinalize, "jobname")
|
2021-04-20 12:14:51 +00:00
|
|
|
GEN_TEST_FUNC(qemuMonitorJSONBlockJobCancel, "jobname", true)
|
2021-08-20 12:39:27 +00:00
|
|
|
GEN_TEST_FUNC(qemuMonitorJSONSetAction,
|
|
|
|
QEMU_MONITOR_ACTION_SHUTDOWN_PAUSE,
|
|
|
|
QEMU_MONITOR_ACTION_REBOOT_RESET,
|
|
|
|
QEMU_MONITOR_ACTION_WATCHDOG_SHUTDOWN,
|
|
|
|
QEMU_MONITOR_ACTION_PANIC_SHUTDOWN)
|
2021-11-17 01:21:19 +00:00
|
|
|
GEN_TEST_FUNC(qemuMonitorJSONSetLaunchSecurityState, "sev_secret_header",
|
|
|
|
"sev_secret", 0, true)
|
2013-10-01 14:23:50 +00:00
|
|
|
|
2019-04-09 21:21:38 +00:00
|
|
|
static int
|
|
|
|
testQemuMonitorJSONqemuMonitorJSONNBDServerStart(const void *opaque)
|
|
|
|
{
|
|
|
|
const testGenericData *data = opaque;
|
2021-03-11 07:16:13 +00:00
|
|
|
virDomainXMLOption *xmlopt = data->xmlopt;
|
2019-04-09 21:21:38 +00:00
|
|
|
virStorageNetHostDef server_tcp = {
|
|
|
|
.name = (char *)"localhost",
|
|
|
|
.port = 12345,
|
|
|
|
.transport = VIR_STORAGE_NET_HOST_TRANS_TCP,
|
|
|
|
};
|
|
|
|
virStorageNetHostDef server_unix = {
|
|
|
|
.socket = (char *)"/tmp/sock",
|
|
|
|
.transport = VIR_STORAGE_NET_HOST_TRANS_UNIX,
|
|
|
|
};
|
2019-10-15 12:47:50 +00:00
|
|
|
g_autoptr(qemuMonitorTest) test = NULL;
|
2019-04-09 21:21:38 +00:00
|
|
|
|
|
|
|
if (!(test = qemuMonitorTestNewSchema(xmlopt, data->schema)))
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
if (qemuMonitorTestAddItem(test, "nbd-server-start",
|
|
|
|
"{\"return\":{}}") < 0)
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
if (qemuMonitorTestAddItem(test, "nbd-server-start",
|
|
|
|
"{\"return\":{}}") < 0)
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
if (qemuMonitorJSONNBDServerStart(qemuMonitorTestGetMonitor(test),
|
|
|
|
&server_tcp, "test-alias") < 0)
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
if (qemuMonitorJSONNBDServerStart(qemuMonitorTestGetMonitor(test),
|
|
|
|
&server_unix, "test-alias") < 0)
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2024-07-17 18:21:35 +00:00
|
|
|
|
|
|
|
static int
|
|
|
|
testQemuMonitorJSONqemuMonitorJSONSnapshot(const void *opaque)
|
|
|
|
{
|
|
|
|
const testGenericData *data = opaque;
|
|
|
|
virDomainXMLOption *xmlopt = data->xmlopt;
|
|
|
|
g_autoptr(qemuMonitorTest) test = NULL;
|
|
|
|
const char *disks[] = { "test", "disk", NULL };
|
|
|
|
|
|
|
|
if (!(test = qemuMonitorTestNewSchema(xmlopt, data->schema)))
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
if (qemuMonitorTestAddItem(test, "snapshot-save",
|
|
|
|
"{\"return\":{}}") < 0)
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
if (qemuMonitorTestAddItem(test, "snapshot-delete",
|
|
|
|
"{\"return\":{}}") < 0)
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
if (qemuMonitorJSONSnapshotSave(qemuMonitorTestGetMonitor(test),
|
|
|
|
"jobname", "snapshotname", "vmstate", disks) < 0)
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
if (qemuMonitorJSONSnapshotDelete(qemuMonitorTestGetMonitor(test),
|
|
|
|
"jobname", "snapshotname", disks) < 0)
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2016-08-01 11:44:25 +00:00
|
|
|
static bool
|
|
|
|
testQemuMonitorJSONqemuMonitorJSONQueryCPUsEqual(struct qemuMonitorQueryCpusEntry *a,
|
|
|
|
struct qemuMonitorQueryCpusEntry *b)
|
|
|
|
{
|
2016-07-28 08:33:10 +00:00
|
|
|
if (a->tid != b->tid ||
|
|
|
|
STRNEQ_NULLABLE(a->qom_path, b->qom_path))
|
2016-08-01 11:44:25 +00:00
|
|
|
return false;
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2013-10-02 09:40:33 +00:00
|
|
|
|
2018-04-04 14:45:04 +00:00
|
|
|
static int
|
2021-03-11 07:16:13 +00:00
|
|
|
testQEMUMonitorJSONqemuMonitorJSONQueryCPUsHelper(qemuMonitorTest *test,
|
2018-04-04 14:45:04 +00:00
|
|
|
struct qemuMonitorQueryCpusEntry *expect,
|
|
|
|
size_t num)
|
|
|
|
{
|
|
|
|
struct qemuMonitorQueryCpusEntry *cpudata = NULL;
|
|
|
|
size_t ncpudata = 0;
|
|
|
|
size_t i;
|
|
|
|
int ret = -1;
|
|
|
|
|
|
|
|
if (qemuMonitorJSONQueryCPUs(qemuMonitorTestGetMonitor(test),
|
2022-08-08 15:15:07 +00:00
|
|
|
&cpudata, &ncpudata, true) < 0)
|
2018-04-04 14:45:04 +00:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-04-29 17:47:36 +00:00
|
|
|
static int
|
|
|
|
testQemuMonitorJSONqemuMonitorJSONQueryCPUsFast(const void *opaque)
|
|
|
|
{
|
|
|
|
const testGenericData *data = opaque;
|
2021-03-11 07:16:13 +00:00
|
|
|
virDomainXMLOption *xmlopt = data->xmlopt;
|
2020-04-29 17:47:36 +00:00
|
|
|
struct qemuMonitorQueryCpusEntry expect_fast[] = {
|
|
|
|
{0, 17629, (char *) "/machine/unattached/device[0]", false},
|
|
|
|
{1, 17630, (char *) "/machine/unattached/device[1]", false},
|
|
|
|
};
|
|
|
|
g_autoptr(qemuMonitorTest) test = NULL;
|
|
|
|
|
|
|
|
if (!(test = qemuMonitorTestNewSchema(xmlopt, data->schema)))
|
|
|
|
return -1;
|
|
|
|
|
2018-04-04 14:45:04 +00:00
|
|
|
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)
|
2019-06-11 03:01:08 +00:00
|
|
|
return -1;
|
2013-10-02 09:40:33 +00:00
|
|
|
|
2018-04-04 14:45:04 +00:00
|
|
|
/* query-cpus-fast */
|
2022-08-08 15:15:06 +00:00
|
|
|
if (testQEMUMonitorJSONqemuMonitorJSONQueryCPUsHelper(test, expect_fast, 2))
|
2019-06-11 03:01:08 +00:00
|
|
|
return -1;
|
2013-10-02 09:40:33 +00:00
|
|
|
|
2019-06-11 03:01:08 +00:00
|
|
|
return 0;
|
2013-10-02 09:40:33 +00:00
|
|
|
}
|
|
|
|
|
2013-10-02 10:02:53 +00:00
|
|
|
static int
|
qemumonitorjsontest: Validate more commands against schema
The DO_TEST() macro in qemumonitorjsontest.c was not passing the
schema through, which meant that we were not validating any of those
tests for correct usage according to the schema.
In the process of mechanically altering tests to pass the schema
through, use VIR_AUTOPTR on all of the affected test instances. The
next patch will do some further cleanups that it exposes.
Tested by using this hack, where the test mistakenly passed pre-patch,
but correctly diagnosed the garbage post-patch:
| diff --git i/src/qemu/qemu_monitor_json.c w/src/qemu/qemu_monitor_json.c
| index 53a7de8b77..86d8450814 100644
| --- i/src/qemu/qemu_monitor_json.c
| +++ w/src/qemu/qemu_monitor_json.c
| @@ -1532,7 +1532,8 @@ qemuMonitorJSONGetStatus(qemuMonitorPtr mon,
| if (reason)
| *reason = VIR_DOMAIN_PAUSED_UNKNOWN;
|
| - if (!(cmd = qemuMonitorJSONMakeCommand("query-status", NULL)))
| + if (!(cmd = qemuMonitorJSONMakeCommand("query-status",
| + "s:garbage", "foo", NULL)))
| return -1;
|
| if (qemuMonitorJSONCommand(mon, cmd, &reply) < 0)
Suggested-by: Peter Krempa <pkrempa@redhat.com>
Signed-off-by: Eric Blake <eblake@redhat.com>
Acked-by: Peter Krempa <pkrempa@redhat.com>
2019-06-12 01:59:11 +00:00
|
|
|
testQemuMonitorJSONqemuMonitorJSONGetBalloonInfo(const void *opaque)
|
2013-10-02 10:02:53 +00:00
|
|
|
{
|
qemumonitorjsontest: Validate more commands against schema
The DO_TEST() macro in qemumonitorjsontest.c was not passing the
schema through, which meant that we were not validating any of those
tests for correct usage according to the schema.
In the process of mechanically altering tests to pass the schema
through, use VIR_AUTOPTR on all of the affected test instances. The
next patch will do some further cleanups that it exposes.
Tested by using this hack, where the test mistakenly passed pre-patch,
but correctly diagnosed the garbage post-patch:
| diff --git i/src/qemu/qemu_monitor_json.c w/src/qemu/qemu_monitor_json.c
| index 53a7de8b77..86d8450814 100644
| --- i/src/qemu/qemu_monitor_json.c
| +++ w/src/qemu/qemu_monitor_json.c
| @@ -1532,7 +1532,8 @@ qemuMonitorJSONGetStatus(qemuMonitorPtr mon,
| if (reason)
| *reason = VIR_DOMAIN_PAUSED_UNKNOWN;
|
| - if (!(cmd = qemuMonitorJSONMakeCommand("query-status", NULL)))
| + if (!(cmd = qemuMonitorJSONMakeCommand("query-status",
| + "s:garbage", "foo", NULL)))
| return -1;
|
| if (qemuMonitorJSONCommand(mon, cmd, &reply) < 0)
Suggested-by: Peter Krempa <pkrempa@redhat.com>
Signed-off-by: Eric Blake <eblake@redhat.com>
Acked-by: Peter Krempa <pkrempa@redhat.com>
2019-06-12 01:59:11 +00:00
|
|
|
const testGenericData *data = opaque;
|
2021-03-11 07:16:13 +00:00
|
|
|
virDomainXMLOption *xmlopt = data->xmlopt;
|
2013-10-02 10:02:53 +00:00
|
|
|
unsigned long long currmem;
|
2019-10-15 12:47:50 +00:00
|
|
|
g_autoptr(qemuMonitorTest) test = NULL;
|
2013-10-02 10:02:53 +00:00
|
|
|
|
qemumonitorjsontest: Validate more commands against schema
The DO_TEST() macro in qemumonitorjsontest.c was not passing the
schema through, which meant that we were not validating any of those
tests for correct usage according to the schema.
In the process of mechanically altering tests to pass the schema
through, use VIR_AUTOPTR on all of the affected test instances. The
next patch will do some further cleanups that it exposes.
Tested by using this hack, where the test mistakenly passed pre-patch,
but correctly diagnosed the garbage post-patch:
| diff --git i/src/qemu/qemu_monitor_json.c w/src/qemu/qemu_monitor_json.c
| index 53a7de8b77..86d8450814 100644
| --- i/src/qemu/qemu_monitor_json.c
| +++ w/src/qemu/qemu_monitor_json.c
| @@ -1532,7 +1532,8 @@ qemuMonitorJSONGetStatus(qemuMonitorPtr mon,
| if (reason)
| *reason = VIR_DOMAIN_PAUSED_UNKNOWN;
|
| - if (!(cmd = qemuMonitorJSONMakeCommand("query-status", NULL)))
| + if (!(cmd = qemuMonitorJSONMakeCommand("query-status",
| + "s:garbage", "foo", NULL)))
| return -1;
|
| if (qemuMonitorJSONCommand(mon, cmd, &reply) < 0)
Suggested-by: Peter Krempa <pkrempa@redhat.com>
Signed-off-by: Eric Blake <eblake@redhat.com>
Acked-by: Peter Krempa <pkrempa@redhat.com>
2019-06-12 01:59:11 +00:00
|
|
|
if (!(test = qemuMonitorTestNewSchema(xmlopt, data->schema)))
|
2013-10-02 10:02:53 +00:00
|
|
|
return -1;
|
|
|
|
|
|
|
|
if (qemuMonitorTestAddItem(test, "query-balloon",
|
|
|
|
"{"
|
|
|
|
" \"return\": {"
|
2018-08-24 11:30:17 +00:00
|
|
|
" \"actual\": 18446744073709551615"
|
2013-10-02 10:02:53 +00:00
|
|
|
" },"
|
|
|
|
" \"id\": \"libvirt-9\""
|
|
|
|
"}") < 0)
|
2019-06-11 03:01:08 +00:00
|
|
|
return -1;
|
2013-10-02 10:02:53 +00:00
|
|
|
|
|
|
|
if (qemuMonitorJSONGetBalloonInfo(qemuMonitorTestGetMonitor(test), &currmem) < 0)
|
2019-06-11 03:01:08 +00:00
|
|
|
return -1;
|
2013-10-02 10:02:53 +00:00
|
|
|
|
2018-08-24 11:30:17 +00:00
|
|
|
if (currmem != (18446744073709551615ULL/1024)) {
|
2013-10-02 10:02:53 +00:00
|
|
|
virReportError(VIR_ERR_INTERNAL_ERROR,
|
|
|
|
"Unexpected currmem value: %llu", currmem);
|
2019-06-11 03:01:08 +00:00
|
|
|
return -1;
|
2013-10-02 10:02:53 +00:00
|
|
|
}
|
|
|
|
|
2019-06-11 03:01:08 +00:00
|
|
|
return 0;
|
2013-10-02 10:02:53 +00:00
|
|
|
}
|
|
|
|
|
2018-08-06 12:35:20 +00:00
|
|
|
static void
|
|
|
|
testQemuMonitorJSONGetBlockInfoPrint(const struct qemuDomainDiskInfo *d)
|
|
|
|
{
|
|
|
|
VIR_TEST_VERBOSE("removable: %d, tray: %d, tray_open: %d, empty: %d, "
|
2019-05-03 08:45:58 +00:00
|
|
|
"io_status: %d, nodename: '%s'",
|
2018-08-06 12:35:20 +00:00
|
|
|
d->removable, d->tray, d->tray_open, d->empty,
|
|
|
|
d->io_status, NULLSTR(d->nodename));
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2013-10-02 12:39:10 +00:00
|
|
|
static int
|
|
|
|
testHashEqualQemuDomainDiskInfo(const void *value1, const void *value2)
|
|
|
|
{
|
|
|
|
const struct qemuDomainDiskInfo *info1 = value1, *info2 = value2;
|
2018-08-06 12:35:20 +00:00
|
|
|
int ret;
|
|
|
|
|
|
|
|
if ((ret = memcmp(info1, info2, sizeof(*info1))) != 0) {
|
|
|
|
testQemuMonitorJSONGetBlockInfoPrint(info1);
|
|
|
|
testQemuMonitorJSONGetBlockInfoPrint(info2);
|
|
|
|
}
|
2013-10-02 12:39:10 +00:00
|
|
|
|
2018-08-06 12:35:20 +00:00
|
|
|
return ret;
|
2013-10-02 12:39:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
qemumonitorjsontest: Validate more commands against schema
The DO_TEST() macro in qemumonitorjsontest.c was not passing the
schema through, which meant that we were not validating any of those
tests for correct usage according to the schema.
In the process of mechanically altering tests to pass the schema
through, use VIR_AUTOPTR on all of the affected test instances. The
next patch will do some further cleanups that it exposes.
Tested by using this hack, where the test mistakenly passed pre-patch,
but correctly diagnosed the garbage post-patch:
| diff --git i/src/qemu/qemu_monitor_json.c w/src/qemu/qemu_monitor_json.c
| index 53a7de8b77..86d8450814 100644
| --- i/src/qemu/qemu_monitor_json.c
| +++ w/src/qemu/qemu_monitor_json.c
| @@ -1532,7 +1532,8 @@ qemuMonitorJSONGetStatus(qemuMonitorPtr mon,
| if (reason)
| *reason = VIR_DOMAIN_PAUSED_UNKNOWN;
|
| - if (!(cmd = qemuMonitorJSONMakeCommand("query-status", NULL)))
| + if (!(cmd = qemuMonitorJSONMakeCommand("query-status",
| + "s:garbage", "foo", NULL)))
| return -1;
|
| if (qemuMonitorJSONCommand(mon, cmd, &reply) < 0)
Suggested-by: Peter Krempa <pkrempa@redhat.com>
Signed-off-by: Eric Blake <eblake@redhat.com>
Acked-by: Peter Krempa <pkrempa@redhat.com>
2019-06-12 01:59:11 +00:00
|
|
|
testQemuMonitorJSONqemuMonitorJSONGetBlockInfo(const void *opaque)
|
2013-10-02 12:39:10 +00:00
|
|
|
{
|
qemumonitorjsontest: Validate more commands against schema
The DO_TEST() macro in qemumonitorjsontest.c was not passing the
schema through, which meant that we were not validating any of those
tests for correct usage according to the schema.
In the process of mechanically altering tests to pass the schema
through, use VIR_AUTOPTR on all of the affected test instances. The
next patch will do some further cleanups that it exposes.
Tested by using this hack, where the test mistakenly passed pre-patch,
but correctly diagnosed the garbage post-patch:
| diff --git i/src/qemu/qemu_monitor_json.c w/src/qemu/qemu_monitor_json.c
| index 53a7de8b77..86d8450814 100644
| --- i/src/qemu/qemu_monitor_json.c
| +++ w/src/qemu/qemu_monitor_json.c
| @@ -1532,7 +1532,8 @@ qemuMonitorJSONGetStatus(qemuMonitorPtr mon,
| if (reason)
| *reason = VIR_DOMAIN_PAUSED_UNKNOWN;
|
| - if (!(cmd = qemuMonitorJSONMakeCommand("query-status", NULL)))
| + if (!(cmd = qemuMonitorJSONMakeCommand("query-status",
| + "s:garbage", "foo", NULL)))
| return -1;
|
| if (qemuMonitorJSONCommand(mon, cmd, &reply) < 0)
Suggested-by: Peter Krempa <pkrempa@redhat.com>
Signed-off-by: Eric Blake <eblake@redhat.com>
Acked-by: Peter Krempa <pkrempa@redhat.com>
2019-06-12 01:59:11 +00:00
|
|
|
const testGenericData *data = opaque;
|
2021-03-11 07:16:13 +00:00
|
|
|
virDomainXMLOption *xmlopt = data->xmlopt;
|
2021-07-05 14:36:01 +00:00
|
|
|
g_autoptr(GHashTable) blockDevices = virHashNew(g_free);
|
|
|
|
g_autoptr(GHashTable) expectedBlockDevices = virHashNew(g_free);
|
2013-10-02 12:39:10 +00:00
|
|
|
struct qemuDomainDiskInfo *info;
|
2019-10-15 12:47:50 +00:00
|
|
|
g_autoptr(qemuMonitorTest) test = NULL;
|
2013-10-02 12:39:10 +00:00
|
|
|
|
qemumonitorjsontest: Validate more commands against schema
The DO_TEST() macro in qemumonitorjsontest.c was not passing the
schema through, which meant that we were not validating any of those
tests for correct usage according to the schema.
In the process of mechanically altering tests to pass the schema
through, use VIR_AUTOPTR on all of the affected test instances. The
next patch will do some further cleanups that it exposes.
Tested by using this hack, where the test mistakenly passed pre-patch,
but correctly diagnosed the garbage post-patch:
| diff --git i/src/qemu/qemu_monitor_json.c w/src/qemu/qemu_monitor_json.c
| index 53a7de8b77..86d8450814 100644
| --- i/src/qemu/qemu_monitor_json.c
| +++ w/src/qemu/qemu_monitor_json.c
| @@ -1532,7 +1532,8 @@ qemuMonitorJSONGetStatus(qemuMonitorPtr mon,
| if (reason)
| *reason = VIR_DOMAIN_PAUSED_UNKNOWN;
|
| - if (!(cmd = qemuMonitorJSONMakeCommand("query-status", NULL)))
| + if (!(cmd = qemuMonitorJSONMakeCommand("query-status",
| + "s:garbage", "foo", NULL)))
| return -1;
|
| if (qemuMonitorJSONCommand(mon, cmd, &reply) < 0)
Suggested-by: Peter Krempa <pkrempa@redhat.com>
Signed-off-by: Eric Blake <eblake@redhat.com>
Acked-by: Peter Krempa <pkrempa@redhat.com>
2019-06-12 01:59:11 +00:00
|
|
|
if (!(test = qemuMonitorTestNewSchema(xmlopt, data->schema)))
|
2013-10-02 12:39:10 +00:00
|
|
|
return -1;
|
|
|
|
|
2020-09-22 22:42:45 +00:00
|
|
|
info = g_new0(struct qemuDomainDiskInfo, 1);
|
2013-10-02 12:39:10 +00:00
|
|
|
|
|
|
|
if (virHashAddEntry(expectedBlockDevices, "virtio-disk0", info) < 0) {
|
|
|
|
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
|
|
|
"Unable to create expectedBlockDevices hash table");
|
2021-07-05 14:35:09 +00:00
|
|
|
return -1;
|
2013-10-02 12:39:10 +00:00
|
|
|
}
|
|
|
|
|
2020-09-22 22:42:45 +00:00
|
|
|
info = g_new0(struct qemuDomainDiskInfo, 1);
|
2013-10-02 12:39:10 +00:00
|
|
|
|
|
|
|
if (virHashAddEntry(expectedBlockDevices, "virtio-disk1", info) < 0) {
|
|
|
|
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
|
|
|
"Unable to create expectedBlockDevices hash table");
|
2021-07-05 14:35:09 +00:00
|
|
|
return -1;
|
2013-10-02 12:39:10 +00:00
|
|
|
}
|
|
|
|
|
2020-09-22 22:42:45 +00:00
|
|
|
info = g_new0(struct qemuDomainDiskInfo, 1);
|
2013-10-02 12:39:10 +00:00
|
|
|
|
|
|
|
info->removable = true;
|
2016-05-19 12:57:41 +00:00
|
|
|
info->tray = true;
|
|
|
|
|
2013-10-02 12:39:10 +00:00
|
|
|
if (virHashAddEntry(expectedBlockDevices, "ide0-1-0", info) < 0) {
|
|
|
|
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
|
|
|
"Unable to create expectedBlockDevices hash table");
|
2021-07-05 14:35:09 +00:00
|
|
|
return -1;
|
2013-10-02 12:39:10 +00:00
|
|
|
}
|
|
|
|
|
2020-09-22 22:42:45 +00:00
|
|
|
info = g_new0(struct qemuDomainDiskInfo, 1);
|
2016-05-19 12:57:41 +00:00
|
|
|
|
|
|
|
info->removable = true;
|
|
|
|
info->tray = true;
|
|
|
|
info->empty = true;
|
|
|
|
|
|
|
|
if (virHashAddEntry(expectedBlockDevices, "ide0-1-1", info) < 0) {
|
|
|
|
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
|
|
|
"Unable to create expectedBlockDevices hash table");
|
2021-07-05 14:35:09 +00:00
|
|
|
return -1;
|
2016-05-19 12:57:41 +00:00
|
|
|
}
|
|
|
|
|
2013-10-02 16:46:42 +00:00
|
|
|
if (qemuMonitorTestAddItem(test, "query-block", queryBlockReply) < 0)
|
2021-07-05 14:35:09 +00:00
|
|
|
return -1;
|
2013-10-02 12:39:10 +00:00
|
|
|
|
|
|
|
if (qemuMonitorJSONGetBlockInfo(qemuMonitorTestGetMonitor(test), blockDevices) < 0)
|
2021-07-05 14:35:09 +00:00
|
|
|
return -1;
|
2013-10-02 12:39:10 +00:00
|
|
|
|
|
|
|
if (!virHashEqual(blockDevices, expectedBlockDevices, testHashEqualQemuDomainDiskInfo)) {
|
|
|
|
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
|
|
|
"Hashtable is different to the expected one");
|
2021-07-05 14:35:09 +00:00
|
|
|
return -1;
|
2013-10-02 12:39:10 +00:00
|
|
|
}
|
|
|
|
|
2021-07-05 14:35:09 +00:00
|
|
|
return 0;
|
2013-10-02 12:39:10 +00:00
|
|
|
}
|
|
|
|
|
2013-10-02 13:08:02 +00:00
|
|
|
static int
|
qemumonitorjsontest: Validate more commands against schema
The DO_TEST() macro in qemumonitorjsontest.c was not passing the
schema through, which meant that we were not validating any of those
tests for correct usage according to the schema.
In the process of mechanically altering tests to pass the schema
through, use VIR_AUTOPTR on all of the affected test instances. The
next patch will do some further cleanups that it exposes.
Tested by using this hack, where the test mistakenly passed pre-patch,
but correctly diagnosed the garbage post-patch:
| diff --git i/src/qemu/qemu_monitor_json.c w/src/qemu/qemu_monitor_json.c
| index 53a7de8b77..86d8450814 100644
| --- i/src/qemu/qemu_monitor_json.c
| +++ w/src/qemu/qemu_monitor_json.c
| @@ -1532,7 +1532,8 @@ qemuMonitorJSONGetStatus(qemuMonitorPtr mon,
| if (reason)
| *reason = VIR_DOMAIN_PAUSED_UNKNOWN;
|
| - if (!(cmd = qemuMonitorJSONMakeCommand("query-status", NULL)))
| + if (!(cmd = qemuMonitorJSONMakeCommand("query-status",
| + "s:garbage", "foo", NULL)))
| return -1;
|
| if (qemuMonitorJSONCommand(mon, cmd, &reply) < 0)
Suggested-by: Peter Krempa <pkrempa@redhat.com>
Signed-off-by: Eric Blake <eblake@redhat.com>
Acked-by: Peter Krempa <pkrempa@redhat.com>
2019-06-12 01:59:11 +00:00
|
|
|
testQemuMonitorJSONqemuMonitorJSONGetAllBlockStatsInfo(const void *opaque)
|
2013-10-02 13:08:02 +00:00
|
|
|
{
|
qemumonitorjsontest: Validate more commands against schema
The DO_TEST() macro in qemumonitorjsontest.c was not passing the
schema through, which meant that we were not validating any of those
tests for correct usage according to the schema.
In the process of mechanically altering tests to pass the schema
through, use VIR_AUTOPTR on all of the affected test instances. The
next patch will do some further cleanups that it exposes.
Tested by using this hack, where the test mistakenly passed pre-patch,
but correctly diagnosed the garbage post-patch:
| diff --git i/src/qemu/qemu_monitor_json.c w/src/qemu/qemu_monitor_json.c
| index 53a7de8b77..86d8450814 100644
| --- i/src/qemu/qemu_monitor_json.c
| +++ w/src/qemu/qemu_monitor_json.c
| @@ -1532,7 +1532,8 @@ qemuMonitorJSONGetStatus(qemuMonitorPtr mon,
| if (reason)
| *reason = VIR_DOMAIN_PAUSED_UNKNOWN;
|
| - if (!(cmd = qemuMonitorJSONMakeCommand("query-status", NULL)))
| + if (!(cmd = qemuMonitorJSONMakeCommand("query-status",
| + "s:garbage", "foo", NULL)))
| return -1;
|
| if (qemuMonitorJSONCommand(mon, cmd, &reply) < 0)
Suggested-by: Peter Krempa <pkrempa@redhat.com>
Signed-off-by: Eric Blake <eblake@redhat.com>
Acked-by: Peter Krempa <pkrempa@redhat.com>
2019-06-12 01:59:11 +00:00
|
|
|
const testGenericData *data = opaque;
|
2021-03-11 07:16:13 +00:00
|
|
|
virDomainXMLOption *xmlopt = data->xmlopt;
|
2021-07-05 14:32:07 +00:00
|
|
|
g_autoptr(GHashTable) blockstats = virHashNew(g_free);
|
2021-03-11 07:16:13 +00:00
|
|
|
qemuBlockStats *stats;
|
2019-10-15 12:47:50 +00:00
|
|
|
g_autoptr(qemuMonitorTest) test = NULL;
|
2013-10-02 13:08:02 +00:00
|
|
|
|
|
|
|
const char *reply =
|
|
|
|
"{"
|
|
|
|
" \"return\": ["
|
|
|
|
" {"
|
|
|
|
" \"device\": \"drive-virtio-disk0\","
|
|
|
|
" \"parent\": {"
|
|
|
|
" \"stats\": {"
|
|
|
|
" \"flush_total_time_ns\": 0,"
|
|
|
|
" \"wr_highest_offset\": 5256018944,"
|
|
|
|
" \"wr_total_time_ns\": 0,"
|
|
|
|
" \"wr_bytes\": 0,"
|
|
|
|
" \"rd_total_time_ns\": 0,"
|
|
|
|
" \"flush_operations\": 0,"
|
|
|
|
" \"wr_operations\": 0,"
|
|
|
|
" \"rd_bytes\": 0,"
|
|
|
|
" \"rd_operations\": 0"
|
|
|
|
" }"
|
|
|
|
" },"
|
|
|
|
" \"stats\": {"
|
|
|
|
" \"flush_total_time_ns\": 0,"
|
|
|
|
" \"wr_highest_offset\": 10406001664,"
|
|
|
|
" \"wr_total_time_ns\": 530699221,"
|
|
|
|
" \"wr_bytes\": 2845696,"
|
|
|
|
" \"rd_total_time_ns\": 640616474,"
|
|
|
|
" \"flush_operations\": 0,"
|
|
|
|
" \"wr_operations\": 174,"
|
|
|
|
" \"rd_bytes\": 28505088,"
|
|
|
|
" \"rd_operations\": 1279"
|
|
|
|
" }"
|
|
|
|
" },"
|
|
|
|
" {"
|
|
|
|
" \"device\": \"drive-virtio-disk1\","
|
|
|
|
" \"parent\": {"
|
|
|
|
" \"stats\": {"
|
|
|
|
" \"flush_total_time_ns\": 0,"
|
|
|
|
" \"wr_highest_offset\": 0,"
|
|
|
|
" \"wr_total_time_ns\": 0,"
|
|
|
|
" \"wr_bytes\": 0,"
|
|
|
|
" \"rd_total_time_ns\": 0,"
|
|
|
|
" \"flush_operations\": 0,"
|
|
|
|
" \"wr_operations\": 0,"
|
|
|
|
" \"rd_bytes\": 0,"
|
|
|
|
" \"rd_operations\": 0"
|
|
|
|
" }"
|
|
|
|
" },"
|
|
|
|
" \"stats\": {"
|
|
|
|
" \"flush_total_time_ns\": 0,"
|
|
|
|
" \"wr_highest_offset\": 0,"
|
|
|
|
" \"wr_total_time_ns\": 0,"
|
|
|
|
" \"wr_bytes\": 0,"
|
|
|
|
" \"rd_total_time_ns\": 8232156,"
|
|
|
|
" \"flush_operations\": 0,"
|
|
|
|
" \"wr_operations\": 0,"
|
|
|
|
" \"rd_bytes\": 348160,"
|
|
|
|
" \"rd_operations\": 85"
|
|
|
|
" }"
|
|
|
|
" },"
|
|
|
|
" {"
|
|
|
|
" \"device\": \"drive-ide0-1-0\","
|
|
|
|
" \"parent\": {"
|
|
|
|
" \"stats\": {"
|
|
|
|
" \"flush_total_time_ns\": 0,"
|
|
|
|
" \"wr_total_time_ns\": 0,"
|
|
|
|
" \"wr_bytes\": 0,"
|
|
|
|
" \"rd_total_time_ns\": 0,"
|
|
|
|
" \"flush_operations\": 0,"
|
|
|
|
" \"wr_operations\": 0,"
|
|
|
|
" \"rd_bytes\": 0,"
|
|
|
|
" \"rd_operations\": 0"
|
|
|
|
" }"
|
|
|
|
" },"
|
|
|
|
" \"stats\": {"
|
|
|
|
" \"flush_total_time_ns\": 0,"
|
|
|
|
" \"wr_highest_offset\": 0,"
|
|
|
|
" \"wr_total_time_ns\": 0,"
|
|
|
|
" \"wr_bytes\": 0,"
|
|
|
|
" \"rd_total_time_ns\": 1004952,"
|
|
|
|
" \"flush_operations\": 0,"
|
|
|
|
" \"wr_operations\": 0,"
|
|
|
|
" \"rd_bytes\": 49250,"
|
|
|
|
" \"rd_operations\": 16"
|
|
|
|
" }"
|
|
|
|
" }"
|
|
|
|
" ],"
|
|
|
|
" \"id\": \"libvirt-11\""
|
|
|
|
"}";
|
|
|
|
|
qemumonitorjsontest: Validate more commands against schema
The DO_TEST() macro in qemumonitorjsontest.c was not passing the
schema through, which meant that we were not validating any of those
tests for correct usage according to the schema.
In the process of mechanically altering tests to pass the schema
through, use VIR_AUTOPTR on all of the affected test instances. The
next patch will do some further cleanups that it exposes.
Tested by using this hack, where the test mistakenly passed pre-patch,
but correctly diagnosed the garbage post-patch:
| diff --git i/src/qemu/qemu_monitor_json.c w/src/qemu/qemu_monitor_json.c
| index 53a7de8b77..86d8450814 100644
| --- i/src/qemu/qemu_monitor_json.c
| +++ w/src/qemu/qemu_monitor_json.c
| @@ -1532,7 +1532,8 @@ qemuMonitorJSONGetStatus(qemuMonitorPtr mon,
| if (reason)
| *reason = VIR_DOMAIN_PAUSED_UNKNOWN;
|
| - if (!(cmd = qemuMonitorJSONMakeCommand("query-status", NULL)))
| + if (!(cmd = qemuMonitorJSONMakeCommand("query-status",
| + "s:garbage", "foo", NULL)))
| return -1;
|
| if (qemuMonitorJSONCommand(mon, cmd, &reply) < 0)
Suggested-by: Peter Krempa <pkrempa@redhat.com>
Signed-off-by: Eric Blake <eblake@redhat.com>
Acked-by: Peter Krempa <pkrempa@redhat.com>
2019-06-12 01:59:11 +00:00
|
|
|
if (!(test = qemuMonitorTestNewSchema(xmlopt, data->schema)))
|
2013-10-02 13:08:02 +00:00
|
|
|
return -1;
|
|
|
|
|
2018-06-18 08:22:18 +00:00
|
|
|
if (qemuMonitorTestAddItem(test, "query-blockstats", reply) < 0)
|
2021-07-05 14:31:31 +00:00
|
|
|
return -1;
|
2021-11-24 16:22:29 +00:00
|
|
|
if (qemuMonitorTestAddItem(test, "query-blockstats", reply) < 0)
|
|
|
|
return -1;
|
2013-10-02 13:08:02 +00:00
|
|
|
|
2015-06-23 14:58:07 +00:00
|
|
|
#define CHECK0FULL(var, value, varformat, valformat) \
|
2015-03-10 16:11:22 +00:00
|
|
|
if (stats->var != value) { \
|
2013-10-02 13:08:02 +00:00
|
|
|
virReportError(VIR_ERR_INTERNAL_ERROR, \
|
2015-06-23 14:58:07 +00:00
|
|
|
"Invalid " #var " value: " varformat \
|
|
|
|
", expected " valformat, \
|
2015-03-10 16:11:22 +00:00
|
|
|
stats->var, value); \
|
2021-07-05 14:31:31 +00:00
|
|
|
return -1; \
|
2013-10-02 13:08:02 +00:00
|
|
|
}
|
|
|
|
|
2015-06-23 14:58:07 +00:00
|
|
|
#define CHECK0(var, value) CHECK0FULL(var, value, "%lld", "%d")
|
|
|
|
|
2017-11-03 12:09:47 +00:00
|
|
|
#define CHECK(NAME, RD_REQ, RD_BYTES, RD_TOTAL_TIMES, WR_REQ, WR_BYTES, \
|
|
|
|
WR_TOTAL_TIMES, FLUSH_REQ, FLUSH_TOTAL_TIMES, \
|
|
|
|
WR_HIGHEST_OFFSET, WR_HIGHEST_OFFSET_VALID) \
|
|
|
|
if (!(stats = virHashLookup(blockstats, NAME))) { \
|
|
|
|
virReportError(VIR_ERR_INTERNAL_ERROR, \
|
|
|
|
"block stats for device '%s' is missing", NAME); \
|
2021-07-05 14:31:31 +00:00
|
|
|
return -1; \
|
2017-11-03 12:09:47 +00:00
|
|
|
} \
|
2013-10-02 13:08:02 +00:00
|
|
|
CHECK0(rd_req, RD_REQ) \
|
|
|
|
CHECK0(rd_bytes, RD_BYTES) \
|
|
|
|
CHECK0(rd_total_times, RD_TOTAL_TIMES) \
|
|
|
|
CHECK0(wr_req, WR_REQ) \
|
|
|
|
CHECK0(wr_bytes, WR_BYTES) \
|
|
|
|
CHECK0(wr_total_times, WR_TOTAL_TIMES) \
|
|
|
|
CHECK0(flush_req, FLUSH_REQ) \
|
2015-06-23 14:58:07 +00:00
|
|
|
CHECK0(flush_total_times, FLUSH_TOTAL_TIMES) \
|
|
|
|
CHECK0FULL(wr_highest_offset, WR_HIGHEST_OFFSET, "%llu", "%llu") \
|
|
|
|
CHECK0FULL(wr_highest_offset_valid, WR_HIGHEST_OFFSET_VALID, "%d", "%d")
|
2013-10-02 13:08:02 +00:00
|
|
|
|
2018-06-18 08:24:17 +00:00
|
|
|
if (qemuMonitorJSONGetAllBlockStatsInfo(qemuMonitorTestGetMonitor(test),
|
2021-10-19 13:25:46 +00:00
|
|
|
blockstats) < 0)
|
2021-07-05 14:31:31 +00:00
|
|
|
return -1;
|
2013-10-02 13:08:02 +00:00
|
|
|
|
2015-03-10 16:11:22 +00:00
|
|
|
if (!blockstats) {
|
|
|
|
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
2018-06-18 08:24:17 +00:00
|
|
|
"qemuMonitorJSONGetAllBlockStatsInfo didn't return stats");
|
2021-07-05 14:31:31 +00:00
|
|
|
return -1;
|
2013-10-02 13:08:02 +00:00
|
|
|
}
|
|
|
|
|
2015-06-23 14:58:07 +00:00
|
|
|
CHECK("virtio-disk0", 1279, 28505088, 640616474, 174, 2845696, 530699221, 0, 0, 5256018944ULL, true)
|
|
|
|
CHECK("virtio-disk1", 85, 348160, 8232156, 0, 0, 0, 0, 0, 0ULL, true)
|
2015-06-26 14:40:29 +00:00
|
|
|
CHECK("ide0-1-0", 16, 49250, 1004952, 0, 0, 0, 0, 0, 0ULL, false)
|
2015-03-10 16:11:22 +00:00
|
|
|
|
2021-07-05 14:31:31 +00:00
|
|
|
return 0;
|
2013-10-02 13:08:02 +00:00
|
|
|
|
|
|
|
#undef CHECK
|
|
|
|
#undef CHECK0
|
2015-06-23 14:58:07 +00:00
|
|
|
#undef CHECK0FULL
|
2013-10-02 13:08:02 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
|
2016-04-14 10:33:50 +00:00
|
|
|
|
2013-10-02 14:43:35 +00:00
|
|
|
static int
|
qemumonitorjsontest: Validate more commands against schema
The DO_TEST() macro in qemumonitorjsontest.c was not passing the
schema through, which meant that we were not validating any of those
tests for correct usage according to the schema.
In the process of mechanically altering tests to pass the schema
through, use VIR_AUTOPTR on all of the affected test instances. The
next patch will do some further cleanups that it exposes.
Tested by using this hack, where the test mistakenly passed pre-patch,
but correctly diagnosed the garbage post-patch:
| diff --git i/src/qemu/qemu_monitor_json.c w/src/qemu/qemu_monitor_json.c
| index 53a7de8b77..86d8450814 100644
| --- i/src/qemu/qemu_monitor_json.c
| +++ w/src/qemu/qemu_monitor_json.c
| @@ -1532,7 +1532,8 @@ qemuMonitorJSONGetStatus(qemuMonitorPtr mon,
| if (reason)
| *reason = VIR_DOMAIN_PAUSED_UNKNOWN;
|
| - if (!(cmd = qemuMonitorJSONMakeCommand("query-status", NULL)))
| + if (!(cmd = qemuMonitorJSONMakeCommand("query-status",
| + "s:garbage", "foo", NULL)))
| return -1;
|
| if (qemuMonitorJSONCommand(mon, cmd, &reply) < 0)
Suggested-by: Peter Krempa <pkrempa@redhat.com>
Signed-off-by: Eric Blake <eblake@redhat.com>
Acked-by: Peter Krempa <pkrempa@redhat.com>
2019-06-12 01:59:11 +00:00
|
|
|
testQemuMonitorJSONqemuMonitorJSONGetMigrationStats(const void *opaque)
|
2013-10-02 14:43:35 +00:00
|
|
|
{
|
qemumonitorjsontest: Validate more commands against schema
The DO_TEST() macro in qemumonitorjsontest.c was not passing the
schema through, which meant that we were not validating any of those
tests for correct usage according to the schema.
In the process of mechanically altering tests to pass the schema
through, use VIR_AUTOPTR on all of the affected test instances. The
next patch will do some further cleanups that it exposes.
Tested by using this hack, where the test mistakenly passed pre-patch,
but correctly diagnosed the garbage post-patch:
| diff --git i/src/qemu/qemu_monitor_json.c w/src/qemu/qemu_monitor_json.c
| index 53a7de8b77..86d8450814 100644
| --- i/src/qemu/qemu_monitor_json.c
| +++ w/src/qemu/qemu_monitor_json.c
| @@ -1532,7 +1532,8 @@ qemuMonitorJSONGetStatus(qemuMonitorPtr mon,
| if (reason)
| *reason = VIR_DOMAIN_PAUSED_UNKNOWN;
|
| - if (!(cmd = qemuMonitorJSONMakeCommand("query-status", NULL)))
| + if (!(cmd = qemuMonitorJSONMakeCommand("query-status",
| + "s:garbage", "foo", NULL)))
| return -1;
|
| if (qemuMonitorJSONCommand(mon, cmd, &reply) < 0)
Suggested-by: Peter Krempa <pkrempa@redhat.com>
Signed-off-by: Eric Blake <eblake@redhat.com>
Acked-by: Peter Krempa <pkrempa@redhat.com>
2019-06-12 01:59:11 +00:00
|
|
|
const testGenericData *data = opaque;
|
2021-03-11 07:16:13 +00:00
|
|
|
virDomainXMLOption *xmlopt = data->xmlopt;
|
2023-08-03 09:48:30 +00:00
|
|
|
qemuMonitorMigrationStats stats;
|
|
|
|
qemuMonitorMigrationStats expectedStats = { 0 };
|
2021-09-04 20:33:55 +00:00
|
|
|
g_autofree char *error = NULL;
|
2019-10-15 12:47:50 +00:00
|
|
|
g_autoptr(qemuMonitorTest) test = NULL;
|
2013-10-02 14:43:35 +00:00
|
|
|
|
qemumonitorjsontest: Validate more commands against schema
The DO_TEST() macro in qemumonitorjsontest.c was not passing the
schema through, which meant that we were not validating any of those
tests for correct usage according to the schema.
In the process of mechanically altering tests to pass the schema
through, use VIR_AUTOPTR on all of the affected test instances. The
next patch will do some further cleanups that it exposes.
Tested by using this hack, where the test mistakenly passed pre-patch,
but correctly diagnosed the garbage post-patch:
| diff --git i/src/qemu/qemu_monitor_json.c w/src/qemu/qemu_monitor_json.c
| index 53a7de8b77..86d8450814 100644
| --- i/src/qemu/qemu_monitor_json.c
| +++ w/src/qemu/qemu_monitor_json.c
| @@ -1532,7 +1532,8 @@ qemuMonitorJSONGetStatus(qemuMonitorPtr mon,
| if (reason)
| *reason = VIR_DOMAIN_PAUSED_UNKNOWN;
|
| - if (!(cmd = qemuMonitorJSONMakeCommand("query-status", NULL)))
| + if (!(cmd = qemuMonitorJSONMakeCommand("query-status",
| + "s:garbage", "foo", NULL)))
| return -1;
|
| if (qemuMonitorJSONCommand(mon, cmd, &reply) < 0)
Suggested-by: Peter Krempa <pkrempa@redhat.com>
Signed-off-by: Eric Blake <eblake@redhat.com>
Acked-by: Peter Krempa <pkrempa@redhat.com>
2019-06-12 01:59:11 +00:00
|
|
|
if (!(test = qemuMonitorTestNewSchema(xmlopt, data->schema)))
|
2013-10-02 14:43:35 +00:00
|
|
|
return -1;
|
|
|
|
|
2015-11-26 12:23:08 +00:00
|
|
|
expectedStats.status = QEMU_MONITOR_MIGRATION_STATUS_ACTIVE;
|
|
|
|
expectedStats.total_time = 47;
|
|
|
|
expectedStats.ram_total = 1611038720;
|
|
|
|
expectedStats.ram_remaining = 1605013504;
|
|
|
|
expectedStats.ram_transferred = 3625548;
|
2013-10-02 14:43:35 +00:00
|
|
|
|
|
|
|
if (qemuMonitorTestAddItem(test, "query-migrate",
|
|
|
|
"{"
|
|
|
|
" \"return\": {"
|
|
|
|
" \"status\": \"active\","
|
|
|
|
" \"total-time\": 47,"
|
|
|
|
" \"ram\": {"
|
|
|
|
" \"total\": 1611038720,"
|
|
|
|
" \"remaining\": 1605013504,"
|
|
|
|
" \"transferred\": 3625548"
|
|
|
|
" }"
|
|
|
|
" },"
|
|
|
|
" \"id\": \"libvirt-13\""
|
2017-10-12 13:19:19 +00:00
|
|
|
"}") < 0 ||
|
|
|
|
qemuMonitorTestAddItem(test, "query-migrate",
|
|
|
|
"{"
|
|
|
|
" \"return\": {"
|
|
|
|
" \"status\": \"failed\","
|
|
|
|
" \"error-desc\": \"It's broken\""
|
|
|
|
" },"
|
|
|
|
" \"id\": \"libvirt-14\""
|
2013-10-02 14:43:35 +00:00
|
|
|
"}") < 0)
|
2021-09-04 20:38:39 +00:00
|
|
|
return -1;
|
2013-10-02 14:43:35 +00:00
|
|
|
|
2017-10-12 13:19:19 +00:00
|
|
|
if (qemuMonitorJSONGetMigrationStats(qemuMonitorTestGetMonitor(test),
|
|
|
|
&stats, &error) < 0)
|
2021-09-04 20:38:39 +00:00
|
|
|
return -1;
|
2017-10-12 13:19:19 +00:00
|
|
|
|
|
|
|
if (memcmp(&stats, &expectedStats, sizeof(stats)) != 0 || error) {
|
|
|
|
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
|
|
|
"Invalid migration statistics");
|
2021-09-04 20:38:39 +00:00
|
|
|
return -1;
|
2017-10-12 13:19:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
memset(&stats, 0, sizeof(stats));
|
|
|
|
if (qemuMonitorJSONGetMigrationStats(qemuMonitorTestGetMonitor(test),
|
|
|
|
&stats, &error) < 0)
|
2021-09-04 20:38:39 +00:00
|
|
|
return -1;
|
2013-10-02 14:43:35 +00:00
|
|
|
|
2017-10-12 13:19:19 +00:00
|
|
|
if (stats.status != QEMU_MONITOR_MIGRATION_STATUS_ERROR ||
|
|
|
|
STRNEQ_NULLABLE(error, "It's broken")) {
|
2013-10-02 14:43:35 +00:00
|
|
|
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
2017-10-12 13:19:19 +00:00
|
|
|
"Invalid failed migration status");
|
2021-09-04 20:38:39 +00:00
|
|
|
return -1;
|
2013-10-02 14:43:35 +00:00
|
|
|
}
|
|
|
|
|
2021-09-04 20:38:39 +00:00
|
|
|
return 0;
|
2013-10-02 14:43:35 +00:00
|
|
|
}
|
|
|
|
|
2013-10-02 15:11:30 +00:00
|
|
|
static int
|
2014-11-13 18:29:14 +00:00
|
|
|
testHashEqualChardevInfo(const void *value1, const void *value2)
|
2013-10-02 15:11:30 +00:00
|
|
|
{
|
2014-11-13 18:29:14 +00:00
|
|
|
const qemuMonitorChardevInfo *info1 = value1;
|
|
|
|
const qemuMonitorChardevInfo *info2 = value2;
|
|
|
|
|
|
|
|
if (info1->state != info2->state)
|
|
|
|
goto error;
|
|
|
|
|
|
|
|
if (STRNEQ_NULLABLE(info1->ptyPath, info2->ptyPath))
|
|
|
|
goto error;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
error:
|
|
|
|
fprintf(stderr, "\n"
|
|
|
|
"info1->state: %d info2->state: %d\n"
|
|
|
|
"info1->ptyPath: %s info2->ptyPath: %s\n",
|
|
|
|
info1->state, info2->state, info1->ptyPath, info2->ptyPath);
|
|
|
|
return -1;
|
2013-10-02 15:11:30 +00:00
|
|
|
}
|
|
|
|
|
2014-11-13 18:29:14 +00:00
|
|
|
|
2013-10-02 15:11:30 +00:00
|
|
|
static int
|
qemumonitorjsontest: Validate more commands against schema
The DO_TEST() macro in qemumonitorjsontest.c was not passing the
schema through, which meant that we were not validating any of those
tests for correct usage according to the schema.
In the process of mechanically altering tests to pass the schema
through, use VIR_AUTOPTR on all of the affected test instances. The
next patch will do some further cleanups that it exposes.
Tested by using this hack, where the test mistakenly passed pre-patch,
but correctly diagnosed the garbage post-patch:
| diff --git i/src/qemu/qemu_monitor_json.c w/src/qemu/qemu_monitor_json.c
| index 53a7de8b77..86d8450814 100644
| --- i/src/qemu/qemu_monitor_json.c
| +++ w/src/qemu/qemu_monitor_json.c
| @@ -1532,7 +1532,8 @@ qemuMonitorJSONGetStatus(qemuMonitorPtr mon,
| if (reason)
| *reason = VIR_DOMAIN_PAUSED_UNKNOWN;
|
| - if (!(cmd = qemuMonitorJSONMakeCommand("query-status", NULL)))
| + if (!(cmd = qemuMonitorJSONMakeCommand("query-status",
| + "s:garbage", "foo", NULL)))
| return -1;
|
| if (qemuMonitorJSONCommand(mon, cmd, &reply) < 0)
Suggested-by: Peter Krempa <pkrempa@redhat.com>
Signed-off-by: Eric Blake <eblake@redhat.com>
Acked-by: Peter Krempa <pkrempa@redhat.com>
2019-06-12 01:59:11 +00:00
|
|
|
testQemuMonitorJSONqemuMonitorJSONGetChardevInfo(const void *opaque)
|
2013-10-02 15:11:30 +00:00
|
|
|
{
|
qemumonitorjsontest: Validate more commands against schema
The DO_TEST() macro in qemumonitorjsontest.c was not passing the
schema through, which meant that we were not validating any of those
tests for correct usage according to the schema.
In the process of mechanically altering tests to pass the schema
through, use VIR_AUTOPTR on all of the affected test instances. The
next patch will do some further cleanups that it exposes.
Tested by using this hack, where the test mistakenly passed pre-patch,
but correctly diagnosed the garbage post-patch:
| diff --git i/src/qemu/qemu_monitor_json.c w/src/qemu/qemu_monitor_json.c
| index 53a7de8b77..86d8450814 100644
| --- i/src/qemu/qemu_monitor_json.c
| +++ w/src/qemu/qemu_monitor_json.c
| @@ -1532,7 +1532,8 @@ qemuMonitorJSONGetStatus(qemuMonitorPtr mon,
| if (reason)
| *reason = VIR_DOMAIN_PAUSED_UNKNOWN;
|
| - if (!(cmd = qemuMonitorJSONMakeCommand("query-status", NULL)))
| + if (!(cmd = qemuMonitorJSONMakeCommand("query-status",
| + "s:garbage", "foo", NULL)))
| return -1;
|
| if (qemuMonitorJSONCommand(mon, cmd, &reply) < 0)
Suggested-by: Peter Krempa <pkrempa@redhat.com>
Signed-off-by: Eric Blake <eblake@redhat.com>
Acked-by: Peter Krempa <pkrempa@redhat.com>
2019-06-12 01:59:11 +00:00
|
|
|
const testGenericData *data = opaque;
|
2021-03-11 07:16:13 +00:00
|
|
|
virDomainXMLOption *xmlopt = data->xmlopt;
|
2021-07-05 14:49:52 +00:00
|
|
|
g_autoptr(GHashTable) info = virHashNew(qemuMonitorChardevInfoFree);
|
|
|
|
g_autoptr(GHashTable) expectedInfo = virHashNew(NULL);
|
2014-11-13 18:29:14 +00:00
|
|
|
qemuMonitorChardevInfo info0 = { NULL, VIR_DOMAIN_CHR_DEVICE_STATE_DEFAULT };
|
|
|
|
qemuMonitorChardevInfo info1 = { (char *) "/dev/pts/21", VIR_DOMAIN_CHR_DEVICE_STATE_CONNECTED };
|
|
|
|
qemuMonitorChardevInfo info2 = { (char *) "/dev/pts/20", VIR_DOMAIN_CHR_DEVICE_STATE_DEFAULT };
|
|
|
|
qemuMonitorChardevInfo info3 = { NULL, VIR_DOMAIN_CHR_DEVICE_STATE_DISCONNECTED };
|
2019-10-15 12:47:50 +00:00
|
|
|
g_autoptr(qemuMonitorTest) test = NULL;
|
2013-10-02 15:11:30 +00:00
|
|
|
|
qemumonitorjsontest: Validate more commands against schema
The DO_TEST() macro in qemumonitorjsontest.c was not passing the
schema through, which meant that we were not validating any of those
tests for correct usage according to the schema.
In the process of mechanically altering tests to pass the schema
through, use VIR_AUTOPTR on all of the affected test instances. The
next patch will do some further cleanups that it exposes.
Tested by using this hack, where the test mistakenly passed pre-patch,
but correctly diagnosed the garbage post-patch:
| diff --git i/src/qemu/qemu_monitor_json.c w/src/qemu/qemu_monitor_json.c
| index 53a7de8b77..86d8450814 100644
| --- i/src/qemu/qemu_monitor_json.c
| +++ w/src/qemu/qemu_monitor_json.c
| @@ -1532,7 +1532,8 @@ qemuMonitorJSONGetStatus(qemuMonitorPtr mon,
| if (reason)
| *reason = VIR_DOMAIN_PAUSED_UNKNOWN;
|
| - if (!(cmd = qemuMonitorJSONMakeCommand("query-status", NULL)))
| + if (!(cmd = qemuMonitorJSONMakeCommand("query-status",
| + "s:garbage", "foo", NULL)))
| return -1;
|
| if (qemuMonitorJSONCommand(mon, cmd, &reply) < 0)
Suggested-by: Peter Krempa <pkrempa@redhat.com>
Signed-off-by: Eric Blake <eblake@redhat.com>
Acked-by: Peter Krempa <pkrempa@redhat.com>
2019-06-12 01:59:11 +00:00
|
|
|
if (!(test = qemuMonitorTestNewSchema(xmlopt, data->schema)))
|
2013-10-02 15:11:30 +00:00
|
|
|
return -1;
|
|
|
|
|
2014-11-13 18:29:14 +00:00
|
|
|
if (virHashAddEntry(expectedInfo, "charserial1", &info1) < 0 ||
|
|
|
|
virHashAddEntry(expectedInfo, "charserial0", &info2) < 0 ||
|
|
|
|
virHashAddEntry(expectedInfo, "charmonitor", &info0) < 0 ||
|
|
|
|
virHashAddEntry(expectedInfo, "charserial2", &info3) < 0) {
|
2013-10-02 15:11:30 +00:00
|
|
|
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
2014-11-13 15:17:21 +00:00
|
|
|
"Unable to create expectedInfo hash table");
|
2021-07-05 14:49:05 +00:00
|
|
|
return -1;
|
2013-10-02 15:11:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (qemuMonitorTestAddItem(test, "query-chardev",
|
|
|
|
"{"
|
|
|
|
" \"return\": ["
|
|
|
|
" {"
|
|
|
|
" \"filename\": \"pty:/dev/pts/21\","
|
2014-11-13 18:29:14 +00:00
|
|
|
" \"label\": \"charserial1\","
|
|
|
|
" \"frontend-open\": true"
|
2013-10-02 15:11:30 +00:00
|
|
|
" },"
|
|
|
|
" {"
|
|
|
|
" \"filename\": \"pty:/dev/pts/20\","
|
|
|
|
" \"label\": \"charserial0\""
|
|
|
|
" },"
|
|
|
|
" {"
|
|
|
|
" \"filename\": \"unix:/var/lib/libvirt/qemu/gentoo.monitor,server\","
|
|
|
|
" \"label\": \"charmonitor\""
|
2014-11-13 18:29:14 +00:00
|
|
|
" },"
|
|
|
|
" {"
|
|
|
|
" \"filename\": \"unix:/path/to/socket,server\","
|
|
|
|
" \"label\": \"charserial2\","
|
|
|
|
" \"frontend-open\": false"
|
2013-10-02 15:11:30 +00:00
|
|
|
" }"
|
|
|
|
" ],"
|
|
|
|
" \"id\": \"libvirt-15\""
|
|
|
|
"}") < 0)
|
2021-07-05 14:49:05 +00:00
|
|
|
return -1;
|
2013-10-02 15:11:30 +00:00
|
|
|
|
2014-11-13 15:17:21 +00:00
|
|
|
if (qemuMonitorJSONGetChardevInfo(qemuMonitorTestGetMonitor(test),
|
|
|
|
info) < 0)
|
2021-07-05 14:49:05 +00:00
|
|
|
return -1;
|
2013-10-02 15:11:30 +00:00
|
|
|
|
2014-11-13 18:29:14 +00:00
|
|
|
if (!virHashEqual(info, expectedInfo, testHashEqualChardevInfo)) {
|
2013-10-02 15:11:30 +00:00
|
|
|
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
|
|
|
"Hashtable is different to the expected one");
|
2021-07-05 14:49:05 +00:00
|
|
|
return -1;
|
2013-10-02 15:11:30 +00:00
|
|
|
}
|
|
|
|
|
2021-07-05 14:49:05 +00:00
|
|
|
return 0;
|
2013-10-02 15:11:30 +00:00
|
|
|
}
|
|
|
|
|
2016-10-31 21:22:59 +00:00
|
|
|
|
|
|
|
static int
|
2017-04-03 16:53:31 +00:00
|
|
|
testValidateGetBlockIoThrottle(const virDomainBlockIoTuneInfo *info,
|
|
|
|
const virDomainBlockIoTuneInfo *expectedInfo)
|
2016-10-31 21:22:59 +00:00
|
|
|
{
|
|
|
|
#define VALIDATE_IOTUNE(field) \
|
2017-04-03 16:53:31 +00:00
|
|
|
if (info->field != expectedInfo->field) { \
|
2016-10-31 21:22:59 +00:00
|
|
|
virReportError(VIR_ERR_INTERNAL_ERROR, \
|
2017-11-03 12:09:47 +00:00
|
|
|
"info->%s=%llu != expected=%llu", \
|
2017-04-03 16:53:31 +00:00
|
|
|
#field, info->field, expectedInfo->field); \
|
2016-10-31 21:22:59 +00:00
|
|
|
return -1; \
|
|
|
|
} \
|
2017-04-03 16:53:31 +00:00
|
|
|
if (info->field##_max != expectedInfo->field##_max) { \
|
2016-10-31 21:22:59 +00:00
|
|
|
virReportError(VIR_ERR_INTERNAL_ERROR, \
|
2017-11-03 12:09:47 +00:00
|
|
|
"info->%s_max=%llu != expected=%llu", \
|
2017-04-03 16:53:31 +00:00
|
|
|
#field, info->field##_max, expectedInfo->field##_max); \
|
2016-10-31 21:22:59 +00:00
|
|
|
return -1; \
|
|
|
|
} \
|
2017-04-03 16:53:31 +00:00
|
|
|
if (info->field##_max_length != expectedInfo->field##_max_length) { \
|
2016-10-31 21:22:59 +00:00
|
|
|
virReportError(VIR_ERR_INTERNAL_ERROR, \
|
2017-11-03 12:09:47 +00:00
|
|
|
"info->%s_max_length=%llu != expected=%llu", \
|
2017-04-03 16:53:31 +00:00
|
|
|
#field, info->field##_max_length, \
|
|
|
|
expectedInfo->field##_max_length); \
|
2016-10-31 21:22:59 +00:00
|
|
|
return -1; \
|
|
|
|
}
|
|
|
|
VALIDATE_IOTUNE(total_bytes_sec);
|
|
|
|
VALIDATE_IOTUNE(read_bytes_sec);
|
|
|
|
VALIDATE_IOTUNE(write_bytes_sec);
|
|
|
|
VALIDATE_IOTUNE(total_iops_sec);
|
|
|
|
VALIDATE_IOTUNE(read_iops_sec);
|
|
|
|
VALIDATE_IOTUNE(write_iops_sec);
|
2017-04-03 16:53:31 +00:00
|
|
|
if (info->size_iops_sec != expectedInfo->size_iops_sec) {
|
2016-10-31 21:22:59 +00:00
|
|
|
virReportError(VIR_ERR_INTERNAL_ERROR,
|
2017-04-03 16:53:31 +00:00
|
|
|
"info->size_iops_sec=%llu != expected=%llu",
|
|
|
|
info->size_iops_sec, expectedInfo->size_iops_sec);
|
2016-10-31 21:22:59 +00:00
|
|
|
return -1;
|
|
|
|
}
|
2017-04-03 16:53:31 +00:00
|
|
|
if (STRNEQ(info->group_name, expectedInfo->group_name)) {
|
2016-10-31 21:22:59 +00:00
|
|
|
virReportError(VIR_ERR_INTERNAL_ERROR,
|
2017-04-03 16:53:31 +00:00
|
|
|
"info->group_name=%s != expected=%s",
|
|
|
|
info->group_name, expectedInfo->group_name);
|
2016-10-31 21:22:59 +00:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
#undef VALIDATE_IOTUNE
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2013-10-02 16:46:42 +00:00
|
|
|
static int
|
qemumonitorjsontest: Validate more commands against schema
The DO_TEST() macro in qemumonitorjsontest.c was not passing the
schema through, which meant that we were not validating any of those
tests for correct usage according to the schema.
In the process of mechanically altering tests to pass the schema
through, use VIR_AUTOPTR on all of the affected test instances. The
next patch will do some further cleanups that it exposes.
Tested by using this hack, where the test mistakenly passed pre-patch,
but correctly diagnosed the garbage post-patch:
| diff --git i/src/qemu/qemu_monitor_json.c w/src/qemu/qemu_monitor_json.c
| index 53a7de8b77..86d8450814 100644
| --- i/src/qemu/qemu_monitor_json.c
| +++ w/src/qemu/qemu_monitor_json.c
| @@ -1532,7 +1532,8 @@ qemuMonitorJSONGetStatus(qemuMonitorPtr mon,
| if (reason)
| *reason = VIR_DOMAIN_PAUSED_UNKNOWN;
|
| - if (!(cmd = qemuMonitorJSONMakeCommand("query-status", NULL)))
| + if (!(cmd = qemuMonitorJSONMakeCommand("query-status",
| + "s:garbage", "foo", NULL)))
| return -1;
|
| if (qemuMonitorJSONCommand(mon, cmd, &reply) < 0)
Suggested-by: Peter Krempa <pkrempa@redhat.com>
Signed-off-by: Eric Blake <eblake@redhat.com>
Acked-by: Peter Krempa <pkrempa@redhat.com>
2019-06-12 01:59:11 +00:00
|
|
|
testQemuMonitorJSONqemuMonitorJSONSetBlockIoThrottle(const void *opaque)
|
2013-10-02 16:46:42 +00:00
|
|
|
{
|
qemumonitorjsontest: Validate more commands against schema
The DO_TEST() macro in qemumonitorjsontest.c was not passing the
schema through, which meant that we were not validating any of those
tests for correct usage according to the schema.
In the process of mechanically altering tests to pass the schema
through, use VIR_AUTOPTR on all of the affected test instances. The
next patch will do some further cleanups that it exposes.
Tested by using this hack, where the test mistakenly passed pre-patch,
but correctly diagnosed the garbage post-patch:
| diff --git i/src/qemu/qemu_monitor_json.c w/src/qemu/qemu_monitor_json.c
| index 53a7de8b77..86d8450814 100644
| --- i/src/qemu/qemu_monitor_json.c
| +++ w/src/qemu/qemu_monitor_json.c
| @@ -1532,7 +1532,8 @@ qemuMonitorJSONGetStatus(qemuMonitorPtr mon,
| if (reason)
| *reason = VIR_DOMAIN_PAUSED_UNKNOWN;
|
| - if (!(cmd = qemuMonitorJSONMakeCommand("query-status", NULL)))
| + if (!(cmd = qemuMonitorJSONMakeCommand("query-status",
| + "s:garbage", "foo", NULL)))
| return -1;
|
| if (qemuMonitorJSONCommand(mon, cmd, &reply) < 0)
Suggested-by: Peter Krempa <pkrempa@redhat.com>
Signed-off-by: Eric Blake <eblake@redhat.com>
Acked-by: Peter Krempa <pkrempa@redhat.com>
2019-06-12 01:59:11 +00:00
|
|
|
const testGenericData *data = opaque;
|
2021-03-11 07:16:13 +00:00
|
|
|
virDomainXMLOption *xmlopt = data->xmlopt;
|
2013-10-02 16:46:42 +00:00
|
|
|
int ret = -1;
|
|
|
|
virDomainBlockIoTuneInfo info, expectedInfo;
|
2019-10-15 12:47:50 +00:00
|
|
|
g_autoptr(qemuMonitorTest) test = NULL;
|
2013-10-02 16:46:42 +00:00
|
|
|
|
qemumonitorjsontest: Validate more commands against schema
The DO_TEST() macro in qemumonitorjsontest.c was not passing the
schema through, which meant that we were not validating any of those
tests for correct usage according to the schema.
In the process of mechanically altering tests to pass the schema
through, use VIR_AUTOPTR on all of the affected test instances. The
next patch will do some further cleanups that it exposes.
Tested by using this hack, where the test mistakenly passed pre-patch,
but correctly diagnosed the garbage post-patch:
| diff --git i/src/qemu/qemu_monitor_json.c w/src/qemu/qemu_monitor_json.c
| index 53a7de8b77..86d8450814 100644
| --- i/src/qemu/qemu_monitor_json.c
| +++ w/src/qemu/qemu_monitor_json.c
| @@ -1532,7 +1532,8 @@ qemuMonitorJSONGetStatus(qemuMonitorPtr mon,
| if (reason)
| *reason = VIR_DOMAIN_PAUSED_UNKNOWN;
|
| - if (!(cmd = qemuMonitorJSONMakeCommand("query-status", NULL)))
| + if (!(cmd = qemuMonitorJSONMakeCommand("query-status",
| + "s:garbage", "foo", NULL)))
| return -1;
|
| if (qemuMonitorJSONCommand(mon, cmd, &reply) < 0)
Suggested-by: Peter Krempa <pkrempa@redhat.com>
Signed-off-by: Eric Blake <eblake@redhat.com>
Acked-by: Peter Krempa <pkrempa@redhat.com>
2019-06-12 01:59:11 +00:00
|
|
|
if (!(test = qemuMonitorTestNewSchema(xmlopt, data->schema)))
|
2013-10-02 16:46:42 +00:00
|
|
|
return -1;
|
|
|
|
|
2016-10-31 21:22:59 +00:00
|
|
|
expectedInfo = (virDomainBlockIoTuneInfo) {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, NULL, 15, 16, 17, 18, 19, 20};
|
2019-10-20 11:49:46 +00:00
|
|
|
expectedInfo.group_name = g_strdup("group14");
|
2013-10-02 16:46:42 +00:00
|
|
|
|
2023-05-22 15:08:27 +00:00
|
|
|
if (qemuMonitorTestAddItem(test, "query-block", queryBlockReply) < 0)
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
if (qemuMonitorTestAddItemVerbatim(test,
|
|
|
|
"{\"execute\":\"block_set_io_throttle\","
|
2023-05-23 12:20:29 +00:00
|
|
|
" \"arguments\":{\"id\": \"drive-virtio-disk1\","
|
2023-05-22 15:08:27 +00:00
|
|
|
" \"bps\": 1,"
|
|
|
|
" \"bps_rd\": 2,"
|
|
|
|
" \"bps_wr\": 3,"
|
|
|
|
" \"iops\": 4,"
|
|
|
|
" \"iops_rd\": 5,"
|
|
|
|
" \"iops_wr\": 6,"
|
|
|
|
" \"bps_max\": 7,"
|
|
|
|
" \"bps_rd_max\": 8,"
|
|
|
|
" \"bps_wr_max\": 9,"
|
|
|
|
" \"iops_max\": 10,"
|
|
|
|
" \"iops_rd_max\": 11,"
|
|
|
|
" \"iops_wr_max\": 12,"
|
|
|
|
" \"iops_size\": 13,"
|
|
|
|
" \"group\": \"group14\","
|
|
|
|
" \"bps_max_length\": 15,"
|
|
|
|
" \"bps_rd_max_length\": 16,"
|
|
|
|
" \"bps_wr_max_length\": 17,"
|
|
|
|
" \"iops_max_length\": 18,"
|
|
|
|
" \"iops_rd_max_length\": 19,"
|
|
|
|
" \"iops_wr_max_length\": 20},"
|
|
|
|
" \"id\":\"libvirt-2\"}",
|
|
|
|
NULL,
|
|
|
|
"{ \"return\" : {}}") < 0)
|
|
|
|
return -1;
|
2013-10-02 16:46:42 +00:00
|
|
|
|
|
|
|
if (qemuMonitorJSONGetBlockIoThrottle(qemuMonitorTestGetMonitor(test),
|
2023-05-23 13:32:49 +00:00
|
|
|
"drive-virtio-disk0", &info) < 0)
|
2013-10-02 16:46:42 +00:00
|
|
|
goto cleanup;
|
|
|
|
|
2017-04-03 16:53:31 +00:00
|
|
|
if (testValidateGetBlockIoThrottle(&info, &expectedInfo) < 0)
|
2013-10-02 16:46:42 +00:00
|
|
|
goto cleanup;
|
|
|
|
|
|
|
|
if (qemuMonitorJSONSetBlockIoThrottle(qemuMonitorTestGetMonitor(test),
|
2023-05-23 13:32:49 +00:00
|
|
|
"drive-virtio-disk1", &info) < 0)
|
2013-10-02 16:46:42 +00:00
|
|
|
goto cleanup;
|
|
|
|
|
|
|
|
ret = 0;
|
2014-03-25 06:53:44 +00:00
|
|
|
cleanup:
|
2016-10-31 21:22:59 +00:00
|
|
|
VIR_FREE(info.group_name);
|
|
|
|
VIR_FREE(expectedInfo.group_name);
|
2013-10-02 16:46:42 +00:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2013-10-02 16:55:42 +00:00
|
|
|
static int
|
qemumonitorjsontest: Validate more commands against schema
The DO_TEST() macro in qemumonitorjsontest.c was not passing the
schema through, which meant that we were not validating any of those
tests for correct usage according to the schema.
In the process of mechanically altering tests to pass the schema
through, use VIR_AUTOPTR on all of the affected test instances. The
next patch will do some further cleanups that it exposes.
Tested by using this hack, where the test mistakenly passed pre-patch,
but correctly diagnosed the garbage post-patch:
| diff --git i/src/qemu/qemu_monitor_json.c w/src/qemu/qemu_monitor_json.c
| index 53a7de8b77..86d8450814 100644
| --- i/src/qemu/qemu_monitor_json.c
| +++ w/src/qemu/qemu_monitor_json.c
| @@ -1532,7 +1532,8 @@ qemuMonitorJSONGetStatus(qemuMonitorPtr mon,
| if (reason)
| *reason = VIR_DOMAIN_PAUSED_UNKNOWN;
|
| - if (!(cmd = qemuMonitorJSONMakeCommand("query-status", NULL)))
| + if (!(cmd = qemuMonitorJSONMakeCommand("query-status",
| + "s:garbage", "foo", NULL)))
| return -1;
|
| if (qemuMonitorJSONCommand(mon, cmd, &reply) < 0)
Suggested-by: Peter Krempa <pkrempa@redhat.com>
Signed-off-by: Eric Blake <eblake@redhat.com>
Acked-by: Peter Krempa <pkrempa@redhat.com>
2019-06-12 01:59:11 +00:00
|
|
|
testQemuMonitorJSONqemuMonitorJSONGetTargetArch(const void *opaque)
|
2013-10-02 16:55:42 +00:00
|
|
|
{
|
qemumonitorjsontest: Validate more commands against schema
The DO_TEST() macro in qemumonitorjsontest.c was not passing the
schema through, which meant that we were not validating any of those
tests for correct usage according to the schema.
In the process of mechanically altering tests to pass the schema
through, use VIR_AUTOPTR on all of the affected test instances. The
next patch will do some further cleanups that it exposes.
Tested by using this hack, where the test mistakenly passed pre-patch,
but correctly diagnosed the garbage post-patch:
| diff --git i/src/qemu/qemu_monitor_json.c w/src/qemu/qemu_monitor_json.c
| index 53a7de8b77..86d8450814 100644
| --- i/src/qemu/qemu_monitor_json.c
| +++ w/src/qemu/qemu_monitor_json.c
| @@ -1532,7 +1532,8 @@ qemuMonitorJSONGetStatus(qemuMonitorPtr mon,
| if (reason)
| *reason = VIR_DOMAIN_PAUSED_UNKNOWN;
|
| - if (!(cmd = qemuMonitorJSONMakeCommand("query-status", NULL)))
| + if (!(cmd = qemuMonitorJSONMakeCommand("query-status",
| + "s:garbage", "foo", NULL)))
| return -1;
|
| if (qemuMonitorJSONCommand(mon, cmd, &reply) < 0)
Suggested-by: Peter Krempa <pkrempa@redhat.com>
Signed-off-by: Eric Blake <eblake@redhat.com>
Acked-by: Peter Krempa <pkrempa@redhat.com>
2019-06-12 01:59:11 +00:00
|
|
|
const testGenericData *data = opaque;
|
2021-03-11 07:16:13 +00:00
|
|
|
virDomainXMLOption *xmlopt = data->xmlopt;
|
2020-03-05 08:33:55 +00:00
|
|
|
g_autofree char *arch = NULL;
|
2019-10-15 12:47:50 +00:00
|
|
|
g_autoptr(qemuMonitorTest) test = NULL;
|
2013-10-02 16:55:42 +00:00
|
|
|
|
qemumonitorjsontest: Validate more commands against schema
The DO_TEST() macro in qemumonitorjsontest.c was not passing the
schema through, which meant that we were not validating any of those
tests for correct usage according to the schema.
In the process of mechanically altering tests to pass the schema
through, use VIR_AUTOPTR on all of the affected test instances. The
next patch will do some further cleanups that it exposes.
Tested by using this hack, where the test mistakenly passed pre-patch,
but correctly diagnosed the garbage post-patch:
| diff --git i/src/qemu/qemu_monitor_json.c w/src/qemu/qemu_monitor_json.c
| index 53a7de8b77..86d8450814 100644
| --- i/src/qemu/qemu_monitor_json.c
| +++ w/src/qemu/qemu_monitor_json.c
| @@ -1532,7 +1532,8 @@ qemuMonitorJSONGetStatus(qemuMonitorPtr mon,
| if (reason)
| *reason = VIR_DOMAIN_PAUSED_UNKNOWN;
|
| - if (!(cmd = qemuMonitorJSONMakeCommand("query-status", NULL)))
| + if (!(cmd = qemuMonitorJSONMakeCommand("query-status",
| + "s:garbage", "foo", NULL)))
| return -1;
|
| if (qemuMonitorJSONCommand(mon, cmd, &reply) < 0)
Suggested-by: Peter Krempa <pkrempa@redhat.com>
Signed-off-by: Eric Blake <eblake@redhat.com>
Acked-by: Peter Krempa <pkrempa@redhat.com>
2019-06-12 01:59:11 +00:00
|
|
|
if (!(test = qemuMonitorTestNewSchema(xmlopt, data->schema)))
|
2013-10-02 16:55:42 +00:00
|
|
|
return -1;
|
|
|
|
|
|
|
|
if (qemuMonitorTestAddItem(test, "query-target",
|
|
|
|
"{"
|
|
|
|
" \"return\": {"
|
|
|
|
" \"arch\": \"x86_64\""
|
|
|
|
" },"
|
|
|
|
" \"id\": \"libvirt-21\""
|
|
|
|
"}") < 0)
|
2020-03-05 08:33:55 +00:00
|
|
|
return -1;
|
2013-10-02 16:55:42 +00:00
|
|
|
|
|
|
|
if (!(arch = qemuMonitorJSONGetTargetArch(qemuMonitorTestGetMonitor(test))))
|
2020-03-05 08:33:55 +00:00
|
|
|
return -1;
|
2013-10-02 16:55:42 +00:00
|
|
|
|
|
|
|
if (STRNEQ(arch, "x86_64")) {
|
|
|
|
virReportError(VIR_ERR_INTERNAL_ERROR,
|
|
|
|
"Unexpected architecture %s, expecting x86_64",
|
|
|
|
arch);
|
2020-03-05 08:33:55 +00:00
|
|
|
return -1;
|
2013-10-02 16:55:42 +00:00
|
|
|
}
|
|
|
|
|
2020-03-05 08:33:55 +00:00
|
|
|
return 0;
|
2013-10-02 16:55:42 +00:00
|
|
|
}
|
|
|
|
|
2013-10-02 17:03:53 +00:00
|
|
|
static int
|
qemumonitorjsontest: Validate more commands against schema
The DO_TEST() macro in qemumonitorjsontest.c was not passing the
schema through, which meant that we were not validating any of those
tests for correct usage according to the schema.
In the process of mechanically altering tests to pass the schema
through, use VIR_AUTOPTR on all of the affected test instances. The
next patch will do some further cleanups that it exposes.
Tested by using this hack, where the test mistakenly passed pre-patch,
but correctly diagnosed the garbage post-patch:
| diff --git i/src/qemu/qemu_monitor_json.c w/src/qemu/qemu_monitor_json.c
| index 53a7de8b77..86d8450814 100644
| --- i/src/qemu/qemu_monitor_json.c
| +++ w/src/qemu/qemu_monitor_json.c
| @@ -1532,7 +1532,8 @@ qemuMonitorJSONGetStatus(qemuMonitorPtr mon,
| if (reason)
| *reason = VIR_DOMAIN_PAUSED_UNKNOWN;
|
| - if (!(cmd = qemuMonitorJSONMakeCommand("query-status", NULL)))
| + if (!(cmd = qemuMonitorJSONMakeCommand("query-status",
| + "s:garbage", "foo", NULL)))
| return -1;
|
| if (qemuMonitorJSONCommand(mon, cmd, &reply) < 0)
Suggested-by: Peter Krempa <pkrempa@redhat.com>
Signed-off-by: Eric Blake <eblake@redhat.com>
Acked-by: Peter Krempa <pkrempa@redhat.com>
2019-06-12 01:59:11 +00:00
|
|
|
testQemuMonitorJSONqemuMonitorJSONGetMigrationCapabilities(const void *opaque)
|
2013-10-02 17:03:53 +00:00
|
|
|
{
|
qemumonitorjsontest: Validate more commands against schema
The DO_TEST() macro in qemumonitorjsontest.c was not passing the
schema through, which meant that we were not validating any of those
tests for correct usage according to the schema.
In the process of mechanically altering tests to pass the schema
through, use VIR_AUTOPTR on all of the affected test instances. The
next patch will do some further cleanups that it exposes.
Tested by using this hack, where the test mistakenly passed pre-patch,
but correctly diagnosed the garbage post-patch:
| diff --git i/src/qemu/qemu_monitor_json.c w/src/qemu/qemu_monitor_json.c
| index 53a7de8b77..86d8450814 100644
| --- i/src/qemu/qemu_monitor_json.c
| +++ w/src/qemu/qemu_monitor_json.c
| @@ -1532,7 +1532,8 @@ qemuMonitorJSONGetStatus(qemuMonitorPtr mon,
| if (reason)
| *reason = VIR_DOMAIN_PAUSED_UNKNOWN;
|
| - if (!(cmd = qemuMonitorJSONMakeCommand("query-status", NULL)))
| + if (!(cmd = qemuMonitorJSONMakeCommand("query-status",
| + "s:garbage", "foo", NULL)))
| return -1;
|
| if (qemuMonitorJSONCommand(mon, cmd, &reply) < 0)
Suggested-by: Peter Krempa <pkrempa@redhat.com>
Signed-off-by: Eric Blake <eblake@redhat.com>
Acked-by: Peter Krempa <pkrempa@redhat.com>
2019-06-12 01:59:11 +00:00
|
|
|
const testGenericData *data = opaque;
|
2021-03-11 07:16:13 +00:00
|
|
|
virDomainXMLOption *xmlopt = data->xmlopt;
|
2022-05-10 13:20:25 +00:00
|
|
|
size_t cap;
|
2020-11-30 14:29:49 +00:00
|
|
|
g_auto(GStrv) caps = NULL;
|
|
|
|
g_autoptr(virBitmap) bitmap = NULL;
|
|
|
|
g_autoptr(virJSONValue) json = NULL;
|
2013-10-02 17:03:53 +00:00
|
|
|
const char *reply =
|
|
|
|
"{"
|
|
|
|
" \"return\": ["
|
|
|
|
" {"
|
|
|
|
" \"state\": false,"
|
|
|
|
" \"capability\": \"xbzrle\""
|
2022-05-10 13:20:25 +00:00
|
|
|
" },"
|
|
|
|
" {"
|
|
|
|
" \"state\": true,"
|
|
|
|
" \"capability\": \"events\""
|
2013-10-02 17:03:53 +00:00
|
|
|
" }"
|
|
|
|
" ],"
|
|
|
|
" \"id\": \"libvirt-22\""
|
|
|
|
"}";
|
2019-10-15 12:47:50 +00:00
|
|
|
g_autoptr(qemuMonitorTest) test = NULL;
|
2013-10-02 17:03:53 +00:00
|
|
|
|
qemumonitorjsontest: Validate more commands against schema
The DO_TEST() macro in qemumonitorjsontest.c was not passing the
schema through, which meant that we were not validating any of those
tests for correct usage according to the schema.
In the process of mechanically altering tests to pass the schema
through, use VIR_AUTOPTR on all of the affected test instances. The
next patch will do some further cleanups that it exposes.
Tested by using this hack, where the test mistakenly passed pre-patch,
but correctly diagnosed the garbage post-patch:
| diff --git i/src/qemu/qemu_monitor_json.c w/src/qemu/qemu_monitor_json.c
| index 53a7de8b77..86d8450814 100644
| --- i/src/qemu/qemu_monitor_json.c
| +++ w/src/qemu/qemu_monitor_json.c
| @@ -1532,7 +1532,8 @@ qemuMonitorJSONGetStatus(qemuMonitorPtr mon,
| if (reason)
| *reason = VIR_DOMAIN_PAUSED_UNKNOWN;
|
| - if (!(cmd = qemuMonitorJSONMakeCommand("query-status", NULL)))
| + if (!(cmd = qemuMonitorJSONMakeCommand("query-status",
| + "s:garbage", "foo", NULL)))
| return -1;
|
| if (qemuMonitorJSONCommand(mon, cmd, &reply) < 0)
Suggested-by: Peter Krempa <pkrempa@redhat.com>
Signed-off-by: Eric Blake <eblake@redhat.com>
Acked-by: Peter Krempa <pkrempa@redhat.com>
2019-06-12 01:59:11 +00:00
|
|
|
if (!(test = qemuMonitorTestNewSchema(xmlopt, data->schema)))
|
2013-10-02 17:03:53 +00:00
|
|
|
return -1;
|
|
|
|
|
|
|
|
if (qemuMonitorTestAddItem(test, "query-migrate-capabilities", reply) < 0 ||
|
|
|
|
qemuMonitorTestAddItem(test, "migrate-set-capabilities",
|
|
|
|
"{\"return\":{}}") < 0)
|
2020-11-30 14:29:49 +00:00
|
|
|
return -1;
|
2013-10-02 17:03:53 +00:00
|
|
|
|
2017-10-17 20:01:01 +00:00
|
|
|
if (qemuMonitorGetMigrationCapabilities(qemuMonitorTestGetMonitor(test),
|
|
|
|
&caps) < 0)
|
2020-11-30 14:29:49 +00:00
|
|
|
return -1;
|
2017-10-17 20:01:01 +00:00
|
|
|
|
2022-05-10 13:20:25 +00:00
|
|
|
for (cap = 0; cap < QEMU_MIGRATION_CAP_LAST; cap++) {
|
|
|
|
const char *capStr = qemuMigrationCapabilityTypeToString(cap);
|
|
|
|
bool present = g_strv_contains((const char **) caps, capStr);
|
|
|
|
|
|
|
|
switch (cap) {
|
|
|
|
case QEMU_MIGRATION_CAP_XBZRLE:
|
|
|
|
case QEMU_MIGRATION_CAP_EVENTS:
|
|
|
|
if (!present) {
|
|
|
|
VIR_TEST_VERBOSE("Expected capability %s is missing", capStr);
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
if (present) {
|
|
|
|
VIR_TEST_VERBOSE("Unexpected capability %s found", capStr);
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
}
|
2013-10-02 17:03:53 +00:00
|
|
|
}
|
|
|
|
|
2018-04-05 20:17:26 +00:00
|
|
|
bitmap = virBitmapNew(QEMU_MIGRATION_CAP_LAST);
|
|
|
|
ignore_value(virBitmapSetBit(bitmap, QEMU_MIGRATION_CAP_XBZRLE));
|
2018-04-05 18:59:07 +00:00
|
|
|
if (!(json = qemuMigrationCapsToJSON(bitmap, bitmap)))
|
2020-11-30 14:29:49 +00:00
|
|
|
return -1;
|
2018-04-05 18:59:07 +00:00
|
|
|
|
2020-11-30 14:29:49 +00:00
|
|
|
return qemuMonitorJSONSetMigrationCapabilities(qemuMonitorTestGetMonitor(test),
|
|
|
|
&json);
|
2013-10-02 17:03:53 +00:00
|
|
|
}
|
|
|
|
|
2013-10-02 16:23:17 +00:00
|
|
|
static int
|
qemumonitorjsontest: Validate more commands against schema
The DO_TEST() macro in qemumonitorjsontest.c was not passing the
schema through, which meant that we were not validating any of those
tests for correct usage according to the schema.
In the process of mechanically altering tests to pass the schema
through, use VIR_AUTOPTR on all of the affected test instances. The
next patch will do some further cleanups that it exposes.
Tested by using this hack, where the test mistakenly passed pre-patch,
but correctly diagnosed the garbage post-patch:
| diff --git i/src/qemu/qemu_monitor_json.c w/src/qemu/qemu_monitor_json.c
| index 53a7de8b77..86d8450814 100644
| --- i/src/qemu/qemu_monitor_json.c
| +++ w/src/qemu/qemu_monitor_json.c
| @@ -1532,7 +1532,8 @@ qemuMonitorJSONGetStatus(qemuMonitorPtr mon,
| if (reason)
| *reason = VIR_DOMAIN_PAUSED_UNKNOWN;
|
| - if (!(cmd = qemuMonitorJSONMakeCommand("query-status", NULL)))
| + if (!(cmd = qemuMonitorJSONMakeCommand("query-status",
| + "s:garbage", "foo", NULL)))
| return -1;
|
| if (qemuMonitorJSONCommand(mon, cmd, &reply) < 0)
Suggested-by: Peter Krempa <pkrempa@redhat.com>
Signed-off-by: Eric Blake <eblake@redhat.com>
Acked-by: Peter Krempa <pkrempa@redhat.com>
2019-06-12 01:59:11 +00:00
|
|
|
testQemuMonitorJSONqemuMonitorJSONSendKey(const void *opaque)
|
2013-10-02 16:23:17 +00:00
|
|
|
{
|
qemumonitorjsontest: Validate more commands against schema
The DO_TEST() macro in qemumonitorjsontest.c was not passing the
schema through, which meant that we were not validating any of those
tests for correct usage according to the schema.
In the process of mechanically altering tests to pass the schema
through, use VIR_AUTOPTR on all of the affected test instances. The
next patch will do some further cleanups that it exposes.
Tested by using this hack, where the test mistakenly passed pre-patch,
but correctly diagnosed the garbage post-patch:
| diff --git i/src/qemu/qemu_monitor_json.c w/src/qemu/qemu_monitor_json.c
| index 53a7de8b77..86d8450814 100644
| --- i/src/qemu/qemu_monitor_json.c
| +++ w/src/qemu/qemu_monitor_json.c
| @@ -1532,7 +1532,8 @@ qemuMonitorJSONGetStatus(qemuMonitorPtr mon,
| if (reason)
| *reason = VIR_DOMAIN_PAUSED_UNKNOWN;
|
| - if (!(cmd = qemuMonitorJSONMakeCommand("query-status", NULL)))
| + if (!(cmd = qemuMonitorJSONMakeCommand("query-status",
| + "s:garbage", "foo", NULL)))
| return -1;
|
| if (qemuMonitorJSONCommand(mon, cmd, &reply) < 0)
Suggested-by: Peter Krempa <pkrempa@redhat.com>
Signed-off-by: Eric Blake <eblake@redhat.com>
Acked-by: Peter Krempa <pkrempa@redhat.com>
2019-06-12 01:59:11 +00:00
|
|
|
const testGenericData *data = opaque;
|
2021-03-11 07:16:13 +00:00
|
|
|
virDomainXMLOption *xmlopt = data->xmlopt;
|
2013-10-02 16:23:17 +00:00
|
|
|
unsigned int keycodes[] = {43, 26, 46, 32};
|
2019-10-15 12:47:50 +00:00
|
|
|
g_autoptr(qemuMonitorTest) test = NULL;
|
2013-10-02 16:23:17 +00:00
|
|
|
|
qemumonitorjsontest: Validate more commands against schema
The DO_TEST() macro in qemumonitorjsontest.c was not passing the
schema through, which meant that we were not validating any of those
tests for correct usage according to the schema.
In the process of mechanically altering tests to pass the schema
through, use VIR_AUTOPTR on all of the affected test instances. The
next patch will do some further cleanups that it exposes.
Tested by using this hack, where the test mistakenly passed pre-patch,
but correctly diagnosed the garbage post-patch:
| diff --git i/src/qemu/qemu_monitor_json.c w/src/qemu/qemu_monitor_json.c
| index 53a7de8b77..86d8450814 100644
| --- i/src/qemu/qemu_monitor_json.c
| +++ w/src/qemu/qemu_monitor_json.c
| @@ -1532,7 +1532,8 @@ qemuMonitorJSONGetStatus(qemuMonitorPtr mon,
| if (reason)
| *reason = VIR_DOMAIN_PAUSED_UNKNOWN;
|
| - if (!(cmd = qemuMonitorJSONMakeCommand("query-status", NULL)))
| + if (!(cmd = qemuMonitorJSONMakeCommand("query-status",
| + "s:garbage", "foo", NULL)))
| return -1;
|
| if (qemuMonitorJSONCommand(mon, cmd, &reply) < 0)
Suggested-by: Peter Krempa <pkrempa@redhat.com>
Signed-off-by: Eric Blake <eblake@redhat.com>
Acked-by: Peter Krempa <pkrempa@redhat.com>
2019-06-12 01:59:11 +00:00
|
|
|
if (!(test = qemuMonitorTestNewSchema(xmlopt, data->schema)))
|
2013-10-02 16:23:17 +00:00
|
|
|
return -1;
|
|
|
|
|
|
|
|
if (qemuMonitorTestAddItem(test, "send-key",
|
|
|
|
"{\"return\": {}, \"id\": \"libvirt-16\"}") < 0)
|
2019-06-11 03:01:08 +00:00
|
|
|
return -1;
|
2013-10-02 16:23:17 +00:00
|
|
|
|
|
|
|
if (qemuMonitorJSONSendKey(qemuMonitorTestGetMonitor(test),
|
2019-10-15 11:55:26 +00:00
|
|
|
0, keycodes, G_N_ELEMENTS(keycodes)) < 0)
|
2019-06-11 03:01:08 +00:00
|
|
|
return -1;
|
2013-10-02 16:23:17 +00:00
|
|
|
|
2019-06-11 03:01:08 +00:00
|
|
|
return 0;
|
2013-10-02 16:23:17 +00:00
|
|
|
}
|
|
|
|
|
2014-06-03 09:19:51 +00:00
|
|
|
static int
|
qemumonitorjsontest: Validate more commands against schema
The DO_TEST() macro in qemumonitorjsontest.c was not passing the
schema through, which meant that we were not validating any of those
tests for correct usage according to the schema.
In the process of mechanically altering tests to pass the schema
through, use VIR_AUTOPTR on all of the affected test instances. The
next patch will do some further cleanups that it exposes.
Tested by using this hack, where the test mistakenly passed pre-patch,
but correctly diagnosed the garbage post-patch:
| diff --git i/src/qemu/qemu_monitor_json.c w/src/qemu/qemu_monitor_json.c
| index 53a7de8b77..86d8450814 100644
| --- i/src/qemu/qemu_monitor_json.c
| +++ w/src/qemu/qemu_monitor_json.c
| @@ -1532,7 +1532,8 @@ qemuMonitorJSONGetStatus(qemuMonitorPtr mon,
| if (reason)
| *reason = VIR_DOMAIN_PAUSED_UNKNOWN;
|
| - if (!(cmd = qemuMonitorJSONMakeCommand("query-status", NULL)))
| + if (!(cmd = qemuMonitorJSONMakeCommand("query-status",
| + "s:garbage", "foo", NULL)))
| return -1;
|
| if (qemuMonitorJSONCommand(mon, cmd, &reply) < 0)
Suggested-by: Peter Krempa <pkrempa@redhat.com>
Signed-off-by: Eric Blake <eblake@redhat.com>
Acked-by: Peter Krempa <pkrempa@redhat.com>
2019-06-12 01:59:11 +00:00
|
|
|
testQemuMonitorJSONqemuMonitorJSONSendKeyHoldtime(const void *opaque)
|
2014-06-03 09:19:51 +00:00
|
|
|
{
|
qemumonitorjsontest: Validate more commands against schema
The DO_TEST() macro in qemumonitorjsontest.c was not passing the
schema through, which meant that we were not validating any of those
tests for correct usage according to the schema.
In the process of mechanically altering tests to pass the schema
through, use VIR_AUTOPTR on all of the affected test instances. The
next patch will do some further cleanups that it exposes.
Tested by using this hack, where the test mistakenly passed pre-patch,
but correctly diagnosed the garbage post-patch:
| diff --git i/src/qemu/qemu_monitor_json.c w/src/qemu/qemu_monitor_json.c
| index 53a7de8b77..86d8450814 100644
| --- i/src/qemu/qemu_monitor_json.c
| +++ w/src/qemu/qemu_monitor_json.c
| @@ -1532,7 +1532,8 @@ qemuMonitorJSONGetStatus(qemuMonitorPtr mon,
| if (reason)
| *reason = VIR_DOMAIN_PAUSED_UNKNOWN;
|
| - if (!(cmd = qemuMonitorJSONMakeCommand("query-status", NULL)))
| + if (!(cmd = qemuMonitorJSONMakeCommand("query-status",
| + "s:garbage", "foo", NULL)))
| return -1;
|
| if (qemuMonitorJSONCommand(mon, cmd, &reply) < 0)
Suggested-by: Peter Krempa <pkrempa@redhat.com>
Signed-off-by: Eric Blake <eblake@redhat.com>
Acked-by: Peter Krempa <pkrempa@redhat.com>
2019-06-12 01:59:11 +00:00
|
|
|
const testGenericData *data = opaque;
|
2021-03-11 07:16:13 +00:00
|
|
|
virDomainXMLOption *xmlopt = data->xmlopt;
|
2014-06-03 09:19:51 +00:00
|
|
|
unsigned int keycodes[] = {43, 26, 46, 32};
|
2019-10-15 12:47:50 +00:00
|
|
|
g_autoptr(qemuMonitorTest) test = NULL;
|
2014-06-03 09:19:51 +00:00
|
|
|
|
qemumonitorjsontest: Validate more commands against schema
The DO_TEST() macro in qemumonitorjsontest.c was not passing the
schema through, which meant that we were not validating any of those
tests for correct usage according to the schema.
In the process of mechanically altering tests to pass the schema
through, use VIR_AUTOPTR on all of the affected test instances. The
next patch will do some further cleanups that it exposes.
Tested by using this hack, where the test mistakenly passed pre-patch,
but correctly diagnosed the garbage post-patch:
| diff --git i/src/qemu/qemu_monitor_json.c w/src/qemu/qemu_monitor_json.c
| index 53a7de8b77..86d8450814 100644
| --- i/src/qemu/qemu_monitor_json.c
| +++ w/src/qemu/qemu_monitor_json.c
| @@ -1532,7 +1532,8 @@ qemuMonitorJSONGetStatus(qemuMonitorPtr mon,
| if (reason)
| *reason = VIR_DOMAIN_PAUSED_UNKNOWN;
|
| - if (!(cmd = qemuMonitorJSONMakeCommand("query-status", NULL)))
| + if (!(cmd = qemuMonitorJSONMakeCommand("query-status",
| + "s:garbage", "foo", NULL)))
| return -1;
|
| if (qemuMonitorJSONCommand(mon, cmd, &reply) < 0)
Suggested-by: Peter Krempa <pkrempa@redhat.com>
Signed-off-by: Eric Blake <eblake@redhat.com>
Acked-by: Peter Krempa <pkrempa@redhat.com>
2019-06-12 01:59:11 +00:00
|
|
|
if (!(test = qemuMonitorTestNewSchema(xmlopt, data->schema)))
|
2014-06-03 09:19:51 +00:00
|
|
|
return -1;
|
|
|
|
|
2023-05-22 15:08:27 +00:00
|
|
|
if (qemuMonitorTestAddItemVerbatim(test,
|
|
|
|
"{\"execute\":\"send-key\","
|
|
|
|
" \"arguments\":{\"keys\":[{\"type\":\"number\",\"data\":43},"
|
|
|
|
" {\"type\":\"number\",\"data\":26},"
|
|
|
|
" {\"type\":\"number\",\"data\":46},"
|
|
|
|
" {\"type\":\"number\",\"data\":32}],"
|
|
|
|
" \"hold-time\":31337},"
|
|
|
|
" \"id\":\"libvirt-1\"}",
|
|
|
|
NULL,
|
|
|
|
"{ \"return\" : {}}") < 0)
|
2019-06-11 03:01:08 +00:00
|
|
|
return -1;
|
2014-06-03 09:19:51 +00:00
|
|
|
|
|
|
|
if (qemuMonitorJSONSendKey(qemuMonitorTestGetMonitor(test),
|
|
|
|
31337, keycodes,
|
2019-10-15 11:55:26 +00:00
|
|
|
G_N_ELEMENTS(keycodes)) < 0)
|
2019-06-11 03:01:08 +00:00
|
|
|
return -1;
|
2014-06-03 09:19:51 +00:00
|
|
|
|
2019-06-11 03:01:08 +00:00
|
|
|
return 0;
|
2014-06-03 09:19:51 +00:00
|
|
|
}
|
|
|
|
|
2014-03-23 03:51:13 +00:00
|
|
|
static int
|
qemumonitorjsontest: Validate more commands against schema
The DO_TEST() macro in qemumonitorjsontest.c was not passing the
schema through, which meant that we were not validating any of those
tests for correct usage according to the schema.
In the process of mechanically altering tests to pass the schema
through, use VIR_AUTOPTR on all of the affected test instances. The
next patch will do some further cleanups that it exposes.
Tested by using this hack, where the test mistakenly passed pre-patch,
but correctly diagnosed the garbage post-patch:
| diff --git i/src/qemu/qemu_monitor_json.c w/src/qemu/qemu_monitor_json.c
| index 53a7de8b77..86d8450814 100644
| --- i/src/qemu/qemu_monitor_json.c
| +++ w/src/qemu/qemu_monitor_json.c
| @@ -1532,7 +1532,8 @@ qemuMonitorJSONGetStatus(qemuMonitorPtr mon,
| if (reason)
| *reason = VIR_DOMAIN_PAUSED_UNKNOWN;
|
| - if (!(cmd = qemuMonitorJSONMakeCommand("query-status", NULL)))
| + if (!(cmd = qemuMonitorJSONMakeCommand("query-status",
| + "s:garbage", "foo", NULL)))
| return -1;
|
| if (qemuMonitorJSONCommand(mon, cmd, &reply) < 0)
Suggested-by: Peter Krempa <pkrempa@redhat.com>
Signed-off-by: Eric Blake <eblake@redhat.com>
Acked-by: Peter Krempa <pkrempa@redhat.com>
2019-06-12 01:59:11 +00:00
|
|
|
testQemuMonitorJSONqemuMonitorJSONGetDumpGuestMemoryCapability(const void *opaque)
|
2014-03-23 03:51:13 +00:00
|
|
|
{
|
qemumonitorjsontest: Validate more commands against schema
The DO_TEST() macro in qemumonitorjsontest.c was not passing the
schema through, which meant that we were not validating any of those
tests for correct usage according to the schema.
In the process of mechanically altering tests to pass the schema
through, use VIR_AUTOPTR on all of the affected test instances. The
next patch will do some further cleanups that it exposes.
Tested by using this hack, where the test mistakenly passed pre-patch,
but correctly diagnosed the garbage post-patch:
| diff --git i/src/qemu/qemu_monitor_json.c w/src/qemu/qemu_monitor_json.c
| index 53a7de8b77..86d8450814 100644
| --- i/src/qemu/qemu_monitor_json.c
| +++ w/src/qemu/qemu_monitor_json.c
| @@ -1532,7 +1532,8 @@ qemuMonitorJSONGetStatus(qemuMonitorPtr mon,
| if (reason)
| *reason = VIR_DOMAIN_PAUSED_UNKNOWN;
|
| - if (!(cmd = qemuMonitorJSONMakeCommand("query-status", NULL)))
| + if (!(cmd = qemuMonitorJSONMakeCommand("query-status",
| + "s:garbage", "foo", NULL)))
| return -1;
|
| if (qemuMonitorJSONCommand(mon, cmd, &reply) < 0)
Suggested-by: Peter Krempa <pkrempa@redhat.com>
Signed-off-by: Eric Blake <eblake@redhat.com>
Acked-by: Peter Krempa <pkrempa@redhat.com>
2019-06-12 01:59:11 +00:00
|
|
|
const testGenericData *data = opaque;
|
2021-03-11 07:16:13 +00:00
|
|
|
virDomainXMLOption *xmlopt = data->xmlopt;
|
2014-03-23 03:51:13 +00:00
|
|
|
int cap;
|
|
|
|
const char *reply =
|
|
|
|
"{"
|
|
|
|
" \"return\": {"
|
|
|
|
" \"formats\": ["
|
|
|
|
" \"elf\","
|
|
|
|
" \"kdump-zlib\","
|
|
|
|
" \"kdump-lzo\","
|
|
|
|
" \"kdump-snappy\""
|
|
|
|
" ]"
|
|
|
|
" },"
|
|
|
|
" \"id\": \"libvirt-9\""
|
|
|
|
"}";
|
2019-10-15 12:47:50 +00:00
|
|
|
g_autoptr(qemuMonitorTest) test = NULL;
|
2014-03-23 03:51:13 +00:00
|
|
|
|
qemumonitorjsontest: Validate more commands against schema
The DO_TEST() macro in qemumonitorjsontest.c was not passing the
schema through, which meant that we were not validating any of those
tests for correct usage according to the schema.
In the process of mechanically altering tests to pass the schema
through, use VIR_AUTOPTR on all of the affected test instances. The
next patch will do some further cleanups that it exposes.
Tested by using this hack, where the test mistakenly passed pre-patch,
but correctly diagnosed the garbage post-patch:
| diff --git i/src/qemu/qemu_monitor_json.c w/src/qemu/qemu_monitor_json.c
| index 53a7de8b77..86d8450814 100644
| --- i/src/qemu/qemu_monitor_json.c
| +++ w/src/qemu/qemu_monitor_json.c
| @@ -1532,7 +1532,8 @@ qemuMonitorJSONGetStatus(qemuMonitorPtr mon,
| if (reason)
| *reason = VIR_DOMAIN_PAUSED_UNKNOWN;
|
| - if (!(cmd = qemuMonitorJSONMakeCommand("query-status", NULL)))
| + if (!(cmd = qemuMonitorJSONMakeCommand("query-status",
| + "s:garbage", "foo", NULL)))
| return -1;
|
| if (qemuMonitorJSONCommand(mon, cmd, &reply) < 0)
Suggested-by: Peter Krempa <pkrempa@redhat.com>
Signed-off-by: Eric Blake <eblake@redhat.com>
Acked-by: Peter Krempa <pkrempa@redhat.com>
2019-06-12 01:59:11 +00:00
|
|
|
if (!(test = qemuMonitorTestNewSchema(xmlopt, data->schema)))
|
2014-03-23 03:51:13 +00:00
|
|
|
return -1;
|
|
|
|
|
|
|
|
if (qemuMonitorTestAddItem(test, "query-dump-guest-memory-capability",
|
|
|
|
reply) < 0)
|
2019-06-11 03:01:08 +00:00
|
|
|
return -1;
|
2014-03-23 03:51:13 +00:00
|
|
|
|
|
|
|
cap = qemuMonitorJSONGetDumpGuestMemoryCapability(
|
|
|
|
qemuMonitorTestGetMonitor(test), "elf");
|
|
|
|
|
|
|
|
if (cap != 1) {
|
|
|
|
virReportError(VIR_ERR_INTERNAL_ERROR,
|
|
|
|
"Unexpected capability: %d, expecting 1",
|
|
|
|
cap);
|
2019-06-11 03:01:08 +00:00
|
|
|
return -1;
|
2014-03-23 03:51:13 +00:00
|
|
|
}
|
|
|
|
|
2019-06-11 03:01:08 +00:00
|
|
|
return 0;
|
2014-03-23 03:51:13 +00:00
|
|
|
}
|
2013-07-22 11:07:23 +00:00
|
|
|
|
|
|
|
struct testCPUData {
|
|
|
|
const char *name;
|
2021-03-11 07:16:13 +00:00
|
|
|
virDomainXMLOption *xmlopt;
|
2020-10-22 17:04:18 +00:00
|
|
|
GHashTable *schema;
|
2013-07-22 11:07:23 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
static int
|
|
|
|
testQemuMonitorJSONGetCPUData(const void *opaque)
|
|
|
|
{
|
|
|
|
const struct testCPUData *data = opaque;
|
2021-09-03 20:59:14 +00:00
|
|
|
g_autoptr(virCPUData) cpuData = NULL;
|
2021-09-04 20:33:55 +00:00
|
|
|
g_autofree char *jsonFile = NULL;
|
|
|
|
g_autofree char *dataFile = NULL;
|
|
|
|
g_autofree char *jsonStr = NULL;
|
|
|
|
g_autofree char *actual = NULL;
|
2019-10-15 12:47:50 +00:00
|
|
|
g_autoptr(qemuMonitorTest) test = NULL;
|
2013-07-22 11:07:23 +00:00
|
|
|
|
qemumonitorjsontest: Validate more commands against schema
The DO_TEST() macro in qemumonitorjsontest.c was not passing the
schema through, which meant that we were not validating any of those
tests for correct usage according to the schema.
In the process of mechanically altering tests to pass the schema
through, use VIR_AUTOPTR on all of the affected test instances. The
next patch will do some further cleanups that it exposes.
Tested by using this hack, where the test mistakenly passed pre-patch,
but correctly diagnosed the garbage post-patch:
| diff --git i/src/qemu/qemu_monitor_json.c w/src/qemu/qemu_monitor_json.c
| index 53a7de8b77..86d8450814 100644
| --- i/src/qemu/qemu_monitor_json.c
| +++ w/src/qemu/qemu_monitor_json.c
| @@ -1532,7 +1532,8 @@ qemuMonitorJSONGetStatus(qemuMonitorPtr mon,
| if (reason)
| *reason = VIR_DOMAIN_PAUSED_UNKNOWN;
|
| - if (!(cmd = qemuMonitorJSONMakeCommand("query-status", NULL)))
| + if (!(cmd = qemuMonitorJSONMakeCommand("query-status",
| + "s:garbage", "foo", NULL)))
| return -1;
|
| if (qemuMonitorJSONCommand(mon, cmd, &reply) < 0)
Suggested-by: Peter Krempa <pkrempa@redhat.com>
Signed-off-by: Eric Blake <eblake@redhat.com>
Acked-by: Peter Krempa <pkrempa@redhat.com>
2019-06-12 01:59:11 +00:00
|
|
|
if (!(test = qemuMonitorTestNewSchema(data->xmlopt, data->schema)))
|
2013-07-22 11:07:23 +00:00
|
|
|
return -1;
|
|
|
|
|
2019-10-22 13:26:14 +00:00
|
|
|
jsonFile = g_strdup_printf("%s/qemumonitorjsondata/qemumonitorjson-getcpu-%s.json",
|
|
|
|
abs_srcdir, data->name);
|
|
|
|
dataFile = g_strdup_printf("%s/qemumonitorjsondata/qemumonitorjson-getcpu-%s.data",
|
|
|
|
abs_srcdir, data->name);
|
2013-07-22 11:07:23 +00:00
|
|
|
|
2016-05-26 15:01:52 +00:00
|
|
|
if (virTestLoadFile(jsonFile, &jsonStr) < 0)
|
2021-09-04 20:38:39 +00:00
|
|
|
return -1;
|
2013-07-22 11:07:23 +00:00
|
|
|
|
2013-11-11 15:34:53 +00:00
|
|
|
if (qemuMonitorTestAddItem(test, "qom-list",
|
|
|
|
"{"
|
|
|
|
" \"return\": ["
|
|
|
|
" {"
|
|
|
|
" \"name\": \"filtered-features\","
|
|
|
|
" \"type\": \"X86CPUFeatureWordInfo\""
|
|
|
|
" },"
|
|
|
|
" {"
|
|
|
|
" \"name\": \"feature-words\","
|
|
|
|
" \"type\": \"X86CPUFeatureWordInfo\""
|
|
|
|
" }"
|
|
|
|
" ],"
|
|
|
|
" \"id\": \"libvirt-19\""
|
|
|
|
"}") < 0)
|
2021-09-04 20:38:39 +00:00
|
|
|
return -1;
|
2013-11-11 15:34:53 +00:00
|
|
|
|
2013-07-22 11:07:23 +00:00
|
|
|
if (qemuMonitorTestAddItem(test, "qom-get", jsonStr) < 0)
|
2021-09-04 20:38:39 +00:00
|
|
|
return -1;
|
2013-07-22 11:07:23 +00:00
|
|
|
|
2019-06-17 14:56:32 +00:00
|
|
|
if (qemuMonitorJSONGetGuestCPUx86(qemuMonitorTestGetMonitor(test),
|
2022-02-07 10:45:18 +00:00
|
|
|
"dummy",
|
2019-06-17 14:56:32 +00:00
|
|
|
&cpuData, NULL) < 0)
|
2021-09-04 20:38:39 +00:00
|
|
|
return -1;
|
2013-07-22 11:07:23 +00:00
|
|
|
|
2016-11-04 14:09:20 +00:00
|
|
|
if (!(actual = virCPUDataFormat(cpuData)))
|
2021-09-04 20:38:39 +00:00
|
|
|
return -1;
|
2013-07-22 11:07:23 +00:00
|
|
|
|
2016-05-26 15:01:53 +00:00
|
|
|
if (virTestCompareToFile(actual, dataFile) < 0)
|
2021-09-04 20:38:39 +00:00
|
|
|
return -1;
|
2013-07-22 11:07:23 +00:00
|
|
|
|
2021-09-04 20:38:39 +00:00
|
|
|
return 0;
|
2013-07-22 11:07:23 +00:00
|
|
|
}
|
|
|
|
|
2013-11-19 15:30:28 +00:00
|
|
|
static int
|
|
|
|
testQemuMonitorJSONGetNonExistingCPUData(const void *opaque)
|
|
|
|
{
|
qemumonitorjsontest: Validate more commands against schema
The DO_TEST() macro in qemumonitorjsontest.c was not passing the
schema through, which meant that we were not validating any of those
tests for correct usage according to the schema.
In the process of mechanically altering tests to pass the schema
through, use VIR_AUTOPTR on all of the affected test instances. The
next patch will do some further cleanups that it exposes.
Tested by using this hack, where the test mistakenly passed pre-patch,
but correctly diagnosed the garbage post-patch:
| diff --git i/src/qemu/qemu_monitor_json.c w/src/qemu/qemu_monitor_json.c
| index 53a7de8b77..86d8450814 100644
| --- i/src/qemu/qemu_monitor_json.c
| +++ w/src/qemu/qemu_monitor_json.c
| @@ -1532,7 +1532,8 @@ qemuMonitorJSONGetStatus(qemuMonitorPtr mon,
| if (reason)
| *reason = VIR_DOMAIN_PAUSED_UNKNOWN;
|
| - if (!(cmd = qemuMonitorJSONMakeCommand("query-status", NULL)))
| + if (!(cmd = qemuMonitorJSONMakeCommand("query-status",
| + "s:garbage", "foo", NULL)))
| return -1;
|
| if (qemuMonitorJSONCommand(mon, cmd, &reply) < 0)
Suggested-by: Peter Krempa <pkrempa@redhat.com>
Signed-off-by: Eric Blake <eblake@redhat.com>
Acked-by: Peter Krempa <pkrempa@redhat.com>
2019-06-12 01:59:11 +00:00
|
|
|
const testGenericData *data = opaque;
|
2021-03-11 07:16:13 +00:00
|
|
|
virDomainXMLOption *xmlopt = data->xmlopt;
|
2021-09-03 20:59:14 +00:00
|
|
|
g_autoptr(virCPUData) cpuData = NULL;
|
2021-09-04 20:38:39 +00:00
|
|
|
int rv;
|
2019-10-15 12:47:50 +00:00
|
|
|
g_autoptr(qemuMonitorTest) test = NULL;
|
2013-11-19 15:30:28 +00:00
|
|
|
|
qemumonitorjsontest: Validate more commands against schema
The DO_TEST() macro in qemumonitorjsontest.c was not passing the
schema through, which meant that we were not validating any of those
tests for correct usage according to the schema.
In the process of mechanically altering tests to pass the schema
through, use VIR_AUTOPTR on all of the affected test instances. The
next patch will do some further cleanups that it exposes.
Tested by using this hack, where the test mistakenly passed pre-patch,
but correctly diagnosed the garbage post-patch:
| diff --git i/src/qemu/qemu_monitor_json.c w/src/qemu/qemu_monitor_json.c
| index 53a7de8b77..86d8450814 100644
| --- i/src/qemu/qemu_monitor_json.c
| +++ w/src/qemu/qemu_monitor_json.c
| @@ -1532,7 +1532,8 @@ qemuMonitorJSONGetStatus(qemuMonitorPtr mon,
| if (reason)
| *reason = VIR_DOMAIN_PAUSED_UNKNOWN;
|
| - if (!(cmd = qemuMonitorJSONMakeCommand("query-status", NULL)))
| + if (!(cmd = qemuMonitorJSONMakeCommand("query-status",
| + "s:garbage", "foo", NULL)))
| return -1;
|
| if (qemuMonitorJSONCommand(mon, cmd, &reply) < 0)
Suggested-by: Peter Krempa <pkrempa@redhat.com>
Signed-off-by: Eric Blake <eblake@redhat.com>
Acked-by: Peter Krempa <pkrempa@redhat.com>
2019-06-12 01:59:11 +00:00
|
|
|
if (!(test = qemuMonitorTestNewSchema(xmlopt, data->schema)))
|
2013-11-19 15:30:28 +00:00
|
|
|
return -1;
|
|
|
|
|
|
|
|
if (qemuMonitorTestAddItem(test, "qom-list",
|
|
|
|
"{"
|
|
|
|
" \"id\": \"libvirt-7\","
|
|
|
|
" \"error\": {"
|
|
|
|
" \"class\": \"CommandNotFound\","
|
|
|
|
" \"desc\": \"The command qom-list has not been found\""
|
|
|
|
" }"
|
|
|
|
"}") < 0)
|
2021-09-04 20:38:39 +00:00
|
|
|
return -1;
|
2013-11-19 15:30:28 +00:00
|
|
|
|
2019-06-17 14:56:32 +00:00
|
|
|
rv = qemuMonitorJSONGetGuestCPUx86(qemuMonitorTestGetMonitor(test),
|
2022-02-07 10:45:18 +00:00
|
|
|
"dummy",
|
2019-06-17 14:56:32 +00:00
|
|
|
&cpuData, NULL);
|
2013-11-19 15:30:28 +00:00
|
|
|
if (rv != -2) {
|
|
|
|
virReportError(VIR_ERR_INTERNAL_ERROR,
|
|
|
|
"Unexpected return value %d, expecting -2", rv);
|
2021-09-04 20:38:39 +00:00
|
|
|
return -1;
|
2013-11-19 15:30:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (cpuData) {
|
|
|
|
virReportError(VIR_ERR_INTERNAL_ERROR,
|
|
|
|
"Unexpected allocation of data = %p, expecting NULL",
|
|
|
|
cpuData);
|
2021-09-04 20:38:39 +00:00
|
|
|
return -1;
|
2013-11-19 15:30:28 +00:00
|
|
|
}
|
|
|
|
|
2021-09-04 20:38:39 +00:00
|
|
|
return 0;
|
2013-11-19 15:30:28 +00:00
|
|
|
}
|
2013-07-22 11:07:23 +00:00
|
|
|
|
2014-08-29 20:23:11 +00:00
|
|
|
static int
|
qemumonitorjsontest: Validate more commands against schema
The DO_TEST() macro in qemumonitorjsontest.c was not passing the
schema through, which meant that we were not validating any of those
tests for correct usage according to the schema.
In the process of mechanically altering tests to pass the schema
through, use VIR_AUTOPTR on all of the affected test instances. The
next patch will do some further cleanups that it exposes.
Tested by using this hack, where the test mistakenly passed pre-patch,
but correctly diagnosed the garbage post-patch:
| diff --git i/src/qemu/qemu_monitor_json.c w/src/qemu/qemu_monitor_json.c
| index 53a7de8b77..86d8450814 100644
| --- i/src/qemu/qemu_monitor_json.c
| +++ w/src/qemu/qemu_monitor_json.c
| @@ -1532,7 +1532,8 @@ qemuMonitorJSONGetStatus(qemuMonitorPtr mon,
| if (reason)
| *reason = VIR_DOMAIN_PAUSED_UNKNOWN;
|
| - if (!(cmd = qemuMonitorJSONMakeCommand("query-status", NULL)))
| + if (!(cmd = qemuMonitorJSONMakeCommand("query-status",
| + "s:garbage", "foo", NULL)))
| return -1;
|
| if (qemuMonitorJSONCommand(mon, cmd, &reply) < 0)
Suggested-by: Peter Krempa <pkrempa@redhat.com>
Signed-off-by: Eric Blake <eblake@redhat.com>
Acked-by: Peter Krempa <pkrempa@redhat.com>
2019-06-12 01:59:11 +00:00
|
|
|
testQemuMonitorJSONGetIOThreads(const void *opaque)
|
2014-08-29 20:23:11 +00:00
|
|
|
{
|
qemumonitorjsontest: Validate more commands against schema
The DO_TEST() macro in qemumonitorjsontest.c was not passing the
schema through, which meant that we were not validating any of those
tests for correct usage according to the schema.
In the process of mechanically altering tests to pass the schema
through, use VIR_AUTOPTR on all of the affected test instances. The
next patch will do some further cleanups that it exposes.
Tested by using this hack, where the test mistakenly passed pre-patch,
but correctly diagnosed the garbage post-patch:
| diff --git i/src/qemu/qemu_monitor_json.c w/src/qemu/qemu_monitor_json.c
| index 53a7de8b77..86d8450814 100644
| --- i/src/qemu/qemu_monitor_json.c
| +++ w/src/qemu/qemu_monitor_json.c
| @@ -1532,7 +1532,8 @@ qemuMonitorJSONGetStatus(qemuMonitorPtr mon,
| if (reason)
| *reason = VIR_DOMAIN_PAUSED_UNKNOWN;
|
| - if (!(cmd = qemuMonitorJSONMakeCommand("query-status", NULL)))
| + if (!(cmd = qemuMonitorJSONMakeCommand("query-status",
| + "s:garbage", "foo", NULL)))
| return -1;
|
| if (qemuMonitorJSONCommand(mon, cmd, &reply) < 0)
Suggested-by: Peter Krempa <pkrempa@redhat.com>
Signed-off-by: Eric Blake <eblake@redhat.com>
Acked-by: Peter Krempa <pkrempa@redhat.com>
2019-06-12 01:59:11 +00:00
|
|
|
const testGenericData *data = opaque;
|
2021-03-11 07:16:13 +00:00
|
|
|
virDomainXMLOption *xmlopt = data->xmlopt;
|
|
|
|
qemuMonitorIOThreadInfo **info;
|
2014-08-29 20:23:11 +00:00
|
|
|
int ninfo = 0;
|
|
|
|
int ret = -1;
|
|
|
|
size_t i;
|
2019-10-15 12:47:50 +00:00
|
|
|
g_autoptr(qemuMonitorTest) test = NULL;
|
2014-08-29 20:23:11 +00:00
|
|
|
|
qemumonitorjsontest: Validate more commands against schema
The DO_TEST() macro in qemumonitorjsontest.c was not passing the
schema through, which meant that we were not validating any of those
tests for correct usage according to the schema.
In the process of mechanically altering tests to pass the schema
through, use VIR_AUTOPTR on all of the affected test instances. The
next patch will do some further cleanups that it exposes.
Tested by using this hack, where the test mistakenly passed pre-patch,
but correctly diagnosed the garbage post-patch:
| diff --git i/src/qemu/qemu_monitor_json.c w/src/qemu/qemu_monitor_json.c
| index 53a7de8b77..86d8450814 100644
| --- i/src/qemu/qemu_monitor_json.c
| +++ w/src/qemu/qemu_monitor_json.c
| @@ -1532,7 +1532,8 @@ qemuMonitorJSONGetStatus(qemuMonitorPtr mon,
| if (reason)
| *reason = VIR_DOMAIN_PAUSED_UNKNOWN;
|
| - if (!(cmd = qemuMonitorJSONMakeCommand("query-status", NULL)))
| + if (!(cmd = qemuMonitorJSONMakeCommand("query-status",
| + "s:garbage", "foo", NULL)))
| return -1;
|
| if (qemuMonitorJSONCommand(mon, cmd, &reply) < 0)
Suggested-by: Peter Krempa <pkrempa@redhat.com>
Signed-off-by: Eric Blake <eblake@redhat.com>
Acked-by: Peter Krempa <pkrempa@redhat.com>
2019-06-12 01:59:11 +00:00
|
|
|
if (!(test = qemuMonitorTestNewSchema(xmlopt, data->schema)))
|
2014-08-29 20:23:11 +00:00
|
|
|
return -1;
|
|
|
|
|
|
|
|
if (qemuMonitorTestAddItem(test, "query-iothreads",
|
|
|
|
"{ "
|
|
|
|
" \"return\": [ "
|
|
|
|
" { "
|
|
|
|
" \"id\": \"iothread1\", "
|
|
|
|
" \"thread-id\": 30992 "
|
|
|
|
" }, "
|
|
|
|
" { "
|
|
|
|
" \"id\": \"iothread2\", "
|
|
|
|
" \"thread-id\": 30993 "
|
|
|
|
" } "
|
|
|
|
" ]"
|
|
|
|
"}") < 0)
|
|
|
|
goto cleanup;
|
|
|
|
|
2020-12-02 17:34:24 +00:00
|
|
|
if (qemuMonitorGetIOThreads(qemuMonitorTestGetMonitor(test),
|
|
|
|
&info, &ninfo) < 0)
|
2014-08-29 20:23:11 +00:00
|
|
|
goto cleanup;
|
|
|
|
|
|
|
|
if (ninfo != 2) {
|
|
|
|
virReportError(VIR_ERR_INTERNAL_ERROR,
|
|
|
|
"ninfo %d is not 2", ninfo);
|
|
|
|
goto cleanup;
|
|
|
|
}
|
|
|
|
|
2017-11-03 12:09:47 +00:00
|
|
|
#define CHECK(i, wantiothread_id, wantthread_id) \
|
|
|
|
do { \
|
|
|
|
if (info[i]->iothread_id != (wantiothread_id)) { \
|
|
|
|
virReportError(VIR_ERR_INTERNAL_ERROR, \
|
|
|
|
"iothread_id %u is not %u", \
|
|
|
|
info[i]->iothread_id, (wantiothread_id)); \
|
|
|
|
goto cleanup; \
|
|
|
|
} \
|
|
|
|
if (info[i]->thread_id != (wantthread_id)) { \
|
|
|
|
virReportError(VIR_ERR_INTERNAL_ERROR, \
|
|
|
|
"thread_id %d is not %d", \
|
|
|
|
info[i]->thread_id, (wantthread_id)); \
|
|
|
|
goto cleanup; \
|
|
|
|
} \
|
2014-08-29 20:23:11 +00:00
|
|
|
} while (0)
|
|
|
|
|
2015-04-27 18:16:54 +00:00
|
|
|
CHECK(0, 1, 30992);
|
|
|
|
CHECK(1, 2, 30993);
|
2014-08-29 20:23:11 +00:00
|
|
|
|
|
|
|
#undef CHECK
|
|
|
|
|
|
|
|
ret = 0;
|
|
|
|
|
|
|
|
cleanup:
|
|
|
|
for (i = 0; i < ninfo; i++)
|
2015-04-28 10:32:52 +00:00
|
|
|
VIR_FREE(info[i]);
|
2014-08-29 20:23:11 +00:00
|
|
|
VIR_FREE(info);
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2016-07-29 16:08:06 +00:00
|
|
|
struct testCPUInfoData {
|
|
|
|
const char *name;
|
|
|
|
size_t maxvcpus;
|
2021-03-11 07:16:13 +00:00
|
|
|
virDomainXMLOption *xmlopt;
|
2020-10-22 17:04:18 +00:00
|
|
|
GHashTable *schema;
|
2016-07-29 16:08:06 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
static char *
|
2021-03-11 07:16:13 +00:00
|
|
|
testQemuMonitorCPUInfoFormat(qemuMonitorCPUInfo *vcpus,
|
2016-07-29 16:08:06 +00:00
|
|
|
size_t nvcpus)
|
|
|
|
{
|
2020-07-02 23:35:41 +00:00
|
|
|
g_auto(virBuffer) buf = VIR_BUFFER_INITIALIZER;
|
2021-03-11 07:16:13 +00:00
|
|
|
qemuMonitorCPUInfo *vcpu;
|
2016-07-29 16:08:06 +00:00
|
|
|
size_t i;
|
|
|
|
|
|
|
|
for (i = 0; i < nvcpus; i++) {
|
|
|
|
vcpu = vcpus + i;
|
|
|
|
|
|
|
|
virBufferAsprintf(&buf, "[vcpu libvirt-id='%zu']\n", i);
|
|
|
|
virBufferAdjustIndent(&buf, 4);
|
|
|
|
|
2016-09-13 15:52:38 +00:00
|
|
|
virBufferAsprintf(&buf, "online=%s\n", vcpu->online ? "yes" : "no");
|
|
|
|
virBufferAsprintf(&buf, "hotpluggable=%s\n", vcpu->hotpluggable ? "yes" : "no");
|
|
|
|
|
2016-07-29 16:08:06 +00:00
|
|
|
if (vcpu->tid)
|
|
|
|
virBufferAsprintf(&buf, "thread-id='%llu'\n",
|
|
|
|
(unsigned long long) vcpu->tid);
|
|
|
|
|
|
|
|
if (vcpu->id != 0)
|
2016-11-22 09:21:46 +00:00
|
|
|
virBufferAsprintf(&buf, "enable-id='%d'\n", vcpu->id);
|
2016-07-29 16:08:06 +00:00
|
|
|
|
2016-11-22 08:32:11 +00:00
|
|
|
if (vcpu->qemu_id != -1)
|
|
|
|
virBufferAsprintf(&buf, "query-cpus-id='%d'\n", vcpu->qemu_id);
|
|
|
|
|
2016-07-29 16:08:06 +00:00
|
|
|
if (vcpu->type)
|
|
|
|
virBufferAsprintf(&buf, "type='%s'\n", vcpu->type);
|
|
|
|
|
|
|
|
if (vcpu->alias)
|
|
|
|
virBufferAsprintf(&buf, "alias='%s'\n", vcpu->alias);
|
|
|
|
if (vcpu->qom_path)
|
|
|
|
virBufferAsprintf(&buf, "qom_path='%s'\n", vcpu->qom_path);
|
|
|
|
|
2024-01-08 17:44:25 +00:00
|
|
|
if (vcpu->socket_id != -1 || vcpu->die_id != -1 ||
|
|
|
|
vcpu->cluster_id != -1 || vcpu->core_id != -1 ||
|
2016-07-29 16:08:06 +00:00
|
|
|
vcpu->thread_id != -1 || vcpu->vcpus != 0) {
|
|
|
|
virBufferAddLit(&buf, "topology:");
|
|
|
|
if (vcpu->socket_id != -1)
|
|
|
|
virBufferAsprintf(&buf, " socket='%d'", vcpu->socket_id);
|
2020-03-16 12:55:52 +00:00
|
|
|
if (vcpu->die_id != -1)
|
|
|
|
virBufferAsprintf(&buf, " die='%d'", vcpu->die_id);
|
2024-01-08 17:44:25 +00:00
|
|
|
if (vcpu->cluster_id != -1)
|
|
|
|
virBufferAsprintf(&buf, " cluster_id='%d'", vcpu->cluster_id);
|
2016-07-29 16:08:06 +00:00
|
|
|
if (vcpu->core_id != -1)
|
|
|
|
virBufferAsprintf(&buf, " core='%d'", vcpu->core_id);
|
|
|
|
if (vcpu->thread_id != -1)
|
|
|
|
virBufferAsprintf(&buf, " thread='%d'", vcpu->thread_id);
|
2017-06-27 14:04:38 +00:00
|
|
|
if (vcpu->node_id != -1)
|
|
|
|
virBufferAsprintf(&buf, " node='%d'", vcpu->node_id);
|
2016-07-29 16:08:06 +00:00
|
|
|
if (vcpu->vcpus != 0)
|
|
|
|
virBufferAsprintf(&buf, " vcpus='%u'", vcpu->vcpus);
|
|
|
|
virBufferAddLit(&buf, "\n");
|
|
|
|
}
|
|
|
|
|
2018-04-12 15:14:30 +00:00
|
|
|
if (vcpu->halted)
|
|
|
|
virBufferAddLit(&buf, "halted\n");
|
|
|
|
|
2016-07-29 16:08:06 +00:00
|
|
|
virBufferAdjustIndent(&buf, -4);
|
|
|
|
}
|
|
|
|
|
|
|
|
return virBufferContentAndReset(&buf);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static int
|
|
|
|
testQemuMonitorCPUInfo(const void *opaque)
|
|
|
|
{
|
|
|
|
const struct testCPUInfoData *data = opaque;
|
2021-03-11 07:16:13 +00:00
|
|
|
virDomainObj *vm = NULL;
|
2021-09-04 20:33:55 +00:00
|
|
|
g_autofree char *queryCpusFile = NULL;
|
|
|
|
g_autofree char *queryHotpluggableFile = NULL;
|
|
|
|
g_autofree char *dataFile = NULL;
|
|
|
|
g_autofree char *queryCpusStr = NULL;
|
|
|
|
g_autofree char *queryHotpluggableStr = NULL;
|
|
|
|
g_autofree char *actual = NULL;
|
2021-03-11 07:16:13 +00:00
|
|
|
qemuMonitorCPUInfo *vcpus = NULL;
|
2016-07-29 16:08:06 +00:00
|
|
|
int rc;
|
|
|
|
int ret = -1;
|
2019-10-15 12:47:50 +00:00
|
|
|
g_autoptr(qemuMonitorTest) test = NULL;
|
2016-07-29 16:08:06 +00:00
|
|
|
|
qemumonitorjsontest: Validate more commands against schema
The DO_TEST() macro in qemumonitorjsontest.c was not passing the
schema through, which meant that we were not validating any of those
tests for correct usage according to the schema.
In the process of mechanically altering tests to pass the schema
through, use VIR_AUTOPTR on all of the affected test instances. The
next patch will do some further cleanups that it exposes.
Tested by using this hack, where the test mistakenly passed pre-patch,
but correctly diagnosed the garbage post-patch:
| diff --git i/src/qemu/qemu_monitor_json.c w/src/qemu/qemu_monitor_json.c
| index 53a7de8b77..86d8450814 100644
| --- i/src/qemu/qemu_monitor_json.c
| +++ w/src/qemu/qemu_monitor_json.c
| @@ -1532,7 +1532,8 @@ qemuMonitorJSONGetStatus(qemuMonitorPtr mon,
| if (reason)
| *reason = VIR_DOMAIN_PAUSED_UNKNOWN;
|
| - if (!(cmd = qemuMonitorJSONMakeCommand("query-status", NULL)))
| + if (!(cmd = qemuMonitorJSONMakeCommand("query-status",
| + "s:garbage", "foo", NULL)))
| return -1;
|
| if (qemuMonitorJSONCommand(mon, cmd, &reply) < 0)
Suggested-by: Peter Krempa <pkrempa@redhat.com>
Signed-off-by: Eric Blake <eblake@redhat.com>
Acked-by: Peter Krempa <pkrempa@redhat.com>
2019-06-12 01:59:11 +00:00
|
|
|
if (!(test = qemuMonitorTestNewSchema(data->xmlopt, data->schema)))
|
2016-07-29 16:08:06 +00:00
|
|
|
return -1;
|
|
|
|
|
2019-10-22 13:26:14 +00:00
|
|
|
queryCpusFile = g_strdup_printf("%s/qemumonitorjsondata/qemumonitorjson-cpuinfo-%s-cpus.json",
|
|
|
|
abs_srcdir, data->name);
|
|
|
|
queryHotpluggableFile = g_strdup_printf("%s/qemumonitorjsondata/qemumonitorjson-cpuinfo-%s-hotplug.json",
|
|
|
|
abs_srcdir, data->name);
|
|
|
|
dataFile = g_strdup_printf("%s/qemumonitorjsondata/qemumonitorjson-cpuinfo-%s.data",
|
|
|
|
abs_srcdir, data->name);
|
2016-07-29 16:08:06 +00:00
|
|
|
|
|
|
|
if (virTestLoadFile(queryCpusFile, &queryCpusStr) < 0)
|
|
|
|
goto cleanup;
|
|
|
|
|
|
|
|
if (virTestLoadFile(queryHotpluggableFile, &queryHotpluggableStr) < 0)
|
|
|
|
goto cleanup;
|
|
|
|
|
|
|
|
if (qemuMonitorTestAddItem(test, "query-hotpluggable-cpus",
|
|
|
|
queryHotpluggableStr) < 0)
|
|
|
|
goto cleanup;
|
|
|
|
|
2022-08-08 15:15:06 +00:00
|
|
|
if (qemuMonitorTestAddItem(test, "query-cpus-fast", queryCpusStr) < 0)
|
2016-07-29 16:08:06 +00:00
|
|
|
goto cleanup;
|
|
|
|
|
2018-04-04 14:45:04 +00:00
|
|
|
vm = qemuMonitorTestGetDomainObj(test);
|
|
|
|
if (!vm)
|
2018-04-18 10:33:42 +00:00
|
|
|
goto cleanup;
|
2018-04-04 14:45:04 +00:00
|
|
|
|
2016-07-29 16:08:06 +00:00
|
|
|
rc = qemuMonitorGetCPUInfo(qemuMonitorTestGetMonitor(test),
|
2022-08-08 15:15:07 +00:00
|
|
|
&vcpus, data->maxvcpus, true);
|
2016-07-29 16:08:06 +00:00
|
|
|
|
|
|
|
if (rc < 0)
|
|
|
|
goto cleanup;
|
|
|
|
|
|
|
|
actual = testQemuMonitorCPUInfoFormat(vcpus, data->maxvcpus);
|
|
|
|
|
|
|
|
if (virTestCompareToFile(actual, dataFile) < 0)
|
|
|
|
goto cleanup;
|
|
|
|
|
|
|
|
ret = 0;
|
|
|
|
cleanup:
|
|
|
|
qemuMonitorCPUInfoFree(vcpus, data->maxvcpus);
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2018-03-22 16:07:43 +00:00
|
|
|
struct testQAPISchemaData {
|
2020-10-22 17:04:18 +00:00
|
|
|
GHashTable *schema;
|
2018-03-22 16:07:43 +00:00
|
|
|
const char *name;
|
|
|
|
const char *query;
|
|
|
|
const char *json;
|
|
|
|
bool success;
|
2019-04-09 11:22:32 +00:00
|
|
|
int rc;
|
|
|
|
bool replyobj;
|
2018-03-22 16:07:43 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2019-04-09 11:22:32 +00:00
|
|
|
static int
|
|
|
|
testQAPISchemaQuery(const void *opaque)
|
|
|
|
{
|
|
|
|
const struct testQAPISchemaData *data = opaque;
|
2021-03-11 07:16:13 +00:00
|
|
|
virJSONValue *replyobj = NULL;
|
2019-04-09 11:22:32 +00:00
|
|
|
int rc;
|
|
|
|
|
|
|
|
rc = virQEMUQAPISchemaPathGet(data->query, data->schema, &replyobj);
|
|
|
|
|
|
|
|
if (data->rc != rc || data->replyobj != !!replyobj) {
|
|
|
|
VIR_TEST_VERBOSE("\n success: expected '%d' got '%d', replyobj: expected '%d' got '%d'",
|
|
|
|
data->rc, rc, data->replyobj, !!replyobj);
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2018-03-22 16:07:43 +00:00
|
|
|
static int
|
2019-04-09 08:32:33 +00:00
|
|
|
testQAPISchemaValidate(const void *opaque)
|
2018-03-22 16:07:43 +00:00
|
|
|
{
|
|
|
|
const struct testQAPISchemaData *data = opaque;
|
2020-07-02 23:35:41 +00:00
|
|
|
g_auto(virBuffer) debug = VIR_BUFFER_INITIALIZER;
|
2021-03-11 07:16:13 +00:00
|
|
|
virJSONValue *schemaroot;
|
2021-09-03 20:45:48 +00:00
|
|
|
g_autoptr(virJSONValue) json = NULL;
|
2018-03-22 16:07:43 +00:00
|
|
|
int ret = -1;
|
|
|
|
|
|
|
|
if (virQEMUQAPISchemaPathGet(data->query, data->schema, &schemaroot) < 0)
|
2021-09-04 20:38:39 +00:00
|
|
|
return -1;
|
2018-03-22 16:07:43 +00:00
|
|
|
|
|
|
|
if (!(json = virJSONValueFromString(data->json)))
|
2021-09-04 20:38:39 +00:00
|
|
|
return -1;
|
2018-03-22 16:07:43 +00:00
|
|
|
|
2020-04-29 15:52:43 +00:00
|
|
|
if ((testQEMUSchemaValidate(json, schemaroot, data->schema, false,
|
|
|
|
&debug) == 0) != data->success) {
|
2018-03-22 16:07:43 +00:00
|
|
|
if (!data->success)
|
2019-05-03 08:45:58 +00:00
|
|
|
VIR_TEST_VERBOSE("\nschema validation should have failed");
|
2018-03-22 16:07:43 +00:00
|
|
|
} else {
|
|
|
|
ret = 0;
|
|
|
|
}
|
|
|
|
|
2018-07-12 11:36:48 +00:00
|
|
|
if (virTestGetDebug() >= 3 ||
|
2018-03-22 16:07:43 +00:00
|
|
|
(ret < 0 && virTestGetVerbose())) {
|
|
|
|
char *debugstr = virBufferContentAndReset(&debug);
|
|
|
|
fprintf(stderr, "\n%s\n", debugstr);
|
|
|
|
VIR_FREE(debugstr);
|
|
|
|
}
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-08-06 17:45:24 +00:00
|
|
|
/**
|
|
|
|
* testQAPISchemaObjectDeviceAdd:
|
|
|
|
*
|
|
|
|
* Purpose of this test is to add a last-resort notification that 'object-add'
|
|
|
|
* and 'device_add' are not covered by the QMP schema by surprise. Ideally QEMU
|
|
|
|
* developers will notify us before they switch so we have time to adapt our
|
|
|
|
* generators first. This didn't work out when netdev-add was converted.
|
|
|
|
*
|
|
|
|
* We validate that the QMP schema describes only the expected types and nothing
|
|
|
|
* else assuming that no new field will be added until final conversion.
|
|
|
|
*/
|
|
|
|
static int
|
|
|
|
testQAPISchemaObjectDeviceAdd(const void *opaque)
|
|
|
|
{
|
2020-10-22 17:04:18 +00:00
|
|
|
GHashTable *schema = (GHashTable *) opaque;
|
2021-03-11 07:16:13 +00:00
|
|
|
virJSONValue *entry;
|
2020-08-06 17:45:24 +00:00
|
|
|
|
|
|
|
if (virQEMUQAPISchemaPathGet("device_add/arg-type", schema, &entry) < 0) {
|
|
|
|
fprintf(stderr, "schema for 'device_add' not found\n");
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (testQEMUSchemaEntryMatchTemplate(entry,
|
|
|
|
"str:driver",
|
|
|
|
"str:bus",
|
|
|
|
"str:id",
|
|
|
|
NULL) < 0) {
|
|
|
|
VIR_TEST_VERBOSE("device_add has unexpected members in schema");
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2018-12-04 16:58:38 +00:00
|
|
|
static void
|
2021-03-11 07:16:13 +00:00
|
|
|
testQueryJobsPrintJob(virBuffer *buf,
|
|
|
|
qemuMonitorJobInfo *job)
|
2018-12-04 16:58:38 +00:00
|
|
|
{
|
|
|
|
virBufferAddLit(buf, "[job]\n");
|
|
|
|
virBufferAsprintf(buf, "id=%s\n", NULLSTR(job->id));
|
|
|
|
virBufferAsprintf(buf, "type=%s\n", NULLSTR(qemuMonitorJobTypeToString(job->type)));
|
|
|
|
virBufferAsprintf(buf, "status=%s\n", NULLSTR(qemuMonitorJobStatusTypeToString(job->status)));
|
|
|
|
virBufferAsprintf(buf, "error=%s\n", NULLSTR(job->error));
|
|
|
|
virBufferAddLit(buf, "\n");
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
struct testQueryJobsData {
|
|
|
|
const char *name;
|
2021-03-11 07:16:13 +00:00
|
|
|
virDomainXMLOption *xmlopt;
|
2018-12-04 16:58:38 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
static int
|
|
|
|
testQueryJobs(const void *opaque)
|
|
|
|
{
|
|
|
|
const struct testQueryJobsData *data = opaque;
|
2021-11-01 08:51:01 +00:00
|
|
|
g_autoptr(qemuMonitorTest) test = qemuMonitorTestNewSimple(data->xmlopt);
|
2019-10-15 13:16:31 +00:00
|
|
|
g_autofree char *filenameJSON = NULL;
|
|
|
|
g_autofree char *fileJSON = NULL;
|
|
|
|
g_autofree char *filenameResult = NULL;
|
|
|
|
g_autofree char *actual = NULL;
|
2021-03-11 07:16:13 +00:00
|
|
|
qemuMonitorJobInfo **jobs = NULL;
|
2020-07-02 23:35:41 +00:00
|
|
|
g_auto(virBuffer) buf = VIR_BUFFER_INITIALIZER;
|
2018-12-04 16:58:38 +00:00
|
|
|
size_t njobs = 0;
|
|
|
|
size_t i;
|
|
|
|
int ret = -1;
|
|
|
|
|
2019-07-23 12:09:19 +00:00
|
|
|
if (!test)
|
|
|
|
return -1;
|
|
|
|
|
2019-10-22 13:26:14 +00:00
|
|
|
filenameJSON = g_strdup_printf(abs_srcdir "/qemumonitorjsondata/query-jobs-%s.json",
|
|
|
|
data->name);
|
|
|
|
filenameResult = g_strdup_printf(abs_srcdir "/qemumonitorjsondata/query-jobs-%s.result",
|
|
|
|
data->name);
|
2018-12-04 16:58:38 +00:00
|
|
|
|
|
|
|
if (virTestLoadFile(filenameJSON, &fileJSON) < 0)
|
|
|
|
goto cleanup;
|
|
|
|
|
|
|
|
if (qemuMonitorTestAddItem(test, "query-jobs", fileJSON) < 0)
|
|
|
|
goto cleanup;
|
|
|
|
|
|
|
|
if (qemuMonitorJSONGetJobInfo(qemuMonitorTestGetMonitor(test),
|
|
|
|
&jobs, &njobs) < 0)
|
|
|
|
goto cleanup;
|
|
|
|
|
|
|
|
for (i = 0; i < njobs; i++)
|
|
|
|
testQueryJobsPrintJob(&buf, jobs[i]);
|
|
|
|
|
2020-02-02 19:26:38 +00:00
|
|
|
virBufferTrim(&buf, "\n");
|
2018-12-04 16:58:38 +00:00
|
|
|
|
|
|
|
actual = virBufferContentAndReset(&buf);
|
|
|
|
|
|
|
|
if (virTestCompareToFile(actual, filenameResult) < 0)
|
|
|
|
goto cleanup;
|
|
|
|
|
|
|
|
ret = 0;
|
|
|
|
|
|
|
|
cleanup:
|
2019-07-29 12:12:22 +00:00
|
|
|
for (i = 0; i < njobs; i++)
|
|
|
|
qemuMonitorJobInfoFree(jobs[i]);
|
|
|
|
VIR_FREE(jobs);
|
2018-12-04 16:58:38 +00:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2019-09-26 14:12:20 +00:00
|
|
|
static int
|
|
|
|
testQemuMonitorJSONTransaction(const void *opaque)
|
|
|
|
{
|
|
|
|
const testGenericData *data = opaque;
|
2019-10-15 12:47:50 +00:00
|
|
|
g_autoptr(qemuMonitorTest) test = NULL;
|
|
|
|
g_autoptr(virJSONValue) actions = NULL;
|
|
|
|
g_autoptr(virJSONValue) mergebitmaps = NULL;
|
2019-09-26 14:12:20 +00:00
|
|
|
|
|
|
|
if (!(test = qemuMonitorTestNewSchema(data->xmlopt, data->schema)))
|
|
|
|
return -1;
|
|
|
|
|
2020-01-31 07:18:36 +00:00
|
|
|
actions = virJSONValueNewArray();
|
|
|
|
mergebitmaps = virJSONValueNewArray();
|
2019-09-26 14:12:20 +00:00
|
|
|
|
2019-10-07 14:19:34 +00:00
|
|
|
if (qemuMonitorTransactionBitmapMergeSourceAddBitmap(mergebitmaps, "node1", "bitmap1") < 0 ||
|
|
|
|
qemuMonitorTransactionBitmapMergeSourceAddBitmap(mergebitmaps, "node2", "bitmap2") < 0)
|
2019-09-26 14:12:20 +00:00
|
|
|
return -1;
|
|
|
|
|
2019-11-28 15:03:16 +00:00
|
|
|
if (qemuMonitorTransactionBitmapAdd(actions, "node1", "bitmap1", true, true, 1234) < 0 ||
|
2019-09-26 14:12:20 +00:00
|
|
|
qemuMonitorTransactionBitmapRemove(actions, "node2", "bitmap2") < 0 ||
|
|
|
|
qemuMonitorTransactionBitmapEnable(actions, "node3", "bitmap3") < 0 ||
|
|
|
|
qemuMonitorTransactionBitmapDisable(actions, "node4", "bitmap4") < 0 ||
|
|
|
|
qemuMonitorTransactionBitmapMerge(actions, "node5", "bitmap5", &mergebitmaps) < 0 ||
|
2019-09-27 15:28:48 +00:00
|
|
|
qemuMonitorTransactionSnapshotBlockdev(actions, "node7", "overlay7") < 0 ||
|
|
|
|
qemuMonitorTransactionBackup(actions, "dev8", "job8", "target8", "bitmap8",
|
|
|
|
QEMU_MONITOR_TRANSACTION_BACKUP_SYNC_MODE_NONE) < 0 ||
|
|
|
|
qemuMonitorTransactionBackup(actions, "dev9", "job9", "target9", "bitmap9",
|
|
|
|
QEMU_MONITOR_TRANSACTION_BACKUP_SYNC_MODE_INCREMENTAL) < 0 ||
|
|
|
|
qemuMonitorTransactionBackup(actions, "devA", "jobA", "targetA", "bitmapA",
|
|
|
|
QEMU_MONITOR_TRANSACTION_BACKUP_SYNC_MODE_FULL) < 0)
|
2019-09-26 14:12:20 +00:00
|
|
|
return -1;
|
|
|
|
|
|
|
|
if (qemuMonitorTestAddItem(test, "transaction", "{\"return\":{}}") < 0)
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
if (qemuMonitorJSONTransaction(qemuMonitorTestGetMonitor(test), &actions) < 0)
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-10-14 09:33:06 +00:00
|
|
|
static int
|
|
|
|
testQemuMonitorJSONBlockExportAdd(const void *opaque)
|
|
|
|
{
|
|
|
|
const testGenericData *data = opaque;
|
|
|
|
g_autoptr(qemuMonitorTest) test = NULL;
|
|
|
|
g_autoptr(virJSONValue) nbddata = NULL;
|
2020-10-26 12:06:17 +00:00
|
|
|
const char *bitmaps[] = { "bitmap1", "bitmap2", NULL };
|
2020-10-14 09:33:06 +00:00
|
|
|
|
|
|
|
if (!(test = qemuMonitorTestNewSchema(data->xmlopt, data->schema)))
|
|
|
|
return -1;
|
|
|
|
|
2020-10-26 12:06:17 +00:00
|
|
|
if (!(nbddata = qemuBlockExportGetNBDProps("nodename", "exportname", true, bitmaps)))
|
2020-10-14 09:33:06 +00:00
|
|
|
return -1;
|
|
|
|
|
|
|
|
if (qemuMonitorTestAddItem(test, "block-export-add", "{\"return\":{}}") < 0)
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
if (qemuMonitorJSONBlockExportAdd(qemuMonitorTestGetMonitor(test), &nbddata) < 0)
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2021-02-22 16:59:28 +00:00
|
|
|
|
|
|
|
static int
|
|
|
|
testQemuMonitorJSONBlockdevReopen(const void *opaque)
|
|
|
|
{
|
|
|
|
const testGenericData *data = opaque;
|
|
|
|
g_autoptr(qemuMonitorTest) test = NULL;
|
|
|
|
g_autoptr(virStorageSource) src = virStorageSourceNew();
|
2023-11-22 15:47:00 +00:00
|
|
|
g_autoptr(virJSONValue) reopenoptions = virJSONValueNewArray();
|
|
|
|
g_autoptr(virJSONValue) srcprops = NULL;
|
2021-02-22 16:59:28 +00:00
|
|
|
|
|
|
|
if (!(test = qemuMonitorTestNewSchema(data->xmlopt, data->schema)))
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
src->format = VIR_STORAGE_FILE_QCOW2;
|
|
|
|
src->readonly = true;
|
2023-10-16 13:55:25 +00:00
|
|
|
qemuBlockStorageSourceSetFormatNodename(src, g_strdup("test node"));
|
2023-09-25 14:19:34 +00:00
|
|
|
qemuBlockStorageSourceSetStorageNodename(src, g_strdup("backing nodename"));
|
2021-02-22 16:59:28 +00:00
|
|
|
src->backingStore = virStorageSourceNew();
|
|
|
|
|
2023-11-22 15:47:00 +00:00
|
|
|
if (!(srcprops = qemuBlockStorageSourceGetFormatProps(src, src->backingStore)))
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
if (virJSONValueArrayAppend(reopenoptions, &srcprops) < 0)
|
|
|
|
return -1;
|
|
|
|
|
2021-02-22 16:59:28 +00:00
|
|
|
if (qemuMonitorTestAddItem(test, "blockdev-reopen", "{\"return\":{}}") < 0)
|
|
|
|
return -1;
|
|
|
|
|
2023-11-22 15:47:00 +00:00
|
|
|
if (qemuMonitorBlockdevReopen(qemuMonitorTestGetMonitor(test), &reopenoptions) < 0)
|
2021-02-22 16:59:28 +00:00
|
|
|
return -1;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-02-20 22:01:47 +00:00
|
|
|
static int
|
|
|
|
testQemuMonitorJSONqemuMonitorJSONGetCPUModelComparison(const void *opaque)
|
|
|
|
{
|
|
|
|
const testGenericData *data = opaque;
|
|
|
|
g_autoptr(qemuMonitorTest) test = NULL;
|
2020-02-21 23:55:50 +00:00
|
|
|
g_autoptr(virCPUDef) cpu_a = virCPUDefNew();
|
|
|
|
g_autoptr(virCPUDef) cpu_b = virCPUDefNew();
|
2020-02-20 22:01:47 +00:00
|
|
|
g_autofree char *result = NULL;
|
|
|
|
|
|
|
|
if (!(test = qemuMonitorTestNewSchema(data->xmlopt, data->schema)))
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
if (qemuMonitorTestAddItem(test, "query-cpu-model-comparison",
|
|
|
|
"{\"return\":{\"result\":\"test\"}}") < 0)
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
cpu_a->model = g_strdup("cpu_a");
|
|
|
|
cpu_b->model = g_strdup("cpu_b");
|
|
|
|
|
|
|
|
if (qemuMonitorJSONGetCPUModelComparison(qemuMonitorTestGetMonitor(test),
|
|
|
|
cpu_a, cpu_b, &result) < 0)
|
2020-02-21 23:55:50 +00:00
|
|
|
return -1;
|
2020-02-20 22:01:47 +00:00
|
|
|
|
|
|
|
if (!result || STRNEQ(result, "test")) {
|
|
|
|
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
|
|
|
"Compare result not set");
|
2020-02-21 23:55:50 +00:00
|
|
|
return -1;
|
2020-02-20 22:01:47 +00:00
|
|
|
}
|
|
|
|
|
2020-02-21 23:55:50 +00:00
|
|
|
return 0;
|
2020-02-20 22:01:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-02-20 22:01:48 +00:00
|
|
|
static int
|
|
|
|
testQemuMonitorJSONqemuMonitorJSONGetCPUModelBaseline(const void *opaque)
|
|
|
|
{
|
|
|
|
const testGenericData *data = opaque;
|
|
|
|
g_autoptr(qemuMonitorTest) test = NULL;
|
2020-02-21 23:55:50 +00:00
|
|
|
g_autoptr(virCPUDef) cpu_a = virCPUDefNew();
|
|
|
|
g_autoptr(virCPUDef) cpu_b = virCPUDefNew();
|
2021-11-01 11:58:27 +00:00
|
|
|
g_autoptr(qemuMonitorCPUModelInfo) baseline = NULL;
|
2020-02-20 22:01:48 +00:00
|
|
|
|
|
|
|
if (!(test = qemuMonitorTestNewSchema(data->xmlopt, data->schema)))
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
if (qemuMonitorTestAddItem(test, "query-cpu-model-baseline",
|
|
|
|
"{ "
|
|
|
|
" \"return\": { "
|
|
|
|
" \"model\": { "
|
|
|
|
" \"name\": \"cpu_c\", "
|
|
|
|
" \"props\": { "
|
|
|
|
" \"feat_a\": true, "
|
|
|
|
" \"feat_b\": false "
|
|
|
|
" } "
|
|
|
|
" } "
|
|
|
|
" } "
|
|
|
|
"}") < 0)
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
cpu_a->model = g_strdup("cpu_a");
|
|
|
|
cpu_b->model = g_strdup("cpu_b");
|
|
|
|
|
|
|
|
if (virCPUDefAddFeature(cpu_a, "feat_a", VIR_CPU_FEATURE_REQUIRE) < 0 ||
|
|
|
|
virCPUDefAddFeature(cpu_a, "feat_b", VIR_CPU_FEATURE_REQUIRE) < 0 ||
|
|
|
|
virCPUDefAddFeature(cpu_a, "feat_c", VIR_CPU_FEATURE_REQUIRE) < 0)
|
2021-11-01 09:20:57 +00:00
|
|
|
return -1;
|
2020-02-20 22:01:48 +00:00
|
|
|
|
|
|
|
if (qemuMonitorJSONGetCPUModelBaseline(qemuMonitorTestGetMonitor(test),
|
|
|
|
cpu_a, cpu_b, &baseline) < 0)
|
2021-11-01 09:20:57 +00:00
|
|
|
return -1;
|
2020-02-20 22:01:48 +00:00
|
|
|
|
|
|
|
if (!baseline) {
|
|
|
|
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
|
|
|
"Baseline missing result");
|
2021-11-01 09:20:57 +00:00
|
|
|
return -1;
|
2020-02-20 22:01:48 +00:00
|
|
|
}
|
|
|
|
if (!baseline->name) {
|
|
|
|
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
|
|
|
"Baseline missing model name");
|
2021-11-01 09:20:57 +00:00
|
|
|
return -1;
|
2020-02-20 22:01:48 +00:00
|
|
|
}
|
|
|
|
if (baseline->nprops != 2) {
|
|
|
|
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
|
|
|
"Baseline missing properties");
|
2021-11-01 09:20:57 +00:00
|
|
|
return -1;
|
2020-02-20 22:01:48 +00:00
|
|
|
}
|
|
|
|
if (STRNEQ(baseline->props[0].name, "feat_a") ||
|
|
|
|
!baseline->props[0].value.boolean ||
|
|
|
|
STRNEQ(baseline->props[1].name, "feat_b") ||
|
|
|
|
baseline->props[1].value.boolean) {
|
|
|
|
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
|
|
|
"Baseline property error");
|
2021-11-01 09:20:57 +00:00
|
|
|
return -1;
|
2020-02-20 22:01:48 +00:00
|
|
|
}
|
|
|
|
|
2021-11-01 09:20:57 +00:00
|
|
|
return 0;
|
2020-02-20 22:01:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2021-12-08 12:05:44 +00:00
|
|
|
static int
|
|
|
|
testQemuMonitorJSONGetSEVInfo(const void *opaque)
|
|
|
|
{
|
|
|
|
const testGenericData *data = opaque;
|
|
|
|
virDomainXMLOption *xmlopt = data->xmlopt;
|
|
|
|
g_autoptr(qemuMonitorTest) test = NULL;
|
2024-06-10 14:17:26 +00:00
|
|
|
qemuMonitorSEVInfo info = { };
|
2021-12-08 12:05:44 +00:00
|
|
|
|
|
|
|
if (!(test = qemuMonitorTestNewSchema(xmlopt, data->schema)))
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
if (qemuMonitorTestAddItem(test, "query-sev",
|
|
|
|
"{"
|
|
|
|
" \"return\": {"
|
|
|
|
" \"enabled\": false,"
|
|
|
|
" \"api-minor\": 8,"
|
|
|
|
" \"handle\": 0,"
|
|
|
|
" \"state\": \"uninit\","
|
|
|
|
" \"api-major\": 1,"
|
|
|
|
" \"build-id\": 834,"
|
|
|
|
" \"policy\": 3"
|
|
|
|
" },"
|
|
|
|
" \"id\": \"libvirt-15\""
|
|
|
|
"}") < 0)
|
|
|
|
return -1;
|
|
|
|
|
2024-06-10 14:17:26 +00:00
|
|
|
if (qemuMonitorGetSEVInfo(qemuMonitorTestGetMonitor(test), &info) < 0)
|
2021-12-08 12:05:44 +00:00
|
|
|
return -1;
|
|
|
|
|
2024-06-10 14:17:26 +00:00
|
|
|
if (info.apiMajor != 1 || info.apiMinor != 8 || info.buildID != 834 ||
|
|
|
|
info.type != QEMU_MONITOR_SEV_GUEST_TYPE_SEV ||
|
|
|
|
info.data.sev.policy != 3 || info.data.sev.handle != 0) {
|
2021-12-08 12:05:44 +00:00
|
|
|
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
|
|
|
"Unexpected SEV info values");
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2024-06-10 14:17:26 +00:00
|
|
|
if (qemuMonitorTestAddItem(test, "query-sev",
|
|
|
|
"{"
|
|
|
|
" \"return\": {"
|
|
|
|
" \"enabled\": true,"
|
|
|
|
" \"api-minor\": 55,"
|
|
|
|
" \"handle\": 1,"
|
|
|
|
" \"state\": \"running\","
|
|
|
|
" \"api-major\": 1,"
|
|
|
|
" \"sev-type\": \"sev\","
|
|
|
|
" \"build-id\": 21,"
|
|
|
|
" \"policy\": 1"
|
|
|
|
" },"
|
|
|
|
" \"id\": \"libvirt-16\""
|
|
|
|
"}") < 0)
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
if (qemuMonitorGetSEVInfo(qemuMonitorTestGetMonitor(test), &info) < 0)
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
if (info.apiMajor != 1 || info.apiMinor != 55 || info.buildID != 21 ||
|
|
|
|
info.type != QEMU_MONITOR_SEV_GUEST_TYPE_SEV ||
|
|
|
|
info.data.sev.policy != 1 || info.data.sev.handle != 1) {
|
|
|
|
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
|
|
|
"Unexpected SEV info values");
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (qemuMonitorTestAddItem(test, "query-sev",
|
|
|
|
"{"
|
|
|
|
" \"return\": {"
|
|
|
|
" \"enabled\": true,"
|
|
|
|
" \"api-minor\": 55,"
|
|
|
|
" \"state\": \"running\","
|
|
|
|
" \"api-major\": 1,"
|
|
|
|
" \"sev-type\": \"sev-snp\","
|
|
|
|
" \"build-id\": 21,"
|
|
|
|
" \"snp-policy\": 196608"
|
|
|
|
" },"
|
|
|
|
" \"id\": \"libvirt-16\""
|
|
|
|
"}") < 0)
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
if (qemuMonitorGetSEVInfo(qemuMonitorTestGetMonitor(test), &info) < 0)
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
if (info.apiMajor != 1 || info.apiMinor != 55 || info.buildID != 21 ||
|
|
|
|
info.type != QEMU_MONITOR_SEV_GUEST_TYPE_SEV_SNP ||
|
|
|
|
info.data.sev_snp.snp_policy != 0x30000) {
|
|
|
|
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
|
|
|
"Unexpected SEV SNP info values");
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2021-12-08 12:05:44 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2012-08-20 12:31:29 +00:00
|
|
|
static int
|
|
|
|
mymain(void)
|
|
|
|
{
|
|
|
|
int ret = 0;
|
tests: Avoid use of virQEMUDriverCreateXMLConf(NULL)
We use the function to create a virDomainXMLOption object that is
required for some functions. However, we don't pass the driver
pointer to the object anywhere - rather than pass NULL. This
causes trouble later when parsing a domain XML and calling post
parse callbacks:
Program received signal SIGSEGV, Segmentation fault.
0x000000000043fa3e in qemuDomainDefPostParse (def=0x7d36c0, caps=0x7caf10, opaque=0x0) at qemu/qemu_domain.c:1043
1043 qemuCaps = virQEMUCapsCacheLookup(driver->qemuCapsCache, def->emulator);
(gdb) bt
#0 0x000000000043fa3e in qemuDomainDefPostParse (def=0x7d36c0, caps=0x7caf10, opaque=0x0) at qemu/qemu_domain.c:1043
#1 0x00007ffff2928bf9 in virDomainDefPostParse (def=0x7d36c0, caps=0x7caf10, xmlopt=0x7c82c0) at conf/domain_conf.c:4269
#2 0x00007ffff294de04 in virDomainDefParseXML (xml=0x7da8c0, root=0x7dab80, ctxt=0x7da980, caps=0x7caf10, xmlopt=0x7c82c0, flags=0) at conf/domain_conf.c:16400
#3 0x00007ffff294e5b5 in virDomainDefParseNode (xml=0x7da8c0, root=0x7dab80, caps=0x7caf10, xmlopt=0x7c82c0, flags=0) at conf/domain_conf.c:16582
#4 0x00007ffff294e424 in virDomainDefParse (xmlStr=0x0, filename=0x7c7ef0 "/home/zippy/work/libvirt/libvirt.git/tests/securityselinuxlabeldata/disks.xml", caps=0x7caf10, xmlopt=0x7c82c0, flags=0) at conf/domain_conf.c:16529
#5 0x00007ffff294e4b2 in virDomainDefParseFile (filename=0x7c7ef0 "/home/zippy/work/libvirt/libvirt.git/tests/securityselinuxlabeldata/disks.xml", caps=0x7caf10, xmlopt=0x7c82c0, flags=0) at conf/domain_conf.c:16553
#6 0x00000000004303ca in testSELinuxLoadDef (testname=0x53c929 "disks") at securityselinuxlabeltest.c:192
#7 0x00000000004309e8 in testSELinuxLabeling (opaque=0x53c929) at securityselinuxlabeltest.c:313
#8 0x0000000000431207 in virtTestRun (title=0x53c92f "Labelling \"disks\"", body=0x430964 <testSELinuxLabeling>, data=0x53c929) at testutils.c:211
#9 0x0000000000430c5d in mymain () at securityselinuxlabeltest.c:373
#10 0x00000000004325c2 in virtTestMain (argc=1, argv=0x7fffffffd7e8, func=0x430b4a <mymain>) at testutils.c:863
#11 0x0000000000430deb in main (argc=1, argv=0x7fffffffd7e8) at securityselinuxlabeltest.c:381
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2015-09-22 14:27:57 +00:00
|
|
|
virQEMUDriver driver;
|
2013-09-18 15:28:31 +00:00
|
|
|
testQemuMonitorJSONSimpleFuncData simpleFunc;
|
2021-11-30 10:49:24 +00:00
|
|
|
g_autoptr(GHashTable) qapischema_x86_64 = NULL;
|
|
|
|
g_autoptr(GHashTable) qapischema_s390x = NULL;
|
2018-03-22 16:07:43 +00:00
|
|
|
struct testQAPISchemaData qapiData;
|
2012-08-20 12:31:29 +00:00
|
|
|
|
2019-09-16 16:44:23 +00:00
|
|
|
if (qemuTestDriverInit(&driver) < 0)
|
2013-02-22 22:42:39 +00:00
|
|
|
return EXIT_FAILURE;
|
2012-08-20 12:31:29 +00:00
|
|
|
|
|
|
|
virEventRegisterDefaultImpl();
|
|
|
|
|
2021-11-30 10:49:24 +00:00
|
|
|
if (!(qapischema_x86_64 = testQEMUSchemaLoadLatest("x86_64"))) {
|
|
|
|
VIR_TEST_VERBOSE("failed to load x86_64 qapi schema");
|
2018-03-22 18:07:21 +00:00
|
|
|
ret = -1;
|
|
|
|
goto cleanup;
|
|
|
|
}
|
|
|
|
|
2021-11-30 10:49:24 +00:00
|
|
|
qapiData.schema = qapischema_x86_64;
|
|
|
|
|
2017-11-03 12:09:47 +00:00
|
|
|
#define DO_TEST(name) \
|
qemumonitorjsontest: Validate more commands against schema
The DO_TEST() macro in qemumonitorjsontest.c was not passing the
schema through, which meant that we were not validating any of those
tests for correct usage according to the schema.
In the process of mechanically altering tests to pass the schema
through, use VIR_AUTOPTR on all of the affected test instances. The
next patch will do some further cleanups that it exposes.
Tested by using this hack, where the test mistakenly passed pre-patch,
but correctly diagnosed the garbage post-patch:
| diff --git i/src/qemu/qemu_monitor_json.c w/src/qemu/qemu_monitor_json.c
| index 53a7de8b77..86d8450814 100644
| --- i/src/qemu/qemu_monitor_json.c
| +++ w/src/qemu/qemu_monitor_json.c
| @@ -1532,7 +1532,8 @@ qemuMonitorJSONGetStatus(qemuMonitorPtr mon,
| if (reason)
| *reason = VIR_DOMAIN_PAUSED_UNKNOWN;
|
| - if (!(cmd = qemuMonitorJSONMakeCommand("query-status", NULL)))
| + if (!(cmd = qemuMonitorJSONMakeCommand("query-status",
| + "s:garbage", "foo", NULL)))
| return -1;
|
| if (qemuMonitorJSONCommand(mon, cmd, &reply) < 0)
Suggested-by: Peter Krempa <pkrempa@redhat.com>
Signed-off-by: Eric Blake <eblake@redhat.com>
Acked-by: Peter Krempa <pkrempa@redhat.com>
2019-06-12 01:59:11 +00:00
|
|
|
do { \
|
|
|
|
testGenericData data = { driver.xmlopt, qapiData.schema }; \
|
|
|
|
if (virTestRun(# name, testQemuMonitorJSON ## name, &data) < 0) \
|
|
|
|
ret = -1; \
|
|
|
|
} while (0)
|
2012-08-20 12:31:29 +00:00
|
|
|
|
2017-11-03 12:09:47 +00:00
|
|
|
#define DO_TEST_SIMPLE(CMD, FNC, ...) \
|
2013-09-18 15:28:31 +00:00
|
|
|
simpleFunc = (testQemuMonitorJSONSimpleFuncData) {.cmd = CMD, .func = FNC, \
|
2018-07-12 11:40:00 +00:00
|
|
|
.xmlopt = driver.xmlopt, \
|
|
|
|
.schema = qapiData.schema, \
|
|
|
|
__VA_ARGS__ }; \
|
2017-11-03 12:09:47 +00:00
|
|
|
if (virTestRun(# FNC, testQemuMonitorJSONSimpleFunc, &simpleFunc) < 0) \
|
2013-09-18 15:28:31 +00:00
|
|
|
ret = -1
|
|
|
|
|
2020-04-29 17:41:38 +00:00
|
|
|
#define DO_TEST_GEN_FULL(name, dpr, rmvd, ...) \
|
tests: Avoid use of virQEMUDriverCreateXMLConf(NULL)
We use the function to create a virDomainXMLOption object that is
required for some functions. However, we don't pass the driver
pointer to the object anywhere - rather than pass NULL. This
causes trouble later when parsing a domain XML and calling post
parse callbacks:
Program received signal SIGSEGV, Segmentation fault.
0x000000000043fa3e in qemuDomainDefPostParse (def=0x7d36c0, caps=0x7caf10, opaque=0x0) at qemu/qemu_domain.c:1043
1043 qemuCaps = virQEMUCapsCacheLookup(driver->qemuCapsCache, def->emulator);
(gdb) bt
#0 0x000000000043fa3e in qemuDomainDefPostParse (def=0x7d36c0, caps=0x7caf10, opaque=0x0) at qemu/qemu_domain.c:1043
#1 0x00007ffff2928bf9 in virDomainDefPostParse (def=0x7d36c0, caps=0x7caf10, xmlopt=0x7c82c0) at conf/domain_conf.c:4269
#2 0x00007ffff294de04 in virDomainDefParseXML (xml=0x7da8c0, root=0x7dab80, ctxt=0x7da980, caps=0x7caf10, xmlopt=0x7c82c0, flags=0) at conf/domain_conf.c:16400
#3 0x00007ffff294e5b5 in virDomainDefParseNode (xml=0x7da8c0, root=0x7dab80, caps=0x7caf10, xmlopt=0x7c82c0, flags=0) at conf/domain_conf.c:16582
#4 0x00007ffff294e424 in virDomainDefParse (xmlStr=0x0, filename=0x7c7ef0 "/home/zippy/work/libvirt/libvirt.git/tests/securityselinuxlabeldata/disks.xml", caps=0x7caf10, xmlopt=0x7c82c0, flags=0) at conf/domain_conf.c:16529
#5 0x00007ffff294e4b2 in virDomainDefParseFile (filename=0x7c7ef0 "/home/zippy/work/libvirt/libvirt.git/tests/securityselinuxlabeldata/disks.xml", caps=0x7caf10, xmlopt=0x7c82c0, flags=0) at conf/domain_conf.c:16553
#6 0x00000000004303ca in testSELinuxLoadDef (testname=0x53c929 "disks") at securityselinuxlabeltest.c:192
#7 0x00000000004309e8 in testSELinuxLabeling (opaque=0x53c929) at securityselinuxlabeltest.c:313
#8 0x0000000000431207 in virtTestRun (title=0x53c92f "Labelling \"disks\"", body=0x430964 <testSELinuxLabeling>, data=0x53c929) at testutils.c:211
#9 0x0000000000430c5d in mymain () at securityselinuxlabeltest.c:373
#10 0x00000000004325c2 in virtTestMain (argc=1, argv=0x7fffffffd7e8, func=0x430b4a <mymain>) at testutils.c:863
#11 0x0000000000430deb in main (argc=1, argv=0x7fffffffd7e8) at securityselinuxlabeltest.c:381
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2015-09-22 14:27:57 +00:00
|
|
|
simpleFunc = (testQemuMonitorJSONSimpleFuncData) {.xmlopt = driver.xmlopt, \
|
2020-04-29 17:41:38 +00:00
|
|
|
.allowDeprecated = dpr, \
|
|
|
|
.allowRemoved = rmvd, \
|
2018-07-12 11:53:25 +00:00
|
|
|
.schema = qapiData.schema \
|
2017-11-03 12:09:47 +00:00
|
|
|
__VA_ARGS__ }; \
|
|
|
|
if (virTestRun(# name, testQemuMonitorJSON ## name, &simpleFunc) < 0) \
|
2013-10-01 14:23:50 +00:00
|
|
|
ret = -1
|
|
|
|
|
2020-04-29 17:41:38 +00:00
|
|
|
#define DO_TEST_GEN(name, ...) DO_TEST_GEN_FULL(name, false, false, __VA_ARGS__)
|
|
|
|
#define DO_TEST_GEN_DEPRECATED(name, removed, ...) \
|
|
|
|
DO_TEST_GEN_FULL(name, true, removed, __VA_ARGS__)
|
|
|
|
|
2013-07-22 11:07:23 +00:00
|
|
|
#define DO_TEST_CPU_DATA(name) \
|
2017-11-03 12:09:47 +00:00
|
|
|
do { \
|
qemumonitorjsontest: Validate more commands against schema
The DO_TEST() macro in qemumonitorjsontest.c was not passing the
schema through, which meant that we were not validating any of those
tests for correct usage according to the schema.
In the process of mechanically altering tests to pass the schema
through, use VIR_AUTOPTR on all of the affected test instances. The
next patch will do some further cleanups that it exposes.
Tested by using this hack, where the test mistakenly passed pre-patch,
but correctly diagnosed the garbage post-patch:
| diff --git i/src/qemu/qemu_monitor_json.c w/src/qemu/qemu_monitor_json.c
| index 53a7de8b77..86d8450814 100644
| --- i/src/qemu/qemu_monitor_json.c
| +++ w/src/qemu/qemu_monitor_json.c
| @@ -1532,7 +1532,8 @@ qemuMonitorJSONGetStatus(qemuMonitorPtr mon,
| if (reason)
| *reason = VIR_DOMAIN_PAUSED_UNKNOWN;
|
| - if (!(cmd = qemuMonitorJSONMakeCommand("query-status", NULL)))
| + if (!(cmd = qemuMonitorJSONMakeCommand("query-status",
| + "s:garbage", "foo", NULL)))
| return -1;
|
| if (qemuMonitorJSONCommand(mon, cmd, &reply) < 0)
Suggested-by: Peter Krempa <pkrempa@redhat.com>
Signed-off-by: Eric Blake <eblake@redhat.com>
Acked-by: Peter Krempa <pkrempa@redhat.com>
2019-06-12 01:59:11 +00:00
|
|
|
struct testCPUData data = { name, driver.xmlopt, qapiData.schema }; \
|
2017-11-03 12:09:47 +00:00
|
|
|
const char *label = "GetCPUData(" name ")"; \
|
|
|
|
if (virTestRun(label, testQemuMonitorJSONGetCPUData, &data) < 0) \
|
|
|
|
ret = -1; \
|
2013-07-22 11:07:23 +00:00
|
|
|
} while (0)
|
|
|
|
|
2017-11-03 12:09:47 +00:00
|
|
|
#define DO_TEST_CPU_INFO(name, maxvcpus) \
|
|
|
|
do { \
|
2022-08-08 15:15:06 +00:00
|
|
|
struct testCPUInfoData data = {name, maxvcpus, driver.xmlopt, \
|
qemumonitorjsontest: Validate more commands against schema
The DO_TEST() macro in qemumonitorjsontest.c was not passing the
schema through, which meant that we were not validating any of those
tests for correct usage according to the schema.
In the process of mechanically altering tests to pass the schema
through, use VIR_AUTOPTR on all of the affected test instances. The
next patch will do some further cleanups that it exposes.
Tested by using this hack, where the test mistakenly passed pre-patch,
but correctly diagnosed the garbage post-patch:
| diff --git i/src/qemu/qemu_monitor_json.c w/src/qemu/qemu_monitor_json.c
| index 53a7de8b77..86d8450814 100644
| --- i/src/qemu/qemu_monitor_json.c
| +++ w/src/qemu/qemu_monitor_json.c
| @@ -1532,7 +1532,8 @@ qemuMonitorJSONGetStatus(qemuMonitorPtr mon,
| if (reason)
| *reason = VIR_DOMAIN_PAUSED_UNKNOWN;
|
| - if (!(cmd = qemuMonitorJSONMakeCommand("query-status", NULL)))
| + if (!(cmd = qemuMonitorJSONMakeCommand("query-status",
| + "s:garbage", "foo", NULL)))
| return -1;
|
| if (qemuMonitorJSONCommand(mon, cmd, &reply) < 0)
Suggested-by: Peter Krempa <pkrempa@redhat.com>
Signed-off-by: Eric Blake <eblake@redhat.com>
Acked-by: Peter Krempa <pkrempa@redhat.com>
2019-06-12 01:59:11 +00:00
|
|
|
qapiData.schema}; \
|
2018-04-04 14:45:04 +00:00
|
|
|
if (virTestRun("GetCPUInfo(" name ")", testQemuMonitorCPUInfo, \
|
|
|
|
&data) < 0) \
|
|
|
|
ret = -1; \
|
|
|
|
} while (0)
|
|
|
|
|
2012-08-20 12:31:29 +00:00
|
|
|
DO_TEST(GetStatus);
|
2012-08-15 14:04:09 +00:00
|
|
|
DO_TEST(GetVersion);
|
2012-08-15 15:18:41 +00:00
|
|
|
DO_TEST(GetMachines);
|
2012-08-20 14:58:20 +00:00
|
|
|
DO_TEST(GetCPUDefinitions);
|
2013-04-26 11:13:05 +00:00
|
|
|
DO_TEST(GetTPMModels);
|
qemumonitorjsontest: Validate more commands against schema
The DO_TEST() macro in qemumonitorjsontest.c was not passing the
schema through, which meant that we were not validating any of those
tests for correct usage according to the schema.
In the process of mechanically altering tests to pass the schema
through, use VIR_AUTOPTR on all of the affected test instances. The
next patch will do some further cleanups that it exposes.
Tested by using this hack, where the test mistakenly passed pre-patch,
but correctly diagnosed the garbage post-patch:
| diff --git i/src/qemu/qemu_monitor_json.c w/src/qemu/qemu_monitor_json.c
| index 53a7de8b77..86d8450814 100644
| --- i/src/qemu/qemu_monitor_json.c
| +++ w/src/qemu/qemu_monitor_json.c
| @@ -1532,7 +1532,8 @@ qemuMonitorJSONGetStatus(qemuMonitorPtr mon,
| if (reason)
| *reason = VIR_DOMAIN_PAUSED_UNKNOWN;
|
| - if (!(cmd = qemuMonitorJSONMakeCommand("query-status", NULL)))
| + if (!(cmd = qemuMonitorJSONMakeCommand("query-status",
| + "s:garbage", "foo", NULL)))
| return -1;
|
| if (qemuMonitorJSONCommand(mon, cmd, &reply) < 0)
Suggested-by: Peter Krempa <pkrempa@redhat.com>
Signed-off-by: Eric Blake <eblake@redhat.com>
Acked-by: Peter Krempa <pkrempa@redhat.com>
2019-06-12 01:59:11 +00:00
|
|
|
if (qemuMonitorJSONTestAttachChardev(driver.xmlopt, qapiData.schema) < 0)
|
2016-09-27 13:49:05 +00:00
|
|
|
ret = -1;
|
2013-03-12 18:57:48 +00:00
|
|
|
DO_TEST(DetachChardev);
|
2013-06-24 17:51:56 +00:00
|
|
|
DO_TEST(GetListPaths);
|
2013-07-03 18:15:07 +00:00
|
|
|
DO_TEST(GetObjectProperty);
|
2013-07-03 18:42:40 +00:00
|
|
|
DO_TEST(SetObjectProperty);
|
2013-07-19 13:01:38 +00:00
|
|
|
DO_TEST(GetDeviceAliases);
|
2013-09-18 13:11:06 +00:00
|
|
|
DO_TEST(CPU);
|
2013-11-19 15:30:28 +00:00
|
|
|
DO_TEST(GetNonExistingCPUData);
|
2014-08-29 20:23:11 +00:00
|
|
|
DO_TEST(GetIOThreads);
|
2021-12-08 12:05:44 +00:00
|
|
|
DO_TEST(GetSEVInfo);
|
2019-09-26 14:12:20 +00:00
|
|
|
DO_TEST(Transaction);
|
2020-10-14 09:33:06 +00:00
|
|
|
DO_TEST(BlockExportAdd);
|
2021-02-22 16:59:28 +00:00
|
|
|
DO_TEST(BlockdevReopen);
|
2013-09-18 15:28:31 +00:00
|
|
|
DO_TEST_SIMPLE("qmp_capabilities", qemuMonitorJSONSetCapabilities);
|
2013-10-01 14:28:51 +00:00
|
|
|
DO_TEST_SIMPLE("system_powerdown", qemuMonitorJSONSystemPowerdown);
|
2013-09-18 15:28:31 +00:00
|
|
|
DO_TEST_SIMPLE("system_reset", qemuMonitorJSONSystemReset);
|
|
|
|
DO_TEST_SIMPLE("migrate_cancel", qemuMonitorJSONMigrateCancel);
|
|
|
|
DO_TEST_SIMPLE("inject-nmi", qemuMonitorJSONInjectNMI);
|
|
|
|
DO_TEST_SIMPLE("system_wakeup", qemuMonitorJSONSystemWakeup);
|
|
|
|
DO_TEST_SIMPLE("nbd-server-stop", qemuMonitorJSONNBDServerStop);
|
2014-08-13 12:28:24 +00:00
|
|
|
DO_TEST_SIMPLE("rtc-reset-reinjection", qemuMonitorJSONRTCResetReinjection);
|
2013-10-01 14:23:50 +00:00
|
|
|
DO_TEST_GEN(qemuMonitorJSONSetLink);
|
|
|
|
DO_TEST_GEN(qemuMonitorJSONBlockResize);
|
|
|
|
DO_TEST_GEN(qemuMonitorJSONSetPassword);
|
|
|
|
DO_TEST_GEN(qemuMonitorJSONExpirePassword);
|
|
|
|
DO_TEST_GEN(qemuMonitorJSONSetBalloon);
|
|
|
|
DO_TEST_GEN(qemuMonitorJSONSaveVirtualMemory);
|
|
|
|
DO_TEST_GEN(qemuMonitorJSONSavePhysicalMemory);
|
|
|
|
DO_TEST_GEN(qemuMonitorJSONMigrate);
|
2022-05-10 13:20:25 +00:00
|
|
|
DO_TEST_GEN(qemuMonitorJSONMigrateRecover);
|
2022-05-10 13:20:25 +00:00
|
|
|
DO_TEST_SIMPLE("migrate-pause", qemuMonitorJSONMigratePause);
|
2013-10-01 14:23:50 +00:00
|
|
|
DO_TEST_GEN(qemuMonitorJSONDump);
|
|
|
|
DO_TEST_GEN(qemuMonitorJSONGraphicsRelocate);
|
|
|
|
DO_TEST_GEN(qemuMonitorJSONRemoveNetdev);
|
|
|
|
DO_TEST_GEN(qemuMonitorJSONDelDevice);
|
2018-08-16 16:42:12 +00:00
|
|
|
DO_TEST_GEN(qemuMonitorJSONBlockdevMirror);
|
2018-08-15 13:42:22 +00:00
|
|
|
DO_TEST_GEN(qemuMonitorJSONBlockStream);
|
2013-10-01 14:23:50 +00:00
|
|
|
DO_TEST_GEN(qemuMonitorJSONBlockCommit);
|
|
|
|
DO_TEST_GEN(qemuMonitorJSONScreendump);
|
|
|
|
DO_TEST_GEN(qemuMonitorJSONOpenGraphics);
|
2020-10-14 09:49:50 +00:00
|
|
|
DO_TEST_GEN_DEPRECATED(qemuMonitorJSONNBDServerAdd, true);
|
2013-10-01 14:23:50 +00:00
|
|
|
DO_TEST_GEN(qemuMonitorJSONDetachCharDev);
|
2018-07-12 10:11:31 +00:00
|
|
|
DO_TEST_GEN(qemuMonitorJSONBlockdevTrayOpen);
|
|
|
|
DO_TEST_GEN(qemuMonitorJSONBlockdevTrayClose);
|
|
|
|
DO_TEST_GEN(qemuMonitorJSONBlockdevMediumRemove);
|
|
|
|
DO_TEST_GEN(qemuMonitorJSONBlockdevMediumInsert);
|
2021-02-08 15:58:53 +00:00
|
|
|
DO_TEST_GEN(qemuMonitorJSONBitmapRemove);
|
2018-08-16 09:48:41 +00:00
|
|
|
DO_TEST_GEN(qemuMonitorJSONJobDismiss);
|
2018-08-16 09:48:41 +00:00
|
|
|
DO_TEST_GEN(qemuMonitorJSONJobComplete);
|
2022-06-21 13:22:15 +00:00
|
|
|
DO_TEST_GEN(qemuMonitorJSONJobFinalize);
|
2021-04-20 14:14:56 +00:00
|
|
|
DO_TEST_GEN(qemuMonitorJSONBlockJobCancel);
|
2021-08-20 12:39:27 +00:00
|
|
|
DO_TEST_GEN(qemuMonitorJSONSetAction);
|
2021-11-17 01:21:19 +00:00
|
|
|
DO_TEST_GEN(qemuMonitorJSONSetLaunchSecurityState);
|
2013-10-02 10:02:53 +00:00
|
|
|
DO_TEST(qemuMonitorJSONGetBalloonInfo);
|
2013-10-02 12:39:10 +00:00
|
|
|
DO_TEST(qemuMonitorJSONGetBlockInfo);
|
2018-06-18 08:24:17 +00:00
|
|
|
DO_TEST(qemuMonitorJSONGetAllBlockStatsInfo);
|
2015-11-26 12:23:08 +00:00
|
|
|
DO_TEST(qemuMonitorJSONGetMigrationStats);
|
2014-11-13 15:17:21 +00:00
|
|
|
DO_TEST(qemuMonitorJSONGetChardevInfo);
|
2013-10-02 16:46:42 +00:00
|
|
|
DO_TEST(qemuMonitorJSONSetBlockIoThrottle);
|
2013-10-02 16:55:42 +00:00
|
|
|
DO_TEST(qemuMonitorJSONGetTargetArch);
|
2018-03-01 09:51:53 +00:00
|
|
|
DO_TEST(qemuMonitorJSONGetMigrationCapabilities);
|
2020-04-29 17:47:36 +00:00
|
|
|
DO_TEST(qemuMonitorJSONQueryCPUsFast);
|
2013-10-02 16:23:17 +00:00
|
|
|
DO_TEST(qemuMonitorJSONSendKey);
|
2014-03-23 03:51:13 +00:00
|
|
|
DO_TEST(qemuMonitorJSONGetDumpGuestMemoryCapability);
|
2014-06-03 09:19:51 +00:00
|
|
|
DO_TEST(qemuMonitorJSONSendKeyHoldtime);
|
2019-04-09 21:21:38 +00:00
|
|
|
DO_TEST(qemuMonitorJSONNBDServerStart);
|
2024-07-17 18:21:35 +00:00
|
|
|
DO_TEST(qemuMonitorJSONSnapshot);
|
2012-08-20 12:31:29 +00:00
|
|
|
|
2013-07-22 11:07:23 +00:00
|
|
|
DO_TEST_CPU_DATA("host");
|
|
|
|
DO_TEST_CPU_DATA("full");
|
2016-05-20 09:17:11 +00:00
|
|
|
DO_TEST_CPU_DATA("ecx");
|
2013-07-22 11:07:23 +00:00
|
|
|
|
2022-08-08 15:15:06 +00:00
|
|
|
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("x86-dies", 16);
|
2016-07-29 16:08:06 +00:00
|
|
|
|
2022-08-08 15:15:06 +00:00
|
|
|
DO_TEST_CPU_INFO("ppc64-basic", 24);
|
|
|
|
DO_TEST_CPU_INFO("ppc64-hotplug-1", 24);
|
|
|
|
DO_TEST_CPU_INFO("ppc64-hotplug-2", 24);
|
|
|
|
DO_TEST_CPU_INFO("ppc64-hotplug-4", 24);
|
|
|
|
DO_TEST_CPU_INFO("ppc64-no-threads", 16);
|
2016-07-29 17:24:22 +00:00
|
|
|
|
2024-01-08 17:44:25 +00:00
|
|
|
/* aarch64 doesn't support CPU hotplug yet, so the data used in
|
|
|
|
* this test is partially synthetic */
|
|
|
|
DO_TEST_CPU_INFO("aarch64-clusters", 16);
|
|
|
|
|
2022-08-08 15:15:06 +00:00
|
|
|
DO_TEST_CPU_INFO("s390", 2);
|
2018-04-04 14:45:06 +00:00
|
|
|
|
2017-03-13 11:47:46 +00:00
|
|
|
|
2019-04-09 11:22:32 +00:00
|
|
|
#define DO_TEST_QAPI_QUERY(nme, qry, scc, rplobj) \
|
|
|
|
do { \
|
|
|
|
qapiData.name = nme; \
|
|
|
|
qapiData.query = qry; \
|
|
|
|
qapiData.rc = scc; \
|
|
|
|
qapiData.replyobj = rplobj; \
|
2020-04-01 10:37:48 +00:00
|
|
|
if (virTestRun("qapi schema query " nme, testQAPISchemaQuery, &qapiData) < 0)\
|
2019-04-09 11:22:32 +00:00
|
|
|
ret = -1; \
|
|
|
|
} while (0)
|
|
|
|
|
2019-04-09 12:09:33 +00:00
|
|
|
DO_TEST_QAPI_QUERY("command", "blockdev-add", 1, true);
|
|
|
|
DO_TEST_QAPI_QUERY("event", "RTC_CHANGE", 1, true);
|
|
|
|
DO_TEST_QAPI_QUERY("object property", "screendump/arg-type/device", 1, true);
|
|
|
|
DO_TEST_QAPI_QUERY("optional property", "block-commit/arg-type/*top", 1, true);
|
|
|
|
DO_TEST_QAPI_QUERY("variant", "blockdev-add/arg-type/+file", 1, true);
|
|
|
|
DO_TEST_QAPI_QUERY("variant property", "blockdev-add/arg-type/+file/filename", 1, true);
|
2019-04-11 12:54:41 +00:00
|
|
|
DO_TEST_QAPI_QUERY("enum value", "query-status/ret-type/status/^debug", 1, false);
|
2019-04-11 12:54:41 +00:00
|
|
|
DO_TEST_QAPI_QUERY("builtin type", "query-qmp-schema/ret-type/name/!string", 1, false);
|
2019-04-11 12:54:41 +00:00
|
|
|
DO_TEST_QAPI_QUERY("alternate variant 1", "blockdev-add/arg-type/+qcow2/backing/!null", 1, false);
|
|
|
|
DO_TEST_QAPI_QUERY("alternate variant 2", "blockdev-add/arg-type/+qcow2/backing/!string", 1, false);
|
|
|
|
DO_TEST_QAPI_QUERY("alternate variant 3", "blockdev-add/arg-type/+qcow2/backing/+file/filename", 1, true);
|
2019-04-09 11:22:32 +00:00
|
|
|
|
|
|
|
DO_TEST_QAPI_QUERY("nonexistent command", "nonexistent", 0, false);
|
|
|
|
DO_TEST_QAPI_QUERY("nonexistent attr", "screendump/arg-type/nonexistent", 0, false);
|
|
|
|
DO_TEST_QAPI_QUERY("nonexistent variant", "blockdev-add/arg-type/+nonexistent", 0, false);
|
2019-04-11 12:54:41 +00:00
|
|
|
DO_TEST_QAPI_QUERY("nonexistent enum value", "query-status/ret-type/status/^nonexistentdebug", 0, false);
|
|
|
|
DO_TEST_QAPI_QUERY("broken query for enum value", "query-status/ret-type/status/^debug/test", -1, false);
|
2019-04-11 12:54:41 +00:00
|
|
|
DO_TEST_QAPI_QUERY("builtin type", "query-qmp-schema/ret-type/name/!number", 0, false);
|
2019-04-09 11:22:32 +00:00
|
|
|
|
|
|
|
#undef DO_TEST_QAPI_QUERY
|
|
|
|
|
|
|
|
|
2019-04-09 08:32:33 +00:00
|
|
|
#define DO_TEST_QAPI_VALIDATE(nme, rootquery, scc, jsonstr) \
|
2018-03-22 16:07:43 +00:00
|
|
|
do { \
|
|
|
|
qapiData.name = nme; \
|
|
|
|
qapiData.query = rootquery; \
|
|
|
|
qapiData.success = scc; \
|
|
|
|
qapiData.json = jsonstr; \
|
2020-04-01 10:37:48 +00:00
|
|
|
if (virTestRun("qapi schema validate " nme, testQAPISchemaValidate, &qapiData) < 0)\
|
2018-03-22 16:07:43 +00:00
|
|
|
ret = -1; \
|
|
|
|
} while (0)
|
|
|
|
|
2012-08-20 12:31:29 +00:00
|
|
|
|
2019-04-09 08:32:33 +00:00
|
|
|
DO_TEST_QAPI_VALIDATE("string", "trace-event-get-state/arg-type", true,
|
|
|
|
"{\"name\":\"test\"}");
|
|
|
|
DO_TEST_QAPI_VALIDATE("attr type mismatch", "trace-event-get-state/arg-type", false,
|
|
|
|
"{\"name\":123}");
|
|
|
|
DO_TEST_QAPI_VALIDATE("missing mandatory attr", "trace-event-get-state/arg-type", false,
|
2023-06-06 09:03:39 +00:00
|
|
|
"{}");
|
2019-04-09 08:32:33 +00:00
|
|
|
DO_TEST_QAPI_VALIDATE("attr name not present", "trace-event-get-state/arg-type", false,
|
|
|
|
"{\"name\":\"test\", \"blah\":123}");
|
|
|
|
DO_TEST_QAPI_VALIDATE("variant", "blockdev-add/arg-type", true,
|
|
|
|
"{\"driver\":\"file\", \"filename\":\"ble\"}");
|
|
|
|
DO_TEST_QAPI_VALIDATE("variant wrong", "blockdev-add/arg-type", false,
|
|
|
|
"{\"driver\":\"filefilefilefile\", \"filename\":\"ble\"}");
|
|
|
|
DO_TEST_QAPI_VALIDATE("variant missing mandatory", "blockdev-add/arg-type", false,
|
|
|
|
"{\"driver\":\"file\", \"pr-manager\":\"ble\"}");
|
|
|
|
DO_TEST_QAPI_VALIDATE("variant missing discriminator", "blockdev-add/arg-type", false,
|
|
|
|
"{\"node-name\":\"dfgfdg\"}");
|
|
|
|
DO_TEST_QAPI_VALIDATE("alternate 1", "blockdev-add/arg-type", true,
|
|
|
|
"{\"driver\":\"qcow2\","
|
|
|
|
"\"file\": { \"driver\":\"file\", \"filename\":\"ble\"}}");
|
|
|
|
DO_TEST_QAPI_VALIDATE("alternate 2", "blockdev-add/arg-type", true,
|
|
|
|
"{\"driver\":\"qcow2\",\"file\": \"somepath\"}");
|
|
|
|
DO_TEST_QAPI_VALIDATE("alternate 2", "blockdev-add/arg-type", false,
|
|
|
|
"{\"driver\":\"qcow2\",\"file\": 1234}");
|
2018-03-22 16:07:43 +00:00
|
|
|
|
2019-04-09 08:32:33 +00:00
|
|
|
#undef DO_TEST_QAPI_VALIDATE
|
2018-03-22 16:07:43 +00:00
|
|
|
|
2020-08-06 17:45:24 +00:00
|
|
|
if (virTestRun("validate that object-add and device_add don't have schema",
|
|
|
|
testQAPISchemaObjectDeviceAdd, qapiData.schema) < 0)
|
|
|
|
ret = -1;
|
|
|
|
|
2018-12-04 16:58:38 +00:00
|
|
|
#define DO_TEST_QUERY_JOBS(name) \
|
|
|
|
do { \
|
|
|
|
struct testQueryJobsData data = { name, driver.xmlopt}; \
|
|
|
|
if (virTestRun("query-jobs-" name, testQueryJobs, &data) < 0) \
|
|
|
|
ret = -1; \
|
|
|
|
} while (0)
|
|
|
|
|
|
|
|
DO_TEST_QUERY_JOBS("empty");
|
|
|
|
DO_TEST_QUERY_JOBS("create");
|
|
|
|
|
|
|
|
#undef DO_TEST_QUERY_JOBS
|
|
|
|
|
2021-11-30 10:49:24 +00:00
|
|
|
if (!(qapischema_s390x = testQEMUSchemaLoadLatest("s390x"))) {
|
2020-02-20 22:01:47 +00:00
|
|
|
VIR_TEST_VERBOSE("failed to load qapi schema for s390x");
|
|
|
|
ret = -1;
|
|
|
|
goto cleanup;
|
|
|
|
}
|
|
|
|
|
2021-11-30 10:49:24 +00:00
|
|
|
qapiData.schema = qapischema_s390x;
|
|
|
|
|
2020-02-20 22:01:47 +00:00
|
|
|
DO_TEST(qemuMonitorJSONGetCPUModelComparison);
|
2020-02-20 22:01:48 +00:00
|
|
|
DO_TEST(qemuMonitorJSONGetCPUModelBaseline);
|
2020-02-20 22:01:47 +00:00
|
|
|
|
2018-03-22 16:07:43 +00:00
|
|
|
cleanup:
|
|
|
|
qemuTestDriverFree(&driver);
|
2012-08-20 12:31:29 +00:00
|
|
|
return (ret == 0) ? EXIT_SUCCESS : EXIT_FAILURE;
|
|
|
|
}
|
|
|
|
|
2020-10-21 14:53:26 +00:00
|
|
|
VIR_TEST_MAIN(mymain)
|