Modern code uses QMP schema to query for active commit support.
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Neal Gompa <ngompa13@gmail.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
}
-/* Probe whether active commits are supported by a given qemu binary. */
-bool
-qemuMonitorSupportsActiveCommit(qemuMonitor *mon)
-{
- if (!mon)
- return false;
-
- return qemuMonitorJSONSupportsActiveCommit(mon);
-}
-
-
/* Determine the name that qemu is using for tracking the backing
* element TARGET within the chain starting at TOP. */
char *
const char *backingName,
unsigned long long bandwidth)
ATTRIBUTE_NONNULL(2);
-bool qemuMonitorSupportsActiveCommit(qemuMonitor *mon);
char *qemuMonitorDiskNameLookup(qemuMonitor *mon,
const char *device,
virStorageSource *top,
return ret;
}
-/* Probe if active commit is supported: pass in a bogus device and NULL top
- * and base. The probe return is true if active commit is detected or false
- * if not supported or on any error */
-bool
-qemuMonitorJSONSupportsActiveCommit(qemuMonitor *mon)
-{
- bool ret = false;
- virJSONValue *cmd;
- virJSONValue *reply = NULL;
-
- if (!(cmd = qemuMonitorJSONMakeCommand("block-commit", "s:device",
- "bogus", NULL)))
- return false;
-
- if (qemuMonitorJSONCommand(mon, cmd, &reply) < 0)
- goto cleanup;
-
- if (qemuMonitorJSONHasError(reply, "DeviceNotFound")) {
- VIR_DEBUG("block-commit supports active commit");
- ret = true;
- goto cleanup;
- }
-
- /* This is a false negative for qemu 2.0; but probably not
- * worth the additional complexity to worry about it */
- VIR_DEBUG("block-commit requires 'top' parameter, "
- "assuming it lacks active commit");
- cleanup:
- virJSONValueFree(cmd);
- virJSONValueFree(reply);
- return ret;
-}
-
/* speed is in bytes/sec. Returns 0 on success, -1 with error message
* emitted on failure. */
const char *jobname)
ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2);
-bool qemuMonitorJSONSupportsActiveCommit(qemuMonitor *mon)
- ATTRIBUTE_NONNULL(1);
-
int qemuMonitorJSONBlockCommit(qemuMonitor *mon,
const char *device,
const char *jobname,
return 0;
}
-static int
-testQemuMonitorJSONqemuMonitorSupportsActiveCommit(const void *opaque)
-{
- const testGenericData *data = opaque;
- virDomainXMLOption *xmlopt = data->xmlopt;
- const char *error1 =
- "{"
- " \"error\": {"
- " \"class\": \"DeviceNotFound\","
- " \"desc\": \"Device 'bogus' not found\""
- " }"
- "}";
- const char *error2 =
- "{"
- " \"error\": {"
- " \"class\": \"GenericError\","
- " \"desc\": \"Parameter 'top' is missing\""
- " }"
- "}";
- g_autoptr(qemuMonitorTest) test = NULL;
-
- if (!(test = qemuMonitorTestNewSchema(xmlopt, data->schema)))
- return -1;
-
- if (qemuMonitorTestAddItemParams(test, "block-commit", error1,
- "device", "\"bogus\"",
- NULL, NULL) < 0)
- return -1;
-
- if (!qemuMonitorSupportsActiveCommit(qemuMonitorTestGetMonitor(test)))
- return -1;
-
- if (qemuMonitorTestAddItemParams(test, "block-commit", error2,
- "device", "\"bogus\"",
- NULL, NULL) < 0)
- return -1;
-
- if (qemuMonitorSupportsActiveCommit(qemuMonitorTestGetMonitor(test)))
- return -1;
-
- return 0;
-}
-
static int
testQemuMonitorJSONqemuMonitorJSONGetDumpGuestMemoryCapability(const void *opaque)
{
DO_TEST(qemuMonitorJSONSendKey);
DO_TEST(qemuMonitorJSONGetDumpGuestMemoryCapability);
DO_TEST(qemuMonitorJSONSendKeyHoldtime);
- DO_TEST(qemuMonitorSupportsActiveCommit);
DO_TEST(qemuMonitorJSONNBDServerStart);
DO_TEST_CPU_DATA("host");