[libvirt] Expose virDomainGetAutostart through virsh?

Hi list, I'd like to check if a domain has autostart enabled. I do this now by looking if there's a symlink in /etc/libvirt/qemu/autostart, but it feels a bit hackish. Is this something that could be added to virsh? Something like virsh get-autostart domain would be great. Kind regards, Ruben

On 2012年11月07日 18:04, Ruben Kerkhof wrote:
Hi list,
I'd like to check if a domain has autostart enabled. I do this now by looking if there's a symlink in /etc/libvirt/qemu/autostart, but it feels a bit hackish.
Is this something that could be added to virsh? Something like virsh get-autostart domain would be great.
It's already exposed in virsh, see "virsh dominfo", there is a field for it. Regards, Osier

On Wed, Nov 7, 2012 at 11:27 AM, Osier Yang <jyang@redhat.com> wrote:
On 2012年11月07日 18:04, Ruben Kerkhof wrote:
Hi list,
I'd like to check if a domain has autostart enabled. I do this now by looking if there's a symlink in /etc/libvirt/qemu/autostart, but it feels a bit hackish.
Is this something that could be added to virsh? Something like virsh get-autostart domain would be great.
It's already exposed in virsh, see "virsh dominfo", there is a field for it.
I don't know how I've missed that, thanks!
Regards, Osier
Regards, Ruben

On 11/07/12 11:04, Ruben Kerkhof wrote:
Hi list,
I'd like to check if a domain has autostart enabled. I do this now by looking if there's a symlink in /etc/libvirt/qemu/autostart, but it feels a bit hackish.
Is this something that could be added to virsh? Something like virsh get-autostart domain would be great.
For now there are two options how to check the autostart flag: 1) virsh dominfo - This is suitable to check for the state of a single guest. Unfortunately we have just this one output option where it is embedded with other information about the guest: $ virsh dominfo tr Id: 1 Name: tr UUID: 17f42b42-9fdd-81e3-4a93-a75021a707d3 OS Type: hvm State: running CPU(s): 1 CPU time: 200.5s Max memory: 53248 KiB Used memory: 53248 KiB Persistent: yes Autostart: enable <- here! Managed save: no Security model: none Security DOI: 0 2) use virsh list --all --autostart to list guests that have the autostart flag enabled (also note that there are script-friendly outputs for virsh list --name and --uuid): $ virsh list --all --autostart Id Name State ---------------------------------------------------- 1 tr running - Bare shut off We're planing on adding the autostart flag as an XML element and a few other improvements of autostaring guests.
Kind regards,
Ruben
Peter

Hi Peter, On Wed, Nov 7, 2012 at 11:32 AM, Peter Krempa <pkrempa@redhat.com> wrote:
2) use virsh list --all --autostart to list guests that have the autostart flag enabled (also note that there are script-friendly outputs for virsh list --name and --uuid):
$ virsh list --all --autostart Id Name State ---------------------------------------------------- 1 tr running - Bare shut off
Ah, that's nice. I looked for something for that but libvirt on rhel6 doesn't have this yet.
We're planing on adding the autostart flag as an XML element and a few other improvements of autostaring guests.
Great, thanks! Ruben

