Fallback to saved ovf-env.xml file

This commit is contained in:
Reyk Floeter 2017-06-29 14:06:58 +02:00
parent 01e02ae0aa
commit 0bd6427d39
2 changed files with 17 additions and 5 deletions

View file

@ -653,17 +653,27 @@ azure_getovfenv(struct system_config *sc)
int mount = 0, ret = -1, fd = -1;
FILE *fp;
/* try to mount the cdrom */
if (shell("mount", "-r", sc->sc_cdrom, "/mnt", NULL) == 0) {
/* Silently try to mount the cdrom */
fd = disable_output(sc, STDERR_FILENO);
ret = shell("mount", "-r", sc->sc_cdrom, "/mnt", NULL);
enable_output(sc, STDERR_FILENO, fd);
fd = -1;
if (ret == 0) {
log_debug("%s: mounted %s", __func__, sc->sc_cdrom);
mount = 1;
}
ret = -1;
if (xml_init(&xml) != 0) {
log_debug("%s: xml", __func__);
goto done;
}
xml_parse(&xml, "/mnt/ovf-env.xml");
/* Fallback to and older ovf-env.xml file */
if (xml_parse(&xml, "/mnt/ovf-env.xml") == -1 &&
xml_parse(&xml, sc->sc_ovfenv) == -1)
goto done;
/* unmount if we mounted the cdrom before */
if (mount && shell("umount", "/mnt", NULL) == 0) {

View file

@ -341,8 +341,10 @@ xml_parse(struct xml *env, const char *file)
void *xml;
ssize_t len;
if ((fd = open(file, O_RDONLY)) == -1)
fatal("open %s", file);
if ((fd = open(file, O_RDONLY)) == -1) {
log_debug("%s: open %s", __func__, file);
return (-1);
}
do {
if ((xml = XML_GetBuffer(parser, BUFSIZ)) == NULL)