[PATCH v2 0/6] qemu_monitor_json: Assume existence of some commands

Technically a v2 of: https://listman.redhat.com/archives/libvir-list/2021-October/msg00825.html but I've cancelled sending in the middle of v1. Anyway, patch 1/6 is new (yeah, I've noticed a test failing so I've cancelled sending v1). Michal Prívozník (6): qemumigparamstest: Drop "unsupported" test case qemuMonitorJSONGetMigrationParams: Don't return early on CommandNotFound qemuMonitorJSONGetDumpGuestMemoryCapability: Don't return early on CommandNotFound qemuMonitorJSONGetKVMState: Don't return early on CommandNotFound qemuMonitorJSONGetMemoryDeviceInfo: Don't return early on CommandNotFound qemuMonitorJSONGetMigrationCapabilities: Don't return early on CommandNotFound src/qemu/qemu_monitor_json.c | 23 ----------------------- tests/qemumigparamsdata/unsupported.json | 3 --- tests/qemumigparamsdata/unsupported.reply | 7 ------- tests/qemumigparamsdata/unsupported.xml | 4 ---- tests/qemumigparamstest.c | 1 - 5 files changed, 38 deletions(-) delete mode 100644 tests/qemumigparamsdata/unsupported.json delete mode 100644 tests/qemumigparamsdata/unsupported.reply delete mode 100644 tests/qemumigparamsdata/unsupported.xml -- 2.32.0

The aim of "unsupported" test case is to check whether our code handles 'CommandNotFound' error returned for 'query-migrate-parameters' monitor command. Well, the command is pretty old and every QEMU that we are dealing with supports it. Thus this test case is useless. Drop it. Signed-off-by: Michal Privoznik <mprivozn@redhat.com> --- tests/qemumigparamsdata/unsupported.json | 3 --- tests/qemumigparamsdata/unsupported.reply | 7 ------- tests/qemumigparamsdata/unsupported.xml | 4 ---- tests/qemumigparamstest.c | 1 - 4 files changed, 15 deletions(-) delete mode 100644 tests/qemumigparamsdata/unsupported.json delete mode 100644 tests/qemumigparamsdata/unsupported.reply delete mode 100644 tests/qemumigparamsdata/unsupported.xml diff --git a/tests/qemumigparamsdata/unsupported.json b/tests/qemumigparamsdata/unsupported.json deleted file mode 100644 index 0db3279e44..0000000000 --- a/tests/qemumigparamsdata/unsupported.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - -} diff --git a/tests/qemumigparamsdata/unsupported.reply b/tests/qemumigparamsdata/unsupported.reply deleted file mode 100644 index 2b88ba10c3..0000000000 --- a/tests/qemumigparamsdata/unsupported.reply +++ /dev/null @@ -1,7 +0,0 @@ -{ - "id": "libvirt-1", - "error": { - "class": "CommandNotFound", - "desc": "The command query-migrate-parameters has not been found" - } -} diff --git a/tests/qemumigparamsdata/unsupported.xml b/tests/qemumigparamsdata/unsupported.xml deleted file mode 100644 index 8aa3abefc0..0000000000 --- a/tests/qemumigparamsdata/unsupported.xml +++ /dev/null @@ -1,4 +0,0 @@ -<test> - <migParams> - </migParams> -</test> diff --git a/tests/qemumigparamstest.c b/tests/qemumigparamstest.c index f445c92ff8..4ab40d9d2e 100644 --- a/tests/qemumigparamstest.c +++ b/tests/qemumigparamstest.c @@ -219,7 +219,6 @@ mymain(void) ret = -1; \ } while (0) - DO_TEST("unsupported"); DO_TEST("empty"); DO_TEST("basic"); DO_TEST("tls"); -- 2.32.0

