import libvirt, { DomainBuilder, domainDescToXml, domainDescFromXml, } from "../dist"; (async () => { const uri = process.env.LIBVIRT_URI || "qemu:///system"; const hypervisor = new libvirt.Hypervisor({ uri }); await hypervisor.connectOpen(); const template = await domainDescFromXml( ` 1048576 1048576 1 hvm /usr/bin/qemu-system-x86_64 `); const domain = new DomainBuilder() .fromTemplate(template) .setName("test1") .setUUID("148d0864-2354-4c27-b82c-731bdd3f320c") .addDisk({ type: "file", device: "disk", driver: { name: "qemu", type: "qcow2" }, source: { file: "/home/leon/test1.img" }, target: { dev: "vda", bus: "virtio" }, }) .addInterface({ type: "network", source: { network: "default" }, mac: { address: "52:54:00:8e:c6:5f" }, model: { type: "virtio" }, }) .build(); const xml = domainDescToXml(domain); await hypervisor.domainDefineXML(xml); })();