On Wed, Nov 07, 2012 at 11:32:22AM +0100, Peter Krempa wrote:
On 11/07/12 11:04, Ruben Kerkhof wrote:
Hi list,
I'd like to check if a domain has autostart enabled. I do this now by looking if there's a symlink in /etc/libvirt/qemu/autostart, but it feels a bit hackish.
Is this something that could be added to virsh? Something like virsh get-autostart domain would be great.
For now there are two options how to check the autostart flag:
1) virsh dominfo - This is suitable to check for the state of a single guest. Unfortunately we have just this one output option where it is embedded with other information about the guest:
$ virsh dominfo tr Id: 1 Name: tr UUID: 17f42b42-9fdd-81e3-4a93-a75021a707d3 OS Type: hvm State: running CPU(s): 1 CPU time: 200.5s Max memory: 53248 KiB Used memory: 53248 KiB Persistent: yes Autostart: enable <- here! Managed save: no Security model: none Security DOI: 0
2) use virsh list --all --autostart to list guests that have the autostart flag enabled (also note that there are script-friendly outputs for virsh list --name and --uuid):
$ virsh list --all --autostart Id Name State ---------------------------------------------------- 1 tr running - Bare shut off
We're planing on adding the autostart flag as an XML element and a few other improvements of autostaring guests.
I don't think the XML should be in the business of having the autostart flag, as this is not guest configuration information. Having it in the XML introduces the problem of maintaining the correct synchronization between the autostart symlink and the XML description. Further, in the future I'd like to actually replace our current autostart code, with code that just sets up systemd units to deal with autostart. In such a scenario, the user will be able to toggle autostart directly using systemd, so we don't want libvirt duplicating that info in the XML since it won't be aware of when systemd changes the autostart flag. Daniel -- |: http://berrange.com -o- http://www.flickr.com/photos/dberrange/ :| |: http://libvirt.org -o- http://virt-manager.org :| |: http://autobuild.org -o- http://search.cpan.org/~danberr/ :| |: http://entangle-photo.org -o- http://live.gnome.org/gtk-vnc :|

On 11/08/12 15:13, Daniel P. Berrange wrote:
On Wed, Nov 07, 2012 at 11:32:22AM +0100, Peter Krempa wrote:
On 11/07/12 11:04, Ruben Kerkhof wrote:
Hi list,
I'd like to check if a domain has autostart enabled. I do this now by looking if there's a symlink in /etc/libvirt/qemu/autostart, but it feels a bit hackish.
Is this something that could be added to virsh? Something like virsh get-autostart domain would be great.
For now there are two options how to check the autostart flag:
1) virsh dominfo - This is suitable to check for the state of a single guest. Unfortunately we have just this one output option where it is embedded with other information about the guest:
$ virsh dominfo tr Id: 1 Name: tr UUID: 17f42b42-9fdd-81e3-4a93-a75021a707d3 OS Type: hvm State: running CPU(s): 1 CPU time: 200.5s Max memory: 53248 KiB Used memory: 53248 KiB Persistent: yes Autostart: enable <- here! Managed save: no Security model: none Security DOI: 0
2) use virsh list --all --autostart to list guests that have the autostart flag enabled (also note that there are script-friendly outputs for virsh list --name and --uuid):
$ virsh list --all --autostart Id Name State ---------------------------------------------------- 1 tr running - Bare shut off
We're planing on adding the autostart flag as an XML element and a few other improvements of autostaring guests.
I don't think the XML should be in the business of having the autostart flag, as this is not guest configuration information. Having it in the XML introduces the problem of maintaining the correct synchronization between the autostart symlink and the XML description.
Yes, that will be troublesome. It's unfortunate we still have to use the symlink approach.
Further, in the future I'd like to actually replace our current autostart code, with code that just sets up systemd units to deal with autostart.
In such a scenario, the user will be able to toggle autostart directly using systemd, so we don't want libvirt duplicating that info in the XML since it won't be aware of when systemd changes the autostart flag.
Note that there are still distros that are doing everything possible to avoid having systemd. It wouldn't be nice if we broke autostarting there.
Daniel

