diff --git a/src/conf/domain_audit.c b/src/conf/domain_audit.c index 1e667af73c4f165d993e18f59f2ee51644adae35..4afc22019904051c056a2c5ee442e1c14d09f44f 100644 --- a/src/conf/domain_audit.c +++ b/src/conf/domain_audit.c @@ -68,38 +68,6 @@ virDomainAuditGetRdev(const char *path ATTRIBUTE_UNUSED) #endif -static const char * -virDomainAuditChardevPath(virDomainChrSourceDefPtr chr) -{ - if (!chr) - return NULL; - - switch ((virDomainChrType) chr->type) { - case VIR_DOMAIN_CHR_TYPE_PTY: - case VIR_DOMAIN_CHR_TYPE_DEV: - case VIR_DOMAIN_CHR_TYPE_FILE: - case VIR_DOMAIN_CHR_TYPE_PIPE: - case VIR_DOMAIN_CHR_TYPE_NMDM: - return chr->data.file.path; - - case VIR_DOMAIN_CHR_TYPE_UNIX: - return chr->data.nix.path; - - case VIR_DOMAIN_CHR_TYPE_TCP: - case VIR_DOMAIN_CHR_TYPE_UDP: - case VIR_DOMAIN_CHR_TYPE_NULL: - case VIR_DOMAIN_CHR_TYPE_VC: - case VIR_DOMAIN_CHR_TYPE_STDIO: - case VIR_DOMAIN_CHR_TYPE_SPICEVMC: - case VIR_DOMAIN_CHR_TYPE_SPICEPORT: - case VIR_DOMAIN_CHR_TYPE_LAST: - return NULL; - } - - return NULL; -} - - static void virDomainAuditGenericDev(virDomainObjPtr vm, const char *type, @@ -178,8 +146,8 @@ virDomainAuditChardev(virDomainObjPtr vm, newsrc = newDef->source; virDomainAuditGenericDev(vm, "chardev", - virDomainAuditChardevPath(oldsrc), - virDomainAuditChardevPath(newsrc), + virDomainChrSourceDefGetPath(oldsrc), + virDomainChrSourceDefGetPath(newsrc), reason, success); } @@ -218,7 +186,7 @@ virDomainAuditSmartcard(virDomainObjPtr vm, case VIR_DOMAIN_SMARTCARD_TYPE_PASSTHROUGH: virDomainAuditGenericDev(vm, "smartcard", NULL, - virDomainAuditChardevPath(def->data.passthru), + virDomainChrSourceDefGetPath(def->data.passthru), reason, success); break; @@ -264,7 +232,7 @@ virDomainAuditRNG(virDomainObjPtr vm, break; case VIR_DOMAIN_RNG_BACKEND_EGD: - newsrcpath = virDomainAuditChardevPath(newDef->source.chardev); + newsrcpath = virDomainChrSourceDefGetPath(newDef->source.chardev); break; case VIR_DOMAIN_RNG_BACKEND_LAST: @@ -279,7 +247,7 @@ virDomainAuditRNG(virDomainObjPtr vm, break; case VIR_DOMAIN_RNG_BACKEND_EGD: - oldsrcpath = virDomainAuditChardevPath(oldDef->source.chardev); + oldsrcpath = virDomainChrSourceDefGetPath(oldDef->source.chardev); break; case VIR_DOMAIN_RNG_BACKEND_LAST: @@ -982,7 +950,7 @@ virDomainAuditShmem(virDomainObjPtr vm, { char uuidstr[VIR_UUID_STRING_BUFLEN]; char *vmname = virAuditEncode("vm", vm->def->name); - const char *srcpath = virDomainAuditChardevPath(&def->server.chr); + const char *srcpath = virDomainChrSourceDefGetPath(&def->server.chr); const char *virt = virDomainVirtTypeToString(vm->def->virtType); char *shmpath = NULL; diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 59771e48ba1e7426dccb267a6e580d4ecb9cf024..570cc5c9310ce086c9743bf7d509da50d7b93689 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -2039,6 +2039,39 @@ virDomainNetDefFree(virDomainNetDefPtr def) VIR_FREE(def); } + +const char * +virDomainChrSourceDefGetPath(virDomainChrSourceDefPtr chr) +{ + if (!chr) + return NULL; + + switch ((virDomainChrType) chr->type) { + case VIR_DOMAIN_CHR_TYPE_PTY: + case VIR_DOMAIN_CHR_TYPE_DEV: + case VIR_DOMAIN_CHR_TYPE_FILE: + case VIR_DOMAIN_CHR_TYPE_PIPE: + case VIR_DOMAIN_CHR_TYPE_NMDM: + return chr->data.file.path; + + case VIR_DOMAIN_CHR_TYPE_UNIX: + return chr->data.nix.path; + + case VIR_DOMAIN_CHR_TYPE_TCP: + case VIR_DOMAIN_CHR_TYPE_UDP: + case VIR_DOMAIN_CHR_TYPE_NULL: + case VIR_DOMAIN_CHR_TYPE_VC: + case VIR_DOMAIN_CHR_TYPE_STDIO: + case VIR_DOMAIN_CHR_TYPE_SPICEVMC: + case VIR_DOMAIN_CHR_TYPE_SPICEPORT: + case VIR_DOMAIN_CHR_TYPE_LAST: + return NULL; + } + + return NULL; +} + + void ATTRIBUTE_NONNULL(1) virDomainChrSourceDefClear(virDomainChrSourceDefPtr def) { diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h index a9b079cf290caf9e0ca4068be4f173bc91a72d39..1baf854532e2c3326777afcb51551b2698f07060 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -3284,6 +3284,8 @@ int virDomainDefFindDevice(virDomainDefPtr def, virDomainDeviceDefPtr dev, bool reportError); +const char *virDomainChrSourceDefGetPath(virDomainChrSourceDefPtr chr); + void virDomainChrSourceDefClear(virDomainChrSourceDefPtr def); char *virDomainObjGetMetadata(virDomainObjPtr vm, diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index 6331f1a73473a5fbdb995ebadf9f9eaf5e092a2f..3f94521df0ca70d8a4caec75833e65cb0b9bfc71 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -208,6 +208,7 @@ virDomainChrSerialTargetTypeToString; virDomainChrSourceDefClear; virDomainChrSourceDefCopy; virDomainChrSourceDefFree; +virDomainChrSourceDefGetPath; virDomainChrSpicevmcTypeFromString; virDomainChrSpicevmcTypeToString; virDomainChrTcpProtocolTypeFromString;