mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-02-22 11:22:23 +00:00
qemu: Introduce nbd-server-start command
This will be used with new migration scheme. This patch creates basically just monitor stub functions. Wiring them into something useful is done in later patches.
This commit is contained in:
parent
121d4cfb9a
commit
bb6359e8d4
@ -3463,3 +3463,25 @@ int qemuMonitorSetMigrationCapability(qemuMonitorPtr mon,
|
||||
|
||||
return qemuMonitorJSONSetMigrationCapability(mon, capability);
|
||||
}
|
||||
|
||||
int qemuMonitorNBDServerStart(qemuMonitorPtr mon,
|
||||
const char *host,
|
||||
unsigned int port)
|
||||
{
|
||||
VIR_DEBUG("mon=%p host=%s port=%u",
|
||||
mon, host, port);
|
||||
|
||||
if (!mon) {
|
||||
virReportError(VIR_ERR_INVALID_ARG, "%s",
|
||||
_("monitor must not be NULL"));
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (!mon->json) {
|
||||
virReportError(VIR_ERR_OPERATION_UNSUPPORTED, "%s",
|
||||
_("JSON monitor is required"));
|
||||
return -1;
|
||||
}
|
||||
|
||||
return qemuMonitorJSONNBDServerStart(mon, host, port);
|
||||
}
|
||||
|
@ -676,6 +676,9 @@ int qemuMonitorGetObjectProps(qemuMonitorPtr mon,
|
||||
char ***props);
|
||||
char *qemuMonitorGetTargetArch(qemuMonitorPtr mon);
|
||||
|
||||
int qemuMonitorNBDServerStart(qemuMonitorPtr mon,
|
||||
const char *host,
|
||||
unsigned int port);
|
||||
/**
|
||||
* When running two dd process and using <> redirection, we need a
|
||||
* shell that will not truncate files. These two strings serve that
|
||||
|
@ -4607,3 +4607,59 @@ no_memory:
|
||||
virReportOOMError();
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
int
|
||||
qemuMonitorJSONNBDServerStart(qemuMonitorPtr mon,
|
||||
const char *host,
|
||||
unsigned int port)
|
||||
{
|
||||
int ret = -1;
|
||||
virJSONValuePtr cmd = NULL;
|
||||
virJSONValuePtr reply = NULL;
|
||||
virJSONValuePtr data = NULL;
|
||||
virJSONValuePtr addr = NULL;
|
||||
char *port_str = NULL;
|
||||
|
||||
if (!(data = virJSONValueNewObject()) ||
|
||||
!(addr = virJSONValueNewObject()) ||
|
||||
(virAsprintf(&port_str, "%u", port) < 0)) {
|
||||
virReportOOMError();
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
/* port is really expected as a string here by qemu */
|
||||
if (virJSONValueObjectAppendString(data, "host", host) < 0 ||
|
||||
virJSONValueObjectAppendString(data, "port", port_str) < 0 ||
|
||||
virJSONValueObjectAppendString(addr, "type", "inet") < 0 ||
|
||||
virJSONValueObjectAppend(addr, "data", data) < 0) {
|
||||
virReportOOMError();
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
/* From now on, @data is part of @addr */
|
||||
data = NULL;
|
||||
|
||||
if (!(cmd = qemuMonitorJSONMakeCommand("nbd-server-start",
|
||||
"a:addr", addr,
|
||||
NULL)))
|
||||
goto cleanup;
|
||||
|
||||
/* From now on, @addr is part of @cmd */
|
||||
addr = NULL;
|
||||
|
||||
if (qemuMonitorJSONCommand(mon, cmd, &reply) < 0)
|
||||
goto cleanup;
|
||||
|
||||
if (qemuMonitorJSONCheckError(cmd, reply) < 0)
|
||||
goto cleanup;
|
||||
|
||||
ret = 0;
|
||||
|
||||
cleanup:
|
||||
VIR_FREE(port_str);
|
||||
virJSONValueFree(reply);
|
||||
virJSONValueFree(cmd);
|
||||
virJSONValueFree(addr);
|
||||
virJSONValueFree(data);
|
||||
return ret;
|
||||
}
|
||||
|
@ -334,4 +334,7 @@ int qemuMonitorJSONGetObjectProps(qemuMonitorPtr mon,
|
||||
ATTRIBUTE_NONNULL(2) ATTRIBUTE_NONNULL(3);
|
||||
char *qemuMonitorJSONGetTargetArch(qemuMonitorPtr mon);
|
||||
|
||||
int qemuMonitorJSONNBDServerStart(qemuMonitorPtr mon,
|
||||
const char *host,
|
||||
unsigned int port);
|
||||
#endif /* QEMU_MONITOR_JSON_H */
|
||||
|
Loading…
x
Reference in New Issue
Block a user