@@ -1845,11 +1845,14 @@ static void ram_block_add(RAMBlock *new_block, Error **errp)
}
if (new_block->flags & RAM_GUEST_MEMFD) {
+ int ret;
+
assert(kvm_enabled());
assert(new_block->guest_memfd < 0);
- if (ram_block_discard_require(true) < 0) {
- error_setg_errno(errp, errno,
+ ret = ram_block_discard_require(true);
+ if (ret < 0) {
+ error_setg_errno(errp, -ret,
"cannot set up private guest memory: discard currently blocked");
error_append_hint(errp, "Are you using assigned devices?\n");
goto out_free;