Dynamic network configuration

Is it possible to (virtually) disconnect/reconnect “network cable” (bridged network) to a running container?
On the same line: is it possible to dynamically add/change “cd-rom images” to running VMs?

I know how to do that on a stopped container, but that is not what I need.


Adding/removing disk to VMs is supported in 5.0 so you can use lxc config device add to add/remove disk devices (which also apply to cdrom).

For bouncing the network, if the network was configured through a profile, you can temporarily mask it and add it back with:

  • lxc config device add NAME eth0 none
  • lxc config device remove NAME eth0

If the instance has its own network device in local config, then you’d need to remove the device and add it back, which means recording all its properties so you can add it back correctly.

Thanks Stéphane!
Do I read you correctly if I say adding/removing disk/device/whatever to a running container/vm will be honored immediately without restart?
I did not understand it that way (my bad, of course).

Yes, we apply things immediately at runtime.

You can see an example of it in What's new in LXD 5.0 LTS? - YouTube

I must have misunderstood something :frowning:

mcon@ikea:~$ lxc config device add WinX eth0 none
Error: Failed to add device "eth0": Device cannot be added when instance is running

My (tentative) win10 VM has a very simple configuration:

mcon@ikea:~$ lxc config show WinX
architecture: x86_64
  limits.cpu: "4"
  limits.memory: 4GB
  security.secureboot: "false"
  volatile.cloud-init.instance-id: 4c596810-7a7a-480a-acae-d0b0329df70e
  volatile.last_state.power: RUNNING
  volatile.uuid: b6bd543d-8063-4dbc-a071-4e5481e4de33
  volatile.vsock_id: "28"
    boot.priority: "10"
    source: /home/mcon/projects/Win10_21H2_English_x64_repacked.iso
    type: disk
    path: /
    pool: default
    size: 20GB
    type: disk
ephemeral: false
- default
stateful: false
description: ""

with a completely standard default profile:

mcon@ikea:~$ lxc profile show default
config: {}
description: Default LXD profile
    name: eth0
    network: lxdbr0
    type: nic
    path: /
    pool: default
    type: disk
name: default
- /1.0/instances/yocto-builder
- /1.0/instances/zero
- /1.0/instances/ztncui
- /1.0/instances/zdev
- /1.0/instances/WinX

What am I missing?