[PATCH v2 05/11] qemu: Introduce nbd-server-stop command

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

 



This will be used after all migration work is done
to stop NBD server running on destination.  It
doesn't take any arguments, just issues a command.
---
 src/qemu/qemu_monitor.c      |   19 +++++++++++++++++++
 src/qemu/qemu_monitor.h      |    1 +
 src/qemu/qemu_monitor_json.c |   21 +++++++++++++++++++++
 src/qemu/qemu_monitor_json.h |    1 +
 4 files changed, 42 insertions(+), 0 deletions(-)

diff --git a/src/qemu/qemu_monitor.c b/src/qemu/qemu_monitor.c
index 525cc0e..c7a07c2 100644
--- a/src/qemu/qemu_monitor.c
+++ b/src/qemu/qemu_monitor.c
@@ -3364,3 +3364,22 @@ int qemuMonitorNBDServerAdd(qemuMonitorPtr mon,
 
     return qemuMonitorJSONNBDServerAdd(mon, deviceID, writable);
 }
+
+int qemuMonitorNBDServerStop(qemuMonitorPtr mon)
+{
+    VIR_DEBUG("mon=%p", mon);
+
+    if (!mon) {
+        virReportError(VIR_ERR_INVALID_ARG, "%s",
+                       _("monitor must not be NULL"));
+        return -1;
+    }
+
+    if (!mon->json) {
+        virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
+                       _("JSON monitor is required"));
+        return -1;
+    }
+
+    return qemuMonitorJSONNBDServerStop(mon);
+}
diff --git a/src/qemu/qemu_monitor.h b/src/qemu/qemu_monitor.h
index 33c772f..a18691d 100644
--- a/src/qemu/qemu_monitor.h
+++ b/src/qemu/qemu_monitor.h
@@ -637,6 +637,7 @@ int qemuMonitorNBDServerStart(qemuMonitorPtr mon,
 int qemuMonitorNBDServerAdd(qemuMonitorPtr mon,
                             const char *deviceID,
                             bool writable);
+int qemuMonitorNBDServerStop(qemuMonitorPtr);
 /**
  * When running two dd process and using <> redirection, we need a
  * shell that will not truncate files.  These two strings serve that
diff --git a/src/qemu/qemu_monitor_json.c b/src/qemu/qemu_monitor_json.c
index 1f2951f..d9504ca 100644
--- a/src/qemu/qemu_monitor_json.c
+++ b/src/qemu/qemu_monitor_json.c
@@ -4347,3 +4347,24 @@ qemuMonitorJSONNBDServerAdd(qemuMonitorPtr mon,
     virJSONValueFree(reply);
     return ret;
 }
+
+int
+qemuMonitorJSONNBDServerStop(qemuMonitorPtr mon)
+{
+    int ret = -1;
+    virJSONValuePtr cmd;
+    virJSONValuePtr reply = NULL;
+
+    if (!(cmd = qemuMonitorJSONMakeCommand("nbd-server-stop",
+                                           NULL)))
+        return ret;
+
+    ret = qemuMonitorJSONCommand(mon, cmd, &reply);
+
+    if (ret == 0)
+        ret = qemuMonitorJSONCheckError(cmd, reply);
+
+    virJSONValueFree(cmd);
+    virJSONValueFree(reply);
+    return ret;
+}
diff --git a/src/qemu/qemu_monitor_json.h b/src/qemu/qemu_monitor_json.h
index 14bd59f..7193998 100644
--- a/src/qemu/qemu_monitor_json.h
+++ b/src/qemu/qemu_monitor_json.h
@@ -330,4 +330,5 @@ int qemuMonitorJSONNBDServerStart(qemuMonitorPtr mon,
 int qemuMonitorJSONNBDServerAdd(qemuMonitorPtr mon,
                                 const char *deviceID,
                                 bool writable);
+int qemuMonitorJSONNBDServerStop(qemuMonitorPtr mon);
 #endif /* QEMU_MONITOR_JSON_H */
-- 
1.7.8.6

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list


[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]