@@ -510,17 +510,12 @@ static QemuOptsList qemu_name_opts = {
},
};
-/**
- * Get machine options
- *
- * Returns: machine options (never null).
- */
-QemuOpts *qemu_get_machine_opts(void)
+static QemuOpts *qemu_get_opts_nofail(const char *type)
{
QemuOptsList *list;
QemuOpts *opts;
- list = qemu_find_opts("machine");
+ list = qemu_find_opts(type);
assert(list);
opts = qemu_opts_find(list, NULL);
if (!opts) {
@@ -529,6 +524,17 @@ QemuOpts *qemu_get_machine_opts(void)
return opts;
}
+/**
+ * Get machine options
+ *
+ * Returns: machine options (never null).
+ */
+
+QemuOpts *qemu_get_machine_opts(void)
+{
+ return qemu_get_opts_nofail("machine");
+}
+
const char *qemu_get_vm_name(void)
{
return qemu_name;
This "nofail" (i.e. does not return NULL) mechanism driving qemu_get_machine_opts() does not need to be specific to machine opts - its applicable to other types of opts. Generalise and re-implement qemu_get_machine_opts() as a caller of the generalisation. Signed-off-by: Peter Crosthwaite <peter.crosthwaite@xilinx.com> --- vl.c | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-)