121 Commits

Author SHA1 Message Date
Richard W.M. Jones
923b319886 appliance: Add suggested udevadm monitor command
While debugging some udev issues, I found use of 'udevadm monitor' to
be fairly useful.  Add a suggested debugging command that might be
used, but comment it out.

Thanks: Alasdair Kergon
2026-01-27 16:36:12 +00:00
Richard W.M. Jones
217823da95 appliance/init: Add lsblk and blkid output to verbose log
This is useful for debugging.  The output looks like:

  + lsblk
  NAME        MAJ:MIN RM  SIZE RO TYPE MOUNTPOINTS
  sda           8:0    0    1G  0 disk
  |-sda1        8:1    0  512M  0 part
  `-sda2        8:2    0  512M  0 part
    |-VG-Root 252:0    0   32M  0 lvm
    |-VG-LV1  252:1    0   32M  0 lvm
    |-VG-LV2  252:2    0   32M  0 lvm
    `-VG-LV3  252:3    0   64M  0 lvm
  sdb           8:16   0    4G  0 disk /
  + blkid
  /dev/mapper/VG-LV1: UUID="cc8a3437-4169-4b1c-b432-ee8adc563f6d" BLOCK_SIZE="4096" TYPE="ext2"
  /dev/sdb: UUID="30c70ddc-d00b-4620-a408-025890e59aa6" BLOCK_SIZE="4096" TYPE="ext2"
  /dev/mapper/VG-LV2: UUID="747009aa-e183-46ba-a034-0c437b15cebc" BLOCK_SIZE="1024" TYPE="ext2"
  /dev/mapper/VG-Root: LABEL="ROOT" UUID="01234567-0123-0123-0123-012345678902" BLOCK_SIZE="4096" TYPE="ext2"
  /dev/sda2: UUID="DfEjc1-wRU6-vh8U-we7U-ivEl-FRwo-rG0ZuL" TYPE="LVM2_member" PARTUUID="184cbb43-02"
  /dev/sda1: LABEL="BOOT" UUID="01234567-0123-0123-0123-012345678901" BLOCK_SIZE="4096" TYPE="ext2" PARTUUID="184cbb43-01"
  /dev/mapper/VG-LV3: UUID="f9e5dc21-9a2a-45a0-85b0-e2889607139a" BLOCK_SIZE="2048" TYPE="ext2"

Fixes: https://issues.redhat.com/browse/RHEL-106490
2025-07-30 11:06:37 +01:00
Richard W.M. Jones
dc218b25f0 appliance: Ignore sit0 network device in the guest
Reported-by: Srikanth Aithal <sraithal@amd.com>
Fixed-by: Stefano Brivio <sbrivio@redhat.com>
Tested-by: Srikanth Aithal <sraithal@amd.com>
See-also: https://lists.libguestfs.org/archives/list/guestfs@lists.libguestfs.org/thread/566LAY7RNM7T7EMQQQYIQA2VK5TXETK5/
2025-06-25 11:15:31 +01:00
Richard W.M. Jones
6ba8449927 appliance/init: Fix /usr/sbin symlinks in Fedora 42+
Since Fedora 42 merged /usr/sbin and /usr/bin, /usr/sbin is usually
populated with symbolic links to binaries in /usr/bin.  These are
created by a complicated script in filesystem.spec that we don't run.
Emulate sort of what that script is doing instead.

This is a hack that we can eventually remove, hopefully.

See-also: https://lists.fedoraproject.org/archives/list/devel@lists.fedoraproject.org/thread/PCU2WWLEGLGIOY4TCCBIHLYS6ZCZ4GSS/
2025-02-05 13:09:26 +00:00
Thomas Wouters
84d1cd0707 Fix dhcpcd failing on systemd-resolved stub
dhcpcd fails to update /etc/resolv.conf if is a dangling symlink, so remove it
if it is.

This happens on Arch Linux when systemd-resolved is enabled by symlinking
/etc/resolv.conf to /run/systemd/resolve/stub-resolv.conf. The symlink is copied
into the supermin appliance, but the target file is not and this causes dhcpcd to
fail when it tries to update /etc/resolv.conf.

