Add qemuMonitorNBDServerStartUnix used to instruct QEMU to connect
to a UNIX socket as a NBD drive mirror destination.
Signed-off-by: Pavel Boldin <pboldin(a)mirantis.com>
---
src/qemu/qemu_monitor.c | 12 ++++++++++++
src/qemu/qemu_monitor.h | 2 ++
src/qemu/qemu_monitor_json.c | 35 +++++++++++++++++++++++++++++++++++
src/qemu/qemu_monitor_json.h | 2 ++
4 files changed, 51 insertions(+)
diff --git a/src/qemu/qemu_monitor.c b/src/qemu/qemu_monitor.c
index 49d4aa2..9c8e0fe 100644
--- a/src/qemu/qemu_monitor.c
+++ b/src/qemu/qemu_monitor.c
@@ -3594,6 +3594,18 @@ qemuMonitorNBDServerStart(qemuMonitorPtr mon,
int
+qemuMonitorNBDServerStartUnix(qemuMonitorPtr mon,
+ const char *file)
+{
+ VIR_DEBUG("file=%s", file);
+
+ QEMU_CHECK_MONITOR_JSON(mon);
+
+ return qemuMonitorJSONNBDServerStartUnix(mon, file);
+}
+
+
+int
qemuMonitorNBDServerAdd(qemuMonitorPtr mon,
const char *deviceID,
bool writable)
diff --git a/src/qemu/qemu_monitor.h b/src/qemu/qemu_monitor.h
index 2ce3958..e94ac93 100644
--- a/src/qemu/qemu_monitor.h
+++ b/src/qemu/qemu_monitor.h
@@ -873,6 +873,8 @@ char *qemuMonitorGetTargetArch(qemuMonitorPtr mon);
int qemuMonitorNBDServerStart(qemuMonitorPtr mon,
const char *host,
unsigned int port);
+int qemuMonitorNBDServerStartUnix(qemuMonitorPtr mon,
+ const char *path);
int qemuMonitorNBDServerAdd(qemuMonitorPtr mon,
const char *deviceID,
bool writable);
diff --git a/src/qemu/qemu_monitor_json.c b/src/qemu/qemu_monitor_json.c
index b39b29b..ef162a4 100644
--- a/src/qemu/qemu_monitor_json.c
+++ b/src/qemu/qemu_monitor_json.c
@@ -5749,6 +5749,41 @@ qemuMonitorJSONNBDServerStart(qemuMonitorPtr mon,
}
int
+qemuMonitorJSONNBDServerStartUnix(qemuMonitorPtr mon,
+ const char *file)
+{
+ int ret = -1;
+ virJSONValuePtr cmd = NULL;
+ virJSONValuePtr reply = NULL;
+ virJSONValuePtr addr = NULL;
+
+ if (!(addr = qemuMonitorJSONBuildUnixSocketAddress(file)))
+ return ret;
+
+ 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:
+ virJSONValueFree(reply);
+ virJSONValueFree(cmd);
+ virJSONValueFree(addr);
+ return ret;
+}
+
+int
qemuMonitorJSONNBDServerAdd(qemuMonitorPtr mon,
const char *deviceID,
bool writable)
diff --git a/src/qemu/qemu_monitor_json.h b/src/qemu/qemu_monitor_json.h
index 120bd93..28e17c0 100644
--- a/src/qemu/qemu_monitor_json.h
+++ b/src/qemu/qemu_monitor_json.h
@@ -441,6 +441,8 @@ char *qemuMonitorJSONGetTargetArch(qemuMonitorPtr mon);
int qemuMonitorJSONNBDServerStart(qemuMonitorPtr mon,
const char *host,
unsigned int port);
+int qemuMonitorJSONNBDServerStartUnix(qemuMonitorPtr mon,
+ const char *path);
int qemuMonitorJSONNBDServerAdd(qemuMonitorPtr mon,
const char *deviceID,
bool writable);
--
1.9.1