[libvirt] [PATCH] storage: Check stderr when matching parted output
Hao Liu
hliu at redhat.com
Wed Dec 10 06:47:18 UTC 2014
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 at redhat.com>
---
src/storage/storage_backend_disk.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/src/storage/storage_backend_disk.c b/src/storage/storage_backend_disk.c
index 4b05e8c..d57b67d 100644
--- a/src/storage/storage_backend_disk.c
+++ b/src/storage/storage_backend_disk.c
@@ -370,16 +370,19 @@ virStorageBackendDiskFindLabel(const char* device)
};
virCommandPtr cmd = virCommandNew(PARTED);
char *output = NULL;
+ char *error = NULL;
int ret = -1;
virCommandAddArgSet(cmd, args);
virCommandAddEnvString(cmd, "LC_ALL=C");
virCommandSetOutputBuffer(cmd, &output);
+ virCommandSetErrorBuffer(cmd, &error);
/* if parted succeeds we have a valid partition table */
ret = virCommandRun(cmd, NULL);
if (ret < 0) {
- if (strstr(output, "unrecognised disk label"))
+ if (strstr(output, "unrecognised disk label") ||
+ strstr(error, "unrecognised disk label"))
ret = 1;
}
--
1.8.3.1
More information about the libvir-list
mailing list