diff --git a/locale/tr/LC_MESSAGES/django.mo b/locale/tr/LC_MESSAGES/django.mo index 81cf4373..66ce0f8f 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 1c2d2818..1d8298f8 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-17 08:38+0000\n" +"POT-Creation-Date: 2026-11-17 10:54+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" @@ -3291,17 +3291,17 @@ msgstr "Klonun adını boş adlar listesinden seçin" msgid "%(quota)s: cannot create '%(clone_name)s'." msgstr "%(quota)s: '%(clone_name)s' oluşturulamıyor." -#: instances/jobs.py:206 instances/jobs.py:646 vmbackups/jobs.py:539 +#: instances/jobs.py:206 instances/jobs.py:646 vmbackups/jobs.py:548 #, python-format msgid "Instance '%(clone_name)s' already exists!" msgstr "'%(clone_name)s' sanal makinesi zaten mevcut!" -#: instances/jobs.py:208 vmbackups/jobs.py:541 +#: instances/jobs.py:208 vmbackups/jobs.py:550 #, python-format msgid "Instance name '%(clone_name)s' is longer than 64 characters" msgstr "'%(clone_name)s' sanal makine adı 64 karakterden uzun" -#: instances/jobs.py:211 vmbackups/jobs.py:543 +#: instances/jobs.py:211 vmbackups/jobs.py:552 #, python-format msgid "Instance name '%(clone_name)s' contains invalid characters!" msgstr "Sanal makine adı '%(clone_name)s' geçersiz karakterler içermektedir!" @@ -3458,11 +3458,11 @@ msgid "Clone VM" msgstr "Sanal makineyi klonla" #: instances/jobs.py:656 instances/jobs.py:663 instances/jobs.py:1005 -#: vmbackups/jobs.py:234 vmbackups/jobs.py:643 +#: vmbackups/jobs.py:243 vmbackups/jobs.py:652 msgid "Copying disks" msgstr "Diskler kopyalanıyor" -#: instances/jobs.py:715 vmbackups/jobs.py:310 +#: instances/jobs.py:715 vmbackups/jobs.py:319 msgid "libvirt has no result of the copy" msgstr "libvirt'te kopyanın sonucu yok" @@ -3475,7 +3475,7 @@ msgstr "" "Kopyalama başarısız oldu: %(error)s. Konuğun dosya sistemleri çözülemedi " "(%(thaw)s); şununla çözün: virsh domfsthaw %(vm)s" -#: instances/jobs.py:729 instances/jobs.py:821 vmbackups/jobs.py:316 +#: instances/jobs.py:729 instances/jobs.py:821 vmbackups/jobs.py:325 msgid "The copy failed" msgstr "Kopyalama başarısız oldu" @@ -3497,11 +3497,11 @@ msgstr "" "Klonun bir birimi oluşturuluyordu; şu birimleri kontrol edin, sonra bu işi " "çözün: %(volumes)s" -#: instances/jobs.py:801 vmbackups/jobs.py:353 +#: instances/jobs.py:801 vmbackups/jobs.py:362 msgid "The job stopped before the copy started" msgstr "İş, kopyalama başlamadan durdu" -#: instances/jobs.py:808 vmbackups/jobs.py:401 +#: instances/jobs.py:808 vmbackups/jobs.py:410 msgid "libvirt is still copying the disks" msgstr "libvirt diskleri hâlâ kopyalıyor" @@ -3542,12 +3542,12 @@ msgstr "" msgid "Each network card needs a network" msgstr "Her ağ kartının bir ağı olmalı" -#: instances/jobs.py:868 vrtManager/backup.py:260 vrtManager/instance.py:2871 +#: instances/jobs.py:868 vrtManager/backup.py:276 vrtManager/instance.py:2871 #, python-format msgid "This host has no network %(name)s" msgstr "Bu sunucuda %(name)s ağı yok" -#: instances/jobs.py:870 vrtManager/backup.py:264 vrtManager/instance.py:2873 +#: instances/jobs.py:870 vrtManager/backup.py:280 vrtManager/instance.py:2873 #, python-format msgid "This host has no network filter %(name)s" msgstr "Bu sunucuda %(name)s ağ filtresi yok" @@ -9832,30 +9832,30 @@ msgstr "" "Sanal makinenin NVRAM dosyası yedeklenirken değişti; sanal makineyi yeniden " "yedekleyin" -#: vmbackups/jobs.py:186 +#: vmbackups/jobs.py:195 msgid "Back up VM" msgstr "Sanal makineyi yedekle" -#: vmbackups/jobs.py:221 +#: vmbackups/jobs.py:230 msgid "The schedule's window ended before the backup could start" msgstr "Yedek başlayamadan zamanlamanın penceresi bitti" -#: vmbackups/jobs.py:223 +#: vmbackups/jobs.py:232 #, python-format msgid "" "%(compute)s went into maintenance before the scheduled backup could start" msgstr "Zamanlanmış yedek başlayamadan %(compute)s bakıma alındı" -#: vmbackups/jobs.py:250 vmbackups/jobs.py:317 +#: vmbackups/jobs.py:259 vmbackups/jobs.py:326 msgid "Writing the backup's files" msgstr "Yedeğin dosyaları yazılıyor" -#: vmbackups/jobs.py:329 +#: vmbackups/jobs.py:338 msgid "The guest's file systems could not be thawed; trying again" msgstr "" "Konuğun dosya sistemlerinin dondurulması kaldırılamadı; yeniden deneniyor" -#: vmbackups/jobs.py:378 +#: vmbackups/jobs.py:387 #, python-format msgid "" "The VM is no longer on the compute the job ran on; check these volumes of the" @@ -9864,7 +9864,7 @@ msgstr "" "Sanal makine artık işin çalıştığı sunucuda değil; yedek hedefindeki şu " "birimleri kontrol edin, sonra bu işi çözün: %(volumes)s" -#: vmbackups/jobs.py:395 +#: vmbackups/jobs.py:404 #, python-format msgid "" "A disk was being copied when the job stopped; check these volumes of the " @@ -9873,7 +9873,7 @@ msgstr "" "İş durduğunda bir disk kopyalanıyordu; yedek hedefindeki şu birimleri kontrol" " edin, sonra bu işi çözün: %(volumes)s" -#: vmbackups/jobs.py:405 +#: vmbackups/jobs.py:414 #, python-format msgid "" "Another backup runs on the VM; check these volumes of the backup target, then" @@ -9882,7 +9882,7 @@ msgstr "" "Sanal makinede başka bir yedekleme çalışıyor; yedek hedefindeki şu birimleri " "kontrol edin, sonra bu işi çözün: %(volumes)s" -#: vmbackups/jobs.py:411 +#: vmbackups/jobs.py:420 #, python-format msgid "" "libvirt has no result of the copy; check these volumes of the backup target, " @@ -9891,72 +9891,72 @@ msgstr "" "libvirt'te kopyanın sonucu yok; yedek hedefindeki şu birimleri kontrol edin, " "sonra bu işi çözün: %(volumes)s" -#: vmbackups/jobs.py:419 +#: vmbackups/jobs.py:428 msgid "The job stopped before the copy ended" msgstr "İş, kopyalama bitmeden durdu" -#: vmbackups/jobs.py:426 +#: vmbackups/jobs.py:435 #, python-format msgid "The backup's files could not be written: %(error)s" msgstr "Yedeğin dosyaları yazılamadı: %(error)s" -#: vmbackups/jobs.py:446 +#: vmbackups/jobs.py:455 #, python-format msgid "No compute of backup target %(target)s reaches its storage pool" msgstr "" "%(target)s yedek hedefinin hiçbir sunucusu depolama havuzuna erişemiyor" -#: vmbackups/jobs.py:480 +#: vmbackups/jobs.py:489 msgid "Delete backup" msgstr "Yedeği sil" -#: vmbackups/jobs.py:491 +#: vmbackups/jobs.py:500 msgid "This backup is being made; cancel its job to stop it" msgstr "Bu yedek alınıyor; durdurmak için işini iptal edin" -#: vmbackups/jobs.py:504 +#: vmbackups/jobs.py:513 msgid "The backup is no longer beyond what its schedule keeps; it is kept" msgstr "Yedek artık zamanlamasının tuttuğu sayının dışında değil; tutuluyor" -#: vmbackups/jobs.py:556 +#: vmbackups/jobs.py:565 #, python-format msgid "The backup's file %(name)s is missing from the target" msgstr "Yedeğin %(name)s dosyası hedefte yok" -#: vmbackups/jobs.py:559 vmbackups/jobs.py:561 +#: vmbackups/jobs.py:568 vmbackups/jobs.py:570 #, python-format msgid "The backup's file %(name)s differs from the one written" msgstr "Yedeğin %(name)s dosyası yazılandan farklı" -#: vmbackups/jobs.py:571 vmbackups/templates/vmbackups/restore.html:7 +#: vmbackups/jobs.py:580 vmbackups/templates/vmbackups/restore.html:7 msgid "Restore backup" msgstr "Yedeği geri yükle" -#: vmbackups/jobs.py:584 +#: vmbackups/jobs.py:593 msgid "Only a ready backup is restored" msgstr "Yalnızca hazır bir yedek geri yüklenir" -#: vmbackups/jobs.py:614 +#: vmbackups/jobs.py:623 #, python-format msgid "A VM named %(name)s exists on %(compute)s" msgstr "%(compute)s üzerinde %(name)s adlı bir sanal makine var" -#: vmbackups/jobs.py:622 +#: vmbackups/jobs.py:631 #, python-format msgid "This host has no active directory storage pool %(pool)s" msgstr "Bu sunucuda %(pool)s adlı etkin bir dizin depolama havuzu yok" -#: vmbackups/jobs.py:639 +#: vmbackups/jobs.py:648 #, python-format msgid "The NVRAM file %(path)s exists already" msgstr "%(path)s NVRAM dosyası zaten var" -#: vmbackups/jobs.py:670 +#: vmbackups/jobs.py:679 #, python-format msgid "The VM was restored; it did not start: %(error)s" msgstr "Sanal makine geri yüklendi; başlamadı: %(error)s" -#: vmbackups/jobs.py:692 +#: vmbackups/jobs.py:701 #, python-format msgid "" "A disk was being copied when the job stopped; check this volume, then resolve" @@ -9965,7 +9965,7 @@ msgstr "" "İş durduğunda bir disk kopyalanıyordu; bu birimi kontrol edin, sonra bu işi " "çözün: %(volumes)s" -#: vmbackups/jobs.py:697 +#: vmbackups/jobs.py:706 #, python-format msgid "" "Storage pool %(pool)s is not active; the restore's copies in it are removed " @@ -9974,15 +9974,15 @@ msgstr "" "%(pool)s depolama havuzu etkin değil; geri yüklemenin içindeki kopyaları " "havuz etkin olunca kaldırılır" -#: vmbackups/jobs.py:706 +#: vmbackups/jobs.py:715 msgid "The VM was not defined; its copies were removed" msgstr "Sanal makine tanımlanmadı; kopyaları kaldırıldı" -#: vmbackups/jobs.py:725 vmbackups/templates/vmbackups/target.html:18 +#: vmbackups/jobs.py:734 vmbackups/templates/vmbackups/target.html:18 msgid "Read backups from target" msgstr "Yedekleri hedeften oku" -#: vmbackups/jobs.py:773 +#: vmbackups/jobs.py:782 #, python-format msgid "" "Not read, as a file of the backup is missing, changed or unreadable: " @@ -9991,11 +9991,11 @@ msgstr "" "Yedeğin bir dosyası eksik, değişmiş ya da okunamaz olduğu için okunmadı: " "%(names)s" -#: vmbackups/jobs.py:789 +#: vmbackups/jobs.py:798 msgid "Check backup target" msgstr "Yedek hedefini denetle" -#: vmbackups/jobs.py:816 +#: vmbackups/jobs.py:825 #, python-format msgid "Files of these backups are missing from the target: %(backups)s" msgstr "Şu yedeklerin dosyaları hedefte yok: %(backups)s" @@ -10350,62 +10350,71 @@ msgstr "" "%(pool)s depolama havuzu bu sunucuda etkin bir dizin veya NFS havuzu değil ya" " da yedek hedefinin kaydettiği havuz değil" -#: vrtManager/backup.py:62 +#: vrtManager/backup.py:63 #, python-format msgid "%(vm)s has a saved state; start it or remove the saved state first" msgstr "" "%(vm)s kaydedilmiş bir durum taşıyor; önce başlatın veya kaydedilmiş durumu " "kaldırın" -#: vrtManager/backup.py:64 -#, python-format -msgid "%(vm)s has TPM state; TPM backups come later" -msgstr "%(vm)s TPM durumu taşıyor; TPM yedekleri sonra gelecek" - #: vrtManager/backup.py:66 #, python-format +msgid "" +"%(vm)s has a TPM of its own settings (encryption, a state path or another " +"backend); it cannot be backed up" +msgstr "" +"%(vm)s kendi ayarlarına sahip bir TPM taşıyor (şifreleme, durum yolu ya da " +"başka bir arka uç); yedeklenemez" + +#: vrtManager/backup.py:69 +#, python-format +msgid "%(vm)s has TPM state; shut it down to back it up" +msgstr "%(vm)s TPM durumu taşıyor; yedeklemek için kapatın" + +#: vrtManager/backup.py:71 +#, python-format msgid "%(vm)s shares a host directory (filesystem); it cannot be backed up" msgstr "%(vm)s bir sunucu dizinini paylaşıyor (filesystem); yedeklenemez" -#: vrtManager/backup.py:68 +#: vrtManager/backup.py:73 #, python-format msgid "%(vm)s boots a kernel file of the host; it cannot be backed up" msgstr "%(vm)s sunucudaki bir çekirdek dosyasıyla açılıyor; yedeklenemez" -#: vrtManager/backup.py:70 +#: vrtManager/backup.py:75 #, python-format msgid "%(vm)s has a host device; it cannot be backed up" msgstr "%(vm)s bir sunucu aygıtı kullanıyor; yedeklenemez" -#: vrtManager/backup.py:76 +#: vrtManager/backup.py:81 msgid "CD-ROM: not copied" msgstr "CD-ROM: kopyalanmaz" -#: vrtManager/backup.py:76 +#: vrtManager/backup.py:81 msgid "Floppy: not copied" msgstr "Disket: kopyalanmaz" -#: vrtManager/backup.py:80 +#: vrtManager/backup.py:85 #, python-format msgid "Disk %(dev)s is encrypted; it cannot be backed up" msgstr "%(dev)s diski şifreli; yedeklenemez" -#: vrtManager/backup.py:83 +#: vrtManager/backup.py:88 #, python-format msgid "Disk %(dev)s is not a file; it cannot be backed up" msgstr "%(dev)s diski bir dosya değil; yedeklenemez" -#: vrtManager/backup.py:85 +#: vrtManager/backup.py:90 #, python-format msgid "Disk %(dev)s is shareable; it cannot be backed up" msgstr "%(dev)s diski paylaşılabilir; yedeklenemez" -#: vrtManager/backup.py:88 +#: vrtManager/backup.py:93 #, python-format msgid "Disk %(dev)s is %(format)s; only qcow2 and raw disks are backed up" msgstr "%(dev)s diski %(format)s; yalnızca qcow2 ve raw diskler yedeklenir" -#: vrtManager/backup.py:95 +#: vrtManager/backup.py:100 #, python-format msgid "" "Disk %(dev)s (%(path)s) is in no storage pool of the host; it cannot be " @@ -10414,7 +10423,7 @@ msgstr "" "%(dev)s diski (%(path)s) sunucunun hiçbir depolama havuzunda değil; " "yedeklenemez" -#: vrtManager/backup.py:108 +#: vrtManager/backup.py:113 #, python-format msgid "" "Disks %(devs)s change at the next start; back the VM up after it restarts" @@ -10422,7 +10431,7 @@ msgstr "" "%(devs)s diskleri sonraki başlatmada değişiyor; sanal makineyi yeniden " "başladıktan sonra yedekleyin" -#: vrtManager/backup.py:113 vrtManager/instance.py:494 +#: vrtManager/backup.py:118 vrtManager/instance.py:494 #, python-format msgid "" "The NVRAM file %(path)s is not in libvirt's NVRAM directory %(dir)s and " @@ -10431,7 +10440,7 @@ msgstr "" "%(path)s NVRAM dosyası libvirt'in NVRAM dizini %(dir)s içinde değil ve " "kopyalanamaz" -#: vrtManager/backup.py:164 +#: vrtManager/backup.py:180 #, python-format msgid "" "Storage pool %(pool)s has %(free).1f GiB free; the backup needs %(size).1f " @@ -10441,14 +10450,14 @@ msgstr "" " gerektiriyor (kopyalanan diskler, artı bunların %%%(percent)g kadarı, en az " "%(minimum)g GiB)" -#: vrtManager/backup.py:177 +#: vrtManager/backup.py:193 #, python-format msgid "" "The file %(name)s read back from the backup target differs from the one " "written" msgstr "Yedek hedefinden geri okunan %(name)s dosyası yazılandan farklı" -#: vrtManager/backup.py:254 +#: vrtManager/backup.py:270 #, python-format msgid "" "This host cannot run the VM's emulator %(emulator)s with machine type " @@ -10457,33 +10466,33 @@ msgstr "" "Bu sunucu sanal makinenin %(emulator)s öykünücüsünü %(machine)s makine " "türüyle çalıştıramıyor: %(error)s" -#: vrtManager/backup.py:258 +#: vrtManager/backup.py:274 #, python-format msgid "This host has no firmware %(loader)s" msgstr "Bu sunucuda %(loader)s firmware'i yok" -#: vrtManager/backup.py:262 +#: vrtManager/backup.py:278 #, python-format msgid "This host has no bridge %(name)s" msgstr "Bu sunucuda %(name)s köprüsü yok" -#: vrtManager/connection.py:45 +#: vrtManager/connection.py:46 msgid "Connection closed (error)" msgstr "Bağlantı kapandı (hata)" -#: vrtManager/connection.py:46 +#: vrtManager/connection.py:47 msgid "Connection closed (end of file)" msgstr "Bağlantı kapandı (dosya sonu)" -#: vrtManager/connection.py:47 +#: vrtManager/connection.py:48 msgid "Connection closed (keepalive timeout)" msgstr "Bağlantı kapandı (canlı tutma zaman aşımı)" -#: vrtManager/connection.py:48 +#: vrtManager/connection.py:49 msgid "Connection closed (client closed)" msgstr "Bağlantı kapandı (istemci kapattı)" -#: vrtManager/connection.py:155 +#: vrtManager/connection.py:156 #, python-format msgid "" "Connection Failed: %(host)s does not answer: %(requests)s requests still wait" @@ -10492,36 +10501,36 @@ msgstr "" "Bağlantı başarısız: %(host)s yanıt vermiyor: %(requests)s istek hâlâ onu " "bekliyor" -#: vrtManager/connection.py:250 +#: vrtManager/connection.py:253 #, python-format msgid "Connection Failed: %(host)s did not answer within %(seconds)s s" msgstr "Bağlantı başarısız: %(host)s %(seconds)s sn içinde yanıt vermedi" -#: vrtManager/connection.py:261 +#: vrtManager/connection.py:264 msgid "the connection closed right after opening" msgstr "bağlantı açıldıktan hemen sonra kapandı" -#: vrtManager/connection.py:274 +#: vrtManager/connection.py:277 #, python-format msgid "Connection Failed: %(error)s" msgstr "Bağlantı başarısız: %(error)s" -#: vrtManager/connection.py:343 +#: vrtManager/connection.py:346 #, python-format msgid "Connection closed (%(reason)s)" msgstr "Bağlantı kapandı (%(reason)s)" -#: vrtManager/connection.py:495 +#: vrtManager/connection.py:498 #, python-format msgid "Connection Failed: %(host)s is not connected" msgstr "Bağlantı başarısız: %(host)s bağlı değil" -#: vrtManager/connection.py:547 +#: vrtManager/connection.py:550 #, python-format msgid "This host has no architecture %(arch)s" msgstr "Bu sunucuda %(arch)s mimarisi yok" -#: vrtManager/connection.py:1233 +#: vrtManager/connection.py:1265 #, python-format msgid "" "Pool %(pool)s is not active: the files the disks of the VMs in it are made " diff --git a/locale/zh/LC_MESSAGES/django.mo b/locale/zh/LC_MESSAGES/django.mo index 8915b281..954096b6 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 fb70e7b5..d81a2871 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-17 08:38+0000\n" +"POT-Creation-Date: 2026-11-17 10:54+0000\n" "PO-Revision-Date: \n" "Last-Translator: \n" "Language-Team: \n" @@ -3136,17 +3136,17 @@ msgstr "请从可用名称列表中选择克隆的名称" msgid "%(quota)s: cannot create '%(clone_name)s'." msgstr "%(quota)s:无法创建“%(clone_name)s”。" -#: instances/jobs.py:206 instances/jobs.py:646 vmbackups/jobs.py:539 +#: instances/jobs.py:206 instances/jobs.py:646 vmbackups/jobs.py:548 #, python-format msgid "Instance '%(clone_name)s' already exists!" msgstr "虚拟机 '%(clone_name)s' 已存在!" -#: instances/jobs.py:208 vmbackups/jobs.py:541 +#: instances/jobs.py:208 vmbackups/jobs.py:550 #, python-format msgid "Instance name '%(clone_name)s' is longer than 64 characters" msgstr "虚拟机名称“%(clone_name)s”超过 64 个字符" -#: instances/jobs.py:211 vmbackups/jobs.py:543 +#: instances/jobs.py:211 vmbackups/jobs.py:552 #, python-format msgid "Instance name '%(clone_name)s' contains invalid characters!" msgstr "虚拟机名称 '%(clone_name)s' 包含无效字符!" @@ -3288,11 +3288,11 @@ msgid "Clone VM" msgstr "克隆虚拟机" #: instances/jobs.py:656 instances/jobs.py:663 instances/jobs.py:1005 -#: vmbackups/jobs.py:234 vmbackups/jobs.py:643 +#: vmbackups/jobs.py:243 vmbackups/jobs.py:652 msgid "Copying disks" msgstr "正在复制磁盘" -#: instances/jobs.py:715 vmbackups/jobs.py:310 +#: instances/jobs.py:715 vmbackups/jobs.py:319 msgid "libvirt has no result of the copy" msgstr "libvirt 没有复制的结果" @@ -3303,7 +3303,7 @@ msgid "" "(%(thaw)s); thaw them with: virsh domfsthaw %(vm)s" msgstr "复制失败:%(error)s。无法解冻客户机的文件系统(%(thaw)s);请用以下命令解冻:virsh domfsthaw %(vm)s" -#: instances/jobs.py:729 instances/jobs.py:821 vmbackups/jobs.py:316 +#: instances/jobs.py:729 instances/jobs.py:821 vmbackups/jobs.py:325 msgid "The copy failed" msgstr "复制失败" @@ -3321,11 +3321,11 @@ msgid "" "this job: %(volumes)s" msgstr "克隆的一个卷正在创建中;请检查这些卷,然后处理此任务:%(volumes)s" -#: instances/jobs.py:801 vmbackups/jobs.py:353 +#: instances/jobs.py:801 vmbackups/jobs.py:362 msgid "The job stopped before the copy started" msgstr "任务在复制开始前停止" -#: instances/jobs.py:808 vmbackups/jobs.py:401 +#: instances/jobs.py:808 vmbackups/jobs.py:410 msgid "libvirt is still copying the disks" msgstr "libvirt 仍在复制磁盘" @@ -3358,12 +3358,12 @@ msgstr "镜像已存在。请检查卷或更改虚拟机名称" msgid "Each network card needs a network" msgstr "每个网卡都需要一个网络" -#: instances/jobs.py:868 vrtManager/backup.py:260 vrtManager/instance.py:2871 +#: instances/jobs.py:868 vrtManager/backup.py:276 vrtManager/instance.py:2871 #, python-format msgid "This host has no network %(name)s" msgstr "此主机没有网络 %(name)s" -#: instances/jobs.py:870 vrtManager/backup.py:264 vrtManager/instance.py:2873 +#: instances/jobs.py:870 vrtManager/backup.py:280 vrtManager/instance.py:2873 #, python-format msgid "This host has no network filter %(name)s" msgstr "此主机没有网络过滤器 %(name)s" @@ -9270,154 +9270,154 @@ msgid "" "The VM's NVRAM file changed while it was backed up; back the VM up again" msgstr "虚拟机的 NVRAM 文件在备份期间发生了变化;请重新备份该虚拟机" -#: vmbackups/jobs.py:186 +#: vmbackups/jobs.py:195 msgid "Back up VM" msgstr "备份虚拟机" -#: vmbackups/jobs.py:221 +#: vmbackups/jobs.py:230 msgid "The schedule's window ended before the backup could start" msgstr "备份开始前计划的时间窗口已结束" -#: vmbackups/jobs.py:223 +#: vmbackups/jobs.py:232 #, python-format msgid "" "%(compute)s went into maintenance before the scheduled backup could start" msgstr "计划的备份开始前 %(compute)s 已进入维护" -#: vmbackups/jobs.py:250 vmbackups/jobs.py:317 +#: vmbackups/jobs.py:259 vmbackups/jobs.py:326 msgid "Writing the backup's files" msgstr "正在写入备份文件" -#: vmbackups/jobs.py:329 +#: vmbackups/jobs.py:338 msgid "The guest's file systems could not be thawed; trying again" msgstr "无法解冻客户机的文件系统;正在重试" -#: vmbackups/jobs.py:378 +#: vmbackups/jobs.py:387 #, python-format msgid "" "The VM is no longer on the compute the job ran on; check these volumes of the" " backup target, then resolve this job: %(volumes)s" msgstr "虚拟机已不在作业运行的计算节点上;请检查备份目标中的这些卷,然后解决此作业:%(volumes)s" -#: vmbackups/jobs.py:395 +#: vmbackups/jobs.py:404 #, python-format msgid "" "A disk was being copied when the job stopped; check these volumes of the " "backup target, then resolve this job: %(volumes)s" msgstr "作业停止时正在复制磁盘;请检查备份目标中的这些卷,然后解决此作业:%(volumes)s" -#: vmbackups/jobs.py:405 +#: vmbackups/jobs.py:414 #, python-format msgid "" "Another backup runs on the VM; check these volumes of the backup target, then" " resolve this job: %(volumes)s" msgstr "虚拟机上正在运行另一个备份;请检查备份目标中的这些卷,然后解决此作业:%(volumes)s" -#: vmbackups/jobs.py:411 +#: vmbackups/jobs.py:420 #, python-format msgid "" "libvirt has no result of the copy; check these volumes of the backup target, " "then resolve this job: %(volumes)s" msgstr "libvirt 没有复制的结果;请检查备份目标中的这些卷,然后解决此作业:%(volumes)s" -#: vmbackups/jobs.py:419 +#: vmbackups/jobs.py:428 msgid "The job stopped before the copy ended" msgstr "作业在复制结束前停止" -#: vmbackups/jobs.py:426 +#: vmbackups/jobs.py:435 #, python-format msgid "The backup's files could not be written: %(error)s" msgstr "无法写入备份文件:%(error)s" -#: vmbackups/jobs.py:446 +#: vmbackups/jobs.py:455 #, python-format msgid "No compute of backup target %(target)s reaches its storage pool" msgstr "备份目标 %(target)s 的计算节点都无法访问其存储池" -#: vmbackups/jobs.py:480 +#: vmbackups/jobs.py:489 msgid "Delete backup" msgstr "删除备份" -#: vmbackups/jobs.py:491 +#: vmbackups/jobs.py:500 msgid "This backup is being made; cancel its job to stop it" msgstr "此备份正在创建;要停止它,请取消其作业" -#: vmbackups/jobs.py:504 +#: vmbackups/jobs.py:513 msgid "The backup is no longer beyond what its schedule keeps; it is kept" msgstr "该备份已不再超出其计划保留的数量;予以保留" -#: vmbackups/jobs.py:556 +#: vmbackups/jobs.py:565 #, python-format msgid "The backup's file %(name)s is missing from the target" msgstr "目标中缺少备份文件 %(name)s" -#: vmbackups/jobs.py:559 vmbackups/jobs.py:561 +#: vmbackups/jobs.py:568 vmbackups/jobs.py:570 #, python-format msgid "The backup's file %(name)s differs from the one written" msgstr "备份文件 %(name)s 与写入的不同" -#: vmbackups/jobs.py:571 vmbackups/templates/vmbackups/restore.html:7 +#: vmbackups/jobs.py:580 vmbackups/templates/vmbackups/restore.html:7 msgid "Restore backup" msgstr "恢复备份" -#: vmbackups/jobs.py:584 +#: vmbackups/jobs.py:593 msgid "Only a ready backup is restored" msgstr "只能恢复就绪的备份" -#: vmbackups/jobs.py:614 +#: vmbackups/jobs.py:623 #, python-format msgid "A VM named %(name)s exists on %(compute)s" msgstr "%(compute)s 上已存在名为 %(name)s 的虚拟机" -#: vmbackups/jobs.py:622 +#: vmbackups/jobs.py:631 #, python-format msgid "This host has no active directory storage pool %(pool)s" msgstr "此主机没有名为 %(pool)s 的活动目录存储池" -#: vmbackups/jobs.py:639 +#: vmbackups/jobs.py:648 #, python-format msgid "The NVRAM file %(path)s exists already" msgstr "NVRAM 文件 %(path)s 已存在" -#: vmbackups/jobs.py:670 +#: vmbackups/jobs.py:679 #, python-format msgid "The VM was restored; it did not start: %(error)s" msgstr "虚拟机已恢复;但未能启动:%(error)s" -#: vmbackups/jobs.py:692 +#: vmbackups/jobs.py:701 #, python-format msgid "" "A disk was being copied when the job stopped; check this volume, then resolve" " this job: %(volumes)s" msgstr "作业停止时正在复制磁盘;请检查此卷,然后解决此作业:%(volumes)s" -#: vmbackups/jobs.py:697 +#: vmbackups/jobs.py:706 #, python-format msgid "" "Storage pool %(pool)s is not active; the restore's copies in it are removed " "when it is" msgstr "存储池 %(pool)s 未激活;其中恢复的副本将在其激活后删除" -#: vmbackups/jobs.py:706 +#: vmbackups/jobs.py:715 msgid "The VM was not defined; its copies were removed" msgstr "虚拟机未定义;其副本已删除" -#: vmbackups/jobs.py:725 vmbackups/templates/vmbackups/target.html:18 +#: vmbackups/jobs.py:734 vmbackups/templates/vmbackups/target.html:18 msgid "Read backups from target" msgstr "从目标读取备份" -#: vmbackups/jobs.py:773 +#: vmbackups/jobs.py:782 #, python-format msgid "" "Not read, as a file of the backup is missing, changed or unreadable: " "%(names)s" msgstr "由于备份的某个文件缺失、已更改或无法读取,未读取:%(names)s" -#: vmbackups/jobs.py:789 +#: vmbackups/jobs.py:798 msgid "Check backup target" msgstr "检查备份目标" -#: vmbackups/jobs.py:816 +#: vmbackups/jobs.py:825 #, python-format msgid "Files of these backups are missing from the target: %(backups)s" msgstr "以下备份的文件在目标中缺失:%(backups)s" @@ -9744,80 +9744,87 @@ msgid "" " not the one the backup target registered" msgstr "存储池 %(pool)s 不是此主机上活动的目录或 NFS 存储池,或不是备份目标登记的那个存储池" -#: vrtManager/backup.py:62 +#: vrtManager/backup.py:63 #, python-format msgid "%(vm)s has a saved state; start it or remove the saved state first" msgstr "%(vm)s 有已保存的状态;请先启动它或删除已保存的状态" -#: vrtManager/backup.py:64 -#, python-format -msgid "%(vm)s has TPM state; TPM backups come later" -msgstr "%(vm)s 有 TPM 状态;TPM 备份将在以后支持" - #: vrtManager/backup.py:66 #, python-format +msgid "" +"%(vm)s has a TPM of its own settings (encryption, a state path or another " +"backend); it cannot be backed up" +msgstr "%(vm)s 的 TPM 有自己的设置(加密、状态路径或其他后端);无法备份" + +#: vrtManager/backup.py:69 +#, python-format +msgid "%(vm)s has TPM state; shut it down to back it up" +msgstr "%(vm)s 有 TPM 状态;请将其关机后再备份" + +#: vrtManager/backup.py:71 +#, python-format msgid "%(vm)s shares a host directory (filesystem); it cannot be backed up" msgstr "%(vm)s 共享主机目录(filesystem);无法备份" -#: vrtManager/backup.py:68 +#: vrtManager/backup.py:73 #, python-format msgid "%(vm)s boots a kernel file of the host; it cannot be backed up" msgstr "%(vm)s 从主机上的内核文件启动;无法备份" -#: vrtManager/backup.py:70 +#: vrtManager/backup.py:75 #, python-format msgid "%(vm)s has a host device; it cannot be backed up" msgstr "%(vm)s 有主机设备;无法备份" -#: vrtManager/backup.py:76 +#: vrtManager/backup.py:81 msgid "CD-ROM: not copied" msgstr "CD-ROM:不复制" -#: vrtManager/backup.py:76 +#: vrtManager/backup.py:81 msgid "Floppy: not copied" msgstr "软盘:不复制" -#: vrtManager/backup.py:80 +#: vrtManager/backup.py:85 #, python-format msgid "Disk %(dev)s is encrypted; it cannot be backed up" msgstr "磁盘 %(dev)s 已加密;无法备份" -#: vrtManager/backup.py:83 +#: vrtManager/backup.py:88 #, python-format msgid "Disk %(dev)s is not a file; it cannot be backed up" msgstr "磁盘 %(dev)s 不是文件;无法备份" -#: vrtManager/backup.py:85 +#: vrtManager/backup.py:90 #, python-format msgid "Disk %(dev)s is shareable; it cannot be backed up" msgstr "磁盘 %(dev)s 可共享;无法备份" -#: vrtManager/backup.py:88 +#: vrtManager/backup.py:93 #, python-format msgid "Disk %(dev)s is %(format)s; only qcow2 and raw disks are backed up" msgstr "磁盘 %(dev)s 是 %(format)s 格式;只备份 qcow2 和 raw 磁盘" -#: vrtManager/backup.py:95 +#: vrtManager/backup.py:100 #, python-format msgid "" "Disk %(dev)s (%(path)s) is in no storage pool of the host; it cannot be " "backed up" msgstr "磁盘 %(dev)s(%(path)s)不在主机的任何存储池中;无法备份" -#: vrtManager/backup.py:108 +#: vrtManager/backup.py:113 #, python-format msgid "" "Disks %(devs)s change at the next start; back the VM up after it restarts" msgstr "磁盘 %(devs)s 将在下次启动时更改;请在虚拟机重启后再备份" -#: vrtManager/backup.py:113 vrtManager/instance.py:494 +#: vrtManager/backup.py:118 vrtManager/instance.py:494 #, python-format msgid "" "The NVRAM file %(path)s is not in libvirt's NVRAM directory %(dir)s and " "cannot be copied" msgstr "NVRAM 文件 %(path)s 不在 libvirt 的 NVRAM 目录 %(dir)s 中,无法复制" -#: vrtManager/backup.py:164 +#: vrtManager/backup.py:180 #, python-format msgid "" "Storage pool %(pool)s has %(free).1f GiB free; the backup needs %(size).1f " @@ -9826,83 +9833,83 @@ msgstr "" "存储池 %(pool)s 有 %(free).1f GiB 可用空间;备份需要 %(size).1f GiB(复制的磁盘,加上其 " "%(percent)g%%,至少 %(minimum)g GiB)" -#: vrtManager/backup.py:177 +#: vrtManager/backup.py:193 #, python-format msgid "" "The file %(name)s read back from the backup target differs from the one " "written" msgstr "从备份目标读回的文件 %(name)s 与写入的不同" -#: vrtManager/backup.py:254 +#: vrtManager/backup.py:270 #, python-format msgid "" "This host cannot run the VM's emulator %(emulator)s with machine type " "%(machine)s: %(error)s" msgstr "此主机无法以机器类型 %(machine)s 运行虚拟机的模拟器 %(emulator)s:%(error)s" -#: vrtManager/backup.py:258 +#: vrtManager/backup.py:274 #, python-format msgid "This host has no firmware %(loader)s" msgstr "此主机没有固件 %(loader)s" -#: vrtManager/backup.py:262 +#: vrtManager/backup.py:278 #, python-format msgid "This host has no bridge %(name)s" msgstr "此主机没有网桥 %(name)s" -#: vrtManager/connection.py:45 +#: vrtManager/connection.py:46 msgid "Connection closed (error)" msgstr "连接已关闭(错误)" -#: vrtManager/connection.py:46 +#: vrtManager/connection.py:47 msgid "Connection closed (end of file)" msgstr "连接已关闭(文件结束)" -#: vrtManager/connection.py:47 +#: vrtManager/connection.py:48 msgid "Connection closed (keepalive timeout)" msgstr "连接已关闭(保活超时)" -#: vrtManager/connection.py:48 +#: vrtManager/connection.py:49 msgid "Connection closed (client closed)" msgstr "连接已关闭(客户端已关闭)" -#: vrtManager/connection.py:155 +#: vrtManager/connection.py:156 #, python-format msgid "" "Connection Failed: %(host)s does not answer: %(requests)s requests still wait" " for it" msgstr "连接失败:%(host)s 无响应:仍有 %(requests)s 个请求在等待它" -#: vrtManager/connection.py:250 +#: vrtManager/connection.py:253 #, python-format msgid "Connection Failed: %(host)s did not answer within %(seconds)s s" msgstr "连接失败:%(host)s 在 %(seconds)s 秒内未响应" -#: vrtManager/connection.py:261 +#: vrtManager/connection.py:264 msgid "the connection closed right after opening" msgstr "连接在打开后立即关闭" -#: vrtManager/connection.py:274 +#: vrtManager/connection.py:277 #, python-format msgid "Connection Failed: %(error)s" msgstr "连接失败:%(error)s" -#: vrtManager/connection.py:343 +#: vrtManager/connection.py:346 #, python-format msgid "Connection closed (%(reason)s)" msgstr "连接已关闭(%(reason)s)" -#: vrtManager/connection.py:495 +#: vrtManager/connection.py:498 #, python-format msgid "Connection Failed: %(host)s is not connected" msgstr "连接失败:%(host)s 未连接" -#: vrtManager/connection.py:547 +#: vrtManager/connection.py:550 #, python-format msgid "This host has no architecture %(arch)s" msgstr "此主机没有 %(arch)s 架构" -#: vrtManager/connection.py:1233 +#: vrtManager/connection.py:1265 #, python-format msgid "" "Pool %(pool)s is not active: the files the disks of the VMs in it are made " diff --git a/vmbackups/jobs.py b/vmbackups/jobs.py index 0b20b047..39b9b271 100644 --- a/vmbackups/jobs.py +++ b/vmbackups/jobs.py @@ -141,6 +141,12 @@ def _publish(op, proxy, pool): if nvram is not None: files.append({"role": BackupFile.NVRAM, "dev": "", "volume": names["nvram"], "format": "raw", "capacity": len(nvram), "size": len(nvram), "sha256": put_file(proxy, pool, names["nvram"], nvram, _owner())}) + # a shut-off VM's (a running one with a TPM is refused); a secret: no other user reads it + tpm = proxy.read_tpm() if plan["tpm"] else None + for name, data in (tpm or {}).items(): + files.append({"role": BackupFile.TPM, "dev": name, "volume": names["tpm"] + name, "format": "raw", + "capacity": len(data), "size": len(data), + "sha256": put_file(proxy, pool, names["tpm"] + name, data, _owner(), mode="0600")}) definition = plan["definition"].encode() files.append({"role": BackupFile.DOMAIN, "dev": "", "volume": names["domain"], "format": "", "capacity": len(definition), "size": len(definition), "sha256": put_file(proxy, pool, names["domain"], definition, _owner())}) @@ -152,6 +158,7 @@ def _publish(op, proxy, pool): "created_at": backup.created_at.isoformat(), "consistency": op.intent["consistency"], "nvram": "copied" if nvram is not None else ("never written" if plan["nvram"] else "none"), + "tpm": "copied" if tpm else ("never written" if tpm == {} else "none"), "files": files, "left_out": plan["left_out"], "libvirt": proxy.wvm.getLibVersion(), @@ -173,7 +180,9 @@ def _publish(op, proxy, pool): def _discard(op, pool): """The job's files removed, its row failed.""" - remove_files(pool, _all_names(op.intent["names"])) + pool.refresh(0) # the TPM state files are named by what the VM had + names = op.intent["names"] + remove_files(pool, [*_all_names(names), *(n for n in pool.listVolumes() if n.startswith(names["tpm"]))]) Backup.objects.filter(uuid=op.intent["backup"]).update(state=Backup.FAILED, finished_at=timezone.now()) diff --git a/vmbackups/migrations/0003_tpm_files.py b/vmbackups/migrations/0003_tpm_files.py new file mode 100644 index 00000000..bebbf1f1 --- /dev/null +++ b/vmbackups/migrations/0003_tpm_files.py @@ -0,0 +1,18 @@ +# Generated by Django 5.2.18 on 2026-11-17 10:46 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('vmbackups', '0002_schedules'), + ] + + operations = [ + migrations.AlterField( + model_name='backupfile', + name='role', + field=models.CharField(choices=[('disk', 'disk'), ('nvram', 'nvram'), ('tpm', 'tpm'), ('domain', 'domain'), ('manifest', 'manifest')], max_length=16), + ), + ] diff --git a/vmbackups/models.py b/vmbackups/models.py index de01c331..71f0e477 100644 --- a/vmbackups/models.py +++ b/vmbackups/models.py @@ -115,12 +115,12 @@ class Backup(models.Model): class BackupFile(models.Model): - DISK, NVRAM, DOMAIN, MANIFEST = "disk", "nvram", "domain", "manifest" - ROLES = [(DISK, "disk"), (NVRAM, "nvram"), (DOMAIN, "domain"), (MANIFEST, "manifest")] + DISK, NVRAM, TPM, DOMAIN, MANIFEST = "disk", "nvram", "tpm", "domain", "manifest" + ROLES = [(DISK, "disk"), (NVRAM, "nvram"), (TPM, "tpm"), (DOMAIN, "domain"), (MANIFEST, "manifest")] backup = models.ForeignKey(Backup, on_delete=models.CASCADE, related_name="files") role = models.CharField(max_length=16, choices=ROLES) - dev = models.CharField(max_length=32, blank=True) + dev = models.CharField(max_length=32, blank=True) # a disk's target, a TPM state file's name volume = models.CharField(max_length=255) format = models.CharField(max_length=16, blank=True) capacity = models.BigIntegerField(default=0) diff --git a/vmbackups/tests/test_create.py b/vmbackups/tests/test_create.py index 34e51d64..db9ad4ee 100644 --- a/vmbackups/tests/test_create.py +++ b/vmbackups/tests/test_create.py @@ -31,11 +31,12 @@ def libvirt_error(text="x"): return libvirt.libvirtError(text) -def plan(nvram=None): +def plan(nvram=None, tpm=False): return { "definition": "vm1", "disks": [{"dev": "vda", "path": "/pool/a.qcow2", "pool": "default", "format": "qcow2", "capacity": GIB}], "nvram": nvram, + "tpm": tpm, "left_out": [{"dev": "sda", "why": "CD-ROM: not copied"}], } @@ -53,6 +54,7 @@ def proxy(status=libvirt.VIR_DOMAIN_SHUTOFF, nvram=None): p.backup_progress.return_value = None p.backup_result.return_value = (True, "") p.read_nvram.return_value = b"vars" + p.read_tpm.return_value = {"tpm2-00.permall": b"state"} return p @@ -75,11 +77,12 @@ class CreateBackupTests(TransactionTestCase): self.proxy = proxy() self.pool = target_pool() self.written = [] + self.modes = {} self.removed = [] for name, value in ( ("vmbackups.jobs.wvmBackup", MagicMock(return_value=self.proxy)), ("vmbackups.jobs.target_pool", MagicMock(return_value=self.pool)), - ("vmbackups.jobs.put_file", MagicMock(side_effect=lambda conn, pool, n, data, owner: self.written.append(n) or "sha")), + ("vmbackups.jobs.put_file", MagicMock(side_effect=self.put_file)), ("vmbackups.jobs.remove_files", MagicMock(side_effect=lambda pool, names: self.removed.extend(names))), ("vmbackups.jobs.NVRAM_WAIT", 0), ("vmbackups.jobs.PROGRESS_EVERY", 0), @@ -88,6 +91,15 @@ class CreateBackupTests(TransactionTestCase): patcher.start() self.addCleanup(patcher.stop) + fail_on = None + + def put_file(self, conn, pool, name, data, owner, mode="0644"): + if self.fail_on and name.endswith(self.fail_on): + raise libvirt_error("No space left on device") + self.written.append(name) + self.modes[name] = mode + return "sha" + def submit(self, frozen=False): op = jobs.submit("backup.create", self.admin, {"instance": self.vm.pk, "target": self.target.pk, "frozen": frozen}, f"key-{uuid4().hex[:12]}") @@ -123,6 +135,37 @@ class CreateBackupTests(TransactionTestCase): self.assertEqual((files["disk"].dev, files["disk"].capacity, files["disk"].size), ("vda", GIB, GIB // 2)) self.assertEqual(backup.manifest["left_out"], plan()["left_out"]) self.assertEqual(backup.manifest["consistency"], "offline") + self.assertEqual(backup.manifest["tpm"], "none") + + def test_a_shut_off_vms_tpm_state_is_kept(self): + self.proxy.backup_plan.return_value = plan(tpm=True) + op = self.submit() + self.run_job(op) + prefix = f"wvc-{op.intent['backup']}" + self.assertEqual(self.written, [f"{prefix}-tpm-tpm2-00.permall", f"{prefix}-domain.xml", f"{prefix}-manifest.json"]) + self.assertEqual(self.modes[f"{prefix}-tpm-tpm2-00.permall"], "0600") # a secret + tpm = self.backup(op).files.get(role=BackupFile.TPM) + self.assertEqual((tpm.dev, tpm.volume, tpm.size, tpm.sha256), ("tpm2-00.permall", f"{prefix}-tpm-tpm2-00.permall", 5, "sha")) + self.assertEqual(self.backup(op).manifest["tpm"], "copied") + + def test_a_tpm_that_never_started_is_said_so(self): + self.proxy.backup_plan.return_value = plan(tpm=True) + self.proxy.read_tpm.return_value = {} + op = self.submit() + self.run_job(op) + self.assertEqual(self.backup(op).manifest["tpm"], "never written") + self.assertFalse(self.backup(op).files.filter(role=BackupFile.TPM).exists()) + + def test_a_failed_backup_removes_the_tpm_files_it_wrote(self): + self.proxy.backup_plan.return_value = plan(tpm=True) + op = self.submit() + prefix = f"wvc-{op.intent['backup']}" + self.pool.listVolumes.return_value = [f"{prefix}-tpm-tpm2-00.permall", "wvc-00000000-0000-4000-8000-000000000009-tpm-x"] + self.fail_on = "-domain.xml" # once the TPM file is written + op = self.interrupted(op) + self.assertEqual(CreateBackup().reconcile(op).state, Operation.FAILED) + self.assertIn(f"{prefix}-tpm-tpm2-00.permall", self.removed) + self.assertNotIn("wvc-00000000-0000-4000-8000-000000000009-tpm-x", self.removed) def test_a_running_vm_is_frozen_backed_up_and_thawed(self): self.proxy.get_status.return_value = libvirt.VIR_DOMAIN_RUNNING diff --git a/vrtManager/backup.py b/vrtManager/backup.py index bd6e4c55..fa10ecb3 100644 --- a/vrtManager/backup.py +++ b/vrtManager/backup.py @@ -54,14 +54,19 @@ class wvmBackup(wvmInstance): def backup_plan(self): """What a backup of the VM copies, from its persistent definition: {"definition", "disks": [{dev, path, pool, format, capacity}], - "nvram": path or None, "left_out": [{dev, why}]}. Refuses, naming + "nvram": path or None, "tpm": whether it has a TPM (shut off: its + state is read by the job), "left_out": [{dev, why}]}. Refuses, naming why, a VM whose backup could not be restored as it is.""" tree = etree.fromstring(self._XMLDesc(PERSISTENT_XML)) name = self.instance.name() if self.instance.hasManagedSaveImage(0): raise OperationError(gettext_noop("%(vm)s has a saved state; start it or remove the saved state first"), vm=name) - if tree.find("devices/tpm") is not None: - raise OperationError(gettext_noop("%(vm)s has TPM state; TPM backups come later"), vm=name) + tpm = self.get_tpm() + if tpm == "custom": + raise OperationError(gettext_noop("%(vm)s has a TPM of its own settings (encryption, a state path or " + "another backend); it cannot be backed up"), vm=name) + if tpm and self.instance.state()[0] != libvirt.VIR_DOMAIN_SHUTOFF: + raise OperationError(gettext_noop("%(vm)s has TPM state; shut it down to back it up"), vm=name) if tree.find("devices/filesystem") is not None: raise OperationError(gettext_noop("%(vm)s shares a host directory (filesystem); it cannot be backed up"), vm=name) if tree.xpath("os/kernel|os/initrd|os/dtb"): @@ -112,7 +117,8 @@ class wvmBackup(wvmInstance): if nvram and os.path.dirname(nvram) != NVRAM_DIR: raise OperationError(gettext_noop("The NVRAM file %(path)s is not in libvirt's NVRAM directory %(dir)s and cannot be copied"), path=nvram, dir=NVRAM_DIR) - return {"definition": etree.tostring(tree).decode(), "disks": disks, "nvram": nvram, "left_out": left_out} + return {"definition": etree.tostring(tree).decode(), "disks": disks, "nvram": nvram, "tpm": bool(tpm), + "left_out": left_out} def copy_disk_offline(self, disk, pool, name, owner_uid, owner_gid): """A shut-off VM's disk copied into the target pool, flat, in its @@ -140,6 +146,15 @@ class wvmBackup(wvmInstance): vol = self._find_volume(pool, os.path.basename(path)) return None if vol is None else self.download_volume(vol) + def read_tpm(self): + """The shut-off VM's TPM state files: {name: bytes}, {} when it never + started. swtpm's .lock is not state.""" + with self._tpm_pool(self.instance.UUIDString()) as pool: + if pool is None: + return {} + return {name: self.download_volume(pool.storageVolLookupByName(name)) + for name in sorted(pool.listVolumes()) if not name.startswith(".")} + def backup_file_names(uuid, disks, nvram): """The names of a backup's files in the target pool, from its UUID only.""" @@ -147,6 +162,7 @@ def backup_file_names(uuid, disks, nvram): return { "disks": {d["dev"]: f"{prefix}-{d['dev']}.{'qcow2' if d['format'] == 'qcow2' else 'raw'}" for d in disks}, "nvram": f"{prefix}-nvram.fd" if nvram else None, + "tpm": f"{prefix}-tpm-", # and the state file's name "domain": f"{prefix}-domain.xml", "manifest": f"{prefix}-manifest.json", } @@ -166,12 +182,12 @@ def check_target_space(pool, disks, free_percent, free_min_gib): pool=pool.name(), free=free / 1024**3, size=needed / 1024**3, percent=free_percent, minimum=free_min_gib) -def put_file(conn, pool, name, data, owner): +def put_file(conn, pool, name, data, owner, mode="0644"): """Writes a small file of a backup into the target pool as owner (uid, - gid), replacing one of that name, and reads it back. Returns its - SHA-256.""" + gid) with mode, replacing one of that name, and reads it back. Returns + its SHA-256.""" remove_files(pool, [name]) - vol = conn.upload_volume(pool, name, data, owner=owner) + vol = conn.upload_volume(pool, name, data, owner=owner, mode=mode) if conn.download_volume(vol) != data: vol.delete(0) raise OperationError(gettext_noop("The file %(name)s read back from the backup target differs from the one written"), name=name) diff --git a/vrtManager/connection.py b/vrtManager/connection.py index bc449214..cdb104f3 100644 --- a/vrtManager/connection.py +++ b/vrtManager/connection.py @@ -1,5 +1,6 @@ from django.utils.translation import gettext_noop import contextlib +import errno import io import logging import os @@ -188,6 +189,8 @@ request_finished.connect(_request_finished, dispatch_uid="vrtManager.connection. # libvirt's per-host directory of the VMs' UEFI variables (NVRAM) NVRAM_DIR = "/var/lib/libvirt/qemu/nvram" +# libvirt's per-host directory of the emulated TPMs' state: /tpm2/ +SWTPM_DIR = "/var/lib/libvirt/swtpm" # the files and devices of a definition's disks that may grow from others; a # raw one does not UNREAD_DISKS = etree.XPath("devices/disk[@device='disk'][not(driver/@type='raw')]/source/@file|" @@ -1072,6 +1075,35 @@ class wvmConnect(object): with contextlib.suppress(libvirtError): pool.destroy() + @contextlib.contextmanager + def _tpm_pool(self, vm_uuid, build=False): + """An active, refreshed pool on the TPM 2.0 state directory of the VM + vm_uuid, destroyed after; None when the directory does not exist (the + VM never started) and build is false; build makes it. Used only by + the worker's jobs that hold the VM: the pool a stopped worker left on + the directory is taken, as libvirt refuses a second one.""" + path = f"{SWTPM_DIR}/{vm_uuid}/tpm2" + pool = self.pool_at(path) + if pool is not None: + pool.refresh(0) + else: + try: + pool = self.wvm.storagePoolCreateXML( + f"webvirtcloud-tpm-{uuid.uuid4().hex[:8]}" + f"{path}", + libvirt.VIR_STORAGE_POOL_CREATE_WITH_BUILD if build else 0, + ) + except libvirtError as err: + if build or err.get_error_code() != libvirt.VIR_ERR_SYSTEM_ERROR or err.get_int1() != errno.ENOENT: + raise + yield None + return + try: + yield pool + finally: + with contextlib.suppress(libvirtError): + pool.destroy() + def upload_volume(self, pool, name, data, owner=None, mode="0644"): """A new raw volume in pool holding data, written through a libvirt stream, which every connection type carries; owner: (uid, gid) of diff --git a/vrtManager/tests/test_backup.py b/vrtManager/tests/test_backup.py index dcb6745c..b6e21e52 100644 --- a/vrtManager/tests/test_backup.py +++ b/vrtManager/tests/test_backup.py @@ -2,6 +2,7 @@ names and space, and the small files' upload read back.""" import unittest +from contextlib import nullcontext from unittest.mock import MagicMock import libvirt @@ -13,6 +14,7 @@ from vrtManager.instance import PERSISTENT_XML GIB = 1024**3 QCOW = "" RAW = "" +TPM = "" CDROM = "" @@ -34,6 +36,7 @@ def proxy(xml=None, live=None, state=libvirt.VIR_DOMAIN_SHUTOFF, managed_save=Fa p.wvm = MagicMock() p.instance = MagicMock() p.instance.name.return_value = "vm1" + p.instance.UUIDString.return_value = "u" p.instance.state.return_value = [state, 0] p.instance.hasManagedSaveImage.return_value = managed_save persistent = xml or domain() @@ -103,7 +106,12 @@ class BackupPlanTestCase(unittest.TestCase): "host device": (QCOW + "", ("host device",)), "host device NIC": (QCOW + "", ("host device",)), - "tpm": (QCOW + "", ("vm1", "TPM")), + "encrypted tpm": (QCOW + "" + "", ("vm1", "TPM")), + "tpm state path": (QCOW + "" + "", ("vm1", "TPM")), + "host tpm": (QCOW + "", + ("vm1", "TPM")), } for name, (devices, texts) in cases.items(): with self.subTest(name): @@ -112,6 +120,33 @@ class BackupPlanTestCase(unittest.TestCase): with self.subTest(tag): self.refused(proxy(domain(os_extra=f"<{tag}>/boot/x")), "kernel") + def test_a_shut_off_vms_tpm_is_backed_up_and_its_state_read_by_the_job(self): + p = proxy(domain(QCOW + TPM)) + p._tpm_pool = MagicMock() + self.assertTrue(p.backup_plan()["tpm"]) + p._tpm_pool.assert_not_called() # the plan runs in pages too: only the worker reads the state + self.assertFalse(proxy(domain(QCOW)).backup_plan()["tpm"]) + + def test_the_tpm_state_files_are_read_without_swtpms_lock(self): + p = proxy(domain(QCOW + TPM)) + state = MagicMock() + state.listVolumes.return_value = [".lock", "tpm2-00.permall"] + p._tpm_pool = MagicMock(return_value=nullcontext(state)) + p.download_volume = MagicMock(return_value=b"state") + self.assertEqual(p.read_tpm(), {"tpm2-00.permall": b"state"}) + p._tpm_pool.assert_called_once_with("u") + state.storageVolLookupByName.assert_called_once_with("tpm2-00.permall") + + def test_a_tpm_that_never_started_has_no_files(self): + p = proxy(domain(QCOW + TPM)) + p._tpm_pool = MagicMock(return_value=nullcontext(None)) + self.assertEqual(p.read_tpm(), {}) + + def test_a_running_or_paused_vm_with_a_tpm_is_refused(self): + for state in (libvirt.VIR_DOMAIN_RUNNING, libvirt.VIR_DOMAIN_PAUSED): + with self.subTest(state): + self.refused(proxy(domain(QCOW + TPM), state=state), "vm1", "TPM", "shut it down") + def test_a_saved_state_is_refused(self): self.refused(proxy(managed_save=True), "saved state") @@ -145,6 +180,7 @@ class FilesTestCase(unittest.TestCase): { "disks": {"vda": f"wvc-{uuid}-vda.qcow2", "vdb": f"wvc-{uuid}-vdb.raw"}, "nvram": f"wvc-{uuid}-nvram.fd", + "tpm": f"wvc-{uuid}-tpm-", "domain": f"wvc-{uuid}-domain.xml", "manifest": f"wvc-{uuid}-manifest.json", }, @@ -181,7 +217,42 @@ class FilesTestCase(unittest.TestCase): ) old.delete.assert_called_once_with(0) # written as QEMU's user: an NFS export that squashes root refuses root's files - conn.upload_volume.assert_called_once_with(pool, "wvc-x-domain.xml", b"data", owner=(107, 108)) + conn.upload_volume.assert_called_once_with(pool, "wvc-x-domain.xml", b"data", owner=(107, 108), mode="0644") + + def test_a_tpm_directory_that_does_not_exist_gives_no_pool(self): + import errno + + from vrtManager.connection import wvmConnect + + conn = wvmConnect.__new__(wvmConnect) + conn.wvm = MagicMock() + missing = libvirt.libvirtError("cannot open directory") + missing.err = (libvirt.VIR_ERR_SYSTEM_ERROR, 0, "", 2, None, None, None, errno.ENOENT, -1) + conn.wvm.storagePoolCreateXML.side_effect = missing + conn.wvm.listAllStoragePools.return_value = [] + with conn._tpm_pool("u") as pool: + self.assertIsNone(pool) + self.assertIn("/var/lib/libvirt/swtpm/u/tpm2", conn.wvm.storagePoolCreateXML.call_args.args[0]) + conn.wvm.listAllStoragePools.return_value = [] + with self.assertRaises(libvirt.libvirtError), conn._tpm_pool("u", build=True): + pass + missing.err = (libvirt.VIR_ERR_SYSTEM_ERROR, 0, "", 2, None, None, None, errno.EACCES, -1) + with self.assertRaises(libvirt.libvirtError), conn._tpm_pool("u"): + pass + + def test_a_tpm_pool_a_stopped_worker_left_is_taken_and_destroyed(self): + from vrtManager.connection import wvmConnect + + conn = wvmConnect.__new__(wvmConnect) + conn.wvm = MagicMock() + left = MagicMock() + left.XMLDesc.return_value = "/var/lib/libvirt/swtpm/u/tpm2" + conn.wvm.listAllStoragePools.return_value = [left] + with conn._tpm_pool("u") as pool: + self.assertIs(pool, left) + conn.wvm.storagePoolCreateXML.assert_not_called() + left.refresh.assert_called_once_with(0) + left.destroy.assert_called_once_with() def test_upload_volume_sets_the_owner(self): from lxml import etree