virsh – matoken's blog https://matoken.org/blog Is there no plan B? Mon, 25 May 2026 22:18:04 +0000 ja hourly 1 https://wordpress.org/?v=7.0 https://matoken.org/blog/wp-content/uploads/2025/03/cropped-1865f695c4eecc844385acef2f078255036adccd42c254580ea3844543ab56d9-32x32.jpeg virsh – matoken's blog https://matoken.org/blog 32 32 virsh consoleで仮想マシンに接続できない https://matoken.org/blog/2026/05/26/virsh-console-console-connection-failed/ https://matoken.org/blog/2026/05/26/virsh-console-console-connection-failed/#respond Mon, 25 May 2026 22:16:34 +0000 https://matoken.org/blog/?p=5486
virt manager

virsh consoleコマンドでvmに繋がらなくなりました.

$ virsh console openbsd7.9
error: operation failed: Active console session exists for this domain

エラーメッセージから検索してdaemonを再起動したり,hostを再起動しても駄目です.

virshのmanを見るとこんなオプションが.

Option‐ally the --force flag may be specified, requesting to disconnect any existing sessions, such as in a case of a broken connection.
— `man 1 virsh`

--force オプションをを付けると繋がり,一度繋がると --force 無しでも繋がるようになりました.

$ virsh console openbsd7.9 --force
Connected to domain 'openbsd7.9'
Escape character is ^] (Ctrl + ])
^]
$ virsh console openbsd7.9
Connected to domain 'openbsd7.9'
Escape character is ^] (Ctrl + ])

fugu$ pfetch
      _____       matoken@fugu.matoken.org
    \-     -/     os     OpenBSD 7.9
 \_/         \    host   pc-i440fx-9.1
 |        O O |   uptime 1h 56m
 |_  <   )  3 )   pkgs   117
 / \         /    memory 169M / 989M
    /-_____-\

fugu$

恐らく電池切れでホストのOSが強制終了したときに既存のセッション情報が残ってしまい今回のような状態になったのだと思います.

環境
$ dpkg-query -W libvirt-clients libvirt-daemon
libvirt-clients 12.3.0-1
libvirt-daemon  12.3.0-1
$ uname -rm
7.0.9+deb14-amd64 x86_64
$ lsb_release -dr
Description:    Debian GNU/Linux forky/sid
Release:        n/a
$ arch
x86_64
]]>
https://matoken.org/blog/2026/05/26/virsh-console-console-connection-failed/feed/ 0