-
-
Notifications
You must be signed in to change notification settings - Fork 26
/
0005-Add-nostrictreset-attribute-to-PCI-host-devices.patch
197 lines (181 loc) · 7.46 KB
/
0005-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
From 38b6bf3ec3d7df7c1dcfedf8b648cb72f7c6859c Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Marek=20Marczykowski-G=C3=B3recki?=
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
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 <[email protected]>
---
docs/formatdomain.rst | 2 ++
src/conf/domain_conf.c | 12 ++++++++++++
src/conf/domain_conf.h | 1 +
src/conf/schemas/domaincommon.rng | 5 +++++
src/hypervisor/virhostdev.c | 2 ++
src/util/virpci.c | 18 ++++++++++++++++++
src/util/virpci.h | 2 ++
7 files changed, 42 insertions(+)
diff --git a/docs/formatdomain.rst b/docs/formatdomain.rst
index 1629b84407..582571e4e8 100644
--- a/docs/formatdomain.rst
+++ b/docs/formatdomain.rst
@@ -4424,6 +4424,8 @@ or:
to the guest. This framebuffer allows the vgpu to be used as a boot display
before the gpu driver is loaded within the guest. ``ramfb`` requires the
``display`` attribute to be set to ``on``.
+ Additionally when ``strictreset`` is ``no``, device will be assigned to
+ the domain, even when reset fails. The default is ``yes``.
``scsi``
For SCSI devices, user is responsible to make sure the device is not used
by host. If supported by the hypervisor and OS, the optional ``sgio`` (
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index c41bb3492e..a5459c9ae9 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -6226,6 +6226,7 @@ virDomainHostdevDefParseXMLSubsys(xmlNodePtr node,
virDomainHostdevSubsysSCSIVHost *scsihostsrc = &def->source.subsys.u.scsi_host;
virDomainHostdevSubsysMediatedDev *mdevsrc = &def->source.subsys.u.mdev;
virTristateBool managed;
+ g_autofree char *nostrictreset = NULL;
g_autofree char *model = NULL;
int rv;
@@ -6238,6 +6239,11 @@ virDomainHostdevDefParseXMLSubsys(xmlNodePtr node,
VIR_XML_PROP_NONE, &managed));
virTristateBoolToBool(managed, &def->managed);
+ if ((nostrictreset = virXMLPropString(node, "nostrictreset")) != NULL) {
+ if (STREQ(nostrictreset, "yes"))
+ def->nostrictreset = true;
+ }
+
model = virXMLPropString(node, "model");
/* @type is passed in from the caller rather than read from the
@@ -23906,6 +23912,8 @@ virDomainActualNetDefFormat(virBuffer *buf,
virDomainHostdevDef *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'",
@@ -24200,6 +24208,8 @@ virDomainNetDefFormat(virBuffer *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));
@@ -26409,6 +26419,8 @@ virDomainHostdevDefFormat(virBuffer *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 d149eae979..f0db176cd1 100644
--- a/src/conf/domain_conf.h
+++ b/src/conf/domain_conf.h
@@ -368,6 +368,7 @@ struct _virDomainHostdevDef {
bool readonly;
bool shareable;
virTristateBool writeFiltering;
+ bool nostrictreset;
union {
virDomainHostdevSubsys subsys;
virDomainHostdevCaps caps;
diff --git a/src/conf/schemas/domaincommon.rng b/src/conf/schemas/domaincommon.rng
index 69cdb2e8c8..583b0421dc 100644
--- a/src/conf/schemas/domaincommon.rng
+++ b/src/conf/schemas/domaincommon.rng
@@ -3618,6 +3618,11 @@
<ref name="virYesNo"/>
</attribute>
</optional>
+ <optional>
+ <attribute name="nostrictreset">
+ <ref name="virYesNo"/>
+ </attribute>
+ </optional>
<interleave>
<element name="source">
<optional>
diff --git a/src/hypervisor/virhostdev.c b/src/hypervisor/virhostdev.c
index 185ec2ca50..03e493ea57 100644
--- a/src/hypervisor/virhostdev.c
+++ b/src/hypervisor/virhostdev.c
@@ -255,6 +255,8 @@ virHostdevGetPCIHostDevice(const virDomainHostdevDef *hostdev,
return -1;
}
+ virPCIDeviceSetStrictReset(actual, !hostdev->nostrictreset);
+
*pci = g_steal_pointer(&actual);
return 0;
}
diff --git a/src/util/virpci.c b/src/util/virpci.c
index 289c0b330b..38163699f1 100644
--- a/src/util/virpci.c
+++ b/src/util/virpci.c
@@ -91,6 +91,7 @@ struct _virPCIDevice {
/**/
bool managed;
+ bool strictreset;
virPCIStubDriver stubDriverType;
char *stubDriverName; /* if blank, use default for type */
@@ -1157,6 +1158,9 @@ virPCIDeviceReset(virPCIDevice *dev,
dev->name,
err ? err->message :
_("no FLR, PM reset or bus reset available"));
+ if (!dev->strictreset)
+ /* do not fail */
+ ret = 0;
}
cleanup:
@@ -1873,6 +1877,8 @@ virPCIDeviceNew(const virPCIDeviceAddress *address)
virPCIDeviceAddressCopy(&dev->address, address);
+ dev->strictreset = true;
+
dev->name = virPCIDeviceAddressAsString(&dev->address);
dev->path = g_strdup_printf(PCI_SYSFS "devices/%s/config", dev->name);
@@ -1987,6 +1993,18 @@ virPCIDeviceGetManaged(virPCIDevice *dev)
return dev->managed;
}
+void
+virPCIDeviceSetStrictReset(virPCIDevice *dev, bool strictreset)
+{
+ dev->strictreset = strictreset;
+}
+
+unsigned int
+virPCIDeviceGetStrictReset(virPCIDevice *dev)
+{
+ return dev->strictreset;
+}
+
void
virPCIDeviceSetStubDriverType(virPCIDevice *dev, virPCIStubDriver driverType)
{
diff --git a/src/util/virpci.h b/src/util/virpci.h
index ba5e0ae6f1..c6f5a784f3 100644
--- a/src/util/virpci.h
+++ b/src/util/virpci.h
@@ -135,6 +135,8 @@ virPCIStubDriver virPCIDeviceGetStubDriverType(virPCIDevice *dev);
void virPCIDeviceSetStubDriverName(virPCIDevice *dev,
const char *driverName);
const char *virPCIDeviceGetStubDriverName(virPCIDevice *dev);
+void virPCIDeviceSetStrictReset(virPCIDevice *dev, bool strictreset);
+unsigned int virPCIDeviceGetStrictReset(virPCIDevice *dev);
virPCIDeviceAddress *virPCIDeviceGetAddress(virPCIDevice *dev);
int virPCIDeviceSetUsedBy(virPCIDevice *dev,
const char *drv_name,
--
2.45.2