summaryrefslogtreecommitdiffstats
path: root/src/launch.c
Commit message (Collapse)AuthorAgeFilesLines
* virtio-scsi: Increase udev timeout.Richard W.M. Jones2012-06-141-1/+1
| | | | | In Koji, when you've got 200+ disks, udev times out before all the udev events have been processed.
* New API: guestfs_max_disks.Richard W.M. Jones2012-06-131-0/+10
| | | | Returns the maximum number of disks that may be added to a handle.
* virtio-scsi: Fix disk name calculation.Richard W.M. Jones2012-06-131-2/+3
| | | | This fixes commit 0c0a7d0d868d153adf0600189f771459e1068b0a.
* appliance: Add support for virtio-scsi.Richard W.M. Jones2012-06-121-24/+116
| | | | This requires febootstrap >= 3.15.
* Record output of qemu -device '?'.Richard W.M. Jones2012-06-121-0/+9
| | | | | This allows us to find out what qemu devices are supported at runtime.
* Require QEMU >= 1.0.Richard W.M. Jones2012-06-121-22/+5
| | | | | | | | | | | QEMU 1.0 was released at the end of 2011. Remove all the cruft about detecting broken -machine type which was only required for QEMU 0.15. This also reverts commit 30ecbf3ec2ada68f7e125a180553e31b069033b7. Even on ARM you can pass -machine accel=kvm:tcg and qemu does the right thing, so I'm not sure why we wanted to disable that.
* Remove ./configure --with-drive-if and --with-net-if options.Richard W.M. Jones2012-06-121-6/+7
| | | | | | | | | | | | These were used to select the default drive and network interface. They both default to 'virtio'. These were added back in the day when virtio was buggy, so that packagers could revert to using ide/ne2k_pci to work around distro bugs. However virtio has been stable in qemu for a very long time, so it seems unlikely that any packager would need to use these, and in any case it would be better to do this detection at runtime (cf. for virtio-scsi).
* arm: Use #if defined instead of #ifdef.Richard W.M. Jones2012-06-061-1/+1
| | | | No functional change.
* ppc64: Avoid "defined by not used" warning for is_openable function.Richard W.M. Jones2012-06-021-0/+4
|
* qemu: Move -nodefaults etc logically together.Richard W.M. Jones2012-05-121-16/+16
| | | | This is just code motion.
* arm: Add configure flag '--with-qemu-options'.Richard W.M. Jones2012-05-121-0/+65
| | | | | | | This flag allows extra QEMU options to be passed on the command line. This is useful mainly on arm (see the notes in the updated README file).
* arm: Disable -machine, -enable-kvm options except on x86, x86-64.Richard W.M. Jones2012-05-121-0/+5
| | | | | | | Presently KVM is only applicable to x86 and x86-64 (although that will change in future, and there are rumoured to be implementations for some current non-x86 architectures). In any case having these options breaks ARM, so disable them for non-x86 architectures at the moment.
* arm: On Linux ARM kernels, the serial console is ttyAMA0.Richard W.M. Jones2012-05-121-1/+7
| | | | Cope with unnecessary lack of standardization.
* arm: Disable test for -no-hpet during launch.Richard W.M. Jones2012-05-121-0/+8
|
* lib: Remove the BUSY state.Richard W.M. Jones2012-04-261-1/+2
| | | | | | | | | | | | | | | Originally this state was intended so that in some way you could find out if the appliance was running a command. However there was never a thread-safe way to access the state of the handle, so in effect you could never do anything useful safely with this information. This commit completely removes the BUSY state. The only visible change is to the guestfs_is_busy API. Previously you could never call this safely from another thread. If you called it from the same thread it would always return false (since the current thread can't be running a libguestfs command at that point by definition). Now it always returns false.
* lib: Escape , as ,, on qemu command line (RHBZ#811649).Richard W.M. Jones2012-04-121-3/+16
|
* lib: Remove check_path function, limitation is colon, not comma (RHBZ#811649).Richard W.M. Jones2012-04-121-12/+8
| | | | | | | | | | | | | | | Remove the bogus check_path function and move the functionality into the two places where it was being used. qemu -cdrom , works fine, I tested it. Colon cannot be used in a block device filename anywhere, since the qemu block driver interprets it as a prefix. There is no known way to work around this problem. I checked this is true with kwolf. Comma is fine in -drive options, provided it is escaped by doubling it.
* Revert "launch: don't add a drive twice"Richard W.M. Jones2012-04-121-19/+2
| | | | This reverts commit be47b66c3033105a2b880dbc10bfc2b163b7eafe.
* launch: Set error when qemu fails early during launch (RHBZ#811650).Richard W.M. Jones2012-04-111-1/+4
| | | | | This caused the Python bindings (and probably others) to segfault because guestfs_last_error(g) would return NULL.
* Use O_CLOEXEC / SOCK_CLOEXEC for almost all file descriptors.Richard W.M. Jones2012-03-141-4/+4
| | | | | | | | | | | | | | | | | | | | | | | | The presumption is that all file descriptors should be created with the close-on-exec flag set. The only exception are file descriptors that we want passed through to exec'd subprocesses (mainly pipes and stdin/stdout/stderr). For open calls, we pass O_CLOEXEC as an extra flag, eg: fd = open ("foo", O_RDONLY|O_CLOEXEC); This is a Linux-ism, but using a macro we can easily make it portable. For sockets, similarly: sock = socket (..., SOCK_STREAM|SOCK_CLOEXEC, ...); For accepted sockets, we use the Linux accept4 system call which allows flags to be supplied, but we use the Gnulib 'accept4' module to make this portable. For dup, dup2, we use the Linux dup3 system call, and the Gnulib modules 'dup3' and 'cloexec'.
* lib: Remove some unused variables.Richard W.M. Jones2012-03-121-1/+0
|
* Close all file descriptors and remove all signal handlers in the recovery ↵Richard W.M. Jones2012-03-091-0/+25
| | | | | | | | | | | | | | | | | process. If the parent process uses a pipe (or any fd, but pipes are a particular problem), then the recovery process would hold open the file descriptor(s) of the pipe, meaning that it could not be fully closed in the parent. Because the recovery process doesn't use exec(2), this wasn't avoidable even using FD_CLOEXEC. Avoid this by closing all file descriptors when starting the recovery process. After discussion with Dan Berrange, he points out that it's also a good idea to set signal handlers to the default after forking, so that any signal handlers set up in the parent don't affect the child.
* Rebrand 'ordinary appliance' as 'old-style appliance'.Richard W.M. Jones2012-03-031-1/+1
| | | | This is just code motion.
* appliance: Make appliance building thread-safe (RHBZ#790721).Richard W.M. Jones2012-02-151-1/+12
| | | | | | | | | | | | | | | Appliance building can be called from multiple processes, but this is only safe if each process holds a lock on the 'checksum' file. However threads within a process are not excluded by a file lock, and so this strategy completely failed for a multithreaded program calling guestfs_launch in parallel. Since it makes no sense for threads in a single program to race each other to try to create the appliance, add a lock around appliance building. This serialises building the appliance, but the rest of guestfs_launch (eg. starting up qemu) can run in parallel.
* Enable running the daemon under valgrind.Richard W.M. Jones2012-01-241-0/+10
| | | | | | | | | | | | | | | | | This commit allows you to run the daemon under valgrind. You have to enable it at configure time: ./configure --enable-valgrind-daemon This should *not* be done for production builds. When this feature is enabled, valgrind is added to the appliance and the daemon is run under valgrind. Log messages from valgrind are passed back over a virtio-serial channel into a file called 'valgrind.log.$PID' in the top build directory. Running 'make check', 'make extra-tests' etc causes many valgrind.log.* files to be created which must be examined by hand.
* Tempus fugit.Richard W.M. Jones2012-01-181-1/+1
| | | | Update all copyright dates to 2012.
* Allow /dev/null to be added multiple times.Richard W.M. Jones2012-01-101-1/+8
| | | | | | | | Change the test for duplicate drives so that you're allowed to add /dev/null multiple times. This corresponds to traditional usage. This amends commit be47b66c3033105a2b880dbc10bfc2b163b7eafe.
* launch: move the filename checking to a wrapperWanlong Gao2012-01-091-6/+12
| | | | | | Move the filename's comma character checking to a wrapper. Signed-off-by: Wanlong Gao <gaowanlong@cn.fujitsu.com>
* launch: don't add a drive twiceWanlong Gao2012-01-091-2/+12
| | | | | | | | | | | | | | 1. Change the g->path to restore a absolute path instead of the mixed. 2. Check that if the adding drive is duplicated with the added drive. Signed-off-by: Wanlong Gao <gaowanlong@cn.fujitsu.com> RWMJ: - Make sure abs_path is NULL before it is assigned, so freeing it will work along the error path. - Fix the test which added /dev/null multiple times.
* launch: add a goto label when add_drive errorWanlong Gao2012-01-091-18/+11
| | | | | | | Code cleanup. Add a goto label to simplify the code. Signed-off-by: Wanlong Gao <gaowanlong@cn.fujitsu.com>
* lib: Add guestfs___remove_tmpdir helper function.Richard W.M. Jones2011-12-231-0/+30
| | | | | | | This function does 'rm -rf <dir>' for temporary directories, safely working if '<dir>' contains shell meta-characters. Replace existing code for removing directories with this.
* Security: Mitigate possible privilege escalation via SG_IO ioctl ↵Richard W.M. Jones2011-12-221-0/+10
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | (CVE-2011-4127, RHBZ#757071) CVE-2011-4127 is a serious qemu & kernel privilege escalation bug found by Paolo Bonzini. http://seclists.org/oss-sec/2011/q4/536 An untrusted guest kernel is able to issue special SG_IO ioctls on virtio devices which qemu passes through to the host kernel without filtering or sanitizing. These ioctls allow raw sectors from the underlying host device to be read and written. Significantly, neither qemu nor the host kernel checks that the range of sectors is within the partition / LV assigned to the guest. For example, if the guest is assigned host partition /dev/sda3, it would be able to read or write any part of /dev/sda including other partitions and the boot sector. Exploits through LVs passed to the guest are also possible, with some limitations. File-backed virtual block devices are not vulnerable. Non-virtio block devices are not vulnerable. This patch mitigates the problem by disabling the SG_IO ioctl passthrough in qemu. Thus if libguestfs is examining an untrusted guest and the libguestfs appliance/daemon is compromised (eg. by executing guest commands, or through some other compromise), then the compromised appliance will not be able to issue the above SG_IO ioctls and exploit the host. Note that this is just mitigation for libguestfs. Users will still want to fully update their host kernel, qemu/KVM and libvirt, in order to prevent other (non-libguestfs) routes to compromise. The following versions of libguestfs (will/have) this patch applied. libguestfs >= 1.15.13 libguestfs >= 1.14.8 libguestfs >= 1.12.11 libguestfs >= 1.10.12 libguestfs >= 1.8.16 Earlier versions may be vulnerable unless a downstream packager has applied this patch. Cc: Hilko Bengen <bengen@hilluzination.de>
* Add test for qemu broken -machine option (RHBZ#748266).Richard W.M. Jones2011-10-241-0/+12
| | | | | | | Also add this option, if necessary, when testing for virtio-serial support. When the workaround is enabled, we specify machine type 'pc'.
* add-drive-opts: Correctly handle unreadable and unwritable files (RHBZ#747287).Richard W.M. Jones2011-10-211-3/+14
|
* lib: Common code for formatting the qemu -drive parameter.Richard W.M. Jones2011-10-211-28/+32
| | | | This is just code refactoring.
* inspect: Add drive naming hintsMatthew Booth2011-10-191-0/+8
| | | | | | | | | | | We currently use a heuristic to guess how drive names we find referenced in the guest map to drive names in the appliance. If this heuristic fails it can cause inspection to fail. This change adds a new 'name' option to add_drive_opts, which allows the user to explicitly pass the name of a drive to libguestfs if it is known. This change also updates the fstab-parsing inspection code to use this information if it is available.
* launch: Store drive information in guestfs_hMatthew Booth2011-10-191-31/+89
| | | | | | | | | | | | | | | | | | This is a NFC on its own, but provides a place-holder for drive metadata which can be used after launch. Fixes by RWMJ: - Fix the tests: this requires a new internal function 'debug-drives' that dumps out the g->drives information so it can be checked in two of the tests. Previously these tests used 'debug-cmdline'. - Test file existence / use_cache_off in the add_drive_opts function, not when launching qemu in the child process. - Call free along error paths. - Add comments.
* launch: Ensure g->cmdline is allocated before assigning g->cmdline[0].Richard W.M. Jones2011-10-191-7/+14
|
* Add systemtap/DTrace probes.Richard W.M. Jones2011-10-101-0/+10
| | | | | Mainly this is a documentation change. However a sample of DTrace-compatible userspace probes are also added.
* New API: set-smp, get-smpRichard W.M. Jones2011-09-281-0/+6
| | | | | | | These calls allow you to change the number of virtual CPUs assigned to the appliance. This also adds a --smp option to virt-rescue.
* Add no_timer_check to disable faulty test during boot (RHBZ#502058).Richard W.M. Jones2011-09-261-0/+1
| | | | | | | | | See: https://bugzilla.redhat.com/show_bug.cgi?id=502058#c15 https://bugzilla.redhat.com/show_bug.cgi?id=698842#c8 This updates commit 79e66f89e2f6c27486476d7857da58feb491bf5c.
* Enable APIC.Richard W.M. Jones2011-09-211-1/+0
| | | | | | | | | Originally this was disabled to work around RHBZ#502058. That bug was never officially fixed, but it may have fixed itself. In the meantime, KVM has broken ordinary PIC support (RHBZ#723822). Since APIC is the most common way that regular Linux and Windows guests run it makes sense to remove this hack.
* test_qemu: Improve the error message.Richard W.M. Jones2011-08-231-1/+2
| | | | | Note that errno is probably not set to a useful value here, so there is not much point recording it.
* test_qemu: pclose may return any != 0 on error.Richard W.M. Jones2011-08-231-1/+1
| | | | In particular pclose returns a status > 0 if the command fails.
* qemu detection: Free up previous qemu help/version strings if they exist.Richard W.M. Jones2011-08-231-0/+5
|
* Coverity: test_qemu: Ensure FILE * is not leaked along error paths.Richard W.M. Jones2011-08-231-15/+21
| | | | | This refactors the code in test_qemu slightly to ensure that FILE *fp is not leaked on error paths.
* Remove guestfs___print_timestamped_argv.Richard W.M. Jones2011-08-181-44/+38
| | | | | | | | | | | | | | | | | | | | | | | This function was used to print the qemu and febootstrap-supermin-helper command lines. Unfortunately in the qemu case it was used incorrectly: it called the internal debug function (ie. event API callback) from the forked qemu subprocess, which meant that higher level event callbacks might have been invoked from the child process. To fix this, convert the qemu case into a new function called print_qemu_command line which just prints the command line directly to stderr. This is called after stderr has been redirected into the pipe to the main process. Thus the qemu command line will be marshalled into the event API along with other qemu and appliance output. After fixing this, only one use of guestfs___print_timestamped_argv remained, for printing the febootstrap-supermin-helper command line. This is converted to a local function print_febootstrap_command_line. Also print_febootstrap_command_line is now called before we fork febootstrap-supermin-helper, so that messages no longer overlap.
* Change link, since PostgreSQL switched to using git.Richard W.M. Jones2011-08-011-1/+1
|
* launch: Add qemu_supports_re function.Richard W.M. Jones2011-07-261-0/+43
| | | | | | | This function is like qemu_supports, but allows us to grep the help text using regular expressions. Note the function is not used yet.
* appliance: Capture stderr from qemu to the event system.Richard W.M. Jones2011-07-201-1/+9
|