From 794c9ec535fd86dfd87e77c97f7d77389e916173 Mon Sep 17 00:00:00 2001 From: Peter Krempa Date: Wed, 13 Nov 2019 12:45:54 +0100 Subject: [PATCH] qemu: domain: Use g_file_read_link instead of virFileReadLink MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 Reviewed-by: Ján Tomko --- src/qemu/qemu_domain.c | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index 54dde34f15..7123f45cd7 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -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; }