Skip to content

Commit

Permalink
Refactor TPM handling logic
Browse files Browse the repository at this point in the history
  • Loading branch information
Shotaro-Kawaguchi committed Oct 23, 2024
1 parent e378412 commit fb5bf9e
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/components/vm/vmActions.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -457,7 +457,7 @@ const VmActions = ({ vm, vms, onAddErrorNotification, isDetailsPage }) => {
dropdownItems.push(<Divider key="separator-rename" />);
}

if (!Object.keys(vm.tpm).length) {
if (!vm.tpm) {
dropdownItems.push(
<DropdownItem key={`${id}-add-tpm`}
id={`${id}-add-tpm`}
Expand Down
7 changes: 4 additions & 3 deletions src/libvirt-xml-parse.js
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,8 @@ export function parseDomainDumpxml(connectionName, domXml, objPath) {
const watchdog = parseDumpxmlForWatchdog(devicesElem);
const vsock = parseDumpxmlForVsock(devicesElem);
const hasSpice = parseDumpxmlForSpice(devicesElem);
const { tpm, hasTPM } = parseDumpxmlForTPM(devicesElem);
const hasTPM = !!parseDumpxmlForTPM(devicesElem);
const tpm = parseDumpxmlForTPM(devicesElem);

const hasInstallPhase = parseDumpxmlMachinesMetadataElement(metadataElem, 'has_install_phase') === 'true';
const installSourceType = parseDumpxmlMachinesMetadataElement(metadataElem, 'install_source_type');
Expand Down Expand Up @@ -577,9 +578,9 @@ function parseDumpxmlForTPM(devicesElem) {
version,
devicePath,
};
return { tpm, hasTPM: true };
return tpm;
}
return { tpm: {}, hasTPM: false };
return null;
}

export function parseDumpxmlForFilesystems(devicesElem) {
Expand Down

0 comments on commit fb5bf9e

Please sign in to comment.