The qemuMonitorJSONGetMigrationParams() function executes 'query-migrate-parameters' command and returns early if QEMU doesn't know the command. Well, the command was introduced in QEMU release 2.4 (specifically in commit v2.4.0-rc0~147^2~3) and since the minimum required version is 2.11.0 we can be sure that the command will always exist. Signed-off-by: Michal Privoznik <mprivozn@redhat.com> --- src/qemu/qemu_monitor_json.c | 5 ----- 1 file changed, 5 deletions(-) diff --git a/src/qemu/qemu_monitor_json.c b/src/qemu/qemu_monitor_json.c index 7bf3a9981b..08cd535045 100644 --- a/src/qemu/qemu_monitor_json.c +++ b/src/qemu/qemu_monitor_json.c @@ -3281,11 +3281,6 @@ qemuMonitorJSONGetMigrationParams(qemuMonitor *mon, if (qemuMonitorJSONCommand(mon, cmd, &reply) < 0) goto cleanup; - if (qemuMonitorJSONHasError(reply, "CommandNotFound")) { - ret = 0; - goto cleanup; - } - if (qemuMonitorJSONCheckReply(cmd, reply, VIR_JSON_TYPE_OBJECT) < 0) goto cleanup; -- 2.32.0

The qemuMonitorJSONGetDumpGuestMemoryCapability() command executes 'query-dump-guest-memory-capability' command and returns early if QEMU doesn't know the command. Well, the command was introduced in QEMU release 2.0 (specifically in commit v2.0.0-rc0~43^2~16) and since the minimum required version is 2.11.0 we can be sure that command will always exist. Signed-off-by: Michal Privoznik <mprivozn@redhat.com> --- src/qemu/qemu_monitor_json.c | 5 ----- 1 file changed, 5 deletions(-) diff --git a/src/qemu/qemu_monitor_json.c b/src/qemu/qemu_monitor_json.c index 08cd535045..df3e14a153 100644 --- a/src/qemu/qemu_monitor_json.c +++ b/src/qemu/qemu_monitor_json.c @@ -3666,11 +3666,6 @@ qemuMonitorJSONGetDumpGuestMemoryCapability(qemuMonitor *mon, if (qemuMonitorJSONCommand(mon, cmd, &reply) < 0) goto cleanup; - if (qemuMonitorJSONHasError(reply, "CommandNotFound")) { - ret = 0; - goto cleanup; - } - if (qemuMonitorJSONCheckReply(cmd, reply, VIR_JSON_TYPE_OBJECT) < 0) goto cleanup; -- 2.32.0

The qemuMonitorJSONGetKVMState() command executes 'query-kvm' command and returns early if QEMU doesn't know the command. Well, the command was introduced in QEMU release 0.14 and since the minimum required version is 2.11.0 we can be sure that command will always exist. Signed-off-by: Michal Privoznik <mprivozn@redhat.com> --- src/qemu/qemu_monitor_json.c | 5 ----- 1 file changed, 5 deletions(-) diff --git a/src/qemu/qemu_monitor_json.c b/src/qemu/qemu_monitor_json.c index df3e14a153..70e3c70441 100644 --- a/src/qemu/qemu_monitor_json.c +++ b/src/qemu/qemu_monitor_json.c @@ -6020,11 +6020,6 @@ int qemuMonitorJSONGetKVMState(qemuMonitor *mon, if (qemuMonitorJSONCommand(mon, cmd, &reply) < 0) goto cleanup; - if (qemuMonitorJSONHasError(reply, "CommandNotFound")) { - ret = 0; - goto cleanup; - } - if (qemuMonitorJSONCheckReply(cmd, reply, VIR_JSON_TYPE_OBJECT) < 0) goto cleanup; -- 2.32.0

