[PATCH v3 5/9] qemu_monitor: Introduce qemuMonitorDetachCharDev

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

 



This function wraps 'chardev-remove' qemu monitor command around.
It takes chardev alias as its single argument besides qemu monitor
pointer.
---
 src/qemu/qemu_monitor.c      | 20 ++++++++++++++++++++
 src/qemu/qemu_monitor.h      |  2 ++
 src/qemu/qemu_monitor_json.c | 23 +++++++++++++++++++++++
 src/qemu/qemu_monitor_json.h |  2 ++
 4 files changed, 47 insertions(+)

diff --git a/src/qemu/qemu_monitor.c b/src/qemu/qemu_monitor.c
index 3c45cf4..db65c0b 100644
--- a/src/qemu/qemu_monitor.c
+++ b/src/qemu/qemu_monitor.c
@@ -3647,3 +3647,23 @@ int qemuMonitorAttachCharDev(qemuMonitorPtr mon,
 
     return qemuMonitorJSONAttachCharDev(mon, chrID, chr);
 }
+
+int qemuMonitorDetachCharDev(qemuMonitorPtr mon,
+                             const char *chrID)
+{
+    VIR_DEBUG("mon=%p chrID=%s", mon, chrID);
+
+    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 qemuMonitorJSONDetachCharDev(mon, chrID);
+}
diff --git a/src/qemu/qemu_monitor.h b/src/qemu/qemu_monitor.h
index b382df3..f87ca60 100644
--- a/src/qemu/qemu_monitor.h
+++ b/src/qemu/qemu_monitor.h
@@ -700,6 +700,8 @@ int qemuMonitorGetTPMTypes(qemuMonitorPtr mon,
 int qemuMonitorAttachCharDev(qemuMonitorPtr mon,
                              const char *chrID,
                              virDomainChrSourceDefPtr chr);
+int qemuMonitorDetachCharDev(qemuMonitorPtr mon,
+                             const char *chrID);
 /**
  * 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 1d6f25c..d9fdd95 100644
--- a/src/qemu/qemu_monitor_json.c
+++ b/src/qemu/qemu_monitor_json.c
@@ -5160,3 +5160,26 @@ cleanup:
     virJSONValueFree(reply);
     return ret;
 }
+
+int
+qemuMonitorJSONDetachCharDev(qemuMonitorPtr mon,
+                             const char *chrID)
+{
+    int ret = -1;
+    virJSONValuePtr cmd;
+    virJSONValuePtr reply = NULL;
+
+    if (!(cmd = qemuMonitorJSONMakeCommand("chardev-remove",
+                                           "s:id", chrID,
+                                           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 e0a4883..2660773 100644
--- a/src/qemu/qemu_monitor_json.h
+++ b/src/qemu/qemu_monitor_json.h
@@ -356,4 +356,6 @@ int qemuMonitorJSONGetTPMTypes(qemuMonitorPtr mon,
 int qemuMonitorJSONAttachCharDev(qemuMonitorPtr mon,
                                  const char *chrID,
                                  virDomainChrSourceDefPtr chr);
+int qemuMonitorJSONDetachCharDev(qemuMonitorPtr mon,
+                                 const char *chrID);
 #endif /* QEMU_MONITOR_JSON_H */
-- 
1.8.1.5

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