mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-03-07 17:28:15 +00:00
qemu: Introduce qemuMonitorSetMigrationCapabilities
Our current monitor API forces the caller to call migrate-set-capabilities QMP command for each capability separately, which is quite suboptimal. Let's add a new API for setting all capabilities at once. Signed-off-by: Jiri Denemark <jdenemar@redhat.com> Reviewed-by: Ján Tomko <jtomko@redhat.com>
This commit is contained in:
parent
7b559ad373
commit
23f173d1e1
@ -3960,6 +3960,25 @@ qemuMonitorSetMigrationCapability(qemuMonitorPtr mon,
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
qemuMonitorSetMigrationCapabilities(qemuMonitorPtr mon,
|
||||
virBitmapPtr caps,
|
||||
virBitmapPtr states)
|
||||
{
|
||||
char *capsStr = virBitmapFormat(caps);
|
||||
char *statesStr = virBitmapFormat(states);
|
||||
|
||||
VIR_DEBUG("caps=%s, states=%s", NULLSTR(capsStr), NULLSTR(statesStr));
|
||||
|
||||
VIR_FREE(capsStr);
|
||||
VIR_FREE(statesStr);
|
||||
|
||||
QEMU_CHECK_MONITOR_JSON(mon);
|
||||
|
||||
return qemuMonitorJSONSetMigrationCapabilities(mon, caps, states);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* qemuMonitorGetGICCapabilities:
|
||||
* @mon: QEMU monitor
|
||||
|
@ -763,6 +763,9 @@ int qemuMonitorGetMigrationCapabilities(qemuMonitorPtr mon,
|
||||
int qemuMonitorSetMigrationCapability(qemuMonitorPtr mon,
|
||||
qemuMonitorMigrationCaps capability,
|
||||
bool state);
|
||||
int qemuMonitorSetMigrationCapabilities(qemuMonitorPtr mon,
|
||||
virBitmapPtr caps,
|
||||
virBitmapPtr states);
|
||||
|
||||
int qemuMonitorGetGICCapabilities(qemuMonitorPtr mon,
|
||||
virGICCapability **capabilities);
|
||||
|
@ -6251,6 +6251,69 @@ qemuMonitorJSONSetMigrationCapability(qemuMonitorPtr mon,
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
qemuMonitorJSONSetMigrationCapabilities(qemuMonitorPtr mon,
|
||||
virBitmapPtr caps,
|
||||
virBitmapPtr states)
|
||||
{
|
||||
int ret = -1;
|
||||
qemuMonitorMigrationCaps bit;
|
||||
virJSONValuePtr cmd = NULL;
|
||||
virJSONValuePtr reply = NULL;
|
||||
virJSONValuePtr cap = NULL;
|
||||
virJSONValuePtr array;
|
||||
|
||||
if (!(array = virJSONValueNewArray()))
|
||||
goto cleanup;
|
||||
|
||||
for (bit = 0; bit < QEMU_MONITOR_MIGRATION_CAPS_LAST; bit++) {
|
||||
bool supported = false;
|
||||
bool state = false;
|
||||
|
||||
ignore_value(virBitmapGetBit(caps, bit, &supported));
|
||||
if (!supported)
|
||||
continue;
|
||||
|
||||
ignore_value(virBitmapGetBit(states, bit, &state));
|
||||
|
||||
if (!(cap = virJSONValueNewObject()))
|
||||
goto cleanup;
|
||||
|
||||
if (virJSONValueObjectAppendString(cap, "capability",
|
||||
qemuMonitorMigrationCapsTypeToString(bit)) < 0)
|
||||
goto cleanup;
|
||||
|
||||
if (virJSONValueObjectAppendBoolean(cap, "state", state) < 0)
|
||||
goto cleanup;
|
||||
|
||||
if (virJSONValueArrayAppend(array, cap) < 0)
|
||||
goto cleanup;
|
||||
|
||||
cap = NULL;
|
||||
}
|
||||
|
||||
cmd = qemuMonitorJSONMakeCommand("migrate-set-capabilities",
|
||||
"a:capabilities", &array,
|
||||
NULL);
|
||||
if (!cmd)
|
||||
goto cleanup;
|
||||
|
||||
if (qemuMonitorJSONCommand(mon, cmd, &reply) < 0)
|
||||
goto cleanup;
|
||||
|
||||
if (qemuMonitorJSONCheckError(cmd, reply) < 0)
|
||||
goto cleanup;
|
||||
|
||||
ret = 0;
|
||||
cleanup:
|
||||
virJSONValueFree(array);
|
||||
virJSONValueFree(cap);
|
||||
virJSONValueFree(cmd);
|
||||
virJSONValueFree(reply);
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* qemuMonitorJSONGetGICCapabilities:
|
||||
* @mon: QEMU JSON monitor
|
||||
|
@ -148,6 +148,9 @@ int qemuMonitorJSONGetMigrationCapabilities(qemuMonitorPtr mon,
|
||||
int qemuMonitorJSONSetMigrationCapability(qemuMonitorPtr mon,
|
||||
qemuMonitorMigrationCaps capability,
|
||||
bool state);
|
||||
int qemuMonitorJSONSetMigrationCapabilities(qemuMonitorPtr mon,
|
||||
virBitmapPtr caps,
|
||||
virBitmapPtr states);
|
||||
|
||||
int qemuMonitorJSONGetGICCapabilities(qemuMonitorPtr mon,
|
||||
virGICCapability **capabilities);
|
||||
|
Loading…
x
Reference in New Issue
Block a user