Skip to content

Commit e385e26

Browse files
authored
Merge pull request #11136 from ru-fu/LXD-268-instances-doc
doc/instances: clean up devices overview section
2 parents 0294ee9 + 582ea72 commit e385e26

File tree

11 files changed

+73
-67
lines changed

11 files changed

+73
-67
lines changed

doc/explanation/instance_config.md

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,14 +21,26 @@ Instance options
2121

2222
In the YAML configuration, options are located under the `config` entry.
2323

24-
See {ref}`instance-options` for a reference of available instance options.
24+
See {ref}`instance-options` for a reference of available instance options, and {ref}`instances-configure-options` for instructions on how to configure the options.
25+
26+
Instance devices
27+
: Instance devices are attached to an instance.
28+
They include, for example, network interfaces, mount points, USB and GPU devices.
29+
Devices are usually added after an instance is created with the `lxc config device add` command, but they can also be added to a profile or a YAML configuration file that is used to create an instance.
30+
31+
Each type of device has its own specific set of options, referred to as *instance device options*.
32+
33+
In the YAML configuration, devices are located under the `devices` entry.
34+
35+
See {ref}`devices` for a reference of available devices and the corresponding instance device options, and {ref}`instances-configure-devices` for instructions on how to add and configure instance devices.
2536

2637
```{toctree}
2738
:maxdepth: 1
2839
:hidden:
2940
3041
../reference/instance_properties.md
3142
../reference/instance_options.md
43+
../reference/devices.md
3244
Override QEMU configuration <../howto/instance_qemu_config.md>
3345
../reference/instance_units.md
3446
```

doc/howto/instances_configure.md

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ See the following sections for instructions.
99
To store and reuse different instance configurations, use {ref}`profiles <profiles>`.
1010
```
1111

12+
(instances-configure-options)=
1213
## Configure instance options
1314

1415
You can specify instance options when you {ref}`create an instance <instances-create>`.
@@ -31,15 +32,29 @@ Others are updated only when the instance is restarted.
3132
See the "Live update" column in the {ref}`instance-options` table for information about which options are applied immediately while the instance is running.
3233
```
3334

35+
(instances-configure-devices)=
3436
## Configure devices
3537

3638
To add and configure an instance device for your instance, use the `lxc config device add` command.
37-
Specify the instance name, a device name, the device type and maybe device options (depending on the {ref}`device type <device-types>`):
39+
Generally, devices can be added or removed for a container while it is running.
40+
VMs support hotplugging for some device types, but not all.
41+
42+
Specify the instance name, a device name, the device type and maybe device options (depending on the {ref}`device type <devices>`):
3843

3944
lxc config device add <instance_name> <device_name> <device_type> <device_option_key>=<device_option_value> <device_option_key>=<device_option_value> ...
4045

4146
See {ref}`devices` for a list of available device types and their options.
4247

48+
```{note}
49+
Every device entry is identified by a name unique to the instance.
50+
51+
Devices from profiles are applied to the instance in the order in which the profiles are assigned to the instance.
52+
Devices defined directly in the instance configuration are applied last.
53+
At each stage, if a device with the same name already exists from an earlier stage, the whole device entry is overridden by the latest definition.
54+
55+
Device names are limited to a maximum of 64 characters.
56+
```
57+
4358
For example, to add the storage at `/share/c1` on the host system to your instance at path `/opt`, enter the following command:
4459

4560
lxc config device add my-container disk-storage-device disk source=/share/c1 path=/opt
@@ -48,6 +63,9 @@ To configure instance device options for a device that you have added earlier, u
4863

4964
lxc config device set <instance_name> <device_name> <device_option_key>=<device_option_value> <device_option_key>=<device_option_value> ...
5065

66+
To remove a device, use the `lxc config device remove` command.
67+
See `lxc config device --help` for a full list of available commands.
68+
5169
## Display instance configuration
5270

5371
To display the current configuration of your instance, including writable instance properties, instance options, devices and device options, enter the following command:

