summaryrefslogtreecommitdiffstats
path: root/src/launch.c
Commit message (Collapse)AuthorAgeFilesLines
* launch: Handle guestfs_config qemu_value == NULL.Richard W.M. Jones2012-09-211-1/+1
| | | | | | | | | | | | | The second parameter to 'config' may be NULL. In commit 52fa23d74f6308daf804c2330b0b27e0b4412594 (refactoring of guestfs_config) the code this got lost, and guestfs_config would segfault if qemu_value was NULL. Also this fixes the libvirt method to handle the same case. I checked libguestfs-1.18 and -1.16 branches, and this problem does NOT affect them.
* launch: Make the "launched failed" message more explanatory.Richard W.M. Jones2012-09-201-0/+16
| | | | | | | Since this is the most common error seen by people who have installation problems, buggy qemu, etc, and since no one reads the FAQ, describe in this error message what resources are available to debug launch problems.
* lib: These optargs structures are not modified, hence const.Richard W.M. Jones2012-09-151-3/+3
|
* launch: For /dev/null drives, create a temporary disk.Richard W.M. Jones2012-08-151-18/+52
| | | | | This is a workaround for a bug with virtio-scsi in qemu 1.2: https://bugzilla.redhat.com/show_bug.cgi?id=847549
* launch: Move code to add a drive to the list to separate add_drive utility ↵Richard W.M. Jones2012-08-151-28/+32
| | | | | | function. This is just code motion / simplification.
* launch: Add utility function guestfs___lazy_make_tmpdir.Richard W.M. Jones2012-08-151-8/+20
| | | | | | This lets us create g->tmpdir lazily earlier if needed. This commit is just code motion.
* launch: Make get-pid and max-disks APIs into virtual methods of the current ↵Richard W.M. Jones2012-07-231-17/+45
| | | | attach-method.
* tests: Move debug-drives testing API to launch.c and change the output.Richard W.M. Jones2012-07-231-0/+31
| | | | It should work with any attach-method.
* launch: Add libvirt backend.Richard W.M. Jones2012-07-221-2/+2
| | | | | | | | | | | | Complete the attach-method libvirt backend. This backend uses libvirt to create a transient KVM domain to run the appliance. Note that this still will only work with local libvirt URIs since the <kernel>, <initrd> and appliance links in the libvirt XML refer to local files, and virtio serial only works locally (limitation of libvirt). Remote support will be added later.
* Add attach-method "libvirt" or "libvirt:<URI>".Richard W.M. Jones2012-07-211-0/+4
| | | | | With this commit, you can set the attach method to libvirt, but calling launch will give an error.
* launch: Abstract attach method operations.Richard W.M. Jones2012-07-201-3/+7
| | | | | | g->attach_ops points to a structure which contains the operations supported by each attach method backend (ie. appliance, unix, etc.).
* launch: Move guestfs_config API and build list of qemu parameters in handle.Richard W.M. Jones2012-07-201-0/+35
| | | | | | Move and rewrite guestfs_config so it accumulates a list of qemu parameters in the handle. These are added to the appliance at launch time (with attach method == unix:... you'll now get an error).
* launch: Move launch timing / messages code into launch.c.Richard W.M. Jones2012-07-201-0/+73
|
* lib: Split launch.c into separate files.Richard W.M. Jones2012-07-191-1244/+2
| | | | | | | | | | | | | | | | | | | | | | launch-appliance.c contains the code associated with the 'appliance' attach-method. Mostly. In fact there are a few APIs which don't fit so nicely: - config: deprecated API which fiddles with the qemu command line directly - max-disks: depends on the qemu implementation (virtio-scsi or not) - debug-drives: used for testing only launch-unix.c contains the code associated with 'unix:<path>'. launch.c is the common code for launching, along with a few other APIs such as guestfs_add_drive_opts. This commit also reduces the number of headers to just those which are required.
* Remove debug-cmdline API.Richard W.M. Jones2012-07-191-20/+0
| | | | | Note that debug* calls are not part of the stable API and can be removed or changed at any time.
* generator: Rename 'add_drive_opts' API to 'add_drive'.Richard W.M. Jones2012-07-141-10/+0
| | | | | | By using the once_had_no_optargs flag, this change is backwards compatible for callers (except Haskell, PHP and GObject as discussed in earlier commit).
* Revert "launch: Correction in comment."Richard W.M. Jones2012-07-081-2/+4
| | | | | | This reverts commit 6e5a85bb9b6557bc337625a339728e23f5f2dd94. It turns out this is a bug in QEMU after all.
* launch: Correction in comment.Richard W.M. Jones2012-07-071-4/+2
| | | | | | | https://bugs.launchpad.net/qemu/+bug/1021649 is invalid, probably caused by a Fedora ROM. This updates commit 52d188e32fb8addb45bf926df07e34ab35898f85.
* qemu: Use sgabios by default (thanks Dan Berrange).Richard W.M. Jones2012-07-061-0/+9
|
* New API: guestfs_shutdown: Cleanly shutdown the backend.Richard W.M. Jones2012-07-031-11/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | The new API splits orderly close into a two-step process: if (guestfs_shutdown (g) == -1) { /* handle the error, eg. qemu error */ } guestfs_close (g); Note that the explicit shutdown step is only necessary in the case where you have made changes to the disk image and want to handle write errors. Read the documentation for further information. This change also: - deprecates guestfs_kill_subprocess - turns guestfs_kill_subprocess into the same as guestfs_shutdown - changes guestfish and other tools to call shutdown + close where necessary (not for read-only tools) - updates documentation - updates examples
* Add notes about how qemu cache=none works internally.Richard W.M. Jones2012-07-021-1/+12
| | | | This is just a comment and has no functional effect.
* Rename qemu option cache=off to cache=none.Richard W.M. Jones2012-07-021-9/+9
| | | | | Note that qemu treats these identically, so this change has no functional effect.
* launch: Avoid double-close when qemu exits early.Richard W.M. Jones2012-06-261-2/+6
| | | | | | | | | | | | | | | The stdin and stdout of the qemu process are aliased to g->fd: g->fd[0] = wfd[1]; g->fd[1] = rfd[0]; However if the child exits early, then child_cleanup closes g->fd[0], g->fd[1], AND the code at the cleanup1 label closes wfd[1], rfd[0], resulting in a double-close. Avoid this case by setting wfd[1], rfd[0] to -1. In the cleanup1 label, only close wfd[1], rfd[0] if they are not -1, and add the same for g->fd[0], g->fd[1].
* launch: Ensure errno from test_qemu_cmd is captured and printed.Richard W.M. Jones2012-06-261-5/+3
|
* launch: Set g->sock = -1 to avoid double-close.Richard W.M. Jones2012-06-261-0/+1
| | | | This fixes commit ef5c02c6ee72eb8e127115923951777a2c2b8480.
* launch: Log errors from close syscall.Richard W.M. Jones2012-06-261-1/+6
|
* launch: Treat /dev/null specially, for old KVM.Richard W.M. Jones2012-06-251-0/+19
| | | | | | | | | Old KVM can't add /dev/null readonly. Treat /dev/null as a special case. We also fix a few tests where /dev/null was being used with format=qcow2. This was always incorrect behaviour, but qemu appears to tolerate it.
* ppc64: is_openable function needed on all platforms now.Richard W.M. Jones2012-06-141-4/+0
| | | | This fixes commit 295d6af48d1d8c5238d1536b0c6a2ece42b0b445.
* 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.