1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
use crate::parsers::ARG_VGA;
use crate::to_command::ToCommand;
use proptest_derive::Arbitrary;
use std::fmt::Display;
use std::str::FromStr;
#[derive(Debug, Clone, Hash, Ord, PartialOrd, Eq, PartialEq, Arbitrary)]
pub enum VGA {
/// Cirrus Logic GD5446 Video card. All Windows versions starting
/// from Windows 95 should recognize and use this graphic card. For
/// optimal performances, use 16 bit color depth in the guest and
/// the host OS. (This card was the default before QEMU 2.2)
Cirrus,
/// Standard VGA card with Bochs VBE extensions. If your guest OS
/// supports the VESA 2.0 VBE extensions (e.g. Windows XP) and if
/// you want to use high resolution modes (>= 1280x1024x16) then you
/// should use this option. (This card is the default since QEMU
/// 2.2)
Std,
/// VMWare SVGA-II compatible adapter. Use it if you have
/// sufficiently recent XFree86/XOrg server or Windows guest with a
/// driver for this card.
Vmware,
/// QXL paravirtual graphic card. It is VGA compatible (including
/// VESA 2.0 VBE support). Works best with qxl guest drivers
/// installed though. Recommended choice when using the spice
/// protocol.
Qxl,
/// (sun4m only) Sun TCX framebuffer. This is the default
/// framebuffer for sun4m machines and offers both 8-bit and 24-bit
/// colour depths at a fixed resolution of 1024x768.
Tcx,
/// (sun4m only) Sun cgthree framebuffer. This is a simple 8-bit
/// framebuffer for sun4m machines available in both 1024x768
/// (OpenBIOS) and 1152x900 (OBP) resolutions aimed at people
/// wishing to run older Solaris versions.
Cg3,
/// Virtio VGA card.
Virtio,
/// Disable VGA card.
None,
}
impl FromStr for VGA {
type Err = String;
fn from_str(s: &str) -> Result<Self, Self::Err> {
match s {
"cirrus" => Ok(VGA::Cirrus),
"std" => Ok(VGA::Std),
"vmware" => Ok(VGA::Vmware),
"qxl" => Ok(VGA::Qxl),
"tcx" => Ok(VGA::Tcx),
"cg3" => Ok(VGA::Cg3),
"virtio" => Ok(VGA::Virtio),
"none" => Ok(VGA::None),
other => Err(format!("Unknown vga type: {}", other)),
}
}
}
impl Display for VGA {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match self {
VGA::Cirrus => write!(f, "cirrus"),
VGA::Std => write!(f, "std"),
VGA::Vmware => write!(f, "vmware"),
VGA::Qxl => write!(f, "qxl"),
VGA::Tcx => write!(f, "tcx"),
VGA::Cg3 => write!(f, "cg3"),
VGA::Virtio => write!(f, "virtio"),
VGA::None => write!(f, "none"),
}
}
}
impl ToCommand for VGA {
fn command(&self) -> String {
ARG_VGA.to_string()
}
fn to_args(&self) -> Vec<String> {
let mut args = vec![];
match self {
VGA::Cirrus => {
args.push("cirrus".to_string());
}
VGA::Std => {
args.push("std".to_string());
}
VGA::Vmware => {
args.push("vmware".to_string());
}
VGA::Qxl => {
args.push("qxl".to_string());
}
VGA::Tcx => {
args.push("tcx".to_string());
}
VGA::Cg3 => {
args.push("cg3".to_string());
}
VGA::Virtio => {
args.push("virtio".to_string());
}
VGA::None => {
args.push("none".to_string());
}
}
args
}
}