summaryrefslogtreecommitdiffstats
path: root/daemon
Commit message (Collapse)AuthorAgeFilesLines
* daemon: Mark some functions as attribute((noreturn)).Richard W.M. Jones2012-10-301-2/+2
| | | | (cherry picked from commit 5c8f073786285303f3bda1c30bd0b1953e0667a7)
* daemon: Call udev-settle at the start of the daemon.Richard W.M. Jones2012-10-301-0/+11
| | | | (cherry picked from commit 15b9ed3ed2078c034f25bf3ba31298dd89c6cddf)
* daemon: When sorting devices, don't fail on mix of /dev/sd and /dev/vdRichard W.M. Jones2012-10-011-0/+8
| | | | | | | | | | | | | | | (RHBZ#858128). If compare_device_names was given two devices with devices with different interfaces (eg. /dev/sda and /dev/vda) then it would try to compare the partition numbers, and fail when it could parse them. It's arguable what we should be doing in this case (except for strongly discouraging people from using the interface feature), but let's at least not cause the daemon to assert-fail. Found by Red Hat QA, thanks Mohua Li. (cherry picked from commit 6f53d49a27fbf7f1b5c22080e2509375e128d5e4)
* syntax: Remove definitions of O_CLOEXEC, except in examples (thanks Jim ↵Richard W.M. Jones2012-09-191-4/+0
| | | | | | | | | Meyering). The gnulib <fcntl.h> replacement header will now define this symbol if it's not defined already. (cherry picked from commit cb13ffe190ac41a9b77fe27521838f495c1a5077)
* syntax: Remove gnulib "ignore-value.h" in files that don't use it.Richard W.M. Jones2012-09-191-1/+0
| | | | | | | Found by 'make syntax-check'. Cherry picked from commit a67129b0fb45b2f83eb711c6c599569d0f53e580 and modified for 1.18 branch.
* syntax: Remove include <dirent.h> in files that don't use it.Richard W.M. Jones2012-09-192-2/+0
| | | | | Found by 'make syntax-check'. (cherry picked from commit d6bb49a172c369c3bcc85771af804649c3733ef3)
* daemon: Call udev_settle after mkswap.Richard W.M. Jones2012-08-301-0/+2
| | | | | | | | | | | | | | | | | | | | | | | | | This adds a call to udev_settle after creating the swap device. This is an attempt to workaround the following problem seen in Koji and Rawhide: libguestfs: trace: mkswap_L "swapit" "/dev/sda1" libguestfs: send_to_daemon: 72 bytes: 00 00 00 44 | 20 00 f5 f5 | 00 00 00 04 | 00 00 00 83 | 00 00 00 00 | ... guestfsd: main_loop: proc 210 (part_disk) took 2.28 seconds guestfsd: main_loop: new request, len 0x44 mkswap -f -L swapit /dev/sda1 libguestfs: recv_from_daemon: 40 bytes: 20 00 f5 f5 | 00 00 00 04 | 00 00 00 83 | 00 00 00 01 | 00 12 37 cf | ... libguestfs: trace: mkswap_L = 0 libguestfs: trace: swapon_label "swapit" libguestfs: send_to_daemon: 56 bytes: 00 00 00 34 | 20 00 f5 f5 | 00 00 00 04 | 00 00 00 ae | 00 00 00 00 | ... guestfsd: main_loop: proc 131 (mkswap_L) took 0.77 seconds guestfsd: main_loop: new request, len 0x34 swapon -L swapit swapon: cannot find the device for swapit guestfsd: error: swapit: swapon: cannot find the device for swapit libguestfs: recv_from_daemon: 100 bytes: 20 00 f5 f5 | 00 00 00 04 | 00 00 00 ae | 00 00 00 01 | 00 12 37 d0 | ... libguestfs: trace: swapon_label = -1 (error) swapon_label: swapit: swapon: cannot find the device for swapit test_swapon_label_0 FAILED
* daemon: New utility functions 'join_strings', 'concat_strings'.Richard W.M. Jones2012-08-302-0/+48
| | | | | Useful functions for concatenating strings together. (cherry picked from commit 637b06ab1384f0c904715ba76fc759dac1b95500)
* build: Rename most C files that contain underscore with dash.Richard W.M. Jones2012-08-052-6/+6
| | | | | | | | | | | | | | This is just code motion. Some files cannot be renamed. Notably rpcgen input and output files must not contain dash characters, else rpcgen breaks. Cherry picked from commit 2e4089f30007e79bc157c775cfd3b326d22f2992 and modified so that conflicts in the following files: po-docs/ja.po po-docs/libguestfs-docs.pot po-docs/uk.po were resolved by simply copying the files from the master branch.
* tar-in: Add --no-same-owner flag to tar command when target filesystem ↵Richard W.M. Jones2012-08-051-3/+54
| | | | | | | | | | | | | | | | | doesn't support chown (RHBZ#840572). When using tar-in or tools built around it such as virt-make-fs, if the target filesystem is vfat then unpacking the tarball would fail because tar tries to chown(2) files and fails. You would see errors such as: tar: <file>: Cannot change ownership to uid 500, gid 500: Operation not permitted This change detects whether the target filesystem supports chown(2). If not, it adds the --no-same-owner flag to tar to stop it from trying to change the ownership of newly created files. (cherry picked from commit 50780a84f65ec5d76605691cea889392c2730f54)
* daemon: Make 'random_name' into a utility function.Richard W.M. Jones2012-08-053-30/+51
| | | | | | This is mostly code motion, although the precise contract of this function changes slightly to make it more generally useful (cherry picked from commit 781857a86b3bc8238995a9212ea09aa368fc2fc9)
* augeas: make functions as noreturnWanlong Gao2012-08-051-14/+14
| | | | | | | Just make gcc happy. Signed-off-by: Wanlong Gao <gaowanlong@cn.fujitsu.com> (cherry picked from commit 2f89f584c0203023f8a829ff9796dc2c14ddeb68)
* case_sensitive_path: Allow trailing path element to be missing (RHBZ#840115).Richard W.M. Jones2012-08-051-15/+21
| | | | | | | | | | | | | | case_sensitive_path is undefined when the final path element doesn't exist. Currently it returns an error, but this means that creating a new file doesn't work as expected: $ guestfish --rw -i -d windows touch 'win:c:\blah' libguestfs: error: case_sensitive_path: blah no file or directory found with this name We should allow this case (provided there is no trailing slash) so that new files or directories can be created. (cherry picked from commit 973581780d8a006f336684fef6762801402d775d)
* case_sensitive_path: Move variables to top of function.Richard W.M. Jones2012-08-051-6/+8
| | | | | This is just code motion. (cherry picked from commit ac0373bdecfabe6acf99d3662e5117de73fa2aef)
* daemon: Run fsync on block devices after sync (RHBZ#836710).Richard W.M. Jones2012-07-061-0/+78
| | | | | | | | | | | | | | | | | | | On Linux, sync(2) does not actually issue a write barrier, thus it doesn't force a flush of the underlying hardware write cache (or qemu's disk cache in the virtual case). This can be a problem, because libguestfs relies on running sync in the appliance, followed by killing qemu (using SIGTERM). In most cases, this is fine, because killing qemu with SIGTERM should cause it to flush out the disk cache before it exits. However we have found various bugs in qemu which cause qemu to crash while doing the flush, leaving the data unwritten (see RHBZ#836913). The solution is to issue fsync(2) to the block devices. This has a write barrier, so it ensures that qemu writes out its cache long before we get around to killing qemu. (cherry picked from commit c0a3c9ce70b98171e737e49e6dccc4457963f2ec)
* daemon: Code tidy up in devsparts.Richard W.M. Jones2012-07-061-8/+9
| | | | | No functional change. (cherry picked from commit cb24ceedd8a8ef7da71cfcce6db10669de47685c)
* New API: guestfs_nr_devicesRichard W.M. Jones2012-07-061-0/+17
| | | | | | | | This returns the number of whole block devices added. It is usually simpler to call this than to list the devices and count them, which is what we do in some places in the current codebase. (cherry picked from commit 152b179a19e43fcb0baec65ea65d394ee1dba891)
* New API: device-index.Richard W.M. Jones2012-07-061-0/+23
| | | | | | | | This returns the index of the device, eg. /dev/sdb => 1. Or you can think of it as the order that the device was added, or the index of the device in guestfs_list_devices. (cherry picked from commit a9d7d044f552855a7ef78d953c0c2672e35bfc80)
* part-get-bootable: Fix when partitions are missing or unordered (RHBZ#602997).Richard W.M. Jones2012-06-281-4/+16
| | | | | | | | | The original fix for this in commit 511c82df46f5c6f4a7f984fdb81d4691038ed6da was not complete, in that it did not fix the case of the old (pre '-m' option) parted. This doesn't matter for Fedora, but it matters for RHEL 5 which has this ancient parted. (cherry picked from commit 4d3ec25b47361601604e2f585178393e60f4cd4d)
* lvm-filter: Make it work with > 26 devices.Richard W.M. Jones2012-06-211-11/+14
| | | | | Thanks Alasdair Kergon. (cherry picked from commit 998ebc333dbfe40c5953e36fb42f9610727a7532)
* daemon: Fix order of devices in guestfs_list_devices when > 26 disks.Richard W.M. Jones2012-06-213-2/+69
| | | | | | Sort the device names correctly, not just treating them as strings. As a result, /dev/sdz < /dev/sdaa. (cherry picked from commit c0a087b8236755e95371d5c352c9d29a3ca992c0)
* daemon: Always pass -F option to mke2fs.Richard W.M. Jones2012-06-211-6/+6
| | | | | | | | | | | Apparently e2fsprogs only knows that "/dev/sda" is a whole device, but doesn't think that "/dev/vda" is. On switching the default device over to virtio-scsi, that causes mke2fs without -F option to complain and ask for an interactive prompt. Adding -F forces it to go ahead anyway. This caused several less-used APIs to break with virtio-scsi. (cherry picked from commit 62c5b6db58911a5e51f59965619355437b7a7214)
* fish/mount: Add better error message when -m (mount) fails (RHBZ#824043).Richard W.M. Jones2012-06-011-1/+2
| | | | (cherry picked from commit ee9ab52bc3e087f63dcc51d3b6ac5c79277425e1)
* NEW API: add new api btrfs-fsckWanlong Gao2012-05-151-0/+44
| | | | | | | | | Add the new API btrfs-fsck to check the btrfs filesystem. Btrfs is currently under heavy development, and not suitable for any uses other than benchmarking and review. But it'll be useful in the near future. Signed-off-by: Wanlong Gao <gaowanlong@cn.fujitsu.com>
* btrfs: change the return value of btrfs-set-seedingWanlong Gao2012-05-151-1/+1
| | | | | | Change the return value from "r" to "0". Signed-off-by: Wanlong Gao <gaowanlong@cn.fujitsu.com>
* doc: Add notes on how GPT works on 4k sector disks.Richard W.M. Jones2012-05-141-1/+3
| | | | | | | | | I used scsi_debug to create a 4k sector virtual disk: modprobe scsi_debug dev_size_mb=128 sector_size=4096 I then used 'gdisk' to create lots of partitions, and used 'hexdump' to examine what was written to disk.
* New API: add new api btrfs-set-seeding to enable or disable seeding.Wanlong Gao2012-05-141-0/+19
| | | | | | | Add the new API btrfs-set-seeding to support the seeding-device feature for btrfs. Signed-off-by: Wanlong Gao <gaowanlong@cn.fujitsu.com>
* debug: 'progress' (unsupported debug command) now checks argument is ↵Richard W.M. Jones2012-04-271-1/+5
| | | | | | reasonable (RHBZ#816839). Thanks Yuyu Zhou.
* btrfs-device-delete: Use correct (sysroot-prefixed) path to filesystem.Richard W.M. Jones2012-04-251-1/+3
| | | | This fixes commit 87ea7a04094d5ed40f3f047ff2b7a613d4d530d4.
* New btrfs APIs.Richard W.M. Jones2012-04-251-0/+396
| | | | | | | | | | | | | | | | Bind the easy parts of the 'btrfs' program. The new APIs are: btrfs-device-add: add devices to a btrfs filesystem btrfs-device-delete: remove devices from a btrfs filesystem btrfs-filesystem-sync: sync a btrfs filesystem btrfs-filesystem-balance: balance a btrfs filesystem btrfs-subvolume-create: create a btrfs snapshot btrfs-subvolume-delete: delete a btrfs snapshot btrfs-subvolume-list: list btrfs snapshots and subvolumes btrfs-subvolume-set-default: set default btrfs subvolume btrfs-subvolume-snapshot: create a writable btrfs snapshot
* btrfs: Modify mkfs-btrfs API so it takes a list of devices.Richard W.M. Jones2012-04-251-7/+16
| | | | | | | btrfs filesystems can span multiple filesystems. Note this changes the API, but this API has not yet been released in a stable version of libguestfs.
* New APIs for reading and writing ext2 file attributes and file generation.Richard W.M. Jones2012-04-131-1/+193
| | | | | | | | | | | | The new APIs are: get-e2attrs: List ext2 file attributes of a file. set-e2attrs: Set or clear ext2 file attributes of a file. get-e2generation: Get ext2 file generation of a file. set-e2generation: Set ext2 file generation of a file. These are implemented using the lsattr and chattr programs from e2fsprogs.
* New API: mkfs-btrfs for creating btrfs filesystems (RHBZ#807905).Richard W.M. Jones2012-04-022-1/+110
| | | | This allows all parameters from btrfs to be accessed.
* mkfs: Don't allow blocksize to be set on btrfs (RHBZ#807905).Richard W.M. Jones2012-04-021-0/+5
|
* New API: md-stat.Richard W.M. Jones2012-03-201-0/+172
| | | | | This returns information about the underlying devices of an MD (software RAID) device.
* daemon: Add reply_with_error_errno function.Richard W.M. Jones2012-03-202-6/+7
| | | | | | This function allows you to pass an explicit errno back to the library. reply_with_error is redefined as a macro that calls reply_with_error_errno with errno == 0.
* New API: vgmeta: Download volume group metadata.Richard W.M. Jones2012-03-171-0/+88
|
* New APIs: isoinfo and isoinfo-device.Richard W.M. Jones2012-03-162-0/+293
| | | | | Get ISO primary volume descriptor information for either ISO devices or ISO files.
* daemon: Don't call reply_with_* after split_lines fails.Richard W.M. Jones2012-03-162-6/+2
| | | | | split_lines already sets reply_with_*, so calling it again would lose protocol synchronization.
* Use the new lvcreate-free API to create largest possible LVs.Richard W.M. Jones2012-03-151-1/+1
|
* New API: lvcreate-free: Create logical volume as % of free space.Richard W.M. Jones2012-03-151-0/+30
|
* New API: zero_free_space: zero free space in a filesystem.Richard W.M. Jones2012-03-151-0/+104
| | | | | | | | | | | | | | Add an API for doing what virt-sparsify was doing: freeing up free space in a filesystem. The current implementation is simple-minded: we create a file, fill it with zeroes until we run out of space, then delete the file. However the description leaves it open to do a better implementation, eg. using sparsification support that is currently being worked on in ext4 and qemu. The implementation also sends progress notifications, which is an advantage over the old 'dd' method.
* Use O_CLOEXEC / SOCK_CLOEXEC for almost all file descriptors.Richard W.M. Jones2012-03-1422-51/+57
| | | | | | | | | | | | | | | | | | | | | | | | 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'.
* daemon: When copy subprocess fails, print return code.Richard W.M. Jones2012-03-141-1/+1
| | | | Useful for debugging.
* daemon: labels: Memory leak in 'set_label'.Richard W.M. Jones2012-03-141-3/+7
| | | | This fixes commit d1711dae9dbd7f516469f88807604894c1304228.
* Replace 'int' with 'size_t' passim.Richard W.M. Jones2012-03-1313-66/+74
| | | | | Analyze all uses of 'int' in the code, and replace with 'size_t' where appropriate.
* daemon: Implement a growable strings buffer type.Richard W.M. Jones2012-03-1316-196/+209
| | | | | | | | | | | | | | | | | | | | | | | | Previously a lot of daemon code used three variables (a string list, 'int size' and 'int alloc') to track growable strings buffers. This commit implements a simple struct containing the same variables, but using size_t instead of int: struct stringsbuf { char **argv; size_t size; size_t alloc; }; Use it like this: DECLARE_STRINGSBUF (ret); //... if (add_string (&ret, str) == -1) return NULL; //... if (end_stringsbuf (&ret) == -1) return NULL; return ret.argv;
* daemon: Remove unused variables.Richard W.M. Jones2012-03-122-8/+0
|
* resize2fs: Run 'e2fsck -f' automatically if filesystem is not mounted.Richard W.M. Jones2012-03-093-0/+81
|
* e2fsck: Comment, whitespace, error message cleanups.Richard W.M. Jones2012-03-091-2/+2
|