[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

[libvirt] [PATCH 2/3] New 'permissive' attribute for hostdev



When it is set to 'yes', some check whether a device is safe to be
assigned to a guest will be weakened.

Signed-off-by: Jiri Denemark <jdenemar redhat com>
---
 docs/schemas/domain.rng |    8 ++++++++
 src/conf/domain_conf.c  |   14 ++++++++++++--
 src/conf/domain_conf.h  |    1 +
 3 files changed, 21 insertions(+), 2 deletions(-)

diff --git a/docs/schemas/domain.rng b/docs/schemas/domain.rng
index 566b117..02116c3 100644
--- a/docs/schemas/domain.rng
+++ b/docs/schemas/domain.rng
@@ -1129,6 +1129,14 @@
           </choice>
         </attribute>
       </optional>
+      <optional>
+        <attribute name="permissive">
+          <choice>
+            <value>yes</value>
+            <value>no</value>
+          </choice>
+        </attribute>
+      </optional>
       <group>
         <element name="source">
           <choice>
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 0b4fe8b..642744d 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -2422,6 +2422,7 @@ virDomainHostdevDefParseXML(virConnectPtr conn,
     xmlNodePtr cur;
     virDomainHostdevDefPtr def;
     char *mode, *type = NULL, *managed = NULL;
+    char *permissive = NULL;
 
     if (VIR_ALLOC(def) < 0) {
         virReportOOMError(conn);
@@ -2460,6 +2461,13 @@ virDomainHostdevDefParseXML(virConnectPtr conn,
         VIR_FREE(managed);
     }
 
+    permissive = virXMLPropString(node, "permissive");
+    if (permissive != NULL) {
+        if (STREQ(permissive, "yes"))
+            def->permissive = 1;
+        VIR_FREE(permissive);
+    }
+
     cur = node->children;
     while (cur != NULL) {
         if (cur->type == XML_ELEMENT_NODE) {
@@ -4497,8 +4505,10 @@ virDomainHostdevDefFormat(virConnectPtr conn,
         return -1;
     }
 
-    virBufferVSprintf(buf, "    <hostdev mode='%s' type='%s' managed='%s'>\n",
-                      mode, type, def->managed ? "yes" : "no");
+    virBufferVSprintf(buf, "    <hostdev mode='%s' type='%s' managed='%s' permissive='%s'>\n",
+                      mode, type,
+                      def->managed ? "yes" : "no",
+                      def->permissive ? "yes" : "no");
     virBufferAddLit(buf, "      <source>\n");
 
     if (def->source.subsys.type == VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_USB) {
diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h
index a807e9d..e8607b5 100644
--- a/src/conf/domain_conf.h
+++ b/src/conf/domain_conf.h
@@ -431,6 +431,7 @@ typedef virDomainHostdevDef *virDomainHostdevDefPtr;
 struct _virDomainHostdevDef {
     int mode; /* enum virDomainHostdevMode */
     unsigned int managed : 1;
+    unsigned int permissive : 1;
     union {
         struct {
             int type; /* enum virDomainHostdevBusType */
-- 
1.6.6.rc4


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]