mirror of
https://github.com/libguestfs/libguestfs.git
synced 2026-03-21 22:53:37 +00:00
daemon: lvm: Do reverse device name translation on pvs_full device fields
Intermittent test failures in virt-filesystems showed that when using
the pvs_full API, the pv_name field in the returned list of structures
was not being reverse translated. As a result internal partition
names could appear in the output of virt-filesystems.
See: https://listman.redhat.com/archives/libguestfs/2023-July/032058.html
(cherry picked from commit 32cb5b45cf)
This commit is contained in:
29
daemon/lvm.c
29
daemon/lvm.c
@@ -146,7 +146,34 @@ do_vgs (void)
|
||||
guestfs_int_lvm_pv_list *
|
||||
do_pvs_full (void)
|
||||
{
|
||||
return parse_command_line_pvs ();
|
||||
guestfs_int_lvm_pv_list *r;
|
||||
size_t i;
|
||||
char *din, *dout;
|
||||
|
||||
r = parse_command_line_pvs ();
|
||||
if (r == NULL)
|
||||
/* parse_command_line_pvs has already called reply_with_error */
|
||||
return NULL;
|
||||
|
||||
/* The pv_name fields contain device names which must be reverse
|
||||
* translated. The problem here is that the generator does not have
|
||||
* a "FMountable" field type in types.mli.
|
||||
*/
|
||||
for (i = 0; i < r->guestfs_int_lvm_pv_list_len; ++i) {
|
||||
din = r->guestfs_int_lvm_pv_list_val[i].pv_name;
|
||||
if (din) {
|
||||
dout = reverse_device_name_translation (din);
|
||||
if (!dout) {
|
||||
/* reverse_device_name_translation has already called reply_with_error*/
|
||||
/* XXX memory leak here */
|
||||
return NULL;
|
||||
}
|
||||
r->guestfs_int_lvm_pv_list_val[i].pv_name = dout;
|
||||
free (din);
|
||||
}
|
||||
}
|
||||
|
||||
return r;
|
||||
}
|
||||
|
||||
guestfs_int_lvm_vg_list *
|
||||
|
||||
Reference in New Issue
Block a user