On Thu, Nov 08, 2012 at 03:41:12PM +0100, Peter Krempa wrote:
On 11/08/12 15:13, Daniel P. Berrange wrote:
On Wed, Nov 07, 2012 at 11:32:22AM +0100, Peter Krempa wrote:
On 11/07/12 11:04, Ruben Kerkhof wrote:
Hi list,
I'd like to check if a domain has autostart enabled. I do this now by looking if there's a symlink in /etc/libvirt/qemu/autostart, but it feels a bit hackish.
Is this something that could be added to virsh? Something like virsh get-autostart domain would be great.
For now there are two options how to check the autostart flag:
1) virsh dominfo - This is suitable to check for the state of a single guest. Unfortunately we have just this one output option where it is embedded with other information about the guest:
$ virsh dominfo tr Id: 1 Name: tr UUID: 17f42b42-9fdd-81e3-4a93-a75021a707d3 OS Type: hvm State: running CPU(s): 1 CPU time: 200.5s Max memory: 53248 KiB Used memory: 53248 KiB Persistent: yes Autostart: enable <- here! Managed save: no Security model: none Security DOI: 0
2) use virsh list --all --autostart to list guests that have the autostart flag enabled (also note that there are script-friendly outputs for virsh list --name and --uuid):
$ virsh list --all --autostart Id Name State ---------------------------------------------------- 1 tr running - Bare shut off
We're planing on adding the autostart flag as an XML element and a few other improvements of autostaring guests.
I don't think the XML should be in the business of having the autostart flag, as this is not guest configuration information. Having it in the XML introduces the problem of maintaining the correct synchronization between the autostart symlink and the XML description.
Yes, that will be troublesome. It's unfortunate we still have to use the symlink approach.
Further, in the future I'd like to actually replace our current autostart code, with code that just sets up systemd units to deal with autostart.
In such a scenario, the user will be able to toggle autostart directly using systemd, so we don't want libvirt duplicating that info in the XML since it won't be aware of when systemd changes the autostart flag.
Note that there are still distros that are doing everything possible to avoid having systemd. It wouldn't be nice if we broke autostarting there.
Of course, not least RHEL-5 and RHEL-6. If we did support systemd, we would have a compile time option to use systemd vs our current autostart code. Daniel -- |: http://berrange.com -o- http://www.flickr.com/photos/dberrange/ :| |: http://libvirt.org -o- http://virt-manager.org :| |: http://autobuild.org -o- http://search.cpan.org/~danberr/ :| |: http://entangle-photo.org -o- http://live.gnome.org/gtk-vnc :|

On Thu, Nov 08, 2012 at 03:41:12PM +0100, Peter Krempa wrote:
On 11/08/12 15:13, Daniel P. Berrange wrote:
On Wed, Nov 07, 2012 at 11:32:22AM +0100, Peter Krempa wrote:
On 11/07/12 11:04, Ruben Kerkhof wrote:
Hi list,
I'd like to check if a domain has autostart enabled. I do this now by looking if there's a symlink in /etc/libvirt/qemu/autostart, but it feels a bit hackish.
Is this something that could be added to virsh? Something like virsh get-autostart domain would be great.
For now there are two options how to check the autostart flag:
1) virsh dominfo - This is suitable to check for the state of a single guest. Unfortunately we have just this one output option where it is embedded with other information about the guest:
$ virsh dominfo tr Id: 1 Name: tr UUID: 17f42b42-9fdd-81e3-4a93-a75021a707d3 OS Type: hvm State: running CPU(s): 1 CPU time: 200.5s Max memory: 53248 KiB Used memory: 53248 KiB Persistent: yes Autostart: enable <- here! Managed save: no Security model: none Security DOI: 0
2) use virsh list --all --autostart to list guests that have the autostart flag enabled (also note that there are script-friendly outputs for virsh list --name and --uuid):
$ virsh list --all --autostart Id Name State ---------------------------------------------------- 1 tr running - Bare shut off
We're planing on adding the autostart flag as an XML element and a few other improvements of autostaring guests.
I don't think the XML should be in the business of having the autostart flag, as this is not guest configuration information. Having it in the XML introduces the problem of maintaining the correct synchronization between the autostart symlink and the XML description.
Yes, that will be troublesome. It's unfortunate we still have to use the symlink approach.
Further, in the future I'd like to actually replace our current autostart code, with code that just sets up systemd units to deal with autostart.
In such a scenario, the user will be able to toggle autostart directly using systemd, so we don't want libvirt duplicating that info in the XML since it won't be aware of when systemd changes the autostart flag.
Note that there are still distros that are doing everything possible to avoid having systemd. It wouldn't be nice if we broke autostarting there.
Of course, not least RHEL-5 and RHEL-6. If we did support systemd, we would have a compile time option to use systemd vs our current autostart code. Can we make this runtime then? Some distroy like Debian have systemd
On Thu, Nov 08, 2012 at 03:42:49PM +0100, Daniel P. Berrange wrote: optional so toggling this based on systemd actually being used would be most helpful. Cheers, -- Guido

