mirror of
https://github.com/libvirt/libvirt.git
synced 2026-09-03 20:53:04 -05:00
conf: Clean up and report error in virDomainGenerateMachineName
Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
This commit is contained in:
@@ -27481,25 +27481,23 @@ virDomainGenerateMachineName(const char *drivername,
|
|||||||
const char *name,
|
const char *name,
|
||||||
bool privileged)
|
bool privileged)
|
||||||
{
|
{
|
||||||
char *machinename = NULL;
|
|
||||||
char *username = NULL;
|
char *username = NULL;
|
||||||
virBuffer buf = VIR_BUFFER_INITIALIZER;
|
virBuffer buf = VIR_BUFFER_INITIALIZER;
|
||||||
|
|
||||||
if (privileged) {
|
if (privileged) {
|
||||||
virBufferAsprintf(&buf, "%s-", drivername);
|
virBufferAsprintf(&buf, "%s-", drivername);
|
||||||
} else {
|
} else {
|
||||||
if (!(username = virGetUserName(geteuid())))
|
if (!(username = virGetUserName(geteuid()))) {
|
||||||
goto cleanup;
|
virBufferFreeAndReset(&buf);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
virBufferAsprintf(&buf, "%s-%s-", username, drivername);
|
virBufferAsprintf(&buf, "%s-%s-", username, drivername);
|
||||||
|
VIR_FREE(username);
|
||||||
}
|
}
|
||||||
|
|
||||||
virBufferAsprintf(&buf, "%d-", id);
|
virBufferAsprintf(&buf, "%d-", id);
|
||||||
virDomainMachineNameAppendValid(&buf, name);
|
virDomainMachineNameAppendValid(&buf, name);
|
||||||
|
|
||||||
machinename = virBufferContentAndReset(&buf);
|
virBufferCheckError(&buf);
|
||||||
cleanup:
|
return virBufferContentAndReset(&buf);
|
||||||
VIR_FREE(username);
|
|
||||||
|
|
||||||
return machinename;
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user