switch (tpm->type) {
case VIR_DOMAIN_TPM_TYPE_PASSTHROUGH:
- path = tpm->data.passthrough.source.data.file.path;
+ path = tpm->data.passthrough.source->data.file.path;
if (!(device = virAuditEncode("device", VIR_AUDIT_STR(path)))) {
VIR_WARN("OOM while encoding audit message");
goto cleanup;
virt, reason, vmname, uuidstr, device);
break;
case VIR_DOMAIN_TPM_TYPE_EMULATOR:
- path = tpm->data.emulator.source.data.nix.path;
+ path = tpm->data.emulator.source->data.nix.path;
if (!(device = virAuditEncode("device", VIR_AUDIT_STR(path)))) {
VIR_WARN("OOM while encoding audit message");
goto cleanup;
switch (def->type) {
case VIR_DOMAIN_TPM_TYPE_PASSTHROUGH:
- virDomainChrSourceDefClear(&def->data.passthrough.source);
+ virObjectUnref(def->data.passthrough.source);
break;
case VIR_DOMAIN_TPM_TYPE_EMULATOR:
- virDomainChrSourceDefClear(&def->data.emulator.source);
+ virObjectUnref(def->data.emulator.source);
g_free(def->data.emulator.storagepath);
g_free(def->data.emulator.logfile);
break;
switch (def->type) {
case VIR_DOMAIN_TPM_TYPE_PASSTHROUGH:
+ if (!(def->data.passthrough.source = virDomainChrSourceDefNew(xmlopt)))
+ goto error;
path = virXPathString("string(./backend/device/@path)", ctxt);
if (!path)
path = g_strdup(VIR_DOMAIN_TPM_DEFAULT_DEVICE);
- def->data.passthrough.source.data.file.path = g_steal_pointer(&path);
- def->data.passthrough.source.type = VIR_DOMAIN_CHR_TYPE_DEV;
+ def->data.passthrough.source->type = VIR_DOMAIN_CHR_TYPE_DEV;
+ def->data.passthrough.source->data.file.path = g_steal_pointer(&path);
break;
case VIR_DOMAIN_TPM_TYPE_EMULATOR:
+ if (!(def->data.emulator.source = virDomainChrSourceDefNew(xmlopt)))
+ goto error;
secretuuid = virXPathString("string(./backend/encryption/@secret)", ctxt);
if (secretuuid) {
if (virUUIDParse(secretuuid, def->data.emulator.secretuuid) < 0) {
virBufferAddLit(buf, ">\n");
virBufferAdjustIndent(buf, 2);
virBufferEscapeString(buf, "<device path='%s'/>\n",
- def->data.passthrough.source.data.file.path);
+ def->data.passthrough.source->data.file.path);
virBufferAdjustIndent(buf, -2);
virBufferAddLit(buf, "</backend>\n");
break;
int version; /* virDomainTPMVersion */
union {
struct {
- virDomainChrSourceDef source;
+ virDomainChrSourceDef *source;
} passthrough;
struct {
- virDomainChrSourceDef source;
+ virDomainChrSourceDef *source;
char *storagepath;
char *logfile;
unsigned char secretuuid[VIR_UUID_BUFLEN];
switch (dev->type) {
case VIR_DOMAIN_TPM_TYPE_PASSTHROUGH:
- ret = qemuSetupChrSourceCgroup(vm, &dev->data.passthrough.source);
+ ret = qemuSetupChrSourceCgroup(vm, dev->data.passthrough.source);
break;
case VIR_DOMAIN_TPM_TYPE_EMULATOR:
case VIR_DOMAIN_TPM_TYPE_LAST:
switch (tpm->type) {
case VIR_DOMAIN_TPM_TYPE_PASSTHROUGH:
- tpmdev = tpm->data.passthrough.source.data.file.path;
+ tpmdev = tpm->data.passthrough.source->data.file.path;
if (!(cancel_path = virTPMCreateCancelPath(tpmdev)))
return NULL;
virBufferAddLit(&buf, ",chardev=chrtpm");
*chardev = g_strdup_printf("socket,id=chrtpm,path=%s",
- tpm->data.emulator.source.data.nix.path);
+ tpm->data.emulator.source->data.nix.path);
break;
case VIR_DOMAIN_TPM_TYPE_LAST:
if (virJSONValueObjectAdd(&props,
"s:driver", virDomainTPMModelTypeToString(tpm->model),
"s:id", tpm->info.alias,
- "s:host-path", tpm->data.passthrough.source.data.file.path,
+ "s:host-path", tpm->data.passthrough.source->data.file.path,
NULL) < 0)
return -1;
{
switch (dev->type) {
case VIR_DOMAIN_TPM_TYPE_PASSTHROUGH:
- *paths = g_slist_prepend(*paths, g_strdup(dev->data.passthrough.source.data.file.path));
+ *paths = g_slist_prepend(*paths, g_strdup(dev->data.passthrough.source->data.file.path));
break;
case VIR_DOMAIN_TPM_TYPE_EMULATOR:
return -1;
/* create the socket filename */
- if (!tpm->data.emulator.source.data.nix.path &&
- !(tpm->data.emulator.source.data.nix.path =
+ if (!tpm->data.emulator.source->data.nix.path &&
+ !(tpm->data.emulator.source->data.nix.path =
qemuTPMCreateEmulatorSocket(swtpmStateDir, shortName)))
return -1;
- tpm->data.emulator.source.type = VIR_DOMAIN_CHR_TYPE_UNIX;
+ tpm->data.emulator.source->type = VIR_DOMAIN_CHR_TYPE_UNIX;
return 0;
}
secretuuid) < 0)
goto error;
- unlink(tpm->data.emulator.source.data.nix.path);
+ unlink(tpm->data.emulator.source->data.nix.path);
cmd = virCommandNew(swtpm);
if (!cmd)
virCommandAddArgList(cmd, "socket", "--daemon", "--ctrl", NULL);
virCommandAddArgFormat(cmd, "type=unixio,path=%s,mode=0600",
- tpm->data.emulator.source.data.nix.path);
+ tpm->data.emulator.source->data.nix.path);
virCommandAddArg(cmd, "--tpmstate");
virCommandAddArgFormat(cmd, "dir=%s,mode=0600",
switch (tpm->type) {
case VIR_DOMAIN_TPM_TYPE_PASSTHROUGH:
ret = virSecurityDACSetChardevLabelHelper(mgr, def,
- &tpm->data.passthrough.source,
+ tpm->data.passthrough.source,
false, false);
break;
case VIR_DOMAIN_TPM_TYPE_EMULATOR:
ret = virSecurityDACSetChardevLabelHelper(mgr, def,
- &tpm->data.emulator.source,
+ tpm->data.emulator.source,
false, false);
break;
case VIR_DOMAIN_TPM_TYPE_LAST:
switch (tpm->type) {
case VIR_DOMAIN_TPM_TYPE_PASSTHROUGH:
ret = virSecurityDACRestoreChardevLabelHelper(mgr, def,
- &tpm->data.passthrough.source,
+ tpm->data.passthrough.source,
false, false);
break;
case VIR_DOMAIN_TPM_TYPE_EMULATOR:
switch (tpm->type) {
case VIR_DOMAIN_TPM_TYPE_PASSTHROUGH:
- tpmdev = tpm->data.passthrough.source.data.file.path;
+ tpmdev = tpm->data.passthrough.source->data.file.path;
rc = virSecuritySELinuxSetFilecon(mgr, tpmdev, seclabel->imagelabel, false);
if (rc < 0)
return -1;
}
break;
case VIR_DOMAIN_TPM_TYPE_EMULATOR:
- tpmdev = tpm->data.emulator.source.data.nix.path;
+ tpmdev = tpm->data.emulator.source->data.nix.path;
rc = virSecuritySELinuxSetFilecon(mgr, tpmdev, seclabel->imagelabel, false);
if (rc < 0)
return -1;
switch (tpm->type) {
case VIR_DOMAIN_TPM_TYPE_PASSTHROUGH:
- tpmdev = tpm->data.passthrough.source.data.file.path;
+ tpmdev = tpm->data.passthrough.source->data.file.path;
rc = virSecuritySELinuxRestoreFileLabel(mgr, tpmdev, false);
if ((cancel_path = virTPMCreateCancelPath(tpmdev)) != NULL) {
if (vm->def->tpms[i]->type != VIR_DOMAIN_TPM_TYPE_EMULATOR)
continue;
- VIR_FREE(vm->def->tpms[i]->data.emulator.source.data.file.path);
- vm->def->tpms[i]->data.emulator.source.data.file.path = g_strdup("/dev/test");
- vm->def->tpms[i]->data.emulator.source.type = VIR_DOMAIN_CHR_TYPE_FILE;
+ VIR_FREE(vm->def->tpms[i]->data.emulator.source->data.file.path);
+ vm->def->tpms[i]->data.emulator.source->data.file.path = g_strdup("/dev/test");
+ vm->def->tpms[i]->data.emulator.source->type = VIR_DOMAIN_CHR_TYPE_FILE;
}
for (i = 0; i < vm->def->nvideos; i++) {