From nobody Sun Dec 22 02:49:53 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.libvirt.org designates 8.43.85.245 as permitted sender) client-ip=8.43.85.245; envelope-from=devel-bounces@lists.libvirt.org; helo=lists.libvirt.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of lists.libvirt.org designates 8.43.85.245 as permitted sender) smtp.mailfrom=devel-bounces@lists.libvirt.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.libvirt.org (lists.libvirt.org [8.43.85.245]) by mx.zohomail.com with SMTPS id 1734449549748307.4767698084878; Tue, 17 Dec 2024 07:32:29 -0800 (PST) Received: by lists.libvirt.org (Postfix, from userid 996) id 9D59015AF; Tue, 17 Dec 2024 10:32:28 -0500 (EST) Received: from lists.libvirt.org (localhost [IPv6:::1]) by lists.libvirt.org (Postfix) with ESMTP id 95BE71586; Tue, 17 Dec 2024 10:32:03 -0500 (EST) Received: by lists.libvirt.org (Postfix, from userid 996) id 83E3A156F; Tue, 17 Dec 2024 10:32:00 -0500 (EST) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by lists.libvirt.org (Postfix) with ESMTPS id B2F361502 for ; Tue, 17 Dec 2024 10:31:58 -0500 (EST) Received: from mx-prod-mc-03.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-64-h6MMdsvyP728crQsAN5HuA-1; Tue, 17 Dec 2024 10:31:54 -0500 Received: from mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.17]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id BF03C1955F54 for ; Tue, 17 Dec 2024 15:31:53 +0000 (UTC) Received: from toolbox.redhat.com (unknown [10.42.28.136]) by mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id A54551956053; Tue, 17 Dec 2024 15:31:52 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on lists.libvirt.org X-Spam-Level: X-Spam-Status: No, score=-1.7 required=5.0 tests=DKIM_INVALID,DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2,RCVD_IN_VALIDITY_RPBL_BLOCKED, RCVD_IN_VALIDITY_SAFE_BLOCKED,SPF_HELO_NONE autolearn=unavailable autolearn_force=no version=3.4.4 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1734449518; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=Ar84p5Vv+eFPJmtXBKlAIRNfA7r+FayyU7tzcUklZF0=; b=ULoAhCLG7XmeVaF0AO7vQH84BiQ2cUOGl1Z/NQdL/E2AbW0umPAOA6aec2X0nEYr7K3O95 ep6ERbI2BsjmwZNQTgFCqncbKG2qAHm1c9zg5StnSMmI/kJ4vb7TQufAJJQDLfHRi2QsxJ eiKkYHPW4+OVj86G+8gZwTmWiCWX0KQ= X-MC-Unique: h6MMdsvyP728crQsAN5HuA-1 X-Mimecast-MFC-AGG-ID: h6MMdsvyP728crQsAN5HuA From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= To: devel@lists.libvirt.org Cc: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= Subject: [PATCH] src: drop obsolete checks for virDomainConfigFile failure Date: Tue, 17 Dec 2024 15:31:51 +0000 Message-ID: <20241217153151.3934138-1-berrange@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.0 on 10.30.177.17 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: uplWKd4TwME2bNgSHgJYhsDb6u_TCph0ZCxYIXEkoQM_1734449513 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Message-ID-Hash: B5EFLXDDRERKAKJ3LNC5USCZFV4JMUBR X-Message-ID-Hash: B5EFLXDDRERKAKJ3LNC5USCZFV4JMUBR X-MailFrom: berrange@redhat.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-config-1; header-match-config-2; header-match-config-3; header-match-devel.lists.libvirt.org-0; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; suspicious-header X-Mailman-Version: 3.2.2 Precedence: list List-Id: Development discussions about the libvirt library & tools Archived-At: List-Archive: List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1734449551577116600 Content-Type: text/plain; charset="utf-8" This cannot ever return NULL Signed-off-by: Daniel P. Berrang=C3=A9 Reviewed-by: Michal Privoznik --- src/bhyve/bhyve_driver.c | 6 ++---- src/conf/domain_conf.c | 7 ++----- src/conf/virdomainobjlist.c | 9 +++------ src/libxl/libxl_driver.c | 6 ++---- src/lxc/lxc_controller.c | 4 +--- src/lxc/lxc_driver.c | 10 ++-------- src/qemu/qemu_driver.c | 22 ++++++---------------- 7 files changed, 18 insertions(+), 46 deletions(-) diff --git a/src/bhyve/bhyve_driver.c b/src/bhyve/bhyve_driver.c index 2bd1e4c387..8f97ac032c 100644 --- a/src/bhyve/bhyve_driver.c +++ b/src/bhyve/bhyve_driver.c @@ -364,10 +364,8 @@ bhyveDomainSetAutostart(virDomainPtr domain, int autos= tart) autostart =3D (autostart !=3D 0); =20 if (vm->autostart !=3D autostart) { - if ((configFile =3D virDomainConfigFile(BHYVE_CONFIG_DIR, vm->def-= >name)) =3D=3D NULL) - goto cleanup; - if ((autostartLink =3D virDomainConfigFile(BHYVE_AUTOSTART_DIR, vm= ->def->name)) =3D=3D NULL) - goto cleanup; + configFile =3D virDomainConfigFile(BHYVE_CONFIG_DIR, vm->def->name= ); + autostartLink =3D virDomainConfigFile(BHYVE_AUTOSTART_DIR, vm->def= ->name); =20 if (autostart) { if (g_mkdir_with_parents(BHYVE_AUTOSTART_DIR, 0777) < 0) { diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 4ad8289b89..cae5ba9df1 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -29060,11 +29060,8 @@ virDomainDeleteConfig(const char *configDir, g_autofree char *configFile =3D NULL; g_autofree char *autostartLink =3D NULL; =20 - if ((configFile =3D virDomainConfigFile(configDir, dom->def->name)) = =3D=3D NULL) - return -1; - if ((autostartLink =3D virDomainConfigFile(autostartDir, - dom->def->name)) =3D=3D NULL) - return -1; + configFile =3D virDomainConfigFile(configDir, dom->def->name); + autostartLink =3D virDomainConfigFile(autostartDir, dom->def->name); =20 /* Not fatal if this doesn't work */ unlink(autostartLink); diff --git a/src/conf/virdomainobjlist.c b/src/conf/virdomainobjlist.c index 166bbc5cfd..72207450c5 100644 --- a/src/conf/virdomainobjlist.c +++ b/src/conf/virdomainobjlist.c @@ -492,16 +492,14 @@ virDomainObjListLoadConfig(virDomainObjList *doms, int autostart; g_autoptr(virDomainDef) oldDef =3D NULL; =20 - if ((configFile =3D virDomainConfigFile(configDir, name)) =3D=3D NULL) - return NULL; + configFile =3D virDomainConfigFile(configDir, name); if (!(def =3D virDomainDefParseFile(configFile, xmlopt, NULL, VIR_DOMAIN_DEF_PARSE_INACTIVE | VIR_DOMAIN_DEF_PARSE_SKIP_VALIDATE | VIR_DOMAIN_DEF_PARSE_ALLOW_POST_PARS= E_FAIL))) return NULL; =20 - if ((autostartLink =3D virDomainConfigFile(autostartDir, name)) =3D=3D= NULL) - return NULL; + autostartLink =3D virDomainConfigFile(autostartDir, name); =20 autostart =3D virFileLinkPointsTo(autostartLink, configFile); =20 @@ -529,8 +527,7 @@ virDomainObjListLoadStatus(virDomainObjList *doms, virDomainObj *obj =3D NULL; char uuidstr[VIR_UUID_STRING_BUFLEN]; =20 - if ((statusFile =3D virDomainConfigFile(statusDir, name)) =3D=3D NULL) - goto error; + statusFile =3D virDomainConfigFile(statusDir, name); =20 if (!(obj =3D virDomainObjParseFile(statusFile, xmlopt, VIR_DOMAIN_DEF_PARSE_STATUS | diff --git a/src/libxl/libxl_driver.c b/src/libxl/libxl_driver.c index e72553603d..b8f721351c 100644 --- a/src/libxl/libxl_driver.c +++ b/src/libxl/libxl_driver.c @@ -4651,10 +4651,8 @@ libxlDomainSetAutostart(virDomainPtr dom, int autost= art) autostart =3D (autostart !=3D 0); =20 if (vm->autostart !=3D autostart) { - if (!(configFile =3D virDomainConfigFile(cfg->configDir, vm->def->= name))) - goto endjob; - if (!(autostartLink =3D virDomainConfigFile(cfg->autostartDir, vm-= >def->name))) - goto endjob; + configFile =3D virDomainConfigFile(cfg->configDir, vm->def->name); + autostartLink =3D virDomainConfigFile(cfg->autostartDir, vm->def->= name); =20 if (autostart) { if (g_mkdir_with_parents(cfg->autostartDir, 0777) < 0) { diff --git a/src/lxc/lxc_controller.c b/src/lxc/lxc_controller.c index 7b432a1160..fb7f8e0bc2 100644 --- a/src/lxc/lxc_controller.c +++ b/src/lxc/lxc_controller.c @@ -196,9 +196,7 @@ static virLXCController *virLXCControllerNew(const char= *name) if (!(driver =3D virLXCControllerDriverNew())) goto error; =20 - if ((configFile =3D virDomainConfigFile(LXC_STATE_DIR, - ctrl->name)) =3D=3D NULL) - goto error; + configFile =3D virDomainConfigFile(LXC_STATE_DIR, ctrl->name); =20 if ((ctrl->vm =3D virDomainObjParseFile(configFile, driver->xmlopt, diff --git a/src/lxc/lxc_driver.c b/src/lxc/lxc_driver.c index 2488940feb..b1a355794c 100644 --- a/src/lxc/lxc_driver.c +++ b/src/lxc/lxc_driver.c @@ -2430,14 +2430,8 @@ static int lxcDomainSetAutostart(virDomainPtr dom, goto endjob; } =20 - configFile =3D virDomainConfigFile(cfg->configDir, - vm->def->name); - if (configFile =3D=3D NULL) - goto endjob; - autostartLink =3D virDomainConfigFile(cfg->autostartDir, - vm->def->name); - if (autostartLink =3D=3D NULL) - goto endjob; + configFile =3D virDomainConfigFile(cfg->configDir, vm->def->name); + autostartLink =3D virDomainConfigFile(cfg->autostartDir, vm->def->name= ); =20 if (autostart) { if (g_mkdir_with_parents(cfg->autostartDir, 0777) < 0) { diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index 672b42b44e..72d6b627f9 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -7784,12 +7784,8 @@ static int qemuDomainSetAutostart(virDomainPtr dom, if (virDomainObjBeginJob(vm, VIR_JOB_MODIFY) < 0) goto cleanup; =20 - if (!(configFile =3D virDomainConfigFile(cfg->configDir, vm->def->= name))) - goto endjob; - - if (!(autostartLink =3D virDomainConfigFile(cfg->autostartDir, - vm->def->name))) - goto endjob; + configFile =3D virDomainConfigFile(cfg->configDir, vm->def->name); + autostartLink =3D virDomainConfigFile(cfg->autostartDir, vm->def->= name); =20 if (autostart) { if (g_mkdir_with_parents(cfg->autostartDir, 0777) < 0) { @@ -18339,21 +18335,15 @@ qemuDomainRenameCallback(virDomainObj *vm, =20 new_dom_name =3D g_strdup(new_name); =20 - if (!(new_dom_cfg_file =3D virDomainConfigFile(cfg->configDir, - new_dom_name)) || - !(old_dom_cfg_file =3D virDomainConfigFile(cfg->configDir, - vm->def->name))) - return -1; + new_dom_cfg_file =3D virDomainConfigFile(cfg->configDir, new_dom_name); + old_dom_cfg_file =3D virDomainConfigFile(cfg->configDir, vm->def->name= ); =20 if (qemuDomainNamePathsCleanup(cfg, new_name, false) < 0) goto cleanup; =20 if (vm->autostart) { - if (!(new_dom_autostart_link =3D virDomainConfigFile(cfg->autostar= tDir, - new_dom_name)) || - !(old_dom_autostart_link =3D virDomainConfigFile(cfg->autostar= tDir, - vm->def->name))) - return -1; + new_dom_autostart_link =3D virDomainConfigFile(cfg->autostartDir, = new_dom_name); + old_dom_autostart_link =3D virDomainConfigFile(cfg->autostartDir, = vm->def->name); =20 if (symlink(new_dom_cfg_file, new_dom_autostart_link) < 0) { virReportSystemError(errno, --=20 2.46.0