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);
|
autostart = (autostart != 0);
|
||||||
|
|
||||||
if (vm->autostart != autostart) {
|
if (vm->autostart != autostart) {
|
||||||
if ((configFile = virDomainConfigFile(BHYVE_CONFIG_DIR, vm->def->name)) == NULL)
|
configFile = virDomainConfigFile(BHYVE_CONFIG_DIR, vm->def->name);
|
||||||
goto cleanup;
|
autostartLink = virDomainConfigFile(BHYVE_AUTOSTART_DIR, vm->def->name);
|
||||||
if ((autostartLink = virDomainConfigFile(BHYVE_AUTOSTART_DIR, vm->def->name)) == NULL)
|
|
||||||
goto cleanup;
|
|
||||||
|
|
||||||
if (autostart) {
|
if (autostart) {
|
||||||
if (g_mkdir_with_parents(BHYVE_AUTOSTART_DIR, 0777) < 0) {
|
if (g_mkdir_with_parents(BHYVE_AUTOSTART_DIR, 0777) < 0) {
|
||||||
|
@ -29002,8 +29002,7 @@ virDomainDefSaveXML(virDomainDef *def,
|
|||||||
if (!configDir)
|
if (!configDir)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
if ((configFile = virDomainConfigFile(configDir, def->name)) == NULL)
|
configFile = virDomainConfigFile(configDir, def->name);
|
||||||
return -1;
|
|
||||||
|
|
||||||
if (g_mkdir_with_parents(configDir, 0777) < 0) {
|
if (g_mkdir_with_parents(configDir, 0777) < 0) {
|
||||||
virReportSystemError(errno,
|
virReportSystemError(errno,
|
||||||
@ -29060,11 +29059,8 @@ virDomainDeleteConfig(const char *configDir,
|
|||||||
g_autofree char *configFile = NULL;
|
g_autofree char *configFile = NULL;
|
||||||
g_autofree char *autostartLink = NULL;
|
g_autofree char *autostartLink = NULL;
|
||||||
|
|
||||||
if ((configFile = virDomainConfigFile(configDir, dom->def->name)) == NULL)
|
configFile = virDomainConfigFile(configDir, dom->def->name);
|
||||||
return -1;
|
autostartLink = virDomainConfigFile(autostartDir, dom->def->name);
|
||||||
if ((autostartLink = virDomainConfigFile(autostartDir,
|
|
||||||
dom->def->name)) == NULL)
|
|
||||||
return -1;
|
|
||||||
|
|
||||||
/* Not fatal if this doesn't work */
|
/* Not fatal if this doesn't work */
|
||||||
unlink(autostartLink);
|
unlink(autostartLink);
|
||||||
|
@ -492,16 +492,14 @@ virDomainObjListLoadConfig(virDomainObjList *doms,
|
|||||||
int autostart;
|
int autostart;
|
||||||
g_autoptr(virDomainDef) oldDef = NULL;
|
g_autoptr(virDomainDef) oldDef = NULL;
|
||||||
|
|
||||||
if ((configFile = virDomainConfigFile(configDir, name)) == NULL)
|
configFile = virDomainConfigFile(configDir, name);
|
||||||
return NULL;
|
|
||||||
if (!(def = virDomainDefParseFile(configFile, xmlopt, NULL,
|
if (!(def = virDomainDefParseFile(configFile, xmlopt, NULL,
|
||||||
VIR_DOMAIN_DEF_PARSE_INACTIVE |
|
VIR_DOMAIN_DEF_PARSE_INACTIVE |
|
||||||
VIR_DOMAIN_DEF_PARSE_SKIP_VALIDATE |
|
VIR_DOMAIN_DEF_PARSE_SKIP_VALIDATE |
|
||||||
VIR_DOMAIN_DEF_PARSE_ALLOW_POST_PARSE_FAIL)))
|
VIR_DOMAIN_DEF_PARSE_ALLOW_POST_PARSE_FAIL)))
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
if ((autostartLink = virDomainConfigFile(autostartDir, name)) == NULL)
|
autostartLink = virDomainConfigFile(autostartDir, name);
|
||||||
return NULL;
|
|
||||||
|
|
||||||
autostart = virFileLinkPointsTo(autostartLink, configFile);
|
autostart = virFileLinkPointsTo(autostartLink, configFile);
|
||||||
|
|
||||||
@ -529,8 +527,7 @@ virDomainObjListLoadStatus(virDomainObjList *doms,
|
|||||||
virDomainObj *obj = NULL;
|
virDomainObj *obj = NULL;
|
||||||
char uuidstr[VIR_UUID_STRING_BUFLEN];
|
char uuidstr[VIR_UUID_STRING_BUFLEN];
|
||||||
|
|
||||||
if ((statusFile = virDomainConfigFile(statusDir, name)) == NULL)
|
statusFile = virDomainConfigFile(statusDir, name);
|
||||||
goto error;
|
|
||||||
|
|
||||||
if (!(obj = virDomainObjParseFile(statusFile, xmlopt,
|
if (!(obj = virDomainObjParseFile(statusFile, xmlopt,
|
||||||
VIR_DOMAIN_DEF_PARSE_STATUS |
|
VIR_DOMAIN_DEF_PARSE_STATUS |
|
||||||
|
@ -4656,10 +4656,8 @@ libxlDomainSetAutostart(virDomainPtr dom, int autostart)
|
|||||||
autostart = (autostart != 0);
|
autostart = (autostart != 0);
|
||||||
|
|
||||||
if (vm->autostart != autostart) {
|
if (vm->autostart != autostart) {
|
||||||
if (!(configFile = virDomainConfigFile(cfg->configDir, vm->def->name)))
|
configFile = virDomainConfigFile(cfg->configDir, vm->def->name);
|
||||||
goto endjob;
|
autostartLink = virDomainConfigFile(cfg->autostartDir, vm->def->name);
|
||||||
if (!(autostartLink = virDomainConfigFile(cfg->autostartDir, vm->def->name)))
|
|
||||||
goto endjob;
|
|
||||||
|
|
||||||
if (autostart) {
|
if (autostart) {
|
||||||
if (g_mkdir_with_parents(cfg->autostartDir, 0777) < 0) {
|
if (g_mkdir_with_parents(cfg->autostartDir, 0777) < 0) {
|
||||||
|
@ -196,9 +196,7 @@ static virLXCController *virLXCControllerNew(const char *name)
|
|||||||
if (!(driver = virLXCControllerDriverNew()))
|
if (!(driver = virLXCControllerDriverNew()))
|
||||||
goto error;
|
goto error;
|
||||||
|
|
||||||
if ((configFile = virDomainConfigFile(LXC_STATE_DIR,
|
configFile = virDomainConfigFile(LXC_STATE_DIR, ctrl->name);
|
||||||
ctrl->name)) == NULL)
|
|
||||||
goto error;
|
|
||||||
|
|
||||||
if ((ctrl->vm = virDomainObjParseFile(configFile,
|
if ((ctrl->vm = virDomainObjParseFile(configFile,
|
||||||
driver->xmlopt,
|
driver->xmlopt,
|
||||||
|
@ -2439,14 +2439,8 @@ static int lxcDomainSetAutostart(virDomainPtr dom,
|
|||||||
goto endjob;
|
goto endjob;
|
||||||
}
|
}
|
||||||
|
|
||||||
configFile = virDomainConfigFile(cfg->configDir,
|
configFile = virDomainConfigFile(cfg->configDir, vm->def->name);
|
||||||
vm->def->name);
|
autostartLink = virDomainConfigFile(cfg->autostartDir, vm->def->name);
|
||||||
if (configFile == NULL)
|
|
||||||
goto endjob;
|
|
||||||
autostartLink = virDomainConfigFile(cfg->autostartDir,
|
|
||||||
vm->def->name);
|
|
||||||
if (autostartLink == NULL)
|
|
||||||
goto endjob;
|
|
||||||
|
|
||||||
if (autostart) {
|
if (autostart) {
|
||||||
if (g_mkdir_with_parents(cfg->autostartDir, 0777) < 0) {
|
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)
|
if (virDomainObjBeginJob(vm, VIR_JOB_MODIFY) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
if (!(configFile = virDomainConfigFile(cfg->configDir, vm->def->name)))
|
configFile = virDomainConfigFile(cfg->configDir, vm->def->name);
|
||||||
goto endjob;
|
autostartLink = virDomainConfigFile(cfg->autostartDir, vm->def->name);
|
||||||
|
|
||||||
if (!(autostartLink = virDomainConfigFile(cfg->autostartDir,
|
|
||||||
vm->def->name)))
|
|
||||||
goto endjob;
|
|
||||||
|
|
||||||
if (autostart) {
|
if (autostart) {
|
||||||
if (g_mkdir_with_parents(cfg->autostartDir, 0777) < 0) {
|
if (g_mkdir_with_parents(cfg->autostartDir, 0777) < 0) {
|
||||||
@ -18345,21 +18341,15 @@ qemuDomainRenameCallback(virDomainObj *vm,
|
|||||||
|
|
||||||
new_dom_name = g_strdup(new_name);
|
new_dom_name = g_strdup(new_name);
|
||||||
|
|
||||||
if (!(new_dom_cfg_file = virDomainConfigFile(cfg->configDir,
|
new_dom_cfg_file = virDomainConfigFile(cfg->configDir, new_dom_name);
|
||||||
new_dom_name)) ||
|
old_dom_cfg_file = virDomainConfigFile(cfg->configDir, vm->def->name);
|
||||||
!(old_dom_cfg_file = virDomainConfigFile(cfg->configDir,
|
|
||||||
vm->def->name)))
|
|
||||||
return -1;
|
|
||||||
|
|
||||||
if (qemuDomainNamePathsCleanup(cfg, new_name, false) < 0)
|
if (qemuDomainNamePathsCleanup(cfg, new_name, false) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
if (vm->autostart) {
|
if (vm->autostart) {
|
||||||
if (!(new_dom_autostart_link = virDomainConfigFile(cfg->autostartDir,
|
new_dom_autostart_link = virDomainConfigFile(cfg->autostartDir, new_dom_name);
|
||||||
new_dom_name)) ||
|
old_dom_autostart_link = virDomainConfigFile(cfg->autostartDir, vm->def->name);
|
||||||
!(old_dom_autostart_link = virDomainConfigFile(cfg->autostartDir,
|
|
||||||
vm->def->name)))
|
|
||||||
return -1;
|
|
||||||
|
|
||||||
if (symlink(new_dom_cfg_file, new_dom_autostart_link) < 0) {
|
if (symlink(new_dom_cfg_file, new_dom_autostart_link) < 0) {
|
||||||
virReportSystemError(errno,
|
virReportSystemError(errno,
|
||||||
|
Loading…
Reference in New Issue
Block a user