doc/instances.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,5 +13,4 @@ Run commands <instance-exec.md>
1313
Access the console <howto/instances_console.md>
1414
Access files <howto/instances_access_files.md>
1515
explanation/instance_config.md
16-
explanation/devices.md
1716
```

doc/profiles.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ Enter the following command to create an empty profile:
3535

3636
lxc profile create <profile_name>
3737

38+
(profiles-edit)=
3839
## Edit a profile
3940

4041
You can either set specific configuration options for a profile or edit the full profile in YAML format.
@@ -47,7 +48,7 @@ Specify the profile name and the key and value of the instance option:
4748
lxc profile set <profile_name> <option_key>=<option_value> <option_key>=<option_value> ...
4849

4950
To add and configure an instance device for your profile, use the `lxc profile device add` command.
50-
Specify the profile name, a device name, the device type and maybe device options (depending on the {ref}`device type <device-types>`):
51+
Specify the profile name, a device name, the device type and maybe device options (depending on the {ref}`device type <devices>`):
5152

5253
lxc profile device add <instance_name> <device_name> <device_type> <device_option_key>=<device_option_value> <device_option_key>=<device_option_value> ...
5354

Lines changed: 5 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -1,61 +1,11 @@
11
(devices)=
22
# Devices
33

4-
Devices are attached to an instance.
4+
Devices are attached to an instance (see {ref}`instances-configure-devices`) or to a profile (see {ref}`profiles-edit`).
5+
56
They include, for example, network interfaces, mount points, USB and GPU devices.
67
These devices can have instance device options, depending on the type of the instance device.
78

8-
## Standard devices
9-
10-
LXD will always provide the instance with the basic devices which are required
11-
for a standard POSIX system to work. These aren't visible in instance or
12-
profile configuration and may not be overridden.
13-
14-
Those include:
15-
16-
- `/dev/null` (character device)
17-
- `/dev/zero` (character device)
18-
- `/dev/full` (character device)
19-
- `/dev/console` (character device)
20-
- `/dev/tty` (character device)
21-
- `/dev/random` (character device)
22-
- `/dev/urandom` (character device)
23-
- `/dev/net/tun` (character device)
24-
- `/dev/fuse` (character device)
25-
- `lo` (network interface)
26-
27-
Anything else has to be defined in the instance configuration or in one of its
28-
profiles. The default profile will typically contain a network interface to
29-
become `eth0` in the instance.
30-
31-
## How to add devices
32-
33-
To add extra devices to an instance, device entries can be added directly to an
34-
instance, or to a profile.
35-
36-
Devices may be added or removed while the instance is running.
37-
38-
Every device entry is identified by a unique name. If the same name is used in
39-
a subsequent profile or in the instance's own configuration, the whole entry
40-
is overridden by the new definition.
41-
42-
Device names are limited to a maximum of 64 characters.
43-
44-
Device entries are added to an instance through:
45-
46-
```bash
47-
lxc config device add <instance> <name> <type> [key=value]...
48-
```
49-
50-
or to a profile with:
51-
52-
```bash
53-
lxc profile device add <profile> <name> <type> [key=value]...
54-
```
55-
56-
(device-types)=
57-
## Device types
58-
599
LXD supports the following device types:
6010

6111
| ID (database) | Name | Condition | Description |
@@ -73,10 +23,13 @@ LXD supports the following device types:
7323
| 10 | [`tpm`](devices-tpm) | - | TPM device |
7424
| 11 | [`pci`](devices-pci) | VM | PCI device |
7525

26+
Each instance comes with a set of {ref}`standard-devices`.
27+
7628
```{toctree}
7729
:maxdepth: 1
7830
:hidden:
7931
32+
../reference/standard_devices.md
8033
../reference/devices_none.md
8134
../reference/devices_nic.md
8235
../reference/devices_disk.md

doc/reference/devices_disk.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
(devices-disk)=
22
# Type: `disk`
33

4-
Supported instance types: container, VM
4+
Supported instance types: container, VM (supports hotplugging)
55

66
Disk entries are essentially mount points inside the instance. They can
77
either be a bind-mount of an existing file or directory on the host, or

doc/reference/devices_gpu.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ Key | Type | Default | Required | Description
5656

5757
## `gpu`: `mig`
5858

59-
Supported instance types: container
59+
Supported instance types: container (does not support hotplugging)
6060

6161
Creates and passes through a MIG compute instance. This currently requires NVIDIA MIG instances to be pre-created.
6262

doc/reference/devices_nic.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ The following NICs can be specified using only the `nictype` property:
3939
(instance_device_type_nic_bridged)=
4040
## `nic`: `bridged`
4141

42-
Supported instance types: container, VM
42+
Supported instance types: container, VM (supports hotplugging)
4343

4444
Selected using: `nictype`, `network`
4545

@@ -76,7 +76,7 @@ Key | Type | Default | Required | Managed | De
7676

7777
## `nic`: `macvlan`
7878

79-
Supported instance types: container, VM
79+
Supported instance types: container, VM (supports hotplugging)
8080

8181
Selected using: `nictype`, `network`
8282

@@ -99,7 +99,7 @@ Key | Type | Default | Required | Managed | Des
9999

100100
## `nic`: `sriov`
101101

102-
Supported instance types: container, VM
102+
Supported instance types: container, VM (supports hotplugging)
103103

104104
Selected using: `nictype`, `network`
105105

@@ -186,7 +186,7 @@ ip link set enp9s0f0np0 up
186186

187187
## `nic`: `physical`
188188

189-
Supported instance types: container, VM
189+
Supported instance types: container, VM (supports hotplugging)
190190

191191
Selected using: `nictype`
192192

@@ -208,7 +208,7 @@ Key | Type | Default | Required | Description
208208

209209
## `nic`: `ipvlan`
210210

211-
Supported instance types: container
211+
Supported instance types: container (does not support hotplugging)
212212

213213
Selected using: `nictype`
214214

@@ -255,7 +255,7 @@ Key | Type | Default | Required | Description
255255

256256
## `nic`: `p2p`
257257

258-
Supported instance types: container, VM
258+
Supported instance types: container, VM (supports hotplugging)
259259

260260
Selected using: `nictype`
261261

@@ -278,7 +278,7 @@ Key | Type | Default | Required | Description
278278

279279
## `nic`: `routed`
280280

281-
Supported instance types: container, VM
281+
Supported instance types: container, VM (supports hotplugging)
282282

283283
Selected using: `nictype`
284284

doc/reference/devices_proxy.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ discourse: 8355
55
(devices-proxy)=
66
# Type: `proxy`
77

8-
Supported instance types: container (`nat` and non-`nat` modes), VM (`nat` mode only)
8+
Supported instance types: container (`nat` and non-`nat` modes), VM (`nat` mode only, supports hotplugging)
99

1010
Proxy devices allow forwarding network connections between host and instance.
1111
This makes it possible to forward traffic hitting one of the host's

doc/reference/devices_usb.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
(devices-usb)=
22
# Type: `usb`
33

4-
Supported instance types: container, VM
4+
Supported instance types: container, VM (supports hotplugging)
55

66
USB device entries simply make the requested USB device appear in the
77
instance.

0 commit comments

Comments
 (0)