summaryrefslogtreecommitdiffstats
path: root/src/launch.c
Commit message (Collapse)AuthorAgeFilesLines
* appliance: Pass lpj=... on the appliance command line (thanks Marcelo Tosatti).Richard W.M. Jones2012-11-241-1/+20
| | | | | | | | | | | | | | | | | | | | | Try to get the host's loops_per_jiffy value and pass this on the command line to the guest. In theory this should avoid the appliance having to recalculate this value in a VM with TCG (which is generally error-prone). This should avoid timing issues. We only do this when we are certain that the guest will be TCG. Currently we only have enough information to do this from the libvirt attach-method. So mostly this will only affect people using Fedora in a VM. The host loops_per_jiffy value is not exported by the kernel. It is only printed by the kernel early during boot, so if boot messages have "scrolled off" the kernel ring buffer, it won't be available. Some operating systems save early kernel messages in /var/log/dmesg but (a) Fedora 18+ seem to have abandoned this file and (b) on Ubuntu this file is unreadable for spurious "security" reasons. I have submitted a patch to make lpj available through /proc/cpuinfo.
* launch: Refactor duplicate code which constructs the appliance command line.Richard W.M. Jones2012-11-231-0/+47
| | | | Move this into a common file.
* lib: Rework temporary and cache directory code.Richard W.M. Jones2012-11-091-75/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | New APIs: set-tmpdir, get-tmpdir, set-cachedir, get-cachedir. The current code has evolved over time and has a number of problems: (a) A single environment variable ($TMPDIR) controls the location of several directories. (b) It's hard for the library user to predict which directory libguestfs will use, unless the user simulates the same internal steps that libguestfs performs. This commit fixes these issues. (a) Now three environment variables control the location of all small temporary files, and the appliance cache: For temporary files: $LIBGUESTFS_TMPDIR or $TMPDIR or /tmp. For the appliance cache: $LIBGUESTFS_CACHEDIR or $TMPDIR or /var/tmp. The user can also set these directories explicitly through API calls (guestfs_set_tmpdir and guestfs_set_cachedir). (b) The user can also retrieve the actual directories that libguestfs will use, by calling guestfs_get_tmpdir and guestfs_get_cachedir. These functions are also used internally. This commit also: - reworks the internal tmpdir code - removes the internal (undocumented) guestfs_tmpdir call (replacing it with calls to the documented guestfs_get_tmpdir API instead) - changes the ./run script to set LIBGUESTFS_TMPDIR and LIBGUESTFS_CACHEDIR - adds a test - fixes a few places like libguestfs-make-fixed-appliance which depended on $TMPDIR
* lib: Change guestfs___remove_tmpdir function to use command mini-library.Richard W.M. Jones2012-10-181-19/+10
|
* Add support for hotplugging (removing disks).Richard W.M. Jones2012-10-091-0/+54
| | | | | | | | New API: remove-drive. Note because of a bug in fuser, this only works with psmisc >= 22.20. This also updates the hotplugging tests.
* Add support for hotplugging (adding disks) to the libvirt attach-method.Richard W.M. Jones2012-10-081-7/+73
| | | | | | | | | | | | | When libvirt is used, we can allow disks to be hotplugged. guestfs_add_drive can be called after launch to hot-add a disk. When a disk is hot-added, we first ask libvirt to add the disk to the appliance, then we make an internal call into the appliance to get it to wait for the disk to appear (ie. udev_settle ()). Hot-added disks are tracked in the g->drives array. This also adds a test.
* launch: Add add_drive 'label' option.Richard W.M. Jones2012-10-081-5/+37
| | | | | | | | | | | | | | | | | | | | | New API: list-disk-labels Allow the user to pass an optional disk label when adding a drive. This is passed through to qemu / libvirt using the disk serial field, and from there to the appliance which exposes it through udev, creating a special alias of the device /dev/disk/guestfs/<label>. Partitions are named /dev/disk/guestfs/<label><partnum>. virtio-blk and virtio-scsi limit the serial field to 20 bytes. We further limit the name to maximum 20 ASCII characters in [a-zA-Z]. list-devices and list-partitions are not changed: these calls still return raw block device names. However a new call, list-disk-labels, returns a hash table allowing callers to map between disk labels, and block device and partition names. This commit also includes a test.
* launch: Make g->drives into an array (was a linked list).Richard W.M. Jones2012-10-081-34/+52
| | | | Using an array simplifies the implementation of hotplugging.
* launch: Add private data pointer to the struct drive.Richard W.M. Jones2012-10-061-0/+3
| | | | This can be used by the attach-method, eg. for libvirt-only data.
* launch: add_null_drive: Force null drive to be writable.Richard W.M. Jones2012-10-061-0/+5
| | | | | Because we create a special file, there is no point forcing qemu to create an overlay as well. Save time by setting readonly = 0.
* launch: Rearrange code for adding drives to the g->drives list in the handle.Richard W.M. Jones2012-10-061-23/+62
| | | | This is just code motion.
* 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).