[PATCH 09/12] qemu_monitor: add 2 functions qemuMonitorDetachRNGDev and qemuMonitorAttachRNGDev

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

 



These 2 functions just do some basic check and then call
qemuMonitorJSONAttachRNGDev and qemuMonitorDelObject to
help us.

Signed-off-by: Luyao Huang <lhuang@xxxxxxxxxx>
---
 src/qemu/qemu_monitor.c | 43 +++++++++++++++++++++++++++++++++++++++++++
 src/qemu/qemu_monitor.h |  7 +++++++
 2 files changed, 50 insertions(+)

diff --git a/src/qemu/qemu_monitor.c b/src/qemu/qemu_monitor.c
index 100bbd0..9ac5934 100644
--- a/src/qemu/qemu_monitor.c
+++ b/src/qemu/qemu_monitor.c
@@ -4140,6 +4140,49 @@ int qemuMonitorDetachCharDev(qemuMonitorPtr mon,
     return qemuMonitorJSONDetachCharDev(mon, chrID);
 }
 
+int qemuMonitorAttachRNGDev(qemuMonitorPtr mon,
+                            const char *chrID,
+                            const char *objID,
+                            virDomainRNGDefPtr rng)
+{
+    VIR_DEBUG("mon=%p chrID=%s objID=%s rng=%p", mon, chrID, objID, rng);
+
+    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 qemuMonitorJSONAttachRNGDev(mon, chrID, objID, rng);
+}
+
+int qemuMonitorDetachRNGDev(qemuMonitorPtr mon,
+                             const char *objID)
+{
+    VIR_DEBUG("mon=%p objID=%s", mon, objID);
+
+    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 qemuMonitorDelObject(mon, objID);
+}
+
+
 int
 qemuMonitorGetDeviceAliases(qemuMonitorPtr mon,
                             char ***aliases)
diff --git a/src/qemu/qemu_monitor.h b/src/qemu/qemu_monitor.h
index edab66f..99587e8 100644
--- a/src/qemu/qemu_monitor.h
+++ b/src/qemu/qemu_monitor.h
@@ -865,6 +865,13 @@ int qemuMonitorAttachCharDev(qemuMonitorPtr mon,
 int qemuMonitorDetachCharDev(qemuMonitorPtr mon,
                              const char *chrID);
 
+int qemuMonitorAttachRNGDev(qemuMonitorPtr mon,
+                            const char *chrID,
+                            const char *objID,
+                            virDomainRNGDefPtr rng);
+int qemuMonitorDetachRNGDev(qemuMonitorPtr mon,
+                            const char *objID);
+
 int qemuMonitorGetDeviceAliases(qemuMonitorPtr mon,
                                 char ***aliases);
 
-- 
1.8.3.1

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