forked from nrgaway/qubes-core-libvirt
-
Notifications
You must be signed in to change notification settings - Fork 0
/
0010-Add-nostrictreset-attribute-to-PCI-host-devices.patch
208 lines (197 loc) · 7.61 KB
/
0010-Add-nostrictreset-attribute-to-PCI-host-devices.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
From b07a9dfce325aa7302af4b41c3e38c1b37ba71f3 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Marek=20Marczykowski-G=C3=B3recki?=
<marmarek@invisiblethingslab.com>
Date: Sat, 23 May 2015 04:25:01 +0200
Subject: [PATCH] Add 'nostrictreset' attribute to PCI host devices
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>
This allows to assign PCI device to some VM, even when the device does not
support any reset method. This may be dangerous in some cases (especially when
the device is later assigned to some other VM). But in some cases it still
makes sense - for example when the device is assigned to the same VM whole the
time.
Signed-off-by: Marek Marczykowski-Górecki <marmarek@invisiblethingslab.com>
---
docs/formatdomain.html.in | 3 +++
docs/schemas/domaincommon.rng | 5 +++++
src/conf/domain_conf.c | 13 +++++++++++++
src/conf/domain_conf.h | 1 +
src/util/virhostdev.c | 2 ++
src/util/virpci.c | 18 +++++++++++++++++-
src/util/virpci.h | 2 ++
7 files changed, 43 insertions(+), 1 deletion(-)
diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in
index e0faebe..47f1921 100644
--- a/docs/formatdomain.html.in
+++ b/docs/formatdomain.html.in
@@ -3989,6 +3989,9 @@
or hot-plugging the device and <code>virNodeDeviceReAttach</code>
(or <code>virsh nodedev-reattach</code>) after hot-unplug or
stopping the guest.
+ Additionally when <code>strictreset</code> is "no", device will
+ be assigned to the domain, even when reset fails. The default is
+ "yes".
</dd>
<dt><code>scsi</code></dt>
<dd>For SCSI devices, user is responsible to make sure the device
diff --git a/docs/schemas/domaincommon.rng b/docs/schemas/domaincommon.rng
index 06f3561..2eed0ca 100644
--- a/docs/schemas/domaincommon.rng
+++ b/docs/schemas/domaincommon.rng
@@ -2495,6 +2495,11 @@
<ref name="virYesNo"/>
</attribute>
</optional>
+ <optional>
+ <attribute name="nostrictreset">
+ <ref name="virYesNo"/>
+ </attribute>
+ </optional>
<interleave>
<element name="source">
<optional>
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 7d450c0..daf628b 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -6500,6 +6500,7 @@ virDomainHostdevDefParseXMLSubsys(xmlNodePtr node,
{
xmlNodePtr sourcenode;
char *managed = NULL;
+ char *nostrictreset = NULL;
char *sgio = NULL;
char *rawio = NULL;
char *backendStr = NULL;
@@ -6520,6 +6521,11 @@ virDomainHostdevDefParseXMLSubsys(xmlNodePtr node,
def->managed = true;
}
+ if ((nostrictreset = virXMLPropString(node, "nostrictreset")) != NULL) {
+ if (STREQ(nostrictreset, "yes"))
+ def->nostrictreset = true;
+ }
+
sgio = virXMLPropString(node, "sgio");
rawio = virXMLPropString(node, "rawio");
model = virXMLPropString(node, "model");
@@ -6659,6 +6665,7 @@ virDomainHostdevDefParseXMLSubsys(xmlNodePtr node,
ret = 0;
error:
VIR_FREE(managed);
+ VIR_FREE(nostrictreset);
VIR_FREE(sgio);
VIR_FREE(rawio);
VIR_FREE(backendStr);
@@ -21856,6 +21863,8 @@ virDomainActualNetDefFormat(virBufferPtr buf,
virDomainHostdevDefPtr hostdef = virDomainNetGetActualHostdev(def);
if (hostdef && hostdef->managed)
virBufferAddLit(buf, " managed='yes'");
+ if (hostdef && hostdef->nostrictreset)
+ virBufferAddLit(buf, " nostrictreset='yes'");
}
if (def->trustGuestRxFilters)
virBufferAsprintf(buf, " trustGuestRxFilters='%s'",
@@ -22031,6 +22040,8 @@ virDomainNetDefFormat(virBufferPtr buf,
virBufferAsprintf(buf, "<interface type='%s'", typeStr);
if (hostdef && hostdef->managed)
virBufferAddLit(buf, " managed='yes'");
+ if (hostdef && hostdef->nostrictreset)
+ virBufferAddLit(buf, " nostrictreset='yes'");
if (def->trustGuestRxFilters)
virBufferAsprintf(buf, " trustGuestRxFilters='%s'",
virTristateBoolTypeToString(def->trustGuestRxFilters));
@@ -23633,6 +23644,8 @@ virDomainHostdevDefFormat(virBufferPtr buf,
if (def->mode == VIR_DOMAIN_HOSTDEV_MODE_SUBSYS) {
virBufferAsprintf(buf, " managed='%s'",
def->managed ? "yes" : "no");
+ if (def->nostrictreset)
+ virBufferAddLit(buf, " nostrictreset='yes'");
if (def->source.subsys.type == VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_SCSI &&
scsisrc->sgio)
diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h
index 659caa1..86cd2d9 100644
--- a/src/conf/domain_conf.h
+++ b/src/conf/domain_conf.h
@@ -446,6 +446,7 @@ struct _virDomainHostdevDef {
bool missing;
bool readonly;
bool shareable;
+ bool nostrictreset;
union {
virDomainHostdevSubsys subsys;
virDomainHostdevCaps caps;
diff --git a/src/util/virhostdev.c b/src/util/virhostdev.c
index 579563c..27028d0 100644
--- a/src/util/virhostdev.c
+++ b/src/util/virhostdev.c
@@ -268,6 +268,8 @@ virHostdevGetPCIHostDeviceList(virDomainHostdevDefPtr *hostdevs, int nhostdevs)
virPCIDeviceSetStubDriver(pci, VIR_PCI_STUB_DRIVER_XEN);
else
virPCIDeviceSetStubDriver(pci, VIR_PCI_STUB_DRIVER_KVM);
+
+ virPCIDeviceSetStrictReset(pci, !hostdev->nostrictreset);
}
return pcidevs;
diff --git a/src/util/virpci.c b/src/util/virpci.c
index 1b3be92..ee9f5b1 100644
--- a/src/util/virpci.c
+++ b/src/util/virpci.c
@@ -84,7 +84,7 @@ struct _virPCIDevice {
bool has_flr;
bool has_pm_reset;
bool managed;
-
+ bool strictreset;
virPCIStubDriver stubDriver;
/* used by reattach function */
@@ -1000,6 +1000,9 @@ virPCIDeviceReset(virPCIDevicePtr dev,
dev->name,
err ? err->message :
_("no FLR, PM reset or bus reset available"));
+ if (!dev->strictreset)
+ /* do not fail */
+ ret = 0;
}
cleanup:
@@ -1768,6 +1771,7 @@ virPCIDeviceNew(unsigned int domain,
dev->address.bus = bus;
dev->address.slot = slot;
dev->address.function = function;
+ dev->strictreset = true;
if (snprintf(dev->name, sizeof(dev->name), "%.4x:%.2x:%.2x.%.1x",
domain, bus, slot, function) >= sizeof(dev->name)) {
@@ -1902,6 +1906,18 @@ virPCIDeviceGetManaged(virPCIDevicePtr dev)
}
void
+virPCIDeviceSetStrictReset(virPCIDevicePtr dev, bool strictreset)
+{
+ dev->strictreset = strictreset;
+}
+
+unsigned int
+virPCIDeviceGetStrictReset(virPCIDevicePtr dev)
+{
+ return dev->strictreset;
+}
+
+void
virPCIDeviceSetStubDriver(virPCIDevicePtr dev, virPCIStubDriver driver)
{
dev->stubDriver = driver;
diff --git a/src/util/virpci.h b/src/util/virpci.h
index 570684e..62bc06c 100644
--- a/src/util/virpci.h
+++ b/src/util/virpci.h
@@ -116,6 +116,8 @@ bool virPCIDeviceGetManaged(virPCIDevice *dev);
void virPCIDeviceSetStubDriver(virPCIDevicePtr dev,
virPCIStubDriver driver);
virPCIStubDriver virPCIDeviceGetStubDriver(virPCIDevicePtr dev);
+void virPCIDeviceSetStrictReset(virPCIDevice *dev, bool strictreset);
+unsigned int virPCIDeviceGetStrictReset(virPCIDevicePtr dev);
virPCIDeviceAddressPtr virPCIDeviceGetAddress(virPCIDevicePtr dev);
int virPCIDeviceSetUsedBy(virPCIDevice *dev,
const char *drv_name,
--
2.7.4