[libvirt] [PATCH 1/8] qemu: add a new qemuMonitorSetBootIndex() method to set device's bootorder
John Ferlan
jferlan at redhat.com
Tue Feb 3 01:38:35 UTC 2015
On 01/05/2015 02:29 AM, Wang Rui wrote:
> 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 at huawei.com>
> Signed-off-by: Zhou Yimin <zhouyimin at huawei.com>
> ---
> 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(+)
>
Looks like this was "missed/lost/forgotten" from the holidays... You'll
need to update with top of tree...
What happens if qemu < 2.2? Is there a way to test? Callers will end
up failing perhaps when you don't want them to...
After reading later patches - is there a similar qom-get for this field?
That would simplify a few nasty error paths later..
> 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;
> + }
See [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);
[1]
If you change this slightly to be
int bootIndex)
ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2);
Then you avoid the !mon || !name checks above.... also the %p:%s becomes
unnecessary - that is either %p or %s.
> +
> /**
> * 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 */
>
More information about the libvir-list
mailing list