| Commit message (Collapse) | Author | Age | Files | Lines |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
This commit uses the Gnulib 'lock' module to implement a mutex on
the global list of handles which is stored by the library.
Note that Gnulib nicely avoids explicitly linking with -lpthread
unless the application program itself links to -lpthread. Locks
are only enabled in multithreaded applications.
$ ldd src/.libs/libguestfs.so.0.217.0
linux-vdso.so.1 => (0x00007fffcb7ff000)
libc.so.6 => /lib64/libc.so.6 (0x00007f96a4e6c000)
/lib64/ld-linux-x86-64.so.2 (0x00007f96a544d000)
Please enter the commit message for your changes. Lines starting
|
|
|
|
|
| |
Move these to private header file(s) and other places as required
since these aren't part of the public API.
|
| |
|
|
|
|
|
| |
In verbose mode, print timestamped messages during guestfs_launch
so we can see how long each step takes.
|
|
|
|
|
|
|
|
|
|
| |
The guest handle field start_t was previously used (when we
had the wait_ready call), but had fallen into disuse. Note
that it could never be accessed through the API.
Rename this field as launch_t, convert it to a timeval, and
use it to measure the time since guestfs_launch was called
so that we can start profiling guest launch.
|
| |
|
|
|
|
|
| |
git grep -l 'strcmp *([^=]*== *0'|xargs \
perl -pi -e 's/\bstrcmp( *\(.*?\)) *== *0/STREQ$1/g'
|
| |
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* cfg.mk (disable_temporarily): Don't disable sc_avoid_ctype_macros.
* fish/tilde.c: Remove unnecessary inclusion of ctype.h.
* bootstrap: Add gnulib's c-ctype module to the list.
* daemon/m4/gnulib-cache.m4: Likewise.
* daemon/ext2.c: Include "c-ctype.h", not <ctype.h>.
Use c_isspace, etc, rather than isspace.
* daemon/guestfsd.c: Likewise.
* daemon/lvm.c: Likewise.
* daemon/proto.c: Likewise.
* fish/fish.c: Likewise.
* fish/tilde.c: Likewise.
* src/generator.ml: Likewise.
* src/guestfs.c: Likewise.
* examples/to-xml.c: Likewise.
* examples/Makefile.am (to_xml_CPPFLAGS): Add -I$(top_srcdir)/gnulib/lib
so inclusion of "c-ctype.h" works.
(to_xml_CPPFLAGS): Rename from to_xml_CFLAGS.
|
|
|
|
|
|
|
|
| |
When the g->direct flag is set, the appliance stdin/stdout
are not connected to the library. Instead they inherit the
stdin/stdout of the caller.
This is used to implement virt-rescue.
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
This commit removes the requirement for vmchannel, although retaining
support for it.
In this configuration, known as "null vmchannel", the library
listens on a random loopback port. It passes the number of this
port to the appliance (guestfs_vmchannel=tcp:10.0.2.2:12345), and
the daemon then connects back. The library, instead of connecting,
listens and accepts the connection during guestfs_launch.
QEMU SLIRP (user mode networking) is still required to make this
work: SLIRP forwards the TCP connection transparently (instead of
explicitly as with guestfwd) to 127.0.0.1:<port>
There is a window in which any other local process on the machine
could see the port number in the qemu command line and try to
connect to it. This would be a devastating security hole, because
any local process could pretend to be the daemon and feed back
malicious replies to our remote procedure calls. To prevent this,
we check the UID of the other side of the TCP connection. If
the UID is different from the library's EUID, then we reject the
connection. To do this we have to parse /proc/net/tcp. (On Solaris
we could use getsockopt (SO_PEERCRED), but this doesn't work on
Linux TCP sockets).
Other vmchannel(s) are still supported. This is important, because
we can't in general be sure the qemu will always support SLIRP.
In particular, in recent versions of qemu it is possible to compile
out SLIRP.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
This reimplements parts of commit da0a4f8d1f6ddd302ceba028d87c6e009589e503
in a different, but compatible way.
We pass guestfs_vmchannel=tcp:<ip>:<port> on the command line. This
is intended to be used as follows (now and in future versions):
tcp:10.0.2.4:6666 for guestfwd vmchannel
tcp:10.0.2.2:<port> for future "no vmchannel" implementation
/dev/vcon4 for future virtio-console vmchannel*
It also accepts the old-style guestfs=10.0.2.4:6666 parameter which
is sent by older libraries, and turns this transparently into the
correct format above.
If no guestfs_vmchannel is passed, then this defaults to the guestfwd
vmchannel which older libraries would expect.
* Maybe this last one should be dev:/dev/vcon4 or file:/dev/vcon4, but
we don't need to decide that now.
|
| |
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
This commit changes guestfs_launch so that it both launches
the appliance and waits until it is ready (ie. the daemon communicates
back to us).
Since we removed the pretence that we could implement a low-level
asynchronous API, the need to call launch() followed by wait_ready()
has looked a bit silly.
Now guestfs_wait_ready() is basically a no-op. It is left in the
API for backwards compatibility. Any calls to guestfs_wait_ready()
can be removed from client code.
|
|
|
|
|
|
|
| |
buf[], append[] and memsize_str[] were all temporary buffers
used in non-overlapping code.
Combine them to use a single buffer (buf[]).
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
| |
Newer versions of qemu have changed the command line format
(again). '-net channel' is now deprecated. Instead we use:
-chardev socket,id=guestfsvmc,path=/path/to/sock,server,nowait
-net user,vlan=0,net=10.0.2.0/8,guestfwd=tcp:10.0.2.4:6666-chardev:guestfsvmc
-net nic,model=ne2k_pci,vlan=0
The old style format is still used if the new style is not
detected at runtime.
|
|
|
|
|
|
|
|
|
|
| |
Since we control the appliance tightly, we can just specify
that it will always use a particular host and port, and we
don't need to pass it on the command line each time.
Also the VMCHANNEL_* constants are only relevant to the
particular guestfwd vmchannel implementation, so we rename
them as GUESTFWD_*.
|
|
|
|
|
|
|
|
|
|
| |
Add the configure parameter --enable-packet-dump so that this
code can be enabled without editing the source.
This code is normally commented out, because it is too verbose
unless you happen to be debugging the underlying protocol. Because
it is normally commented out, I found it had bit-rotted slightly.
This commit also fixes the obvious problems.
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
This commit removes the external main loop, which never worked
and caused a number of bugs. Requests are now done synchronously,
and if the user wants to have requests issued in the background
or to have a responsive GUI, then they'll just have to use threads.
The big change is to push all reads and writes through two
functions called send_to_daemon (for writes) and recv_from_daemon
(for reads) which operate synchronously. These functions
read/write whole messages, and also handle checking for EOF
(ie. daemon died) and asynchronous log message events from
qemu (eg. from debug / dmesg printed by the guest). A more
complete description of how these work can be found in the code.
This code passes a complete run of the tests.
Bugs believed to be fixed by this commit:
https://bugzilla.redhat.com/show_bug.cgi?id=501888
internal error: reply callback called twice
https://bugzilla.redhat.com/show_bug.cgi?id=504418
In virt-inspector: "download: guestfs_download reply failed, see earlier error messages"
I have tried to avoid reintroducing this:
https://bugzilla.redhat.com/show_bug.cgi?id=508713
libguestfs: error: write: Broken pipe (guestfish only)
One other benefit of this is that 'set_busy/end_busy' calls
no longer appear in traces.
|
|
|
|
|
| |
Enable this by calling guestfs_trace (handle, 1) or by
setting the LIBGUESTFS_TRACE=1 environment variable.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Previously non-daemon actions were called directly by
user code, eg:
/* Non-generated */
int
guestfs_set_verbose (guestfs_h *g, int v)
{
g->verbose = !!v;
return 0;
}
This changes these actions so they go indirectly via
some generated code, eg:
/* Generated */
int guestfs_set_verbose (guestfs_h *g,
int verbose)
{
return guestfs__set_verbose (g, verbose);
}
/* Non-generated */
int
guestfs__set_verbose (guestfs_h *g, int v)
{
g->verbose = !!v;
return 0;
}
The aim is to have a place in the generated code where
we can add debug or tracing information for these non-
daemon calls.
|
|
|
|
|
| |
* src/guestfs.c (guestfs__receive_file_sync): Don't set "r",
only to ignore it.
|
|
|
|
|
|
|
|
|
|
|
|
| |
Now that we're using gnulib in earnest, any manual definition
would provoke a redefinition warning.
* fish/fish.c (_GNU_SOURCE): Don't define.
* fish/destpaths.c (_GNU_SOURCE): Likewise.
* src/guestfs.c (_GNU_SOURCE): Likewise.
* bootstrap (modules): Add asprintf, strchrnul, strerror, strndup
and vasprintf.
* fish/fish.c (main): Set argv[0] to sanitized program_name, so
functions like getopt_long that use argv[0] use the clean name.
|
| |
|
| |
|
|
|
|
|
| |
GCC 4.4.1 warns about some unused macros. Comment these out
while they are not used.
|
|
|
|
|
|
|
| |
Even though these functions are marked as "not implemented yet",
and they will surely return a value once implemented, ...
* src/guestfs.c (select_add_timeout): Declare with noreturn attribute.
(select_remove_timeout): Likewise.
|
|
|
|
| |
* src/guestfs.c (guestfs_end_busy): Add a "default:" label.
|
|
|
|
|
| |
* src/guestfs.c [struct guestfs_h] (msg_in_size, msg_in_allocated):
(msg_out_size, msg_out_allocated): Change type from int to unsigned int.
|
|
|
|
| |
* src/guestfs.c (receive_file_data_sync, xread, xwrite): Use char*.
|
|
|
|
| |
* src/guestfs.c (guestfs_launch): Handle dup failure.
|
|
|
|
|
|
|
|
|
| |
* bootstrap (modules): Add ignore-value.
* src/guestfs.c: Include "ignore-value.h".
(stdout_event): Ignore failure to write to stderr.
Also, prefer STDERR_FILENO over the literal "2".
* src/Makefile.am (libguestfs_la_CPPFLAGS): Include gnulib's .h files.
(libprotocol_la_CFLAGS): Remove -Wall -Wno-unused.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
If you use the guestfs_add_drive function, then currently it
generates a qemu command line element like:
-drive ...,cache=off,...
This causes qemu to try to open the device with O_DIRECT.
Unfortunately some filesystems don't support this flag, notably tmpfs,
which means you can't use libguestfs in conjunction with tmpfs. On
some systems /tmp is a tmpfs filesystem.
This patch fixes this so that if the filesystem doesn't support
O_DIRECT, then we omit the cache=off parameter. This seems reasonable
from a reliability point of view, because if you're using tmpfs then
you probably didn't expect reliability in the case where your system
suddenly powers off.
|
|
|
|
| |
Adds new API calls to set and get this flags.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Change the way the qemu command is displayed to look like
this:
/usr/bin/qemu-kvm \
-drive file=/tmp/test.img,cache=off,if=virtio \
-m 500 \
-no-reboot \
-kernel /tmp/libguestfsHBJHRh/kernel \
-initrd /tmp/libguestfsHBJHRh/initrd \
[...]
This allows the command line to be copied and pasted directly
into the shell, and also makes it simpler to read.
|
|
|
|
|
|
|
|
| |
Add ./configure --with-net-if=(virtio|ne2k_pci) option.
This lets you workaround the following virtio_net bug:
https://bugzilla.redhat.com/show_bug.cgi?id=516022
|
|
|
|
|
| |
This allows people to use the ne2k-pci network driver, for those
situations where the virtio_net driver is broken (cough 516022 cough).
|
|
|
|
|
|
| |
Use:
-net user,vlan=0,net=10.0.2.0/8
just to make the (already implicit) 10.0.2.x network explicit.
|
|
|
|
|
|
|
|
|
|
|
| |
Do it by running this command:
[exempted files are matched via .x-sc_TAB_in_indentation]
git ls-files \
| pcregrep -vf .x-sc_TAB_in_indentation \
| xargs pcregrep -l '^ *\t' \
| xargs perl -MText::Tabs -ni -le \
'$m=/^( *\t[ \t]*)(.*)/; print $m ? expand($1) . $2 : $_'
|
|
|
|
|
| |
* src/guestfs.c (guestfs_perrorf): Rename former err to errnum,
to avoid compilation error.
|
|
|
|
| |
* src/guestfs.c (guestfs_perrorf): Handle failed vasprintf.
|
|
|
|
|
|
|
|
|
|
|
| |
SELinux exists in a very disturbed state if it is enabled at
boot time, but no policy is loaded. In particular, it messes
up the security.selinux extended attributes on files in a
not-very-useful way.
We can't enable SELinux because we don't know what policy
can or should be loaded. Therefore it's best to disable it
completely.
|
| |
|
|
|
|
|
|
| |
appliance kernel."
This reverts commit 34d2df41626f1ee4172a6d40b06d72d6ed9d6348.
|
|
|
|
|
| |
This allows you to override the appliance kernel with an easy
command or environment variable.
|