mirror of https://github.com/apache/cloudstack.git
Summary: KVM - Add virtio-serial device to libvirt xml for system vms
Detail: This device can be used for remotely controlling the system vms through a local socket on the host. We will attempt to replace the KVM patchdisk with it. Tested, successfully deploys VM, and if system vm has proper driver it will create a /dev/vport0p1 device within the VM. We will be updating the system VM in 4.2/5.0 and will support this. Signed-off-by: Marcus Sorensen <marcus@betterservers.com> 1362527352 -0700
This commit is contained in:
parent
33757377c0
commit
d81f7156dc
|
|
@ -188,6 +188,7 @@ import com.cloud.hypervisor.kvm.resource.LibvirtVMDef.InputDef;
|
|||
import com.cloud.hypervisor.kvm.resource.LibvirtVMDef.InterfaceDef;
|
||||
import com.cloud.hypervisor.kvm.resource.LibvirtVMDef.InterfaceDef.hostNicType;
|
||||
import com.cloud.hypervisor.kvm.resource.LibvirtVMDef.SerialDef;
|
||||
import com.cloud.hypervisor.kvm.resource.LibvirtVMDef.VirtioSerialDef;
|
||||
import com.cloud.hypervisor.kvm.resource.LibvirtVMDef.TermPolicy;
|
||||
import com.cloud.hypervisor.kvm.storage.KVMPhysicalDisk;
|
||||
import com.cloud.hypervisor.kvm.storage.KVMPhysicalDisk.PhysicalDiskFormat;
|
||||
|
|
@ -3053,6 +3054,11 @@ ServerResource {
|
|||
SerialDef serial = new SerialDef("pty", null, (short) 0);
|
||||
devices.addDevice(serial);
|
||||
|
||||
if (vmTO.getType() != VirtualMachine.Type.User) {
|
||||
VirtioSerialDef vserial = new VirtioSerialDef(vmTO.getName(), null);
|
||||
devices.addDevice(vserial);
|
||||
}
|
||||
|
||||
ConsoleDef console = new ConsoleDef("pty", null, null, (short) 0);
|
||||
devices.addDevice(console);
|
||||
|
||||
|
|
|
|||
|
|
@ -846,6 +846,31 @@ public class LibvirtVMDef {
|
|||
}
|
||||
}
|
||||
|
||||
public static class VirtioSerialDef {
|
||||
private final String _name;
|
||||
private String _path;
|
||||
|
||||
public VirtioSerialDef(String name, String path) {
|
||||
_name = name;
|
||||
_path = path;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuilder virtioSerialBuilder = new StringBuilder();
|
||||
if(_path == null) {
|
||||
_path = "/var/lib/libvirt/qemu";
|
||||
}
|
||||
virtioSerialBuilder.append("<channel type='unix'>\n");
|
||||
virtioSerialBuilder.append("<source mode='bind' path='" + _path
|
||||
+ "/" + _name + ".agent'/>\n");
|
||||
virtioSerialBuilder.append("<target type='virtio' name='org.qemu.guest_agent.0'/>\n");
|
||||
virtioSerialBuilder.append("<address type='virtio-serial' controller='0' bus='0' port='1'/>\n");
|
||||
virtioSerialBuilder.append("</channel>\n");
|
||||
return virtioSerialBuilder.toString();
|
||||
}
|
||||
}
|
||||
|
||||
public static class GraphicDef {
|
||||
private final String _type;
|
||||
private short _port = -2;
|
||||
|
|
|
|||
Loading…
Reference in New Issue