Гостевой агент был добавлен: машины из готовых образов ставят qemu-guest-agent, панель видит их IP и в домашней сети

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_019LEUXMcdZo7b87mjkUsPgg
Этот коммит содержится в:
Claude
2026-09-25 15:27:25 +00:00
родитель 024fe5a267
Коммит 1d39029472
3 изменённых файлов: 22 добавлений и 10 удалений
+14 -9
Просмотреть файл
@@ -406,15 +406,17 @@ def parse_virsh_list() -> list[dict[str, str]]:
return []
def ip_from_domifaddr(name: str) -> str:
try:
result = run_cmd(["virsh", "domifaddr", name], timeout=8)
if result.get("ok"):
for ip in re.findall(r"\b(\d{1,3}(?:\.\d{1,3}){3})/\d+", result.get("stdout", "")):
ip = clean_ip(ip)
if ip:
return ip
except Exception:
pass
# DHCP lease first (NAT network), then the guest agent (machines in the home network via br0).
for extra in ([], ["--source", "agent"]):
try:
result = run_cmd(["virsh", "domifaddr", name, *extra], timeout=8)
if result.get("ok"):
for ip in re.findall(r"\b(\d{1,3}(?:\.\d{1,3}){3})/\d+", result.get("stdout", "")):
ip = clean_ip(ip)
if ip:
return ip
except Exception:
pass
return ""
def ip_from_network_core(name: str) -> str:
@@ -1860,6 +1862,9 @@ def vm_create_submit(request: Request, name: str = Form(...), memory: int = Form
# Windows 11 refuses to install without a TPM 2.0.
cmd += ["--tpm", "model=tpm-crb,backend.type=emulator,backend.version=2.0"]
graphics = ["--graphics", "vnc,listen=127.0.0.1", "--noautoconsole"]
if not windows:
# Channel for qemu-guest-agent (installed by cloud-init; on ISO installs — by the user or the distro).
graphics = ["--channel", "unix,target.type=virtio,target.name=org.qemu.guest_agent.0", *graphics]
seed_file = ""
login_hint = ""
+5 -1
Просмотреть файл
@@ -77,7 +77,11 @@ def build_user_data(hostname: str, user: str, password_hash: str, ssh_keys: list
" mode: auto",
" devices: ['/']",
"resize_rootfs: true",
"package_update: false",
# The guest agent lets the panel see the machine's address in any network and shut it down cleanly.
"package_update: true",
"packages: [qemu-guest-agent]",
"runcmd:",
" - [sh, -c, 'systemctl enable --now qemu-guest-agent 2>/dev/null || { rc-update add qemu-guest-agent default && rc-service qemu-guest-agent start; } || true']",
]
return "\n".join(lines) + "\n"