]> xenbits.xensource.com Git - libvirt.git/commitdiff
conf: Add rom.enabled attribute for PCI devices
authorAndrea Bolognani <abologna@redhat.com>
Thu, 19 Apr 2018 15:55:41 +0000 (17:55 +0200)
committerAndrea Bolognani <abologna@redhat.com>
Mon, 23 Apr 2018 13:20:54 +0000 (15:20 +0200)
The attribute can be used to disable ROM loading completely
for a device.

This might be needed because, even when the guest is configured
such that the PCI ROM will not be loaded in the PCI BAR, some
hypervisors (eg. QEMU) might still make it available to the
guest in a form (eg. fw_cfg) that some firmwares (eg. SeaBIOS)
will consume, thus not achieving the desired result.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
docs/formatdomain.html.in
docs/schemas/domaincommon.rng
src/conf/device_conf.h
src/conf/domain_conf.c

index ada0df227f57c60b9dd804c643949c52b7cd3bde..8e864f7113911b2d525d1b00491ec3fced063354 100644 (file)
         virtual function of an sr-iov capable ethernet device (which
         has no boot ROMs for the VFs).
         <span class="since">Since 0.9.10 (QEMU and KVM only)</span>.
+        The optional <code>enabled</code> attribute can be set to
+        <code>no</code> to disable PCI ROM loading completely for the device;
+        if PCI ROM loading is disabled through this attribute, attempts to
+        tweak the loading process further using the <code>bar</code> or
+        <code>file</code> attributes will be rejected.
+        <span class="since">Since 4.3.0 (QEMU and KVM only)</span>.
       </dd>
       <dt><code>address</code></dt>
       <dd>The <code>address</code> element for USB devices has a
index 4cab55f05dd63b37a93bcdffc4159bb2c8122e75..3569b92127376fb8d055421b0ef8da2f7199c614 100644 (file)
 
   <define name="rom">
     <element name="rom">
+      <optional>
+        <attribute name="enabled">
+          <ref name="virYesNo"/>
+        </attribute>
+      </optional>
       <optional>
         <attribute name="bar">
           <ref name="virOnOff"/>
index f87d6f1fc6ee8db0370d5cbadf09e5c5b0133faa..a31ce9c376a266efbd20f976dbc11e02f6c76197 100644 (file)
@@ -153,6 +153,7 @@ struct _virDomainDeviceInfo {
     } master;
     /* rombar and romfile are only used for pci hostdev and network
      * devices. */
+    int romenabled; /* enum virTristateBool */
     int rombar;         /* enum virTristateSwitch */
     char *romfile;
     /* bootIndex is only used for disk, network interface, hostdev
index 65b429460a30ca8e7d1edc551c1417d73561a7fe..9f7dce1bed0f3591583b057deb643c7df9c0f4c1 100644 (file)
@@ -6095,9 +6095,17 @@ virDomainDeviceInfoFormat(virBufferPtr buf,
     }
 
     if ((flags & VIR_DOMAIN_DEF_FORMAT_ALLOW_ROM) &&
-        (info->rombar != VIR_TRISTATE_SWITCH_ABSENT || info->romfile)) {
+        (info->romenabled != VIR_TRISTATE_BOOL_ABSENT ||
+         info->rombar != VIR_TRISTATE_SWITCH_ABSENT ||
+         info->romfile)) {
 
         virBufferAddLit(buf, "<rom");
+        if (info->romenabled != VIR_TRISTATE_BOOL_ABSENT) {
+            const char *romenabled = virTristateBoolTypeToString(info->romenabled);
+
+            if (romenabled)
+                virBufferAsprintf(buf, " enabled='%s'", romenabled);
+        }
         if (info->rombar != VIR_TRISTATE_SWITCH_ABSENT) {
             const char *rombar = virTristateSwitchTypeToString(info->rombar);
 
@@ -6738,6 +6746,7 @@ virDomainDeviceInfoParseXML(virDomainXMLOptionPtr xmlopt ATTRIBUTE_UNUSED,
     xmlNodePtr boot = NULL;
     xmlNodePtr rom = NULL;
     char *type = NULL;
+    char *romenabled = NULL;
     char *rombar = NULL;
     char *aliasStr = NULL;
     int ret = -1;
@@ -6791,6 +6800,12 @@ virDomainDeviceInfoParseXML(virDomainXMLOptionPtr xmlopt ATTRIBUTE_UNUSED,
     }
 
     if (rom) {
+        if ((romenabled = virXMLPropString(rom, "enabled")) &&
+            ((info->romenabled = virTristateBoolTypeFromString(romenabled)) <= 0)) {
+            virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
+                           _("unknown rom enabled value '%s'"), romenabled);
+            goto cleanup;
+        }
         if ((rombar = virXMLPropString(rom, "bar")) &&
             ((info->rombar = virTristateSwitchTypeFromString(rombar)) <= 0)) {
             virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
@@ -6798,6 +6813,13 @@ virDomainDeviceInfoParseXML(virDomainXMLOptionPtr xmlopt ATTRIBUTE_UNUSED,
             goto cleanup;
         }
         info->romfile = virXMLPropString(rom, "file");
+
+        if (info->romenabled == VIR_TRISTATE_BOOL_NO &&
+            (info->rombar != VIR_TRISTATE_SWITCH_ABSENT || info->romfile)) {
+            virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
+                           _("ROM tuning is not supported when ROM is disabled"));
+            goto cleanup;
+        }
     }
 
     if (address &&
@@ -6811,6 +6833,7 @@ virDomainDeviceInfoParseXML(virDomainXMLOptionPtr xmlopt ATTRIBUTE_UNUSED,
         virDomainDeviceInfoClear(info);
     VIR_FREE(type);
     VIR_FREE(rombar);
+    VIR_FREE(romenabled);
     VIR_FREE(aliasStr);
     return ret;
 }