[PATCH v2] qemu: Advertise <drivediscard/> in capabilities if 'discard' is supported.

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

 



The capabilities will have a <drivediscard/> feature if you are
allowed to use the qemu attribute:

  <driver name='qemu' ... discard='unmap|ignore' />

The new capabilities XML looks like this:

<capabilities>
  ...
  <guest>
    <os_type>hvm</os_type>
    ...
    <features>
      <drivediscard/>
    </features>
  </guest>
</capabilities>
---
 src/conf/capabilities.c      | 3 ++-
 src/qemu/qemu_capabilities.c | 4 ++++
 2 files changed, 6 insertions(+), 1 deletion(-)

diff --git a/src/conf/capabilities.c b/src/conf/capabilities.c
index c1c4ab8..ff5912a 100644
--- a/src/conf/capabilities.c
+++ b/src/conf/capabilities.c
@@ -947,7 +947,8 @@ virCapabilitiesFormatXML(virCapsPtr caps)
                     STREQ(caps->guests[i]->features[j]->name, "nonpae") ||
                     STREQ(caps->guests[i]->features[j]->name, "ia64_be") ||
                     STREQ(caps->guests[i]->features[j]->name, "cpuselection") ||
-                    STREQ(caps->guests[i]->features[j]->name, "deviceboot")) {
+                    STREQ(caps->guests[i]->features[j]->name, "deviceboot") ||
+                    STREQ(caps->guests[i]->features[j]->name, "drivediscard")) {
                     virBufferAsprintf(&xml, "      <%s/>\n",
                                       caps->guests[i]->features[j]->name);
                 } else {
diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c
index cae25e0..b755fb2 100644
--- a/src/qemu/qemu_capabilities.c
+++ b/src/qemu/qemu_capabilities.c
@@ -778,6 +778,10 @@ virQEMUCapsInitGuest(virCapsPtr caps,
         !virCapabilitiesAddGuestFeature(guest, "deviceboot", 1, 0))
         goto error;
 
+    if (virQEMUCapsGet(qemubinCaps, QEMU_CAPS_DRIVE_DISCARD) &&
+        !virCapabilitiesAddGuestFeature(guest, "drivediscard", 0, 0))
+        goto error;
+
     if (virCapabilitiesAddGuestDomain(guest,
                                       "qemu",
                                       NULL,
-- 
1.8.5.3

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list




[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]