git.annexia.org
/
libguestfs.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
0c06d74
)
add-drive-opts: Correctly handle unreadable and unwritable files (RHBZ#747287).
author
Richard W.M. Jones
<rjones@redhat.com>
Fri, 21 Oct 2011 15:29:20 +0000
(16:29 +0100)
committer
Richard W.M. Jones
<rjones@redhat.com>
Fri, 21 Oct 2011 15:31:19 +0000
(16:31 +0100)
src/launch.c
patch
|
blob
|
history
diff --git
a/src/launch.c
b/src/launch.c
index
ce26e25
..
1988f70
100644
(file)
--- a/
src/launch.c
+++ b/
src/launch.c
@@
-233,17
+233,21
@@
guestfs__config (guestfs_h *g,
* O_DIRECT. This fails on some filesystem types (notably tmpfs).
* So we check if we can open the file with or without O_DIRECT,
* and use cache=off (or not) accordingly.
* O_DIRECT. This fails on some filesystem types (notably tmpfs).
* So we check if we can open the file with or without O_DIRECT,
* and use cache=off (or not) accordingly.
+ *
+ * NB: This function is only called on the !readonly path. We must
+ * try to open with O_RDWR to test that the file is readable and
+ * writable here.
*/
static int
test_cache_off (guestfs_h *g, const char *filename)
{
*/
static int
test_cache_off (guestfs_h *g, const char *filename)
{
- int fd = open (filename, O_RD
ONLY
|O_DIRECT);
+ int fd = open (filename, O_RD
WR
|O_DIRECT);
if (fd >= 0) {
close (fd);
return 1;
}
if (fd >= 0) {
close (fd);
return 1;
}
- fd = open (filename, O_RD
ONLY
);
+ fd = open (filename, O_RD
WR
);
if (fd >= 0) {
close (fd);
return 0;
if (fd >= 0) {
close (fd);
return 0;
@@
-325,7
+329,7
@@
guestfs__add_drive_opts (guestfs_h *g, const char *filename,
}
if (readonly) {
}
if (readonly) {
- if (access (filename,
F
_OK) == -1) {
+ if (access (filename,
R
_OK) == -1) {
perrorf (g, "%s", filename);
free (format);
free (iface);
perrorf (g, "%s", filename);
free (format);
free (iface);
@@
-853,6
+857,13
@@
launch_appliance (guestfs_h *g)
if (r == -1)
goto cleanup1;
if (r == -1)
goto cleanup1;
+ /* NB: We reach here just because qemu has opened the socket. It
+ * does not mean the daemon is up until we read the
+ * GUESTFS_LAUNCH_FLAG below. Failures in qemu startup can still
+ * happen even if we reach here, even early failures like not being
+ * able to open a drive.
+ */
+
close (g->sock); /* Close the listening socket. */
g->sock = r; /* This is the accepted data socket. */
close (g->sock); /* Close the listening socket. */
g->sock = r; /* This is the accepted data socket. */