XenAPI.Session session = new XenAPI.Session(new Uri("https://xenserver.example.com"), "username", "password", false); XenAPI.Host host = XenAPI.Host.get_by_name_label(session, "Host1")[0]; XenAPI.VM template = XenAPI.VM.get_by_name_label(session, "Windows 10 x64 Template")[0]; XenAPI.VM newVM = template.create_clone(session, "My New VM"); newVM.set_memory_limits(session, 2048L * 1024L * 1024L, 4096L * 1024L * 1024L, 4096L * 1024L * 1024L); newVM.set_VCPUs_max(session, 2); newVM.set_VCPUs_at_startup(session, 2); newVM.set_affinity(session, new List() { host }); newVM.provision(session);
XenAPI.Session session = new XenAPI.Session(new Uri("https://xenserver.example.com"), "username", "password", false); XenAPI.VM myVM = XenAPI.VM.get_by_name_label(session, "My VM")[0]; myVM.start(session, false, false);This example shows how to use XenAPI VM to start a virtual machine. The `start()` method takes two boolean parameters: `startPaused` specifies whether the VM should start paused, and `force` specifies whether to forcefully start the VM even if other VMs are already running on the host. Package library: XenAPI VM is part of the XenServer API, which is distributed as part of the XenServer installation package.