Package com.cloud.hypervisor.kvm.resource.LibvirtVMDef

Examples of com.cloud.hypervisor.kvm.resource.LibvirtVMDef.GuestDef


        vm.setDomainName(vmTO.getName());
        vm.setDomUUID(UUID.nameUUIDFromBytes(vmTO.getName().getBytes())
                .toString());
        vm.setDomDescription(vmTO.getOs());

        GuestDef guest = new GuestDef();
        guest.setGuestType(GuestDef.guestType.KVM);
        guest.setGuestArch(vmTO.getArch());
        guest.setMachineType("pc");
        guest.setBootOrder(GuestDef.bootOrder.CDROM);
        guest.setBootOrder(GuestDef.bootOrder.HARDISK);

        vm.addComp(guest);

        GuestResourceDef grd = new GuestResourceDef();
        grd.setMemorySize(vmTO.getMinRam() / 1024);
View Full Code Here


        String uuid = vmTO.getUuid();
        uuid = getUuid(uuid);
        vm.setDomUUID(uuid);
        vm.setDomDescription(vmTO.getOs());

        GuestDef guest = new GuestDef();

        if (HypervisorType.LXC == _hypervisorType &&
            VirtualMachine.Type.User == vmTO.getType()) {
            // LXC domain is only valid for user VMs. Use KVM for system VMs.
            guest.setGuestType(GuestDef.guestType.LXC);
            vm.setHvsType(HypervisorType.LXC.toString().toLowerCase());
        } else {
            guest.setGuestType(GuestDef.guestType.KVM);
            vm.setHvsType(HypervisorType.KVM.toString().toLowerCase());
            vm.setLibvirtVersion(_hypervisorLibvirtVersion);
            vm.setQemuVersion(_hypervisorQemuVersion);
        }
        guest.setGuestArch(vmTO.getArch());
        guest.setMachineType("pc");
        guest.setBootOrder(GuestDef.bootOrder.CDROM);
        guest.setBootOrder(GuestDef.bootOrder.HARDISK);

        vm.addComp(guest);

        GuestResourceDef grd = new GuestResourceDef();

        if (vmTO.getMinRam() != vmTO.getMaxRam()){
            grd.setMemBalloning(true);
            grd.setCurrentMem((long)vmTO.getMinRam()/1024);
            grd.setMemorySize((long)vmTO.getMaxRam()/1024);
        }
        else{
            grd.setMemorySize(vmTO.getMaxRam() / 1024);
        }
        grd.setVcpuNum(vmTO.getCpus());
        vm.addComp(grd);

        CpuModeDef cmd = new CpuModeDef();
        cmd.setMode(_guestCpuMode);
        cmd.setModel(_guestCpuModel);
        vm.addComp(cmd);

        if (_hypervisorLibvirtVersion >= 9000) {
            CpuTuneDef ctd = new CpuTuneDef();
            /**
             A 4.0.X/4.1.X management server doesn't send the correct JSON
             command for getMinSpeed, it only sends a 'speed' field.

             So if getMinSpeed() returns null we fall back to getSpeed().

             This way a >4.1 agent can work communicate a <=4.1 management server

             This change is due to the overcommit feature in 4.2
             */
            if (vmTO.getMinSpeed() != null) {
                ctd.setShares(vmTO.getCpus() * vmTO.getMinSpeed());
            } else {
                ctd.setShares(vmTO.getCpus() * vmTO.getSpeed());
            }
            vm.addComp(ctd);
        }

        FeaturesDef features = new FeaturesDef();
        features.addFeatures("pae");
        features.addFeatures("apic");
        features.addFeatures("acpi");
        vm.addComp(features);

        TermPolicy term = new TermPolicy();
        term.setCrashPolicy("destroy");
        term.setPowerOffPolicy("destroy");
        term.setRebootPolicy("restart");
        vm.addComp(term);

        ClockDef clock = new ClockDef();
        if (vmTO.getOs().startsWith("Windows")) {
            clock.setClockOffset(ClockDef.ClockOffset.LOCALTIME);
            clock.setTimer("rtc", "catchup", null);
        }

        vm.addComp(clock);

        DevicesDef devices = new DevicesDef();
        devices.setEmulatorPath(_hypervisorPath);
        devices.setGuestType(guest.getGuestType());

        SerialDef serial = new SerialDef("pty", null, (short) 0);
        devices.addDevice(serial);

        if (vmTO.getType() != VirtualMachine.Type.User) {
View Full Code Here

        String uuid = vmTO.getUuid();
        uuid = getUuid(uuid);
        vm.setDomUUID(uuid);
        vm.setDomDescription(vmTO.getOs());

        GuestDef guest = new GuestDef();

        if (HypervisorType.LXC == _hypervisorType &&
            VirtualMachine.Type.User == vmTO.getType()) {
            // LXC domain is only valid for user VMs. Use KVM for system VMs.
            guest.setGuestType(GuestDef.guestType.LXC);
            vm.setHvsType(HypervisorType.LXC.toString().toLowerCase());
        } else {
            guest.setGuestType(GuestDef.guestType.KVM);
            vm.setHvsType(HypervisorType.KVM.toString().toLowerCase());
            vm.setLibvirtVersion(_hypervisorLibvirtVersion);
            vm.setQemuVersion(_hypervisorQemuVersion);
        }
        guest.setGuestArch(vmTO.getArch());
        guest.setMachineType("pc");
        guest.setBootOrder(GuestDef.bootOrder.CDROM);
        guest.setBootOrder(GuestDef.bootOrder.HARDISK);

        vm.addComp(guest);

        GuestResourceDef grd = new GuestResourceDef();

        if (vmTO.getMinRam() != vmTO.getMaxRam() && !_noMemBalloon) {
            grd.setMemBalloning(true);
            grd.setCurrentMem(vmTO.getMinRam()/1024);
            grd.setMemorySize(vmTO.getMaxRam()/1024);
        }
        else{
            grd.setMemorySize(vmTO.getMaxRam() / 1024);
        }
        int vcpus = vmTO.getCpus();
        grd.setVcpuNum(vcpus);
        vm.addComp(grd);

        CpuModeDef cmd = new CpuModeDef();
        cmd.setMode(_guestCpuMode);
        cmd.setModel(_guestCpuModel);
        // multi cores per socket, for larger core configs
        if (vcpus % 6 == 0) {
            int sockets = vcpus / 6;
            cmd.setTopology(6, sockets);
        } else if (vcpus % 4 == 0) {
            int sockets = vcpus / 4;
            cmd.setTopology(4, sockets);
        }
        vm.addComp(cmd);

        if (_hypervisorLibvirtVersion >= 9000) {
            CpuTuneDef ctd = new CpuTuneDef();
            /**
             A 4.0.X/4.1.X management server doesn't send the correct JSON
             command for getMinSpeed, it only sends a 'speed' field.

             So if getMinSpeed() returns null we fall back to getSpeed().

             This way a >4.1 agent can work communicate a <=4.1 management server

             This change is due to the overcommit feature in 4.2
             */
            if (vmTO.getMinSpeed() != null) {
                ctd.setShares(vmTO.getCpus() * vmTO.getMinSpeed());
            } else {
                ctd.setShares(vmTO.getCpus() * vmTO.getSpeed());
            }
            vm.addComp(ctd);
        }

        FeaturesDef features = new FeaturesDef();
        features.addFeatures("pae");
        features.addFeatures("apic");
        features.addFeatures("acpi");
        vm.addComp(features);

        TermPolicy term = new TermPolicy();
        term.setCrashPolicy("destroy");
        term.setPowerOffPolicy("destroy");
        term.setRebootPolicy("restart");
        vm.addComp(term);

        ClockDef clock = new ClockDef();
        if (vmTO.getOs().startsWith("Windows")) {
            clock.setClockOffset(ClockDef.ClockOffset.LOCALTIME);
            clock.setTimer("rtc", "catchup", null);
        }

        vm.addComp(clock);

        DevicesDef devices = new DevicesDef();
        devices.setEmulatorPath(_hypervisorPath);
        devices.setGuestType(guest.getGuestType());

        SerialDef serial = new SerialDef("pty", null, (short) 0);
        devices.addDevice(serial);

        if (vmTO.getType() != VirtualMachine.Type.User) {
View Full Code Here

        vm.setDomainName(vmTO.getName());
        vm.setDomUUID(UUID.nameUUIDFromBytes(vmTO.getName().getBytes())
                .toString());
        vm.setDomDescription(vmTO.getOs());

        GuestDef guest = new GuestDef();
        guest.setGuestType(GuestDef.guestType.KVM);
        guest.setGuestArch(vmTO.getArch());
        guest.setMachineType("pc");
        guest.setBootOrder(GuestDef.bootOrder.CDROM);
        guest.setBootOrder(GuestDef.bootOrder.HARDISK);

        vm.addComp(guest);

        GuestResourceDef grd = new GuestResourceDef();
        grd.setMemorySize(vmTO.getMinRam() / 1024);
View Full Code Here

        uuid = getUuid(uuid);
        vm.setDomUUID(uuid);
        vm.setDomDescription(vmTO.getOs());
        vm.setPlatformEmulator(vmTO.getPlatformEmulator());

        GuestDef guest = new GuestDef();

        if (HypervisorType.LXC == _hypervisorType && VirtualMachine.Type.User == vmTO.getType()) {
            // LXC domain is only valid for user VMs. Use KVM for system VMs.
            guest.setGuestType(GuestDef.guestType.LXC);
            vm.setHvsType(HypervisorType.LXC.toString().toLowerCase());
        } else {
            guest.setGuestType(GuestDef.guestType.KVM);
            vm.setHvsType(HypervisorType.KVM.toString().toLowerCase());
            vm.setLibvirtVersion(_hypervisorLibvirtVersion);
            vm.setQemuVersion(_hypervisorQemuVersion);
        }
        guest.setGuestArch(vmTO.getArch());
        guest.setMachineType("pc");
        guest.setBootOrder(GuestDef.bootOrder.CDROM);
        guest.setBootOrder(GuestDef.bootOrder.HARDISK);

        vm.addComp(guest);

        GuestResourceDef grd = new GuestResourceDef();

        if (vmTO.getMinRam() != vmTO.getMaxRam() && !_noMemBalloon) {
            grd.setMemBalloning(true);
            grd.setCurrentMem(vmTO.getMinRam() / 1024);
            grd.setMemorySize(vmTO.getMaxRam() / 1024);
        } else {
            grd.setMemorySize(vmTO.getMaxRam() / 1024);
        }
        int vcpus = vmTO.getCpus();
        grd.setVcpuNum(vcpus);
        vm.addComp(grd);

        CpuModeDef cmd = new CpuModeDef();
        cmd.setMode(_guestCpuMode);
        cmd.setModel(_guestCpuModel);
        // multi cores per socket, for larger core configs
        if (vcpus % 6 == 0) {
            int sockets = vcpus / 6;
            cmd.setTopology(6, sockets);
        } else if (vcpus % 4 == 0) {
            int sockets = vcpus / 4;
            cmd.setTopology(4, sockets);
        }
        vm.addComp(cmd);

        if (_hypervisorLibvirtVersion >= 9000) {
            CpuTuneDef ctd = new CpuTuneDef();
            /**
             A 4.0.X/4.1.X management server doesn't send the correct JSON
             command for getMinSpeed, it only sends a 'speed' field.

             So if getMinSpeed() returns null we fall back to getSpeed().

             This way a >4.1 agent can work communicate a <=4.1 management server

             This change is due to the overcommit feature in 4.2
             */
            if (vmTO.getMinSpeed() != null) {
                ctd.setShares(vmTO.getCpus() * vmTO.getMinSpeed());
            } else {
                ctd.setShares(vmTO.getCpus() * vmTO.getSpeed());
            }
            vm.addComp(ctd);
        }

        FeaturesDef features = new FeaturesDef();
        features.addFeatures("pae");
        features.addFeatures("apic");
        features.addFeatures("acpi");
        vm.addComp(features);

        TermPolicy term = new TermPolicy();
        term.setCrashPolicy("destroy");
        term.setPowerOffPolicy("destroy");
        term.setRebootPolicy("restart");
        vm.addComp(term);

        ClockDef clock = new ClockDef();
        if (vmTO.getOs().startsWith("Windows")) {
            clock.setClockOffset(ClockDef.ClockOffset.LOCALTIME);
            clock.setTimer("rtc", "catchup", null);
        }

        vm.addComp(clock);

        DevicesDef devices = new DevicesDef();
        devices.setEmulatorPath(_hypervisorPath);
        devices.setGuestType(guest.getGuestType());

        SerialDef serial = new SerialDef("pty", null, (short)0);
        devices.addDevice(serial);

        if (vmTO.getType() != VirtualMachine.Type.User) {
View Full Code Here

        String uuid = vmTO.getUuid();
        uuid = getUuid(uuid);
        vm.setDomUUID(uuid);
        vm.setDomDescription(vmTO.getOs());

        GuestDef guest = new GuestDef();

        if (HypervisorType.LXC == _hypervisorType &&
            VirtualMachine.Type.User == vmTO.getType()) {
            // LXC domain is only valid for user VMs. Use KVM for system VMs.
            guest.setGuestType(GuestDef.guestType.LXC);
            vm.setHvsType(HypervisorType.LXC.toString().toLowerCase());
        } else {
            guest.setGuestType(GuestDef.guestType.KVM);
            vm.setHvsType(HypervisorType.KVM.toString().toLowerCase());
            vm.setLibvirtVersion(_hypervisorLibvirtVersion);
            vm.setQemuVersion(_hypervisorQemuVersion);
        }
        guest.setGuestArch(vmTO.getArch());
        guest.setMachineType("pc");
        guest.setBootOrder(GuestDef.bootOrder.CDROM);
        guest.setBootOrder(GuestDef.bootOrder.HARDISK);

        vm.addComp(guest);

        GuestResourceDef grd = new GuestResourceDef();

        if (vmTO.getMinRam() != vmTO.getMaxRam()){
            grd.setMemBalloning(true);
            grd.setCurrentMem((long)vmTO.getMinRam()/1024);
            grd.setMemorySize((long)vmTO.getMaxRam()/1024);
        }
        else{
            grd.setMemorySize(vmTO.getMaxRam() / 1024);
        }
        grd.setVcpuNum(vmTO.getCpus());
        vm.addComp(grd);

        CpuModeDef cmd = new CpuModeDef();
        cmd.setMode(_guestCpuMode);
        cmd.setModel(_guestCpuModel);
        vm.addComp(cmd);

        if (_hypervisorLibvirtVersion >= 9000) {
            CpuTuneDef ctd = new CpuTuneDef();
            /**
             A 4.0.X/4.1.X management server doesn't send the correct JSON
             command for getMinSpeed, it only sends a 'speed' field.

             So if getMinSpeed() returns null we fall back to getSpeed().

             This way a >4.1 agent can work communicate a <=4.1 management server

             This change is due to the overcommit feature in 4.2
             */
            if (vmTO.getMinSpeed() != null) {
                ctd.setShares(vmTO.getCpus() * vmTO.getMinSpeed());
            } else {
                ctd.setShares(vmTO.getCpus() * vmTO.getSpeed());
            }
            vm.addComp(ctd);
        }

        FeaturesDef features = new FeaturesDef();
        features.addFeatures("pae");
        features.addFeatures("apic");
        features.addFeatures("acpi");
        vm.addComp(features);

        TermPolicy term = new TermPolicy();
        term.setCrashPolicy("destroy");
        term.setPowerOffPolicy("destroy");
        term.setRebootPolicy("restart");
        vm.addComp(term);

        ClockDef clock = new ClockDef();
        if (vmTO.getOs().startsWith("Windows")) {
            clock.setClockOffset(ClockDef.ClockOffset.LOCALTIME);
            clock.setTimer("rtc", "catchup", null);
        }

        vm.addComp(clock);

        DevicesDef devices = new DevicesDef();
        devices.setEmulatorPath(_hypervisorPath);
        devices.setGuestType(guest.getGuestType());

        SerialDef serial = new SerialDef("pty", null, (short) 0);
        devices.addDevice(serial);

        if (vmTO.getType() != VirtualMachine.Type.User) {
View Full Code Here

        vm.setDomainName(vmTO.getName());
        vm.setDomUUID(UUID.nameUUIDFromBytes(vmTO.getName().getBytes())
                .toString());
        vm.setDomDescription(vmTO.getOs());

        GuestDef guest = new GuestDef();
        guest.setGuestType(GuestDef.guestType.KVM);
        guest.setGuestArch(vmTO.getArch());
        guest.setMachineType("pc");
        guest.setBootOrder(GuestDef.bootOrder.CDROM);
        guest.setBootOrder(GuestDef.bootOrder.HARDISK);

        vm.addComp(guest);

        GuestResourceDef grd = new GuestResourceDef();
        grd.setMemorySize(vmTO.getMinRam() / 1024);
View Full Code Here

        vm.setDomainName(vmTO.getName());
        vm.setDomUUID(UUID.nameUUIDFromBytes(vmTO.getName().getBytes())
                .toString());
        vm.setDomDescription(vmTO.getOs());

        GuestDef guest = new GuestDef();
        guest.setGuestType(GuestDef.guestType.KVM);
        guest.setGuestArch(vmTO.getArch());
        guest.setMachineType("pc");
        guest.setBootOrder(GuestDef.bootOrder.CDROM);
        guest.setBootOrder(GuestDef.bootOrder.HARDISK);

        vm.addComp(guest);

        GuestResourceDef grd = new GuestResourceDef();
        grd.setMemorySize(vmTO.getMinRam() / 1024);
View Full Code Here

        vm.setDomainName(vmTO.getName());
        vm.setDomUUID(UUID.nameUUIDFromBytes(vmTO.getName().getBytes())
                .toString());
        vm.setDomDescription(vmTO.getOs());

        GuestDef guest = new GuestDef();
        guest.setGuestType(GuestDef.guestType.KVM);
        guest.setGuestArch(vmTO.getArch());
        guest.setMachineType("pc");
        guest.setBootOrder(GuestDef.bootOrder.CDROM);
        guest.setBootOrder(GuestDef.bootOrder.HARDISK);

        vm.addComp(guest);

        GuestResourceDef grd = new GuestResourceDef();
        grd.setMemorySize(vmTO.getMinRam() / 1024);
View Full Code Here

        String uuid = vmTO.getUuid();
        uuid = getUuid(uuid);
        vm.setDomUUID(uuid);
        vm.setDomDescription(vmTO.getOs());

        GuestDef guest = new GuestDef();

        if (HypervisorType.LXC == _hypervisorType &&
            VirtualMachine.Type.User == vmTO.getType()) {
            // LXC domain is only valid for user VMs. Use KVM for system VMs.
            guest.setGuestType(GuestDef.guestType.LXC);
            vm.setHvsType(HypervisorType.LXC.toString().toLowerCase());
        } else {
            guest.setGuestType(GuestDef.guestType.KVM);
            vm.setHvsType(HypervisorType.KVM.toString().toLowerCase());
            vm.setLibvirtVersion(_hypervisorLibvirtVersion);
            vm.setQemuVersion(_hypervisorQemuVersion);
        }
        guest.setGuestArch(vmTO.getArch());
        guest.setMachineType("pc");
        guest.setBootOrder(GuestDef.bootOrder.CDROM);
        guest.setBootOrder(GuestDef.bootOrder.HARDISK);

        vm.addComp(guest);

        GuestResourceDef grd = new GuestResourceDef();

        if (vmTO.getMinRam() != vmTO.getMaxRam() && !_noMemBalloon) {
            grd.setMemBalloning(true);
            grd.setCurrentMem(vmTO.getMinRam()/1024);
            grd.setMemorySize(vmTO.getMaxRam()/1024);
        }
        else{
            grd.setMemorySize(vmTO.getMaxRam() / 1024);
        }
        int vcpus = vmTO.getCpus();
        grd.setVcpuNum(vcpus);
        vm.addComp(grd);

        CpuModeDef cmd = new CpuModeDef();
        cmd.setMode(_guestCpuMode);
        cmd.setModel(_guestCpuModel);
        // multi cores per socket, for larger core configs
        if (vcpus % 6 == 0) {
            int sockets = vcpus / 6;
            cmd.setTopology(6, sockets);
        } else if (vcpus % 4 == 0) {
            int sockets = vcpus / 4;
            cmd.setTopology(4, sockets);
        }
        vm.addComp(cmd);

        if (_hypervisorLibvirtVersion >= 9000) {
            CpuTuneDef ctd = new CpuTuneDef();
            /**
             A 4.0.X/4.1.X management server doesn't send the correct JSON
             command for getMinSpeed, it only sends a 'speed' field.

             So if getMinSpeed() returns null we fall back to getSpeed().

             This way a >4.1 agent can work communicate a <=4.1 management server

             This change is due to the overcommit feature in 4.2
             */
            if (vmTO.getMinSpeed() != null) {
                ctd.setShares(vmTO.getCpus() * vmTO.getMinSpeed());
            } else {
                ctd.setShares(vmTO.getCpus() * vmTO.getSpeed());
            }
            vm.addComp(ctd);
        }

        FeaturesDef features = new FeaturesDef();
        features.addFeatures("pae");
        features.addFeatures("apic");
        features.addFeatures("acpi");
        vm.addComp(features);

        TermPolicy term = new TermPolicy();
        term.setCrashPolicy("destroy");
        term.setPowerOffPolicy("destroy");
        term.setRebootPolicy("restart");
        vm.addComp(term);

        ClockDef clock = new ClockDef();
        if (vmTO.getOs().startsWith("Windows")) {
            clock.setClockOffset(ClockDef.ClockOffset.LOCALTIME);
            clock.setTimer("rtc", "catchup", null);
        }

        vm.addComp(clock);

        DevicesDef devices = new DevicesDef();
        devices.setEmulatorPath(_hypervisorPath);
        devices.setGuestType(guest.getGuestType());

        SerialDef serial = new SerialDef("pty", null, (short) 0);
        devices.addDevice(serial);

        if (vmTO.getType() != VirtualMachine.Type.User) {
View Full Code Here

TOP

Related Classes of com.cloud.hypervisor.kvm.resource.LibvirtVMDef.GuestDef

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.