render / rpms / libvirt

Forked from rpms/libvirt a year ago
Clone
6d3351
From 51a842ccdf1c02ec00ba96217658b0db31a6addb Mon Sep 17 00:00:00 2001
6d3351
Message-Id: <51a842ccdf1c02ec00ba96217658b0db31a6addb@dist-git>
6d3351
From: =?UTF-8?q?J=C3=A1n=20Tomko?= <jtomko@redhat.com>
6d3351
Date: Fri, 9 Jun 2017 12:49:02 +0200
6d3351
Subject: [PATCH] Add virtio-related options to disks
6d3351
MIME-Version: 1.0
6d3351
Content-Type: text/plain; charset=UTF-8
6d3351
Content-Transfer-Encoding: 8bit
6d3351
6d3351
https://bugzilla.redhat.com/show_bug.cgi?id=1283251
6d3351
6d3351
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
6d3351
(cherry picked from commit 1bc2cb3b3205dca7174147ac970e2b82c8af69da)
6d3351
Signed-off-by: Ján Tomko <jtomko@redhat.com>
6d3351
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
6d3351
---
6d3351
 docs/formatdomain.html.in                              |  5 +++++
6d3351
 docs/schemas/domaincommon.rng                          |  1 +
6d3351
 src/conf/domain_conf.c                                 | 15 +++++++++++++++
6d3351
 src/conf/domain_conf.h                                 |  1 +
6d3351
 tests/qemuxml2argvdata/qemuxml2argv-virtio-options.xml |  2 +-
6d3351
 5 files changed, 23 insertions(+), 1 deletion(-)
6d3351
6d3351
diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in
6d3351
index 2556f383fc..bb7a85a1a1 100644
6d3351
--- a/docs/formatdomain.html.in
6d3351
+++ b/docs/formatdomain.html.in
6d3351
@@ -3008,6 +3008,11 @@
6d3351
             bus and "pci" or "ccw" address types.
6d3351
             Since 1.2.8 (QEMU 2.1)
6d3351
           
