1
0
mirror of https://gitlab.com/libvirt/libvirt.git synced 2025-03-20 07:59:00 +00:00

qemu: domain: Use g_file_read_link instead of virFileReadLink

In an effort to remove as much gnulib usage as possible let's
reimplement virFileReadLink. Since it's used in two places only I opted
to open-code it.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
This commit is contained in:
Peter Krempa 2019-11-13 12:45:54 +01:00
parent f6cccece48
commit 794c9ec535

View File

@ -13167,12 +13167,13 @@ qemuDomainCreateDeviceRecursive(const char *device,
}
if (isLink) {
g_autoptr(GError) gerr = NULL;
/* We are dealing with a symlink. Create a dangling symlink and descend
* down one level which hopefully creates the symlink's target. */
if (virFileReadLink(device, &target) < 0) {
virReportSystemError(errno,
_("unable to resolve symlink %s"),
device);
if (!(target = g_file_read_link(device, &gerr))) {
virReportError(VIR_ERR_SYSTEM_ERROR,
_("failed to resolve symlink %s: %s"), device, gerr->message);
goto cleanup;
}
@ -14161,10 +14162,11 @@ qemuDomainAttachDeviceMknodRecursive(virQEMUDriverPtr driver,
data.target = target;
} else if (isLink) {
if (virFileReadLink(file, &target) < 0) {
virReportSystemError(errno,
_("unable to resolve symlink %s"),
file);
g_autoptr(GError) gerr = NULL;
if (!(target = g_file_read_link(file, &gerr))) {
virReportError(VIR_ERR_SYSTEM_ERROR,
_("failed to resolve symlink %s: %s"), file, gerr->message);
return ret;
}