Message ID | 1575903705-12925-8-git-send-email-pbonzini@redhat.com |
---|---|
State | New |
Headers | show |
Series | Complete the implementation of -accel | expand |
On 12/9/19 4:01 PM, Paolo Bonzini wrote: > We will reuse the parsing loop of machine_set_property soon for "-accel", > but we do not want the "_" -> "-" conversion since "-accel" can just > standardize on dashes. We will also add a bunch of legacy option handling > to keep the QOM machine object clean. Extract the loop into a separate > function, and keep the legacy handling in machine_set_property. > > Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> > --- > vl.c | 35 ++++++++++++++++++++--------------- > 1 file changed, 20 insertions(+), 15 deletions(-) > > diff --git a/vl.c b/vl.c > index 19c77b4..66dff1b 100644 > --- a/vl.c > +++ b/vl.c > @@ -2615,27 +2615,17 @@ static MachineClass *select_machine(void) > return machine_class; > } > > -static int machine_set_property(void *opaque, > - const char *name, const char *value, > - Error **errp) > +static int object_parse_property_opt(Object *obj, > + const char *name, const char *value, > + const char *skip, Error **errp) Can you document the 'skip' argument? Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com> > { > - Object *obj = OBJECT(opaque); > Error *local_err = NULL; > - char *p, *qom_name; > > - if (strcmp(name, "type") == 0) { > + if (g_str_equal(name, skip)) { > return 0; > } > > - qom_name = g_strdup(name); > - for (p = qom_name; *p; p++) { > - if (*p == '_') { > - *p = '-'; > - } > - } > - > - object_property_parse(obj, value, qom_name, &local_err); > - g_free(qom_name); > + object_property_parse(obj, value, name, &local_err); > > if (local_err) { > error_propagate(errp, local_err); > @@ -2645,6 +2635,21 @@ static int machine_set_property(void *opaque, > return 0; > } > > +static int machine_set_property(void *opaque, > + const char *name, const char *value, > + Error **errp) > +{ > + g_autofree char *qom_name = g_strdup(name); > + char *p; > + > + for (p = qom_name; *p; p++) { > + if (*p == '_') { > + *p = '-'; > + } > + } > + > + return object_parse_property_opt(opaque, name, value, "type", errp); > +} > > /* > * Initial object creation happens before all other >
diff --git a/vl.c b/vl.c index 19c77b4..66dff1b 100644 --- a/vl.c +++ b/vl.c @@ -2615,27 +2615,17 @@ static MachineClass *select_machine(void) return machine_class; } -static int machine_set_property(void *opaque, - const char *name, const char *value, - Error **errp) +static int object_parse_property_opt(Object *obj, + const char *name, const char *value, + const char *skip, Error **errp) { - Object *obj = OBJECT(opaque); Error *local_err = NULL; - char *p, *qom_name; - if (strcmp(name, "type") == 0) { + if (g_str_equal(name, skip)) { return 0; } - qom_name = g_strdup(name); - for (p = qom_name; *p; p++) { - if (*p == '_') { - *p = '-'; - } - } - - object_property_parse(obj, value, qom_name, &local_err); - g_free(qom_name); + object_property_parse(obj, value, name, &local_err); if (local_err) { error_propagate(errp, local_err); @@ -2645,6 +2635,21 @@ static int machine_set_property(void *opaque, return 0; } +static int machine_set_property(void *opaque, + const char *name, const char *value, + Error **errp) +{ + g_autofree char *qom_name = g_strdup(name); + char *p; + + for (p = qom_name; *p; p++) { + if (*p == '_') { + *p = '-'; + } + } + + return object_parse_property_opt(opaque, name, value, "type", errp); +} /* * Initial object creation happens before all other
We will reuse the parsing loop of machine_set_property soon for "-accel", but we do not want the "_" -> "-" conversion since "-accel" can just standardize on dashes. We will also add a bunch of legacy option handling to keep the QOM machine object clean. Extract the loop into a separate function, and keep the legacy handling in machine_set_property. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> --- vl.c | 35 ++++++++++++++++++++--------------- 1 file changed, 20 insertions(+), 15 deletions(-)