提交 37ef8763 编写于 作者: M Michal Privoznik

conf: Rename and expose virDomainChrSourceDefPath

It comes very handy to have source path for chardevs. We already
have such function: virDomainAuditChardevPath() but it's static
and has name not suitable for exposing. Moreover, while exposing
it change its name slightly to virDomainChrSourceDefGetPath.
Signed-off-by: NMichal Privoznik <mprivozn@redhat.com>
Reviewed-by: NJohn Ferlan <jferlan@redhat.com>
上级 a1ac4c88
...@@ -68,38 +68,6 @@ virDomainAuditGetRdev(const char *path ATTRIBUTE_UNUSED) ...@@ -68,38 +68,6 @@ virDomainAuditGetRdev(const char *path ATTRIBUTE_UNUSED)
#endif #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 static void
virDomainAuditGenericDev(virDomainObjPtr vm, virDomainAuditGenericDev(virDomainObjPtr vm,
const char *type, const char *type,
...@@ -178,8 +146,8 @@ virDomainAuditChardev(virDomainObjPtr vm, ...@@ -178,8 +146,8 @@ virDomainAuditChardev(virDomainObjPtr vm,
newsrc = newDef->source; newsrc = newDef->source;
virDomainAuditGenericDev(vm, "chardev", virDomainAuditGenericDev(vm, "chardev",
virDomainAuditChardevPath(oldsrc), virDomainChrSourceDefGetPath(oldsrc),
virDomainAuditChardevPath(newsrc), virDomainChrSourceDefGetPath(newsrc),
reason, success); reason, success);
} }
...@@ -218,7 +186,7 @@ virDomainAuditSmartcard(virDomainObjPtr vm, ...@@ -218,7 +186,7 @@ virDomainAuditSmartcard(virDomainObjPtr vm,
case VIR_DOMAIN_SMARTCARD_TYPE_PASSTHROUGH: case VIR_DOMAIN_SMARTCARD_TYPE_PASSTHROUGH:
virDomainAuditGenericDev(vm, "smartcard", NULL, virDomainAuditGenericDev(vm, "smartcard", NULL,
virDomainAuditChardevPath(def->data.passthru), virDomainChrSourceDefGetPath(def->data.passthru),
reason, success); reason, success);
break; break;
...@@ -264,7 +232,7 @@ virDomainAuditRNG(virDomainObjPtr vm, ...@@ -264,7 +232,7 @@ virDomainAuditRNG(virDomainObjPtr vm,
break; break;
case VIR_DOMAIN_RNG_BACKEND_EGD: case VIR_DOMAIN_RNG_BACKEND_EGD:
newsrcpath = virDomainAuditChardevPath(newDef->source.chardev); newsrcpath = virDomainChrSourceDefGetPath(newDef->source.chardev);
break; break;
case VIR_DOMAIN_RNG_BACKEND_LAST: case VIR_DOMAIN_RNG_BACKEND_LAST:
...@@ -279,7 +247,7 @@ virDomainAuditRNG(virDomainObjPtr vm, ...@@ -279,7 +247,7 @@ virDomainAuditRNG(virDomainObjPtr vm,
break; break;
case VIR_DOMAIN_RNG_BACKEND_EGD: case VIR_DOMAIN_RNG_BACKEND_EGD:
oldsrcpath = virDomainAuditChardevPath(oldDef->source.chardev); oldsrcpath = virDomainChrSourceDefGetPath(oldDef->source.chardev);
break; break;
case VIR_DOMAIN_RNG_BACKEND_LAST: case VIR_DOMAIN_RNG_BACKEND_LAST:
...@@ -982,7 +950,7 @@ virDomainAuditShmem(virDomainObjPtr vm, ...@@ -982,7 +950,7 @@ virDomainAuditShmem(virDomainObjPtr vm,
{ {
char uuidstr[VIR_UUID_STRING_BUFLEN]; char uuidstr[VIR_UUID_STRING_BUFLEN];
char *vmname = virAuditEncode("vm", vm->def->name); 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); const char *virt = virDomainVirtTypeToString(vm->def->virtType);
char *shmpath = NULL; char *shmpath = NULL;
......
...@@ -2039,6 +2039,39 @@ virDomainNetDefFree(virDomainNetDefPtr def) ...@@ -2039,6 +2039,39 @@ virDomainNetDefFree(virDomainNetDefPtr def)
VIR_FREE(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) void ATTRIBUTE_NONNULL(1)
virDomainChrSourceDefClear(virDomainChrSourceDefPtr def) virDomainChrSourceDefClear(virDomainChrSourceDefPtr def)
{ {
......
...@@ -3284,6 +3284,8 @@ int virDomainDefFindDevice(virDomainDefPtr def, ...@@ -3284,6 +3284,8 @@ int virDomainDefFindDevice(virDomainDefPtr def,
virDomainDeviceDefPtr dev, virDomainDeviceDefPtr dev,
bool reportError); bool reportError);
const char *virDomainChrSourceDefGetPath(virDomainChrSourceDefPtr chr);
void virDomainChrSourceDefClear(virDomainChrSourceDefPtr def); void virDomainChrSourceDefClear(virDomainChrSourceDefPtr def);
char *virDomainObjGetMetadata(virDomainObjPtr vm, char *virDomainObjGetMetadata(virDomainObjPtr vm,
......
...@@ -208,6 +208,7 @@ virDomainChrSerialTargetTypeToString; ...@@ -208,6 +208,7 @@ virDomainChrSerialTargetTypeToString;
virDomainChrSourceDefClear; virDomainChrSourceDefClear;
virDomainChrSourceDefCopy; virDomainChrSourceDefCopy;
virDomainChrSourceDefFree; virDomainChrSourceDefFree;
virDomainChrSourceDefGetPath;
virDomainChrSpicevmcTypeFromString; virDomainChrSpicevmcTypeFromString;
virDomainChrSpicevmcTypeToString; virDomainChrSpicevmcTypeToString;
virDomainChrTcpProtocolTypeFromString; virDomainChrTcpProtocolTypeFromString;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册