mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-09-09 09:14:57 +00:00
virsh: time_t is not a long on FreeBSD
localtime_r expects time_t.
This commit is contained in:
parent
cded0c80b0
commit
6df05081cb
@ -10442,7 +10442,8 @@ cmdSnapshotList(vshControl *ctl, const vshCmd *cmd)
|
|||||||
char *doc = NULL;
|
char *doc = NULL;
|
||||||
virDomainSnapshotPtr snapshot = NULL;
|
virDomainSnapshotPtr snapshot = NULL;
|
||||||
char *state = NULL;
|
char *state = NULL;
|
||||||
long creation;
|
long long creation_longlong;
|
||||||
|
time_t creation_time_t;
|
||||||
char timestr[100];
|
char timestr[100];
|
||||||
struct tm time_info;
|
struct tm time_info;
|
||||||
|
|
||||||
@ -10501,10 +10502,15 @@ cmdSnapshotList(vshControl *ctl, const vshCmd *cmd)
|
|||||||
state = virXPathString("string(/domainsnapshot/state)", ctxt);
|
state = virXPathString("string(/domainsnapshot/state)", ctxt);
|
||||||
if (state == NULL)
|
if (state == NULL)
|
||||||
continue;
|
continue;
|
||||||
if (virXPathLong("string(/domainsnapshot/creationTime)", ctxt,
|
if (virXPathLongLong("string(/domainsnapshot/creationTime)", ctxt,
|
||||||
&creation) < 0)
|
&creation_longlong) < 0)
|
||||||
continue;
|
continue;
|
||||||
localtime_r(&creation, &time_info);
|
creation_time_t = creation_longlong;
|
||||||
|
if (creation_time_t != creation_longlong) {
|
||||||
|
vshError(ctl, "%s", _("time_t overflow"));
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
localtime_r(&creation_time_t, &time_info);
|
||||||
strftime(timestr, sizeof(timestr), "%Y-%m-%d %H:%M:%S %z", &time_info);
|
strftime(timestr, sizeof(timestr), "%Y-%m-%d %H:%M:%S %z", &time_info);
|
||||||
|
|
||||||
vshPrint(ctl, " %-20s %-25s %s\n", names[i], timestr, state);
|
vshPrint(ctl, " %-20s %-25s %s\n", names[i], timestr, state);
|
||||||
|
Loading…
Reference in New Issue
Block a user