Snippet to run a Debian GNU/Linux bullseye VM in libvirt

$ sudo virt-builder debian-11 --output debian-11.qcow2 --size 6G --format qcow2 --run-command 'apt-get --allow-releaseinfo-change update' --install sudo --run-command 'dpkg-reconfigure --frontend=noninteractive openssh-server' --run-command 'useradd -s /bin/bash -m debian || true ; echo "debian ALL=(ALL) NOPASSWD:ALL" > /etc/sudoers.d/90-debian'
[   1.1] Downloading: http://builder.libguestfs.org/debian-11.xz
[   1.7] Planning how to build this image
[   1.7] Uncompressing
[   6.7] Converting raw to qcow2
[   7.7] Opening the new disk
[  10.8] Setting a random seed
virt-builder: warning: random seed could not be set for this type of guest
[  10.9] Running: apt-get --allow-releaseinfo-change update
[  16.9] Installing packages: sudo
[  39.7] Running: dpkg-reconfigure --frontend=noninteractive openssh-server
[  40.7] Running: useradd -s /bin/bash -m debian || true ; echo "debian ALL=(ALL) NOPASSWD:ALL" > /etc/sudoers.d/90-debian
[  40.7] Setting passwords
virt-builder: Setting random password of root to c84LEYjuDB6nyepk
[  41.5] Finishing off
                   Output file: debian-11.qcow2
                   Output size: 6.0G
                 Output format: qcow2
            Total usable space: 5.8G
                    Free space: 4.8G (82%)
$ sudo virt-sysprep -a $(pwd)/debian-11.qcow2 --run-command 'dpkg-reconfigure --frontend=noninteractive openssh-server' --run-command 'useradd -s /bin/bash -m debian || true ; echo "debian ALL=(ALL) NOPASSWD:ALL" > /etc/sudoers.d/90-debian' --edit '/etc/network/interfaces: s/ens2/enp1s0/' --ssh-inject debian:file:$HOME/.ssh/id_rsa.pub
[   0.0] Examining the guest ...
[   2.9] Performing "abrt-data" ...
[   2.9] Performing "backup-files" ...
[   3.1] Performing "bash-history" ...
[   3.1] Performing "blkid-tab" ...
[   3.1] Performing "crash-data" ...
[   3.2] Performing "cron-spool" ...
[   3.2] Performing "dhcp-client-state" ...
[   3.2] Performing "dhcp-server-state" ...
[   3.2] Performing "dovecot-data" ...
[   3.2] Performing "logfiles" ...
[   3.3] Performing "machine-id" ...
[   3.3] Performing "mail-spool" ...
[   3.3] Performing "net-hostname" ...
[   3.4] Performing "net-hwaddr" ...
[   3.4] Performing "pacct-log" ...
[   3.4] Performing "package-manager-cache" ...
[   3.4] Performing "pam-data" ...
[   3.5] Performing "passwd-backups" ...
[   3.5] Performing "puppet-data-log" ...
[   3.5] Performing "rh-subscription-manager" ...
[   3.6] Performing "rhn-systemid" ...
[   3.6] Performing "rpm-db" ...
[   3.6] Performing "samba-db-log" ...
[   3.6] Performing "script" ...
[   3.6] Performing "smolt-uuid" ...
[   3.7] Performing "ssh-hostkeys" ...
[   3.7] Performing "ssh-userdir" ...
[   3.7] Performing "sssd-db-log" ...
[   3.7] Performing "tmp-files" ...
[   3.8] Performing "udev-persistent-net" ...
[   3.8] Performing "utmp" ...
[   3.8] Performing "yum-uuid" ...
[   3.8] Performing "customize" ...
[   3.9] Setting a random seed
virt-sysprep: warning: random seed could not be set for this type of guest
[   3.9] Setting the machine ID in /etc/machine-id
[   3.9] Running: dpkg-reconfigure --frontend=noninteractive openssh-server
[   4.8] Running: useradd -s /bin/bash -m debian || true ; echo "debian ALL=(ALL) NOPASSWD:ALL" > /etc/sudoers.d/90-debian
[   4.9] Editing: /etc/network/interfaces
[   5.0] SSH key inject: debian
[   5.7] Performing "lvm-uuids" ...
$ virt-install --connect qemu:///system --boot hd --name debianvm --memory 2048 --vcpus 1 --cpu host --disk path=$(pwd)/debian-11.qcow2,bus=virtio,format=qcow2 --os-type=linux --os-variant=debian10 --noautoconsole

Starting install...
Domain creation completed.
$ virsh domifaddr debianvm
 Name       MAC address          Protocol     Address
-------------------------------------------------------------------------------
 vnet0      52:54:00:bb:e3:a2    ipv4         192.168.122.32/24
$ $ ssh debian@192.168.122.32
Warning: Permanently added '192.168.122.32' (ECDSA) to the list of known hosts.
Linux unassigned-hostname 5.10.0-9-amd64 #1 SMP Debian 5.10.70-1 (2021-09-30) x86_64

The programs included with the Debian GNU/Linux system are free software;
the exact distribution terms for each program are described in the
individual files in /usr/share/doc/*/copyright.

Debian GNU/Linux comes with ABSOLUTELY NO WARRANTY, to the extent
permitted by applicable law.
Last login: Tue Mar 29 17:58:40 2022 from 192.168.122.1
debian@unassigned-hostname:~$ sudo apt-get update
Hit:1 http://security.debian.org/debian-security bullseye-security InRelease
Hit:2 http://deb.debian.org/debian bullseye InRelease
Hit:3 http://deb.debian.org/debian bullseye-updates InRelease
Reading package lists... Done
debian@unassigned-hostname:~$