summaryrefslogtreecommitdiff
path: root/kvm-all.c
diff options
context:
space:
mode:
authorEric Auger <eric.auger@redhat.com>2017-06-13 14:57:00 +0100
committerPeter Maydell <peter.maydell@linaro.org>2017-06-13 14:57:00 +0100
commit556969e938a97e98eec9df039944741ed74ce049 (patch)
tree5bfd2e4bed79664d6ef46861ab7197f40d3eb35e /kvm-all.c
parent1403f36447216775e701fdae8bc8f00d359ecf0a (diff)
downloadqemu-556969e938a97e98eec9df039944741ed74ce049.zip
kvm-all: Pass an error object to kvm_device_access
In some circumstances, we don't want to abort if the kvm_device_access fails. This will be the case during ITS migration, in case the ITS table save/restore fails because the guest did not program the vITS correctly. So let's pass an error object to the function and return the ioctl value. New callers will be able to make a decision upon this returned value. Existing callers pass &error_abort which will cause the function to abort on failure. Signed-off-by: Eric Auger <eric.auger@redhat.com> Reviewed-by: Juan Quintela <quintela@redhat.com> Reviewed-by: Peter Xu <peterx@redhat.com> Message-id: 1497023553-18411-2-git-send-email-eric.auger@redhat.com [PMM: wrapped long line] Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Diffstat (limited to 'kvm-all.c')
-rw-r--r--kvm-all.c14
1 files changed, 8 insertions, 6 deletions
diff --git a/kvm-all.c b/kvm-all.c
index 44b3cf43cc..ab8262f672 100644
--- a/kvm-all.c
+++ b/kvm-all.c
@@ -23,6 +23,7 @@
#include "qemu/option.h"
#include "qemu/config-file.h"
#include "qemu/error-report.h"
+#include "qapi/error.h"
#include "hw/hw.h"
#include "hw/pci/msi.h"
#include "hw/pci/msix.h"
@@ -2216,8 +2217,8 @@ int kvm_device_check_attr(int dev_fd, uint32_t group, uint64_t attr)
return kvm_device_ioctl(dev_fd, KVM_HAS_DEVICE_ATTR, &attribute) ? 0 : 1;
}
-void kvm_device_access(int fd, int group, uint64_t attr,
- void *val, bool write)
+int kvm_device_access(int fd, int group, uint64_t attr,
+ void *val, bool write, Error **errp)
{
struct kvm_device_attr kvmattr;
int err;
@@ -2231,11 +2232,12 @@ void kvm_device_access(int fd, int group, uint64_t attr,
write ? KVM_SET_DEVICE_ATTR : KVM_GET_DEVICE_ATTR,
&kvmattr);
if (err < 0) {
- error_report("KVM_%s_DEVICE_ATTR failed: %s",
- write ? "SET" : "GET", strerror(-err));
- error_printf("Group %d attr 0x%016" PRIx64 "\n", group, attr);
- abort();
+ error_setg_errno(errp, -err,
+ "KVM_%s_DEVICE_ATTR failed: Group %d "
+ "attr 0x%016" PRIx64,
+ write ? "SET" : "GET", group, attr);
}
+ return err;
}
/* Return 1 on success, 0 on failure */