Right now, we only use NBD exports during storage migration,
where we control the NBD client and therefore don't care about
the export name (qemu's default of naming the export after the
device is fine). But upcoming patches for exposing backups over
NBD wants to use a different export name (matching the libvirt
domain XML rather than the qemu device name); so enhance the
QMP glue code to allow this flexibility.
Signed-off-by: Eric Blake <eblake(a)redhat.com>
---
src/qemu/qemu_monitor.h | 1 +
src/qemu/qemu_monitor_json.h | 1 +
src/qemu/qemu_migration.c | 2 +-
src/qemu/qemu_monitor.c | 5 +++--
src/qemu/qemu_monitor_json.c | 2 ++
tests/qemumonitorjsontest.c | 2 +-
6 files changed, 9 insertions(+), 4 deletions(-)
diff --git a/src/qemu/qemu_monitor.h b/src/qemu/qemu_monitor.h
index fd7dcc9196..55acd60380 100644
--- a/src/qemu/qemu_monitor.h
+++ b/src/qemu/qemu_monitor.h
@@ -1099,6 +1099,7 @@ int qemuMonitorNBDServerStart(qemuMonitorPtr mon,
const char *tls_alias);
int qemuMonitorNBDServerAdd(qemuMonitorPtr mon,
const char *deviceID,
+ const char *export,
bool writable);
int qemuMonitorNBDServerStop(qemuMonitorPtr);
int qemuMonitorGetTPMModels(qemuMonitorPtr mon,
diff --git a/src/qemu/qemu_monitor_json.h b/src/qemu/qemu_monitor_json.h
index 62772228fe..b105964ed6 100644
--- a/src/qemu/qemu_monitor_json.h
+++ b/src/qemu/qemu_monitor_json.h
@@ -465,6 +465,7 @@ int qemuMonitorJSONNBDServerStart(qemuMonitorPtr mon,
const char *tls_alias);
int qemuMonitorJSONNBDServerAdd(qemuMonitorPtr mon,
const char *deviceID,
+ const char *export,
bool writable);
int qemuMonitorJSONNBDServerStop(qemuMonitorPtr mon);
int qemuMonitorJSONGetTPMModels(qemuMonitorPtr mon,
diff --git a/src/qemu/qemu_migration.c b/src/qemu/qemu_migration.c
index 1433b2c2f3..39a228d977 100644
--- a/src/qemu/qemu_migration.c
+++ b/src/qemu/qemu_migration.c
@@ -417,7 +417,7 @@ qemuMigrationDstStartNBDServer(virQEMUDriverPtr driver,
goto exit_monitor;
}
- if (qemuMonitorNBDServerAdd(priv->mon, diskAlias, true) < 0)
+ if (qemuMonitorNBDServerAdd(priv->mon, diskAlias, NULL, true) < 0)
goto exit_monitor;
if (qemuDomainObjExitMonitor(driver, vm) < 0)
goto cleanup;
diff --git a/src/qemu/qemu_monitor.c b/src/qemu/qemu_monitor.c
index 8bd4d4d761..296563ce1c 100644
--- a/src/qemu/qemu_monitor.c
+++ b/src/qemu/qemu_monitor.c
@@ -3945,13 +3945,14 @@ qemuMonitorNBDServerStart(qemuMonitorPtr mon,
int
qemuMonitorNBDServerAdd(qemuMonitorPtr mon,
const char *deviceID,
+ const char *export,
bool writable)
{
- VIR_DEBUG("deviceID=%s", deviceID);
+ VIR_DEBUG("deviceID=%s, export=%s", deviceID, NULLSTR(export));
QEMU_CHECK_MONITOR(mon);
- return qemuMonitorJSONNBDServerAdd(mon, deviceID, writable);
+ return qemuMonitorJSONNBDServerAdd(mon, deviceID, export, writable);
}
diff --git a/src/qemu/qemu_monitor_json.c b/src/qemu/qemu_monitor_json.c
index 8bafa93c8d..37626b64ea 100644
--- a/src/qemu/qemu_monitor_json.c
+++ b/src/qemu/qemu_monitor_json.c
@@ -6767,6 +6767,7 @@ qemuMonitorJSONNBDServerStart(qemuMonitorPtr mon,
int
qemuMonitorJSONNBDServerAdd(qemuMonitorPtr mon,
const char *deviceID,
+ const char *export,
bool writable)
{
int ret = -1;
@@ -6775,6 +6776,7 @@ qemuMonitorJSONNBDServerAdd(qemuMonitorPtr mon,
if (!(cmd = qemuMonitorJSONMakeCommand("nbd-server-add",
"s:device", deviceID,
+ "S:name", export,
"b:writable", writable,
NULL)))
return ret;
diff --git a/tests/qemumonitorjsontest.c b/tests/qemumonitorjsontest.c
index 1a8a31717f..1bdef11d15 100644
--- a/tests/qemumonitorjsontest.c
+++ b/tests/qemumonitorjsontest.c
@@ -1354,7 +1354,7 @@ GEN_TEST_FUNC(qemuMonitorJSONDrivePivot, "vdb")
GEN_TEST_FUNC(qemuMonitorJSONScreendump, "devicename", 1,
"/foo/bar")
GEN_TEST_FUNC(qemuMonitorJSONOpenGraphics, "spice", "spicefd",
false)
GEN_TEST_FUNC(qemuMonitorJSONNBDServerStart, "localhost", 12345,
"test-alias")
-GEN_TEST_FUNC(qemuMonitorJSONNBDServerAdd, "vda", true)
+GEN_TEST_FUNC(qemuMonitorJSONNBDServerAdd, "vda", NULL, true)
GEN_TEST_FUNC(qemuMonitorJSONDetachCharDev, "serial1")
GEN_TEST_FUNC(qemuMonitorJSONBlockdevTrayOpen, "foodev", true)
GEN_TEST_FUNC(qemuMonitorJSONBlockdevTrayClose, "foodev")
--
2.20.1