Renamed from virSecurityLabelDefFree. Signed-off-by: Cole Robinson <crobinso@xxxxxxxxxx> --- cfg.mk | 1 + src/conf/domain_conf.c | 17 +++++++++-------- src/conf/domain_conf.h | 1 + src/libvirt_private.syms | 2 +- src/qemu/qemu_driver.c | 4 +--- src/security/security_apparmor.c | 11 ++--------- src/security/security_selinux.c | 9 ++------- 7 files changed, 17 insertions(+), 28 deletions(-) diff --git a/cfg.mk b/cfg.mk index 03186b3..2c6f595 100644 --- a/cfg.mk +++ b/cfg.mk @@ -98,6 +98,7 @@ useless_free_options = \ --name=virDomainInputDefFree \ --name=virDomainNetDefFree \ --name=virDomainObjFree \ + --name=virDomainSeclabelDefClear \ --name=virDomainSnapshotDefFree \ --name=virDomainSnapshotObjFree \ --name=virDomainSoundDefFree \ diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index b4df38c..8f6ef55 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -754,13 +754,14 @@ void virDomainDeviceDefFree(virDomainDeviceDefPtr def) VIR_FREE(def); } -void virSecurityLabelDefFree(virDomainDefPtr def); - -void virSecurityLabelDefFree(virDomainDefPtr def) +void virDomainSeclabelDefClear(virSecurityLabelDefPtr seclabel) { - VIR_FREE(def->seclabel.model); - VIR_FREE(def->seclabel.label); - VIR_FREE(def->seclabel.imagelabel); + if (!seclabel) + return; + + VIR_FREE(seclabel->model); + VIR_FREE(seclabel->label); + VIR_FREE(seclabel->imagelabel); } static void @@ -855,7 +856,7 @@ void virDomainDefFree(virDomainDefPtr def) virDomainMemballoonDefFree(def->memballoon); - virSecurityLabelDefFree(def); + virDomainSeclabelDefClear(&def->seclabel); virCPUDefFree(def->cpu); @@ -4272,7 +4273,7 @@ virSecurityLabelDefParseXML(const virDomainDefPtr def, return 0; error: - virSecurityLabelDefFree(def); + virDomainSeclabelDefClear(&def->seclabel); return -1; } diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h index a459a22..b5cf433 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -1082,6 +1082,7 @@ void virDomainWatchdogDefFree(virDomainWatchdogDefPtr def); void virDomainVideoDefFree(virDomainVideoDefPtr def); void virDomainHostdevDefFree(virDomainHostdevDefPtr def); void virDomainDeviceDefFree(virDomainDeviceDefPtr def); +void virDomainSeclabelDefClear(virSecurityLabelDefPtr seclabel); int virDomainDeviceAddressIsValid(virDomainDeviceInfoPtr info, int type); int virDomainDevicePCIAddressIsValid(virDomainDevicePCIAddressPtr addr); diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index e9b8cb7..191ae6a 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -279,6 +279,7 @@ virDomainRemoveInactive; virDomainSaveConfig; virDomainSaveStatus; virDomainSaveXML; +virDomainSeclabelDefClear; virDomainSnapshotAssignDef; virDomainSnapshotDefFormat; virDomainSnapshotDefFree; @@ -313,7 +314,6 @@ virDomainWatchdogActionTypeToString; virDomainWatchdogModelTypeFromString; virDomainWatchdogModelTypeToString; - # domain_event.h virDomainEventCallbackListAdd; virDomainEventCallbackListAddID; diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index 9eb9cd5..3745cce 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -3043,9 +3043,7 @@ static void qemudShutdownVMDaemon(struct qemud_driver *driver, /* Clear out dynamically assigned labels */ if (vm->def->seclabel.type == VIR_DOMAIN_SECLABEL_DYNAMIC) { - VIR_FREE(vm->def->seclabel.model); - VIR_FREE(vm->def->seclabel.label); - VIR_FREE(vm->def->seclabel.imagelabel); + virDomainSeclabelDefClear(&vm->def->seclabel); } virDomainDefClearDeviceAliases(vm->def); diff --git a/src/security/security_apparmor.c b/src/security/security_apparmor.c index d82ba73..42f812c 100644 --- a/src/security/security_apparmor.c +++ b/src/security/security_apparmor.c @@ -475,9 +475,7 @@ AppArmorGenSecurityLabel(virSecurityManagerPtr mgr ATTRIBUTE_UNUSED, goto clean; err: - VIR_FREE(vm->def->seclabel.label); - VIR_FREE(vm->def->seclabel.imagelabel); - VIR_FREE(vm->def->seclabel.model); + virDomainSeclabelDefClear(&vm->def->seclabel); clean: VIR_FREE(profile_name); @@ -547,12 +545,7 @@ static int AppArmorReleaseSecurityLabel(virSecurityManagerPtr mgr ATTRIBUTE_UNUSED, virDomainObjPtr vm) { - const virSecurityLabelDefPtr secdef = &vm->def->seclabel; - - VIR_FREE(secdef->model); - VIR_FREE(secdef->label); - VIR_FREE(secdef->imagelabel); - + virDomainSeclabelDefClear(&vm->def->seclabel); return 0; } diff --git a/src/security/security_selinux.c b/src/security/security_selinux.c index d06afde..f11e209 100644 --- a/src/security/security_selinux.c +++ b/src/security/security_selinux.c @@ -216,9 +216,7 @@ SELinuxGenSecurityLabel(virSecurityManagerPtr mgr ATTRIBUTE_UNUSED, rc = 0; goto done; err: - VIR_FREE(vm->def->seclabel.label); - VIR_FREE(vm->def->seclabel.imagelabel); - VIR_FREE(vm->def->seclabel.model); + virDomainSeclabelDefClear(&vm->def->seclabel); done: VIR_FREE(scontext); return rc; @@ -830,10 +828,7 @@ SELinuxReleaseSecurityLabel(virSecurityManagerPtr mgr ATTRIBUTE_UNUSED, context_free(con); } - VIR_FREE(secdef->model); - VIR_FREE(secdef->label); - VIR_FREE(secdef->imagelabel); - + virDomainSeclabelDefClear(secdef); return 0; } -- 1.7.3.2 -- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list