mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-03-07 17:28:15 +00:00
conf: use g_autofree and remove unnecessary label
Signed-off-by: Jiang Jiacheng <jiangjiacheng@huawei.com> Reviewed-by: Jonathon Jongsma <jjongsma@redhat.com> Reviewed-by: Ján Tomko <jtomko@redhat.com> Signed-off-by: Ján Tomko <jtomko@redhat.com>
This commit is contained in:
parent
7050dad5f9
commit
a9027d447b
@ -300,9 +300,9 @@ virDomainAuditNetDevice(virDomainDef *vmDef, virDomainNetDef *netDef,
|
|||||||
{
|
{
|
||||||
char uuidstr[VIR_UUID_STRING_BUFLEN];
|
char uuidstr[VIR_UUID_STRING_BUFLEN];
|
||||||
char macstr[VIR_MAC_STRING_BUFLEN];
|
char macstr[VIR_MAC_STRING_BUFLEN];
|
||||||
char *vmname;
|
g_autofree char *vmname = NULL;
|
||||||
char *dev_name = NULL;
|
g_autofree char *dev_name = NULL;
|
||||||
char *rdev;
|
g_autofree char *rdev = NULL;
|
||||||
const char *virt = virDomainAuditGetVirtType(vmDef);
|
const char *virt = virDomainAuditGetVirtType(vmDef);
|
||||||
|
|
||||||
virUUIDFormat(vmDef->uuid, uuidstr);
|
virUUIDFormat(vmDef->uuid, uuidstr);
|
||||||
@ -312,17 +312,12 @@ virDomainAuditNetDevice(virDomainDef *vmDef, virDomainNetDef *netDef,
|
|||||||
if (!(vmname = virAuditEncode("vm", vmDef->name)) ||
|
if (!(vmname = virAuditEncode("vm", vmDef->name)) ||
|
||||||
!(dev_name = virAuditEncode("path", device))) {
|
!(dev_name = virAuditEncode("path", device))) {
|
||||||
VIR_WARN("OOM while encoding audit message");
|
VIR_WARN("OOM while encoding audit message");
|
||||||
goto cleanup;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
VIR_AUDIT(VIR_AUDIT_RECORD_RESOURCE, success,
|
VIR_AUDIT(VIR_AUDIT_RECORD_RESOURCE, success,
|
||||||
"virt=%s resrc=net reason=open %s uuid=%s net=%s %s rdev=%s",
|
"virt=%s resrc=net reason=open %s uuid=%s net=%s %s rdev=%s",
|
||||||
virt, vmname, uuidstr, macstr, dev_name, VIR_AUDIT_STR(rdev));
|
virt, vmname, uuidstr, macstr, dev_name, VIR_AUDIT_STR(rdev));
|
||||||
|
|
||||||
cleanup:
|
|
||||||
VIR_FREE(vmname);
|
|
||||||
VIR_FREE(dev_name);
|
|
||||||
VIR_FREE(rdev);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -339,9 +334,9 @@ virDomainAuditHostdev(virDomainObj *vm, virDomainHostdevDef *hostdev,
|
|||||||
const char *reason, bool success)
|
const char *reason, bool success)
|
||||||
{
|
{
|
||||||
char uuidstr[VIR_UUID_STRING_BUFLEN];
|
char uuidstr[VIR_UUID_STRING_BUFLEN];
|
||||||
char *vmname;
|
g_autofree char *vmname = NULL;
|
||||||
char *address = NULL;
|
g_autofree char *address = NULL;
|
||||||
char *device = NULL;
|
g_autofree char *device = NULL;
|
||||||
const char *virt = virDomainAuditGetVirtType(vm->def);
|
const char *virt = virDomainAuditGetVirtType(vm->def);
|
||||||
|
|
||||||
virDomainHostdevSubsysUSB *usbsrc = &hostdev->source.subsys.u.usb;
|
virDomainHostdevSubsysUSB *usbsrc = &hostdev->source.subsys.u.usb;
|
||||||
@ -371,7 +366,7 @@ virDomainAuditHostdev(virDomainObj *vm, virDomainHostdevDef *hostdev,
|
|||||||
/* Follow virDomainAuditDisk && virDomainAuditGenericDev
|
/* Follow virDomainAuditDisk && virDomainAuditGenericDev
|
||||||
* and don't audit the networked device.
|
* and don't audit the networked device.
|
||||||
*/
|
*/
|
||||||
goto cleanup;
|
return;
|
||||||
} else {
|
} else {
|
||||||
virDomainHostdevSubsysSCSIHost *scsihostsrc = &scsisrc->u.host;
|
virDomainHostdevSubsysSCSIHost *scsihostsrc = &scsisrc->u.host;
|
||||||
|
|
||||||
@ -392,12 +387,12 @@ virDomainAuditHostdev(virDomainObj *vm, virDomainHostdevDef *hostdev,
|
|||||||
default:
|
default:
|
||||||
VIR_WARN("Unexpected hostdev type while encoding audit message: %d",
|
VIR_WARN("Unexpected hostdev type while encoding audit message: %d",
|
||||||
hostdev->source.subsys.type);
|
hostdev->source.subsys.type);
|
||||||
goto cleanup;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!(device = virAuditEncode("device", VIR_AUDIT_STR(address)))) {
|
if (!(device = virAuditEncode("device", VIR_AUDIT_STR(address)))) {
|
||||||
VIR_WARN("OOM while encoding audit message");
|
VIR_WARN("OOM while encoding audit message");
|
||||||
goto cleanup;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
VIR_AUDIT(VIR_AUDIT_RECORD_RESOURCE, success,
|
VIR_AUDIT(VIR_AUDIT_RECORD_RESOURCE, success,
|
||||||
@ -413,7 +408,7 @@ virDomainAuditHostdev(virDomainObj *vm, virDomainHostdevDef *hostdev,
|
|||||||
if (!(device = virAuditEncode("disk",
|
if (!(device = virAuditEncode("disk",
|
||||||
VIR_AUDIT_STR(hostdev->source.caps.u.storage.block)))) {
|
VIR_AUDIT_STR(hostdev->source.caps.u.storage.block)))) {
|
||||||
VIR_WARN("OOM while encoding audit message");
|
VIR_WARN("OOM while encoding audit message");
|
||||||
goto cleanup;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
VIR_AUDIT(VIR_AUDIT_RECORD_RESOURCE, success,
|
VIR_AUDIT(VIR_AUDIT_RECORD_RESOURCE, success,
|
||||||
@ -425,7 +420,7 @@ virDomainAuditHostdev(virDomainObj *vm, virDomainHostdevDef *hostdev,
|
|||||||
if (!(device = virAuditEncode("chardev",
|
if (!(device = virAuditEncode("chardev",
|
||||||
VIR_AUDIT_STR(hostdev->source.caps.u.misc.chardev)))) {
|
VIR_AUDIT_STR(hostdev->source.caps.u.misc.chardev)))) {
|
||||||
VIR_WARN("OOM while encoding audit message");
|
VIR_WARN("OOM while encoding audit message");
|
||||||
goto cleanup;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
VIR_AUDIT(VIR_AUDIT_RECORD_RESOURCE, success,
|
VIR_AUDIT(VIR_AUDIT_RECORD_RESOURCE, success,
|
||||||
@ -436,7 +431,7 @@ virDomainAuditHostdev(virDomainObj *vm, virDomainHostdevDef *hostdev,
|
|||||||
default:
|
default:
|
||||||
VIR_WARN("Unexpected hostdev type while encoding audit message: %d",
|
VIR_WARN("Unexpected hostdev type while encoding audit message: %d",
|
||||||
hostdev->source.caps.type);
|
hostdev->source.caps.type);
|
||||||
goto cleanup;
|
return;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@ -444,13 +439,8 @@ virDomainAuditHostdev(virDomainObj *vm, virDomainHostdevDef *hostdev,
|
|||||||
default:
|
default:
|
||||||
VIR_WARN("Unexpected hostdev mode while encoding audit message: %d",
|
VIR_WARN("Unexpected hostdev mode while encoding audit message: %d",
|
||||||
hostdev->mode);
|
hostdev->mode);
|
||||||
goto cleanup;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
cleanup:
|
|
||||||
VIR_FREE(vmname);
|
|
||||||
VIR_FREE(device);
|
|
||||||
VIR_FREE(address);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -468,9 +458,9 @@ virDomainAuditRedirdev(virDomainObj *vm, virDomainRedirdevDef *redirdev,
|
|||||||
const char *reason, bool success)
|
const char *reason, bool success)
|
||||||
{
|
{
|
||||||
char uuidstr[VIR_UUID_STRING_BUFLEN];
|
char uuidstr[VIR_UUID_STRING_BUFLEN];
|
||||||
char *vmname;
|
g_autofree char *vmname = NULL;
|
||||||
char *address = NULL;
|
g_autofree char *address = NULL;
|
||||||
char *device = NULL;
|
g_autofree char *device = NULL;
|
||||||
const char *virt = virDomainAuditGetVirtType(vm->def);
|
const char *virt = virDomainAuditGetVirtType(vm->def);
|
||||||
|
|
||||||
virUUIDFormat(vm->def->uuid, uuidstr);
|
virUUIDFormat(vm->def->uuid, uuidstr);
|
||||||
@ -486,12 +476,12 @@ virDomainAuditRedirdev(virDomainObj *vm, virDomainRedirdevDef *redirdev,
|
|||||||
default:
|
default:
|
||||||
VIR_WARN("Unexpected redirdev bus while encoding audit message: %d",
|
VIR_WARN("Unexpected redirdev bus while encoding audit message: %d",
|
||||||
redirdev->bus);
|
redirdev->bus);
|
||||||
goto cleanup;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!(device = virAuditEncode("device", VIR_AUDIT_STR(address)))) {
|
if (!(device = virAuditEncode("device", VIR_AUDIT_STR(address)))) {
|
||||||
VIR_WARN("OOM while encoding audit message");
|
VIR_WARN("OOM while encoding audit message");
|
||||||
goto cleanup;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
VIR_AUDIT(VIR_AUDIT_RECORD_RESOURCE, success,
|
VIR_AUDIT(VIR_AUDIT_RECORD_RESOURCE, success,
|
||||||
@ -499,11 +489,6 @@ virDomainAuditRedirdev(virDomainObj *vm, virDomainRedirdevDef *redirdev,
|
|||||||
virt, reason, vmname, uuidstr,
|
virt, reason, vmname, uuidstr,
|
||||||
virDomainRedirdevBusTypeToString(redirdev->bus),
|
virDomainRedirdevBusTypeToString(redirdev->bus),
|
||||||
device);
|
device);
|
||||||
|
|
||||||
cleanup:
|
|
||||||
VIR_FREE(vmname);
|
|
||||||
VIR_FREE(device);
|
|
||||||
VIR_FREE(address);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -522,9 +507,9 @@ virDomainAuditTPM(virDomainObj *vm, virDomainTPMDef *tpm,
|
|||||||
const char *reason, bool success)
|
const char *reason, bool success)
|
||||||
{
|
{
|
||||||
char uuidstr[VIR_UUID_STRING_BUFLEN];
|
char uuidstr[VIR_UUID_STRING_BUFLEN];
|
||||||
char *vmname;
|
g_autofree char *vmname = NULL;
|
||||||
char *path = NULL;
|
char *path = NULL;
|
||||||
char *device = NULL;
|
g_autofree char *device = NULL;
|
||||||
const char *virt = virDomainAuditGetVirtType(vm->def);
|
const char *virt = virDomainAuditGetVirtType(vm->def);
|
||||||
|
|
||||||
virUUIDFormat(vm->def->uuid, uuidstr);
|
virUUIDFormat(vm->def->uuid, uuidstr);
|
||||||
@ -538,7 +523,7 @@ virDomainAuditTPM(virDomainObj *vm, virDomainTPMDef *tpm,
|
|||||||
path = tpm->data.passthrough.source->data.file.path;
|
path = tpm->data.passthrough.source->data.file.path;
|
||||||
if (!(device = virAuditEncode("device", VIR_AUDIT_STR(path)))) {
|
if (!(device = virAuditEncode("device", VIR_AUDIT_STR(path)))) {
|
||||||
VIR_WARN("OOM while encoding audit message");
|
VIR_WARN("OOM while encoding audit message");
|
||||||
goto cleanup;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
VIR_AUDIT(VIR_AUDIT_RECORD_RESOURCE, success,
|
VIR_AUDIT(VIR_AUDIT_RECORD_RESOURCE, success,
|
||||||
@ -549,7 +534,7 @@ virDomainAuditTPM(virDomainObj *vm, virDomainTPMDef *tpm,
|
|||||||
path = tpm->data.emulator.source->data.nix.path;
|
path = tpm->data.emulator.source->data.nix.path;
|
||||||
if (!(device = virAuditEncode("device", VIR_AUDIT_STR(path)))) {
|
if (!(device = virAuditEncode("device", VIR_AUDIT_STR(path)))) {
|
||||||
VIR_WARN("OOM while encoding audit message");
|
VIR_WARN("OOM while encoding audit message");
|
||||||
goto cleanup;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
VIR_AUDIT(VIR_AUDIT_RECORD_RESOURCE, success,
|
VIR_AUDIT(VIR_AUDIT_RECORD_RESOURCE, success,
|
||||||
@ -560,7 +545,7 @@ virDomainAuditTPM(virDomainObj *vm, virDomainTPMDef *tpm,
|
|||||||
path = tpm->data.external.source->data.nix.path;
|
path = tpm->data.external.source->data.nix.path;
|
||||||
if (!(device = virAuditEncode("device", VIR_AUDIT_STR(path)))) {
|
if (!(device = virAuditEncode("device", VIR_AUDIT_STR(path)))) {
|
||||||
VIR_WARN("OOM while encoding audit message");
|
VIR_WARN("OOM while encoding audit message");
|
||||||
goto cleanup;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
VIR_AUDIT(VIR_AUDIT_RECORD_RESOURCE, success,
|
VIR_AUDIT(VIR_AUDIT_RECORD_RESOURCE, success,
|
||||||
@ -571,10 +556,6 @@ virDomainAuditTPM(virDomainObj *vm, virDomainTPMDef *tpm,
|
|||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
cleanup:
|
|
||||||
VIR_FREE(vmname);
|
|
||||||
VIR_FREE(device);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -596,9 +577,9 @@ virDomainAuditCgroup(virDomainObj *vm, virCgroup *cgroup,
|
|||||||
const char *reason, const char *extra, bool success)
|
const char *reason, const char *extra, bool success)
|
||||||
{
|
{
|
||||||
char uuidstr[VIR_UUID_STRING_BUFLEN];
|
char uuidstr[VIR_UUID_STRING_BUFLEN];
|
||||||
char *vmname;
|
g_autofree char *vmname = NULL;
|
||||||
char *controller = NULL;
|
g_autofree char *controller = NULL;
|
||||||
char *detail;
|
g_autofree char *detail = NULL;
|
||||||
const char *virt = virDomainAuditGetVirtType(vm->def);
|
const char *virt = virDomainAuditGetVirtType(vm->def);
|
||||||
|
|
||||||
virUUIDFormat(vm->def->uuid, uuidstr);
|
virUUIDFormat(vm->def->uuid, uuidstr);
|
||||||
@ -616,10 +597,6 @@ virDomainAuditCgroup(virDomainObj *vm, virCgroup *cgroup,
|
|||||||
"virt=%s resrc=cgroup reason=%s %s uuid=%s %s class=%s",
|
"virt=%s resrc=cgroup reason=%s %s uuid=%s %s class=%s",
|
||||||
virt, reason, vmname, uuidstr,
|
virt, reason, vmname, uuidstr,
|
||||||
detail ? detail : "cgroup=?", extra);
|
detail ? detail : "cgroup=?", extra);
|
||||||
|
|
||||||
VIR_FREE(vmname);
|
|
||||||
VIR_FREE(controller);
|
|
||||||
VIR_FREE(detail);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -639,14 +616,12 @@ virDomainAuditCgroupMajor(virDomainObj *vm, virCgroup *cgroup,
|
|||||||
const char *reason, int maj, const char *name,
|
const char *reason, int maj, const char *name,
|
||||||
const char *perms, bool success)
|
const char *perms, bool success)
|
||||||
{
|
{
|
||||||
char *extra;
|
g_autofree char *extra = NULL;
|
||||||
|
|
||||||
extra = g_strdup_printf("major category=%s maj=%02X acl=%s",
|
extra = g_strdup_printf("major category=%s maj=%02X acl=%s",
|
||||||
name, maj, perms);
|
name, maj, perms);
|
||||||
|
|
||||||
virDomainAuditCgroup(vm, cgroup, reason, extra, success);
|
virDomainAuditCgroup(vm, cgroup, reason, extra, success);
|
||||||
|
|
||||||
VIR_FREE(extra);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -666,9 +641,9 @@ virDomainAuditCgroupPath(virDomainObj *vm, virCgroup *cgroup,
|
|||||||
const char *reason, const char *path, const char *perms,
|
const char *reason, const char *path, const char *perms,
|
||||||
int rc)
|
int rc)
|
||||||
{
|
{
|
||||||
char *detail;
|
g_autofree char *detail = NULL;
|
||||||
char *rdev;
|
g_autofree char *rdev = NULL;
|
||||||
char *extra = NULL;
|
g_autofree char *extra = NULL;
|
||||||
|
|
||||||
/* Nothing to audit for regular files. */
|
/* Nothing to audit for regular files. */
|
||||||
if (rc > 0)
|
if (rc > 0)
|
||||||
@ -678,18 +653,13 @@ virDomainAuditCgroupPath(virDomainObj *vm, virCgroup *cgroup,
|
|||||||
|
|
||||||
if (!(detail = virAuditEncode("path", path))) {
|
if (!(detail = virAuditEncode("path", path))) {
|
||||||
VIR_WARN("OOM while encoding audit message");
|
VIR_WARN("OOM while encoding audit message");
|
||||||
goto cleanup;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
extra = g_strdup_printf("path %s rdev=%s acl=%s",
|
extra = g_strdup_printf("path %s rdev=%s acl=%s",
|
||||||
detail, VIR_AUDIT_STR(rdev), perms);
|
detail, VIR_AUDIT_STR(rdev), perms);
|
||||||
|
|
||||||
virDomainAuditCgroup(vm, cgroup, reason, extra, rc == 0);
|
virDomainAuditCgroup(vm, cgroup, reason, extra, rc == 0);
|
||||||
|
|
||||||
cleanup:
|
|
||||||
VIR_FREE(extra);
|
|
||||||
VIR_FREE(detail);
|
|
||||||
VIR_FREE(rdev);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -709,7 +679,7 @@ virDomainAuditResource(virDomainObj *vm, const char *resource,
|
|||||||
const char *reason, bool success)
|
const char *reason, bool success)
|
||||||
{
|
{
|
||||||
char uuidstr[VIR_UUID_STRING_BUFLEN];
|
char uuidstr[VIR_UUID_STRING_BUFLEN];
|
||||||
char *vmname;
|
g_autofree char *vmname = NULL;
|
||||||
const char *virt = virDomainAuditGetVirtType(vm->def);
|
const char *virt = virDomainAuditGetVirtType(vm->def);
|
||||||
|
|
||||||
virUUIDFormat(vm->def->uuid, uuidstr);
|
virUUIDFormat(vm->def->uuid, uuidstr);
|
||||||
@ -722,8 +692,6 @@ virDomainAuditResource(virDomainObj *vm, const char *resource,
|
|||||||
"virt=%s resrc=%s reason=%s %s uuid=%s old-%s=%lld new-%s=%lld",
|
"virt=%s resrc=%s reason=%s %s uuid=%s old-%s=%lld new-%s=%lld",
|
||||||
virt, resource, reason, vmname, uuidstr,
|
virt, resource, reason, vmname, uuidstr,
|
||||||
resource, oldval, resource, newval);
|
resource, oldval, resource, newval);
|
||||||
|
|
||||||
VIR_FREE(vmname);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
@ -756,7 +724,7 @@ virDomainAuditLifecycle(virDomainObj *vm, const char *op,
|
|||||||
const char *reason, bool success)
|
const char *reason, bool success)
|
||||||
{
|
{
|
||||||
char uuidstr[VIR_UUID_STRING_BUFLEN];
|
char uuidstr[VIR_UUID_STRING_BUFLEN];
|
||||||
char *vmname;
|
g_autofree char *vmname = NULL;
|
||||||
const char *virt = virDomainAuditGetVirtType(vm->def);
|
const char *virt = virDomainAuditGetVirtType(vm->def);
|
||||||
|
|
||||||
virUUIDFormat(vm->def->uuid, uuidstr);
|
virUUIDFormat(vm->def->uuid, uuidstr);
|
||||||
@ -769,8 +737,6 @@ virDomainAuditLifecycle(virDomainObj *vm, const char *op,
|
|||||||
VIR_AUDIT(VIR_AUDIT_RECORD_MACHINE_CONTROL, success,
|
VIR_AUDIT(VIR_AUDIT_RECORD_MACHINE_CONTROL, success,
|
||||||
"virt=%s op=%s reason=%s %s uuid=%s vm-pid=%lld",
|
"virt=%s op=%s reason=%s %s uuid=%s vm-pid=%lld",
|
||||||
virt, op, reason, vmname, uuidstr, (long long)vm->pid);
|
virt, op, reason, vmname, uuidstr, (long long)vm->pid);
|
||||||
|
|
||||||
VIR_FREE(vmname);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -851,7 +817,7 @@ virDomainAuditInit(virDomainObj *vm,
|
|||||||
ino_t pidns)
|
ino_t pidns)
|
||||||
{
|
{
|
||||||
char uuidstr[VIR_UUID_STRING_BUFLEN];
|
char uuidstr[VIR_UUID_STRING_BUFLEN];
|
||||||
char *vmname;
|
g_autofree char *vmname = NULL;
|
||||||
const char *virt = virDomainAuditGetVirtType(vm->def);
|
const char *virt = virDomainAuditGetVirtType(vm->def);
|
||||||
|
|
||||||
virUUIDFormat(vm->def->uuid, uuidstr);
|
virUUIDFormat(vm->def->uuid, uuidstr);
|
||||||
@ -865,8 +831,6 @@ virDomainAuditInit(virDomainObj *vm,
|
|||||||
"virt=%s op=init %s uuid=%s vm-pid=%lld init-pid=%lld pid-ns=%lld",
|
"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,
|
virt, vmname, uuidstr, (long long)vm->pid, (long long)initpid,
|
||||||
(long long)pidns);
|
(long long)pidns);
|
||||||
|
|
||||||
VIR_FREE(vmname);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
@ -879,7 +843,7 @@ void
|
|||||||
virDomainAuditSecurityLabel(virDomainObj *vm, bool success)
|
virDomainAuditSecurityLabel(virDomainObj *vm, bool success)
|
||||||
{
|
{
|
||||||
char uuidstr[VIR_UUID_STRING_BUFLEN];
|
char uuidstr[VIR_UUID_STRING_BUFLEN];
|
||||||
char *vmname;
|
g_autofree char *vmname = NULL;
|
||||||
size_t i;
|
size_t i;
|
||||||
const char *virt = virDomainAuditGetVirtType(vm->def);
|
const char *virt = virDomainAuditGetVirtType(vm->def);
|
||||||
|
|
||||||
@ -897,8 +861,6 @@ virDomainAuditSecurityLabel(virDomainObj *vm, bool success)
|
|||||||
VIR_AUDIT_STR(vm->def->seclabels[i]->imagelabel),
|
VIR_AUDIT_STR(vm->def->seclabels[i]->imagelabel),
|
||||||
VIR_AUDIT_STR(vm->def->seclabels[i]->model));
|
VIR_AUDIT_STR(vm->def->seclabels[i]->model));
|
||||||
}
|
}
|
||||||
|
|
||||||
VIR_FREE(vmname);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
@ -907,16 +869,16 @@ virDomainAuditShmem(virDomainObj *vm,
|
|||||||
const char *reason, bool success)
|
const char *reason, bool success)
|
||||||
{
|
{
|
||||||
char uuidstr[VIR_UUID_STRING_BUFLEN];
|
char uuidstr[VIR_UUID_STRING_BUFLEN];
|
||||||
char *vmname = virAuditEncode("vm", vm->def->name);
|
g_autofree char *vmname = virAuditEncode("vm", vm->def->name);
|
||||||
const char *srcpath = virDomainChrSourceDefGetPath(def->server.chr);
|
const char *srcpath = virDomainChrSourceDefGetPath(def->server.chr);
|
||||||
const char *virt = virDomainAuditGetVirtType(vm->def);
|
const char *virt = virDomainAuditGetVirtType(vm->def);
|
||||||
char *shmpath = NULL;
|
g_autofree char *shmpath = NULL;
|
||||||
|
|
||||||
virUUIDFormat(vm->def->uuid, uuidstr);
|
virUUIDFormat(vm->def->uuid, uuidstr);
|
||||||
|
|
||||||
if (!vmname) {
|
if (!vmname) {
|
||||||
VIR_WARN("OOM while encoding audit message");
|
VIR_WARN("OOM while encoding audit message");
|
||||||
goto cleanup;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
shmpath = g_strdup_printf("/dev/shm/%s", def->name);
|
shmpath = g_strdup_printf("/dev/shm/%s", def->name);
|
||||||
@ -936,11 +898,6 @@ virDomainAuditShmem(virDomainObj *vm,
|
|||||||
"virt=%s resrc=shmem reason=%s %s uuid=%s size=%llu path=%s",
|
"virt=%s resrc=shmem reason=%s %s uuid=%s size=%llu path=%s",
|
||||||
virt, reason, vmname, uuidstr, def->size, VIR_AUDIT_STR(shmpath));
|
virt, reason, vmname, uuidstr, def->size, VIR_AUDIT_STR(shmpath));
|
||||||
}
|
}
|
||||||
|
|
||||||
cleanup:
|
|
||||||
VIR_FREE(vmname);
|
|
||||||
VIR_FREE(shmpath);
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -78,7 +78,7 @@ virNodeDeviceCreateVport(virStorageAdapterFCHost *fchost)
|
|||||||
{
|
{
|
||||||
unsigned int parent_host;
|
unsigned int parent_host;
|
||||||
char *name = NULL;
|
char *name = NULL;
|
||||||
char *parent_hoststr = NULL;
|
g_autofree char *parent_hoststr = NULL;
|
||||||
bool skip_capable_check = false;
|
bool skip_capable_check = false;
|
||||||
|
|
||||||
VIR_DEBUG("parent='%s', wwnn='%s' wwpn='%s'",
|
VIR_DEBUG("parent='%s', wwnn='%s' wwpn='%s'",
|
||||||
@ -91,27 +91,27 @@ virNodeDeviceCreateVport(virStorageAdapterFCHost *fchost)
|
|||||||
fchost->parent_wwpn))) {
|
fchost->parent_wwpn))) {
|
||||||
virReportError(VIR_ERR_XML_ERROR, "%s",
|
virReportError(VIR_ERR_XML_ERROR, "%s",
|
||||||
_("cannot find parent using provided wwnn/wwpn"));
|
_("cannot find parent using provided wwnn/wwpn"));
|
||||||
goto cleanup;
|
return NULL;
|
||||||
}
|
}
|
||||||
} else if (fchost->parent_fabric_wwn) {
|
} else if (fchost->parent_fabric_wwn) {
|
||||||
if (!(parent_hoststr =
|
if (!(parent_hoststr =
|
||||||
virVHBAGetHostByFabricWWN(NULL, fchost->parent_fabric_wwn))) {
|
virVHBAGetHostByFabricWWN(NULL, fchost->parent_fabric_wwn))) {
|
||||||
virReportError(VIR_ERR_XML_ERROR, "%s",
|
virReportError(VIR_ERR_XML_ERROR, "%s",
|
||||||
_("cannot find parent using provided fabric_wwn"));
|
_("cannot find parent using provided fabric_wwn"));
|
||||||
goto cleanup;
|
return NULL;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (!(parent_hoststr = virVHBAFindVportHost(NULL))) {
|
if (!(parent_hoststr = virVHBAFindVportHost(NULL))) {
|
||||||
virReportError(VIR_ERR_XML_ERROR, "%s",
|
virReportError(VIR_ERR_XML_ERROR, "%s",
|
||||||
_("'parent' for vHBA not specified, and "
|
_("'parent' for vHBA not specified, and "
|
||||||
"cannot find one on this host"));
|
"cannot find one on this host"));
|
||||||
goto cleanup;
|
return NULL;
|
||||||
}
|
}
|
||||||
skip_capable_check = true;
|
skip_capable_check = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (virSCSIHostGetNumber(parent_hoststr, &parent_host) < 0)
|
if (virSCSIHostGetNumber(parent_hoststr, &parent_host) < 0)
|
||||||
goto cleanup;
|
return NULL;
|
||||||
|
|
||||||
/* NOTE:
|
/* NOTE:
|
||||||
* We do not save the parent_hoststr in fchost->parent since
|
* We do not save the parent_hoststr in fchost->parent since
|
||||||
@ -125,23 +125,21 @@ virNodeDeviceCreateVport(virStorageAdapterFCHost *fchost)
|
|||||||
virReportError(VIR_ERR_XML_ERROR,
|
virReportError(VIR_ERR_XML_ERROR,
|
||||||
_("parent '%s' specified for vHBA does not exist"),
|
_("parent '%s' specified for vHBA does not exist"),
|
||||||
parent_hoststr);
|
parent_hoststr);
|
||||||
goto cleanup;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (virVHBAManageVport(parent_host, fchost->wwpn, fchost->wwnn,
|
if (virVHBAManageVport(parent_host, fchost->wwpn, fchost->wwnn,
|
||||||
VPORT_CREATE) < 0)
|
VPORT_CREATE) < 0)
|
||||||
goto cleanup;
|
return NULL;
|
||||||
|
|
||||||
/* Let's ensure the device was created */
|
/* Let's ensure the device was created */
|
||||||
virWaitForDevices();
|
virWaitForDevices();
|
||||||
if (!(name = virVHBAGetHostByWWN(NULL, fchost->wwnn, fchost->wwpn))) {
|
if (!(name = virVHBAGetHostByWWN(NULL, fchost->wwnn, fchost->wwpn))) {
|
||||||
ignore_value(virVHBAManageVport(parent_host, fchost->wwpn, fchost->wwnn,
|
ignore_value(virVHBAManageVport(parent_host, fchost->wwpn, fchost->wwnn,
|
||||||
VPORT_DELETE));
|
VPORT_DELETE));
|
||||||
goto cleanup;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
cleanup:
|
|
||||||
VIR_FREE(parent_hoststr);
|
|
||||||
return name;
|
return name;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -160,11 +158,10 @@ int
|
|||||||
virNodeDeviceDeleteVport(virConnectPtr conn,
|
virNodeDeviceDeleteVport(virConnectPtr conn,
|
||||||
virStorageAdapterFCHost *fchost)
|
virStorageAdapterFCHost *fchost)
|
||||||
{
|
{
|
||||||
char *name = NULL;
|
g_autofree char *name = NULL;
|
||||||
char *scsi_host_name = NULL;
|
g_autofree char *scsi_host_name = NULL;
|
||||||
unsigned int parent_host;
|
unsigned int parent_host;
|
||||||
char *vhba_parent = NULL;
|
g_autofree char *vhba_parent = NULL;
|
||||||
int ret = -1;
|
|
||||||
|
|
||||||
VIR_DEBUG("conn=%p parent='%s', managed='%d' wwnn='%s' wwpn='%s'",
|
VIR_DEBUG("conn=%p parent='%s', managed='%d' wwnn='%s' wwpn='%s'",
|
||||||
conn, NULLSTR(fchost->parent), fchost->managed,
|
conn, NULLSTR(fchost->parent), fchost->managed,
|
||||||
@ -179,7 +176,7 @@ virNodeDeviceDeleteVport(virConnectPtr conn,
|
|||||||
virReportError(VIR_ERR_INTERNAL_ERROR,
|
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||||
_("Failed to find fc_host for wwnn='%s' and wwpn='%s'"),
|
_("Failed to find fc_host for wwnn='%s' and wwpn='%s'"),
|
||||||
fchost->wwnn, fchost->wwpn);
|
fchost->wwnn, fchost->wwpn);
|
||||||
goto cleanup;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
scsi_host_name = g_strdup_printf("scsi_%s", name);
|
scsi_host_name = g_strdup_printf("scsi_%s", name);
|
||||||
@ -193,36 +190,28 @@ virNodeDeviceDeleteVport(virConnectPtr conn,
|
|||||||
* was the same as the scsi_host - meaning we have a pool
|
* was the same as the scsi_host - meaning we have a pool
|
||||||
* backed to an HBA, so there won't be a vHBA to delete */
|
* backed to an HBA, so there won't be a vHBA to delete */
|
||||||
if (STREQ(scsi_host_name, fchost->parent)) {
|
if (STREQ(scsi_host_name, fchost->parent)) {
|
||||||
ret = 0;
|
return 0;
|
||||||
goto cleanup;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (virSCSIHostGetNumber(fchost->parent, &parent_host) < 0)
|
if (virSCSIHostGetNumber(fchost->parent, &parent_host) < 0)
|
||||||
goto cleanup;
|
return -1;
|
||||||
} else {
|
} else {
|
||||||
if (!(vhba_parent = virNodeDeviceGetParentName(conn, scsi_host_name)))
|
if (!(vhba_parent = virNodeDeviceGetParentName(conn, scsi_host_name)))
|
||||||
goto cleanup;
|
return -1;
|
||||||
|
|
||||||
/* If the parent is not a scsi_host, then this is a pool backed
|
/* If the parent is not a scsi_host, then this is a pool backed
|
||||||
* directly to an HBA and there's no vHBA to remove - so we're done */
|
* directly to an HBA and there's no vHBA to remove - so we're done */
|
||||||
if (!STRPREFIX(vhba_parent, "scsi_host")) {
|
if (!STRPREFIX(vhba_parent, "scsi_host")) {
|
||||||
ret = 0;
|
return 0;
|
||||||
goto cleanup;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (virSCSIHostGetNumber(vhba_parent, &parent_host) < 0)
|
if (virSCSIHostGetNumber(vhba_parent, &parent_host) < 0)
|
||||||
goto cleanup;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (virVHBAManageVport(parent_host, fchost->wwpn, fchost->wwnn,
|
if (virVHBAManageVport(parent_host, fchost->wwpn, fchost->wwnn,
|
||||||
VPORT_DELETE) < 0)
|
VPORT_DELETE) < 0)
|
||||||
goto cleanup;
|
return -1;
|
||||||
|
|
||||||
ret = 0;
|
return 0;
|
||||||
|
|
||||||
cleanup:
|
|
||||||
VIR_FREE(name);
|
|
||||||
VIR_FREE(vhba_parent);
|
|
||||||
VIR_FREE(scsi_host_name);
|
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
@ -2375,10 +2375,10 @@ virNWFilterRuleDefFixup(virNWFilterRuleDef *rule)
|
|||||||
static virNWFilterRuleDef *
|
static virNWFilterRuleDef *
|
||||||
virNWFilterRuleParse(xmlNodePtr node)
|
virNWFilterRuleParse(xmlNodePtr node)
|
||||||
{
|
{
|
||||||
char *action;
|
g_autofree char *action = NULL;
|
||||||
char *direction;
|
g_autofree char *direction = NULL;
|
||||||
char *prio;
|
g_autofree char *prio = NULL;
|
||||||
char *statematch;
|
g_autofree char *statematch = NULL;
|
||||||
bool found;
|
bool found;
|
||||||
int found_i = 0;
|
int found_i = 0;
|
||||||
int priority;
|
int priority;
|
||||||
@ -2476,17 +2476,11 @@ virNWFilterRuleParse(xmlNodePtr node)
|
|||||||
|
|
||||||
virNWFilterRuleDefFixup(ret);
|
virNWFilterRuleDefFixup(ret);
|
||||||
|
|
||||||
cleanup:
|
|
||||||
VIR_FREE(prio);
|
|
||||||
VIR_FREE(action);
|
|
||||||
VIR_FREE(direction);
|
|
||||||
VIR_FREE(statematch);
|
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
err_exit:
|
err_exit:
|
||||||
g_clear_pointer(&ret, virNWFilterRuleDefFree);
|
g_clear_pointer(&ret, virNWFilterRuleDefFree);
|
||||||
goto cleanup;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -2521,7 +2515,7 @@ virNWFilterIsAllowedChain(const char *chainname)
|
|||||||
{
|
{
|
||||||
virNWFilterChainSuffixType i;
|
virNWFilterChainSuffixType i;
|
||||||
const char *name;
|
const char *name;
|
||||||
char *msg;
|
g_autofree char *msg = NULL;
|
||||||
g_auto(virBuffer) buf = VIR_BUFFER_INITIALIZER;
|
g_auto(virBuffer) buf = VIR_BUFFER_INITIALIZER;
|
||||||
bool printed = false;
|
bool printed = false;
|
||||||
|
|
||||||
@ -2559,7 +2553,6 @@ virNWFilterIsAllowedChain(const char *chainname)
|
|||||||
msg = virBufferContentAndReset(&buf);
|
msg = virBufferContentAndReset(&buf);
|
||||||
|
|
||||||
virReportError(VIR_ERR_INVALID_ARG, "%s", msg);
|
virReportError(VIR_ERR_INVALID_ARG, "%s", msg);
|
||||||
VIR_FREE(msg);
|
|
||||||
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
@ -2570,9 +2563,9 @@ virNWFilterDefParseXML(xmlXPathContextPtr ctxt)
|
|||||||
{
|
{
|
||||||
virNWFilterDef *ret;
|
virNWFilterDef *ret;
|
||||||
xmlNodePtr curr = ctxt->node;
|
xmlNodePtr curr = ctxt->node;
|
||||||
char *uuid = NULL;
|
g_autofree char *uuid = NULL;
|
||||||
char *chain = NULL;
|
g_autofree char *chain = NULL;
|
||||||
char *chain_pri_s = NULL;
|
g_autofree char *chain_pri_s = NULL;
|
||||||
virNWFilterEntry *entry;
|
virNWFilterEntry *entry;
|
||||||
int chain_priority;
|
int chain_priority;
|
||||||
const char *name_prefix;
|
const char *name_prefix;
|
||||||
@ -2641,7 +2634,6 @@ virNWFilterDefParseXML(xmlXPathContextPtr ctxt)
|
|||||||
"%s", _("malformed uuid element"));
|
"%s", _("malformed uuid element"));
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
VIR_FREE(uuid);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
curr = curr->children;
|
curr = curr->children;
|
||||||
@ -2671,16 +2663,10 @@ virNWFilterDefParseXML(xmlXPathContextPtr ctxt)
|
|||||||
curr = curr->next;
|
curr = curr->next;
|
||||||
}
|
}
|
||||||
|
|
||||||
VIR_FREE(chain);
|
|
||||||
VIR_FREE(chain_pri_s);
|
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
cleanup:
|
cleanup:
|
||||||
virNWFilterDefFree(ret);
|
virNWFilterDefFree(ret);
|
||||||
VIR_FREE(chain);
|
|
||||||
VIR_FREE(uuid);
|
|
||||||
VIR_FREE(chain_pri_s);
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2707,24 +2693,21 @@ virNWFilterSaveConfig(const char *configDir,
|
|||||||
virNWFilterDef *def)
|
virNWFilterDef *def)
|
||||||
{
|
{
|
||||||
int ret = -1;
|
int ret = -1;
|
||||||
char *xml;
|
g_autofree char *xml = NULL;
|
||||||
char uuidstr[VIR_UUID_STRING_BUFLEN];
|
char uuidstr[VIR_UUID_STRING_BUFLEN];
|
||||||
char *configFile = NULL;
|
g_autofree char *configFile = NULL;
|
||||||
|
|
||||||
if (!(xml = virNWFilterDefFormat(def)))
|
if (!(xml = virNWFilterDefFormat(def)))
|
||||||
goto cleanup;
|
return -1;
|
||||||
|
|
||||||
if (!(configFile = virFileBuildPath(configDir, def->name, ".xml")))
|
if (!(configFile = virFileBuildPath(configDir, def->name, ".xml")))
|
||||||
goto cleanup;
|
return -1;
|
||||||
|
|
||||||
virUUIDFormat(def->uuid, uuidstr);
|
virUUIDFormat(def->uuid, uuidstr);
|
||||||
ret = virXMLSaveFile(configFile,
|
ret = virXMLSaveFile(configFile,
|
||||||
virXMLPickShellSafeComment(def->name, uuidstr),
|
virXMLPickShellSafeComment(def->name, uuidstr),
|
||||||
"nwfilter-edit", xml);
|
"nwfilter-edit", xml);
|
||||||
|
|
||||||
cleanup:
|
|
||||||
VIR_FREE(configFile);
|
|
||||||
VIR_FREE(xml);
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2733,23 +2716,19 @@ int
|
|||||||
virNWFilterDeleteDef(const char *configDir,
|
virNWFilterDeleteDef(const char *configDir,
|
||||||
virNWFilterDef *def)
|
virNWFilterDef *def)
|
||||||
{
|
{
|
||||||
int ret = -1;
|
g_autofree char *configFile = NULL;
|
||||||
char *configFile = NULL;
|
|
||||||
|
|
||||||
if (!(configFile = virFileBuildPath(configDir, def->name, ".xml")))
|
if (!(configFile = virFileBuildPath(configDir, def->name, ".xml")))
|
||||||
goto error;
|
return -1;
|
||||||
|
|
||||||
if (unlink(configFile) < 0) {
|
if (unlink(configFile) < 0) {
|
||||||
virReportError(VIR_ERR_INTERNAL_ERROR,
|
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||||
_("cannot remove config for %s"),
|
_("cannot remove config for %s"),
|
||||||
def->name);
|
def->name);
|
||||||
goto error;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = 0;
|
return 0;
|
||||||
error:
|
|
||||||
VIR_FREE(configFile);
|
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -260,8 +260,7 @@ virNetworkObjMacMgrAdd(virNetworkObj *obj,
|
|||||||
const virMacAddr *mac)
|
const virMacAddr *mac)
|
||||||
{
|
{
|
||||||
char macStr[VIR_MAC_STRING_BUFLEN];
|
char macStr[VIR_MAC_STRING_BUFLEN];
|
||||||
char *file = NULL;
|
g_autofree char *file = NULL;
|
||||||
int ret = -1;
|
|
||||||
|
|
||||||
if (!obj->macmap)
|
if (!obj->macmap)
|
||||||
return 0;
|
return 0;
|
||||||
@ -269,18 +268,15 @@ virNetworkObjMacMgrAdd(virNetworkObj *obj,
|
|||||||
virMacAddrFormat(mac, macStr);
|
virMacAddrFormat(mac, macStr);
|
||||||
|
|
||||||
if (!(file = virMacMapFileName(dnsmasqStateDir, obj->def->bridge)))
|
if (!(file = virMacMapFileName(dnsmasqStateDir, obj->def->bridge)))
|
||||||
goto cleanup;
|
return -1;
|
||||||
|
|
||||||
if (virMacMapAdd(obj->macmap, domain, macStr) < 0)
|
if (virMacMapAdd(obj->macmap, domain, macStr) < 0)
|
||||||
goto cleanup;
|
return -1;
|
||||||
|
|
||||||
if (virMacMapWriteFile(obj->macmap, file) < 0)
|
if (virMacMapWriteFile(obj->macmap, file) < 0)
|
||||||
goto cleanup;
|
return -1;
|
||||||
|
|
||||||
ret = 0;
|
return 0;
|
||||||
cleanup:
|
|
||||||
VIR_FREE(file);
|
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -291,8 +287,7 @@ virNetworkObjMacMgrDel(virNetworkObj *obj,
|
|||||||
const virMacAddr *mac)
|
const virMacAddr *mac)
|
||||||
{
|
{
|
||||||
char macStr[VIR_MAC_STRING_BUFLEN];
|
char macStr[VIR_MAC_STRING_BUFLEN];
|
||||||
char *file = NULL;
|
g_autofree char *file = NULL;
|
||||||
int ret = -1;
|
|
||||||
|
|
||||||
if (!obj->macmap)
|
if (!obj->macmap)
|
||||||
return 0;
|
return 0;
|
||||||
@ -300,18 +295,15 @@ virNetworkObjMacMgrDel(virNetworkObj *obj,
|
|||||||
virMacAddrFormat(mac, macStr);
|
virMacAddrFormat(mac, macStr);
|
||||||
|
|
||||||
if (!(file = virMacMapFileName(dnsmasqStateDir, obj->def->bridge)))
|
if (!(file = virMacMapFileName(dnsmasqStateDir, obj->def->bridge)))
|
||||||
goto cleanup;
|
return -1;
|
||||||
|
|
||||||
if (virMacMapRemove(obj->macmap, domain, macStr) < 0)
|
if (virMacMapRemove(obj->macmap, domain, macStr) < 0)
|
||||||
goto cleanup;
|
return -1;
|
||||||
|
|
||||||
if (virMacMapWriteFile(obj->macmap, file) < 0)
|
if (virMacMapWriteFile(obj->macmap, file) < 0)
|
||||||
goto cleanup;
|
return -1;
|
||||||
|
|
||||||
ret = 0;
|
return 0;
|
||||||
cleanup:
|
|
||||||
VIR_FREE(file);
|
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -819,20 +811,16 @@ virNetworkObjSaveStatus(const char *statusDir,
|
|||||||
virNetworkObj *obj,
|
virNetworkObj *obj,
|
||||||
virNetworkXMLOption *xmlopt)
|
virNetworkXMLOption *xmlopt)
|
||||||
{
|
{
|
||||||
int ret = -1;
|
|
||||||
int flags = 0;
|
int flags = 0;
|
||||||
char *xml;
|
g_autofree char *xml = NULL;
|
||||||
|
|
||||||
if (!(xml = virNetworkObjFormat(obj, xmlopt, flags)))
|
if (!(xml = virNetworkObjFormat(obj, xmlopt, flags)))
|
||||||
goto cleanup;
|
return -1;
|
||||||
|
|
||||||
if (virNetworkSaveXML(statusDir, obj->def, xml))
|
if (virNetworkSaveXML(statusDir, obj->def, xml))
|
||||||
goto cleanup;
|
return -1;
|
||||||
|
|
||||||
ret = 0;
|
return 0;
|
||||||
cleanup:
|
|
||||||
VIR_FREE(xml);
|
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -953,29 +941,30 @@ virNetworkLoadConfig(virNetworkObjList *nets,
|
|||||||
const char *name,
|
const char *name,
|
||||||
virNetworkXMLOption *xmlopt)
|
virNetworkXMLOption *xmlopt)
|
||||||
{
|
{
|
||||||
char *configFile = NULL, *autostartLink = NULL;
|
g_autofree char *configFile = NULL;
|
||||||
|
g_autofree char *autostartLink = NULL;
|
||||||
g_autoptr(virNetworkDef) def = NULL;
|
g_autoptr(virNetworkDef) def = NULL;
|
||||||
virNetworkObj *obj;
|
virNetworkObj *obj;
|
||||||
bool saveConfig = false;
|
bool saveConfig = false;
|
||||||
int autostart;
|
int autostart;
|
||||||
|
|
||||||
if ((configFile = virNetworkConfigFile(configDir, name)) == NULL)
|
if ((configFile = virNetworkConfigFile(configDir, name)) == NULL)
|
||||||
goto error;
|
return NULL;
|
||||||
if ((autostartLink = virNetworkConfigFile(autostartDir, name)) == NULL)
|
if ((autostartLink = virNetworkConfigFile(autostartDir, name)) == NULL)
|
||||||
goto error;
|
return NULL;
|
||||||
|
|
||||||
if ((autostart = virFileLinkPointsTo(autostartLink, configFile)) < 0)
|
if ((autostart = virFileLinkPointsTo(autostartLink, configFile)) < 0)
|
||||||
goto error;
|
return NULL;
|
||||||
|
|
||||||
if (!(def = virNetworkDefParse(NULL, configFile, xmlopt, false)))
|
if (!(def = virNetworkDefParse(NULL, configFile, xmlopt, false)))
|
||||||
goto error;
|
return NULL;
|
||||||
|
|
||||||
if (STRNEQ(name, def->name)) {
|
if (STRNEQ(name, def->name)) {
|
||||||
virReportError(VIR_ERR_INTERNAL_ERROR,
|
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||||
_("Network config filename '%s'"
|
_("Network config filename '%s'"
|
||||||
" does not match network name '%s'"),
|
" does not match network name '%s'"),
|
||||||
configFile, def->name);
|
configFile, def->name);
|
||||||
goto error;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
switch ((virNetworkForwardType) def->forward.type) {
|
switch ((virNetworkForwardType) def->forward.type) {
|
||||||
@ -1005,7 +994,7 @@ virNetworkLoadConfig(virNetworkObjList *nets,
|
|||||||
case VIR_NETWORK_FORWARD_LAST:
|
case VIR_NETWORK_FORWARD_LAST:
|
||||||
default:
|
default:
|
||||||
virReportEnumRangeError(virNetworkForwardType, def->forward.type);
|
virReportEnumRangeError(virNetworkForwardType, def->forward.type);
|
||||||
goto error;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* The network didn't have a UUID so we generated a new one, and
|
/* The network didn't have a UUID so we generated a new one, and
|
||||||
@ -1016,25 +1005,17 @@ virNetworkLoadConfig(virNetworkObjList *nets,
|
|||||||
|
|
||||||
if (saveConfig &&
|
if (saveConfig &&
|
||||||
virNetworkSaveConfig(configDir, def, xmlopt) < 0) {
|
virNetworkSaveConfig(configDir, def, xmlopt) < 0) {
|
||||||
goto error;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!(obj = virNetworkObjAssignDef(nets, def, 0)))
|
if (!(obj = virNetworkObjAssignDef(nets, def, 0)))
|
||||||
goto error;
|
return NULL;
|
||||||
|
|
||||||
def = NULL;
|
def = NULL;
|
||||||
|
|
||||||
obj->autostart = (autostart == 1);
|
obj->autostart = (autostart == 1);
|
||||||
|
|
||||||
VIR_FREE(configFile);
|
|
||||||
VIR_FREE(autostartLink);
|
|
||||||
|
|
||||||
return obj;
|
return obj;
|
||||||
|
|
||||||
error:
|
|
||||||
VIR_FREE(configFile);
|
|
||||||
VIR_FREE(autostartLink);
|
|
||||||
return NULL;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -1110,14 +1091,13 @@ virNetworkObjDeleteConfig(const char *configDir,
|
|||||||
const char *autostartDir,
|
const char *autostartDir,
|
||||||
virNetworkObj *obj)
|
virNetworkObj *obj)
|
||||||
{
|
{
|
||||||
char *configFile = NULL;
|
g_autofree char *configFile = NULL;
|
||||||
char *autostartLink = NULL;
|
g_autofree char *autostartLink = NULL;
|
||||||
int ret = -1;
|
|
||||||
|
|
||||||
if (!(configFile = virNetworkConfigFile(configDir, obj->def->name)))
|
if (!(configFile = virNetworkConfigFile(configDir, obj->def->name)))
|
||||||
goto error;
|
return -1;
|
||||||
if (!(autostartLink = virNetworkConfigFile(autostartDir, obj->def->name)))
|
if (!(autostartLink = virNetworkConfigFile(autostartDir, obj->def->name)))
|
||||||
goto error;
|
return -1;
|
||||||
|
|
||||||
/* Not fatal if this doesn't work */
|
/* Not fatal if this doesn't work */
|
||||||
unlink(autostartLink);
|
unlink(autostartLink);
|
||||||
@ -1127,15 +1107,10 @@ virNetworkObjDeleteConfig(const char *configDir,
|
|||||||
virReportSystemError(errno,
|
virReportSystemError(errno,
|
||||||
_("cannot remove config file '%s'"),
|
_("cannot remove config file '%s'"),
|
||||||
configFile);
|
configFile);
|
||||||
goto error;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = 0;
|
return 0;
|
||||||
|
|
||||||
error:
|
|
||||||
VIR_FREE(configFile);
|
|
||||||
VIR_FREE(autostartLink);
|
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -415,22 +415,18 @@ virNetworkPortDefDeleteStatus(virNetworkPortDef *def,
|
|||||||
const char *dir)
|
const char *dir)
|
||||||
{
|
{
|
||||||
char uuidstr[VIR_UUID_STRING_BUFLEN];
|
char uuidstr[VIR_UUID_STRING_BUFLEN];
|
||||||
char *path;
|
g_autofree char *path = NULL;
|
||||||
int ret = -1;
|
|
||||||
|
|
||||||
virUUIDFormat(def->uuid, uuidstr);
|
virUUIDFormat(def->uuid, uuidstr);
|
||||||
|
|
||||||
if (!(path = virNetworkPortDefConfigFile(dir, uuidstr)))
|
if (!(path = virNetworkPortDefConfigFile(dir, uuidstr)))
|
||||||
goto cleanup;
|
return -1;
|
||||||
|
|
||||||
if (unlink(path) < 0 && errno != ENOENT) {
|
if (unlink(path) < 0 && errno != ENOENT) {
|
||||||
virReportSystemError(errno,
|
virReportSystemError(errno,
|
||||||
_("Unable to delete %s"), path);
|
_("Unable to delete %s"), path);
|
||||||
goto cleanup;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = 0;
|
return 0;
|
||||||
cleanup:
|
|
||||||
VIR_FREE(path);
|
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
@ -146,8 +146,8 @@ int
|
|||||||
virNWFilterBindingObjSave(const virNWFilterBindingObj *obj,
|
virNWFilterBindingObjSave(const virNWFilterBindingObj *obj,
|
||||||
const char *statusDir)
|
const char *statusDir)
|
||||||
{
|
{
|
||||||
char *filename;
|
g_autofree char *filename = NULL;
|
||||||
char *xml = NULL;
|
g_autofree char *xml = NULL;
|
||||||
int ret = -1;
|
int ret = -1;
|
||||||
|
|
||||||
if (!(filename = virNWFilterBindingObjConfigFile(statusDir,
|
if (!(filename = virNWFilterBindingObjConfigFile(statusDir,
|
||||||
@ -155,22 +155,19 @@ virNWFilterBindingObjSave(const virNWFilterBindingObj *obj,
|
|||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
if (!(xml = virNWFilterBindingObjFormat(obj)))
|
if (!(xml = virNWFilterBindingObjFormat(obj)))
|
||||||
goto cleanup;
|
return -1;
|
||||||
|
|
||||||
if (g_mkdir_with_parents(statusDir, 0777) < 0) {
|
if (g_mkdir_with_parents(statusDir, 0777) < 0) {
|
||||||
virReportSystemError(errno,
|
virReportSystemError(errno,
|
||||||
_("cannot create config directory '%s'"),
|
_("cannot create config directory '%s'"),
|
||||||
statusDir);
|
statusDir);
|
||||||
goto cleanup;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = virXMLSaveFile(filename,
|
ret = virXMLSaveFile(filename,
|
||||||
obj->def->portdevname, "nwfilter-binding-create",
|
obj->def->portdevname, "nwfilter-binding-create",
|
||||||
xml);
|
xml);
|
||||||
|
|
||||||
cleanup:
|
|
||||||
VIR_FREE(xml);
|
|
||||||
VIR_FREE(filename);
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -179,8 +176,7 @@ int
|
|||||||
virNWFilterBindingObjDelete(const virNWFilterBindingObj *obj,
|
virNWFilterBindingObjDelete(const virNWFilterBindingObj *obj,
|
||||||
const char *statusDir)
|
const char *statusDir)
|
||||||
{
|
{
|
||||||
char *filename;
|
g_autofree char *filename = NULL;
|
||||||
int ret = -1;
|
|
||||||
|
|
||||||
if (!(filename = virNWFilterBindingObjConfigFile(statusDir,
|
if (!(filename = virNWFilterBindingObjConfigFile(statusDir,
|
||||||
obj->def->portdevname)))
|
obj->def->portdevname)))
|
||||||
@ -191,14 +187,10 @@ virNWFilterBindingObjDelete(const virNWFilterBindingObj *obj,
|
|||||||
virReportSystemError(errno,
|
virReportSystemError(errno,
|
||||||
_("Unable to remove status '%s' for nwfilter binding %s'"),
|
_("Unable to remove status '%s' for nwfilter binding %s'"),
|
||||||
filename, obj->def->portdevname);
|
filename, obj->def->portdevname);
|
||||||
goto cleanup;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = 0;
|
return 0;
|
||||||
|
|
||||||
cleanup:
|
|
||||||
VIR_FREE(filename);
|
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -281,21 +281,14 @@ static bool
|
|||||||
virNWFilterDefEqual(const virNWFilterDef *def1,
|
virNWFilterDefEqual(const virNWFilterDef *def1,
|
||||||
virNWFilterDef *def2)
|
virNWFilterDef *def2)
|
||||||
{
|
{
|
||||||
bool ret = false;
|
g_autofree char *xml1 = NULL;
|
||||||
char *xml1 = NULL;
|
g_autofree char *xml2 = NULL;
|
||||||
char *xml2 = NULL;
|
|
||||||
|
|
||||||
if (!(xml1 = virNWFilterDefFormat(def1)) ||
|
if (!(xml1 = virNWFilterDefFormat(def1)) ||
|
||||||
!(xml2 = virNWFilterDefFormat(def2)))
|
!(xml2 = virNWFilterDefFormat(def2)))
|
||||||
goto cleanup;
|
return false;
|
||||||
|
|
||||||
ret = STREQ(xml1, xml2);
|
return STREQ(xml1, xml2);
|
||||||
|
|
||||||
cleanup:
|
|
||||||
VIR_FREE(xml1);
|
|
||||||
VIR_FREE(xml2);
|
|
||||||
|
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -573,7 +566,7 @@ virNWFilterObjListLoadConfig(virNWFilterObjList *nwfilters,
|
|||||||
{
|
{
|
||||||
virNWFilterDef *def = NULL;
|
virNWFilterDef *def = NULL;
|
||||||
virNWFilterObj *obj;
|
virNWFilterObj *obj;
|
||||||
char *configFile = NULL;
|
g_autofree char *configFile = NULL;
|
||||||
|
|
||||||
if (!(configFile = virFileBuildPath(configDir, name, ".xml")))
|
if (!(configFile = virFileBuildPath(configDir, name, ".xml")))
|
||||||
goto error;
|
goto error;
|
||||||
@ -597,11 +590,9 @@ virNWFilterObjListLoadConfig(virNWFilterObjList *nwfilters,
|
|||||||
if (!(obj = virNWFilterObjListAssignDef(nwfilters, def)))
|
if (!(obj = virNWFilterObjListAssignDef(nwfilters, def)))
|
||||||
goto error;
|
goto error;
|
||||||
|
|
||||||
VIR_FREE(configFile);
|
|
||||||
return obj;
|
return obj;
|
||||||
|
|
||||||
error:
|
error:
|
||||||
VIR_FREE(configFile);
|
|
||||||
virNWFilterDefFree(def);
|
virNWFilterDefFree(def);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
@ -1088,9 +1088,8 @@ static int
|
|||||||
getSCSIHostNumber(virStorageAdapterSCSIHost *scsi_host,
|
getSCSIHostNumber(virStorageAdapterSCSIHost *scsi_host,
|
||||||
unsigned int *hostnum)
|
unsigned int *hostnum)
|
||||||
{
|
{
|
||||||
int ret = -1;
|
|
||||||
unsigned int num;
|
unsigned int num;
|
||||||
char *name = NULL;
|
g_autofree char *name = NULL;
|
||||||
|
|
||||||
if (scsi_host->has_parent) {
|
if (scsi_host->has_parent) {
|
||||||
virPCIDeviceAddress *addr = &scsi_host->parentaddr;
|
virPCIDeviceAddress *addr = &scsi_host->parentaddr;
|
||||||
@ -1101,20 +1100,17 @@ getSCSIHostNumber(virStorageAdapterSCSIHost *scsi_host,
|
|||||||
addr->slot,
|
addr->slot,
|
||||||
addr->function,
|
addr->function,
|
||||||
unique_id)))
|
unique_id)))
|
||||||
goto cleanup;
|
return -1;
|
||||||
if (virSCSIHostGetNumber(name, &num) < 0)
|
if (virSCSIHostGetNumber(name, &num) < 0)
|
||||||
goto cleanup;
|
return -1;
|
||||||
} else {
|
} else {
|
||||||
if (virSCSIHostGetNumber(scsi_host->name, &num) < 0)
|
if (virSCSIHostGetNumber(scsi_host->name, &num) < 0)
|
||||||
goto cleanup;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
*hostnum = num;
|
*hostnum = num;
|
||||||
ret = 0;
|
|
||||||
|
|
||||||
cleanup:
|
return 0;
|
||||||
VIR_FREE(name);
|
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -1147,9 +1143,9 @@ matchFCHostToSCSIHost(virStorageAdapterFCHost *fchost,
|
|||||||
{
|
{
|
||||||
virConnectPtr conn = NULL;
|
virConnectPtr conn = NULL;
|
||||||
bool ret = false;
|
bool ret = false;
|
||||||
char *name = NULL;
|
g_autofree char *name = NULL;
|
||||||
char *scsi_host_name = NULL;
|
g_autofree char *scsi_host_name = NULL;
|
||||||
char *parent_name = NULL;
|
g_autofree char *parent_name = NULL;
|
||||||
|
|
||||||
/* If we have a parent defined, get its hostnum, and compare to the
|
/* If we have a parent defined, get its hostnum, and compare to the
|
||||||
* scsi_hostnum. If they are the same, then we have a match
|
* scsi_hostnum. If they are the same, then we have a match
|
||||||
@ -1202,9 +1198,6 @@ matchFCHostToSCSIHost(virStorageAdapterFCHost *fchost,
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
cleanup:
|
cleanup:
|
||||||
VIR_FREE(name);
|
|
||||||
VIR_FREE(parent_name);
|
|
||||||
VIR_FREE(scsi_host_name);
|
|
||||||
virConnectClose(conn);
|
virConnectClose(conn);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user