The qemuMonitorJSONGetMemoryDeviceInfo() command executes 'query-memory-devices' command and returns early if QEMU doesn't know the command. Well, the command was introduced in QEMU release 2.1 (specifically in commit v2.1.0-rc0~41^2~9) and since the minimum required version is 2.11.0 we can be sure that command will always exist. Signed-off-by: Michal Privoznik <mprivozn@redhat.com> --- src/qemu/qemu_monitor_json.c | 5 ----- 1 file changed, 5 deletions(-) diff --git a/src/qemu/qemu_monitor_json.c b/src/qemu/qemu_monitor_json.c index 70e3c70441..586b30763b 100644 --- a/src/qemu/qemu_monitor_json.c +++ b/src/qemu/qemu_monitor_json.c @@ -7788,11 +7788,6 @@ qemuMonitorJSONGetMemoryDeviceInfo(qemuMonitor *mon, if (qemuMonitorJSONCommand(mon, cmd, &reply) < 0) goto cleanup; - if (qemuMonitorJSONHasError(reply, "CommandNotFound")) { - ret = -2; - goto cleanup; - } - if (qemuMonitorJSONCheckReply(cmd, reply, VIR_JSON_TYPE_ARRAY) < 0) goto cleanup; -- 2.32.0

The qemuMonitorJSONGetMigrationCapabilities() command executes 'query-migrate-capabilities' command and returns early if QEMU doesn't know the command. Well, the command was introduced in QEMU release 1.2 (specifically in commit v1.2.0-rc0~29^2~11) and since the minimum required version is 2.11.0 we can be sure that command will always exist. Signed-off-by: Michal Privoznik <mprivozn@redhat.com> --- src/qemu/qemu_monitor_json.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/qemu/qemu_monitor_json.c b/src/qemu/qemu_monitor_json.c index 586b30763b..a7a980fccd 100644 --- a/src/qemu/qemu_monitor_json.c +++ b/src/qemu/qemu_monitor_json.c @@ -6518,9 +6518,6 @@ qemuMonitorJSONGetMigrationCapabilities(qemuMonitor *mon, if (qemuMonitorJSONCommand(mon, cmd, &reply) < 0) return -1; - if (qemuMonitorJSONHasError(reply, "CommandNotFound")) - return 0; - if (qemuMonitorJSONCheckReply(cmd, reply, VIR_JSON_TYPE_ARRAY) < 0) return -1; -- 2.32.0

On a Thursday in 2021, Michal Privoznik wrote:
Technically a v2 of:
https://listman.redhat.com/archives/libvir-list/2021-October/msg00825.html
but I've cancelled sending in the middle of v1. Anyway, patch 1/6 is new (yeah, I've noticed a test failing so I've cancelled sending v1).
Michal Prívozník (6): qemumigparamstest: Drop "unsupported" test case qemuMonitorJSONGetMigrationParams: Don't return early on CommandNotFound
qemuMonitorGetMigrationParams' comment can now lose the comment about QEMU support
qemuMonitorJSONGetDumpGuestMemoryCapability: Don't return early on CommandNotFound qemuMonitorJSONGetKVMState: Don't return early on CommandNotFound qemuMonitorJSONGetMemoryDeviceInfo: Don't return early on CommandNotFound
qemuDomainUpdateMemoryDeviceInfo no longer needs to consider -2 and the comment about -2 in qemuMonitorGetMemoryDeviceInfo's description can be dropped
qemuMonitorJSONGetMigrationCapabilities: Don't return early on CommandNotFound
src/qemu/qemu_monitor_json.c | 23 ----------------------- tests/qemumigparamsdata/unsupported.json | 3 --- tests/qemumigparamsdata/unsupported.reply | 7 ------- tests/qemumigparamsdata/unsupported.xml | 4 ---- tests/qemumigparamstest.c | 1 - 5 files changed, 38 deletions(-) delete mode 100644 tests/qemumigparamsdata/unsupported.json delete mode 100644 tests/qemumigparamsdata/unsupported.reply delete mode 100644 tests/qemumigparamsdata/unsupported.xml
Regardless of whether you squash in the above suggestions, resend them separately or leave it up to future me: Reviewed-by: Ján Tomko <jtomko@redhat.com> Jano
participants (2)
-
Ján Tomko
-
Michal Privoznik