The handling of /etc/resolv.conf could be improved in dhcpcd but it's not their
job to decide when to remove the symlink. We do have the authority to decide
whether or not to use systemd-resolved or resolvconf in the appliance, so we can
remove it.
2024-11-13 14:09:59 +01:00
Richard W.M. Jones
b2d682a473 appliance/init: Don't set impossible "noop" disk scheduler
Since RHEL 7.4, the noop scheduler is no longer a thing.  Trying to
set it results in the error:

  + echo noop
  /init: line 108: echo: write error: Invalid argument

The current recommendation (https://access.redhat.com/solutions/5427)
is to use mq-deadline, but that's also the default so we don't have to
do anything.

A bigger reason to remove these lines is that kernel 6.11.0 has
introduced a hang where -- rarely -- the ext4 filesystem hangs if you
try to change the scheduler while handing a page fault, even if you're
setting a scheduler that doesn't exist.  I couldn't get much detail
except for a couple of stack traces from different VMs:

  crash> set 234
      PID: 234
  COMMAND: "modprobe"
     TASK: ffff9f5ec3a22f40  [THREAD_INFO: ffff9f5ec3a22f40]
      CPU: 0
    STATE: TASK_UNINTERRUPTIBLE
  crash> bt
  PID: 234      TASK: ffff9f5ec3a22f40  CPU: 0    COMMAND: "modprobe"
   #0 [ffffb21e002e7840] __schedule at ffffffffa718f6d0
   #1 [ffffb21e002e78f8] schedule at ffffffffa7190a27
   #2 [ffffb21e002e7908] __bio_queue_enter at ffffffffa67e121c
   #3 [ffffb21e002e7968] blk_mq_submit_bio at ffffffffa67f358c
   #4 [ffffb21e002e79f0] __submit_bio at ffffffffa67e1e3c
   #5 [ffffb21e002e7a58] submit_bio_noacct_nocheck at ffffffffa67e2326
   #6 [ffffb21e002e7ac0] ext4_mpage_readpages at ffffffffa65ceafc
   #7 [ffffb21e002e7be0] read_pages at ffffffffa6381d17
   #8 [ffffb21e002e7c40] page_cache_ra_unbounded at ffffffffa6381ff5
   #9 [ffffb21e002e7ca8] filemap_fault at ffffffffa63761b5
  #10 [ffffb21e002e7d48] __do_fault at ffffffffa63d1892
  #11 [ffffb21e002e7d70] do_fault at ffffffffa63d2425
  #12 [ffffb21e002e7da0] __handle_mm_fault at ffffffffa63d8c6b
  #13 [ffffb21e002e7e88] handle_mm_fault at ffffffffa63d95c2
  #14 [ffffb21e002e7ec8] do_user_addr_fault at ffffffffa60b34ea
  #15 [ffffb21e002e7f28] exc_page_fault at ffffffffa7186e4e
  #16 [ffffb21e002e7f50] asm_exc_page_fault at ffffffffa72012a6
      RIP: 000055d16159f8d8  RSP: 00007ffdd4c1f340  RFLAGS: 00010206
      RAX: 00000000000bec82  RBX: 00007ff2fd00dc82  RCX: 000055d1615b492a
      RDX: 00007ffdd4c216b0  RSI: 00000000200bec82  RDI: 000055d185725960
      RBP: 00007ffdd4c1f5a0   R8: 0000000000000000   R9: 0000000000000000
      R10: 0000000000000000  R11: 0000000000000202  R12: 00000000200bec82
      R13: 000055d185725960  R14: 00007ffdd4c216b0  R15: 000055d1615b9708
      ORIG_RAX: ffffffffffffffff  CS: 0033  SS: 002b

  crash> set 230
      PID: 230
  COMMAND: "modprobe"
     TASK: ffff98ce03ca3040  [THREAD_INFO: ffff98ce03ca3040]
      CPU: 0
    STATE: TASK_UNINTERRUPTIBLE
  crash> bt
  PID: 230      TASK: ffff98ce03ca3040  CPU: 0    COMMAND: "modprobe"
   #0 [ffffaf9940307840] __schedule at ffffffff9618f6d0
   #1 [ffffaf99403078f8] schedule at ffffffff96190a27
   #2 [ffffaf9940307908] __bio_queue_enter at ffffffff957e121c
   #3 [ffffaf9940307968] blk_mq_submit_bio at ffffffff957f358c
   #4 [ffffaf99403079f0] __submit_bio at ffffffff957e1e3c
   #5 [ffffaf9940307a58] submit_bio_noacct_nocheck at ffffffff957e2326
   #6 [ffffaf9940307ac0] ext4_mpage_readpages at ffffffff955ceafc
   #7 [ffffaf9940307be0] read_pages at ffffffff95381d1a
   #8 [ffffaf9940307c40] page_cache_ra_unbounded at ffffffff95381ff5
   #9 [ffffaf9940307ca8] filemap_fault at ffffffff953761b5
  #10 [ffffaf9940307d48] __do_fault at ffffffff953d1895
  #11 [ffffaf9940307d70] do_fault at ffffffff953d2425
  #12 [ffffaf9940307da0] __handle_mm_fault at ffffffff953d8c6b
  #13 [ffffaf9940307e88] handle_mm_fault at ffffffff953d95c2
  #14 [ffffaf9940307ec8] do_user_addr_fault at ffffffff950b34ea
  #15 [ffffaf9940307f28] exc_page_fault at ffffffff96186e4e
  #16 [ffffaf9940307f50] asm_exc_page_fault at ffffffff962012a6
      RIP: 0000556b7a7468d8  RSP: 00007ffde2ffb560  RFLAGS: 00000206
      RAX: 00000000000bec82  RBX: 00007f5331a0dc82  RCX: 0000556b7a75b92a
      RDX: 00007ffde2ffd8d0  RSI: 00000000200bec82  RDI: 0000556ba8edf960
      RBP: 00007ffde2ffb7c0   R8: 0000000000000000   R9: 0000000000000000
      R10: 0000000000000000  R11: 0000000000000202  R12: 00000000200bec82
      R13: 0000556ba8edf960  R14: 00007ffde2ffd8d0  R15: 0000556b7a760708
      ORIG_RAX: ffffffffffffffff  CS: 0033  SS: 002b

Fixes: https://bugzilla.redhat.com/show_bug.cgi?id=2303267
2024-08-16 08:32:40 +01:00
Olaf Hering
4ef645778a appliance: only wait for resolv.conf update if dhcpcd succeeded
In case network was requested, but the host lacks both dhclient and
dhcpcd, skip the loop which waits for a resolv.conf update.

This reduces boot time by 10 seconds.

Signed-off-by: Olaf Hering <olaf@aepfle.de>
2024-05-15 17:11:02 +01:00
Richard W.M. Jones
f53859723e appliance: Wait for /etc/resolv.conf to be populated
Work around this issue with dhcpcd:
https://github.com/NetworkConfiguration/dhcpcd/issues/258

Fixes: commit 0e37e5feea
2023-11-16 10:17:35 +00:00
Richard W.M. Jones
001683e885 appliance: Remove LD_PRELOAD=libSegFault.so
This feature was removed in glibc 2.35:
https://savannah.gnu.org/forum/forum.php?forum_id=10111
2022-10-24 10:41:09 +01:00
Richard W.M. Jones
4004e8eb36 appliance: Create symlink /etc/crypto-policies/back-ends/opensslcnf.config
Downstream patched openssl in Fedora 37+ broke unless
/etc/crypto-policies/back-ends/opensslcnf.conf is present.  Files in
this directory are generated by %post rules that use scripting
languages so cannot easily be created by supermin.

Add a symlink to the DEFAULT policy file if the configuration file
doesn't exist.

A symptom of this problem is the error:

  Requested hash sha256 is not supported.
  Failed to set pbkdf parameters.

Fixes: https://bugzilla.redhat.com/show_bug.cgi?id=2133884
Updates: commit d6ba398825
2022-10-12 12:42:15 +01:00
Laszlo Ersek
8fc4d16715 appliance, daemon: disable lvm2 devicesfile
In guestfs-tools commit 4fe8a03cd2d3 ('sysprep: remove lvm2's default
"system.devices" file', 2022-04-11), we disabled the use of LVM2's new
"devicesfile" feature, which could interfere with the cloning of virtual
machines.

We suspected in

  https://bugzilla.redhat.com/show_bug.cgi?id=2072493#c6

that the same lvm2 feature could affect the libguestfs appliance itself,
but decided in

  https://bugzilla.redhat.com/show_bug.cgi?id=2072493#c8
  https://bugzilla.redhat.com/show_bug.cgi?id=2072493#c10

that this would not be the case, because "appliance/init" already
constructed a pristine LVM_SYSTEM_DIR.

Unfortunately, that's not enough: due to the "use_devicesfile=1" default
(on RHEL9 anyway), some "lvm" invocation, possibly inside the
lvm-set-filter API, *creates* "$LVM_SYSTEM_DIR/devices/system.devices".
And then we get (minimally) warnings such as

> Please remove the lvm.conf global_filter, it is ignored with the devices
> file.
> Please remove the lvm.conf filter, it is ignored with the devices file.

when using the lvm-set-filter API.

Explicitly disable the "devices file" in "appliance/init", and also
whenever we rewrite "lvm.conf" -- that is, in set_filter()
[daemon/lvm-filter.c]. In the former, check for the feature by locating
the devicesfile-related utilities "lvmdevices" and "vgimportdevices". In
the C code, invoke the utilities with the "--help" option instead. (In
"appliance/init",  I thought it was best not to call any lvm2 utilities
even with "--help", with our lvm2.conf still under construction there.) If
either utility is available, set "use_devicesfile = 0".

Cc: David Teigland <teigland@redhat.com>
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=1965941
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
Message-Id: <20220530141027.16167-1-lersek@redhat.com>
Acked-by: Richard W.M. Jones <rjones@redhat.com>
[lersek@redhat.com: style fix: break "devicesfile_feature" in the function
 definition to a new line]
2022-05-31 08:47:58 +02:00
Olaf Hering
f47e0bb672 appliance: reorder mounting of special filesystems in init
Make sure proc and dev are available early.
No change in behavior intended.

Signed-off-by: Olaf Hering <olaf@aepfle.de>
2021-09-15 12:37:08 +01:00
Olaf Hering
9db0c98c99 appliance: enable bash's Process Substitution feature
bash can read input from a spawned process, and even provide input to
such process. This feature relies on /dev/fd/ being present. In the
past udev silently created this symlink, so this bash feature worked
more or less by accident. With recent systemd versions, such as 246
which is included in Leap 15.3, the symlink is not created anymore. As
a result scripts, such as /sbin/dhclient-script, fail to work
properly.

This symlink should have been created in version 1 of this variant of /init.

https://bugzilla.opensuse.org/show_bug.cgi?id=1190501

Signed-off-by: Olaf Hering <olaf@aepfle.de>
2021-09-15 12:37:08 +01:00
Richard W.M. Jones
2bb6be333e appliance: Remove /etc/dhcp/dhclient-enter-hooks.d/resolved.
Workaround for Ubuntu which uses this script to try to start a systemd
service.  That won't work because systemd is not used inside the
appliance.  See:

https://bugs.launchpad.net/ubuntu/+source/supermin/+bug/1824236

Thanks: Ioanna Alifieraki
2019-05-29 17:54:52 +01:00
Richard W.M. Jones
dd162d2cd5 daemon: Move lvmetad to early in the appliance boot process.
When the daemon starts up it creates a fresh (empty) LVM configuration
and starts up lvmetad (which depends on the LVM configuration).

However this appears to cause problems: Some types of PV seem to
require lvmetad and don't work without it
(https://bugzilla.redhat.com/show_bug.cgi?id=1581810).  If we don't
start lvmetad earlier, the device nodes are not created.

Therefore move the whole initialization step into appliance/init.

Two further changes had to be made:

Now we are using lvmetad all the time, using vgchange is incorrect.
With lvmetad activated early we must use ‘pvscan --cache --activate ay’
to scan all disks for PVs and activate any VGs on them (although the
documentation is complex, confusing and contradictory so I'm not
completely sure about this).

The ‘lvm_system_dir’ local variable in ‘daemon/lvm-filter.c’
previously contained the path of the directory above $LVM_SYSTEM_DIR
(eg. $LVM_SYSTEM_DIR = "/etc/lvm", lvm_system_dir = "/etc").  As this
was highly confusing, I have changed it so the local variable and the
environment variable have identical contents.  This involved removing
the ‘lvm/’ component from a couple of paths since it is now included
in the local variable.
2018-05-29 20:38:40 +01:00
Mykola Ivanets
b00379fbd6 appliance: init: Avoid running degraded md devices
The issue:
- raid1 will be in degraded state if one of its components is logical volume (LV)
- raid0 will be inoperable at all (inacessible from within appliance) if one of its component is LV
- raidN: you can expect the same issue for any raid level depends on how many components are inaccessible at the time mdadm is running and raid redundency.

It happens because mdadm is launched prior to lvm AND it is instructed to run found arrays immediately (--run flag) regardless of completeness of their components.
Later (when lvm activates found LVs) md signature on LV might be recognized BUT newly found raid components could't be inserted into already running (in degraded state)
or marked as inoperable raid arrays.

The patch fixes the issue in the following way:

1. Found arrays won't be run immediately unless ALL expected drives (components) are present. Here '--no-degraded' flag comes into a play. See mdadm(8).
2. Second mdadm call (after LVM is scanned) will scan UNUSED yet devices and make an attempt to run all found arrays (even they will be in degraded state).

There is no performance penalty because second pass scans UNUSED yet devices. Here is 'boot-benchmark' before and after patch:

             : libvirt backend : direct backend
------------------------------------------------
master       : 835.2ms ±1.1ms  : 670.4ms ±0.3ms
master+patch : 837.7ms ±2.4ms  : 671.8ms ±0.2ms
2018-01-16 09:49:21 +00:00
Richard W.M. Jones
0cc6737374 appliance: Print /etc/resolv.conf in debugging output. 2017-10-11 17:58:15 +01:00
Richard W.M. Jones
4d869035b8 appliance: Create /dev/shm (RHBZ#1500537).
This is required by ansible and probably other applications.

Thanks: Nicolas Hicher
2017-10-11 17:58:15 +01:00
Richard W.M. Jones
9fdc495602 appliance/init: Allow daemon stack traces to be captured by gdb.
This fragment, not enabled by default, allows stack traces to be
captured and displayed by gdb in case the daemon crashes.
2017-06-21 16:12:09 +01:00
Richard W.M. Jones
fa6bc0fd83 init: Add comment that we should consider using /proc/consoles.
Although we can't use it at the moment because it is incorrect
on at least s390x (RHBZ#1351968).
2017-05-18 19:02:01 +01:00
Richard W.M. Jones
8c58b62f9d Replace possessive ASCII apostrophe ('s) with Unicode apostrophe (’s).
Only replaced in end-user messages and documentation, not in code,
comments, or anything else that's not end-user visible.

See: https://www.cl.cam.ac.uk/~mgk25/ucs/quotes.html
2017-03-31 10:38:04 +01:00
Pino Toscano
e48c17b10d appliance: run systemd-tmpfiles also for /var/run
Commit a6330e9d3a enabled /run for
systemd-tmpfiles: while this works fine in most of the cases, there are
few tmpfiles configurations that still references /var/run instead of
/run.  As result, include also /var/run in the systemd-tmpfiles
execution.
2017-03-13 08:53:49 +01:00
Richard W.M. Jones
33d2ae7961 rescue: Implement -m and -i options.
`virt-rescue -a disk -i' does the right thing.

`-m' was previously an alternate form of `--memsize'.  By sniffing the
parameter we can make `-m MB' continue to work, while also allowing
`-m' to be used as a short form for the `--mount' option.

This also removes most of the description of `--suggest' from the man
page, since it is no longer needed.
2017-03-07 12:47:52 +00:00
Richard W.M. Jones
32d6080144 rescue: Modify virt-rescue so it doesn't use direct mode (RHBZ#1152819, RHBZ#1171654).
Instead of using "direct mode" (which was basically a quick hack),
virt-rescue now launches the appliance with a running daemon.

The daemon doesn't do much -- there is still a bash shell which the
user interacts with.  The daemon is there simply to provide the
initial GUESTFS_LAUNCH_FLAG message and to handle shutdown a bit more
gracefully.

To interact with the shell, and replacing direct mode, virt-rescue now
prints out log messages (the output of the shell), and sends input
typed by the user directly to the console socket.  This uses the
guestfs_internal_get_console_socket API added previously.  Most of the
complexity behind this is hidden in virt-rescue.

This fully fixes the handling of ^C (RHBZ#1152819).  Also there were
earlier reports that full screen commands like 'vim' didn't work well,
(RHBZ#1171654), but in this version vim appears to work fine, albeit
only using 80x24 of the screen because of the serial console.
2017-03-07 12:47:52 +00:00
Richard W.M. Jones
8c73e9aa4e appliance: Fix job control in virt-rescue.
See comment and link to busybox FAQ for explanation.
2017-03-07 12:47:51 +00:00
Pino Toscano
b01416121f appliance: mount also /dev/pts
Tools could require the use of pseudo-terminals, so make sure we have
/dev/pts available in the appliance.  The "command" API already
bind-mounts it when running commands, so this is the only bit needed.
2016-12-06 18:11:44 +01:00
Pino Toscano
a6330e9d3a appliance: run systemd-tmpfiles also for /run
Setup the volatile /run in the appliance also with the tmpfiles
configurations available.  In particular, setting up correctly the lvm
bits allow lvmetad to run.
2016-07-26 18:24:40 +02:00
Pino Toscano
2c4f154b91 daemon: lvm-filter: start lvmetad better
Currently lvmetad is started in init, and thus using the system
(= appliance) configuration of lvm.  Later on, in the daemon, a local
copy of the lvm configuration is setup, and set it for use using the
LVM_SYSTEM_DIR environment variable: this means only the programmes
executed by the daemon will use the local lvm configuration, and not
lvmetad.

Thus manually start lvmetad from the daemon, right after having setup
the local lvm configuration, and still without failing if it cannot be
executed.

Additionally, since lvmetad now respects the right configuration, make
sure to update its cache when rescanning the VGs by passing --cache to
vgscan.
2016-07-26 18:24:31 +02:00
Pino Toscano
fd60be9509 appliance: touch /etc/fstab when enabling the network (RHBZ#1224795)
Sadly, the dhclient-script shipped as part of isc-dhcp-client in Ubuntu
unconditionally reads from /etc/fstab without checking for its
existence.  Since no package holds /etc/fstab, this file will not exist
in the appliance, cause dhclient to fail (actually keep looping calling
the failing dhclient-script) when the network is requested.

As a workaround, touch /etc/fstab just before enabling the network: if
that file exists nothing changes, while an empty file will be available
in the other case, making at least dhclient-script in Ubuntu working.
2016-07-14 14:09:18 +02:00
Cédric Bosdonnat
89ae53ecdd appliance: skip /etc/mtab creation is already existing
At least on openSUSE and SLES, the /etc/mtab file is already existing.
Skipping the symlink creation in init removes one error message during
the appliance boot.
2016-05-19 19:06:00 +02:00
Richard W.M. Jones
8a4dcde16a appliance: Find udevd a bit faster.
Rearrange the paths that we check for udevd so that the systemd paths
are first.  Break from the loop as soon as we find udevd.
2016-05-17 15:35:20 +01:00
Richard W.M. Jones
ba8e8d277d Revert "appliance: init: run ldconfig"
Running ldconfig adds about 100ms to the boot time.  I would prefer
that we understood which libraries need ldconfig to be run, and fix
that.  We could also consider running ldconfig in parallel, but since
it might be required by just about any binary that the init script
runs it's not clear what benefit that gives.

This reverts commit 66aa98265d.
2016-05-13 13:30:39 +01:00
Pino Toscano
807433bc23 appliance: init: generate /etc/machine-id
Some of the systemd-tmpfiles snippets need the machine ID of the running
system; the current lack of this file produces warning messages during
the appliance boot like:

[/usr/lib/tmpfiles.d/systemd.conf:26] Failed to replace specifiers: /run/log/journal/%m
[/usr/lib/tmpfiles.d/systemd.conf:28] Failed to replace specifiers: /run/log/journal/%m
[/usr/lib/tmpfiles.d/systemd.conf:29] Failed to replace specifiers: /run/log/journal/%m

Thus create a new randomly-generated /etc/machine-id on boot.
2016-03-30 10:15:49 +02:00
Richard W.M. Jones
0ba59db611 tests/qemu: Add program for tracing and analyzing boot times. 2016-03-23 13:25:46 +00:00
Richard W.M. Jones
f36ba38886 appliance: init: Don't run hwclock command.
This command alone took 0.3 seconds which is about 10% of the current
launch time.  It appears to be unnecessary.

This reverts commit 508f1ee87e.
2016-03-23 12:58:15 +00:00
Richard W.M. Jones
705b721b42 appliance: init: Mount selinuxfs along with other special filesystems.
Move this earlier.
2016-03-23 12:58:15 +00:00
Richard W.M. Jones
cb8f69e959 appliance: init: Move cmdline parsing earlier.
Since commit bb5d30ab2a, we don't
require any external programs like grep to parse the command line.  We
only use bash intrinsics.

Therefore we can do it early (but after /proc is mounted).

This allows verbose mode to enable set -x early on, so we can trace
most things that the init script does.
2016-03-23 12:58:15 +00:00
Richard W.M. Jones
d368fa0895 appliance: When using verbose mode, 'set -x' in the appliance init script. 2016-03-23 12:58:15 +00:00
Pino Toscano
bb5d30ab2a appliance: use bash features for string matching in files
Read the content of /proc/cmdline using bash features, and use its
[[ ... ]] expression to find texts in a variable.

This shaves off 5 grep invocations.
2016-03-22 22:30:59 +00:00
Richard W.M. Jones
5897b3bbad appliance: Quiet some warnings about missing files.
Try to make the appliance script as quiet as possible along
the fast path.
2016-03-18 13:18:13 +00:00
Richard W.M. Jones
23028cb30d appliance: Make it clear that the init script is a bash script.
We have used /bin/sh here since 2009.  However this is a bash
script and probably won't work well with other shells.
2016-03-18 13:18:13 +00:00
Richard W.M. Jones
7bc6fb2451 build: Remove ./configure --enable-valgrind-daemon.
If you've ever tried to use this option, you'll know that it didn't
work well.  It broke random things (probably RHBZ#1020216, definitely
RHBZ#1023630), and caused random failures generally, while often not
actually failing when valgrind itself found problems.
2015-10-01 15:32:49 +01:00
Cédric Bosdonnat
2d2a65504d appliance init: find NIC name for dhcpcd
dhcpcd requires an interface name as parameter to work. We are now
getting it from /proc/sys/net/ipv4/conf/ folder children. dhclient
on Debian also has the problem, thus use the guessed interface name
for it too.
2015-07-29 17:31:33 +01:00
Richard W.M. Jones
8cb1a35d75 daemon: Move all the kernel command line parsing to the init script.
Instead of parsing /proc/cmdline from the daemon, move all of that
parsing into the init script, and pass the argument via the daemon
command line.

For example, previously the daemon and init script both looked for
guestfs_network=1 in /proc/cmdline.  Now the init script still looks
for it, and if found it runs `guestfsd --network'.
2015-06-29 23:08:43 +01:00
Richard W.M. Jones
34439a04f1 appliance: Make sure /tmp and /var/tmp are real directories.
Currently if /tmp (on the host) is a symlink, then the symlink is
copied into the appliance, probably pointing to a non-existent
directory, and everything goes downhill from there.

Avoid this by making sure that /tmp and /var/tmp are real directories.
2015-06-06 14:04:40 +01:00
Richard W.M. Jones
4e9bda4598 appliance: Create /etc/mtab in init script to work around util-linux nuttiness. 2015-02-28 11:10:31 +00:00
Richard W.M. Jones
3dabc7a7ba appliance: When running systemd-tmpfiles, pass --boot option (RHBZ#1165785).
This causes all tmpfiles to be created.
2014-11-20 13:05:26 +00:00
Richard W.M. Jones
8e78a83067 appliance: Create tmpfiles before running udev.
This is the same order as systemd would run them.
2014-11-20 13:04:45 +00:00
Richard W.M. Jones
07c0926b58 appliance: Change example ping lines to ping 8.8.8.8.
This are commented out (still) so this change does nothing.
2014-10-02 15:31:50 +01:00
Richard W.M. Jones
67e6f32a24 appliance: Use dhclient or dhcpcd instead of hard-coding IP address of appliance.
qemu in SLIRP mode offers DHCP services to the appliance.  We don't
use them, but use a fixed IP address intead.  This changes the
appliance to get its IP address using DHCP.

Note: This is only used when the network is enabled.  dhclient is
somewhat slower, but the penalty (a few seconds) is only paid for
network users.

On SuSE or other distros, dhcpcd could be used if available.
2014-10-02 15:31:49 +01:00