mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-03-07 17:28:15 +00:00
storage: Check stderr when matching parted output
In old version of parted like parted-2.1-25, error message is shown in stdout when printing a disk info without disk label. Error: /dev/sda: unrecognised disk label This line has been moved to stderr in newer version of parted. So we should check both stdout and stderr when locating this message. This should fix bug: https://bugzilla.redhat.com/show_bug.cgi?id=1172468 Signed-off-by: Hao Liu <hliu@redhat.com>
This commit is contained in:
parent
57023c0a3a
commit
9788007892
@ -370,21 +370,26 @@ virStorageBackendDiskFindLabel(const char* device)
|
|||||||
};
|
};
|
||||||
virCommandPtr cmd = virCommandNew(PARTED);
|
virCommandPtr cmd = virCommandNew(PARTED);
|
||||||
char *output = NULL;
|
char *output = NULL;
|
||||||
|
char *error = NULL;
|
||||||
int ret = -1;
|
int ret = -1;
|
||||||
|
|
||||||
virCommandAddArgSet(cmd, args);
|
virCommandAddArgSet(cmd, args);
|
||||||
virCommandAddEnvString(cmd, "LC_ALL=C");
|
virCommandAddEnvString(cmd, "LC_ALL=C");
|
||||||
virCommandSetOutputBuffer(cmd, &output);
|
virCommandSetOutputBuffer(cmd, &output);
|
||||||
|
virCommandSetErrorBuffer(cmd, &error);
|
||||||
|
|
||||||
/* if parted succeeds we have a valid partition table */
|
/* if parted succeeds we have a valid partition table */
|
||||||
ret = virCommandRun(cmd, NULL);
|
ret = virCommandRun(cmd, NULL);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
if (strstr(output, "unrecognised disk label"))
|
if (strstr(output, "unrecognised disk label") ||
|
||||||
|
strstr(error, "unrecognised disk label")) {
|
||||||
ret = 1;
|
ret = 1;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
virCommandFree(cmd);
|
virCommandFree(cmd);
|
||||||
VIR_FREE(output);
|
VIR_FREE(output);
|
||||||
|
VIR_FREE(error);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user