On Thu, Sep 20, 2018 at 10:20 PM, John Ferlan <jferlan(a)redhat.com> wrote:
On 09/20/2018 09:28 AM, Fabiano Fidêncio wrote:
> Signed-off-by: Fabiano Fidêncio <fidencio(a)redhat.com>
> ---
> src/xenconfig/xen_common.c | 27 +++++++++++++--------------
> 1 file changed, 13 insertions(+), 14 deletions(-)
>
> diff --git a/src/xenconfig/xen_common.c b/src/xenconfig/xen_common.c
> index 058f35825e..21f1f4a24c 100644
> --- a/src/xenconfig/xen_common.c
> +++ b/src/xenconfig/xen_common.c
> @@ -773,11 +773,13 @@ xenParseVfb(virConfPtr conf, virDomainDefPtr def)
> static int
> xenParseCharDev(virConfPtr conf, virDomainDefPtr def, const char
*nativeFormat)
> {
> - virConfValuePtr value = NULL;
> + VIR_AUTOPTR(virString) serials = NULL;
> virDomainChrDefPtr chr = NULL;
>
> if (def->os.type == VIR_DOMAIN_OSTYPE_HVM) {
> VIR_AUTOFREE(char *) parallel = NULL;
> + int rc;
> +
> if (xenConfigGetString(conf, "parallel", ¶llel, NULL)
< 0)
> goto cleanup;
> if (parallel && STRNEQ(parallel, "none") &&
> @@ -795,8 +797,8 @@ xenParseCharDev(virConfPtr conf, virDomainDefPtr
def, const char *nativeFormat)
> }
>
> /* Try to get the list of values to support multiple serial
ports */
> - value = virConfGetValue(conf, "serial");
> - if (value && value->type == VIR_CONF_LIST) {
> + if ((rc = virConfGetValueStringList(conf, "serial", false,
&serials)) == 1) {
> + virString *entries;
> int portnum = -1;
>
> if (STREQ(nativeFormat, XEN_CONFIG_FORMAT_XM)) {
> @@ -805,18 +807,12 @@ xenParseCharDev(virConfPtr conf, virDomainDefPtr
def, const char *nativeFormat)
> goto cleanup;
> }
>
> - value = value->list;
> - while (value) {
> - char *port = NULL;
> + for (entries = serials; *entries; entries++) {
> + virString port = *entries;
>
> - if ((value->type != VIR_CONF_STRING) || (value->str ==
NULL))
> - goto cleanup;
> - port = value->str;
> portnum++;
> - if (STREQ(port, "none")) {
> - value = value->next;
> + if (STREQ(port, "none"))
> continue;
> - }
>
> if (!(chr = xenParseSxprChar(port, NULL)))
> goto cleanup;
> @@ -824,11 +820,14 @@ xenParseCharDev(virConfPtr conf, virDomainDefPtr
def, const char *nativeFormat)
> chr->target.port = portnum;
> if (VIR_APPEND_ELEMENT(def->serials, def->nserials,
chr) < 0)
> goto cleanup;
> -
> - value = value->next;
> }
> } else {
> VIR_AUTOFREE(char *) serial = NULL;
> +
> + rc = xenHandleConfGetValueStringListErrors(rc,
virGetLastErrorCode());
> + if (rc < 0)
Based on patch4 change, this is simplified to just:
if (xenHandleConfGetValueStringListErrors(rc) < 0)
I can alter before pushing if you're fine with that.
Sure. Thanks a lot for the review, John!
Reviewed-by: John Ferlan <jferlan(a)redhat.com>
John
Logic is sooo much nicer with these VIR_AUTOFREE and VIR_AUTOPTR!
> + goto cleanup;
> +
> /* If domain is not using multiple serial ports we parse
data old way */
> if (xenConfigGetString(conf, "serial", &serial, NULL)
< 0)
> goto cleanup;
>