]> xenbits.xensource.com Git - libvirt.git/commitdiff
virt-host-validate-common: Use automatic memory freeing for virBitmap
authorPeter Krempa <pkrempa@redhat.com>
Tue, 7 Dec 2021 15:34:00 +0000 (16:34 +0100)
committerPeter Krempa <pkrempa@redhat.com>
Fri, 10 Dec 2021 15:37:42 +0000 (16:37 +0100)
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
tools/virt-host-validate-common.c

index aba1bdf6cf4408662c7ddbb6b696f1f2992e9d5f..647ed7b48bddebab0cf4497b5de9edb07f3d4420 100644 (file)
@@ -330,7 +330,7 @@ int virHostValidateCGroupControllers(const char *hvname G_GNUC_UNUSED,
 int virHostValidateIOMMU(const char *hvname,
                          virHostValidateLevel level)
 {
-    virBitmap *flags;
+    g_autoptr(virBitmap) flags = NULL;
     struct stat sb;
     const char *bootarg = NULL;
     bool isAMD = false, isIntel = false;
@@ -347,8 +347,6 @@ int virHostValidateIOMMU(const char *hvname,
     else if (flags && virBitmapIsBitSet(flags, VIR_HOST_VALIDATE_CPU_FLAG_SVM))
         isAMD = true;
 
-    virBitmapFree(flags);
-
     if (isIntel) {
         if (access("/sys/firmware/acpi/tables/DMAR", F_OK) == 0) {
             virHostMsgPass();
@@ -445,7 +443,7 @@ bool virHostKernelModuleIsLoaded(const char *module)
 int virHostValidateSecureGuests(const char *hvname,
                                 virHostValidateLevel level)
 {
-    virBitmap *flags;
+    g_autoptr(virBitmap) flags = NULL;
     bool hasFac158 = false;
     bool hasAMDSev = false;
     virArch arch = virArchFromHost();
@@ -460,8 +458,6 @@ int virHostValidateSecureGuests(const char *hvname,
     else if (flags && virBitmapIsBitSet(flags, VIR_HOST_VALIDATE_CPU_FLAG_SEV))
         hasAMDSev = true;
 
-    virBitmapFree(flags);
-
     virHostMsgCheck(hvname, "%s", _("for secure guest support"));
     if (ARCH_IS_S390(arch)) {
         if (hasFac158) {