forked from nrgaway/qubes-core-libvirt
-
Notifications
You must be signed in to change notification settings - Fork 0
/
0003-libxl-Stubdom-emulator-type.patch
230 lines (216 loc) · 8.44 KB
/
0003-libxl-Stubdom-emulator-type.patch
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
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
From 99fd72440695a2ab6d41552d27ab7d602875ede8 Mon Sep 17 00:00:00 2001
From: Marek Marczykowski <marmarek@invisiblethingslab.com>
Date: Sun, 7 Apr 2013 19:48:52 +0200
Subject: [PATCH] libxl: Stubdom emulator type
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Organization: Invisible Things Lab
Cc: Marek Marczykowski-Górecki <marmarek@invisiblethingslab.com>
Xen have feature of having device model in separate domain (called stub
domain). Add 'type' attribute to 'emulator' element to allow selecting
such configuration. Emulator path is still used for qemu running in dom0
(if any). Libxl currently do not allow to select stubdomain path.
Signed-off-by: Marek Marczykowski-Górecki <marmarek@invisiblethingslab.com>
---
docs/formatdomain.html.in | 17 +++++++++++++++
docs/schemas/domaincommon.rng | 28 +++++++++++++++++++++++-
src/conf/domain_conf.c | 41 +++++++++++++++++++++++++++++++++--
src/conf/domain_conf.h | 10 +++++++++
src/libxl/libxl_conf.c | 17 +++++++++++++++
5 files changed, 110 insertions(+), 3 deletions(-)
diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in
index 33cec1e6dd..bdbef45a9c 100644
--- a/docs/formatdomain.html.in
+++ b/docs/formatdomain.html.in
@@ -2829,6 +2829,23 @@
The <a href="formatcaps.html">capabilities XML</a> specifies
the recommended default emulator to use for each particular
domain type / architecture combination.
+
+ <span class="since">Since 1.2.13</span>, the <code>emulator</code>
+ element may contain <code>type</code> attribute. Possible values are:
+ <dl>
+ <dt><code>type='default'</code></dt>
+ <dd>Equivalent to not setting <code>type</code> attribute at all.
+ </dd>
+
+ <dt><code>type='stubdom'</code></dt>
+ <dd>Launch emulator in stub domain (Xen only). The emulator path
+ still indicate which binary is used in dom0 - there is no control
+ which binary is used as a stub domain.
+ </dd>
+ </dl>
+ <span class="since">Since 1.2.20</span>, the <code>emulator</code>
+ element may contain <code>cmdline</code> attribute with custom command
+ line arguments.
</dd>
</dl>
diff --git a/docs/schemas/domaincommon.rng b/docs/schemas/domaincommon.rng
index 96fe4abcce..be20f0c951 100644
--- a/docs/schemas/domaincommon.rng
+++ b/docs/schemas/domaincommon.rng
@@ -3458,7 +3458,33 @@
-->
<define name="emulator">
<element name="emulator">
- <ref name="absFilePath"/>
+ <choice>
+ <group>
+ <optional>
+ <attribute name="type">
+ <choice>
+ <value>qemu</value>
+ <value>stubdom</value>
+ </choice>
+ </attribute>
+ </optional>
+ <optional>
+ <attribute name="cmdline">
+ <text/>
+ </attribute>
+ </optional>
+ <ref name="absFilePath"/>
+ </group>
+ <group>
+ <attribute name="type">
+ <choice>
+ <value>qemu</value>
+ <value>stubdom</value>
+ </choice>
+ </attribute>
+ <empty/>
+ </group>
+ </choice>
</element>
</define>
<!--
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index a7f75eb53d..620ef00500 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -1145,6 +1145,11 @@ VIR_ENUM_IMPL(virDomainDiskTray,
"open",
);
+VIR_ENUM_IMPL(virDomainEmulatorType,
+ VIR_DOMAIN_EMULATOR_TYPE_LAST,
+ "qemu",
+ "stubdom");
+
VIR_ENUM_IMPL(virDomainRNGModel,
VIR_DOMAIN_RNG_MODEL_LAST,
"virtio",
@@ -21545,6 +21550,17 @@ virDomainDefParseXML(xmlDocPtr xml,
if (virDomainDefParseBootOptions(def, ctxt) < 0)
goto error;
+ def->emulator = virXPathString("string(./devices/emulator[1])", ctxt);
+ if ((tmp = virXPathString("string(./devices/emulator/@type)", ctxt))) {
+ def->emulator_type = virDomainEmulatorTypeTypeFromString(tmp);
+ VIR_FREE(tmp);
+ if (def->emulator_type < 0) {
+ virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
+ _("Unknown emulator type '%s'"), tmp);
+ }
+ }
+ def->emulator_cmdline = virXPathString("string(./devices/emulator/@cmdline)", ctxt);
+
/* analysis of the disk devices */
if ((n = virXPathNodeSet("./devices/disk", ctxt, &nodes)) < 0)
goto error;
@@ -24062,6 +24078,14 @@ virDomainDefCheckABIStabilityFlags(virDomainDefPtr src,
goto error;
}
+ if (src->emulator_type != dst->emulator_type) {
+ virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
+ _("Target domain emulator type %s does not match source %s"),
+ virDomainEmulatorTypeTypeToString(dst->emulator_type),
+ virDomainEmulatorTypeTypeToString(src->emulator_type));
+ goto error;
+ }
+
if (!virDomainDefFeaturesCheckABIStability(src, dst))
goto error;
@@ -29737,8 +29761,21 @@ virDomainDefFormatInternalSetRootName(virDomainDefPtr def,
virBufferAddLit(buf, "<devices>\n");
virBufferAdjustIndent(buf, 2);
- virBufferEscapeString(buf, "<emulator>%s</emulator>\n",
- def->emulator);
+ if (def->emulator ||
+ def->emulator_type != VIR_DOMAIN_EMULATOR_TYPE_DEFAULT) {
+ virBufferAddLit(buf, "<emulator");
+ if (def->emulator_type != VIR_DOMAIN_EMULATOR_TYPE_DEFAULT) {
+ virBufferAsprintf(buf, " type='%s'",
+ virDomainEmulatorTypeTypeToString(def->emulator_type));
+ }
+ virBufferEscapeString(buf, " cmdline='%s'", def->emulator_cmdline);
+ if (!def->emulator) {
+ virBufferAddLit(buf, "/>\n");
+ } else {
+ virBufferEscapeString(buf, ">%s</emulator>\n",
+ def->emulator);
+ }
+ }
for (n = 0; n < def->ndisks; n++)
if (virDomainDiskDefFormat(buf, def->disks[n], flags, xmlopt) < 0)
diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h
index d072569ce9..bc78d6bb30 100644
--- a/src/conf/domain_conf.h
+++ b/src/conf/domain_conf.h
@@ -2206,6 +2206,13 @@ struct _virBlkioDevice {
unsigned long long wbps;
};
+typedef enum {
+ VIR_DOMAIN_EMULATOR_TYPE_DEFAULT,
+ VIR_DOMAIN_EMULATOR_TYPE_STUBDOM,
+
+ VIR_DOMAIN_EMULATOR_TYPE_LAST
+} virDomainEmulatorType;
+
typedef enum {
VIR_DOMAIN_RNG_MODEL_VIRTIO,
VIR_DOMAIN_RNG_MODEL_VIRTIO_TRANSITIONAL,
@@ -2536,6 +2543,8 @@ struct _virDomainDef {
virDomainOSDef os;
char *emulator;
+ virDomainEmulatorType emulator_type;
+ char *emulator_cmdline;
/* Most {caps_,hyperv_,kvm_,}feature options utilize a virTristateSwitch
* to handle support. A few assign specific data values to the option.
* See virDomainDefFeaturesCheckABIStability() for details. */
@@ -3594,6 +3603,7 @@ VIR_ENUM_DECL(virDomainHyperv);
VIR_ENUM_DECL(virDomainKVM);
VIR_ENUM_DECL(virDomainXen);
VIR_ENUM_DECL(virDomainXenPassthroughMode);
+VIR_ENUM_DECL(virDomainEmulatorType);
VIR_ENUM_DECL(virDomainMsrsUnknown);
VIR_ENUM_DECL(virDomainRNGModel);
VIR_ENUM_DECL(virDomainRNGBackend);
diff --git a/src/libxl/libxl_conf.c b/src/libxl/libxl_conf.c
index bdb468438f..866386f2ef 100644
--- a/src/libxl/libxl_conf.c
+++ b/src/libxl/libxl_conf.c
@@ -593,6 +593,23 @@ libxlMakeDomBuildInfo(virDomainDefPtr def,
b_info->device_model_version = libxlDomainGetEmulatorType(def);
}
+ /* In case of stubdom there will be two qemu instances:
+ * - in stubdom (libxl uses hardcoded path for this one),
+ * - in dom0 as a backend for stubdom (if needed).
+ * Emulator path control only the second one. It makes a perfect sense
+ * to use <emulator type='stubdom'/> (yes, without emulator path).
+ */
+ if (def->emulator_type == VIR_DOMAIN_EMULATOR_TYPE_STUBDOM)
+ libxl_defbool_set(&b_info->device_model_stubdomain, 1);
+
+ if (def->emulator_cmdline && def->emulator_cmdline[0]) {
+ b_info->extra_hvm = virStringSplit(def->emulator_cmdline, " ", 0);
+ if (b_info->extra_hvm == NULL) {
+ virReportOOMError();
+ return -1;
+ }
+ }
+
if (def->nserials) {
if (def->nserials == 1) {
if (libxlMakeChrdevStr(def->serials[0], &b_info->u.hvm.serial) <
--
2.25.4