[PATCH 6/6] qemuBlockExportAddNBD: Use 'block-export-add' when available

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Switch to the new QMP command once it becomes available. Since the code
was refactored to have just one central location to do this we can
contain the ugly bits to just this one function.

Since we now use the replacement for 'nbd-server-add' mark the test case
as being OK with removal of the command.

Signed-off-by: Peter Krempa <pkrempa@xxxxxxxxxx>
---
 src/qemu/qemu_block.c       | 20 ++++++++++++++++----
 tests/qemumonitorjsontest.c |  2 +-
 2 files changed, 17 insertions(+), 5 deletions(-)

diff --git a/src/qemu/qemu_block.c b/src/qemu/qemu_block.c
index 85a0320520..f1cd12a950 100644
--- a/src/qemu/qemu_block.c
+++ b/src/qemu/qemu_block.c
@@ -3414,15 +3414,27 @@ qemuBlockExportAddNBD(virDomainObjPtr vm,
                       const char *bitmap)
 {
     qemuDomainObjPrivatePtr priv = vm->privateData;
-    const char *exportsrc = drivealias;

     if (virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_BLOCKDEV)) {
-        exportsrc = src->nodeformat;
+        if (virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_BLOCK_EXPORT_ADD)) {
+            g_autoptr(virJSONValue) nbdprops = NULL;
+
+            if (!(nbdprops = qemuBlockExportGetNBDProps(src->nodeformat,
+                                                        exportname,
+                                                        writable,
+                                                        bitmap)))
+                return -1;
+
+            return qemuMonitorBlockExportAdd(priv->mon, &nbdprops);
+        } else {
+            return qemuMonitorNBDServerAdd(priv->mon, src->nodeformat,
+                                           exportname, writable, bitmap);
+        }
     } else {
         /* older qemu versions didn't support configuring the exportname and
          * took the 'drivealias' as the export name */
-        exportname = NULL;
+        return qemuMonitorNBDServerAdd(priv->mon, drivealias, NULL, writable, NULL);
     }

-    return qemuMonitorNBDServerAdd(priv->mon, exportsrc, exportname, writable, bitmap);
+    return 0;
 }
diff --git a/tests/qemumonitorjsontest.c b/tests/qemumonitorjsontest.c
index d65af6fadc..0611fdfd34 100644
--- a/tests/qemumonitorjsontest.c
+++ b/tests/qemumonitorjsontest.c
@@ -3299,7 +3299,7 @@ mymain(void)
     DO_TEST_GEN(qemuMonitorJSONDrivePivot);
     DO_TEST_GEN(qemuMonitorJSONScreendump);
     DO_TEST_GEN(qemuMonitorJSONOpenGraphics);
-    DO_TEST_GEN_DEPRECATED(qemuMonitorJSONNBDServerAdd, false);
+    DO_TEST_GEN_DEPRECATED(qemuMonitorJSONNBDServerAdd, true);
     DO_TEST_GEN(qemuMonitorJSONDetachCharDev);
     DO_TEST_GEN(qemuMonitorJSONBlockdevTrayOpen);
     DO_TEST_GEN(qemuMonitorJSONBlockdevTrayClose);
-- 
2.26.2




[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]

  Powered by Linux