search for: perrorf

Displaying 20 results from an estimated 208 matches for "perrorf".

Did you mean: perror
2020 Feb 26
2
[PATCH] lib: command: switch from select() to poll()
...X (cmd->outfd, maxfd); + fds[1].events = POLLIN; nr_fds++; } while (nr_fds > 0) { - rset2 = rset; - r = select (maxfd+1, &rset2, NULL, NULL, NULL); + r = poll (fds, 2, -1); if (r == -1) { if (errno == EINTR || errno == EAGAIN) continue; - perrorf (cmd->g, "select"); + perrorf (cmd->g, "poll"); + return -1; + } + if (fds[0].revents & POLLERR || fds[1].revents & POLLERR) { + perrorf (cmd->g, "poll"); return -1; } - if (cmd->errorfd >= 0 && FD_IS...
2013 Mar 07
3
[PATCH 0/3] protocol: Abstract out socket operations.
I've been taking a long hard look at the protocol layer. It has evolved over a long time without any particular direction, and the result is, to say the least, not very organized. These patches take a first step at cleaning up the mess by abstracting out socket operations from the rest of the code. The purpose of this is to allow us to slot in a different connection layer under the
2017 Mar 03
2
[PATCH 1/2] Use gnulib set_nonblocking_flag function instead of fcntl.
...e "guestfs.h" #include "guestfs-internal.h" @@ -129,8 +130,8 @@ accept_connection (guestfs_h *g, struct connection *connv) conn->daemon_sock = sock; /* Make sure the new socket is non-blocking. */ - if (fcntl (conn->daemon_sock, F_SETFL, O_NONBLOCK) == -1) { - perrorf (g, "accept_connection: fcntl"); + if (set_nonblocking_flag (conn->daemon_sock, 1) == -1) { + perrorf (g, "accept_connection: set_nonblocking_flag"); return -1; } @@ -438,14 +439,14 @@ guestfs_int_new_conn_socket_listening (guestfs_h *g, assert (daemon_acce...
2017 Sep 12
2
Re: [PATCH v2 2/5] lib: qemu: Factor out common code for reading and writing cache files.
...turn 0; /* no cache, run the test instead */ This will go ahead if access() failed for any other error though; IMHO a better check could be: if (access (filename, R_OK) == -1) { if (errno == ENOENT) return 0; /* no cache, run the test instead */ perrorf (g, "access: %s", filename); return -1; } > +static int > +generic_write_cache (guestfs_h *g, const char *filename, const char *str) > +{ > + CLEANUP_FCLOSE FILE *fp = fopen (filename, "w"); > + if (fp == NULL) { > + perrorf (g, "%s", file...
2013 Mar 07
4
[PATCH 0/4] Small refactorings of the protocol layer.
As the start of work to add remote support, I'm taking a close look at the protocol layer in the library. These are some small cleanups. Rich.
2020 Feb 26
0
Re: [PATCH] lib: command: switch from select() to poll()
...> nr_fds++; > } > > while (nr_fds > 0) { > - rset2 = rset; > - r = select (maxfd+1, &rset2, NULL, NULL, NULL); > + r = poll (fds, 2, -1); > if (r == -1) { > if (errno == EINTR || errno == EAGAIN) > continue; > - perrorf (cmd->g, "select"); > + perrorf (cmd->g, "poll"); > + return -1; > + } > + if (fds[0].revents & POLLERR || fds[1].revents & POLLERR) { > + perrorf (cmd->g, "poll"); > return -1; > } > > -...
2016 Apr 14
2
Re: [PATCH v3 libguestfs] launch: Implement a safer getumask.
On Thu, Apr 14, 2016 at 07:38:23AM -0600, Eric Blake wrote: > > + /* Read the umask. */ > > + if (read (fd[0], &mask, sizeof mask) != sizeof mask) { > > + perrorf (g, "read"); > > + close (fd[0]); > > + return -1; > > Oops - this strands a child process. You have to reap the child, even > if the read() failed. Bleah that was stupid. Try attached version - the only difference is I added a waitpid call to the error path...
2020 Feb 26
1
Re: [PATCH] lib: command: switch from select() to poll()
...; > while (nr_fds > 0) { > > - rset2 = rset; > > - r = select (maxfd+1, &rset2, NULL, NULL, NULL); > > + r = poll (fds, 2, -1); > > if (r == -1) { > > if (errno == EINTR || errno == EAGAIN) > > continue; > > - perrorf (cmd->g, "select"); > > + perrorf (cmd->g, "poll"); > > + return -1; > > + } > > + if (fds[0].revents & POLLERR || fds[1].revents & POLLERR) { > > + perrorf (cmd->g, "poll"); > > return -1...
2014 Feb 13
3
Libguestfs (1.22.6) driver/changes for mingw/win32
Hi, I attached the changes I made to a vanilla libguestfs-1.22.6 in order to make it work in mingw/win32. Added is also the patch required to make QEMU compatible (add a command to QMP that lists the supported devices (the regilat way you do it print it to stderr, which is difficult to redirect in win32)). This is done on behalf of Intel Corp. Thanks, Or (oberon in irc)
2016 Apr 13
3
[PATCH libguestfs] launch: Implement a safer getumask.
...On failure, returns C<-1> and + * sets the error in the guestfs handle. + * + * Thanks to: Josh Stone, Jiri Jaburek, Eric Blake. + */ +int +guestfs_int_getumask (guestfs_h *g) +{ + pid_t pid; + int fd[2], r; + int mask; + int status; + + r = pipe2 (fd, O_CLOEXEC); + if (r == -1) { + perrorf (g, "pipe2"); + return -1; + } + + pid = fork (); + if (pid == -1) { + perrorf (g, "fork"); + close (fd[0]); + close (fd[1]); + return -1; + } + if (pid == 0) { + /* The child process must ONLY call async-safe functions. */ + close (fd[0]); + + mask...
2012 Oct 18
10
[PATCH 0/10] Add a mini-library for running external commands.
Inspired by libvirt's virCommand* internal mini-library, this adds some internal APIs for running commands. The first patch contains the new APIs. The subsequent patches change various parts of the library over to use it. Rich.
2011 Dec 23
4
Remove temporary directories created during appliance building along error paths (RHBZ#769680)
https://bugzilla.redhat.com/show_bug.cgi?id=769680
2017 Sep 12
0
[PATCH v2 2/5] lib: qemu: Factor out common code for reading and writing cache files.
...*qemu_help_filename = NULL, *qemu_devices_filename = NULL; - int generation; - uint64_t prev_size, prev_mtime; + struct qemu_data *data; + CLEANUP_FREE char *cachedir = NULL; + CLEANUP_FREE char *stat_filename = NULL; + int r; + size_t i; if (stat (g->hv, &statbuf) == -1) { perrorf (g, "stat: %s", g->hv); @@ -89,165 +126,198 @@ guestfs_int_test_qemu (guestfs_h *g) if (cachedir == NULL) return NULL; - qemu_stat_filename = safe_asprintf (g, "%s/qemu.stat", cachedir); - qemu_help_filename = safe_asprintf (g, "%s/qemu.help", cachedir);...
2015 May 29
2
[PATCH 1/3] inspection: Add func for merging fs inspections
...(; dst->drive_mappings[n] != NULL; n++) + ; + old = n; + for (; src->drive_mappings[n] != NULL; n++) + ; + + /* Merge the src mappings to dst */ + mappings = realloc (dst->drive_mappings, (n + 1) * sizeof (char *)); + if (mappings == NULL) { + perrorf (g, "realloc"); + return -1; + } + + for (i = old; i < n; i++) + mappings[i] = src->drive_mappings[i - old]; + + mappings[n] = NULL; + dst->drive_mappings = mappings; + + free(src->drive_mappings); + src->drive_mappings = NULL; +...
2016 Apr 14
2
[PATCH v3 libguestfs] launch: Implement a safer getumask.
...On failure, returns C<-1> and + * sets the error in the guestfs handle. + * + * Thanks to: Josh Stone, Jiri Jaburek, Eric Blake. + */ +int +guestfs_int_getumask (guestfs_h *g) +{ + pid_t pid; + int fd[2], r; + int mask; + int status; + + r = pipe2 (fd, O_CLOEXEC); + if (r == -1) { + perrorf (g, "pipe2"); + return -1; + } + + pid = fork (); + if (pid == -1) { + perrorf (g, "fork"); + close (fd[0]); + close (fd[1]); + return -1; + } + if (pid == 0) { + /* The child process must ONLY call async-safe functions. */ + close (fd[0]); + + /* um...
2015 Sep 29
8
[PATCH 0/7] copy-in/copy-out: Capture errors from tar subprocess (RHBZ#1267032).
Commits 3c27f3d91e1566854747bbe844186783fc84f3a8 and 1b6f0daa9ae7fcc94e389232d0c397816cda973d added an internal API for running commands asynchronously. It is only used by the copy-in and copy-out APIs. Unfortunately this made the command code very complex: it was almost impossible to redirect stderr to a file, and there were a lot of long-range dependencies through the file. It was also buggy:
2016 Apr 13
0
Re: [PATCH libguestfs] launch: Implement a safer getumask.
...handle. > + * > + * Thanks to: Josh Stone, Jiri Jaburek, Eric Blake. > + */ > +int > +guestfs_int_getumask (guestfs_h *g) > +{ > + pid_t pid; > + int fd[2], r; > + int mask; > + int status; > + > + r = pipe2 (fd, O_CLOEXEC); > + if (r == -1) { > + perrorf (g, "pipe2"); > + return -1; > + } > + > + pid = fork (); > + if (pid == -1) { > + perrorf (g, "fork"); > + close (fd[0]); > + close (fd[1]); > + return -1; > + } > + if (pid == 0) { > + /* The child process must ONLY ca...
2014 Oct 31
1
[PATCH] launch: libvirt: Implement drive secrets (RHBZ#1159016).
...Ptr secret = NULL; + size_t i; + + if (drv->src.secret == NULL) + return 0; + + /* If it was already stored, don't create another secret. */ + if (have_secret (g, data, drv)) + return 0; + + /* Create the XML for the secret. */ + xb = xmlBufferCreate (); + if (xb == NULL) { + perrorf (g, "xmlBufferCreate"); + return -1; + } + ob = xmlOutputBufferCreateBuffer (xb, NULL); + if (ob == NULL) { + perrorf (g, "xmlOutputBufferCreateBuffer"); + return -1; + } + xo = xmlNewTextWriter (ob); + if (xo == NULL) { + perrorf (g, "xmlNewTextWriter&quo...
2016 Mar 29
3
[PATCH 0/2] added filesystem_walk API
The filesystem_walk API parses the FS internals of a partition and returns a list of all the files and directories contained within. It list deleted files and directories as well. For each node, it reports its relative path, its inode and its allocation status. This is the end user API for inspecting a disk partition content. The command can handle filenames with special characters. Example
2018 Feb 14
1
[PATCH] inspector: rpm summary and description may not be utf-8
...f8_utf8 = (iconv_t)(-1); + iconv_t cd_utf8_latin1 = (iconv_t)(-1); + size_t in_left, out_left, res; + char *in_ptr; + char *out_ptr; + char *output = NULL; + char *result = NULL; + + cd_utf8_utf8 = iconv_open("UTF-8", "UTF-8"); + if (cd_utf8_utf8 == (iconv_t)(-1)) { + perrorf(g, "No iconv UTF-8 encoding"); + goto cleanup; + } + + in_ptr = input; + in_left = strlen(input) + 1; + out_left = in_left * 4; + output = safe_malloc(g, out_left); + out_ptr = output; + + res = iconv(cd_utf8_utf8, &in_ptr, &in_left, &out_ptr, &out_left); + if (...