Re: autostart sessiioned vms

2024-08-28 Thread Michal Prívozník
On 8/27/24 17:42, daggs wrote:
>> Sent: Tuesday, August 27, 2024 at 10:34 AM
>> From: "Michal Prívozník" 
>> To: "daggs" 
>> Cc: users@lists.libvirt.org
>> Subject: Re: autostart sessiioned vms
>>
>> On 8/26/24 19:33, daggs wrote:
>>> Greetings Michal,
>>>
 Sent: Monday, August 26, 2024 at 11:52 AM
 From: "Michal Prívozník" 
 To: "daggs" , users@lists.libvirt.org
 Subject: Re: autostart sessiioned vms

 On 8/23/24 14:23, daggs via Users wrote:
> Greetings,
>
> I'm running sessioned vms which I want to start them up at boot.
> I've marked a vm inside a use as autostart, added libvirtd to the boot 
> order and rebooted but it didn't started the vm.
> I tried adding libvirt-guests to bott services but my sessioned vm is 
> still not autostarting.
> what is the proper way to do so?

 There are two modes of operation:

 1) qemu:///system
 2) qemu:///session

 The former runs a system-wide VMs, the latter runs per-user VMs. The
 former runs libvirtd under root, the latter runs libvirtd under given
 user. If you enable libvirtd at startup, it's very likely that you're
 starting the system-wide instance (i.e. qemu:///system).

 Usually, per-user daemons (like dbus, pipewire) are started after user
 logs in. That's where you want to place libvirtd start too. I'm not sure
 what init system you're using, but perhaps it has a way to start a
 per-user service - consult documentation to your init system.

 BTW: user daemon is started automatically upon connection opening. For
 instance, running the following starts a session daemon:

   $ virsh uri

 Oh, and if you're using autostart for other objects than domains, then
 you need to start corresponding daemons.

 Michal


>>>
>>> I'm using openrc.
>>> so based on the above, if I login as the user where the vm is defined, it 
>>> should start it?
>>
>> If you configure your session manager then yes. For instance, I'm using
>> KDE and I can configure what files should be executed after login.
>>
> that system uses only cli, I need the vms to start at boot

Then consult openrc manpage. Looks like Gentoo has good docs:

https://wiki.gentoo.org/wiki/OpenRC/User_services

> 
>>> what happens if I log out from the user? the vm stays up?
>>
>> Yes, the daemon won't die unless there's no VM running and no client
>> connected for 120 seconds (by default).
> what do you mean by "client"

Libvirt uses client server architecture. Now, a client can be just
anything - virsh [1]. virt-manager, virt-viewer, ...

1: by default, running just 'virsh' in interactive mode won't connect
anywhere. Only after the first command is entered virsh opens a
connection. Oh, an running virsh in non-interactive mode causes virsh to
connect, run the command and disconnect.

Michal


Re: autostart sessiioned vms

2024-08-28 Thread daggs via Users



> Sent: Wednesday, August 28, 2024 at 10:57 AM
> From: "Michal Prívozník" 
> To: "daggs" 
> Cc: users@lists.libvirt.org
> Subject: Re: autostart sessiioned vms
>
> On 8/27/24 17:42, daggs wrote:
> >> Sent: Tuesday, August 27, 2024 at 10:34 AM
> >> From: "Michal Prívozník" 
> >> To: "daggs" 
> >> Cc: users@lists.libvirt.org
> >> Subject: Re: autostart sessiioned vms
> >>
> >> On 8/26/24 19:33, daggs wrote:
> >>> Greetings Michal,
> >>>
>  Sent: Monday, August 26, 2024 at 11:52 AM
>  From: "Michal Prívozník" 
>  To: "daggs" , users@lists.libvirt.org
>  Subject: Re: autostart sessiioned vms
> 
>  On 8/23/24 14:23, daggs via Users wrote:
> > Greetings,
> >
> > I'm running sessioned vms which I want to start them up at boot.
> > I've marked a vm inside a use as autostart, added libvirtd to the boot 
> > order and rebooted but it didn't started the vm.
> > I tried adding libvirt-guests to bott services but my sessioned vm is 
> > still not autostarting.
> > what is the proper way to do so?
> 
>  There are two modes of operation:
> 
>  1) qemu:///system
>  2) qemu:///session
> 
>  The former runs a system-wide VMs, the latter runs per-user VMs. The
>  former runs libvirtd under root, the latter runs libvirtd under given
>  user. If you enable libvirtd at startup, it's very likely that you're
>  starting the system-wide instance (i.e. qemu:///system).
> 
>  Usually, per-user daemons (like dbus, pipewire) are started after user
>  logs in. That's where you want to place libvirtd start too. I'm not sure
>  what init system you're using, but perhaps it has a way to start a
>  per-user service - consult documentation to your init system.
> 
>  BTW: user daemon is started automatically upon connection opening. For
>  instance, running the following starts a session daemon:
> 
>    $ virsh uri
> 
>  Oh, and if you're using autostart for other objects than domains, then
>  you need to start corresponding daemons.
> 
>  Michal
> 
> 
> >>>
> >>> I'm using openrc.
> >>> so based on the above, if I login as the user where the vm is defined, it 
> >>> should start it?
> >>
> >> If you configure your session manager then yes. For instance, I'm using
> >> KDE and I can configure what files should be executed after login.
> >>
> > that system uses only cli, I need the vms to start at boot
> 
> Then consult openrc manpage. Looks like Gentoo has good docs:
> 
> https://wiki.gentoo.org/wiki/OpenRC/User_services
understood, that's easy, I'll write a service that boots them up.

> 
> > 
> >>> what happens if I log out from the user? the vm stays up?
> >>
> >> Yes, the daemon won't die unless there's no VM running and no client
> >> connected for 120 seconds (by default).
> > what do you mean by "client"
> 
> Libvirt uses client server architecture. Now, a client can be just
> anything - virsh [1]. virt-manager, virt-viewer, ...
> 
> 1: by default, running just 'virsh' in interactive mode won't connect
> anywhere. Only after the first command is entered virsh opens a
> connection. Oh, an running virsh in non-interactive mode causes virsh to
> connect, run the command and disconnect.
> 
> Michal
> 
> 
that I know, I'm using it currently. just needed the clarification on what 
client means.

thanks for all the info