001/* 002 * To change this template, choose Tools | Templates 003 * and open the template in the editor. 004 */ 005package org.anarres.qemu.exec; 006 007import java.util.Arrays; 008import java.util.List; 009import javax.annotation.CheckForNull; 010import javax.annotation.Nonnull; 011 012/** 013 * 014 * @author shevek 015 */ 016public class QEmuMachineOption extends AbstractQEmuOption { 017 018 public static enum Acceleration { 019 020 kvm, tcg, xen; 021 } 022 // accel=kvm:tcg :xen 023 public QEmuMachine type; 024 public List<Acceleration> acceleration; 025 026 public QEmuMachineOption(@CheckForNull QEmuMachine type) { 027 this.type = type; 028 } 029 030 public QEmuMachineOption() { 031 } 032 033 @Nonnull 034 public QEmuMachineOption withType(QEmuMachine type) { 035 this.type = type; 036 return this; 037 } 038 039 @Nonnull 040 public QEmuMachineOption withAcceleration(List<Acceleration> acceleration) { 041 this.acceleration = acceleration; 042 return this; 043 } 044 045 @Nonnull 046 public QEmuMachineOption withAcceleration(@Nonnull Acceleration... acceleration) { 047 return withAcceleration(Arrays.asList(acceleration)); 048 } 049 050 @Override 051 public void appendTo(List<? super String> line) { 052 StringBuilder buf = new StringBuilder(); 053 appendTo(buf, "type", type); 054 appendTo(buf, "accel", join(":", acceleration)); 055 add(line, "-machine", buf); 056 } 057}