Message ID | 34caebc321743acdc19a7cfbe4ed438985077e28.1397794966.git.peter.crosthwaite@xilinx.com |
---|---|
State | New |
Headers | show |
On Fri, Apr 18, 2014 at 2:53 PM, Paolo Bonzini <pbonzini@redhat.com> wrote: > Il 18/04/2014 00:25, Peter Crosthwaite ha scritto: > >> 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(-) >> >> diff --git a/vl.c b/vl.c >> index 9975e5a..bc12d0f 100644 >> --- a/vl.c >> +++ b/vl.c >> @@ -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 is already planned for 2.1 as qemu_find_opts_singleton, which either > Igor or Hu will send. > I see. Anything else in that work that you see conflicting with other components of this series? AFAICT its just a trivial change to P2 to back onto the qemu_find_opts_singleton work and the rest stands as-is. Regards, Peter > Paolo >
diff --git a/vl.c b/vl.c index 9975e5a..bc12d0f 100644 --- a/vl.c +++ b/vl.c @@ -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(-)