mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-03-20 07:59:00 +00:00
qemu: command: Use 'qemuBuildChrChardevCommand' to build TPM backend
Since the backend of the TPM is a chardev we can use the common helper to instantiate it. This commit also ensures proper ordering so that the backend chardev is formatted before it's being referenced. Signed-off-by: Peter Krempa <pkrempa@redhat.com> Reviewed-by: Ján Tomko <jtomko@redhat.com>
This commit is contained in:
parent
5c62df7e78
commit
1ee3314c10
@ -9734,8 +9734,7 @@ static char *
|
|||||||
qemuBuildTPMBackendStr(virCommand *cmd,
|
qemuBuildTPMBackendStr(virCommand *cmd,
|
||||||
virDomainTPMDef *tpm,
|
virDomainTPMDef *tpm,
|
||||||
int *tpmfd,
|
int *tpmfd,
|
||||||
int *cancelfd,
|
int *cancelfd)
|
||||||
char **chardev)
|
|
||||||
{
|
{
|
||||||
g_auto(virBuffer) buf = VIR_BUFFER_INITIALIZER;
|
g_auto(virBuffer) buf = VIR_BUFFER_INITIALIZER;
|
||||||
g_autofree char *cancel_path = NULL;
|
g_autofree char *cancel_path = NULL;
|
||||||
@ -9774,10 +9773,6 @@ qemuBuildTPMBackendStr(virCommand *cmd,
|
|||||||
break;
|
break;
|
||||||
case VIR_DOMAIN_TPM_TYPE_EMULATOR:
|
case VIR_DOMAIN_TPM_TYPE_EMULATOR:
|
||||||
virBufferAddLit(&buf, ",chardev=chrtpm");
|
virBufferAddLit(&buf, ",chardev=chrtpm");
|
||||||
|
|
||||||
*chardev = g_strdup_printf("socket,id=chrtpm,path=%s",
|
|
||||||
tpm->data.emulator.source->data.nix.path);
|
|
||||||
|
|
||||||
break;
|
break;
|
||||||
case VIR_DOMAIN_TPM_TYPE_LAST:
|
case VIR_DOMAIN_TPM_TYPE_LAST:
|
||||||
return NULL;
|
return NULL;
|
||||||
@ -9793,22 +9788,20 @@ qemuBuildTPMCommandLine(virCommand *cmd,
|
|||||||
virDomainTPMDef *tpm,
|
virDomainTPMDef *tpm,
|
||||||
virQEMUCaps *qemuCaps)
|
virQEMUCaps *qemuCaps)
|
||||||
{
|
{
|
||||||
char *optstr;
|
g_autofree char *tpmdevstr = NULL;
|
||||||
g_autofree char *chardev = NULL;
|
|
||||||
int tpmfd = -1;
|
int tpmfd = -1;
|
||||||
int cancelfd = -1;
|
int cancelfd = -1;
|
||||||
char *fdset;
|
char *fdset;
|
||||||
|
|
||||||
if (!(optstr = qemuBuildTPMBackendStr(cmd, tpm,
|
if (tpm->type == VIR_DOMAIN_TPM_TYPE_EMULATOR) {
|
||||||
&tpmfd, &cancelfd,
|
if (qemuBuildChardevCommand(cmd, tpm->data.emulator.source, "chrtpm", qemuCaps) < 0)
|
||||||
&chardev)))
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!(tpmdevstr = qemuBuildTPMBackendStr(cmd, tpm, &tpmfd, &cancelfd)))
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
virCommandAddArgList(cmd, "-tpmdev", optstr, NULL);
|
virCommandAddArgList(cmd, "-tpmdev", tpmdevstr, NULL);
|
||||||
VIR_FREE(optstr);
|
|
||||||
|
|
||||||
if (chardev)
|
|
||||||
virCommandAddArgList(cmd, "-chardev", chardev, NULL);
|
|
||||||
|
|
||||||
if (tpmfd >= 0) {
|
if (tpmfd >= 0) {
|
||||||
fdset = qemuVirCommandGetFDSet(cmd, tpmfd);
|
fdset = qemuVirCommandGetFDSet(cmd, tpmfd);
|
||||||
|
@ -27,8 +27,8 @@ XDG_CONFIG_HOME=/tmp/lib/domain--1-aarch64test/.config \
|
|||||||
-no-shutdown \
|
-no-shutdown \
|
||||||
-no-acpi \
|
-no-acpi \
|
||||||
-boot strict=on \
|
-boot strict=on \
|
||||||
-tpmdev emulator,id=tpm-tpm0,chardev=chrtpm \
|
|
||||||
-chardev socket,id=chrtpm,path=/dev/test \
|
-chardev socket,id=chrtpm,path=/dev/test \
|
||||||
|
-tpmdev emulator,id=tpm-tpm0,chardev=chrtpm \
|
||||||
-device '{"driver":"tpm-tis-device","tpmdev":"tpm-tpm0","id":"tpm0"}' \
|
-device '{"driver":"tpm-tis-device","tpmdev":"tpm-tpm0","id":"tpm0"}' \
|
||||||
-audiodev '{"id":"audio1","driver":"none"}' \
|
-audiodev '{"id":"audio1","driver":"none"}' \
|
||||||
-sandbox on,obsolete=deny,elevateprivileges=deny,spawn=deny,resourcecontrol=deny \
|
-sandbox on,obsolete=deny,elevateprivileges=deny,spawn=deny,resourcecontrol=deny \
|
||||||
|
@ -28,8 +28,8 @@ XDG_CONFIG_HOME=/tmp/lib/domain--1-QEMUGuest1/.config \
|
|||||||
-boot strict=on \
|
-boot strict=on \
|
||||||
-device '{"driver":"pci-ohci","id":"usb","bus":"pci.0","addr":"0x1"}' \
|
-device '{"driver":"pci-ohci","id":"usb","bus":"pci.0","addr":"0x1"}' \
|
||||||
-device '{"driver":"spapr-tpm-proxy","id":"tpm0","host-path":"/dev/tpmrm0"}' \
|
-device '{"driver":"spapr-tpm-proxy","id":"tpm0","host-path":"/dev/tpmrm0"}' \
|
||||||
-tpmdev emulator,id=tpm-tpm1,chardev=chrtpm \
|
|
||||||
-chardev socket,id=chrtpm,path=/dev/test \
|
-chardev socket,id=chrtpm,path=/dev/test \
|
||||||
|
-tpmdev emulator,id=tpm-tpm1,chardev=chrtpm \
|
||||||
-device '{"driver":"tpm-spapr","tpmdev":"tpm-tpm1","id":"tpm1","reg":16384}' \
|
-device '{"driver":"tpm-spapr","tpmdev":"tpm-tpm1","id":"tpm1","reg":16384}' \
|
||||||
-audiodev '{"id":"audio1","driver":"none"}' \
|
-audiodev '{"id":"audio1","driver":"none"}' \
|
||||||
-device '{"driver":"virtio-balloon-pci","id":"balloon0","bus":"pci.0","addr":"0x6"}' \
|
-device '{"driver":"virtio-balloon-pci","id":"balloon0","bus":"pci.0","addr":"0x6"}' \
|
||||||
|
@ -36,8 +36,8 @@ XDG_CONFIG_HOME=/tmp/lib/domain--1-TPM-VM/.config \
|
|||||||
-device '{"driver":"spapr-vty","chardev":"charserial0","id":"serial0","reg":805306368}' \
|
-device '{"driver":"spapr-vty","chardev":"charserial0","id":"serial0","reg":805306368}' \
|
||||||
-chardev pty,id=charserial1 \
|
-chardev pty,id=charserial1 \
|
||||||
-device '{"driver":"spapr-vty","chardev":"charserial1","id":"serial1","reg":805310464}' \
|
-device '{"driver":"spapr-vty","chardev":"charserial1","id":"serial1","reg":805310464}' \
|
||||||
-tpmdev emulator,id=tpm-tpm0,chardev=chrtpm \
|
|
||||||
-chardev socket,id=chrtpm,path=/dev/test \
|
-chardev socket,id=chrtpm,path=/dev/test \
|
||||||
|
-tpmdev emulator,id=tpm-tpm0,chardev=chrtpm \
|
||||||
-device '{"driver":"tpm-spapr","tpmdev":"tpm-tpm0","id":"tpm0","reg":20480}' \
|
-device '{"driver":"tpm-spapr","tpmdev":"tpm-tpm0","id":"tpm0","reg":20480}' \
|
||||||
-audiodev '{"id":"audio1","driver":"none"}' \
|
-audiodev '{"id":"audio1","driver":"none"}' \
|
||||||
-global spapr-nvram.reg=0x4000 \
|
-global spapr-nvram.reg=0x4000 \
|
||||||
|
@ -27,8 +27,8 @@ XDG_CONFIG_HOME=/tmp/lib/domain--1-TPM-VM/.config \
|
|||||||
-no-shutdown \
|
-no-shutdown \
|
||||||
-boot menu=on,strict=on \
|
-boot menu=on,strict=on \
|
||||||
-device '{"driver":"piix3-usb-uhci","id":"usb","bus":"pci.0","addr":"0x1.0x2"}' \
|
-device '{"driver":"piix3-usb-uhci","id":"usb","bus":"pci.0","addr":"0x1.0x2"}' \
|
||||||
-tpmdev emulator,id=tpm-tpm0,chardev=chrtpm \
|
|
||||||
-chardev socket,id=chrtpm,path=/dev/test \
|
-chardev socket,id=chrtpm,path=/dev/test \
|
||||||
|
-tpmdev emulator,id=tpm-tpm0,chardev=chrtpm \
|
||||||
-device '{"driver":"tpm-tis","tpmdev":"tpm-tpm0","id":"tpm0"}' \
|
-device '{"driver":"tpm-tis","tpmdev":"tpm-tpm0","id":"tpm0"}' \
|
||||||
-audiodev '{"id":"audio1","driver":"none"}' \
|
-audiodev '{"id":"audio1","driver":"none"}' \
|
||||||
-device '{"driver":"virtio-balloon-pci","id":"balloon0","bus":"pci.0","addr":"0x2"}' \
|
-device '{"driver":"virtio-balloon-pci","id":"balloon0","bus":"pci.0","addr":"0x2"}' \
|
||||||
|
@ -27,8 +27,8 @@ XDG_CONFIG_HOME=/tmp/lib/domain--1-TPM-VM/.config \
|
|||||||
-no-shutdown \
|
-no-shutdown \
|
||||||
-boot menu=on,strict=on \
|
-boot menu=on,strict=on \
|
||||||
-device '{"driver":"piix3-usb-uhci","id":"usb","bus":"pci.0","addr":"0x1.0x2"}' \
|
-device '{"driver":"piix3-usb-uhci","id":"usb","bus":"pci.0","addr":"0x1.0x2"}' \
|
||||||
-tpmdev emulator,id=tpm-tpm0,chardev=chrtpm \
|
|
||||||
-chardev socket,id=chrtpm,path=/dev/test \
|
-chardev socket,id=chrtpm,path=/dev/test \
|
||||||
|
-tpmdev emulator,id=tpm-tpm0,chardev=chrtpm \
|
||||||
-device '{"driver":"tpm-tis","tpmdev":"tpm-tpm0","id":"tpm0"}' \
|
-device '{"driver":"tpm-tis","tpmdev":"tpm-tpm0","id":"tpm0"}' \
|
||||||
-audiodev '{"id":"audio1","driver":"none"}' \
|
-audiodev '{"id":"audio1","driver":"none"}' \
|
||||||
-device '{"driver":"virtio-balloon-pci","id":"balloon0","bus":"pci.0","addr":"0x2"}' \
|
-device '{"driver":"virtio-balloon-pci","id":"balloon0","bus":"pci.0","addr":"0x2"}' \
|
||||||
|
@ -27,8 +27,8 @@ XDG_CONFIG_HOME=/tmp/lib/domain--1-TPM-VM/.config \
|
|||||||
-no-shutdown \
|
-no-shutdown \
|
||||||
-boot menu=on,strict=on \
|
-boot menu=on,strict=on \
|
||||||
-device '{"driver":"piix3-usb-uhci","id":"usb","bus":"pci.0","addr":"0x1.0x2"}' \
|
-device '{"driver":"piix3-usb-uhci","id":"usb","bus":"pci.0","addr":"0x1.0x2"}' \
|
||||||
-tpmdev emulator,id=tpm-tpm0,chardev=chrtpm \
|
|
||||||
-chardev socket,id=chrtpm,path=/dev/test \
|
-chardev socket,id=chrtpm,path=/dev/test \
|
||||||
|
-tpmdev emulator,id=tpm-tpm0,chardev=chrtpm \
|
||||||
-device '{"driver":"tpm-tis","tpmdev":"tpm-tpm0","id":"tpm0"}' \
|
-device '{"driver":"tpm-tis","tpmdev":"tpm-tpm0","id":"tpm0"}' \
|
||||||
-audiodev '{"id":"audio1","driver":"none"}' \
|
-audiodev '{"id":"audio1","driver":"none"}' \
|
||||||
-device '{"driver":"virtio-balloon-pci","id":"balloon0","bus":"pci.0","addr":"0x2"}' \
|
-device '{"driver":"virtio-balloon-pci","id":"balloon0","bus":"pci.0","addr":"0x2"}' \
|
||||||
|
@ -27,8 +27,8 @@ XDG_CONFIG_HOME=/tmp/lib/domain--1-TPM-VM/.config \
|
|||||||
-no-shutdown \
|
-no-shutdown \
|
||||||
-boot menu=on,strict=on \
|
-boot menu=on,strict=on \
|
||||||
-device '{"driver":"piix3-usb-uhci","id":"usb","bus":"pci.0","addr":"0x1.0x2"}' \
|
-device '{"driver":"piix3-usb-uhci","id":"usb","bus":"pci.0","addr":"0x1.0x2"}' \
|
||||||
-tpmdev emulator,id=tpm-tpm0,chardev=chrtpm \
|
|
||||||
-chardev socket,id=chrtpm,path=/dev/test \
|
-chardev socket,id=chrtpm,path=/dev/test \
|
||||||
|
-tpmdev emulator,id=tpm-tpm0,chardev=chrtpm \
|
||||||
-device '{"driver":"tpm-tis","tpmdev":"tpm-tpm0","id":"tpm0"}' \
|
-device '{"driver":"tpm-tis","tpmdev":"tpm-tpm0","id":"tpm0"}' \
|
||||||
-audiodev '{"id":"audio1","driver":"none"}' \
|
-audiodev '{"id":"audio1","driver":"none"}' \
|
||||||
-device '{"driver":"virtio-balloon-pci","id":"balloon0","bus":"pci.0","addr":"0x2"}' \
|
-device '{"driver":"virtio-balloon-pci","id":"balloon0","bus":"pci.0","addr":"0x2"}' \
|
||||||
|
Loading…
x
Reference in New Issue
Block a user