aboutsummaryrefslogtreecommitdiff
path: root/cutils.c
diff options
context:
space:
mode:
Diffstat (limited to 'cutils.c')
-rw-r--r--cutils.c12
1 files changed, 12 insertions, 0 deletions
diff --git a/cutils.c b/cutils.c
index c91f88732e..5d995bc4e5 100644
--- a/cutils.c
+++ b/cutils.c
@@ -415,3 +415,15 @@ int64_t strtosz(const char *nptr, char **end)
{
return strtosz_suffix(nptr, end, STRTOSZ_DEFSUFFIX_MB);
}
+
+int qemu_parse_fd(const char *param)
+{
+ int fd;
+ char *endptr = NULL;
+
+ fd = strtol(param, &endptr, 10);
+ if (*endptr || (fd == 0 && param == endptr)) {
+ return -1;
+ }
+ return fd;
+}