首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >virsh自动启动不工作

virsh自动启动不工作
EN

Server Fault用户
提问于 2022-01-15 07:35:22
回答 3查看 2.4K关注 0票数 4
代码语言:javascript
复制
root@virtual3:~# virsh autostart nstest
Domain nstest marked as autostarted

root@virtual3:~# virsh dominfo nstest 
Id:             -
Name:           nstest
UUID:           8cf691cd-7246-442b-a26b-3580e24600c5
OS Type:        hvm
State:          shut off
CPU(s):         2
Max memory:     6291456 KiB
Used memory:    2097152 KiB
Persistent:     yes
Autostart:      disable
Managed save:   no
Security model: apparmor
Security DOI:   0

root@virtual3:~# 

我做错了什么?域xml列在/etc/libvirt/qemu/autostart中,但仍然没有自动启动:(

日志中没有任何内容:(

EN

回答 3

Server Fault用户

发布于 2022-02-03 21:43:31

我也有同样的问题(2/3/22),现在找到了解决办法(2/7/22)。

问题:我也有同样的问题。以前从没发生过这种事。在一台Centos 7主机上,我先前设置为自动启动的前3个VM工作正常(我可以启用和禁用自动启动)。但我有另外4个以前自动启动,现在设置为不这样做,而且我无法启用。我通常使用UI。如果我点击自动启动,保存,并回来,它没有检查,即使它应该是。因此,我在命令行中尝试了它,它也不起作用,并且我发现了上面您发现的内容。重新启动客户端或主机都没有区别。无论客户端VM正在运行还是关闭,都没有区别。

解决方案。好像有些东西不同步了。什么,我不确定。这个问题显然不是保存在虚拟机.xml文件中的东西。虽然我从来没有发现到底出了什么问题,但我还是想出了解决办法。任何设置为autostart的内容都应该在/etc/libvirt/qemu/autostart/命名中有一个条目,类似于machinename.xml,其中包含与/etc/libvirt/qemu/中同名的虚拟机的xml配置文件的符号链接。删除/etc/libvirt/ qemu /autostart目录中问题客户端的符号链接(确保不删除qemu目录中的源xml )。现在,当您尝试通过UI或via‘virsh自动启动-机器名打开自动启动时。我删除了4个问题客户端的autostart/*xml文件,然后通过UI反复打开和关闭一个文件,通过命令行打开和关闭另一个文件,现在一切都正常.

票数 2
EN

Server Fault用户

发布于 2022-02-18 15:06:56

在我的例子中,问题是我在autostart文件夹中有一个文件,而不是一个链接。

代码语言:javascript
复制
root@kvm1630:/etc/libvirt/qemu # ls -l 
-rw------- 1 root root  7982 févr. 18 15:17 hebergement.xml

root@kvm1630:/etc/libvirt/qemu # ls -l autostart/
-rwx------ 1 root root 6195 avril 16  2021 hebergement.xml*

解决方案:删除文件并创建一个符号链接。

代码语言:javascript
复制
root@kvm1630:/etc/libvirt/qemu # rm autostart/hebergement.xml
rm: remove regular file 'autostart/hebergement.xml'? y

然后再次运行命令,使VM自动启动:

代码语言:javascript
复制
root@kvm1630:/etc/libvirt/qemu # virsh autostart hebergement
Domain hebergement marked as autostarted

root@kvm1630:/etc/libvirt/qemu # ls -l autostart/
lrwxrwxrwx 1 root root   33 févr. 18 15:49 hebergement.xml -> /etc/libvirt/qemu/hebergement.xml

最后,我们检查VM确实是自动启动的。

代码语言:javascript
复制
root@kvm1630:/etc/libvirt/qemu # virsh dominfo hebergement
Id:             9
Name:           hebergement
UUID:           74590197-8b3a-4bed-95e6-653ce7c456af
OS Type:        hvm
State:          running
CPU(s):         1
CPU time:       6614,7s
Max memory:     8388608 KiB
Used memory:    8388608 KiB
Persistent:     yes
Autostart:      enable
Managed save:   no
Security model: none
Security DOI:   0

我每小时用fi备份LibVirtKvm脚本创建VM快照.结果: VM定义xml文件每小时更改一次,如下所示:

代码语言:javascript
复制
root@kvm1630:/etc/libvirt/qemu # colordiff hebergement.xml autostart/hebergement.xml
46,83c48
<       <source file='/var/lib/libvirt/images/hebergement.bimg-20220218-151710'/>
<       <backingStore type='file'>
<         <format type='qcow2'/>
<         <source file='/var/lib/libvirt/images/hebergement.bimg-20220218-141710'/>
<         <backingStore type='file'>
<           <format type='qcow2'/>
<           <source file='/var/lib/libvirt/images/hebergement.bimg-20220218-131710'/>
<           <backingStore type='file'>
<             <format type='qcow2'/>
<             <source file='/var/lib/libvirt/images/hebergement.bimg-20220218-121709'/>
<             <backingStore type='file'>
<               <format type='qcow2'/>
<               <source file='/var/lib/libvirt/images/hebergement.bimg-20220218-111709'/>
<               <backingStore type='file'>
<                 <format type='qcow2'/>
<                 <source file='/var/lib/libvirt/images/hebergement.bimg-20220218-101711'/>
<                 <backingStore type='file'>
<                   <format type='qcow2'/>
<                   <source file='/var/lib/libvirt/images/hebergement.bimg-20220218-091738'/>
<                   <backingStore type='file'>
<                     <format type='qcow2'/>
<                     <source file='/var/lib/libvirt/images/hebergement.bimg-20220218-091200'/>
<                     <backingStore type='file'>
<                       <format type='qcow2'/>
<                       <source file='/var/lib/libvirt/images/hebergement.bimg-20220218-082151'/>
<                       <backingStore type='file'>
<                         <format type='qcow2'/>
<                         <source file='/var/lib/libvirt/images/hebergement.qcow2'/>
<                         <backingStore/>
<                       </backingStore>
<                     </backingStore>
<                   </backingStore>
<                 </backingStore>
<               </backingStore>
<             </backingStore>
<           </backingStore>
<         </backingStore>
<       </backingStore>
---
>       <source file='/var/lib/libvirt/images/hebergement.bimg-20210415-011726'/>

希望它能帮上忙

欧内斯特。

票数 1
EN

Server Fault用户

发布于 2022-01-15 18:00:05

看起来,您希望设置“自动启动”将立即启动VM。然而,这并不是自动启动的预期效果。相反,它只是为了确保VM在主机启动时自动启动。来自手册页

将域配置为在引导时自动启动。

如果您想要立即启动VM,则需要使用virsh start

票数 0
EN
页面原文内容由Server Fault提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://serverfault.com/questions/1090087

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档