<div dir="ltr"><div dir="ltr"><br></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Tue, Feb 18, 2020 at 12:03 AM Michal Privoznik <<a href="mailto:mprivozn@redhat.com">mprivozn@redhat.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">On 2/17/20 8:20 PM, Yuri Weinstein wrote:<br>
> Thanks Michal!<br>
> <br>
> See comments in line<br>
> <br>
> On Mon, Feb 17, 2020 at 9:23 AM Michal Privoznik <<a href="mailto:mprivozn@redhat.com" target="_blank">mprivozn@redhat.com</a> <br>
> <mailto:<a href="mailto:mprivozn@redhat.com" target="_blank">mprivozn@redhat.com</a>>> wrote:<br>
> <br>
>     On 2/16/20 10:20 PM, Yuri Weinstein wrote:<br>
>      > I used to have QEMU/KVM and Virtual Machine Manager running on<br>
>     ubuntu<br>
>      > 16.04 and used to start my VM from crontab as:<br>
>      ><br>
>      > @reboot sleep 30 && virsh start WINDOWS10<br>
> <br>
>     Libvirt has an autostart feature, which can start your domain on the<br>
>     first time libvirtd is started (i.e. during boot).<br>
> <br>
>     virsh autostart WINDOWS10<br>
> <br>
>      ><br>
>      > After upgrading to ubuntu 18.04 this stopped working, with error:<br>
>      ><br>
>      > error: failed to get domain 'WINDOWS10'<br>
>      > error: Domain not found: no domain with matching name 'WINDOWS10'<br>
>      ><br>
>      > Running command as "virsh start WINDOWS10" works fine.<br>
>      ><br>
> <br>
>     This is probably because cron doesn't run the command as root and hence<br>
>     the virsh is no longer connecting to 'qemu:///system' but<br>
>     'qemu:///session'. Change it to:<br>
> <br>
>     virsh -c qemu:///system start WINDOWS10<br>
> <br>
> <br>
> I managed to force austart via Startup App as:<br>
> sh -c "sleep 30 && /usr/bin/virsh start WINDOWS10"<br>
> <br>
> See your point about using root and/or 'qemu:///system' and will try it.<br>
> <br>
> <br>
>     But I suggest using the autostart feature instead.<br>
> <br>
> <br>
> This is the main issue - it does not work! :(  Tried via command line and UI<br>
> You can see =><br>
> Autostart:      enable<br>
> <br>
> How can this be fixed and/or troubleshooted?<br>
<br>
Oh, I've completely missed that. Sorry. What is your libvirt version? <br>
Since v5.9.0 libvirt will autostart domains exactly once for every boot <br>
of the host. I mean, when libvirtd is started it will check if <br>
/var/run/libvirt/qemu/autostarted file exists and if it doesn't, it will <br>
autostart all qemu domains with autostart enabled. If the file does <br>
exist then no autostart is attempted.<br></blockquote><div><br></div><div>My version show:</div><div> virsh version<br>Compiled against library: libvirt 4.0.0<br>Using library: libvirt 4.0.0<br>Using API: QEMU 4.0.0<br>Running hypervisor: QEMU 2.11.1</div><div><br></div><div>Is it right?  I thought my system is up to date.<br></div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<br>
This usually works as expected - when host boots and starts libvirtd <br>
service all domains are autostarted. And if libvirtd is restarted <br>
afterwards no autostart is happening. If host reboots, /var/run should <br>
be purged and the file with it. Therefore, autostart will be run after <br>
reboot again.<br>
<br>
Under what connection does your domain live? qemu:///system or <br>
qemu:///session? Because if it is the latter then this won't work - <br>
session daemon is not started automatically. However, if you are using <br>
socket activated system daemon, then the daemon is not started on the <br>
boot only on its first use and therefore autostart will be delayed until <br>
then.<br>
<br>
Michal<br></blockquote><div><br></div><div>I can do  <br></div><div><br></div><div>virsh -c qemu:///system</div><div>and list --all shows my domains</div><div> (virsh -c qemu:///session won't do it)</div><div><br></div><div>So I guess under qemu:///system</div><div><br></div></div></div>