virStorageSource: Add fields for storing last I/O error message

Hypervisors may report a I/O error message (unstable; for human use)
to libvirt. In order to store it with the appropriate virStorageSource
so that it can be later queried we need to add fields to
virStorageSource to store the timestamp and message.

The message is deliberately not copied via virStorageSourceCopy.

The messages are also not serialized to the status XML as losing them on
a daemon restart as they're likely to be stale anyways.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
This commit is contained in:
Peter Krempa 2025-01-27 16:20:43 +01:00
parent 0525323175
commit 2f6c9fa4f6
2 changed files with 11 additions and 0 deletions

View File

@ -917,6 +917,8 @@ virStorageSourceCopy(const virStorageSource *src,
def->nfs_uid = src->nfs_uid; def->nfs_uid = src->nfs_uid;
def->nfs_gid = src->nfs_gid; def->nfs_gid = src->nfs_gid;
/* 'ioerror_timestamp' and 'ioerror_message' are deliberately not copied */
return g_steal_pointer(&def); return g_steal_pointer(&def);
} }
@ -1203,6 +1205,9 @@ virStorageSourceClear(virStorageSource *def)
g_clear_pointer(&def->fdtuple, g_object_unref); g_clear_pointer(&def->fdtuple, g_object_unref);
VIR_FREE(def->ioerror_timestamp);
VIR_FREE(def->ioerror_message);
/* clear everything except the class header as the object APIs /* clear everything except the class header as the object APIs
* will break otherwise */ * will break otherwise */
memset((char *) def + sizeof(def->parent), 0, memset((char *) def + sizeof(def->parent), 0,

View File

@ -445,6 +445,12 @@ struct _virStorageSource {
* to do this decision. * to do this decision.
*/ */
bool seclabelSkipRemember; bool seclabelSkipRemember;
/* Last instance of hypervisor originated I/O error message and timestamp.
* The error stored here is not designed to be stable. The message
* is also not copied via virStorageSourceCopy */
char *ioerror_timestamp;
char *ioerror_message;
}; };
G_DEFINE_AUTOPTR_CLEANUP_FUNC(virStorageSource, virObjectUnref); G_DEFINE_AUTOPTR_CLEANUP_FUNC(virStorageSource, virObjectUnref);