#endif
+static const char *
+virDomainAuditGetVirtType(virDomainDefPtr def)
+{
+ const char *virt;
+
+ if (!(virt = virDomainVirtTypeToString(def->virtType))) {
+ VIR_WARN("Unexpected virt type %d while encoding audit message",
+ def->virtType);
+ virt = "?";
+ }
+
+ return virt;
+}
+
+
static void
virDomainAuditGenericDev(virDomainObjPtr vm,
const char *type,
char *vmname = NULL;
char *oldsrc = NULL;
char *newsrc = NULL;
- const char *virt;
+ const char *virt = virDomainAuditGetVirtType(vm->def);
/* if both new and old source aren't provided don't log anything */
if (!newsrcpath && !oldsrcpath)
if (!(vmname = virAuditEncode("vm", vm->def->name)))
goto no_memory;
- if (!(virt = virDomainVirtTypeToString(vm->def->virtType))) {
- VIR_WARN("Unexpected virt type %d while encoding audit message",
- vm->def->virtType);
- virt = "?";
- }
-
if (!(newsrc = virAuditEncode(newdev, VIR_AUDIT_STR(newsrcpath))))
goto no_memory;
char *vmname;
char *dev_name = NULL;
char *rdev;
- const char *virt;
+ const char *virt = virDomainAuditGetVirtType(vmDef);
virUUIDFormat(vmDef->uuid, uuidstr);
virMacAddrFormat(&netDef->mac, macstr);
goto cleanup;
}
- if (!(virt = virDomainVirtTypeToString(vmDef->virtType))) {
- VIR_WARN("Unexpected virt type %d while encoding audit message", vmDef->virtType);
- virt = "?";
- }
-
VIR_AUDIT(VIR_AUDIT_RECORD_RESOURCE, success,
"virt=%s resrc=net reason=open %s uuid=%s net=%s %s rdev=%s",
virt, vmname, uuidstr, macstr, dev_name, VIR_AUDIT_STR(rdev));
char *vmname;
char *address = NULL;
char *device = NULL;
- const char *virt;
+ const char *virt = virDomainAuditGetVirtType(vm->def);
+
virDomainHostdevSubsysUSBPtr usbsrc = &hostdev->source.subsys.u.usb;
virDomainHostdevSubsysPCIPtr pcisrc = &hostdev->source.subsys.u.pci;
virDomainHostdevSubsysSCSIPtr scsisrc = &hostdev->source.subsys.u.scsi;
return;
}
- if (!(virt = virDomainVirtTypeToString(vm->def->virtType))) {
- VIR_WARN("Unexpected virt type %d while encoding audit message", vm->def->virtType);
- virt = "?";
- }
-
switch ((virDomainHostdevMode) hostdev->mode) {
case VIR_DOMAIN_HOSTDEV_MODE_SUBSYS:
switch ((virDomainHostdevSubsysType) hostdev->source.subsys.type) {
char *vmname;
char *address = NULL;
char *device = NULL;
- const char *virt;
+ const char *virt = virDomainAuditGetVirtType(vm->def);
virUUIDFormat(vm->def->uuid, uuidstr);
if (!(vmname = virAuditEncode("vm", vm->def->name))) {
return;
}
- if (!(virt = virDomainVirtTypeToString(vm->def->virtType))) {
- VIR_WARN("Unexpected virt type %d while encoding audit message", vm->def->virtType);
- virt = "?";
- }
-
switch (redirdev->bus) {
case VIR_DOMAIN_REDIRDEV_BUS_USB:
if (VIR_STRDUP_QUIET(address, "USB redirdev") < 0) {
char *vmname;
char *path = NULL;
char *device = NULL;
- const char *virt;
+ const char *virt = virDomainAuditGetVirtType(vm->def);
virUUIDFormat(vm->def->uuid, uuidstr);
if (!(vmname = virAuditEncode("vm", vm->def->name))) {
return;
}
- if (!(virt = virDomainVirtTypeToString(vm->def->virtType))) {
- VIR_WARN("Unexpected virt type %d while encoding audit message", vm->def->virtType);
- virt = "?";
- }
-
switch (tpm->type) {
case VIR_DOMAIN_TPM_TYPE_PASSTHROUGH:
path = tpm->data.passthrough.source.data.file.path;
char *vmname;
char *controller = NULL;
char *detail;
- const char *virt;
+ const char *virt = virDomainAuditGetVirtType(vm->def);
virUUIDFormat(vm->def->uuid, uuidstr);
if (!(vmname = virAuditEncode("vm", vm->def->name))) {
return;
}
- if (!(virt = virDomainVirtTypeToString(vm->def->virtType))) {
- VIR_WARN("Unexpected virt type %d while encoding audit message", vm->def->virtType);
- virt = "?";
- }
-
ignore_value(virCgroupPathOfController(cgroup,
VIR_CGROUP_CONTROLLER_DEVICES,
NULL, &controller));
{
char uuidstr[VIR_UUID_STRING_BUFLEN];
char *vmname;
- const char *virt;
+ const char *virt = virDomainAuditGetVirtType(vm->def);
virUUIDFormat(vm->def->uuid, uuidstr);
if (!(vmname = virAuditEncode("vm", vm->def->name))) {
return;
}
- if (!(virt = virDomainVirtTypeToString(vm->def->virtType))) {
- VIR_WARN("Unexpected virt type %d while encoding audit message", vm->def->virtType);
- virt = "?";
- }
-
VIR_AUDIT(VIR_AUDIT_RECORD_RESOURCE, success,
"virt=%s resrc=%s reason=%s %s uuid=%s old-%s=%lld new-%s=%lld",
virt, resource, reason, vmname, uuidstr,
{
char uuidstr[VIR_UUID_STRING_BUFLEN];
char *vmname;
- const char *virt;
+ const char *virt = virDomainAuditGetVirtType(vm->def);
virUUIDFormat(vm->def->uuid, uuidstr);
return;
}
- if (!(virt = virDomainVirtTypeToString(vm->def->virtType))) {
- VIR_WARN("Unexpected virt type %d while encoding audit message", vm->def->virtType);
- virt = "?";
- }
-
VIR_AUDIT(VIR_AUDIT_RECORD_MACHINE_CONTROL, success,
"virt=%s op=%s reason=%s %s uuid=%s vm-pid=%lld",
virt, op, reason, vmname, uuidstr, (long long)vm->pid);
{
char uuidstr[VIR_UUID_STRING_BUFLEN];
char *vmname;
- const char *virt;
+ const char *virt = virDomainAuditGetVirtType(vm->def);
virUUIDFormat(vm->def->uuid, uuidstr);
return;
}
- if (!(virt = virDomainVirtTypeToString(vm->def->virtType))) {
- VIR_WARN("Unexpected virt type %d while encoding audit message", vm->def->virtType);
- virt = "?";
- }
-
VIR_AUDIT(VIR_AUDIT_RECORD_MACHINE_CONTROL, true,
"virt=%s op=init %s uuid=%s vm-pid=%lld init-pid=%lld pid-ns=%lld",
virt, vmname, uuidstr, (long long)vm->pid, (long long)initpid,
{
char uuidstr[VIR_UUID_STRING_BUFLEN];
char *vmname;
- const char *virt;
size_t i;
+ const char *virt = virDomainAuditGetVirtType(vm->def);
virUUIDFormat(vm->def->uuid, uuidstr);
if (!(vmname = virAuditEncode("vm", vm->def->name))) {
return;
}
- if (!(virt = virDomainVirtTypeToString(vm->def->virtType))) {
- VIR_WARN("Unexpected virt type %d while encoding audit message", vm->def->virtType);
- virt = "?";
- }
-
for (i = 0; i < vm->def->nseclabels; i++) {
VIR_AUDIT(VIR_AUDIT_RECORD_MACHINE_ID, success,
"virt=%s %s uuid=%s vm-ctx=%s img-ctx=%s model=%s",
char uuidstr[VIR_UUID_STRING_BUFLEN];
char *vmname = virAuditEncode("vm", vm->def->name);
const char *srcpath = virDomainChrSourceDefGetPath(&def->server.chr);
- const char *virt = virDomainVirtTypeToString(vm->def->virtType);
+ const char *virt = virDomainAuditGetVirtType(vm->def);
char *shmpath = NULL;
virUUIDFormat(vm->def->uuid, uuidstr);
{
char uuidstr[VIR_UUID_STRING_BUFLEN];
char *vmname;
- const char *virt = virDomainVirtTypeToString(vm->def->virtType);
+ const char *virt = virDomainAuditGetVirtType(vm->def);
virUUIDFormat(vm->def->uuid, uuidstr);