mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-12-22 05:35:25 +00:00
src: drop obsolete checks for virDomainConfigFile failure
This cannot ever return NULL Reviewed-by: Michal Privoznik <mprivozn@redhat.com> Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
This commit is contained in:
parent
8575724aef
commit
f7cbb136c3
@ -364,10 +364,8 @@ bhyveDomainSetAutostart(virDomainPtr domain, int autostart)
|
||||
autostart = (autostart != 0);
|
||||
|
||||
if (vm->autostart != autostart) {
|
||||
if ((configFile = virDomainConfigFile(BHYVE_CONFIG_DIR, vm->def->name)) == NULL)
|
||||
goto cleanup;
|
||||
if ((autostartLink = virDomainConfigFile(BHYVE_AUTOSTART_DIR, vm->def->name)) == NULL)
|
||||
goto cleanup;
|
||||
configFile = virDomainConfigFile(BHYVE_CONFIG_DIR, vm->def->name);
|
||||
autostartLink = virDomainConfigFile(BHYVE_AUTOSTART_DIR, vm->def->name);
|
||||
|
||||
if (autostart) {
|
||||
if (g_mkdir_with_parents(BHYVE_AUTOSTART_DIR, 0777) < 0) {
|
||||
|
@ -29002,8 +29002,7 @@ virDomainDefSaveXML(virDomainDef *def,
|
||||
if (!configDir)
|
||||
return 0;
|
||||
|
||||
if ((configFile = virDomainConfigFile(configDir, def->name)) == NULL)
|
||||
return -1;
|
||||
configFile = virDomainConfigFile(configDir, def->name);
|
||||
|
||||
if (g_mkdir_with_parents(configDir, 0777) < 0) {
|
||||
virReportSystemError(errno,
|
||||
@ -29060,11 +29059,8 @@ virDomainDeleteConfig(const char *configDir,
|
||||
g_autofree char *configFile = NULL;
|
||||
g_autofree char *autostartLink = NULL;
|
||||
|
||||
if ((configFile = virDomainConfigFile(configDir, dom->def->name)) == NULL)
|
||||
return -1;
|
||||
if ((autostartLink = virDomainConfigFile(autostartDir,
|
||||
dom->def->name)) == NULL)
|
||||
return -1;
|
||||
configFile = virDomainConfigFile(configDir, dom->def->name);
|
||||
autostartLink = virDomainConfigFile(autostartDir, dom->def->name);
|
||||
|
||||
/* Not fatal if this doesn't work */
|
||||
unlink(autostartLink);
|
||||
|
@ -492,16 +492,14 @@ virDomainObjListLoadConfig(virDomainObjList *doms,
|
||||
int autostart;
|
||||
g_autoptr(virDomainDef) oldDef = NULL;
|
||||
|
||||
if ((configFile = virDomainConfigFile(configDir, name)) == NULL)
|
||||
return NULL;
|
||||
configFile = virDomainConfigFile(configDir, name);
|
||||
if (!(def = virDomainDefParseFile(configFile, xmlopt, NULL,
|
||||
VIR_DOMAIN_DEF_PARSE_INACTIVE |
|
||||
VIR_DOMAIN_DEF_PARSE_SKIP_VALIDATE |
|
||||
VIR_DOMAIN_DEF_PARSE_ALLOW_POST_PARSE_FAIL)))
|
||||
return NULL;
|
||||
|
||||
if ((autostartLink = virDomainConfigFile(autostartDir, name)) == NULL)
|
||||
return NULL;
|
||||
autostartLink = virDomainConfigFile(autostartDir, name);
|
||||
|
||||
autostart = virFileLinkPointsTo(autostartLink, configFile);
|
||||
|
||||
@ -529,8 +527,7 @@ virDomainObjListLoadStatus(virDomainObjList *doms,
|
||||
virDomainObj *obj = NULL;
|
||||
char uuidstr[VIR_UUID_STRING_BUFLEN];
|
||||
|
||||
if ((statusFile = virDomainConfigFile(statusDir, name)) == NULL)
|
||||
goto error;
|
||||
statusFile = virDomainConfigFile(statusDir, name);
|
||||
|
||||
if (!(obj = virDomainObjParseFile(statusFile, xmlopt,
|
||||
VIR_DOMAIN_DEF_PARSE_STATUS |
|
||||
|
@ -4656,10 +4656,8 @@ libxlDomainSetAutostart(virDomainPtr dom, int autostart)
|
||||
autostart = (autostart != 0);
|
||||
|
||||
if (vm->autostart != autostart) {
|
||||
if (!(configFile = virDomainConfigFile(cfg->configDir, vm->def->name)))
|
||||
goto endjob;
|
||||
if (!(autostartLink = virDomainConfigFile(cfg->autostartDir, vm->def->name)))
|
||||
goto endjob;
|
||||
configFile = virDomainConfigFile(cfg->configDir, vm->def->name);
|
||||
autostartLink = virDomainConfigFile(cfg->autostartDir, vm->def->name);
|
||||
|
||||
if (autostart) {
|
||||
if (g_mkdir_with_parents(cfg->autostartDir, 0777) < 0) {
|
||||
|
@ -196,9 +196,7 @@ static virLXCController *virLXCControllerNew(const char *name)
|
||||
if (!(driver = virLXCControllerDriverNew()))
|
||||
goto error;
|
||||
|
||||
if ((configFile = virDomainConfigFile(LXC_STATE_DIR,
|
||||
ctrl->name)) == NULL)
|
||||
goto error;
|
||||
configFile = virDomainConfigFile(LXC_STATE_DIR, ctrl->name);
|
||||
|
||||
if ((ctrl->vm = virDomainObjParseFile(configFile,
|
||||
driver->xmlopt,
|
||||
|
@ -2439,14 +2439,8 @@ static int lxcDomainSetAutostart(virDomainPtr dom,
|
||||
goto endjob;
|
||||
}
|
||||
|
||||
configFile = virDomainConfigFile(cfg->configDir,
|
||||
vm->def->name);
|
||||
if (configFile == NULL)
|
||||
goto endjob;
|
||||
autostartLink = virDomainConfigFile(cfg->autostartDir,
|
||||
vm->def->name);
|
||||
if (autostartLink == NULL)
|
||||
goto endjob;
|
||||
configFile = virDomainConfigFile(cfg->configDir, vm->def->name);
|
||||
autostartLink = virDomainConfigFile(cfg->autostartDir, vm->def->name);
|
||||
|
||||
if (autostart) {
|
||||
if (g_mkdir_with_parents(cfg->autostartDir, 0777) < 0) {
|
||||
|
@ -7790,12 +7790,8 @@ static int qemuDomainSetAutostart(virDomainPtr dom,
|
||||
if (virDomainObjBeginJob(vm, VIR_JOB_MODIFY) < 0)
|
||||
goto cleanup;
|
||||
|
||||
if (!(configFile = virDomainConfigFile(cfg->configDir, vm->def->name)))
|
||||
goto endjob;
|
||||
|
||||
if (!(autostartLink = virDomainConfigFile(cfg->autostartDir,
|
||||
vm->def->name)))
|
||||
goto endjob;
|
||||
configFile = virDomainConfigFile(cfg->configDir, vm->def->name);
|
||||
autostartLink = virDomainConfigFile(cfg->autostartDir, vm->def->name);
|
||||
|
||||
if (autostart) {
|
||||
if (g_mkdir_with_parents(cfg->autostartDir, 0777) < 0) {
|
||||
@ -18345,21 +18341,15 @@ qemuDomainRenameCallback(virDomainObj *vm,
|
||||
|
||||
new_dom_name = g_strdup(new_name);
|
||||
|
||||
if (!(new_dom_cfg_file = virDomainConfigFile(cfg->configDir,
|
||||
new_dom_name)) ||
|
||||
!(old_dom_cfg_file = virDomainConfigFile(cfg->configDir,
|
||||
vm->def->name)))
|
||||
return -1;
|
||||
new_dom_cfg_file = virDomainConfigFile(cfg->configDir, new_dom_name);
|
||||
old_dom_cfg_file = virDomainConfigFile(cfg->configDir, vm->def->name);
|
||||
|
||||
if (qemuDomainNamePathsCleanup(cfg, new_name, false) < 0)
|
||||
goto cleanup;
|
||||
|
||||
if (vm->autostart) {
|
||||
if (!(new_dom_autostart_link = virDomainConfigFile(cfg->autostartDir,
|
||||
new_dom_name)) ||
|
||||
!(old_dom_autostart_link = virDomainConfigFile(cfg->autostartDir,
|
||||
vm->def->name)))
|
||||
return -1;
|
||||
new_dom_autostart_link = virDomainConfigFile(cfg->autostartDir, new_dom_name);
|
||||
old_dom_autostart_link = virDomainConfigFile(cfg->autostartDir, vm->def->name);
|
||||
|
||||
if (symlink(new_dom_cfg_file, new_dom_autostart_link) < 0) {
|
||||
virReportSystemError(errno,
|
||||
|
Loading…
Reference in New Issue
Block a user