UNPKG

@sentry0/qemu-hook-manager

Version:
2 lines (1 loc) 541 B
import{EOL as e}from"os";import{asyncExec as n}from"../../index.js";import{logger as a}from"./logger.js";export const VIRSH="virsh";const c=async t=>{if(/^[A-Za-z0-9_\.\+\-&:/]*$/.test(t)===!1)return a.error(`Domain ${t} contains invalid characters`),!1;const r=[VIRSH,"domstate",t];try{return await n(r.join(" ")),!0}catch{return!1}},i=async()=>{const t=[VIRSH,"list","--all","--name"],{stdout:r,stderr:o}=await n(t.join(" "));if(o)throw new Error(o);return r.split(e).filter(s=>s.length>0)};export{c as domainExists,i as fetchAllDomains};