From 43a85277629e599f5eb7adcf12006b5222cb8452 Mon Sep 17 00:00:00 2001 From: Peter Krempa Date: Tue, 2 Apr 2019 12:31:31 +0200 Subject: [PATCH] qemu: Move SEV capability handling into virQEMUCapsProbeQMPSEVCapabilities Move the code out of virQEMUCapsInitQMPMonitor similarly to other functions. Signed-off-by: Peter Krempa Reviewed-by: Erik Skultety --- src/qemu/qemu_capabilities.c | 29 ++++++++++++++--------------- 1 file changed, 14 insertions(+), 15 deletions(-) diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c index 6ee6a8c648..d49e02cc6c 100644 --- a/src/qemu/qemu_capabilities.c +++ b/src/qemu/qemu_capabilities.c @@ -2752,7 +2752,6 @@ virQEMUCapsProbeQMPGICCapabilities(virQEMUCapsPtr qemuCaps, } -/* Returns -1 on error, 0 if SEV is not supported, 1 if SEV is supported */ static int virQEMUCapsProbeQMPSEVCapabilities(virQEMUCapsPtr qemuCaps, qemuMonitorPtr mon) @@ -2760,12 +2759,21 @@ virQEMUCapsProbeQMPSEVCapabilities(virQEMUCapsPtr qemuCaps, int rc = -1; virSEVCapability *caps = NULL; - if ((rc = qemuMonitorGetSEVCapabilities(mon, &caps)) <= 0) - return rc; + if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_SEV_GUEST)) + return 0; + + if ((rc = qemuMonitorGetSEVCapabilities(mon, &caps)) < 0) + return -1; + + /* SEV isn't actually supported */ + if (rc == 0) { + virQEMUCapsClear(qemuCaps, QEMU_CAPS_SEV_GUEST); + return 0; + } virSEVCapabilitiesFree(qemuCaps->sevCapabilities); qemuCaps->sevCapabilities = caps; - return rc; + return 0; } @@ -4375,17 +4383,8 @@ virQEMUCapsInitQMPMonitor(virQEMUCapsPtr qemuCaps, goto cleanup; if (virQEMUCapsProbeQMPGICCapabilities(qemuCaps, mon) < 0) goto cleanup; - - /* Probe for SEV capabilities */ - if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_SEV_GUEST)) { - int rc = virQEMUCapsProbeQMPSEVCapabilities(qemuCaps, mon); - - if (rc < 0) - goto cleanup; - - if (rc == 0) - virQEMUCapsClear(qemuCaps, QEMU_CAPS_SEV_GUEST); - } + if (virQEMUCapsProbeQMPSEVCapabilities(qemuCaps, mon) < 0) + goto cleanup; virQEMUCapsInitProcessCaps(qemuCaps);