Skip to content

Commit d81f715

Browse files
author
Marcus Sorensen
committed
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
1 parent 3375737 commit d81f715

2 files changed

Lines changed: 31 additions & 0 deletions

File tree

‎plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtComputingResource.java‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,7 @@
188188
import com.cloud.hypervisor.kvm.resource.LibvirtVMDef.InterfaceDef;
189189
import com.cloud.hypervisor.kvm.resource.LibvirtVMDef.InterfaceDef.hostNicType;
190190
import com.cloud.hypervisor.kvm.resource.LibvirtVMDef.SerialDef;
191+
import com.cloud.hypervisor.kvm.resource.LibvirtVMDef.VirtioSerialDef;
191192
import com.cloud.hypervisor.kvm.resource.LibvirtVMDef.TermPolicy;
192193
import com.cloud.hypervisor.kvm.storage.KVMPhysicalDisk;
193194
import com.cloud.hypervisor.kvm.storage.KVMPhysicalDisk.PhysicalDiskFormat;
@@ -3053,6 +3054,11 @@ So if getMinSpeed() returns null we fall back to getSpeed().
30533054
SerialDef serial = new SerialDef("pty", null, (short) 0);
30543055
devices.addDevice(serial);
30553056

3057+
if (vmTO.getType() != VirtualMachine.Type.User) {
3058+
VirtioSerialDef vserial = new VirtioSerialDef(vmTO.getName(), null);
3059+
devices.addDevice(vserial);
3060+
}
3061+
30563062
ConsoleDef console = new ConsoleDef("pty", null, null, (short) 0);
30573063
devices.addDevice(console);
30583064

‎plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtVMDef.java‎

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -846,6 +846,31 @@ public String toString() {
846846
}
847847
}
848848

849+
public static class VirtioSerialDef {
850+
private final String _name;
851+
private String _path;
852+
853+
public VirtioSerialDef(String name, String path) {
854+
_name = name;
855+
_path = path;
856+
}
857+
858+
@Override
859+
public String toString() {
860+
StringBuilder virtioSerialBuilder = new StringBuilder();
861+
if(_path == null) {
862+
_path = "/var/lib/libvirt/qemu";
863+
}
864+
virtioSerialBuilder.append("<channel type='unix'>\n");
865+
virtioSerialBuilder.append("<source mode='bind' path='" + _path
866+
+ "/" + _name + ".agent'/>\n");
867+
virtioSerialBuilder.append("<target type='virtio' name='org.qemu.guest_agent.0'/>\n");
868+
virtioSerialBuilder.append("<address type='virtio-serial' controller='0' bus='0' port='1'/>\n");
869+
virtioSerialBuilder.append("</channel>\n");
870+
return virtioSerialBuilder.toString();
871+
}
872+
}
873+
849874
public static class GraphicDef {
850875
private final String _type;
851876
private short _port = -2;

0 commit comments

Comments
 (0)