[libvirt-users] VM Creation Timestamp

Hello, Is there any way to query libvirt, ideally through virsh CLI utility or similar, to get a timestamp of when a VM was created. Or to put it another way, a timestamp of when a domain's UUID was allocated. Many thanks, -- Tony Atkinson

On 02/26/2014 04:42 AM, Tony Atkinson wrote:
Hello, Is there any way to query libvirt, ideally through virsh CLI utility or similar, to get a timestamp of when a VM was created. Or to put it another way, a timestamp of when a domain's UUID was allocated.
Sorry, there is no such information currently tracked in <domain> xml. You could use the metadata element to track this information yourself: http://libvirt.org/formatdomain.html#elementsMetadata but if we decide to add it in libvirt proper, it would not appear any sooner than someone writes a patch (and certainly won't be in the upcoming 1.2.2 release, since we're past feature freeze) -- Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org

On 02/26/2014 08:21 AM, Eric Blake wrote:
On 02/26/2014 04:42 AM, Tony Atkinson wrote:
Hello, Is there any way to query libvirt, ideally through virsh CLI utility or similar, to get a timestamp of when a VM was created. Or to put it another way, a timestamp of when a domain's UUID was allocated.
Sorry, there is no such information currently tracked in <domain> xml. You could use the metadata element to track this information yourself: http://libvirt.org/formatdomain.html#elementsMetadata
but if we decide to add it in libvirt proper, it would not appear any sooner than someone writes a patch (and certainly won't be in the upcoming 1.2.2 release, since we're past feature freeze)
When you say "creation timestamp", do you mean the time at which the qemu process was spawned (as in 'virsh create' for transient guests or 'virsh start' for persistent guests - basically an uptime measurement) or the time at which XML was first recorded for the guest (as in 'virsh create' or 'virsh define' - more of an initial install timestamp, with no bearing on actual runtime of the guest)? I'm assuming that you'd want live migration to preserve the timestamp, but what happens with reverting to snapshots or saving/restoring from files (which are also situations that create a new qemu process, but where the guest has previous uptime already accumulated)? -- Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org

On 26/02/14 19:02, Eric Blake wrote:
When you say "creation timestamp", do you mean the time at which the qemu process was spawned (as in 'virsh create' for transient guests or 'virsh start' for persistent guests - basically an uptime measurement) or the time at which XML was first recorded for the guest (as in 'virsh create' or 'virsh define' - more of an initial install timestamp, with no bearing on actual runtime of the guest)? I'm assuming that you'd want live migration to preserve the timestamp, but what happens with reverting to snapshots or saving/restoring from files (which are also situations that create a new qemu process, but where the guest has previous uptime already accumulated)?
sorry, our conversation got split between here and the bug report I filed. https://bugzilla.redhat.com/show_bug.cgi?id=1070411 Just to clarify A timestamp of when the domain is first defined. (when the UUID for the domain is allocated) My /particular/ use case involves tracking guest resource usage over time. I need to maintain a consistant ordering of virtual machines. Domain ID is not persistant, and the UUID (while unique and persistant) is not useful for sorting. Ideally, I would want something like <domain type='kvm'> <name>banana</name> <uuid>b4f24019-ee69-6b4b-34a1-40f6e4126c57</uuid> <created>1393442012</created> ... </domain> For my particular need I've hacked the timestamp out of the apparmor definition file stat --format="%Y" /etc/apparmor.d/libvirt/libvirt-${VM_UUID} I just thought it was a useful piece of info that may be worth formally including in the domain definition. -- Tony Atkinson
participants (2)
-
Eric Blake
-
Tony Atkinson