public View_Model_To_Service(Libvirt.CS_Objects.Host con, Libvirt.Models.Concrete.Virtual_Machine d) { _Validation_Errors = new Dictionary <string, List <string> >(); Model_State = new Libvirt.Models.Concrete.Validator(_Validation_Errors); _Connection = con; _Machine_Definition = d; }
public Libvirt.Models.Concrete.Virtual_Machine virDomainGetXMLDesc(virDomainXMLFlags flags) { var vm = new Libvirt.Models.Concrete.Virtual_Machine(); vm.From_XML(System.Xml.Linq.XDocument.Parse(API.virDomainGetXMLDesc(_DomainPtr, flags)).Root); return(vm); }
public Boot(Libvirt.Models.Concrete.Virtual_Machine vm) { InitializeComponent(); this.Dock = DockStyle.Fill; _VM = vm; BuildInfo(); }
public Local_Media_Create(UserControl p, Libvirt.CS_Objects.Host con, Libvirt.Models.Concrete.Virtual_Machine d) { InitializeComponent(); this.Dock = DockStyle.Fill; _Previous = p; _Local_Media_Create_Model = new Local_Media_Create_Model(con, d); Init_Controls(); }
public Processor(Libvirt.Models.Concrete.Virtual_Machine vm) { InitializeComponent(); this.Dock = DockStyle.Fill; _VM = vm; cpu_type_combobx.SelectedIndex = 5; BuildInfo(); this.Disposed += Processor_Disposed; }
public Create_First_Step(UserControl p, Libvirt.CS_Objects.Host con, Libvirt.Models.Concrete.Virtual_Machine d) { InitializeComponent(); this.Dock = DockStyle.Fill; _Previous = p; _Create_First_Step_Model = new Create_First_Step_Model(con, d); textBox2.DataBindings.Add( Safe_Property.GetPropertyInfo(textBox2, a => a.Text).Name, d.Metadata, Safe_Property.GetPropertyInfo(d.Metadata, a => a.name).Name, false, DataSourceUpdateMode.OnPropertyChanged); }
public Cpu_Ram_Create(UserControl p, Libvirt.CS_Objects.Host con, Libvirt.Models.Concrete.Virtual_Machine d) { InitializeComponent(); this.Dock = DockStyle.Fill; _Previous = p; _Local_Media_Create_Model = new Cpu_Ram_Create_Model(con, d); UpdateControls(); Memory_num.DataBindings.Add( Safe_Property.GetPropertyInfo(Memory_num, a => a.Value).Name, d.Memory, Safe_Property.GetPropertyInfo(d.Memory, a => a.memory).Name, false, DataSourceUpdateMode.OnPropertyChanged); CPU_num.DataBindings.Add( Safe_Property.GetPropertyInfo(CPU_num, a => a.Value).Name, d.CPU, Safe_Property.GetPropertyInfo(d.CPU, a => a.vCpu_Count).Name, false, DataSourceUpdateMode.OnPropertyChanged); }
public Main_Form(Libvirt.CS_Objects.Host h, string domainname) { InitializeComponent(); using (var item = h.virDomainLookupByName(domainname)) { if (!item.IsValid) { MessageBox.Show("Could not find the VM, Try refreshing the VM list."); this.Close(); } else { var xmldesc = item.virDomainGetXMLDesc(Libvirt.virDomainXMLFlags.VIR_DEFAULT); _VM = new Libvirt.Models.Concrete.Virtual_Machine(); var d = System.Xml.Linq.XDocument.Parse(xmldesc); _VM.From_XML(d.Root); } } _CurrentControl = new Overview(_VM); panel1.Controls.Add(_CurrentControl); }
public Cpu_Ram_Create_Model(Libvirt.CS_Objects.Host con, Libvirt.Models.Concrete.Virtual_Machine d) : base(con, d) { _CPU_Layout_Validator = new Libvirt.Service.Concrete.CPU_Layout_Validator(); _Memory_Allocation_Validator = new Libvirt.Service.Concrete.Memory_Allocation_Validator(); }
public Libvirt.Models.Concrete.Virtual_Machine virDomainGetXMLDesc(virDomainXMLFlags flags) { var vm = new Libvirt.Models.Concrete.Virtual_Machine(); vm.From_XML(System.Xml.Linq.XDocument.Parse(API.virDomainGetXMLDesc(_DomainPtr, flags)).Root); return vm; }
public Create_First_Step_Model(Libvirt.CS_Objects.Host con, Libvirt.Models.Concrete.Virtual_Machine d) : base(con, d) { _General_Metadata_Validator = new Libvirt.Service.Concrete.General_Metadata_Validator(); }
public Storage_Create_Model(Libvirt.CS_Objects.Host con, Libvirt.Models.Concrete.Virtual_Machine d) : base(con, d) { _Device_Validator = new Libvirt.Service.Concrete.Device_Collection_Validator(); }
public void QuickCreate(Libvirt_WebManager.Areas.Domain.Models.New_Domain_VM v) { var h = Service.VM_Manager.Instance.virConnectOpen(v.Host); var capabilities = System.Xml.Linq.XDocument.Parse(h.virConnectGetCapabilities()).Root; Libvirt.Models.Concrete.Virtual_Machine virtuammachine = new Libvirt.Models.Concrete.Virtual_Machine(); virtuammachine.CPU.vCpu_Count = v.Cpus; virtuammachine.type = Libvirt.Models.Concrete.Virtual_Machine.Domain_Types.qemu; virtuammachine.Metadata.name = v.Name; virtuammachine.Memory.memory_unit = virtuammachine.Memory.currentMemory_unit = Libvirt.Models.Concrete.Memory_Allocation.UnitTypes.MiB; virtuammachine.Memory.currentMemory = virtuammachine.Memory.memory = v.Ram; //Add a hard drive var harddrive = new Libvirt.Models.Concrete.Disk(); harddrive.Device_Bus_Type = Libvirt.Models.Concrete.Disk.Disk_Bus_Types.virtio; harddrive.Disk_Device_Type = Libvirt.Models.Concrete.Disk.Disk_Device_Types.disk; harddrive.Device_Type = Libvirt.Models.Concrete.Disk.Disk_Types.volume; harddrive.Driver_Cache_Type = Libvirt.Models.Concrete.Disk.Driver_Cache_Types.none; harddrive.Driver_Type = Libvirt.Models.Concrete.Disk.Driver_Types.raw; harddrive.ReadOnly = false; harddrive.Snapshot_Type = Libvirt.Models.Concrete.Disk.Snapshot_Types._default; var source = new Libvirt.Models.Concrete.Device_Source_Volume(); source.pool = v.HD_Pool; source.volume = v.HD_Volume; source.Source_Startup_Policy = Libvirt.Models.Concrete.Disk.Source_Startup_Policies.mandatory; harddrive.Source = source; virtuammachine.Drives.Add(harddrive); var oscdrom = new Libvirt.Models.Concrete.Disk(); oscdrom.Device_Bus_Type = Libvirt.Models.Concrete.Disk.Disk_Bus_Types.ide; oscdrom.Disk_Device_Type = Libvirt.Models.Concrete.Disk.Disk_Device_Types.cdrom; oscdrom.Device_Type = Libvirt.Models.Concrete.Disk.Disk_Types.volume; oscdrom.Driver_Cache_Type = Libvirt.Models.Concrete.Disk.Driver_Cache_Types.none; oscdrom.Driver_Type = Libvirt.Models.Concrete.Disk.Driver_Types.raw; oscdrom.ReadOnly = true; oscdrom.Snapshot_Type = Libvirt.Models.Concrete.Disk.Snapshot_Types._default; var cdsource = new Libvirt.Models.Concrete.Device_Source_Volume(); cdsource.pool = v.OS_Pool; cdsource.volume = v.OS_Volume; cdsource.Source_Startup_Policy = Libvirt.Models.Concrete.Disk.Source_Startup_Policies.optional; oscdrom.Source = cdsource; virtuammachine.Drives.Add(oscdrom); virtuammachine.graphics = new Libvirt.Models.Concrete.Graphics(); virtuammachine.graphics.Graphic_Type = Libvirt.Models.Concrete.Graphics.Graphic_Types.vnc; virtuammachine.graphics.autoport = true; virtuammachine.graphics.websocket = -1; virtuammachine.graphics.listen = "0.0.0.0"; virtuammachine.clock = v.Operating_System == Areas.Domain.Models.OS_Options.Windows ? Libvirt.Models.Concrete.Virtual_Machine.Clock_Types.localtime : Libvirt.Models.Concrete.Virtual_Machine.Clock_Types.utc; var hostcapabilities = System.Xml.Linq.XDocument.Parse(h.virConnectGetCapabilities()).Root; foreach(var item in hostcapabilities.Elements("guest")) { var arch = item.Element("arch"); if (arch != null) { var attr = arch.Attribute("name"); if (attr != null) { if(attr.Value == "x86_64") { var wordsize = arch.Element("wordsize"); if (wordsize != null) { if (wordsize.Value == "64") {//GOT IT!!! 64 bit, x86 type.. get host capaciliies and pick best var ele = arch.Element("emulator"); if (ele != null) { virtuammachine.emulator = ele.Value; } ele = arch.Element("machine"); if (ele != null) { var fattr = ele.Attribute("canonical"); if (fattr != null) { virtuammachine.BootLoader.machine = fattr.Value; } else { virtuammachine.BootLoader.machine = ele.Value; } } } } } } } } using (var domain = h.virDomainDefineXML(virtuammachine)) { if (domain.IsValid) { if (domain.virDomainCreate() == 0) { Debug.WriteLine("Successfully created and started the new VM!"); } else { Debug.WriteLine("Successfully created the VM, but was unable to start it. Check the error logs"); } } else { Debug.WriteLine("Unable to create the VM, please check the error logs!"); } } }
public Domain virDomainDefineXMLFlags(Libvirt.Models.Concrete.Virtual_Machine machine_def, virDomainDefineFlags flags) { return(new Domain(API.virDomainDefineXMLFlags(_ConnectPtr, machine_def.To_XML(), flags))); }
public Domain virDomainDefineXML(Libvirt.Models.Concrete.Virtual_Machine machine_def) { return(new Domain(API.virDomainDefineXML(_ConnectPtr, machine_def.To_XML()))); }
public Domain virDomainCreateXMLWithFiles(Libvirt.Models.Concrete.Virtual_Machine machine_def, int[] files, virDomainCreateFlags flags) { return(new Domain(API.virDomainCreateXMLWithFiles(_ConnectPtr, machine_def.To_XML(), Convert.ToUInt32(files.Length), files, flags))); }