[PATCHv2 2/5] conf: introduce shareable in shmem device element

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

 



Signed-off-by: Luyao Huang <lhuang@xxxxxxxxxx>
---
 docs/formatdomain.html.in                          |  5 +++
 docs/schemas/domaincommon.rng                      |  5 +++
 src/conf/domain_conf.c                             |  6 +++
 src/conf/domain_conf.h                             |  1 +
 .../qemuxml2argv-shmem-shareable.xml               | 43 ++++++++++++++++++++++
 tests/qemuxml2xmltest.c                            |  1 +
 6 files changed, 61 insertions(+)
 create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-shmem-shareable.xml

diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in
index f2ac5fb..def76fe 100644
--- a/docs/formatdomain.html.in
+++ b/docs/formatdomain.html.in
@@ -6195,6 +6195,11 @@ qemu-kvm -net nic,model=? /dev/null
       vectors. The <code>ioeventd</code> attribute enables/disables (values
       "on"/"off", respectively) ioeventfd.
     </dd>
+    <dt><code>shareable</code></dt>
+    <dd>
+      If present, this indicates the device is expected to be shared
+      between domains (assuming the hypervisor and OS support this).
+    </dd>
     <dt><code>seclabel</code></dt>
     <dd>
       The element may contain an optional <code>seclabel</code> to override the
diff --git a/docs/schemas/domaincommon.rng b/docs/schemas/domaincommon.rng
index f13f566..350f1b3 100644
--- a/docs/schemas/domaincommon.rng
+++ b/docs/schemas/domaincommon.rng
@@ -3371,6 +3371,11 @@
             </optional>
           </element>
         </optional>
+        <optional>
+          <element name="shareable">
+            <empty/>
+          </element>
+        </optional>
         <zeroOrMore>
           <ref name='devSeclabel'/>
         </zeroOrMore>
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index ece9f2d..34cd93c 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -11585,6 +11585,9 @@ virDomainShmemDefParseXML(xmlNodePtr node,
         goto cleanup;
     }
 
+    if (virXPathBoolean("boolean(./shareable)", ctxt))
+        def->shareable = true;
+
     if (virDomainDeviceInfoParseXML(node, NULL, &def->info, flags) < 0)
         goto cleanup;
 
@@ -20634,6 +20637,9 @@ virDomainShmemDefFormat(virBufferPtr buf,
         virBufferAddLit(&childrenBuf, "/>\n");
     }
 
+    if (def->shareable)
+        virBufferAddLit(&childrenBuf, "<shareable/>\n");
+
     for (n = 0; n < def->nseclabels; n++)
         virSecurityDeviceLabelDefFormat(&childrenBuf, def->seclabels[n], flags);
 
diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h
index d53c36f..06c304d 100644
--- a/src/conf/domain_conf.h
+++ b/src/conf/domain_conf.h
@@ -1642,6 +1642,7 @@ struct _virDomainShmemDef {
         unsigned vectors;
         virTristateSwitch ioeventfd;
     } msi;
+    bool shareable;
     size_t nseclabels;
     virSecurityDeviceLabelDefPtr *seclabels;
     virDomainDeviceInfo info;
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-shmem-shareable.xml b/tests/qemuxml2argvdata/qemuxml2argv-shmem-shareable.xml
new file mode 100644
index 0000000..c94102c
--- /dev/null
+++ b/tests/qemuxml2argvdata/qemuxml2argv-shmem-shareable.xml
@@ -0,0 +1,43 @@
+<domain type='qemu'>
+  <name>QEMUGuest1</name>
+  <uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid>
+  <memory unit='KiB'>219136</memory>
+  <currentMemory unit='KiB'>219136</currentMemory>
+  <vcpu placement='static'>1</vcpu>
+  <os>
+    <type arch='i686' machine='pc'>hvm</type>
+    <boot dev='hd'/>
+  </os>
+  <clock offset='utc'/>
+  <on_poweroff>destroy</on_poweroff>
+  <on_reboot>restart</on_reboot>
+  <on_crash>destroy</on_crash>
+  <devices>
+    <emulator>/usr/bin/qemu</emulator>
+    <controller type='usb' index='0'/>
+    <controller type='pci' index='0' model='pci-root'/>
+    <memballoon model='none'/>
+    <shmem name='shmem0'>
+      <shareable/>
+    </shmem>
+    <shmem name='shmem1'>
+      <size unit='M'>128</size>
+      <shareable/>
+    </shmem>
+    <shmem name='shmem2'>
+      <size unit='M'>256</size>
+      <shareable/>
+      <address type='pci' domain='0x0000' bus='0x00' slot='0x04' function='0x0'/>
+    </shmem>
+    <shmem name='shmem3'>
+      <size unit='M'>512</size>
+      <server/>
+      <shareable/>
+    </shmem>
+    <shmem name='shmem4'>
+      <size unit='M'>1024</size>
+      <server path='/tmp/shmem4-sock'/>
+      <shareable/>
+    </shmem>
+  </devices>
+</domain>
diff --git a/tests/qemuxml2xmltest.c b/tests/qemuxml2xmltest.c
index 7361db5..76df46a 100644
--- a/tests/qemuxml2xmltest.c
+++ b/tests/qemuxml2xmltest.c
@@ -623,6 +623,7 @@ mymain(void)
 
     DO_TEST("shmem");
     DO_TEST("shmem-seclabel");
+    DO_TEST("shmem-shareable");
 
     DO_TEST("smbios");
     DO_TEST("smbios-multiple-type2");
-- 
1.8.3.1

--
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]