6d3351
+          
  • 6d3351
    +          For virtio disks,
    6d3351
    +          Virtio-specific options can also be
    6d3351
    +          set. (Since 3.5.0)
    6d3351
    +          
    6d3351
             
    6d3351
           
    6d3351
           
    backenddomain
    6d3351
    diff --git a/docs/schemas/domaincommon.rng b/docs/schemas/domaincommon.rng
    6d3351
    index f571af6706..f838dc55fd 100644
    6d3351
    --- a/docs/schemas/domaincommon.rng
    6d3351
    +++ b/docs/schemas/domaincommon.rng
    6d3351
    @@ -1716,6 +1716,7 @@
    6d3351
           <optional>
    6d3351
             <ref name="detect_zeroes"/>
    6d3351
           </optional>
    6d3351
    +      <ref name="virtioOptions"/>
    6d3351
           <empty/>
    6d3351
         </element>
    6d3351
       </define>
    6d3351
    diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
    6d3351
    index 4768d02029..a4b4f70855 100644
    6d3351
    --- a/src/conf/domain_conf.c
    6d3351
    +++ b/src/conf/domain_conf.c
    6d3351
    @@ -1745,6 +1745,7 @@ virDomainDiskDefFree(virDomainDiskDefPtr def)
    6d3351
         VIR_FREE(def->product);
    6d3351
         VIR_FREE(def->domain_name);
    6d3351
         VIR_FREE(def->blkdeviotune.group_name);
    6d3351
    +    VIR_FREE(def->virtio);
    6d3351
         virDomainDeviceInfoClear(&def->info);
    6d3351
         virObjectUnref(def->privateData);
    6d3351
     
    6d3351
    @@ -4440,6 +4441,10 @@ virDomainDeviceDefPostParseInternal(virDomainDeviceDefPtr dev,
    6d3351
                 }
    6d3351
             }
    6d3351
     
    6d3351
    +        if (disk->bus != VIR_DOMAIN_DISK_BUS_VIRTIO &&
    6d3351
    +            virDomainCheckVirtioOptions(disk->virtio) < 0)
    6d3351
    +            return -1;
    6d3351
    +
    6d3351
             if (disk->info.type == VIR_DOMAIN_DEVICE_ADDRESS_TYPE_NONE &&
    6d3351
                 virDomainDiskDefAssignAddress(xmlopt, disk, def) < 0)
    6d3351
                 return -1;
    6d3351
    @@ -8420,6 +8425,9 @@ virDomainDiskDefParseXML(virDomainXMLOptionPtr xmlopt,
    6d3351
             }
    6d3351
         }
    6d3351
     
    6d3351
    +    if (virDomainVirtioOptionsParseXML(ctxt, &def->virtio) < 0)
    6d3351
    +        goto error;
    6d3351
    +
    6d3351
         /* Disk volume types will have authentication information handled in
    6d3351
          * virStorageTranslateDiskSourcePool
    6d3351
          */
    6d3351
    @@ -19146,6 +19154,10 @@ virDomainDiskDefCheckABIStability(virDomainDiskDefPtr src,
    6d3351
             return false;
    6d3351
         }
    6d3351
     
    6d3351
    +    if (src->virtio && dst->virtio &&
    6d3351
    +        !virDomainVirtioOptionsCheckABIStability(src->virtio, dst->virtio))
    6d3351
    +        return false;
    6d3351
    +
    6d3351
         if (!virDomainDeviceInfoCheckABIStability(&src->info, &dst->info))
    6d3351
             return false;
    6d3351
     
    6d3351
    @@ -21307,6 +21319,9 @@ virDomainDiskDefFormat(virBufferPtr buf,
    6d3351
             virBufferAsprintf(&driverBuf, " iothread='%u'", def->iothread);
    6d3351
         if (def->detect_zeroes)
    6d3351
             virBufferAsprintf(&driverBuf, " detect_zeroes='%s'", detect_zeroes);
    6d3351
    +
    6d3351
    +    virDomainVirtioOptionsFormat(&driverBuf, def->virtio);
    6d3351
    +
    6d3351
         if (virBufferUse(&driverBuf)) {
    6d3351
             virBufferAddLit(buf, "
    6d3351
             virBufferAddBuffer(buf, &driverBuf);
    6d3351
    diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h
    6d3351
    index f1f9208b91..eac1919175 100644
    6d3351
    --- a/src/conf/domain_conf.h
    6d3351
    +++ b/src/conf/domain_conf.h
    6d3351
    @@ -668,6 +668,7 @@ struct _virDomainDiskDef {
    6d3351
         unsigned int iothread; /* unused = 0, > 0 specific thread # */
    6d3351
         int detect_zeroes; /* enum virDomainDiskDetectZeroes */
    6d3351
         char *domain_name; /* backend domain name */
    6d3351
    +    virDomainVirtioOptionsPtr virtio;
    6d3351
     };
    6d3351
     
    6d3351
     
    6d3351
    diff --git a/tests/qemuxml2argvdata/qemuxml2argv-virtio-options.xml b/tests/qemuxml2argvdata/qemuxml2argv-virtio-options.xml
    6d3351
    index b16a9847fe..6dd82de648 100644
    6d3351
    --- a/tests/qemuxml2argvdata/qemuxml2argv-virtio-options.xml
    6d3351
    +++ b/tests/qemuxml2argvdata/qemuxml2argv-virtio-options.xml
    6d3351
    @@ -15,7 +15,7 @@
    6d3351
       <devices>
    6d3351
         <emulator>/usr/bin/qemu-system-x86_64</emulator>
    6d3351
         <disk type='file' device='disk'>
    6d3351
    -      <driver name='qemu' type='raw'/>
    6d3351
    +      <driver name='qemu' type='raw' iommu='on' ats='on'/>
    6d3351
           <source file='/var/lib/libvirt/images/img1'/>
    6d3351
           <target dev='vda' bus='virtio'/>
    6d3351
           <address type='pci' domain='0x0000' bus='0x00' slot='0x0a' function='0x0'/>
    6d3351
    -- 
    6d3351
    2.13.1
    6d3351