From nobody Sun Feb 8 12:58:01 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1547558637992459.1662393297257; Tue, 15 Jan 2019 05:23:57 -0800 (PST) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 66DE1811D8; Tue, 15 Jan 2019 13:23:55 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 199555C7A0; Tue, 15 Jan 2019 13:23:55 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id B6F4518434BE; Tue, 15 Jan 2019 13:23:54 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x0FDNiFk011166 for ; Tue, 15 Jan 2019 08:23:44 -0500 Received: by smtp.corp.redhat.com (Postfix) id 7322B600C8; Tue, 15 Jan 2019 13:23:44 +0000 (UTC) Received: from lpt.brq.redhat.com (unknown [10.43.2.68]) by smtp.corp.redhat.com (Postfix) with ESMTP id EDAB75C7A0 for ; Tue, 15 Jan 2019 13:23:43 +0000 (UTC) From: =?UTF-8?q?J=C3=A1n=20Tomko?= To: libvir-list@redhat.com Date: Tue, 15 Jan 2019 14:23:10 +0100 Message-Id: <682df89c64b2efe2b7bb66cc7c2530db65f607f1.1547558465.git.jtomko@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 14/23] qemu_conf: split out virQEMUDriverConfigLoadProcessEntry X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Tue, 15 Jan 2019 13:23:56 +0000 (UTC) Split out parts of the config parsing code to make the parent function easier to read. Signed-off-by: J=C3=A1n Tomko Reviewed-by: John Ferlan --- src/qemu/qemu_conf.c | 162 ++++++++++++++++++++++++------------------- 1 file changed, 90 insertions(+), 72 deletions(-) diff --git a/src/qemu/qemu_conf.c b/src/qemu/qemu_conf.c index 776ba3f3ad..8bc653fa9e 100644 --- a/src/qemu/qemu_conf.c +++ b/src/qemu/qemu_conf.c @@ -423,6 +423,95 @@ virQEMUDriverConfigHugeTLBFSInit(virHugeTLBFSPtr huget= lbfs, } =20 =20 +static int +virQEMUDriverConfigLoadProcessEntry(virQEMUDriverConfigPtr cfg, + virConfPtr conf) +{ + char *stdioHandler =3D NULL; + char **hugetlbfs =3D NULL; + char *corestr =3D NULL; + int ret =3D -1; + size_t i; + + if (virConfGetValueStringList(conf, "hugetlbfs_mount", true, + &hugetlbfs) < 0) + goto cleanup; + if (hugetlbfs) { + /* There already might be something autodetected. Avoid leaking it= . */ + while (cfg->nhugetlbfs) { + cfg->nhugetlbfs--; + VIR_FREE(cfg->hugetlbfs[cfg->nhugetlbfs].mnt_dir); + } + VIR_FREE(cfg->hugetlbfs); + + cfg->nhugetlbfs =3D virStringListLength((const char *const *)huget= lbfs); + if (hugetlbfs[0] && + VIR_ALLOC_N(cfg->hugetlbfs, cfg->nhugetlbfs) < 0) + goto cleanup; + + for (i =3D 0; hugetlbfs[i] !=3D NULL; i++) { + if (virQEMUDriverConfigHugeTLBFSInit(&cfg->hugetlbfs[i], + hugetlbfs[i], i !=3D 0) <= 0) + goto cleanup; + } + } + + if (virConfGetValueBool(conf, "clear_emulator_capabilities", &cfg->cle= arEmulatorCapabilities) < 0) + goto cleanup; + if (virConfGetValueString(conf, "bridge_helper", &cfg->bridgeHelperNam= e) < 0) + goto cleanup; + + if (virConfGetValueString(conf, "pr_helper", &cfg->prHelperName) < 0) + goto cleanup; + + if (virConfGetValueBool(conf, "set_process_name", &cfg->setProcessName= ) < 0) + goto cleanup; + if (virConfGetValueUInt(conf, "max_processes", &cfg->maxProcesses) < 0) + goto cleanup; + if (virConfGetValueUInt(conf, "max_files", &cfg->maxFiles) < 0) + goto cleanup; + + if (virConfGetValueType(conf, "max_core") =3D=3D VIR_CONF_STRING) { + if (virConfGetValueString(conf, "max_core", &corestr) < 0) + goto cleanup; + if (STREQ(corestr, "unlimited")) { + cfg->maxCore =3D ULLONG_MAX; + } else { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("Unknown core size '%s'"), + corestr); + goto cleanup; + } + } else if (virConfGetValueULLong(conf, "max_core", &cfg->maxCore) < 0)= { + goto cleanup; + } + + if (virConfGetValueBool(conf, "dump_guest_core", &cfg->dumpGuestCore) = < 0) + goto cleanup; + if (virConfGetValueString(conf, "stdio_handler", &stdioHandler) < 0) + goto cleanup; + if (stdioHandler) { + if (STREQ(stdioHandler, "logd")) { + cfg->stdioLogD =3D true; + } else if (STREQ(stdioHandler, "file")) { + cfg->stdioLogD =3D false; + } else { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("Unknown stdio handler %s"), + stdioHandler); + VIR_FREE(stdioHandler); + goto cleanup; + } + VIR_FREE(stdioHandler); + } + + ret =3D 0; + cleanup: + virStringListFree(hugetlbfs); + VIR_FREE(corestr); + return ret; +} + static int virQEMUDriverConfigLoadDeviceEntry(virQEMUDriverConfigPtr cfg, virConfPtr conf) @@ -722,8 +811,6 @@ int virQEMUDriverConfigLoadFile(virQEMUDriverConfigPtr = cfg, virConfPtr conf =3D NULL; int ret =3D -1; int rv; - size_t i; - char *stdioHandler =3D NULL; char **hugetlbfs =3D NULL; char *corestr =3D NULL; =20 @@ -894,79 +981,10 @@ int virQEMUDriverConfigLoadFile(virQEMUDriverConfigPt= r cfg, goto cleanup; if (virConfGetValueBool(conf, "auto_start_bypass_cache", &cfg->autoSta= rtBypassCache) < 0) goto cleanup; - - if (virConfGetValueStringList(conf, "hugetlbfs_mount", true, - &hugetlbfs) < 0) - goto cleanup; - if (hugetlbfs) { - /* There already might be something autodetected. Avoid leaking it= . */ - while (cfg->nhugetlbfs) { - cfg->nhugetlbfs--; - VIR_FREE(cfg->hugetlbfs[cfg->nhugetlbfs].mnt_dir); - } - VIR_FREE(cfg->hugetlbfs); - - cfg->nhugetlbfs =3D virStringListLength((const char *const *)huget= lbfs); - if (hugetlbfs[0] && - VIR_ALLOC_N(cfg->hugetlbfs, cfg->nhugetlbfs) < 0) - goto cleanup; - - for (i =3D 0; hugetlbfs[i] !=3D NULL; i++) { - if (virQEMUDriverConfigHugeTLBFSInit(&cfg->hugetlbfs[i], - hugetlbfs[i], i !=3D 0) <= 0) - goto cleanup; - } - } - - if (virConfGetValueString(conf, "bridge_helper", &cfg->bridgeHelperNam= e) < 0) - goto cleanup; - - if (virConfGetValueString(conf, "pr_helper", &cfg->prHelperName) < 0) goto cleanup; =20 - if (virConfGetValueBool(conf, "clear_emulator_capabilities", &cfg->cle= arEmulatorCapabilities) < 0) - goto cleanup; - if (virConfGetValueBool(conf, "set_process_name", &cfg->setProcessName= ) < 0) + if (virQEMUDriverConfigLoadProcessEntry(cfg, conf) < 0) goto cleanup; - if (virConfGetValueUInt(conf, "max_processes", &cfg->maxProcesses) < 0) - goto cleanup; - if (virConfGetValueUInt(conf, "max_files", &cfg->maxFiles) < 0) - goto cleanup; - - if (virConfGetValueType(conf, "max_core") =3D=3D VIR_CONF_STRING) { - if (virConfGetValueString(conf, "max_core", &corestr) < 0) - goto cleanup; - if (STREQ(corestr, "unlimited")) { - cfg->maxCore =3D ULLONG_MAX; - } else { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, - _("Unknown core size '%s'"), - corestr); - goto cleanup; - } - } else if (virConfGetValueULLong(conf, "max_core", &cfg->maxCore) < 0)= { - goto cleanup; - } - - if (virConfGetValueBool(conf, "dump_guest_core", &cfg->dumpGuestCore) = < 0) - goto cleanup; - - if (virConfGetValueString(conf, "stdio_handler", &stdioHandler) < 0) - goto cleanup; - if (stdioHandler) { - if (STREQ(stdioHandler, "logd")) { - cfg->stdioLogD =3D true; - } else if (STREQ(stdioHandler, "file")) { - cfg->stdioLogD =3D false; - } else { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, - _("Unknown stdio handler %s"), - stdioHandler); - VIR_FREE(stdioHandler); - goto cleanup; - } - VIR_FREE(stdioHandler); - } =20 if (virQEMUDriverConfigLoadDeviceEntry(cfg, conf) < 0) goto cleanup; --=20 2.20.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list