On Fri, Nov 09, 2012 at 01:19:01AM +0100, Guido Günther wrote:
On Thu, Nov 08, 2012 at 03:41:12PM +0100, Peter Krempa wrote:
On 11/08/12 15:13, Daniel P. Berrange wrote:
On Wed, Nov 07, 2012 at 11:32:22AM +0100, Peter Krempa wrote:
On 11/07/12 11:04, Ruben Kerkhof wrote:
Hi list,
I'd like to check if a domain has autostart enabled. I do this now by looking if there's a symlink in /etc/libvirt/qemu/autostart, but it feels a bit hackish.
Is this something that could be added to virsh? Something like virsh get-autostart domain would be great.
For now there are two options how to check the autostart flag:
1) virsh dominfo - This is suitable to check for the state of a single guest. Unfortunately we have just this one output option where it is embedded with other information about the guest:
$ virsh dominfo tr Id: 1 Name: tr UUID: 17f42b42-9fdd-81e3-4a93-a75021a707d3 OS Type: hvm State: running CPU(s): 1 CPU time: 200.5s Max memory: 53248 KiB Used memory: 53248 KiB Persistent: yes Autostart: enable <- here! Managed save: no Security model: none Security DOI: 0
2) use virsh list --all --autostart to list guests that have the autostart flag enabled (also note that there are script-friendly outputs for virsh list --name and --uuid):
$ virsh list --all --autostart Id Name State ---------------------------------------------------- 1 tr running - Bare shut off
We're planing on adding the autostart flag as an XML element and a few other improvements of autostaring guests.
I don't think the XML should be in the business of having the autostart flag, as this is not guest configuration information. Having it in the XML introduces the problem of maintaining the correct synchronization between the autostart symlink and the XML description.
Yes, that will be troublesome. It's unfortunate we still have to use the symlink approach.
Further, in the future I'd like to actually replace our current autostart code, with code that just sets up systemd units to deal with autostart.
In such a scenario, the user will be able to toggle autostart directly using systemd, so we don't want libvirt duplicating that info in the XML since it won't be aware of when systemd changes the autostart flag.
Note that there are still distros that are doing everything possible to avoid having systemd. It wouldn't be nice if we broke autostarting there.
Of course, not least RHEL-5 and RHEL-6. If we did support systemd, we would have a compile time option to use systemd vs our current autostart code. Can we make this runtime then? Some distroy like Debian have systemd
On Thu, Nov 08, 2012 at 03:42:49PM +0100, Daniel P. Berrange wrote: optional so toggling this based on systemd actually being used would be most helpful.
Sure, that's possible too. FYI, i have no plans to work on actually implmenting this feature in the near future - just wanted to let people know about the idea. Daniel -- |: http://berrange.com -o- http://www.flickr.com/photos/dberrange/ :| |: http://libvirt.org -o- http://virt-manager.org :| |: http://autobuild.org -o- http://search.cpan.org/~danberr/ :| |: http://entangle-photo.org -o- http://live.gnome.org/gtk-vnc :|
participants (5)
-
Daniel P. Berrange
-
Guido Günther
-
Osier Yang
-
Peter Krempa
-
Ruben Kerkhof