[PATCH 1/8] qemu: add a new qemuMonitorSetBootIndex() method to set device's bootorder

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

 



The new qemuMonitorSetBootIndex() method can set device' boot order online
using 'qom-set' JSON monitor command. HMP is not supported. And it is used
for QEMU >= 2.2.0 . The QMP command is like "qom-set net1 bootindex 2".

Signed-off-by: Wang Rui <moon.wangrui@xxxxxxxxxx>
Signed-off-by: Zhou Yimin <zhouyimin@xxxxxxxxxx>
---
 src/qemu/qemu_monitor.c      | 25 +++++++++++++++++++++++++
 src/qemu/qemu_monitor.h      |  4 ++++
 src/qemu/qemu_monitor_json.c | 19 +++++++++++++++++++
 src/qemu/qemu_monitor_json.h |  5 +++++
 4 files changed, 53 insertions(+)

diff --git a/src/qemu/qemu_monitor.c b/src/qemu/qemu_monitor.c
index 100bbd0..907834f 100644
--- a/src/qemu/qemu_monitor.c
+++ b/src/qemu/qemu_monitor.c
@@ -4292,3 +4292,28 @@ void qemuMonitorIOThreadsInfoFree(qemuMonitorIOThreadsInfoPtr iothread)
     VIR_FREE(iothread->name);
     VIR_FREE(iothread);
 }
+
+int
+qemuMonitorSetBootIndex(qemuMonitorPtr mon,
+                        const char *name,
+                        int bootIndex)
+{
+    int ret;
+    VIR_DEBUG("mon=%p, name=%p:%s, bootIndex=%d", mon, name, name, bootIndex);
+
+    if (!mon || !name) {
+        virReportError(VIR_ERR_INVALID_ARG, "%s",
+                       _("monitor || name must not be NULL"));
+        return -1;
+    }
+
+    if (!mon->json) {
+        virReportError(VIR_ERR_OPERATION_UNSUPPORTED, "%s",
+                       _("JSON monitor is required"));
+        return -1;
+    }
+
+    ret = qemuMonitorJSONSetBootIndex(mon, name, bootIndex);
+
+    return ret;
+}
diff --git a/src/qemu/qemu_monitor.h b/src/qemu/qemu_monitor.h
index edab66f..8e5d86e 100644
--- a/src/qemu/qemu_monitor.h
+++ b/src/qemu/qemu_monitor.h
@@ -888,6 +888,10 @@ int qemuMonitorGetIOThreads(qemuMonitorPtr mon,
 
 void qemuMonitorIOThreadsInfoFree(qemuMonitorIOThreadsInfoPtr iothread);
 
+int qemuMonitorSetBootIndex(qemuMonitorPtr mon,
+                            const char *name,
+                            int bootIndex);
+
 /**
  * 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 e567aa7..df52101 100644
--- a/src/qemu/qemu_monitor_json.c
+++ b/src/qemu/qemu_monitor_json.c
@@ -6500,3 +6500,22 @@ qemuMonitorJSONGetIOThreads(qemuMonitorPtr mon,
     virJSONValueFree(reply);
     return ret;
 }
+
+int
+qemuMonitorJSONSetBootIndex(qemuMonitorPtr mon,
+                            const char *name,
+                            int bootIndex)
+{
+    qemuMonitorJSONObjectProperty prop;
+
+    memset(&prop, 0, sizeof(qemuMonitorJSONObjectProperty));
+    prop.type = QEMU_MONITOR_OBJECT_PROPERTY_INT;
+    prop.val.iv = bootIndex;
+
+    if (qemuMonitorJSONSetObjectProperty(mon, name,
+                                         "bootindex",
+                                         &prop) < 0) {
+        return -1;
+    }
+    return 0;
+}
diff --git a/src/qemu/qemu_monitor_json.h b/src/qemu/qemu_monitor_json.h
index 222f11e..6355ddf 100644
--- a/src/qemu/qemu_monitor_json.h
+++ b/src/qemu/qemu_monitor_json.h
@@ -472,4 +472,9 @@ int qemuMonitorJSONRTCResetReinjection(qemuMonitorPtr mon);
 int qemuMonitorJSONGetIOThreads(qemuMonitorPtr mon,
                                 qemuMonitorIOThreadsInfoPtr **iothreads)
     ATTRIBUTE_NONNULL(2);
+
+int qemuMonitorJSONSetBootIndex(qemuMonitorPtr mon,
+                                const char *name,
+                                int bootIndex);
+
 #endif /* QEMU_MONITOR_JSON_H */
-- 
1.7.12.4


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