diff --git a/instances/forms.py b/instances/forms.py index 37310a56..1e8f4e0a 100644 --- a/instances/forms.py +++ b/instances/forms.py @@ -55,6 +55,9 @@ class ConsoleForm(forms.Form): types = [("vnc", "VNC")] if settings.SERIAL_CONSOLE_ENABLED: types.append(("pty", _("Serial (xterm; the guest needs a getty on ttyS0)"))) + # a type the panel does not create (SPICE) is offered, so a save keeps it + if instance.config_console_type not in (None, "pty", "vnc"): + types.append((instance.config_console_type, instance.config_console_type.upper())) self.fields["console_type"].choices = types # the VNC settings are shown and saved while the console is VNC; a # switch to Serial ignores them @@ -88,8 +91,11 @@ class ConsoleForm(forms.Form): if not password: self.add_error("password", _("Enter the new password.")) # VNC takes 8 bytes, and the browser console sends only ASCII as typed - elif len(password) > 8 or not all(" " <= c <= "~" for c in password): + elif (data.get("console_type") or self.initial["console_type"]) == "vnc" and ( + len(password) > 8 or not all(" " <= c <= "~" for c in password)): self.add_error("password", _("A VNC password takes up to 8 letters, digits or symbols, without accents.")) + elif not password.isprintable(): # a SPICE password + self.add_error("password", _("A password takes no line breaks or other control characters.")) # A console that listens beyond localhost (set by an administrator) # keeps its password unless an administrator removes it. if action == "none" and not self.is_superuser and not self.instance.proxy.console_listens_locally(): diff --git a/instances/tests/test_console_settings.py b/instances/tests/test_console_settings.py index 8835d783..5b1ab9e3 100644 --- a/instances/tests/test_console_settings.py +++ b/instances/tests/test_console_settings.py @@ -96,6 +96,21 @@ class UpdateConsoleTestCase(TestCase): form = ConsoleForm(instance=Instance.objects.get(pk=self.instance.pk), is_superuser=True) self.assertEqual((form["console_type"].value(), sorted(form.fields)), ("pty", ["console_type"])) + def test_a_spice_console_stays_spice_when_its_settings_are_saved(self): + # SPICE is not offered for new consoles: a save would have made it VNC + proxy, messages = self.post({**VNC, "console_type": "spice", "keymap": "de"}, console_type="spice") + self.assertEqual(messages, []) + proxy.set_console_type.assert_not_called() + proxy.set_console_keymap.assert_called_once_with("de") + proxy, _ = self.post({**VNC, "console_type": "vnc"}, console_type="spice") + proxy.set_console_type.assert_called_once_with("vnc") + # the VNC limits are not SPICE's + for password, saved in (("é-a-longer-one", True), ("a\nb", False)): + with self.subTest(password=password): + proxy, _ = self.post({**VNC, "console_type": "spice", "password_action": "set", "password": password}, + console_type="spice") + self.assertEqual(proxy.set_console_passwd.called, saved) + @override_settings(SERIAL_CONSOLE_ENABLED=False) def test_serial_is_not_offered_while_the_serial_console_is_off(self): proxy, _ = self.post({**VNC, "console_type": "pty"}) diff --git a/locale/tr/LC_MESSAGES/django.mo b/locale/tr/LC_MESSAGES/django.mo index c5bf9367..36f5be74 100644 Binary files a/locale/tr/LC_MESSAGES/django.mo and b/locale/tr/LC_MESSAGES/django.mo differ diff --git a/locale/tr/LC_MESSAGES/django.po b/locale/tr/LC_MESSAGES/django.po index 8b74973b..49e608b3 100644 --- a/locale/tr/LC_MESSAGES/django.po +++ b/locale/tr/LC_MESSAGES/django.po @@ -11,7 +11,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2026-11-13 19:25+0000\n" +"POT-Creation-Date: 2026-11-13 19:49+0000\n" "PO-Revision-Date: 2020-11-04 12:00+0000\n" "Last-Translator: catborise , 2020\n" "Language-Team: Turkish (https://www.transifex.com/catborise/teams/110663/tr/)\n" @@ -2834,29 +2834,33 @@ msgstr "Yeni parola" msgid "Serial (xterm; the guest needs a getty on ttyS0)" msgstr "Seri (xterm; konuk sistemde ttyS0 üzerinde getty gerekir)" -#: instances/forms.py:64 +#: instances/forms.py:67 msgid "Auto" msgstr "Otomatik" -#: instances/forms.py:73 +#: instances/forms.py:76 msgid "Listen on" msgstr "Dinlenen" -#: instances/forms.py:80 +#: instances/forms.py:83 msgid "Keymap" msgstr "Klavye eşlemi" -#: instances/forms.py:89 +#: instances/forms.py:92 msgid "Enter the new password." msgstr "Yeni parolayı girin." -#: instances/forms.py:92 +#: instances/forms.py:96 msgid "" "A VNC password takes up to 8 letters, digits or symbols, without accents." msgstr "" "VNC parolası en çok 8 harf, rakam ya da simge alır; aksanlı harf olmaz." #: instances/forms.py:98 +msgid "A password takes no line breaks or other control characters." +msgstr "Parola satır sonu ya da başka denetim karakteri içeremez." + +#: instances/forms.py:104 msgid "" "The console listens beyond localhost; only an administrator can remove its " "password." @@ -2864,7 +2868,7 @@ msgstr "" "Konsol localhost dışında da dinliyor; parolasını yalnızca bir yönetici " "kaldırabilir." -#: instances/forms.py:142 +#: instances/forms.py:148 msgid "The name of the virtual machine must not contain any special characters" msgstr "Sanal makine adı özel karakterler içeremez" @@ -2942,7 +2946,7 @@ msgstr "" msgid "Delete snapshot" msgstr "Anlık görüntüyü sil" -#: instances/jobs.py:356 vrtManager/instance.py:2389 +#: instances/jobs.py:356 vrtManager/instance.py:2404 #, python-format msgid "The VM has no external snapshot named %(name)s" msgstr "Sanal makinede %(name)s adında harici anlık görüntü yok" @@ -2977,7 +2981,7 @@ msgstr "Sanal makine artık işin çalıştığı sunucuda değil" msgid "Take snapshot" msgstr "Anlık görüntü al" -#: instances/jobs.py:424 instances/jobs.py:433 vrtManager/instance.py:1980 +#: instances/jobs.py:424 instances/jobs.py:433 vrtManager/instance.py:1995 #, python-format msgid "A snapshot named %(name)s already exists" msgstr "%(name)s adında bir anlık görüntü zaten var" @@ -3139,12 +3143,12 @@ msgstr "" msgid "Each network card needs a network" msgstr "Her ağ kartının bir ağı olmalı" -#: instances/jobs.py:851 vrtManager/instance.py:2847 +#: instances/jobs.py:851 vrtManager/instance.py:2863 #, python-format msgid "This host has no network %(name)s" msgstr "Bu sunucuda %(name)s ağı yok" -#: instances/jobs.py:853 vrtManager/instance.py:2849 +#: instances/jobs.py:853 vrtManager/instance.py:2865 #, python-format msgid "This host has no network filter %(name)s" msgstr "Bu sunucuda %(name)s ağ filtresi yok" @@ -3218,7 +3222,7 @@ msgstr "cloud-init tohumu, disk için bir dizin depolama havuzu gerektirir" msgid "This host offers no firmware %(firmware)s" msgstr "Bu sunucu %(firmware)s firmware'ini sunmuyor" -#: instances/jobs.py:939 vrtManager/instance.py:3196 +#: instances/jobs.py:939 vrtManager/instance.py:3212 msgid "This host offers no TPM 2.0: install swtpm on it" msgstr "Bu sunucu TPM 2.0 sunmuyor: üzerine swtpm kurun" @@ -4507,7 +4511,7 @@ msgid "Add USB device" msgstr "USB aygıtı ekle" #: instances/templates/instances/host_devices_form.html:18 -#: vrtManager/instance.py:3100 +#: vrtManager/instance.py:3116 msgid "" "A VM with a saved state does not change its USB devices: start it, or start " "it without its saved state" @@ -6530,7 +6534,7 @@ msgstr "Birim başarıyla değiştirildi." msgid "Disk %(dev)s is not a storage volume of this instance" msgstr "%(dev)s diski bu sanal makinenin bir depolama birimi değil" -#: instances/views.py:1554 vrtManager/instance.py:2399 +#: instances/views.py:1554 vrtManager/instance.py:2414 msgid "The VM has a saved state; start it or remove the saved state first" msgstr "" "Sanal makinenin kaydedilmiş durumu var; önce başlatın veya kaydedilmiş durumu" @@ -9613,11 +9617,11 @@ msgid "Please shutdown the instance then try to enable vCPU hotplug" msgstr "" "vCPU hotplug özelliğini etkinleştirmek için önce sanal makineyi kapatın" -#: vrtManager/instance.py:1762 +#: vrtManager/instance.py:1777 msgid "The VM has no video card" msgstr "Sanal makinede ekran kartı yok" -#: vrtManager/instance.py:1772 +#: vrtManager/instance.py:1787 #, python-format msgid "" "The VM's CPU topology has %(count)s vCPUs: change it in the XML editor to set" @@ -9626,62 +9630,62 @@ msgstr "" "VM'nin CPU topolojisi %(count)s vCPU içeriyor: başka bir en fazla değer için " "onu XML düzenleyicide değiştirin" -#: vrtManager/instance.py:1798 +#: vrtManager/instance.py:1813 #, python-format msgid "The VM's next start has a maximum memory of %(max)s MiB" msgstr "" "Sanal makinenin bir sonraki başlangıcındaki en yüksek bellek %(max)s MiB" -#: vrtManager/instance.py:1939 +#: vrtManager/instance.py:1954 msgid "" "The VM has external snapshots; internal snapshots cannot be mixed with them" msgstr "" "Sanal makinenin harici anlık görüntüleri var; dahili anlık görüntüler " "bunlarla karıştırılamaz" -#: vrtManager/instance.py:1971 +#: vrtManager/instance.py:1986 msgid "A snapshot with memory is not quiesced; it keeps the whole guest state" msgstr "" "Bellekli bir anlık görüntüde dosya sistemleri dondurulmaz; tüm konuk durumunu" " saklar" -#: vrtManager/instance.py:1973 +#: vrtManager/instance.py:1988 msgid "Only a running VM's file systems can be frozen" msgstr "Yalnızca çalışan bir sanal makinenin dosya sistemleri dondurulabilir" -#: vrtManager/instance.py:1975 +#: vrtManager/instance.py:1990 msgid "The QEMU guest agent is not connected; it freezes the file systems" msgstr "QEMU konuk aracısı bağlı değil; dosya sistemlerini o dondurur" -#: vrtManager/instance.py:1978 +#: vrtManager/instance.py:1993 msgid "" "The VM has internal snapshots; external snapshots cannot be mixed with them" msgstr "" "Sanal makinenin dahili anlık görüntüleri var; harici anlık görüntüler " "bunlarla karıştırılamaz" -#: vrtManager/instance.py:1983 +#: vrtManager/instance.py:1998 msgid "Newer snapshots exist after the last revert; delete them first" msgstr "" "Son geri dönüşten sonra daha yeni anlık görüntüler var; önce onları silin" -#: vrtManager/instance.py:1986 +#: vrtManager/instance.py:2001 msgid "No snapshot is current; revert to a snapshot first" msgstr "Geçerli anlık görüntü yok; önce bir anlık görüntüye geri dönün" -#: vrtManager/instance.py:1992 +#: vrtManager/instance.py:2007 #, python-format msgid "Eject the media from %(dev)s first" msgstr "Önce %(dev)s içindeki ortamı çıkarın" -#: vrtManager/instance.py:1994 +#: vrtManager/instance.py:2009 #, python-format msgid "Disk %(dev)s is not a file; external snapshots need file disks" msgstr "" "Disk %(dev)s bir dosya değil; harici anlık görüntüler dosya diskleri " "gerektirir" -#: vrtManager/instance.py:2002 +#: vrtManager/instance.py:2017 #, python-format msgid "" "The storage pools could not be refreshed, so their free space is unknown: " @@ -9689,21 +9693,21 @@ msgid "" msgstr "" "Depolama havuzları yenilenemedi, bu yüzden boş alanları bilinmiyor: %(err)s" -#: vrtManager/instance.py:2023 +#: vrtManager/instance.py:2038 msgid "Memory is saved only from a running VM" msgstr "Bellek yalnızca çalışan bir sanal makineden kaydedilir" -#: vrtManager/instance.py:2025 +#: vrtManager/instance.py:2040 msgid "The VM has no disk to keep its memory next to" msgstr "Sanal makinenin, belleğinin yanına kaydedileceği bir diski yok" -#: vrtManager/instance.py:2029 +#: vrtManager/instance.py:2044 #, python-format msgid "%(disk)s is not in a storage pool; memory is saved only into one" msgstr "" "%(disk)s bir depolama havuzunda değil; bellek yalnızca bir havuza kaydedilir" -#: vrtManager/instance.py:2060 +#: vrtManager/instance.py:2075 #, python-format msgid "" "Storage pool %(pool)s has %(free).1f GiB free; the snapshot needs %(size).1f " @@ -9714,7 +9718,7 @@ msgstr "" "%(size).1f GiB gerektiriyor (sanal makinenin oradaki disklerinin " "%%%(percent)g kadarı, en az %(minimum)g GiB, ve kaydediliyorsa bellek)" -#: vrtManager/instance.py:2078 +#: vrtManager/instance.py:2093 msgid "" "This snapshot was taken by an older version on a UEFI VM and cannot be " "reverted; delete it instead" @@ -9722,7 +9726,7 @@ msgstr "" "Bu anlık görüntü UEFI bir sanal makinede eski bir sürümle alındı ve geri " "dönülemez; bunun yerine silin" -#: vrtManager/instance.py:2108 +#: vrtManager/instance.py:2123 #, python-format msgid "" "The revert failed twice; try again in a moment (%(error)s). The VM is " @@ -9731,7 +9735,7 @@ msgstr "" "Geri dönüş iki kez başarısız oldu; biraz sonra tekrar deneyin (%(error)s). " "Sanal makine çalışıyor." -#: vrtManager/instance.py:2110 +#: vrtManager/instance.py:2125 #, python-format msgid "" "The revert failed twice; try again in a moment (%(error)s). The VM is shut " @@ -9740,13 +9744,13 @@ msgstr "" "Geri dönüş iki kez başarısız oldu; biraz sonra tekrar deneyin (%(error)s). " "Sanal makine kapalı." -#: vrtManager/instance.py:2278 +#: vrtManager/instance.py:2293 msgid "A disk moves when its VM is defined and running, paused or shut off" msgstr "" "Bir disk, sanal makinesi tanımlıyken ve çalışırken, duraklatılmışken veya " "kapalıyken taşınır" -#: vrtManager/instance.py:2280 +#: vrtManager/instance.py:2295 msgid "" "A disk of a VM with snapshots, a saved state or a running block job does not " "move" @@ -9754,7 +9758,7 @@ msgstr "" "Anlık görüntüleri, kaydedilmiş durumu veya çalışan bir blok işi olan sanal " "makinenin diski taşınmaz" -#: vrtManager/instance.py:2288 +#: vrtManager/instance.py:2303 #, python-format msgid "" "%(dev)s is not a disk file of the VM, the same in its running and next " @@ -9763,127 +9767,127 @@ msgstr "" "%(dev)s, sanal makinenin çalışan ve sonraki başlatma tanımlarında aynı olan " "bir disk dosyası değil" -#: vrtManager/instance.py:2293 +#: vrtManager/instance.py:2308 #, python-format msgid "%(dev)s does not move: only writable raw and qcow2 disks do" msgstr "%(dev)s taşınmaz: yalnızca yazılabilir raw ve qcow2 diskler taşınır" -#: vrtManager/instance.py:2300 +#: vrtManager/instance.py:2315 #, python-format msgid "%(dev)s does not move: no storage pool has %(path)s" msgstr "%(dev)s taşınmaz: hiçbir depolama havuzunda %(path)s yok" -#: vrtManager/instance.py:2302 +#: vrtManager/instance.py:2317 #, python-format msgid "%(dev)s does not move: it has a backing file" msgstr "%(dev)s taşınmaz: temel (backing) dosyası var" -#: vrtManager/instance.py:2305 +#: vrtManager/instance.py:2320 #, python-format msgid "%(pool_name)s is not an active pool of disk files of this host" msgstr "%(pool_name)s bu sunucunun etkin bir disk dosyası havuzu değil" -#: vrtManager/instance.py:2308 +#: vrtManager/instance.py:2323 #, python-format msgid "%(dev)s is in pool %(pool_name)s already" msgstr "%(dev)s zaten %(pool_name)s havuzunda" -#: vrtManager/instance.py:2312 +#: vrtManager/instance.py:2327 #, python-format msgid "Pool %(pool_name)s already has a file %(name)s" msgstr "%(pool_name)s havuzunda zaten %(name)s dosyası var" -#: vrtManager/instance.py:2336 +#: vrtManager/instance.py:2351 #, python-format msgid "The copy of %(dev)s ended before it was complete" msgstr "%(dev)s kopyası tamamlanmadan sona erdi" -#: vrtManager/instance.py:2381 +#: vrtManager/instance.py:2396 #, python-format msgid "%(error)s; remove %(dest)s if it is there: %(cleanup_error)s" msgstr "%(error)s; varsa %(dest)s dosyasını kaldırın: %(cleanup_error)s" -#: vrtManager/instance.py:2383 +#: vrtManager/instance.py:2398 #, python-format msgid "%(error)s; the VM may use %(dest)s now: check its disk %(dev)s" msgstr "" "%(error)s; sanal makine şu anda %(dest)s dosyasını kullanıyor olabilir: " "%(dev)s diskini kontrol edin" -#: vrtManager/instance.py:2390 +#: vrtManager/instance.py:2405 #, python-format msgid "The VM has no internal snapshot named %(name)s" msgstr "Sanal makinenin %(name)s adlı dahili anlık görüntüsü yok" -#: vrtManager/instance.py:2401 +#: vrtManager/instance.py:2416 msgid "A snapshot job is still running on this VM; try again when it ends" msgstr "" "Bu sanal makinede hâlâ bir anlık görüntü işi çalışıyor; bittiğinde tekrar " "deneyin" -#: vrtManager/instance.py:2411 +#: vrtManager/instance.py:2426 msgid "Shut the VM down to revert to an internal snapshot" msgstr "Dahili bir anlık görüntüye geri dönmek için sanal makineyi kapatın" -#: vrtManager/instance.py:2498 +#: vrtManager/instance.py:2513 msgid "A VM with a host's or an external TPM is not cloned; remove it first" msgstr "" "Ana makinenin ya da harici bir TPM'i olan sanal makine klonlanmaz; önce onu " "kaldırın" -#: vrtManager/instance.py:2528 +#: vrtManager/instance.py:2544 msgid "Cannot clone a VM whose NVRAM is not a file" msgstr "NVRAM'i dosya olmayan bir sanal makine klonlanamaz" -#: vrtManager/instance.py:2598 +#: vrtManager/instance.py:2614 #, python-format msgid "Clone failed (%(err)s); remove these copies by hand: %(path)s" msgstr "" "Klonlama başarısız oldu (%(err)s); bu kopyaları elle kaldırın: %(path)s" -#: vrtManager/instance.py:2609 +#: vrtManager/instance.py:2625 msgid "Shut the VM down before cloning it" msgstr "Klonlamadan önce sanal makineyi kapatın" -#: vrtManager/instance.py:2663 +#: vrtManager/instance.py:2679 #, python-format msgid "Clone failed (%(err)s); remove these copies by hand: %(leftovers)s" msgstr "" "Klonlama başarısız oldu (%(err)s); bu kopyaları elle kaldırın: %(leftovers)s" -#: vrtManager/instance.py:2674 +#: vrtManager/instance.py:2690 msgid "Live clone needs libvirt 11.10 or later; shut the VM down to clone it" msgstr "" "Canlı klonlama libvirt 11.10 veya sonrasını gerektirir; klonlamak için sanal " "makineyi kapatın" -#: vrtManager/instance.py:2677 +#: vrtManager/instance.py:2693 msgid "A VM with a TPM is cloned only shut down" msgstr "TPM'i olan bir sanal makine yalnızca kapalıyken klonlanır" -#: vrtManager/instance.py:2680 +#: vrtManager/instance.py:2696 #, python-format msgid "Disk %(dev)s is not a local file; shut the VM down to clone it" msgstr "" "Disk %(dev)s yerel bir dosya değil; klonlamak için sanal makineyi kapatın" -#: vrtManager/instance.py:2682 +#: vrtManager/instance.py:2698 #, python-format msgid "Disk %(dev)s is shareable; shut the VM down to clone it" msgstr "Disk %(dev)s paylaşılabilir; klonlamak için sanal makineyi kapatın" -#: vrtManager/instance.py:2687 +#: vrtManager/instance.py:2703 #, python-format msgid "Disk %(dev)s changes at the next start; shut the VM down to clone it" msgstr "" "Disk %(dev)s sonraki başlatmada değişiyor; klonlamak için sanal makineyi " "kapatın" -#: vrtManager/instance.py:2689 +#: vrtManager/instance.py:2705 msgid "Another job is running on the VM; clone it when that ends" msgstr "Sanal makinede başka bir iş çalışıyor; o bittiğinde klonlayın" -#: vrtManager/instance.py:2715 +#: vrtManager/instance.py:2731 #, python-format msgid "" "Storage pool %(pool)s has %(free).1f GiB free; the clone needs %(size).1f GiB" @@ -9893,25 +9897,25 @@ msgstr "" "gerektiriyor (kopyalanan diskler, artı bunların %%%(percent)g kadarı, en az " "%(minimum)g GiB)" -#: vrtManager/instance.py:2732 +#: vrtManager/instance.py:2748 #, python-format msgid "Volume %(name)s already exists in storage pool %(pool)s" msgstr "%(name)s birimi %(pool)s depolama havuzunda zaten var" -#: vrtManager/instance.py:2886 +#: vrtManager/instance.py:2902 msgid "A network interface that is a host device is removed in the XML editor" msgstr "Sunucu aygıtı olan bir ağ arabirimi XML düzenleyicide kaldırılır" -#: vrtManager/instance.py:2902 +#: vrtManager/instance.py:2918 #, python-format msgid "No network interface with MAC %(old_mac)s" msgstr "MAC adresi %(old_mac)s olan ağ arabirimi yok" -#: vrtManager/instance.py:2905 +#: vrtManager/instance.py:2921 msgid "A network interface that is a host device is changed in the XML editor" msgstr "Sunucu aygıtı olan bir ağ arabirimi XML düzenleyicide değiştirilir" -#: vrtManager/instance.py:2999 +#: vrtManager/instance.py:3015 msgid "" "A VM changes its PCI devices while it runs, or is shut off without a saved " "state" @@ -9919,43 +9923,43 @@ msgstr "" "Sanal makine PCI aygıtlarını çalışırken veya kaydedilmiş durumu olmadan " "kapalıyken değiştirir" -#: vrtManager/instance.py:3020 +#: vrtManager/instance.py:3036 #, python-format msgid "%(err)s; whether the VM has %(device)s now is not known" msgstr "%(err)s; sanal makinede şu anda %(device)s olup olmadığı bilinmiyor" -#: vrtManager/instance.py:3022 +#: vrtManager/instance.py:3038 #, python-format msgid "%(err)s; %(device)s: the VM is not running, its next start has it" msgstr "%(err)s; %(device)s: sanal makine çalışmıyor, sonraki başlatmada var" -#: vrtManager/instance.py:3023 +#: vrtManager/instance.py:3039 #, python-format msgid "" "%(err)s; %(device)s: the VM is not running, its next start does not have it" msgstr "%(err)s; %(device)s: sanal makine çalışmıyor, sonraki başlatmada yok" -#: vrtManager/instance.py:3024 +#: vrtManager/instance.py:3040 #, python-format msgid "%(err)s; %(device)s: the running VM has it, its next start has it" msgstr "" "%(err)s; %(device)s: çalışan sanal makinede var, sonraki başlatmada var" -#: vrtManager/instance.py:3025 +#: vrtManager/instance.py:3041 #, python-format msgid "" "%(err)s; %(device)s: the running VM has it, its next start does not have it" msgstr "" "%(err)s; %(device)s: çalışan sanal makinede var, sonraki başlatmada yok" -#: vrtManager/instance.py:3026 +#: vrtManager/instance.py:3042 #, python-format msgid "" "%(err)s; %(device)s: the running VM does not have it, its next start has it" msgstr "" "%(err)s; %(device)s: çalışan sanal makinede yok, sonraki başlatmada var" -#: vrtManager/instance.py:3028 +#: vrtManager/instance.py:3044 #, python-format msgid "" "%(err)s; %(device)s: the running VM does not have it, its next start does not" @@ -9963,48 +9967,48 @@ msgid "" msgstr "" "%(err)s; %(device)s: çalışan sanal makinede yok, sonraki başlatmada yok" -#: vrtManager/instance.py:3062 +#: vrtManager/instance.py:3078 #, python-format msgid "The VM has no PCI device %(address)s" msgstr "Sanal makinede %(address)s PCI aygıtı yok" -#: vrtManager/instance.py:3083 +#: vrtManager/instance.py:3099 msgid "The VM has no USB controller" msgstr "Sanal makinede USB denetleyicisi yok" -#: vrtManager/instance.py:3117 +#: vrtManager/instance.py:3133 msgid "The VM has no such USB device" msgstr "Sanal makinede böyle bir USB aygıtı yok" -#: vrtManager/instance.py:3131 +#: vrtManager/instance.py:3147 #, python-format msgid "The VM has no network interface %(mac)s" msgstr "Sanal makinede %(mac)s ağ arabirimi yok" -#: vrtManager/instance.py:3162 +#: vrtManager/instance.py:3178 msgid "The VM has its own RNG device: change it in the XML editor" msgstr "" "Sanal makinenin kendi RNG aygıtı var: bunu XML düzenleyicide değiştirin" -#: vrtManager/instance.py:3189 +#: vrtManager/instance.py:3205 msgid "The VM has its own TPM: change it in the XML editor" msgstr "Sanal makinenin kendi TPM'i var: bunu XML düzenleyicide değiştirin" -#: vrtManager/instance.py:3208 +#: vrtManager/instance.py:3224 #, python-format msgid "Unknown crash action %(action)s" msgstr "Bilinmeyen çökme eylemi %(action)s" -#: vrtManager/instance.py:3235 +#: vrtManager/instance.py:3251 #, python-format msgid "Network interface %(mac)s is not in the definition" msgstr "%(mac)s ağ arayüzü tanımda yok" -#: vrtManager/instance.py:3326 +#: vrtManager/instance.py:3342 msgid "The guest agent did not answer in time; nothing was changed" msgstr "Konuk ajanı zamanında yanıt vermedi; hiçbir şey değiştirilmedi" -#: vrtManager/instance.py:3329 +#: vrtManager/instance.py:3345 msgid "The VM runs Windows: its guest agent sets no root password or SSH key" msgstr "" "Sanal makinede Windows çalışıyor: konuk ajanı root parolası ya da SSH " diff --git a/locale/zh/LC_MESSAGES/django.mo b/locale/zh/LC_MESSAGES/django.mo index 49e1c44c..b967660b 100644 Binary files a/locale/zh/LC_MESSAGES/django.mo and b/locale/zh/LC_MESSAGES/django.mo differ diff --git a/locale/zh/LC_MESSAGES/django.po b/locale/zh/LC_MESSAGES/django.po index eb85ff04..88798b7b 100644 --- a/locale/zh/LC_MESSAGES/django.po +++ b/locale/zh/LC_MESSAGES/django.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: \n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2026-11-13 19:25+0000\n" +"POT-Creation-Date: 2026-11-13 19:49+0000\n" "PO-Revision-Date: \n" "Last-Translator: \n" "Language-Team: \n" @@ -2724,34 +2724,38 @@ msgstr "新密码" msgid "Serial (xterm; the guest needs a getty on ttyS0)" msgstr "串行(xterm;客户机需要在 ttyS0 上运行 getty)" -#: instances/forms.py:64 +#: instances/forms.py:67 msgid "Auto" msgstr "自动" -#: instances/forms.py:73 +#: instances/forms.py:76 msgid "Listen on" msgstr "监听地址" -#: instances/forms.py:80 +#: instances/forms.py:83 msgid "Keymap" msgstr "键盘映射" -#: instances/forms.py:89 +#: instances/forms.py:92 msgid "Enter the new password." msgstr "请输入新密码。" -#: instances/forms.py:92 +#: instances/forms.py:96 msgid "" "A VNC password takes up to 8 letters, digits or symbols, without accents." msgstr "VNC 密码最多 8 个字母、数字或符号,不能有带重音的字母。" #: instances/forms.py:98 +msgid "A password takes no line breaks or other control characters." +msgstr "密码不能包含换行或其他控制字符。" + +#: instances/forms.py:104 msgid "" "The console listens beyond localhost; only an administrator can remove its " "password." msgstr "控制台监听的不只是 localhost;只有管理员可以移除其密码。" -#: instances/forms.py:142 +#: instances/forms.py:148 msgid "The name of the virtual machine must not contain any special characters" msgstr "虚拟机名称不能包含任何特殊字符" @@ -2826,7 +2830,7 @@ msgstr "虚拟机未定义;请检查这些卷,然后处理此任务:%(volu msgid "Delete snapshot" msgstr "删除快照" -#: instances/jobs.py:356 vrtManager/instance.py:2389 +#: instances/jobs.py:356 vrtManager/instance.py:2404 #, python-format msgid "The VM has no external snapshot named %(name)s" msgstr "虚拟机没有名为 %(name)s 的外部快照" @@ -2858,7 +2862,7 @@ msgstr "虚拟机已不在运行该任务的计算节点上" msgid "Take snapshot" msgstr "创建快照" -#: instances/jobs.py:424 instances/jobs.py:433 vrtManager/instance.py:1980 +#: instances/jobs.py:424 instances/jobs.py:433 vrtManager/instance.py:1995 #, python-format msgid "A snapshot named %(name)s already exists" msgstr "名为 %(name)s 的快照已存在" @@ -2997,12 +3001,12 @@ msgstr "镜像已存在。请检查卷或更改虚拟机名称" msgid "Each network card needs a network" msgstr "每个网卡都需要一个网络" -#: instances/jobs.py:851 vrtManager/instance.py:2847 +#: instances/jobs.py:851 vrtManager/instance.py:2863 #, python-format msgid "This host has no network %(name)s" msgstr "此主机没有网络 %(name)s" -#: instances/jobs.py:853 vrtManager/instance.py:2849 +#: instances/jobs.py:853 vrtManager/instance.py:2865 #, python-format msgid "This host has no network filter %(name)s" msgstr "此主机没有网络过滤器 %(name)s" @@ -3072,7 +3076,7 @@ msgstr "cloud-init 种子需要为磁盘使用目录类型的存储池" msgid "This host offers no firmware %(firmware)s" msgstr "此主机不提供固件 %(firmware)s" -#: instances/jobs.py:939 vrtManager/instance.py:3196 +#: instances/jobs.py:939 vrtManager/instance.py:3212 msgid "This host offers no TPM 2.0: install swtpm on it" msgstr "此主机不提供 TPM 2.0:请在主机上安装 swtpm" @@ -4306,7 +4310,7 @@ msgid "Add USB device" msgstr "添加 USB 设备" #: instances/templates/instances/host_devices_form.html:18 -#: vrtManager/instance.py:3100 +#: vrtManager/instance.py:3116 msgid "" "A VM with a saved state does not change its USB devices: start it, or start " "it without its saved state" @@ -6172,7 +6176,7 @@ msgstr "卷已成功更改。" msgid "Disk %(dev)s is not a storage volume of this instance" msgstr "磁盘 %(dev)s 不是此虚拟机的存储卷" -#: instances/views.py:1554 vrtManager/instance.py:2399 +#: instances/views.py:1554 vrtManager/instance.py:2414 msgid "The VM has a saved state; start it or remove the saved state first" msgstr "虚拟机有保存的状态;请先启动它或删除保存的状态" @@ -9076,83 +9080,83 @@ msgstr "磁盘 %(target_dev)s 不在虚拟机的定义中" msgid "Please shutdown the instance then try to enable vCPU hotplug" msgstr "请先关闭虚拟机,再启用 vCPU 热插拔" -#: vrtManager/instance.py:1762 +#: vrtManager/instance.py:1777 msgid "The VM has no video card" msgstr "虚拟机没有显卡" -#: vrtManager/instance.py:1772 +#: vrtManager/instance.py:1787 #, python-format msgid "" "The VM's CPU topology has %(count)s vCPUs: change it in the XML editor to set" " another maximum" msgstr "该虚拟机的 CPU 拓扑为 %(count)s 个 vCPU:要设置其他最大值,请在 XML 编辑器中修改拓扑" -#: vrtManager/instance.py:1798 +#: vrtManager/instance.py:1813 #, python-format msgid "The VM's next start has a maximum memory of %(max)s MiB" msgstr "虚拟机下次启动时的最大内存为 %(max)s MiB" -#: vrtManager/instance.py:1939 +#: vrtManager/instance.py:1954 msgid "" "The VM has external snapshots; internal snapshots cannot be mixed with them" msgstr "虚拟机有外部快照;内部快照不能与其混用" -#: vrtManager/instance.py:1971 +#: vrtManager/instance.py:1986 msgid "A snapshot with memory is not quiesced; it keeps the whole guest state" msgstr "含内存的快照不会静默文件系统;它保存整个客户机状态" -#: vrtManager/instance.py:1973 +#: vrtManager/instance.py:1988 msgid "Only a running VM's file systems can be frozen" msgstr "只有运行中的虚拟机的文件系统可以冻结" -#: vrtManager/instance.py:1975 +#: vrtManager/instance.py:1990 msgid "The QEMU guest agent is not connected; it freezes the file systems" msgstr "QEMU 客户机代理未连接;文件系统由它冻结" -#: vrtManager/instance.py:1978 +#: vrtManager/instance.py:1993 msgid "" "The VM has internal snapshots; external snapshots cannot be mixed with them" msgstr "虚拟机有内部快照;外部快照不能与其混用" -#: vrtManager/instance.py:1983 +#: vrtManager/instance.py:1998 msgid "Newer snapshots exist after the last revert; delete them first" msgstr "上次还原后存在更新的快照;请先删除它们" -#: vrtManager/instance.py:1986 +#: vrtManager/instance.py:2001 msgid "No snapshot is current; revert to a snapshot first" msgstr "没有当前快照;请先还原到某个快照" -#: vrtManager/instance.py:1992 +#: vrtManager/instance.py:2007 #, python-format msgid "Eject the media from %(dev)s first" msgstr "请先弹出 %(dev)s 中的介质" -#: vrtManager/instance.py:1994 +#: vrtManager/instance.py:2009 #, python-format msgid "Disk %(dev)s is not a file; external snapshots need file disks" msgstr "磁盘 %(dev)s 不是文件;外部快照需要文件磁盘" -#: vrtManager/instance.py:2002 +#: vrtManager/instance.py:2017 #, python-format msgid "" "The storage pools could not be refreshed, so their free space is unknown: " "%(err)s" msgstr "无法刷新存储池,其可用空间未知:%(err)s" -#: vrtManager/instance.py:2023 +#: vrtManager/instance.py:2038 msgid "Memory is saved only from a running VM" msgstr "只能保存运行中的虚拟机的内存" -#: vrtManager/instance.py:2025 +#: vrtManager/instance.py:2040 msgid "The VM has no disk to keep its memory next to" msgstr "虚拟机没有可存放其内存的磁盘" -#: vrtManager/instance.py:2029 +#: vrtManager/instance.py:2044 #, python-format msgid "%(disk)s is not in a storage pool; memory is saved only into one" msgstr "%(disk)s 不在存储池中;内存只能保存到存储池中" -#: vrtManager/instance.py:2060 +#: vrtManager/instance.py:2075 #, python-format msgid "" "Storage pool %(pool)s has %(free).1f GiB free; the snapshot needs %(size).1f " @@ -9162,151 +9166,151 @@ msgstr "" "存储池 %(pool)s 可用 %(free).1f GiB;快照需要 %(size).1f GiB(其中虚拟机磁盘的 %(percent)g%%,至少 " "%(minimum)g GiB,若保存内存则另加内存)" -#: vrtManager/instance.py:2078 +#: vrtManager/instance.py:2093 msgid "" "This snapshot was taken by an older version on a UEFI VM and cannot be " "reverted; delete it instead" msgstr "此快照由旧版本在 UEFI 虚拟机上创建,无法还原;请将其删除" -#: vrtManager/instance.py:2108 +#: vrtManager/instance.py:2123 #, python-format msgid "" "The revert failed twice; try again in a moment (%(error)s). The VM is " "running." msgstr "还原两次失败;请稍后重试(%(error)s)。虚拟机正在运行。" -#: vrtManager/instance.py:2110 +#: vrtManager/instance.py:2125 #, python-format msgid "" "The revert failed twice; try again in a moment (%(error)s). The VM is shut " "off." msgstr "还原两次失败;请稍后重试(%(error)s)。虚拟机已关机。" -#: vrtManager/instance.py:2278 +#: vrtManager/instance.py:2293 msgid "A disk moves when its VM is defined and running, paused or shut off" msgstr "仅当虚拟机已定义且处于运行、暂停或关机状态时才能移动磁盘" -#: vrtManager/instance.py:2280 +#: vrtManager/instance.py:2295 msgid "" "A disk of a VM with snapshots, a saved state or a running block job does not " "move" msgstr "有快照、保存的状态或正在运行块任务的虚拟机的磁盘不能移动" -#: vrtManager/instance.py:2288 +#: vrtManager/instance.py:2303 #, python-format msgid "" "%(dev)s is not a disk file of the VM, the same in its running and next " "start's definition" msgstr "%(dev)s 不是该虚拟机在运行中的定义和下次启动定义中相同的磁盘文件" -#: vrtManager/instance.py:2293 +#: vrtManager/instance.py:2308 #, python-format msgid "%(dev)s does not move: only writable raw and qcow2 disks do" msgstr "%(dev)s 不能移动:只能移动可写的 raw 和 qcow2 磁盘" -#: vrtManager/instance.py:2300 +#: vrtManager/instance.py:2315 #, python-format msgid "%(dev)s does not move: no storage pool has %(path)s" msgstr "%(dev)s 不能移动:没有存储池包含 %(path)s" -#: vrtManager/instance.py:2302 +#: vrtManager/instance.py:2317 #, python-format msgid "%(dev)s does not move: it has a backing file" msgstr "%(dev)s 不能移动:它有后备文件" -#: vrtManager/instance.py:2305 +#: vrtManager/instance.py:2320 #, python-format msgid "%(pool_name)s is not an active pool of disk files of this host" msgstr "%(pool_name)s 不是此主机上活动的磁盘文件存储池" -#: vrtManager/instance.py:2308 +#: vrtManager/instance.py:2323 #, python-format msgid "%(dev)s is in pool %(pool_name)s already" msgstr "%(dev)s 已在存储池 %(pool_name)s 中" -#: vrtManager/instance.py:2312 +#: vrtManager/instance.py:2327 #, python-format msgid "Pool %(pool_name)s already has a file %(name)s" msgstr "存储池 %(pool_name)s 中已有文件 %(name)s" -#: vrtManager/instance.py:2336 +#: vrtManager/instance.py:2351 #, python-format msgid "The copy of %(dev)s ended before it was complete" msgstr "%(dev)s 的复制在完成前结束" -#: vrtManager/instance.py:2381 +#: vrtManager/instance.py:2396 #, python-format msgid "%(error)s; remove %(dest)s if it is there: %(cleanup_error)s" msgstr "%(error)s;如果 %(dest)s 存在请将其删除:%(cleanup_error)s" -#: vrtManager/instance.py:2383 +#: vrtManager/instance.py:2398 #, python-format msgid "%(error)s; the VM may use %(dest)s now: check its disk %(dev)s" msgstr "%(error)s;虚拟机现在可能在使用 %(dest)s:请检查其磁盘 %(dev)s" -#: vrtManager/instance.py:2390 +#: vrtManager/instance.py:2405 #, python-format msgid "The VM has no internal snapshot named %(name)s" msgstr "虚拟机没有名为 %(name)s 的内部快照" -#: vrtManager/instance.py:2401 +#: vrtManager/instance.py:2416 msgid "A snapshot job is still running on this VM; try again when it ends" msgstr "此虚拟机上仍有快照任务在运行;请在其结束后重试" -#: vrtManager/instance.py:2411 +#: vrtManager/instance.py:2426 msgid "Shut the VM down to revert to an internal snapshot" msgstr "请关闭虚拟机后再还原到内部快照" -#: vrtManager/instance.py:2498 +#: vrtManager/instance.py:2513 msgid "A VM with a host's or an external TPM is not cloned; remove it first" msgstr "带有主机 TPM 或外部 TPM 的虚拟机无法克隆;请先将其移除" -#: vrtManager/instance.py:2528 +#: vrtManager/instance.py:2544 msgid "Cannot clone a VM whose NVRAM is not a file" msgstr "NVRAM 不是文件的虚拟机无法克隆" -#: vrtManager/instance.py:2598 +#: vrtManager/instance.py:2614 #, python-format msgid "Clone failed (%(err)s); remove these copies by hand: %(path)s" msgstr "克隆失败(%(err)s);请手动删除这些副本:%(path)s" -#: vrtManager/instance.py:2609 +#: vrtManager/instance.py:2625 msgid "Shut the VM down before cloning it" msgstr "请先关闭虚拟机再克隆" -#: vrtManager/instance.py:2663 +#: vrtManager/instance.py:2679 #, python-format msgid "Clone failed (%(err)s); remove these copies by hand: %(leftovers)s" msgstr "克隆失败(%(err)s);请手动删除这些副本:%(leftovers)s" -#: vrtManager/instance.py:2674 +#: vrtManager/instance.py:2690 msgid "Live clone needs libvirt 11.10 or later; shut the VM down to clone it" msgstr "在线克隆需要 libvirt 11.10 或更高版本;请关闭虚拟机后再克隆" -#: vrtManager/instance.py:2677 +#: vrtManager/instance.py:2693 msgid "A VM with a TPM is cloned only shut down" msgstr "带 TPM 的虚拟机只能在关机时克隆" -#: vrtManager/instance.py:2680 +#: vrtManager/instance.py:2696 #, python-format msgid "Disk %(dev)s is not a local file; shut the VM down to clone it" msgstr "磁盘 %(dev)s 不是本地文件;请关闭虚拟机后再克隆" -#: vrtManager/instance.py:2682 +#: vrtManager/instance.py:2698 #, python-format msgid "Disk %(dev)s is shareable; shut the VM down to clone it" msgstr "磁盘 %(dev)s 是可共享的;请关闭虚拟机后再克隆" -#: vrtManager/instance.py:2687 +#: vrtManager/instance.py:2703 #, python-format msgid "Disk %(dev)s changes at the next start; shut the VM down to clone it" msgstr "磁盘 %(dev)s 在下次启动时会改变;请关闭虚拟机后再克隆" -#: vrtManager/instance.py:2689 +#: vrtManager/instance.py:2705 msgid "Another job is running on the VM; clone it when that ends" msgstr "虚拟机上有另一个任务正在运行;请在其结束后再克隆" -#: vrtManager/instance.py:2715 +#: vrtManager/instance.py:2731 #, python-format msgid "" "Storage pool %(pool)s has %(free).1f GiB free; the clone needs %(size).1f GiB" @@ -9315,111 +9319,111 @@ msgstr "" "存储池 %(pool)s 可用 %(free).1f GiB;克隆需要 %(size).1f GiB(复制的磁盘,再加其 %(percent)g%%,至少" " %(minimum)g GiB)" -#: vrtManager/instance.py:2732 +#: vrtManager/instance.py:2748 #, python-format msgid "Volume %(name)s already exists in storage pool %(pool)s" msgstr "卷 %(name)s 已存在于存储池 %(pool)s 中" -#: vrtManager/instance.py:2886 +#: vrtManager/instance.py:2902 msgid "A network interface that is a host device is removed in the XML editor" msgstr "作为主机设备的网络接口需在 XML 编辑器中删除" -#: vrtManager/instance.py:2902 +#: vrtManager/instance.py:2918 #, python-format msgid "No network interface with MAC %(old_mac)s" msgstr "没有 MAC 为 %(old_mac)s 的网络接口" -#: vrtManager/instance.py:2905 +#: vrtManager/instance.py:2921 msgid "A network interface that is a host device is changed in the XML editor" msgstr "作为主机设备的网络接口需在 XML 编辑器中修改" -#: vrtManager/instance.py:2999 +#: vrtManager/instance.py:3015 msgid "" "A VM changes its PCI devices while it runs, or is shut off without a saved " "state" msgstr "虚拟机只能在运行时或无保存的状态的关机时更改其 PCI 设备" -#: vrtManager/instance.py:3020 +#: vrtManager/instance.py:3036 #, python-format msgid "%(err)s; whether the VM has %(device)s now is not known" msgstr "%(err)s;虚拟机现在是否有 %(device)s 未知" -#: vrtManager/instance.py:3022 +#: vrtManager/instance.py:3038 #, python-format msgid "%(err)s; %(device)s: the VM is not running, its next start has it" msgstr "%(err)s;%(device)s:虚拟机未运行,下次启动时有它" -#: vrtManager/instance.py:3023 +#: vrtManager/instance.py:3039 #, python-format msgid "" "%(err)s; %(device)s: the VM is not running, its next start does not have it" msgstr "%(err)s;%(device)s:虚拟机未运行,下次启动时没有它" -#: vrtManager/instance.py:3024 +#: vrtManager/instance.py:3040 #, python-format msgid "%(err)s; %(device)s: the running VM has it, its next start has it" msgstr "%(err)s;%(device)s:运行中的虚拟机有它,下次启动时有它" -#: vrtManager/instance.py:3025 +#: vrtManager/instance.py:3041 #, python-format msgid "" "%(err)s; %(device)s: the running VM has it, its next start does not have it" msgstr "%(err)s;%(device)s:运行中的虚拟机有它,下次启动时没有它" -#: vrtManager/instance.py:3026 +#: vrtManager/instance.py:3042 #, python-format msgid "" "%(err)s; %(device)s: the running VM does not have it, its next start has it" msgstr "%(err)s;%(device)s:运行中的虚拟机没有它,下次启动时有它" -#: vrtManager/instance.py:3028 +#: vrtManager/instance.py:3044 #, python-format msgid "" "%(err)s; %(device)s: the running VM does not have it, its next start does not" " have it" msgstr "%(err)s;%(device)s:运行中的虚拟机没有它,下次启动时没有它" -#: vrtManager/instance.py:3062 +#: vrtManager/instance.py:3078 #, python-format msgid "The VM has no PCI device %(address)s" msgstr "虚拟机没有 PCI 设备 %(address)s" -#: vrtManager/instance.py:3083 +#: vrtManager/instance.py:3099 msgid "The VM has no USB controller" msgstr "虚拟机没有 USB 控制器" -#: vrtManager/instance.py:3117 +#: vrtManager/instance.py:3133 msgid "The VM has no such USB device" msgstr "虚拟机没有此 USB 设备" -#: vrtManager/instance.py:3131 +#: vrtManager/instance.py:3147 #, python-format msgid "The VM has no network interface %(mac)s" msgstr "虚拟机没有网络接口 %(mac)s" -#: vrtManager/instance.py:3162 +#: vrtManager/instance.py:3178 msgid "The VM has its own RNG device: change it in the XML editor" msgstr "虚拟机有自己的 RNG 设备:请在 XML 编辑器中修改" -#: vrtManager/instance.py:3189 +#: vrtManager/instance.py:3205 msgid "The VM has its own TPM: change it in the XML editor" msgstr "虚拟机有自己的 TPM:请在 XML 编辑器中修改" -#: vrtManager/instance.py:3208 +#: vrtManager/instance.py:3224 #, python-format msgid "Unknown crash action %(action)s" msgstr "未知的崩溃操作 %(action)s" -#: vrtManager/instance.py:3235 +#: vrtManager/instance.py:3251 #, python-format msgid "Network interface %(mac)s is not in the definition" msgstr "网络接口 %(mac)s 不在定义中" -#: vrtManager/instance.py:3326 +#: vrtManager/instance.py:3342 msgid "The guest agent did not answer in time; nothing was changed" msgstr "客户机代理未及时响应;未做任何更改" -#: vrtManager/instance.py:3329 +#: vrtManager/instance.py:3345 msgid "The VM runs Windows: its guest agent sets no root password or SSH key" msgstr "该虚拟机运行 Windows:其客户机代理不能设置 root 密码或 SSH 密钥" diff --git a/vrtManager/instance.py b/vrtManager/instance.py index d064b589..3168e858 100644 --- a/vrtManager/instance.py +++ b/vrtManager/instance.py @@ -1604,11 +1604,11 @@ class wvmInstance(wvmConnect): def get_console_listener_addr(self, config=False): listener_addr = util.get_xml_path( - self._XMLDesc(PERSISTENT_XML if config else 0), "/domain/devices/graphics/@listen" + self._XMLDesc(PERSISTENT_XML if config else 0), "/domain/devices/graphics[1]/@listen" ) if listener_addr is None: listener_addr = util.get_xml_path( - self._XMLDesc(PERSISTENT_XML if config else 0), "/domain/devices/graphics/listen/@address" + self._XMLDesc(PERSISTENT_XML if config else 0), "/domain/devices/graphics[1]/listen/@address" ) if listener_addr is None: return "127.0.0.1" @@ -1665,21 +1665,36 @@ class wvmInstance(wvmConnect): serial console opens (libvirt adds the serial port for the console).""" root = etree.fromstring(self._XMLDesc(PERSISTENT_XML)) devices = root.find("devices") - for graphic in devices.findall("graphics"): + graphics = devices.findall("graphics") + for graphic in graphics: devices.remove(graphic) + # libvirt refuses SPICE channels, USB redirection and smartcards + # without SPICE graphics; SPICE audio goes silent + for device in devices.xpath("channel[@type='spicevmc' or @type='spiceport'] | redirdev[@type='spicevmc']" + " | smartcard[@type='spicevmc']"): + devices.remove(device) + for audio in devices.findall("audio[@type='spice']"): + audio.set("type", "none") if console_type == "vnc": - etree.SubElement(devices, "graphics", type="vnc", port="-1", autoport="yes", listen="127.0.0.1") + vnc = etree.SubElement(devices, "graphics", type="vnc", port="-1", autoport="yes", listen="127.0.0.1") + # a SPICE console's keymap and password stay, a password VNC cannot take is replaced + if graphics and graphics[0].get("keymap"): + vnc.set("keymap", graphics[0].get("keymap")) + passwd = graphics[0].get("passwd") if graphics else None + if passwd is not None: + fits = len(passwd) <= 8 and all(" " <= c <= "~" for c in passwd) + vnc.set("passwd", passwd if fits else util.randomPasswd(8)) elif devices.find("console") is None: etree.SubElement(devices, "console", type="pty") return self._defineXML(etree.tostring(root).decode()) def get_console_socket(self): - socket = util.get_xml_path(self._XMLDesc(0), "/domain/devices/graphics/@socket") + socket = util.get_xml_path(self._XMLDesc(0), "/domain/devices/graphics[1]/@socket") return socket def get_console_type(self, config=False): xml = self._XMLDesc(PERSISTENT_XML if config else 0) - console_type = util.get_xml_path(xml, "/domain/devices/graphics/@type") + console_type = util.get_xml_path(xml, "/domain/devices/graphics[1]/@type") if console_type is None: console_type = util.get_xml_path(xml, "/domain/devices/console/@type") return console_type @@ -1689,13 +1704,13 @@ class wvmInstance(wvmConnect): console_type = self.get_console_type() port = util.get_xml_path( self._XMLDesc(0), - "/domain/devices/graphics[@type='%s']/@port" % console_type, + "/domain/devices/graphics[1][@type='%s']/@port" % console_type, ) return port def get_console_passwd(self, config=False): return util.get_xml_path( - self._XMLDesc(PERSISTENT_XML if config else VIR_DOMAIN_XML_SECURE), "/domain/devices/graphics/@passwd" + self._XMLDesc(PERSISTENT_XML if config else VIR_DOMAIN_XML_SECURE), "/domain/devices/graphics[1]/@passwd" ) def set_console_passwd(self, passwd): @@ -1730,7 +1745,7 @@ class wvmInstance(wvmConnect): def get_console_keymap(self, config=False): return ( util.get_xml_path( - self._XMLDesc(PERSISTENT_XML if config else VIR_DOMAIN_XML_SECURE), "/domain/devices/graphics/@keymap" + self._XMLDesc(PERSISTENT_XML if config else VIR_DOMAIN_XML_SECURE), "/domain/devices/graphics[1]/@keymap" ) or "" ) diff --git a/vrtManager/tests/test_console_graphics.py b/vrtManager/tests/test_console_graphics.py new file mode 100644 index 00000000..afafeb0a --- /dev/null +++ b/vrtManager/tests/test_console_graphics.py @@ -0,0 +1,56 @@ +"""A VM's console is its first graphics device: each setting is read from +it, and a switch away from SPICE leaves a definition libvirt accepts.""" + +import unittest + +from lxml import etree + +from vrtManager.instance import wvmInstance + +SPICE = """ + + + + + """ + + +def vm(xml): + p = wvmInstance.__new__(wvmInstance) # no connection: only these calls + p._XMLDesc = lambda flags: xml + p.defined = [] + p._defineXML = p.defined.append + return p + + +class ConsoleGraphicsTestCase(unittest.TestCase): + def test_a_switch_from_spice_drops_the_devices_that_need_it(self): + for console_type in ("vnc", "pty"): + with self.subTest(console_type): + p = vm(SPICE % "spice123") + p.set_console_type(console_type) + devices = etree.fromstring(p.defined[0]).find("devices") + self.assertEqual([c.get("type") for c in devices.findall("channel")], ["unix"]) + self.assertEqual(devices.findall("redirdev") + devices.findall("smartcard"), []) + self.assertEqual(devices.find("audio").get("type"), "none") + self.assertEqual(devices.find("video/model").get("type"), "qxl") + + def test_vnc_keeps_the_spice_keymap_and_a_password_it_can_take(self): + for passwd, kept in (("spice123", True), ("a-longer-spice-password", False)): + with self.subTest(passwd): + p = vm(SPICE % passwd) + p.set_console_type("vnc") + (graphic,) = etree.fromstring(p.defined[0]).findall("devices/graphics") + self.assertEqual((graphic.get("type"), graphic.get("listen"), graphic.get("keymap")), + ("vnc", "127.0.0.1", "de")) + self.assertEqual(graphic.get("passwd") == passwd, kept) + self.assertEqual(len(graphic.get("passwd")), 8) + + def test_every_setting_is_read_from_the_first_graphics_device(self): + # VNC without a password or keymap first: SPICE's must not be shown as its + p = vm(""" + + """) + self.assertEqual((p.get_console_type(), p.get_console_port(), p.get_console_passwd(), + p.get_console_keymap(), p.get_console_listener_addr()), + ("vnc", "5901", None, "", "127.0.0.1"))