February 7, 20215 yr Does Unraid have any plugin or functionality to create and configure VM programatically? I need to create system where virtual machines are created on demand .
February 7, 20215 yr Not that I'm aware of. You could look at some of spaceinvader one's recent work, he is doing something along the same idea.
February 11, 20215 yr On 2/7/2021 at 9:58 PM, moke said: Does Unraid have any plugin or functionality to create and configure VM programatically? I need to create system where virtual machines are created on demand . You can create an XML and pass that into virsh to create VMs and destroy them. https://libvirt.org/manpages/virsh.html Edited February 11, 20215 yr by SimonF
February 12, 20215 yr function virsh_device_by_bus($action, $vmname, $usbbus, $usbdev) { $usbstr = ''; if (!empty($usbbus)) { $usbbus=ltrim($usbbus, "0"); $usbdev=ltrim($usbdev, "0") ; $usbstr .= "<hostdev mode='subsystem' type='usb'> <source> <address bus='${usbbus}' device='${usbdev}' /> </source> </hostdev>"; } $filename = '/tmp/libvirthotplugusbbybus'.$vmname.'.xml'; file_put_contents($filename,$usbstr); return shell_exec("/usr/sbin/virsh $action-device '$vmname' '".$filename."' 2>&1"); #echo "Running virsh ${COMMAND} ${DOMAIN} for USB bus=${BUSNUM} device=${DEVNUM}:" >&2 #virsh "${COMMAND}" "${DOMAIN}" /dev/stdin <<END #<hostdev mode='subsystem' type='usb'> # <source> # <address bus='${BUSNUM}' device='${DEVNUM}' /> # </source> #</hostdev> #END } Here is some PHP code that I use for hotplugging USB devices into a VM.
February 12, 20215 yr Author 5 hours ago, SimonF said: ...... Here is some PHP code that I use for hotplugging USB devices into a VM. Thanks a lot. That gives me the start I need. Does Unraid detect these virsh created machines and show them in server UI?
Archived
This topic is now archived and is closed to further replies.