UNPKG

@sentry0/qemu-hook-manager

Version:
2 lines (1 loc) 1.01 kB
import n from"chalk";import{fetchIommuGroups as r,fetchActiveDomains as l}from"./general.js";import{fetchAllDomains as m}from"./virsh.js";const u=t=>{const o=[],s=[...t.entries()].sort((e,i)=>e[0]-i[0]);for(const[e,i]of s){o.push({title:n.bold.cyan(`\u2500\u2500 IOMMU Group ${e} \u2500\u2500`),disabled:!0});for(const a of i){const c=a.pciAddress.replace(/^0000:/,"");o.push({title:` ${a.description}`,value:c,selected:!1})}}return o},p=async()=>{const t=await r(),o=await m(),s=await l();return[{type:"toggle",name:"useOwnHooks",message:"Will you use your own hooks?",initial:!1,active:"yes",inactive:"no"},{type:e=>e?"text":null,name:"hooksDir",message:"Enter the path to your hooks"},{type:"multiselect",name:"iommuGroups",message:"Select the hardware to toggle passthrough for",choices:u(t),min:1},{type:"multiselect",name:"domains",message:"Select a domain to toggle passthrough on or unselect to disable",choices:o.map(e=>({title:e,value:e,selected:s.includes(e)}))}]};export{p as buildQuestions};