Bug 1070411 - RFE: domain: Add <creationTime> timestamp
Summary: RFE: domain: Add <creationTime> timestamp
Keywords:
Status: CLOSED WONTFIX
Alias: None
Product: Virtualization Tools
Classification: Community
Component: libvirt
Version: unspecified
Hardware: Unspecified
OS: Unspecified
unspecified
unspecified
Target Milestone: ---
Assignee: Libvirt Maintainers
QA Contact:
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2014-02-26 18:39 UTC by Tony
Modified: 2020-04-17 12:20 UTC (History)
3 users (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2020-04-17 12:20:49 UTC
Embargoed:


Attachments (Terms of Use)

Description Tony 2014-02-26 18:39:01 UTC
I hope this is the correct way of requesting a feature enhancement, apologies if not.

Re: question on mailing list
https://www.redhat.com/archives/libvirt-users/2014-February/msg00136.html

Would it be possible to extend libvirt to include a domain's creation date in the metadata.

Comment 1 Eric Blake 2014-02-26 18:58:26 UTC
I'd like some clarification on what is desired here.  In virsh terminology, 'virsh create' starts a transient guest, while 'virsh define' creates but does not start a persistent guest.  Are you looking at the time since a domain first had XML registered (whether transient or persistent, and for the persistent case, regardless of whether the guest is running or not), or at the time since a domain has been running (uptime, but only available while the guest is running, resets each time a persistent guest goes offline)?

Comment 2 Tony 2014-02-26 19:19:43 UTC
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>

Comment 3 Eric Blake 2014-02-26 19:37:01 UTC
As pointed out upstream, you can use <metadata> to track anything you want alongside a uuid, including a timestamp when you allocated the uuid, which should work for you now whether or not libvirt adds a <created> element down the road.

There's also the consideration of how to handle this for transient domains - if no timestamp is specified in the incoming XML, libvirt would supply the current domain, but in many cases (think VDSM as an application managing transient domains across a cluster of hosts) the actual domain definition has an older date of UUID allocation, known by management but not libvirt.  So that means it should also be possible to set the timestamp when creating a domain XML to something other than the current time, which means that timestamps can be modified by modifying XML, which means they might possibly be less reliable than you were hoping.

Comment 4 Tony 2014-02-26 19:47:25 UTC
Ok, no problem

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.

Comment 5 Eric Blake 2014-02-26 19:54:30 UTC
Personally, I _do_ think it is worth adding an element to the libvirt XML - we already have a <creationTime> element for domain snapshots.  I'm just trying to make sure that we are thinking about the implications, and that we are also aware of alternatives for working around older libvirt that don't support an element.

Comment 6 Daniel Berrangé 2020-04-17 12:20:49 UTC
Closing old RFE since it isn't a critical and there's a viable workaround via the <metadata> element for mgmt apps to record a creation time and other interesting info.


Note You need to log in before you can comment on or make changes to this bug.